dev-environment: add ctrl+alt+R shortcut to reload styles

This commit is contained in:
juliandescottes 2017-08-01 23:05:28 +02:00 committed by Julian Descottes
parent 170a7e4731
commit 4e86fa1570
4 changed files with 23 additions and 1 deletions

View File

@ -201,6 +201,11 @@
dialogId : 'unsupported-browser' dialogId : 'unsupported-browser'
}); });
} }
if (pskl.utils.Environment.isDebug()) {
pskl.app.shortcutService.registerShortcut(pskl.service.keyboard.Shortcuts.DEBUG.RELOAD_STYLES,
window.reloadStyles);
}
}, },
loadPiskel_ : function (piskelData) { loadPiskel_ : function (piskelData) {

View File

@ -84,6 +84,10 @@
'123456789'.split(''), '1 to 9') '123456789'.split(''), '1 to 9')
}, },
DEBUG : {
RELOAD_STYLES : createShortcut('move-left', 'Move viewport left', 'ctrl+alt+R'),
},
CATEGORIES : ['TOOL', 'SELECTION', 'MISC', 'STORAGE', 'COLOR'] CATEGORIES : ['TOOL', 'SELECTION', 'MISC', 'STORAGE', 'COLOR']
}; };
})(); })();

View File

@ -23,6 +23,10 @@
isIntegrationTest : function () { isIntegrationTest : function () {
return window.location.href.indexOf('integration-test') !== -1; return window.location.href.indexOf('integration-test') !== -1;
},
isDebug : function () {
return window.location.href.indexOf('debug') !== -1;
} }
}; };

View File

@ -68,12 +68,21 @@
}; };
loadScript('piskel-script-list.js', 'loadNextScript()'); loadScript('piskel-script-list.js', 'loadNextScript()');
var styles;
window.loadStyles = function () { window.loadStyles = function () {
var styles = window.pskl_exports.styles; styles = window.pskl_exports.styles;
for (var i = 0 ; i < styles.length ; i++) { for (var i = 0 ; i < styles.length ; i++) {
loadStyle(styles[i]); loadStyle(styles[i]);
} }
}; };
window.reloadStyles = function () {
for (var i = 0 ; i < styles.length ; i++) {
document.querySelector('link[href="' + styles[i] + '"]').remove();
loadStyle(styles[i]);
}
};
loadScript('piskel-style-list.js', 'loadStyles()'); loadScript('piskel-style-list.js', 'loadStyles()');
} else { } else {
var script; var script;