Permalink
Browse files

refactor global style split & removal

1) Removed page-global CSS from 'widgets.GlobalStyle' and extracted
some of it into 'templates.LegacyGeneralStyle', which is automatically
loaded for backward compatibility in templates when AriaSkin is available.

2) "aria.widgets.GlobalStyle" is loaded only when widgets are present.

3) Removed skin from bootstrap.js. Added skin in attester config instead.

4) In AriaSkinBeans: renamed "GeneralCfg" to "PageGeneralCfg"; removed some
deprecated items from it; created "WidgetGeneralCfg" being subset of
"PageGeneralCfg" to be able to separate font settings for widgets from
font settings for the page in general. This followed some changes in
skin normalization.
  • Loading branch information...
1 parent f44de2f commit 59e9ba72a65c810df7935c5a1a4195365e44d233 @jakub-g committed with divdavem Mar 14, 2013
View
@@ -123,12 +123,9 @@
'aria/core/environment/EnvironmentBase.js', 'aria/core/environment/Environment.js',
// resource manager
- 'aria/core/ResMgr.js', 'aria/utils/Profiling.js',
-
- // Skin
- 'aria/css/atskin.js'];
+ 'aria/core/ResMgr.js', 'aria/utils/Profiling.js'];
for (var i = 0; coreScripts.length > i; i++) {
loadScript(coreScripts[i]);
}
-})();
+})();
@@ -149,7 +149,10 @@
classes.push("aria.templates.ModuleCtrlFactory", moduleCtrl.classpath);
}
- var cssToReload = ['aria.templates.GlobalStyle', 'aria.widgets.GlobalStyle'];
+ var cssToReload = ['aria.templates.GlobalStyle'];
+ if (aria.widgets.AriaSkin) {
+ cssToReload.push('aria.templates.LegacyGeneralStyle');
+ }
if (cfg.reload) {
aria.templates.TemplateManager.unloadTemplate(cfg.classpath, cfg.reloadByPassCache);
if (aria.templates.CSSMgr) {
@@ -202,9 +202,11 @@ Aria.classDefinition({
__disposeLibs : function (libs) {
for (var i = 0; i < libs.length; i++) {
var lib = libs[i];
- aria.templates.ITemplate.prototype.$destructor.call(lib._tpl);
+ if (aria.templates.ITemplate) {
+ aria.templates.ITemplate.prototype.$destructor.call(lib._tpl);
+ }
lib.$dispose();
}
}
}
-});
+});
@@ -373,12 +373,9 @@ Aria.classDefinition({
delete this.__invalidClasspaths[cssClasspath];
var cssCtxt = aria.templates.CSSCtxtManager.getContext(cssClasspath, contextArgs);
- if (cssClasspath == "aria.templates.GlobalStyle") {
- // Give a prefix to the Global file in order to have higher priority
- this.__getPrefix(cssClasspath);
- }
- if (cssClasspath == "aria.widgets.GlobalStyle") {
- // Give a prefix to the Global file in order to have higher priority
+ // Give a prefix to the Global file in order to have higher priority
+ if (cssClasspath == "aria.templates.GlobalStyle" || cssClasspath == "aria.templates.LegacyGeneralStyle"
+ || cssClasspath == "aria.widgets.GlobalStyle") {
this.__getPrefix(cssClasspath);
}
if (cssCtxt.doPrefixing()) {
@@ -788,4 +785,4 @@ Aria.classDefinition({
return invalidClasspaths;
}
}
-});
+});
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2013 Amadeus s.a.s.
+ * 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.
+ */
+
+{CSSTemplate {
+ $classpath : "aria.templates.LegacyGeneralStyle",
+ $dependencies : ["aria.widgets.AriaSkinInterface"],
+ $csslibs : {
+ text : "aria.widgets.TextStyle"
+ }
+}}
+
+{macro main()}
+ {var general = aria.widgets.AriaSkinInterface.getGeneral() /}
+ {call writeGeneralStyle(general) /}
+{/macro}
+
+{macro writeGeneralStyle(general)}
+ {if general.font}
+ body, textarea, select, input, button, table {
+ {call text.writeFontStyleInner(general.font) /}
+ }
+ {/if}
+
+ {if general.anchor && general.anchor.states}
+ {call text.writeAnchorsStyle(general.anchor.states) /}
+ {/if}
+
+
+ {if ! general.disable.ul.list.style}
+ ul, li {list-style-type:none;}
+ {/if}
+
+{/macro}
+
+{/CSSTemplate}
@@ -169,8 +169,11 @@
aria.templates.CSSMgr.unloadDependencies(this);
if (this._globalCssDepsLoaded) {
// PTR 05086835: only unload the global CSS if it was loaded by this instance
- aria.templates.CSSMgr.unloadWidgetDependencies('aria.templates.Template', [
- 'aria.templates.GlobalStyle', /* BACKWARD-COMPATIBILITY-BEGIN */'aria.widgets.GlobalStyle' /* BACKWARD-COMPATIBILITY-END */]);
+ var deps = ['aria.templates.GlobalStyle'];
+ if (aria.widgets.AriaSkin) {
+ deps.push('aria.templates.LegacyGeneralStyle');
+ }
+ aria.templates.CSSMgr.unloadWidgetDependencies('aria.templates.Template', deps);
this._globalCssDepsLoaded = false;
}
this._cssClasses = null;
@@ -1703,9 +1706,11 @@
if (!classes) {
if (this._cfg.isRootTemplate) {
// PTR 05086835: load the global CSS here, and remember that it was loaded
- aria.templates.CSSMgr.loadWidgetDependencies('aria.templates.Template', [
- 'aria.templates.GlobalStyle', /* BACKWARD-COMPATIBILITY-BEGIN */
- 'aria.widgets.GlobalStyle' /* BACKWARD-COMPATIBILITY-END */]);
+ var deps = ['aria.templates.GlobalStyle'];
+ if (aria.widgets.AriaSkin) {
+ deps.push('aria.templates.LegacyGeneralStyle');
+ }
+ aria.templates.CSSMgr.loadWidgetDependencies('aria.templates.Template', deps);
this._globalCssDepsLoaded = true;
}
// Load the CSS dependencies, the style should be added before the html
@@ -42,37 +42,66 @@ Aria.beanDefinitions({
$minValue : 0,
$maxValue : 100
},
- "GeneralCfg" : {
+ "WidgetGeneralCfg" : {
$type : "Object",
$description : "",
$properties : {
- "imagesRoot" : {
- $type : "json:String",
- $description : "Root path for skin images (relative to Aria.rootFolderPath). It is supposed to end with a slash.",
- $default : "css/"
- },
"font" : {
$type : "Object",
$description : "",
$properties : {
"size" : {
$type : "Pixels",
- $description : "[Deprecated, please use a CSS file directly] General font size for the application (in pixels)."
+ $description : "Font size inside the widgets (in pixels)."
},
"family" : {
$type : "json:String",
- $description : "[Deprecated, please use a CSS file directly] General font family for the application."
+ $description : "Font family inside the widgets."
+ }
+ }
+ },
+ "anchor" : {
+ $type : "Object",
+ $description : "Settings for anchors inside widgets.",
+ $properties : {
+ "states" : {
+ $type : "StatesSet",
+ $description : "",
+ $properties : {
+ "normal" : {
+ $type : "AnchorState"
+ },
+ "link" : {
+ $type : "AnchorState"
+ },
+ "visited" : {
+ $type : "AnchorState"
+ },
+ "hover" : {
+ $type : "AnchorState"
+ },
+ "focus" : {
+ $type : "AnchorState"
+ }
+ }
}
}
+ }
+ }
+ },
+ "PageGeneralCfg" : {
+ $type : "WidgetGeneralCfg",
+ $description : "",
+ $properties : {
+ "imagesRoot" : {
+ $type : "json:String",
+ $description : "Root path for skin images (relative to Aria.rootFolderPath). It is supposed to end with a slash.",
+ $default : "css/"
},
"colors" : {
$type : "Object",
$description : "General color settings for your application",
$properties : {
- "bkg" : {
- $type : "Color",
- $description : "[Deprecated, please use a CSS file directly] General background color of the application."
- },
"disabled" : {
$type : "Color",
// used in aria.widgets.calendar.CalendarStyle
@@ -132,33 +161,6 @@ Aria.beanDefinitions({
}
}
},
- "anchor" : {
- $type : "Object",
- $description : "[Deprecated, please use a CSS file directly] General settings for anchors.",
- $properties : {
- "states" : {
- $type : "StatesSet",
- $description : "",
- $properties : {
- "normal" : {
- $type : "AnchorState"
- },
- "link" : {
- $type : "AnchorState"
- },
- "visited" : {
- $type : "AnchorState"
- },
- "hover" : {
- $type : "AnchorState"
- },
- "focus" : {
- $type : "AnchorState"
- }
- }
- }
- }
- },
"disable" : {
$type : "Object",
$description : "",
@@ -105,12 +105,28 @@ Aria.classDefinition({
* normalization function before returning its result.
*/
getGeneral : function () {
- var general = aria.widgets.AriaSkin.skinObject.general;
+ return this._normalizeAndGetGeneral("general", "PageGeneralCfg");
+ },
+
+ /**
+ * Return widget - general skin properties. If those properties are not normalized yet, this function calls the
+ * normalization function before returning its result.
+ */
+ getWidgetGeneral : function () {
+ return this._normalizeAndGetGeneral("widgets", "WidgetGeneralCfg");
+ },
+
+ /**
+ * Helper function to retrieve (and normalize if needed) general or widget-general skin properties.
+ * @param {String} skinObjPropName
+ * @param {String} beanType
+ */
+ _normalizeAndGetGeneral : function (skinObjProp, beanType) {
+ var general = aria.widgets.AriaSkin.skinObject[skinObjProp];
if (!general || !general['aria:skinNormalized']) {
- var newValue = aria.widgets.AriaSkinNormalization.normalizeGeneral(general);
+ var newValue = aria.widgets.AriaSkinNormalization.normalizeGeneral(general, beanType);
if (general != newValue) {
- general = newValue;
- aria.widgets.AriaSkin.skinObject.general = newValue;
+ aria.widgets.AriaSkin.skinObject[skinObjProp] = general = newValue;
}
}
return general;
@@ -214,11 +214,14 @@ Aria.classDefinition({
return;
}
for (var widget in skinObject) {
- if (skinObject.hasOwnProperty(widget) && widget != "general") {
+ if (skinObject.hasOwnProperty(widget) && widget != "general" && widget != "widgets") {
skinObject[widget] = this.normalizeWidget(widget, skinObject[widget]);
}
}
- skinObject.general = this.normalizeGeneral(skinObject.general);
+ skinObject.general = this.normalizeGeneral(skinObject.general, "PageGeneralCfg");
+ if (skinObject.widgets) {
+ skinObject.widgets = this.normalizeGeneral(skinObject.widgets, "WidgetGeneralCfg");
+ }
skinObject['aria:skinNormalized'] = true;
return skinObject;
},
@@ -521,12 +524,16 @@ Aria.classDefinition({
/**
* Normalizes the given general skin properties and returns it.
- * @param {aria.widgets.AriaSkinBeans.GeneralCfg} general
+ * @param {aria.widgets.AriaSkinBeans.WidgetsGeneralCfg|PageGeneralCfg} general
+ * @param {String} beanType
*/
- normalizeGeneral : function (general) {
+ normalizeGeneral : function (general, beanType) {
+ if (!general) {
+ general = {};
+ }
var param = {
json : general,
- beanName : "aria.widgets.AriaSkinBeans.GeneralCfg"
+ beanName : "aria.widgets.AriaSkinBeans." + beanType
};
var normalizationResults = this._normalize(param);
if (!normalizationResults.result) {
Oops, something went wrong.

0 comments on commit 59e9ba7

Please sign in to comment.