Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added AMD loader, refs #12672 \!strict

  • Loading branch information...
commit 53066461009f23d96d10b26a50a617bba7ffa607 1 parent e90518a
@rcgill rcgill authored
Showing with 8,223 additions and 5,361 deletions.
  1. +6 −1 AdapterRegistry.js
  2. +6 −1 DeferredList.js
  3. +6 −1 NodeList-data.js
  4. +6 −1 NodeList-fx.js
  5. +6 −1 NodeList-html.js
  6. +6 −1 NodeList-manipulate.js
  7. +6 −1 NodeList-traverse.js
  8. +6 −1 Stateful.js
  9. +32 −37 _base/Color.js
  10. +58 −55 _base/Deferred.js
  11. +166 −170 _base/NodeList.js
  12. +1 −0  _base/_loader/bootstrap.js
  13. +1 −0  _base/_loader/loader.js
  14. +56 −73 _base/array.js
  15. +18 −18 _base/browser.js
  16. +154 −0 _base/config.js
  17. +89 −0 _base/configNode.js
  18. +131 −0 _base/configRhino.js
  19. +24 −20 _base/connect.js
  20. +29 −26 _base/declare.js
  21. +18 −20 _base/event.js
  22. +16 −19 _base/fx.js
  23. +199 −195 _base/html.js
  24. +7 −7 _base/json.js
  25. +436 −0 _base/kernel.js
  26. +43 −43 _base/lang.js
  27. +54 −0 _base/load.js
  28. +92 −0 _base/loader.js
  29. +172 −205 _base/query.js
  30. +192 −0 _base/sniff.js
  31. +76 −0 _base/unload.js
  32. +128 −0 _base/url.js
  33. +10 −6 _base/window.js
  34. +96 −58 _base/xhr.js
  35. +7 −36 _firebug/firebug.js
  36. +6 −1 back.js
  37. +6 −1 behavior.js
  38. +5 −111 cache.js
  39. +6 −1 cldr/monetary.js
  40. +6 −1 cldr/supplemental.js
  41. +6 −1 colors.js
  42. +6 −1 cookie.js
  43. +6 −1 currency.js
  44. +6 −1 data/ItemFileReadStore.js
  45. +6 −1 data/ItemFileWriteStore.js
  46. +6 −1 data/ObjectStore.js
  47. +6 −1 data/api/Identity.js
  48. +6 −1 data/api/Notification.js
  49. +6 −1 data/api/Read.js
  50. +6 −1 data/api/Request.js
  51. +6 −1 data/api/Write.js
  52. +6 −1 data/util/filter.js
  53. +6 −1 data/util/simpleFetch.js
  54. +6 −1 data/util/sorter.js
  55. +6 −1 date.js
  56. +7 −7 date/locale.js
  57. +6 −1 date/stamp.js
  58. +6 −1 dnd/Avatar.js
  59. +6 −1 dnd/Container.js
  60. +6 −1 dnd/Manager.js
  61. +6 −1 dnd/Moveable.js
  62. +6 −1 dnd/Mover.js
  63. +6 −1 dnd/Selector.js
  64. +6 −1 dnd/Source.js
  65. +6 −1 dnd/TimedMoveable.js
  66. +6 −1 dnd/autoscroll.js
  67. +6 −1 dnd/common.js
  68. +6 −1 dnd/move.js
  69. +1,596 −187 dojo.js
  70. +6 −1 fx.js
  71. +6 −1 fx/Toggler.js
  72. +6 −1 fx/easing.js
  73. +6 −1 gears.js
  74. +160 −0 has.js
  75. +6 −1 hash.js
  76. +6 −1 html.js
  77. +144 −244 i18n.js
  78. +6 −1 io/iframe.js
  79. +6 −1 io/script.js
  80. +6 −1 jaxer.js
  81. +2 −1  json.js
  82. +38 −0 main.js
  83. +6 −1 number.js
  84. +29 −19 package.json
  85. +56 −63 parser.js
  86. +6 −1 regexp.js
  87. +6 −1 rpc/JsonService.js
  88. +6 −1 rpc/JsonpService.js
  89. +6 −1 rpc/RpcService.js
  90. +6 −1 store/Cache.js
  91. +6 −1 store/DataStore.js
  92. +6 −1 store/JsonRest.js
  93. +6 −1 store/Memory.js
  94. +6 −1 store/Observable.js
  95. +6 −1 store/util/QueryResults.js
  96. +6 −1 store/util/SimpleQueryEngine.js
  97. +6 −1 string.js
  98. +3 −2 tests/AdapterRegistry.js
  99. +63 −70 tests/DeferredList.js
  100. +171 −178 tests/NodeList-data.html
  101. +5 −4 tests/NodeList-data.js
  102. +3 −7 tests/NodeList-fx.html
  103. +300 −307 tests/NodeList-manipulate.html
  104. +5 −4 tests/NodeList-manipulate.js
  105. +113 −120 tests/NodeList-traverse.html
  106. +5 −4 tests/NodeList-traverse.js
  107. +48 −52 tests/Stateful.js
  108. +28 −140 tests/_base.js
  109. +7 −11 tests/_base/NodeList.html
  110. +12 −11 tests/_base/declare.js
  111. +429 −433 tests/_base/fx.html
  112. +5 −4 tests/_base/fx.js
  113. +29 −32 tests/_base/html.html
  114. +13 −12 tests/_base/html.js
  115. +38 −41 tests/_base/html_box.html
  116. +38 −41 tests/_base/html_box_quirks.html
  117. +19 −20 tests/_base/html_docScroll.html
  118. +3 −6 tests/_base/html_element.html
  119. +4 −6 tests/_base/html_id.html
  120. +4 −6 tests/_base/html_isBodyLtr.html
  121. +3 −6 tests/_base/html_quirks.html
  122. +3 −6 tests/_base/html_rtl.html
  123. +10 −10 tests/_base/lang.js
  124. +11 −18 tests/_base/query.html
  125. +6 −5 tests/_base/query.js
  126. +4 −6 tests/_base/window.js
  127. +11 −10 tests/_base/xhr.html
  128. +5 −4 tests/_base/xhr.js
  129. +3 −7 tests/back-hash.js
  130. +5 −4 tests/back.js
  131. +1 −7 tests/baseonly.js
  132. +18 −23 tests/behavior.html
  133. +5 −4 tests/behavior.js
  134. +5 −9 tests/cache.js
  135. +5 −9 tests/cldr.js
  136. +37 −39 tests/colors.js
  137. +63 −69 tests/cookie.html
  138. +5 −4 tests/cookie.js
  139. +30 −48 tests/currency.js
  140. +6 −2 tests/data.js
  141. +5 −2 tests/data/ItemFileReadStore.js
  142. +43 −34 tests/data/ItemFileWriteStore.js
  143. +316 −315 tests/data/readOnlyItemFileTestTemplates.js
  144. +4 −4 tests/data/utils.js
  145. +4 −10 tests/date.js
  146. +7 −11 tests/fx.html
  147. +7 −5 tests/fx.js
  148. +4 −7 tests/hash.js
  149. +5 −4 tests/html.js
  150. +352 −361 tests/html/test_set.html
  151. +45 −133 tests/i18n.js
  152. +133 −139 tests/io/iframe.html
  153. +5 −4 tests/io/iframe.js
  154. +89 −98 tests/io/script.html
  155. +5 −4 tests/io/script.js
  156. +32 −36 tests/module.js
  157. +215 −216 tests/number.js
  158. +324 −326 tests/parser.html
  159. +5 −4 tests/parser.js
  160. +5 −6 tests/regexp.js
  161. +8 −12 tests/rpc.js
  162. +1 −1  tests/runTests.html
  163. +6 −2 tests/store.js
  164. +4 −6 tests/store/JsonRest.js
  165. +8 −8 tests/string.js
  166. +6 −7 tests/test_fx.html
  167. +5 −8 tests/uacss.js
  168. +3 −6 tests/uacss/sniffQuirks.html
  169. +3 −5 tests/uacss/sniffStandards.html
  170. +5 −11 tests/window.js
  171. +38 −39 tests/window/test_scroll.html
  172. +22 −29 tests/window/viewport.html
  173. +188 −0 text.js
  174. +26 −25 uacss.js
  175. +6 −1 window.js
