sproutcore 1.5.0.rc.1 → 1.5.0.rc.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (193) hide show
  1. data/CHANGELOG +4 -0
  2. data/VERSION.yml +1 -1
  3. data/lib/frameworks/sproutcore/Buildfile +9 -4
  4. data/lib/frameworks/sproutcore/README.md +1 -0
  5. data/lib/frameworks/sproutcore/design/{TestRunner_Design.gaffle → TestRunner_Design.graffle}/QuickLook/Preview.pdf +0 -0
  6. data/lib/frameworks/sproutcore/design/{TestRunner_Design.gaffle → TestRunner_Design.graffle}/QuickLook/Thumbnail.tiff +0 -0
  7. data/lib/frameworks/sproutcore/design/{TestRunner_Design.gaffle → TestRunner_Design.graffle}/data.plist +0 -0
  8. data/lib/frameworks/sproutcore/design/{TestRunner_Design.gaffle → TestRunner_Design.graffle}/image10.png +0 -0
  9. data/lib/frameworks/sproutcore/design/{TestRunner_Design.gaffle → TestRunner_Design.graffle}/image11.png +0 -0
  10. data/lib/frameworks/sproutcore/design/{TestRunner_Design.gaffle → TestRunner_Design.graffle}/image13.png +0 -0
  11. data/lib/frameworks/sproutcore/design/{TestRunner_Design.gaffle → TestRunner_Design.graffle}/image15.png +0 -0
  12. data/lib/frameworks/sproutcore/design/{TestRunner_Design.gaffle → TestRunner_Design.graffle}/image16.png +0 -0
  13. data/lib/frameworks/sproutcore/design/{TestRunner_Design.gaffle → TestRunner_Design.graffle}/image17.png +0 -0
  14. data/lib/frameworks/sproutcore/design/{TestRunner_Design.gaffle → TestRunner_Design.graffle}/image18.png +0 -0
  15. data/lib/frameworks/sproutcore/design/{TestRunner_Design.gaffle → TestRunner_Design.graffle}/image19.png +0 -0
  16. data/lib/frameworks/sproutcore/design/{TestRunner_Design.gaffle → TestRunner_Design.graffle}/image22.tiff +0 -0
  17. data/lib/frameworks/sproutcore/design/{TestRunner_Design.gaffle → TestRunner_Design.graffle}/image23.png +0 -0
  18. data/lib/frameworks/sproutcore/design/{TestRunner_Design.gaffle → TestRunner_Design.graffle}/image24.png +0 -0
  19. data/lib/frameworks/sproutcore/design/{TestRunner_Design.gaffle → TestRunner_Design.graffle}/image25.png +0 -0
  20. data/lib/frameworks/sproutcore/design/{TestRunner_Design.gaffle → TestRunner_Design.graffle}/image30.png +0 -0
  21. data/lib/frameworks/sproutcore/design/{TestRunner_Design.gaffle → TestRunner_Design.graffle}/image31.png +0 -0
  22. data/lib/frameworks/sproutcore/design/{TestRunner_Design.gaffle → TestRunner_Design.graffle}/image8.png +0 -0
  23. data/lib/frameworks/sproutcore/design/{TestRunner_Design.gaffle → TestRunner_Design.graffle}/image9.png +0 -0
  24. data/lib/frameworks/sproutcore/frameworks/animation/core.js +23 -25
  25. data/lib/frameworks/sproutcore/frameworks/bootstrap/system/browser.js +160 -0
  26. data/lib/frameworks/sproutcore/frameworks/core_foundation/controllers/array.js +73 -82
  27. data/lib/frameworks/sproutcore/frameworks/core_foundation/core.js +1 -3
  28. data/lib/frameworks/sproutcore/frameworks/{handlebars/extensions → core_foundation/ext/handlebars}/bind.js +110 -7
  29. data/lib/frameworks/sproutcore/frameworks/{handlebars/extensions → core_foundation/ext/handlebars}/collection.js +10 -7
  30. data/lib/frameworks/sproutcore/frameworks/{handlebars/extensions → core_foundation/ext/handlebars}/localization.js +1 -1
  31. data/lib/frameworks/sproutcore/frameworks/{handlebars/extensions → core_foundation/ext/handlebars}/view.js +4 -2
  32. data/lib/frameworks/sproutcore/frameworks/{handlebars/extensions.js → core_foundation/ext/handlebars.js} +0 -57
  33. data/lib/frameworks/sproutcore/frameworks/core_foundation/ext/object.js +1 -3
  34. data/lib/frameworks/sproutcore/frameworks/core_foundation/mixins/template_helpers/text_field_support.js +11 -0
  35. data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/main.js +1 -3
  36. data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/pane.js +2 -4
  37. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/application.js +14 -16
  38. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/builder.js +29 -37
  39. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/datetime.js +0 -0
  40. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/event.js +71 -19
  41. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/locale.js +3 -7
  42. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/page.js +5 -7
  43. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/selection_set.js +1 -3
  44. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/sparse_array.js +4 -0
  45. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/timer.js +21 -27
  46. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/utils.js +3 -5
  47. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/controllers/array/array_case.js +3 -3
  48. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/controllers/object/single_enumerable_case.js +1 -1
  49. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/system/sparse_array.js +1 -1
  50. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/template/handlebars.js +93 -1
  51. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/clippingFrame.js +1 -1
  52. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/convertLayouts.js +13 -11
  53. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layer.js +2 -6
  54. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layoutStyle.js +4 -4
  55. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/theme.js +2 -0
  56. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/view.js +4 -4
  57. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/template.js +6 -2
  58. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/template_collection.js +87 -32
  59. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/layout.js +21 -25
  60. data/lib/frameworks/sproutcore/frameworks/datastore/data_sources/cascade.js +15 -19
  61. data/lib/frameworks/sproutcore/frameworks/datastore/data_sources/data_source.js +114 -167
  62. data/lib/frameworks/sproutcore/frameworks/datastore/data_sources/fixtures.js +4 -4
  63. data/lib/frameworks/sproutcore/frameworks/datastore/models/child_attribute.js +4 -6
  64. data/lib/frameworks/sproutcore/frameworks/datastore/models/children_attribute.js +2 -4
  65. data/lib/frameworks/sproutcore/frameworks/datastore/models/fetched_attribute.js +7 -7
  66. data/lib/frameworks/sproutcore/frameworks/datastore/models/many_attribute.js +18 -20
  67. data/lib/frameworks/sproutcore/frameworks/datastore/models/record.js +74 -72
  68. data/lib/frameworks/sproutcore/frameworks/datastore/models/record_attribute.js +36 -29
  69. data/lib/frameworks/sproutcore/frameworks/datastore/models/single_attribute.js +2 -2
  70. data/lib/frameworks/sproutcore/frameworks/datastore/system/child_array.js +97 -78
  71. data/lib/frameworks/sproutcore/frameworks/datastore/system/many_array.js +117 -97
  72. data/lib/frameworks/sproutcore/frameworks/datastore/system/nested_store.js +13 -13
  73. data/lib/frameworks/sproutcore/frameworks/datastore/system/query.js +111 -108
  74. data/lib/frameworks/sproutcore/frameworks/datastore/system/record_array.js +231 -198
  75. data/lib/frameworks/sproutcore/frameworks/datastore/system/store.js +146 -145
  76. data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/query/builders.js +21 -21
  77. data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/record_array/flush.js +49 -50
  78. data/lib/frameworks/sproutcore/frameworks/datetime/{system → frameworks/core/system}/datetime.js +122 -171
  79. data/lib/frameworks/sproutcore/frameworks/datetime/{tests → frameworks/core/tests}/system/datetime.js +0 -0
  80. data/lib/frameworks/sproutcore/frameworks/datetime/{resources → frameworks/localized/resources}/strings.js +0 -0
  81. data/lib/frameworks/sproutcore/frameworks/datetime/frameworks/localized/system/datetime.js +91 -0
  82. data/lib/frameworks/sproutcore/frameworks/desktop/core.js +18 -2
  83. data/lib/frameworks/sproutcore/frameworks/desktop/mixins/border.js +23 -16
  84. data/lib/frameworks/sproutcore/frameworks/desktop/mixins/collection_fast_path.js +56 -45
  85. data/lib/frameworks/sproutcore/frameworks/desktop/mixins/collection_group.js +5 -2
  86. data/lib/frameworks/sproutcore/frameworks/desktop/mixins/collection_row_delegate.js +21 -19
  87. data/lib/frameworks/sproutcore/frameworks/desktop/mixins/collection_view_delegate.js +82 -77
  88. data/lib/frameworks/sproutcore/frameworks/desktop/mixins/navigation_builder.js +18 -12
  89. data/lib/frameworks/sproutcore/frameworks/desktop/mixins/scrollable.js +29 -17
  90. data/lib/frameworks/sproutcore/frameworks/desktop/panes/alert.js +148 -107
  91. data/lib/frameworks/sproutcore/frameworks/desktop/panes/menu.js +31 -16
  92. data/lib/frameworks/sproutcore/frameworks/desktop/panes/modal.js +16 -13
  93. data/lib/frameworks/sproutcore/frameworks/desktop/panes/palette.js +38 -17
  94. data/lib/frameworks/sproutcore/frameworks/desktop/panes/panel.js +37 -25
  95. data/lib/frameworks/sproutcore/frameworks/desktop/panes/picker.js +247 -144
  96. data/lib/frameworks/sproutcore/frameworks/desktop/panes/select_button.js +155 -100
  97. data/lib/frameworks/sproutcore/frameworks/desktop/panes/sheet.js +39 -17
  98. data/lib/frameworks/sproutcore/frameworks/desktop/protocols/drag_data_source.js +9 -6
  99. data/lib/frameworks/sproutcore/frameworks/desktop/protocols/drag_source.js +18 -22
  100. data/lib/frameworks/sproutcore/frameworks/desktop/protocols/drop_target.js +27 -17
  101. data/lib/frameworks/sproutcore/frameworks/desktop/system/drag.js +77 -44
  102. data/lib/frameworks/sproutcore/frameworks/desktop/system/undo_manager.js +68 -33
  103. data/lib/frameworks/sproutcore/frameworks/desktop/views/button.js +168 -110
  104. data/lib/frameworks/sproutcore/frameworks/desktop/views/checkbox.js +37 -5
  105. data/lib/frameworks/sproutcore/frameworks/desktop/views/collection.js +187 -123
  106. data/lib/frameworks/sproutcore/frameworks/desktop/views/date_field.js +73 -49
  107. data/lib/frameworks/sproutcore/frameworks/desktop/views/disclosure.js +34 -9
  108. data/lib/frameworks/sproutcore/frameworks/desktop/views/file.js +51 -14
  109. data/lib/frameworks/sproutcore/frameworks/desktop/views/grid.js +38 -8
  110. data/lib/frameworks/sproutcore/frameworks/desktop/views/image_button.js +15 -9
  111. data/lib/frameworks/sproutcore/frameworks/desktop/views/list.js +54 -34
  112. data/lib/frameworks/sproutcore/frameworks/desktop/views/list_item.js +113 -42
  113. data/lib/frameworks/sproutcore/frameworks/desktop/views/master_detail.js +84 -28
  114. data/lib/frameworks/sproutcore/frameworks/desktop/views/menu_item.js +67 -51
  115. data/lib/frameworks/sproutcore/frameworks/desktop/views/menu_scroll.js +122 -35
  116. data/lib/frameworks/sproutcore/frameworks/desktop/views/navigation.js +40 -16
  117. data/lib/frameworks/sproutcore/frameworks/desktop/views/navigation_bar.js +28 -18
  118. data/lib/frameworks/sproutcore/frameworks/desktop/views/popup_button.js +27 -31
  119. data/lib/frameworks/sproutcore/frameworks/desktop/views/progress.js +118 -68
  120. data/lib/frameworks/sproutcore/frameworks/desktop/views/radio.js +117 -61
  121. data/lib/frameworks/sproutcore/frameworks/desktop/views/scene.js +23 -16
  122. data/lib/frameworks/sproutcore/frameworks/desktop/views/scroll.js +241 -77
  123. data/lib/frameworks/sproutcore/frameworks/desktop/views/scroller.js +134 -69
  124. data/lib/frameworks/sproutcore/frameworks/desktop/views/segment.js +107 -25
  125. data/lib/frameworks/sproutcore/frameworks/desktop/views/segmented.js +125 -48
  126. data/lib/frameworks/sproutcore/frameworks/desktop/views/select.js +165 -69
  127. data/lib/frameworks/sproutcore/frameworks/desktop/views/select_field.js +73 -24
  128. data/lib/frameworks/sproutcore/frameworks/desktop/views/separator.js +19 -5
  129. data/lib/frameworks/sproutcore/frameworks/desktop/views/source_list.js +16 -4
  130. data/lib/frameworks/sproutcore/frameworks/desktop/views/source_list_group.js +14 -7
  131. data/lib/frameworks/sproutcore/frameworks/desktop/views/split.js +43 -37
  132. data/lib/frameworks/sproutcore/frameworks/desktop/views/split_divider.js +8 -1
  133. data/lib/frameworks/sproutcore/frameworks/desktop/views/stacked.js +14 -3
  134. data/lib/frameworks/sproutcore/frameworks/desktop/views/static_content.js +16 -2
  135. data/lib/frameworks/sproutcore/frameworks/desktop/views/tab.js +99 -0
  136. data/lib/frameworks/sproutcore/frameworks/desktop/views/thumb.js +13 -1
  137. data/lib/frameworks/sproutcore/frameworks/desktop/views/toolbar.js +58 -8
  138. data/lib/frameworks/sproutcore/frameworks/desktop/views/web.js +34 -18
  139. data/lib/frameworks/sproutcore/frameworks/desktop/views/well.js +25 -9
  140. data/lib/frameworks/sproutcore/frameworks/desktop/views/workspace.js +70 -36
  141. data/lib/frameworks/sproutcore/frameworks/foundation/controllers/tree.js +10 -5
  142. data/lib/frameworks/sproutcore/frameworks/foundation/debug/control_test_pane.js +28 -17
  143. data/lib/frameworks/sproutcore/frameworks/foundation/delegates/inline_text_field.js +41 -43
  144. data/lib/frameworks/sproutcore/frameworks/foundation/gestures/pinch.js +42 -4
  145. data/lib/frameworks/sproutcore/frameworks/foundation/gestures/swipe.js +94 -4
  146. data/lib/frameworks/sproutcore/frameworks/foundation/gestures/tap.js +41 -1
  147. data/lib/frameworks/sproutcore/frameworks/foundation/mixins/auto_mixin.js +2 -0
  148. data/lib/frameworks/sproutcore/frameworks/foundation/mixins/auto_resize.js +18 -9
  149. data/lib/frameworks/sproutcore/frameworks/foundation/mixins/collection_content.js +7 -5
  150. data/lib/frameworks/sproutcore/frameworks/foundation/mixins/content_display.js +7 -8
  151. data/lib/frameworks/sproutcore/frameworks/foundation/mixins/content_value_support.js +34 -24
  152. data/lib/frameworks/sproutcore/frameworks/foundation/mixins/control.js +48 -18
  153. data/lib/frameworks/sproutcore/frameworks/foundation/mixins/inline_text_field.js +1 -0
  154. data/lib/frameworks/sproutcore/frameworks/foundation/system/utils/misc.js +1 -2
  155. data/lib/frameworks/sproutcore/frameworks/foundation/tasks/preload_bundle.js +1 -1
  156. data/lib/frameworks/sproutcore/frameworks/foundation/tests/mixins/inline_text_field/beginEditing.js +0 -11
  157. data/lib/frameworks/sproutcore/frameworks/foundation/validators/date_time.js +1 -1
  158. data/lib/frameworks/sproutcore/frameworks/foundation/views/text_field.js +8 -0
  159. data/lib/frameworks/sproutcore/frameworks/qunit/README.md +24 -0
  160. data/lib/frameworks/sproutcore/frameworks/qunit/package.json +21 -0
  161. data/lib/frameworks/sproutcore/frameworks/qunit/qunit/qunit.css +215 -0
  162. data/lib/frameworks/sproutcore/frameworks/qunit/qunit/qunit.js +1442 -0
  163. data/lib/frameworks/sproutcore/frameworks/qunit/test/headless.html +24 -0
  164. data/lib/frameworks/sproutcore/frameworks/qunit/test/index.html +18 -0
  165. data/lib/frameworks/sproutcore/frameworks/qunit/test/logs.html +17 -0
  166. data/lib/frameworks/sproutcore/frameworks/qunit/test/logs.js +150 -0
  167. data/lib/frameworks/sproutcore/frameworks/qunit/test/same.js +1421 -0
  168. data/lib/frameworks/sproutcore/frameworks/qunit/test/test.js +314 -0
  169. data/lib/frameworks/sproutcore/frameworks/runtime/core.js +1 -1
  170. data/lib/frameworks/sproutcore/frameworks/runtime/mixins/array.js +369 -60
  171. data/lib/frameworks/sproutcore/frameworks/runtime/mixins/enumerable.js +2 -405
  172. data/lib/frameworks/sproutcore/frameworks/runtime/mixins/observable.js +3 -9
  173. data/lib/frameworks/sproutcore/frameworks/runtime/private/property_chain.js +50 -45
  174. data/lib/frameworks/sproutcore/frameworks/runtime/system/binding.js +20 -1
  175. data/lib/frameworks/sproutcore/frameworks/runtime/system/object.js +0 -9
  176. data/lib/frameworks/sproutcore/frameworks/runtime/tests/core/guidFor.js +1 -1
  177. data/lib/frameworks/sproutcore/frameworks/runtime/tests/mixins/array.js +36 -14
  178. data/lib/frameworks/sproutcore/frameworks/runtime/tests/mixins/enumerable/enumerable.js +0 -34
  179. data/lib/frameworks/sproutcore/frameworks/runtime/tests/mixins/enumerable/enumerable_observers.js +50 -61
  180. data/lib/frameworks/sproutcore/frameworks/runtime/tests/mixins/observable/observable.js +2 -2
  181. data/lib/frameworks/sproutcore/frameworks/runtime/tests/mixins/observable/propertyChanges.js +1 -1
  182. data/lib/frameworks/sproutcore/frameworks/runtime/tests/mixins/observable/registerDependentKeys.js +45 -1
  183. data/lib/frameworks/sproutcore/frameworks/runtime/tests/mixins/propertyChanges.js +1 -1
  184. data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/object/bindings.js +5 -0
  185. data/lib/frameworks/sproutcore/frameworks/runtime/tests/system/object/enhance.js +1 -1
  186. data/lib/frameworks/sproutcore/frameworks/testing/core.js +3 -0
  187. data/lib/frameworks/sproutcore/frameworks/testing/system/plan.js +0 -1
  188. data/lib/frameworks/sproutcore/frameworks/testing/system/runner.js +0 -1
  189. data/lib/gen/html_app/templates/apps/@target_name@/@target_name@.js +1 -1
  190. data/vendor/chance/lib/chance/instance.rb +8 -6
  191. metadata +41 -31
  192. data/lib/frameworks/sproutcore/frameworks/testing/jquery.js +0 -3559
  193. data/lib/frameworks/sproutcore/frameworks/testing/qunit.js +0 -827
