yarn 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. data/lib/rack/handler/yarn.rb +3 -7
  2. data/lib/yarn/abstract_handler.rb +19 -4
  3. data/lib/yarn/directory_lister.rb +3 -2
  4. data/lib/yarn/error_page.rb +3 -0
  5. data/lib/yarn/logging.rb +7 -0
  6. data/lib/yarn/parser.rb +3 -0
  7. data/lib/yarn/rack_handler.rb +4 -0
  8. data/lib/yarn/request_handler.rb +23 -13
  9. data/lib/yarn/response.rb +8 -1
  10. data/lib/yarn/server.rb +16 -3
  11. data/lib/yarn/statuses.rb +53 -52
  12. data/lib/yarn/version.rb +2 -1
  13. metadata +27 -108
  14. data/.autotest +0 -5
  15. data/.gitignore +0 -11
  16. data/.rspec +0 -2
  17. data/Gemfile +0 -7
  18. data/LICENCE +0 -22
  19. data/Rakefile +0 -4
  20. data/cucumber.yml +0 -3
  21. data/features/concurrency.feature +0 -13
  22. data/features/dynamic_request.feature +0 -18
  23. data/features/logger.feature +0 -16
  24. data/features/parser.feature +0 -15
  25. data/features/rack.feature +0 -15
  26. data/features/server.feature +0 -14
  27. data/features/static_request.feature +0 -25
  28. data/features/step_definitions/concurrency_steps.rb +0 -34
  29. data/features/step_definitions/parser_steps.rb +0 -23
  30. data/features/step_definitions/rack_steps.rb +0 -16
  31. data/features/step_definitions/server_steps.rb +0 -42
  32. data/features/step_definitions/web_steps.rb +0 -15
  33. data/features/support/env.rb +0 -20
  34. data/features/support/hooks.rb +0 -5
  35. data/spec/helpers.rb +0 -92
  36. data/spec/rack/handler/yarn_spec.rb +0 -21
  37. data/spec/spec_helper.rb +0 -17
  38. data/spec/yarn/abstract_handler_spec.rb +0 -98
  39. data/spec/yarn/directory_lister_spec.rb +0 -41
  40. data/spec/yarn/error_page_spec.rb +0 -33
  41. data/spec/yarn/logging_spec.rb +0 -53
  42. data/spec/yarn/parser_spec.rb +0 -122
  43. data/spec/yarn/rack_handler_spec.rb +0 -55
  44. data/spec/yarn/request_handler_spec.rb +0 -164
  45. data/spec/yarn/response_spec.rb +0 -36
  46. data/spec/yarn/server_spec.rb +0 -102
  47. data/test_objects/.gitignore +0 -10
  48. data/test_objects/config.ru +0 -6
  49. data/test_objects/index.html +0 -13
  50. data/test_objects/jquery.js +0 -8865
  51. data/test_objects/rails_test/.gitignore +0 -5
  52. data/test_objects/rails_test/Gemfile +0 -34
  53. data/test_objects/rails_test/README +0 -261
  54. data/test_objects/rails_test/Rakefile +0 -7
  55. data/test_objects/rails_test/app/assets/images/rails.png +0 -0
  56. data/test_objects/rails_test/app/assets/javascripts/application.js +0 -6
  57. data/test_objects/rails_test/app/assets/stylesheets/application.css +0 -7
  58. data/test_objects/rails_test/app/assets/stylesheets/scaffolds.css.scss +0 -56
  59. data/test_objects/rails_test/app/mailers/.gitkeep +0 -0
  60. data/test_objects/rails_test/app/models/.gitkeep +0 -0
  61. data/test_objects/rails_test/app/views/layouts/application.html.erb +0 -15
  62. data/test_objects/rails_test/app/views/posts/_form.html.erb +0 -25
  63. data/test_objects/rails_test/app/views/posts/edit.html.erb +0 -6
  64. data/test_objects/rails_test/app/views/posts/index.html.erb +0 -20
  65. data/test_objects/rails_test/app/views/posts/new.html.erb +0 -5
  66. data/test_objects/rails_test/app/views/posts/show.html.erb +0 -15
  67. data/test_objects/rails_test/config.ru +0 -4
  68. data/test_objects/rails_test/config/database.yml +0 -25
  69. data/test_objects/rails_test/config/locales/en.yml +0 -5
  70. data/test_objects/rails_test/doc/README_FOR_APP +0 -2
  71. data/test_objects/rails_test/lib/assets/.gitkeep +0 -0
  72. data/test_objects/rails_test/lib/tasks/.gitkeep +0 -0
  73. data/test_objects/rails_test/log/.gitkeep +0 -0
  74. data/test_objects/rails_test/public/404.html +0 -26
  75. data/test_objects/rails_test/public/422.html +0 -26
  76. data/test_objects/rails_test/public/500.html +0 -26
  77. data/test_objects/rails_test/public/favicon.ico +0 -0
  78. data/test_objects/rails_test/public/robots.txt +0 -5
  79. data/test_objects/rails_test/script/rails +0 -6
  80. data/test_objects/rails_test/test/fixtures/.gitkeep +0 -0
  81. data/test_objects/rails_test/test/fixtures/posts.yml +0 -9
  82. data/test_objects/rails_test/test/functional/.gitkeep +0 -0
  83. data/test_objects/rails_test/test/integration/.gitkeep +0 -0
  84. data/test_objects/rails_test/test/unit/.gitkeep +0 -0
  85. data/test_objects/rails_test/vendor/assets/stylesheets/.gitkeep +0 -0
  86. data/test_objects/rails_test/vendor/plugins/.gitkeep +0 -0
  87. data/yarn.gemspec +0 -29
