From 4dafa95365608a3940d67393578c918a57a3eb09 Mon Sep 17 00:00:00 2001 From: Koong Kyungmi Date: Tue, 24 Nov 2015 20:12:40 +0900 Subject: [PATCH 1/3] [FEATURE] Support theme (temporary work before building theme plugin) [DESC.] - Using `theme.apply()`, image resources can be loaded by its sub path on theme set directories. - For instance, it was applied at two places on source codes(Help > About dialog, preference toolbar icon). --- apps/ide/src/plugins/help/about.html | 2 +- apps/ide/src/plugins/help/help-commands.js | 28 +++-- .../src/plugins/webida.preference/plugin.json | 2 +- common/src/webida/app-config.js | 4 + .../workbench/command-system/toolbar.js | 102 +++++++++--------- common/src/webida/util/theme.js | 37 +++++++ 6 files changed, 114 insertions(+), 61 deletions(-) create mode 100644 common/src/webida/util/theme.js diff --git a/apps/ide/src/plugins/help/about.html b/apps/ide/src/plugins/help/about.html index 0882673a..3949071c 100644 --- a/apps/ide/src/plugins/help/about.html +++ b/apps/ide/src/plugins/help/about.html @@ -62,7 +62,7 @@
-
diff --git a/apps/ide/src/plugins/help/help-commands.js b/apps/ide/src/plugins/help/help-commands.js index c84b0d0d..13c53cfb 100644 --- a/apps/ide/src/plugins/help/help-commands.js +++ b/apps/ide/src/plugins/help/help-commands.js @@ -44,14 +44,23 @@ define(['require'], function (require) { } function showAbout() { - require(['text!./about.html', - 'text!/package.json', - 'dojo/i18n!./nls/resource', - 'webida-lib/plugins/workbench/plugin', - 'webida-lib/util/locale', - 'webida-lib/widgets/dialogs/buttoned-dialog/ButtonedDialog' - ], - function (aboutHtml, text, i18n, workbench, Locale, ButtonedDialog) { + require([ + 'text!./about.html', + 'text!/package.json', + 'dojo/i18n!./nls/resource', + 'webida-lib/plugins/workbench/plugin', + 'webida-lib/util/locale', + 'webida-lib/util/theme', + 'webida-lib/widgets/dialogs/buttoned-dialog/ButtonedDialog' + ], function ( + aboutHtml, + text, + i18n, + workbench, + Locale, + theme, + ButtonedDialog + ) { var localizer = new Locale(i18n); var pane = new ButtonedDialog({ buttons: [], @@ -81,7 +90,8 @@ define(['require'], function (require) { commitId: data.buildcommitid || 'Unknown' }; - pane.setContentArea(aboutHtml); + + pane.setContentArea(theme.apply(aboutHtml)); $('#version').text(localizer.formatMessage('messageVersion', versionInfo)); $('#buildInfo').html( diff --git a/apps/ide/src/plugins/webida.preference/plugin.json b/apps/ide/src/plugins/webida.preference/plugin.json index 45fe01c1..f8ca0116 100644 --- a/apps/ide/src/plugins/webida.preference/plugin.json +++ b/apps/ide/src/plugins/webida.preference/plugin.json @@ -23,7 +23,7 @@ "keys" : { "default" : "Alt + P" }, "desc" : "Workspace Preferences" }, "toolbar": { - "icons" : "./styles/theme/webida-light/images/icons/toolbar_preference.png", + "icons" : "<%= themePath %>/images/icons/toolbar_preference.png", "tooltip" : "Preferences", "enabledOn": "toolbar.preferences.enable", "disabledOn": "toolbar.preferences.disable" diff --git a/common/src/webida/app-config.js b/common/src/webida/app-config.js index ecfc166e..3496e081 100644 --- a/common/src/webida/app-config.js +++ b/common/src/webida/app-config.js @@ -57,6 +57,10 @@ define([ dir: '.project', file: 'project.json' } + }, + theme: { + name: 'webida-light', + basePath: serverConf.systemApps[APP_ID].baseUrl + '/apps/ide/src/styles/theme/webida-light' } }; }); \ No newline at end of file diff --git a/common/src/webida/plugins/workbench/command-system/toolbar.js b/common/src/webida/plugins/workbench/command-system/toolbar.js index 5e788bd4..f8768223 100644 --- a/common/src/webida/plugins/workbench/command-system/toolbar.js +++ b/common/src/webida/plugins/workbench/command-system/toolbar.js @@ -24,55 +24,57 @@ * toolbar.js */ -define(['webida-lib/plugin-manager-0.1', // pm - 'external/lodash/lodash.min', // _ - './MenuItemTree', // MenuItemTree - 'dojo', // dojo - 'dojo/on', // on - 'dojo/dom-style', // domStyle - 'dojo/dom-class', // domClass - 'dojo/dom-attr', // domAttr - 'dojo/html', // html - 'dojo/query', // query - 'dojo/aspect', // aspect - 'dojo/topic', // topic - 'dojo/Deferred', // Deferred - 'dojo/_base/lang', // lang - 'dijit/Toolbar', // Toolbar - 'dijit/form/Button', // Button - 'dijit/form/DropDownButton', // DropDownButton - 'dijit/form/ComboButton', // ComboButton - 'dijit/Menu', // Menu - 'dijit/DropDownMenu', // DropDownMenu - 'dijit/MenuItem', // MenuItem - 'dijit/MenuSeparator', // MenuSeparator - 'dijit/ToolbarSeparator', // ToolbarSeparator - ], -function (pm, - _, - MenuItemTree, - dojo, - on, - domStyle, - domClass, - domAttr, - html, - query, - aspect, - topic, - Deferred, - lang, - Toolbar, - Button, - DropDownButton, - ComboButton, - Menu, - DropDownMenu, - MenuItem, - MenuSeparator, - ToolbarSeparator - ) -{ +define([ + 'external/lodash/lodash.min', // _ + 'dojo', // dojo + 'dojo/on', // on + 'dojo/dom-style', // domStyle + 'dojo/dom-class', // domClass + 'dojo/dom-attr', // domAttr + 'dojo/html', // html + 'dojo/query', // query + 'dojo/aspect', // aspect + 'dojo/topic', // topic + 'dojo/Deferred', // Deferred + 'dojo/_base/lang', // lang + 'dijit/Toolbar', // Toolbar + 'dijit/form/Button', // Button + 'dijit/form/DropDownButton', // DropDownButton + 'dijit/form/ComboButton', // ComboButton + 'dijit/Menu', // Menu + 'dijit/DropDownMenu', // DropDownMenu + 'dijit/MenuItem', // MenuItem + 'dijit/MenuSeparator', // MenuSeparator + 'dijit/ToolbarSeparator', // ToolbarSeparator + 'webida-lib/plugin-manager-0.1', // pm + 'webida-lib/util/theme', // theme + './MenuItemTree' // MenuItemTree +], function ( + _, + dojo, + on, + domStyle, + domClass, + domAttr, + html, + query, + aspect, + topic, + Deferred, + lang, + Toolbar, + Button, + DropDownButton, + ComboButton, + Menu, + DropDownMenu, + MenuItem, + MenuSeparator, + ToolbarSeparator, + pm, + theme, + MenuItemTree +) { 'use strict'; //console.log('mira: toolbar module loaded...'); @@ -101,7 +103,7 @@ function (pm, var modifiedIconClass = menuitem.replace(/&/g, '').replace(/\//g, '__').replace(/ /g, '_') + '_wticons'; img = ''; imgClass = modifiedIconClass; diff --git a/common/src/webida/util/theme.js b/common/src/webida/util/theme.js new file mode 100644 index 00000000..d90ba62b --- /dev/null +++ b/common/src/webida/util/theme.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2012-2015 S-Core Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * + * @since: 15. 11. 24 + * @author: Koong Kyungmi (kyungmi.k@samsung.com) + */ + +define([ + 'external/lodash/lodash.min', + 'webida-lib/app-config' +], function ( + _, + config +) { + var theme = config.theme; + + return { + apply: function (template) { + return _.template(template)({theme: theme.name, themePath: theme.basePath}); + } + }; +}); \ No newline at end of file From ee448be8224a0d21d9481f9f1cb8d0a00b7825ee Mon Sep 17 00:00:00 2001 From: Kyungmi Koong Date: Tue, 24 Nov 2015 20:18:03 +0900 Subject: [PATCH 2/3] [CODE_CONVENTION] follow jshint --- common/src/webida/util/theme.js | 1 + 1 file changed, 1 insertion(+) diff --git a/common/src/webida/util/theme.js b/common/src/webida/util/theme.js index d90ba62b..e877089c 100644 --- a/common/src/webida/util/theme.js +++ b/common/src/webida/util/theme.js @@ -27,6 +27,7 @@ define([ _, config ) { + 'use strict'; var theme = config.theme; return { From b4d5d318eadb5cdad2b3aae054068a85ffe5891a Mon Sep 17 00:00:00 2001 From: Koong Kyungmi Date: Wed, 25 Nov 2015 11:21:30 +0900 Subject: [PATCH 3/3] [BUGFIX] fix some code following advice --- apps/ide/src/plugins/help/help-commands.js | 2 +- common/src/webida/plugins/workbench/command-system/toolbar.js | 2 +- common/src/webida/{util => }/theme.js | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename common/src/webida/{util => }/theme.js (100%) diff --git a/apps/ide/src/plugins/help/help-commands.js b/apps/ide/src/plugins/help/help-commands.js index 13c53cfb..64bde249 100644 --- a/apps/ide/src/plugins/help/help-commands.js +++ b/apps/ide/src/plugins/help/help-commands.js @@ -50,7 +50,7 @@ define(['require'], function (require) { 'dojo/i18n!./nls/resource', 'webida-lib/plugins/workbench/plugin', 'webida-lib/util/locale', - 'webida-lib/util/theme', + 'webida-lib/theme', 'webida-lib/widgets/dialogs/buttoned-dialog/ButtonedDialog' ], function ( aboutHtml, diff --git a/common/src/webida/plugins/workbench/command-system/toolbar.js b/common/src/webida/plugins/workbench/command-system/toolbar.js index f8768223..9de9d6e4 100644 --- a/common/src/webida/plugins/workbench/command-system/toolbar.js +++ b/common/src/webida/plugins/workbench/command-system/toolbar.js @@ -47,7 +47,7 @@ define([ 'dijit/MenuSeparator', // MenuSeparator 'dijit/ToolbarSeparator', // ToolbarSeparator 'webida-lib/plugin-manager-0.1', // pm - 'webida-lib/util/theme', // theme + 'webida-lib/theme', // theme './MenuItemTree' // MenuItemTree ], function ( _, diff --git a/common/src/webida/util/theme.js b/common/src/webida/theme.js similarity index 100% rename from common/src/webida/util/theme.js rename to common/src/webida/theme.js