Refactor: clean some globals

This commit is contained in:
jean-emmanuel 2017-10-18 15:14:00 +02:00
parent d5713084c7
commit 96726bf429
5 changed files with 19 additions and 33 deletions

View file

@ -19,7 +19,7 @@ var callbacks = module.exports = {
},
connected:function(){
window.LOADING.close()
LOADING.close()
},
sessionList: function(data){
@ -72,12 +72,12 @@ var callbacks = module.exports = {
setTimeout(()=>{
$('canvas').trigger('resize',[0,0,true])
},100)
window.GRIDWIDTH = getComputedStyle(document.documentElement).getPropertyValue("--grid-width")
// window.PXSCALE_RESET()
GRIDWIDTH = getComputedStyle(document.documentElement).getPropertyValue("--grid-width")
},
readOnly: function(){
window.READ_ONLY = true
READ_ONLY = true
}
}

View file

@ -4,9 +4,6 @@ var Editor = class Editor {
constructor() {
this.enabled = false
EDITING = false
$(document).ready(()=>{
init()
@ -17,7 +14,7 @@ var Editor = class Editor {
enable() {
window.GRIDWIDTH = getComputedStyle(document.documentElement).getPropertyValue("--grid-width")
GRIDWIDTH = getComputedStyle(document.documentElement).getPropertyValue("--grid-width")
$('.editor-root').attr('data-widget', $('.root-container').attr('data-widget')).removeClass('disabled')
$('.enable-editor').addClass('on')
@ -25,9 +22,7 @@ var Editor = class Editor {
$('body').addClass('editor-enabled')
.toggleClass('no-grid', GRIDWIDTH==1)
this.enabled = true
window.EDITING = true
EDITING = true
var f = $('<div class="form" id="grid-width-input"></div>'),
h = $('<div class="separator"><span>Grid</span></div>').appendTo(f),
@ -61,8 +56,7 @@ var Editor = class Editor {
$('body').removeClass('editor-enabled')
$('#grid-width-input').remove()
this.enabled = false
window.EDITING = false
EDITING = false
if (READ_ONLY) {
this.enable = ()=>{}

View file

@ -5,32 +5,26 @@ location.search.replace(/[?&]+([^=&]+)=([^&]*)/gi, (s,k,v)=>{
window.PACKAGE = require('../../../../app/package.json')
window.LOADING = null
window.CLIPBOARD = null
window.EDITING = false
window.READ_ONLY = false
window.EDITING = false
window.GRIDWIDTH = 10
window.PXSCALE = 1
window.INITIALZOOM = ARGV.zoom ? ARGV.zoom : 1
window.PXSCALE_RESET = ()=>{
PXSCALE = INITIALZOOM
document.documentElement.style.setProperty('font-size', PXSCALE + 'px')
}
PXSCALE_RESET()
window.CANVAS_SCALING = parseFloat(ARGV.forceHdpi) || ( ARGV.hdpi ? window.devicePixelRatio : 1 )
window.INITIALZOOM = ARGV.zoom ? ARGV.zoom : 1
window.PXSCALE = INITIALZOOM
document.documentElement.style.setProperty('font-size', PXSCALE + 'px')
window.DOUBLE_TAP_TIME = ARGV.doubletap ? ARGV.doubletap : 375
window.JSON.parseFlex = require('json5').parse
///////////////////////
window.$ = require('jquery/dist/jquery.slim.min.js')
require('../libs/jquery.ui')

View file

@ -74,7 +74,7 @@ var SessionManager = class SessionManager {
var lobby = $(`
<div class="main">
<div class="header">
${window.PACKAGE.productName}
${PACKAGE.productName}
</div>
<div class="list"></div>
<div class="footer"></div>
@ -95,12 +95,12 @@ var SessionManager = class SessionManager {
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 (!window.READ_ONLY) {
if (!READ_ONLY) {
}
list.append(`
<a href="#" tabIndex="0" class="btn load" data-session="${data[i]}">
${file} <em style="opacity:0.45">(${path})</em>
${window.READ_ONLY? '' : '<span>'+icon('remove')+'</span>'}
${READ_ONLY? '' : '<span>'+icon('remove')+'</span>'}
</a>
`)

View file

@ -21,8 +21,6 @@ module.exports.reset = function(){
}
module.exports.widgets = function(data, parentNode, parentWidget, tab) {
for (let i in data) {