smparkes-envjs 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (186) hide show
  1. data/bin/envjsrb +157 -73
  2. data/bin/jquery-1.3.2-test.js +11 -4
  3. data/lib/envjs/env.js +935 -11028
  4. data/lib/envjs/net/cgi.rb +94 -0
  5. data/lib/envjs/net/file.rb +4 -4
  6. data/lib/envjs/runtime.rb +80 -24
  7. data/test/call-load-test.js +0 -2
  8. data/test/firebug/errorIcon.png +0 -0
  9. data/test/firebug/firebug.css +209 -0
  10. data/test/firebug/firebug.html +23 -0
  11. data/test/firebug/firebug.js +672 -0
  12. data/test/firebug/firebugx.js +10 -0
  13. data/test/firebug/infoIcon.png +0 -0
  14. data/test/firebug/warningIcon.png +0 -0
  15. data/test/fixtures/html/events.html +171 -0
  16. data/test/fixtures/html/iframe1.html +46 -0
  17. data/test/fixtures/html/iframe1a.html +46 -0
  18. data/test/fixtures/html/iframe2.html +45 -0
  19. data/test/fixtures/html/iframe3.html +28 -0
  20. data/test/fixtures/html/iframeN.html +57 -0
  21. data/test/fixtures/html/malformed.html +181 -0
  22. data/test/fixtures/html/scope.html +81 -0
  23. data/test/fixtures/html/trivial.html +19 -0
  24. data/test/fixtures/html/with_js.html +26 -0
  25. data/test/fixtures/images/icon-blue.png +0 -0
  26. data/test/fixtures/js/external_script.js +1 -0
  27. data/test/fixtures/js/script.js +1 -0
  28. data/test/fixtures/js/script_error.js +2 -0
  29. data/test/html/malformed.html +1 -0
  30. data/test/index.html +21 -19
  31. data/test/{primaryTests.js → primary-tests.js} +1 -3
  32. data/test/{prototype.js → prototype-test.js} +0 -2
  33. data/test/qunit/qunit/qunit.css +0 -0
  34. data/test/qunit/qunit/qunit.js +2 -2
  35. data/test/{qunit/qunit/qunit.js.smp → specs/dist/env.spec.js} +539 -7
  36. data/test/specs/envjs.spec.css +46 -0
  37. data/test/specs/parser/html.js +31 -0
  38. data/test/specs/parser/spec.html +40 -0
  39. data/test/specs/parser/xml.js +31 -0
  40. data/test/specs/qunit.bdd.js +210 -0
  41. data/test/{qunit.smp/qunit → specs}/qunit.css +0 -0
  42. data/test/{qunit.smp/qunit → specs}/qunit.js +2 -2
  43. data/test/specs/template/spec-0.js +31 -0
  44. data/test/specs/template/spec-1.js +31 -0
  45. data/test/specs/template/spec.html +40 -0
  46. data/test/specs/window/css.js +23 -0
  47. data/test/specs/window/dialog.js +25 -0
  48. data/test/specs/window/document.js +23 -0
  49. data/test/specs/window/event.js +25 -0
  50. data/test/specs/window/history.js +34 -0
  51. data/test/specs/window/location.js +34 -0
  52. data/test/specs/window/navigator.js +71 -0
  53. data/test/specs/window/screen.js +42 -0
  54. data/test/specs/window/spec.html +48 -0
  55. data/test/specs/window/timer.js +26 -0
  56. data/test/specs/window/window.js +53 -0
  57. data/test/specs/xhr/spec.html +47 -0
  58. data/test/specs/xhr/xhr.js +31 -0
  59. data/test/test.js +10 -0
  60. data/test/unit/elementmembers.js +31 -0
  61. data/test/unit/nu.validator.js +34 -0
  62. data/test/unit/onload.js +1 -3
  63. data/test/unit/parser.js +106 -98
  64. data/test/unit/prototypecompat.js +2 -2
  65. data/test/vendor/jQuery/1.3.2/ChangeLog.txt +98 -0
  66. data/test/vendor/jQuery/1.3.2/GPL-LICENSE.txt +278 -0
  67. data/test/vendor/jQuery/1.3.2/MIT-LICENSE.txt +20 -0
  68. data/test/vendor/jQuery/1.3.2/Makefile +154 -0
  69. data/test/vendor/jQuery/1.3.2/README +67 -0
  70. data/test/vendor/jQuery/1.3.2/build/ant-contrib-0.6.jar +0 -0
  71. data/test/vendor/jQuery/1.3.2/build/build/min.js +11 -0
  72. data/test/vendor/jQuery/1.3.2/build/build/pack.js +19 -0
  73. data/test/vendor/jQuery/1.3.2/build/js/Packer.js +209 -0
  74. data/test/vendor/jQuery/1.3.2/build/js/ParseMaster.js +106 -0
  75. data/test/vendor/jQuery/1.3.2/build/js/Words.js +62 -0
  76. data/test/vendor/jQuery/1.3.2/build/js/base2.js +978 -0
  77. data/test/vendor/jQuery/1.3.2/build/js/jsmin.js +316 -0
  78. data/test/vendor/jQuery/1.3.2/build/js/json.js +117 -0
  79. data/test/vendor/jQuery/1.3.2/build/js/pack.js +316 -0
  80. data/test/vendor/jQuery/1.3.2/build/js/parse.js +105 -0
  81. data/test/vendor/jQuery/1.3.2/build/js/writeFile.js +19 -0
  82. data/test/vendor/jQuery/1.3.2/build/js/xml.js +25 -0
  83. data/test/vendor/jQuery/1.3.2/build/js.jar +0 -0
  84. data/test/vendor/jQuery/1.3.2/build/runtest/env.js +1 -0
  85. data/test/vendor/jQuery/1.3.2/build/runtest/test.js +106 -0
  86. data/test/vendor/jQuery/1.3.2/build/runtest/testrunner.js +197 -0
  87. data/test/vendor/jQuery/1.3.2/build/speed/benchmarker.css +65 -0
  88. data/test/vendor/jQuery/1.3.2/build/speed/benchmarker.js +181 -0
  89. data/test/vendor/jQuery/1.3.2/build/speed/index.html +72 -0
  90. data/test/vendor/jQuery/1.3.2/build/speed/jquery-basis.js +3549 -0
  91. data/test/vendor/jQuery/1.3.2/build/style.xsl +99 -0
  92. data/test/vendor/jQuery/1.3.2/build/yuicompressor-2.4.2.jar +0 -0
  93. data/test/vendor/jQuery/1.3.2/build.xml +123 -0
  94. data/test/vendor/jQuery/1.3.2/dist/jquery.js +4376 -0
  95. data/test/vendor/jQuery/1.3.2/reminder.txt +3 -0
  96. data/test/vendor/jQuery/1.3.2/src/ajax.js +541 -0
  97. data/test/vendor/jQuery/1.3.2/src/core.js +1255 -0
  98. data/test/vendor/jQuery/1.3.2/src/data.js +145 -0
  99. data/test/vendor/jQuery/1.3.2/src/dimensions.js +49 -0
  100. data/test/vendor/jQuery/1.3.2/src/event.js +684 -0
  101. data/test/vendor/jQuery/1.3.2/src/fx.js +407 -0
  102. data/test/vendor/jQuery/1.3.2/src/intro.js +13 -0
  103. data/test/vendor/jQuery/1.3.2/src/offset.js +155 -0
  104. data/test/vendor/jQuery/1.3.2/src/outro.js +1 -0
  105. data/test/vendor/jQuery/1.3.2/src/selector.js +1015 -0
  106. data/test/vendor/jQuery/1.3.2/src/support.js +112 -0
  107. data/test/vendor/jQuery/1.3.2/test/data/cow.jpg +0 -0
  108. data/test/vendor/jQuery/1.3.2/test/data/dashboard.xml +11 -0
  109. data/test/vendor/jQuery/1.3.2/test/data/echoQuery.php +1 -0
  110. data/test/vendor/jQuery/1.3.2/test/data/iframe.html +8 -0
  111. data/test/vendor/jQuery/1.3.2/test/data/json.php +9 -0
  112. data/test/vendor/jQuery/1.3.2/test/data/json_assigned_obj.js +1 -0
  113. data/test/vendor/jQuery/1.3.2/test/data/json_obj.js +1 -0
  114. data/test/vendor/jQuery/1.3.2/test/data/jsonp.php +10 -0
  115. data/test/vendor/jQuery/1.3.2/test/data/name.html +1 -0
  116. data/test/vendor/jQuery/1.3.2/test/data/name.php +29 -0
  117. data/test/vendor/jQuery/1.3.2/test/data/offset/absolute.html +39 -0
  118. data/test/vendor/jQuery/1.3.2/test/data/offset/body.html +24 -0
  119. data/test/vendor/jQuery/1.3.2/test/data/offset/fixed.html +33 -0
  120. data/test/vendor/jQuery/1.3.2/test/data/offset/relative.html +31 -0
  121. data/test/vendor/jQuery/1.3.2/test/data/offset/scroll.html +39 -0
  122. data/test/vendor/jQuery/1.3.2/test/data/offset/static.html +31 -0
  123. data/test/vendor/jQuery/1.3.2/test/data/offset/table.html +43 -0
  124. data/test/vendor/jQuery/1.3.2/test/data/params_html.php +12 -0
  125. data/test/vendor/jQuery/1.3.2/test/data/test.html +7 -0
  126. data/test/vendor/jQuery/1.3.2/test/data/test.js +3 -0
  127. data/test/vendor/jQuery/1.3.2/test/data/test.php +7 -0
  128. data/test/vendor/jQuery/1.3.2/test/data/test2.html +5 -0
  129. data/test/vendor/jQuery/1.3.2/test/data/test3.html +3 -0
  130. data/test/vendor/jQuery/1.3.2/test/data/testrunner.js +1 -0
  131. data/test/vendor/jQuery/1.3.2/test/data/text.php +12 -0
  132. data/test/vendor/jQuery/1.3.2/test/data/with_fries.xml +25 -0
  133. data/test/vendor/jQuery/1.3.2/test/index.html +229 -0
  134. data/test/vendor/jQuery/1.3.2/test/jqenv-1259090275493.html +247 -0
  135. data/test/vendor/jQuery/1.3.2/test/jqenv-1259091671501.html +247 -0
  136. data/test/vendor/jQuery/1.3.2/test/jqenv-1259175319655.html +247 -0
  137. data/test/vendor/jQuery/1.3.2/test/offset.html +28 -0
  138. data/test/vendor/jQuery/1.3.2/test/otherlibs/jquery/1.2.1/jquery.js +11 -0
  139. data/test/vendor/jQuery/1.3.2/test/otherlibs/jquery/1.2.3/jquery.js +11 -0
  140. data/test/vendor/jQuery/1.3.2/test/otherlibs/mootools/1.11/mootools.js +1577 -0
  141. data/test/vendor/jQuery/1.3.2/test/otherlibs/prototype/1.6.0.2/prototype.js +4221 -0
  142. data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.7.0/builder.js +131 -0
  143. data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.7.0/controls.js +835 -0
  144. data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.7.0/dragdrop.js +944 -0
  145. data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.7.0/effects.js +1090 -0
  146. data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.7.0/scriptaculous.js +51 -0
  147. data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.7.0/slider.js +278 -0
  148. data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.7.0/unittest.js +564 -0
  149. data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.8.1/builder.js +136 -0
  150. data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.8.1/controls.js +965 -0
  151. data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.8.1/dragdrop.js +974 -0
  152. data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.8.1/effects.js +1122 -0
  153. data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.8.1/scriptaculous.js +58 -0
  154. data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.8.1/slider.js +275 -0
  155. data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.8.1/sound.js +55 -0
  156. data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.8.1/unittest.js +568 -0
  157. data/test/vendor/jQuery/1.3.2/test/polluted.php +64 -0
  158. data/test/vendor/jQuery/1.3.2/test/qunit/testrunner.js +780 -0
  159. data/test/vendor/jQuery/1.3.2/test/qunit/testsuite.css +120 -0
  160. data/test/vendor/jQuery/1.3.2/test/test.js +41 -0
  161. data/test/vendor/jQuery/1.3.2/test/unit/ajax.js +856 -0
  162. data/test/vendor/jQuery/1.3.2/test/unit/core.js +1872 -0
  163. data/test/vendor/jQuery/1.3.2/test/unit/data.js +160 -0
  164. data/test/vendor/jQuery/1.3.2/test/unit/dimensions.js +86 -0
  165. data/test/vendor/jQuery/1.3.2/test/unit/event.js +670 -0
  166. data/test/vendor/jQuery/1.3.2/test/unit/fx.js +451 -0
  167. data/test/vendor/jQuery/1.3.2/test/unit/offset.js +173 -0
  168. data/test/vendor/jQuery/1.3.2/test/unit/selector.js +395 -0
  169. data/test/vendor/jQuery/1.3.2/test/xhtml.php +5 -0
  170. data/test/vendor/jQuery/1.3.2/version.txt +1 -0
  171. metadata +158 -22
  172. data/lib/envjs/runtime.rb.smp +0 -133
  173. data/test/envjs-call-load-test.js +0 -5
  174. data/test/envjs-prototype.js +0 -5
  175. data/test/qunit/package.json +0 -21
  176. data/test/qunit/test/index.html +0 -17
  177. data/test/qunit/test/same.js +0 -1368
  178. data/test/qunit/test/test.js +0 -136
  179. data/test/qunit.smp/package.json +0 -21
  180. data/test/qunit.smp/test/index.html +0 -17
  181. data/test/qunit.smp/test/same.js +0 -1368
  182. data/test/qunit.smp/test/test.js +0 -136
  183. data/test/rhino-call-load-test.js +0 -5
  184. data/test/rhino-prototype.js +0 -5
  185. data/test/test-with-envs-jar.js +0 -8
  186. data/test/test-with-rhino-jar.js +0 -9
