From c2dbddcf9f94694f226092bcd1cb4b8c25318032 Mon Sep 17 00:00:00 2001 From: Julian Descottes Date: Sat, 10 Jun 2017 11:06:16 +0200 Subject: [PATCH] Issue #636 - rename all application-settings things to preferences-settings The name is not ideal, but it's better to have a MiscPreferencesController than a MainApplicationController for this kind of very simple panels. --- src/css/settings-application.css | 12 +++---- src/index.html | 8 ++--- .../settings/ApplicationSettingsController.js | 35 ------------------- .../settings/PreferencesController.js | 35 +++++++++++++++++++ .../controller/settings/SettingsController.js | 4 +-- .../GridPreferencesController.js} | 18 +++++----- .../MiscPreferencesController.js} | 20 +++++------ .../TilePreferencesController.js} | 16 ++++----- src/js/utils/UserSettings.js | 4 +-- src/piskel-script-list.js | 8 ++--- .../{application.html => preferences.html} | 6 ++-- .../{application => preferences}/grid.html | 4 +-- .../main.html => preferences/misc.html} | 4 +-- .../{application => preferences}/tile.html | 4 +-- test/casperjs/integration/IntegrationSuite.js | 2 +- ...ation-main.js => test-preferences-main.js} | 28 +++++++-------- .../test-settings-open-panels-on-click.js | 10 +++--- 17 files changed, 109 insertions(+), 109 deletions(-) delete mode 100644 src/js/controller/settings/ApplicationSettingsController.js create mode 100644 src/js/controller/settings/PreferencesController.js rename src/js/controller/settings/{application/GridApplicationController.js => preferences/GridPreferencesController.js} (82%) rename src/js/controller/settings/{application/MainApplicationController.js => preferences/MiscPreferencesController.js} (82%) rename src/js/controller/settings/{application/TileApplicationController.js => preferences/TilePreferencesController.js} (74%) rename src/templates/settings/{application.html => preferences.html} (75%) rename src/templates/settings/{application => preferences}/grid.html (92%) rename src/templates/settings/{application/main.html => preferences/misc.html} (94%) rename src/templates/settings/{application => preferences}/tile.html (83%) rename test/casperjs/integration/settings/{test-application-main.js => test-preferences-main.js} (68%) diff --git a/src/css/settings-application.css b/src/css/settings-application.css index ea2166ff..99ad9dea 100644 --- a/src/css/settings-application.css +++ b/src/css/settings-application.css @@ -1,8 +1,8 @@ -/*******************************/ -/* Application Setting panel */ -/*******************************/ +/********************************/ +/* Preferences Settings panel */ +/********************************/ -.settings-section-application { +.settings-section-preferences { height: 100%; position: relative; overflow: hidden; @@ -109,12 +109,12 @@ border-color: gold; } -.settings-section-application > .settings-title { +.settings-section-preferences > .settings-title { /* Override the default 10px margin bottom for this panel */ margin-bottom: 15px; } -.settings-section-application .button-primary { +.settings-section-preferences .button-primary { margin-top: 10px; } diff --git a/src/index.html b/src/index.html index d7cfe429..cc2dbe57 100644 --- a/src/index.html +++ b/src/index.html @@ -83,10 +83,10 @@ @@include('templates/dialogs/unsupported-browser.html', {}) - @@include('templates/settings/application.html', {}) - @@include('templates/settings/application/grid.html', {}) - @@include('templates/settings/application/main.html', {}) - @@include('templates/settings/application/tile.html', {}) + @@include('templates/settings/preferences.html', {}) + @@include('templates/settings/preferences/grid.html', {}) + @@include('templates/settings/preferences/misc.html', {}) + @@include('templates/settings/preferences/tile.html', {}) @@include('templates/settings/resize.html', {}) @@include('templates/settings/save.html', {}) @@include('templates/settings/import.html', {}) diff --git a/src/js/controller/settings/ApplicationSettingsController.js b/src/js/controller/settings/ApplicationSettingsController.js deleted file mode 100644 index 1b11d03b..00000000 --- a/src/js/controller/settings/ApplicationSettingsController.js +++ /dev/null @@ -1,35 +0,0 @@ -(function () { - var ns = $.namespace('pskl.controller.settings'); - - var tabs = { - 'main' : { - template : 'templates/settings/application/main.html', - controller : ns.application.MainApplicationController - }, - 'grid' : { - template : 'templates/settings/application/grid.html', - controller : ns.application.GridApplicationController - }, - 'tile' : { - template : 'templates/settings/application/tile.html', - controller : ns.application.TileApplicationController - } - }; - - ns.ApplicationSettingsController = function () { - this.tabsWidget = new pskl.widgets.Tabs(tabs, this, pskl.UserSettings.APPLICATION_SETTINGS_TAB); - }; - - pskl.utils.inherit(ns.ApplicationSettingsController, pskl.controller.settings.AbstractSettingController); - - ns.ApplicationSettingsController.prototype.init = function() { - var container = document.querySelector('.settings-section-application'); - this.tabsWidget.init(container); - }; - - ns.ApplicationSettingsController.prototype.destroy = function () { - this.tabsWidget.destroy(); - this.superclass.destroy.call(this); - }; - -})(); diff --git a/src/js/controller/settings/PreferencesController.js b/src/js/controller/settings/PreferencesController.js new file mode 100644 index 00000000..74252857 --- /dev/null +++ b/src/js/controller/settings/PreferencesController.js @@ -0,0 +1,35 @@ +(function () { + var ns = $.namespace('pskl.controller.settings'); + + var tabs = { + 'misc' : { + template : 'templates/settings/preferences/misc.html', + controller : ns.preferences.MiscPreferencesController + }, + 'grid' : { + template : 'templates/settings/preferences/grid.html', + controller : ns.preferences.GridPreferencesController + }, + 'tile' : { + template : 'templates/settings/preferences/tile.html', + controller : ns.preferences.TilePreferencesController + } + }; + + ns.PreferencesController = function () { + this.tabsWidget = new pskl.widgets.Tabs(tabs, this, pskl.UserSettings.PREFERENCES_TAB); + }; + + pskl.utils.inherit(ns.PreferencesController, pskl.controller.settings.AbstractSettingController); + + ns.PreferencesController.prototype.init = function() { + var container = document.querySelector('.settings-section-preferences'); + this.tabsWidget.init(container); + }; + + ns.PreferencesController.prototype.destroy = function () { + this.tabsWidget.destroy(); + this.superclass.destroy.call(this); + }; + +})(); diff --git a/src/js/controller/settings/SettingsController.js b/src/js/controller/settings/SettingsController.js index 0ee4fc93..10dfec16 100644 --- a/src/js/controller/settings/SettingsController.js +++ b/src/js/controller/settings/SettingsController.js @@ -3,8 +3,8 @@ var settings = { 'user' : { - template : 'templates/settings/application.html', - controller : ns.ApplicationSettingsController + template : 'templates/settings/preferences.html', + controller : ns.PreferencesController }, 'resize' : { template : 'templates/settings/resize.html', diff --git a/src/js/controller/settings/application/GridApplicationController.js b/src/js/controller/settings/preferences/GridPreferencesController.js similarity index 82% rename from src/js/controller/settings/application/GridApplicationController.js rename to src/js/controller/settings/preferences/GridPreferencesController.js index 952e436e..4a194eec 100644 --- a/src/js/controller/settings/application/GridApplicationController.js +++ b/src/js/controller/settings/preferences/GridPreferencesController.js @@ -1,5 +1,5 @@ (function () { - var ns = $.namespace('pskl.controller.settings.application'); + var ns = $.namespace('pskl.controller.settings.preferences'); var colorsMap = { 'transparent': Constants.TRANSPARENT_COLOR, @@ -18,15 +18,15 @@ 'red': '#FF004D', }; - ns.GridApplicationController = function (piskelController, applicationController) { + ns.GridPreferencesController = function (piskelController, preferencesController) { this.piskelController = piskelController; - this.applicationController = applicationController; + this.preferencesController = preferencesController; this.sizePicker = new pskl.widgets.SizePicker(this.onSizePickerChanged_.bind(this)); }; - pskl.utils.inherit(ns.GridApplicationController, pskl.controller.settings.AbstractSettingController); + pskl.utils.inherit(ns.GridPreferencesController, pskl.controller.settings.AbstractSettingController); - ns.GridApplicationController.prototype.init = function () { + ns.GridPreferencesController.prototype.init = function () { // Grid enabled var isEnabled = pskl.UserSettings.get(pskl.UserSettings.GRID_ENABLED); var enableGridCheckbox = document.querySelector('.enable-grid-checkbox'); @@ -66,20 +66,20 @@ this.addEventListener(this.gridColorList, 'click', this.onGridColorClicked_.bind(this)); }; - ns.GridApplicationController.prototype.destroy = function () { + ns.GridPreferencesController.prototype.destroy = function () { this.sizePicker.destroy(); this.superclass.destroy.call(this); }; - ns.GridApplicationController.prototype.onSizePickerChanged_ = function (size) { + ns.GridPreferencesController.prototype.onSizePickerChanged_ = function (size) { pskl.UserSettings.set(pskl.UserSettings.GRID_WIDTH, size); }; - ns.GridApplicationController.prototype.onEnableGridChange_ = function (evt) { + ns.GridPreferencesController.prototype.onEnableGridChange_ = function (evt) { pskl.UserSettings.set(pskl.UserSettings.GRID_ENABLED, evt.currentTarget.checked); }; - ns.GridApplicationController.prototype.onGridColorClicked_ = function (evt) { + ns.GridPreferencesController.prototype.onGridColorClicked_ = function (evt) { var color = evt.target.dataset.color; if (color) { pskl.UserSettings.set(pskl.UserSettings.GRID_COLOR, color); diff --git a/src/js/controller/settings/application/MainApplicationController.js b/src/js/controller/settings/preferences/MiscPreferencesController.js similarity index 82% rename from src/js/controller/settings/application/MainApplicationController.js rename to src/js/controller/settings/preferences/MiscPreferencesController.js index 6da0b18c..c12cee4d 100644 --- a/src/js/controller/settings/application/MainApplicationController.js +++ b/src/js/controller/settings/preferences/MiscPreferencesController.js @@ -1,14 +1,14 @@ (function () { - var ns = $.namespace('pskl.controller.settings.application'); + var ns = $.namespace('pskl.controller.settings.preferences'); - ns.MainApplicationController = function (piskelController, applicationController) { + ns.MiscPreferencesController = function (piskelController, preferencesController) { this.piskelController = piskelController; - this.applicationController = applicationController; + this.preferencesController = preferencesController; }; - pskl.utils.inherit(ns.MainApplicationController, pskl.controller.settings.AbstractSettingController); + pskl.utils.inherit(ns.MiscPreferencesController, pskl.controller.settings.AbstractSettingController); - ns.MainApplicationController.prototype.init = function () { + ns.MiscPreferencesController.prototype.init = function () { this.backgroundContainer = document.querySelector('.background-picker-wrapper'); this.addEventListener(this.backgroundContainer, 'click', this.onBackgroundClick_); @@ -42,7 +42,7 @@ this.updateLayerOpacityText_(layerOpacityInput.value); }; - ns.MainApplicationController.prototype.onBackgroundClick_ = function (evt) { + ns.MiscPreferencesController.prototype.onBackgroundClick_ = function (evt) { var target = evt.target; var background = target.dataset.background; if (background) { @@ -55,11 +55,11 @@ } }; - ns.MainApplicationController.prototype.onColorFormatChange_ = function (evt) { + ns.MiscPreferencesController.prototype.onColorFormatChange_ = function (evt) { pskl.UserSettings.set(pskl.UserSettings.COLOR_FORMAT, evt.target.value); }; - ns.MainApplicationController.prototype.onMaxFpsChange_ = function (evt) { + ns.MiscPreferencesController.prototype.onMaxFpsChange_ = function (evt) { var target = evt.target; var fps = parseInt(target.value, 10); if (fps && !isNaN(fps)) { @@ -69,7 +69,7 @@ } }; - ns.MainApplicationController.prototype.onLayerOpacityChange_ = function (evt) { + ns.MiscPreferencesController.prototype.onLayerOpacityChange_ = function (evt) { var target = evt.target; var opacity = parseFloat(target.value); if (!isNaN(opacity)) { @@ -81,7 +81,7 @@ } }; - ns.MainApplicationController.prototype.updateLayerOpacityText_ = function (opacity) { + ns.MiscPreferencesController.prototype.updateLayerOpacityText_ = function (opacity) { var layerOpacityText = document.querySelector('.layer-opacity-text'); layerOpacityText.innerHTML = (opacity * 1).toFixed(2); }; diff --git a/src/js/controller/settings/application/TileApplicationController.js b/src/js/controller/settings/preferences/TilePreferencesController.js similarity index 74% rename from src/js/controller/settings/application/TileApplicationController.js rename to src/js/controller/settings/preferences/TilePreferencesController.js index 3b1ceec1..9df62afc 100644 --- a/src/js/controller/settings/application/TileApplicationController.js +++ b/src/js/controller/settings/preferences/TilePreferencesController.js @@ -1,14 +1,14 @@ (function () { - var ns = $.namespace('pskl.controller.settings.application'); + var ns = $.namespace('pskl.controller.settings.preferences'); - ns.TileApplicationController = function (piskelController, applicationController) { + ns.TilePreferencesController = function (piskelController, preferencesController) { this.piskelController = piskelController; - this.applicationController = applicationController; + this.preferencesController = preferencesController; }; - pskl.utils.inherit(ns.TileApplicationController, pskl.controller.settings.AbstractSettingController); + pskl.utils.inherit(ns.TilePreferencesController, pskl.controller.settings.AbstractSettingController); - ns.TileApplicationController.prototype.init = function () { + ns.TilePreferencesController.prototype.init = function () { // Tile mode var tileMode = pskl.UserSettings.get(pskl.UserSettings.SEAMLESS_MODE); var tileModeCheckbox = document.querySelector('.tile-mode-checkbox'); @@ -25,11 +25,11 @@ this.updateTileMaskOpacityText_(tileMaskOpacityInput.value); }; - ns.TileApplicationController.prototype.onTileModeChange_ = function (evt) { + ns.TilePreferencesController.prototype.onTileModeChange_ = function (evt) { pskl.UserSettings.set(pskl.UserSettings.SEAMLESS_MODE, evt.currentTarget.checked); }; - ns.TileApplicationController.prototype.onTileMaskOpacityChange_ = function (evt) { + ns.TilePreferencesController.prototype.onTileMaskOpacityChange_ = function (evt) { var target = evt.target; var opacity = parseFloat(target.value); if (!isNaN(opacity)) { @@ -40,7 +40,7 @@ } }; - ns.TileApplicationController.prototype.updateTileMaskOpacityText_ = function (opacity) { + ns.TilePreferencesController.prototype.updateTileMaskOpacityText_ = function (opacity) { var seamlessOpacityText = document.querySelector('.tile-mask-opacity-text'); seamlessOpacityText.innerHTML = (opacity * 1).toFixed(2); }; diff --git a/src/js/utils/UserSettings.js b/src/js/utils/UserSettings.js index cae7ca7c..d0899e5b 100644 --- a/src/js/utils/UserSettings.js +++ b/src/js/utils/UserSettings.js @@ -21,7 +21,7 @@ RESIZE_SETTINGS: 'RESIZE_SETTINGS', COLOR_FORMAT: 'COLOR_FORMAT', TRANSFORM_SHOW_MORE: 'TRANSFORM_SHOW_MORE', - APPLICATION_SETTINGS_TAB: 'APPLICATION_SETTINGS_TAB', + PREFERENCES_TAB: 'PREFERENCES_TAB', KEY_TO_DEFAULT_VALUE_MAP_ : { 'GRID_COLOR' : Constants.TRANSPARENT_COLOR, 'GRID_ENABLED' : false, @@ -49,7 +49,7 @@ }, COLOR_FORMAT: 'hex', TRANSFORM_SHOW_MORE: false, - APPLICATION_SETTINGS_TAB: 'main', + PREFERENCES_TAB: 'misc', }, /** diff --git a/src/piskel-script-list.js b/src/piskel-script-list.js index 2c4b21a4..06e9bfcd 100644 --- a/src/piskel-script-list.js +++ b/src/piskel-script-list.js @@ -122,10 +122,10 @@ // Settings sub-controllers "js/controller/settings/AbstractSettingController.js", - "js/controller/settings/application/GridApplicationController.js", - "js/controller/settings/application/MainApplicationController.js", - "js/controller/settings/application/TileApplicationController.js", - "js/controller/settings/ApplicationSettingsController.js", + "js/controller/settings/preferences/GridPreferencesController.js", + "js/controller/settings/preferences/MiscPreferencesController.js", + "js/controller/settings/preferences/TilePreferencesController.js", + "js/controller/settings/PreferencesController.js", "js/controller/settings/exportimage/GifExportController.js", "js/controller/settings/exportimage/PngExportController.js", "js/controller/settings/exportimage/ZipExportController.js", diff --git a/src/templates/settings/application.html b/src/templates/settings/preferences.html similarity index 75% rename from src/templates/settings/application.html rename to src/templates/settings/preferences.html index d4c94842..49ae6bdb 100644 --- a/src/templates/settings/application.html +++ b/src/templates/settings/preferences.html @@ -1,8 +1,8 @@ -