@@ -1,827 +0,0 @@
1
- /*
2
- * QUnit - jQuery unit testrunner
3
- *
4
- * http://docs.jquery.com/QUnit
5
- *
6
- * Copyright (c) 2008 John Resig, Jörn Zaefferer
7
- * Dual licensed under the MIT (MIT-LICENSE.txt)
8
- * and GPL (GPL-LICENSE.txt) licenses.
9
- *
10
- */
11
-
12
- // NOTE: This version of Qunit has been tweaked slightly to use a private
13
- // version of jQuery (called Q$). You should be able to merge this file with
14
- // changes from the main Qunit though with only minor effort.
15
- sc_require('jquery');
16
-
17
-
18
- (function($) {
19
-
20
- // Tests for equality any JavaScript type and structure without unexpected results.
21
- // Discussions and reference: http://philrathe.com/articles/equiv
22
- // Test suites: http://philrathe.com/tests/equiv
23
- // Author: Philippe Rathé <prathe@gmail.com>
24
- var equiv = function () {
25
-
26
- var innerEquiv; // the real equiv function
27
- var callers = []; // stack to decide between skip/abort functions
28
-
29
- // Determine what is o.
30
- function hoozit(o) {
31
- if (typeof o === "string") {
32
- return "string";
33
-
34
- } else if (typeof o === "boolean") {
35
- return "boolean";
36
-
37
- } else if (typeof o === "number") {
38
-
39
- if (isNaN(o)) {
40
- return "nan";
41
- } else {
42
- return "number";
43
- }
44
-
45
- } else if (typeof o === "undefined") {
46
- return "undefined";
47
-
48
- // consider: typeof null === object
49
- } else if (o === null) {
50
- return "null";
51
-
52
- // consider: typeof [] === object
53
- } else if (o instanceof Array) {
54
- return "array";
55
-
56
- // consider: typeof new Date() === object
57
- } else if (o instanceof Date) {
58
- return "date";
59
-
60
- // consider: /./ instanceof Object;
61
- // /./ instanceof RegExp;
62
- // typeof /./ === "function"; // => false in IE and Opera,
63
- // true in FF and Safari
64
- } else if (o instanceof RegExp) {
65
- return "regexp";
66
-
67
- } else if (typeof o === "object") {
68
- return "object";
69
-
70
- } else if (o instanceof Function) {
71
- return "function";
72
- }
73
- }
74
-
75
- // Call the o related callback with the given arguments.
76
- function bindCallbacks(o, callbacks, args) {
77
- var prop = hoozit(o);
78
- if (prop) {
79
- if (hoozit(callbacks[prop]) === "function") {
80
- return callbacks[prop].apply(callbacks, args);
81
- } else {
82
- return callbacks[prop]; // or undefined
83
- }
84
- }
85
- }
86
-
87
- var callbacks = function () {
88
-
89
- // for string, boolean, number and null
90
- function useStrictEquality(b, a) {
91
- return a === b;
92
- }
93
-
94
- return {
95
- "string": useStrictEquality,
96
- "boolean": useStrictEquality,
97
- "number": useStrictEquality,
98
- "null": useStrictEquality,
99
- "undefined": useStrictEquality,
100
-
101
- "nan": function (b) {
102
- return isNaN(b);
103
- },
104
-
105
- "date": function (b, a) {
106
- return hoozit(b) === "date" && a.valueOf() === b.valueOf();
107
- },
108
-
109
- "regexp": function (b, a) {
110
- return hoozit(b) === "regexp" &&
111
- a.source === b.source && // the regex itself
112
- a.global === b.global && // and its modifers (gmi) ...
113
- a.ignoreCase === b.ignoreCase &&
114
- a.multiline === b.multiline;
115
- },
116
-
117
- // - skip when the property is a method of an instance (OOP)
118
- // - abort otherwise,
119
- // initial === would have catch identical references anyway
120
- "function": function () {
121
- var caller = callers[callers.length - 1];
122
- return caller !== Object &&
123
- typeof caller !== "undefined";
124
- },
125
-
126
- "array": function (b, a) {
127
- var i;
128
- var len;
129
-
130
- // b could be an object literal here
131
- if ( ! (hoozit(b) === "array")) {
132
- return false;
133
- }
134
-
135
- len = a.length;
136
- if (len !== b.length) { // safe and faster
137
- return false;
138
- }
139
- for (i = 0; i < len; i++) {
140
- if( ! innerEquiv(a[i], b[i])) {
141
- return false;
142
- }
143
- }
144
- return true;
145
- },
146
-
147
- "object": function (b, a) {
148
- var i;
149
- var eq = true; // unless we can proove it
150
- var aProperties = [], bProperties = []; // collection of strings
151
-
152
- // comparing constructors is more strict than using instanceof
153
- if ( a.constructor !== b.constructor) {
154
- return false;
155
- }
156
-
157
- // stack constructor before traversing properties
158
- callers.push(a.constructor);
159
-
160
- for (i in a) { // be strict: don't ensures hasOwnProperty and go deep
161
-
162
- aProperties.push(i); // collect a's properties
163
-
164
- if ( ! innerEquiv(a[i], b[i])) {
165
- eq = false;
166
- }
167
- }
168
-
169
- callers.pop(); // unstack, we are done
170
-
171
- for (i in b) {
172
- bProperties.push(i); // collect b's properties
173
- }
174
-
175
- // Ensures identical properties name
176
- return eq && innerEquiv(aProperties.sort(), bProperties.sort());
177
- }
178
- };
179
- }();
180
-
181
- innerEquiv = function () { // can take multiple arguments
182
- var args = Array.prototype.slice.apply(arguments);
183
- if (args.length < 2) {
184
- return true; // end transition
185
- }
186
-
187
- return (function (a, b) {
188
- if (a === b) {
189
- return true; // catch the most you can
190
-
191
- } else if (typeof a !== typeof b || a === null || b === null || typeof a === "undefined" || typeof b === "undefined") {
192
- return false; // don't lose time with error prone cases
193
-
194
- } else {
195
- return bindCallbacks(a, callbacks, [b, a]);
196
- }
197
-
198
- // apply transition with (1..n) arguments
199
- })(args[0], args[1]) && arguments.callee.apply(this, args.splice(1, args.length -1));
200
- };
201
-
202
- return innerEquiv;
203
- }(); // equiv
204
-
205
- var GETParams = $.map( location.search.slice(1).split('&'), decodeURIComponent ),
206
- ngindex = $.inArray("noglobals", GETParams),
207
- noglobals = ngindex !== -1;
208
-
209
- if( noglobals )
210
- GETParams.splice( ngindex, 1 );
211
-
212
- var config = {
213
- stats: {
214
- all: 0,
215
- bad: 0
216
- },
217
- queue: [],
218
- // block until document ready
219
- blocking: true,
220
- //restrict modules/tests by get parameters
221
- filters: GETParams,
222
- isLocal: !!(window.location.protocol == 'file:')
223
- };
224
-
225
- // public API as global methods
226
- $.extend(window, {
227
- test: test,
228
- module: module,
229
- expect: expect,
230
- ok: ok,
231
- equals: equals,
232
- start: start,
233
- stop: stop,
234
- reset: reset,
235
- synchronize: synchronize,
236
- isLocal: config.isLocal,
237
- same: function(a, b, message) {
238
- push(equiv(a, b), a, b, message);
239
- },
240
- QUnit: {
241
- equiv: equiv
242
- },
243
- // legacy methods below
244
- isSet: isSet,
245
- isObj: isObj,
246
- compare: function() {
247
- throw "compare is deprecated - use same() instead";
248
- },
249
- compare2: function() {
250
- throw "compare2 is deprecated - use same() instead";
251
- },
252
- serialArray: function() {
253
- throw "serialArray is deprecated - use jsDump.parse() instead";
254
- },
255
- q: q,
256
- t: t,
257
- url: url,
258
- triggerEvent: triggerEvent
259
- });
260
-
261
- $(window).load(function() {
262
-
263
- // if ($('#qunit').length === 0) {
264
- // $('body').append($('<div id="qunit"></div>'));
265
- // }
266
- //
267
- // if($('#userAgent').length == 0) {
268
- // $('#qunit').append($('<div id="userAgent"></div>'));
269
- // }
270
- //
271
- // if ($('#tests').length == 0) {
272
- // $('#qunit').append($('<ol id="tests"></ol>')) ;
273
- // }
274
- //
275
- // $('#userAgent').html(navigator.userAgent);
276
- // var head = $('<div class="testrunner-toolbar"><label for="filter">Hide passed tests</label></div>').insertAfter("#userAgent");
277
- // $('<input type="checkbox" id="filter" />').attr("disabled", true).prependTo(head).click(function() {
278
- // $('li.pass')[this.checked ? 'hide' : 'show']();
279
- // });
280
- //runTest();
281
- });
282
-
283
- function synchronize(callback) {
284
- config.queue.push(callback);
285
- if(!config.blocking) {
286
- process();
287
- }
288
- }
289
-
290
- function process() {
291
- window.config = config ;
292
- while(config.queue.length && !config.blocking) {
293
- config.queue.shift()();
294
- }
295
- }
296
-
297
- function stop(timeout) {
298
- config.blocking = true;
299
- if (timeout)
300
- config.timeout = setTimeout(function() {
301
- ok( false, "Test timed out" );
302
- start();
303
- }, timeout);
304
- }
305
- function start() {
306
- // A slight delay, to avoid any current callbacks
307
- setTimeout(function() {
308
- if(config.timeout)
309
- clearTimeout(config.timeout);
310
- config.blocking = false;
311
- process();
312
- }, 13);
313
- }
314
-
315
- function validTest( name ) {
316
- var i = config.filters.length,
317
- run = false;
318
-
319
- if( !i )
320
- return true;
321
-
322
- while( i-- ){
323
- var filter = config.filters[i],
324
- not = filter.charAt(0) == '!';
325
- if( not )
326
- filter = filter.slice(1);
327
- if( name.indexOf(filter) != -1 )
328
- return !not;
329
- if( not )
330
- run = true;
331
- }
332
- return run;
333
- }
334
-
335
- function runTest() {
336
- config.blocking = false;
337
- var started = +new Date;
338
-
339
- config.ajaxSettings = $.ajaxSettings;
340
- synchronize(function() {
341
- $('<p id="testresult" class="result"/>').html(['Tests completed in ',
342
- +new Date - started, ' milliseconds.<br/>',
343
- '<span class="bad">', config.stats.bad, '</span> tests of <span class="all">', config.stats.all, '</span> failed.']
344
- .join(''))
345
- .appendTo("#qunit");
346
- $("#banner").addClass(config.stats.bad ? "fail" : "pass");
347
- });
348
- }
349
-
350
- var pollution;
351
-
352
- function saveGlobal(){
353
- pollution = [ ];
354
-
355
- if( noglobals )
356
- for( var key in window )
357
- pollution.push(key);
358
- }
359
- function checkPollution( name ){
360
- var old = pollution;
361
- saveGlobal();
362
-
363
- if( pollution.length > old.length ){
364
- ok( false, "Introduced global variable(s): " + diff(old, pollution).join(", ") );
365
- config.expected++;
366
- }
367
- }
368
-
369
- function diff( clean, dirty ){
370
- return $.grep( dirty, function(name){
371
- return $.inArray( name, clean ) == -1;
372
- });
373
- }
374
-
375
- function test(name, callback) {
376
- if(config.currentModule)
377
- name = config.currentModule + " module: " + name;
378
- var lifecycle = $.extend({
379
- setup: function() {},
380
- teardown: function() {}
381
- }, config.moduleLifecycle);
382
-
383
- if ( !validTest(name) )
384
- return;
385
-
386
- synchronize(function() {
387
-
388
- // save main fixture...
389
- var mainEl = document.getElementById('main');
390
- config.fixture = mainEl ? mainEl.innerHTML : '';
391
- mainEl = null;
392
-
393
- config.assertions = [];
394
- config.expected = null;
395
- try {
396
- if( !pollution )
397
- saveGlobal();
398
- lifecycle.setup();
399
- } catch(e) {
400
- config.assertions.push( {
401
- result: false,
402
- message: "Setup failed on " + name + ": " + e.message
403
- });
404
- }
405
- })
406
- synchronize(function() {
407
- try {
408
- callback();
409
- } catch(e) {
410
- if( typeof console != "undefined" && console.error && console.warn ) {
411
- console.error("Test " + name + " died, exception and test follows");
412
- console.error(e);
413
- console.warn(callback.toString());
414
- }
415
- config.assertions.push( {
416
- result: false,
417
- message: "Died on test #" + (config.assertions.length + 1) + ": " + e.message
418
- });
419
- // else next test will carry the responsibility
420
- saveGlobal();
421
- }
422
- });
423
- synchronize(function() {
424
- try {
425
- checkPollution();
426
- lifecycle.teardown();
427
- } catch(e) {
428
- config.assertions.push( {
429
- result: false,
430
- message: "Teardown failed on " + name + ": " + e.message
431
- });
432
- }
433
- })
434
- synchronize(function() {
435
- try {
436
- reset();
437
- } catch(e) {
438
- if( typeof console != "undefined" && console.error && console.warn ) {
439
- console.error("reset() failed, following Test " + name + ", exception and reset fn follows");
440
- console.error(e);
441
- console.warn(reset.toString());
442
- }
443
- }
444
-
445
- if(config.expected && config.expected != config.assertions.length) {
446
- config.assertions.push({
447
- result: false,
448
- message: "Expected " + config.expected + " assertions, but " + config.assertions.length + " were run"
449
- });
450
- }
451
-
452
- var good = 0, bad = 0;
453
- var ol = $("<ol/>").hide();
454
- config.stats.all += config.assertions.length;
455
- for ( var i = 0; i < config.assertions.length; i++ ) {
456
- var assertion = config.assertions[i];
457
- $("<li/>").addClass(assertion.result ? "pass" : "fail").text(assertion.message || "(no message)").appendTo(ol);
458
- assertion.result ? good++ : bad++;
459
- }
460
- config.stats.bad += bad;
461
-
462
- var b = $("<strong/>").html(name + " <b style='color:black;'>(<b class='fail'>" + bad + "</b>, <b class='pass'>" + good + "</b>, " + config.assertions.length + ")</b>")
463
- .click(function(){
464
- $(this).next().toggle();
465
- })
466
- .dblclick(function(event) {
467
- var target = $(event.target).filter("strong").clone();
468
- if ( target.length ) {
469
- target.children().remove();
470
- location.href = location.href.match(/^(.+?)(\?.*)?$/)[1] + "?" + encodeURIComponent($.trim(target.text()));
471
- }
472
- });
473
-
474
- $("<li/>").addClass(bad ? "fail" : "pass").append(b).append(ol).appendTo("#tests");
475
-
476
- if(bad) {
477
- $("#filter").attr("disabled", null);
478
- }
479
- });
480
- }
481
-
482
- // call on start of module test to prepend name to all tests
483
- function module(name, lifecycle) {
484
- config.currentModule = name;
485
- config.moduleLifecycle = lifecycle;
486
- }
487
-
488
- /**
489
- * Specify the number of expected assertions to gurantee that failed test (no assertions are run at all) don't slip through.
490
- */
491
- function expect(asserts) {
492
- config.expected = asserts;
493
- }
494
-
495
- /**
496
- * Resets the test setup. Useful for tests that modify the DOM.
497
- */
498
- function reset() {
499
- $("#main").html( config.fixture );
500
- $.event.global = {};
501
- $.ajaxSettings = $.extend({}, config.ajaxSettings);
502
- }
503
-
504
- /**
505
- * Asserts true.
506
- * @example ok( $("a").size() > 5, "There must be at least 5 anchors" );
507
- */
508
- function ok(a, msg) {
509
- config.assertions.push({
510
- result: !!a,
511
- message: msg
512
- });
513
- }
514
-
515
- /**
516
- * Asserts that two arrays are the same
517
- */
518
- function isSet(a, b, msg) {
519
- function serialArray( a ) {
520
- var r = [];
521
-
522
- if ( a && a.length )
523
- for ( var i = 0; i < a.length; i++ ) {
524
- var str = a[i].nodeName;
525
- if ( str ) {
526
- str = str.toLowerCase();
527
- if ( a[i].id )
528
- str += "#" + a[i].id;
529
- } else
530
- str = a[i];
531
- r.push( str );
532
- }
533
-
534
- return "[ " + r.join(", ") + " ]";
535
- }
536
- var ret = true;
537
- if ( a && b && a.length != undefined && a.length == b.length ) {
538
- for ( var i = 0; i < a.length; i++ )
539
- if ( a[i] != b[i] )
540
- ret = false;
541
- } else ret = false;
542
-
543
- window.ok(ret, a, b, msg);
544
- }
545
-
546
- /**
547
- * Asserts that two objects are equivalent
548
- */
549
- function isObj(a, b, msg) {
550
- var ret = true;
551
-
552
- if ( a && b ) {
553
- for ( var i in a )
554
- if ( a[i] != b[i] )
555
- ret = false;
556
-
557
- for ( i in b )
558
- if ( a[i] != b[i] )
559
- ret = false;
560
- } else
561
- ret = false;
562
-
563
- config.assertions.push({
564
- result: ret,
565
- message: msg
566
- });
567
- }
568
-
569
- /**
570
- * Returns an array of elements with the given IDs, eg.
571
- * @example q("main", "foo", "bar")
572
- * @result [<div id="main">, <span id="foo">, <input id="bar">]
573
- */
574
- function q() {
575
- var r = [];
576
- for ( var i = 0; i < arguments.length; i++ )
577
- r.push( document.getElementById( arguments[i] ) );
578
- return r;
579
- }
580
-
581
- /**
582
- * Asserts that a select matches the given IDs
583
- * @example t("Check for something", "//[a]", ["foo", "baar"]);
584
- * @result returns true if "//[a]" return two elements with the IDs 'foo' and 'baar'
585
- */
586
- function t(a,b,c) {
587
- var f = $(b);
588
- var s = "";
589
- for ( var i = 0; i < f.length; i++ )
590
- s += (s && ",") + '"' + f[i].id + '"';
591
-
592
- var a1 = a, b1 = b;
593
- var ret = true;
594
-
595
- a = f ;
596
- b = q.apply(q,c);
597
- if ( a && b && a.length != undefined && a.length == b.length ) {
598
- for ( var i = 0; i < a.length; i++ ) {
599
- if ( a[i] != b[i] ) ret = false;
600
- }
601
- } else ret = false;
602
- window.ok(ret, a, b, a1 + " (" + b1 + ")");
603
- }
604
-
605
- /**
606
- * Add random number to url to stop IE from caching
607
- *
608
- * @example url("data/test.html")
609
- * @result "data/test.html?10538358428943"
610
- *
611
- * @example url("data/test.php?foo=bar")
612
- * @result "data/test.php?foo=bar&10538358345554"
613
- */
614
- function url(value) {
615
- return value + (/\?/.test(value) ? "&" : "?") + new Date().getTime() + "" + parseInt(Math.random()*100000);
616
- }
617
-
618
- /**
619
- * Checks that the first two arguments are equal, with an optional message.
620
- * Prints out both actual and expected values.
621
- *
622
- * Prefered to ok( actual == expected, message )
623
- *
624
- * @example equals( $.format("Received {0} bytes.", 2), "Received 2 bytes." );
625
- *
626
- * @param Object actual
627
- * @param Object expected
628
- * @param String message (optional)
629
- */
630
- function equals(actual, expected, message) {
631
- push(expected == actual, actual, expected, message);
632
- }
633
-
634
- function push(result, actual, expected, message) {
635
- message = message || (result ? "okay" : "failed");
636
- config.assertions.push({
637
- result: result,
638
- message: result ? message + ": " + jsDump.parse(expected) : message + ", expected: " + jsDump.parse(expected) + " result: " + jsDump.parse(actual)
639
- });
640
- }
641
-
642
- /**
643
- * Trigger an event on an element.
644
- *
645
- * @example triggerEvent( document.body, "click" );
646
- *
647
- * @param DOMElement elem
648
- * @param String type
649
- */
650
- function triggerEvent( elem, type, event ) {
651
- if ( $.browser.mozilla || $.browser.opera ) {
652
- event = document.createEvent("MouseEvents");
653
- event.initMouseEvent(type, true, true, elem.ownerDocument.defaultView,
654
- 0, 0, 0, 0, 0, false, false, false, false, 0, null);
655
- elem.dispatchEvent( event );
656
- } else if ( $.browser.msie ) {
657
- elem.fireEvent("on"+type);
658
- }
659
- }
660
-
661
- })(Q$);
662
-
663
- /**
664
- * jsDump
665
- * Copyright (c) 2008 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
666
- * Licensed under BSD (http://www.opensource.org/licenses/bsd-license.php)
667
- * Date: 5/15/2008
668
- * @projectDescription Advanced and extensible data dumping for Javascript.
669
- * @version 1.0.0
670
- * @author Ariel Flesler
671
- * @link {http://flesler.blogspot.com/2008/05/jsdump-pretty-dump-of-any-javascript.html}
672
- */
673
- (function(){
674
- function quote( str ){
675
- return '"' + str.toString().replace(/"/g, '\\"') + '"';
676
- };
677
- function literal( o ){
678
- return o + '';
679
- };
680
- function join( pre, arr, post ){
681
- var s = jsDump.separator(),
682
- base = jsDump.indent();
683
- inner = jsDump.indent(1);
684
- if( arr.join )
685
- arr = arr.join( ',' + s + inner );
686
- if( !arr )
687
- return pre + post;
688
- return [ pre, inner + arr, base + post ].join(s);
689
- };
690
- function array( arr ){
691
- var i = arr.length, ret = Array(i);
692
- this.up();
693
- while( i-- )
694
- ret[i] = this.parse( arr[i] );
695
- this.down();
696
- return join( '[', ret, ']' );
697
- };
698
-
699
- var reName = /^function (\w+)/;
700
-
701
- var jsDump = window.jsDump = {
702
- parse:function( obj, type ){//type is used mostly internally, you can fix a (custom)type in advance
703
- var parser = this.parsers[ type || this.typeOf(obj) ];
704
- type = typeof parser;
705
-
706
- return type == 'function' ? parser.call( this, obj ) :
707
- type == 'string' ? parser :
708
- this.parsers.error;
709
- },
710
- typeOf:function( obj ){
711
- var type = typeof obj,
712
- f = 'function';//we'll use it 3 times, save it
713
-
714
- if (obj && (obj.isObject || obj.isClass)) return 'scobj';
715
- return type != 'object' && type != f ? type :
716
- !obj ? 'null' :
717
- obj.exec ? 'regexp' :// some browsers (FF) consider regexps functions
718
- obj.getHours ? 'date' :
719
- obj.scrollBy ? 'window' :
720
- obj.nodeName == '#document' ? 'document' :
721
- obj.nodeName ? 'node' :
722
- obj.item ? 'nodelist' : // Safari reports nodelists as functions
723
- obj.callee ? 'arguments' :
724
- obj.call || obj.constructor != Array && //an array would also fall on this hack
725
- (obj+'').indexOf(f) != -1 ? f : //IE reports functions like alert, as objects
726
- 'length' in obj ? 'array' :
727
- type;
728
- },
729
- separator:function(){
730
- return this.multiline ? this.HTML ? '<br />' : '\n' : this.HTML ? '&nbsp;' : ' ';
731
- },
732
- indent:function( extra ){// extra can be a number, shortcut for increasing-calling-decreasing
733
- if( !this.multiline )
734
- return '';
735
- var chr = this.indentChar;
736
- if( this.HTML )
737
- chr = chr.replace(/\t/g,' ').replace(/ /g,'&nbsp;');
738
- return Array( this._depth_ + (extra||0) ).join(chr);
739
- },
740
- up:function( a ){
741
- this._depth_ += a || 1;
742
- },
743
- down:function( a ){
744
- this._depth_ -= a || 1;
745
- },
746
- setParser:function( name, parser ){
747
- this.parsers[name] = parser;
748
- },
749
- // The next 3 are exposed so you can use them
750
- quote:quote,
751
- literal:literal,
752
- join:join,
753
- //
754
- _depth_: 1,
755
- // This is the list of parsers, to modify them, use jsDump.setParser
756
- parsers:{
757
- window: '[Window]',
758
- document: '[Document]',
759
- error:'[ERROR]', //when no parser is found, shouldn't happen
760
- unknown: '[Unknown]',
761
- 'null':'null',
762
- undefined:'undefined',
763
- 'function':function( fn ){
764
- var ret = 'function',
765
- name = 'name' in fn ? fn.name : (reName.exec(fn)||[])[1];//functions never have name in IE
766
- if( name )
767
- ret += ' ' + name;
768
- ret += '(';
769
-
770
- ret = [ ret, this.parse( fn, 'functionArgs' ), '){'].join('');
771
- return join( ret, this.parse(fn,'functionCode'), '}' );
772
- },
773
- array: array,
774
- nodelist: array,
775
- arguments: array,
776
- scobj: function(obj) { return obj.toString(); },
777
- object:function( map ){
778
- var ret = [ ];
779
- this.up();
780
- for( var key in map )
781
- ret.push( this.parse(key,'key') + ': ' + this.parse(map[key]) );
782
- this.down();
783
- return join( '{', ret, '}' );
784
- },
785
- node:function( node ){
786
- var open = this.HTML ? '&lt;' : '<',
787
- close = this.HTML ? '&gt;' : '>';
788
-
789
- var tag = node.nodeName.toLowerCase(),
790
- ret = open + tag;
791
-
792
- for( var a in this.DOMAttrs ){
793
- var val = node[this.DOMAttrs[a]];
794
- if( val )
795
- ret += ' ' + a + '=' + this.parse( val, 'attribute' );
796
- }
797
- return ret + close + open + '/' + tag + close;
798
- },
799
- functionArgs:function( fn ){//function calls it internally, it's the arguments part of the function
800
- var l = fn.length;
801
- if( !l ) return '';
802
-
803
- var args = Array(l);
804
- while( l-- )
805
- args[l] = String.fromCharCode(97+l);//97 is 'a'
806
- return ' ' + args.join(', ') + ' ';
807
- },
808
- key:quote, //object calls it internally, the key part of an item in a map
809
- functionCode:'[code]', //function calls it internally, it's the content of the function
810
- attribute:quote, //node calls it internally, it's an html attribute value
811
- string:quote,
812
- date:quote,
813
- regexp:literal, //regex
814
- number:literal,
815
- 'boolean':literal
816
- },
817
- DOMAttrs:{//attributes to dump from nodes, name=>realName
818
- id:'id',
819
- name:'name',
820
- 'class':'className'
821
- },
822
- HTML:false,//if true, entities are escaped ( <, >, \t, space and \n )
823
- indentChar:' ',//indentation unit
824
- multiline:true //if true, items in a collection, are separated by a \n, else just a space.
825
- };
826
-
827
- })();