@@ -0,0 +1,684 @@
1
+ /*
2
+ * A number of helper functions used for managing events.
3
+ * Many of the ideas behind this code originated from
4
+ * Dean Edwards' addEvent library.
5
+ */
6
+ jQuery.event = {
7
+
8
+ // Bind an event to an element
9
+ // Original by Dean Edwards
10
+ add: function(elem, types, handler, data) {
11
+ if ( elem.nodeType == 3 || elem.nodeType == 8 )
12
+ return;
13
+
14
+ // For whatever reason, IE has trouble passing the window object
15
+ // around, causing it to be cloned in the process
16
+ if ( elem.setInterval && elem != window )
17
+ elem = window;
18
+
19
+ // Make sure that the function being executed has a unique ID
20
+ if ( !handler.guid )
21
+ handler.guid = this.guid++;
22
+
23
+ // if data is passed, bind to handler
24
+ if ( data !== undefined ) {
25
+ // Create temporary function pointer to original handler
26
+ var fn = handler;
27
+
28
+ // Create unique handler function, wrapped around original handler
29
+ handler = this.proxy( fn );
30
+
31
+ // Store data in unique handler
32
+ handler.data = data;
33
+ }
34
+
35
+ // Init the element's event structure
36
+ var events = jQuery.data(elem, "events") || jQuery.data(elem, "events", {}),
37
+ handle = jQuery.data(elem, "handle") || jQuery.data(elem, "handle", function(){
38
+ // Handle the second event of a trigger and when
39
+ // an event is called after a page has unloaded
40
+ return typeof jQuery !== "undefined" && !jQuery.event.triggered ?
41
+ jQuery.event.handle.apply(arguments.callee.elem, arguments) :
42
+ undefined;
43
+ });
44
+ // Add elem as a property of the handle function
45
+ // This is to prevent a memory leak with non-native
46
+ // event in IE.
47
+ handle.elem = elem;
48
+
49
+ // Handle multiple events separated by a space
50
+ // jQuery(...).bind("mouseover mouseout", fn);
51
+ jQuery.each(types.split(/\s+/), function(index, type) {
52
+ // Namespaced event handlers
53
+ var namespaces = type.split(".");
54
+ type = namespaces.shift();
55
+ handler.type = namespaces.slice().sort().join(".");
56
+
57
+ // Get the current list of functions bound to this event
58
+ var handlers = events[type];
59
+
60
+ if ( jQuery.event.specialAll[type] )
61
+ jQuery.event.specialAll[type].setup.call(elem, data, namespaces);
62
+
63
+ // Init the event handler queue
64
+ if (!handlers) {
65
+ handlers = events[type] = {};
66
+
67
+ // Check for a special event handler
68
+ // Only use addEventListener/attachEvent if the special
69
+ // events handler returns false
70
+ if ( !jQuery.event.special[type] || jQuery.event.special[type].setup.call(elem, data, namespaces) === false ) {
71
+ // Bind the global event handler to the element
72
+ if (elem.addEventListener)
73
+ elem.addEventListener(type, handle, false);
74
+ else if (elem.attachEvent)
75
+ elem.attachEvent("on" + type, handle);
76
+ }
77
+ }
78
+
79
+ // Add the function to the element's handler list
80
+ handlers[handler.guid] = handler;
81
+
82
+ // Keep track of which events have been used, for global triggering
83
+ jQuery.event.global[type] = true;
84
+ });
85
+
86
+ // Nullify elem to prevent memory leaks in IE
87
+ elem = null;
88
+ },
89
+
90
+ guid: 1,
91
+ global: {},
92
+
93
+ // Detach an event or set of events from an element
94
+ remove: function(elem, types, handler) {
95
+ // don't do events on text and comment nodes
96
+ if ( elem.nodeType == 3 || elem.nodeType == 8 )
97
+ return;
98
+
99
+ var events = jQuery.data(elem, "events"), ret, index;
100
+
101
+ if ( events ) {
102
+ // Unbind all events for the element
103
+ if ( types === undefined || (typeof types === "string" && types.charAt(0) == ".") )
104
+ for ( var type in events )
105
+ this.remove( elem, type + (types || "") );
106
+ else {
107
+ // types is actually an event object here
108
+ if ( types.type ) {
109
+ handler = types.handler;
110
+ types = types.type;
111
+ }
112
+
113
+ // Handle multiple events seperated by a space
114
+ // jQuery(...).unbind("mouseover mouseout", fn);
115
+ jQuery.each(types.split(/\s+/), function(index, type){
116
+ // Namespaced event handlers
117
+ var namespaces = type.split(".");
118
+ type = namespaces.shift();
119
+ var namespace = RegExp("(^|\\.)" + namespaces.slice().sort().join(".*\\.") + "(\\.|$)");
120
+
121
+ if ( events[type] ) {
122
+ // remove the given handler for the given type
123
+ if ( handler )
124
+ delete events[type][handler.guid];
125
+
126
+ // remove all handlers for the given type
127
+ else
128
+ for ( var handle in events[type] )
129
+ // Handle the removal of namespaced events
130
+ if ( namespace.test(events[type][handle].type) )
131
+ delete events[type][handle];
132
+
133
+ if ( jQuery.event.specialAll[type] )
134
+ jQuery.event.specialAll[type].teardown.call(elem, namespaces);
135
+
136
+ // remove generic event handler if no more handlers exist
137
+ for ( ret in events[type] ) break;
138
+ if ( !ret ) {
139
+ if ( !jQuery.event.special[type] || jQuery.event.special[type].teardown.call(elem, namespaces) === false ) {
140
+ if (elem.removeEventListener)
141
+ elem.removeEventListener(type, jQuery.data(elem, "handle"), false);
142
+ else if (elem.detachEvent)
143
+ elem.detachEvent("on" + type, jQuery.data(elem, "handle"));
144
+ }
145
+ ret = null;
146
+ delete events[type];
147
+ }
148
+ }
149
+ });
150
+ }
151
+
152
+ // Remove the expando if it's no longer used
153
+ for ( ret in events ) break;
154
+ if ( !ret ) {
155
+ var handle = jQuery.data( elem, "handle" );
156
+ if ( handle ) handle.elem = null;
157
+ jQuery.removeData( elem, "events" );
158
+ jQuery.removeData( elem, "handle" );
159
+ }
160
+ }
161
+ },
162
+
163
+ // bubbling is internal
164
+ trigger: function( event, data, elem, bubbling ) {
165
+ // Event object or event type
166
+ var type = event.type || event;
167
+
168
+ if( !bubbling ){
169
+ event = typeof event === "object" ?
170
+ // jQuery.Event object
171
+ event[expando] ? event :
172
+ // Object literal
173
+ jQuery.extend( jQuery.Event(type), event ) :
174
+ // Just the event type (string)
175
+ jQuery.Event(type);
176
+
177
+ if ( type.indexOf("!") >= 0 ) {
178
+ event.type = type = type.slice(0, -1);
179
+ event.exclusive = true;
180
+ }
181
+
182
+ // Handle a global trigger
183
+ if ( !elem ) {
184
+ // Don't bubble custom events when global (to avoid too much overhead)
185
+ event.stopPropagation();
186
+ // Only trigger if we've ever bound an event for it
187
+ if ( this.global[type] )
188
+ jQuery.each( jQuery.cache, function(){
189
+ if ( this.events && this.events[type] )
190
+ jQuery.event.trigger( event, data, this.handle.elem );
191
+ });
192
+ }
193
+
194
+ // Handle triggering a single element
195
+
196
+ // don't do events on text and comment nodes
197
+ if ( !elem || elem.nodeType == 3 || elem.nodeType == 8 )
198
+ return undefined;
199
+
200
+ // Clean up in case it is reused
201
+ event.result = undefined;
202
+ event.target = elem;
203
+
204
+ // Clone the incoming data, if any
205
+ data = jQuery.makeArray(data);
206
+ data.unshift( event );
207
+ }
208
+
209
+ event.currentTarget = elem;
210
+
211
+ // Trigger the event, it is assumed that "handle" is a function
212
+ var handle = jQuery.data(elem, "handle");
213
+ if ( handle )
214
+ handle.apply( elem, data );
215
+
216
+ // Handle triggering native .onfoo handlers (and on links since we don't call .click() for links)
217
+ if ( (!elem[type] || (jQuery.nodeName(elem, 'a') && type == "click")) && elem["on"+type] && elem["on"+type].apply( elem, data ) === false )
218
+ event.result = false;
219
+
220
+ // Trigger the native events (except for clicks on links)
221
+ if ( !bubbling && elem[type] && !event.isDefaultPrevented() && !(jQuery.nodeName(elem, 'a') && type == "click") ) {
222
+ this.triggered = true;
223
+ try {
224
+ elem[ type ]();
225
+ // prevent IE from throwing an error for some hidden elements
226
+ } catch (e) {}
227
+ }
228
+
229
+ this.triggered = false;
230
+
231
+ if ( !event.isPropagationStopped() ) {
232
+ var parent = elem.parentNode || elem.ownerDocument;
233
+ if ( parent )
234
+ jQuery.event.trigger(event, data, parent, true);
235
+ }
236
+ },
237
+
238
+ handle: function(event) {
239
+ // returned undefined or false
240
+ var all, handlers;
241
+
242
+ event = arguments[0] = jQuery.event.fix( event || window.event );
243
+ event.currentTarget = this;
244
+
245
+ // Namespaced event handlers
246
+ var namespaces = event.type.split(".");
247
+ event.type = namespaces.shift();
248
+
249
+ // Cache this now, all = true means, any handler
250
+ all = !namespaces.length && !event.exclusive;
251
+
252
+ var namespace = RegExp("(^|\\.)" + namespaces.slice().sort().join(".*\\.") + "(\\.|$)");
253
+
254
+ handlers = ( jQuery.data(this, "events") || {} )[event.type];
255
+
256
+ for ( var j in handlers ) {
257
+ var handler = handlers[j];
258
+
259
+ // Filter the functions by class
260
+ if ( all || namespace.test(handler.type) ) {
261
+ // Pass in a reference to the handler function itself
262
+ // So that we can later remove it
263
+ event.handler = handler;
264
+ event.data = handler.data;
265
+
266
+ var ret = handler.apply(this, arguments);
267
+
268
+ if( ret !== undefined ){
269
+ event.result = ret;
270
+ if ( ret === false ) {
271
+ event.preventDefault();
272
+ event.stopPropagation();
273
+ }
274
+ }
275
+
276
+ if( event.isImmediatePropagationStopped() )
277
+ break;
278
+
279
+ }
280
+ }
281
+ },
282
+
283
+ props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode metaKey newValue originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),
284
+
285
+ fix: function(event) {
286
+ if ( event[expando] )
287
+ return event;
288
+
289
+ // store a copy of the original event object
290
+ // and "clone" to set read-only properties
291
+ var originalEvent = event;
292
+ event = jQuery.Event( originalEvent );
293
+
294
+ for ( var i = this.props.length, prop; i; ){
295
+ prop = this.props[ --i ];
296
+ event[ prop ] = originalEvent[ prop ];
297
+ }
298
+
299
+ // Fix target property, if necessary
300
+ if ( !event.target )
301
+ event.target = event.srcElement || document; // Fixes #1925 where srcElement might not be defined either
302
+
303
+ // check if target is a textnode (safari)
304
+ if ( event.target.nodeType == 3 )
305
+ event.target = event.target.parentNode;
306
+
307
+ // Add relatedTarget, if necessary
308
+ if ( !event.relatedTarget && event.fromElement )
309
+ event.relatedTarget = event.fromElement == event.target ? event.toElement : event.fromElement;
310
+
311
+ // Calculate pageX/Y if missing and clientX/Y available
312
+ if ( event.pageX == null && event.clientX != null ) {
313
+ var doc = document.documentElement, body = document.body;
314
+ event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc.clientLeft || 0);
315
+ event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc.clientTop || 0);
316
+ }
317
+
318
+ // Add which for key events
319
+ if ( !event.which && ((event.charCode || event.charCode === 0) ? event.charCode : event.keyCode) )
320
+ event.which = event.charCode || event.keyCode;
321
+
322
+ // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
323
+ if ( !event.metaKey && event.ctrlKey )
324
+ event.metaKey = event.ctrlKey;
325
+
326
+ // Add which for click: 1 == left; 2 == middle; 3 == right
327
+ // Note: button is not normalized, so don't use it
328
+ if ( !event.which && event.button )
329
+ event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) ));
330
+
331
+ return event;
332
+ },
333
+
334
+ proxy: function( fn, proxy ){
335
+ proxy = proxy || function(){ return fn.apply(this, arguments); };
336
+ // Set the guid of unique handler to the same of original handler, so it can be removed
337
+ proxy.guid = fn.guid = fn.guid || proxy.guid || this.guid++;
338
+ // So proxy can be declared as an argument
339
+ return proxy;
340
+ },
341
+
342
+ special: {
343
+ ready: {
344
+ // Make sure the ready event is setup
345
+ setup: bindReady,
346
+ teardown: function() {}
347
+ }
348
+ },
349
+
350
+ specialAll: {
351
+ live: {
352
+ setup: function( selector, namespaces ){
353
+ jQuery.event.add( this, namespaces[0], liveHandler );
354
+ },
355
+ teardown: function( namespaces ){
356
+ if ( namespaces.length ) {
357
+ var remove = 0, name = RegExp("(^|\\.)" + namespaces[0] + "(\\.|$)");
358
+
359
+ jQuery.each( (jQuery.data(this, "events").live || {}), function(){
360
+ if ( name.test(this.type) )
361
+ remove++;
362
+ });
363
+
364
+ if ( remove < 1 )
365
+ jQuery.event.remove( this, namespaces[0], liveHandler );
366
+ }
367
+ }
368
+ }
369
+ }
370
+ };
371
+
372
+ jQuery.Event = function( src ){
373
+ // Allow instantiation without the 'new' keyword
374
+ if( !this.preventDefault )
375
+ return new jQuery.Event(src);
376
+
377
+ // Event object
378
+ if( src && src.type ){
379
+ this.originalEvent = src;
380
+ this.type = src.type;
381
+ // Event type
382
+ }else
383
+ this.type = src;
384
+
385
+ // timeStamp is buggy for some events on Firefox(#3843)
386
+ // So we won't rely on the native value
387
+ this.timeStamp = now();
388
+
389
+ // Mark it as fixed
390
+ this[expando] = true;
391
+ };
392
+
393
+ function returnFalse(){
394
+ return false;
395
+ }
396
+ function returnTrue(){
397
+ return true;
398
+ }
399
+
400
+ // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
401
+ // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
402
+ jQuery.Event.prototype = {
403
+ preventDefault: function() {
404
+ this.isDefaultPrevented = returnTrue;
405
+
406
+ var e = this.originalEvent;
407
+ if( !e )
408
+ return;
409
+ // if preventDefault exists run it on the original event
410
+ if (e.preventDefault)
411
+ e.preventDefault();
412
+ // otherwise set the returnValue property of the original event to false (IE)
413
+ e.returnValue = false;
414
+ },
415
+ stopPropagation: function() {
416
+ this.isPropagationStopped = returnTrue;
417
+
418
+ var e = this.originalEvent;
419
+ if( !e )
420
+ return;
421
+ // if stopPropagation exists run it on the original event
422
+ if (e.stopPropagation)
423
+ e.stopPropagation();
424
+ // otherwise set the cancelBubble property of the original event to true (IE)
425
+ e.cancelBubble = true;
426
+ },
427
+ stopImmediatePropagation:function(){
428
+ this.isImmediatePropagationStopped = returnTrue;
429
+ this.stopPropagation();
430
+ },
431
+ isDefaultPrevented: returnFalse,
432
+ isPropagationStopped: returnFalse,
433
+ isImmediatePropagationStopped: returnFalse
434
+ };
435
+ // Checks if an event happened on an element within another element
436
+ // Used in jQuery.event.special.mouseenter and mouseleave handlers
437
+ var withinElement = function(event) {
438
+ // Check if mouse(over|out) are still within the same parent element
439
+ var parent = event.relatedTarget;
440
+ // Traverse up the tree
441
+ while ( parent && parent != this )
442
+ try { parent = parent.parentNode; }
443
+ catch(e) { parent = this; }
444
+
445
+ if( parent != this ){
446
+ // set the correct event type
447
+ event.type = event.data;
448
+ // handle event if we actually just moused on to a non sub-element
449
+ jQuery.event.handle.apply( this, arguments );
450
+ }
451
+ };
452
+
453
+ jQuery.each({
454
+ mouseover: 'mouseenter',
455
+ mouseout: 'mouseleave'
456
+ }, function( orig, fix ){
457
+ jQuery.event.special[ fix ] = {
458
+ setup: function(){
459
+ jQuery.event.add( this, orig, withinElement, fix );
460
+ },
461
+ teardown: function(){
462
+ jQuery.event.remove( this, orig, withinElement );
463
+ }
464
+ };
465
+ });
466
+
467
+ jQuery.fn.extend({
468
+ bind: function( type, data, fn ) {
469
+ return type == "unload" ? this.one(type, data, fn) : this.each(function(){
470
+ jQuery.event.add( this, type, fn || data, fn && data );
471
+ });
472
+ },
473
+
474
+ one: function( type, data, fn ) {
475
+ var one = jQuery.event.proxy( fn || data, function(event) {
476
+ jQuery(this).unbind(event, one);
477
+ return (fn || data).apply( this, arguments );
478
+ });
479
+ return this.each(function(){
480
+ jQuery.event.add( this, type, one, fn && data);
481
+ });
482
+ },
483
+
484
+ unbind: function( type, fn ) {
485
+ return this.each(function(){
486
+ jQuery.event.remove( this, type, fn );
487
+ });
488
+ },
489
+
490
+ trigger: function( type, data ) {
491
+ return this.each(function(){
492
+ jQuery.event.trigger( type, data, this );
493
+ });
494
+ },
495
+
496
+ triggerHandler: function( type, data ) {
497
+ if( this[0] ){
498
+ var event = jQuery.Event(type);
499
+ event.preventDefault();
500
+ event.stopPropagation();
501
+ jQuery.event.trigger( event, data, this[0] );
502
+ return event.result;
503
+ }
504
+ },
505
+
506
+ toggle: function( fn ) {
507
+ // Save reference to arguments for access in closure
508
+ var args = arguments, i = 1;
509
+
510
+ // link all the functions, so any of them can unbind this click handler
511
+ while( i < args.length )
512
+ jQuery.event.proxy( fn, args[i++] );
513
+
514
+ return this.click( jQuery.event.proxy( fn, function(event) {
515
+ // Figure out which function to execute
516
+ this.lastToggle = ( this.lastToggle || 0 ) % i;
517
+
518
+ // Make sure that clicks stop
519
+ event.preventDefault();
520
+
521
+ // and execute the function
522
+ return args[ this.lastToggle++ ].apply( this, arguments ) || false;
523
+ }));
524
+ },
525
+
526
+ hover: function(fnOver, fnOut) {
527
+ return this.mouseenter(fnOver).mouseleave(fnOut);
528
+ },
529
+
530
+ ready: function(fn) {
531
+ // Attach the listeners
532
+ bindReady();
533
+
534
+ // If the DOM is already ready
535
+ if ( jQuery.isReady )
536
+ // Execute the function immediately
537
+ fn.call( document, jQuery );
538
+
539
+ // Otherwise, remember the function for later
540
+ else
541
+ // Add the function to the wait list
542
+ jQuery.readyList.push( fn );
543
+
544
+ return this;
545
+ },
546
+
547
+ live: function( type, fn ){
548
+ var proxy = jQuery.event.proxy( fn );
549
+ proxy.guid += this.selector + type;
550
+
551
+ jQuery(document).bind( liveConvert(type, this.selector), this.selector, proxy );
552
+
553
+ return this;
554
+ },
555
+
556
+ die: function( type, fn ){
557
+ jQuery(document).unbind( liveConvert(type, this.selector), fn ? { guid: fn.guid + this.selector + type } : null );
558
+ return this;
559
+ }
560
+ });
561
+
562
+ function liveHandler( event ){
563
+ var check = RegExp("(^|\\.)" + event.type + "(\\.|$)"),
564
+ stop = true,
565
+ elems = [];
566
+
567
+ jQuery.each(jQuery.data(this, "events").live || [], function(i, fn){
568
+ if ( check.test(fn.type) ) {
569
+ var elem = jQuery(event.target).closest(fn.data)[0];
570
+ if ( elem )
571
+ elems.push({ elem: elem, fn: fn });
572
+ }
573
+ });
574
+
575
+ elems.sort(function(a,b) {
576
+ return jQuery.data(a.elem, "closest") - jQuery.data(b.elem, "closest");
577
+ });
578
+
579
+ jQuery.each(elems, function(){
580
+ if ( this.fn.call(this.elem, event, this.fn.data) === false )
581
+ return (stop = false);
582
+ });
583
+
584
+ return stop;
585
+ }
586
+
587
+ function liveConvert(type, selector){
588
+ return ["live", type, selector.replace(/\./g, "`").replace(/ /g, "|")].join(".");
589
+ }
590
+
591
+ jQuery.extend({
592
+ isReady: false,
593
+ readyList: [],
594
+ // Handle when the DOM is ready
595
+ ready: function() {
596
+ // Make sure that the DOM is not already loaded
597
+ if ( !jQuery.isReady ) {
598
+ // Remember that the DOM is ready
599
+ jQuery.isReady = true;
600
+
601
+ // If there are functions bound, to execute
602
+ if ( jQuery.readyList ) {
603
+ // Execute all of them
604
+ jQuery.each( jQuery.readyList, function(){
605
+ this.call( document, jQuery );
606
+ });
607
+
608
+ // Reset the list of functions
609
+ jQuery.readyList = null;
610
+ }
611
+
612
+ // Trigger any bound ready events
613
+ jQuery(document).triggerHandler("ready");
614
+ }
615
+ }
616
+ });
617
+
618
+ var readyBound = false;
619
+
620
+ function bindReady(){
621
+ if ( readyBound ) return;
622
+ readyBound = true;
623
+
624
+ // Mozilla, Opera and webkit nightlies currently support this event
625
+ if ( document.addEventListener ) {
626
+ // Use the handy event callback
627
+ document.addEventListener( "DOMContentLoaded", function(){
628
+ document.removeEventListener( "DOMContentLoaded", arguments.callee, false );
629
+ jQuery.ready();
630
+ }, false );
631
+
632
+ // If IE event model is used
633
+ } else if ( document.attachEvent ) {
634
+ // ensure firing before onload,
635
+ // maybe late but safe also for iframes
636
+ document.attachEvent("onreadystatechange", function(){
637
+ if ( document.readyState === "complete" ) {
638
+ document.detachEvent( "onreadystatechange", arguments.callee );
639
+ jQuery.ready();
640
+ }
641
+ });
642
+
643
+ // If IE and not an iframe
644
+ // continually check to see if the document is ready
645
+ if ( document.documentElement.doScroll && window == window.top ) (function(){
646
+ if ( jQuery.isReady ) return;
647
+
648
+ try {
649
+ // If IE is used, use the trick by Diego Perini
650
+ // http://javascript.nwbox.com/IEContentLoaded/
651
+ document.documentElement.doScroll("left");
652
+ } catch( error ) {
653
+ setTimeout( arguments.callee, 0 );
654
+ return;
655
+ }
656
+
657
+ // and execute any waiting functions
658
+ jQuery.ready();
659
+ })();
660
+ }
661
+
662
+ // A fallback to window.onload, that will always work
663
+ jQuery.event.add( window, "load", jQuery.ready );
664
+ }
665
+
666
+ jQuery.each( ("blur,focus,load,resize,scroll,unload,click,dblclick," +
667
+ "mousedown,mouseup,mousemove,mouseover,mouseout,mouseenter,mouseleave," +
668
+ "change,select,submit,keydown,keypress,keyup,error").split(","), function(i, name){
669
+
670
+ // Handle event binding
671
+ jQuery.fn[name] = function(fn){
672
+ return fn ? this.bind(name, fn) : this.trigger(name);
673
+ };
674
+ });
675
+
676
+ // Prevent memory leaks in IE
677
+ // And prevent errors on refresh with events like mouseover in other browsers
678
+ // Window isn't included so as not to unbind existing unload events
679
+ jQuery( window ).bind( 'unload', function(){
680
+ for ( var id in jQuery.cache )
681
+ // Skip the window
682
+ if ( id != 1 && jQuery.cache[ id ].handle )
683
+ jQuery.event.remove( jQuery.cache[ id ].handle.elem );
684
+ });