mirror of
https://github.com/lospec/pixel-editor.git
synced 2023-08-10 21:12:51 +03:00
Introduce feature toggles and hide ellipsis tool behind such toggle
This commit is contained in:
33
js/_featureToggles.js
Normal file
33
js/_featureToggles.js
Normal file
@@ -0,0 +1,33 @@
|
||||
const featureToggles = (function featureTogglesModule() {
|
||||
|
||||
const ellipseToolLocalStorageKey = 'feature_ellipseTool';
|
||||
|
||||
return {
|
||||
onLoad: () => {
|
||||
updateEllipseToolVisibility()
|
||||
},
|
||||
enableEllipseTool,
|
||||
disableEllipseTool
|
||||
}
|
||||
|
||||
////////
|
||||
|
||||
function updateEllipseToolVisibility() {
|
||||
// TODO: [ELLIPSE] Once ellipse is ready for release make it enabled by default
|
||||
const isEllipseToolEnabled = (window.localStorage.getItem(ellipseToolLocalStorageKey) === "yes") || false;
|
||||
const ellipseToolElement = document.getElementById("tools-menu--ellipse");
|
||||
ellipseToolElement.style.display = isEllipseToolEnabled ? 'block' : 'none';
|
||||
}
|
||||
|
||||
function enableEllipseTool() {
|
||||
window.localStorage.setItem(ellipseToolLocalStorageKey, "yes");
|
||||
updateEllipseToolVisibility();
|
||||
}
|
||||
|
||||
function disableEllipseTool() {
|
||||
window.localStorage.setItem(ellipseToolLocalStorageKey, "no");
|
||||
updateEllipseToolVisibility();
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
//when the page is donw loading, you can get ready to start
|
||||
window.onload = function(){
|
||||
currentTool.updateCursor();
|
||||
//when the page is done loading, you can get ready to start
|
||||
window.onload = function () {
|
||||
|
||||
featureToggles.onLoad();
|
||||
|
||||
currentTool.updateCursor();
|
||||
|
||||
//if the user specified dimensions
|
||||
if (specifiedDimentions) {
|
||||
//create a new pixel
|
||||
newPixel(getValue('size-width'), getValue('size-height'), getValue('editor-mode'));
|
||||
} else {
|
||||
//otherwise show the new pixel dialog
|
||||
showDialogue('splash', false);
|
||||
}
|
||||
|
||||
//if the user specified dimentions
|
||||
if (specifiedDimentions)
|
||||
//create a new pixel
|
||||
newPixel(getValue('size-width'),getValue('size-height'), getValue('editor-mode'));
|
||||
else
|
||||
//otherwise show the new pixel dialog
|
||||
showDialogue('splash', false);
|
||||
};
|
||||
@@ -81,3 +81,6 @@
|
||||
|
||||
/**libraries**/
|
||||
//=include _jscolor.js
|
||||
|
||||
/**feature toggles**/
|
||||
//=include _featureToggles.js
|
||||
|
||||
Reference in New Issue
Block a user