Permalink
Browse files

refactor Stricter options on JsHint

Enable more strict option on JsHint and update the package dependencies.

Close #244 close #579
  • Loading branch information...
1 parent fd16004 commit 8c34b0c07db209a05c4d86754287431dfbf484ee @piuccio committed Jun 24, 2013
Showing with 815 additions and 844 deletions.
  1. +13 −3 build/config/jshint.json
  2. +22 −16 build/grunt-config/config-checkStyle.js
  3. +5 −5 package.json
  4. +1 −2 src/aria/Aria.js
  5. +1 −0 src/aria/bootstrap.js
  6. +1 −2 src/aria/core/BaseTypes.js
  7. +1 −3 src/aria/core/ClassMgr.js
  8. +2 −5 src/aria/core/DownloadMgr.js
  9. +1 −5 src/aria/core/FileLoader.js
  10. +2 −3 src/aria/core/Interfaces.js
  11. +2 −3 src/aria/core/JsClassLoader.js
  12. +2 −2 src/aria/core/JsObject.js
  13. +2 −3 src/aria/core/JsonTypes.js
  14. +4 −5 src/aria/core/ResClassLoader.js
  15. +3 −5 src/aria/core/Timer.js
  16. +0 −3 src/aria/core/environment/Customizations.js
  17. +0 −3 src/aria/core/environment/Environment.js
  18. +0 −1 src/aria/core/environment/EnvironmentBase.js
  19. +3 −3 src/aria/core/log/AjaxAppender.js
  20. +3 −3 src/aria/core/log/DefaultAppender.js
  21. +3 −4 src/aria/core/log/DivAppender.js
  22. +3 −3 src/aria/core/log/WindowAppender.js
  23. +2 −4 src/aria/dom/DomReady.js
  24. +1 −1 src/aria/embed/CfgBeans.js
  25. +1 −2 src/aria/embed/IContentProvider.js
  26. +1 −3 src/aria/embed/Placeholder.js
  27. +1 −3 src/aria/ext/StressCss.js
  28. +2 −4 src/aria/ext/filesgenerator/Generator.js
  29. +1 −4 src/aria/ext/filesgenerator/GeneratorBeans.js
  30. +2 −2 src/aria/html/beans/TemplateCfg.js
  31. +2 −3 src/aria/jsunit/AppletWorker.js
  32. +4 −6 src/aria/jsunit/IOViewer.js
  33. +1 −4 src/aria/jsunit/JsCoverageReport.js
  34. +2 −7 src/aria/jsunit/MultiSelectTemplateTestCase.js
  35. +1 −2 src/aria/jsunit/ScreenCapture.js
  36. +2 −3 src/aria/jsunit/SynEvents.js
  37. +29 −28 src/aria/jsunit/TestWrapper.js
  38. +1 −0 src/aria/node.js
  39. +1 −0 src/aria/utils/FireDomEvent.js
  40. +1 −1 src/aria/utils/validators/Object.js
  41. +4 −3 src/aria/widgets/AriaSkinInterface.js
  42. +665 −670 src/aria/widgets/Widget.js
  43. +1 −3 src/aria/widgets/controllers/DropDownListController.js
  44. +1 −2 src/aria/widgets/errorlist/ErrorListTemplateScript.js
  45. +2 −2 test/aria/core/CallbackTest.js
  46. +1 −0 test/aria/core/JsonValidatorTest.js
  47. +0 −1 test/aria/core/ObservableTest.js
  48. +2 −1 test/aria/jsunit/AssertTest.js
  49. +1 −0 test/aria/utils/NumberLocale.js
  50. +2 −1 test/aria/utils/Object.js
  51. +2 −1 test/aria/utils/StackHashMapTest.js
  52. +1 −0 test/aria/utils/String.js
  53. +1 −0 test/aria/utils/TypeTest.js
  54. +1 −0 test/aria/utils/validators/Object.js
  55. +2 −1 test/aria/utils/validators/String.js
View
16 build/config/jshint.json
@@ -3,8 +3,10 @@
"camelcase" : false,
"curly" : false,
"eqeqeq" : false,
+ "es3" : false,
"forin" : false,
"immed" : false,
+ "indent" : false,
"latedef" : false,
"newcap" : false,
"noarg" : false,
@@ -17,8 +19,8 @@
"unused" : false,
"strict" : false,
"trailing" : true,
- "maxparams" : 0,
- "maxdepth" : 0,
+ "maxparams" : 6,
+ "maxdepth" : 6,
"maxstatements" : 0,
"maxcomplexity" : 0,
"maxlen" : 0,
@@ -61,13 +63,21 @@
"rhino" : false,
"worker" : false,
"wsh" : false,
+ "yui" : false,
"nomen" : false,
"onevar" : false,
"passfail" : false,
"white" : false,
- "predef" : ["aria", "Aria", "setTimeout", "setInterval", "clearTimeout", "clearInterval"],
+ "globals" : {
+ "aria" : false,
+ "Aria" : false,
+ "setTimeout" : false,
+ "setInterval" : false,
+ "clearTimeout" : false,
+ "clearInterval" : false
+ },
"maxerr" : 150,
"-W018" : true
View
38 build/grunt-config/config-checkStyle.js
@@ -39,32 +39,38 @@ module.exports = function (grunt) {
src : ['test/**/*.js', '!test/node/**/*.js',
// Using some window globals
'!test/iframeLoaderOs.js',
- // Bad escaping
- '!test/aria/utils/validators/String.js',
- '!test/aria/utils/String.js',
// Syntax errors, used for testing
'!test/aria/templates/test/error/*.js',
// Syntax errors, used for testing
'!test/aria/templates/reloadResources/ExternalResourceErr.js']
},
options : {
- "predef" : ["aria", "Aria", "setTimeout", "setInterval", "clearTimeout", "clearInterval", "test", "Syn"],
- // Object literal notation
- "-W010" : true,
- // Array literal notation
- "-W009" : true,
- // It's not necessary to initialize to 'undefined'
- "-W080" : true,
- // Duplicate key
- "-W075" : true,
- // Do not use String as a contructor
- "-W053" : true
+ "globals" : {
+ "aria": false,
+ "Aria": false,
+ "setTimeout": false,
+ "setInterval": false,
+ "clearTimeout": false,
+ "clearInterval": false,
+ "test": false,
+ "Syn": false
+ }
}
},
node : {
- files : 'test/node/**/*.js',
+ src : ['test/node/**/*.js'],
options : {
- "predef" : ["aria", "Aria", "require", "describe", "it", "before", "beforeEach", "after", "afterEach"]
+ "node" : true,
+ "globals" : {
+ "aria" : false,
+ "Aria" : false,
+ "describe" : false,
+ "it" : false,
+ "before" : false,
+ "beforeEach" : false,
+ "after" : false,
+ "afterEach" : false
+ }
}
}
});
View
10 package.json
@@ -23,14 +23,14 @@
"test": "npm run-script lint && npm run-script grunt && npm run-script mocha && npm run-script attester"
},
"devDependencies": {
- "gzip-js": "0.3.1",
+ "gzip-js": "0.3.2",
"grunt-verifylowercase": "0.2.0",
"grunt": "git+https://github.com/divdavem/grunt.git#9952016e64f18404d459a39fd9273c7939693900",
- "grunt-contrib-jshint": "0.2.0",
+ "grunt-contrib-jshint": "0.6.0",
"attester": "1.1.0",
- "express": "3.0.3",
- "jade": "0.27.7",
+ "express": "3.2.6",
+ "jade": "0.31.2",
"atpackager": "0.1.0",
- "mocha": "1.8.2"
+ "mocha": "1.11.0"
}
}
View
3 src/aria/Aria.js
@@ -1,3 +1,4 @@
+/* global Aria:true */
/*
* Copyright 2012 Amadeus s.a.s.
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,8 +16,6 @@
/**
* Global Aria object defining the base methods to manage objects, logs and file dependencies.
- * @class Aria
- * @singleton
*/
(function () {
View
1 src/aria/bootstrap.js
@@ -1,3 +1,4 @@
+/* global Aria:true */
/*
* Copyright 2012 Amadeus s.a.s.
* Licensed under the Apache License, Version 2.0 (the "License");
View
3 src/aria/core/BaseTypes.js
@@ -15,7 +15,6 @@
/**
* Definition of all base beans used in all JSON schemas
- * @class aria.core.BaseTypes
*/
Aria.beanDefinitions({
$package : "aria.core.BaseTypes",
@@ -306,4 +305,4 @@ Aria.beanDefinitions({
}
}
}
-});
+});
View
4 src/aria/core/ClassMgr.js
@@ -14,12 +14,10 @@
*/
/**
- * @class aria.core.ClassMgr Manage the class dependency load thanks to ClassLoaders. Classes can be of different types
+ * Manage the class dependency load thanks to ClassLoaders. Classes can be of different types
* (currently six: "JS", "TPL", "RES", "CSS", "TML" and "TXT"). Before loading a class, it is necessary to know its type
* (there is no naming convention). This class uses the Cache object to store class definitions (through the
* DownloadMgr) and indicators telling that a class is being downloaded.
- * @extends aria.core.JsObject
- * @singleton
*/
Aria.classDefinition({
$classpath : "aria.core.ClassMgr",
View
7 src/aria/core/DownloadMgr.js
@@ -18,14 +18,11 @@
* associated to the same physical URL, makes sure listeneres are associated to the same loader Manage logical path /
* physical URL mapping (the same physical URL can be used for multiple logical paths in case of multipart (packaged)
* files) thanks to the Url Map.
- * @class aria.core.DownloadMgr
- * @extends aria.core.JsObject
- * @singleton
*/
Aria.classDefinition({
- $classpath : 'aria.core.DownloadMgr',
+ $classpath : "aria.core.DownloadMgr",
$singleton : true,
- $dependencies : ['aria.utils.Type', 'aria.utils.Json'],
+ $dependencies : ["aria.utils.Type", "aria.utils.Json"],
$constructor : function () {
/**
View
6 src/aria/core/FileLoader.js
@@ -13,12 +13,8 @@
* limitations under the License.
*/
-/**
- * @class aria.core.FileLoader File loader
- * @extends aria.core.JsObject
- */
Aria.classDefinition({
- $classpath : 'aria.core.FileLoader',
+ $classpath : "aria.core.FileLoader",
$events : {
/**
View
5 src/aria/core/Interfaces.js
@@ -211,12 +211,11 @@
/**
* Singleton in charge of interface-related operations. It contains internal methods of the framework which should
- * not be called directly by the application developper.
- * @class aria.core.Interfaces
+ * not be called directly by the application developer.
* @private
*/
Aria.classDefinition({
- $classpath : 'aria.core.Interfaces',
+ $classpath : "aria.core.Interfaces",
$singleton : true,
$statics : {
// ERROR MESSAGES:
View
5 src/aria/core/JsClassLoader.js
@@ -14,8 +14,7 @@
*/
/**
- * @class aria.core.JsClassLoader ClassLoader for js files.
- * @extends aria.core.ClassLoader
+ * ClassLoader for js files.
*/
Aria.classDefinition({
$classpath : 'aria.core.JsClassLoader',
@@ -39,4 +38,4 @@ Aria.classDefinition({
}
}
}
-});
+});
View
4 src/aria/core/JsObject.js
@@ -244,7 +244,7 @@
};
/**
- * @class aria.core.JsObject Base class from which derive all Js classes defined through Aria.classDefinition()
+ * Base class from which derive all JS classes defined through Aria.classDefinition()
*/
Aria.classDefinition({
$classpath : "aria.core.JsObject",
@@ -261,7 +261,7 @@
MISSING_SCOPE : "scope property is mandatory when adding or removing a listener (event: %1)",
INTERFACE_NOT_SUPPORTED : "The '%1' interface is not supported on this object (of type '%2').",
ASSERT_FAILURE : "Assert #%1 failed in %2",
- CALLBACK_ERROR : "An error occured while processing a callback function: \ncalling class: %1\ncalled class: %2"
+ CALLBACK_ERROR : "An error occurred while processing a callback function: \ncalling class: %1\ncalled class: %2"
},
$prototype : {
/**
View
5 src/aria/core/JsonTypes.js
@@ -14,7 +14,6 @@
*/
/**
- * @class aria.core.JsonTypes
* Definition of all base types used in JSON schemas
*/
Aria.beanDefinitions({
@@ -52,7 +51,7 @@ Aria.beanDefinitions({
},
"RegExp" : {
$type : "RegExp",
- $description : "Correspond to a JavaScript regular expresssion",
+ $description : "Correspond to a JavaScript regular expression",
$sample : /^\w([\w\.]*\w)?$/
},
"ObjectRef" : {
@@ -101,4 +100,4 @@ Aria.beanDefinitions({
$regExp : /^([a-zA-Z_\$][\w\$]*($|\.(?=.)))+$/
}
}
-});
+});
View
9 src/aria/core/ResClassLoader.js
@@ -14,12 +14,11 @@
*/
/**
- * @class aria.core.ResClassLoader ClassLoader for resource files.
- * @extends aria.core.ClassLoader
+ * ClassLoader for resource files.
*/
Aria.classDefinition({
- $classpath : 'aria.core.ResClassLoader',
- $extends : 'aria.core.ClassLoader',
+ $classpath : "aria.core.ResClassLoader",
+ $extends : "aria.core.ClassLoader",
$constructor : function (classpath, classtype) {
this.$ClassLoader.constructor.apply(this, arguments);
this.serverResource = false;
@@ -219,4 +218,4 @@ Aria.classDefinition({
}
}
-});
+});
View
8 src/aria/core/Timer.js
@@ -14,14 +14,12 @@
*/
/**
- * @class aria.core.Timer This class handles asynchronous callbacks and gives the possibility to associate an object
+ * This class handles asynchronous callbacks and gives the possibility to associate an object
* (scope) to the callback function - which is not possible with setTimeout(...) It also creates a unique id that
* can be used to cancel the callback
- * @extends aria.core.JsObject
- * @singleton
*/
Aria.classDefinition({
- $classpath : 'aria.core.Timer',
+ $classpath : "aria.core.Timer",
$singleton : true,
$constructor : function () {
/**
@@ -218,4 +216,4 @@ Aria.classDefinition({
}
}
}
-});
+});
View
3 src/aria/core/environment/Customizations.js
@@ -15,9 +15,6 @@
/**
* Contains getters for the Number environment.
- * @class aria.core.environment.Customizations
- * @extends aria.core.environment.EnvironmentBase
- * @singleton
*/
Aria.classDefinition({
$classpath : "aria.core.environment.Customizations",
View
3 src/aria/core/environment/Environment.js
@@ -15,9 +15,6 @@
/**
* Public API for retrieving, applying application variables.
- * @class aria.core.environment.Environment
- * @extends aria.core.environment.EnvironmentBase
- * @singleton
*/
Aria.classDefinition({
$classpath : "aria.core.environment.Environment",
View
1 src/aria/core/environment/EnvironmentBase.js
@@ -15,7 +15,6 @@
/**
* Base class containing shared methods for all environment classes.
- * @class aria.core.environment.EnvironmentBase
*/
Aria.classDefinition({
$classpath : "aria.core.environment.EnvironmentBase",
View
6 src/aria/core/log/AjaxAppender.js
@@ -14,7 +14,7 @@
*/
/**
- * @class aria.core.log.AjaxAppender This type of appender gathers all the logs sent to it and sends them in a JSON POST
+ * This type of appender gathers all the logs sent to it and sends them in a JSON POST
* message to the configured server URL. This is experimental for now. Never tested.
* @param {String} url The URL to send the logs to (the server logic running at this url should be prepared to handle
* JSON POST messages in the following form: {logs: [{time: <ms timestamp>, level: <debug|info|warn|error>, msg: <the
@@ -25,7 +25,7 @@
* logs (logs are sent as a batch)
*/
Aria.classDefinition({
- $classpath : 'aria.core.log.AjaxAppender',
+ $classpath : "aria.core.log.AjaxAppender",
$dependencies : ["aria.core.IO", "aria.utils.Json"],
$constructor : function (url, minInterval, minLogNb) {
this._logStack = [];
@@ -174,4 +174,4 @@ Aria.classDefinition({
return str;
}
}
-});
+});
View
6 src/aria/core/log/DefaultAppender.js
@@ -16,12 +16,12 @@
(function () {
var console = Aria.$global.console;
/**
- * @class aria.core.log.DefaultAppender Default appender used by the logger to output log lines. The default
+ * Default appender used by the logger to output log lines. The default
* appender is using Firebug/Firebug lite to log (or in fact, any console that defines the window.console object).
* Other appenders can be written by extending this default class in order to output elsewhere.
*/
Aria.classDefinition({
- $classpath : 'aria.core.log.DefaultAppender',
+ $classpath : "aria.core.log.DefaultAppender",
$prototype : console ? {
/**
* Output the first part of the string corresponding to the classname in the log
@@ -114,4 +114,4 @@
error : function () {}
}
});
-})();
+})();
View
7 src/aria/core/log/DivAppender.js
@@ -15,17 +15,16 @@
/**
* This appender output logs to a div in simple HTML format.
- * @class aria.core.log.DivAppender
*/
Aria.classDefinition({
- $classpath : 'aria.core.log.DivAppender',
+ $classpath : "aria.core.log.DivAppender",
/**
* Takes the div used for logs as argument
* @param {HTMLElement} div
*/
$constructor : function (div) {
this.div = div;
- div.innerHTML = '<h2>Logs</h2>';
+ div.innerHTML = "<h2>Logs</h2>";
this.groupSpacer = "";
},
$destructor : function () {
@@ -141,4 +140,4 @@ Aria.classDefinition({
this.div.innerHTML += txt;
}
}
-});
+});
View
6 src/aria/core/log/WindowAppender.js
@@ -14,10 +14,10 @@
*/
/**
- * @class aria.core.log.WindowAppender This appender output logs to an external browser window in simple HTML format.
+ * This appender output logs to an external browser window in simple HTML format.
*/
Aria.classDefinition({
- $classpath : 'aria.core.log.WindowAppender',
+ $classpath : "aria.core.log.WindowAppender",
$constructor : function () {
/**
* The popup window object into which the logs are going
@@ -134,4 +134,4 @@ Aria.classDefinition({
this.w.scroll(0, 10000000);
}
}
-});
+});
View
6 src/aria/dom/DomReady.js
@@ -14,12 +14,10 @@
*/
/**
- * @class aria.dom.DomReady Global class it checks DOM is in Ready state and executes the callback function
- * @extends aria.core.JsObject
- * @singleton
+ * Global class it checks DOM is in Ready state and executes the callback function
*/
Aria.classDefinition({
- $classpath : 'aria.dom.DomReady',
+ $classpath : "aria.dom.DomReady",
$singleton : true,
$events : {
"ready" : "Raised when the DOM is in ready state."
View
2 src/aria/embed/CfgBeans.js
@@ -14,7 +14,7 @@
*/
/**
- * @class aria.embed.CfgBeans Configuration Beans associated to the Aria Templates Widgets
+ * Configuration Beans associated to the Aria Templates Widgets
*/
Aria.beanDefinitions({
$package : "aria.embed.CfgBeans",
View
3 src/aria/embed/IContentProvider.js
@@ -15,10 +15,9 @@
/**
* Default interface for a content provider
- * @class aria.embed.IContentProvider
*/
Aria.interfaceDefinition({
- $classpath : 'aria.embed.IContentProvider',
+ $classpath : "aria.embed.IContentProvider",
$events : {
"contentChange" : {
description : "Raised when the content associated to one or more placeholder paths changes.",
View
4 src/aria/embed/Placeholder.js
@@ -15,8 +15,6 @@
/**
* Placeholder widget
- * @class aria.embed.Placeholder
- * @extends aria.widgetLibs.BaseWidget
*/
Aria.classDefinition({
$classpath : "aria.embed.Placeholder",
@@ -161,4 +159,4 @@ Aria.classDefinition({
return placeholderPath + this._cfg.name;
}
}
-});
+});
View
4 src/aria/ext/StressCss.js
@@ -564,8 +564,6 @@
* Stress test the CSS added to the CSS Manager. This class executes and measures a given action removing all CSS in
* the page one by one. It'll report the slowest running selectors. Default test action is a refresh of all root
* templates. This action can be modified from the arguments of 'stressTest' method
- * @class aria.ext.StressCss
- * @singleton
* @since 1.1-13
*/
Aria.classDefinition({
@@ -629,4 +627,4 @@
}
}
});
-})();
+})();
View
6 src/aria/ext/filesgenerator/Generator.js
@@ -16,12 +16,10 @@
/**
* File skeleton generator utility class to be used to get the text content of any type of Aria Templates file. A class,
* a module controller, a template, a template script, a CSS template, a flow, an interface, ...
- * @class aria.ext.filesgenerator.Generator
- * @extends aria.core.JsObject
*/
Aria.classDefinition({
- $classpath : 'aria.ext.filesgenerator.Generator',
- $extends : 'aria.core.JsObject',
+ $classpath : "aria.ext.filesgenerator.Generator",
+ $extends : "aria.core.JsObject",
$singleton : true,
$dependencies : ["aria.core.JsonValidator", "aria.ext.filesgenerator.GeneratorBeans"],
$texts : {
View
5 src/aria/ext/filesgenerator/GeneratorBeans.js
@@ -13,9 +13,6 @@
* limitations under the License.
*/
-/**
- * @class aria.ext.filesgenerator.GeneratorBeans
- */
Aria.beanDefinitions({
$package : "aria.ext.filesgenerator.GeneratorBeans",
$description : "Definition of the JSON beans used as input of the file skeleton generator",
@@ -307,4 +304,4 @@ Aria.beanDefinitions({
}
}
}
-});
+});
View
4 src/aria/html/beans/TemplateCfg.js
@@ -14,7 +14,7 @@
*/
/**
- * @class aria.html.beans.TemplateCfg Configuration Beans associated to the HTML include simple widget
+ * Configuration Beans associated to the HTML include simple widget
*/
Aria.beanDefinitions({
$package : "aria.html.beans.TemplateCfg",
@@ -74,4 +74,4 @@ Aria.beanDefinitions({
}
}
}
-});
+});
View
5 src/aria/jsunit/AppletWorker.js
@@ -28,14 +28,13 @@
};
/**
- * @class AppletWorker The AppletWorker class is the API that allows to use the applet as a communication bridge
+ * The AppletWorker class is the API that allows to use the applet as a communication bridge
* between the javascript and external applications For the bridge to work you need to add an applet tag to your
* HTML page in the following way:
- * @constructor
* @param {String} appletName The name of the applet that was added the page
*/
Aria.classDefinition({
- $classpath : 'aria.jsunit.AppletWorker',
+ $classpath : "aria.jsunit.AppletWorker",
$singleton : true,
$constructor : function () {
this._applet = null;
View
10 src/aria/jsunit/IOViewer.js
@@ -14,12 +14,10 @@
*/
/**
- * @class aria.jsunit.IOViewer HTML UI Renderer for aria.core.IO
- * @extends aria.core.JsObject
- * @singleton
+ * HTML UI Renderer for aria.core.IO
*/
Aria.classDefinition({
- $classpath : 'aria.jsunit.IOViewer',
+ $classpath : "aria.jsunit.IOViewer",
$singleton : true,
$constructor : function () {
this._outputDiv = null; // reference to the DOM output div
@@ -35,7 +33,7 @@ Aria.classDefinition({
* Id of the DIV element to use as output container Can be changed by the user before run() is called
* @type String
*/
- outputDivId : '_IOViewerOutput_',
+ outputDivId : "_IOViewerOutput_",
/**
* Main function to display the IO report. If no div corresponding to outputDivId is found in the DOM, a new DIV
@@ -116,4 +114,4 @@ Aria.classDefinition({
this._outputDiv.innerHTML = h.join('');
}
}
-});
+});
View
5 src/aria/jsunit/JsCoverageReport.js
@@ -16,13 +16,10 @@
(function () {
/**
* Generate an HTML report from the data contained in an instance of aria.jsunit.JsCoverage
- * @class aria.jsunit.JsCoverageReport
- * @extends aria.jsunit.Report
*/
var classDefinition = {
- $classpath : 'aria.jsunit.JsCoverageReport',
+ $classpath : "aria.jsunit.JsCoverageReport",
$singleton : false,
- $dependencies : [],
$constructor : function (conf) {
this.jsCoverage = conf.jsCoverage || {};
/**
View
9 src/aria/jsunit/MultiSelectTemplateTestCase.js
@@ -16,15 +16,10 @@
/**
* Class to be extended to create a template test case that tests the multiselect widget. Provides utility methods
* related to multiselect.
- * @class aria.jsunit.MultiSelectTemplateTestCase
- * @extends aria.jsunit.TemplateTestCase
*/
Aria.classDefinition({
- $classpath : 'aria.jsunit.MultiSelectTemplateTestCase',
- $extends : 'aria.jsunit.TemplateTestCase',
- $constructor : function () {
- this.$TemplateTestCase.constructor.call(this);
- },
+ $classpath : "aria.jsunit.MultiSelectTemplateTestCase",
+ $extends : "aria.jsunit.TemplateTestCase",
$prototype : {
/**
View
3 src/aria/jsunit/ScreenCapture.js
@@ -1,3 +1,4 @@
+/* jshint maxparams:7 */
/*
* Copyright 2012 Amadeus s.a.s.
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -28,8 +29,6 @@
* <pre>
* var sc = new ScreenCapture('myTestApplet');
* </pre>
- *
- * @class aria.jsunit.ScreenCapture
*/
Aria.classDefinition({
$classpath : 'aria.jsunit.ScreenCapture',
View
5 src/aria/jsunit/SynEvents.js
@@ -16,13 +16,12 @@
/**
* Layer on top of aria.jsunit.Robot to allow higher-level input (involving DOM elements). (This class is still
* experimental currently, and is marked private for that reason)
- * @class aria.jsunit.SynEvents
* @private
*/
Aria.classDefinition({
- $classpath : 'aria.jsunit.SynEvents',
+ $classpath : "aria.jsunit.SynEvents",
$singleton : true,
- $dependencies : ['aria.jsunit.Robot'],
+ $dependencies : ["aria.jsunit.Robot"],
$constructor : function () {
this._robot = aria.jsunit.Robot;
},
View
57 src/aria/jsunit/TestWrapper.js
@@ -141,39 +141,40 @@ Aria.classDefinition({
* Dispose the framework in the iframe if possible and remove then the iframe.
*/
_removeFrame : function () {
- if (this._frame) {
- // Here, we are using Aria["eval"] in the sub window because otherwise, any exception raised by the test
- // $dispose method or Aria.dispose cannot be caught on IE7
- if (this._subWindow.Aria && this._subWindow.Aria["eval"]) {
- var disposeResult = this._subWindow.Aria["eval"]("(function () { try { if (this._testInstance) {this._testInstance.$dispose();} return Aria.dispose(); } catch (e) { return { error: e }; }}).call(arguments[2])", null, this);
- this._testInstance = null;
- if (disposeResult) {
- if (disposeResult.error) {
- this.raiseError(disposeResult.error, "An exception occurred while disposing the test or the framework.");
- } else if (disposeResult.nbNotDisposed !== 0) {
- var undisposed = disposeResult.notDisposed;
- var msg = ["There were ", disposeResult.nbNotDisposed, " undisposed objects ("];
- var first = true;
- for (var i in undisposed) {
- if (undisposed.hasOwnProperty(i)) {
- if (first) {
- first = false;
- } else {
- msg.push(", ");
- }
- msg.push(undisposed[i].$classpath);
+ if (!this._frame) {
+ return;
+ }
+ // Here, we are using Aria["eval"] in the sub window because otherwise, any exception raised by the test
+ // $dispose method or Aria.dispose cannot be caught on IE7
+ if (this._subWindow.Aria && this._subWindow.Aria["eval"]) {
+ var disposeResult = this._subWindow.Aria["eval"]("(function () { try { if (this._testInstance) {this._testInstance.$dispose();} return Aria.dispose(); } catch (e) { return { error: e }; }}).call(arguments[2])", null, this);
+ this._testInstance = null;
+ if (disposeResult) {
+ if (disposeResult.error) {
+ this.raiseError(disposeResult.error, "An exception occurred while disposing the test or the framework.");
+ } else if (disposeResult.nbNotDisposed !== 0) {
+ var undisposed = disposeResult.notDisposed;
+ var msg = ["There were ", disposeResult.nbNotDisposed, " undisposed objects ("];
+ var first = true;
+ for (var i in undisposed) {
+ if (undisposed.hasOwnProperty(i)) {
+ if (first) {
+ first = false;
+ } else {
+ msg.push(", ");
}
+ msg.push(undisposed[i].$classpath);
}
- msg.push(")");
- this.raiseFailure(msg.join(''));
}
+ msg.push(")");
+ this.raiseFailure(msg.join(''));
}
}
- var body = Aria.$window.document.body;
- body.removeChild(this._frame);
- this._subWindow = null;
- this._frame = null;
}
+ var body = Aria.$window.document.body;
+ body.removeChild(this._frame);
+ this._subWindow = null;
+ this._frame = null;
},
/**
@@ -185,4 +186,4 @@ Aria.classDefinition({
}
}
-});
+});
View
1 src/aria/node.js
@@ -1,3 +1,4 @@
+/* global Aria:true, aria:true */
var vm = require("vm"), fs = require("fs"), path = require("path");
/* aria and Aria are going to be global */
View
1 src/aria/utils/FireDomEvent.js
@@ -1,3 +1,4 @@
+/* jshint maxparams:false */
/*
* Copyright 2012 Amadeus s.a.s.
* Licensed under the Apache License, Version 2.0 (the "License");
View
2 src/aria/utils/validators/Object.js
@@ -34,4 +34,4 @@ Aria.classDefinition({
return this._validationFailed();
}
}
-});
+});
View
7 src/aria/widgets/AriaSkinInterface.js
@@ -1,3 +1,4 @@
+/* jshint maxdepth:9 */
/*
* Copyright 2012 Amadeus s.a.s.
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -17,10 +18,10 @@
* A class that provides an interface to the AriaSkin object that comes from the skinning system.
*/
Aria.classDefinition({
- $classpath : 'aria.widgets.AriaSkinInterface',
+ $classpath : "aria.widgets.AriaSkinInterface",
$singleton : true,
- $dependencies : ['aria.core.JsonValidator', 'aria.widgets.AriaSkinBeans', 'aria.widgets.AriaSkinNormalization',
- 'aria.core.DownloadMgr'],
+ $dependencies : ["aria.core.JsonValidator", "aria.widgets.AriaSkinBeans", "aria.widgets.AriaSkinNormalization",
+ "aria.core.DownloadMgr"],
$statics : {
// ERROR MESSAGES:
WIDGET_SKIN_CLASS_OBJECT_NOT_FOUND : "There is no skin configuration for skin class %1 of widget %2. Skin class std will be used instead. The widget will probably not be displayed correctly."
View
1,335 src/aria/widgets/Widget.js
@@ -13,726 +13,721 @@
* limitations under the License.
*/
-(function () {
-
- // shorcuts
- var delegateManager = null;
- var jsonUtils = null;
+/**
+ * Base Widget class from which all widgets must derive
+ */
+Aria.classDefinition({
+ $classpath : "aria.widgets.Widget",
+ $extends : "aria.widgetLibs.BindableWidget",
+ $dependencies : ["aria.widgets.CfgBeans", "aria.utils.Json", "aria.utils.Dom", "aria.DomEvent",
+ "aria.utils.Delegate", "aria.widgets.AriaSkinInterface", "aria.utils.Type",
+ "aria.templates.RefreshManager"],
+ $css : ["aria.widgets.GlobalStyle"],
+ $onload : function () {
+ // check for skin existency
+ if (!aria.widgets.AriaSkin) {
+ this.$JsObject.$logError.call(this, this.SKIN_NOT_READY);
+ }
+ },
/**
- * Base Widget class from which all widgets must derive
+ * Widget constructor
+ * @param {aria.widgets.CfgBeans.WidgetCfg} cfg the widget configuration
+ * @param {aria.templates.TemplateCtxt} ctxt template context
+ * @param {Number} lineNumber line number in current template
*/
- Aria.classDefinition({
- $classpath : "aria.widgets.Widget",
- $extends : "aria.widgetLibs.BindableWidget",
- $dependencies : ["aria.widgets.CfgBeans", "aria.utils.Json", "aria.utils.Dom", "aria.DomEvent",
- "aria.utils.Delegate", "aria.widgets.AriaSkinInterface", "aria.utils.Type",
- "aria.templates.RefreshManager"],
- $css : ["aria.widgets.GlobalStyle"],
- $onload : function () {
- delegateManager = aria.utils.Delegate;
- jsonUtils = aria.utils.Json;
-
- // check for skin existency
- if (!aria.widgets.AriaSkin) {
- this.$JsObject.$logError.call(this, this.SKIN_NOT_READY);
+ $constructor : function (cfg, context, lineNumber) {
+ // if cfg is not defined, make it an object
+ cfg = (!cfg) ? {} : cfg;
+
+ this.$BindableWidget.constructor.call(this, cfg, context, lineNumber);
+
+ this.$assert(18, context && context.$getId);
+
+ /**
+ * Reference to the dom element
+ * @protected
+ * @type {DOMElement}
+ */
+ this._domElt = null;
+
+ /**
+ * Default margin for widget
+ * @protected
+ * @type {Number}
+ */
+ this._defaultMargin = 1;
+
+ /**
+ * Does this widget needs the default markup
+ * @protected
+ * @Boolean
+ */
+ this._hasMarkup = true;
+
+ /**
+ * Specify if this widget is differed in it's rendering
+ * @type Boolean
+ */
+ this.isDiffered = false;
+
+ /**
+ * Delegate id for this widget
+ * @protected
+ * @type String
+ */
+ this._delegateId = null;
+
+ /**
+ * Flag to check if initialization of widget has been done
+ * @protected
+ * @type Boolean
+ */
+ this._initDone = false;
+
+ /**
+ * Flag to check if dom for this widget have been injected (in fact only check that it has been produced)
+ * @protected
+ * @type Boolean
+ */
+ this._domReady = false;
+
+ /**
+ * Maps of parameter to update with old and new value when refresh manager is stopped.
+ * @protected
+ * @type Object
+ */
+ this._refreshMap = null;
+
+ /**
+ * CSS classes which should be applied to this widget when it is created.
+ * @protected
+ * @type String
+ */
+ this._cssClassNames = "xWidget";
+
+ /**
+ * True if the widget is in the middle of an initialization triggered by a delegated content change event.
+ * @type Boolean
+ * @private
+ */
+ this.__initWhileContentChange = false;
+
+ this._cfgOk = aria.core.JsonValidator.validateCfg(this._cfgBean || this._cfgPackage + "." + this.$class + "Cfg", cfg);
+
+ var bindings = cfg.bind;
+ if (bindings) {
+ this._initBindings(bindings);
+ }
+
+ // check id
+ var id = cfg.id;
+ var domId;
+ if (id && id.indexOf('+') > -1) {
+ if (Aria.testMode) {
+ domId = this._context.$getAutoId(id);
}
- },
- $onunload : function () {
- delegateManager = null;
- jsonUtils = null;
- },
+ // From the application's point of view, an id with a '+' inside it is equivalent to no id at all.
+ // We only use the id with a '+' inside it to generate the id used in the DOM
+ delete cfg.id;
+ id = null;
+ }
+ this._domId = domId || (id ? this._context.$getId(id) : this._createDynamicId());
+ },
+ $destructor : function () {
+ this.removeDelegation();
+
+ if (this._tooltipWidget) {
+ this._tooltipWidget = null;
+ }
+ if (this._domElt) {
+ this._domElt.__widget = null;
+ }
+ this.$BindableWidget.$destructor.call(this);
+
+ this._domElt = null;
+ this._refreshMap = null;
+ this._context = null;
+ this._cfg = null;
+ },
+ $statics : {
+ // ERROR MESSAGES:
+ SKIN_NOT_READY : "CRITICAL ! There is no skin available, widgets can not be used. Check that the skin (css+js) is properly loaded.",
+ WIDGET_NOT_FOUND : "%1Following %3 widget was not found in DOM: %2",
+ WIDGET_TOOLTIP_NOT_FOUND : "%1Tooltip with id '%2', for widget %3 was not found in template '%4'.",
+ WIDGET_BINDING_ERROR : "%1Binding failed in widget: \tInside:%2\tTo:%3",
+ WIDGET_PROPERTY_DEPRECATION : "%1The following property is deprecated and will be removed from the framework in the near future. Refactor your code to avoid any issues. Property:'%2'.",
+ INVALID_VERTICAL_ALIGN : "%1Invalid verticalAlign:'%2'.",
+
+ verticalAlignTester : /^[%a-z0-9-]*$/
+ },
+ $prototype : {
/**
- * Widget constructor
- * @param {aria.widgets.CfgBeans.WidgetCfg} cfg the widget configuration
- * @param {aria.templates.TemplateCtxt} ctxt template context
- * @param {Number} lineNumber line number in current template
- */
- $constructor : function (cfg, context, lineNumber) {
- // if cfg is not defined, make it an object
- cfg = (!cfg) ? {} : cfg;
-
- this.$BindableWidget.constructor.call(this, cfg, context, lineNumber);
-
- this.$assert(18, context && context.$getId);
-
- /**
- * Reference to the dom element
- * @protected
- * @type {DOMElement}
- */
- this._domElt = null;
-
- /**
- * Default margin for widget
- * @protected
- * @type {Number}
- */
- this._defaultMargin = 1;
-
- /**
- * Does this widget needs the default markup
- * @protected
- * @Boolean
- */
- this._hasMarkup = true;
-
- /**
- * Specify if this widget is differed in it's rendering
- * @type Boolean
- */
- this.isDiffered = false;
-
- /**
- * Delegate id for this widget
- * @protected
- * @type String
- */
- this._delegateId = null;
-
- /**
- * Flag to check if initialization of widget has been done
- * @protected
- * @type Boolean
- */
- this._initDone = false;
-
- /**
- * Flag to check if dom for this widget have been injected (in fact only check that it has been produced)
- * @protected
- * @type Boolean
- */
- this._domReady = false;
-
- /**
- * Maps of parameter to update with old and new value when refresh manager is stopped.
- * @protected
- * @type Object
- */
- this._refreshMap = null;
+ * Classpath of the CfgBeans to use when validating the configuration of this widget.
+ * @type String
+ */
+ _cfgPackage : "aria.widgets.CfgBeans",
- /**
- * CSS classes which should be applied to this widget when it is created.
- * @protected
- * @type String
- */
- this._cssClassNames = "xWidget";
-
- /**
- * True if the widget is in the middle of an initialization triggered by a delegated content change event.
- * @type Boolean
- * @private
- */
- this.__initWhileContentChange = false;
-
- this._cfgOk = aria.core.JsonValidator.validateCfg(this._cfgBean || this._cfgPackage + "." + this.$class + "Cfg", cfg);
-
- var bindings = cfg.bind;
- if (bindings) {
- var bnd, inside, to, bindValue, transform;
- for (var bindedProperty in bindings) {
- if (bindings.hasOwnProperty(bindedProperty)) {
- bnd = bindings[bindedProperty];
- inside = bnd.inside;
- to = bnd.to;
- transform = bnd.transform;
- if (inside && (to || to === 0)) {
- // there is binding
- bindValue = inside[to];
-
- // Different behavior if the data bound to is defined or not.
- // Used to be able to set default value directly in cfg
- // without initializing data model before.
- if (typeof(bindValue) != "undefined") {
- if (transform) {
- // If we have a transform specified,
- // transform the datamodel value to widget value before storing into cfg
- bindValue = this._transform(transform, bindValue, "toWidget");
- if (typeof bindValue == "undefined") {
- // no bindValue available, skip this one
- continue;
- }
- }
- // set the computed value, to preserve configuration
- this._cfg[bindedProperty] = bindValue;
- } else {
- // If the property is explicitly set, transfer to data model
- if (typeof(this._cfg[bindedProperty]) != "undefined") {
- var valueToDataModel = this._transform(transform, this._cfg[bindedProperty], "fromWidget");
- jsonUtils.setValue(inside, to, valueToDataModel);
+ /**
+ * Widget Cfg Bean Classpath to use when validating the configuration for the widget.
+ * @type String
+ */
+ _cfgBean : null,
+
+ /**
+ * Flag for widget that get initialized right after being displayed (typically, templates)
+ * @protected
+ * @type Boolean
+ */
+ _directInit : false,
+
+ /**
+ * Initialize the binding description.
+ * @param {Array} bindings List of bindings
+ */
+ _initBindings : function (bindings) {
+ var bnd, inside, to, bindValue, transform, jsonUtils = aria.utils.Json;
+ for (var bindedProperty in bindings) {
+ if (bindings.hasOwnProperty(bindedProperty)) {
+ bnd = bindings[bindedProperty];
+ inside = bnd.inside;
+ to = bnd.to;
+ transform = bnd.transform;
+ if (inside && (to || to === 0)) {
+ // there is binding
+ bindValue = inside[to];
+
+ // Different behavior if the data bound to is defined or not.
+ // Used to be able to set default value directly in cfg
+ // without initializing data model before.
+ if (typeof(bindValue) != "undefined") {
+ if (transform) {
+ // If we have a transform specified,
+ // transform the datamodel value to widget value before storing into cfg
+ bindValue = this._transform(transform, bindValue, "toWidget");
+ if (typeof bindValue == "undefined") {
+ // no bindValue available, skip this one
+ continue;
}
}
+ // set the computed value, to preserve configuration
+ this._cfg[bindedProperty] = bindValue;
+ } else {
+ // If the property is explicitly set, transfer to data model
+ if (typeof(this._cfg[bindedProperty]) != "undefined") {
+ var valueToDataModel = this._transform(transform, this._cfg[bindedProperty], "fromWidget");
+ aria.utils.Json.setValue(inside, to, valueToDataModel);
+ }
}
}
}
}
+ },
- // check id
- var id = cfg.id;
- var domId;
- if (id && id.indexOf('+') > -1) {
- if (Aria.testMode) {
- domId = this._context.$getAutoId(id);
- }
- // From the application's point of view, an id with a '+' inside it is equivalent to no id at all.
- // We only use the id with a '+' inside it to generate the id used in the DOM
- delete cfg.id;
- id = null;
+ /**
+ * Main widget entry-point called by the template objects to get the markup associated to a widget for
+ * non-container widgets
+ * @param {aria.templates.MarkupWriter} out
+ */
+ writeMarkup : function (out) {
+
+ if (this._cfgOk) {
+ if (this._hasMarkup) {
+ // call the begin method that is used also for container widgets
+ this.__markupBegin(out);
+ }
+ // internal markup
+ this._widgetMarkup(out);
+ if (this._hasMarkup) {
+ // call the end method that is used also for container widgets
+ this.__markupEnd(out);
+ }
+ this._domReady = true;
+ } else {
+ out.write('#ERROR#<span style="font-size:x-small"><br/>Widget: ' + this.$classpath + '<br/>Tpl:'
+ + this._context.tplClasspath + '<br/>Line: ' + this._lineNumber + '</span>');
}
- this._domId = domId || (id ? this._context.$getId(id) : this._createDynamicId());
},
- $destructor : function () {
- this.removeDelegation();
- if (this._tooltipWidget) {
- this._tooltipWidget = null;
- }
- if (this._domElt) {
- this._domElt.__widget = null;
+ /**
+ * Method called to write the begin markup for container widgets
+ * @param {aria.templates.MarkupWriter} out
+ */
+ writeMarkupBegin : function (out) {
+ if (this._cfgOk) {
+ if (this._hasMarkup) {
+ this.__markupBegin(out);
+ }
+ this._widgetMarkupBegin(out);
+ } else {
+ out.write('#ERROR - Begin#<span style:"font-size:x-small"><br/>Widget: ' + this.$classpath
+ + '<br/>Tpl:' + this._context.tplClasspath + '<br/>Line: ' + this._lineNumber + '</span>');
}
+ },
- this.$BindableWidget.$destructor.call(this);
+ /**
+ * Method called to write the end markup for container widgets
+ * @param {aria.templates.MarkupWriter} out
+ */
+ writeMarkupEnd : function (out) {
+ if (this._cfgOk) {
+ this._widgetMarkupEnd(out);
+ if (this._hasMarkup) {
+ this.__markupEnd(out);
+ }
+ this._domReady = true;
+ } else {
+ out.write('#ERROR - End#');
+ }
+ },
- this._domElt = null;
- this._refreshMap = null;
- this._context = null;
- this._cfg = null;
+ /**
+ * Return the id of the widget, if it should be referenced from the template scripts or other widgets.
+ * Called by the section when registering the widget (out.registerBehavior). This id is checked for unicity
+ * in aria.templates.Section.
+ * @return {String} id of the widget, as specified in the config
+ */
+ getId : function () {
+ // do not return dynamic ids, as they don't need to be checked for unicity
+ // and they are not known outside the widget
+ return this._cfg.id;
},
- $statics : {
- // ERROR MESSAGES:
- SKIN_NOT_READY : "CRITICAL ! There is no skin available, widgets can not be used. Check that the skin (css+js) is properly loaded.",
- WIDGET_NOT_FOUND : "%1Following %3 widget was not found in DOM: %2",
- WIDGET_TOOLTIP_NOT_FOUND : "%1Tooltip with id '%2', for widget %3 was not found in template '%4'.",
- WIDGET_BINDING_ERROR : "%1Binding failed in widget: \tInside:%2\tTo:%3",
- WIDGET_PROPERTY_DEPRECATION : "%1The following property is deprecated and will be removed from the framework in the near future. Refactor your code to avoid any issues. Property:'%2'.",
- INVALID_VERTICAL_ALIGN : "%1Invalid verticalAlign:'%2'.",
-
- verticalAlignTester : /^[%a-z0-9-]*$/
+
+ /**
+ * Method to write the end markup
+ * @private
+ * @param {aria.templates.MarkupWriter} out
+ */
+ __markupEnd : function (out) {
+ out.write('</span>');
},
- $prototype : {
- /**
- * Classpath of the CfgBeans to use when validating the configuration of this widget.
- * @type String
- */
- _cfgPackage : "aria.widgets.CfgBeans",
-
- /**
- * Widget Cfg Bean Classpath to use when validating the configuration for the widget.
- * @type String
- */
- _cfgBean : null,
-
- /**
- * Flag for widget that get initialized right after being displayed (typically, templates)
- * @protected
- * @type Boolean
- */
- _directInit : false,
-
- /**
- * Main widget entry-point called by the template objects to get the markup associated to a widget for
- * non-container widgets
- * @param {aria.templates.MarkupWriter} out
- */
- writeMarkup : function (out) {
-
- if (this._cfgOk) {
- if (this._hasMarkup) {
- // call the begin method that is used also for container widgets
- this.__markupBegin(out);
- }
- // internal markup
- this._widgetMarkup(out);
- if (this._hasMarkup) {
- // call the end method that is used also for container widgets
- this.__markupEnd(out);
- }
- this._domReady = true;
- } else {
- out.write('#ERROR#<span style="font-size:x-small"><br/>Widget: ' + this.$classpath + '<br/>Tpl:'
- + this._context.tplClasspath + '<br/>Line: ' + this._lineNumber + '</span>');
- }
- },
-
- /**
- * Method called to write the begin markup for container widgets
- * @param {aria.templates.MarkupWriter} out
- */
- writeMarkupBegin : function (out) {
- if (this._cfgOk) {
- if (this._hasMarkup) {
- this.__markupBegin(out);
- }
- this._widgetMarkupBegin(out);
+
+ /**
+ * Method to write the begin markup
+ * @private
+ * @param {aria.templates.MarkupWriter} out
+ */
+ __markupBegin : function (out) {
+ var cfg = this._cfg, cssClasses = aria.core.TplClassLoader.addPrintOptions(this._cssClassNames, cfg.printOptions);
+ var delegateManager = aria.utils.Delegate;
+ if (cfg.block) {
+ cssClasses += " xBlock";
+ }
+
+ this._checkCfgConsistency();
+
+ // widget markup begin
+ out.write('<span id="' + this._domId + '" ');
+
+ // Tag the span for event delegation. delegateId might be defined by someone else
+ if (!this._delegateId) {
+ this._delegateId = delegateManager.add({
+ fn : this.delegate,
+ scope : this
+ });
+ }
+
+ out.write(delegateManager.getMarkup(this._delegateId) + " ");
+
+ out.write('class="' + cssClasses + '" ');
+
+ out.write('style="');
+ if (this._spanStyle != null) {
+ out.write(this._spanStyle);
+ }
+ if (cfg.width > -1) {
+ out.write('width:' + cfg.width + 'px;');
+ }
+ if (cfg.height != null && cfg.height != -1) {
+ out.write('height:' + cfg.height + 'px;');
+ }
+ if (cfg.verticalAlign != null) {
+ if (this.verticalAlignTester.test(cfg.verticalAlign)) {
+ out.write('vertical-align:' + cfg.verticalAlign + ';');
} else {
- out.write('#ERROR - Begin#<span style:"font-size:x-small"><br/>Widget: ' + this.$classpath
- + '<br/>Tpl:' + this._context.tplClasspath + '<br/>Line: ' + this._lineNumber + '</span>');
+ this.$logError(this.INVALID_VERTICAL_ALIGN, [cfg.verticalAlign]);
}
- },
-
- /**
- * Method called to write the end markup for container widgets
- * @param {aria.templates.MarkupWriter} out
- */
- writeMarkupEnd : function (out) {
- if (this._cfgOk) {
- this._widgetMarkupEnd(out);
- if (this._hasMarkup) {
- this.__markupEnd(out);
- }
- this._domReady = true;
+ }
+ if (cfg.margins != null && cfg.margins.match(/^(\d+|x) (\d+|x) (\d+|x) (\d+|x)$/)) {
+ var margins = cfg.margins.split(" ");
+ out.write(['margin:', margins[0] === "x" ? this._defaultMargin : margins[0], 'px ',
+ margins[1] === "x" ? this._defaultMargin : margins[1], 'px ',
+ margins[2] === "x" ? this._defaultMargin : margins[2], 'px ',
+ margins[3] === "x" ? this._defaultMargin : margins[3], 'px;" '].join(''));
+ } else {
+ out.write('margin:' + this._defaultMargin + 'px;" ');
+ }
+ if (cfg.tooltip) {
+ out.write('title="' + cfg.tooltip + '" ');
+ }
+ if (cfg.tabIndex != null && !this._customTabIndexProvided && !cfg.disabled) {
+ var tabIndex = this._calculateTabIndex();
+ out.write('tabindex="' + tabIndex + '" ');
+ }
+ out.write('>'); // end of main span.
+ },
+
+ /**
+ * Calculates the real tab index from configuration parameters given to the widget. Only valid to call if
+ * baseTabIndex and tabIndex are correctly set, otherwise method will return -1.
+ * @protected
+ * @return {Number}
+ */
+ _calculateTabIndex : function () {
+ var retVal = -1;
+ if (this._context && this._context._cfg && this._context._cfg.baseTabIndex >= 0) {
+ if (this._cfg.tabIndex > 0) {
+ retVal = this._context._cfg.baseTabIndex + this._cfg.tabIndex;
} else {
- out.write('#ERROR - End#');
- }
- },
-
- /**
- * Return the id of the widget, if it should be referenced from the template scripts or other widgets.
- * Called by the section when registering the widget (out.registerBehavior). This id is checked for unicity
- * in aria.templates.Section.
- * @return {String} id of the widget, as specified in the config
- */
- getId : function () {
- // do not return dynamic ids, as they don't need to be checked for unicity
- // and they are not known outside the widget
- return this._cfg.id;
- },
-
- /**
- * Method to write the end markup
- * @private
- * @param {aria.templates.MarkupWriter} out
- */
- __markupEnd : function (out) {
- out.write('</span>');
- },
-
- /**
- * Method to write the begin markup
- * @private
- * @param {aria.templates.MarkupWriter} out
- */
- __markupBegin : function (out) {
- var cfg = this._cfg, cssClasses = aria.core.TplClassLoader.addPrintOptions(this._cssClassNames, cfg.printOptions);
- if (cfg.block) {
- cssClasses += " xBlock";
+ retVal = this._cfg.tabIndex;
}
+ }
+ return retVal;
+ },
- this._checkCfgConsistency();
+ /**
+ * Internal function to override to generate the internal widget markup
+ * @protected
+ * @param {aria.templates.MarkupWriter} out
+ */
+ _widgetMarkup : function (out) {},
- // widget markup begin
- out.write('<span id="' + this._domId + '" ');
+ /**
+ * Internal function to override to generate the internal widget begin markup
+ * @protected
+ * @param {aria.templates.MarkupWriter} out
+ */
+ _widgetMarkupBegin : function (out) {},
- // Tag the span for event delegation. delegateId might be defined by someone else
- if (!this._delegateId) {
- this._delegateId = delegateManager.add({
- fn : this.delegate,
- scope : this
- });
- }
+ /**
+ * Internal function to override to generate the internal widget end markup
+ * @protected
+ * @param {aria.templates.MarkupWriter} out
+ */
+ _widgetMarkupEnd : function (out) {},
- out.write(delegateManager.getMarkup(this._delegateId) + " ");
+ /**
+ * Internal function called before markup generation to check the widget configuration consistency (e.g.
+ * make sure that the label width is less than the widget width, etc..) When called the cfg structure has
+ * already been normalized from its bean definition Note: this method must be overridden if extra-checks
+ * have to be made in sub-widgets
+ * @protected
+ * @param {aria.widgets.CfgBeans.WidgetCfg} cfg
+ */
+ _checkCfgConsistency : function () {},
- out.write('class="' + cssClasses + '" ');
+ /**
+ * Associate the tooltip widget to this widget.
+ * @protected
+ */
+ _linkToTooltipWidget : function () {
+ var tooltipId = this._cfg.tooltipId;
+ if (!tooltipId) {
+ return;
+ }
+ var tooltipWidget = this._context.getBehaviorById(tooltipId);
+ if (!tooltipWidget) {
+ this.$logError(this.WIDGET_TOOLTIP_NOT_FOUND, [tooltipId, this.$class, this._context.tplClasspath]);
+ return;
+ }
+ this._tooltipWidget = tooltipWidget;
+ },
- out.write('style="');
- if (this._spanStyle != null) {
- out.write(this._spanStyle);
- }
- if (cfg.width > -1) {
- out.write('width:' + cfg.width + 'px;');
- }
- if (cfg.height != null && cfg.height != -1) {
- out.write('height:' + cfg.height + 'px;');
- }
- if (cfg.verticalAlign != null) {
- if (this.verticalAlignTester.test(cfg.verticalAlign)) {
- out.write('vertical-align:' + cfg.verticalAlign + ';');
- } else {
- this.$logError(this.INVALID_VERTICAL_ALIGN, [cfg.verticalAlign]);
- }
- }
- if (cfg.margins != null && cfg.margins.match(/^(\d+|x) (\d+|x) (\d+|x) (\d+|x)$/)) {
- var margins = cfg.margins.split(" ");
- out.write(['margin:', margins[0] === "x" ? this._defaultMargin : margins[0], 'px ',
- margins[1] === "x" ? this._defaultMargin : margins[1], 'px ',
- margins[2] === "x" ? this._defaultMargin : margins[2], 'px ',
- margins[3] === "x" ? this._defaultMargin : margins[3], 'px;" '].join(''));
- } else {
- out.write('margin:' + this._defaultMargin + 'px;" ');
- }
- if (cfg.tooltip) {
- out.write('title="' + cfg.tooltip + '" ');
- }
- if (cfg.tabIndex != null && !this._customTabIndexProvided && !cfg.disabled) {
- var tabIndex = this._calculateTabIndex();
- out.write('tabindex="' + tabIndex + '" ');
- }
- out.write('>'); // end of main span.
- },
-
- /**
- * Calculates the real tab index from configuration parameters given to the widget. Only valid to call if
- * baseTabIndex and tabIndex are correctly set, otherwise method will return -1.
- * @protected
- * @return {Number}
- */
- _calculateTabIndex : function () {
- var retVal = -1;
- if (this._context && this._context._cfg && this._context._cfg.baseTabIndex >= 0) {
- if (this._cfg.tabIndex > 0) {
- retVal = this._context._cfg.baseTabIndex + this._cfg.tabIndex;
- } else {
- retVal = this._cfg.tabIndex;
- }
- }
- return retVal;
- },
-
- /**
- * Internal function to override to generate the internal widget markup
- * @protected
- * @param {aria.templates.MarkupWriter} out
- */
- _widgetMarkup : function (out) {},
-
- /**
- * Internal function to override to generate the internal widget begin markup
- * @protected
- * @param {aria.templates.MarkupWriter} out
- */
- _widgetMarkupBegin : function (out) {},
-
- /**
- * Internal function to override to generate the internal widget end markup
- * @protected
- * @param {aria.templates.MarkupWriter} out
- */
- _widgetMarkupEnd : function (out) {},
-
- /**
- * Internal function called before markup generation to check the widget configuration consistency (e.g.
- * make sure that the label width is less than the widget width, etc..) When called the cfg structure has
- * already been normalized from its bean definition Note: this method must be overridden if extra-checks
- * have to be made in sub-widgets
- * @protected
- * @param {aria.widgets.CfgBeans.WidgetCfg} cfg
- */
- _checkCfgConsistency : function () {},
-
- /**
- * Associate the tooltip widget to this widget.
- * @protected
- */
- _linkToTooltipWidget : function () {
- var tooltipId = this._cfg.tooltipId;
- if (!tooltipId) {
- return;
- }
- var tooltipWidget = this._context.getBehaviorById(tooltipId);
- if (!tooltipWidget) {
- this.$logError(this.WIDGET_TOOLTIP_NOT_FOUND, [tooltipId, this.$class, this._context.tplClasspath]);
- return;
- }
- this._tooltipWidget = tooltipWidget;
- },
-
- /**
- * Handler for mouse move event, to deal with tooltip.
- * @protected
- * @param {aria.DomEvent} domEvt
- */
- _dom_onmousemove : function (domEvt) {
- if (this._tooltipWidget) {
- this._tooltipWidget.associatedWidgetMouseMove(this, domEvt);
- domEvt.$dispose();
- }
- },
-
- /**
- * Handler for mouse over event, to deal with tooltip.
- * @protected
- * @param {aria.DomEvent} domEvt
- */
- _dom_onmouseover : function (domEvt) {
- if (this._tooltipWidget) {
- this._tooltipWidget.associatedWidgetMouseOver(this, domEvt);
- domEvt.$dispose();
- }
- },
-
- /**
- * Handler for mouse out event, to deal with tooltip.
- * @protected
- * @param {aria.DomEvent} domEvt
- */
- _dom_onmouseout : function (domEvt) {
- if (this._tooltipWidget) {
- this._tooltipWidget.associatedWidgetMouseOut(this, domEvt);
- domEvt.$dispose();
- }
- },
-
- /**
- * Initialization method called by the delegate engine when the DOM is loaded
- */
- initWidget : function () {
- this._linkToTooltipWidget();
- this._registerBindings();
- if (this._directInit && this._hasMarkup) {
- this.initWidgetDom();
- }
- },
-
- /**
- * Initialize link between widget and DOM. Called when an access to dom is first required.
- * @param {HTMLElement} dom
- */
- initWidgetDom : function (dom) {
- this._initDone = true;
+ /**
+ * Handler for mouse move event, to deal with tooltip.
+ * @protected
+ * @param {aria.DomEvent} domEvt
+ */
+ _dom_onmousemove : function (domEvt) {
+ if (this._tooltipWidget) {
+ this._tooltipWidget.associatedWidgetMouseMove(this, domEvt);
+ domEvt.$dispose();
+ }
+ },
+
+ /**
+ * Handler for mouse over event, to deal with tooltip.
+ * @protected
+ * @param {aria.DomEvent} domEvt
+ */
+ _dom_onmouseover : function (domEvt) {
+ if (this._tooltipWidget) {
+ this._tooltipWidget.associatedWidgetMouseOver(this, domEvt);
+ domEvt.$dispose();
+ }
+ },
+
+ /**
+ * Handler for mouse out event, to deal with tooltip.
+ * @protected
+ * @param {aria.DomEvent} domEvt
+ */
+ _dom_onmouseout : function (domEvt) {
+ if (this._tooltipWidget) {
+ this._tooltipWidget.associatedWidgetMouseOut(this, domEvt);
+ domEvt.$dispose();
+ }
+ },
+
+ /**
+ * Initialization method called by the delegate engine when the DOM is loaded
+ */
+ initWidget : function () {
+ this._linkToTooltipWidget();
+ this._registerBindings();
+ if (this._directInit && this._hasMarkup) {
+ this.initWidgetDom();
+ }
+ },
+
+ /**
+ * Initialize link between widget and DOM. Called when an access to dom is first required.
+ * @param {HTMLElement} dom
+ */
+ initWidgetDom : function (dom) {
+ this._initDone = true;
+ if (!dom) {
+ dom = aria.utils.Dom.getElementById(this._domId);
if (!dom) {
- dom = aria.utils.Dom.getElementById(this._domId);
- if (!dom) {
- this.$logError(this.WIDGET_NOT_FOUND, [this._domId, this.$class]);
- }
- }
- dom.__widget = this;
- this._domElt = dom;
- this._init();
- },
-
- /**
- * Internal method to override to initialize a widget when DOM is available
- * @protected
- */
- _init : function () {},
-
- /**
- * Set and propagate bindable property changes in JSON data if applicable. This method must be called
- * internally by widgets when one of their property changes (e.g. field value for a TextField)
- * @param {String} propertyName
- * @param {Multitype} newValue If transformation is used, this should be the widget value and not the data
- * model value
- * @return {Object} null if the property did not change or if no binding is defined (there is no way to get
- * the previous value) or an {oldValue:'',newValue:''} object if property changed
- */
- setProperty : function (propertyName, newValue) {
-
- var structureValue;
-
- if (!this._cfg) {
- return null;
+ this.$logError(this.WIDGET_NOT_FOUND, [this._domId, this.$class]);
}
+ }
+ dom.__widget = this;
+ this._domElt = dom;
+ this._init();
+ },
- var bnds = this._cfg.bind;
- // note that oldValue can be equal to newValue in case setWidgetProperty has already been called before
- // (happens when calling changeProperty)
- var oldValue = this.getProperty(propertyName);
+ /**
+ * Internal method to override to initialize a widget when DOM is available
+ * @protected
+ */
+ _init : function () {},
- this._cfg[propertyName] = newValue;
+ /**
+ * Set and propagate bindable property changes in JSON data if applicable. This method must be called
+ * internally by widgets when one of their property changes (e.g. field value for a TextField)
+ * @param {String} propertyName
+ * @param {Multitype} newValue If transformation is used, this should be the widget value and not the data
+ * model value
+ * @return {Object} null if the property did not change or if no binding is defined (there is no way to get
+ * the previous value) or an {oldValue:'',newValue:''} object if property changed
+ */
+ setProperty : function (propertyName, newValue) {
- if (bnds) {
- var target = bnds[propertyName];
- if (target) {
- var holder = target.inside;
- var nm = target.to;
- var transform = target.transform;
- if (holder && (nm || nm === 0)) {
- structureValue = this._transform(transform, newValue, "fromWidget");
- var listener = this._bindingListeners[propertyName];
- jsonUtils.setValue(holder, nm, structureValue, listener ? listener.cb : null);
- }
+ var structureValue;
+
+ if (!this._cfg) {
+ return null;
+ }
+
+ var bnds = this._cfg.bind;
+ // note that oldValue can be equal to newValue in case setWidgetProperty has already been called before
+ // (happens when calling changeProperty)
+ var oldValue = this.getProperty(propertyName);
+
+ this._cfg[propertyName] = newValue;
+
+ if (bnds) {
+ var target = bnds[propertyName];
+ if (target) {
+ var holder = target.inside;
+ var nm = target.to;
+ var transform = target.transform;
+ if (holder && (nm || nm === 0)) {
+ structureValue = this._transform(transform, newValue, "fromWidget");
+ var listener = this._bindingListeners[propertyName];
+ aria.utils.Json.setValue(holder, nm, structureValue, listener ? listener.cb : null);
}
}
+ }
- if (oldValue !== newValue) {
- return {
- oldValue : oldValue,
- newValue : newValue
- };
- }
- },
-
- /**
- * Set property for this widget, and reflect change on itself, but not in the associated datamodel
- * @param {String} propertyName in the configuration
- * @param {Object} newValue to set
- */
- setWidgetProperty : function (propertyName, newValue) {
- if (!this._cfg) {
- return;
- }
- var oldValue = this.getProperty(propertyName);
- if (newValue != oldValue) {
- this._cfg[propertyName] = newValue;
- this._onBoundPropertyChange(propertyName, newValue, oldValue);
- }
- },
-
- /**
- * Set the property in the JSON model and reflect the change in the widget (setProperty() only changes the
- * value in the JSON model)
- * @param {String} propertyName
- * @param {Object} newValue. Refers to the widget value and not the data model value (transformers may
- * apply)
- */
- changeProperty : function (propertyName, newValue) {
- if (!this._cfg) {
- return;
- }
- // setWidgetProperty must be called before setProperty
- // otherwise _onBoundPropertyChange is not called
- // (as both setWidgetProperty and setProperty change this._cfg[propertyName])
- this.setWidgetProperty(propertyName, newValue);
- this.setProperty(propertyName, newValue);
- },
-
- /**
- * Get the value of a configuration property, or its new value if it has changed
- * @param {String} propertyName