View
7 AdapterRegistry.js
@@ -1,4 +1,9 @@
-define("dojo/AdapterRegistry", ["dojo"], function(dojo) {
+define(["."], function(dojo) {
+ // module:
+ // dojo/AdapterRegistry
+ // summary:
+ // TODOC:This module defines
+
dojo.AdapterRegistry = function(/*Boolean?*/ returnWrappers){
// summary:
View
7 DeferredList.js
@@ -1,4 +1,9 @@
-define("dojo/DeferredList", ["dojo"], function(dojo) {
+define(["."], function(dojo) {
+ // module:
+ // dojo/DeferredList
+ // summary:
+ // TODOC:This module defines
+
dojo.DeferredList = function(/*Array*/ list, /*Boolean?*/ fireOnOneCallback, /*Boolean?*/ fireOnOneErrback, /*Boolean?*/ consumeErrors, /*Function?*/ canceller){
// summary:
View
7 NodeList-data.js
@@ -1,4 +1,9 @@
-define("dojo/NodeList-data", ["dojo"], function(dojo) {
+define(["."], function(dojo) {
+ // module:
+ // dojo/NodeList-data
+ // summary:
+ // TODOC:This module defines
+
(function(d){
/*=====
View
7 NodeList-fx.js
@@ -1,4 +1,9 @@
-define("dojo/NodeList-fx", ["dojo", "dojo/fx"], function(dojo) {
+define([".", "./fx"], function(dojo) {
+ // module:
+ // dojo/NodeList-fx
+ // summary:
+ // TODOC:This module defines
+
/*=====
dojo["NodeList-fx"] = {
View
7 NodeList-html.js
@@ -1,4 +1,9 @@
-define("dojo/NodeList-html", ["dojo", "dojo/html"], function(dojo) {
+define([".", "./html"], function(dojo) {
+ // module:
+ // dojo/NodeList-html
+ // summary:
+ // TODOC:This module defines
+
/*=====
dojo["NodeList-html"] = {
View
7 NodeList-manipulate.js
@@ -1,4 +1,9 @@
-define("dojo/NodeList-manipulate", ["dojo"], function(dojo) {
+define(["."], function(dojo) {
+ // module:
+ // dojo/NodeList-manipulate
+ // summary:
+ // TODOC:This module defines
+
/*=====
dojo["NodeList-manipulate"] = {
View
7 NodeList-traverse.js
@@ -1,4 +1,9 @@
-define("dojo/NodeList-traverse", ["dojo"], function(dojo) {
+define(["."], function(dojo) {
+ // module:
+ // dojo/NodeList-traverse
+ // summary:
+ // TODOC:This module defines
+
/*=====
dojo["NodeList-traverse"] = {
View
7 Stateful.js
@@ -1,4 +1,9 @@
-define("dojo/Stateful", ["dojo"], function(dojo) {
+define(["."], function(dojo) {
+ // module:
+ // dojo/Stateful
+ // summary:
+ // TODOC:This module defines
+
dojo.declare("dojo.Stateful", null, {
// summary:
View
69 _base/Color.js
@@ -1,14 +1,10 @@
-define("dojo/_base/Color", ["dojo/lib/kernel", "dojo/_base/array", "dojo/_base/lang"], function(dojo){
-
-(function(){
-
- var d = dojo;
+define(["./kernel", "./array", "./lang"], function(dojo){
dojo.Color = function(/*Array|String|Object*/ color){
// summary:
- // Takes a named string, hex string, array of rgb or rgba values,
- // an object with r, g, b, and a properties, or another `dojo.Color` object
- // and creates a new Color instance to work from.
+ // Takes a named string, hex string, array of rgb or rgba values,
+ // an object with r, g, b, and a properties, or another `dojo.Color` object
+ // and creates a new Color instance to work from.
//
// example:
// Work with a Color instance:
@@ -27,26 +23,26 @@ define("dojo/_base/Color", ["dojo/lib/kernel", "dojo/_base/array", "dojo/_base/l
};
// FIXME:
- // there's got to be a more space-efficient way to encode or discover
- // these!! Use hex?
+ // there's got to be a more space-efficient way to encode or discover
+ // these!! Use hex?
dojo.Color.named = {
- black: [0,0,0],
- silver: [192,192,192],
- gray: [128,128,128],
- white: [255,255,255],
+ black: [0,0,0],
+ silver: [192,192,192],
+ gray: [128,128,128],
+ white: [255,255,255],
maroon: [128,0,0],
- red: [255,0,0],
+ red: [255,0,0],
purple: [128,0,128],
fuchsia: [255,0,255],
- green: [0,128,0],
- lime: [0,255,0],
+ green: [0,128,0],
+ lime: [0,255,0],
olive: [128,128,0],
yellow: [255,255,0],
- navy: [0,0,128],
- blue: [0,0,255],
+ navy: [0,0,128],
+ blue: [0,0,255],
teal: [0,128,128],
aqua: [0,255,255],
- transparent: d.config.transparentColor || [255,255,255]
+ transparent: dojo.config.transparentColor || [255,255,255]
};
dojo.extend(dojo.Color, {
@@ -63,13 +59,13 @@ define("dojo/_base/Color", ["dojo/lib/kernel", "dojo/_base/array", "dojo/_base/l
// example:
// | var c = new dojo.Color(); // no color
// | c.setColor("#ededed"); // greyish
- if(d.isString(color)){
- d.colorFromString(color, this);
- }else if(d.isArray(color)){
- d.colorFromArray(color, this);
+ if(dojo.isString(color)){
+ dojo.colorFromString(color, this);
+ }else if(dojo.isArray(color)){
+ dojo.colorFromArray(color, this);
}else{
this._set(color.r, color.g, color.b, color.a);
- if(!(color instanceof d.Color)){ this.sanitize(); }
+ if(!(color instanceof dojo.Color)){ this.sanitize(); }
}
return this; // dojo.Color
},
@@ -86,7 +82,7 @@ define("dojo/_base/Color", ["dojo/lib/kernel", "dojo/_base/array", "dojo/_base/l
// Returns 3 component array of rgb values
// example:
// | var c = new dojo.Color("#000000");
- // | console.log(c.toRgb()); // [0,0,0]
+ // | console.log(c.toRgb()); // [0,0,0]
var t = this;
return [t.r, t.g, t.b]; // Array
},
@@ -101,8 +97,8 @@ define("dojo/_base/Color", ["dojo/lib/kernel", "dojo/_base/array", "dojo/_base/l
// summary:
// Returns a CSS color string in hexadecimal representation
// example:
- // | console.log(new dojo.Color([0,0,0]).toHex()); // #000000
- var arr = d.map(["r", "g", "b"], function(x){
+ // | console.log(new dojo.Color([0,0,0]).toHex()); // #000000
+ var arr = dojo.map(["r", "g", "b"], function(x){
var s = this[x].toString(16);
return s.length < 2 ? "0" + s : s;
}, this);
@@ -133,8 +129,8 @@ define("dojo/_base/Color", ["dojo/lib/kernel", "dojo/_base/array", "dojo/_base/l
// summary:
// Blend colors end and start with weight from 0 to 1, 0.5 being a 50/50 blend,
// can reuse a previously allocated dojo.Color object for the result
- var t = obj || new d.Color();
- d.forEach(["r", "g", "b", "a"], function(x){
+ var t = obj || new dojo.Color();
+ dojo.forEach(["r", "g", "b", "a"], function(x){
t[x] = start[x] + (end[x] - start[x]) * weight;
if(x != "a"){ t[x] = Math.round(t[x]); }
});
@@ -167,14 +163,14 @@ define("dojo/_base/Color", ["dojo/lib/kernel", "dojo/_base/array", "dojo/_base/l
//
// example:
// | var thing = dojo.colorFromHex("#000"); // black, shorthand
- var t = obj || new d.Color(),
+ var t = obj || new dojo.Color(),
bits = (color.length == 4) ? 4 : 8,
mask = (1 << bits) - 1;
color = Number("0x" + color.substr(1));
if(isNaN(color)){
return null; // dojo.Color
}
- d.forEach(["b", "g", "r"], function(x){
+ dojo.forEach(["b", "g", "r"], function(x){
var c = color & mask;
color >>= bits;
t[x] = bits == 4 ? 17 * c : c;
@@ -191,7 +187,7 @@ define("dojo/_base/Color", ["dojo/lib/kernel", "dojo/_base/array", "dojo/_base/l
// | var myColor = dojo.colorFromArray([237,237,237,0.5]); // grey, 50% alpha
// returns:
// A dojo.Color object. If obj is passed, it will be the return value.
- var t = obj || new d.Color();
+ var t = obj || new dojo.Color();
t._set(Number(a[0]), Number(a[1]), Number(a[2]), Number(a[3]));
if(isNaN(t.a)){ t.a = 1; }
return t.sanitize(); // dojo.Color
@@ -208,10 +204,9 @@ define("dojo/_base/Color", ["dojo/lib/kernel", "dojo/_base/array", "dojo/_base/l
// 10, 50)"
// returns:
// A dojo.Color object. If obj is passed, it will be the return value.
- var a = d.Color.named[str];
- return a && d.colorFromArray(a, obj) || d.colorFromRgb(str, obj) || d.colorFromHex(str, obj);
+ var a = dojo.Color.named[str];
+ return a && dojo.colorFromArray(a, obj) || dojo.colorFromRgb(str, obj) || dojo.colorFromHex(str, obj);
};
-})();
-return dojo.Color;
+ return dojo.Color;
});
View
113 _base/Deferred.js
@@ -1,13 +1,16 @@
-define("dojo/_base/Deferred", ["dojo/lib/kernel", "dojo/_base/lang"], function(dojo){
+define(["./kernel", "./lang"], function(dojo){
+ // module:
+ // dojo/_base/Deferred
+ // summary:
+ // This module defines dojo.Deferred.
-(function(){
var mutator = function(){};
var freeze = Object.freeze || function(){};
// A deferred provides an API for creating and resolving a promise.
dojo.Deferred = function(/*Function?*/canceller){
// summary:
// Deferreds provide a generic means for encapsulating an asynchronous
- // operation and notifying users of the completion and result of the operation.
+ // operation and notifying users of the completion and result of the operation.
// description:
// The dojo.Deferred API is based on the concept of promises that provide a
// generic interface into the eventual completion of an asynchronous action.
@@ -23,12 +26,12 @@ define("dojo/_base/Deferred", ["dojo/lib/kernel", "dojo/_base/lang"], function(d
// separated from the concerns of asynchronous interaction (which are
// handled by the promise).
//
- // The dojo.Deferred is a type of promise that provides methods for fulfilling the
- // promise with a successful result or an error. The most important method for
- // working with Dojo's promises is the then() method, which follows the
- // CommonJS proposed promise API. An example of using a Dojo promise:
+ // The dojo.Deferred is a type of promise that provides methods for fulfilling the
+ // promise with a successful result or an error. The most important method for
+ // working with Dojo's promises is the then() method, which follows the
+ // CommonJS proposed promise API. An example of using a Dojo promise:
//
- // | var resultingPromise = someAsyncOperation.then(function(result){
+ // | var resultingPromise = someAsyncOperation.then(function(result){
// | ... handle result ...
// | },
// | function(error){
@@ -36,7 +39,7 @@ define("dojo/_base/Deferred", ["dojo/lib/kernel", "dojo/_base/lang"], function(d
// | });
//
// The .then() call returns a new promise that represents the result of the
- // execution of the callback. The callbacks will never affect the original promises value.
+ // execution of the callback. The callbacks will never affect the original promises value.
//
// The dojo.Deferred instances also provide the following functions for backwards compatibility:
//
@@ -48,7 +51,7 @@ define("dojo/_base/Deferred", ["dojo/lib/kernel", "dojo/_base/lang"], function(d
// Callbacks are allowed to return promises themselves, so
// you can build complicated sequences of events with ease.
//
- // The creator of the Deferred may specify a canceller. The canceller
+ // The creator of the Deferred may specify a canceller. The canceller
// is a function that will be called if Deferred.cancel is called
// before the Deferred fires. You can use this to implement clean
// aborting of an XMLHttpRequest, etc. Note that cancel will fire the
@@ -231,26 +234,26 @@ define("dojo/_base/Deferred", ["dojo/lib/kernel", "dojo/_base/lang"], function(d
// provide the implementation of the promise
this.then = promise.then = function(/*Function?*/resolvedCallback, /*Function?*/errorCallback, /*Function?*/progressCallback){
// summary:
- // Adds a fulfilledHandler, errorHandler, and progressHandler to be called for
- // completion of a promise. The fulfilledHandler is called when the promise
- // is fulfilled. The errorHandler is called when a promise fails. The
- // progressHandler is called for progress events. All arguments are optional
- // and non-function values are ignored. The progressHandler is not only an
- // optional argument, but progress events are purely optional. Promise
- // providers are not required to ever create progress events.
+ // Adds a fulfilledHandler, errorHandler, and progressHandler to be called for
+ // completion of a promise. The fulfilledHandler is called when the promise
+ // is fulfilled. The errorHandler is called when a promise fails. The
+ // progressHandler is called for progress events. All arguments are optional
+ // and non-function values are ignored. The progressHandler is not only an
+ // optional argument, but progress events are purely optional. Promise
+ // providers are not required to ever create progress events.
//
- // This function will return a new promise that is fulfilled when the given
- // fulfilledHandler or errorHandler callback is finished. This allows promise
- // operations to be chained together. The value returned from the callback
- // handler is the fulfillment value for the returned promise. If the callback
- // throws an error, the returned promise will be moved to failed state.
+ // This function will return a new promise that is fulfilled when the given
+ // fulfilledHandler or errorHandler callback is finished. This allows promise
+ // operations to be chained together. The value returned from the callback
+ // handler is the fulfillment value for the returned promise. If the callback
+ // throws an error, the returned promise will be moved to failed state.
//
// example:
- // An example of using a CommonJS compliant promise:
- // | asyncComputeTheAnswerToEverything().
+ // An example of using a CommonJS compliant promise:
+ // | asyncComputeTheAnswerToEverything().
// | then(addTwo).
// | then(printResult, onError);
- // | >44
+ // | >44
//
var returnDeferred = progressCallback == mutator ? this : new dojo.Deferred(promise.cancel);
var listener = {
@@ -302,35 +305,35 @@ define("dojo/_base/Deferred", ["dojo/lib/kernel", "dojo/_base/lang"], function(d
},
fired: -1
});
-})();
-dojo.when = function(promiseOrValue, /*Function?*/callback, /*Function?*/errback, /*Function?*/progressHandler){
- // summary:
- // This provides normalization between normal synchronous values and
- // asynchronous promises, so you can interact with them in a common way
- // example:
- // | function printFirstAndList(items){
- // | dojo.when(findFirst(items), console.log);
- // | dojo.when(findLast(items), console.log);
- // | }
- // | function findFirst(items){
- // | return dojo.when(items, function(items){
- // | return items[0];
- // | });
- // | }
- // | function findLast(items){
- // | return dojo.when(items, function(items){
- // | return items[items.length];
- // | });
- // | }
- // And now all three of his functions can be used sync or async.
- // | printFirstAndLast([1,2,3,4]) will work just as well as
- // | printFirstAndLast(dojo.xhrGet(...));
-
- if(promiseOrValue && typeof promiseOrValue.then === "function"){
- return promiseOrValue.then(callback, errback, progressHandler);
- }
- return callback(promiseOrValue);
-};
-return dojo.Deferred;
+ dojo.when = function(promiseOrValue, /*Function?*/callback, /*Function?*/errback, /*Function?*/progressHandler){
+ // summary:
+ // This provides normalization between normal synchronous values and
+ // asynchronous promises, so you can interact with them in a common way
+ // example:
+ // | function printFirstAndList(items){
+ // | dojo.when(findFirst(items), console.log);
+ // | dojo.when(findLast(items), console.log);
+ // | }
+ // | function findFirst(items){
+ // | return dojo.when(items, function(items){
+ // | return items[0];
+ // | });
+ // | }
+ // | function findLast(items){
+ // | return dojo.when(items, function(items){
+ // | return items[items.length];
+ // | });
+ // | }
+ // And now all three of his functions can be used sync or async.
+ // | printFirstAndLast([1,2,3,4]) will work just as well as
+ // | printFirstAndLast(dojo.xhrGet(...));
+
+ if(promiseOrValue && typeof promiseOrValue.then === "function"){
+ return promiseOrValue.then(callback, errback, progressHandler);
+ }
+ return callback(promiseOrValue);
+ };
+
+ return dojo.Deferred;
});
View
336 _base/NodeList.js
@@ -1,26 +1,26 @@
-define("dojo/_base/NodeList", ["dojo/lib/kernel", "dojo/_base/lang", "dojo/_base/array", "dojo/_base/connect", "dojo/_base/html"], function(dojo){
-
-//>>excludeStart("webkitMobile", kwArgs.webkitMobile);
-(function(){
+define(["./kernel", "./lang", "./array", "./connect", "./html"], function(dojo){
+ // module:
+ // dojo/_base/NodeList
+ // summary:
+ // This module defines dojo.NodeList.
var d = dojo;
-//>>excludeEnd("webkitMobile");
var ap = Array.prototype, aps = ap.slice, apc = ap.concat;
var tnl = function(/*Array*/ a, /*dojo.NodeList?*/ parent, /*Function?*/ NodeListCtor){
// summary:
- // decorate an array to make it look like a `dojo.NodeList`.
+ // decorate an array to make it look like a `dojo.NodeList`.
// a:
- // Array of nodes to decorate.
+ // Array of nodes to decorate.
// parent:
- // An optional parent NodeList that generated the current
- // list of nodes. Used to call _stash() so the parent NodeList
- // can be accessed via end() later.
+ // An optional parent NodeList that generated the current
+ // list of nodes. Used to call _stash() so the parent NodeList
+ // can be accessed via end() later.
// NodeListCtor:
- // An optional constructor function to use for any
- // new NodeList calls. This allows a certain chain of
- // NodeList calls to use a different object than dojo.NodeList.
+ // An optional constructor function to use for any
+ // new NodeList calls. This allows a certain chain of
+ // NodeList calls to use a different object than dojo.NodeList.
if(!a.sort){
// make sure it's a real array before we pass it on to be wrapped
a = aps.call(a, 0);
@@ -44,13 +44,13 @@ define("dojo/_base/NodeList", ["dojo/lib/kernel", "dojo/_base/lang", "dojo/_base
// adapters
var adaptAsForEach = function(f, o){
- // summary:
+ // summary:
// adapts a single node function to be used in the forEach-type
// actions. The initial object is returned from the specialized
// function.
- // f: Function
+ // f: Function
// a function to adapt
- // o: Object?
+ // o: Object?
// an optional context for f
return function(){
this.forEach(loopBody(f, arguments, o));
@@ -59,12 +59,12 @@ define("dojo/_base/NodeList", ["dojo/lib/kernel", "dojo/_base/lang", "dojo/_base
};
var adaptAsMap = function(f, o){
- // summary:
+ // summary:
// adapts a single node function to be used in the map-type
// actions. The return is a new array of values, as via `dojo.map`
- // f: Function
+ // f: Function
// a function to adapt
- // o: Object?
+ // o: Object?
// an optional context for f
return function(){
return this.map(loopBody(f, arguments, o));
@@ -72,11 +72,11 @@ define("dojo/_base/NodeList", ["dojo/lib/kernel", "dojo/_base/lang", "dojo/_base
};
var adaptAsFilter = function(f, o){
- // summary:
+ // summary:
// adapts a single node function to be used in the filter-type actions
- // f: Function
+ // f: Function
// a function to adapt
- // o: Object?
+ // o: Object?
// an optional context for f
return function(){
return this.filter(loopBody(f, arguments, o));
@@ -84,14 +84,14 @@ define("dojo/_base/NodeList", ["dojo/lib/kernel", "dojo/_base/lang", "dojo/_base
};
var adaptWithCondition = function(f, g, o){
- // summary:
+ // summary:
// adapts a single node function to be used in the map-type
// actions, behaves like forEach() or map() depending on arguments
- // f: Function
+ // f: Function
// a function to adapt
- // g: Function
+ // g: Function
// a condition function, if true runs as map(), otherwise runs as forEach()
- // o: Object?
+ // o: Object?
// an optional context for f and g
return function(){
var a = arguments, body = loopBody(f, a, o);
@@ -104,13 +104,13 @@ define("dojo/_base/NodeList", ["dojo/lib/kernel", "dojo/_base/lang", "dojo/_base
};
var magicGuard = function(a){
- // summary:
+ // summary:
// the guard function for dojo.attr() and dojo.style()
return a.length == 1 && (typeof a[0] == "string"); // inline'd type check
};
var orphan = function(node){
- // summary:
+ // summary:
// function to orphan nodes
var p = node.parentNode;
if(p){
@@ -120,28 +120,28 @@ define("dojo/_base/NodeList", ["dojo/lib/kernel", "dojo/_base/lang", "dojo/_base
// FIXME: should we move orphan() to dojo.html?
dojo.NodeList = function(){
- // summary:
+ // summary:
// dojo.NodeList is an of Array subclass which adds syntactic
// sugar for chaining, common iteration operations, animation, and
// node manipulation. NodeLists are most often returned as the
// result of dojo.query() calls.
- // description:
+ // description:
// dojo.NodeList instances provide many utilities that reflect
// core Dojo APIs for Array iteration and manipulation, DOM
// manipulation, and event handling. Instead of needing to dig up
// functions in the dojo.* namespace, NodeLists generally make the
// full power of Dojo available for DOM manipulation tasks in a
// simple, chainable way.
- // example:
+ // example:
// create a node list from a node
// | new dojo.NodeList(dojo.byId("foo"));
- // example:
+ // example:
// get a NodeList from a CSS query and iterate on it
// | var l = dojo.query(".thinger");
// | l.forEach(function(node, index, nodeList){
// | console.log(index, node.innerHTML);
// | });
- // example:
+ // example:
// use native and Dojo-provided array methods to manipulate a
// NodeList without needing to use dojo.* functions explicitly:
// | var l = dojo.query(".thinger");
@@ -160,7 +160,7 @@ define("dojo/_base/NodeList", ["dojo/lib/kernel", "dojo/_base/lang", "dojo/_base
// | // function to get specific items wrapped in a new NodeList:
// | var node = l[3]; // the 4th element
// | var newList = l.at(1, 3); // the 2nd and 4th elements
- // example:
+ // example:
// the style functions you expect are all there too:
// | // style() as a getter...
// | var borders = dojo.query(".thinger").style("border");
@@ -170,7 +170,7 @@ define("dojo/_base/NodeList", ["dojo/lib/kernel", "dojo/_base/lang", "dojo/_base
// | dojo.query("li:nth-child(even)").addClass("even");
// | // even getting the coordinates of all the items
// | var coords = dojo.query(".thinger").coords();
- // example:
+ // example:
// DOM manipulation functions from the dojo.* namespace area also
// available:
// | // remove all of the elements in the list from their
@@ -178,7 +178,7 @@ define("dojo/_base/NodeList", ["dojo/lib/kernel", "dojo/_base/lang", "dojo/_base
// | dojo.query(".thinger").orphan();
// | // place all elements in the list at the front of #foo
// | dojo.query(".thinger").place("foo", "first");
- // example:
+ // example:
// Event handling couldn't be easier. `dojo.connect` is mapped in,
// and shortcut handlers are provided for most DOM events:
// | // like dojo.connect(), but with implicit scope
@@ -190,7 +190,7 @@ define("dojo/_base/NodeList", ["dojo/lib/kernel", "dojo/_base/lang", "dojo/_base
// | dojo.query("p")
// | .onmouseenter(toggleHovered)
// | .onmouseleave(toggleHovered);
- // example:
+ // example:
// chainability is a key advantage of NodeLists:
// | dojo.query(".thinger")
// | .onclick(function(e){ /* ... */ })
@@ -211,7 +211,7 @@ define("dojo/_base/NodeList", ["dojo/lib/kernel", "dojo/_base/lang", "dojo/_base
nl._wrap = nlp._wrap = tnl;
nl._adaptAsMap = adaptAsMap;
nl._adaptAsForEach = adaptAsForEach;
- nl._adaptAsFilter = adaptAsFilter;
+ nl._adaptAsFilter = adaptAsFilter;
nl._adaptWithCondition = adaptWithCondition;
// mass assignment
@@ -246,19 +246,19 @@ define("dojo/_base/NodeList", ["dojo/lib/kernel", "dojo/_base/lang", "dojo/_base
dojo.extend(dojo.NodeList, {
_normalize: function(/*String||Element||Object||NodeList*/content, /*DOMNode?*/refNode){
// summary:
- // normalizes data to an array of items to insert.
+ // normalizes data to an array of items to insert.
// description:
- // If content is an object, it can have special properties "template" and
- // "parse". If "template" is defined, then the template value is run through
- // dojo.string.substitute (if dojo.string.substitute has been dojo.required elsewhere),
- // or if templateFunc is a function on the content, that function will be used to
- // transform the template into a final string to be used for for passing to dojo._toDom.
- // If content.parse is true, then it is remembered for later, for when the content
- // nodes are inserted into the DOM. At that point, the nodes will be parsed for widgets
- // (if dojo.parser has been dojo.required elsewhere).
+ // If content is an object, it can have special properties "template" and
+ // "parse". If "template" is defined, then the template value is run through
+ // dojo.string.substitute (if dojo.string.substitute has been dojo.required elsewhere),
+ // or if templateFunc is a function on the content, that function will be used to
+ // transform the template into a final string to be used for for passing to dojo._toDom.
+ // If content.parse is true, then it is remembered for later, for when the content
+ // nodes are inserted into the DOM. At that point, the nodes will be parsed for widgets
+ // (if dojo.parser has been dojo.required elsewhere).
//Wanted to just use a DocumentFragment, but for the array/NodeList
- //case that meant using cloneNode, but we may not want that.
+ //case that meant using cloneNode, but we may not want that.
//Cloning should only happen if the node operations span
//multiple refNodes. Also, need a real array, not a NodeList from the
//DOM since the node movements could change those NodeLists.
@@ -297,18 +297,18 @@ define("dojo/_base/NodeList", ["dojo/lib/kernel", "dojo/_base/lang", "dojo/_base
_cloneNode: function(/*DOMNode*/ node){
// summary:
- // private utility to clone a node. Not very interesting in the vanilla
- // dojo.NodeList case, but delegates could do interesting things like
- // clone event handlers if that is derivable from the node.
+ // private utility to clone a node. Not very interesting in the vanilla
+ // dojo.NodeList case, but delegates could do interesting things like
+ // clone event handlers if that is derivable from the node.
return node.cloneNode(true);
},
_place: function(/*Array*/ary, /*DOMNode*/refNode, /*String*/position, /*Boolean*/useClone){
// summary:
- // private utility to handle placing an array of nodes relative to another node.
+ // private utility to handle placing an array of nodes relative to another node.
// description:
- // Allows for cloning the nodes in the array, and for
- // optionally parsing widgets, if ary._runParse is true.
+ // Allows for cloning the nodes in the array, and for
+ // optionally parsing widgets, if ary._runParse is true.
//Avoid a disallowed operation if trying to do an innerHTML on a non-element node.
if(refNode.nodeType != 1 && position == "only"){
@@ -348,14 +348,14 @@ define("dojo/_base/NodeList", ["dojo/lib/kernel", "dojo/_base/lang", "dojo/_base
_stash: function(parent){
// summary:
- // private function to hold to a parent NodeList. end() to return the parent NodeList.
+ // private function to hold to a parent NodeList. end() to return the parent NodeList.
//
// example:
// How to make a `dojo.NodeList` method that only returns the third node in
// the dojo.NodeList but allows access to the original NodeList by using this._stash:
// | dojo.extend(dojo.NodeList, {
// | third: function(){
- // | var newNodeList = dojo.NodeList(this[2]);
+ // | var newNodeList = dojo.NodeList(this[2]);
// | return newNodeList._stash(this);
// | }
// | });
@@ -374,11 +374,11 @@ define("dojo/_base/NodeList", ["dojo/lib/kernel", "dojo/_base/lang", "dojo/_base
end: function(){
// summary:
- // Ends use of the current `dojo.NodeList` by returning the previous dojo.NodeList
- // that generated the current dojo.NodeList.
+ // Ends use of the current `dojo.NodeList` by returning the previous dojo.NodeList
+ // that generated the current dojo.NodeList.
// description:
- // Returns the `dojo.NodeList` that generated the current `dojo.NodeList`. If there
- // is no parent dojo.NodeList, an empty dojo.NodeList is returned.
+ // Returns the `dojo.NodeList` that generated the current `dojo.NodeList`. If there
+ // is no parent dojo.NodeList, an empty dojo.NodeList is returned.
// example:
// | dojo.query("a")
// | .filter(".disabled")
@@ -438,8 +438,8 @@ define("dojo/_base/NodeList", ["dojo/lib/kernel", "dojo/_base/lang", "dojo/_base
// with the caveat that it returns a dojo.NodeList and not a
// raw Array. For more details, see Mozilla's (splice
// documentation)[http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Array:splice]
- // For backwards compatibility, calling .end() on the spliced NodeList
- // does not return the original NodeList -- splice alters the NodeList in place.
+ // For backwards compatibility, calling .end() on the spliced NodeList
+ // does not return the original NodeList -- splice alters the NodeList in place.
// index: Integer
// begin can be a positive or negative integer, with positive
// integers noting the offset to begin at, and negative
@@ -458,18 +458,18 @@ define("dojo/_base/NodeList", ["dojo/lib/kernel", "dojo/_base/lang", "dojo/_base
},
indexOf: function(value, fromIndex){
- // summary:
+ // summary:
// see dojo.indexOf(). The primary difference is that the acted-on
// array is implicitly this NodeList
// value: Object:
// The value to search for.
// fromIndex: Integer?:
// The location to start searching from. Optional. Defaults to 0.
- // description:
+ // description:
// For more details on the behavior of indexOf, see Mozilla's
// (indexOf
// docs)[http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Array:indexOf]
- // returns:
+ // returns:
// Positive Integer or 0 for a match, -1 of not found.
return d.indexOf(this, value, fromIndex); // Integer
},
@@ -478,7 +478,7 @@ define("dojo/_base/NodeList", ["dojo/lib/kernel", "dojo/_base/lang", "dojo/_base
// summary:
// see dojo.lastIndexOf(). The primary difference is that the
// acted-on array is implicitly this NodeList
- // description:
+ // description:
// For more details on the behavior of lastIndexOf, see
// Mozilla's (lastIndexOf
// docs)[http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Array:lastIndexOf]
@@ -492,7 +492,7 @@ define("dojo/_base/NodeList", ["dojo/lib/kernel", "dojo/_base/lang", "dojo/_base
},
every: function(callback, thisObject){
- // summary:
+ // summary:
// see `dojo.every()` and the (Array.every
// docs)[http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Array:every].
// Takes the same structure of arguments and returns as
@@ -504,10 +504,10 @@ define("dojo/_base/NodeList", ["dojo/lib/kernel", "dojo/_base/lang", "dojo/_base
},
some: function(callback, thisObject){
- // summary:
+ // summary:
// Takes the same structure of arguments and returns as
// `dojo.some()` with the caveat that the passed array is
- // implicitly this NodeList. See `dojo.some()` and Mozilla's
+ // implicitly this NodeList. See `dojo.some()` and Mozilla's
// (Array.some
// documentation)[http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Array:some].
// callback: Function: the callback
@@ -553,7 +553,7 @@ define("dojo/_base/NodeList", ["dojo/lib/kernel", "dojo/_base/lang", "dojo/_base
},
map: function(/*Function*/ func, /*Function?*/ obj){
- // summary:
+ // summary:
// see dojo.map(). The primary difference is that the acted-on
// array is implicitly this NodeList and the return is a
// dojo.NodeList (a subclass of Array)
@@ -562,7 +562,7 @@ define("dojo/_base/NodeList", ["dojo/lib/kernel", "dojo/_base/lang", "dojo/_base
},
forEach: function(callback, thisObj){
- // summary:
+ // summary:
// see `dojo.forEach()`. The primary difference is that the acted-on
// array is implicitly this NodeList. If you want the option to break out
// of the forEach loop, use every() or some() instead.
@@ -573,7 +573,7 @@ define("dojo/_base/NodeList", ["dojo/lib/kernel", "dojo/_base/lang", "dojo/_base
/*=====
coords: function(){
- // summary:
+ // summary:
// Returns the box objects of all elements in a node list as
// an Array (*not* a NodeList). Acts like `dojo.coords`, though assumes
// the node passed is each node in this list.
@@ -582,7 +582,7 @@ define("dojo/_base/NodeList", ["dojo/lib/kernel", "dojo/_base/lang", "dojo/_base
},
position: function(){
- // summary:
+ // summary:
// Returns border-box objects (x/y/w/h) of all elements in a node list
// as an Array (*not* a NodeList). Acts like `dojo.position`, though
// assumes the node passed is each node in this list.
@@ -591,23 +591,23 @@ define("dojo/_base/NodeList", ["dojo/lib/kernel", "dojo/_base/lang", "dojo/_base
},
attr: function(property, value){
- // summary:
+ // summary:
// gets or sets the DOM attribute for every element in the
// NodeList. See also `dojo.attr`
- // property: String
+ // property: String
// the attribute to get/set
- // value: String?
+ // value: String?
// optional. The value to set the property to
- // returns:
+ // returns:
// if no value is passed, the result is an array of attribute values
// If a value is passed, the return is this NodeList
- // example:
+ // example:
// Make all nodes with a particular class focusable:
// | dojo.query(".focusable").attr("tabIndex", -1);
- // example:
+ // example:
// Disable a group of buttons:
// | dojo.query("button.group").attr("disabled", true);
- // example:
+ // example:
// innerHTML can be assigned or retrieved as well:
// | // get the innerHTML (as an array) for each list item
// | var ih = dojo.query("li.replaceable").attr("innerHTML");
@@ -616,14 +616,14 @@ define("dojo/_base/NodeList", ["dojo/lib/kernel", "dojo/_base/lang", "dojo/_base
},
style: function(property, value){
- // summary:
+ // summary:
// gets or sets the CSS property for every element in the NodeList
- // property: String
+ // property: String
// the CSS property to get/set, in JavaScript notation
// ("lineHieght" instead of "line-height")
- // value: String?
+ // value: String?
// optional. The value to set the property to
- // returns:
+ // returns:
// if no value is passed, the result is an array of strings.
// If a value is passed, the return is this NodeList
return; // dojo.NodeList
@@ -631,54 +631,54 @@ define("dojo/_base/NodeList", ["dojo/lib/kernel", "dojo/_base/lang", "dojo/_base
},
addClass: function(className){
- // summary:
+ // summary:
// adds the specified class to every node in the list
- // className: String|Array
+ // className: String|Array
// A String class name to add, or several space-separated class names,
// or an array of class names.
return; // dojo.NodeList
},
removeClass: function(className){
- // summary:
+ // summary:
// removes the specified class from every node in the list
- // className: String|Array?
+ // className: String|Array?
// An optional String class name to remove, or several space-separated
// class names, or an array of class names. If omitted, all class names
// will be deleted.
- // returns:
+ // returns:
// dojo.NodeList, this list
return; // dojo.NodeList
},
toggleClass: function(className, condition){
- // summary:
+ // summary:
// Adds a class to node if not present, or removes if present.
// Pass a boolean condition if you want to explicitly add or remove.
- // condition: Boolean?
+ // condition: Boolean?
// If passed, true means to add the class, false means to remove.
- // className: String
+ // className: String
// the CSS class to add
return; // dojo.NodeList
},
connect: function(methodName, objOrFunc, funcName){
- // summary:
+ // summary:
// attach event handlers to every item of the NodeList. Uses dojo.connect()
// so event properties are normalized
- // methodName: String
+ // methodName: String
// the name of the method to attach to. For DOM events, this should be
// the lower-case name of the event
- // objOrFunc: Object|Function|String
+ // objOrFunc: Object|Function|String
// if 2 arguments are passed (methodName, objOrFunc), objOrFunc should
// reference a function or be the name of the function in the global
// namespace to attach. If 3 arguments are provided
// (methodName, objOrFunc, funcName), objOrFunc must be the scope to
// locate the bound function in
- // funcName: String?
+ // funcName: String?
// optional. A string naming the function in objOrFunc to bind to the
// event. May also be a function reference.
- // example:
+ // example:
// add an onclick handler to every button on the page
// | dojo.query("div:nth-child(odd)").connect("onclick", function(e){
// | console.log("clicked!");
@@ -689,7 +689,7 @@ define("dojo/_base/NodeList", ["dojo/lib/kernel", "dojo/_base/lang", "dojo/_base
},
empty: function(){
- // summary:
+ // summary:
// clears all content from each node in the list. Effectively
// equivalent to removing all child nodes from every item in
// the list.
@@ -706,22 +706,22 @@ define("dojo/_base/NodeList", ["dojo/lib/kernel", "dojo/_base/lang", "dojo/_base
/*
destroy: function(){
- // summary:
- // destroys every item in the list.
+ // summary:
+ // destroys every item in the list.
this.forEach(d.destroy);
// FIXME: should we be checking for and/or disposing of widgets below these nodes?
},
*/
place: function(/*String||Node*/ queryOrNode, /*String*/ position){
- // summary:
+ // summary:
// places elements of this node list relative to the first element matched
// by queryOrNode. Returns the original NodeList. See: `dojo.place`
- // queryOrNode:
+ // queryOrNode:
// may be a string representing any valid CSS3 selector or a DOM node.
// In the selector case, only the first matching element will be used
// for relative positioning.
- // position:
+ // position:
// can be one of:
// | "last" (default)
// | "first"
@@ -729,32 +729,32 @@ define("dojo/_base/NodeList", ["dojo/lib/kernel", "dojo/_base/lang", "dojo/_base
// | "after"
// | "only"
// | "replace"
- // or an offset in the childNodes property
+ // or an offset in the childNodes property
var item = d.query(queryOrNode)[0];
return this.forEach(function(node){ d.place(node, item, position); }); // dojo.NodeList
},
orphan: function(/*String?*/ filter){
- // summary:
+ // summary:
// removes elements in this list that match the filter
// from their parents and returns them as a new NodeList.
- // filter:
+ // filter:
// CSS selector like ".foo" or "div > span"
- // returns:
+ // returns:
// `dojo.NodeList` containing the orphaned elements
return (filter ? d._filterQueryResult(this, filter) : this).forEach(orphan); // dojo.NodeList
},
adopt: function(/*String||Array||DomNode*/ queryOrListOrNode, /*String?*/ position){
- // summary:
+ // summary:
// places any/all elements in queryOrListOrNode at a
// position relative to the first element in this list.
// Returns a dojo.NodeList of the adopted elements.
- // queryOrListOrNode:
+ // queryOrListOrNode:
// a DOM node or a query string or a query result.
// Represents the nodes to be adopted relative to the
// first element of this NodeList.
- // position:
+ // position:
// can be one of:
// | "last" (default)
// | "first"
@@ -762,17 +762,17 @@ define("dojo/_base/NodeList", ["dojo/lib/kernel", "dojo/_base/lang", "dojo/_base
// | "after"
// | "only"
// | "replace"
- // or an offset in the childNodes property
+ // or an offset in the childNodes property
return d.query(queryOrListOrNode).place(this[0], position)._stash(this); // dojo.NodeList
},
// FIXME: do we need this?
query: function(/*String*/ queryStr){
- // summary:
+ // summary:
// Returns a new list whose members match the passed query,
// assuming elements of the current NodeList as the root for
// each search.
- // example:
+ // example:
// assume a DOM created by this markup:
// | <div id="foo">
// | <p>
@@ -786,7 +786,7 @@ define("dojo/_base/NodeList", ["dojo/lib/kernel", "dojo/_base/lang", "dojo/_base
// | var l = new dojo.NodeList(dojo.byId("foo"), dojo.byId("bar"));
// it's possible to find all span elements under paragraphs
// contained by these elements with this sub-query:
- // | var spans = l.query("p span");
+ // | var spans = l.query("p span");
// FIXME: probably slow
if(!queryStr){ return this; }
@@ -798,14 +798,14 @@ define("dojo/_base/NodeList", ["dojo/lib/kernel", "dojo/_base/lang", "dojo/_base
},
filter: function(/*String|Function*/ filter){
- // summary:
- // "masks" the built-in javascript filter() method (supported
- // in Dojo via `dojo.filter`) to support passing a simple
- // string filter in addition to supporting filtering function
- // objects.
- // filter:
+ // summary:
+ // "masks" the built-in javascript filter() method (supported
+ // in Dojo via `dojo.filter`) to support passing a simple
+ // string filter in addition to supporting filtering function
+ // objects.
+ // filter:
// If a string, a CSS rule like ".thinger" or "div > span".
- // example:
+ // example:
// "regular" JS filter syntax as exposed in dojo.filter:
// | dojo.query("*").filter(function(item){
// | // highlight every paragraph
@@ -838,26 +838,26 @@ define("dojo/_base/NodeList", ["dojo/lib/kernel", "dojo/_base/lang", "dojo/_base
*/
addContent: function(/*String||DomNode||Object||dojo.NodeList*/ content, /*String||Integer?*/ position){
- // summary:
+ // summary:
// add a node, NodeList or some HTML as a string to every item in the
- // list. Returns the original list.
- // description:
+ // list. Returns the original list.
+ // description:
// a copy of the HTML content is added to each item in the
// list, with an optional position argument. If no position
// argument is provided, the content is appended to the end of
// each item.
- // content:
+ // content:
// DOM node, HTML in string format, a NodeList or an Object. If a DOM node or
- // NodeList, the content will be cloned if the current NodeList has more than one
- // element. Only the DOM nodes are cloned, no event handlers. If it is an Object,
- // it should be an object with at "template" String property that has the HTML string
- // to insert. If dojo.string has already been dojo.required, then dojo.string.substitute
- // will be used on the "template" to generate the final HTML string. Other allowed
- // properties on the object are: "parse" if the HTML
- // string should be parsed for widgets (dojo.require("dojo.parser") to get that
- // option to work), and "templateFunc" if a template function besides dojo.string.substitute
- // should be used to transform the "template".
- // position:
+ // NodeList, the content will be cloned if the current NodeList has more than one
+ // element. Only the DOM nodes are cloned, no event handlers. If it is an Object,
+ // it should be an object with at "template" String property that has the HTML string
+ // to insert. If dojo.string has already been dojo.required, then dojo.string.substitute
+ // will be used on the "template" to generate the final HTML string. Other allowed
+ // properties on the object are: "parse" if the HTML
+ // string should be parsed for widgets (dojo.require("dojo.parser") to get that
+ // option to work), and "templateFunc" if a template function besides dojo.string.substitute
+ // should be used to transform the "template".
+ // position:
// can be one of:
// | "last"||"end" (default)
// | "first||"start"
@@ -865,38 +865,38 @@ define("dojo/_base/NodeList", ["dojo/lib/kernel", "dojo/_base/lang", "dojo/_base
// | "after"
// | "replace" (replaces nodes in this NodeList with new content)
// | "only" (removes other children of the nodes so new content is the only child)
- // or an offset in the childNodes property
- // example:
+ // or an offset in the childNodes property
+ // example:
// appends content to the end if the position is omitted
// | dojo.query("h3 > p").addContent("hey there!");
- // example:
+ // example:
// add something to the front of each element that has a
// "thinger" property:
// | dojo.query("[thinger]").addContent("...", "first");
- // example:
+ // example:
// adds a header before each element of the list
// | dojo.query(".note").addContent("<h4>NOTE:</h4>", "before");
- // example:
+ // example:
// add a clone of a DOM node to the end of every element in
// the list, removing it from its existing parent.
// | dojo.query(".note").addContent(dojo.byId("foo"));
- // example:
- // Append nodes from a templatized string.
- // dojo.require("dojo.string");
- // dojo.query(".note").addContent({
- // template: '<b>${id}: </b><span>${name}</span>',
- // id: "user332",
- // name: "Mr. Anderson"
- // });
- // example:
- // Append nodes from a templatized string that also has widgets parsed.
- // dojo.require("dojo.string");
- // dojo.require("dojo.parser");
- // var notes = dojo.query(".note").addContent({
- // template: '<button dojoType="dijit.form.Button">${text}</button>',
- // parse: true,
- // text: "Send"
- // });
+ // example:
+ // Append nodes from a templatized string.
+ // dojo.require("dojo.string");
+ // dojo.query(".note").addContent({
+ // template: '<b>${id}: </b><span>${name}</span>',
+ // id: "user332",
+ // name: "Mr. Anderson"
+ // });
+ // example:
+ // Append nodes from a templatized string that also has widgets parsed.
+ // dojo.require("dojo.string");
+ // dojo.require("dojo.parser");
+ // var notes = dojo.query(".note").addContent({
+ // template: '<button dojoType="dijit.form.Button">${text}</button>',
+ // parse: true,
+ // text: "Send"
+ // });
content = this._normalize(content, this[0]);
for(var i = 0, node; (node = this[i]); i++){
this._place(content, node, position, i > 0);
@@ -905,11 +905,11 @@ define("dojo/_base/NodeList", ["dojo/lib/kernel", "dojo/_base/lang", "dojo/_base
},
instantiate: function(/*String|Object*/ declaredClass, /*Object?*/ properties){
- // summary:
+ // summary:
// Create a new instance of a specified class, using the
// specified properties and each node in the nodeList as a
// srcNodeRef.
- // example:
+ // example:
// Grabs all buttons in the page and converts them to diji.form.Buttons.
// | var buttons = dojo.query("button").instantiate("dijit.form.Button", {showLabel: true});
var c = d.isFunction(declaredClass) ? declaredClass : d.getObject(declaredClass);
@@ -920,31 +920,31 @@ define("dojo/_base/NodeList", ["dojo/lib/kernel", "dojo/_base/lang", "dojo/_base
},
at: function(/*===== index =====*/){
- // summary:
+ // summary:
// Returns a new NodeList comprised of items in this NodeList
// at the given index or indices.
//
- // index: Integer...
+ // index: Integer...
// One or more 0-based indices of items in the current
// NodeList. A negative index will start at the end of the
// list and go backwards.
//
- // example:
+ // example:
// Shorten the list to the first, second, and third elements
// | dojo.query("a").at(0, 1, 2).forEach(fn);
//
- // example:
+ // example:
// Retrieve the first and last elements of a unordered list:
// | dojo.query("ul > li").at(0, -1).forEach(cb);
//
- // example:
+ // example:
// Do something for the first element only, but end() out back to
// the original list and continue chaining:
// | dojo.query("a").at(0).onclick(fn).end().forEach(function(n){
// | console.log(n); // all anchors on the page.
// | })
//
- // returns:
+ // returns:
// dojo.NodeList
var t = new this._NodeListCtor();
d.forEach(arguments, function(i){
@@ -996,9 +996,5 @@ define("dojo/_base/NodeList", ["dojo/lib/kernel", "dojo/_base/lang", "dojo/_base
}
);
-//>>excludeStart("webkitMobile", kwArgs.webkitMobile);
-})();
-//>>excludeEnd("webkitMobile");
-
-return dojo.NodeList;
+ return dojo.NodeList;
});
View
1  _base/_loader/bootstrap.js
@@ -1,3 +1,4 @@
+//>>not-amd pragma for docscript to say this is not an amd module
//>>includeStart("amdLoader", kwArgs.asynchLoader);
(function(){
View
1  _base/_loader/loader.js
@@ -2,6 +2,7 @@
* loader.js - A bootstrap module. Runs before the hostenv_*.js file. Contains
* all of the package loading methods.
*/
+//>>not-amd pragma for docscript to say this is not an amd module
//>>excludeStart("webkitMobile", kwArgs.webkitMobile);
(function(){
var d = dojo, currentModule;
View
129 _base/array.js
@@ -1,26 +1,29 @@
-define("dojo/_base/array", ["dojo/lib/kernel", "dojo/_base/lang"], function(dojo){
+define(["./kernel", "./lang"], function(dojo){
+ // module:
+ // dojo/_base/array
+ // summary:
+ // This module defines the Javascript v1.6 array extensions.
-//>>excludeStart("webkitMobile", kwArgs.webkitMobile);
-(function(){
- var _getParts = function(arr, obj, cb){
- return [
- (typeof arr == "string") ? arr.split("") : arr,
- obj || dojo.global,
- // FIXME: cache the anonymous functions we create here?
- (typeof cb == "string") ? new Function("item", "index", "array", cb) : cb
- ];
- };
+ var
+ getParts = function(arr, obj, cb){
+ return [
+ (typeof arr == "string") ? arr.split("") : arr,
+ obj || dojo.global,
+ // FIXME: cache the anonymous functions we create here?
+ (typeof cb == "string") ? new Function("item", "index", "array", cb) : cb
+ ];
+ },
- var everyOrSome = function(/*Boolean*/every, /*Array|String*/arr, /*Function|String*/callback, /*Object?*/thisObject){
- var _p = _getParts(arr, thisObject, callback); arr = _p[0];
- for(var i=0,l=arr.length; i<l; ++i){
- var result = !!_p[2].call(_p[1], arr[i], i, arr);
- if(every ^ result){
- return result; // Boolean
+ everyOrSome = function(/*Boolean*/every, /*Array|String*/arr, /*Function|String*/callback, /*Object?*/thisObject){
+ var _p = getParts(arr, thisObject, callback); arr = _p[0];
+ for(var i=0,l=arr.length; i<l; ++i){
+ var result = !!_p[2].call(_p[1], arr[i], i, arr);
+ if(every ^ result){
+ return result; // Boolean
+ }
}
- }
- return every; // Boolean
- };
+ return every; // Boolean
+ };
dojo.mixin(dojo, {
indexOf: function( /*Array*/ array,
@@ -60,7 +63,7 @@ define("dojo/_base/array", ["dojo/lib/kernel", "dojo/_base/lang"], function(dojo
// run over sparse arrays, the Dojo function invokes the callback for every index whereas JavaScript
// 1.6's lastIndexOf skips the holes in the sparse array.
// For details on this method, see:
- // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/lastIndexOf
+ // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/lastIndexOf
return dojo.indexOf(array, value, fromIndex, true); // Number
},
@@ -82,50 +85,50 @@ define("dojo/_base/array", ["dojo/lib/kernel", "dojo/_base/lang"], function(dojo
// For more details, see:
// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/forEach
// example:
- // | // log out all members of the array:
- // | dojo.forEach(
+ // | // log out all members of the array:
+ // | dojo.forEach(
// | [ "thinger", "blah", "howdy", 10 ],
// | function(item){
// | console.log(item);
// | }
- // | );
+ // | );
// example:
- // | // log out the members and their indexes
- // | dojo.forEach(
+ // | // log out the members and their indexes
+ // | dojo.forEach(
// | [ "thinger", "blah", "howdy", 10 ],
// | function(item, idx, arr){
// | console.log(item, "at index:", idx);
// | }
- // | );
+ // | );
// example:
- // | // use a scoped object member as the callback
+ // | // use a scoped object member as the callback
// |
- // | var obj = {
+ // | var obj = {
// | prefix: "logged via obj.callback:",
// | callback: function(item){
// | console.log(this.prefix, item);
// | }
- // | };
+ // | };
// |
- // | // specifying the scope function executes the callback in that scope
- // | dojo.forEach(
+ // | // specifying the scope function executes the callback in that scope
+ // | dojo.forEach(
// | [ "thinger", "blah", "howdy", 10 ],
// | obj.callback,
// | obj
- // | );
+ // | );
// |
- // | // alternately, we can accomplish the same thing with dojo.hitch()
- // | dojo.forEach(
+ // | // alternately, we can accomplish the same thing with dojo.hitch()
+ // | dojo.forEach(
// | [ "thinger", "blah", "howdy", 10 ],
// | dojo.hitch(obj, "callback")
- // | );
+ // | );
// match the behavior of the built-in forEach WRT empty arrs
if(!arr || !arr.length){ return; }
// FIXME: there are several ways of handilng thisObject. Is
// dojo.global always the default context?
- var _p = _getParts(arr, thisObject, callback); arr = _p[0];
+ var _p = getParts(arr, thisObject, callback); arr = _p[0];
for(var i=0,l=arr.length; i<l; ++i){
_p[2].call(_p[1], arr[i], i, arr);
}
@@ -149,11 +152,11 @@ define("dojo/_base/array", ["dojo/lib/kernel", "dojo/_base/lang"], function(dojo
// For more details, see:
// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/every
// example:
- // | // returns false
- // | dojo.every([1, 2, 3, 4], function(item){ return item>1; });
+ // | // returns false
+ // | dojo.every([1, 2, 3, 4], function(item){ return item>1; });
// example:
- // | // returns true
- // | dojo.every([1, 2, 3, 4], function(item){ return item>0; });
+ // | // returns true
+ // | dojo.every([1, 2, 3, 4], function(item){ return item>0; });
return everyOrSome(true, arr, callback, thisObject); // Boolean
},
@@ -175,11 +178,11 @@ define("dojo/_base/array", ["dojo/lib/kernel", "dojo/_base/lang"], function(dojo
// For more details, see:
// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/some
// example:
- // | // is true
- // | dojo.some([1, 2, 3, 4], function(item){ return item>1; });
+ // | // is true
+ // | dojo.some([1, 2, 3, 4], function(item){ return item>1; });
// example:
- // | // is false
- // | dojo.some([1, 2, 3, 4], function(item){ return item<1; });
+ // | // is false
+ // | dojo.some([1, 2, 3, 4], function(item){ return item<1; });
return everyOrSome(false, arr, callback, thisObject); // Boolean
},
@@ -192,7 +195,7 @@ define("dojo/_base/array", ["dojo/lib/kernel", "dojo/_base/lang"], function(dojo
// individual characters.
// callback:
// a function is invoked with three arguments, (item, index,
- // array), and returns a value
+ // array), and returns a value
// thisObject:
// may be used to scope the call to callback
// description:
@@ -202,10 +205,10 @@ define("dojo/_base/array", ["dojo/lib/kernel", "dojo/_base/lang"], function(dojo
// For more details, see:
// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/map
// example:
- // | // returns [2, 3, 4, 5]
- // | dojo.map([1, 2, 3, 4], function(item){ return item+1 });
+ // | // returns [2, 3, 4, 5]
+ // | dojo.map([1, 2, 3, 4], function(item){ return item+1 });
- var _p = _getParts(arr, thisObject, callback); arr = _p[0];
+ var _p = getParts(arr, thisObject, callback); arr = _p[0];
var outArr = (arguments[3] ? (new arguments[3]()) : []);
for(var i=0,l=arr.length; i<l; ++i){
outArr.push(_p[2].call(_p[1], arr[i], i, arr));
@@ -233,10 +236,10 @@ define("dojo/_base/array", ["dojo/lib/kernel", "dojo/_base/lang"], function(dojo
// For more details, see:
// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/filter
// example:
- // | // returns [2, 3, 4]
- // | dojo.filter([1, 2, 3, 4], function(item){ return item>1; });
+ // | // returns [2, 3, 4]
+ // | dojo.filter([1, 2, 3, 4], function(item){ return item>1; });
- var _p = _getParts(arr, thisObject, callback); arr = _p[0];
+ var _p = getParts(arr, thisObject, callback); arr = _p[0];
var outArr = [];
for(var i=0,l=arr.length; i<l; ++i){
if(_p[2].call(_p[1], arr[i], i, arr)){
@@ -246,26 +249,6 @@ define("dojo/_base/array", ["dojo/lib/kernel", "dojo/_base/lang"], function(dojo
return outArr; // Array
}
});
-})();
-//>>excludeEnd("webkitMobile");
-//>>excludeStart("webkitMobile", kwArgs.webkitMobile);
-/*
-//>>excludeEnd("webkitMobile");
-//>>includeStart("webkitMobile", kwArgs.webkitMobile);
-["indexOf", "lastIndexOf", "forEach", "map", "some", "every", "filter"].forEach(
- function(name, idx){
- dojo[name] = function(arr, callback, thisObj){
- if((idx > 1) && (typeof callback == "string")){
- callback = new Function("item", "index", "array", callback);
- }
- return Array.prototype[name].call(arr, callback, thisObj);
- }
- }
-);
-//>>includeEnd("webkitMobile");
-//>>excludeStart("webkitMobile", kwArgs.webkitMobile);
-*/
-//>>excludeEnd("webkitMobile");
-return dojo;
+ return dojo;
});
View
36 _base/browser.js
@@ -1,20 +1,20 @@
-define("dojo/_base/browser",[
-
-"dojo/_base/window",
-"dojo/_base/connect",
-"dojo/_base/event",
-"dojo/_base/html",
-"dojo/_base/NodeList",
-"dojo/_base/query",
-"dojo/_base/xhr",
-"dojo/_base/fx"
-], function(){
- //Need this to be the last code segment in base, so do not place any
- //dojo/requireIf calls in this file/ Otherwise, due to how the build system
- //puts all requireIf dependencies after the current file, the require calls
- //could be called before all of base is defined/
- dojo.forEach(dojo.config.require, function(i){
- dojo["require"](i);
- });
+define([
+ "./kernel",
+ "./sniff",
+ "./unload",
+ "./url",
+ "./window",
+ "./event",
+ "./html",
+ "./NodeList",
+ "./query",
+ "./xhr",
+ "./fx"], function(dojo) {
+ // module:
+ // dojo/_base/browser
+ // summary:
+ // This module causes the browser-only base modules to be loaded.
return dojo;
});
+
+
View
154 _base/config.js
@@ -0,0 +1,154 @@
+define(["../has", "require"], function(has, require){
+ // module:
+ // dojo/_base/config
+ // summary:
+ // This module processes the user configuration during bootstrap.
+
+ has.add("dojo-sniff",
+ // inspect script elements for data-dojo-config during bootstrap
+ has("dom") ? 1 : 0
+ );
+
+ var result= this.dojoConfig || this.djConfig || {};
+ if(has("dom") && has("dojo-sniff")){
+ // notice this loop breaks on first match
+ for (var config, src, match, scripts = document.getElementsByTagName("script"), i= 0; i<scripts.length && !match; i++) {
+ if ((src = scripts[i].getAttribute("src")) && (match = src.match(/(.*)\/?(dojo|require)\.js(\W|$)/i))) {
+ // consider baseUrl iff this is a dojo built-in AMD loader; otherwise it's just the location of the
+ // loader and may have nothing to do with dojo
+ if(match[2]=="dojo"){
+ result.baseUrl= match[1];
+ }
+
+ // see if there's a dojo configuration stuffed into the node
+ config= (scripts[i].getAttribute("data-dojo-config") || scripts[i].getAttribute("djConfig"));
+ if(config){
+ config= eval("({ "+config+" })\r\n//@ sourceURL=dojo/config/data-dojo-config");
+ for(var p in config){
+ result[p] = config[p];
+ }
+ }
+ }
+ }
+ }else{
+ var p, sniffedConfig= require.dojoConfig || {};
+ for(p in sniffedConfig){
+ result[p]= sniffedConfig[p];
+ }
+ }
+ return result;
+});
+
+/*=====
+// note:
+// 'dojoConfig' does not exist under 'dojo.*' so that it can be set before the
+// 'dojo' variable exists.
+// note:
+// Setting any of these variables *after* the library has loaded does
+// nothing at all.
+
+dojoConfig = {
+ // summary:
+ // Application code can set the global 'dojoConfig' prior to loading
+ // the library to controll certain global settings for how dojo works.
+ //
+ // isDebug: Boolean
+ // Defaults to `false`. If set to `true`, ensures that Dojo provides
+ // extended debugging feedback via Firebug. If Firebug is not available
+ // on your platform, setting `isDebug` to `true` will force Dojo to
+ // pull in (and display) the version of Firebug Lite which is
+ // integrated into the Dojo distribution, thereby always providing a
+ // debugging/logging console when `isDebug` is enabled. Note that
+ // Firebug's `console.*` methods are ALWAYS defined by Dojo. If
+ // `isDebug` is false and you are on a platform without Firebug, these
+ // methods will be defined as no-ops.
+ isDebug: false,
+ // locale: String
+ // The locale to assume for loading localized resources in this page,
+ // specified according to [RFC 3066](http://www.ietf.org/rfc/rfc3066.txt).
+ // Must be specified entirely in lowercase, e.g. `en-us` and `zh-cn`.
+ // See the documentation for `dojo.i18n` and `dojo.requireLocalization`
+ // for details on loading localized resources. If no locale is specified,
+ // Dojo assumes the locale of the user agent, according to `navigator.userLanguage`
+ // or `navigator.language` properties.
+ locale: undefined,
+ // extraLocale: Array
+ // No default value. Specifies additional locales whose
+ // resources should also be loaded alongside the default locale when
+ // calls to `dojo.requireLocalization()` are processed.
+ extraLocale: undefined,
+ // baseUrl: String
+ // The directory in which `dojo.js` is located. Under normal
+ // conditions, Dojo auto-detects the correct location from which it
+ // was loaded. You may need to manually configure `baseUrl` in cases
+ // where you have renamed `dojo.js` or in which `<base>` tags confuse
+ // some browsers (e.g. IE 6). The variable `dojo.baseUrl` is assigned
+ // either the value of `djConfig.baseUrl` if one is provided or the
+ // auto-detected root if not. Other modules are located relative to
+ // this path. The path should end in a slash.
+ baseUrl: undefined,
+ // modulePaths: Object
+ // A map of module names to paths relative to `dojo.baseUrl`. The
+ // key/value pairs correspond directly to the arguments which
+ // `dojo.registerModulePath` accepts. Specifiying
+ // `djConfig.modulePaths = { "foo": "../../bar" }` is the equivalent
+ // of calling `dojo.registerModulePath("foo", "../../bar");`. Multiple
+ // modules may be configured via `djConfig.modulePaths`.
+ modulePaths: {},
+ // afterOnLoad: Boolean
+ // Indicates Dojo was added to the page after the page load. In this case
+ // Dojo will not wait for the page DOMContentLoad/load events and fire
+ // its dojo.addOnLoad callbacks after making sure all outstanding
+ // dojo.required modules have loaded. Only works with a built dojo.js,
+ // it does not work the dojo.js directly from source control.
+ afterOnLoad: false,
+ // addOnLoad: Function or Array
+ // Adds a callback via dojo.addOnLoad. Useful when Dojo is added after
+ // the page loads and djConfig.afterOnLoad is true. Supports the same
+ // arguments as dojo.addOnLoad. When using a function reference, use
+ // `djConfig.addOnLoad = function(){};`. For object with function name use
+ // `djConfig.addOnLoad = [myObject, "functionName"];` and for object with
+ // function reference use
+ // `djConfig.addOnLoad = [myObject, function(){}];`
+ addOnLoad: null,
+ // require: Array
+ // An array of module names to be loaded immediately after dojo.js has been included
+ // in a page.
+ require: [],
+ // defaultDuration: Array
+ // Default duration, in milliseconds, for wipe and fade animations within dijits.
+ // Assigned to dijit.defaultDuration.
+ defaultDuration: 200,
+ // dojoBlankHtmlUrl: String
+ // Used by some modules to configure an empty iframe. Used by dojo.io.iframe and
+ // dojo.back, and dijit popup support in IE where an iframe is needed to make sure native
+ // controls do not bleed through the popups. Normally this configuration variable
+ // does not need to be set, except when using cross-domain/CDN Dojo builds.
+ // Save dojo/resources/blank.html to your domain and set `djConfig.dojoBlankHtmlUrl`
+ // to the path on your domain your copy of blank.html.
+ dojoBlankHtmlUrl: undefined,
+ // ioPublish: Boolean?
+ // Set this to true to enable publishing of topics for the different phases of
+ // IO operations. Publishing is done via dojo.publish. See dojo.__IoPublish for a list
+ // of topics that are published.
+ ioPublish: false,
+ // useCustomLogger: Anything?
+ // If set to a value that evaluates to true such as a string or array and
+ // isDebug is true and Firebug is not available or running, then it bypasses
+ // the creation of Firebug Lite allowing you to define your own console object.
+ useCustomLogger: undefined,
+ // transparentColor: Array
+ // Array containing the r, g, b components used as transparent color in dojo.Color;
+ // if undefined, [255,255,255] (white) will be used.
+ transparentColor: undefined,
+ // skipIeDomLoaded: Boolean
+ // For IE only, skip the DOMContentLoaded hack used. Sometimes it can cause an Operation
+ // Aborted error if the rest of the page triggers script defers before the DOM is ready.
+ // If this is config value is set to true, then dojo.addOnLoad callbacks will not be
+ // triggered until the page load event, which is after images and iframes load. If you
+ // want to trigger the callbacks sooner, you can put a script block in the bottom of
+ // your HTML that calls dojo._loadInit();. If you are using multiversion support, change
+ // "dojo." to the appropriate scope name for dojo.
+ skipIeDomLoaded: false
+}
+=====*/
View
89 _base/configNode.js
@@ -0,0 +1,89 @@
+exports.config= function(config) {
+ // summary:
+ // This module provides bootstrap configuration for running dojo in node.js
+
+ // any command line arguments with the load flag are pushed into deps
+ for (var deps= [], args= [], i= 0; i<process.argv.length; i++) {
+ var arg= (process.argv[i]+"").split("=");
+ if (arg[0]=="load") {
+ deps.push(arg[1]);
+ } else {
+ args.push(arg);
+ }
+ }
+
+ var fs= require("fs");
+
+ // make sure global require exists
+ //if (typeof global.require=="undefined") {
+ // global.require= {};
+ //}
+
+ // reset the has cache with node-appropriate values;
+ var hasCache= {
+ "host-node":1,
+ "host-browser":0,
+ "dom":0,
+ "loader-hasApi":1,
+ "loader-provides-xhr":0,
+ "loader-injectApi":1,
+ "loader-timeoutApi":0,
+ "loader-traceApi":1,
+ "loader-catchApi":1,
+ "loader-pageLoadApi":0,
+ "loader-priority-readyApi":1,
+ "loader-errorApi":1,
+ "loader-publish-privates":1,
+ "loader-getTextApi":1,
+ "dojo-sniff":0,
+ "dojo-loader":1,
+ "dojo-boot":1,
+ "dojo-test-xd":0,
+ "dojo-test-sniff":0
+ };
+ for (var p in hasCache) {
+ config.hasCache[p]= hasCache[p];
+ }
+
+
+ // reset some configuration switches with node-appropriate values
+ var nodeConfig= {
+ baseUrl: __dirname.match(/(.+)\/_base$/)[1],
+ isBrowser:0,
+ commandLineArgs:args,
+ deps:deps,
+
+ // TODO: really get the locale
+ locale:"us-en",
+
+ debug: function(item) {
+ // define debug for console messages during dev instead of console.log
+ // (node's heavy async makes console.log confusing sometimes)
+ require("util").debug(item);
+ },
+
+ eval: function(__text, __urlHint) {
+ return process.compile(__text, __urlHint);
+ },
+
+ injectUrl: function(url, callback) {
+ try {
+ process.compile(fs.readFileSync(url, "utf8"), url);
+ callback();
+ } catch(e) {
+ console.log("failed to load resource (" + url + ")");
+ console.log(e);
+ }
+ },
+
+ getXhr: 0,
+
+ getText: function(url, sync, onLoad){
+ // TODO: implement async and http/https handling
+ onLoad(fs.readFileSync(url, "utf8"));
+ }
+ };
+ for (p in nodeConfig) {
+ config[p]= nodeConfig[p];
+ }
+};
View
131 _base/configRhino.js
@@ -0,0 +1,131 @@
+function rhinoDojoConfig(config, baseUrl, rhinoArgs) {
+ // summary:
+ // This module provides bootstrap configuration for running dojo in rhino.
+
+ // TODO: v1.6 tries to set dojo.doc and dojo.body in rhino; why?
+
+ // get a minimal console up
+ var log= function(hint, args) {
+ print((hint ? hint + ":" : "") + args[0]);
+ for (var i= 1; i<args.length; i++) {
+ print(", " + args[i]);
+ }
+ };
+ // intentionally define console in the global namespace
+ console= {
+ log: function(){ log(0, arguments); },
+ error: function(){ log("ERROR", arguments); },
+ warn: function(){ log("WARN", arguments); }
+ };
+
+ // any command line arguments with the load flag are pushed into deps
+ for (var deps= [], i= 0; i<rhinoArgs.length; i++) {
+ var arg= (rhinoArgs[i]+"").split("=");
+ if (arg[0]=="load") {
+ deps.push(arg[1]);
+ }
+ }
+
+ // provides timed callbacks using Java threads
+ if(typeof setTimeout == "undefined" || typeof clearTimeout == "undefined"){
+ var timeouts = [];
+ clearTimeout = function(idx){
+ if(!timeouts[idx]){ return; }
+ timeouts[idx].stop();
+ };
+
+ setTimeout = function(func, delay){
+ var def={
+ sleepTime:delay,
+ hasSlept:false,
+
+ run:function(){
+ if(!this.hasSlept){
+ this.hasSlept=true;
+ java.lang.Thread.currentThread().sleep(this.sleepTime);
+ }
+ try{
+ func();
+ }catch(e){
+ console.debug("Error running setTimeout thread:" + e);
+ }
+ }
+ };
+
+ var runnable = new java.lang.Runnable(def);
+ var thread = new java.lang.Thread(runnable);
+ thread.start();
+ return timeouts.push(thread)-1;
+ };
+ }
+
+ var isLocal= function(url) {
+ return (new java.io.File(url)).exists();
+ };
+
+ // make sure global require exists
+ //if (typeof require=="undefined") {
+ // require= {};
+ // }
+
+ // reset the has cache with node-appropriate values;
+ var hasCache= {
+ "host-rhino":1,
+ "host-browser":0,
+ "dom":0,
+ "loader-hasApi":1,
+ "loader-provides-xhr":0,
+ "loader-injectApi":1,
+ "loader-timeoutApi":0,
+ "loader-traceApi":1,
+ "loader-catchApi":1,
+ "loader-pageLoadApi":0,
+ "loader-priority-readyApi":1,
+ "loader-errorApi":1,
+ "loader-publish-privates":1,
+ "loader-getTextApi":1,
+ "dojo-sniff":0,
+ "dojo-loader":1,
+ "dojo-boot":1,
+ "dojo-test-xd":0,
+ "dojo-test-sniff":0
+ };
+ for (var p in hasCache) {
+ config.hasCache[p]= hasCache[p];
+ }
+
+ // reset some configuration switches with rhino-appropriate values
+ var rhinoConfig= {
+ baseUrl:baseUrl,
+ isBrowser:0,
+ commandLineArgs:rhinoArgs,
+ deps:deps,
+ timeout:0,
+ locale:String(java.util.Locale.getDefault().toString().replace('_','-').toLowerCase()),
+
+ injectUrl: function(url, callback) {
+ try {
+ if (isLocal(url)) {
+ load(url);
+ } else {
+ require.eval(readUrl(url, "UTF-8"));
+ }
+ callback();
+ } catch(e) {
+ console.log("failed to load resource (" + url + ")");
+ console.log(e);
+ }
+ },
+
+ getXhr: 0,
+
+ getText: function(url, sync, onLoad) {
+ // TODO: test https://bugzilla.mozilla.org/show_bug.cgi?id=471005; see v1.6 hostenv_rhino
+ // note: async mode not supported in rhino
+ onLoad(isLocal(url) ? readFile(url, "UTF-8") : readUrl(url, "UTF-8"));
+ }
+ };
+ for (p in rhinoConfig) {
+ config[p]= rhinoConfig[p];
+ }
+}
View