@@ -1,36 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Yarn
4
-
5
- describe Response do
6
- before do
7
- @response = Response.new
8
- end
9
-
10
- describe "#status" do
11
- it "should is a HTTP status code" do
12
- @response.status = 404
13
- @response.status.should == 404
14
- end
15
- end
16
-
17
- describe "#headers" do
18
- it "should is a headers hash" do
19
- @response.headers = { "Connection" => "Close" }
20
- @response.headers["Connection"].should == "Close"
21
- end
22
- end
23
-
24
- describe "#body" do
25
- it "should be an array containing the response body" do
26
- @response.body << "Line 1" << "Line 2"
27
- @response.body.size.should == 2
28
- @response.body[0].should == "Line 1"
29
- @response.body[1].should == "Line 2"
30
- end
31
- end
32
-
33
- end
34
-
35
- end
36
-
@@ -1,102 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Yarn
4
- describe Server do
5
-
6
- after(:each) do
7
- stop_server
8
- end
9
-
10
- describe "#new" do
11
- it "should set the app if parameter is given" do
12
- @server = Server.new({ rack: "test_objects/config.ru" })
13
-
14
- @server.instance_variable_get("@app").should_not be_nil
15
- end
16
- end
17
-
18
- describe "#load_rack_app" do
19
-
20
- before(:each) do
21
- $console = MockIO.new
22
- @server = Server.new( output: $console )
23
- end
24
-
25
- it "should print a message and exit if the file does not exist" do
26
- Kernel.should_receive(:exit)
27
- @server.load_rack_app("non-existing-app.ru")
28
- $console.should include("non-existing-app.ru does not exist. Exiting.")
29
- end
30
-
31
- it "should return a rack app if the file exists" do
32
- app = @server.load_rack_app("test_objects/config.ru")
33
- app.class.should == Rack::Builder
34
- end
35
- end
36
-
37
- describe "#start" do
38
- it "should creates a TCP server" do
39
- @server = Server.new
40
- @server.stub(:init_workers)
41
- @server.start
42
-
43
- @server.socket.class.should == TCPServer
44
- end
45
-
46
- it "should listen on the supplied port" do
47
- @server = Server.new({ port: 4000 })
48
- @server.stub(:init_workers)
49
- @server.start
50
-
51
- @server.socket.addr.should include(4000)
52
- end
53
- end
54
-
55
- describe "#worker" do
56
- it "should start the handler" do
57
- # modify loop to only run once
58
- class Yarn::Server
59
- private
60
- def loop
61
- yield
62
- end
63
- end
64
- @server = Server.new
65
- @server.stub(:init_workers)
66
- @server.stub(:configure_socket)
67
- @server.socket.stub(:accept).and_return("GET / HTTP/1.1")
68
-
69
- RequestHandler.any_instance.should_receive(:run)
70
-
71
- @server.worker
72
- end
73
- end
74
-
75
- describe "#get_handler" do
76
- it "should return the RequestHandler if an app is not given" do
77
- @server = Server.new
78
-
79
- @server.get_handler.class.should == RequestHandler
80
- end
81
-
82
- it "should return the Rackhandler if an app is given" do
83
- @server = Server.new(rack: "test_objects/config.ru")
84
-
85
- @server.get_handler.class.should == RackHandler
86
- end
87
- end
88
-
89
- describe "#stop" do
90
- it "should notify the server is stopped" do
91
- $console = MockIO.new
92
- @server = Server.new({ output: $console })
93
- @server.stub(:init_workers)
94
- @server.start
95
- @server.stop
96
-
97
- $console.should include("Server stopped")
98
- end
99
- end
100
-
101
- end
102
- end
@@ -1,10 +0,0 @@
1
- coverage/*
2
- *.gem
3
- .bundle
4
- Gemfile.lock
5
- pkg/*
6
- *.rbc
7
- doc/*
8
- rails_app
9
- rails_app/*
10
- *.rb
@@ -1,6 +0,0 @@
1
- require 'rubygems'
2
- require 'rack'
3
-
4
- run Proc.new { |env|
5
- [200, {'Content-Type' => "text/plain"}, ["Rack works"]]
6
- }
@@ -1,13 +0,0 @@
1
- <html>
2
- <head>
3
- <meta http-equiv="content-type" content="text/html; charset=utf-8">
4
-
5
- <title>Index</title>
6
-
7
- </head>
8
- <body>
9
- <p>
10
- Success!
11
- </p>
12
- </body>
13
- </html>
@@ -1,8865 +0,0 @@
1
- /*!
2
- * jQuery JavaScript Library v1.6
3
- * http://jquery.com/
4
- *
5
- * Copyright 2011, John Resig
6
- * Dual licensed under the MIT or GPL Version 2 licenses.
7
- * http://jquery.org/license
8
- *
9
- * Includes Sizzle.js
10
- * http://sizzlejs.com/
11
- * Copyright 2011, The Dojo Foundation
12
- * Released under the MIT, BSD, and GPL Licenses.
13
- *
14
- * Date: Mon May 2 13:50:00 2011 -0400
15
- */
16
- (function( window, undefined ) {
17
-
18
- // Use the correct document accordingly with window argument (sandbox)
19
- var document = window.document,
20
- navigator = window.navigator,
21
- location = window.location;
22
- var jQuery = (function() {
23
-
24
- // Define a local copy of jQuery
25
- var jQuery = function( selector, context ) {
26
- // The jQuery object is actually just the init constructor 'enhanced'
27
- return new jQuery.fn.init( selector, context, rootjQuery );
28
- },
29
-
30
- // Map over jQuery in case of overwrite
31
- _jQuery = window.jQuery,
32
-
33
- // Map over the $ in case of overwrite
34
- _$ = window.$,
35
-
36
- // A central reference to the root jQuery(document)
37
- rootjQuery,
38
-
39
- // A simple way to check for HTML strings or ID strings
40
- // (both of which we optimize for)
41
- quickExpr = /^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,
42
-
43
- // Check if a string has a non-whitespace character in it
44
- rnotwhite = /\S/,
45
-
46
- // Used for trimming whitespace
47
- trimLeft = /^\s+/,
48
- trimRight = /\s+$/,
49
-
50
- // Check for digits
51
- rdigit = /\d/,
52
-
53
- // Match a standalone tag
54
- rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
55
-
56
- // JSON RegExp
57
- rvalidchars = /^[\],:{}\s]*$/,
58
- rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,
59
- rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
60
- rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
61
-
62
- // Useragent RegExp
63
- rwebkit = /(webkit)[ \/]([\w.]+)/,
64
- ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/,
65
- rmsie = /(msie) ([\w.]+)/,
66
- rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/,
67
-
68
- // Keep a UserAgent string for use with jQuery.browser
69
- userAgent = navigator.userAgent,
70
-
71
- // For matching the engine and version of the browser
72
- browserMatch,
73
-
74
- // The deferred used on DOM ready
75
- readyList,
76
-
77
- // The ready event handler
78
- DOMContentLoaded,
79
-
80
- // Save a reference to some core methods
81
- toString = Object.prototype.toString,
82
- hasOwn = Object.prototype.hasOwnProperty,
83
- push = Array.prototype.push,
84
- slice = Array.prototype.slice,
85
- trim = String.prototype.trim,
86
- indexOf = Array.prototype.indexOf,
87
-
88
- // [[Class]] -> type pairs
89
- class2type = {};
90
-
91
- jQuery.fn = jQuery.prototype = {
92
- constructor: jQuery,
93
- init: function( selector, context, rootjQuery ) {
94
- var match, elem, ret, doc;
95
-
96
- // Handle $(""), $(null), or $(undefined)
97
- if ( !selector ) {
98
- return this;
99
- }
100
-
101
- // Handle $(DOMElement)
102
- if ( selector.nodeType ) {
103
- this.context = this[0] = selector;
104
- this.length = 1;
105
- return this;
106
- }
107
-
108
- // The body element only exists once, optimize finding it
109
- if ( selector === "body" && !context && document.body ) {
110
- this.context = document;
111
- this[0] = document.body;
112
- this.selector = selector;
113
- this.length = 1;
114
- return this;
115
- }
116
-
117
- // Handle HTML strings
118
- if ( typeof selector === "string" ) {
119
- // Are we dealing with HTML string or an ID?
120
- if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {
121
- // Assume that strings that start and end with <> are HTML and skip the regex check
122
- match = [ null, selector, null ];
123
-
124
- } else {
125
- match = quickExpr.exec( selector );
126
- }
127
-
128
- // Verify a match, and that no context was specified for #id
129
- if ( match && (match[1] || !context) ) {
130
-
131
- // HANDLE: $(html) -> $(array)
132
- if ( match[1] ) {
133
- context = context instanceof jQuery ? context[0] : context;
134
- doc = (context ? context.ownerDocument || context : document);
135
-
136
- // If a single string is passed in and it's a single tag
137
- // just do a createElement and skip the rest
138
- ret = rsingleTag.exec( selector );
139
-
140
- if ( ret ) {
141
- if ( jQuery.isPlainObject( context ) ) {
142
- selector = [ document.createElement( ret[1] ) ];
143
- jQuery.fn.attr.call( selector, context, true );
144
-
145
- } else {
146
- selector = [ doc.createElement( ret[1] ) ];
147
- }
148
-
149
- } else {
150
- ret = jQuery.buildFragment( [ match[1] ], [ doc ] );
151
- selector = (ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment).childNodes;
152
- }
153
-
154
- return jQuery.merge( this, selector );
155
-
156
- // HANDLE: $("#id")
157
- } else {
158
- elem = document.getElementById( match[2] );
159
-
160
- // Check parentNode to catch when Blackberry 4.6 returns
161
- // nodes that are no longer in the document #6963
162
- if ( elem && elem.parentNode ) {
163
- // Handle the case where IE and Opera return items
164
- // by name instead of ID
165
- if ( elem.id !== match[2] ) {
166
- return rootjQuery.find( selector );
167
- }
168
-
169
- // Otherwise, we inject the element directly into the jQuery object
170
- this.length = 1;
171
- this[0] = elem;
172
- }
173
-
174
- this.context = document;
175
- this.selector = selector;
176
- return this;
177
- }
178
-
179
- // HANDLE: $(expr, $(...))
180
- } else if ( !context || context.jquery ) {
181
- return (context || rootjQuery).find( selector );
182
-
183
- // HANDLE: $(expr, context)
184
- // (which is just equivalent to: $(context).find(expr)
185
- } else {
186
- return this.constructor( context ).find( selector );
187
- }
188
-
189
- // HANDLE: $(function)
190
- // Shortcut for document ready
191
- } else if ( jQuery.isFunction( selector ) ) {
192
- return rootjQuery.ready( selector );
193
- }
194
-
195
- if (selector.selector !== undefined) {
196
- this.selector = selector.selector;
197
- this.context = selector.context;
198
- }
199
-
200
- return jQuery.makeArray( selector, this );
201
- },
202
-
203
- // Start with an empty selector
204
- selector: "",
205
-
206
- // The current version of jQuery being used
207
- jquery: "1.6",
208
-
209
- // The default length of a jQuery object is 0
210
- length: 0,
211
-
212
- // The number of elements contained in the matched element set
213
- size: function() {
214
- return this.length;
215
- },
216
-
217
- toArray: function() {
218
- return slice.call( this, 0 );
219
- },
220
-
221
- // Get the Nth element in the matched element set OR
222
- // Get the whole matched element set as a clean array
223
- get: function( num ) {
224
- return num == null ?
225
-
226
- // Return a 'clean' array
227
- this.toArray() :
228
-
229
- // Return just the object
230
- ( num < 0 ? this[ this.length + num ] : this[ num ] );
231
- },
232
-
233
- // Take an array of elements and push it onto the stack
234
- // (returning the new matched element set)
235
- pushStack: function( elems, name, selector ) {
236
- // Build a new jQuery matched element set
237
- var ret = this.constructor();
238
-
239
- if ( jQuery.isArray( elems ) ) {
240
- push.apply( ret, elems );
241
-
242
- } else {
243
- jQuery.merge( ret, elems );
244
- }
245
-
246
- // Add the old object onto the stack (as a reference)
247
- ret.prevObject = this;
248
-
249
- ret.context = this.context;
250
-
251
- if ( name === "find" ) {
252
- ret.selector = this.selector + (this.selector ? " " : "") + selector;
253
- } else if ( name ) {
254
- ret.selector = this.selector + "." + name + "(" + selector + ")";
255
- }
256
-
257
- // Return the newly-formed element set
258
- return ret;
259
- },
260
-
261
- // Execute a callback for every element in the matched set.
262
- // (You can seed the arguments with an array of args, but this is
263
- // only used internally.)
264
- each: function( callback, args ) {
265
- return jQuery.each( this, callback, args );
266
- },
267
-
268
- ready: function( fn ) {
269
- // Attach the listeners
270
- jQuery.bindReady();
271
-
272
- // Add the callback
273
- readyList.done( fn );
274
-
275
- return this;
276
- },
277
-
278
- eq: function( i ) {
279
- return i === -1 ?
280
- this.slice( i ) :
281
- this.slice( i, +i + 1 );
282
- },
283
-
284
- first: function() {
285
- return this.eq( 0 );
286
- },
287
-
288
- last: function() {
289
- return this.eq( -1 );
290
- },
291
-
292
- slice: function() {
293
- return this.pushStack( slice.apply( this, arguments ),
294
- "slice", slice.call(arguments).join(",") );
295
- },
296
-
297
- map: function( callback ) {
298
- return this.pushStack( jQuery.map(this, function( elem, i ) {
299
- return callback.call( elem, i, elem );
300
- }));
301
- },
302
-
303
- end: function() {
304
- return this.prevObject || this.constructor(null);
305
- },
306
-
307
- // For internal use only.
308
- // Behaves like an Array's method, not like a jQuery method.
309
- push: push,
310
- sort: [].sort,
311
- splice: [].splice
312
- };
313
-
314
- // Give the init function the jQuery prototype for later instantiation
315
- jQuery.fn.init.prototype = jQuery.fn;
316
-
317
- jQuery.extend = jQuery.fn.extend = function() {
318
- var options, name, src, copy, copyIsArray, clone,
319
- target = arguments[0] || {},
320
- i = 1,
321
- length = arguments.length,
322
- deep = false;
323
-
324
- // Handle a deep copy situation
325
- if ( typeof target === "boolean" ) {
326
- deep = target;
327
- target = arguments[1] || {};
328
- // skip the boolean and the target
329
- i = 2;
330
- }
331
-
332
- // Handle case when target is a string or something (possible in deep copy)
333
- if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
334
- target = {};
335
- }
336
-
337
- // extend jQuery itself if only one argument is passed
338
- if ( length === i ) {
339
- target = this;
340
- --i;
341
- }
342
-
343
- for ( ; i < length; i++ ) {
344
- // Only deal with non-null/undefined values
345
- if ( (options = arguments[ i ]) != null ) {
346
- // Extend the base object
347
- for ( name in options ) {
348
- src = target[ name ];
349
- copy = options[ name ];
350
-
351
- // Prevent never-ending loop
352
- if ( target === copy ) {
353
- continue;
354
- }
355
-
356
- // Recurse if we're merging plain objects or arrays
357
- if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
358
- if ( copyIsArray ) {
359
- copyIsArray = false;
360
- clone = src && jQuery.isArray(src) ? src : [];
361
-
362
- } else {
363
- clone = src && jQuery.isPlainObject(src) ? src : {};
364
- }
365
-
366
- // Never move original objects, clone them
367
- target[ name ] = jQuery.extend( deep, clone, copy );
368
-
369
- // Don't bring in undefined values
370
- } else if ( copy !== undefined ) {
371
- target[ name ] = copy;
372
- }
373
- }
374
- }
375
- }
376
-
377
- // Return the modified object
378
- return target;
379
- };
380
-
381
- jQuery.extend({
382
- noConflict: function( deep ) {
383
- if ( window.$ === jQuery ) {
384
- window.$ = _$;
385
- }
386
-
387
- if ( deep && window.jQuery === jQuery ) {
388
- window.jQuery = _jQuery;
389
- }
390
-
391
- return jQuery;
392
- },
393
-
394
- // Is the DOM ready to be used? Set to true once it occurs.
395
- isReady: false,
396
-
397
- // A counter to track how many items to wait for before
398
- // the ready event fires. See #6781
399
- readyWait: 1,
400
-
401
- // Hold (or release) the ready event
402
- holdReady: function( hold ) {
403
- if ( hold ) {
404
- jQuery.readyWait++;
405
- } else {
406
- jQuery.ready( true );
407
- }
408
- },
409
-
410
- // Handle when the DOM is ready
411
- ready: function( wait ) {
412
- // Either a released hold or an DOMready/load event and not yet ready
413
- if ( (wait === true && !--jQuery.readyWait) || (wait !== true && !jQuery.isReady) ) {
414
- // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
415
- if ( !document.body ) {
416
- return setTimeout( jQuery.ready, 1 );
417
- }
418
-
419
- // Remember that the DOM is ready
420
- jQuery.isReady = true;
421
-
422
- // If a normal DOM Ready event fired, decrement, and wait if need be
423
- if ( wait !== true && --jQuery.readyWait > 0 ) {
424
- return;
425
- }
426
-
427
- // If there are functions bound, to execute
428
- readyList.resolveWith( document, [ jQuery ] );
429
-
430
- // Trigger any bound ready events
431
- if ( jQuery.fn.trigger ) {
432
- jQuery( document ).trigger( "ready" ).unbind( "ready" );
433
- }
434
- }
435
- },
436
-
437
- bindReady: function() {
438
- if ( readyList ) {
439
- return;
440
- }
441
-
442
- readyList = jQuery._Deferred();
443
-
444
- // Catch cases where $(document).ready() is called after the
445
- // browser event has already occurred.
446
- if ( document.readyState === "complete" ) {
447
- // Handle it asynchronously to allow scripts the opportunity to delay ready
448
- return setTimeout( jQuery.ready, 1 );
449
- }
450
-
451
- // Mozilla, Opera and webkit nightlies currently support this event
452
- if ( document.addEventListener ) {
453
- // Use the handy event callback
454
- document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
455
-
456
- // A fallback to window.onload, that will always work
457
- window.addEventListener( "load", jQuery.ready, false );
458
-
459
- // If IE event model is used
460
- } else if ( document.attachEvent ) {
461
- // ensure firing before onload,
462
- // maybe late but safe also for iframes
463
- document.attachEvent( "onreadystatechange", DOMContentLoaded );
464
-
465
- // A fallback to window.onload, that will always work
466
- window.attachEvent( "onload", jQuery.ready );
467
-
468
- // If IE and not a frame
469
- // continually check to see if the document is ready
470
- var toplevel = false;
471
-
472
- try {
473
- toplevel = window.frameElement == null;
474
- } catch(e) {}
475
-
476
- if ( document.documentElement.doScroll && toplevel ) {
477
- doScrollCheck();
478
- }
479
- }
480
- },
481
-
482
- // See test/unit/core.js for details concerning isFunction.
483
- // Since version 1.3, DOM methods and functions like alert
484
- // aren't supported. They return false on IE (#2968).
485
- isFunction: function( obj ) {
486
- return jQuery.type(obj) === "function";
487
- },
488
-
489
- isArray: Array.isArray || function( obj ) {
490
- return jQuery.type(obj) === "array";
491
- },
492
-
493
- // A crude way of determining if an object is a window
494
- isWindow: function( obj ) {
495
- return obj && typeof obj === "object" && "setInterval" in obj;
496
- },
497
-
498
- isNaN: function( obj ) {
499
- return obj == null || !rdigit.test( obj ) || isNaN( obj );
500
- },
501
-
502
- type: function( obj ) {
503
- return obj == null ?
504
- String( obj ) :
505
- class2type[ toString.call(obj) ] || "object";
506
- },
507
-
508
- isPlainObject: function( obj ) {
509
- // Must be an Object.
510
- // Because of IE, we also have to check the presence of the constructor property.
511
- // Make sure that DOM nodes and window objects don't pass through, as well
512
- if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
513
- return false;
514
- }
515
-
516
- // Not own constructor property must be Object
517
- if ( obj.constructor &&
518
- !hasOwn.call(obj, "constructor") &&
519
- !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
520
- return false;
521
- }
522
-
523
- // Own properties are enumerated firstly, so to speed up,
524
- // if last one is own, then all properties are own.
525
-
526
- var key;
527
- for ( key in obj ) {}
528
-
529
- return key === undefined || hasOwn.call( obj, key );
530
- },
531
-
532
- isEmptyObject: function( obj ) {
533
- for ( var name in obj ) {
534
- return false;
535
- }
536
- return true;
537
- },
538
-
539
- error: function( msg ) {
540
- throw msg;
541
- },
542
-
543
- parseJSON: function( data ) {
544
- if ( typeof data !== "string" || !data ) {
545
- return null;
546
- }
547
-
548
- // Make sure leading/trailing whitespace is removed (IE can't handle it)
549
- data = jQuery.trim( data );
550
-
551
- // Attempt to parse using the native JSON parser first
552
- if ( window.JSON && window.JSON.parse ) {
553
- return window.JSON.parse( data );
554
- }
555
-
556
- // Make sure the incoming data is actual JSON
557
- // Logic borrowed from http://json.org/json2.js
558
- if ( rvalidchars.test( data.replace( rvalidescape, "@" )
559
- .replace( rvalidtokens, "]" )
560
- .replace( rvalidbraces, "")) ) {
561
-
562
- return (new Function( "return " + data ))();
563
-
564
- }
565
- jQuery.error( "Invalid JSON: " + data );
566
- },
567
-
568
- // Cross-browser xml parsing
569
- // (xml & tmp used internally)
570
- parseXML: function( data , xml , tmp ) {
571
-
572
- if ( window.DOMParser ) { // Standard
573
- tmp = new DOMParser();
574
- xml = tmp.parseFromString( data , "text/xml" );
575
- } else { // IE
576
- xml = new ActiveXObject( "Microsoft.XMLDOM" );
577
- xml.async = "false";
578
- xml.loadXML( data );
579
- }
580
-
581
- tmp = xml.documentElement;
582
-
583
- if ( ! tmp || ! tmp.nodeName || tmp.nodeName === "parsererror" ) {
584
- jQuery.error( "Invalid XML: " + data );
585
- }
586
-
587
- return xml;
588
- },
589
-
590
- noop: function() {},
591
-
592
- // Evaluates a script in a global context
593
- // Workarounds based on findings by Jim Driscoll
594
- // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
595
- globalEval: function( data ) {
596
- if ( data && rnotwhite.test( data ) ) {
597
- // We use execScript on Internet Explorer
598
- // We use an anonymous function so that context is window
599
- // rather than jQuery in Firefox
600
- ( window.execScript || function( data ) {
601
- window[ "eval" ].call( window, data );
602
- } )( data );
603
- }
604
- },
605
-
606
- nodeName: function( elem, name ) {
607
- return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
608
- },
609
-
610
- // args is for internal usage only
611
- each: function( object, callback, args ) {
612
- var name, i = 0,
613
- length = object.length,
614
- isObj = length === undefined || jQuery.isFunction( object );
615
-
616
- if ( args ) {
617
- if ( isObj ) {
618
- for ( name in object ) {
619
- if ( callback.apply( object[ name ], args ) === false ) {
620
- break;
621
- }
622
- }
623
- } else {
624
- for ( ; i < length; ) {
625
- if ( callback.apply( object[ i++ ], args ) === false ) {
626
- break;
627
- }
628
- }
629
- }
630
-
631
- // A special, fast, case for the most common use of each
632
- } else {
633
- if ( isObj ) {
634
- for ( name in object ) {
635
- if ( callback.call( object[ name ], name, object[ name ] ) === false ) {
636
- break;
637
- }
638
- }
639
- } else {
640
- for ( ; i < length; ) {
641
- if ( callback.call( object[ i ], i, object[ i++ ] ) === false ) {
642
- break;
643
- }
644
- }
645
- }
646
- }
647
-
648
- return object;
649
- },
650
-
651
- // Use native String.trim function wherever possible
652
- trim: trim ?
653
- function( text ) {
654
- return text == null ?
655
- "" :
656
- trim.call( text );
657
- } :
658
-
659
- // Otherwise use our own trimming functionality
660
- function( text ) {
661
- return text == null ?
662
- "" :
663
- text.toString().replace( trimLeft, "" ).replace( trimRight, "" );
664
- },
665
-
666
- // results is for internal usage only
667
- makeArray: function( array, results ) {
668
- var ret = results || [];
669
-
670
- if ( array != null ) {
671
- // The window, strings (and functions) also have 'length'
672
- // The extra typeof function check is to prevent crashes
673
- // in Safari 2 (See: #3039)
674
- // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
675
- var type = jQuery.type( array );
676
-
677
- if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) {
678
- push.call( ret, array );
679
- } else {
680
- jQuery.merge( ret, array );
681
- }
682
- }
683
-
684
- return ret;
685
- },
686
-
687
- inArray: function( elem, array ) {
688
-
689
- if ( indexOf ) {
690
- return indexOf.call( array, elem );
691
- }
692
-
693
- for ( var i = 0, length = array.length; i < length; i++ ) {
694
- if ( array[ i ] === elem ) {
695
- return i;
696
- }
697
- }
698
-
699
- return -1;
700
- },
701
-
702
- merge: function( first, second ) {
703
- var i = first.length,
704
- j = 0;
705
-
706
- if ( typeof second.length === "number" ) {
707
- for ( var l = second.length; j < l; j++ ) {
708
- first[ i++ ] = second[ j ];
709
- }
710
-
711
- } else {
712
- while ( second[j] !== undefined ) {
713
- first[ i++ ] = second[ j++ ];
714
- }
715
- }
716
-
717
- first.length = i;
718
-
719
- return first;
720
- },
721
-
722
- grep: function( elems, callback, inv ) {
723
- var ret = [], retVal;
724
- inv = !!inv;
725
-
726
- // Go through the array, only saving the items
727
- // that pass the validator function
728
- for ( var i = 0, length = elems.length; i < length; i++ ) {
729
- retVal = !!callback( elems[ i ], i );
730
- if ( inv !== retVal ) {
731
- ret.push( elems[ i ] );
732
- }
733
- }
734
-
735
- return ret;
736
- },
737
-
738
- // arg is for internal usage only
739
- map: function( elems, callback, arg ) {
740
- var value, key, ret = [],
741
- i = 0,
742
- length = elems.length,
743
- // jquery objects are treated as arrays
744
- isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ;
745
-
746
- // Go through the array, translating each of the items to their
747
- if ( isArray ) {
748
- for ( ; i < length; i++ ) {
749
- value = callback( elems[ i ], i, arg );
750
-
751
- if ( value != null ) {
752
- ret[ ret.length ] = value;
753
- }
754
- }
755
-
756
- // Go through every key on the object,
757
- } else {
758
- for ( key in elems ) {
759
- value = callback( elems[ key ], key, arg );
760
-
761
- if ( value != null ) {
762
- ret[ ret.length ] = value;
763
- }
764
- }
765
- }
766
-
767
- // Flatten any nested arrays
768
- return ret.concat.apply( [], ret );
769
- },
770
-
771
- // A global GUID counter for objects
772
- guid: 1,
773
-
774
- // Bind a function to a context, optionally partially applying any
775
- // arguments.
776
- proxy: function( fn, context ) {
777
- if ( typeof context === "string" ) {
778
- var tmp = fn[ context ];
779
- context = fn;
780
- fn = tmp;
781
- }
782
-
783
- // Quick check to determine if target is callable, in the spec
784
- // this throws a TypeError, but we will just return undefined.
785
- if ( !jQuery.isFunction( fn ) ) {
786
- return undefined;
787
- }
788
-
789
- // Simulated bind
790
- var args = slice.call( arguments, 2 ),
791
- proxy = function() {
792
- return fn.apply( context, args.concat( slice.call( arguments ) ) );
793
- };
794
-
795
- // Set the guid of unique handler to the same of original handler, so it can be removed
796
- proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
797
-
798
- return proxy;
799
- },
800
-
801
- // Mutifunctional method to get and set values to a collection
802
- // The value/s can be optionally by executed if its a function
803
- access: function( elems, key, value, exec, fn, pass ) {
804
- var length = elems.length;
805
-
806
- // Setting many attributes
807
- if ( typeof key === "object" ) {
808
- for ( var k in key ) {
809
- jQuery.access( elems, k, key[k], exec, fn, value );
810
- }
811
- return elems;
812
- }
813
-
814
- // Setting one attribute
815
- if ( value !== undefined ) {
816
- // Optionally, function values get executed if exec is true
817
- exec = !pass && exec && jQuery.isFunction(value);
818
-
819
- for ( var i = 0; i < length; i++ ) {
820
- fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
821
- }
822
-
823
- return elems;
824
- }
825
-
826
- // Getting an attribute
827
- return length ? fn( elems[0], key ) : undefined;
828
- },
829
-
830
- now: function() {
831
- return (new Date()).getTime();
832
- },
833
-
834
- // Use of jQuery.browser is frowned upon.
835
- // More details: http://docs.jquery.com/Utilities/jQuery.browser
836
- uaMatch: function( ua ) {
837
- ua = ua.toLowerCase();
838
-
839
- var match = rwebkit.exec( ua ) ||
840
- ropera.exec( ua ) ||
841
- rmsie.exec( ua ) ||
842
- ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) ||
843
- [];
844
-
845
- return { browser: match[1] || "", version: match[2] || "0" };
846
- },
847
-
848
- sub: function() {
849
- function jQuerySub( selector, context ) {
850
- return new jQuerySub.fn.init( selector, context );
851
- }
852
- jQuery.extend( true, jQuerySub, this );
853
- jQuerySub.superclass = this;
854
- jQuerySub.fn = jQuerySub.prototype = this();
855
- jQuerySub.fn.constructor = jQuerySub;
856
- jQuerySub.sub = this.sub;
857
- jQuerySub.fn.init = function init( selector, context ) {
858
- if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) {
859
- context = jQuerySub( context );
860
- }
861
-
862
- return jQuery.fn.init.call( this, selector, context, rootjQuerySub );
863
- };
864
- jQuerySub.fn.init.prototype = jQuerySub.fn;
865
- var rootjQuerySub = jQuerySub(document);
866
- return jQuerySub;
867
- },
868
-
869
- browser: {}
870
- });
871
-
872
- // Populate the class2type map
873
- jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) {
874
- class2type[ "[object " + name + "]" ] = name.toLowerCase();
875
- });
876
-
877
- browserMatch = jQuery.uaMatch( userAgent );
878
- if ( browserMatch.browser ) {
879
- jQuery.browser[ browserMatch.browser ] = true;
880
- jQuery.browser.version = browserMatch.version;
881
- }
882
-
883
- // Deprecated, use jQuery.browser.webkit instead
884
- if ( jQuery.browser.webkit ) {
885
- jQuery.browser.safari = true;
886
- }
887
-
888
- // IE doesn't match non-breaking spaces with \s
889
- if ( rnotwhite.test( "\xA0" ) ) {
890
- trimLeft = /^[\s\xA0]+/;
891
- trimRight = /[\s\xA0]+$/;
892
- }
893
-
894
- // All jQuery objects should point back to these
895
- rootjQuery = jQuery(document);
896
-
897
- // Cleanup functions for the document ready method
898
- if ( document.addEventListener ) {
899
- DOMContentLoaded = function() {
900
- document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
901
- jQuery.ready();
902
- };
903
-
904
- } else if ( document.attachEvent ) {
905
- DOMContentLoaded = function() {
906
- // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
907
- if ( document.readyState === "complete" ) {
908
- document.detachEvent( "onreadystatechange", DOMContentLoaded );
909
- jQuery.ready();
910
- }
911
- };
912
- }
913
-
914
- // The DOM ready check for Internet Explorer
915
- function doScrollCheck() {
916
- if ( jQuery.isReady ) {
917
- return;
918
- }
919
-
920
- try {
921
- // If IE is used, use the trick by Diego Perini
922
- // http://javascript.nwbox.com/IEContentLoaded/
923
- document.documentElement.doScroll("left");
924
- } catch(e) {
925
- setTimeout( doScrollCheck, 1 );
926
- return;
927
- }
928
-
929
- // and execute any waiting functions
930
- jQuery.ready();
931
- }
932
-
933
- // Expose jQuery to the global object
934
- return jQuery;
935
-
936
- })();
937
-
938
-
939
- var // Promise methods
940
- promiseMethods = "done fail isResolved isRejected promise then always pipe".split( " " ),
941
- // Static reference to slice
942
- sliceDeferred = [].slice;
943
-
944
- jQuery.extend({
945
- // Create a simple deferred (one callbacks list)
946
- _Deferred: function() {
947
- var // callbacks list
948
- callbacks = [],
949
- // stored [ context , args ]
950
- fired,
951
- // to avoid firing when already doing so
952
- firing,
953
- // flag to know if the deferred has been cancelled
954
- cancelled,
955
- // the deferred itself
956
- deferred = {
957
-
958
- // done( f1, f2, ...)
959
- done: function() {
960
- if ( !cancelled ) {
961
- var args = arguments,
962
- i,
963
- length,
964
- elem,
965
- type,
966
- _fired;
967
- if ( fired ) {
968
- _fired = fired;
969
- fired = 0;
970
- }
971
- for ( i = 0, length = args.length; i < length; i++ ) {
972
- elem = args[ i ];
973
- type = jQuery.type( elem );
974
- if ( type === "array" ) {
975
- deferred.done.apply( deferred, elem );
976
- } else if ( type === "function" ) {
977
- callbacks.push( elem );
978
- }
979
- }
980
- if ( _fired ) {
981
- deferred.resolveWith( _fired[ 0 ], _fired[ 1 ] );
982
- }
983
- }
984
- return this;
985
- },
986
-
987
- // resolve with given context and args
988
- resolveWith: function( context, args ) {
989
- if ( !cancelled && !fired && !firing ) {
990
- // make sure args are available (#8421)
991
- args = args || [];
992
- firing = 1;
993
- try {
994
- while( callbacks[ 0 ] ) {
995
- callbacks.shift().apply( context, args );
996
- }
997
- }
998
- finally {
999
- fired = [ context, args ];
1000
- firing = 0;
1001
- }
1002
- }
1003
- return this;
1004
- },
1005
-
1006
- // resolve with this as context and given arguments
1007
- resolve: function() {
1008
- deferred.resolveWith( this, arguments );
1009
- return this;
1010
- },
1011
-
1012
- // Has this deferred been resolved?
1013
- isResolved: function() {
1014
- return !!( firing || fired );
1015
- },
1016
-
1017
- // Cancel
1018
- cancel: function() {
1019
- cancelled = 1;
1020
- callbacks = [];
1021
- return this;
1022
- }
1023
- };
1024
-
1025
- return deferred;
1026
- },
1027
-
1028
- // Full fledged deferred (two callbacks list)
1029
- Deferred: function( func ) {
1030
- var deferred = jQuery._Deferred(),
1031
- failDeferred = jQuery._Deferred(),
1032
- promise;
1033
- // Add errorDeferred methods, then and promise
1034
- jQuery.extend( deferred, {
1035
- then: function( doneCallbacks, failCallbacks ) {
1036
- deferred.done( doneCallbacks ).fail( failCallbacks );
1037
- return this;
1038
- },
1039
- always: function() {
1040
- return deferred.done.apply( deferred, arguments ).fail.apply( this, arguments );
1041
- },
1042
- fail: failDeferred.done,
1043
- rejectWith: failDeferred.resolveWith,
1044
- reject: failDeferred.resolve,
1045
- isRejected: failDeferred.isResolved,
1046
- pipe: function( fnDone, fnFail ) {
1047
- return jQuery.Deferred(function( newDefer ) {
1048
- jQuery.each( {
1049
- done: [ fnDone, "resolve" ],
1050
- fail: [ fnFail, "reject" ]
1051
- }, function( handler, data ) {
1052
- var fn = data[ 0 ],
1053
- action = data[ 1 ],
1054
- returned;
1055
- if ( jQuery.isFunction( fn ) ) {
1056
- deferred[ handler ](function() {
1057
- returned = fn.apply( this, arguments );
1058
- if ( jQuery.isFunction( returned.promise ) ) {
1059
- returned.promise().then( newDefer.resolve, newDefer.reject );
1060
- } else {
1061
- newDefer[ action ]( returned );
1062
- }
1063
- });
1064
- } else {
1065
- deferred[ handler ]( newDefer[ action ] );
1066
- }
1067
- });
1068
- }).promise();
1069
- },
1070
- // Get a promise for this deferred
1071
- // If obj is provided, the promise aspect is added to the object
1072
- promise: function( obj ) {
1073
- if ( obj == null ) {
1074
- if ( promise ) {
1075
- return promise;
1076
- }
1077
- promise = obj = {};
1078
- }
1079
- var i = promiseMethods.length;
1080
- while( i-- ) {
1081
- obj[ promiseMethods[i] ] = deferred[ promiseMethods[i] ];
1082
- }
1083
- return obj;
1084
- }
1085
- });
1086
- // Make sure only one callback list will be used
1087
- deferred.done( failDeferred.cancel ).fail( deferred.cancel );
1088
- // Unexpose cancel
1089
- delete deferred.cancel;
1090
- // Call given func if any
1091
- if ( func ) {
1092
- func.call( deferred, deferred );
1093
- }
1094
- return deferred;
1095
- },
1096
-
1097
- // Deferred helper
1098
- when: function( firstParam ) {
1099
- var args = arguments,
1100
- i = 0,
1101
- length = args.length,
1102
- count = length,
1103
- deferred = length <= 1 && firstParam && jQuery.isFunction( firstParam.promise ) ?
1104
- firstParam :
1105
- jQuery.Deferred();
1106
- function resolveFunc( i ) {
1107
- return function( value ) {
1108
- args[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value;
1109
- if ( !( --count ) ) {
1110
- // Strange bug in FF4:
1111
- // Values changed onto the arguments object sometimes end up as undefined values
1112
- // outside the $.when method. Cloning the object into a fresh array solves the issue
1113
- deferred.resolveWith( deferred, sliceDeferred.call( args, 0 ) );
1114
- }
1115
- };
1116
- }
1117
- if ( length > 1 ) {
1118
- for( ; i < length; i++ ) {
1119
- if ( args[ i ] && jQuery.isFunction( args[ i ].promise ) ) {
1120
- args[ i ].promise().then( resolveFunc(i), deferred.reject );
1121
- } else {
1122
- --count;
1123
- }
1124
- }
1125
- if ( !count ) {
1126
- deferred.resolveWith( deferred, args );
1127
- }
1128
- } else if ( deferred !== firstParam ) {
1129
- deferred.resolveWith( deferred, length ? [ firstParam ] : [] );
1130
- }
1131
- return deferred.promise();
1132
- }
1133
- });
1134
-
1135
-
1136
-
1137
- jQuery.support = (function() {
1138
-
1139
- var div = document.createElement( "div" ),
1140
- all,
1141
- a,
1142
- select,
1143
- opt,
1144
- input,
1145
- marginDiv,
1146
- support,
1147
- fragment,
1148
- body,
1149
- bodyStyle,
1150
- tds,
1151
- events,
1152
- eventName,
1153
- i,
1154
- isSupported;
1155
-
1156
- // Preliminary tests
1157
- div.setAttribute("className", "t");
1158
- div.innerHTML = " <link/><table></table><a href='/a' style='top:1px;float:left;opacity:.55;'>a</a><input type='checkbox'/>";
1159
-
1160
- all = div.getElementsByTagName( "*" );
1161
- a = div.getElementsByTagName( "a" )[ 0 ];
1162
-
1163
- // Can't get basic test support
1164
- if ( !all || !all.length || !a ) {
1165
- return {};
1166
- }
1167
-
1168
- // First batch of supports tests
1169
- select = document.createElement( "select" );
1170
- opt = select.appendChild( document.createElement("option") );
1171
- input = div.getElementsByTagName( "input" )[ 0 ];
1172
-
1173
- support = {
1174
- // IE strips leading whitespace when .innerHTML is used
1175
- leadingWhitespace: ( div.firstChild.nodeType === 3 ),
1176
-
1177
- // Make sure that tbody elements aren't automatically inserted
1178
- // IE will insert them into empty tables
1179
- tbody: !div.getElementsByTagName( "tbody" ).length,
1180
-
1181
- // Make sure that link elements get serialized correctly by innerHTML
1182
- // This requires a wrapper element in IE
1183
- htmlSerialize: !!div.getElementsByTagName( "link" ).length,
1184
-
1185
- // Get the style information from getAttribute
1186
- // (IE uses .cssText instead)
1187
- style: /top/.test( a.getAttribute("style") ),
1188
-
1189
- // Make sure that URLs aren't manipulated
1190
- // (IE normalizes it by default)
1191
- hrefNormalized: ( a.getAttribute( "href" ) === "/a" ),
1192
-
1193
- // Make sure that element opacity exists
1194
- // (IE uses filter instead)
1195
- // Use a regex to work around a WebKit issue. See #5145
1196
- opacity: /^0.55$/.test( a.style.opacity ),
1197
-
1198
- // Verify style float existence
1199
- // (IE uses styleFloat instead of cssFloat)
1200
- cssFloat: !!a.style.cssFloat,
1201
-
1202
- // Make sure that if no value is specified for a checkbox
1203
- // that it defaults to "on".
1204
- // (WebKit defaults to "" instead)
1205
- checkOn: ( input.value === "on" ),
1206
-
1207
- // Make sure that a selected-by-default option has a working selected property.
1208
- // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
1209
- optSelected: opt.selected,
1210
-
1211
- // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
1212
- getSetAttribute: div.className !== "t",
1213
-
1214
- // Will be defined later
1215
- submitBubbles: true,
1216
- changeBubbles: true,
1217
- focusinBubbles: false,
1218
- deleteExpando: true,
1219
- noCloneEvent: true,
1220
- inlineBlockNeedsLayout: false,
1221
- shrinkWrapBlocks: false,
1222
- reliableMarginRight: true
1223
- };
1224
-
1225
- // Make sure checked status is properly cloned
1226
- input.checked = true;
1227
- support.noCloneChecked = input.cloneNode( true ).checked;
1228
-
1229
- // Make sure that the options inside disabled selects aren't marked as disabled
1230
- // (WebKit marks them as disabled)
1231
- select.disabled = true;
1232
- support.optDisabled = !opt.disabled;
1233
-
1234
- // Test to see if it's possible to delete an expando from an element
1235
- // Fails in Internet Explorer
1236
- try {
1237
- delete div.test;
1238
- } catch( e ) {
1239
- support.deleteExpando = false;
1240
- }
1241
-
1242
- if ( !div.addEventListener && div.attachEvent && div.fireEvent ) {
1243
- div.attachEvent( "onclick", function click() {
1244
- // Cloning a node shouldn't copy over any
1245
- // bound event handlers (IE does this)
1246
- support.noCloneEvent = false;
1247
- div.detachEvent( "onclick", click );
1248
- });
1249
- div.cloneNode( true ).fireEvent( "onclick" );
1250
- }
1251
-
1252
- // Check if a radio maintains it's value
1253
- // after being appended to the DOM
1254
- input = document.createElement("input");
1255
- input.value = "t";
1256
- input.setAttribute("type", "radio");
1257
- support.radioValue = input.value === "t";
1258
-
1259
- input.setAttribute("checked", "checked");
1260
- div.appendChild( input );
1261
- fragment = document.createDocumentFragment();
1262
- fragment.appendChild( div.firstChild );
1263
-
1264
- // WebKit doesn't clone checked state correctly in fragments
1265
- support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked;
1266
-
1267
- div.innerHTML = "";
1268
-
1269
- // Figure out if the W3C box model works as expected
1270
- div.style.width = div.style.paddingLeft = "1px";
1271
-
1272
- // We use our own, invisible, body
1273
- body = document.createElement( "body" );
1274
- bodyStyle = {
1275
- visibility: "hidden",
1276
- width: 0,
1277
- height: 0,
1278
- border: 0,
1279
- margin: 0,
1280
- // Set background to avoid IE crashes when removing (#9028)
1281
- background: "none"
1282
- };
1283
- for ( i in bodyStyle ) {
1284
- body.style[ i ] = bodyStyle[ i ];
1285
- }
1286
- body.appendChild( div );
1287
- document.documentElement.appendChild( body );
1288
-
1289
- // Check if a disconnected checkbox will retain its checked
1290
- // value of true after appended to the DOM (IE6/7)
1291
- support.appendChecked = input.checked;
1292
-
1293
- support.boxModel = div.offsetWidth === 2;
1294
-
1295
- if ( "zoom" in div.style ) {
1296
- // Check if natively block-level elements act like inline-block
1297
- // elements when setting their display to 'inline' and giving
1298
- // them layout
1299
- // (IE < 8 does this)
1300
- div.style.display = "inline";
1301
- div.style.zoom = 1;
1302
- support.inlineBlockNeedsLayout = ( div.offsetWidth === 2 );
1303
-
1304
- // Check if elements with layout shrink-wrap their children
1305
- // (IE 6 does this)
1306
- div.style.display = "";
1307
- div.innerHTML = "<div style='width:4px;'></div>";
1308
- support.shrinkWrapBlocks = ( div.offsetWidth !== 2 );
1309
- }
1310
-
1311
- div.innerHTML = "<table><tr><td style='padding:0;border:0;display:none'></td><td>t</td></tr></table>";
1312
- tds = div.getElementsByTagName( "td" );
1313
-
1314
- // Check if table cells still have offsetWidth/Height when they are set
1315
- // to display:none and there are still other visible table cells in a
1316
- // table row; if so, offsetWidth/Height are not reliable for use when
1317
- // determining if an element has been hidden directly using
1318
- // display:none (it is still safe to use offsets if a parent element is
1319
- // hidden; don safety goggles and see bug #4512 for more information).
1320
- // (only IE 8 fails this test)
1321
- isSupported = ( tds[ 0 ].offsetHeight === 0 );
1322
-
1323
- tds[ 0 ].style.display = "";
1324
- tds[ 1 ].style.display = "none";
1325
-
1326
- // Check if empty table cells still have offsetWidth/Height
1327
- // (IE < 8 fail this test)
1328
- support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 );
1329
- div.innerHTML = "";
1330
-
1331
- // Check if div with explicit width and no margin-right incorrectly
1332
- // gets computed margin-right based on width of container. For more
1333
- // info see bug #3333
1334
- // Fails in WebKit before Feb 2011 nightlies
1335
- // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
1336
- if ( document.defaultView && document.defaultView.getComputedStyle ) {
1337
- marginDiv = document.createElement( "div" );
1338
- marginDiv.style.width = "0";
1339
- marginDiv.style.marginRight = "0";
1340
- div.appendChild( marginDiv );
1341
- support.reliableMarginRight =
1342
- ( parseInt( document.defaultView.getComputedStyle( marginDiv, null ).marginRight, 10 ) || 0 ) === 0;
1343
- }
1344
-
1345
- // Remove the body element we added
1346
- body.innerHTML = "";
1347
- document.documentElement.removeChild( body );
1348
-
1349
- // Technique from Juriy Zaytsev
1350
- // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
1351
- // We only care about the case where non-standard event systems
1352
- // are used, namely in IE. Short-circuiting here helps us to
1353
- // avoid an eval call (in setAttribute) which can cause CSP
1354
- // to go haywire. See: https://developer.mozilla.org/en/Security/CSP
1355
- if ( div.attachEvent ) {
1356
- for( i in {
1357
- submit: 1,
1358
- change: 1,
1359
- focusin: 1
1360
- } ) {
1361
- eventName = "on" + i;
1362
- isSupported = ( eventName in div );
1363
- if ( !isSupported ) {
1364
- div.setAttribute( eventName, "return;" );
1365
- isSupported = ( typeof div[ eventName ] === "function" );
1366
- }
1367
- support[ i + "Bubbles" ] = isSupported;
1368
- }
1369
- }
1370
-
1371
- return support;
1372
- })();
1373
-
1374
- // Keep track of boxModel
1375
- jQuery.boxModel = jQuery.support.boxModel;
1376
-
1377
-
1378
-
1379
-
1380
- var rbrace = /^(?:\{.*\}|\[.*\])$/,
1381
- rmultiDash = /([a-z])([A-Z])/g;
1382
-
1383
- jQuery.extend({
1384
- cache: {},
1385
-
1386
- // Please use with caution
1387
- uuid: 0,
1388
-
1389
- // Unique for each copy of jQuery on the page
1390
- // Non-digits removed to match rinlinejQuery
1391
- expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ),
1392
-
1393
- // The following elements throw uncatchable exceptions if you
1394
- // attempt to add expando properties to them.
1395
- noData: {
1396
- "embed": true,
1397
- // Ban all objects except for Flash (which handle expandos)
1398
- "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
1399
- "applet": true
1400
- },
1401
-
1402
- hasData: function( elem ) {
1403
- elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
1404
-
1405
- return !!elem && !isEmptyDataObject( elem );
1406
- },
1407
-
1408
- data: function( elem, name, data, pvt /* Internal Use Only */ ) {
1409
- if ( !jQuery.acceptData( elem ) ) {
1410
- return;
1411
- }
1412
-
1413
- var internalKey = jQuery.expando, getByName = typeof name === "string", thisCache,
1414
-
1415
- // We have to handle DOM nodes and JS objects differently because IE6-7
1416
- // can't GC object references properly across the DOM-JS boundary
1417
- isNode = elem.nodeType,
1418
-
1419
- // Only DOM nodes need the global jQuery cache; JS object data is
1420
- // attached directly to the object so GC can occur automatically
1421
- cache = isNode ? jQuery.cache : elem,
1422
-
1423
- // Only defining an ID for JS objects if its cache already exists allows
1424
- // the code to shortcut on the same path as a DOM node with no cache
1425
- id = isNode ? elem[ jQuery.expando ] : elem[ jQuery.expando ] && jQuery.expando;
1426
-
1427
- // Avoid doing any more work than we need to when trying to get data on an
1428
- // object that has no data at all
1429
- if ( (!id || (pvt && id && !cache[ id ][ internalKey ])) && getByName && data === undefined ) {
1430
- return;
1431
- }
1432
-
1433
- if ( !id ) {
1434
- // Only DOM nodes need a new unique ID for each element since their data
1435
- // ends up in the global cache
1436
- if ( isNode ) {
1437
- elem[ jQuery.expando ] = id = ++jQuery.uuid;
1438
- } else {
1439
- id = jQuery.expando;
1440
- }
1441
- }
1442
-
1443
- if ( !cache[ id ] ) {
1444
- cache[ id ] = {};
1445
-
1446
- // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery
1447
- // metadata on plain JS objects when the object is serialized using
1448
- // JSON.stringify
1449
- if ( !isNode ) {
1450
- cache[ id ].toJSON = jQuery.noop;
1451
- }
1452
- }
1453
-
1454
- // An object can be passed to jQuery.data instead of a key/value pair; this gets
1455
- // shallow copied over onto the existing cache
1456
- if ( typeof name === "object" || typeof name === "function" ) {
1457
- if ( pvt ) {
1458
- cache[ id ][ internalKey ] = jQuery.extend(cache[ id ][ internalKey ], name);
1459
- } else {
1460
- cache[ id ] = jQuery.extend(cache[ id ], name);
1461
- }
1462
- }
1463
-
1464
- thisCache = cache[ id ];
1465
-
1466
- // Internal jQuery data is stored in a separate object inside the object's data
1467
- // cache in order to avoid key collisions between internal data and user-defined
1468
- // data
1469
- if ( pvt ) {
1470
- if ( !thisCache[ internalKey ] ) {
1471
- thisCache[ internalKey ] = {};
1472
- }
1473
-
1474
- thisCache = thisCache[ internalKey ];
1475
- }
1476
-
1477
- if ( data !== undefined ) {
1478
- thisCache[ name ] = data;
1479
- }
1480
-
1481
- // TODO: This is a hack for 1.5 ONLY. It will be removed in 1.6. Users should
1482
- // not attempt to inspect the internal events object using jQuery.data, as this
1483
- // internal data object is undocumented and subject to change.
1484
- if ( name === "events" && !thisCache[name] ) {
1485
- return thisCache[ internalKey ] && thisCache[ internalKey ].events;
1486
- }
1487
-
1488
- return getByName ? thisCache[ name ] : thisCache;
1489
- },
1490
-
1491
- removeData: function( elem, name, pvt /* Internal Use Only */ ) {
1492
- if ( !jQuery.acceptData( elem ) ) {
1493
- return;
1494
- }
1495
-
1496
- var internalKey = jQuery.expando, isNode = elem.nodeType,
1497
-
1498
- // See jQuery.data for more information
1499
- cache = isNode ? jQuery.cache : elem,
1500
-
1501
- // See jQuery.data for more information
1502
- id = isNode ? elem[ jQuery.expando ] : jQuery.expando;
1503
-
1504
- // If there is already no cache entry for this object, there is no
1505
- // purpose in continuing
1506
- if ( !cache[ id ] ) {
1507
- return;
1508
- }
1509
-
1510
- if ( name ) {
1511
- var thisCache = pvt ? cache[ id ][ internalKey ] : cache[ id ];
1512
-
1513
- if ( thisCache ) {
1514
- delete thisCache[ name ];
1515
-
1516
- // If there is no data left in the cache, we want to continue
1517
- // and let the cache object itself get destroyed
1518
- if ( !isEmptyDataObject(thisCache) ) {
1519
- return;
1520
- }
1521
- }
1522
- }
1523
-
1524
- // See jQuery.data for more information
1525
- if ( pvt ) {
1526
- delete cache[ id ][ internalKey ];
1527
-
1528
- // Don't destroy the parent cache unless the internal data object
1529
- // had been the only thing left in it
1530
- if ( !isEmptyDataObject(cache[ id ]) ) {
1531
- return;
1532
- }
1533
- }
1534
-
1535
- var internalCache = cache[ id ][ internalKey ];
1536
-
1537
- // Browsers that fail expando deletion also refuse to delete expandos on
1538
- // the window, but it will allow it on all other JS objects; other browsers
1539
- // don't care
1540
- if ( jQuery.support.deleteExpando || cache != window ) {
1541
- delete cache[ id ];
1542
- } else {
1543
- cache[ id ] = null;
1544
- }
1545
-
1546
- // We destroyed the entire user cache at once because it's faster than
1547
- // iterating through each key, but we need to continue to persist internal
1548
- // data if it existed
1549
- if ( internalCache ) {
1550
- cache[ id ] = {};
1551
- // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery
1552
- // metadata on plain JS objects when the object is serialized using
1553
- // JSON.stringify
1554
- if ( !isNode ) {
1555
- cache[ id ].toJSON = jQuery.noop;
1556
- }
1557
-
1558
- cache[ id ][ internalKey ] = internalCache;
1559
-
1560
- // Otherwise, we need to eliminate the expando on the node to avoid
1561
- // false lookups in the cache for entries that no longer exist
1562
- } else if ( isNode ) {
1563
- // IE does not allow us to delete expando properties from nodes,
1564
- // nor does it have a removeAttribute function on Document nodes;
1565
- // we must handle all of these cases
1566
- if ( jQuery.support.deleteExpando ) {
1567
- delete elem[ jQuery.expando ];
1568
- } else if ( elem.removeAttribute ) {
1569
- elem.removeAttribute( jQuery.expando );
1570
- } else {
1571
- elem[ jQuery.expando ] = null;
1572
- }
1573
- }
1574
- },
1575
-
1576
- // For internal use only.
1577
- _data: function( elem, name, data ) {
1578
- return jQuery.data( elem, name, data, true );
1579
- },
1580
-
1581
- // A method for determining if a DOM node can handle the data expando
1582
- acceptData: function( elem ) {
1583
- if ( elem.nodeName ) {
1584
- var match = jQuery.noData[ elem.nodeName.toLowerCase() ];
1585
-
1586
- if ( match ) {
1587
- return !(match === true || elem.getAttribute("classid") !== match);
1588
- }
1589
- }
1590
-
1591
- return true;
1592
- }
1593
- });
1594
-
1595
- jQuery.fn.extend({
1596
- data: function( key, value ) {
1597
- var data = null;
1598
-
1599
- if ( typeof key === "undefined" ) {
1600
- if ( this.length ) {
1601
- data = jQuery.data( this[0] );
1602
-
1603
- if ( this[0].nodeType === 1 ) {
1604
- var attr = this[0].attributes, name;
1605
- for ( var i = 0, l = attr.length; i < l; i++ ) {
1606
- name = attr[i].name;
1607
-
1608
- if ( name.indexOf( "data-" ) === 0 ) {
1609
- name = jQuery.camelCase( name.substring(5) );
1610
-
1611
- dataAttr( this[0], name, data[ name ] );
1612
- }
1613
- }
1614
- }
1615
- }
1616
-
1617
- return data;
1618
-
1619
- } else if ( typeof key === "object" ) {
1620
- return this.each(function() {
1621
- jQuery.data( this, key );
1622
- });
1623
- }
1624
-
1625
- var parts = key.split(".");
1626
- parts[1] = parts[1] ? "." + parts[1] : "";
1627
-
1628
- if ( value === undefined ) {
1629
- data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
1630
-
1631
- // Try to fetch any internally stored data first
1632
- if ( data === undefined && this.length ) {
1633
- data = jQuery.data( this[0], key );
1634
- data = dataAttr( this[0], key, data );
1635
- }
1636
-
1637
- return data === undefined && parts[1] ?
1638
- this.data( parts[0] ) :
1639
- data;
1640
-
1641
- } else {
1642
- return this.each(function() {
1643
- var $this = jQuery( this ),
1644
- args = [ parts[0], value ];
1645
-
1646
- $this.triggerHandler( "setData" + parts[1] + "!", args );
1647
- jQuery.data( this, key, value );
1648
- $this.triggerHandler( "changeData" + parts[1] + "!", args );
1649
- });
1650
- }
1651
- },
1652
-
1653
- removeData: function( key ) {
1654
- return this.each(function() {
1655
- jQuery.removeData( this, key );
1656
- });
1657
- }
1658
- });
1659
-
1660
- function dataAttr( elem, key, data ) {
1661
- // If nothing was found internally, try to fetch any
1662
- // data from the HTML5 data-* attribute
1663
- if ( data === undefined && elem.nodeType === 1 ) {
1664
- name = "data-" + key.replace( rmultiDash, "$1-$2" ).toLowerCase();
1665
-
1666
- data = elem.getAttribute( name );
1667
-
1668
- if ( typeof data === "string" ) {
1669
- try {
1670
- data = data === "true" ? true :
1671
- data === "false" ? false :
1672
- data === "null" ? null :
1673
- !jQuery.isNaN( data ) ? parseFloat( data ) :
1674
- rbrace.test( data ) ? jQuery.parseJSON( data ) :
1675
- data;
1676
- } catch( e ) {}
1677
-
1678
- // Make sure we set the data so it isn't changed later
1679
- jQuery.data( elem, key, data );
1680
-
1681
- } else {
1682
- data = undefined;
1683
- }
1684
- }
1685
-
1686
- return data;
1687
- }
1688
-
1689
- // TODO: This is a hack for 1.5 ONLY to allow objects with a single toJSON
1690
- // property to be considered empty objects; this property always exists in
1691
- // order to make sure JSON.stringify does not expose internal metadata
1692
- function isEmptyDataObject( obj ) {
1693
- for ( var name in obj ) {
1694
- if ( name !== "toJSON" ) {
1695
- return false;
1696
- }
1697
- }
1698
-
1699
- return true;
1700
- }
1701
-
1702
-
1703
-
1704
-
1705
- function handleQueueMarkDefer( elem, type, src ) {
1706
- var deferDataKey = type + "defer",
1707
- queueDataKey = type + "queue",
1708
- markDataKey = type + "mark",
1709
- defer = jQuery.data( elem, deferDataKey, undefined, true );
1710
- if ( defer &&
1711
- ( src === "queue" || !jQuery.data( elem, queueDataKey, undefined, true ) ) &&
1712
- ( src === "mark" || !jQuery.data( elem, markDataKey, undefined, true ) ) ) {
1713
- // Give room for hard-coded callbacks to fire first
1714
- // and eventually mark/queue something else on the element
1715
- setTimeout( function() {
1716
- if ( !jQuery.data( elem, queueDataKey, undefined, true ) &&
1717
- !jQuery.data( elem, markDataKey, undefined, true ) ) {
1718
- jQuery.removeData( elem, deferDataKey, true );
1719
- defer.resolve();
1720
- }
1721
- }, 0 );
1722
- }
1723
- }
1724
-
1725
- jQuery.extend({
1726
-
1727
- _mark: function( elem, type ) {
1728
- if ( elem ) {
1729
- type = (type || "fx") + "mark";
1730
- jQuery.data( elem, type, (jQuery.data(elem,type,undefined,true) || 0) + 1, true );
1731
- }
1732
- },
1733
-
1734
- _unmark: function( force, elem, type ) {
1735
- if ( force !== true ) {
1736
- type = elem;
1737
- elem = force;
1738
- force = false;
1739
- }
1740
- if ( elem ) {
1741
- type = type || "fx";
1742
- var key = type + "mark",
1743
- count = force ? 0 : ( (jQuery.data( elem, key, undefined, true) || 1 ) - 1 );
1744
- if ( count ) {
1745
- jQuery.data( elem, key, count, true );
1746
- } else {
1747
- jQuery.removeData( elem, key, true );
1748
- handleQueueMarkDefer( elem, type, "mark" );
1749
- }
1750
- }
1751
- },
1752
-
1753
- queue: function( elem, type, data ) {
1754
- if ( elem ) {
1755
- type = (type || "fx") + "queue";
1756
- var q = jQuery.data( elem, type, undefined, true );
1757
- // Speed up dequeue by getting out quickly if this is just a lookup
1758
- if ( data ) {
1759
- if ( !q || jQuery.isArray(data) ) {
1760
- q = jQuery.data( elem, type, jQuery.makeArray(data), true );
1761
- } else {
1762
- q.push( data );
1763
- }
1764
- }
1765
- return q || [];
1766
- }
1767
- },
1768
-
1769
- dequeue: function( elem, type ) {
1770
- type = type || "fx";
1771
-
1772
- var queue = jQuery.queue( elem, type ),
1773
- fn = queue.shift(),
1774
- defer;
1775
-
1776
- // If the fx queue is dequeued, always remove the progress sentinel
1777
- if ( fn === "inprogress" ) {
1778
- fn = queue.shift();
1779
- }
1780
-
1781
- if ( fn ) {
1782
- // Add a progress sentinel to prevent the fx queue from being
1783
- // automatically dequeued
1784
- if ( type === "fx" ) {
1785
- queue.unshift("inprogress");
1786
- }
1787
-
1788
- fn.call(elem, function() {
1789
- jQuery.dequeue(elem, type);
1790
- });
1791
- }
1792
-
1793
- if ( !queue.length ) {
1794
- jQuery.removeData( elem, type + "queue", true );
1795
- handleQueueMarkDefer( elem, type, "queue" );
1796
- }
1797
- }
1798
- });
1799
-
1800
- jQuery.fn.extend({
1801
- queue: function( type, data ) {
1802
- if ( typeof type !== "string" ) {
1803
- data = type;
1804
- type = "fx";
1805
- }
1806
-
1807
- if ( data === undefined ) {
1808
- return jQuery.queue( this[0], type );
1809
- }
1810
- return this.each(function() {
1811
- var queue = jQuery.queue( this, type, data );
1812
-
1813
- if ( type === "fx" && queue[0] !== "inprogress" ) {
1814
- jQuery.dequeue( this, type );
1815
- }
1816
- });
1817
- },
1818
- dequeue: function( type ) {
1819
- return this.each(function() {
1820
- jQuery.dequeue( this, type );
1821
- });
1822
- },
1823
- // Based off of the plugin by Clint Helfers, with permission.
1824
- // http://blindsignals.com/index.php/2009/07/jquery-delay/
1825
- delay: function( time, type ) {
1826
- time = jQuery.fx ? jQuery.fx.speeds[time] || time : time;
1827
- type = type || "fx";
1828
-
1829
- return this.queue( type, function() {
1830
- var elem = this;
1831
- setTimeout(function() {
1832
- jQuery.dequeue( elem, type );
1833
- }, time );
1834
- });
1835
- },
1836
- clearQueue: function( type ) {
1837
- return this.queue( type || "fx", [] );
1838
- },
1839
- // Get a promise resolved when queues of a certain type
1840
- // are emptied (fx is the type by default)
1841
- promise: function( type, object ) {
1842
- if ( typeof type !== "string" ) {
1843
- object = type;
1844
- type = undefined;
1845
- }
1846
- type = type || "fx";
1847
- var defer = jQuery.Deferred(),
1848
- elements = this,
1849
- i = elements.length,
1850
- count = 1,
1851
- deferDataKey = type + "defer",
1852
- queueDataKey = type + "queue",
1853
- markDataKey = type + "mark";
1854
- function resolve() {
1855
- if ( !( --count ) ) {
1856
- defer.resolveWith( elements, [ elements ] );
1857
- }
1858
- }
1859
- while( i-- ) {
1860
- if (( tmp = jQuery.data( elements[ i ], deferDataKey, undefined, true ) ||
1861
- ( jQuery.data( elements[ i ], queueDataKey, undefined, true ) ||
1862
- jQuery.data( elements[ i ], markDataKey, undefined, true ) ) &&
1863
- jQuery.data( elements[ i ], deferDataKey, jQuery._Deferred(), true ) )) {
1864
- count++;
1865
- tmp.done( resolve );
1866
- }
1867
- }
1868
- resolve();
1869
- return defer.promise();
1870
- }
1871
- });
1872
-
1873
-
1874
-
1875
-
1876
- var rclass = /[\n\t\r]/g,
1877
- rspace = /\s+/,
1878
- rreturn = /\r/g,
1879
- rtype = /^(?:button|input)$/i,
1880
- rfocusable = /^(?:button|input|object|select|textarea)$/i,
1881
- rclickable = /^a(?:rea)?$/i,
1882
- rspecial = /^(?:data-|aria-)/,
1883
- rinvalidChar = /\:/,
1884
- formHook;
1885
-
1886
- jQuery.fn.extend({
1887
- attr: function( name, value ) {
1888
- return jQuery.access( this, name, value, true, jQuery.attr );
1889
- },
1890
-
1891
- removeAttr: function( name ) {
1892
- return this.each(function() {
1893
- jQuery.removeAttr( this, name );
1894
- });
1895
- },
1896
-
1897
- prop: function( name, value ) {
1898
- return jQuery.access( this, name, value, true, jQuery.prop );
1899
- },
1900
-
1901
- removeProp: function( name ) {
1902
- return this.each(function() {
1903
- // try/catch handles cases where IE balks (such as removing a property on window)
1904
- try {
1905
- this[ name ] = undefined;
1906
- delete this[ name ];
1907
- } catch( e ) {}
1908
- });
1909
- },
1910
-
1911
- addClass: function( value ) {
1912
- if ( jQuery.isFunction( value ) ) {
1913
- return this.each(function(i) {
1914
- var self = jQuery(this);
1915
- self.addClass( value.call(this, i, self.attr("class") || "") );
1916
- });
1917
- }
1918
-
1919
- if ( value && typeof value === "string" ) {
1920
- var classNames = (value || "").split( rspace );
1921
-
1922
- for ( var i = 0, l = this.length; i < l; i++ ) {
1923
- var elem = this[i];
1924
-
1925
- if ( elem.nodeType === 1 ) {
1926
- if ( !elem.className ) {
1927
- elem.className = value;
1928
-
1929
- } else {
1930
- var className = " " + elem.className + " ",
1931
- setClass = elem.className;
1932
-
1933
- for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
1934
- if ( className.indexOf( " " + classNames[c] + " " ) < 0 ) {
1935
- setClass += " " + classNames[c];
1936
- }
1937
- }
1938
- elem.className = jQuery.trim( setClass );
1939
- }
1940
- }
1941
- }
1942
- }
1943
-
1944
- return this;
1945
- },
1946
-
1947
- removeClass: function( value ) {
1948
- if ( jQuery.isFunction(value) ) {
1949
- return this.each(function(i) {
1950
- var self = jQuery(this);
1951
- self.removeClass( value.call(this, i, self.attr("class")) );
1952
- });
1953
- }
1954
-
1955
- if ( (value && typeof value === "string") || value === undefined ) {
1956
- var classNames = (value || "").split( rspace );
1957
-
1958
- for ( var i = 0, l = this.length; i < l; i++ ) {
1959
- var elem = this[i];
1960
-
1961
- if ( elem.nodeType === 1 && elem.className ) {
1962
- if ( value ) {
1963
- var className = (" " + elem.className + " ").replace(rclass, " ");
1964
- for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
1965
- className = className.replace(" " + classNames[c] + " ", " ");
1966
- }
1967
- elem.className = jQuery.trim( className );
1968
-
1969
- } else {
1970
- elem.className = "";
1971
- }
1972
- }
1973
- }
1974
- }
1975
-
1976
- return this;
1977
- },
1978
-
1979
- toggleClass: function( value, stateVal ) {
1980
- var type = typeof value,
1981
- isBool = typeof stateVal === "boolean";
1982
-
1983
- if ( jQuery.isFunction( value ) ) {
1984
- return this.each(function(i) {
1985
- var self = jQuery(this);
1986
- self.toggleClass( value.call(this, i, self.attr("class"), stateVal), stateVal );
1987
- });
1988
- }
1989
-
1990
- return this.each(function() {
1991
- if ( type === "string" ) {
1992
- // toggle individual class names
1993
- var className,
1994
- i = 0,
1995
- self = jQuery( this ),
1996
- state = stateVal,
1997
- classNames = value.split( rspace );
1998
-
1999
- while ( (className = classNames[ i++ ]) ) {
2000
- // check each className given, space seperated list
2001
- state = isBool ? state : !self.hasClass( className );
2002
- self[ state ? "addClass" : "removeClass" ]( className );
2003
- }
2004
-
2005
- } else if ( type === "undefined" || type === "boolean" ) {
2006
- if ( this.className ) {
2007
- // store className if set
2008
- jQuery._data( this, "__className__", this.className );
2009
- }
2010
-
2011
- // toggle whole className
2012
- this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || "";
2013
- }
2014
- });
2015
- },
2016
-
2017
- hasClass: function( selector ) {
2018
- var className = " " + selector + " ";
2019
- for ( var i = 0, l = this.length; i < l; i++ ) {
2020
- if ( (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) {
2021
- return true;
2022
- }
2023
- }
2024
-
2025
- return false;
2026
- },
2027
-
2028
- val: function( value ) {
2029
- var hooks, ret,
2030
- elem = this[0];
2031
-
2032
- if ( !arguments.length ) {
2033
- if ( elem ) {
2034
- hooks = jQuery.valHooks[ elem.nodeName.toLowerCase() ] || jQuery.valHooks[ elem.type ];
2035
-
2036
- if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
2037
- return ret;
2038
- }
2039
-
2040
- return (elem.value || "").replace(rreturn, "");
2041
- }
2042
-
2043
- return undefined;
2044
- }
2045
-
2046
- var isFunction = jQuery.isFunction( value );
2047
-
2048
- return this.each(function( i ) {
2049
- var self = jQuery(this), val;
2050
-
2051
- if ( this.nodeType !== 1 ) {
2052
- return;
2053
- }
2054
-
2055
- if ( isFunction ) {
2056
- val = value.call( this, i, self.val() );
2057
- } else {
2058
- val = value;
2059
- }
2060
-
2061
- // Treat null/undefined as ""; convert numbers to string
2062
- if ( val == null ) {
2063
- val = "";
2064
- } else if ( typeof val === "number" ) {
2065
- val += "";
2066
- } else if ( jQuery.isArray( val ) ) {
2067
- val = jQuery.map(val, function ( value ) {
2068
- return value == null ? "" : value + "";
2069
- });
2070
- }
2071
-
2072
- hooks = jQuery.valHooks[ this.nodeName.toLowerCase() ] || jQuery.valHooks[ this.type ];
2073
-
2074
- // If set returns undefined, fall back to normal setting
2075
- if ( !hooks || ("set" in hooks && hooks.set( this, val, "value" ) === undefined) ) {
2076
- this.value = val;
2077
- }
2078
- });
2079
- }
2080
- });
2081
-
2082
- jQuery.extend({
2083
- valHooks: {
2084
- option: {
2085
- get: function( elem ) {
2086
- // attributes.value is undefined in Blackberry 4.7 but
2087
- // uses .value. See #6932
2088
- var val = elem.attributes.value;
2089
- return !val || val.specified ? elem.value : elem.text;
2090
- }
2091
- },
2092
- select: {
2093
- get: function( elem ) {
2094
- var index = elem.selectedIndex,
2095
- values = [],
2096
- options = elem.options,
2097
- one = elem.type === "select-one";
2098
-
2099
- // Nothing was selected
2100
- if ( index < 0 ) {
2101
- return null;
2102
- }
2103
-
2104
- // Loop through all the selected options
2105
- for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) {
2106
- var option = options[ i ];
2107
-
2108
- // Don't return options that are disabled or in a disabled optgroup
2109
- if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) &&
2110
- (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) {
2111
-
2112
- // Get the specific value for the option
2113
- value = jQuery( option ).val();
2114
-
2115
- // We don't need an array for one selects
2116
- if ( one ) {
2117
- return value;
2118
- }
2119
-
2120
- // Multi-Selects return an array
2121
- values.push( value );
2122
- }
2123
- }
2124
-
2125
- // Fixes Bug #2551 -- select.val() broken in IE after form.reset()
2126
- if ( one && !values.length && options.length ) {
2127
- return jQuery( options[ index ] ).val();
2128
- }
2129
-
2130
- return values;
2131
- },
2132
-
2133
- set: function( elem, value ) {
2134
- var values = jQuery.makeArray( value );
2135
-
2136
- jQuery(elem).find("option").each(function() {
2137
- this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
2138
- });
2139
-
2140
- if ( !values.length ) {
2141
- elem.selectedIndex = -1;
2142
- }
2143
- return values;
2144
- }
2145
- }
2146
- },
2147
-
2148
- attrFn: {
2149
- val: true,
2150
- css: true,
2151
- html: true,
2152
- text: true,
2153
- data: true,
2154
- width: true,
2155
- height: true,
2156
- offset: true
2157
- },
2158
-
2159
- attrFix: {
2160
- // Always normalize to ensure hook usage
2161
- tabindex: "tabIndex",
2162
- readonly: "readOnly"
2163
- },
2164
-
2165
- attr: function( elem, name, value, pass ) {
2166
- var nType = elem.nodeType;
2167
-
2168
- // don't get/set attributes on text, comment and attribute nodes
2169
- if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
2170
- return undefined;
2171
- }