modal: refactor modal to look like popups
This commit is contained in:
parent
cca058a862
commit
36c5aebdf4
4 changed files with 80 additions and 82 deletions
|
|
@ -26,7 +26,7 @@ var callbacks = module.exports = {
|
|||
var lobby = $(`
|
||||
<div class="main">
|
||||
<div class="header">
|
||||
${PACKAGE.productName}
|
||||
${window.PACKAGE.productName}
|
||||
</div>
|
||||
<div class="list"></div>
|
||||
<div class="footer"></div>
|
||||
|
|
@ -46,12 +46,12 @@ var callbacks = module.exports = {
|
|||
path = path.substr(0,Math.floor((path.length)/2)-(length-max)/2) + '...' + path.substr(Math.ceil((path.length)/2)+(length-max)/2, path.length)
|
||||
}
|
||||
|
||||
if (!READ_ONLY) {
|
||||
if (!window.READ_ONLY) {
|
||||
}
|
||||
list.append(`
|
||||
<a class="btn load" data-session="${data[i]}">
|
||||
${file} <em style="opacity:0.45">(${path})</em>
|
||||
${READ_ONLY? '' : '<span>'+icon('remove')+'</span>'}
|
||||
${window.READ_ONLY? '' : '<span>'+icon('remove')+'</span>'}
|
||||
</a>
|
||||
`)
|
||||
|
||||
|
|
@ -132,7 +132,7 @@ var callbacks = module.exports = {
|
|||
document.body.appendChild(style)
|
||||
window.GRIDWIDTH = getComputedStyle(document.documentElement).getPropertyValue("--grid-width")
|
||||
if (css.indexOf('--pixel-scale') != -1) {
|
||||
PXSCALE_RESET()
|
||||
window.PXSCALE_RESET()
|
||||
}
|
||||
},
|
||||
|
||||
|
|
@ -144,11 +144,11 @@ var callbacks = module.exports = {
|
|||
setTimeout(()=>{
|
||||
$('canvas').trigger('resize',[0,0,true])
|
||||
},100)
|
||||
GRIDWIDTH = getComputedStyle(document.documentElement).getPropertyValue("--grid-width")
|
||||
PXSCALE_RESET()
|
||||
window.GRIDWIDTH = getComputedStyle(document.documentElement).getPropertyValue("--grid-width")
|
||||
window.PXSCALE_RESET()
|
||||
},
|
||||
readOnly: function(){
|
||||
READ_ONLY = true
|
||||
window.READ_ONLY = true
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
var Panel = require('./panel'),
|
||||
_widgets_base = require('../common/_widgets_base')
|
||||
_widgets_base = require('../common/_widgets_base'),
|
||||
{icon} = require('../../utils')
|
||||
|
||||
|
||||
module.exports = class Modal extends Panel {
|
||||
module.exports = class Modal extends _widgets_base {
|
||||
|
||||
static defaults() {
|
||||
|
||||
|
|
@ -20,6 +21,11 @@ module.exports = class Modal extends Panel {
|
|||
color:'auto',
|
||||
css:'',
|
||||
|
||||
_layout:'popup',
|
||||
|
||||
popupWidth:'100%',
|
||||
popupHeight:'100%',
|
||||
|
||||
_layout:'layout',
|
||||
|
||||
layout:'',
|
||||
|
|
@ -39,21 +45,41 @@ module.exports = class Modal extends Panel {
|
|||
|
||||
constructor(options) {
|
||||
|
||||
super(options)
|
||||
var html = `
|
||||
<div class="popup">
|
||||
<div class="popup-wrapper">
|
||||
<div class="popup-title closable"><span class="popup-label"></span><span class="closer">${icon('remove')}</span></div>
|
||||
<div class="popup-content"></div>
|
||||
</div>
|
||||
</div>`
|
||||
|
||||
this.widget.removeClass('noscroll')
|
||||
super({...options, html:html})
|
||||
|
||||
this.panel = new Panel({props:{...Panel.defaults(), ...options.props}, container: options.container, parent:options.parent})
|
||||
this.panel.widget.appendTo(this.widget.find('.popup-content'))
|
||||
|
||||
this.widget.hide()
|
||||
|
||||
// convert dimensions / coordinates to rem
|
||||
var width = parseFloat(this.getProp('popupWidth'))==this.getProp('popupWidth')?parseFloat(this.getProp('popupWidth'))+'rem' : this.getProp('popupWidth'),
|
||||
height = parseFloat(this.getProp('popupHeight'))==this.getProp('popupHeight')?parseFloat(this.getProp('popupHeight'))+'rem' : this.getProp('popupHeight')
|
||||
|
||||
this.widget[0].style.setProperty('--width', width)
|
||||
this.widget[0].style.setProperty('--height', height)
|
||||
|
||||
this.widget.find('.closer').on('fake-click',(e)=>{
|
||||
this.setValue(false)
|
||||
})
|
||||
|
||||
this.light = $('<div class="light"></div>').appendTo(this.container)
|
||||
|
||||
this.modal = this.widget.detach()
|
||||
|
||||
this.value = false
|
||||
|
||||
this.light.on('fake-click',()=>{
|
||||
this.light.on('fake-click',(e)=>{
|
||||
if (e.type != 'fake-right-click')
|
||||
this.setValue(!this.value)
|
||||
})
|
||||
|
||||
this.parentScroll = [0,0]
|
||||
this.value = false
|
||||
this.init = false
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -61,11 +87,15 @@ module.exports = class Modal extends Panel {
|
|||
|
||||
this.value = v ? true : false
|
||||
|
||||
this.fixScrolling()
|
||||
if (!this.init) {
|
||||
this.widget.find('.popup-title .popup-label').html(this.container.find('> .label span').html())
|
||||
this.init = true
|
||||
}
|
||||
|
||||
this.widget.toggle(this.value)
|
||||
this.container.toggleClass('on', this.value)
|
||||
this.widget.toggleClass('on', this.value)
|
||||
this.light.toggleClass('on', this.value)
|
||||
|
||||
this.fixScrolling()
|
||||
|
||||
if (this.value) $(window).resize()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue