Index: trunk/phase3/tests/jasmine/lib/appendto-jquery-mockjax/jquery.mockjax.js |
— | — | @@ -0,0 +1,326 @@ |
| 2 | +/*! |
| 3 | + * MockJax - jQuery Plugin to Mock Ajax requests |
| 4 | + * |
| 5 | + * Version: 1.3.3 |
| 6 | + * Released: 2010-11-05 |
| 7 | + * Source: http://github.com/appendto/jquery-mockjax |
| 8 | + * Docs: http://enterprisejquery.com/2010/07/mock-your-ajax-requests-with-mockjax-for-rapid-development |
| 9 | + * Plugin: mockjax |
| 10 | + * Author: Jonathan Sharp (http://jdsharp.com) |
| 11 | + * License: MIT,GPL |
| 12 | + * |
| 13 | + * Copyright (c) 2010 appendTo LLC. |
| 14 | + * Dual licensed under the MIT or GPL licenses. |
| 15 | + * http://appendto.com/open-source-licenses |
| 16 | + */ |
| 17 | +(function($) { |
| 18 | + var _ajax = $.ajax, |
| 19 | + mockHandlers = []; |
| 20 | + |
| 21 | + $.extend({ |
| 22 | + ajax: function(origSettings) { |
| 23 | + var s = jQuery.extend(true, {}, jQuery.ajaxSettings, origSettings), |
| 24 | + mock = false; |
| 25 | + // Iterate over our mock handlers (in registration order) until we find |
| 26 | + // one that is willing to intercept the request |
| 27 | + $.each(mockHandlers, function(k, v) { |
| 28 | + if ( !mockHandlers[k] ) { |
| 29 | + return; |
| 30 | + } |
| 31 | + var m = null; |
| 32 | + // If the mock was registered with a function, let the function decide if we |
| 33 | + // want to mock this request |
| 34 | + if ( $.isFunction(mockHandlers[k]) ) { |
| 35 | + m = mockHandlers[k](s); |
| 36 | + } else { |
| 37 | + m = mockHandlers[k]; |
| 38 | + // Inspect the URL of the request and check if the mock handler's url |
| 39 | + // matches the url for this ajax request |
| 40 | + if ( $.isFunction(m.url.test) ) { |
| 41 | + // The user provided a regex for the url, test it |
| 42 | + if ( !m.url.test( s.url ) ) { |
| 43 | + m = null; |
| 44 | + } |
| 45 | + } else { |
| 46 | + // Look for a simple wildcard '*' or a direct URL match |
| 47 | + var star = m.url.indexOf('*'); |
| 48 | + if ( ( m.url != '*' && m.url != s.url && star == -1 ) || |
| 49 | + ( star > -1 && m.url.substr(0, star) != s.url.substr(0, star) ) ) { |
| 50 | + // The url we tested did not match the wildcard * |
| 51 | + m = null; |
| 52 | + } |
| 53 | + } |
| 54 | + if ( m ) { |
| 55 | + // Inspect the data submitted in the request (either POST body or GET query string) |
| 56 | + if ( m.data && s.data ) { |
| 57 | + var identical = false; |
| 58 | + // Deep inspect the identity of the objects |
| 59 | + (function ident(mock, live) { |
| 60 | + // Test for situations where the data is a querystring (not an object) |
| 61 | + if (typeof live === 'string') { |
| 62 | + // Querystring may be a regex |
| 63 | + identical = $.isFunction( mock.test ) ? mock.test(live) : mock == live; |
| 64 | + return identical; |
| 65 | + } |
| 66 | + $.each(mock, function(k, v) { |
| 67 | + if ( live[k] === undefined ) { |
| 68 | + identical = false; |
| 69 | + return false; |
| 70 | + } else { |
| 71 | + identical = true; |
| 72 | + if ( typeof live[k] == 'object' ) { |
| 73 | + return ident(mock[k], live[k]); |
| 74 | + } else { |
| 75 | + if ( $.isFunction( mock[k].test ) ) { |
| 76 | + identical = mock[k].test(live[k]); |
| 77 | + } else { |
| 78 | + identical = ( mock[k] == live[k] ); |
| 79 | + } |
| 80 | + return identical; |
| 81 | + } |
| 82 | + } |
| 83 | + }); |
| 84 | + })(m.data, s.data); |
| 85 | + // They're not identical, do not mock this request |
| 86 | + if ( identical == false ) { |
| 87 | + m = null; |
| 88 | + } |
| 89 | + } |
| 90 | + // Inspect the request type |
| 91 | + if ( m && m.type && m.type != s.type ) { |
| 92 | + // The request type doesn't match (GET vs. POST) |
| 93 | + m = null; |
| 94 | + } |
| 95 | + } |
| 96 | + } |
| 97 | + if ( m ) { |
| 98 | + if ( typeof console !== 'undefined' && console.log ) { |
| 99 | + console.log('MOCK ' + s.type + ': ' + s.url); |
| 100 | + } |
| 101 | + mock = true; |
| 102 | + |
| 103 | + // Handle JSONP Parameter Callbacks, we need to replicate some of the jQuery core here |
| 104 | + // because there isn't an easy hook for the cross domain script tag of jsonp |
| 105 | + if ( s.dataType === "jsonp" ) { |
| 106 | + if ( s.type.toUpperCase() === "GET" ) { |
| 107 | + if ( !jsre.test( s.url ) ) { |
| 108 | + s.url += (rquery.test( s.url ) ? "&" : "?") + (s.jsonp || "callback") + "=?"; |
| 109 | + } |
| 110 | + } else if ( !s.data || !jsre.test(s.data) ) { |
| 111 | + s.data = (s.data ? s.data + "&" : "") + (s.jsonp || "callback") + "=?"; |
| 112 | + } |
| 113 | + s.dataType = "json"; |
| 114 | + } |
| 115 | + |
| 116 | + // Build temporary JSONP function |
| 117 | + var jsre = /=\?(&|$)/; |
| 118 | + if ( s.dataType === "json" && (s.data && jsre.test(s.data) || jsre.test(s.url)) ) { |
| 119 | + jsonp = s.jsonpCallback || ("jsonp" + jsc++); |
| 120 | + |
| 121 | + // Replace the =? sequence both in the query string and the data |
| 122 | + if ( s.data ) { |
| 123 | + s.data = (s.data + "").replace(jsre, "=" + jsonp + "$1"); |
| 124 | + } |
| 125 | + |
| 126 | + s.url = s.url.replace(jsre, "=" + jsonp + "$1"); |
| 127 | + |
| 128 | + // We need to make sure |
| 129 | + // that a JSONP style response is executed properly |
| 130 | + s.dataType = "script"; |
| 131 | + |
| 132 | + // Handle JSONP-style loading |
| 133 | + window[ jsonp ] = window[ jsonp ] || function( tmp ) { |
| 134 | + data = tmp; |
| 135 | + success(); |
| 136 | + complete(); |
| 137 | + // Garbage collect |
| 138 | + window[ jsonp ] = undefined; |
| 139 | + |
| 140 | + try { |
| 141 | + delete window[ jsonp ]; |
| 142 | + } catch(e) {} |
| 143 | + |
| 144 | + if ( head ) { |
| 145 | + head.removeChild( script ); |
| 146 | + } |
| 147 | + }; |
| 148 | + } |
| 149 | + |
| 150 | + var rurl = /^(\w+:)?\/\/([^\/?#]+)/, |
| 151 | + parts = rurl.exec( s.url ), |
| 152 | + remote = parts && (parts[1] && parts[1] !== location.protocol || parts[2] !== location.host); |
| 153 | + |
| 154 | + // Test if we are going to create a script tag (if so, intercept & mock) |
| 155 | + if ( s.dataType === "script" && s.type.toUpperCase() === "GET" && remote ) { |
| 156 | + // Synthesize the mock request for adding a script tag |
| 157 | + var callbackContext = origSettings && origSettings.context || s; |
| 158 | + |
| 159 | + function success() { |
| 160 | + // If a local callback was specified, fire it and pass it the data |
| 161 | + if ( s.success ) { |
| 162 | + s.success.call( callbackContext, ( m.response ? m.response.toString() : m.responseText || ''), status, {} ); |
| 163 | + } |
| 164 | + |
| 165 | + // Fire the global callback |
| 166 | + if ( s.global ) { |
| 167 | + trigger( "ajaxSuccess", [{}, s] ); |
| 168 | + } |
| 169 | + } |
| 170 | + |
| 171 | + function complete() { |
| 172 | + // Process result |
| 173 | + if ( s.complete ) { |
| 174 | + s.complete.call( callbackContext, {} , status ); |
| 175 | + } |
| 176 | + |
| 177 | + // The request was completed |
| 178 | + if ( s.global ) { |
| 179 | + trigger( "ajaxComplete", [{}, s] ); |
| 180 | + } |
| 181 | + |
| 182 | + // Handle the global AJAX counter |
| 183 | + if ( s.global && ! --jQuery.active ) { |
| 184 | + jQuery.event.trigger( "ajaxStop" ); |
| 185 | + } |
| 186 | + } |
| 187 | + |
| 188 | + function trigger(type, args) { |
| 189 | + (s.context ? jQuery(s.context) : jQuery.event).trigger(type, args); |
| 190 | + } |
| 191 | + |
| 192 | + if ( m.response && $.isFunction(m.response) ) { |
| 193 | + m.response(origSettings); |
| 194 | + } else { |
| 195 | + $.globalEval(m.responseText); |
| 196 | + } |
| 197 | + success(); |
| 198 | + complete(); |
| 199 | + return false; |
| 200 | + } |
| 201 | + mock = _ajax.call($, $.extend(true, {}, origSettings, { |
| 202 | + // Mock the XHR object |
| 203 | + xhr: function() { |
| 204 | + // Extend with our default mockjax settings |
| 205 | + m = $.extend({}, $.mockjaxSettings, m); |
| 206 | + // Return our mock xhr object |
| 207 | + return { |
| 208 | + status: m.status, |
| 209 | + readyState: 1, |
| 210 | + open: function() { }, |
| 211 | + send: function() { |
| 212 | + var process = $.proxy(function() { |
| 213 | + // The request has returned |
| 214 | + this.status = m.status; |
| 215 | + this.readyState = 4; |
| 216 | + |
| 217 | + // We have an executable function, call it to give |
| 218 | + // the mock a chance to update it's data |
| 219 | + if ( $.isFunction(m.response) ) { |
| 220 | + m.response(origSettings); |
| 221 | + } |
| 222 | + // Copy over our mock to our xhr object before passing control back to |
| 223 | + // jQuery's onreadystatechange callback |
| 224 | + if ( s.dataType == 'json' && ( typeof m.responseText == 'object' ) ) { |
| 225 | + this.responseText = JSON.stringify(m.responseText); |
| 226 | + } else if ( s.dataType == 'xml' ) { |
| 227 | + if ( $.xmlDOM && typeof m.responseXML == 'string' ) { |
| 228 | + // Parse the XML from a string into a DOM |
| 229 | + this.responseXML = $.xmlDOM( m.responseXML )[0]; |
| 230 | + } else { |
| 231 | + this.responseXML = m.responseXML; |
| 232 | + } |
| 233 | + } else { |
| 234 | + this.responseText = m.responseText; |
| 235 | + } |
| 236 | + this.onreadystatechange( m.isTimeout ? 'timeout' : undefined ); |
| 237 | + }, this); |
| 238 | + |
| 239 | + if ( m.proxy ) { |
| 240 | + // We're proxying this request and loading in an external file instead |
| 241 | + _ajax({ |
| 242 | + global: false, |
| 243 | + url: m.proxy, |
| 244 | + type: m.type, |
| 245 | + data: m.data, |
| 246 | + dataType: s.dataType, |
| 247 | + complete: function(xhr, txt) { |
| 248 | + m.responseXML = xhr.responseXML; |
| 249 | + m.responseText = xhr.responseText; |
| 250 | + this.responseTimer = setTimeout(process, m.responseTime || 0); |
| 251 | + } |
| 252 | + }); |
| 253 | + } else { |
| 254 | + // type == 'POST' || 'GET' || 'DELETE' |
| 255 | + if ( s.async === false ) { |
| 256 | + // TODO: Blocking delay |
| 257 | + process(); |
| 258 | + } else { |
| 259 | + this.responseTimer = setTimeout(process, m.responseTime || 50); |
| 260 | + } |
| 261 | + } |
| 262 | + }, |
| 263 | + abort: function() { |
| 264 | + clearTimeout(this.responseTimer); |
| 265 | + }, |
| 266 | + setRequestHeader: function() { }, |
| 267 | + getResponseHeader: function(header) { |
| 268 | + // 'Last-modified', 'Etag', 'content-type' are all checked by jQuery |
| 269 | + if ( m.headers && m.headers[header] ) { |
| 270 | + // Return arbitrary headers |
| 271 | + return m.headers[header]; |
| 272 | + } else if ( header == 'Last-modified' ) { |
| 273 | + return m.lastModified || (new Date()).toString(); |
| 274 | + } else if ( header == 'Etag' ) { |
| 275 | + return m.etag || ''; |
| 276 | + } else if ( header == 'content-type' ) { |
| 277 | + return m.contentType || 'text/plain'; |
| 278 | + } |
| 279 | + } |
| 280 | + }; |
| 281 | + } |
| 282 | + })); |
| 283 | + return false; |
| 284 | + } |
| 285 | + }); |
| 286 | + // We don't have a mock request, trigger a normal request |
| 287 | + if ( !mock ) { |
| 288 | + return _ajax.apply($, arguments); |
| 289 | + } else { |
| 290 | + return mock; |
| 291 | + } |
| 292 | + } |
| 293 | + }); |
| 294 | + |
| 295 | + $.mockjaxSettings = { |
| 296 | + //url: null, |
| 297 | + //type: 'GET', |
| 298 | + status: 200, |
| 299 | + responseTime: 500, |
| 300 | + isTimeout: false, |
| 301 | + contentType: 'text/plain', |
| 302 | + response: '', |
| 303 | + responseText: '', |
| 304 | + responseXML: '', |
| 305 | + proxy: '', |
| 306 | + |
| 307 | + lastModified: null, |
| 308 | + etag: '', |
| 309 | + headers: { |
| 310 | + etag: 'IJF@H#@923uf8023hFO@I#H#', |
| 311 | + 'content-type' : 'text/plain' |
| 312 | + } |
| 313 | + }; |
| 314 | + |
| 315 | + $.mockjax = function(settings) { |
| 316 | + var i = mockHandlers.length; |
| 317 | + mockHandlers[i] = settings; |
| 318 | + return i; |
| 319 | + }; |
| 320 | + $.mockjaxClear = function(i) { |
| 321 | + if ( arguments.length == 1 ) { |
| 322 | + mockHandlers[i] = null; |
| 323 | + } else { |
| 324 | + mockHandlers = []; |
| 325 | + } |
| 326 | + }; |
| 327 | +})(jQuery); |
Property changes on: trunk/phase3/tests/jasmine/lib/appendto-jquery-mockjax/jquery.mockjax.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 328 | + native |
Index: trunk/phase3/tests/jasmine/lib/appendto-jquery-mockjax/lib/json2.js |
— | — | @@ -0,0 +1,483 @@ |
| 2 | +/* |
| 3 | + http://www.JSON.org/json2.js |
| 4 | + 2010-03-20 |
| 5 | + |
| 6 | + Public Domain. |
| 7 | + |
| 8 | + NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. |
| 9 | + |
| 10 | + See http://www.JSON.org/js.html |
| 11 | + |
| 12 | + |
| 13 | + This code should be minified before deployment. |
| 14 | + See http://javascript.crockford.com/jsmin.html |
| 15 | + |
| 16 | + USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO |
| 17 | + NOT CONTROL. |
| 18 | + |
| 19 | + |
| 20 | + This file creates a global JSON object containing two methods: stringify |
| 21 | + and parse. |
| 22 | + |
| 23 | + JSON.stringify(value, replacer, space) |
| 24 | + value any JavaScript value, usually an object or array. |
| 25 | + |
| 26 | + replacer an optional parameter that determines how object |
| 27 | + values are stringified for objects. It can be a |
| 28 | + function or an array of strings. |
| 29 | + |
| 30 | + space an optional parameter that specifies the indentation |
| 31 | + of nested structures. If it is omitted, the text will |
| 32 | + be packed without extra whitespace. If it is a number, |
| 33 | + it will specify the number of spaces to indent at each |
| 34 | + level. If it is a string (such as '\t' or ' '), |
| 35 | + it contains the characters used to indent at each level. |
| 36 | + |
| 37 | + This method produces a JSON text from a JavaScript value. |
| 38 | + |
| 39 | + When an object value is found, if the object contains a toJSON |
| 40 | + method, its toJSON method will be called and the result will be |
| 41 | + stringified. A toJSON method does not serialize: it returns the |
| 42 | + value represented by the name/value pair that should be serialized, |
| 43 | + or undefined if nothing should be serialized. The toJSON method |
| 44 | + will be passed the key associated with the value, and this will be |
| 45 | + bound to the value |
| 46 | + |
| 47 | + For example, this would serialize Dates as ISO strings. |
| 48 | + |
| 49 | + Date.prototype.toJSON = function (key) { |
| 50 | + function f(n) { |
| 51 | + // Format integers to have at least two digits. |
| 52 | + return n < 10 ? '0' + n : n; |
| 53 | + } |
| 54 | + |
| 55 | + return this.getUTCFullYear() + '-' + |
| 56 | + f(this.getUTCMonth() + 1) + '-' + |
| 57 | + f(this.getUTCDate()) + 'T' + |
| 58 | + f(this.getUTCHours()) + ':' + |
| 59 | + f(this.getUTCMinutes()) + ':' + |
| 60 | + f(this.getUTCSeconds()) + 'Z'; |
| 61 | + }; |
| 62 | + |
| 63 | + You can provide an optional replacer method. It will be passed the |
| 64 | + key and value of each member, with this bound to the containing |
| 65 | + object. The value that is returned from your method will be |
| 66 | + serialized. If your method returns undefined, then the member will |
| 67 | + be excluded from the serialization. |
| 68 | + |
| 69 | + If the replacer parameter is an array of strings, then it will be |
| 70 | + used to select the members to be serialized. It filters the results |
| 71 | + such that only members with keys listed in the replacer array are |
| 72 | + stringified. |
| 73 | + |
| 74 | + Values that do not have JSON representations, such as undefined or |
| 75 | + functions, will not be serialized. Such values in objects will be |
| 76 | + dropped; in arrays they will be replaced with null. You can use |
| 77 | + a replacer function to replace those with JSON values. |
| 78 | + JSON.stringify(undefined) returns undefined. |
| 79 | + |
| 80 | + The optional space parameter produces a stringification of the |
| 81 | + value that is filled with line breaks and indentation to make it |
| 82 | + easier to read. |
| 83 | + |
| 84 | + If the space parameter is a non-empty string, then that string will |
| 85 | + be used for indentation. If the space parameter is a number, then |
| 86 | + the indentation will be that many spaces. |
| 87 | + |
| 88 | + Example: |
| 89 | + |
| 90 | + text = JSON.stringify(['e', {pluribus: 'unum'}]); |
| 91 | + // text is '["e",{"pluribus":"unum"}]' |
| 92 | + |
| 93 | + |
| 94 | + text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t'); |
| 95 | + // text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]' |
| 96 | + |
| 97 | + text = JSON.stringify([new Date()], function (key, value) { |
| 98 | + return this[key] instanceof Date ? |
| 99 | + 'Date(' + this[key] + ')' : value; |
| 100 | + }); |
| 101 | + // text is '["Date(---current time---)"]' |
| 102 | + |
| 103 | + |
| 104 | + JSON.parse(text, reviver) |
| 105 | + This method parses a JSON text to produce an object or array. |
| 106 | + It can throw a SyntaxError exception. |
| 107 | + |
| 108 | + The optional reviver parameter is a function that can filter and |
| 109 | + transform the results. It receives each of the keys and values, |
| 110 | + and its return value is used instead of the original value. |
| 111 | + If it returns what it received, then the structure is not modified. |
| 112 | + If it returns undefined then the member is deleted. |
| 113 | + |
| 114 | + Example: |
| 115 | + |
| 116 | + // Parse the text. Values that look like ISO date strings will |
| 117 | + // be converted to Date objects. |
| 118 | + |
| 119 | + myData = JSON.parse(text, function (key, value) { |
| 120 | + var a; |
| 121 | + if (typeof value === 'string') { |
| 122 | + a = |
| 123 | +/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value); |
| 124 | + if (a) { |
| 125 | + return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4], |
| 126 | + +a[5], +a[6])); |
| 127 | + } |
| 128 | + } |
| 129 | + return value; |
| 130 | + }); |
| 131 | + |
| 132 | + myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) { |
| 133 | + var d; |
| 134 | + if (typeof value === 'string' && |
| 135 | + value.slice(0, 5) === 'Date(' && |
| 136 | + value.slice(-1) === ')') { |
| 137 | + d = new Date(value.slice(5, -1)); |
| 138 | + if (d) { |
| 139 | + return d; |
| 140 | + } |
| 141 | + } |
| 142 | + return value; |
| 143 | + }); |
| 144 | + |
| 145 | + |
| 146 | + This is a reference implementation. You are free to copy, modify, or |
| 147 | + redistribute. |
| 148 | +*/ |
| 149 | + |
| 150 | +/*jslint evil: true, strict: false */ |
| 151 | + |
| 152 | +/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply, |
| 153 | + call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours, |
| 154 | + getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join, |
| 155 | + lastIndex, length, parse, prototype, push, replace, slice, stringify, |
| 156 | + test, toJSON, toString, valueOf |
| 157 | +*/ |
| 158 | + |
| 159 | + |
| 160 | +// Create a JSON object only if one does not already exist. We create the |
| 161 | +// methods in a closure to avoid creating global variables. |
| 162 | + |
| 163 | +if (!this.JSON) { |
| 164 | + this.JSON = {}; |
| 165 | +} |
| 166 | + |
| 167 | +(function () { |
| 168 | + |
| 169 | + function f(n) { |
| 170 | + // Format integers to have at least two digits. |
| 171 | + return n < 10 ? '0' + n : n; |
| 172 | + } |
| 173 | + |
| 174 | + if (typeof Date.prototype.toJSON !== 'function') { |
| 175 | + |
| 176 | + Date.prototype.toJSON = function (key) { |
| 177 | + |
| 178 | + return isFinite(this.valueOf()) ? |
| 179 | + this.getUTCFullYear() + '-' + |
| 180 | + f(this.getUTCMonth() + 1) + '-' + |
| 181 | + f(this.getUTCDate()) + 'T' + |
| 182 | + f(this.getUTCHours()) + ':' + |
| 183 | + f(this.getUTCMinutes()) + ':' + |
| 184 | + f(this.getUTCSeconds()) + 'Z' : null; |
| 185 | + }; |
| 186 | + |
| 187 | + String.prototype.toJSON = |
| 188 | + Number.prototype.toJSON = |
| 189 | + Boolean.prototype.toJSON = function (key) { |
| 190 | + return this.valueOf(); |
| 191 | + }; |
| 192 | + } |
| 193 | + |
| 194 | + var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, |
| 195 | + escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, |
| 196 | + gap, |
| 197 | + indent, |
| 198 | + meta = { // table of character substitutions |
| 199 | + '\b': '\\b', |
| 200 | + '\t': '\\t', |
| 201 | + '\n': '\\n', |
| 202 | + '\f': '\\f', |
| 203 | + '\r': '\\r', |
| 204 | + '"' : '\\"', |
| 205 | + '\\': '\\\\' |
| 206 | + }, |
| 207 | + rep; |
| 208 | + |
| 209 | + |
| 210 | + function quote(string) { |
| 211 | + |
| 212 | +// If the string contains no control characters, no quote characters, and no |
| 213 | +// backslash characters, then we can safely slap some quotes around it. |
| 214 | +// Otherwise we must also replace the offending characters with safe escape |
| 215 | +// sequences. |
| 216 | + |
| 217 | + escapable.lastIndex = 0; |
| 218 | + return escapable.test(string) ? |
| 219 | + '"' + string.replace(escapable, function (a) { |
| 220 | + var c = meta[a]; |
| 221 | + return typeof c === 'string' ? c : |
| 222 | + '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); |
| 223 | + }) + '"' : |
| 224 | + '"' + string + '"'; |
| 225 | + } |
| 226 | + |
| 227 | + |
| 228 | + function str(key, holder) { |
| 229 | + |
| 230 | +// Produce a string from holder[key]. |
| 231 | + |
| 232 | + var i, // The loop counter. |
| 233 | + k, // The member key. |
| 234 | + v, // The member value. |
| 235 | + length, |
| 236 | + mind = gap, |
| 237 | + partial, |
| 238 | + value = holder[key]; |
| 239 | + |
| 240 | +// If the value has a toJSON method, call it to obtain a replacement value. |
| 241 | + |
| 242 | + if (value && typeof value === 'object' && |
| 243 | + typeof value.toJSON === 'function') { |
| 244 | + value = value.toJSON(key); |
| 245 | + } |
| 246 | + |
| 247 | +// If we were called with a replacer function, then call the replacer to |
| 248 | +// obtain a replacement value. |
| 249 | + |
| 250 | + if (typeof rep === 'function') { |
| 251 | + value = rep.call(holder, key, value); |
| 252 | + } |
| 253 | + |
| 254 | +// What happens next depends on the value's type. |
| 255 | + |
| 256 | + switch (typeof value) { |
| 257 | + case 'string': |
| 258 | + return quote(value); |
| 259 | + |
| 260 | + case 'number': |
| 261 | + |
| 262 | +// JSON numbers must be finite. Encode non-finite numbers as null. |
| 263 | + |
| 264 | + return isFinite(value) ? String(value) : 'null'; |
| 265 | + |
| 266 | + case 'boolean': |
| 267 | + case 'null': |
| 268 | + |
| 269 | +// If the value is a boolean or null, convert it to a string. Note: |
| 270 | +// typeof null does not produce 'null'. The case is included here in |
| 271 | +// the remote chance that this gets fixed someday. |
| 272 | + |
| 273 | + return String(value); |
| 274 | + |
| 275 | +// If the type is 'object', we might be dealing with an object or an array or |
| 276 | +// null. |
| 277 | + |
| 278 | + case 'object': |
| 279 | + |
| 280 | +// Due to a specification blunder in ECMAScript, typeof null is 'object', |
| 281 | +// so watch out for that case. |
| 282 | + |
| 283 | + if (!value) { |
| 284 | + return 'null'; |
| 285 | + } |
| 286 | + |
| 287 | +// Make an array to hold the partial results of stringifying this object value. |
| 288 | + |
| 289 | + gap += indent; |
| 290 | + partial = []; |
| 291 | + |
| 292 | +// Is the value an array? |
| 293 | + |
| 294 | + if (Object.prototype.toString.apply(value) === '[object Array]') { |
| 295 | + |
| 296 | +// The value is an array. Stringify every element. Use null as a placeholder |
| 297 | +// for non-JSON values. |
| 298 | + |
| 299 | + length = value.length; |
| 300 | + for (i = 0; i < length; i += 1) { |
| 301 | + partial[i] = str(i, value) || 'null'; |
| 302 | + } |
| 303 | + |
| 304 | +// Join all of the elements together, separated with commas, and wrap them in |
| 305 | +// brackets. |
| 306 | + |
| 307 | + v = partial.length === 0 ? '[]' : |
| 308 | + gap ? '[\n' + gap + |
| 309 | + partial.join(',\n' + gap) + '\n' + |
| 310 | + mind + ']' : |
| 311 | + '[' + partial.join(',') + ']'; |
| 312 | + gap = mind; |
| 313 | + return v; |
| 314 | + } |
| 315 | + |
| 316 | +// If the replacer is an array, use it to select the members to be stringified. |
| 317 | + |
| 318 | + if (rep && typeof rep === 'object') { |
| 319 | + length = rep.length; |
| 320 | + for (i = 0; i < length; i += 1) { |
| 321 | + k = rep[i]; |
| 322 | + if (typeof k === 'string') { |
| 323 | + v = str(k, value); |
| 324 | + if (v) { |
| 325 | + partial.push(quote(k) + (gap ? ': ' : ':') + v); |
| 326 | + } |
| 327 | + } |
| 328 | + } |
| 329 | + } else { |
| 330 | + |
| 331 | +// Otherwise, iterate through all of the keys in the object. |
| 332 | + |
| 333 | + for (k in value) { |
| 334 | + if (Object.hasOwnProperty.call(value, k)) { |
| 335 | + v = str(k, value); |
| 336 | + if (v) { |
| 337 | + partial.push(quote(k) + (gap ? ': ' : ':') + v); |
| 338 | + } |
| 339 | + } |
| 340 | + } |
| 341 | + } |
| 342 | + |
| 343 | +// Join all of the member texts together, separated with commas, |
| 344 | +// and wrap them in braces. |
| 345 | + |
| 346 | + v = partial.length === 0 ? '{}' : |
| 347 | + gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' + |
| 348 | + mind + '}' : '{' + partial.join(',') + '}'; |
| 349 | + gap = mind; |
| 350 | + return v; |
| 351 | + } |
| 352 | + } |
| 353 | + |
| 354 | +// If the JSON object does not yet have a stringify method, give it one. |
| 355 | + |
| 356 | + if (typeof JSON.stringify !== 'function') { |
| 357 | + JSON.stringify = function (value, replacer, space) { |
| 358 | + |
| 359 | +// The stringify method takes a value and an optional replacer, and an optional |
| 360 | +// space parameter, and returns a JSON text. The replacer can be a function |
| 361 | +// that can replace values, or an array of strings that will select the keys. |
| 362 | +// A default replacer method can be provided. Use of the space parameter can |
| 363 | +// produce text that is more easily readable. |
| 364 | + |
| 365 | + var i; |
| 366 | + gap = ''; |
| 367 | + indent = ''; |
| 368 | + |
| 369 | +// If the space parameter is a number, make an indent string containing that |
| 370 | +// many spaces. |
| 371 | + |
| 372 | + if (typeof space === 'number') { |
| 373 | + for (i = 0; i < space; i += 1) { |
| 374 | + indent += ' '; |
| 375 | + } |
| 376 | + |
| 377 | +// If the space parameter is a string, it will be used as the indent string. |
| 378 | + |
| 379 | + } else if (typeof space === 'string') { |
| 380 | + indent = space; |
| 381 | + } |
| 382 | + |
| 383 | +// If there is a replacer, it must be a function or an array. |
| 384 | +// Otherwise, throw an error. |
| 385 | + |
| 386 | + rep = replacer; |
| 387 | + if (replacer && typeof replacer !== 'function' && |
| 388 | + (typeof replacer !== 'object' || |
| 389 | + typeof replacer.length !== 'number')) { |
| 390 | + throw new Error('JSON.stringify'); |
| 391 | + } |
| 392 | + |
| 393 | +// Make a fake root object containing our value under the key of ''. |
| 394 | +// Return the result of stringifying the value. |
| 395 | + |
| 396 | + return str('', {'': value}); |
| 397 | + }; |
| 398 | + } |
| 399 | + |
| 400 | + |
| 401 | +// If the JSON object does not yet have a parse method, give it one. |
| 402 | + |
| 403 | + if (typeof JSON.parse !== 'function') { |
| 404 | + JSON.parse = function (text, reviver) { |
| 405 | + |
| 406 | +// The parse method takes a text and an optional reviver function, and returns |
| 407 | +// a JavaScript value if the text is a valid JSON text. |
| 408 | + |
| 409 | + var j; |
| 410 | + |
| 411 | + function walk(holder, key) { |
| 412 | + |
| 413 | +// The walk method is used to recursively walk the resulting structure so |
| 414 | +// that modifications can be made. |
| 415 | + |
| 416 | + var k, v, value = holder[key]; |
| 417 | + if (value && typeof value === 'object') { |
| 418 | + for (k in value) { |
| 419 | + if (Object.hasOwnProperty.call(value, k)) { |
| 420 | + v = walk(value, k); |
| 421 | + if (v !== undefined) { |
| 422 | + value[k] = v; |
| 423 | + } else { |
| 424 | + delete value[k]; |
| 425 | + } |
| 426 | + } |
| 427 | + } |
| 428 | + } |
| 429 | + return reviver.call(holder, key, value); |
| 430 | + } |
| 431 | + |
| 432 | + |
| 433 | +// Parsing happens in four stages. In the first stage, we replace certain |
| 434 | +// Unicode characters with escape sequences. JavaScript handles many characters |
| 435 | +// incorrectly, either silently deleting them, or treating them as line endings. |
| 436 | + |
| 437 | + text = String(text); |
| 438 | + cx.lastIndex = 0; |
| 439 | + if (cx.test(text)) { |
| 440 | + text = text.replace(cx, function (a) { |
| 441 | + return '\\u' + |
| 442 | + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); |
| 443 | + }); |
| 444 | + } |
| 445 | + |
| 446 | +// In the second stage, we run the text against regular expressions that look |
| 447 | +// for non-JSON patterns. We are especially concerned with '()' and 'new' |
| 448 | +// because they can cause invocation, and '=' because it can cause mutation. |
| 449 | +// But just to be safe, we want to reject all unexpected forms. |
| 450 | + |
| 451 | +// We split the second stage into 4 regexp operations in order to work around |
| 452 | +// crippling inefficiencies in IE's and Safari's regexp engines. First we |
| 453 | +// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we |
| 454 | +// replace all simple value tokens with ']' characters. Third, we delete all |
| 455 | +// open brackets that follow a colon or comma or that begin the text. Finally, |
| 456 | +// we look to see that the remaining characters are only whitespace or ']' or |
| 457 | +// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval. |
| 458 | + |
| 459 | + if (/^[\],:{}\s]*$/. |
| 460 | +test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@'). |
| 461 | +replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']'). |
| 462 | +replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) { |
| 463 | + |
| 464 | +// In the third stage we use the eval function to compile the text into a |
| 465 | +// JavaScript structure. The '{' operator is subject to a syntactic ambiguity |
| 466 | +// in JavaScript: it can begin a block or an object literal. We wrap the text |
| 467 | +// in parens to eliminate the ambiguity. |
| 468 | + |
| 469 | + j = eval('(' + text + ')'); |
| 470 | + |
| 471 | +// In the optional fourth stage, we recursively walk the new structure, passing |
| 472 | +// each name/value pair to a reviver function for possible transformation. |
| 473 | + |
| 474 | + return typeof reviver === 'function' ? |
| 475 | + walk({'': j}, '') : j; |
| 476 | + } |
| 477 | + |
| 478 | +// If the text is not JSON parseable, then a SyntaxError is thrown. |
| 479 | + |
| 480 | + throw new SyntaxError('JSON.parse'); |
| 481 | + }; |
| 482 | + } |
| 483 | +}()); |
| 484 | + |
Property changes on: trunk/phase3/tests/jasmine/lib/appendto-jquery-mockjax/lib/json2.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 485 | + native |
Index: trunk/phase3/tests/jasmine/lib/appendto-jquery-mockjax/lib/jquery.xmldom.js |
— | — | @@ -0,0 +1,46 @@ |
| 2 | +/*! |
| 3 | + * jQuery xmlDOM Plugin v1.0 |
| 4 | + * http://outwestmedia.com/jquery-plugins/xmldom/ |
| 5 | + * |
| 6 | + * Released: 2009-04-06 |
| 7 | + * Version: 1.0 |
| 8 | + * |
| 9 | + * Copyright (c) 2009 Jonathan Sharp, Out West Media LLC. |
| 10 | + * Dual licensed under the MIT and GPL licenses. |
| 11 | + * http://docs.jquery.com/License |
| 12 | + */ |
| 13 | +(function($) { |
| 14 | + // IE DOMParser wrapper |
| 15 | + if ( window['DOMParser'] == undefined && window.ActiveXObject ) { |
| 16 | + DOMParser = function() { }; |
| 17 | + DOMParser.prototype.parseFromString = function( xmlString ) { |
| 18 | + var doc = new ActiveXObject('Microsoft.XMLDOM'); |
| 19 | + doc.async = 'false'; |
| 20 | + doc.loadXML( xmlString ); |
| 21 | + return doc; |
| 22 | + }; |
| 23 | + } |
| 24 | + |
| 25 | + $.xmlDOM = function(xml, onErrorFn) { |
| 26 | + try { |
| 27 | + var xmlDoc = ( new DOMParser() ).parseFromString( xml, 'text/xml' ); |
| 28 | + if ( $.isXMLDoc( xmlDoc ) ) { |
| 29 | + var err = $('parsererror', xmlDoc); |
| 30 | + if ( err.length == 1 ) { |
| 31 | + throw('Error: ' + $(xmlDoc).text() ); |
| 32 | + } |
| 33 | + } else { |
| 34 | + throw('Unable to parse XML'); |
| 35 | + } |
| 36 | + } catch( e ) { |
| 37 | + var msg = ( e.name == undefined ? e : e.name + ': ' + e.message ); |
| 38 | + if ( $.isFunction( onErrorFn ) ) { |
| 39 | + onErrorFn( msg ); |
| 40 | + } else { |
| 41 | + $(document).trigger('xmlParseError', [ msg ]); |
| 42 | + } |
| 43 | + return $([]); |
| 44 | + } |
| 45 | + return $( xmlDoc ); |
| 46 | + }; |
| 47 | +})(jQuery); |
\ No newline at end of file |
Property changes on: trunk/phase3/tests/jasmine/lib/appendto-jquery-mockjax/lib/jquery.xmldom.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 48 | + native |
Index: trunk/phase3/tests/jasmine/lib/appendto-jquery-mockjax/lib/jquery-1.4.2.js |
— | — | @@ -0,0 +1,6240 @@ |
| 2 | +/*! |
| 3 | + * jQuery JavaScript Library v1.4.2 |
| 4 | + * http://jquery.com/ |
| 5 | + * |
| 6 | + * Copyright 2010, John Resig |
| 7 | + * Dual licensed under the MIT or GPL Version 2 licenses. |
| 8 | + * http://jquery.org/license |
| 9 | + * |
| 10 | + * Includes Sizzle.js |
| 11 | + * http://sizzlejs.com/ |
| 12 | + * Copyright 2010, The Dojo Foundation |
| 13 | + * Released under the MIT, BSD, and GPL Licenses. |
| 14 | + * |
| 15 | + * Date: Sat Feb 13 22:33:48 2010 -0500 |
| 16 | + */ |
| 17 | +(function( window, undefined ) { |
| 18 | + |
| 19 | +// Define a local copy of jQuery |
| 20 | +var jQuery = function( selector, context ) { |
| 21 | + // The jQuery object is actually just the init constructor 'enhanced' |
| 22 | + return new jQuery.fn.init( selector, context ); |
| 23 | + }, |
| 24 | + |
| 25 | + // Map over jQuery in case of overwrite |
| 26 | + _jQuery = window.jQuery, |
| 27 | + |
| 28 | + // Map over the $ in case of overwrite |
| 29 | + _$ = window.$, |
| 30 | + |
| 31 | + // Use the correct document accordingly with window argument (sandbox) |
| 32 | + document = window.document, |
| 33 | + |
| 34 | + // A central reference to the root jQuery(document) |
| 35 | + rootjQuery, |
| 36 | + |
| 37 | + // A simple way to check for HTML strings or ID strings |
| 38 | + // (both of which we optimize for) |
| 39 | + quickExpr = /^[^<]*(<[\w\W]+>)[^>]*$|^#([\w-]+)$/, |
| 40 | + |
| 41 | + // Is it a simple selector |
| 42 | + isSimple = /^.[^:#\[\.,]*$/, |
| 43 | + |
| 44 | + // Check if a string has a non-whitespace character in it |
| 45 | + rnotwhite = /\S/, |
| 46 | + |
| 47 | + // Used for trimming whitespace |
| 48 | + rtrim = /^(\s|\u00A0)+|(\s|\u00A0)+$/g, |
| 49 | + |
| 50 | + // Match a standalone tag |
| 51 | + rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/, |
| 52 | + |
| 53 | + // Keep a UserAgent string for use with jQuery.browser |
| 54 | + userAgent = navigator.userAgent, |
| 55 | + |
| 56 | + // For matching the engine and version of the browser |
| 57 | + browserMatch, |
| 58 | + |
| 59 | + // Has the ready events already been bound? |
| 60 | + readyBound = false, |
| 61 | + |
| 62 | + // The functions to execute on DOM ready |
| 63 | + readyList = [], |
| 64 | + |
| 65 | + // The ready event handler |
| 66 | + DOMContentLoaded, |
| 67 | + |
| 68 | + // Save a reference to some core methods |
| 69 | + toString = Object.prototype.toString, |
| 70 | + hasOwnProperty = Object.prototype.hasOwnProperty, |
| 71 | + push = Array.prototype.push, |
| 72 | + slice = Array.prototype.slice, |
| 73 | + indexOf = Array.prototype.indexOf; |
| 74 | + |
| 75 | +jQuery.fn = jQuery.prototype = { |
| 76 | + init: function( selector, context ) { |
| 77 | + var match, elem, ret, doc; |
| 78 | + |
| 79 | + // Handle $(""), $(null), or $(undefined) |
| 80 | + if ( !selector ) { |
| 81 | + return this; |
| 82 | + } |
| 83 | + |
| 84 | + // Handle $(DOMElement) |
| 85 | + if ( selector.nodeType ) { |
| 86 | + this.context = this[0] = selector; |
| 87 | + this.length = 1; |
| 88 | + return this; |
| 89 | + } |
| 90 | + |
| 91 | + // The body element only exists once, optimize finding it |
| 92 | + if ( selector === "body" && !context ) { |
| 93 | + this.context = document; |
| 94 | + this[0] = document.body; |
| 95 | + this.selector = "body"; |
| 96 | + this.length = 1; |
| 97 | + return this; |
| 98 | + } |
| 99 | + |
| 100 | + // Handle HTML strings |
| 101 | + if ( typeof selector === "string" ) { |
| 102 | + // Are we dealing with HTML string or an ID? |
| 103 | + match = quickExpr.exec( selector ); |
| 104 | + |
| 105 | + // Verify a match, and that no context was specified for #id |
| 106 | + if ( match && (match[1] || !context) ) { |
| 107 | + |
| 108 | + // HANDLE: $(html) -> $(array) |
| 109 | + if ( match[1] ) { |
| 110 | + doc = (context ? context.ownerDocument || context : document); |
| 111 | + |
| 112 | + // If a single string is passed in and it's a single tag |
| 113 | + // just do a createElement and skip the rest |
| 114 | + ret = rsingleTag.exec( selector ); |
| 115 | + |
| 116 | + if ( ret ) { |
| 117 | + if ( jQuery.isPlainObject( context ) ) { |
| 118 | + selector = [ document.createElement( ret[1] ) ]; |
| 119 | + jQuery.fn.attr.call( selector, context, true ); |
| 120 | + |
| 121 | + } else { |
| 122 | + selector = [ doc.createElement( ret[1] ) ]; |
| 123 | + } |
| 124 | + |
| 125 | + } else { |
| 126 | + ret = buildFragment( [ match[1] ], [ doc ] ); |
| 127 | + selector = (ret.cacheable ? ret.fragment.cloneNode(true) : ret.fragment).childNodes; |
| 128 | + } |
| 129 | + |
| 130 | + return jQuery.merge( this, selector ); |
| 131 | + |
| 132 | + // HANDLE: $("#id") |
| 133 | + } else { |
| 134 | + elem = document.getElementById( match[2] ); |
| 135 | + |
| 136 | + if ( elem ) { |
| 137 | + // Handle the case where IE and Opera return items |
| 138 | + // by name instead of ID |
| 139 | + if ( elem.id !== match[2] ) { |
| 140 | + return rootjQuery.find( selector ); |
| 141 | + } |
| 142 | + |
| 143 | + // Otherwise, we inject the element directly into the jQuery object |
| 144 | + this.length = 1; |
| 145 | + this[0] = elem; |
| 146 | + } |
| 147 | + |
| 148 | + this.context = document; |
| 149 | + this.selector = selector; |
| 150 | + return this; |
| 151 | + } |
| 152 | + |
| 153 | + // HANDLE: $("TAG") |
| 154 | + } else if ( !context && /^\w+$/.test( selector ) ) { |
| 155 | + this.selector = selector; |
| 156 | + this.context = document; |
| 157 | + selector = document.getElementsByTagName( selector ); |
| 158 | + return jQuery.merge( this, selector ); |
| 159 | + |
| 160 | + // HANDLE: $(expr, $(...)) |
| 161 | + } else if ( !context || context.jquery ) { |
| 162 | + return (context || rootjQuery).find( selector ); |
| 163 | + |
| 164 | + // HANDLE: $(expr, context) |
| 165 | + // (which is just equivalent to: $(context).find(expr) |
| 166 | + } else { |
| 167 | + return jQuery( context ).find( selector ); |
| 168 | + } |
| 169 | + |
| 170 | + // HANDLE: $(function) |
| 171 | + // Shortcut for document ready |
| 172 | + } else if ( jQuery.isFunction( selector ) ) { |
| 173 | + return rootjQuery.ready( selector ); |
| 174 | + } |
| 175 | + |
| 176 | + if (selector.selector !== undefined) { |
| 177 | + this.selector = selector.selector; |
| 178 | + this.context = selector.context; |
| 179 | + } |
| 180 | + |
| 181 | + return jQuery.makeArray( selector, this ); |
| 182 | + }, |
| 183 | + |
| 184 | + // Start with an empty selector |
| 185 | + selector: "", |
| 186 | + |
| 187 | + // The current version of jQuery being used |
| 188 | + jquery: "1.4.2", |
| 189 | + |
| 190 | + // The default length of a jQuery object is 0 |
| 191 | + length: 0, |
| 192 | + |
| 193 | + // The number of elements contained in the matched element set |
| 194 | + size: function() { |
| 195 | + return this.length; |
| 196 | + }, |
| 197 | + |
| 198 | + toArray: function() { |
| 199 | + return slice.call( this, 0 ); |
| 200 | + }, |
| 201 | + |
| 202 | + // Get the Nth element in the matched element set OR |
| 203 | + // Get the whole matched element set as a clean array |
| 204 | + get: function( num ) { |
| 205 | + return num == null ? |
| 206 | + |
| 207 | + // Return a 'clean' array |
| 208 | + this.toArray() : |
| 209 | + |
| 210 | + // Return just the object |
| 211 | + ( num < 0 ? this.slice(num)[ 0 ] : this[ num ] ); |
| 212 | + }, |
| 213 | + |
| 214 | + // Take an array of elements and push it onto the stack |
| 215 | + // (returning the new matched element set) |
| 216 | + pushStack: function( elems, name, selector ) { |
| 217 | + // Build a new jQuery matched element set |
| 218 | + var ret = jQuery(); |
| 219 | + |
| 220 | + if ( jQuery.isArray( elems ) ) { |
| 221 | + push.apply( ret, elems ); |
| 222 | + |
| 223 | + } else { |
| 224 | + jQuery.merge( ret, elems ); |
| 225 | + } |
| 226 | + |
| 227 | + // Add the old object onto the stack (as a reference) |
| 228 | + ret.prevObject = this; |
| 229 | + |
| 230 | + ret.context = this.context; |
| 231 | + |
| 232 | + if ( name === "find" ) { |
| 233 | + ret.selector = this.selector + (this.selector ? " " : "") + selector; |
| 234 | + } else if ( name ) { |
| 235 | + ret.selector = this.selector + "." + name + "(" + selector + ")"; |
| 236 | + } |
| 237 | + |
| 238 | + // Return the newly-formed element set |
| 239 | + return ret; |
| 240 | + }, |
| 241 | + |
| 242 | + // Execute a callback for every element in the matched set. |
| 243 | + // (You can seed the arguments with an array of args, but this is |
| 244 | + // only used internally.) |
| 245 | + each: function( callback, args ) { |
| 246 | + return jQuery.each( this, callback, args ); |
| 247 | + }, |
| 248 | + |
| 249 | + ready: function( fn ) { |
| 250 | + // Attach the listeners |
| 251 | + jQuery.bindReady(); |
| 252 | + |
| 253 | + // If the DOM is already ready |
| 254 | + if ( jQuery.isReady ) { |
| 255 | + // Execute the function immediately |
| 256 | + fn.call( document, jQuery ); |
| 257 | + |
| 258 | + // Otherwise, remember the function for later |
| 259 | + } else if ( readyList ) { |
| 260 | + // Add the function to the wait list |
| 261 | + readyList.push( fn ); |
| 262 | + } |
| 263 | + |
| 264 | + return this; |
| 265 | + }, |
| 266 | + |
| 267 | + eq: function( i ) { |
| 268 | + return i === -1 ? |
| 269 | + this.slice( i ) : |
| 270 | + this.slice( i, +i + 1 ); |
| 271 | + }, |
| 272 | + |
| 273 | + first: function() { |
| 274 | + return this.eq( 0 ); |
| 275 | + }, |
| 276 | + |
| 277 | + last: function() { |
| 278 | + return this.eq( -1 ); |
| 279 | + }, |
| 280 | + |
| 281 | + slice: function() { |
| 282 | + return this.pushStack( slice.apply( this, arguments ), |
| 283 | + "slice", slice.call(arguments).join(",") ); |
| 284 | + }, |
| 285 | + |
| 286 | + map: function( callback ) { |
| 287 | + return this.pushStack( jQuery.map(this, function( elem, i ) { |
| 288 | + return callback.call( elem, i, elem ); |
| 289 | + })); |
| 290 | + }, |
| 291 | + |
| 292 | + end: function() { |
| 293 | + return this.prevObject || jQuery(null); |
| 294 | + }, |
| 295 | + |
| 296 | + // For internal use only. |
| 297 | + // Behaves like an Array's method, not like a jQuery method. |
| 298 | + push: push, |
| 299 | + sort: [].sort, |
| 300 | + splice: [].splice |
| 301 | +}; |
| 302 | + |
| 303 | +// Give the init function the jQuery prototype for later instantiation |
| 304 | +jQuery.fn.init.prototype = jQuery.fn; |
| 305 | + |
| 306 | +jQuery.extend = jQuery.fn.extend = function() { |
| 307 | + // copy reference to target object |
| 308 | + var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options, name, src, copy; |
| 309 | + |
| 310 | + // Handle a deep copy situation |
| 311 | + if ( typeof target === "boolean" ) { |
| 312 | + deep = target; |
| 313 | + target = arguments[1] || {}; |
| 314 | + // skip the boolean and the target |
| 315 | + i = 2; |
| 316 | + } |
| 317 | + |
| 318 | + // Handle case when target is a string or something (possible in deep copy) |
| 319 | + if ( typeof target !== "object" && !jQuery.isFunction(target) ) { |
| 320 | + target = {}; |
| 321 | + } |
| 322 | + |
| 323 | + // extend jQuery itself if only one argument is passed |
| 324 | + if ( length === i ) { |
| 325 | + target = this; |
| 326 | + --i; |
| 327 | + } |
| 328 | + |
| 329 | + for ( ; i < length; i++ ) { |
| 330 | + // Only deal with non-null/undefined values |
| 331 | + if ( (options = arguments[ i ]) != null ) { |
| 332 | + // Extend the base object |
| 333 | + for ( name in options ) { |
| 334 | + src = target[ name ]; |
| 335 | + copy = options[ name ]; |
| 336 | + |
| 337 | + // Prevent never-ending loop |
| 338 | + if ( target === copy ) { |
| 339 | + continue; |
| 340 | + } |
| 341 | + |
| 342 | + // Recurse if we're merging object literal values or arrays |
| 343 | + if ( deep && copy && ( jQuery.isPlainObject(copy) || jQuery.isArray(copy) ) ) { |
| 344 | + var clone = src && ( jQuery.isPlainObject(src) || jQuery.isArray(src) ) ? src |
| 345 | + : jQuery.isArray(copy) ? [] : {}; |
| 346 | + |
| 347 | + // Never move original objects, clone them |
| 348 | + target[ name ] = jQuery.extend( deep, clone, copy ); |
| 349 | + |
| 350 | + // Don't bring in undefined values |
| 351 | + } else if ( copy !== undefined ) { |
| 352 | + target[ name ] = copy; |
| 353 | + } |
| 354 | + } |
| 355 | + } |
| 356 | + } |
| 357 | + |
| 358 | + // Return the modified object |
| 359 | + return target; |
| 360 | +}; |
| 361 | + |
| 362 | +jQuery.extend({ |
| 363 | + noConflict: function( deep ) { |
| 364 | + window.$ = _$; |
| 365 | + |
| 366 | + if ( deep ) { |
| 367 | + window.jQuery = _jQuery; |
| 368 | + } |
| 369 | + |
| 370 | + return jQuery; |
| 371 | + }, |
| 372 | + |
| 373 | + // Is the DOM ready to be used? Set to true once it occurs. |
| 374 | + isReady: false, |
| 375 | + |
| 376 | + // Handle when the DOM is ready |
| 377 | + ready: function() { |
| 378 | + // Make sure that the DOM is not already loaded |
| 379 | + if ( !jQuery.isReady ) { |
| 380 | + // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). |
| 381 | + if ( !document.body ) { |
| 382 | + return setTimeout( jQuery.ready, 13 ); |
| 383 | + } |
| 384 | + |
| 385 | + // Remember that the DOM is ready |
| 386 | + jQuery.isReady = true; |
| 387 | + |
| 388 | + // If there are functions bound, to execute |
| 389 | + if ( readyList ) { |
| 390 | + // Execute all of them |
| 391 | + var fn, i = 0; |
| 392 | + while ( (fn = readyList[ i++ ]) ) { |
| 393 | + fn.call( document, jQuery ); |
| 394 | + } |
| 395 | + |
| 396 | + // Reset the list of functions |
| 397 | + readyList = null; |
| 398 | + } |
| 399 | + |
| 400 | + // Trigger any bound ready events |
| 401 | + if ( jQuery.fn.triggerHandler ) { |
| 402 | + jQuery( document ).triggerHandler( "ready" ); |
| 403 | + } |
| 404 | + } |
| 405 | + }, |
| 406 | + |
| 407 | + bindReady: function() { |
| 408 | + if ( readyBound ) { |
| 409 | + return; |
| 410 | + } |
| 411 | + |
| 412 | + readyBound = true; |
| 413 | + |
| 414 | + // Catch cases where $(document).ready() is called after the |
| 415 | + // browser event has already occurred. |
| 416 | + if ( document.readyState === "complete" ) { |
| 417 | + return jQuery.ready(); |
| 418 | + } |
| 419 | + |
| 420 | + // Mozilla, Opera and webkit nightlies currently support this event |
| 421 | + if ( document.addEventListener ) { |
| 422 | + // Use the handy event callback |
| 423 | + document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false ); |
| 424 | + |
| 425 | + // A fallback to window.onload, that will always work |
| 426 | + window.addEventListener( "load", jQuery.ready, false ); |
| 427 | + |
| 428 | + // If IE event model is used |
| 429 | + } else if ( document.attachEvent ) { |
| 430 | + // ensure firing before onload, |
| 431 | + // maybe late but safe also for iframes |
| 432 | + document.attachEvent("onreadystatechange", DOMContentLoaded); |
| 433 | + |
| 434 | + // A fallback to window.onload, that will always work |
| 435 | + window.attachEvent( "onload", jQuery.ready ); |
| 436 | + |
| 437 | + // If IE and not a frame |
| 438 | + // continually check to see if the document is ready |
| 439 | + var toplevel = false; |
| 440 | + |
| 441 | + try { |
| 442 | + toplevel = window.frameElement == null; |
| 443 | + } catch(e) {} |
| 444 | + |
| 445 | + if ( document.documentElement.doScroll && toplevel ) { |
| 446 | + doScrollCheck(); |
| 447 | + } |
| 448 | + } |
| 449 | + }, |
| 450 | + |
| 451 | + // See test/unit/core.js for details concerning isFunction. |
| 452 | + // Since version 1.3, DOM methods and functions like alert |
| 453 | + // aren't supported. They return false on IE (#2968). |
| 454 | + isFunction: function( obj ) { |
| 455 | + return toString.call(obj) === "[object Function]"; |
| 456 | + }, |
| 457 | + |
| 458 | + isArray: function( obj ) { |
| 459 | + return toString.call(obj) === "[object Array]"; |
| 460 | + }, |
| 461 | + |
| 462 | + isPlainObject: function( obj ) { |
| 463 | + // Must be an Object. |
| 464 | + // Because of IE, we also have to check the presence of the constructor property. |
| 465 | + // Make sure that DOM nodes and window objects don't pass through, as well |
| 466 | + if ( !obj || toString.call(obj) !== "[object Object]" || obj.nodeType || obj.setInterval ) { |
| 467 | + return false; |
| 468 | + } |
| 469 | + |
| 470 | + // Not own constructor property must be Object |
| 471 | + if ( obj.constructor |
| 472 | + && !hasOwnProperty.call(obj, "constructor") |
| 473 | + && !hasOwnProperty.call(obj.constructor.prototype, "isPrototypeOf") ) { |
| 474 | + return false; |
| 475 | + } |
| 476 | + |
| 477 | + // Own properties are enumerated firstly, so to speed up, |
| 478 | + // if last one is own, then all properties are own. |
| 479 | + |
| 480 | + var key; |
| 481 | + for ( key in obj ) {} |
| 482 | + |
| 483 | + return key === undefined || hasOwnProperty.call( obj, key ); |
| 484 | + }, |
| 485 | + |
| 486 | + isEmptyObject: function( obj ) { |
| 487 | + for ( var name in obj ) { |
| 488 | + return false; |
| 489 | + } |
| 490 | + return true; |
| 491 | + }, |
| 492 | + |
| 493 | + error: function( msg ) { |
| 494 | + throw msg; |
| 495 | + }, |
| 496 | + |
| 497 | + parseJSON: function( data ) { |
| 498 | + if ( typeof data !== "string" || !data ) { |
| 499 | + return null; |
| 500 | + } |
| 501 | + |
| 502 | + // Make sure leading/trailing whitespace is removed (IE can't handle it) |
| 503 | + data = jQuery.trim( data ); |
| 504 | + |
| 505 | + // Make sure the incoming data is actual JSON |
| 506 | + // Logic borrowed from http://json.org/json2.js |
| 507 | + if ( /^[\],:{}\s]*$/.test(data.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, "@") |
| 508 | + .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, "]") |
| 509 | + .replace(/(?:^|:|,)(?:\s*\[)+/g, "")) ) { |
| 510 | + |
| 511 | + // Try to use the native JSON parser first |
| 512 | + return window.JSON && window.JSON.parse ? |
| 513 | + window.JSON.parse( data ) : |
| 514 | + (new Function("return " + data))(); |
| 515 | + |
| 516 | + } else { |
| 517 | + jQuery.error( "Invalid JSON: " + data ); |
| 518 | + } |
| 519 | + }, |
| 520 | + |
| 521 | + noop: function() {}, |
| 522 | + |
| 523 | + // Evalulates a script in a global context |
| 524 | + globalEval: function( data ) { |
| 525 | + if ( data && rnotwhite.test(data) ) { |
| 526 | + // Inspired by code by Andrea Giammarchi |
| 527 | + // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html |
| 528 | + var head = document.getElementsByTagName("head")[0] || document.documentElement, |
| 529 | + script = document.createElement("script"); |
| 530 | + |
| 531 | + script.type = "text/javascript"; |
| 532 | + |
| 533 | + if ( jQuery.support.scriptEval ) { |
| 534 | + script.appendChild( document.createTextNode( data ) ); |
| 535 | + } else { |
| 536 | + script.text = data; |
| 537 | + } |
| 538 | + |
| 539 | + // Use insertBefore instead of appendChild to circumvent an IE6 bug. |
| 540 | + // This arises when a base node is used (#2709). |
| 541 | + head.insertBefore( script, head.firstChild ); |
| 542 | + head.removeChild( script ); |
| 543 | + } |
| 544 | + }, |
| 545 | + |
| 546 | + nodeName: function( elem, name ) { |
| 547 | + return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase(); |
| 548 | + }, |
| 549 | + |
| 550 | + // args is for internal usage only |
| 551 | + each: function( object, callback, args ) { |
| 552 | + var name, i = 0, |
| 553 | + length = object.length, |
| 554 | + isObj = length === undefined || jQuery.isFunction(object); |
| 555 | + |
| 556 | + if ( args ) { |
| 557 | + if ( isObj ) { |
| 558 | + for ( name in object ) { |
| 559 | + if ( callback.apply( object[ name ], args ) === false ) { |
| 560 | + break; |
| 561 | + } |
| 562 | + } |
| 563 | + } else { |
| 564 | + for ( ; i < length; ) { |
| 565 | + if ( callback.apply( object[ i++ ], args ) === false ) { |
| 566 | + break; |
| 567 | + } |
| 568 | + } |
| 569 | + } |
| 570 | + |
| 571 | + // A special, fast, case for the most common use of each |
| 572 | + } else { |
| 573 | + if ( isObj ) { |
| 574 | + for ( name in object ) { |
| 575 | + if ( callback.call( object[ name ], name, object[ name ] ) === false ) { |
| 576 | + break; |
| 577 | + } |
| 578 | + } |
| 579 | + } else { |
| 580 | + for ( var value = object[0]; |
| 581 | + i < length && callback.call( value, i, value ) !== false; value = object[++i] ) {} |
| 582 | + } |
| 583 | + } |
| 584 | + |
| 585 | + return object; |
| 586 | + }, |
| 587 | + |
| 588 | + trim: function( text ) { |
| 589 | + return (text || "").replace( rtrim, "" ); |
| 590 | + }, |
| 591 | + |
| 592 | + // results is for internal usage only |
| 593 | + makeArray: function( array, results ) { |
| 594 | + var ret = results || []; |
| 595 | + |
| 596 | + if ( array != null ) { |
| 597 | + // The window, strings (and functions) also have 'length' |
| 598 | + // The extra typeof function check is to prevent crashes |
| 599 | + // in Safari 2 (See: #3039) |
| 600 | + if ( array.length == null || typeof array === "string" || jQuery.isFunction(array) || (typeof array !== "function" && array.setInterval) ) { |
| 601 | + push.call( ret, array ); |
| 602 | + } else { |
| 603 | + jQuery.merge( ret, array ); |
| 604 | + } |
| 605 | + } |
| 606 | + |
| 607 | + return ret; |
| 608 | + }, |
| 609 | + |
| 610 | + inArray: function( elem, array ) { |
| 611 | + if ( array.indexOf ) { |
| 612 | + return array.indexOf( elem ); |
| 613 | + } |
| 614 | + |
| 615 | + for ( var i = 0, length = array.length; i < length; i++ ) { |
| 616 | + if ( array[ i ] === elem ) { |
| 617 | + return i; |
| 618 | + } |
| 619 | + } |
| 620 | + |
| 621 | + return -1; |
| 622 | + }, |
| 623 | + |
| 624 | + merge: function( first, second ) { |
| 625 | + var i = first.length, j = 0; |
| 626 | + |
| 627 | + if ( typeof second.length === "number" ) { |
| 628 | + for ( var l = second.length; j < l; j++ ) { |
| 629 | + first[ i++ ] = second[ j ]; |
| 630 | + } |
| 631 | + |
| 632 | + } else { |
| 633 | + while ( second[j] !== undefined ) { |
| 634 | + first[ i++ ] = second[ j++ ]; |
| 635 | + } |
| 636 | + } |
| 637 | + |
| 638 | + first.length = i; |
| 639 | + |
| 640 | + return first; |
| 641 | + }, |
| 642 | + |
| 643 | + grep: function( elems, callback, inv ) { |
| 644 | + var ret = []; |
| 645 | + |
| 646 | + // Go through the array, only saving the items |
| 647 | + // that pass the validator function |
| 648 | + for ( var i = 0, length = elems.length; i < length; i++ ) { |
| 649 | + if ( !inv !== !callback( elems[ i ], i ) ) { |
| 650 | + ret.push( elems[ i ] ); |
| 651 | + } |
| 652 | + } |
| 653 | + |
| 654 | + return ret; |
| 655 | + }, |
| 656 | + |
| 657 | + // arg is for internal usage only |
| 658 | + map: function( elems, callback, arg ) { |
| 659 | + var ret = [], value; |
| 660 | + |
| 661 | + // Go through the array, translating each of the items to their |
| 662 | + // new value (or values). |
| 663 | + for ( var i = 0, length = elems.length; i < length; i++ ) { |
| 664 | + value = callback( elems[ i ], i, arg ); |
| 665 | + |
| 666 | + if ( value != null ) { |
| 667 | + ret[ ret.length ] = value; |
| 668 | + } |
| 669 | + } |
| 670 | + |
| 671 | + return ret.concat.apply( [], ret ); |
| 672 | + }, |
| 673 | + |
| 674 | + // A global GUID counter for objects |
| 675 | + guid: 1, |
| 676 | + |
| 677 | + proxy: function( fn, proxy, thisObject ) { |
| 678 | + if ( arguments.length === 2 ) { |
| 679 | + if ( typeof proxy === "string" ) { |
| 680 | + thisObject = fn; |
| 681 | + fn = thisObject[ proxy ]; |
| 682 | + proxy = undefined; |
| 683 | + |
| 684 | + } else if ( proxy && !jQuery.isFunction( proxy ) ) { |
| 685 | + thisObject = proxy; |
| 686 | + proxy = undefined; |
| 687 | + } |
| 688 | + } |
| 689 | + |
| 690 | + if ( !proxy && fn ) { |
| 691 | + proxy = function() { |
| 692 | + return fn.apply( thisObject || this, arguments ); |
| 693 | + }; |
| 694 | + } |
| 695 | + |
| 696 | + // Set the guid of unique handler to the same of original handler, so it can be removed |
| 697 | + if ( fn ) { |
| 698 | + proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++; |
| 699 | + } |
| 700 | + |
| 701 | + // So proxy can be declared as an argument |
| 702 | + return proxy; |
| 703 | + }, |
| 704 | + |
| 705 | + // Use of jQuery.browser is frowned upon. |
| 706 | + // More details: http://docs.jquery.com/Utilities/jQuery.browser |
| 707 | + uaMatch: function( ua ) { |
| 708 | + ua = ua.toLowerCase(); |
| 709 | + |
| 710 | + var match = /(webkit)[ \/]([\w.]+)/.exec( ua ) || |
| 711 | + /(opera)(?:.*version)?[ \/]([\w.]+)/.exec( ua ) || |
| 712 | + /(msie) ([\w.]+)/.exec( ua ) || |
| 713 | + !/compatible/.test( ua ) && /(mozilla)(?:.*? rv:([\w.]+))?/.exec( ua ) || |
| 714 | + []; |
| 715 | + |
| 716 | + return { browser: match[1] || "", version: match[2] || "0" }; |
| 717 | + }, |
| 718 | + |
| 719 | + browser: {} |
| 720 | +}); |
| 721 | + |
| 722 | +browserMatch = jQuery.uaMatch( userAgent ); |
| 723 | +if ( browserMatch.browser ) { |
| 724 | + jQuery.browser[ browserMatch.browser ] = true; |
| 725 | + jQuery.browser.version = browserMatch.version; |
| 726 | +} |
| 727 | + |
| 728 | +// Deprecated, use jQuery.browser.webkit instead |
| 729 | +if ( jQuery.browser.webkit ) { |
| 730 | + jQuery.browser.safari = true; |
| 731 | +} |
| 732 | + |
| 733 | +if ( indexOf ) { |
| 734 | + jQuery.inArray = function( elem, array ) { |
| 735 | + return indexOf.call( array, elem ); |
| 736 | + }; |
| 737 | +} |
| 738 | + |
| 739 | +// All jQuery objects should point back to these |
| 740 | +rootjQuery = jQuery(document); |
| 741 | + |
| 742 | +// Cleanup functions for the document ready method |
| 743 | +if ( document.addEventListener ) { |
| 744 | + DOMContentLoaded = function() { |
| 745 | + document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false ); |
| 746 | + jQuery.ready(); |
| 747 | + }; |
| 748 | + |
| 749 | +} else if ( document.attachEvent ) { |
| 750 | + DOMContentLoaded = function() { |
| 751 | + // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). |
| 752 | + if ( document.readyState === "complete" ) { |
| 753 | + document.detachEvent( "onreadystatechange", DOMContentLoaded ); |
| 754 | + jQuery.ready(); |
| 755 | + } |
| 756 | + }; |
| 757 | +} |
| 758 | + |
| 759 | +// The DOM ready check for Internet Explorer |
| 760 | +function doScrollCheck() { |
| 761 | + if ( jQuery.isReady ) { |
| 762 | + return; |
| 763 | + } |
| 764 | + |
| 765 | + try { |
| 766 | + // If IE is used, use the trick by Diego Perini |
| 767 | + // http://javascript.nwbox.com/IEContentLoaded/ |
| 768 | + document.documentElement.doScroll("left"); |
| 769 | + } catch( error ) { |
| 770 | + setTimeout( doScrollCheck, 1 ); |
| 771 | + return; |
| 772 | + } |
| 773 | + |
| 774 | + // and execute any waiting functions |
| 775 | + jQuery.ready(); |
| 776 | +} |
| 777 | + |
| 778 | +function evalScript( i, elem ) { |
| 779 | + if ( elem.src ) { |
| 780 | + jQuery.ajax({ |
| 781 | + url: elem.src, |
| 782 | + async: false, |
| 783 | + dataType: "script" |
| 784 | + }); |
| 785 | + } else { |
| 786 | + jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" ); |
| 787 | + } |
| 788 | + |
| 789 | + if ( elem.parentNode ) { |
| 790 | + elem.parentNode.removeChild( elem ); |
| 791 | + } |
| 792 | +} |
| 793 | + |
| 794 | +// Mutifunctional method to get and set values to a collection |
| 795 | +// The value/s can be optionally by executed if its a function |
| 796 | +function access( elems, key, value, exec, fn, pass ) { |
| 797 | + var length = elems.length; |
| 798 | + |
| 799 | + // Setting many attributes |
| 800 | + if ( typeof key === "object" ) { |
| 801 | + for ( var k in key ) { |
| 802 | + access( elems, k, key[k], exec, fn, value ); |
| 803 | + } |
| 804 | + return elems; |
| 805 | + } |
| 806 | + |
| 807 | + // Setting one attribute |
| 808 | + if ( value !== undefined ) { |
| 809 | + // Optionally, function values get executed if exec is true |
| 810 | + exec = !pass && exec && jQuery.isFunction(value); |
| 811 | + |
| 812 | + for ( var i = 0; i < length; i++ ) { |
| 813 | + fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass ); |
| 814 | + } |
| 815 | + |
| 816 | + return elems; |
| 817 | + } |
| 818 | + |
| 819 | + // Getting an attribute |
| 820 | + return length ? fn( elems[0], key ) : undefined; |
| 821 | +} |
| 822 | + |
| 823 | +function now() { |
| 824 | + return (new Date).getTime(); |
| 825 | +} |
| 826 | +(function() { |
| 827 | + |
| 828 | + jQuery.support = {}; |
| 829 | + |
| 830 | + var root = document.documentElement, |
| 831 | + script = document.createElement("script"), |
| 832 | + div = document.createElement("div"), |
| 833 | + id = "script" + now(); |
| 834 | + |
| 835 | + div.style.display = "none"; |
| 836 | + div.innerHTML = " <link/><table></table><a href='/a' style='color:red;float:left;opacity:.55;'>a</a><input type='checkbox'/>"; |
| 837 | + |
| 838 | + var all = div.getElementsByTagName("*"), |
| 839 | + a = div.getElementsByTagName("a")[0]; |
| 840 | + |
| 841 | + // Can't get basic test support |
| 842 | + if ( !all || !all.length || !a ) { |
| 843 | + return; |
| 844 | + } |
| 845 | + |
| 846 | + jQuery.support = { |
| 847 | + // IE strips leading whitespace when .innerHTML is used |
| 848 | + leadingWhitespace: div.firstChild.nodeType === 3, |
| 849 | + |
| 850 | + // Make sure that tbody elements aren't automatically inserted |
| 851 | + // IE will insert them into empty tables |
| 852 | + tbody: !div.getElementsByTagName("tbody").length, |
| 853 | + |
| 854 | + // Make sure that link elements get serialized correctly by innerHTML |
| 855 | + // This requires a wrapper element in IE |
| 856 | + htmlSerialize: !!div.getElementsByTagName("link").length, |
| 857 | + |
| 858 | + // Get the style information from getAttribute |
| 859 | + // (IE uses .cssText insted) |
| 860 | + style: /red/.test( a.getAttribute("style") ), |
| 861 | + |
| 862 | + // Make sure that URLs aren't manipulated |
| 863 | + // (IE normalizes it by default) |
| 864 | + hrefNormalized: a.getAttribute("href") === "/a", |
| 865 | + |
| 866 | + // Make sure that element opacity exists |
| 867 | + // (IE uses filter instead) |
| 868 | + // Use a regex to work around a WebKit issue. See #5145 |
| 869 | + opacity: /^0.55$/.test( a.style.opacity ), |
| 870 | + |
| 871 | + // Verify style float existence |
| 872 | + // (IE uses styleFloat instead of cssFloat) |
| 873 | + cssFloat: !!a.style.cssFloat, |
| 874 | + |
| 875 | + // Make sure that if no value is specified for a checkbox |
| 876 | + // that it defaults to "on". |
| 877 | + // (WebKit defaults to "" instead) |
| 878 | + checkOn: div.getElementsByTagName("input")[0].value === "on", |
| 879 | + |
| 880 | + // Make sure that a selected-by-default option has a working selected property. |
| 881 | + // (WebKit defaults to false instead of true, IE too, if it's in an optgroup) |
| 882 | + optSelected: document.createElement("select").appendChild( document.createElement("option") ).selected, |
| 883 | + |
| 884 | + parentNode: div.removeChild( div.appendChild( document.createElement("div") ) ).parentNode === null, |
| 885 | + |
| 886 | + // Will be defined later |
| 887 | + deleteExpando: true, |
| 888 | + checkClone: false, |
| 889 | + scriptEval: false, |
| 890 | + noCloneEvent: true, |
| 891 | + boxModel: null |
| 892 | + }; |
| 893 | + |
| 894 | + script.type = "text/javascript"; |
| 895 | + try { |
| 896 | + script.appendChild( document.createTextNode( "window." + id + "=1;" ) ); |
| 897 | + } catch(e) {} |
| 898 | + |
| 899 | + root.insertBefore( script, root.firstChild ); |
| 900 | + |
| 901 | + // Make sure that the execution of code works by injecting a script |
| 902 | + // tag with appendChild/createTextNode |
| 903 | + // (IE doesn't support this, fails, and uses .text instead) |
| 904 | + if ( window[ id ] ) { |
| 905 | + jQuery.support.scriptEval = true; |
| 906 | + delete window[ id ]; |
| 907 | + } |
| 908 | + |
| 909 | + // Test to see if it's possible to delete an expando from an element |
| 910 | + // Fails in Internet Explorer |
| 911 | + try { |
| 912 | + delete script.test; |
| 913 | + |
| 914 | + } catch(e) { |
| 915 | + jQuery.support.deleteExpando = false; |
| 916 | + } |
| 917 | + |
| 918 | + root.removeChild( script ); |
| 919 | + |
| 920 | + if ( div.attachEvent && div.fireEvent ) { |
| 921 | + div.attachEvent("onclick", function click() { |
| 922 | + // Cloning a node shouldn't copy over any |
| 923 | + // bound event handlers (IE does this) |
| 924 | + jQuery.support.noCloneEvent = false; |
| 925 | + div.detachEvent("onclick", click); |
| 926 | + }); |
| 927 | + div.cloneNode(true).fireEvent("onclick"); |
| 928 | + } |
| 929 | + |
| 930 | + div = document.createElement("div"); |
| 931 | + div.innerHTML = "<input type='radio' name='radiotest' checked='checked'/>"; |
| 932 | + |
| 933 | + var fragment = document.createDocumentFragment(); |
| 934 | + fragment.appendChild( div.firstChild ); |
| 935 | + |
| 936 | + // WebKit doesn't clone checked state correctly in fragments |
| 937 | + jQuery.support.checkClone = fragment.cloneNode(true).cloneNode(true).lastChild.checked; |
| 938 | + |
| 939 | + // Figure out if the W3C box model works as expected |
| 940 | + // document.body must exist before we can do this |
| 941 | + jQuery(function() { |
| 942 | + var div = document.createElement("div"); |
| 943 | + div.style.width = div.style.paddingLeft = "1px"; |
| 944 | + |
| 945 | + document.body.appendChild( div ); |
| 946 | + jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2; |
| 947 | + document.body.removeChild( div ).style.display = 'none'; |
| 948 | + |
| 949 | + div = null; |
| 950 | + }); |
| 951 | + |
| 952 | + // Technique from Juriy Zaytsev |
| 953 | + // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/ |
| 954 | + var eventSupported = function( eventName ) { |
| 955 | + var el = document.createElement("div"); |
| 956 | + eventName = "on" + eventName; |
| 957 | + |
| 958 | + var isSupported = (eventName in el); |
| 959 | + if ( !isSupported ) { |
| 960 | + el.setAttribute(eventName, "return;"); |
| 961 | + isSupported = typeof el[eventName] === "function"; |
| 962 | + } |
| 963 | + el = null; |
| 964 | + |
| 965 | + return isSupported; |
| 966 | + }; |
| 967 | + |
| 968 | + jQuery.support.submitBubbles = eventSupported("submit"); |
| 969 | + jQuery.support.changeBubbles = eventSupported("change"); |
| 970 | + |
| 971 | + // release memory in IE |
| 972 | + root = script = div = all = a = null; |
| 973 | +})(); |
| 974 | + |
| 975 | +jQuery.props = { |
| 976 | + "for": "htmlFor", |
| 977 | + "class": "className", |
| 978 | + readonly: "readOnly", |
| 979 | + maxlength: "maxLength", |
| 980 | + cellspacing: "cellSpacing", |
| 981 | + rowspan: "rowSpan", |
| 982 | + colspan: "colSpan", |
| 983 | + tabindex: "tabIndex", |
| 984 | + usemap: "useMap", |
| 985 | + frameborder: "frameBorder" |
| 986 | +}; |
| 987 | +var expando = "jQuery" + now(), uuid = 0, windowData = {}; |
| 988 | + |
| 989 | +jQuery.extend({ |
| 990 | + cache: {}, |
| 991 | + |
| 992 | + expando:expando, |
| 993 | + |
| 994 | + // The following elements throw uncatchable exceptions if you |
| 995 | + // attempt to add expando properties to them. |
| 996 | + noData: { |
| 997 | + "embed": true, |
| 998 | + "object": true, |
| 999 | + "applet": true |
| 1000 | + }, |
| 1001 | + |
| 1002 | + data: function( elem, name, data ) { |
| 1003 | + if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) { |
| 1004 | + return; |
| 1005 | + } |
| 1006 | + |
| 1007 | + elem = elem == window ? |
| 1008 | + windowData : |
| 1009 | + elem; |
| 1010 | + |
| 1011 | + var id = elem[ expando ], cache = jQuery.cache, thisCache; |
| 1012 | + |
| 1013 | + if ( !id && typeof name === "string" && data === undefined ) { |
| 1014 | + return null; |
| 1015 | + } |
| 1016 | + |
| 1017 | + // Compute a unique ID for the element |
| 1018 | + if ( !id ) { |
| 1019 | + id = ++uuid; |
| 1020 | + } |
| 1021 | + |
| 1022 | + // Avoid generating a new cache unless none exists and we |
| 1023 | + // want to manipulate it. |
| 1024 | + if ( typeof name === "object" ) { |
| 1025 | + elem[ expando ] = id; |
| 1026 | + thisCache = cache[ id ] = jQuery.extend(true, {}, name); |
| 1027 | + |
| 1028 | + } else if ( !cache[ id ] ) { |
| 1029 | + elem[ expando ] = id; |
| 1030 | + cache[ id ] = {}; |
| 1031 | + } |
| 1032 | + |
| 1033 | + thisCache = cache[ id ]; |
| 1034 | + |
| 1035 | + // Prevent overriding the named cache with undefined values |
| 1036 | + if ( data !== undefined ) { |
| 1037 | + thisCache[ name ] = data; |
| 1038 | + } |
| 1039 | + |
| 1040 | + return typeof name === "string" ? thisCache[ name ] : thisCache; |
| 1041 | + }, |
| 1042 | + |
| 1043 | + removeData: function( elem, name ) { |
| 1044 | + if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) { |
| 1045 | + return; |
| 1046 | + } |
| 1047 | + |
| 1048 | + elem = elem == window ? |
| 1049 | + windowData : |
| 1050 | + elem; |
| 1051 | + |
| 1052 | + var id = elem[ expando ], cache = jQuery.cache, thisCache = cache[ id ]; |
| 1053 | + |
| 1054 | + // If we want to remove a specific section of the element's data |
| 1055 | + if ( name ) { |
| 1056 | + if ( thisCache ) { |
| 1057 | + // Remove the section of cache data |
| 1058 | + delete thisCache[ name ]; |
| 1059 | + |
| 1060 | + // If we've removed all the data, remove the element's cache |
| 1061 | + if ( jQuery.isEmptyObject(thisCache) ) { |
| 1062 | + jQuery.removeData( elem ); |
| 1063 | + } |
| 1064 | + } |
| 1065 | + |
| 1066 | + // Otherwise, we want to remove all of the element's data |
| 1067 | + } else { |
| 1068 | + if ( jQuery.support.deleteExpando ) { |
| 1069 | + delete elem[ jQuery.expando ]; |
| 1070 | + |
| 1071 | + } else if ( elem.removeAttribute ) { |
| 1072 | + elem.removeAttribute( jQuery.expando ); |
| 1073 | + } |
| 1074 | + |
| 1075 | + // Completely remove the data cache |
| 1076 | + delete cache[ id ]; |
| 1077 | + } |
| 1078 | + } |
| 1079 | +}); |
| 1080 | + |
| 1081 | +jQuery.fn.extend({ |
| 1082 | + data: function( key, value ) { |
| 1083 | + if ( typeof key === "undefined" && this.length ) { |
| 1084 | + return jQuery.data( this[0] ); |
| 1085 | + |
| 1086 | + } else if ( typeof key === "object" ) { |
| 1087 | + return this.each(function() { |
| 1088 | + jQuery.data( this, key ); |
| 1089 | + }); |
| 1090 | + } |
| 1091 | + |
| 1092 | + var parts = key.split("."); |
| 1093 | + parts[1] = parts[1] ? "." + parts[1] : ""; |
| 1094 | + |
| 1095 | + if ( value === undefined ) { |
| 1096 | + var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]); |
| 1097 | + |
| 1098 | + if ( data === undefined && this.length ) { |
| 1099 | + data = jQuery.data( this[0], key ); |
| 1100 | + } |
| 1101 | + return data === undefined && parts[1] ? |
| 1102 | + this.data( parts[0] ) : |
| 1103 | + data; |
| 1104 | + } else { |
| 1105 | + return this.trigger("setData" + parts[1] + "!", [parts[0], value]).each(function() { |
| 1106 | + jQuery.data( this, key, value ); |
| 1107 | + }); |
| 1108 | + } |
| 1109 | + }, |
| 1110 | + |
| 1111 | + removeData: function( key ) { |
| 1112 | + return this.each(function() { |
| 1113 | + jQuery.removeData( this, key ); |
| 1114 | + }); |
| 1115 | + } |
| 1116 | +}); |
| 1117 | +jQuery.extend({ |
| 1118 | + queue: function( elem, type, data ) { |
| 1119 | + if ( !elem ) { |
| 1120 | + return; |
| 1121 | + } |
| 1122 | + |
| 1123 | + type = (type || "fx") + "queue"; |
| 1124 | + var q = jQuery.data( elem, type ); |
| 1125 | + |
| 1126 | + // Speed up dequeue by getting out quickly if this is just a lookup |
| 1127 | + if ( !data ) { |
| 1128 | + return q || []; |
| 1129 | + } |
| 1130 | + |
| 1131 | + if ( !q || jQuery.isArray(data) ) { |
| 1132 | + q = jQuery.data( elem, type, jQuery.makeArray(data) ); |
| 1133 | + |
| 1134 | + } else { |
| 1135 | + q.push( data ); |
| 1136 | + } |
| 1137 | + |
| 1138 | + return q; |
| 1139 | + }, |
| 1140 | + |
| 1141 | + dequeue: function( elem, type ) { |
| 1142 | + type = type || "fx"; |
| 1143 | + |
| 1144 | + var queue = jQuery.queue( elem, type ), fn = queue.shift(); |
| 1145 | + |
| 1146 | + // If the fx queue is dequeued, always remove the progress sentinel |
| 1147 | + if ( fn === "inprogress" ) { |
| 1148 | + fn = queue.shift(); |
| 1149 | + } |
| 1150 | + |
| 1151 | + if ( fn ) { |
| 1152 | + // Add a progress sentinel to prevent the fx queue from being |
| 1153 | + // automatically dequeued |
| 1154 | + if ( type === "fx" ) { |
| 1155 | + queue.unshift("inprogress"); |
| 1156 | + } |
| 1157 | + |
| 1158 | + fn.call(elem, function() { |
| 1159 | + jQuery.dequeue(elem, type); |
| 1160 | + }); |
| 1161 | + } |
| 1162 | + } |
| 1163 | +}); |
| 1164 | + |
| 1165 | +jQuery.fn.extend({ |
| 1166 | + queue: function( type, data ) { |
| 1167 | + if ( typeof type !== "string" ) { |
| 1168 | + data = type; |
| 1169 | + type = "fx"; |
| 1170 | + } |
| 1171 | + |
| 1172 | + if ( data === undefined ) { |
| 1173 | + return jQuery.queue( this[0], type ); |
| 1174 | + } |
| 1175 | + return this.each(function( i, elem ) { |
| 1176 | + var queue = jQuery.queue( this, type, data ); |
| 1177 | + |
| 1178 | + if ( type === "fx" && queue[0] !== "inprogress" ) { |
| 1179 | + jQuery.dequeue( this, type ); |
| 1180 | + } |
| 1181 | + }); |
| 1182 | + }, |
| 1183 | + dequeue: function( type ) { |
| 1184 | + return this.each(function() { |
| 1185 | + jQuery.dequeue( this, type ); |
| 1186 | + }); |
| 1187 | + }, |
| 1188 | + |
| 1189 | + // Based off of the plugin by Clint Helfers, with permission. |
| 1190 | + // http://blindsignals.com/index.php/2009/07/jquery-delay/ |
| 1191 | + delay: function( time, type ) { |
| 1192 | + time = jQuery.fx ? jQuery.fx.speeds[time] || time : time; |
| 1193 | + type = type || "fx"; |
| 1194 | + |
| 1195 | + return this.queue( type, function() { |
| 1196 | + var elem = this; |
| 1197 | + setTimeout(function() { |
| 1198 | + jQuery.dequeue( elem, type ); |
| 1199 | + }, time ); |
| 1200 | + }); |
| 1201 | + }, |
| 1202 | + |
| 1203 | + clearQueue: function( type ) { |
| 1204 | + return this.queue( type || "fx", [] ); |
| 1205 | + } |
| 1206 | +}); |
| 1207 | +var rclass = /[\n\t]/g, |
| 1208 | + rspace = /\s+/, |
| 1209 | + rreturn = /\r/g, |
| 1210 | + rspecialurl = /href|src|style/, |
| 1211 | + rtype = /(button|input)/i, |
| 1212 | + rfocusable = /(button|input|object|select|textarea)/i, |
| 1213 | + rclickable = /^(a|area)$/i, |
| 1214 | + rradiocheck = /radio|checkbox/; |
| 1215 | + |
| 1216 | +jQuery.fn.extend({ |
| 1217 | + attr: function( name, value ) { |
| 1218 | + return access( this, name, value, true, jQuery.attr ); |
| 1219 | + }, |
| 1220 | + |
| 1221 | + removeAttr: function( name, fn ) { |
| 1222 | + return this.each(function(){ |
| 1223 | + jQuery.attr( this, name, "" ); |
| 1224 | + if ( this.nodeType === 1 ) { |
| 1225 | + this.removeAttribute( name ); |
| 1226 | + } |
| 1227 | + }); |
| 1228 | + }, |
| 1229 | + |
| 1230 | + addClass: function( value ) { |
| 1231 | + if ( jQuery.isFunction(value) ) { |
| 1232 | + return this.each(function(i) { |
| 1233 | + var self = jQuery(this); |
| 1234 | + self.addClass( value.call(this, i, self.attr("class")) ); |
| 1235 | + }); |
| 1236 | + } |
| 1237 | + |
| 1238 | + if ( value && typeof value === "string" ) { |
| 1239 | + var classNames = (value || "").split( rspace ); |
| 1240 | + |
| 1241 | + for ( var i = 0, l = this.length; i < l; i++ ) { |
| 1242 | + var elem = this[i]; |
| 1243 | + |
| 1244 | + if ( elem.nodeType === 1 ) { |
| 1245 | + if ( !elem.className ) { |
| 1246 | + elem.className = value; |
| 1247 | + |
| 1248 | + } else { |
| 1249 | + var className = " " + elem.className + " ", setClass = elem.className; |
| 1250 | + for ( var c = 0, cl = classNames.length; c < cl; c++ ) { |
| 1251 | + if ( className.indexOf( " " + classNames[c] + " " ) < 0 ) { |
| 1252 | + setClass += " " + classNames[c]; |
| 1253 | + } |
| 1254 | + } |
| 1255 | + elem.className = jQuery.trim( setClass ); |
| 1256 | + } |
| 1257 | + } |
| 1258 | + } |
| 1259 | + } |
| 1260 | + |
| 1261 | + return this; |
| 1262 | + }, |
| 1263 | + |
| 1264 | + removeClass: function( value ) { |
| 1265 | + if ( jQuery.isFunction(value) ) { |
| 1266 | + return this.each(function(i) { |
| 1267 | + var self = jQuery(this); |
| 1268 | + self.removeClass( value.call(this, i, self.attr("class")) ); |
| 1269 | + }); |
| 1270 | + } |
| 1271 | + |
| 1272 | + if ( (value && typeof value === "string") || value === undefined ) { |
| 1273 | + var classNames = (value || "").split(rspace); |
| 1274 | + |
| 1275 | + for ( var i = 0, l = this.length; i < l; i++ ) { |
| 1276 | + var elem = this[i]; |
| 1277 | + |
| 1278 | + if ( elem.nodeType === 1 && elem.className ) { |
| 1279 | + if ( value ) { |
| 1280 | + var className = (" " + elem.className + " ").replace(rclass, " "); |
| 1281 | + for ( var c = 0, cl = classNames.length; c < cl; c++ ) { |
| 1282 | + className = className.replace(" " + classNames[c] + " ", " "); |
| 1283 | + } |
| 1284 | + elem.className = jQuery.trim( className ); |
| 1285 | + |
| 1286 | + } else { |
| 1287 | + elem.className = ""; |
| 1288 | + } |
| 1289 | + } |
| 1290 | + } |
| 1291 | + } |
| 1292 | + |
| 1293 | + return this; |
| 1294 | + }, |
| 1295 | + |
| 1296 | + toggleClass: function( value, stateVal ) { |
| 1297 | + var type = typeof value, isBool = typeof stateVal === "boolean"; |
| 1298 | + |
| 1299 | + if ( jQuery.isFunction( value ) ) { |
| 1300 | + return this.each(function(i) { |
| 1301 | + var self = jQuery(this); |
| 1302 | + self.toggleClass( value.call(this, i, self.attr("class"), stateVal), stateVal ); |
| 1303 | + }); |
| 1304 | + } |
| 1305 | + |
| 1306 | + return this.each(function() { |
| 1307 | + if ( type === "string" ) { |
| 1308 | + // toggle individual class names |
| 1309 | + var className, i = 0, self = jQuery(this), |
| 1310 | + state = stateVal, |
| 1311 | + classNames = value.split( rspace ); |
| 1312 | + |
| 1313 | + while ( (className = classNames[ i++ ]) ) { |
| 1314 | + // check each className given, space seperated list |
| 1315 | + state = isBool ? state : !self.hasClass( className ); |
| 1316 | + self[ state ? "addClass" : "removeClass" ]( className ); |
| 1317 | + } |
| 1318 | + |
| 1319 | + } else if ( type === "undefined" || type === "boolean" ) { |
| 1320 | + if ( this.className ) { |
| 1321 | + // store className if set |
| 1322 | + jQuery.data( this, "__className__", this.className ); |
| 1323 | + } |
| 1324 | + |
| 1325 | + // toggle whole className |
| 1326 | + this.className = this.className || value === false ? "" : jQuery.data( this, "__className__" ) || ""; |
| 1327 | + } |
| 1328 | + }); |
| 1329 | + }, |
| 1330 | + |
| 1331 | + hasClass: function( selector ) { |
| 1332 | + var className = " " + selector + " "; |
| 1333 | + for ( var i = 0, l = this.length; i < l; i++ ) { |
| 1334 | + if ( (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) { |
| 1335 | + return true; |
| 1336 | + } |
| 1337 | + } |
| 1338 | + |
| 1339 | + return false; |
| 1340 | + }, |
| 1341 | + |
| 1342 | + val: function( value ) { |
| 1343 | + if ( value === undefined ) { |
| 1344 | + var elem = this[0]; |
| 1345 | + |
| 1346 | + if ( elem ) { |
| 1347 | + if ( jQuery.nodeName( elem, "option" ) ) { |
| 1348 | + return (elem.attributes.value || {}).specified ? elem.value : elem.text; |
| 1349 | + } |
| 1350 | + |
| 1351 | + // We need to handle select boxes special |
| 1352 | + if ( jQuery.nodeName( elem, "select" ) ) { |
| 1353 | + var index = elem.selectedIndex, |
| 1354 | + values = [], |
| 1355 | + options = elem.options, |
| 1356 | + one = elem.type === "select-one"; |
| 1357 | + |
| 1358 | + // Nothing was selected |
| 1359 | + if ( index < 0 ) { |
| 1360 | + return null; |
| 1361 | + } |
| 1362 | + |
| 1363 | + // Loop through all the selected options |
| 1364 | + for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) { |
| 1365 | + var option = options[ i ]; |
| 1366 | + |
| 1367 | + if ( option.selected ) { |
| 1368 | + // Get the specifc value for the option |
| 1369 | + value = jQuery(option).val(); |
| 1370 | + |
| 1371 | + // We don't need an array for one selects |
| 1372 | + if ( one ) { |
| 1373 | + return value; |
| 1374 | + } |
| 1375 | + |
| 1376 | + // Multi-Selects return an array |
| 1377 | + values.push( value ); |
| 1378 | + } |
| 1379 | + } |
| 1380 | + |
| 1381 | + return values; |
| 1382 | + } |
| 1383 | + |
| 1384 | + // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified |
| 1385 | + if ( rradiocheck.test( elem.type ) && !jQuery.support.checkOn ) { |
| 1386 | + return elem.getAttribute("value") === null ? "on" : elem.value; |
| 1387 | + } |
| 1388 | + |
| 1389 | + |
| 1390 | + // Everything else, we just grab the value |
| 1391 | + return (elem.value || "").replace(rreturn, ""); |
| 1392 | + |
| 1393 | + } |
| 1394 | + |
| 1395 | + return undefined; |
| 1396 | + } |
| 1397 | + |
| 1398 | + var isFunction = jQuery.isFunction(value); |
| 1399 | + |
| 1400 | + return this.each(function(i) { |
| 1401 | + var self = jQuery(this), val = value; |
| 1402 | + |
| 1403 | + if ( this.nodeType !== 1 ) { |
| 1404 | + return; |
| 1405 | + } |
| 1406 | + |
| 1407 | + if ( isFunction ) { |
| 1408 | + val = value.call(this, i, self.val()); |
| 1409 | + } |
| 1410 | + |
| 1411 | + // Typecast each time if the value is a Function and the appended |
| 1412 | + // value is therefore different each time. |
| 1413 | + if ( typeof val === "number" ) { |
| 1414 | + val += ""; |
| 1415 | + } |
| 1416 | + |
| 1417 | + if ( jQuery.isArray(val) && rradiocheck.test( this.type ) ) { |
| 1418 | + this.checked = jQuery.inArray( self.val(), val ) >= 0; |
| 1419 | + |
| 1420 | + } else if ( jQuery.nodeName( this, "select" ) ) { |
| 1421 | + var values = jQuery.makeArray(val); |
| 1422 | + |
| 1423 | + jQuery( "option", this ).each(function() { |
| 1424 | + this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0; |
| 1425 | + }); |
| 1426 | + |
| 1427 | + if ( !values.length ) { |
| 1428 | + this.selectedIndex = -1; |
| 1429 | + } |
| 1430 | + |
| 1431 | + } else { |
| 1432 | + this.value = val; |
| 1433 | + } |
| 1434 | + }); |
| 1435 | + } |
| 1436 | +}); |
| 1437 | + |
| 1438 | +jQuery.extend({ |
| 1439 | + attrFn: { |
| 1440 | + val: true, |
| 1441 | + css: true, |
| 1442 | + html: true, |
| 1443 | + text: true, |
| 1444 | + data: true, |
| 1445 | + width: true, |
| 1446 | + height: true, |
| 1447 | + offset: true |
| 1448 | + }, |
| 1449 | + |
| 1450 | + attr: function( elem, name, value, pass ) { |
| 1451 | + // don't set attributes on text and comment nodes |
| 1452 | + if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) { |
| 1453 | + return undefined; |
| 1454 | + } |
| 1455 | + |
| 1456 | + if ( pass && name in jQuery.attrFn ) { |
| 1457 | + return jQuery(elem)[name](value); |
| 1458 | + } |
| 1459 | + |
| 1460 | + var notxml = elem.nodeType !== 1 || !jQuery.isXMLDoc( elem ), |
| 1461 | + // Whether we are setting (or getting) |
| 1462 | + set = value !== undefined; |
| 1463 | + |
| 1464 | + // Try to normalize/fix the name |
| 1465 | + name = notxml && jQuery.props[ name ] || name; |
| 1466 | + |
| 1467 | + // Only do all the following if this is a node (faster for style) |
| 1468 | + if ( elem.nodeType === 1 ) { |
| 1469 | + // These attributes require special treatment |
| 1470 | + var special = rspecialurl.test( name ); |
| 1471 | + |
| 1472 | + // Safari mis-reports the default selected property of an option |
| 1473 | + // Accessing the parent's selectedIndex property fixes it |
| 1474 | + if ( name === "selected" && !jQuery.support.optSelected ) { |
| 1475 | + var parent = elem.parentNode; |
| 1476 | + if ( parent ) { |
| 1477 | + parent.selectedIndex; |
| 1478 | + |
| 1479 | + // Make sure that it also works with optgroups, see #5701 |
| 1480 | + if ( parent.parentNode ) { |
| 1481 | + parent.parentNode.selectedIndex; |
| 1482 | + } |
| 1483 | + } |
| 1484 | + } |
| 1485 | + |
| 1486 | + // If applicable, access the attribute via the DOM 0 way |
| 1487 | + if ( name in elem && notxml && !special ) { |
| 1488 | + if ( set ) { |
| 1489 | + // We can't allow the type property to be changed (since it causes problems in IE) |
| 1490 | + if ( name === "type" && rtype.test( elem.nodeName ) && elem.parentNode ) { |
| 1491 | + jQuery.error( "type property can't be changed" ); |
| 1492 | + } |
| 1493 | + |
| 1494 | + elem[ name ] = value; |
| 1495 | + } |
| 1496 | + |
| 1497 | + // browsers index elements by id/name on forms, give priority to attributes. |
| 1498 | + if ( jQuery.nodeName( elem, "form" ) && elem.getAttributeNode(name) ) { |
| 1499 | + return elem.getAttributeNode( name ).nodeValue; |
| 1500 | + } |
| 1501 | + |
| 1502 | + // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set |
| 1503 | + // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ |
| 1504 | + if ( name === "tabIndex" ) { |
| 1505 | + var attributeNode = elem.getAttributeNode( "tabIndex" ); |
| 1506 | + |
| 1507 | + return attributeNode && attributeNode.specified ? |
| 1508 | + attributeNode.value : |
| 1509 | + rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ? |
| 1510 | + 0 : |
| 1511 | + undefined; |
| 1512 | + } |
| 1513 | + |
| 1514 | + return elem[ name ]; |
| 1515 | + } |
| 1516 | + |
| 1517 | + if ( !jQuery.support.style && notxml && name === "style" ) { |
| 1518 | + if ( set ) { |
| 1519 | + elem.style.cssText = "" + value; |
| 1520 | + } |
| 1521 | + |
| 1522 | + return elem.style.cssText; |
| 1523 | + } |
| 1524 | + |
| 1525 | + if ( set ) { |
| 1526 | + // convert the value to a string (all browsers do this but IE) see #1070 |
| 1527 | + elem.setAttribute( name, "" + value ); |
| 1528 | + } |
| 1529 | + |
| 1530 | + var attr = !jQuery.support.hrefNormalized && notxml && special ? |
| 1531 | + // Some attributes require a special call on IE |
| 1532 | + elem.getAttribute( name, 2 ) : |
| 1533 | + elem.getAttribute( name ); |
| 1534 | + |
| 1535 | + // Non-existent attributes return null, we normalize to undefined |
| 1536 | + return attr === null ? undefined : attr; |
| 1537 | + } |
| 1538 | + |
| 1539 | + // elem is actually elem.style ... set the style |
| 1540 | + // Using attr for specific style information is now deprecated. Use style instead. |
| 1541 | + return jQuery.style( elem, name, value ); |
| 1542 | + } |
| 1543 | +}); |
| 1544 | +var rnamespaces = /\.(.*)$/, |
| 1545 | + fcleanup = function( nm ) { |
| 1546 | + return nm.replace(/[^\w\s\.\|`]/g, function( ch ) { |
| 1547 | + return "\\" + ch; |
| 1548 | + }); |
| 1549 | + }; |
| 1550 | + |
| 1551 | +/* |
| 1552 | + * A number of helper functions used for managing events. |
| 1553 | + * Many of the ideas behind this code originated from |
| 1554 | + * Dean Edwards' addEvent library. |
| 1555 | + */ |
| 1556 | +jQuery.event = { |
| 1557 | + |
| 1558 | + // Bind an event to an element |
| 1559 | + // Original by Dean Edwards |
| 1560 | + add: function( elem, types, handler, data ) { |
| 1561 | + if ( elem.nodeType === 3 || elem.nodeType === 8 ) { |
| 1562 | + return; |
| 1563 | + } |
| 1564 | + |
| 1565 | + // For whatever reason, IE has trouble passing the window object |
| 1566 | + // around, causing it to be cloned in the process |
| 1567 | + if ( elem.setInterval && ( elem !== window && !elem.frameElement ) ) { |
| 1568 | + elem = window; |
| 1569 | + } |
| 1570 | + |
| 1571 | + var handleObjIn, handleObj; |
| 1572 | + |
| 1573 | + if ( handler.handler ) { |
| 1574 | + handleObjIn = handler; |
| 1575 | + handler = handleObjIn.handler; |
| 1576 | + } |
| 1577 | + |
| 1578 | + // Make sure that the function being executed has a unique ID |
| 1579 | + if ( !handler.guid ) { |
| 1580 | + handler.guid = jQuery.guid++; |
| 1581 | + } |
| 1582 | + |
| 1583 | + // Init the element's event structure |
| 1584 | + var elemData = jQuery.data( elem ); |
| 1585 | + |
| 1586 | + // If no elemData is found then we must be trying to bind to one of the |
| 1587 | + // banned noData elements |
| 1588 | + if ( !elemData ) { |
| 1589 | + return; |
| 1590 | + } |
| 1591 | + |
| 1592 | + var events = elemData.events = elemData.events || {}, |
| 1593 | + eventHandle = elemData.handle, eventHandle; |
| 1594 | + |
| 1595 | + if ( !eventHandle ) { |
| 1596 | + elemData.handle = eventHandle = function() { |
| 1597 | + // Handle the second event of a trigger and when |
| 1598 | + // an event is called after a page has unloaded |
| 1599 | + return typeof jQuery !== "undefined" && !jQuery.event.triggered ? |
| 1600 | + jQuery.event.handle.apply( eventHandle.elem, arguments ) : |
| 1601 | + undefined; |
| 1602 | + }; |
| 1603 | + } |
| 1604 | + |
| 1605 | + // Add elem as a property of the handle function |
| 1606 | + // This is to prevent a memory leak with non-native events in IE. |
| 1607 | + eventHandle.elem = elem; |
| 1608 | + |
| 1609 | + // Handle multiple events separated by a space |
| 1610 | + // jQuery(...).bind("mouseover mouseout", fn); |
| 1611 | + types = types.split(" "); |
| 1612 | + |
| 1613 | + var type, i = 0, namespaces; |
| 1614 | + |
| 1615 | + while ( (type = types[ i++ ]) ) { |
| 1616 | + handleObj = handleObjIn ? |
| 1617 | + jQuery.extend({}, handleObjIn) : |
| 1618 | + { handler: handler, data: data }; |
| 1619 | + |
| 1620 | + // Namespaced event handlers |
| 1621 | + if ( type.indexOf(".") > -1 ) { |
| 1622 | + namespaces = type.split("."); |
| 1623 | + type = namespaces.shift(); |
| 1624 | + handleObj.namespace = namespaces.slice(0).sort().join("."); |
| 1625 | + |
| 1626 | + } else { |
| 1627 | + namespaces = []; |
| 1628 | + handleObj.namespace = ""; |
| 1629 | + } |
| 1630 | + |
| 1631 | + handleObj.type = type; |
| 1632 | + handleObj.guid = handler.guid; |
| 1633 | + |
| 1634 | + // Get the current list of functions bound to this event |
| 1635 | + var handlers = events[ type ], |
| 1636 | + special = jQuery.event.special[ type ] || {}; |
| 1637 | + |
| 1638 | + // Init the event handler queue |
| 1639 | + if ( !handlers ) { |
| 1640 | + handlers = events[ type ] = []; |
| 1641 | + |
| 1642 | + // Check for a special event handler |
| 1643 | + // Only use addEventListener/attachEvent if the special |
| 1644 | + // events handler returns false |
| 1645 | + if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) { |
| 1646 | + // Bind the global event handler to the element |
| 1647 | + if ( elem.addEventListener ) { |
| 1648 | + elem.addEventListener( type, eventHandle, false ); |
| 1649 | + |
| 1650 | + } else if ( elem.attachEvent ) { |
| 1651 | + elem.attachEvent( "on" + type, eventHandle ); |
| 1652 | + } |
| 1653 | + } |
| 1654 | + } |
| 1655 | + |
| 1656 | + if ( special.add ) { |
| 1657 | + special.add.call( elem, handleObj ); |
| 1658 | + |
| 1659 | + if ( !handleObj.handler.guid ) { |
| 1660 | + handleObj.handler.guid = handler.guid; |
| 1661 | + } |
| 1662 | + } |
| 1663 | + |
| 1664 | + // Add the function to the element's handler list |
| 1665 | + handlers.push( handleObj ); |
| 1666 | + |
| 1667 | + // Keep track of which events have been used, for global triggering |
| 1668 | + jQuery.event.global[ type ] = true; |
| 1669 | + } |
| 1670 | + |
| 1671 | + // Nullify elem to prevent memory leaks in IE |
| 1672 | + elem = null; |
| 1673 | + }, |
| 1674 | + |
| 1675 | + global: {}, |
| 1676 | + |
| 1677 | + // Detach an event or set of events from an element |
| 1678 | + remove: function( elem, types, handler, pos ) { |
| 1679 | + // don't do events on text and comment nodes |
| 1680 | + if ( elem.nodeType === 3 || elem.nodeType === 8 ) { |
| 1681 | + return; |
| 1682 | + } |
| 1683 | + |
| 1684 | + var ret, type, fn, i = 0, all, namespaces, namespace, special, eventType, handleObj, origType, |
| 1685 | + elemData = jQuery.data( elem ), |
| 1686 | + events = elemData && elemData.events; |
| 1687 | + |
| 1688 | + if ( !elemData || !events ) { |
| 1689 | + return; |
| 1690 | + } |
| 1691 | + |
| 1692 | + // types is actually an event object here |
| 1693 | + if ( types && types.type ) { |
| 1694 | + handler = types.handler; |
| 1695 | + types = types.type; |
| 1696 | + } |
| 1697 | + |
| 1698 | + // Unbind all events for the element |
| 1699 | + if ( !types || typeof types === "string" && types.charAt(0) === "." ) { |
| 1700 | + types = types || ""; |
| 1701 | + |
| 1702 | + for ( type in events ) { |
| 1703 | + jQuery.event.remove( elem, type + types ); |
| 1704 | + } |
| 1705 | + |
| 1706 | + return; |
| 1707 | + } |
| 1708 | + |
| 1709 | + // Handle multiple events separated by a space |
| 1710 | + // jQuery(...).unbind("mouseover mouseout", fn); |
| 1711 | + types = types.split(" "); |
| 1712 | + |
| 1713 | + while ( (type = types[ i++ ]) ) { |
| 1714 | + origType = type; |
| 1715 | + handleObj = null; |
| 1716 | + all = type.indexOf(".") < 0; |
| 1717 | + namespaces = []; |
| 1718 | + |
| 1719 | + if ( !all ) { |
| 1720 | + // Namespaced event handlers |
| 1721 | + namespaces = type.split("."); |
| 1722 | + type = namespaces.shift(); |
| 1723 | + |
| 1724 | + namespace = new RegExp("(^|\\.)" + |
| 1725 | + jQuery.map( namespaces.slice(0).sort(), fcleanup ).join("\\.(?:.*\\.)?") + "(\\.|$)") |
| 1726 | + } |
| 1727 | + |
| 1728 | + eventType = events[ type ]; |
| 1729 | + |
| 1730 | + if ( !eventType ) { |
| 1731 | + continue; |
| 1732 | + } |
| 1733 | + |
| 1734 | + if ( !handler ) { |
| 1735 | + for ( var j = 0; j < eventType.length; j++ ) { |
| 1736 | + handleObj = eventType[ j ]; |
| 1737 | + |
| 1738 | + if ( all || namespace.test( handleObj.namespace ) ) { |
| 1739 | + jQuery.event.remove( elem, origType, handleObj.handler, j ); |
| 1740 | + eventType.splice( j--, 1 ); |
| 1741 | + } |
| 1742 | + } |
| 1743 | + |
| 1744 | + continue; |
| 1745 | + } |
| 1746 | + |
| 1747 | + special = jQuery.event.special[ type ] || {}; |
| 1748 | + |
| 1749 | + for ( var j = pos || 0; j < eventType.length; j++ ) { |
| 1750 | + handleObj = eventType[ j ]; |
| 1751 | + |
| 1752 | + if ( handler.guid === handleObj.guid ) { |
| 1753 | + // remove the given handler for the given type |
| 1754 | + if ( all || namespace.test( handleObj.namespace ) ) { |
| 1755 | + if ( pos == null ) { |
| 1756 | + eventType.splice( j--, 1 ); |
| 1757 | + } |
| 1758 | + |
| 1759 | + if ( special.remove ) { |
| 1760 | + special.remove.call( elem, handleObj ); |
| 1761 | + } |
| 1762 | + } |
| 1763 | + |
| 1764 | + if ( pos != null ) { |
| 1765 | + break; |
| 1766 | + } |
| 1767 | + } |
| 1768 | + } |
| 1769 | + |
| 1770 | + // remove generic event handler if no more handlers exist |
| 1771 | + if ( eventType.length === 0 || pos != null && eventType.length === 1 ) { |
| 1772 | + if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) { |
| 1773 | + removeEvent( elem, type, elemData.handle ); |
| 1774 | + } |
| 1775 | + |
| 1776 | + ret = null; |
| 1777 | + delete events[ type ]; |
| 1778 | + } |
| 1779 | + } |
| 1780 | + |
| 1781 | + // Remove the expando if it's no longer used |
| 1782 | + if ( jQuery.isEmptyObject( events ) ) { |
| 1783 | + var handle = elemData.handle; |
| 1784 | + if ( handle ) { |
| 1785 | + handle.elem = null; |
| 1786 | + } |
| 1787 | + |
| 1788 | + delete elemData.events; |
| 1789 | + delete elemData.handle; |
| 1790 | + |
| 1791 | + if ( jQuery.isEmptyObject( elemData ) ) { |
| 1792 | + jQuery.removeData( elem ); |
| 1793 | + } |
| 1794 | + } |
| 1795 | + }, |
| 1796 | + |
| 1797 | + // bubbling is internal |
| 1798 | + trigger: function( event, data, elem /*, bubbling */ ) { |
| 1799 | + // Event object or event type |
| 1800 | + var type = event.type || event, |
| 1801 | + bubbling = arguments[3]; |
| 1802 | + |
| 1803 | + if ( !bubbling ) { |
| 1804 | + event = typeof event === "object" ? |
| 1805 | + // jQuery.Event object |
| 1806 | + event[expando] ? event : |
| 1807 | + // Object literal |
| 1808 | + jQuery.extend( jQuery.Event(type), event ) : |
| 1809 | + // Just the event type (string) |
| 1810 | + jQuery.Event(type); |
| 1811 | + |
| 1812 | + if ( type.indexOf("!") >= 0 ) { |
| 1813 | + event.type = type = type.slice(0, -1); |
| 1814 | + event.exclusive = true; |
| 1815 | + } |
| 1816 | + |
| 1817 | + // Handle a global trigger |
| 1818 | + if ( !elem ) { |
| 1819 | + // Don't bubble custom events when global (to avoid too much overhead) |
| 1820 | + event.stopPropagation(); |
| 1821 | + |
| 1822 | + // Only trigger if we've ever bound an event for it |
| 1823 | + if ( jQuery.event.global[ type ] ) { |
| 1824 | + jQuery.each( jQuery.cache, function() { |
| 1825 | + if ( this.events && this.events[type] ) { |
| 1826 | + jQuery.event.trigger( event, data, this.handle.elem ); |
| 1827 | + } |
| 1828 | + }); |
| 1829 | + } |
| 1830 | + } |
| 1831 | + |
| 1832 | + // Handle triggering a single element |
| 1833 | + |
| 1834 | + // don't do events on text and comment nodes |
| 1835 | + if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) { |
| 1836 | + return undefined; |
| 1837 | + } |
| 1838 | + |
| 1839 | + // Clean up in case it is reused |
| 1840 | + event.result = undefined; |
| 1841 | + event.target = elem; |
| 1842 | + |
| 1843 | + // Clone the incoming data, if any |
| 1844 | + data = jQuery.makeArray( data ); |
| 1845 | + data.unshift( event ); |
| 1846 | + } |
| 1847 | + |
| 1848 | + event.currentTarget = elem; |
| 1849 | + |
| 1850 | + // Trigger the event, it is assumed that "handle" is a function |
| 1851 | + var handle = jQuery.data( elem, "handle" ); |
| 1852 | + if ( handle ) { |
| 1853 | + handle.apply( elem, data ); |
| 1854 | + } |
| 1855 | + |
| 1856 | + var parent = elem.parentNode || elem.ownerDocument; |
| 1857 | + |
| 1858 | + // Trigger an inline bound script |
| 1859 | + try { |
| 1860 | + if ( !(elem && elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()]) ) { |
| 1861 | + if ( elem[ "on" + type ] && elem[ "on" + type ].apply( elem, data ) === false ) { |
| 1862 | + event.result = false; |
| 1863 | + } |
| 1864 | + } |
| 1865 | + |
| 1866 | + // prevent IE from throwing an error for some elements with some event types, see #3533 |
| 1867 | + } catch (e) {} |
| 1868 | + |
| 1869 | + if ( !event.isPropagationStopped() && parent ) { |
| 1870 | + jQuery.event.trigger( event, data, parent, true ); |
| 1871 | + |
| 1872 | + } else if ( !event.isDefaultPrevented() ) { |
| 1873 | + var target = event.target, old, |
| 1874 | + isClick = jQuery.nodeName(target, "a") && type === "click", |
| 1875 | + special = jQuery.event.special[ type ] || {}; |
| 1876 | + |
| 1877 | + if ( (!special._default || special._default.call( elem, event ) === false) && |
| 1878 | + !isClick && !(target && target.nodeName && jQuery.noData[target.nodeName.toLowerCase()]) ) { |
| 1879 | + |
| 1880 | + try { |
| 1881 | + if ( target[ type ] ) { |
| 1882 | + // Make sure that we don't accidentally re-trigger the onFOO events |
| 1883 | + old = target[ "on" + type ]; |
| 1884 | + |
| 1885 | + if ( old ) { |
| 1886 | + target[ "on" + type ] = null; |
| 1887 | + } |
| 1888 | + |
| 1889 | + jQuery.event.triggered = true; |
| 1890 | + target[ type ](); |
| 1891 | + } |
| 1892 | + |
| 1893 | + // prevent IE from throwing an error for some elements with some event types, see #3533 |
| 1894 | + } catch (e) {} |
| 1895 | + |
| 1896 | + if ( old ) { |
| 1897 | + target[ "on" + type ] = old; |
| 1898 | + } |
| 1899 | + |
| 1900 | + jQuery.event.triggered = false; |
| 1901 | + } |
| 1902 | + } |
| 1903 | + }, |
| 1904 | + |
| 1905 | + handle: function( event ) { |
| 1906 | + var all, handlers, namespaces, namespace, events; |
| 1907 | + |
| 1908 | + event = arguments[0] = jQuery.event.fix( event || window.event ); |
| 1909 | + event.currentTarget = this; |
| 1910 | + |
| 1911 | + // Namespaced event handlers |
| 1912 | + all = event.type.indexOf(".") < 0 && !event.exclusive; |
| 1913 | + |
| 1914 | + if ( !all ) { |
| 1915 | + namespaces = event.type.split("."); |
| 1916 | + event.type = namespaces.shift(); |
| 1917 | + namespace = new RegExp("(^|\\.)" + namespaces.slice(0).sort().join("\\.(?:.*\\.)?") + "(\\.|$)"); |
| 1918 | + } |
| 1919 | + |
| 1920 | + var events = jQuery.data(this, "events"), handlers = events[ event.type ]; |
| 1921 | + |
| 1922 | + if ( events && handlers ) { |
| 1923 | + // Clone the handlers to prevent manipulation |
| 1924 | + handlers = handlers.slice(0); |
| 1925 | + |
| 1926 | + for ( var j = 0, l = handlers.length; j < l; j++ ) { |
| 1927 | + var handleObj = handlers[ j ]; |
| 1928 | + |
| 1929 | + // Filter the functions by class |
| 1930 | + if ( all || namespace.test( handleObj.namespace ) ) { |
| 1931 | + // Pass in a reference to the handler function itself |
| 1932 | + // So that we can later remove it |
| 1933 | + event.handler = handleObj.handler; |
| 1934 | + event.data = handleObj.data; |
| 1935 | + event.handleObj = handleObj; |
| 1936 | + |
| 1937 | + var ret = handleObj.handler.apply( this, arguments ); |
| 1938 | + |
| 1939 | + if ( ret !== undefined ) { |
| 1940 | + event.result = ret; |
| 1941 | + if ( ret === false ) { |
| 1942 | + event.preventDefault(); |
| 1943 | + event.stopPropagation(); |
| 1944 | + } |
| 1945 | + } |
| 1946 | + |
| 1947 | + if ( event.isImmediatePropagationStopped() ) { |
| 1948 | + break; |
| 1949 | + } |
| 1950 | + } |
| 1951 | + } |
| 1952 | + } |
| 1953 | + |
| 1954 | + return event.result; |
| 1955 | + }, |
| 1956 | + |
| 1957 | + props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "), |
| 1958 | + |
| 1959 | + fix: function( event ) { |
| 1960 | + if ( event[ expando ] ) { |
| 1961 | + return event; |
| 1962 | + } |
| 1963 | + |
| 1964 | + // store a copy of the original event object |
| 1965 | + // and "clone" to set read-only properties |
| 1966 | + var originalEvent = event; |
| 1967 | + event = jQuery.Event( originalEvent ); |
| 1968 | + |
| 1969 | + for ( var i = this.props.length, prop; i; ) { |
| 1970 | + prop = this.props[ --i ]; |
| 1971 | + event[ prop ] = originalEvent[ prop ]; |
| 1972 | + } |
| 1973 | + |
| 1974 | + // Fix target property, if necessary |
| 1975 | + if ( !event.target ) { |
| 1976 | + event.target = event.srcElement || document; // Fixes #1925 where srcElement might not be defined either |
| 1977 | + } |
| 1978 | + |
| 1979 | + // check if target is a textnode (safari) |
| 1980 | + if ( event.target.nodeType === 3 ) { |
| 1981 | + event.target = event.target.parentNode; |
| 1982 | + } |
| 1983 | + |
| 1984 | + // Add relatedTarget, if necessary |
| 1985 | + if ( !event.relatedTarget && event.fromElement ) { |
| 1986 | + event.relatedTarget = event.fromElement === event.target ? event.toElement : event.fromElement; |
| 1987 | + } |
| 1988 | + |
| 1989 | + // Calculate pageX/Y if missing and clientX/Y available |
| 1990 | + if ( event.pageX == null && event.clientX != null ) { |
| 1991 | + var doc = document.documentElement, body = document.body; |
| 1992 | + event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0); |
| 1993 | + event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0); |
| 1994 | + } |
| 1995 | + |
| 1996 | + // Add which for key events |
| 1997 | + if ( !event.which && ((event.charCode || event.charCode === 0) ? event.charCode : event.keyCode) ) { |
| 1998 | + event.which = event.charCode || event.keyCode; |
| 1999 | + } |
| 2000 | + |
| 2001 | + // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs) |
| 2002 | + if ( !event.metaKey && event.ctrlKey ) { |
| 2003 | + event.metaKey = event.ctrlKey; |
| 2004 | + } |
| 2005 | + |
| 2006 | + // Add which for click: 1 === left; 2 === middle; 3 === right |
| 2007 | + // Note: button is not normalized, so don't use it |
| 2008 | + if ( !event.which && event.button !== undefined ) { |
| 2009 | + event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) )); |
| 2010 | + } |
| 2011 | + |
| 2012 | + return event; |
| 2013 | + }, |
| 2014 | + |
| 2015 | + // Deprecated, use jQuery.guid instead |
| 2016 | + guid: 1E8, |
| 2017 | + |
| 2018 | + // Deprecated, use jQuery.proxy instead |
| 2019 | + proxy: jQuery.proxy, |
| 2020 | + |
| 2021 | + special: { |
| 2022 | + ready: { |
| 2023 | + // Make sure the ready event is setup |
| 2024 | + setup: jQuery.bindReady, |
| 2025 | + teardown: jQuery.noop |
| 2026 | + }, |
| 2027 | + |
| 2028 | + live: { |
| 2029 | + add: function( handleObj ) { |
| 2030 | + jQuery.event.add( this, handleObj.origType, jQuery.extend({}, handleObj, {handler: liveHandler}) ); |
| 2031 | + }, |
| 2032 | + |
| 2033 | + remove: function( handleObj ) { |
| 2034 | + var remove = true, |
| 2035 | + type = handleObj.origType.replace(rnamespaces, ""); |
| 2036 | + |
| 2037 | + jQuery.each( jQuery.data(this, "events").live || [], function() { |
| 2038 | + if ( type === this.origType.replace(rnamespaces, "") ) { |
| 2039 | + remove = false; |
| 2040 | + return false; |
| 2041 | + } |
| 2042 | + }); |
| 2043 | + |
| 2044 | + if ( remove ) { |
| 2045 | + jQuery.event.remove( this, handleObj.origType, liveHandler ); |
| 2046 | + } |
| 2047 | + } |
| 2048 | + |
| 2049 | + }, |
| 2050 | + |
| 2051 | + beforeunload: { |
| 2052 | + setup: function( data, namespaces, eventHandle ) { |
| 2053 | + // We only want to do this special case on windows |
| 2054 | + if ( this.setInterval ) { |
| 2055 | + this.onbeforeunload = eventHandle; |
| 2056 | + } |
| 2057 | + |
| 2058 | + return false; |
| 2059 | + }, |
| 2060 | + teardown: function( namespaces, eventHandle ) { |
| 2061 | + if ( this.onbeforeunload === eventHandle ) { |
| 2062 | + this.onbeforeunload = null; |
| 2063 | + } |
| 2064 | + } |
| 2065 | + } |
| 2066 | + } |
| 2067 | +}; |
| 2068 | + |
| 2069 | +var removeEvent = document.removeEventListener ? |
| 2070 | + function( elem, type, handle ) { |
| 2071 | + elem.removeEventListener( type, handle, false ); |
| 2072 | + } : |
| 2073 | + function( elem, type, handle ) { |
| 2074 | + elem.detachEvent( "on" + type, handle ); |
| 2075 | + }; |
| 2076 | + |
| 2077 | +jQuery.Event = function( src ) { |
| 2078 | + // Allow instantiation without the 'new' keyword |
| 2079 | + if ( !this.preventDefault ) { |
| 2080 | + return new jQuery.Event( src ); |
| 2081 | + } |
| 2082 | + |
| 2083 | + // Event object |
| 2084 | + if ( src && src.type ) { |
| 2085 | + this.originalEvent = src; |
| 2086 | + this.type = src.type; |
| 2087 | + // Event type |
| 2088 | + } else { |
| 2089 | + this.type = src; |
| 2090 | + } |
| 2091 | + |
| 2092 | + // timeStamp is buggy for some events on Firefox(#3843) |
| 2093 | + // So we won't rely on the native value |
| 2094 | + this.timeStamp = now(); |
| 2095 | + |
| 2096 | + // Mark it as fixed |
| 2097 | + this[ expando ] = true; |
| 2098 | +}; |
| 2099 | + |
| 2100 | +function returnFalse() { |
| 2101 | + return false; |
| 2102 | +} |
| 2103 | +function returnTrue() { |
| 2104 | + return true; |
| 2105 | +} |
| 2106 | + |
| 2107 | +// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding |
| 2108 | +// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html |
| 2109 | +jQuery.Event.prototype = { |
| 2110 | + preventDefault: function() { |
| 2111 | + this.isDefaultPrevented = returnTrue; |
| 2112 | + |
| 2113 | + var e = this.originalEvent; |
| 2114 | + if ( !e ) { |
| 2115 | + return; |
| 2116 | + } |
| 2117 | + |
| 2118 | + // if preventDefault exists run it on the original event |
| 2119 | + if ( e.preventDefault ) { |
| 2120 | + e.preventDefault(); |
| 2121 | + } |
| 2122 | + // otherwise set the returnValue property of the original event to false (IE) |
| 2123 | + e.returnValue = false; |
| 2124 | + }, |
| 2125 | + stopPropagation: function() { |
| 2126 | + this.isPropagationStopped = returnTrue; |
| 2127 | + |
| 2128 | + var e = this.originalEvent; |
| 2129 | + if ( !e ) { |
| 2130 | + return; |
| 2131 | + } |
| 2132 | + // if stopPropagation exists run it on the original event |
| 2133 | + if ( e.stopPropagation ) { |
| 2134 | + e.stopPropagation(); |
| 2135 | + } |
| 2136 | + // otherwise set the cancelBubble property of the original event to true (IE) |
| 2137 | + e.cancelBubble = true; |
| 2138 | + }, |
| 2139 | + stopImmediatePropagation: function() { |
| 2140 | + this.isImmediatePropagationStopped = returnTrue; |
| 2141 | + this.stopPropagation(); |
| 2142 | + }, |
| 2143 | + isDefaultPrevented: returnFalse, |
| 2144 | + isPropagationStopped: returnFalse, |
| 2145 | + isImmediatePropagationStopped: returnFalse |
| 2146 | +}; |
| 2147 | + |
| 2148 | +// Checks if an event happened on an element within another element |
| 2149 | +// Used in jQuery.event.special.mouseenter and mouseleave handlers |
| 2150 | +var withinElement = function( event ) { |
| 2151 | + // Check if mouse(over|out) are still within the same parent element |
| 2152 | + var parent = event.relatedTarget; |
| 2153 | + |
| 2154 | + // Firefox sometimes assigns relatedTarget a XUL element |
| 2155 | + // which we cannot access the parentNode property of |
| 2156 | + try { |
| 2157 | + // Traverse up the tree |
| 2158 | + while ( parent && parent !== this ) { |
| 2159 | + parent = parent.parentNode; |
| 2160 | + } |
| 2161 | + |
| 2162 | + if ( parent !== this ) { |
| 2163 | + // set the correct event type |
| 2164 | + event.type = event.data; |
| 2165 | + |
| 2166 | + // handle event if we actually just moused on to a non sub-element |
| 2167 | + jQuery.event.handle.apply( this, arguments ); |
| 2168 | + } |
| 2169 | + |
| 2170 | + // assuming we've left the element since we most likely mousedover a xul element |
| 2171 | + } catch(e) { } |
| 2172 | +}, |
| 2173 | + |
| 2174 | +// In case of event delegation, we only need to rename the event.type, |
| 2175 | +// liveHandler will take care of the rest. |
| 2176 | +delegate = function( event ) { |
| 2177 | + event.type = event.data; |
| 2178 | + jQuery.event.handle.apply( this, arguments ); |
| 2179 | +}; |
| 2180 | + |
| 2181 | +// Create mouseenter and mouseleave events |
| 2182 | +jQuery.each({ |
| 2183 | + mouseenter: "mouseover", |
| 2184 | + mouseleave: "mouseout" |
| 2185 | +}, function( orig, fix ) { |
| 2186 | + jQuery.event.special[ orig ] = { |
| 2187 | + setup: function( data ) { |
| 2188 | + jQuery.event.add( this, fix, data && data.selector ? delegate : withinElement, orig ); |
| 2189 | + }, |
| 2190 | + teardown: function( data ) { |
| 2191 | + jQuery.event.remove( this, fix, data && data.selector ? delegate : withinElement ); |
| 2192 | + } |
| 2193 | + }; |
| 2194 | +}); |
| 2195 | + |
| 2196 | +// submit delegation |
| 2197 | +if ( !jQuery.support.submitBubbles ) { |
| 2198 | + |
| 2199 | + jQuery.event.special.submit = { |
| 2200 | + setup: function( data, namespaces ) { |
| 2201 | + if ( this.nodeName.toLowerCase() !== "form" ) { |
| 2202 | + jQuery.event.add(this, "click.specialSubmit", function( e ) { |
| 2203 | + var elem = e.target, type = elem.type; |
| 2204 | + |
| 2205 | + if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) { |
| 2206 | + return trigger( "submit", this, arguments ); |
| 2207 | + } |
| 2208 | + }); |
| 2209 | + |
| 2210 | + jQuery.event.add(this, "keypress.specialSubmit", function( e ) { |
| 2211 | + var elem = e.target, type = elem.type; |
| 2212 | + |
| 2213 | + if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) { |
| 2214 | + return trigger( "submit", this, arguments ); |
| 2215 | + } |
| 2216 | + }); |
| 2217 | + |
| 2218 | + } else { |
| 2219 | + return false; |
| 2220 | + } |
| 2221 | + }, |
| 2222 | + |
| 2223 | + teardown: function( namespaces ) { |
| 2224 | + jQuery.event.remove( this, ".specialSubmit" ); |
| 2225 | + } |
| 2226 | + }; |
| 2227 | + |
| 2228 | +} |
| 2229 | + |
| 2230 | +// change delegation, happens here so we have bind. |
| 2231 | +if ( !jQuery.support.changeBubbles ) { |
| 2232 | + |
| 2233 | + var formElems = /textarea|input|select/i, |
| 2234 | + |
| 2235 | + changeFilters, |
| 2236 | + |
| 2237 | + getVal = function( elem ) { |
| 2238 | + var type = elem.type, val = elem.value; |
| 2239 | + |
| 2240 | + if ( type === "radio" || type === "checkbox" ) { |
| 2241 | + val = elem.checked; |
| 2242 | + |
| 2243 | + } else if ( type === "select-multiple" ) { |
| 2244 | + val = elem.selectedIndex > -1 ? |
| 2245 | + jQuery.map( elem.options, function( elem ) { |
| 2246 | + return elem.selected; |
| 2247 | + }).join("-") : |
| 2248 | + ""; |
| 2249 | + |
| 2250 | + } else if ( elem.nodeName.toLowerCase() === "select" ) { |
| 2251 | + val = elem.selectedIndex; |
| 2252 | + } |
| 2253 | + |
| 2254 | + return val; |
| 2255 | + }, |
| 2256 | + |
| 2257 | + testChange = function testChange( e ) { |
| 2258 | + var elem = e.target, data, val; |
| 2259 | + |
| 2260 | + if ( !formElems.test( elem.nodeName ) || elem.readOnly ) { |
| 2261 | + return; |
| 2262 | + } |
| 2263 | + |
| 2264 | + data = jQuery.data( elem, "_change_data" ); |
| 2265 | + val = getVal(elem); |
| 2266 | + |
| 2267 | + // the current data will be also retrieved by beforeactivate |
| 2268 | + if ( e.type !== "focusout" || elem.type !== "radio" ) { |
| 2269 | + jQuery.data( elem, "_change_data", val ); |
| 2270 | + } |
| 2271 | + |
| 2272 | + if ( data === undefined || val === data ) { |
| 2273 | + return; |
| 2274 | + } |
| 2275 | + |
| 2276 | + if ( data != null || val ) { |
| 2277 | + e.type = "change"; |
| 2278 | + return jQuery.event.trigger( e, arguments[1], elem ); |
| 2279 | + } |
| 2280 | + }; |
| 2281 | + |
| 2282 | + jQuery.event.special.change = { |
| 2283 | + filters: { |
| 2284 | + focusout: testChange, |
| 2285 | + |
| 2286 | + click: function( e ) { |
| 2287 | + var elem = e.target, type = elem.type; |
| 2288 | + |
| 2289 | + if ( type === "radio" || type === "checkbox" || elem.nodeName.toLowerCase() === "select" ) { |
| 2290 | + return testChange.call( this, e ); |
| 2291 | + } |
| 2292 | + }, |
| 2293 | + |
| 2294 | + // Change has to be called before submit |
| 2295 | + // Keydown will be called before keypress, which is used in submit-event delegation |
| 2296 | + keydown: function( e ) { |
| 2297 | + var elem = e.target, type = elem.type; |
| 2298 | + |
| 2299 | + if ( (e.keyCode === 13 && elem.nodeName.toLowerCase() !== "textarea") || |
| 2300 | + (e.keyCode === 32 && (type === "checkbox" || type === "radio")) || |
| 2301 | + type === "select-multiple" ) { |
| 2302 | + return testChange.call( this, e ); |
| 2303 | + } |
| 2304 | + }, |
| 2305 | + |
| 2306 | + // Beforeactivate happens also before the previous element is blurred |
| 2307 | + // with this event you can't trigger a change event, but you can store |
| 2308 | + // information/focus[in] is not needed anymore |
| 2309 | + beforeactivate: function( e ) { |
| 2310 | + var elem = e.target; |
| 2311 | + jQuery.data( elem, "_change_data", getVal(elem) ); |
| 2312 | + } |
| 2313 | + }, |
| 2314 | + |
| 2315 | + setup: function( data, namespaces ) { |
| 2316 | + if ( this.type === "file" ) { |
| 2317 | + return false; |
| 2318 | + } |
| 2319 | + |
| 2320 | + for ( var type in changeFilters ) { |
| 2321 | + jQuery.event.add( this, type + ".specialChange", changeFilters[type] ); |
| 2322 | + } |
| 2323 | + |
| 2324 | + return formElems.test( this.nodeName ); |
| 2325 | + }, |
| 2326 | + |
| 2327 | + teardown: function( namespaces ) { |
| 2328 | + jQuery.event.remove( this, ".specialChange" ); |
| 2329 | + |
| 2330 | + return formElems.test( this.nodeName ); |
| 2331 | + } |
| 2332 | + }; |
| 2333 | + |
| 2334 | + changeFilters = jQuery.event.special.change.filters; |
| 2335 | +} |
| 2336 | + |
| 2337 | +function trigger( type, elem, args ) { |
| 2338 | + args[0].type = type; |
| 2339 | + return jQuery.event.handle.apply( elem, args ); |
| 2340 | +} |
| 2341 | + |
| 2342 | +// Create "bubbling" focus and blur events |
| 2343 | +if ( document.addEventListener ) { |
| 2344 | + jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) { |
| 2345 | + jQuery.event.special[ fix ] = { |
| 2346 | + setup: function() { |
| 2347 | + this.addEventListener( orig, handler, true ); |
| 2348 | + }, |
| 2349 | + teardown: function() { |
| 2350 | + this.removeEventListener( orig, handler, true ); |
| 2351 | + } |
| 2352 | + }; |
| 2353 | + |
| 2354 | + function handler( e ) { |
| 2355 | + e = jQuery.event.fix( e ); |
| 2356 | + e.type = fix; |
| 2357 | + return jQuery.event.handle.call( this, e ); |
| 2358 | + } |
| 2359 | + }); |
| 2360 | +} |
| 2361 | + |
| 2362 | +jQuery.each(["bind", "one"], function( i, name ) { |
| 2363 | + jQuery.fn[ name ] = function( type, data, fn ) { |
| 2364 | + // Handle object literals |
| 2365 | + if ( typeof type === "object" ) { |
| 2366 | + for ( var key in type ) { |
| 2367 | + this[ name ](key, data, type[key], fn); |
| 2368 | + } |
| 2369 | + return this; |
| 2370 | + } |
| 2371 | + |
| 2372 | + if ( jQuery.isFunction( data ) ) { |
| 2373 | + fn = data; |
| 2374 | + data = undefined; |
| 2375 | + } |
| 2376 | + |
| 2377 | + var handler = name === "one" ? jQuery.proxy( fn, function( event ) { |
| 2378 | + jQuery( this ).unbind( event, handler ); |
| 2379 | + return fn.apply( this, arguments ); |
| 2380 | + }) : fn; |
| 2381 | + |
| 2382 | + if ( type === "unload" && name !== "one" ) { |
| 2383 | + this.one( type, data, fn ); |
| 2384 | + |
| 2385 | + } else { |
| 2386 | + for ( var i = 0, l = this.length; i < l; i++ ) { |
| 2387 | + jQuery.event.add( this[i], type, handler, data ); |
| 2388 | + } |
| 2389 | + } |
| 2390 | + |
| 2391 | + return this; |
| 2392 | + }; |
| 2393 | +}); |
| 2394 | + |
| 2395 | +jQuery.fn.extend({ |
| 2396 | + unbind: function( type, fn ) { |
| 2397 | + // Handle object literals |
| 2398 | + if ( typeof type === "object" && !type.preventDefault ) { |
| 2399 | + for ( var key in type ) { |
| 2400 | + this.unbind(key, type[key]); |
| 2401 | + } |
| 2402 | + |
| 2403 | + } else { |
| 2404 | + for ( var i = 0, l = this.length; i < l; i++ ) { |
| 2405 | + jQuery.event.remove( this[i], type, fn ); |
| 2406 | + } |
| 2407 | + } |
| 2408 | + |
| 2409 | + return this; |
| 2410 | + }, |
| 2411 | + |
| 2412 | + delegate: function( selector, types, data, fn ) { |
| 2413 | + return this.live( types, data, fn, selector ); |
| 2414 | + }, |
| 2415 | + |
| 2416 | + undelegate: function( selector, types, fn ) { |
| 2417 | + if ( arguments.length === 0 ) { |
| 2418 | + return this.unbind( "live" ); |
| 2419 | + |
| 2420 | + } else { |
| 2421 | + return this.die( types, null, fn, selector ); |
| 2422 | + } |
| 2423 | + }, |
| 2424 | + |
| 2425 | + trigger: function( type, data ) { |
| 2426 | + return this.each(function() { |
| 2427 | + jQuery.event.trigger( type, data, this ); |
| 2428 | + }); |
| 2429 | + }, |
| 2430 | + |
| 2431 | + triggerHandler: function( type, data ) { |
| 2432 | + if ( this[0] ) { |
| 2433 | + var event = jQuery.Event( type ); |
| 2434 | + event.preventDefault(); |
| 2435 | + event.stopPropagation(); |
| 2436 | + jQuery.event.trigger( event, data, this[0] ); |
| 2437 | + return event.result; |
| 2438 | + } |
| 2439 | + }, |
| 2440 | + |
| 2441 | + toggle: function( fn ) { |
| 2442 | + // Save reference to arguments for access in closure |
| 2443 | + var args = arguments, i = 1; |
| 2444 | + |
| 2445 | + // link all the functions, so any of them can unbind this click handler |
| 2446 | + while ( i < args.length ) { |
| 2447 | + jQuery.proxy( fn, args[ i++ ] ); |
| 2448 | + } |
| 2449 | + |
| 2450 | + return this.click( jQuery.proxy( fn, function( event ) { |
| 2451 | + // Figure out which function to execute |
| 2452 | + var lastToggle = ( jQuery.data( this, "lastToggle" + fn.guid ) || 0 ) % i; |
| 2453 | + jQuery.data( this, "lastToggle" + fn.guid, lastToggle + 1 ); |
| 2454 | + |
| 2455 | + // Make sure that clicks stop |
| 2456 | + event.preventDefault(); |
| 2457 | + |
| 2458 | + // and execute the function |
| 2459 | + return args[ lastToggle ].apply( this, arguments ) || false; |
| 2460 | + })); |
| 2461 | + }, |
| 2462 | + |
| 2463 | + hover: function( fnOver, fnOut ) { |
| 2464 | + return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); |
| 2465 | + } |
| 2466 | +}); |
| 2467 | + |
| 2468 | +var liveMap = { |
| 2469 | + focus: "focusin", |
| 2470 | + blur: "focusout", |
| 2471 | + mouseenter: "mouseover", |
| 2472 | + mouseleave: "mouseout" |
| 2473 | +}; |
| 2474 | + |
| 2475 | +jQuery.each(["live", "die"], function( i, name ) { |
| 2476 | + jQuery.fn[ name ] = function( types, data, fn, origSelector /* Internal Use Only */ ) { |
| 2477 | + var type, i = 0, match, namespaces, preType, |
| 2478 | + selector = origSelector || this.selector, |
| 2479 | + context = origSelector ? this : jQuery( this.context ); |
| 2480 | + |
| 2481 | + if ( jQuery.isFunction( data ) ) { |
| 2482 | + fn = data; |
| 2483 | + data = undefined; |
| 2484 | + } |
| 2485 | + |
| 2486 | + types = (types || "").split(" "); |
| 2487 | + |
| 2488 | + while ( (type = types[ i++ ]) != null ) { |
| 2489 | + match = rnamespaces.exec( type ); |
| 2490 | + namespaces = ""; |
| 2491 | + |
| 2492 | + if ( match ) { |
| 2493 | + namespaces = match[0]; |
| 2494 | + type = type.replace( rnamespaces, "" ); |
| 2495 | + } |
| 2496 | + |
| 2497 | + if ( type === "hover" ) { |
| 2498 | + types.push( "mouseenter" + namespaces, "mouseleave" + namespaces ); |
| 2499 | + continue; |
| 2500 | + } |
| 2501 | + |
| 2502 | + preType = type; |
| 2503 | + |
| 2504 | + if ( type === "focus" || type === "blur" ) { |
| 2505 | + types.push( liveMap[ type ] + namespaces ); |
| 2506 | + type = type + namespaces; |
| 2507 | + |
| 2508 | + } else { |
| 2509 | + type = (liveMap[ type ] || type) + namespaces; |
| 2510 | + } |
| 2511 | + |
| 2512 | + if ( name === "live" ) { |
| 2513 | + // bind live handler |
| 2514 | + context.each(function(){ |
| 2515 | + jQuery.event.add( this, liveConvert( type, selector ), |
| 2516 | + { data: data, selector: selector, handler: fn, origType: type, origHandler: fn, preType: preType } ); |
| 2517 | + }); |
| 2518 | + |
| 2519 | + } else { |
| 2520 | + // unbind live handler |
| 2521 | + context.unbind( liveConvert( type, selector ), fn ); |
| 2522 | + } |
| 2523 | + } |
| 2524 | + |
| 2525 | + return this; |
| 2526 | + } |
| 2527 | +}); |
| 2528 | + |
| 2529 | +function liveHandler( event ) { |
| 2530 | + var stop, elems = [], selectors = [], args = arguments, |
| 2531 | + related, match, handleObj, elem, j, i, l, data, |
| 2532 | + events = jQuery.data( this, "events" ); |
| 2533 | + |
| 2534 | + // Make sure we avoid non-left-click bubbling in Firefox (#3861) |
| 2535 | + if ( event.liveFired === this || !events || !events.live || event.button && event.type === "click" ) { |
| 2536 | + return; |
| 2537 | + } |
| 2538 | + |
| 2539 | + event.liveFired = this; |
| 2540 | + |
| 2541 | + var live = events.live.slice(0); |
| 2542 | + |
| 2543 | + for ( j = 0; j < live.length; j++ ) { |
| 2544 | + handleObj = live[j]; |
| 2545 | + |
| 2546 | + if ( handleObj.origType.replace( rnamespaces, "" ) === event.type ) { |
| 2547 | + selectors.push( handleObj.selector ); |
| 2548 | + |
| 2549 | + } else { |
| 2550 | + live.splice( j--, 1 ); |
| 2551 | + } |
| 2552 | + } |
| 2553 | + |
| 2554 | + match = jQuery( event.target ).closest( selectors, event.currentTarget ); |
| 2555 | + |
| 2556 | + for ( i = 0, l = match.length; i < l; i++ ) { |
| 2557 | + for ( j = 0; j < live.length; j++ ) { |
| 2558 | + handleObj = live[j]; |
| 2559 | + |
| 2560 | + if ( match[i].selector === handleObj.selector ) { |
| 2561 | + elem = match[i].elem; |
| 2562 | + related = null; |
| 2563 | + |
| 2564 | + // Those two events require additional checking |
| 2565 | + if ( handleObj.preType === "mouseenter" || handleObj.preType === "mouseleave" ) { |
| 2566 | + related = jQuery( event.relatedTarget ).closest( handleObj.selector )[0]; |
| 2567 | + } |
| 2568 | + |
| 2569 | + if ( !related || related !== elem ) { |
| 2570 | + elems.push({ elem: elem, handleObj: handleObj }); |
| 2571 | + } |
| 2572 | + } |
| 2573 | + } |
| 2574 | + } |
| 2575 | + |
| 2576 | + for ( i = 0, l = elems.length; i < l; i++ ) { |
| 2577 | + match = elems[i]; |
| 2578 | + event.currentTarget = match.elem; |
| 2579 | + event.data = match.handleObj.data; |
| 2580 | + event.handleObj = match.handleObj; |
| 2581 | + |
| 2582 | + if ( match.handleObj.origHandler.apply( match.elem, args ) === false ) { |
| 2583 | + stop = false; |
| 2584 | + break; |
| 2585 | + } |
| 2586 | + } |
| 2587 | + |
| 2588 | + return stop; |
| 2589 | +} |
| 2590 | + |
| 2591 | +function liveConvert( type, selector ) { |
| 2592 | + return "live." + (type && type !== "*" ? type + "." : "") + selector.replace(/\./g, "`").replace(/ /g, "&"); |
| 2593 | +} |
| 2594 | + |
| 2595 | +jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " + |
| 2596 | + "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + |
| 2597 | + "change select submit keydown keypress keyup error").split(" "), function( i, name ) { |
| 2598 | + |
| 2599 | + // Handle event binding |
| 2600 | + jQuery.fn[ name ] = function( fn ) { |
| 2601 | + return fn ? this.bind( name, fn ) : this.trigger( name ); |
| 2602 | + }; |
| 2603 | + |
| 2604 | + if ( jQuery.attrFn ) { |
| 2605 | + jQuery.attrFn[ name ] = true; |
| 2606 | + } |
| 2607 | +}); |
| 2608 | + |
| 2609 | +// Prevent memory leaks in IE |
| 2610 | +// Window isn't included so as not to unbind existing unload events |
| 2611 | +// More info: |
| 2612 | +// - http://isaacschlueter.com/2006/10/msie-memory-leaks/ |
| 2613 | +if ( window.attachEvent && !window.addEventListener ) { |
| 2614 | + window.attachEvent("onunload", function() { |
| 2615 | + for ( var id in jQuery.cache ) { |
| 2616 | + if ( jQuery.cache[ id ].handle ) { |
| 2617 | + // Try/Catch is to handle iframes being unloaded, see #4280 |
| 2618 | + try { |
| 2619 | + jQuery.event.remove( jQuery.cache[ id ].handle.elem ); |
| 2620 | + } catch(e) {} |
| 2621 | + } |
| 2622 | + } |
| 2623 | + }); |
| 2624 | +} |
| 2625 | +/*! |
| 2626 | + * Sizzle CSS Selector Engine - v1.0 |
| 2627 | + * Copyright 2009, The Dojo Foundation |
| 2628 | + * Released under the MIT, BSD, and GPL Licenses. |
| 2629 | + * More information: http://sizzlejs.com/ |
| 2630 | + */ |
| 2631 | +(function(){ |
| 2632 | + |
| 2633 | +var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g, |
| 2634 | + done = 0, |
| 2635 | + toString = Object.prototype.toString, |
| 2636 | + hasDuplicate = false, |
| 2637 | + baseHasDuplicate = true; |
| 2638 | + |
| 2639 | +// Here we check if the JavaScript engine is using some sort of |
| 2640 | +// optimization where it does not always call our comparision |
| 2641 | +// function. If that is the case, discard the hasDuplicate value. |
| 2642 | +// Thus far that includes Google Chrome. |
| 2643 | +[0, 0].sort(function(){ |
| 2644 | + baseHasDuplicate = false; |
| 2645 | + return 0; |
| 2646 | +}); |
| 2647 | + |
| 2648 | +var Sizzle = function(selector, context, results, seed) { |
| 2649 | + results = results || []; |
| 2650 | + var origContext = context = context || document; |
| 2651 | + |
| 2652 | + if ( context.nodeType !== 1 && context.nodeType !== 9 ) { |
| 2653 | + return []; |
| 2654 | + } |
| 2655 | + |
| 2656 | + if ( !selector || typeof selector !== "string" ) { |
| 2657 | + return results; |
| 2658 | + } |
| 2659 | + |
| 2660 | + var parts = [], m, set, checkSet, extra, prune = true, contextXML = isXML(context), |
| 2661 | + soFar = selector; |
| 2662 | + |
| 2663 | + // Reset the position of the chunker regexp (start from head) |
| 2664 | + while ( (chunker.exec(""), m = chunker.exec(soFar)) !== null ) { |
| 2665 | + soFar = m[3]; |
| 2666 | + |
| 2667 | + parts.push( m[1] ); |
| 2668 | + |
| 2669 | + if ( m[2] ) { |
| 2670 | + extra = m[3]; |
| 2671 | + break; |
| 2672 | + } |
| 2673 | + } |
| 2674 | + |
| 2675 | + if ( parts.length > 1 && origPOS.exec( selector ) ) { |
| 2676 | + if ( parts.length === 2 && Expr.relative[ parts[0] ] ) { |
| 2677 | + set = posProcess( parts[0] + parts[1], context ); |
| 2678 | + } else { |
| 2679 | + set = Expr.relative[ parts[0] ] ? |
| 2680 | + [ context ] : |
| 2681 | + Sizzle( parts.shift(), context ); |
| 2682 | + |
| 2683 | + while ( parts.length ) { |
| 2684 | + selector = parts.shift(); |
| 2685 | + |
| 2686 | + if ( Expr.relative[ selector ] ) { |
| 2687 | + selector += parts.shift(); |
| 2688 | + } |
| 2689 | + |
| 2690 | + set = posProcess( selector, set ); |
| 2691 | + } |
| 2692 | + } |
| 2693 | + } else { |
| 2694 | + // Take a shortcut and set the context if the root selector is an ID |
| 2695 | + // (but not if it'll be faster if the inner selector is an ID) |
| 2696 | + if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML && |
| 2697 | + Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) { |
| 2698 | + var ret = Sizzle.find( parts.shift(), context, contextXML ); |
| 2699 | + context = ret.expr ? Sizzle.filter( ret.expr, ret.set )[0] : ret.set[0]; |
| 2700 | + } |
| 2701 | + |
| 2702 | + if ( context ) { |
| 2703 | + var ret = seed ? |
| 2704 | + { expr: parts.pop(), set: makeArray(seed) } : |
| 2705 | + Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML ); |
| 2706 | + set = ret.expr ? Sizzle.filter( ret.expr, ret.set ) : ret.set; |
| 2707 | + |
| 2708 | + if ( parts.length > 0 ) { |
| 2709 | + checkSet = makeArray(set); |
| 2710 | + } else { |
| 2711 | + prune = false; |
| 2712 | + } |
| 2713 | + |
| 2714 | + while ( parts.length ) { |
| 2715 | + var cur = parts.pop(), pop = cur; |
| 2716 | + |
| 2717 | + if ( !Expr.relative[ cur ] ) { |
| 2718 | + cur = ""; |
| 2719 | + } else { |
| 2720 | + pop = parts.pop(); |
| 2721 | + } |
| 2722 | + |
| 2723 | + if ( pop == null ) { |
| 2724 | + pop = context; |
| 2725 | + } |
| 2726 | + |
| 2727 | + Expr.relative[ cur ]( checkSet, pop, contextXML ); |
| 2728 | + } |
| 2729 | + } else { |
| 2730 | + checkSet = parts = []; |
| 2731 | + } |
| 2732 | + } |
| 2733 | + |
| 2734 | + if ( !checkSet ) { |
| 2735 | + checkSet = set; |
| 2736 | + } |
| 2737 | + |
| 2738 | + if ( !checkSet ) { |
| 2739 | + Sizzle.error( cur || selector ); |
| 2740 | + } |
| 2741 | + |
| 2742 | + if ( toString.call(checkSet) === "[object Array]" ) { |
| 2743 | + if ( !prune ) { |
| 2744 | + results.push.apply( results, checkSet ); |
| 2745 | + } else if ( context && context.nodeType === 1 ) { |
| 2746 | + for ( var i = 0; checkSet[i] != null; i++ ) { |
| 2747 | + if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && contains(context, checkSet[i])) ) { |
| 2748 | + results.push( set[i] ); |
| 2749 | + } |
| 2750 | + } |
| 2751 | + } else { |
| 2752 | + for ( var i = 0; checkSet[i] != null; i++ ) { |
| 2753 | + if ( checkSet[i] && checkSet[i].nodeType === 1 ) { |
| 2754 | + results.push( set[i] ); |
| 2755 | + } |
| 2756 | + } |
| 2757 | + } |
| 2758 | + } else { |
| 2759 | + makeArray( checkSet, results ); |
| 2760 | + } |
| 2761 | + |
| 2762 | + if ( extra ) { |
| 2763 | + Sizzle( extra, origContext, results, seed ); |
| 2764 | + Sizzle.uniqueSort( results ); |
| 2765 | + } |
| 2766 | + |
| 2767 | + return results; |
| 2768 | +}; |
| 2769 | + |
| 2770 | +Sizzle.uniqueSort = function(results){ |
| 2771 | + if ( sortOrder ) { |
| 2772 | + hasDuplicate = baseHasDuplicate; |
| 2773 | + results.sort(sortOrder); |
| 2774 | + |
| 2775 | + if ( hasDuplicate ) { |
| 2776 | + for ( var i = 1; i < results.length; i++ ) { |
| 2777 | + if ( results[i] === results[i-1] ) { |
| 2778 | + results.splice(i--, 1); |
| 2779 | + } |
| 2780 | + } |
| 2781 | + } |
| 2782 | + } |
| 2783 | + |
| 2784 | + return results; |
| 2785 | +}; |
| 2786 | + |
| 2787 | +Sizzle.matches = function(expr, set){ |
| 2788 | + return Sizzle(expr, null, null, set); |
| 2789 | +}; |
| 2790 | + |
| 2791 | +Sizzle.find = function(expr, context, isXML){ |
| 2792 | + var set, match; |
| 2793 | + |
| 2794 | + if ( !expr ) { |
| 2795 | + return []; |
| 2796 | + } |
| 2797 | + |
| 2798 | + for ( var i = 0, l = Expr.order.length; i < l; i++ ) { |
| 2799 | + var type = Expr.order[i], match; |
| 2800 | + |
| 2801 | + if ( (match = Expr.leftMatch[ type ].exec( expr )) ) { |
| 2802 | + var left = match[1]; |
| 2803 | + match.splice(1,1); |
| 2804 | + |
| 2805 | + if ( left.substr( left.length - 1 ) !== "\\" ) { |
| 2806 | + match[1] = (match[1] || "").replace(/\\/g, ""); |
| 2807 | + set = Expr.find[ type ]( match, context, isXML ); |
| 2808 | + if ( set != null ) { |
| 2809 | + expr = expr.replace( Expr.match[ type ], "" ); |
| 2810 | + break; |
| 2811 | + } |
| 2812 | + } |
| 2813 | + } |
| 2814 | + } |
| 2815 | + |
| 2816 | + if ( !set ) { |
| 2817 | + set = context.getElementsByTagName("*"); |
| 2818 | + } |
| 2819 | + |
| 2820 | + return {set: set, expr: expr}; |
| 2821 | +}; |
| 2822 | + |
| 2823 | +Sizzle.filter = function(expr, set, inplace, not){ |
| 2824 | + var old = expr, result = [], curLoop = set, match, anyFound, |
| 2825 | + isXMLFilter = set && set[0] && isXML(set[0]); |
| 2826 | + |
| 2827 | + while ( expr && set.length ) { |
| 2828 | + for ( var type in Expr.filter ) { |
| 2829 | + if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) { |
| 2830 | + var filter = Expr.filter[ type ], found, item, left = match[1]; |
| 2831 | + anyFound = false; |
| 2832 | + |
| 2833 | + match.splice(1,1); |
| 2834 | + |
| 2835 | + if ( left.substr( left.length - 1 ) === "\\" ) { |
| 2836 | + continue; |
| 2837 | + } |
| 2838 | + |
| 2839 | + if ( curLoop === result ) { |
| 2840 | + result = []; |
| 2841 | + } |
| 2842 | + |
| 2843 | + if ( Expr.preFilter[ type ] ) { |
| 2844 | + match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter ); |
| 2845 | + |
| 2846 | + if ( !match ) { |
| 2847 | + anyFound = found = true; |
| 2848 | + } else if ( match === true ) { |
| 2849 | + continue; |
| 2850 | + } |
| 2851 | + } |
| 2852 | + |
| 2853 | + if ( match ) { |
| 2854 | + for ( var i = 0; (item = curLoop[i]) != null; i++ ) { |
| 2855 | + if ( item ) { |
| 2856 | + found = filter( item, match, i, curLoop ); |
| 2857 | + var pass = not ^ !!found; |
| 2858 | + |
| 2859 | + if ( inplace && found != null ) { |
| 2860 | + if ( pass ) { |
| 2861 | + anyFound = true; |
| 2862 | + } else { |
| 2863 | + curLoop[i] = false; |
| 2864 | + } |
| 2865 | + } else if ( pass ) { |
| 2866 | + result.push( item ); |
| 2867 | + anyFound = true; |
| 2868 | + } |
| 2869 | + } |
| 2870 | + } |
| 2871 | + } |
| 2872 | + |
| 2873 | + if ( found !== undefined ) { |
| 2874 | + if ( !inplace ) { |
| 2875 | + curLoop = result; |
| 2876 | + } |
| 2877 | + |
| 2878 | + expr = expr.replace( Expr.match[ type ], "" ); |
| 2879 | + |
| 2880 | + if ( !anyFound ) { |
| 2881 | + return []; |
| 2882 | + } |
| 2883 | + |
| 2884 | + break; |
| 2885 | + } |
| 2886 | + } |
| 2887 | + } |
| 2888 | + |
| 2889 | + // Improper expression |
| 2890 | + if ( expr === old ) { |
| 2891 | + if ( anyFound == null ) { |
| 2892 | + Sizzle.error( expr ); |
| 2893 | + } else { |
| 2894 | + break; |
| 2895 | + } |
| 2896 | + } |
| 2897 | + |
| 2898 | + old = expr; |
| 2899 | + } |
| 2900 | + |
| 2901 | + return curLoop; |
| 2902 | +}; |
| 2903 | + |
| 2904 | +Sizzle.error = function( msg ) { |
| 2905 | + throw "Syntax error, unrecognized expression: " + msg; |
| 2906 | +}; |
| 2907 | + |
| 2908 | +var Expr = Sizzle.selectors = { |
| 2909 | + order: [ "ID", "NAME", "TAG" ], |
| 2910 | + match: { |
| 2911 | + ID: /#((?:[\w\u00c0-\uFFFF-]|\\.)+)/, |
| 2912 | + CLASS: /\.((?:[\w\u00c0-\uFFFF-]|\\.)+)/, |
| 2913 | + NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF-]|\\.)+)['"]*\]/, |
| 2914 | + ATTR: /\[\s*((?:[\w\u00c0-\uFFFF-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/, |
| 2915 | + TAG: /^((?:[\w\u00c0-\uFFFF\*-]|\\.)+)/, |
| 2916 | + CHILD: /:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/, |
| 2917 | + POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/, |
| 2918 | + PSEUDO: /:((?:[\w\u00c0-\uFFFF-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/ |
| 2919 | + }, |
| 2920 | + leftMatch: {}, |
| 2921 | + attrMap: { |
| 2922 | + "class": "className", |
| 2923 | + "for": "htmlFor" |
| 2924 | + }, |
| 2925 | + attrHandle: { |
| 2926 | + href: function(elem){ |
| 2927 | + return elem.getAttribute("href"); |
| 2928 | + } |
| 2929 | + }, |
| 2930 | + relative: { |
| 2931 | + "+": function(checkSet, part){ |
| 2932 | + var isPartStr = typeof part === "string", |
| 2933 | + isTag = isPartStr && !/\W/.test(part), |
| 2934 | + isPartStrNotTag = isPartStr && !isTag; |
| 2935 | + |
| 2936 | + if ( isTag ) { |
| 2937 | + part = part.toLowerCase(); |
| 2938 | + } |
| 2939 | + |
| 2940 | + for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) { |
| 2941 | + if ( (elem = checkSet[i]) ) { |
| 2942 | + while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {} |
| 2943 | + |
| 2944 | + checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ? |
| 2945 | + elem || false : |
| 2946 | + elem === part; |
| 2947 | + } |
| 2948 | + } |
| 2949 | + |
| 2950 | + if ( isPartStrNotTag ) { |
| 2951 | + Sizzle.filter( part, checkSet, true ); |
| 2952 | + } |
| 2953 | + }, |
| 2954 | + ">": function(checkSet, part){ |
| 2955 | + var isPartStr = typeof part === "string"; |
| 2956 | + |
| 2957 | + if ( isPartStr && !/\W/.test(part) ) { |
| 2958 | + part = part.toLowerCase(); |
| 2959 | + |
| 2960 | + for ( var i = 0, l = checkSet.length; i < l; i++ ) { |
| 2961 | + var elem = checkSet[i]; |
| 2962 | + if ( elem ) { |
| 2963 | + var parent = elem.parentNode; |
| 2964 | + checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false; |
| 2965 | + } |
| 2966 | + } |
| 2967 | + } else { |
| 2968 | + for ( var i = 0, l = checkSet.length; i < l; i++ ) { |
| 2969 | + var elem = checkSet[i]; |
| 2970 | + if ( elem ) { |
| 2971 | + checkSet[i] = isPartStr ? |
| 2972 | + elem.parentNode : |
| 2973 | + elem.parentNode === part; |
| 2974 | + } |
| 2975 | + } |
| 2976 | + |
| 2977 | + if ( isPartStr ) { |
| 2978 | + Sizzle.filter( part, checkSet, true ); |
| 2979 | + } |
| 2980 | + } |
| 2981 | + }, |
| 2982 | + "": function(checkSet, part, isXML){ |
| 2983 | + var doneName = done++, checkFn = dirCheck; |
| 2984 | + |
| 2985 | + if ( typeof part === "string" && !/\W/.test(part) ) { |
| 2986 | + var nodeCheck = part = part.toLowerCase(); |
| 2987 | + checkFn = dirNodeCheck; |
| 2988 | + } |
| 2989 | + |
| 2990 | + checkFn("parentNode", part, doneName, checkSet, nodeCheck, isXML); |
| 2991 | + }, |
| 2992 | + "~": function(checkSet, part, isXML){ |
| 2993 | + var doneName = done++, checkFn = dirCheck; |
| 2994 | + |
| 2995 | + if ( typeof part === "string" && !/\W/.test(part) ) { |
| 2996 | + var nodeCheck = part = part.toLowerCase(); |
| 2997 | + checkFn = dirNodeCheck; |
| 2998 | + } |
| 2999 | + |
| 3000 | + checkFn("previousSibling", part, doneName, checkSet, nodeCheck, isXML); |
| 3001 | + } |
| 3002 | + }, |
| 3003 | + find: { |
| 3004 | + ID: function(match, context, isXML){ |
| 3005 | + if ( typeof context.getElementById !== "undefined" && !isXML ) { |
| 3006 | + var m = context.getElementById(match[1]); |
| 3007 | + return m ? [m] : []; |
| 3008 | + } |
| 3009 | + }, |
| 3010 | + NAME: function(match, context){ |
| 3011 | + if ( typeof context.getElementsByName !== "undefined" ) { |
| 3012 | + var ret = [], results = context.getElementsByName(match[1]); |
| 3013 | + |
| 3014 | + for ( var i = 0, l = results.length; i < l; i++ ) { |
| 3015 | + if ( results[i].getAttribute("name") === match[1] ) { |
| 3016 | + ret.push( results[i] ); |
| 3017 | + } |
| 3018 | + } |
| 3019 | + |
| 3020 | + return ret.length === 0 ? null : ret; |
| 3021 | + } |
| 3022 | + }, |
| 3023 | + TAG: function(match, context){ |
| 3024 | + return context.getElementsByTagName(match[1]); |
| 3025 | + } |
| 3026 | + }, |
| 3027 | + preFilter: { |
| 3028 | + CLASS: function(match, curLoop, inplace, result, not, isXML){ |
| 3029 | + match = " " + match[1].replace(/\\/g, "") + " "; |
| 3030 | + |
| 3031 | + if ( isXML ) { |
| 3032 | + return match; |
| 3033 | + } |
| 3034 | + |
| 3035 | + for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) { |
| 3036 | + if ( elem ) { |
| 3037 | + if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n]/g, " ").indexOf(match) >= 0) ) { |
| 3038 | + if ( !inplace ) { |
| 3039 | + result.push( elem ); |
| 3040 | + } |
| 3041 | + } else if ( inplace ) { |
| 3042 | + curLoop[i] = false; |
| 3043 | + } |
| 3044 | + } |
| 3045 | + } |
| 3046 | + |
| 3047 | + return false; |
| 3048 | + }, |
| 3049 | + ID: function(match){ |
| 3050 | + return match[1].replace(/\\/g, ""); |
| 3051 | + }, |
| 3052 | + TAG: function(match, curLoop){ |
| 3053 | + return match[1].toLowerCase(); |
| 3054 | + }, |
| 3055 | + CHILD: function(match){ |
| 3056 | + if ( match[1] === "nth" ) { |
| 3057 | + // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6' |
| 3058 | + var test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec( |
| 3059 | + match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" || |
| 3060 | + !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]); |
| 3061 | + |
| 3062 | + // calculate the numbers (first)n+(last) including if they are negative |
| 3063 | + match[2] = (test[1] + (test[2] || 1)) - 0; |
| 3064 | + match[3] = test[3] - 0; |
| 3065 | + } |
| 3066 | + |
| 3067 | + // TODO: Move to normal caching system |
| 3068 | + match[0] = done++; |
| 3069 | + |
| 3070 | + return match; |
| 3071 | + }, |
| 3072 | + ATTR: function(match, curLoop, inplace, result, not, isXML){ |
| 3073 | + var name = match[1].replace(/\\/g, ""); |
| 3074 | + |
| 3075 | + if ( !isXML && Expr.attrMap[name] ) { |
| 3076 | + match[1] = Expr.attrMap[name]; |
| 3077 | + } |
| 3078 | + |
| 3079 | + if ( match[2] === "~=" ) { |
| 3080 | + match[4] = " " + match[4] + " "; |
| 3081 | + } |
| 3082 | + |
| 3083 | + return match; |
| 3084 | + }, |
| 3085 | + PSEUDO: function(match, curLoop, inplace, result, not){ |
| 3086 | + if ( match[1] === "not" ) { |
| 3087 | + // If we're dealing with a complex expression, or a simple one |
| 3088 | + if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) { |
| 3089 | + match[3] = Sizzle(match[3], null, null, curLoop); |
| 3090 | + } else { |
| 3091 | + var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not); |
| 3092 | + if ( !inplace ) { |
| 3093 | + result.push.apply( result, ret ); |
| 3094 | + } |
| 3095 | + return false; |
| 3096 | + } |
| 3097 | + } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) { |
| 3098 | + return true; |
| 3099 | + } |
| 3100 | + |
| 3101 | + return match; |
| 3102 | + }, |
| 3103 | + POS: function(match){ |
| 3104 | + match.unshift( true ); |
| 3105 | + return match; |
| 3106 | + } |
| 3107 | + }, |
| 3108 | + filters: { |
| 3109 | + enabled: function(elem){ |
| 3110 | + return elem.disabled === false && elem.type !== "hidden"; |
| 3111 | + }, |
| 3112 | + disabled: function(elem){ |
| 3113 | + return elem.disabled === true; |
| 3114 | + }, |
| 3115 | + checked: function(elem){ |
| 3116 | + return elem.checked === true; |
| 3117 | + }, |
| 3118 | + selected: function(elem){ |
| 3119 | + // Accessing this property makes selected-by-default |
| 3120 | + // options in Safari work properly |
| 3121 | + elem.parentNode.selectedIndex; |
| 3122 | + return elem.selected === true; |
| 3123 | + }, |
| 3124 | + parent: function(elem){ |
| 3125 | + return !!elem.firstChild; |
| 3126 | + }, |
| 3127 | + empty: function(elem){ |
| 3128 | + return !elem.firstChild; |
| 3129 | + }, |
| 3130 | + has: function(elem, i, match){ |
| 3131 | + return !!Sizzle( match[3], elem ).length; |
| 3132 | + }, |
| 3133 | + header: function(elem){ |
| 3134 | + return /h\d/i.test( elem.nodeName ); |
| 3135 | + }, |
| 3136 | + text: function(elem){ |
| 3137 | + return "text" === elem.type; |
| 3138 | + }, |
| 3139 | + radio: function(elem){ |
| 3140 | + return "radio" === elem.type; |
| 3141 | + }, |
| 3142 | + checkbox: function(elem){ |
| 3143 | + return "checkbox" === elem.type; |
| 3144 | + }, |
| 3145 | + file: function(elem){ |
| 3146 | + return "file" === elem.type; |
| 3147 | + }, |
| 3148 | + password: function(elem){ |
| 3149 | + return "password" === elem.type; |
| 3150 | + }, |
| 3151 | + submit: function(elem){ |
| 3152 | + return "submit" === elem.type; |
| 3153 | + }, |
| 3154 | + image: function(elem){ |
| 3155 | + return "image" === elem.type; |
| 3156 | + }, |
| 3157 | + reset: function(elem){ |
| 3158 | + return "reset" === elem.type; |
| 3159 | + }, |
| 3160 | + button: function(elem){ |
| 3161 | + return "button" === elem.type || elem.nodeName.toLowerCase() === "button"; |
| 3162 | + }, |
| 3163 | + input: function(elem){ |
| 3164 | + return /input|select|textarea|button/i.test(elem.nodeName); |
| 3165 | + } |
| 3166 | + }, |
| 3167 | + setFilters: { |
| 3168 | + first: function(elem, i){ |
| 3169 | + return i === 0; |
| 3170 | + }, |
| 3171 | + last: function(elem, i, match, array){ |
| 3172 | + return i === array.length - 1; |
| 3173 | + }, |
| 3174 | + even: function(elem, i){ |
| 3175 | + return i % 2 === 0; |
| 3176 | + }, |
| 3177 | + odd: function(elem, i){ |
| 3178 | + return i % 2 === 1; |
| 3179 | + }, |
| 3180 | + lt: function(elem, i, match){ |
| 3181 | + return i < match[3] - 0; |
| 3182 | + }, |
| 3183 | + gt: function(elem, i, match){ |
| 3184 | + return i > match[3] - 0; |
| 3185 | + }, |
| 3186 | + nth: function(elem, i, match){ |
| 3187 | + return match[3] - 0 === i; |
| 3188 | + }, |
| 3189 | + eq: function(elem, i, match){ |
| 3190 | + return match[3] - 0 === i; |
| 3191 | + } |
| 3192 | + }, |
| 3193 | + filter: { |
| 3194 | + PSEUDO: function(elem, match, i, array){ |
| 3195 | + var name = match[1], filter = Expr.filters[ name ]; |
| 3196 | + |
| 3197 | + if ( filter ) { |
| 3198 | + return filter( elem, i, match, array ); |
| 3199 | + } else if ( name === "contains" ) { |
| 3200 | + return (elem.textContent || elem.innerText || getText([ elem ]) || "").indexOf(match[3]) >= 0; |
| 3201 | + } else if ( name === "not" ) { |
| 3202 | + var not = match[3]; |
| 3203 | + |
| 3204 | + for ( var i = 0, l = not.length; i < l; i++ ) { |
| 3205 | + if ( not[i] === elem ) { |
| 3206 | + return false; |
| 3207 | + } |
| 3208 | + } |
| 3209 | + |
| 3210 | + return true; |
| 3211 | + } else { |
| 3212 | + Sizzle.error( "Syntax error, unrecognized expression: " + name ); |
| 3213 | + } |
| 3214 | + }, |
| 3215 | + CHILD: function(elem, match){ |
| 3216 | + var type = match[1], node = elem; |
| 3217 | + switch (type) { |
| 3218 | + case 'only': |
| 3219 | + case 'first': |
| 3220 | + while ( (node = node.previousSibling) ) { |
| 3221 | + if ( node.nodeType === 1 ) { |
| 3222 | + return false; |
| 3223 | + } |
| 3224 | + } |
| 3225 | + if ( type === "first" ) { |
| 3226 | + return true; |
| 3227 | + } |
| 3228 | + node = elem; |
| 3229 | + case 'last': |
| 3230 | + while ( (node = node.nextSibling) ) { |
| 3231 | + if ( node.nodeType === 1 ) { |
| 3232 | + return false; |
| 3233 | + } |
| 3234 | + } |
| 3235 | + return true; |
| 3236 | + case 'nth': |
| 3237 | + var first = match[2], last = match[3]; |
| 3238 | + |
| 3239 | + if ( first === 1 && last === 0 ) { |
| 3240 | + return true; |
| 3241 | + } |
| 3242 | + |
| 3243 | + var doneName = match[0], |
| 3244 | + parent = elem.parentNode; |
| 3245 | + |
| 3246 | + if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) { |
| 3247 | + var count = 0; |
| 3248 | + for ( node = parent.firstChild; node; node = node.nextSibling ) { |
| 3249 | + if ( node.nodeType === 1 ) { |
| 3250 | + node.nodeIndex = ++count; |
| 3251 | + } |
| 3252 | + } |
| 3253 | + parent.sizcache = doneName; |
| 3254 | + } |
| 3255 | + |
| 3256 | + var diff = elem.nodeIndex - last; |
| 3257 | + if ( first === 0 ) { |
| 3258 | + return diff === 0; |
| 3259 | + } else { |
| 3260 | + return ( diff % first === 0 && diff / first >= 0 ); |
| 3261 | + } |
| 3262 | + } |
| 3263 | + }, |
| 3264 | + ID: function(elem, match){ |
| 3265 | + return elem.nodeType === 1 && elem.getAttribute("id") === match; |
| 3266 | + }, |
| 3267 | + TAG: function(elem, match){ |
| 3268 | + return (match === "*" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match; |
| 3269 | + }, |
| 3270 | + CLASS: function(elem, match){ |
| 3271 | + return (" " + (elem.className || elem.getAttribute("class")) + " ") |
| 3272 | + .indexOf( match ) > -1; |
| 3273 | + }, |
| 3274 | + ATTR: function(elem, match){ |
| 3275 | + var name = match[1], |
| 3276 | + result = Expr.attrHandle[ name ] ? |
| 3277 | + Expr.attrHandle[ name ]( elem ) : |
| 3278 | + elem[ name ] != null ? |
| 3279 | + elem[ name ] : |
| 3280 | + elem.getAttribute( name ), |
| 3281 | + value = result + "", |
| 3282 | + type = match[2], |
| 3283 | + check = match[4]; |
| 3284 | + |
| 3285 | + return result == null ? |
| 3286 | + type === "!=" : |
| 3287 | + type === "=" ? |
| 3288 | + value === check : |
| 3289 | + type === "*=" ? |
| 3290 | + value.indexOf(check) >= 0 : |
| 3291 | + type === "~=" ? |
| 3292 | + (" " + value + " ").indexOf(check) >= 0 : |
| 3293 | + !check ? |
| 3294 | + value && result !== false : |
| 3295 | + type === "!=" ? |
| 3296 | + value !== check : |
| 3297 | + type === "^=" ? |
| 3298 | + value.indexOf(check) === 0 : |
| 3299 | + type === "$=" ? |
| 3300 | + value.substr(value.length - check.length) === check : |
| 3301 | + type === "|=" ? |
| 3302 | + value === check || value.substr(0, check.length + 1) === check + "-" : |
| 3303 | + false; |
| 3304 | + }, |
| 3305 | + POS: function(elem, match, i, array){ |
| 3306 | + var name = match[2], filter = Expr.setFilters[ name ]; |
| 3307 | + |
| 3308 | + if ( filter ) { |
| 3309 | + return filter( elem, i, match, array ); |
| 3310 | + } |
| 3311 | + } |
| 3312 | + } |
| 3313 | +}; |
| 3314 | + |
| 3315 | +var origPOS = Expr.match.POS; |
| 3316 | + |
| 3317 | +for ( var type in Expr.match ) { |
| 3318 | + Expr.match[ type ] = new RegExp( Expr.match[ type ].source + /(?![^\[]*\])(?![^\(]*\))/.source ); |
| 3319 | + Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, function(all, num){ |
| 3320 | + return "\\" + (num - 0 + 1); |
| 3321 | + })); |
| 3322 | +} |
| 3323 | + |
| 3324 | +var makeArray = function(array, results) { |
| 3325 | + array = Array.prototype.slice.call( array, 0 ); |
| 3326 | + |
| 3327 | + if ( results ) { |
| 3328 | + results.push.apply( results, array ); |
| 3329 | + return results; |
| 3330 | + } |
| 3331 | + |
| 3332 | + return array; |
| 3333 | +}; |
| 3334 | + |
| 3335 | +// Perform a simple check to determine if the browser is capable of |
| 3336 | +// converting a NodeList to an array using builtin methods. |
| 3337 | +// Also verifies that the returned array holds DOM nodes |
| 3338 | +// (which is not the case in the Blackberry browser) |
| 3339 | +try { |
| 3340 | + Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType; |
| 3341 | + |
| 3342 | +// Provide a fallback method if it does not work |
| 3343 | +} catch(e){ |
| 3344 | + makeArray = function(array, results) { |
| 3345 | + var ret = results || []; |
| 3346 | + |
| 3347 | + if ( toString.call(array) === "[object Array]" ) { |
| 3348 | + Array.prototype.push.apply( ret, array ); |
| 3349 | + } else { |
| 3350 | + if ( typeof array.length === "number" ) { |
| 3351 | + for ( var i = 0, l = array.length; i < l; i++ ) { |
| 3352 | + ret.push( array[i] ); |
| 3353 | + } |
| 3354 | + } else { |
| 3355 | + for ( var i = 0; array[i]; i++ ) { |
| 3356 | + ret.push( array[i] ); |
| 3357 | + } |
| 3358 | + } |
| 3359 | + } |
| 3360 | + |
| 3361 | + return ret; |
| 3362 | + }; |
| 3363 | +} |
| 3364 | + |
| 3365 | +var sortOrder; |
| 3366 | + |
| 3367 | +if ( document.documentElement.compareDocumentPosition ) { |
| 3368 | + sortOrder = function( a, b ) { |
| 3369 | + if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) { |
| 3370 | + if ( a == b ) { |
| 3371 | + hasDuplicate = true; |
| 3372 | + } |
| 3373 | + return a.compareDocumentPosition ? -1 : 1; |
| 3374 | + } |
| 3375 | + |
| 3376 | + var ret = a.compareDocumentPosition(b) & 4 ? -1 : a === b ? 0 : 1; |
| 3377 | + if ( ret === 0 ) { |
| 3378 | + hasDuplicate = true; |
| 3379 | + } |
| 3380 | + return ret; |
| 3381 | + }; |
| 3382 | +} else if ( "sourceIndex" in document.documentElement ) { |
| 3383 | + sortOrder = function( a, b ) { |
| 3384 | + if ( !a.sourceIndex || !b.sourceIndex ) { |
| 3385 | + if ( a == b ) { |
| 3386 | + hasDuplicate = true; |
| 3387 | + } |
| 3388 | + return a.sourceIndex ? -1 : 1; |
| 3389 | + } |
| 3390 | + |
| 3391 | + var ret = a.sourceIndex - b.sourceIndex; |
| 3392 | + if ( ret === 0 ) { |
| 3393 | + hasDuplicate = true; |
| 3394 | + } |
| 3395 | + return ret; |
| 3396 | + }; |
| 3397 | +} else if ( document.createRange ) { |
| 3398 | + sortOrder = function( a, b ) { |
| 3399 | + if ( !a.ownerDocument || !b.ownerDocument ) { |
| 3400 | + if ( a == b ) { |
| 3401 | + hasDuplicate = true; |
| 3402 | + } |
| 3403 | + return a.ownerDocument ? -1 : 1; |
| 3404 | + } |
| 3405 | + |
| 3406 | + var aRange = a.ownerDocument.createRange(), bRange = b.ownerDocument.createRange(); |
| 3407 | + aRange.setStart(a, 0); |
| 3408 | + aRange.setEnd(a, 0); |
| 3409 | + bRange.setStart(b, 0); |
| 3410 | + bRange.setEnd(b, 0); |
| 3411 | + var ret = aRange.compareBoundaryPoints(Range.START_TO_END, bRange); |
| 3412 | + if ( ret === 0 ) { |
| 3413 | + hasDuplicate = true; |
| 3414 | + } |
| 3415 | + return ret; |
| 3416 | + }; |
| 3417 | +} |
| 3418 | + |
| 3419 | +// Utility function for retreiving the text value of an array of DOM nodes |
| 3420 | +function getText( elems ) { |
| 3421 | + var ret = "", elem; |
| 3422 | + |
| 3423 | + for ( var i = 0; elems[i]; i++ ) { |
| 3424 | + elem = elems[i]; |
| 3425 | + |
| 3426 | + // Get the text from text nodes and CDATA nodes |
| 3427 | + if ( elem.nodeType === 3 || elem.nodeType === 4 ) { |
| 3428 | + ret += elem.nodeValue; |
| 3429 | + |
| 3430 | + // Traverse everything else, except comment nodes |
| 3431 | + } else if ( elem.nodeType !== 8 ) { |
| 3432 | + ret += getText( elem.childNodes ); |
| 3433 | + } |
| 3434 | + } |
| 3435 | + |
| 3436 | + return ret; |
| 3437 | +} |
| 3438 | + |
| 3439 | +// Check to see if the browser returns elements by name when |
| 3440 | +// querying by getElementById (and provide a workaround) |
| 3441 | +(function(){ |
| 3442 | + // We're going to inject a fake input element with a specified name |
| 3443 | + var form = document.createElement("div"), |
| 3444 | + id = "script" + (new Date).getTime(); |
| 3445 | + form.innerHTML = "<a name='" + id + "'/>"; |
| 3446 | + |
| 3447 | + // Inject it into the root element, check its status, and remove it quickly |
| 3448 | + var root = document.documentElement; |
| 3449 | + root.insertBefore( form, root.firstChild ); |
| 3450 | + |
| 3451 | + // The workaround has to do additional checks after a getElementById |
| 3452 | + // Which slows things down for other browsers (hence the branching) |
| 3453 | + if ( document.getElementById( id ) ) { |
| 3454 | + Expr.find.ID = function(match, context, isXML){ |
| 3455 | + if ( typeof context.getElementById !== "undefined" && !isXML ) { |
| 3456 | + var m = context.getElementById(match[1]); |
| 3457 | + return m ? m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ? [m] : undefined : []; |
| 3458 | + } |
| 3459 | + }; |
| 3460 | + |
| 3461 | + Expr.filter.ID = function(elem, match){ |
| 3462 | + var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id"); |
| 3463 | + return elem.nodeType === 1 && node && node.nodeValue === match; |
| 3464 | + }; |
| 3465 | + } |
| 3466 | + |
| 3467 | + root.removeChild( form ); |
| 3468 | + root = form = null; // release memory in IE |
| 3469 | +})(); |
| 3470 | + |
| 3471 | +(function(){ |
| 3472 | + // Check to see if the browser returns only elements |
| 3473 | + // when doing getElementsByTagName("*") |
| 3474 | + |
| 3475 | + // Create a fake element |
| 3476 | + var div = document.createElement("div"); |
| 3477 | + div.appendChild( document.createComment("") ); |
| 3478 | + |
| 3479 | + // Make sure no comments are found |
| 3480 | + if ( div.getElementsByTagName("*").length > 0 ) { |
| 3481 | + Expr.find.TAG = function(match, context){ |
| 3482 | + var results = context.getElementsByTagName(match[1]); |
| 3483 | + |
| 3484 | + // Filter out possible comments |
| 3485 | + if ( match[1] === "*" ) { |
| 3486 | + var tmp = []; |
| 3487 | + |
| 3488 | + for ( var i = 0; results[i]; i++ ) { |
| 3489 | + if ( results[i].nodeType === 1 ) { |
| 3490 | + tmp.push( results[i] ); |
| 3491 | + } |
| 3492 | + } |
| 3493 | + |
| 3494 | + results = tmp; |
| 3495 | + } |
| 3496 | + |
| 3497 | + return results; |
| 3498 | + }; |
| 3499 | + } |
| 3500 | + |
| 3501 | + // Check to see if an attribute returns normalized href attributes |
| 3502 | + div.innerHTML = "<a href='#'></a>"; |
| 3503 | + if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" && |
| 3504 | + div.firstChild.getAttribute("href") !== "#" ) { |
| 3505 | + Expr.attrHandle.href = function(elem){ |
| 3506 | + return elem.getAttribute("href", 2); |
| 3507 | + }; |
| 3508 | + } |
| 3509 | + |
| 3510 | + div = null; // release memory in IE |
| 3511 | +})(); |
| 3512 | + |
| 3513 | +if ( document.querySelectorAll ) { |
| 3514 | + (function(){ |
| 3515 | + var oldSizzle = Sizzle, div = document.createElement("div"); |
| 3516 | + div.innerHTML = "<p class='TEST'></p>"; |
| 3517 | + |
| 3518 | + // Safari can't handle uppercase or unicode characters when |
| 3519 | + // in quirks mode. |
| 3520 | + if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) { |
| 3521 | + return; |
| 3522 | + } |
| 3523 | + |
| 3524 | + Sizzle = function(query, context, extra, seed){ |
| 3525 | + context = context || document; |
| 3526 | + |
| 3527 | + // Only use querySelectorAll on non-XML documents |
| 3528 | + // (ID selectors don't work in non-HTML documents) |
| 3529 | + if ( !seed && context.nodeType === 9 && !isXML(context) ) { |
| 3530 | + try { |
| 3531 | + return makeArray( context.querySelectorAll(query), extra ); |
| 3532 | + } catch(e){} |
| 3533 | + } |
| 3534 | + |
| 3535 | + return oldSizzle(query, context, extra, seed); |
| 3536 | + }; |
| 3537 | + |
| 3538 | + for ( var prop in oldSizzle ) { |
| 3539 | + Sizzle[ prop ] = oldSizzle[ prop ]; |
| 3540 | + } |
| 3541 | + |
| 3542 | + div = null; // release memory in IE |
| 3543 | + })(); |
| 3544 | +} |
| 3545 | + |
| 3546 | +(function(){ |
| 3547 | + var div = document.createElement("div"); |
| 3548 | + |
| 3549 | + div.innerHTML = "<div class='test e'></div><div class='test'></div>"; |
| 3550 | + |
| 3551 | + // Opera can't find a second classname (in 9.6) |
| 3552 | + // Also, make sure that getElementsByClassName actually exists |
| 3553 | + if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) { |
| 3554 | + return; |
| 3555 | + } |
| 3556 | + |
| 3557 | + // Safari caches class attributes, doesn't catch changes (in 3.2) |
| 3558 | + div.lastChild.className = "e"; |
| 3559 | + |
| 3560 | + if ( div.getElementsByClassName("e").length === 1 ) { |
| 3561 | + return; |
| 3562 | + } |
| 3563 | + |
| 3564 | + Expr.order.splice(1, 0, "CLASS"); |
| 3565 | + Expr.find.CLASS = function(match, context, isXML) { |
| 3566 | + if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) { |
| 3567 | + return context.getElementsByClassName(match[1]); |
| 3568 | + } |
| 3569 | + }; |
| 3570 | + |
| 3571 | + div = null; // release memory in IE |
| 3572 | +})(); |
| 3573 | + |
| 3574 | +function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { |
| 3575 | + for ( var i = 0, l = checkSet.length; i < l; i++ ) { |
| 3576 | + var elem = checkSet[i]; |
| 3577 | + if ( elem ) { |
| 3578 | + elem = elem[dir]; |
| 3579 | + var match = false; |
| 3580 | + |
| 3581 | + while ( elem ) { |
| 3582 | + if ( elem.sizcache === doneName ) { |
| 3583 | + match = checkSet[elem.sizset]; |
| 3584 | + break; |
| 3585 | + } |
| 3586 | + |
| 3587 | + if ( elem.nodeType === 1 && !isXML ){ |
| 3588 | + elem.sizcache = doneName; |
| 3589 | + elem.sizset = i; |
| 3590 | + } |
| 3591 | + |
| 3592 | + if ( elem.nodeName.toLowerCase() === cur ) { |
| 3593 | + match = elem; |
| 3594 | + break; |
| 3595 | + } |
| 3596 | + |
| 3597 | + elem = elem[dir]; |
| 3598 | + } |
| 3599 | + |
| 3600 | + checkSet[i] = match; |
| 3601 | + } |
| 3602 | + } |
| 3603 | +} |
| 3604 | + |
| 3605 | +function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { |
| 3606 | + for ( var i = 0, l = checkSet.length; i < l; i++ ) { |
| 3607 | + var elem = checkSet[i]; |
| 3608 | + if ( elem ) { |
| 3609 | + elem = elem[dir]; |
| 3610 | + var match = false; |
| 3611 | + |
| 3612 | + while ( elem ) { |
| 3613 | + if ( elem.sizcache === doneName ) { |
| 3614 | + match = checkSet[elem.sizset]; |
| 3615 | + break; |
| 3616 | + } |
| 3617 | + |
| 3618 | + if ( elem.nodeType === 1 ) { |
| 3619 | + if ( !isXML ) { |
| 3620 | + elem.sizcache = doneName; |
| 3621 | + elem.sizset = i; |
| 3622 | + } |
| 3623 | + if ( typeof cur !== "string" ) { |
| 3624 | + if ( elem === cur ) { |
| 3625 | + match = true; |
| 3626 | + break; |
| 3627 | + } |
| 3628 | + |
| 3629 | + } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) { |
| 3630 | + match = elem; |
| 3631 | + break; |
| 3632 | + } |
| 3633 | + } |
| 3634 | + |
| 3635 | + elem = elem[dir]; |
| 3636 | + } |
| 3637 | + |
| 3638 | + checkSet[i] = match; |
| 3639 | + } |
| 3640 | + } |
| 3641 | +} |
| 3642 | + |
| 3643 | +var contains = document.compareDocumentPosition ? function(a, b){ |
| 3644 | + return !!(a.compareDocumentPosition(b) & 16); |
| 3645 | +} : function(a, b){ |
| 3646 | + return a !== b && (a.contains ? a.contains(b) : true); |
| 3647 | +}; |
| 3648 | + |
| 3649 | +var isXML = function(elem){ |
| 3650 | + // documentElement is verified for cases where it doesn't yet exist |
| 3651 | + // (such as loading iframes in IE - #4833) |
| 3652 | + var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement; |
| 3653 | + return documentElement ? documentElement.nodeName !== "HTML" : false; |
| 3654 | +}; |
| 3655 | + |
| 3656 | +var posProcess = function(selector, context){ |
| 3657 | + var tmpSet = [], later = "", match, |
| 3658 | + root = context.nodeType ? [context] : context; |
| 3659 | + |
| 3660 | + // Position selectors must be done after the filter |
| 3661 | + // And so must :not(positional) so we move all PSEUDOs to the end |
| 3662 | + while ( (match = Expr.match.PSEUDO.exec( selector )) ) { |
| 3663 | + later += match[0]; |
| 3664 | + selector = selector.replace( Expr.match.PSEUDO, "" ); |
| 3665 | + } |
| 3666 | + |
| 3667 | + selector = Expr.relative[selector] ? selector + "*" : selector; |
| 3668 | + |
| 3669 | + for ( var i = 0, l = root.length; i < l; i++ ) { |
| 3670 | + Sizzle( selector, root[i], tmpSet ); |
| 3671 | + } |
| 3672 | + |
| 3673 | + return Sizzle.filter( later, tmpSet ); |
| 3674 | +}; |
| 3675 | + |
| 3676 | +// EXPOSE |
| 3677 | +jQuery.find = Sizzle; |
| 3678 | +jQuery.expr = Sizzle.selectors; |
| 3679 | +jQuery.expr[":"] = jQuery.expr.filters; |
| 3680 | +jQuery.unique = Sizzle.uniqueSort; |
| 3681 | +jQuery.text = getText; |
| 3682 | +jQuery.isXMLDoc = isXML; |
| 3683 | +jQuery.contains = contains; |
| 3684 | + |
| 3685 | +return; |
| 3686 | + |
| 3687 | +window.Sizzle = Sizzle; |
| 3688 | + |
| 3689 | +})(); |
| 3690 | +var runtil = /Until$/, |
| 3691 | + rparentsprev = /^(?:parents|prevUntil|prevAll)/, |
| 3692 | + // Note: This RegExp should be improved, or likely pulled from Sizzle |
| 3693 | + rmultiselector = /,/, |
| 3694 | + slice = Array.prototype.slice; |
| 3695 | + |
| 3696 | +// Implement the identical functionality for filter and not |
| 3697 | +var winnow = function( elements, qualifier, keep ) { |
| 3698 | + if ( jQuery.isFunction( qualifier ) ) { |
| 3699 | + return jQuery.grep(elements, function( elem, i ) { |
| 3700 | + return !!qualifier.call( elem, i, elem ) === keep; |
| 3701 | + }); |
| 3702 | + |
| 3703 | + } else if ( qualifier.nodeType ) { |
| 3704 | + return jQuery.grep(elements, function( elem, i ) { |
| 3705 | + return (elem === qualifier) === keep; |
| 3706 | + }); |
| 3707 | + |
| 3708 | + } else if ( typeof qualifier === "string" ) { |
| 3709 | + var filtered = jQuery.grep(elements, function( elem ) { |
| 3710 | + return elem.nodeType === 1; |
| 3711 | + }); |
| 3712 | + |
| 3713 | + if ( isSimple.test( qualifier ) ) { |
| 3714 | + return jQuery.filter(qualifier, filtered, !keep); |
| 3715 | + } else { |
| 3716 | + qualifier = jQuery.filter( qualifier, filtered ); |
| 3717 | + } |
| 3718 | + } |
| 3719 | + |
| 3720 | + return jQuery.grep(elements, function( elem, i ) { |
| 3721 | + return (jQuery.inArray( elem, qualifier ) >= 0) === keep; |
| 3722 | + }); |
| 3723 | +}; |
| 3724 | + |
| 3725 | +jQuery.fn.extend({ |
| 3726 | + find: function( selector ) { |
| 3727 | + var ret = this.pushStack( "", "find", selector ), length = 0; |
| 3728 | + |
| 3729 | + for ( var i = 0, l = this.length; i < l; i++ ) { |
| 3730 | + length = ret.length; |
| 3731 | + jQuery.find( selector, this[i], ret ); |
| 3732 | + |
| 3733 | + if ( i > 0 ) { |
| 3734 | + // Make sure that the results are unique |
| 3735 | + for ( var n = length; n < ret.length; n++ ) { |
| 3736 | + for ( var r = 0; r < length; r++ ) { |
| 3737 | + if ( ret[r] === ret[n] ) { |
| 3738 | + ret.splice(n--, 1); |
| 3739 | + break; |
| 3740 | + } |
| 3741 | + } |
| 3742 | + } |
| 3743 | + } |
| 3744 | + } |
| 3745 | + |
| 3746 | + return ret; |
| 3747 | + }, |
| 3748 | + |
| 3749 | + has: function( target ) { |
| 3750 | + var targets = jQuery( target ); |
| 3751 | + return this.filter(function() { |
| 3752 | + for ( var i = 0, l = targets.length; i < l; i++ ) { |
| 3753 | + if ( jQuery.contains( this, targets[i] ) ) { |
| 3754 | + return true; |
| 3755 | + } |
| 3756 | + } |
| 3757 | + }); |
| 3758 | + }, |
| 3759 | + |
| 3760 | + not: function( selector ) { |
| 3761 | + return this.pushStack( winnow(this, selector, false), "not", selector); |
| 3762 | + }, |
| 3763 | + |
| 3764 | + filter: function( selector ) { |
| 3765 | + return this.pushStack( winnow(this, selector, true), "filter", selector ); |
| 3766 | + }, |
| 3767 | + |
| 3768 | + is: function( selector ) { |
| 3769 | + return !!selector && jQuery.filter( selector, this ).length > 0; |
| 3770 | + }, |
| 3771 | + |
| 3772 | + closest: function( selectors, context ) { |
| 3773 | + if ( jQuery.isArray( selectors ) ) { |
| 3774 | + var ret = [], cur = this[0], match, matches = {}, selector; |
| 3775 | + |
| 3776 | + if ( cur && selectors.length ) { |
| 3777 | + for ( var i = 0, l = selectors.length; i < l; i++ ) { |
| 3778 | + selector = selectors[i]; |
| 3779 | + |
| 3780 | + if ( !matches[selector] ) { |
| 3781 | + matches[selector] = jQuery.expr.match.POS.test( selector ) ? |
| 3782 | + jQuery( selector, context || this.context ) : |
| 3783 | + selector; |
| 3784 | + } |
| 3785 | + } |
| 3786 | + |
| 3787 | + while ( cur && cur.ownerDocument && cur !== context ) { |
| 3788 | + for ( selector in matches ) { |
| 3789 | + match = matches[selector]; |
| 3790 | + |
| 3791 | + if ( match.jquery ? match.index(cur) > -1 : jQuery(cur).is(match) ) { |
| 3792 | + ret.push({ selector: selector, elem: cur }); |
| 3793 | + delete matches[selector]; |
| 3794 | + } |
| 3795 | + } |
| 3796 | + cur = cur.parentNode; |
| 3797 | + } |
| 3798 | + } |
| 3799 | + |
| 3800 | + return ret; |
| 3801 | + } |
| 3802 | + |
| 3803 | + var pos = jQuery.expr.match.POS.test( selectors ) ? |
| 3804 | + jQuery( selectors, context || this.context ) : null; |
| 3805 | + |
| 3806 | + return this.map(function( i, cur ) { |
| 3807 | + while ( cur && cur.ownerDocument && cur !== context ) { |
| 3808 | + if ( pos ? pos.index(cur) > -1 : jQuery(cur).is(selectors) ) { |
| 3809 | + return cur; |
| 3810 | + } |
| 3811 | + cur = cur.parentNode; |
| 3812 | + } |
| 3813 | + return null; |
| 3814 | + }); |
| 3815 | + }, |
| 3816 | + |
| 3817 | + // Determine the position of an element within |
| 3818 | + // the matched set of elements |
| 3819 | + index: function( elem ) { |
| 3820 | + if ( !elem || typeof elem === "string" ) { |
| 3821 | + return jQuery.inArray( this[0], |
| 3822 | + // If it receives a string, the selector is used |
| 3823 | + // If it receives nothing, the siblings are used |
| 3824 | + elem ? jQuery( elem ) : this.parent().children() ); |
| 3825 | + } |
| 3826 | + // Locate the position of the desired element |
| 3827 | + return jQuery.inArray( |
| 3828 | + // If it receives a jQuery object, the first element is used |
| 3829 | + elem.jquery ? elem[0] : elem, this ); |
| 3830 | + }, |
| 3831 | + |
| 3832 | + add: function( selector, context ) { |
| 3833 | + var set = typeof selector === "string" ? |
| 3834 | + jQuery( selector, context || this.context ) : |
| 3835 | + jQuery.makeArray( selector ), |
| 3836 | + all = jQuery.merge( this.get(), set ); |
| 3837 | + |
| 3838 | + return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ? |
| 3839 | + all : |
| 3840 | + jQuery.unique( all ) ); |
| 3841 | + }, |
| 3842 | + |
| 3843 | + andSelf: function() { |
| 3844 | + return this.add( this.prevObject ); |
| 3845 | + } |
| 3846 | +}); |
| 3847 | + |
| 3848 | +// A painfully simple check to see if an element is disconnected |
| 3849 | +// from a document (should be improved, where feasible). |
| 3850 | +function isDisconnected( node ) { |
| 3851 | + return !node || !node.parentNode || node.parentNode.nodeType === 11; |
| 3852 | +} |
| 3853 | + |
| 3854 | +jQuery.each({ |
| 3855 | + parent: function( elem ) { |
| 3856 | + var parent = elem.parentNode; |
| 3857 | + return parent && parent.nodeType !== 11 ? parent : null; |
| 3858 | + }, |
| 3859 | + parents: function( elem ) { |
| 3860 | + return jQuery.dir( elem, "parentNode" ); |
| 3861 | + }, |
| 3862 | + parentsUntil: function( elem, i, until ) { |
| 3863 | + return jQuery.dir( elem, "parentNode", until ); |
| 3864 | + }, |
| 3865 | + next: function( elem ) { |
| 3866 | + return jQuery.nth( elem, 2, "nextSibling" ); |
| 3867 | + }, |
| 3868 | + prev: function( elem ) { |
| 3869 | + return jQuery.nth( elem, 2, "previousSibling" ); |
| 3870 | + }, |
| 3871 | + nextAll: function( elem ) { |
| 3872 | + return jQuery.dir( elem, "nextSibling" ); |
| 3873 | + }, |
| 3874 | + prevAll: function( elem ) { |
| 3875 | + return jQuery.dir( elem, "previousSibling" ); |
| 3876 | + }, |
| 3877 | + nextUntil: function( elem, i, until ) { |
| 3878 | + return jQuery.dir( elem, "nextSibling", until ); |
| 3879 | + }, |
| 3880 | + prevUntil: function( elem, i, until ) { |
| 3881 | + return jQuery.dir( elem, "previousSibling", until ); |
| 3882 | + }, |
| 3883 | + siblings: function( elem ) { |
| 3884 | + return jQuery.sibling( elem.parentNode.firstChild, elem ); |
| 3885 | + }, |
| 3886 | + children: function( elem ) { |
| 3887 | + return jQuery.sibling( elem.firstChild ); |
| 3888 | + }, |
| 3889 | + contents: function( elem ) { |
| 3890 | + return jQuery.nodeName( elem, "iframe" ) ? |
| 3891 | + elem.contentDocument || elem.contentWindow.document : |
| 3892 | + jQuery.makeArray( elem.childNodes ); |
| 3893 | + } |
| 3894 | +}, function( name, fn ) { |
| 3895 | + jQuery.fn[ name ] = function( until, selector ) { |
| 3896 | + var ret = jQuery.map( this, fn, until ); |
| 3897 | + |
| 3898 | + if ( !runtil.test( name ) ) { |
| 3899 | + selector = until; |
| 3900 | + } |
| 3901 | + |
| 3902 | + if ( selector && typeof selector === "string" ) { |
| 3903 | + ret = jQuery.filter( selector, ret ); |
| 3904 | + } |
| 3905 | + |
| 3906 | + ret = this.length > 1 ? jQuery.unique( ret ) : ret; |
| 3907 | + |
| 3908 | + if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) { |
| 3909 | + ret = ret.reverse(); |
| 3910 | + } |
| 3911 | + |
| 3912 | + return this.pushStack( ret, name, slice.call(arguments).join(",") ); |
| 3913 | + }; |
| 3914 | +}); |
| 3915 | + |
| 3916 | +jQuery.extend({ |
| 3917 | + filter: function( expr, elems, not ) { |
| 3918 | + if ( not ) { |
| 3919 | + expr = ":not(" + expr + ")"; |
| 3920 | + } |
| 3921 | + |
| 3922 | + return jQuery.find.matches(expr, elems); |
| 3923 | + }, |
| 3924 | + |
| 3925 | + dir: function( elem, dir, until ) { |
| 3926 | + var matched = [], cur = elem[dir]; |
| 3927 | + while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) { |
| 3928 | + if ( cur.nodeType === 1 ) { |
| 3929 | + matched.push( cur ); |
| 3930 | + } |
| 3931 | + cur = cur[dir]; |
| 3932 | + } |
| 3933 | + return matched; |
| 3934 | + }, |
| 3935 | + |
| 3936 | + nth: function( cur, result, dir, elem ) { |
| 3937 | + result = result || 1; |
| 3938 | + var num = 0; |
| 3939 | + |
| 3940 | + for ( ; cur; cur = cur[dir] ) { |
| 3941 | + if ( cur.nodeType === 1 && ++num === result ) { |
| 3942 | + break; |
| 3943 | + } |
| 3944 | + } |
| 3945 | + |
| 3946 | + return cur; |
| 3947 | + }, |
| 3948 | + |
| 3949 | + sibling: function( n, elem ) { |
| 3950 | + var r = []; |
| 3951 | + |
| 3952 | + for ( ; n; n = n.nextSibling ) { |
| 3953 | + if ( n.nodeType === 1 && n !== elem ) { |
| 3954 | + r.push( n ); |
| 3955 | + } |
| 3956 | + } |
| 3957 | + |
| 3958 | + return r; |
| 3959 | + } |
| 3960 | +}); |
| 3961 | +var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g, |
| 3962 | + rleadingWhitespace = /^\s+/, |
| 3963 | + rxhtmlTag = /(<([\w:]+)[^>]*?)\/>/g, |
| 3964 | + rselfClosing = /^(?:area|br|col|embed|hr|img|input|link|meta|param)$/i, |
| 3965 | + rtagName = /<([\w:]+)/, |
| 3966 | + rtbody = /<tbody/i, |
| 3967 | + rhtml = /<|&#?\w+;/, |
| 3968 | + rnocache = /<script|<object|<embed|<option|<style/i, |
| 3969 | + rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, // checked="checked" or checked (html5) |
| 3970 | + fcloseTag = function( all, front, tag ) { |
| 3971 | + return rselfClosing.test( tag ) ? |
| 3972 | + all : |
| 3973 | + front + "></" + tag + ">"; |
| 3974 | + }, |
| 3975 | + wrapMap = { |
| 3976 | + option: [ 1, "<select multiple='multiple'>", "</select>" ], |
| 3977 | + legend: [ 1, "<fieldset>", "</fieldset>" ], |
| 3978 | + thead: [ 1, "<table>", "</table>" ], |
| 3979 | + tr: [ 2, "<table><tbody>", "</tbody></table>" ], |
| 3980 | + td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ], |
| 3981 | + col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ], |
| 3982 | + area: [ 1, "<map>", "</map>" ], |
| 3983 | + _default: [ 0, "", "" ] |
| 3984 | + }; |
| 3985 | + |
| 3986 | +wrapMap.optgroup = wrapMap.option; |
| 3987 | +wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; |
| 3988 | +wrapMap.th = wrapMap.td; |
| 3989 | + |
| 3990 | +// IE can't serialize <link> and <script> tags normally |
| 3991 | +if ( !jQuery.support.htmlSerialize ) { |
| 3992 | + wrapMap._default = [ 1, "div<div>", "</div>" ]; |
| 3993 | +} |
| 3994 | + |
| 3995 | +jQuery.fn.extend({ |
| 3996 | + text: function( text ) { |
| 3997 | + if ( jQuery.isFunction(text) ) { |
| 3998 | + return this.each(function(i) { |
| 3999 | + var self = jQuery(this); |
| 4000 | + self.text( text.call(this, i, self.text()) ); |
| 4001 | + }); |
| 4002 | + } |
| 4003 | + |
| 4004 | + if ( typeof text !== "object" && text !== undefined ) { |
| 4005 | + return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) ); |
| 4006 | + } |
| 4007 | + |
| 4008 | + return jQuery.text( this ); |
| 4009 | + }, |
| 4010 | + |
| 4011 | + wrapAll: function( html ) { |
| 4012 | + if ( jQuery.isFunction( html ) ) { |
| 4013 | + return this.each(function(i) { |
| 4014 | + jQuery(this).wrapAll( html.call(this, i) ); |
| 4015 | + }); |
| 4016 | + } |
| 4017 | + |
| 4018 | + if ( this[0] ) { |
| 4019 | + // The elements to wrap the target around |
| 4020 | + var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true); |
| 4021 | + |
| 4022 | + if ( this[0].parentNode ) { |
| 4023 | + wrap.insertBefore( this[0] ); |
| 4024 | + } |
| 4025 | + |
| 4026 | + wrap.map(function() { |
| 4027 | + var elem = this; |
| 4028 | + |
| 4029 | + while ( elem.firstChild && elem.firstChild.nodeType === 1 ) { |
| 4030 | + elem = elem.firstChild; |
| 4031 | + } |
| 4032 | + |
| 4033 | + return elem; |
| 4034 | + }).append(this); |
| 4035 | + } |
| 4036 | + |
| 4037 | + return this; |
| 4038 | + }, |
| 4039 | + |
| 4040 | + wrapInner: function( html ) { |
| 4041 | + if ( jQuery.isFunction( html ) ) { |
| 4042 | + return this.each(function(i) { |
| 4043 | + jQuery(this).wrapInner( html.call(this, i) ); |
| 4044 | + }); |
| 4045 | + } |
| 4046 | + |
| 4047 | + return this.each(function() { |
| 4048 | + var self = jQuery( this ), contents = self.contents(); |
| 4049 | + |
| 4050 | + if ( contents.length ) { |
| 4051 | + contents.wrapAll( html ); |
| 4052 | + |
| 4053 | + } else { |
| 4054 | + self.append( html ); |
| 4055 | + } |
| 4056 | + }); |
| 4057 | + }, |
| 4058 | + |
| 4059 | + wrap: function( html ) { |
| 4060 | + return this.each(function() { |
| 4061 | + jQuery( this ).wrapAll( html ); |
| 4062 | + }); |
| 4063 | + }, |
| 4064 | + |
| 4065 | + unwrap: function() { |
| 4066 | + return this.parent().each(function() { |
| 4067 | + if ( !jQuery.nodeName( this, "body" ) ) { |
| 4068 | + jQuery( this ).replaceWith( this.childNodes ); |
| 4069 | + } |
| 4070 | + }).end(); |
| 4071 | + }, |
| 4072 | + |
| 4073 | + append: function() { |
| 4074 | + return this.domManip(arguments, true, function( elem ) { |
| 4075 | + if ( this.nodeType === 1 ) { |
| 4076 | + this.appendChild( elem ); |
| 4077 | + } |
| 4078 | + }); |
| 4079 | + }, |
| 4080 | + |
| 4081 | + prepend: function() { |
| 4082 | + return this.domManip(arguments, true, function( elem ) { |
| 4083 | + if ( this.nodeType === 1 ) { |
| 4084 | + this.insertBefore( elem, this.firstChild ); |
| 4085 | + } |
| 4086 | + }); |
| 4087 | + }, |
| 4088 | + |
| 4089 | + before: function() { |
| 4090 | + if ( this[0] && this[0].parentNode ) { |
| 4091 | + return this.domManip(arguments, false, function( elem ) { |
| 4092 | + this.parentNode.insertBefore( elem, this ); |
| 4093 | + }); |
| 4094 | + } else if ( arguments.length ) { |
| 4095 | + var set = jQuery(arguments[0]); |
| 4096 | + set.push.apply( set, this.toArray() ); |
| 4097 | + return this.pushStack( set, "before", arguments ); |
| 4098 | + } |
| 4099 | + }, |
| 4100 | + |
| 4101 | + after: function() { |
| 4102 | + if ( this[0] && this[0].parentNode ) { |
| 4103 | + return this.domManip(arguments, false, function( elem ) { |
| 4104 | + this.parentNode.insertBefore( elem, this.nextSibling ); |
| 4105 | + }); |
| 4106 | + } else if ( arguments.length ) { |
| 4107 | + var set = this.pushStack( this, "after", arguments ); |
| 4108 | + set.push.apply( set, jQuery(arguments[0]).toArray() ); |
| 4109 | + return set; |
| 4110 | + } |
| 4111 | + }, |
| 4112 | + |
| 4113 | + // keepData is for internal use only--do not document |
| 4114 | + remove: function( selector, keepData ) { |
| 4115 | + for ( var i = 0, elem; (elem = this[i]) != null; i++ ) { |
| 4116 | + if ( !selector || jQuery.filter( selector, [ elem ] ).length ) { |
| 4117 | + if ( !keepData && elem.nodeType === 1 ) { |
| 4118 | + jQuery.cleanData( elem.getElementsByTagName("*") ); |
| 4119 | + jQuery.cleanData( [ elem ] ); |
| 4120 | + } |
| 4121 | + |
| 4122 | + if ( elem.parentNode ) { |
| 4123 | + elem.parentNode.removeChild( elem ); |
| 4124 | + } |
| 4125 | + } |
| 4126 | + } |
| 4127 | + |
| 4128 | + return this; |
| 4129 | + }, |
| 4130 | + |
| 4131 | + empty: function() { |
| 4132 | + for ( var i = 0, elem; (elem = this[i]) != null; i++ ) { |
| 4133 | + // Remove element nodes and prevent memory leaks |
| 4134 | + if ( elem.nodeType === 1 ) { |
| 4135 | + jQuery.cleanData( elem.getElementsByTagName("*") ); |
| 4136 | + } |
| 4137 | + |
| 4138 | + // Remove any remaining nodes |
| 4139 | + while ( elem.firstChild ) { |
| 4140 | + elem.removeChild( elem.firstChild ); |
| 4141 | + } |
| 4142 | + } |
| 4143 | + |
| 4144 | + return this; |
| 4145 | + }, |
| 4146 | + |
| 4147 | + clone: function( events ) { |
| 4148 | + // Do the clone |
| 4149 | + var ret = this.map(function() { |
| 4150 | + if ( !jQuery.support.noCloneEvent && !jQuery.isXMLDoc(this) ) { |
| 4151 | + // IE copies events bound via attachEvent when |
| 4152 | + // using cloneNode. Calling detachEvent on the |
| 4153 | + // clone will also remove the events from the orignal |
| 4154 | + // In order to get around this, we use innerHTML. |
| 4155 | + // Unfortunately, this means some modifications to |
| 4156 | + // attributes in IE that are actually only stored |
| 4157 | + // as properties will not be copied (such as the |
| 4158 | + // the name attribute on an input). |
| 4159 | + var html = this.outerHTML, ownerDocument = this.ownerDocument; |
| 4160 | + if ( !html ) { |
| 4161 | + var div = ownerDocument.createElement("div"); |
| 4162 | + div.appendChild( this.cloneNode(true) ); |
| 4163 | + html = div.innerHTML; |
| 4164 | + } |
| 4165 | + |
| 4166 | + return jQuery.clean([html.replace(rinlinejQuery, "") |
| 4167 | + // Handle the case in IE 8 where action=/test/> self-closes a tag |
| 4168 | + .replace(/=([^="'>\s]+\/)>/g, '="$1">') |
| 4169 | + .replace(rleadingWhitespace, "")], ownerDocument)[0]; |
| 4170 | + } else { |
| 4171 | + return this.cloneNode(true); |
| 4172 | + } |
| 4173 | + }); |
| 4174 | + |
| 4175 | + // Copy the events from the original to the clone |
| 4176 | + if ( events === true ) { |
| 4177 | + cloneCopyEvent( this, ret ); |
| 4178 | + cloneCopyEvent( this.find("*"), ret.find("*") ); |
| 4179 | + } |
| 4180 | + |
| 4181 | + // Return the cloned set |
| 4182 | + return ret; |
| 4183 | + }, |
| 4184 | + |
| 4185 | + html: function( value ) { |
| 4186 | + if ( value === undefined ) { |
| 4187 | + return this[0] && this[0].nodeType === 1 ? |
| 4188 | + this[0].innerHTML.replace(rinlinejQuery, "") : |
| 4189 | + null; |
| 4190 | + |
| 4191 | + // See if we can take a shortcut and just use innerHTML |
| 4192 | + } else if ( typeof value === "string" && !rnocache.test( value ) && |
| 4193 | + (jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value )) && |
| 4194 | + !wrapMap[ (rtagName.exec( value ) || ["", ""])[1].toLowerCase() ] ) { |
| 4195 | + |
| 4196 | + value = value.replace(rxhtmlTag, fcloseTag); |
| 4197 | + |
| 4198 | + try { |
| 4199 | + for ( var i = 0, l = this.length; i < l; i++ ) { |
| 4200 | + // Remove element nodes and prevent memory leaks |
| 4201 | + if ( this[i].nodeType === 1 ) { |
| 4202 | + jQuery.cleanData( this[i].getElementsByTagName("*") ); |
| 4203 | + this[i].innerHTML = value; |
| 4204 | + } |
| 4205 | + } |
| 4206 | + |
| 4207 | + // If using innerHTML throws an exception, use the fallback method |
| 4208 | + } catch(e) { |
| 4209 | + this.empty().append( value ); |
| 4210 | + } |
| 4211 | + |
| 4212 | + } else if ( jQuery.isFunction( value ) ) { |
| 4213 | + this.each(function(i){ |
| 4214 | + var self = jQuery(this), old = self.html(); |
| 4215 | + self.empty().append(function(){ |
| 4216 | + return value.call( this, i, old ); |
| 4217 | + }); |
| 4218 | + }); |
| 4219 | + |
| 4220 | + } else { |
| 4221 | + this.empty().append( value ); |
| 4222 | + } |
| 4223 | + |
| 4224 | + return this; |
| 4225 | + }, |
| 4226 | + |
| 4227 | + replaceWith: function( value ) { |
| 4228 | + if ( this[0] && this[0].parentNode ) { |
| 4229 | + // Make sure that the elements are removed from the DOM before they are inserted |
| 4230 | + // this can help fix replacing a parent with child elements |
| 4231 | + if ( jQuery.isFunction( value ) ) { |
| 4232 | + return this.each(function(i) { |
| 4233 | + var self = jQuery(this), old = self.html(); |
| 4234 | + self.replaceWith( value.call( this, i, old ) ); |
| 4235 | + }); |
| 4236 | + } |
| 4237 | + |
| 4238 | + if ( typeof value !== "string" ) { |
| 4239 | + value = jQuery(value).detach(); |
| 4240 | + } |
| 4241 | + |
| 4242 | + return this.each(function() { |
| 4243 | + var next = this.nextSibling, parent = this.parentNode; |
| 4244 | + |
| 4245 | + jQuery(this).remove(); |
| 4246 | + |
| 4247 | + if ( next ) { |
| 4248 | + jQuery(next).before( value ); |
| 4249 | + } else { |
| 4250 | + jQuery(parent).append( value ); |
| 4251 | + } |
| 4252 | + }); |
| 4253 | + } else { |
| 4254 | + return this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value ); |
| 4255 | + } |
| 4256 | + }, |
| 4257 | + |
| 4258 | + detach: function( selector ) { |
| 4259 | + return this.remove( selector, true ); |
| 4260 | + }, |
| 4261 | + |
| 4262 | + domManip: function( args, table, callback ) { |
| 4263 | + var results, first, value = args[0], scripts = [], fragment, parent; |
| 4264 | + |
| 4265 | + // We can't cloneNode fragments that contain checked, in WebKit |
| 4266 | + if ( !jQuery.support.checkClone && arguments.length === 3 && typeof value === "string" && rchecked.test( value ) ) { |
| 4267 | + return this.each(function() { |
| 4268 | + jQuery(this).domManip( args, table, callback, true ); |
| 4269 | + }); |
| 4270 | + } |
| 4271 | + |
| 4272 | + if ( jQuery.isFunction(value) ) { |
| 4273 | + return this.each(function(i) { |
| 4274 | + var self = jQuery(this); |
| 4275 | + args[0] = value.call(this, i, table ? self.html() : undefined); |
| 4276 | + self.domManip( args, table, callback ); |
| 4277 | + }); |
| 4278 | + } |
| 4279 | + |
| 4280 | + if ( this[0] ) { |
| 4281 | + parent = value && value.parentNode; |
| 4282 | + |
| 4283 | + // If we're in a fragment, just use that instead of building a new one |
| 4284 | + if ( jQuery.support.parentNode && parent && parent.nodeType === 11 && parent.childNodes.length === this.length ) { |
| 4285 | + results = { fragment: parent }; |
| 4286 | + |
| 4287 | + } else { |
| 4288 | + results = buildFragment( args, this, scripts ); |
| 4289 | + } |
| 4290 | + |
| 4291 | + fragment = results.fragment; |
| 4292 | + |
| 4293 | + if ( fragment.childNodes.length === 1 ) { |
| 4294 | + first = fragment = fragment.firstChild; |
| 4295 | + } else { |
| 4296 | + first = fragment.firstChild; |
| 4297 | + } |
| 4298 | + |
| 4299 | + if ( first ) { |
| 4300 | + table = table && jQuery.nodeName( first, "tr" ); |
| 4301 | + |
| 4302 | + for ( var i = 0, l = this.length; i < l; i++ ) { |
| 4303 | + callback.call( |
| 4304 | + table ? |
| 4305 | + root(this[i], first) : |
| 4306 | + this[i], |
| 4307 | + i > 0 || results.cacheable || this.length > 1 ? |
| 4308 | + fragment.cloneNode(true) : |
| 4309 | + fragment |
| 4310 | + ); |
| 4311 | + } |
| 4312 | + } |
| 4313 | + |
| 4314 | + if ( scripts.length ) { |
| 4315 | + jQuery.each( scripts, evalScript ); |
| 4316 | + } |
| 4317 | + } |
| 4318 | + |
| 4319 | + return this; |
| 4320 | + |
| 4321 | + function root( elem, cur ) { |
| 4322 | + return jQuery.nodeName(elem, "table") ? |
| 4323 | + (elem.getElementsByTagName("tbody")[0] || |
| 4324 | + elem.appendChild(elem.ownerDocument.createElement("tbody"))) : |
| 4325 | + elem; |
| 4326 | + } |
| 4327 | + } |
| 4328 | +}); |
| 4329 | + |
| 4330 | +function cloneCopyEvent(orig, ret) { |
| 4331 | + var i = 0; |
| 4332 | + |
| 4333 | + ret.each(function() { |
| 4334 | + if ( this.nodeName !== (orig[i] && orig[i].nodeName) ) { |
| 4335 | + return; |
| 4336 | + } |
| 4337 | + |
| 4338 | + var oldData = jQuery.data( orig[i++] ), curData = jQuery.data( this, oldData ), events = oldData && oldData.events; |
| 4339 | + |
| 4340 | + if ( events ) { |
| 4341 | + delete curData.handle; |
| 4342 | + curData.events = {}; |
| 4343 | + |
| 4344 | + for ( var type in events ) { |
| 4345 | + for ( var handler in events[ type ] ) { |
| 4346 | + jQuery.event.add( this, type, events[ type ][ handler ], events[ type ][ handler ].data ); |
| 4347 | + } |
| 4348 | + } |
| 4349 | + } |
| 4350 | + }); |
| 4351 | +} |
| 4352 | + |
| 4353 | +function buildFragment( args, nodes, scripts ) { |
| 4354 | + var fragment, cacheable, cacheresults, |
| 4355 | + doc = (nodes && nodes[0] ? nodes[0].ownerDocument || nodes[0] : document); |
| 4356 | + |
| 4357 | + // Only cache "small" (1/2 KB) strings that are associated with the main document |
| 4358 | + // Cloning options loses the selected state, so don't cache them |
| 4359 | + // IE 6 doesn't like it when you put <object> or <embed> elements in a fragment |
| 4360 | + // Also, WebKit does not clone 'checked' attributes on cloneNode, so don't cache |
| 4361 | + if ( args.length === 1 && typeof args[0] === "string" && args[0].length < 512 && doc === document && |
| 4362 | + !rnocache.test( args[0] ) && (jQuery.support.checkClone || !rchecked.test( args[0] )) ) { |
| 4363 | + |
| 4364 | + cacheable = true; |
| 4365 | + cacheresults = jQuery.fragments[ args[0] ]; |
| 4366 | + if ( cacheresults ) { |
| 4367 | + if ( cacheresults !== 1 ) { |
| 4368 | + fragment = cacheresults; |
| 4369 | + } |
| 4370 | + } |
| 4371 | + } |
| 4372 | + |
| 4373 | + if ( !fragment ) { |
| 4374 | + fragment = doc.createDocumentFragment(); |
| 4375 | + jQuery.clean( args, doc, fragment, scripts ); |
| 4376 | + } |
| 4377 | + |
| 4378 | + if ( cacheable ) { |
| 4379 | + jQuery.fragments[ args[0] ] = cacheresults ? fragment : 1; |
| 4380 | + } |
| 4381 | + |
| 4382 | + return { fragment: fragment, cacheable: cacheable }; |
| 4383 | +} |
| 4384 | + |
| 4385 | +jQuery.fragments = {}; |
| 4386 | + |
| 4387 | +jQuery.each({ |
| 4388 | + appendTo: "append", |
| 4389 | + prependTo: "prepend", |
| 4390 | + insertBefore: "before", |
| 4391 | + insertAfter: "after", |
| 4392 | + replaceAll: "replaceWith" |
| 4393 | +}, function( name, original ) { |
| 4394 | + jQuery.fn[ name ] = function( selector ) { |
| 4395 | + var ret = [], insert = jQuery( selector ), |
| 4396 | + parent = this.length === 1 && this[0].parentNode; |
| 4397 | + |
| 4398 | + if ( parent && parent.nodeType === 11 && parent.childNodes.length === 1 && insert.length === 1 ) { |
| 4399 | + insert[ original ]( this[0] ); |
| 4400 | + return this; |
| 4401 | + |
| 4402 | + } else { |
| 4403 | + for ( var i = 0, l = insert.length; i < l; i++ ) { |
| 4404 | + var elems = (i > 0 ? this.clone(true) : this).get(); |
| 4405 | + jQuery.fn[ original ].apply( jQuery(insert[i]), elems ); |
| 4406 | + ret = ret.concat( elems ); |
| 4407 | + } |
| 4408 | + |
| 4409 | + return this.pushStack( ret, name, insert.selector ); |
| 4410 | + } |
| 4411 | + }; |
| 4412 | +}); |
| 4413 | + |
| 4414 | +jQuery.extend({ |
| 4415 | + clean: function( elems, context, fragment, scripts ) { |
| 4416 | + context = context || document; |
| 4417 | + |
| 4418 | + // !context.createElement fails in IE with an error but returns typeof 'object' |
| 4419 | + if ( typeof context.createElement === "undefined" ) { |
| 4420 | + context = context.ownerDocument || context[0] && context[0].ownerDocument || document; |
| 4421 | + } |
| 4422 | + |
| 4423 | + var ret = []; |
| 4424 | + |
| 4425 | + for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) { |
| 4426 | + if ( typeof elem === "number" ) { |
| 4427 | + elem += ""; |
| 4428 | + } |
| 4429 | + |
| 4430 | + if ( !elem ) { |
| 4431 | + continue; |
| 4432 | + } |
| 4433 | + |
| 4434 | + // Convert html string into DOM nodes |
| 4435 | + if ( typeof elem === "string" && !rhtml.test( elem ) ) { |
| 4436 | + elem = context.createTextNode( elem ); |
| 4437 | + |
| 4438 | + } else if ( typeof elem === "string" ) { |
| 4439 | + // Fix "XHTML"-style tags in all browsers |
| 4440 | + elem = elem.replace(rxhtmlTag, fcloseTag); |
| 4441 | + |
| 4442 | + // Trim whitespace, otherwise indexOf won't work as expected |
| 4443 | + var tag = (rtagName.exec( elem ) || ["", ""])[1].toLowerCase(), |
| 4444 | + wrap = wrapMap[ tag ] || wrapMap._default, |
| 4445 | + depth = wrap[0], |
| 4446 | + div = context.createElement("div"); |
| 4447 | + |
| 4448 | + // Go to html and back, then peel off extra wrappers |
| 4449 | + div.innerHTML = wrap[1] + elem + wrap[2]; |
| 4450 | + |
| 4451 | + // Move to the right depth |
| 4452 | + while ( depth-- ) { |
| 4453 | + div = div.lastChild; |
| 4454 | + } |
| 4455 | + |
| 4456 | + // Remove IE's autoinserted <tbody> from table fragments |
| 4457 | + if ( !jQuery.support.tbody ) { |
| 4458 | + |
| 4459 | + // String was a <table>, *may* have spurious <tbody> |
| 4460 | + var hasBody = rtbody.test(elem), |
| 4461 | + tbody = tag === "table" && !hasBody ? |
| 4462 | + div.firstChild && div.firstChild.childNodes : |
| 4463 | + |
| 4464 | + // String was a bare <thead> or <tfoot> |
| 4465 | + wrap[1] === "<table>" && !hasBody ? |
| 4466 | + div.childNodes : |
| 4467 | + []; |
| 4468 | + |
| 4469 | + for ( var j = tbody.length - 1; j >= 0 ; --j ) { |
| 4470 | + if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) { |
| 4471 | + tbody[ j ].parentNode.removeChild( tbody[ j ] ); |
| 4472 | + } |
| 4473 | + } |
| 4474 | + |
| 4475 | + } |
| 4476 | + |
| 4477 | + // IE completely kills leading whitespace when innerHTML is used |
| 4478 | + if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) { |
| 4479 | + div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild ); |
| 4480 | + } |
| 4481 | + |
| 4482 | + elem = div.childNodes; |
| 4483 | + } |
| 4484 | + |
| 4485 | + if ( elem.nodeType ) { |
| 4486 | + ret.push( elem ); |
| 4487 | + } else { |
| 4488 | + ret = jQuery.merge( ret, elem ); |
| 4489 | + } |
| 4490 | + } |
| 4491 | + |
| 4492 | + if ( fragment ) { |
| 4493 | + for ( var i = 0; ret[i]; i++ ) { |
| 4494 | + if ( scripts && jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) { |
| 4495 | + scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] ); |
| 4496 | + |
| 4497 | + } else { |
| 4498 | + if ( ret[i].nodeType === 1 ) { |
| 4499 | + ret.splice.apply( ret, [i + 1, 0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))) ); |
| 4500 | + } |
| 4501 | + fragment.appendChild( ret[i] ); |
| 4502 | + } |
| 4503 | + } |
| 4504 | + } |
| 4505 | + |
| 4506 | + return ret; |
| 4507 | + }, |
| 4508 | + |
| 4509 | + cleanData: function( elems ) { |
| 4510 | + var data, id, cache = jQuery.cache, |
| 4511 | + special = jQuery.event.special, |
| 4512 | + deleteExpando = jQuery.support.deleteExpando; |
| 4513 | + |
| 4514 | + for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) { |
| 4515 | + id = elem[ jQuery.expando ]; |
| 4516 | + |
| 4517 | + if ( id ) { |
| 4518 | + data = cache[ id ]; |
| 4519 | + |
| 4520 | + if ( data.events ) { |
| 4521 | + for ( var type in data.events ) { |
| 4522 | + if ( special[ type ] ) { |
| 4523 | + jQuery.event.remove( elem, type ); |
| 4524 | + |
| 4525 | + } else { |
| 4526 | + removeEvent( elem, type, data.handle ); |
| 4527 | + } |
| 4528 | + } |
| 4529 | + } |
| 4530 | + |
| 4531 | + if ( deleteExpando ) { |
| 4532 | + delete elem[ jQuery.expando ]; |
| 4533 | + |
| 4534 | + } else if ( elem.removeAttribute ) { |
| 4535 | + elem.removeAttribute( jQuery.expando ); |
| 4536 | + } |
| 4537 | + |
| 4538 | + delete cache[ id ]; |
| 4539 | + } |
| 4540 | + } |
| 4541 | + } |
| 4542 | +}); |
| 4543 | +// exclude the following css properties to add px |
| 4544 | +var rexclude = /z-?index|font-?weight|opacity|zoom|line-?height/i, |
| 4545 | + ralpha = /alpha\([^)]*\)/, |
| 4546 | + ropacity = /opacity=([^)]*)/, |
| 4547 | + rfloat = /float/i, |
| 4548 | + rdashAlpha = /-([a-z])/ig, |
| 4549 | + rupper = /([A-Z])/g, |
| 4550 | + rnumpx = /^-?\d+(?:px)?$/i, |
| 4551 | + rnum = /^-?\d/, |
| 4552 | + |
| 4553 | + cssShow = { position: "absolute", visibility: "hidden", display:"block" }, |
| 4554 | + cssWidth = [ "Left", "Right" ], |
| 4555 | + cssHeight = [ "Top", "Bottom" ], |
| 4556 | + |
| 4557 | + // cache check for defaultView.getComputedStyle |
| 4558 | + getComputedStyle = document.defaultView && document.defaultView.getComputedStyle, |
| 4559 | + // normalize float css property |
| 4560 | + styleFloat = jQuery.support.cssFloat ? "cssFloat" : "styleFloat", |
| 4561 | + fcamelCase = function( all, letter ) { |
| 4562 | + return letter.toUpperCase(); |
| 4563 | + }; |
| 4564 | + |
| 4565 | +jQuery.fn.css = function( name, value ) { |
| 4566 | + return access( this, name, value, true, function( elem, name, value ) { |
| 4567 | + if ( value === undefined ) { |
| 4568 | + return jQuery.curCSS( elem, name ); |
| 4569 | + } |
| 4570 | + |
| 4571 | + if ( typeof value === "number" && !rexclude.test(name) ) { |
| 4572 | + value += "px"; |
| 4573 | + } |
| 4574 | + |
| 4575 | + jQuery.style( elem, name, value ); |
| 4576 | + }); |
| 4577 | +}; |
| 4578 | + |
| 4579 | +jQuery.extend({ |
| 4580 | + style: function( elem, name, value ) { |
| 4581 | + // don't set styles on text and comment nodes |
| 4582 | + if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) { |
| 4583 | + return undefined; |
| 4584 | + } |
| 4585 | + |
| 4586 | + // ignore negative width and height values #1599 |
| 4587 | + if ( (name === "width" || name === "height") && parseFloat(value) < 0 ) { |
| 4588 | + value = undefined; |
| 4589 | + } |
| 4590 | + |
| 4591 | + var style = elem.style || elem, set = value !== undefined; |
| 4592 | + |
| 4593 | + // IE uses filters for opacity |
| 4594 | + if ( !jQuery.support.opacity && name === "opacity" ) { |
| 4595 | + if ( set ) { |
| 4596 | + // IE has trouble with opacity if it does not have layout |
| 4597 | + // Force it by setting the zoom level |
| 4598 | + style.zoom = 1; |
| 4599 | + |
| 4600 | + // Set the alpha filter to set the opacity |
| 4601 | + var opacity = parseInt( value, 10 ) + "" === "NaN" ? "" : "alpha(opacity=" + value * 100 + ")"; |
| 4602 | + var filter = style.filter || jQuery.curCSS( elem, "filter" ) || ""; |
| 4603 | + style.filter = ralpha.test(filter) ? filter.replace(ralpha, opacity) : opacity; |
| 4604 | + } |
| 4605 | + |
| 4606 | + return style.filter && style.filter.indexOf("opacity=") >= 0 ? |
| 4607 | + (parseFloat( ropacity.exec(style.filter)[1] ) / 100) + "": |
| 4608 | + ""; |
| 4609 | + } |
| 4610 | + |
| 4611 | + // Make sure we're using the right name for getting the float value |
| 4612 | + if ( rfloat.test( name ) ) { |
| 4613 | + name = styleFloat; |
| 4614 | + } |
| 4615 | + |
| 4616 | + name = name.replace(rdashAlpha, fcamelCase); |
| 4617 | + |
| 4618 | + if ( set ) { |
| 4619 | + style[ name ] = value; |
| 4620 | + } |
| 4621 | + |
| 4622 | + return style[ name ]; |
| 4623 | + }, |
| 4624 | + |
| 4625 | + css: function( elem, name, force, extra ) { |
| 4626 | + if ( name === "width" || name === "height" ) { |
| 4627 | + var val, props = cssShow, which = name === "width" ? cssWidth : cssHeight; |
| 4628 | + |
| 4629 | + function getWH() { |
| 4630 | + val = name === "width" ? elem.offsetWidth : elem.offsetHeight; |
| 4631 | + |
| 4632 | + if ( extra === "border" ) { |
| 4633 | + return; |
| 4634 | + } |
| 4635 | + |
| 4636 | + jQuery.each( which, function() { |
| 4637 | + if ( !extra ) { |
| 4638 | + val -= parseFloat(jQuery.curCSS( elem, "padding" + this, true)) || 0; |
| 4639 | + } |
| 4640 | + |
| 4641 | + if ( extra === "margin" ) { |
| 4642 | + val += parseFloat(jQuery.curCSS( elem, "margin" + this, true)) || 0; |
| 4643 | + } else { |
| 4644 | + val -= parseFloat(jQuery.curCSS( elem, "border" + this + "Width", true)) || 0; |
| 4645 | + } |
| 4646 | + }); |
| 4647 | + } |
| 4648 | + |
| 4649 | + if ( elem.offsetWidth !== 0 ) { |
| 4650 | + getWH(); |
| 4651 | + } else { |
| 4652 | + jQuery.swap( elem, props, getWH ); |
| 4653 | + } |
| 4654 | + |
| 4655 | + return Math.max(0, Math.round(val)); |
| 4656 | + } |
| 4657 | + |
| 4658 | + return jQuery.curCSS( elem, name, force ); |
| 4659 | + }, |
| 4660 | + |
| 4661 | + curCSS: function( elem, name, force ) { |
| 4662 | + var ret, style = elem.style, filter; |
| 4663 | + |
| 4664 | + // IE uses filters for opacity |
| 4665 | + if ( !jQuery.support.opacity && name === "opacity" && elem.currentStyle ) { |
| 4666 | + ret = ropacity.test(elem.currentStyle.filter || "") ? |
| 4667 | + (parseFloat(RegExp.$1) / 100) + "" : |
| 4668 | + ""; |
| 4669 | + |
| 4670 | + return ret === "" ? |
| 4671 | + "1" : |
| 4672 | + ret; |
| 4673 | + } |
| 4674 | + |
| 4675 | + // Make sure we're using the right name for getting the float value |
| 4676 | + if ( rfloat.test( name ) ) { |
| 4677 | + name = styleFloat; |
| 4678 | + } |
| 4679 | + |
| 4680 | + if ( !force && style && style[ name ] ) { |
| 4681 | + ret = style[ name ]; |
| 4682 | + |
| 4683 | + } else if ( getComputedStyle ) { |
| 4684 | + |
| 4685 | + // Only "float" is needed here |
| 4686 | + if ( rfloat.test( name ) ) { |
| 4687 | + name = "float"; |
| 4688 | + } |
| 4689 | + |
| 4690 | + name = name.replace( rupper, "-$1" ).toLowerCase(); |
| 4691 | + |
| 4692 | + var defaultView = elem.ownerDocument.defaultView; |
| 4693 | + |
| 4694 | + if ( !defaultView ) { |
| 4695 | + return null; |
| 4696 | + } |
| 4697 | + |
| 4698 | + var computedStyle = defaultView.getComputedStyle( elem, null ); |
| 4699 | + |
| 4700 | + if ( computedStyle ) { |
| 4701 | + ret = computedStyle.getPropertyValue( name ); |
| 4702 | + } |
| 4703 | + |
| 4704 | + // We should always get a number back from opacity |
| 4705 | + if ( name === "opacity" && ret === "" ) { |
| 4706 | + ret = "1"; |
| 4707 | + } |
| 4708 | + |
| 4709 | + } else if ( elem.currentStyle ) { |
| 4710 | + var camelCase = name.replace(rdashAlpha, fcamelCase); |
| 4711 | + |
| 4712 | + ret = elem.currentStyle[ name ] || elem.currentStyle[ camelCase ]; |
| 4713 | + |
| 4714 | + // From the awesome hack by Dean Edwards |
| 4715 | + // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291 |
| 4716 | + |
| 4717 | + // If we're not dealing with a regular pixel number |
| 4718 | + // but a number that has a weird ending, we need to convert it to pixels |
| 4719 | + if ( !rnumpx.test( ret ) && rnum.test( ret ) ) { |
| 4720 | + // Remember the original values |
| 4721 | + var left = style.left, rsLeft = elem.runtimeStyle.left; |
| 4722 | + |
| 4723 | + // Put in the new values to get a computed value out |
| 4724 | + elem.runtimeStyle.left = elem.currentStyle.left; |
| 4725 | + style.left = camelCase === "fontSize" ? "1em" : (ret || 0); |
| 4726 | + ret = style.pixelLeft + "px"; |
| 4727 | + |
| 4728 | + // Revert the changed values |
| 4729 | + style.left = left; |
| 4730 | + elem.runtimeStyle.left = rsLeft; |
| 4731 | + } |
| 4732 | + } |
| 4733 | + |
| 4734 | + return ret; |
| 4735 | + }, |
| 4736 | + |
| 4737 | + // A method for quickly swapping in/out CSS properties to get correct calculations |
| 4738 | + swap: function( elem, options, callback ) { |
| 4739 | + var old = {}; |
| 4740 | + |
| 4741 | + // Remember the old values, and insert the new ones |
| 4742 | + for ( var name in options ) { |
| 4743 | + old[ name ] = elem.style[ name ]; |
| 4744 | + elem.style[ name ] = options[ name ]; |
| 4745 | + } |
| 4746 | + |
| 4747 | + callback.call( elem ); |
| 4748 | + |
| 4749 | + // Revert the old values |
| 4750 | + for ( var name in options ) { |
| 4751 | + elem.style[ name ] = old[ name ]; |
| 4752 | + } |
| 4753 | + } |
| 4754 | +}); |
| 4755 | + |
| 4756 | +if ( jQuery.expr && jQuery.expr.filters ) { |
| 4757 | + jQuery.expr.filters.hidden = function( elem ) { |
| 4758 | + var width = elem.offsetWidth, height = elem.offsetHeight, |
| 4759 | + skip = elem.nodeName.toLowerCase() === "tr"; |
| 4760 | + |
| 4761 | + return width === 0 && height === 0 && !skip ? |
| 4762 | + true : |
| 4763 | + width > 0 && height > 0 && !skip ? |
| 4764 | + false : |
| 4765 | + jQuery.curCSS(elem, "display") === "none"; |
| 4766 | + }; |
| 4767 | + |
| 4768 | + jQuery.expr.filters.visible = function( elem ) { |
| 4769 | + return !jQuery.expr.filters.hidden( elem ); |
| 4770 | + }; |
| 4771 | +} |
| 4772 | +var jsc = now(), |
| 4773 | + rscript = /<script(.|\s)*?\/script>/gi, |
| 4774 | + rselectTextarea = /select|textarea/i, |
| 4775 | + rinput = /color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week/i, |
| 4776 | + jsre = /=\?(&|$)/, |
| 4777 | + rquery = /\?/, |
| 4778 | + rts = /(\?|&)_=.*?(&|$)/, |
| 4779 | + rurl = /^(\w+:)?\/\/([^\/?#]+)/, |
| 4780 | + r20 = /%20/g, |
| 4781 | + |
| 4782 | + // Keep a copy of the old load method |
| 4783 | + _load = jQuery.fn.load; |
| 4784 | + |
| 4785 | +jQuery.fn.extend({ |
| 4786 | + load: function( url, params, callback ) { |
| 4787 | + if ( typeof url !== "string" ) { |
| 4788 | + return _load.call( this, url ); |
| 4789 | + |
| 4790 | + // Don't do a request if no elements are being requested |
| 4791 | + } else if ( !this.length ) { |
| 4792 | + return this; |
| 4793 | + } |
| 4794 | + |
| 4795 | + var off = url.indexOf(" "); |
| 4796 | + if ( off >= 0 ) { |
| 4797 | + var selector = url.slice(off, url.length); |
| 4798 | + url = url.slice(0, off); |
| 4799 | + } |
| 4800 | + |
| 4801 | + // Default to a GET request |
| 4802 | + var type = "GET"; |
| 4803 | + |
| 4804 | + // If the second parameter was provided |
| 4805 | + if ( params ) { |
| 4806 | + // If it's a function |
| 4807 | + if ( jQuery.isFunction( params ) ) { |
| 4808 | + // We assume that it's the callback |
| 4809 | + callback = params; |
| 4810 | + params = null; |
| 4811 | + |
| 4812 | + // Otherwise, build a param string |
| 4813 | + } else if ( typeof params === "object" ) { |
| 4814 | + params = jQuery.param( params, jQuery.ajaxSettings.traditional ); |
| 4815 | + type = "POST"; |
| 4816 | + } |
| 4817 | + } |
| 4818 | + |
| 4819 | + var self = this; |
| 4820 | + |
| 4821 | + // Request the remote document |
| 4822 | + jQuery.ajax({ |
| 4823 | + url: url, |
| 4824 | + type: type, |
| 4825 | + dataType: "html", |
| 4826 | + data: params, |
| 4827 | + complete: function( res, status ) { |
| 4828 | + // If successful, inject the HTML into all the matched elements |
| 4829 | + if ( status === "success" || status === "notmodified" ) { |
| 4830 | + // See if a selector was specified |
| 4831 | + self.html( selector ? |
| 4832 | + // Create a dummy div to hold the results |
| 4833 | + jQuery("<div />") |
| 4834 | + // inject the contents of the document in, removing the scripts |
| 4835 | + // to avoid any 'Permission Denied' errors in IE |
| 4836 | + .append(res.responseText.replace(rscript, "")) |
| 4837 | + |
| 4838 | + // Locate the specified elements |
| 4839 | + .find(selector) : |
| 4840 | + |
| 4841 | + // If not, just inject the full result |
| 4842 | + res.responseText ); |
| 4843 | + } |
| 4844 | + |
| 4845 | + if ( callback ) { |
| 4846 | + self.each( callback, [res.responseText, status, res] ); |
| 4847 | + } |
| 4848 | + } |
| 4849 | + }); |
| 4850 | + |
| 4851 | + return this; |
| 4852 | + }, |
| 4853 | + |
| 4854 | + serialize: function() { |
| 4855 | + return jQuery.param(this.serializeArray()); |
| 4856 | + }, |
| 4857 | + serializeArray: function() { |
| 4858 | + return this.map(function() { |
| 4859 | + return this.elements ? jQuery.makeArray(this.elements) : this; |
| 4860 | + }) |
| 4861 | + .filter(function() { |
| 4862 | + return this.name && !this.disabled && |
| 4863 | + (this.checked || rselectTextarea.test(this.nodeName) || |
| 4864 | + rinput.test(this.type)); |
| 4865 | + }) |
| 4866 | + .map(function( i, elem ) { |
| 4867 | + var val = jQuery(this).val(); |
| 4868 | + |
| 4869 | + return val == null ? |
| 4870 | + null : |
| 4871 | + jQuery.isArray(val) ? |
| 4872 | + jQuery.map( val, function( val, i ) { |
| 4873 | + return { name: elem.name, value: val }; |
| 4874 | + }) : |
| 4875 | + { name: elem.name, value: val }; |
| 4876 | + }).get(); |
| 4877 | + } |
| 4878 | +}); |
| 4879 | + |
| 4880 | +// Attach a bunch of functions for handling common AJAX events |
| 4881 | +jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "), function( i, o ) { |
| 4882 | + jQuery.fn[o] = function( f ) { |
| 4883 | + return this.bind(o, f); |
| 4884 | + }; |
| 4885 | +}); |
| 4886 | + |
| 4887 | +jQuery.extend({ |
| 4888 | + |
| 4889 | + get: function( url, data, callback, type ) { |
| 4890 | + // shift arguments if data argument was omited |
| 4891 | + if ( jQuery.isFunction( data ) ) { |
| 4892 | + type = type || callback; |
| 4893 | + callback = data; |
| 4894 | + data = null; |
| 4895 | + } |
| 4896 | + |
| 4897 | + return jQuery.ajax({ |
| 4898 | + type: "GET", |
| 4899 | + url: url, |
| 4900 | + data: data, |
| 4901 | + success: callback, |
| 4902 | + dataType: type |
| 4903 | + }); |
| 4904 | + }, |
| 4905 | + |
| 4906 | + getScript: function( url, callback ) { |
| 4907 | + return jQuery.get(url, null, callback, "script"); |
| 4908 | + }, |
| 4909 | + |
| 4910 | + getJSON: function( url, data, callback ) { |
| 4911 | + return jQuery.get(url, data, callback, "json"); |
| 4912 | + }, |
| 4913 | + |
| 4914 | + post: function( url, data, callback, type ) { |
| 4915 | + // shift arguments if data argument was omited |
| 4916 | + if ( jQuery.isFunction( data ) ) { |
| 4917 | + type = type || callback; |
| 4918 | + callback = data; |
| 4919 | + data = {}; |
| 4920 | + } |
| 4921 | + |
| 4922 | + return jQuery.ajax({ |
| 4923 | + type: "POST", |
| 4924 | + url: url, |
| 4925 | + data: data, |
| 4926 | + success: callback, |
| 4927 | + dataType: type |
| 4928 | + }); |
| 4929 | + }, |
| 4930 | + |
| 4931 | + ajaxSetup: function( settings ) { |
| 4932 | + jQuery.extend( jQuery.ajaxSettings, settings ); |
| 4933 | + }, |
| 4934 | + |
| 4935 | + ajaxSettings: { |
| 4936 | + url: location.href, |
| 4937 | + global: true, |
| 4938 | + type: "GET", |
| 4939 | + contentType: "application/x-www-form-urlencoded", |
| 4940 | + processData: true, |
| 4941 | + async: true, |
| 4942 | + /* |
| 4943 | + timeout: 0, |
| 4944 | + data: null, |
| 4945 | + username: null, |
| 4946 | + password: null, |
| 4947 | + traditional: false, |
| 4948 | + */ |
| 4949 | + // Create the request object; Microsoft failed to properly |
| 4950 | + // implement the XMLHttpRequest in IE7 (can't request local files), |
| 4951 | + // so we use the ActiveXObject when it is available |
| 4952 | + // This function can be overriden by calling jQuery.ajaxSetup |
| 4953 | + xhr: window.XMLHttpRequest && (window.location.protocol !== "file:" || !window.ActiveXObject) ? |
| 4954 | + function() { |
| 4955 | + return new window.XMLHttpRequest(); |
| 4956 | + } : |
| 4957 | + function() { |
| 4958 | + try { |
| 4959 | + return new window.ActiveXObject("Microsoft.XMLHTTP"); |
| 4960 | + } catch(e) {} |
| 4961 | + }, |
| 4962 | + accepts: { |
| 4963 | + xml: "application/xml, text/xml", |
| 4964 | + html: "text/html", |
| 4965 | + script: "text/javascript, application/javascript", |
| 4966 | + json: "application/json, text/javascript", |
| 4967 | + text: "text/plain", |
| 4968 | + _default: "*/*" |
| 4969 | + } |
| 4970 | + }, |
| 4971 | + |
| 4972 | + // Last-Modified header cache for next request |
| 4973 | + lastModified: {}, |
| 4974 | + etag: {}, |
| 4975 | + |
| 4976 | + ajax: function( origSettings ) { |
| 4977 | + var s = jQuery.extend(true, {}, jQuery.ajaxSettings, origSettings); |
| 4978 | + |
| 4979 | + var jsonp, status, data, |
| 4980 | + callbackContext = origSettings && origSettings.context || s, |
| 4981 | + type = s.type.toUpperCase(); |
| 4982 | + |
| 4983 | + // convert data if not already a string |
| 4984 | + if ( s.data && s.processData && typeof s.data !== "string" ) { |
| 4985 | + s.data = jQuery.param( s.data, s.traditional ); |
| 4986 | + } |
| 4987 | + |
| 4988 | + // Handle JSONP Parameter Callbacks |
| 4989 | + if ( s.dataType === "jsonp" ) { |
| 4990 | + if ( type === "GET" ) { |
| 4991 | + if ( !jsre.test( s.url ) ) { |
| 4992 | + s.url += (rquery.test( s.url ) ? "&" : "?") + (s.jsonp || "callback") + "=?"; |
| 4993 | + } |
| 4994 | + } else if ( !s.data || !jsre.test(s.data) ) { |
| 4995 | + s.data = (s.data ? s.data + "&" : "") + (s.jsonp || "callback") + "=?"; |
| 4996 | + } |
| 4997 | + s.dataType = "json"; |
| 4998 | + } |
| 4999 | + |
| 5000 | + // Build temporary JSONP function |
| 5001 | + if ( s.dataType === "json" && (s.data && jsre.test(s.data) || jsre.test(s.url)) ) { |
| 5002 | + jsonp = s.jsonpCallback || ("jsonp" + jsc++); |
| 5003 | + |
| 5004 | + // Replace the =? sequence both in the query string and the data |
| 5005 | + if ( s.data ) { |
| 5006 | + s.data = (s.data + "").replace(jsre, "=" + jsonp + "$1"); |
| 5007 | + } |
| 5008 | + |
| 5009 | + s.url = s.url.replace(jsre, "=" + jsonp + "$1"); |
| 5010 | + |
| 5011 | + // We need to make sure |
| 5012 | + // that a JSONP style response is executed properly |
| 5013 | + s.dataType = "script"; |
| 5014 | + |
| 5015 | + // Handle JSONP-style loading |
| 5016 | + window[ jsonp ] = window[ jsonp ] || function( tmp ) { |
| 5017 | + data = tmp; |
| 5018 | + success(); |
| 5019 | + complete(); |
| 5020 | + // Garbage collect |
| 5021 | + window[ jsonp ] = undefined; |
| 5022 | + |
| 5023 | + try { |
| 5024 | + delete window[ jsonp ]; |
| 5025 | + } catch(e) {} |
| 5026 | + |
| 5027 | + if ( head ) { |
| 5028 | + head.removeChild( script ); |
| 5029 | + } |
| 5030 | + }; |
| 5031 | + } |
| 5032 | + |
| 5033 | + if ( s.dataType === "script" && s.cache === null ) { |
| 5034 | + s.cache = false; |
| 5035 | + } |
| 5036 | + |
| 5037 | + if ( s.cache === false && type === "GET" ) { |
| 5038 | + var ts = now(); |
| 5039 | + |
| 5040 | + // try replacing _= if it is there |
| 5041 | + var ret = s.url.replace(rts, "$1_=" + ts + "$2"); |
| 5042 | + |
| 5043 | + // if nothing was replaced, add timestamp to the end |
| 5044 | + s.url = ret + ((ret === s.url) ? (rquery.test(s.url) ? "&" : "?") + "_=" + ts : ""); |
| 5045 | + } |
| 5046 | + |
| 5047 | + // If data is available, append data to url for get requests |
| 5048 | + if ( s.data && type === "GET" ) { |
| 5049 | + s.url += (rquery.test(s.url) ? "&" : "?") + s.data; |
| 5050 | + } |
| 5051 | + |
| 5052 | + // Watch for a new set of requests |
| 5053 | + if ( s.global && ! jQuery.active++ ) { |
| 5054 | + jQuery.event.trigger( "ajaxStart" ); |
| 5055 | + } |
| 5056 | + |
| 5057 | + // Matches an absolute URL, and saves the domain |
| 5058 | + var parts = rurl.exec( s.url ), |
| 5059 | + remote = parts && (parts[1] && parts[1] !== location.protocol || parts[2] !== location.host); |
| 5060 | + |
| 5061 | + // If we're requesting a remote document |
| 5062 | + // and trying to load JSON or Script with a GET |
| 5063 | + if ( s.dataType === "script" && type === "GET" && remote ) { |
| 5064 | + var head = document.getElementsByTagName("head")[0] || document.documentElement; |
| 5065 | + var script = document.createElement("script"); |
| 5066 | + script.src = s.url; |
| 5067 | + if ( s.scriptCharset ) { |
| 5068 | + script.charset = s.scriptCharset; |
| 5069 | + } |
| 5070 | + |
| 5071 | + // Handle Script loading |
| 5072 | + if ( !jsonp ) { |
| 5073 | + var done = false; |
| 5074 | + |
| 5075 | + // Attach handlers for all browsers |
| 5076 | + script.onload = script.onreadystatechange = function() { |
| 5077 | + if ( !done && (!this.readyState || |
| 5078 | + this.readyState === "loaded" || this.readyState === "complete") ) { |
| 5079 | + done = true; |
| 5080 | + success(); |
| 5081 | + complete(); |
| 5082 | + |
| 5083 | + // Handle memory leak in IE |
| 5084 | + script.onload = script.onreadystatechange = null; |
| 5085 | + if ( head && script.parentNode ) { |
| 5086 | + head.removeChild( script ); |
| 5087 | + } |
| 5088 | + } |
| 5089 | + }; |
| 5090 | + } |
| 5091 | + |
| 5092 | + // Use insertBefore instead of appendChild to circumvent an IE6 bug. |
| 5093 | + // This arises when a base node is used (#2709 and #4378). |
| 5094 | + head.insertBefore( script, head.firstChild ); |
| 5095 | + |
| 5096 | + // We handle everything using the script element injection |
| 5097 | + return undefined; |
| 5098 | + } |
| 5099 | + |
| 5100 | + var requestDone = false; |
| 5101 | + |
| 5102 | + // Create the request object |
| 5103 | + var xhr = s.xhr(); |
| 5104 | + |
| 5105 | + if ( !xhr ) { |
| 5106 | + return; |
| 5107 | + } |
| 5108 | + |
| 5109 | + // Open the socket |
| 5110 | + // Passing null username, generates a login popup on Opera (#2865) |
| 5111 | + if ( s.username ) { |
| 5112 | + xhr.open(type, s.url, s.async, s.username, s.password); |
| 5113 | + } else { |
| 5114 | + xhr.open(type, s.url, s.async); |
| 5115 | + } |
| 5116 | + |
| 5117 | + // Need an extra try/catch for cross domain requests in Firefox 3 |
| 5118 | + try { |
| 5119 | + // Set the correct header, if data is being sent |
| 5120 | + if ( s.data || origSettings && origSettings.contentType ) { |
| 5121 | + xhr.setRequestHeader("Content-Type", s.contentType); |
| 5122 | + } |
| 5123 | + |
| 5124 | + // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. |
| 5125 | + if ( s.ifModified ) { |
| 5126 | + if ( jQuery.lastModified[s.url] ) { |
| 5127 | + xhr.setRequestHeader("If-Modified-Since", jQuery.lastModified[s.url]); |
| 5128 | + } |
| 5129 | + |
| 5130 | + if ( jQuery.etag[s.url] ) { |
| 5131 | + xhr.setRequestHeader("If-None-Match", jQuery.etag[s.url]); |
| 5132 | + } |
| 5133 | + } |
| 5134 | + |
| 5135 | + // Set header so the called script knows that it's an XMLHttpRequest |
| 5136 | + // Only send the header if it's not a remote XHR |
| 5137 | + if ( !remote ) { |
| 5138 | + xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest"); |
| 5139 | + } |
| 5140 | + |
| 5141 | + // Set the Accepts header for the server, depending on the dataType |
| 5142 | + xhr.setRequestHeader("Accept", s.dataType && s.accepts[ s.dataType ] ? |
| 5143 | + s.accepts[ s.dataType ] + ", */*" : |
| 5144 | + s.accepts._default ); |
| 5145 | + } catch(e) {} |
| 5146 | + |
| 5147 | + // Allow custom headers/mimetypes and early abort |
| 5148 | + if ( s.beforeSend && s.beforeSend.call(callbackContext, xhr, s) === false ) { |
| 5149 | + // Handle the global AJAX counter |
| 5150 | + if ( s.global && ! --jQuery.active ) { |
| 5151 | + jQuery.event.trigger( "ajaxStop" ); |
| 5152 | + } |
| 5153 | + |
| 5154 | + // close opended socket |
| 5155 | + xhr.abort(); |
| 5156 | + return false; |
| 5157 | + } |
| 5158 | + |
| 5159 | + if ( s.global ) { |
| 5160 | + trigger("ajaxSend", [xhr, s]); |
| 5161 | + } |
| 5162 | + |
| 5163 | + // Wait for a response to come back |
| 5164 | + var onreadystatechange = xhr.onreadystatechange = function( isTimeout ) { |
| 5165 | + // The request was aborted |
| 5166 | + if ( !xhr || xhr.readyState === 0 || isTimeout === "abort" ) { |
| 5167 | + // Opera doesn't call onreadystatechange before this point |
| 5168 | + // so we simulate the call |
| 5169 | + if ( !requestDone ) { |
| 5170 | + complete(); |
| 5171 | + } |
| 5172 | + |
| 5173 | + requestDone = true; |
| 5174 | + if ( xhr ) { |
| 5175 | + xhr.onreadystatechange = jQuery.noop; |
| 5176 | + } |
| 5177 | + |
| 5178 | + // The transfer is complete and the data is available, or the request timed out |
| 5179 | + } else if ( !requestDone && xhr && (xhr.readyState === 4 || isTimeout === "timeout") ) { |
| 5180 | + requestDone = true; |
| 5181 | + xhr.onreadystatechange = jQuery.noop; |
| 5182 | + |
| 5183 | + status = isTimeout === "timeout" ? |
| 5184 | + "timeout" : |
| 5185 | + !jQuery.httpSuccess( xhr ) ? |
| 5186 | + "error" : |
| 5187 | + s.ifModified && jQuery.httpNotModified( xhr, s.url ) ? |
| 5188 | + "notmodified" : |
| 5189 | + "success"; |
| 5190 | + |
| 5191 | + var errMsg; |
| 5192 | + |
| 5193 | + if ( status === "success" ) { |
| 5194 | + // Watch for, and catch, XML document parse errors |
| 5195 | + try { |
| 5196 | + // process the data (runs the xml through httpData regardless of callback) |
| 5197 | + data = jQuery.httpData( xhr, s.dataType, s ); |
| 5198 | + } catch(err) { |
| 5199 | + status = "parsererror"; |
| 5200 | + errMsg = err; |
| 5201 | + } |
| 5202 | + } |
| 5203 | + |
| 5204 | + // Make sure that the request was successful or notmodified |
| 5205 | + if ( status === "success" || status === "notmodified" ) { |
| 5206 | + // JSONP handles its own success callback |
| 5207 | + if ( !jsonp ) { |
| 5208 | + success(); |
| 5209 | + } |
| 5210 | + } else { |
| 5211 | + jQuery.handleError(s, xhr, status, errMsg); |
| 5212 | + } |
| 5213 | + |
| 5214 | + // Fire the complete handlers |
| 5215 | + complete(); |
| 5216 | + |
| 5217 | + if ( isTimeout === "timeout" ) { |
| 5218 | + xhr.abort(); |
| 5219 | + } |
| 5220 | + |
| 5221 | + // Stop memory leaks |
| 5222 | + if ( s.async ) { |
| 5223 | + xhr = null; |
| 5224 | + } |
| 5225 | + } |
| 5226 | + }; |
| 5227 | + |
| 5228 | + // Override the abort handler, if we can (IE doesn't allow it, but that's OK) |
| 5229 | + // Opera doesn't fire onreadystatechange at all on abort |
| 5230 | + try { |
| 5231 | + var oldAbort = xhr.abort; |
| 5232 | + xhr.abort = function() { |
| 5233 | + if ( xhr ) { |
| 5234 | + oldAbort.call( xhr ); |
| 5235 | + } |
| 5236 | + |
| 5237 | + onreadystatechange( "abort" ); |
| 5238 | + }; |
| 5239 | + } catch(e) { } |
| 5240 | + |
| 5241 | + // Timeout checker |
| 5242 | + if ( s.async && s.timeout > 0 ) { |
| 5243 | + setTimeout(function() { |
| 5244 | + // Check to see if the request is still happening |
| 5245 | + if ( xhr && !requestDone ) { |
| 5246 | + onreadystatechange( "timeout" ); |
| 5247 | + } |
| 5248 | + }, s.timeout); |
| 5249 | + } |
| 5250 | + |
| 5251 | + // Send the data |
| 5252 | + try { |
| 5253 | + xhr.send( type === "POST" || type === "PUT" || type === "DELETE" ? s.data : null ); |
| 5254 | + } catch(e) { |
| 5255 | + jQuery.handleError(s, xhr, null, e); |
| 5256 | + // Fire the complete handlers |
| 5257 | + complete(); |
| 5258 | + } |
| 5259 | + |
| 5260 | + // firefox 1.5 doesn't fire statechange for sync requests |
| 5261 | + if ( !s.async ) { |
| 5262 | + onreadystatechange(); |
| 5263 | + } |
| 5264 | + |
| 5265 | + function success() { |
| 5266 | + // If a local callback was specified, fire it and pass it the data |
| 5267 | + if ( s.success ) { |
| 5268 | + s.success.call( callbackContext, data, status, xhr ); |
| 5269 | + } |
| 5270 | + |
| 5271 | + // Fire the global callback |
| 5272 | + if ( s.global ) { |
| 5273 | + trigger( "ajaxSuccess", [xhr, s] ); |
| 5274 | + } |
| 5275 | + } |
| 5276 | + |
| 5277 | + function complete() { |
| 5278 | + // Process result |
| 5279 | + if ( s.complete ) { |
| 5280 | + s.complete.call( callbackContext, xhr, status); |
| 5281 | + } |
| 5282 | + |
| 5283 | + // The request was completed |
| 5284 | + if ( s.global ) { |
| 5285 | + trigger( "ajaxComplete", [xhr, s] ); |
| 5286 | + } |
| 5287 | + |
| 5288 | + // Handle the global AJAX counter |
| 5289 | + if ( s.global && ! --jQuery.active ) { |
| 5290 | + jQuery.event.trigger( "ajaxStop" ); |
| 5291 | + } |
| 5292 | + } |
| 5293 | + |
| 5294 | + function trigger(type, args) { |
| 5295 | + (s.context ? jQuery(s.context) : jQuery.event).trigger(type, args); |
| 5296 | + } |
| 5297 | + |
| 5298 | + // return XMLHttpRequest to allow aborting the request etc. |
| 5299 | + return xhr; |
| 5300 | + }, |
| 5301 | + |
| 5302 | + handleError: function( s, xhr, status, e ) { |
| 5303 | + // If a local callback was specified, fire it |
| 5304 | + if ( s.error ) { |
| 5305 | + s.error.call( s.context || s, xhr, status, e ); |
| 5306 | + } |
| 5307 | + |
| 5308 | + // Fire the global callback |
| 5309 | + if ( s.global ) { |
| 5310 | + (s.context ? jQuery(s.context) : jQuery.event).trigger( "ajaxError", [xhr, s, e] ); |
| 5311 | + } |
| 5312 | + }, |
| 5313 | + |
| 5314 | + // Counter for holding the number of active queries |
| 5315 | + active: 0, |
| 5316 | + |
| 5317 | + // Determines if an XMLHttpRequest was successful or not |
| 5318 | + httpSuccess: function( xhr ) { |
| 5319 | + try { |
| 5320 | + // IE error sometimes returns 1223 when it should be 204 so treat it as success, see #1450 |
| 5321 | + return !xhr.status && location.protocol === "file:" || |
| 5322 | + // Opera returns 0 when status is 304 |
| 5323 | + ( xhr.status >= 200 && xhr.status < 300 ) || |
| 5324 | + xhr.status === 304 || xhr.status === 1223 || xhr.status === 0; |
| 5325 | + } catch(e) {} |
| 5326 | + |
| 5327 | + return false; |
| 5328 | + }, |
| 5329 | + |
| 5330 | + // Determines if an XMLHttpRequest returns NotModified |
| 5331 | + httpNotModified: function( xhr, url ) { |
| 5332 | + var lastModified = xhr.getResponseHeader("Last-Modified"), |
| 5333 | + etag = xhr.getResponseHeader("Etag"); |
| 5334 | + |
| 5335 | + if ( lastModified ) { |
| 5336 | + jQuery.lastModified[url] = lastModified; |
| 5337 | + } |
| 5338 | + |
| 5339 | + if ( etag ) { |
| 5340 | + jQuery.etag[url] = etag; |
| 5341 | + } |
| 5342 | + |
| 5343 | + // Opera returns 0 when status is 304 |
| 5344 | + return xhr.status === 304 || xhr.status === 0; |
| 5345 | + }, |
| 5346 | + |
| 5347 | + httpData: function( xhr, type, s ) { |
| 5348 | + var ct = xhr.getResponseHeader("content-type") || "", |
| 5349 | + xml = type === "xml" || !type && ct.indexOf("xml") >= 0, |
| 5350 | + data = xml ? xhr.responseXML : xhr.responseText; |
| 5351 | + |
| 5352 | + if ( xml && data.documentElement.nodeName === "parsererror" ) { |
| 5353 | + jQuery.error( "parsererror" ); |
| 5354 | + } |
| 5355 | + |
| 5356 | + // Allow a pre-filtering function to sanitize the response |
| 5357 | + // s is checked to keep backwards compatibility |
| 5358 | + if ( s && s.dataFilter ) { |
| 5359 | + data = s.dataFilter( data, type ); |
| 5360 | + } |
| 5361 | + |
| 5362 | + // The filter can actually parse the response |
| 5363 | + if ( typeof data === "string" ) { |
| 5364 | + // Get the JavaScript object, if JSON is used. |
| 5365 | + if ( type === "json" || !type && ct.indexOf("json") >= 0 ) { |
| 5366 | + data = jQuery.parseJSON( data ); |
| 5367 | + |
| 5368 | + // If the type is "script", eval it in global context |
| 5369 | + } else if ( type === "script" || !type && ct.indexOf("javascript") >= 0 ) { |
| 5370 | + jQuery.globalEval( data ); |
| 5371 | + } |
| 5372 | + } |
| 5373 | + |
| 5374 | + return data; |
| 5375 | + }, |
| 5376 | + |
| 5377 | + // Serialize an array of form elements or a set of |
| 5378 | + // key/values into a query string |
| 5379 | + param: function( a, traditional ) { |
| 5380 | + var s = []; |
| 5381 | + |
| 5382 | + // Set traditional to true for jQuery <= 1.3.2 behavior. |
| 5383 | + if ( traditional === undefined ) { |
| 5384 | + traditional = jQuery.ajaxSettings.traditional; |
| 5385 | + } |
| 5386 | + |
| 5387 | + // If an array was passed in, assume that it is an array of form elements. |
| 5388 | + if ( jQuery.isArray(a) || a.jquery ) { |
| 5389 | + // Serialize the form elements |
| 5390 | + jQuery.each( a, function() { |
| 5391 | + add( this.name, this.value ); |
| 5392 | + }); |
| 5393 | + |
| 5394 | + } else { |
| 5395 | + // If traditional, encode the "old" way (the way 1.3.2 or older |
| 5396 | + // did it), otherwise encode params recursively. |
| 5397 | + for ( var prefix in a ) { |
| 5398 | + buildParams( prefix, a[prefix] ); |
| 5399 | + } |
| 5400 | + } |
| 5401 | + |
| 5402 | + // Return the resulting serialization |
| 5403 | + return s.join("&").replace(r20, "+"); |
| 5404 | + |
| 5405 | + function buildParams( prefix, obj ) { |
| 5406 | + if ( jQuery.isArray(obj) ) { |
| 5407 | + // Serialize array item. |
| 5408 | + jQuery.each( obj, function( i, v ) { |
| 5409 | + if ( traditional || /\[\]$/.test( prefix ) ) { |
| 5410 | + // Treat each array item as a scalar. |
| 5411 | + add( prefix, v ); |
| 5412 | + } else { |
| 5413 | + // If array item is non-scalar (array or object), encode its |
| 5414 | + // numeric index to resolve deserialization ambiguity issues. |
| 5415 | + // Note that rack (as of 1.0.0) can't currently deserialize |
| 5416 | + // nested arrays properly, and attempting to do so may cause |
| 5417 | + // a server error. Possible fixes are to modify rack's |
| 5418 | + // deserialization algorithm or to provide an option or flag |
| 5419 | + // to force array serialization to be shallow. |
| 5420 | + buildParams( prefix + "[" + ( typeof v === "object" || jQuery.isArray(v) ? i : "" ) + "]", v ); |
| 5421 | + } |
| 5422 | + }); |
| 5423 | + |
| 5424 | + } else if ( !traditional && obj != null && typeof obj === "object" ) { |
| 5425 | + // Serialize object item. |
| 5426 | + jQuery.each( obj, function( k, v ) { |
| 5427 | + buildParams( prefix + "[" + k + "]", v ); |
| 5428 | + }); |
| 5429 | + |
| 5430 | + } else { |
| 5431 | + // Serialize scalar item. |
| 5432 | + add( prefix, obj ); |
| 5433 | + } |
| 5434 | + } |
| 5435 | + |
| 5436 | + function add( key, value ) { |
| 5437 | + // If value is a function, invoke it and return its value |
| 5438 | + value = jQuery.isFunction(value) ? value() : value; |
| 5439 | + s[ s.length ] = encodeURIComponent(key) + "=" + encodeURIComponent(value); |
| 5440 | + } |
| 5441 | + } |
| 5442 | +}); |
| 5443 | +var elemdisplay = {}, |
| 5444 | + rfxtypes = /toggle|show|hide/, |
| 5445 | + rfxnum = /^([+-]=)?([\d+-.]+)(.*)$/, |
| 5446 | + timerId, |
| 5447 | + fxAttrs = [ |
| 5448 | + // height animations |
| 5449 | + [ "height", "marginTop", "marginBottom", "paddingTop", "paddingBottom" ], |
| 5450 | + // width animations |
| 5451 | + [ "width", "marginLeft", "marginRight", "paddingLeft", "paddingRight" ], |
| 5452 | + // opacity animations |
| 5453 | + [ "opacity" ] |
| 5454 | + ]; |
| 5455 | + |
| 5456 | +jQuery.fn.extend({ |
| 5457 | + show: function( speed, callback ) { |
| 5458 | + if ( speed || speed === 0) { |
| 5459 | + return this.animate( genFx("show", 3), speed, callback); |
| 5460 | + |
| 5461 | + } else { |
| 5462 | + for ( var i = 0, l = this.length; i < l; i++ ) { |
| 5463 | + var old = jQuery.data(this[i], "olddisplay"); |
| 5464 | + |
| 5465 | + this[i].style.display = old || ""; |
| 5466 | + |
| 5467 | + if ( jQuery.css(this[i], "display") === "none" ) { |
| 5468 | + var nodeName = this[i].nodeName, display; |
| 5469 | + |
| 5470 | + if ( elemdisplay[ nodeName ] ) { |
| 5471 | + display = elemdisplay[ nodeName ]; |
| 5472 | + |
| 5473 | + } else { |
| 5474 | + var elem = jQuery("<" + nodeName + " />").appendTo("body"); |
| 5475 | + |
| 5476 | + display = elem.css("display"); |
| 5477 | + |
| 5478 | + if ( display === "none" ) { |
| 5479 | + display = "block"; |
| 5480 | + } |
| 5481 | + |
| 5482 | + elem.remove(); |
| 5483 | + |
| 5484 | + elemdisplay[ nodeName ] = display; |
| 5485 | + } |
| 5486 | + |
| 5487 | + jQuery.data(this[i], "olddisplay", display); |
| 5488 | + } |
| 5489 | + } |
| 5490 | + |
| 5491 | + // Set the display of the elements in a second loop |
| 5492 | + // to avoid the constant reflow |
| 5493 | + for ( var j = 0, k = this.length; j < k; j++ ) { |
| 5494 | + this[j].style.display = jQuery.data(this[j], "olddisplay") || ""; |
| 5495 | + } |
| 5496 | + |
| 5497 | + return this; |
| 5498 | + } |
| 5499 | + }, |
| 5500 | + |
| 5501 | + hide: function( speed, callback ) { |
| 5502 | + if ( speed || speed === 0 ) { |
| 5503 | + return this.animate( genFx("hide", 3), speed, callback); |
| 5504 | + |
| 5505 | + } else { |
| 5506 | + for ( var i = 0, l = this.length; i < l; i++ ) { |
| 5507 | + var old = jQuery.data(this[i], "olddisplay"); |
| 5508 | + if ( !old && old !== "none" ) { |
| 5509 | + jQuery.data(this[i], "olddisplay", jQuery.css(this[i], "display")); |
| 5510 | + } |
| 5511 | + } |
| 5512 | + |
| 5513 | + // Set the display of the elements in a second loop |
| 5514 | + // to avoid the constant reflow |
| 5515 | + for ( var j = 0, k = this.length; j < k; j++ ) { |
| 5516 | + this[j].style.display = "none"; |
| 5517 | + } |
| 5518 | + |
| 5519 | + return this; |
| 5520 | + } |
| 5521 | + }, |
| 5522 | + |
| 5523 | + // Save the old toggle function |
| 5524 | + _toggle: jQuery.fn.toggle, |
| 5525 | + |
| 5526 | + toggle: function( fn, fn2 ) { |
| 5527 | + var bool = typeof fn === "boolean"; |
| 5528 | + |
| 5529 | + if ( jQuery.isFunction(fn) && jQuery.isFunction(fn2) ) { |
| 5530 | + this._toggle.apply( this, arguments ); |
| 5531 | + |
| 5532 | + } else if ( fn == null || bool ) { |
| 5533 | + this.each(function() { |
| 5534 | + var state = bool ? fn : jQuery(this).is(":hidden"); |
| 5535 | + jQuery(this)[ state ? "show" : "hide" ](); |
| 5536 | + }); |
| 5537 | + |
| 5538 | + } else { |
| 5539 | + this.animate(genFx("toggle", 3), fn, fn2); |
| 5540 | + } |
| 5541 | + |
| 5542 | + return this; |
| 5543 | + }, |
| 5544 | + |
| 5545 | + fadeTo: function( speed, to, callback ) { |
| 5546 | + return this.filter(":hidden").css("opacity", 0).show().end() |
| 5547 | + .animate({opacity: to}, speed, callback); |
| 5548 | + }, |
| 5549 | + |
| 5550 | + animate: function( prop, speed, easing, callback ) { |
| 5551 | + var optall = jQuery.speed(speed, easing, callback); |
| 5552 | + |
| 5553 | + if ( jQuery.isEmptyObject( prop ) ) { |
| 5554 | + return this.each( optall.complete ); |
| 5555 | + } |
| 5556 | + |
| 5557 | + return this[ optall.queue === false ? "each" : "queue" ](function() { |
| 5558 | + var opt = jQuery.extend({}, optall), p, |
| 5559 | + hidden = this.nodeType === 1 && jQuery(this).is(":hidden"), |
| 5560 | + self = this; |
| 5561 | + |
| 5562 | + for ( p in prop ) { |
| 5563 | + var name = p.replace(rdashAlpha, fcamelCase); |
| 5564 | + |
| 5565 | + if ( p !== name ) { |
| 5566 | + prop[ name ] = prop[ p ]; |
| 5567 | + delete prop[ p ]; |
| 5568 | + p = name; |
| 5569 | + } |
| 5570 | + |
| 5571 | + if ( prop[p] === "hide" && hidden || prop[p] === "show" && !hidden ) { |
| 5572 | + return opt.complete.call(this); |
| 5573 | + } |
| 5574 | + |
| 5575 | + if ( ( p === "height" || p === "width" ) && this.style ) { |
| 5576 | + // Store display property |
| 5577 | + opt.display = jQuery.css(this, "display"); |
| 5578 | + |
| 5579 | + // Make sure that nothing sneaks out |
| 5580 | + opt.overflow = this.style.overflow; |
| 5581 | + } |
| 5582 | + |
| 5583 | + if ( jQuery.isArray( prop[p] ) ) { |
| 5584 | + // Create (if needed) and add to specialEasing |
| 5585 | + (opt.specialEasing = opt.specialEasing || {})[p] = prop[p][1]; |
| 5586 | + prop[p] = prop[p][0]; |
| 5587 | + } |
| 5588 | + } |
| 5589 | + |
| 5590 | + if ( opt.overflow != null ) { |
| 5591 | + this.style.overflow = "hidden"; |
| 5592 | + } |
| 5593 | + |
| 5594 | + opt.curAnim = jQuery.extend({}, prop); |
| 5595 | + |
| 5596 | + jQuery.each( prop, function( name, val ) { |
| 5597 | + var e = new jQuery.fx( self, opt, name ); |
| 5598 | + |
| 5599 | + if ( rfxtypes.test(val) ) { |
| 5600 | + e[ val === "toggle" ? hidden ? "show" : "hide" : val ]( prop ); |
| 5601 | + |
| 5602 | + } else { |
| 5603 | + var parts = rfxnum.exec(val), |
| 5604 | + start = e.cur(true) || 0; |
| 5605 | + |
| 5606 | + if ( parts ) { |
| 5607 | + var end = parseFloat( parts[2] ), |
| 5608 | + unit = parts[3] || "px"; |
| 5609 | + |
| 5610 | + // We need to compute starting value |
| 5611 | + if ( unit !== "px" ) { |
| 5612 | + self.style[ name ] = (end || 1) + unit; |
| 5613 | + start = ((end || 1) / e.cur(true)) * start; |
| 5614 | + self.style[ name ] = start + unit; |
| 5615 | + } |
| 5616 | + |
| 5617 | + // If a +=/-= token was provided, we're doing a relative animation |
| 5618 | + if ( parts[1] ) { |
| 5619 | + end = ((parts[1] === "-=" ? -1 : 1) * end) + start; |
| 5620 | + } |
| 5621 | + |
| 5622 | + e.custom( start, end, unit ); |
| 5623 | + |
| 5624 | + } else { |
| 5625 | + e.custom( start, val, "" ); |
| 5626 | + } |
| 5627 | + } |
| 5628 | + }); |
| 5629 | + |
| 5630 | + // For JS strict compliance |
| 5631 | + return true; |
| 5632 | + }); |
| 5633 | + }, |
| 5634 | + |
| 5635 | + stop: function( clearQueue, gotoEnd ) { |
| 5636 | + var timers = jQuery.timers; |
| 5637 | + |
| 5638 | + if ( clearQueue ) { |
| 5639 | + this.queue([]); |
| 5640 | + } |
| 5641 | + |
| 5642 | + this.each(function() { |
| 5643 | + // go in reverse order so anything added to the queue during the loop is ignored |
| 5644 | + for ( var i = timers.length - 1; i >= 0; i-- ) { |
| 5645 | + if ( timers[i].elem === this ) { |
| 5646 | + if (gotoEnd) { |
| 5647 | + // force the next step to be the last |
| 5648 | + timers[i](true); |
| 5649 | + } |
| 5650 | + |
| 5651 | + timers.splice(i, 1); |
| 5652 | + } |
| 5653 | + } |
| 5654 | + }); |
| 5655 | + |
| 5656 | + // start the next in the queue if the last step wasn't forced |
| 5657 | + if ( !gotoEnd ) { |
| 5658 | + this.dequeue(); |
| 5659 | + } |
| 5660 | + |
| 5661 | + return this; |
| 5662 | + } |
| 5663 | + |
| 5664 | +}); |
| 5665 | + |
| 5666 | +// Generate shortcuts for custom animations |
| 5667 | +jQuery.each({ |
| 5668 | + slideDown: genFx("show", 1), |
| 5669 | + slideUp: genFx("hide", 1), |
| 5670 | + slideToggle: genFx("toggle", 1), |
| 5671 | + fadeIn: { opacity: "show" }, |
| 5672 | + fadeOut: { opacity: "hide" } |
| 5673 | +}, function( name, props ) { |
| 5674 | + jQuery.fn[ name ] = function( speed, callback ) { |
| 5675 | + return this.animate( props, speed, callback ); |
| 5676 | + }; |
| 5677 | +}); |
| 5678 | + |
| 5679 | +jQuery.extend({ |
| 5680 | + speed: function( speed, easing, fn ) { |
| 5681 | + var opt = speed && typeof speed === "object" ? speed : { |
| 5682 | + complete: fn || !fn && easing || |
| 5683 | + jQuery.isFunction( speed ) && speed, |
| 5684 | + duration: speed, |
| 5685 | + easing: fn && easing || easing && !jQuery.isFunction(easing) && easing |
| 5686 | + }; |
| 5687 | + |
| 5688 | + opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration : |
| 5689 | + jQuery.fx.speeds[opt.duration] || jQuery.fx.speeds._default; |
| 5690 | + |
| 5691 | + // Queueing |
| 5692 | + opt.old = opt.complete; |
| 5693 | + opt.complete = function() { |
| 5694 | + if ( opt.queue !== false ) { |
| 5695 | + jQuery(this).dequeue(); |
| 5696 | + } |
| 5697 | + if ( jQuery.isFunction( opt.old ) ) { |
| 5698 | + opt.old.call( this ); |
| 5699 | + } |
| 5700 | + }; |
| 5701 | + |
| 5702 | + return opt; |
| 5703 | + }, |
| 5704 | + |
| 5705 | + easing: { |
| 5706 | + linear: function( p, n, firstNum, diff ) { |
| 5707 | + return firstNum + diff * p; |
| 5708 | + }, |
| 5709 | + swing: function( p, n, firstNum, diff ) { |
| 5710 | + return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum; |
| 5711 | + } |
| 5712 | + }, |
| 5713 | + |
| 5714 | + timers: [], |
| 5715 | + |
| 5716 | + fx: function( elem, options, prop ) { |
| 5717 | + this.options = options; |
| 5718 | + this.elem = elem; |
| 5719 | + this.prop = prop; |
| 5720 | + |
| 5721 | + if ( !options.orig ) { |
| 5722 | + options.orig = {}; |
| 5723 | + } |
| 5724 | + } |
| 5725 | + |
| 5726 | +}); |
| 5727 | + |
| 5728 | +jQuery.fx.prototype = { |
| 5729 | + // Simple function for setting a style value |
| 5730 | + update: function() { |
| 5731 | + if ( this.options.step ) { |
| 5732 | + this.options.step.call( this.elem, this.now, this ); |
| 5733 | + } |
| 5734 | + |
| 5735 | + (jQuery.fx.step[this.prop] || jQuery.fx.step._default)( this ); |
| 5736 | + |
| 5737 | + // Set display property to block for height/width animations |
| 5738 | + if ( ( this.prop === "height" || this.prop === "width" ) && this.elem.style ) { |
| 5739 | + this.elem.style.display = "block"; |
| 5740 | + } |
| 5741 | + }, |
| 5742 | + |
| 5743 | + // Get the current size |
| 5744 | + cur: function( force ) { |
| 5745 | + if ( this.elem[this.prop] != null && (!this.elem.style || this.elem.style[this.prop] == null) ) { |
| 5746 | + return this.elem[ this.prop ]; |
| 5747 | + } |
| 5748 | + |
| 5749 | + var r = parseFloat(jQuery.css(this.elem, this.prop, force)); |
| 5750 | + return r && r > -10000 ? r : parseFloat(jQuery.curCSS(this.elem, this.prop)) || 0; |
| 5751 | + }, |
| 5752 | + |
| 5753 | + // Start an animation from one number to another |
| 5754 | + custom: function( from, to, unit ) { |
| 5755 | + this.startTime = now(); |
| 5756 | + this.start = from; |
| 5757 | + this.end = to; |
| 5758 | + this.unit = unit || this.unit || "px"; |
| 5759 | + this.now = this.start; |
| 5760 | + this.pos = this.state = 0; |
| 5761 | + |
| 5762 | + var self = this; |
| 5763 | + function t( gotoEnd ) { |
| 5764 | + return self.step(gotoEnd); |
| 5765 | + } |
| 5766 | + |
| 5767 | + t.elem = this.elem; |
| 5768 | + |
| 5769 | + if ( t() && jQuery.timers.push(t) && !timerId ) { |
| 5770 | + timerId = setInterval(jQuery.fx.tick, 13); |
| 5771 | + } |
| 5772 | + }, |
| 5773 | + |
| 5774 | + // Simple 'show' function |
| 5775 | + show: function() { |
| 5776 | + // Remember where we started, so that we can go back to it later |
| 5777 | + this.options.orig[this.prop] = jQuery.style( this.elem, this.prop ); |
| 5778 | + this.options.show = true; |
| 5779 | + |
| 5780 | + // Begin the animation |
| 5781 | + // Make sure that we start at a small width/height to avoid any |
| 5782 | + // flash of content |
| 5783 | + this.custom(this.prop === "width" || this.prop === "height" ? 1 : 0, this.cur()); |
| 5784 | + |
| 5785 | + // Start by showing the element |
| 5786 | + jQuery( this.elem ).show(); |
| 5787 | + }, |
| 5788 | + |
| 5789 | + // Simple 'hide' function |
| 5790 | + hide: function() { |
| 5791 | + // Remember where we started, so that we can go back to it later |
| 5792 | + this.options.orig[this.prop] = jQuery.style( this.elem, this.prop ); |
| 5793 | + this.options.hide = true; |
| 5794 | + |
| 5795 | + // Begin the animation |
| 5796 | + this.custom(this.cur(), 0); |
| 5797 | + }, |
| 5798 | + |
| 5799 | + // Each step of an animation |
| 5800 | + step: function( gotoEnd ) { |
| 5801 | + var t = now(), done = true; |
| 5802 | + |
| 5803 | + if ( gotoEnd || t >= this.options.duration + this.startTime ) { |
| 5804 | + this.now = this.end; |
| 5805 | + this.pos = this.state = 1; |
| 5806 | + this.update(); |
| 5807 | + |
| 5808 | + this.options.curAnim[ this.prop ] = true; |
| 5809 | + |
| 5810 | + for ( var i in this.options.curAnim ) { |
| 5811 | + if ( this.options.curAnim[i] !== true ) { |
| 5812 | + done = false; |
| 5813 | + } |
| 5814 | + } |
| 5815 | + |
| 5816 | + if ( done ) { |
| 5817 | + if ( this.options.display != null ) { |
| 5818 | + // Reset the overflow |
| 5819 | + this.elem.style.overflow = this.options.overflow; |
| 5820 | + |
| 5821 | + // Reset the display |
| 5822 | + var old = jQuery.data(this.elem, "olddisplay"); |
| 5823 | + this.elem.style.display = old ? old : this.options.display; |
| 5824 | + |
| 5825 | + if ( jQuery.css(this.elem, "display") === "none" ) { |
| 5826 | + this.elem.style.display = "block"; |
| 5827 | + } |
| 5828 | + } |
| 5829 | + |
| 5830 | + // Hide the element if the "hide" operation was done |
| 5831 | + if ( this.options.hide ) { |
| 5832 | + jQuery(this.elem).hide(); |
| 5833 | + } |
| 5834 | + |
| 5835 | + // Reset the properties, if the item has been hidden or shown |
| 5836 | + if ( this.options.hide || this.options.show ) { |
| 5837 | + for ( var p in this.options.curAnim ) { |
| 5838 | + jQuery.style(this.elem, p, this.options.orig[p]); |
| 5839 | + } |
| 5840 | + } |
| 5841 | + |
| 5842 | + // Execute the complete function |
| 5843 | + this.options.complete.call( this.elem ); |
| 5844 | + } |
| 5845 | + |
| 5846 | + return false; |
| 5847 | + |
| 5848 | + } else { |
| 5849 | + var n = t - this.startTime; |
| 5850 | + this.state = n / this.options.duration; |
| 5851 | + |
| 5852 | + // Perform the easing function, defaults to swing |
| 5853 | + var specialEasing = this.options.specialEasing && this.options.specialEasing[this.prop]; |
| 5854 | + var defaultEasing = this.options.easing || (jQuery.easing.swing ? "swing" : "linear"); |
| 5855 | + this.pos = jQuery.easing[specialEasing || defaultEasing](this.state, n, 0, 1, this.options.duration); |
| 5856 | + this.now = this.start + ((this.end - this.start) * this.pos); |
| 5857 | + |
| 5858 | + // Perform the next step of the animation |
| 5859 | + this.update(); |
| 5860 | + } |
| 5861 | + |
| 5862 | + return true; |
| 5863 | + } |
| 5864 | +}; |
| 5865 | + |
| 5866 | +jQuery.extend( jQuery.fx, { |
| 5867 | + tick: function() { |
| 5868 | + var timers = jQuery.timers; |
| 5869 | + |
| 5870 | + for ( var i = 0; i < timers.length; i++ ) { |
| 5871 | + if ( !timers[i]() ) { |
| 5872 | + timers.splice(i--, 1); |
| 5873 | + } |
| 5874 | + } |
| 5875 | + |
| 5876 | + if ( !timers.length ) { |
| 5877 | + jQuery.fx.stop(); |
| 5878 | + } |
| 5879 | + }, |
| 5880 | + |
| 5881 | + stop: function() { |
| 5882 | + clearInterval( timerId ); |
| 5883 | + timerId = null; |
| 5884 | + }, |
| 5885 | + |
| 5886 | + speeds: { |
| 5887 | + slow: 600, |
| 5888 | + fast: 200, |
| 5889 | + // Default speed |
| 5890 | + _default: 400 |
| 5891 | + }, |
| 5892 | + |
| 5893 | + step: { |
| 5894 | + opacity: function( fx ) { |
| 5895 | + jQuery.style(fx.elem, "opacity", fx.now); |
| 5896 | + }, |
| 5897 | + |
| 5898 | + _default: function( fx ) { |
| 5899 | + if ( fx.elem.style && fx.elem.style[ fx.prop ] != null ) { |
| 5900 | + fx.elem.style[ fx.prop ] = (fx.prop === "width" || fx.prop === "height" ? Math.max(0, fx.now) : fx.now) + fx.unit; |
| 5901 | + } else { |
| 5902 | + fx.elem[ fx.prop ] = fx.now; |
| 5903 | + } |
| 5904 | + } |
| 5905 | + } |
| 5906 | +}); |
| 5907 | + |
| 5908 | +if ( jQuery.expr && jQuery.expr.filters ) { |
| 5909 | + jQuery.expr.filters.animated = function( elem ) { |
| 5910 | + return jQuery.grep(jQuery.timers, function( fn ) { |
| 5911 | + return elem === fn.elem; |
| 5912 | + }).length; |
| 5913 | + }; |
| 5914 | +} |
| 5915 | + |
| 5916 | +function genFx( type, num ) { |
| 5917 | + var obj = {}; |
| 5918 | + |
| 5919 | + jQuery.each( fxAttrs.concat.apply([], fxAttrs.slice(0,num)), function() { |
| 5920 | + obj[ this ] = type; |
| 5921 | + }); |
| 5922 | + |
| 5923 | + return obj; |
| 5924 | +} |
| 5925 | +if ( "getBoundingClientRect" in document.documentElement ) { |
| 5926 | + jQuery.fn.offset = function( options ) { |
| 5927 | + var elem = this[0]; |
| 5928 | + |
| 5929 | + if ( options ) { |
| 5930 | + return this.each(function( i ) { |
| 5931 | + jQuery.offset.setOffset( this, options, i ); |
| 5932 | + }); |
| 5933 | + } |
| 5934 | + |
| 5935 | + if ( !elem || !elem.ownerDocument ) { |
| 5936 | + return null; |
| 5937 | + } |
| 5938 | + |
| 5939 | + if ( elem === elem.ownerDocument.body ) { |
| 5940 | + return jQuery.offset.bodyOffset( elem ); |
| 5941 | + } |
| 5942 | + |
| 5943 | + var box = elem.getBoundingClientRect(), doc = elem.ownerDocument, body = doc.body, docElem = doc.documentElement, |
| 5944 | + clientTop = docElem.clientTop || body.clientTop || 0, clientLeft = docElem.clientLeft || body.clientLeft || 0, |
| 5945 | + top = box.top + (self.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop ) - clientTop, |
| 5946 | + left = box.left + (self.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft) - clientLeft; |
| 5947 | + |
| 5948 | + return { top: top, left: left }; |
| 5949 | + }; |
| 5950 | + |
| 5951 | +} else { |
| 5952 | + jQuery.fn.offset = function( options ) { |
| 5953 | + var elem = this[0]; |
| 5954 | + |
| 5955 | + if ( options ) { |
| 5956 | + return this.each(function( i ) { |
| 5957 | + jQuery.offset.setOffset( this, options, i ); |
| 5958 | + }); |
| 5959 | + } |
| 5960 | + |
| 5961 | + if ( !elem || !elem.ownerDocument ) { |
| 5962 | + return null; |
| 5963 | + } |
| 5964 | + |
| 5965 | + if ( elem === elem.ownerDocument.body ) { |
| 5966 | + return jQuery.offset.bodyOffset( elem ); |
| 5967 | + } |
| 5968 | + |
| 5969 | + jQuery.offset.initialize(); |
| 5970 | + |
| 5971 | + var offsetParent = elem.offsetParent, prevOffsetParent = elem, |
| 5972 | + doc = elem.ownerDocument, computedStyle, docElem = doc.documentElement, |
| 5973 | + body = doc.body, defaultView = doc.defaultView, |
| 5974 | + prevComputedStyle = defaultView ? defaultView.getComputedStyle( elem, null ) : elem.currentStyle, |
| 5975 | + top = elem.offsetTop, left = elem.offsetLeft; |
| 5976 | + |
| 5977 | + while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) { |
| 5978 | + if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) { |
| 5979 | + break; |
| 5980 | + } |
| 5981 | + |
| 5982 | + computedStyle = defaultView ? defaultView.getComputedStyle(elem, null) : elem.currentStyle; |
| 5983 | + top -= elem.scrollTop; |
| 5984 | + left -= elem.scrollLeft; |
| 5985 | + |
| 5986 | + if ( elem === offsetParent ) { |
| 5987 | + top += elem.offsetTop; |
| 5988 | + left += elem.offsetLeft; |
| 5989 | + |
| 5990 | + if ( jQuery.offset.doesNotAddBorder && !(jQuery.offset.doesAddBorderForTableAndCells && /^t(able|d|h)$/i.test(elem.nodeName)) ) { |
| 5991 | + top += parseFloat( computedStyle.borderTopWidth ) || 0; |
| 5992 | + left += parseFloat( computedStyle.borderLeftWidth ) || 0; |
| 5993 | + } |
| 5994 | + |
| 5995 | + prevOffsetParent = offsetParent, offsetParent = elem.offsetParent; |
| 5996 | + } |
| 5997 | + |
| 5998 | + if ( jQuery.offset.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" ) { |
| 5999 | + top += parseFloat( computedStyle.borderTopWidth ) || 0; |
| 6000 | + left += parseFloat( computedStyle.borderLeftWidth ) || 0; |
| 6001 | + } |
| 6002 | + |
| 6003 | + prevComputedStyle = computedStyle; |
| 6004 | + } |
| 6005 | + |
| 6006 | + if ( prevComputedStyle.position === "relative" || prevComputedStyle.position === "static" ) { |
| 6007 | + top += body.offsetTop; |
| 6008 | + left += body.offsetLeft; |
| 6009 | + } |
| 6010 | + |
| 6011 | + if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) { |
| 6012 | + top += Math.max( docElem.scrollTop, body.scrollTop ); |
| 6013 | + left += Math.max( docElem.scrollLeft, body.scrollLeft ); |
| 6014 | + } |
| 6015 | + |
| 6016 | + return { top: top, left: left }; |
| 6017 | + }; |
| 6018 | +} |
| 6019 | + |
| 6020 | +jQuery.offset = { |
| 6021 | + initialize: function() { |
| 6022 | + var body = document.body, container = document.createElement("div"), innerDiv, checkDiv, table, td, bodyMarginTop = parseFloat( jQuery.curCSS(body, "marginTop", true) ) || 0, |
| 6023 | + html = "<div style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;'><div></div></div><table style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;' cellpadding='0' cellspacing='0'><tr><td></td></tr></table>"; |
| 6024 | + |
| 6025 | + jQuery.extend( container.style, { position: "absolute", top: 0, left: 0, margin: 0, border: 0, width: "1px", height: "1px", visibility: "hidden" } ); |
| 6026 | + |
| 6027 | + container.innerHTML = html; |
| 6028 | + body.insertBefore( container, body.firstChild ); |
| 6029 | + innerDiv = container.firstChild; |
| 6030 | + checkDiv = innerDiv.firstChild; |
| 6031 | + td = innerDiv.nextSibling.firstChild.firstChild; |
| 6032 | + |
| 6033 | + this.doesNotAddBorder = (checkDiv.offsetTop !== 5); |
| 6034 | + this.doesAddBorderForTableAndCells = (td.offsetTop === 5); |
| 6035 | + |
| 6036 | + checkDiv.style.position = "fixed", checkDiv.style.top = "20px"; |
| 6037 | + // safari subtracts parent border width here which is 5px |
| 6038 | + this.supportsFixedPosition = (checkDiv.offsetTop === 20 || checkDiv.offsetTop === 15); |
| 6039 | + checkDiv.style.position = checkDiv.style.top = ""; |
| 6040 | + |
| 6041 | + innerDiv.style.overflow = "hidden", innerDiv.style.position = "relative"; |
| 6042 | + this.subtractsBorderForOverflowNotVisible = (checkDiv.offsetTop === -5); |
| 6043 | + |
| 6044 | + this.doesNotIncludeMarginInBodyOffset = (body.offsetTop !== bodyMarginTop); |
| 6045 | + |
| 6046 | + body.removeChild( container ); |
| 6047 | + body = container = innerDiv = checkDiv = table = td = null; |
| 6048 | + jQuery.offset.initialize = jQuery.noop; |
| 6049 | + }, |
| 6050 | + |
| 6051 | + bodyOffset: function( body ) { |
| 6052 | + var top = body.offsetTop, left = body.offsetLeft; |
| 6053 | + |
| 6054 | + jQuery.offset.initialize(); |
| 6055 | + |
| 6056 | + if ( jQuery.offset.doesNotIncludeMarginInBodyOffset ) { |
| 6057 | + top += parseFloat( jQuery.curCSS(body, "marginTop", true) ) || 0; |
| 6058 | + left += parseFloat( jQuery.curCSS(body, "marginLeft", true) ) || 0; |
| 6059 | + } |
| 6060 | + |
| 6061 | + return { top: top, left: left }; |
| 6062 | + }, |
| 6063 | + |
| 6064 | + setOffset: function( elem, options, i ) { |
| 6065 | + // set position first, in-case top/left are set even on static elem |
| 6066 | + if ( /static/.test( jQuery.curCSS( elem, "position" ) ) ) { |
| 6067 | + elem.style.position = "relative"; |
| 6068 | + } |
| 6069 | + var curElem = jQuery( elem ), |
| 6070 | + curOffset = curElem.offset(), |
| 6071 | + curTop = parseInt( jQuery.curCSS( elem, "top", true ), 10 ) || 0, |
| 6072 | + curLeft = parseInt( jQuery.curCSS( elem, "left", true ), 10 ) || 0; |
| 6073 | + |
| 6074 | + if ( jQuery.isFunction( options ) ) { |
| 6075 | + options = options.call( elem, i, curOffset ); |
| 6076 | + } |
| 6077 | + |
| 6078 | + var props = { |
| 6079 | + top: (options.top - curOffset.top) + curTop, |
| 6080 | + left: (options.left - curOffset.left) + curLeft |
| 6081 | + }; |
| 6082 | + |
| 6083 | + if ( "using" in options ) { |
| 6084 | + options.using.call( elem, props ); |
| 6085 | + } else { |
| 6086 | + curElem.css( props ); |
| 6087 | + } |
| 6088 | + } |
| 6089 | +}; |
| 6090 | + |
| 6091 | + |
| 6092 | +jQuery.fn.extend({ |
| 6093 | + position: function() { |
| 6094 | + if ( !this[0] ) { |
| 6095 | + return null; |
| 6096 | + } |
| 6097 | + |
| 6098 | + var elem = this[0], |
| 6099 | + |
| 6100 | + // Get *real* offsetParent |
| 6101 | + offsetParent = this.offsetParent(), |
| 6102 | + |
| 6103 | + // Get correct offsets |
| 6104 | + offset = this.offset(), |
| 6105 | + parentOffset = /^body|html$/i.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset(); |
| 6106 | + |
| 6107 | + // Subtract element margins |
| 6108 | + // note: when an element has margin: auto the offsetLeft and marginLeft |
| 6109 | + // are the same in Safari causing offset.left to incorrectly be 0 |
| 6110 | + offset.top -= parseFloat( jQuery.curCSS(elem, "marginTop", true) ) || 0; |
| 6111 | + offset.left -= parseFloat( jQuery.curCSS(elem, "marginLeft", true) ) || 0; |
| 6112 | + |
| 6113 | + // Add offsetParent borders |
| 6114 | + parentOffset.top += parseFloat( jQuery.curCSS(offsetParent[0], "borderTopWidth", true) ) || 0; |
| 6115 | + parentOffset.left += parseFloat( jQuery.curCSS(offsetParent[0], "borderLeftWidth", true) ) || 0; |
| 6116 | + |
| 6117 | + // Subtract the two offsets |
| 6118 | + return { |
| 6119 | + top: offset.top - parentOffset.top, |
| 6120 | + left: offset.left - parentOffset.left |
| 6121 | + }; |
| 6122 | + }, |
| 6123 | + |
| 6124 | + offsetParent: function() { |
| 6125 | + return this.map(function() { |
| 6126 | + var offsetParent = this.offsetParent || document.body; |
| 6127 | + while ( offsetParent && (!/^body|html$/i.test(offsetParent.nodeName) && jQuery.css(offsetParent, "position") === "static") ) { |
| 6128 | + offsetParent = offsetParent.offsetParent; |
| 6129 | + } |
| 6130 | + return offsetParent; |
| 6131 | + }); |
| 6132 | + } |
| 6133 | +}); |
| 6134 | + |
| 6135 | + |
| 6136 | +// Create scrollLeft and scrollTop methods |
| 6137 | +jQuery.each( ["Left", "Top"], function( i, name ) { |
| 6138 | + var method = "scroll" + name; |
| 6139 | + |
| 6140 | + jQuery.fn[ method ] = function(val) { |
| 6141 | + var elem = this[0], win; |
| 6142 | + |
| 6143 | + if ( !elem ) { |
| 6144 | + return null; |
| 6145 | + } |
| 6146 | + |
| 6147 | + if ( val !== undefined ) { |
| 6148 | + // Set the scroll offset |
| 6149 | + return this.each(function() { |
| 6150 | + win = getWindow( this ); |
| 6151 | + |
| 6152 | + if ( win ) { |
| 6153 | + win.scrollTo( |
| 6154 | + !i ? val : jQuery(win).scrollLeft(), |
| 6155 | + i ? val : jQuery(win).scrollTop() |
| 6156 | + ); |
| 6157 | + |
| 6158 | + } else { |
| 6159 | + this[ method ] = val; |
| 6160 | + } |
| 6161 | + }); |
| 6162 | + } else { |
| 6163 | + win = getWindow( elem ); |
| 6164 | + |
| 6165 | + // Return the scroll offset |
| 6166 | + return win ? ("pageXOffset" in win) ? win[ i ? "pageYOffset" : "pageXOffset" ] : |
| 6167 | + jQuery.support.boxModel && win.document.documentElement[ method ] || |
| 6168 | + win.document.body[ method ] : |
| 6169 | + elem[ method ]; |
| 6170 | + } |
| 6171 | + }; |
| 6172 | +}); |
| 6173 | + |
| 6174 | +function getWindow( elem ) { |
| 6175 | + return ("scrollTo" in elem && elem.document) ? |
| 6176 | + elem : |
| 6177 | + elem.nodeType === 9 ? |
| 6178 | + elem.defaultView || elem.parentWindow : |
| 6179 | + false; |
| 6180 | +} |
| 6181 | +// Create innerHeight, innerWidth, outerHeight and outerWidth methods |
| 6182 | +jQuery.each([ "Height", "Width" ], function( i, name ) { |
| 6183 | + |
| 6184 | + var type = name.toLowerCase(); |
| 6185 | + |
| 6186 | + // innerHeight and innerWidth |
| 6187 | + jQuery.fn["inner" + name] = function() { |
| 6188 | + return this[0] ? |
| 6189 | + jQuery.css( this[0], type, false, "padding" ) : |
| 6190 | + null; |
| 6191 | + }; |
| 6192 | + |
| 6193 | + // outerHeight and outerWidth |
| 6194 | + jQuery.fn["outer" + name] = function( margin ) { |
| 6195 | + return this[0] ? |
| 6196 | + jQuery.css( this[0], type, false, margin ? "margin" : "border" ) : |
| 6197 | + null; |
| 6198 | + }; |
| 6199 | + |
| 6200 | + jQuery.fn[ type ] = function( size ) { |
| 6201 | + // Get window width or height |
| 6202 | + var elem = this[0]; |
| 6203 | + if ( !elem ) { |
| 6204 | + return size == null ? null : this; |
| 6205 | + } |
| 6206 | + |
| 6207 | + if ( jQuery.isFunction( size ) ) { |
| 6208 | + return this.each(function( i ) { |
| 6209 | + var self = jQuery( this ); |
| 6210 | + self[ type ]( size.call( this, i, self[ type ]() ) ); |
| 6211 | + }); |
| 6212 | + } |
| 6213 | + |
| 6214 | + return ("scrollTo" in elem && elem.document) ? // does it walk and quack like a window? |
| 6215 | + // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode |
| 6216 | + elem.document.compatMode === "CSS1Compat" && elem.document.documentElement[ "client" + name ] || |
| 6217 | + elem.document.body[ "client" + name ] : |
| 6218 | + |
| 6219 | + // Get document width or height |
| 6220 | + (elem.nodeType === 9) ? // is it a document |
| 6221 | + // Either scroll[Width/Height] or offset[Width/Height], whichever is greater |
| 6222 | + Math.max( |
| 6223 | + elem.documentElement["client" + name], |
| 6224 | + elem.body["scroll" + name], elem.documentElement["scroll" + name], |
| 6225 | + elem.body["offset" + name], elem.documentElement["offset" + name] |
| 6226 | + ) : |
| 6227 | + |
| 6228 | + // Get or set width or height on the element |
| 6229 | + size === undefined ? |
| 6230 | + // Get width or height on the element |
| 6231 | + jQuery.css( elem, type ) : |
| 6232 | + |
| 6233 | + // Set the width or height on the element (default to pixels if value is unitless) |
| 6234 | + this.css( type, typeof size === "string" ? size : size + "px" ); |
| 6235 | + }; |
| 6236 | + |
| 6237 | +}); |
| 6238 | +// Expose jQuery to the global object |
| 6239 | +window.jQuery = window.$ = jQuery; |
| 6240 | + |
| 6241 | +})(window); |
Property changes on: trunk/phase3/tests/jasmine/lib/appendto-jquery-mockjax/lib/jquery-1.4.2.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 6242 | + native |
Index: trunk/phase3/tests/jasmine/lib/jasmine-1.0.1/jasmine.js |
— | — | @@ -0,0 +1,2421 @@ |
| 2 | +/** |
| 3 | + * Top level namespace for Jasmine, a lightweight JavaScript BDD/spec/testing framework. |
| 4 | + * |
| 5 | + * @namespace |
| 6 | + */ |
| 7 | +var jasmine = {}; |
| 8 | + |
| 9 | +/** |
| 10 | + * @private |
| 11 | + */ |
| 12 | +jasmine.unimplementedMethod_ = function() { |
| 13 | + throw new Error("unimplemented method"); |
| 14 | +}; |
| 15 | + |
| 16 | +/** |
| 17 | + * Use <code>jasmine.undefined</code> instead of <code>undefined</code>, since <code>undefined</code> is just |
| 18 | + * a plain old variable and may be redefined by somebody else. |
| 19 | + * |
| 20 | + * @private |
| 21 | + */ |
| 22 | +jasmine.undefined = jasmine.___undefined___; |
| 23 | + |
| 24 | +/** |
| 25 | + * Default interval in milliseconds for event loop yields (e.g. to allow network activity or to refresh the screen with the HTML-based runner). Small values here may result in slow test running. Zero means no updates until all tests have completed. |
| 26 | + * |
| 27 | + */ |
| 28 | +jasmine.DEFAULT_UPDATE_INTERVAL = 250; |
| 29 | + |
| 30 | +/** |
| 31 | + * Default timeout interval in milliseconds for waitsFor() blocks. |
| 32 | + */ |
| 33 | +jasmine.DEFAULT_TIMEOUT_INTERVAL = 5000; |
| 34 | + |
| 35 | +jasmine.getGlobal = function() { |
| 36 | + function getGlobal() { |
| 37 | + return this; |
| 38 | + } |
| 39 | + |
| 40 | + return getGlobal(); |
| 41 | +}; |
| 42 | + |
| 43 | +/** |
| 44 | + * Allows for bound functions to be compared. Internal use only. |
| 45 | + * |
| 46 | + * @ignore |
| 47 | + * @private |
| 48 | + * @param base {Object} bound 'this' for the function |
| 49 | + * @param name {Function} function to find |
| 50 | + */ |
| 51 | +jasmine.bindOriginal_ = function(base, name) { |
| 52 | + var original = base[name]; |
| 53 | + if (original.apply) { |
| 54 | + return function() { |
| 55 | + return original.apply(base, arguments); |
| 56 | + }; |
| 57 | + } else { |
| 58 | + // IE support |
| 59 | + return jasmine.getGlobal()[name]; |
| 60 | + } |
| 61 | +}; |
| 62 | + |
| 63 | +jasmine.setTimeout = jasmine.bindOriginal_(jasmine.getGlobal(), 'setTimeout'); |
| 64 | +jasmine.clearTimeout = jasmine.bindOriginal_(jasmine.getGlobal(), 'clearTimeout'); |
| 65 | +jasmine.setInterval = jasmine.bindOriginal_(jasmine.getGlobal(), 'setInterval'); |
| 66 | +jasmine.clearInterval = jasmine.bindOriginal_(jasmine.getGlobal(), 'clearInterval'); |
| 67 | + |
| 68 | +jasmine.MessageResult = function(values) { |
| 69 | + this.type = 'log'; |
| 70 | + this.values = values; |
| 71 | + this.trace = new Error(); // todo: test better |
| 72 | +}; |
| 73 | + |
| 74 | +jasmine.MessageResult.prototype.toString = function() { |
| 75 | + var text = ""; |
| 76 | + for(var i = 0; i < this.values.length; i++) { |
| 77 | + if (i > 0) text += " "; |
| 78 | + if (jasmine.isString_(this.values[i])) { |
| 79 | + text += this.values[i]; |
| 80 | + } else { |
| 81 | + text += jasmine.pp(this.values[i]); |
| 82 | + } |
| 83 | + } |
| 84 | + return text; |
| 85 | +}; |
| 86 | + |
| 87 | +jasmine.ExpectationResult = function(params) { |
| 88 | + this.type = 'expect'; |
| 89 | + this.matcherName = params.matcherName; |
| 90 | + this.passed_ = params.passed; |
| 91 | + this.expected = params.expected; |
| 92 | + this.actual = params.actual; |
| 93 | + |
| 94 | + this.message = this.passed_ ? 'Passed.' : params.message; |
| 95 | + this.trace = this.passed_ ? '' : new Error(this.message); |
| 96 | +}; |
| 97 | + |
| 98 | +jasmine.ExpectationResult.prototype.toString = function () { |
| 99 | + return this.message; |
| 100 | +}; |
| 101 | + |
| 102 | +jasmine.ExpectationResult.prototype.passed = function () { |
| 103 | + return this.passed_; |
| 104 | +}; |
| 105 | + |
| 106 | +/** |
| 107 | + * Getter for the Jasmine environment. Ensures one gets created |
| 108 | + */ |
| 109 | +jasmine.getEnv = function() { |
| 110 | + return jasmine.currentEnv_ = jasmine.currentEnv_ || new jasmine.Env(); |
| 111 | +}; |
| 112 | + |
| 113 | +/** |
| 114 | + * @ignore |
| 115 | + * @private |
| 116 | + * @param value |
| 117 | + * @returns {Boolean} |
| 118 | + */ |
| 119 | +jasmine.isArray_ = function(value) { |
| 120 | + return jasmine.isA_("Array", value); |
| 121 | +}; |
| 122 | + |
| 123 | +/** |
| 124 | + * @ignore |
| 125 | + * @private |
| 126 | + * @param value |
| 127 | + * @returns {Boolean} |
| 128 | + */ |
| 129 | +jasmine.isString_ = function(value) { |
| 130 | + return jasmine.isA_("String", value); |
| 131 | +}; |
| 132 | + |
| 133 | +/** |
| 134 | + * @ignore |
| 135 | + * @private |
| 136 | + * @param value |
| 137 | + * @returns {Boolean} |
| 138 | + */ |
| 139 | +jasmine.isNumber_ = function(value) { |
| 140 | + return jasmine.isA_("Number", value); |
| 141 | +}; |
| 142 | + |
| 143 | +/** |
| 144 | + * @ignore |
| 145 | + * @private |
| 146 | + * @param {String} typeName |
| 147 | + * @param value |
| 148 | + * @returns {Boolean} |
| 149 | + */ |
| 150 | +jasmine.isA_ = function(typeName, value) { |
| 151 | + return Object.prototype.toString.apply(value) === '[object ' + typeName + ']'; |
| 152 | +}; |
| 153 | + |
| 154 | +/** |
| 155 | + * Pretty printer for expecations. Takes any object and turns it into a human-readable string. |
| 156 | + * |
| 157 | + * @param value {Object} an object to be outputted |
| 158 | + * @returns {String} |
| 159 | + */ |
| 160 | +jasmine.pp = function(value) { |
| 161 | + var stringPrettyPrinter = new jasmine.StringPrettyPrinter(); |
| 162 | + stringPrettyPrinter.format(value); |
| 163 | + return stringPrettyPrinter.string; |
| 164 | +}; |
| 165 | + |
| 166 | +/** |
| 167 | + * Returns true if the object is a DOM Node. |
| 168 | + * |
| 169 | + * @param {Object} obj object to check |
| 170 | + * @returns {Boolean} |
| 171 | + */ |
| 172 | +jasmine.isDomNode = function(obj) { |
| 173 | + return obj['nodeType'] > 0; |
| 174 | +}; |
| 175 | + |
| 176 | +/** |
| 177 | + * Returns a matchable 'generic' object of the class type. For use in expecations of type when values don't matter. |
| 178 | + * |
| 179 | + * @example |
| 180 | + * // don't care about which function is passed in, as long as it's a function |
| 181 | + * expect(mySpy).toHaveBeenCalledWith(jasmine.any(Function)); |
| 182 | + * |
| 183 | + * @param {Class} clazz |
| 184 | + * @returns matchable object of the type clazz |
| 185 | + */ |
| 186 | +jasmine.any = function(clazz) { |
| 187 | + return new jasmine.Matchers.Any(clazz); |
| 188 | +}; |
| 189 | + |
| 190 | +/** |
| 191 | + * Jasmine Spies are test doubles that can act as stubs, spies, fakes or when used in an expecation, mocks. |
| 192 | + * |
| 193 | + * Spies should be created in test setup, before expectations. They can then be checked, using the standard Jasmine |
| 194 | + * expectation syntax. Spies can be checked if they were called or not and what the calling params were. |
| 195 | + * |
| 196 | + * A Spy has the following fields: wasCalled, callCount, mostRecentCall, and argsForCall (see docs). |
| 197 | + * |
| 198 | + * Spies are torn down at the end of every spec. |
| 199 | + * |
| 200 | + * Note: Do <b>not</b> call new jasmine.Spy() directly - a spy must be created using spyOn, jasmine.createSpy or jasmine.createSpyObj. |
| 201 | + * |
| 202 | + * @example |
| 203 | + * // a stub |
| 204 | + * var myStub = jasmine.createSpy('myStub'); // can be used anywhere |
| 205 | + * |
| 206 | + * // spy example |
| 207 | + * var foo = { |
| 208 | + * not: function(bool) { return !bool; } |
| 209 | + * } |
| 210 | + * |
| 211 | + * // actual foo.not will not be called, execution stops |
| 212 | + * spyOn(foo, 'not'); |
| 213 | + |
| 214 | + // foo.not spied upon, execution will continue to implementation |
| 215 | + * spyOn(foo, 'not').andCallThrough(); |
| 216 | + * |
| 217 | + * // fake example |
| 218 | + * var foo = { |
| 219 | + * not: function(bool) { return !bool; } |
| 220 | + * } |
| 221 | + * |
| 222 | + * // foo.not(val) will return val |
| 223 | + * spyOn(foo, 'not').andCallFake(function(value) {return value;}); |
| 224 | + * |
| 225 | + * // mock example |
| 226 | + * foo.not(7 == 7); |
| 227 | + * expect(foo.not).toHaveBeenCalled(); |
| 228 | + * expect(foo.not).toHaveBeenCalledWith(true); |
| 229 | + * |
| 230 | + * @constructor |
| 231 | + * @see spyOn, jasmine.createSpy, jasmine.createSpyObj |
| 232 | + * @param {String} name |
| 233 | + */ |
| 234 | +jasmine.Spy = function(name) { |
| 235 | + /** |
| 236 | + * The name of the spy, if provided. |
| 237 | + */ |
| 238 | + this.identity = name || 'unknown'; |
| 239 | + /** |
| 240 | + * Is this Object a spy? |
| 241 | + */ |
| 242 | + this.isSpy = true; |
| 243 | + /** |
| 244 | + * The actual function this spy stubs. |
| 245 | + */ |
| 246 | + this.plan = function() { |
| 247 | + }; |
| 248 | + /** |
| 249 | + * Tracking of the most recent call to the spy. |
| 250 | + * @example |
| 251 | + * var mySpy = jasmine.createSpy('foo'); |
| 252 | + * mySpy(1, 2); |
| 253 | + * mySpy.mostRecentCall.args = [1, 2]; |
| 254 | + */ |
| 255 | + this.mostRecentCall = {}; |
| 256 | + |
| 257 | + /** |
| 258 | + * Holds arguments for each call to the spy, indexed by call count |
| 259 | + * @example |
| 260 | + * var mySpy = jasmine.createSpy('foo'); |
| 261 | + * mySpy(1, 2); |
| 262 | + * mySpy(7, 8); |
| 263 | + * mySpy.mostRecentCall.args = [7, 8]; |
| 264 | + * mySpy.argsForCall[0] = [1, 2]; |
| 265 | + * mySpy.argsForCall[1] = [7, 8]; |
| 266 | + */ |
| 267 | + this.argsForCall = []; |
| 268 | + this.calls = []; |
| 269 | +}; |
| 270 | + |
| 271 | +/** |
| 272 | + * Tells a spy to call through to the actual implemenatation. |
| 273 | + * |
| 274 | + * @example |
| 275 | + * var foo = { |
| 276 | + * bar: function() { // do some stuff } |
| 277 | + * } |
| 278 | + * |
| 279 | + * // defining a spy on an existing property: foo.bar |
| 280 | + * spyOn(foo, 'bar').andCallThrough(); |
| 281 | + */ |
| 282 | +jasmine.Spy.prototype.andCallThrough = function() { |
| 283 | + this.plan = this.originalValue; |
| 284 | + return this; |
| 285 | +}; |
| 286 | + |
| 287 | +/** |
| 288 | + * For setting the return value of a spy. |
| 289 | + * |
| 290 | + * @example |
| 291 | + * // defining a spy from scratch: foo() returns 'baz' |
| 292 | + * var foo = jasmine.createSpy('spy on foo').andReturn('baz'); |
| 293 | + * |
| 294 | + * // defining a spy on an existing property: foo.bar() returns 'baz' |
| 295 | + * spyOn(foo, 'bar').andReturn('baz'); |
| 296 | + * |
| 297 | + * @param {Object} value |
| 298 | + */ |
| 299 | +jasmine.Spy.prototype.andReturn = function(value) { |
| 300 | + this.plan = function() { |
| 301 | + return value; |
| 302 | + }; |
| 303 | + return this; |
| 304 | +}; |
| 305 | + |
| 306 | +/** |
| 307 | + * For throwing an exception when a spy is called. |
| 308 | + * |
| 309 | + * @example |
| 310 | + * // defining a spy from scratch: foo() throws an exception w/ message 'ouch' |
| 311 | + * var foo = jasmine.createSpy('spy on foo').andThrow('baz'); |
| 312 | + * |
| 313 | + * // defining a spy on an existing property: foo.bar() throws an exception w/ message 'ouch' |
| 314 | + * spyOn(foo, 'bar').andThrow('baz'); |
| 315 | + * |
| 316 | + * @param {String} exceptionMsg |
| 317 | + */ |
| 318 | +jasmine.Spy.prototype.andThrow = function(exceptionMsg) { |
| 319 | + this.plan = function() { |
| 320 | + throw exceptionMsg; |
| 321 | + }; |
| 322 | + return this; |
| 323 | +}; |
| 324 | + |
| 325 | +/** |
| 326 | + * Calls an alternate implementation when a spy is called. |
| 327 | + * |
| 328 | + * @example |
| 329 | + * var baz = function() { |
| 330 | + * // do some stuff, return something |
| 331 | + * } |
| 332 | + * // defining a spy from scratch: foo() calls the function baz |
| 333 | + * var foo = jasmine.createSpy('spy on foo').andCall(baz); |
| 334 | + * |
| 335 | + * // defining a spy on an existing property: foo.bar() calls an anonymnous function |
| 336 | + * spyOn(foo, 'bar').andCall(function() { return 'baz';} ); |
| 337 | + * |
| 338 | + * @param {Function} fakeFunc |
| 339 | + */ |
| 340 | +jasmine.Spy.prototype.andCallFake = function(fakeFunc) { |
| 341 | + this.plan = fakeFunc; |
| 342 | + return this; |
| 343 | +}; |
| 344 | + |
| 345 | +/** |
| 346 | + * Resets all of a spy's the tracking variables so that it can be used again. |
| 347 | + * |
| 348 | + * @example |
| 349 | + * spyOn(foo, 'bar'); |
| 350 | + * |
| 351 | + * foo.bar(); |
| 352 | + * |
| 353 | + * expect(foo.bar.callCount).toEqual(1); |
| 354 | + * |
| 355 | + * foo.bar.reset(); |
| 356 | + * |
| 357 | + * expect(foo.bar.callCount).toEqual(0); |
| 358 | + */ |
| 359 | +jasmine.Spy.prototype.reset = function() { |
| 360 | + this.wasCalled = false; |
| 361 | + this.callCount = 0; |
| 362 | + this.argsForCall = []; |
| 363 | + this.calls = []; |
| 364 | + this.mostRecentCall = {}; |
| 365 | +}; |
| 366 | + |
| 367 | +jasmine.createSpy = function(name) { |
| 368 | + |
| 369 | + var spyObj = function() { |
| 370 | + spyObj.wasCalled = true; |
| 371 | + spyObj.callCount++; |
| 372 | + var args = jasmine.util.argsToArray(arguments); |
| 373 | + spyObj.mostRecentCall.object = this; |
| 374 | + spyObj.mostRecentCall.args = args; |
| 375 | + spyObj.argsForCall.push(args); |
| 376 | + spyObj.calls.push({object: this, args: args}); |
| 377 | + return spyObj.plan.apply(this, arguments); |
| 378 | + }; |
| 379 | + |
| 380 | + var spy = new jasmine.Spy(name); |
| 381 | + |
| 382 | + for (var prop in spy) { |
| 383 | + spyObj[prop] = spy[prop]; |
| 384 | + } |
| 385 | + |
| 386 | + spyObj.reset(); |
| 387 | + |
| 388 | + return spyObj; |
| 389 | +}; |
| 390 | + |
| 391 | +/** |
| 392 | + * Determines whether an object is a spy. |
| 393 | + * |
| 394 | + * @param {jasmine.Spy|Object} putativeSpy |
| 395 | + * @returns {Boolean} |
| 396 | + */ |
| 397 | +jasmine.isSpy = function(putativeSpy) { |
| 398 | + return putativeSpy && putativeSpy.isSpy; |
| 399 | +}; |
| 400 | + |
| 401 | +/** |
| 402 | + * Creates a more complicated spy: an Object that has every property a function that is a spy. Used for stubbing something |
| 403 | + * large in one call. |
| 404 | + * |
| 405 | + * @param {String} baseName name of spy class |
| 406 | + * @param {Array} methodNames array of names of methods to make spies |
| 407 | + */ |
| 408 | +jasmine.createSpyObj = function(baseName, methodNames) { |
| 409 | + if (!jasmine.isArray_(methodNames) || methodNames.length == 0) { |
| 410 | + throw new Error('createSpyObj requires a non-empty array of method names to create spies for'); |
| 411 | + } |
| 412 | + var obj = {}; |
| 413 | + for (var i = 0; i < methodNames.length; i++) { |
| 414 | + obj[methodNames[i]] = jasmine.createSpy(baseName + '.' + methodNames[i]); |
| 415 | + } |
| 416 | + return obj; |
| 417 | +}; |
| 418 | + |
| 419 | +/** |
| 420 | + * All parameters are pretty-printed and concatenated together, then written to the current spec's output. |
| 421 | + * |
| 422 | + * Be careful not to leave calls to <code>jasmine.log</code> in production code. |
| 423 | + */ |
| 424 | +jasmine.log = function() { |
| 425 | + var spec = jasmine.getEnv().currentSpec; |
| 426 | + spec.log.apply(spec, arguments); |
| 427 | +}; |
| 428 | + |
| 429 | +/** |
| 430 | + * Function that installs a spy on an existing object's method name. Used within a Spec to create a spy. |
| 431 | + * |
| 432 | + * @example |
| 433 | + * // spy example |
| 434 | + * var foo = { |
| 435 | + * not: function(bool) { return !bool; } |
| 436 | + * } |
| 437 | + * spyOn(foo, 'not'); // actual foo.not will not be called, execution stops |
| 438 | + * |
| 439 | + * @see jasmine.createSpy |
| 440 | + * @param obj |
| 441 | + * @param methodName |
| 442 | + * @returns a Jasmine spy that can be chained with all spy methods |
| 443 | + */ |
| 444 | +var spyOn = function(obj, methodName) { |
| 445 | + return jasmine.getEnv().currentSpec.spyOn(obj, methodName); |
| 446 | +}; |
| 447 | + |
| 448 | +/** |
| 449 | + * Creates a Jasmine spec that will be added to the current suite. |
| 450 | + * |
| 451 | + * // TODO: pending tests |
| 452 | + * |
| 453 | + * @example |
| 454 | + * it('should be true', function() { |
| 455 | + * expect(true).toEqual(true); |
| 456 | + * }); |
| 457 | + * |
| 458 | + * @param {String} desc description of this specification |
| 459 | + * @param {Function} func defines the preconditions and expectations of the spec |
| 460 | + */ |
| 461 | +var it = function(desc, func) { |
| 462 | + return jasmine.getEnv().it(desc, func); |
| 463 | +}; |
| 464 | + |
| 465 | +/** |
| 466 | + * Creates a <em>disabled</em> Jasmine spec. |
| 467 | + * |
| 468 | + * A convenience method that allows existing specs to be disabled temporarily during development. |
| 469 | + * |
| 470 | + * @param {String} desc description of this specification |
| 471 | + * @param {Function} func defines the preconditions and expectations of the spec |
| 472 | + */ |
| 473 | +var xit = function(desc, func) { |
| 474 | + return jasmine.getEnv().xit(desc, func); |
| 475 | +}; |
| 476 | + |
| 477 | +/** |
| 478 | + * Starts a chain for a Jasmine expectation. |
| 479 | + * |
| 480 | + * It is passed an Object that is the actual value and should chain to one of the many |
| 481 | + * jasmine.Matchers functions. |
| 482 | + * |
| 483 | + * @param {Object} actual Actual value to test against and expected value |
| 484 | + */ |
| 485 | +var expect = function(actual) { |
| 486 | + return jasmine.getEnv().currentSpec.expect(actual); |
| 487 | +}; |
| 488 | + |
| 489 | +/** |
| 490 | + * Defines part of a jasmine spec. Used in cominbination with waits or waitsFor in asynchrnous specs. |
| 491 | + * |
| 492 | + * @param {Function} func Function that defines part of a jasmine spec. |
| 493 | + */ |
| 494 | +var runs = function(func) { |
| 495 | + jasmine.getEnv().currentSpec.runs(func); |
| 496 | +}; |
| 497 | + |
| 498 | +/** |
| 499 | + * Waits a fixed time period before moving to the next block. |
| 500 | + * |
| 501 | + * @deprecated Use waitsFor() instead |
| 502 | + * @param {Number} timeout milliseconds to wait |
| 503 | + */ |
| 504 | +var waits = function(timeout) { |
| 505 | + jasmine.getEnv().currentSpec.waits(timeout); |
| 506 | +}; |
| 507 | + |
| 508 | +/** |
| 509 | + * Waits for the latchFunction to return true before proceeding to the next block. |
| 510 | + * |
| 511 | + * @param {Function} latchFunction |
| 512 | + * @param {String} optional_timeoutMessage |
| 513 | + * @param {Number} optional_timeout |
| 514 | + */ |
| 515 | +var waitsFor = function(latchFunction, optional_timeoutMessage, optional_timeout) { |
| 516 | + jasmine.getEnv().currentSpec.waitsFor.apply(jasmine.getEnv().currentSpec, arguments); |
| 517 | +}; |
| 518 | + |
| 519 | +/** |
| 520 | + * A function that is called before each spec in a suite. |
| 521 | + * |
| 522 | + * Used for spec setup, including validating assumptions. |
| 523 | + * |
| 524 | + * @param {Function} beforeEachFunction |
| 525 | + */ |
| 526 | +var beforeEach = function(beforeEachFunction) { |
| 527 | + jasmine.getEnv().beforeEach(beforeEachFunction); |
| 528 | +}; |
| 529 | + |
| 530 | +/** |
| 531 | + * A function that is called after each spec in a suite. |
| 532 | + * |
| 533 | + * Used for restoring any state that is hijacked during spec execution. |
| 534 | + * |
| 535 | + * @param {Function} afterEachFunction |
| 536 | + */ |
| 537 | +var afterEach = function(afterEachFunction) { |
| 538 | + jasmine.getEnv().afterEach(afterEachFunction); |
| 539 | +}; |
| 540 | + |
| 541 | +/** |
| 542 | + * Defines a suite of specifications. |
| 543 | + * |
| 544 | + * Stores the description and all defined specs in the Jasmine environment as one suite of specs. Variables declared |
| 545 | + * are accessible by calls to beforeEach, it, and afterEach. Describe blocks can be nested, allowing for specialization |
| 546 | + * of setup in some tests. |
| 547 | + * |
| 548 | + * @example |
| 549 | + * // TODO: a simple suite |
| 550 | + * |
| 551 | + * // TODO: a simple suite with a nested describe block |
| 552 | + * |
| 553 | + * @param {String} description A string, usually the class under test. |
| 554 | + * @param {Function} specDefinitions function that defines several specs. |
| 555 | + */ |
| 556 | +var describe = function(description, specDefinitions) { |
| 557 | + return jasmine.getEnv().describe(description, specDefinitions); |
| 558 | +}; |
| 559 | + |
| 560 | +/** |
| 561 | + * Disables a suite of specifications. Used to disable some suites in a file, or files, temporarily during development. |
| 562 | + * |
| 563 | + * @param {String} description A string, usually the class under test. |
| 564 | + * @param {Function} specDefinitions function that defines several specs. |
| 565 | + */ |
| 566 | +var xdescribe = function(description, specDefinitions) { |
| 567 | + return jasmine.getEnv().xdescribe(description, specDefinitions); |
| 568 | +}; |
| 569 | + |
| 570 | + |
| 571 | +// Provide the XMLHttpRequest class for IE 5.x-6.x: |
| 572 | +jasmine.XmlHttpRequest = (typeof XMLHttpRequest == "undefined") ? function() { |
| 573 | + try { |
| 574 | + return new ActiveXObject("Msxml2.XMLHTTP.6.0"); |
| 575 | + } catch(e) { |
| 576 | + } |
| 577 | + try { |
| 578 | + return new ActiveXObject("Msxml2.XMLHTTP.3.0"); |
| 579 | + } catch(e) { |
| 580 | + } |
| 581 | + try { |
| 582 | + return new ActiveXObject("Msxml2.XMLHTTP"); |
| 583 | + } catch(e) { |
| 584 | + } |
| 585 | + try { |
| 586 | + return new ActiveXObject("Microsoft.XMLHTTP"); |
| 587 | + } catch(e) { |
| 588 | + } |
| 589 | + throw new Error("This browser does not support XMLHttpRequest."); |
| 590 | +} : XMLHttpRequest; |
| 591 | +/** |
| 592 | + * @namespace |
| 593 | + */ |
| 594 | +jasmine.util = {}; |
| 595 | + |
| 596 | +/** |
| 597 | + * Declare that a child class inherit it's prototype from the parent class. |
| 598 | + * |
| 599 | + * @private |
| 600 | + * @param {Function} childClass |
| 601 | + * @param {Function} parentClass |
| 602 | + */ |
| 603 | +jasmine.util.inherit = function(childClass, parentClass) { |
| 604 | + /** |
| 605 | + * @private |
| 606 | + */ |
| 607 | + var subclass = function() { |
| 608 | + }; |
| 609 | + subclass.prototype = parentClass.prototype; |
| 610 | + childClass.prototype = new subclass; |
| 611 | +}; |
| 612 | + |
| 613 | +jasmine.util.formatException = function(e) { |
| 614 | + var lineNumber; |
| 615 | + if (e.line) { |
| 616 | + lineNumber = e.line; |
| 617 | + } |
| 618 | + else if (e.lineNumber) { |
| 619 | + lineNumber = e.lineNumber; |
| 620 | + } |
| 621 | + |
| 622 | + var file; |
| 623 | + |
| 624 | + if (e.sourceURL) { |
| 625 | + file = e.sourceURL; |
| 626 | + } |
| 627 | + else if (e.fileName) { |
| 628 | + file = e.fileName; |
| 629 | + } |
| 630 | + |
| 631 | + var message = (e.name && e.message) ? (e.name + ': ' + e.message) : e.toString(); |
| 632 | + |
| 633 | + if (file && lineNumber) { |
| 634 | + message += ' in ' + file + ' (line ' + lineNumber + ')'; |
| 635 | + } |
| 636 | + |
| 637 | + return message; |
| 638 | +}; |
| 639 | + |
| 640 | +jasmine.util.htmlEscape = function(str) { |
| 641 | + if (!str) return str; |
| 642 | + return str.replace(/&/g, '&') |
| 643 | + .replace(/</g, '<') |
| 644 | + .replace(/>/g, '>'); |
| 645 | +}; |
| 646 | + |
| 647 | +jasmine.util.argsToArray = function(args) { |
| 648 | + var arrayOfArgs = []; |
| 649 | + for (var i = 0; i < args.length; i++) arrayOfArgs.push(args[i]); |
| 650 | + return arrayOfArgs; |
| 651 | +}; |
| 652 | + |
| 653 | +jasmine.util.extend = function(destination, source) { |
| 654 | + for (var property in source) destination[property] = source[property]; |
| 655 | + return destination; |
| 656 | +}; |
| 657 | + |
| 658 | +/** |
| 659 | + * Environment for Jasmine |
| 660 | + * |
| 661 | + * @constructor |
| 662 | + */ |
| 663 | +jasmine.Env = function() { |
| 664 | + this.currentSpec = null; |
| 665 | + this.currentSuite = null; |
| 666 | + this.currentRunner_ = new jasmine.Runner(this); |
| 667 | + |
| 668 | + this.reporter = new jasmine.MultiReporter(); |
| 669 | + |
| 670 | + this.updateInterval = jasmine.DEFAULT_UPDATE_INTERVAL; |
| 671 | + this.defaultTimeoutInterval = jasmine.DEFAULT_TIMEOUT_INTERVAL; |
| 672 | + this.lastUpdate = 0; |
| 673 | + this.specFilter = function() { |
| 674 | + return true; |
| 675 | + }; |
| 676 | + |
| 677 | + this.nextSpecId_ = 0; |
| 678 | + this.nextSuiteId_ = 0; |
| 679 | + this.equalityTesters_ = []; |
| 680 | + |
| 681 | + // wrap matchers |
| 682 | + this.matchersClass = function() { |
| 683 | + jasmine.Matchers.apply(this, arguments); |
| 684 | + }; |
| 685 | + jasmine.util.inherit(this.matchersClass, jasmine.Matchers); |
| 686 | + |
| 687 | + jasmine.Matchers.wrapInto_(jasmine.Matchers.prototype, this.matchersClass); |
| 688 | +}; |
| 689 | + |
| 690 | + |
| 691 | +jasmine.Env.prototype.setTimeout = jasmine.setTimeout; |
| 692 | +jasmine.Env.prototype.clearTimeout = jasmine.clearTimeout; |
| 693 | +jasmine.Env.prototype.setInterval = jasmine.setInterval; |
| 694 | +jasmine.Env.prototype.clearInterval = jasmine.clearInterval; |
| 695 | + |
| 696 | +/** |
| 697 | + * @returns an object containing jasmine version build info, if set. |
| 698 | + */ |
| 699 | +jasmine.Env.prototype.version = function () { |
| 700 | + if (jasmine.version_) { |
| 701 | + return jasmine.version_; |
| 702 | + } else { |
| 703 | + throw new Error('Version not set'); |
| 704 | + } |
| 705 | +}; |
| 706 | + |
| 707 | +/** |
| 708 | + * @returns string containing jasmine version build info, if set. |
| 709 | + */ |
| 710 | +jasmine.Env.prototype.versionString = function() { |
| 711 | + if (jasmine.version_) { |
| 712 | + var version = this.version(); |
| 713 | + return version.major + "." + version.minor + "." + version.build + " revision " + version.revision; |
| 714 | + } else { |
| 715 | + return "version unknown"; |
| 716 | + } |
| 717 | +}; |
| 718 | + |
| 719 | +/** |
| 720 | + * @returns a sequential integer starting at 0 |
| 721 | + */ |
| 722 | +jasmine.Env.prototype.nextSpecId = function () { |
| 723 | + return this.nextSpecId_++; |
| 724 | +}; |
| 725 | + |
| 726 | +/** |
| 727 | + * @returns a sequential integer starting at 0 |
| 728 | + */ |
| 729 | +jasmine.Env.prototype.nextSuiteId = function () { |
| 730 | + return this.nextSuiteId_++; |
| 731 | +}; |
| 732 | + |
| 733 | +/** |
| 734 | + * Register a reporter to receive status updates from Jasmine. |
| 735 | + * @param {jasmine.Reporter} reporter An object which will receive status updates. |
| 736 | + */ |
| 737 | +jasmine.Env.prototype.addReporter = function(reporter) { |
| 738 | + this.reporter.addReporter(reporter); |
| 739 | +}; |
| 740 | + |
| 741 | +jasmine.Env.prototype.execute = function() { |
| 742 | + this.currentRunner_.execute(); |
| 743 | +}; |
| 744 | + |
| 745 | +jasmine.Env.prototype.describe = function(description, specDefinitions) { |
| 746 | + var suite = new jasmine.Suite(this, description, specDefinitions, this.currentSuite); |
| 747 | + |
| 748 | + var parentSuite = this.currentSuite; |
| 749 | + if (parentSuite) { |
| 750 | + parentSuite.add(suite); |
| 751 | + } else { |
| 752 | + this.currentRunner_.add(suite); |
| 753 | + } |
| 754 | + |
| 755 | + this.currentSuite = suite; |
| 756 | + |
| 757 | + var declarationError = null; |
| 758 | + try { |
| 759 | + specDefinitions.call(suite); |
| 760 | + } catch(e) { |
| 761 | + declarationError = e; |
| 762 | + } |
| 763 | + |
| 764 | + this.currentSuite = parentSuite; |
| 765 | + |
| 766 | + if (declarationError) { |
| 767 | + this.it("encountered a declaration exception", function() { |
| 768 | + throw declarationError; |
| 769 | + }); |
| 770 | + } |
| 771 | + |
| 772 | + return suite; |
| 773 | +}; |
| 774 | + |
| 775 | +jasmine.Env.prototype.beforeEach = function(beforeEachFunction) { |
| 776 | + if (this.currentSuite) { |
| 777 | + this.currentSuite.beforeEach(beforeEachFunction); |
| 778 | + } else { |
| 779 | + this.currentRunner_.beforeEach(beforeEachFunction); |
| 780 | + } |
| 781 | +}; |
| 782 | + |
| 783 | +jasmine.Env.prototype.currentRunner = function () { |
| 784 | + return this.currentRunner_; |
| 785 | +}; |
| 786 | + |
| 787 | +jasmine.Env.prototype.afterEach = function(afterEachFunction) { |
| 788 | + if (this.currentSuite) { |
| 789 | + this.currentSuite.afterEach(afterEachFunction); |
| 790 | + } else { |
| 791 | + this.currentRunner_.afterEach(afterEachFunction); |
| 792 | + } |
| 793 | + |
| 794 | +}; |
| 795 | + |
| 796 | +jasmine.Env.prototype.xdescribe = function(desc, specDefinitions) { |
| 797 | + return { |
| 798 | + execute: function() { |
| 799 | + } |
| 800 | + }; |
| 801 | +}; |
| 802 | + |
| 803 | +jasmine.Env.prototype.it = function(description, func) { |
| 804 | + var spec = new jasmine.Spec(this, this.currentSuite, description); |
| 805 | + this.currentSuite.add(spec); |
| 806 | + this.currentSpec = spec; |
| 807 | + |
| 808 | + if (func) { |
| 809 | + spec.runs(func); |
| 810 | + } |
| 811 | + |
| 812 | + return spec; |
| 813 | +}; |
| 814 | + |
| 815 | +jasmine.Env.prototype.xit = function(desc, func) { |
| 816 | + return { |
| 817 | + id: this.nextSpecId(), |
| 818 | + runs: function() { |
| 819 | + } |
| 820 | + }; |
| 821 | +}; |
| 822 | + |
| 823 | +jasmine.Env.prototype.compareObjects_ = function(a, b, mismatchKeys, mismatchValues) { |
| 824 | + if (a.__Jasmine_been_here_before__ === b && b.__Jasmine_been_here_before__ === a) { |
| 825 | + return true; |
| 826 | + } |
| 827 | + |
| 828 | + a.__Jasmine_been_here_before__ = b; |
| 829 | + b.__Jasmine_been_here_before__ = a; |
| 830 | + |
| 831 | + var hasKey = function(obj, keyName) { |
| 832 | + return obj != null && obj[keyName] !== jasmine.undefined; |
| 833 | + }; |
| 834 | + |
| 835 | + for (var property in b) { |
| 836 | + if (!hasKey(a, property) && hasKey(b, property)) { |
| 837 | + mismatchKeys.push("expected has key '" + property + "', but missing from actual."); |
| 838 | + } |
| 839 | + } |
| 840 | + for (property in a) { |
| 841 | + if (!hasKey(b, property) && hasKey(a, property)) { |
| 842 | + mismatchKeys.push("expected missing key '" + property + "', but present in actual."); |
| 843 | + } |
| 844 | + } |
| 845 | + for (property in b) { |
| 846 | + if (property == '__Jasmine_been_here_before__') continue; |
| 847 | + if (!this.equals_(a[property], b[property], mismatchKeys, mismatchValues)) { |
| 848 | + mismatchValues.push("'" + property + "' was '" + (b[property] ? jasmine.util.htmlEscape(b[property].toString()) : b[property]) + "' in expected, but was '" + (a[property] ? jasmine.util.htmlEscape(a[property].toString()) : a[property]) + "' in actual."); |
| 849 | + } |
| 850 | + } |
| 851 | + |
| 852 | + if (jasmine.isArray_(a) && jasmine.isArray_(b) && a.length != b.length) { |
| 853 | + mismatchValues.push("arrays were not the same length"); |
| 854 | + } |
| 855 | + |
| 856 | + delete a.__Jasmine_been_here_before__; |
| 857 | + delete b.__Jasmine_been_here_before__; |
| 858 | + return (mismatchKeys.length == 0 && mismatchValues.length == 0); |
| 859 | +}; |
| 860 | + |
| 861 | +jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) { |
| 862 | + mismatchKeys = mismatchKeys || []; |
| 863 | + mismatchValues = mismatchValues || []; |
| 864 | + |
| 865 | + for (var i = 0; i < this.equalityTesters_.length; i++) { |
| 866 | + var equalityTester = this.equalityTesters_[i]; |
| 867 | + var result = equalityTester(a, b, this, mismatchKeys, mismatchValues); |
| 868 | + if (result !== jasmine.undefined) return result; |
| 869 | + } |
| 870 | + |
| 871 | + if (a === b) return true; |
| 872 | + |
| 873 | + if (a === jasmine.undefined || a === null || b === jasmine.undefined || b === null) { |
| 874 | + return (a == jasmine.undefined && b == jasmine.undefined); |
| 875 | + } |
| 876 | + |
| 877 | + if (jasmine.isDomNode(a) && jasmine.isDomNode(b)) { |
| 878 | + return a === b; |
| 879 | + } |
| 880 | + |
| 881 | + if (a instanceof Date && b instanceof Date) { |
| 882 | + return a.getTime() == b.getTime(); |
| 883 | + } |
| 884 | + |
| 885 | + if (a instanceof jasmine.Matchers.Any) { |
| 886 | + return a.matches(b); |
| 887 | + } |
| 888 | + |
| 889 | + if (b instanceof jasmine.Matchers.Any) { |
| 890 | + return b.matches(a); |
| 891 | + } |
| 892 | + |
| 893 | + if (jasmine.isString_(a) && jasmine.isString_(b)) { |
| 894 | + return (a == b); |
| 895 | + } |
| 896 | + |
| 897 | + if (jasmine.isNumber_(a) && jasmine.isNumber_(b)) { |
| 898 | + return (a == b); |
| 899 | + } |
| 900 | + |
| 901 | + if (typeof a === "object" && typeof b === "object") { |
| 902 | + return this.compareObjects_(a, b, mismatchKeys, mismatchValues); |
| 903 | + } |
| 904 | + |
| 905 | + //Straight check |
| 906 | + return (a === b); |
| 907 | +}; |
| 908 | + |
| 909 | +jasmine.Env.prototype.contains_ = function(haystack, needle) { |
| 910 | + if (jasmine.isArray_(haystack)) { |
| 911 | + for (var i = 0; i < haystack.length; i++) { |
| 912 | + if (this.equals_(haystack[i], needle)) return true; |
| 913 | + } |
| 914 | + return false; |
| 915 | + } |
| 916 | + return haystack.indexOf(needle) >= 0; |
| 917 | +}; |
| 918 | + |
| 919 | +jasmine.Env.prototype.addEqualityTester = function(equalityTester) { |
| 920 | + this.equalityTesters_.push(equalityTester); |
| 921 | +}; |
| 922 | +/** No-op base class for Jasmine reporters. |
| 923 | + * |
| 924 | + * @constructor |
| 925 | + */ |
| 926 | +jasmine.Reporter = function() { |
| 927 | +}; |
| 928 | + |
| 929 | +//noinspection JSUnusedLocalSymbols |
| 930 | +jasmine.Reporter.prototype.reportRunnerStarting = function(runner) { |
| 931 | +}; |
| 932 | + |
| 933 | +//noinspection JSUnusedLocalSymbols |
| 934 | +jasmine.Reporter.prototype.reportRunnerResults = function(runner) { |
| 935 | +}; |
| 936 | + |
| 937 | +//noinspection JSUnusedLocalSymbols |
| 938 | +jasmine.Reporter.prototype.reportSuiteResults = function(suite) { |
| 939 | +}; |
| 940 | + |
| 941 | +//noinspection JSUnusedLocalSymbols |
| 942 | +jasmine.Reporter.prototype.reportSpecStarting = function(spec) { |
| 943 | +}; |
| 944 | + |
| 945 | +//noinspection JSUnusedLocalSymbols |
| 946 | +jasmine.Reporter.prototype.reportSpecResults = function(spec) { |
| 947 | +}; |
| 948 | + |
| 949 | +//noinspection JSUnusedLocalSymbols |
| 950 | +jasmine.Reporter.prototype.log = function(str) { |
| 951 | +}; |
| 952 | + |
| 953 | +/** |
| 954 | + * Blocks are functions with executable code that make up a spec. |
| 955 | + * |
| 956 | + * @constructor |
| 957 | + * @param {jasmine.Env} env |
| 958 | + * @param {Function} func |
| 959 | + * @param {jasmine.Spec} spec |
| 960 | + */ |
| 961 | +jasmine.Block = function(env, func, spec) { |
| 962 | + this.env = env; |
| 963 | + this.func = func; |
| 964 | + this.spec = spec; |
| 965 | +}; |
| 966 | + |
| 967 | +jasmine.Block.prototype.execute = function(onComplete) { |
| 968 | + try { |
| 969 | + this.func.apply(this.spec); |
| 970 | + } catch (e) { |
| 971 | + this.spec.fail(e); |
| 972 | + } |
| 973 | + onComplete(); |
| 974 | +}; |
| 975 | +/** JavaScript API reporter. |
| 976 | + * |
| 977 | + * @constructor |
| 978 | + */ |
| 979 | +jasmine.JsApiReporter = function() { |
| 980 | + this.started = false; |
| 981 | + this.finished = false; |
| 982 | + this.suites_ = []; |
| 983 | + this.results_ = {}; |
| 984 | +}; |
| 985 | + |
| 986 | +jasmine.JsApiReporter.prototype.reportRunnerStarting = function(runner) { |
| 987 | + this.started = true; |
| 988 | + var suites = runner.topLevelSuites(); |
| 989 | + for (var i = 0; i < suites.length; i++) { |
| 990 | + var suite = suites[i]; |
| 991 | + this.suites_.push(this.summarize_(suite)); |
| 992 | + } |
| 993 | +}; |
| 994 | + |
| 995 | +jasmine.JsApiReporter.prototype.suites = function() { |
| 996 | + return this.suites_; |
| 997 | +}; |
| 998 | + |
| 999 | +jasmine.JsApiReporter.prototype.summarize_ = function(suiteOrSpec) { |
| 1000 | + var isSuite = suiteOrSpec instanceof jasmine.Suite; |
| 1001 | + var summary = { |
| 1002 | + id: suiteOrSpec.id, |
| 1003 | + name: suiteOrSpec.description, |
| 1004 | + type: isSuite ? 'suite' : 'spec', |
| 1005 | + children: [] |
| 1006 | + }; |
| 1007 | + |
| 1008 | + if (isSuite) { |
| 1009 | + var children = suiteOrSpec.children(); |
| 1010 | + for (var i = 0; i < children.length; i++) { |
| 1011 | + summary.children.push(this.summarize_(children[i])); |
| 1012 | + } |
| 1013 | + } |
| 1014 | + return summary; |
| 1015 | +}; |
| 1016 | + |
| 1017 | +jasmine.JsApiReporter.prototype.results = function() { |
| 1018 | + return this.results_; |
| 1019 | +}; |
| 1020 | + |
| 1021 | +jasmine.JsApiReporter.prototype.resultsForSpec = function(specId) { |
| 1022 | + return this.results_[specId]; |
| 1023 | +}; |
| 1024 | + |
| 1025 | +//noinspection JSUnusedLocalSymbols |
| 1026 | +jasmine.JsApiReporter.prototype.reportRunnerResults = function(runner) { |
| 1027 | + this.finished = true; |
| 1028 | +}; |
| 1029 | + |
| 1030 | +//noinspection JSUnusedLocalSymbols |
| 1031 | +jasmine.JsApiReporter.prototype.reportSuiteResults = function(suite) { |
| 1032 | +}; |
| 1033 | + |
| 1034 | +//noinspection JSUnusedLocalSymbols |
| 1035 | +jasmine.JsApiReporter.prototype.reportSpecResults = function(spec) { |
| 1036 | + this.results_[spec.id] = { |
| 1037 | + messages: spec.results().getItems(), |
| 1038 | + result: spec.results().failedCount > 0 ? "failed" : "passed" |
| 1039 | + }; |
| 1040 | +}; |
| 1041 | + |
| 1042 | +//noinspection JSUnusedLocalSymbols |
| 1043 | +jasmine.JsApiReporter.prototype.log = function(str) { |
| 1044 | +}; |
| 1045 | + |
| 1046 | +jasmine.JsApiReporter.prototype.resultsForSpecs = function(specIds){ |
| 1047 | + var results = {}; |
| 1048 | + for (var i = 0; i < specIds.length; i++) { |
| 1049 | + var specId = specIds[i]; |
| 1050 | + results[specId] = this.summarizeResult_(this.results_[specId]); |
| 1051 | + } |
| 1052 | + return results; |
| 1053 | +}; |
| 1054 | + |
| 1055 | +jasmine.JsApiReporter.prototype.summarizeResult_ = function(result){ |
| 1056 | + var summaryMessages = []; |
| 1057 | + var messagesLength = result.messages.length; |
| 1058 | + for (var messageIndex = 0; messageIndex < messagesLength; messageIndex++) { |
| 1059 | + var resultMessage = result.messages[messageIndex]; |
| 1060 | + summaryMessages.push({ |
| 1061 | + text: resultMessage.type == 'log' ? resultMessage.toString() : jasmine.undefined, |
| 1062 | + passed: resultMessage.passed ? resultMessage.passed() : true, |
| 1063 | + type: resultMessage.type, |
| 1064 | + message: resultMessage.message, |
| 1065 | + trace: { |
| 1066 | + stack: resultMessage.passed && !resultMessage.passed() ? resultMessage.trace.stack : jasmine.undefined |
| 1067 | + } |
| 1068 | + }); |
| 1069 | + } |
| 1070 | + |
| 1071 | + return { |
| 1072 | + result : result.result, |
| 1073 | + messages : summaryMessages |
| 1074 | + }; |
| 1075 | +}; |
| 1076 | + |
| 1077 | +/** |
| 1078 | + * @constructor |
| 1079 | + * @param {jasmine.Env} env |
| 1080 | + * @param actual |
| 1081 | + * @param {jasmine.Spec} spec |
| 1082 | + */ |
| 1083 | +jasmine.Matchers = function(env, actual, spec, opt_isNot) { |
| 1084 | + this.env = env; |
| 1085 | + this.actual = actual; |
| 1086 | + this.spec = spec; |
| 1087 | + this.isNot = opt_isNot || false; |
| 1088 | + this.reportWasCalled_ = false; |
| 1089 | +}; |
| 1090 | + |
| 1091 | +// todo: @deprecated as of Jasmine 0.11, remove soon [xw] |
| 1092 | +jasmine.Matchers.pp = function(str) { |
| 1093 | + throw new Error("jasmine.Matchers.pp() is no longer supported, please use jasmine.pp() instead!"); |
| 1094 | +}; |
| 1095 | + |
| 1096 | +// todo: @deprecated Deprecated as of Jasmine 0.10. Rewrite your custom matchers to return true or false. [xw] |
| 1097 | +jasmine.Matchers.prototype.report = function(result, failing_message, details) { |
| 1098 | + throw new Error("As of jasmine 0.11, custom matchers must be implemented differently -- please see jasmine docs"); |
| 1099 | +}; |
| 1100 | + |
| 1101 | +jasmine.Matchers.wrapInto_ = function(prototype, matchersClass) { |
| 1102 | + for (var methodName in prototype) { |
| 1103 | + if (methodName == 'report') continue; |
| 1104 | + var orig = prototype[methodName]; |
| 1105 | + matchersClass.prototype[methodName] = jasmine.Matchers.matcherFn_(methodName, orig); |
| 1106 | + } |
| 1107 | +}; |
| 1108 | + |
| 1109 | +jasmine.Matchers.matcherFn_ = function(matcherName, matcherFunction) { |
| 1110 | + return function() { |
| 1111 | + var matcherArgs = jasmine.util.argsToArray(arguments); |
| 1112 | + var result = matcherFunction.apply(this, arguments); |
| 1113 | + |
| 1114 | + if (this.isNot) { |
| 1115 | + result = !result; |
| 1116 | + } |
| 1117 | + |
| 1118 | + if (this.reportWasCalled_) return result; |
| 1119 | + |
| 1120 | + var message; |
| 1121 | + if (!result) { |
| 1122 | + if (this.message) { |
| 1123 | + message = this.message.apply(this, arguments); |
| 1124 | + if (jasmine.isArray_(message)) { |
| 1125 | + message = message[this.isNot ? 1 : 0]; |
| 1126 | + } |
| 1127 | + } else { |
| 1128 | + var englishyPredicate = matcherName.replace(/[A-Z]/g, function(s) { return ' ' + s.toLowerCase(); }); |
| 1129 | + message = "Expected " + jasmine.pp(this.actual) + (this.isNot ? " not " : " ") + englishyPredicate; |
| 1130 | + if (matcherArgs.length > 0) { |
| 1131 | + for (var i = 0; i < matcherArgs.length; i++) { |
| 1132 | + if (i > 0) message += ","; |
| 1133 | + message += " " + jasmine.pp(matcherArgs[i]); |
| 1134 | + } |
| 1135 | + } |
| 1136 | + message += "."; |
| 1137 | + } |
| 1138 | + } |
| 1139 | + var expectationResult = new jasmine.ExpectationResult({ |
| 1140 | + matcherName: matcherName, |
| 1141 | + passed: result, |
| 1142 | + expected: matcherArgs.length > 1 ? matcherArgs : matcherArgs[0], |
| 1143 | + actual: this.actual, |
| 1144 | + message: message |
| 1145 | + }); |
| 1146 | + this.spec.addMatcherResult(expectationResult); |
| 1147 | + return jasmine.undefined; |
| 1148 | + }; |
| 1149 | +}; |
| 1150 | + |
| 1151 | + |
| 1152 | + |
| 1153 | + |
| 1154 | +/** |
| 1155 | + * toBe: compares the actual to the expected using === |
| 1156 | + * @param expected |
| 1157 | + */ |
| 1158 | +jasmine.Matchers.prototype.toBe = function(expected) { |
| 1159 | + return this.actual === expected; |
| 1160 | +}; |
| 1161 | + |
| 1162 | +/** |
| 1163 | + * toNotBe: compares the actual to the expected using !== |
| 1164 | + * @param expected |
| 1165 | + * @deprecated as of 1.0. Use not.toBe() instead. |
| 1166 | + */ |
| 1167 | +jasmine.Matchers.prototype.toNotBe = function(expected) { |
| 1168 | + return this.actual !== expected; |
| 1169 | +}; |
| 1170 | + |
| 1171 | +/** |
| 1172 | + * toEqual: compares the actual to the expected using common sense equality. Handles Objects, Arrays, etc. |
| 1173 | + * |
| 1174 | + * @param expected |
| 1175 | + */ |
| 1176 | +jasmine.Matchers.prototype.toEqual = function(expected) { |
| 1177 | + return this.env.equals_(this.actual, expected); |
| 1178 | +}; |
| 1179 | + |
| 1180 | +/** |
| 1181 | + * toNotEqual: compares the actual to the expected using the ! of jasmine.Matchers.toEqual |
| 1182 | + * @param expected |
| 1183 | + * @deprecated as of 1.0. Use not.toNotEqual() instead. |
| 1184 | + */ |
| 1185 | +jasmine.Matchers.prototype.toNotEqual = function(expected) { |
| 1186 | + return !this.env.equals_(this.actual, expected); |
| 1187 | +}; |
| 1188 | + |
| 1189 | +/** |
| 1190 | + * Matcher that compares the actual to the expected using a regular expression. Constructs a RegExp, so takes |
| 1191 | + * a pattern or a String. |
| 1192 | + * |
| 1193 | + * @param expected |
| 1194 | + */ |
| 1195 | +jasmine.Matchers.prototype.toMatch = function(expected) { |
| 1196 | + return new RegExp(expected).test(this.actual); |
| 1197 | +}; |
| 1198 | + |
| 1199 | +/** |
| 1200 | + * Matcher that compares the actual to the expected using the boolean inverse of jasmine.Matchers.toMatch |
| 1201 | + * @param expected |
| 1202 | + * @deprecated as of 1.0. Use not.toMatch() instead. |
| 1203 | + */ |
| 1204 | +jasmine.Matchers.prototype.toNotMatch = function(expected) { |
| 1205 | + return !(new RegExp(expected).test(this.actual)); |
| 1206 | +}; |
| 1207 | + |
| 1208 | +/** |
| 1209 | + * Matcher that compares the actual to jasmine.undefined. |
| 1210 | + */ |
| 1211 | +jasmine.Matchers.prototype.toBeDefined = function() { |
| 1212 | + return (this.actual !== jasmine.undefined); |
| 1213 | +}; |
| 1214 | + |
| 1215 | +/** |
| 1216 | + * Matcher that compares the actual to jasmine.undefined. |
| 1217 | + */ |
| 1218 | +jasmine.Matchers.prototype.toBeUndefined = function() { |
| 1219 | + return (this.actual === jasmine.undefined); |
| 1220 | +}; |
| 1221 | + |
| 1222 | +/** |
| 1223 | + * Matcher that compares the actual to null. |
| 1224 | + */ |
| 1225 | +jasmine.Matchers.prototype.toBeNull = function() { |
| 1226 | + return (this.actual === null); |
| 1227 | +}; |
| 1228 | + |
| 1229 | +/** |
| 1230 | + * Matcher that boolean not-nots the actual. |
| 1231 | + */ |
| 1232 | +jasmine.Matchers.prototype.toBeTruthy = function() { |
| 1233 | + return !!this.actual; |
| 1234 | +}; |
| 1235 | + |
| 1236 | + |
| 1237 | +/** |
| 1238 | + * Matcher that boolean nots the actual. |
| 1239 | + */ |
| 1240 | +jasmine.Matchers.prototype.toBeFalsy = function() { |
| 1241 | + return !this.actual; |
| 1242 | +}; |
| 1243 | + |
| 1244 | + |
| 1245 | +/** |
| 1246 | + * Matcher that checks to see if the actual, a Jasmine spy, was called. |
| 1247 | + */ |
| 1248 | +jasmine.Matchers.prototype.toHaveBeenCalled = function() { |
| 1249 | + if (arguments.length > 0) { |
| 1250 | + throw new Error('toHaveBeenCalled does not take arguments, use toHaveBeenCalledWith'); |
| 1251 | + } |
| 1252 | + |
| 1253 | + if (!jasmine.isSpy(this.actual)) { |
| 1254 | + throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.'); |
| 1255 | + } |
| 1256 | + |
| 1257 | + this.message = function() { |
| 1258 | + return [ |
| 1259 | + "Expected spy " + this.actual.identity + " to have been called.", |
| 1260 | + "Expected spy " + this.actual.identity + " not to have been called." |
| 1261 | + ]; |
| 1262 | + }; |
| 1263 | + |
| 1264 | + return this.actual.wasCalled; |
| 1265 | +}; |
| 1266 | + |
| 1267 | +/** @deprecated Use expect(xxx).toHaveBeenCalled() instead */ |
| 1268 | +jasmine.Matchers.prototype.wasCalled = jasmine.Matchers.prototype.toHaveBeenCalled; |
| 1269 | + |
| 1270 | +/** |
| 1271 | + * Matcher that checks to see if the actual, a Jasmine spy, was not called. |
| 1272 | + * |
| 1273 | + * @deprecated Use expect(xxx).not.toHaveBeenCalled() instead |
| 1274 | + */ |
| 1275 | +jasmine.Matchers.prototype.wasNotCalled = function() { |
| 1276 | + if (arguments.length > 0) { |
| 1277 | + throw new Error('wasNotCalled does not take arguments'); |
| 1278 | + } |
| 1279 | + |
| 1280 | + if (!jasmine.isSpy(this.actual)) { |
| 1281 | + throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.'); |
| 1282 | + } |
| 1283 | + |
| 1284 | + this.message = function() { |
| 1285 | + return [ |
| 1286 | + "Expected spy " + this.actual.identity + " to not have been called.", |
| 1287 | + "Expected spy " + this.actual.identity + " to have been called." |
| 1288 | + ]; |
| 1289 | + }; |
| 1290 | + |
| 1291 | + return !this.actual.wasCalled; |
| 1292 | +}; |
| 1293 | + |
| 1294 | +/** |
| 1295 | + * Matcher that checks to see if the actual, a Jasmine spy, was called with a set of parameters. |
| 1296 | + * |
| 1297 | + * @example |
| 1298 | + * |
| 1299 | + */ |
| 1300 | +jasmine.Matchers.prototype.toHaveBeenCalledWith = function() { |
| 1301 | + var expectedArgs = jasmine.util.argsToArray(arguments); |
| 1302 | + if (!jasmine.isSpy(this.actual)) { |
| 1303 | + throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.'); |
| 1304 | + } |
| 1305 | + this.message = function() { |
| 1306 | + if (this.actual.callCount == 0) { |
| 1307 | + // todo: what should the failure message for .not.toHaveBeenCalledWith() be? is this right? test better. [xw] |
| 1308 | + return [ |
| 1309 | + "Expected spy to have been called with " + jasmine.pp(expectedArgs) + " but it was never called.", |
| 1310 | + "Expected spy not to have been called with " + jasmine.pp(expectedArgs) + " but it was." |
| 1311 | + ]; |
| 1312 | + } else { |
| 1313 | + return [ |
| 1314 | + "Expected spy to have been called with " + jasmine.pp(expectedArgs) + " but was called with " + jasmine.pp(this.actual.argsForCall), |
| 1315 | + "Expected spy not to have been called with " + jasmine.pp(expectedArgs) + " but was called with " + jasmine.pp(this.actual.argsForCall) |
| 1316 | + ]; |
| 1317 | + } |
| 1318 | + }; |
| 1319 | + |
| 1320 | + return this.env.contains_(this.actual.argsForCall, expectedArgs); |
| 1321 | +}; |
| 1322 | + |
| 1323 | +/** @deprecated Use expect(xxx).toHaveBeenCalledWith() instead */ |
| 1324 | +jasmine.Matchers.prototype.wasCalledWith = jasmine.Matchers.prototype.toHaveBeenCalledWith; |
| 1325 | + |
| 1326 | +/** @deprecated Use expect(xxx).not.toHaveBeenCalledWith() instead */ |
| 1327 | +jasmine.Matchers.prototype.wasNotCalledWith = function() { |
| 1328 | + var expectedArgs = jasmine.util.argsToArray(arguments); |
| 1329 | + if (!jasmine.isSpy(this.actual)) { |
| 1330 | + throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.'); |
| 1331 | + } |
| 1332 | + |
| 1333 | + this.message = function() { |
| 1334 | + return [ |
| 1335 | + "Expected spy not to have been called with " + jasmine.pp(expectedArgs) + " but it was", |
| 1336 | + "Expected spy to have been called with " + jasmine.pp(expectedArgs) + " but it was" |
| 1337 | + ] |
| 1338 | + }; |
| 1339 | + |
| 1340 | + return !this.env.contains_(this.actual.argsForCall, expectedArgs); |
| 1341 | +}; |
| 1342 | + |
| 1343 | +/** |
| 1344 | + * Matcher that checks that the expected item is an element in the actual Array. |
| 1345 | + * |
| 1346 | + * @param {Object} expected |
| 1347 | + */ |
| 1348 | +jasmine.Matchers.prototype.toContain = function(expected) { |
| 1349 | + return this.env.contains_(this.actual, expected); |
| 1350 | +}; |
| 1351 | + |
| 1352 | +/** |
| 1353 | + * Matcher that checks that the expected item is NOT an element in the actual Array. |
| 1354 | + * |
| 1355 | + * @param {Object} expected |
| 1356 | + * @deprecated as of 1.0. Use not.toNotContain() instead. |
| 1357 | + */ |
| 1358 | +jasmine.Matchers.prototype.toNotContain = function(expected) { |
| 1359 | + return !this.env.contains_(this.actual, expected); |
| 1360 | +}; |
| 1361 | + |
| 1362 | +jasmine.Matchers.prototype.toBeLessThan = function(expected) { |
| 1363 | + return this.actual < expected; |
| 1364 | +}; |
| 1365 | + |
| 1366 | +jasmine.Matchers.prototype.toBeGreaterThan = function(expected) { |
| 1367 | + return this.actual > expected; |
| 1368 | +}; |
| 1369 | + |
| 1370 | +/** |
| 1371 | + * Matcher that checks that the expected exception was thrown by the actual. |
| 1372 | + * |
| 1373 | + * @param {String} expected |
| 1374 | + */ |
| 1375 | +jasmine.Matchers.prototype.toThrow = function(expected) { |
| 1376 | + var result = false; |
| 1377 | + var exception; |
| 1378 | + if (typeof this.actual != 'function') { |
| 1379 | + throw new Error('Actual is not a function'); |
| 1380 | + } |
| 1381 | + try { |
| 1382 | + this.actual(); |
| 1383 | + } catch (e) { |
| 1384 | + exception = e; |
| 1385 | + } |
| 1386 | + if (exception) { |
| 1387 | + result = (expected === jasmine.undefined || this.env.equals_(exception.message || exception, expected.message || expected)); |
| 1388 | + } |
| 1389 | + |
| 1390 | + var not = this.isNot ? "not " : ""; |
| 1391 | + |
| 1392 | + this.message = function() { |
| 1393 | + if (exception && (expected === jasmine.undefined || !this.env.equals_(exception.message || exception, expected.message || expected))) { |
| 1394 | + return ["Expected function " + not + "to throw", expected ? expected.message || expected : " an exception", ", but it threw", exception.message || exception].join(' '); |
| 1395 | + } else { |
| 1396 | + return "Expected function to throw an exception."; |
| 1397 | + } |
| 1398 | + }; |
| 1399 | + |
| 1400 | + return result; |
| 1401 | +}; |
| 1402 | + |
| 1403 | +jasmine.Matchers.Any = function(expectedClass) { |
| 1404 | + this.expectedClass = expectedClass; |
| 1405 | +}; |
| 1406 | + |
| 1407 | +jasmine.Matchers.Any.prototype.matches = function(other) { |
| 1408 | + if (this.expectedClass == String) { |
| 1409 | + return typeof other == 'string' || other instanceof String; |
| 1410 | + } |
| 1411 | + |
| 1412 | + if (this.expectedClass == Number) { |
| 1413 | + return typeof other == 'number' || other instanceof Number; |
| 1414 | + } |
| 1415 | + |
| 1416 | + if (this.expectedClass == Function) { |
| 1417 | + return typeof other == 'function' || other instanceof Function; |
| 1418 | + } |
| 1419 | + |
| 1420 | + if (this.expectedClass == Object) { |
| 1421 | + return typeof other == 'object'; |
| 1422 | + } |
| 1423 | + |
| 1424 | + return other instanceof this.expectedClass; |
| 1425 | +}; |
| 1426 | + |
| 1427 | +jasmine.Matchers.Any.prototype.toString = function() { |
| 1428 | + return '<jasmine.any(' + this.expectedClass + ')>'; |
| 1429 | +}; |
| 1430 | + |
| 1431 | +/** |
| 1432 | + * @constructor |
| 1433 | + */ |
| 1434 | +jasmine.MultiReporter = function() { |
| 1435 | + this.subReporters_ = []; |
| 1436 | +}; |
| 1437 | +jasmine.util.inherit(jasmine.MultiReporter, jasmine.Reporter); |
| 1438 | + |
| 1439 | +jasmine.MultiReporter.prototype.addReporter = function(reporter) { |
| 1440 | + this.subReporters_.push(reporter); |
| 1441 | +}; |
| 1442 | + |
| 1443 | +(function() { |
| 1444 | + var functionNames = [ |
| 1445 | + "reportRunnerStarting", |
| 1446 | + "reportRunnerResults", |
| 1447 | + "reportSuiteResults", |
| 1448 | + "reportSpecStarting", |
| 1449 | + "reportSpecResults", |
| 1450 | + "log" |
| 1451 | + ]; |
| 1452 | + for (var i = 0; i < functionNames.length; i++) { |
| 1453 | + var functionName = functionNames[i]; |
| 1454 | + jasmine.MultiReporter.prototype[functionName] = (function(functionName) { |
| 1455 | + return function() { |
| 1456 | + for (var j = 0; j < this.subReporters_.length; j++) { |
| 1457 | + var subReporter = this.subReporters_[j]; |
| 1458 | + if (subReporter[functionName]) { |
| 1459 | + subReporter[functionName].apply(subReporter, arguments); |
| 1460 | + } |
| 1461 | + } |
| 1462 | + }; |
| 1463 | + })(functionName); |
| 1464 | + } |
| 1465 | +})(); |
| 1466 | +/** |
| 1467 | + * Holds results for a set of Jasmine spec. Allows for the results array to hold another jasmine.NestedResults |
| 1468 | + * |
| 1469 | + * @constructor |
| 1470 | + */ |
| 1471 | +jasmine.NestedResults = function() { |
| 1472 | + /** |
| 1473 | + * The total count of results |
| 1474 | + */ |
| 1475 | + this.totalCount = 0; |
| 1476 | + /** |
| 1477 | + * Number of passed results |
| 1478 | + */ |
| 1479 | + this.passedCount = 0; |
| 1480 | + /** |
| 1481 | + * Number of failed results |
| 1482 | + */ |
| 1483 | + this.failedCount = 0; |
| 1484 | + /** |
| 1485 | + * Was this suite/spec skipped? |
| 1486 | + */ |
| 1487 | + this.skipped = false; |
| 1488 | + /** |
| 1489 | + * @ignore |
| 1490 | + */ |
| 1491 | + this.items_ = []; |
| 1492 | +}; |
| 1493 | + |
| 1494 | +/** |
| 1495 | + * Roll up the result counts. |
| 1496 | + * |
| 1497 | + * @param result |
| 1498 | + */ |
| 1499 | +jasmine.NestedResults.prototype.rollupCounts = function(result) { |
| 1500 | + this.totalCount += result.totalCount; |
| 1501 | + this.passedCount += result.passedCount; |
| 1502 | + this.failedCount += result.failedCount; |
| 1503 | +}; |
| 1504 | + |
| 1505 | +/** |
| 1506 | + * Adds a log message. |
| 1507 | + * @param values Array of message parts which will be concatenated later. |
| 1508 | + */ |
| 1509 | +jasmine.NestedResults.prototype.log = function(values) { |
| 1510 | + this.items_.push(new jasmine.MessageResult(values)); |
| 1511 | +}; |
| 1512 | + |
| 1513 | +/** |
| 1514 | + * Getter for the results: message & results. |
| 1515 | + */ |
| 1516 | +jasmine.NestedResults.prototype.getItems = function() { |
| 1517 | + return this.items_; |
| 1518 | +}; |
| 1519 | + |
| 1520 | +/** |
| 1521 | + * Adds a result, tracking counts (total, passed, & failed) |
| 1522 | + * @param {jasmine.ExpectationResult|jasmine.NestedResults} result |
| 1523 | + */ |
| 1524 | +jasmine.NestedResults.prototype.addResult = function(result) { |
| 1525 | + if (result.type != 'log') { |
| 1526 | + if (result.items_) { |
| 1527 | + this.rollupCounts(result); |
| 1528 | + } else { |
| 1529 | + this.totalCount++; |
| 1530 | + if (result.passed()) { |
| 1531 | + this.passedCount++; |
| 1532 | + } else { |
| 1533 | + this.failedCount++; |
| 1534 | + } |
| 1535 | + } |
| 1536 | + } |
| 1537 | + this.items_.push(result); |
| 1538 | +}; |
| 1539 | + |
| 1540 | +/** |
| 1541 | + * @returns {Boolean} True if <b>everything</b> below passed |
| 1542 | + */ |
| 1543 | +jasmine.NestedResults.prototype.passed = function() { |
| 1544 | + return this.passedCount === this.totalCount; |
| 1545 | +}; |
| 1546 | +/** |
| 1547 | + * Base class for pretty printing for expectation results. |
| 1548 | + */ |
| 1549 | +jasmine.PrettyPrinter = function() { |
| 1550 | + this.ppNestLevel_ = 0; |
| 1551 | +}; |
| 1552 | + |
| 1553 | +/** |
| 1554 | + * Formats a value in a nice, human-readable string. |
| 1555 | + * |
| 1556 | + * @param value |
| 1557 | + */ |
| 1558 | +jasmine.PrettyPrinter.prototype.format = function(value) { |
| 1559 | + if (this.ppNestLevel_ > 40) { |
| 1560 | + throw new Error('jasmine.PrettyPrinter: format() nested too deeply!'); |
| 1561 | + } |
| 1562 | + |
| 1563 | + this.ppNestLevel_++; |
| 1564 | + try { |
| 1565 | + if (value === jasmine.undefined) { |
| 1566 | + this.emitScalar('undefined'); |
| 1567 | + } else if (value === null) { |
| 1568 | + this.emitScalar('null'); |
| 1569 | + } else if (value === jasmine.getGlobal()) { |
| 1570 | + this.emitScalar('<global>'); |
| 1571 | + } else if (value instanceof jasmine.Matchers.Any) { |
| 1572 | + this.emitScalar(value.toString()); |
| 1573 | + } else if (typeof value === 'string') { |
| 1574 | + this.emitString(value); |
| 1575 | + } else if (jasmine.isSpy(value)) { |
| 1576 | + this.emitScalar("spy on " + value.identity); |
| 1577 | + } else if (value instanceof RegExp) { |
| 1578 | + this.emitScalar(value.toString()); |
| 1579 | + } else if (typeof value === 'function') { |
| 1580 | + this.emitScalar('Function'); |
| 1581 | + } else if (typeof value.nodeType === 'number') { |
| 1582 | + this.emitScalar('HTMLNode'); |
| 1583 | + } else if (value instanceof Date) { |
| 1584 | + this.emitScalar('Date(' + value + ')'); |
| 1585 | + } else if (value.__Jasmine_been_here_before__) { |
| 1586 | + this.emitScalar('<circular reference: ' + (jasmine.isArray_(value) ? 'Array' : 'Object') + '>'); |
| 1587 | + } else if (jasmine.isArray_(value) || typeof value == 'object') { |
| 1588 | + value.__Jasmine_been_here_before__ = true; |
| 1589 | + if (jasmine.isArray_(value)) { |
| 1590 | + this.emitArray(value); |
| 1591 | + } else { |
| 1592 | + this.emitObject(value); |
| 1593 | + } |
| 1594 | + delete value.__Jasmine_been_here_before__; |
| 1595 | + } else { |
| 1596 | + this.emitScalar(value.toString()); |
| 1597 | + } |
| 1598 | + } finally { |
| 1599 | + this.ppNestLevel_--; |
| 1600 | + } |
| 1601 | +}; |
| 1602 | + |
| 1603 | +jasmine.PrettyPrinter.prototype.iterateObject = function(obj, fn) { |
| 1604 | + for (var property in obj) { |
| 1605 | + if (property == '__Jasmine_been_here_before__') continue; |
| 1606 | + fn(property, obj.__lookupGetter__ ? (obj.__lookupGetter__(property) != null) : false); |
| 1607 | + } |
| 1608 | +}; |
| 1609 | + |
| 1610 | +jasmine.PrettyPrinter.prototype.emitArray = jasmine.unimplementedMethod_; |
| 1611 | +jasmine.PrettyPrinter.prototype.emitObject = jasmine.unimplementedMethod_; |
| 1612 | +jasmine.PrettyPrinter.prototype.emitScalar = jasmine.unimplementedMethod_; |
| 1613 | +jasmine.PrettyPrinter.prototype.emitString = jasmine.unimplementedMethod_; |
| 1614 | + |
| 1615 | +jasmine.StringPrettyPrinter = function() { |
| 1616 | + jasmine.PrettyPrinter.call(this); |
| 1617 | + |
| 1618 | + this.string = ''; |
| 1619 | +}; |
| 1620 | +jasmine.util.inherit(jasmine.StringPrettyPrinter, jasmine.PrettyPrinter); |
| 1621 | + |
| 1622 | +jasmine.StringPrettyPrinter.prototype.emitScalar = function(value) { |
| 1623 | + this.append(value); |
| 1624 | +}; |
| 1625 | + |
| 1626 | +jasmine.StringPrettyPrinter.prototype.emitString = function(value) { |
| 1627 | + this.append("'" + value + "'"); |
| 1628 | +}; |
| 1629 | + |
| 1630 | +jasmine.StringPrettyPrinter.prototype.emitArray = function(array) { |
| 1631 | + this.append('[ '); |
| 1632 | + for (var i = 0; i < array.length; i++) { |
| 1633 | + if (i > 0) { |
| 1634 | + this.append(', '); |
| 1635 | + } |
| 1636 | + this.format(array[i]); |
| 1637 | + } |
| 1638 | + this.append(' ]'); |
| 1639 | +}; |
| 1640 | + |
| 1641 | +jasmine.StringPrettyPrinter.prototype.emitObject = function(obj) { |
| 1642 | + var self = this; |
| 1643 | + this.append('{ '); |
| 1644 | + var first = true; |
| 1645 | + |
| 1646 | + this.iterateObject(obj, function(property, isGetter) { |
| 1647 | + if (first) { |
| 1648 | + first = false; |
| 1649 | + } else { |
| 1650 | + self.append(', '); |
| 1651 | + } |
| 1652 | + |
| 1653 | + self.append(property); |
| 1654 | + self.append(' : '); |
| 1655 | + if (isGetter) { |
| 1656 | + self.append('<getter>'); |
| 1657 | + } else { |
| 1658 | + self.format(obj[property]); |
| 1659 | + } |
| 1660 | + }); |
| 1661 | + |
| 1662 | + this.append(' }'); |
| 1663 | +}; |
| 1664 | + |
| 1665 | +jasmine.StringPrettyPrinter.prototype.append = function(value) { |
| 1666 | + this.string += value; |
| 1667 | +}; |
| 1668 | +jasmine.Queue = function(env) { |
| 1669 | + this.env = env; |
| 1670 | + this.blocks = []; |
| 1671 | + this.running = false; |
| 1672 | + this.index = 0; |
| 1673 | + this.offset = 0; |
| 1674 | + this.abort = false; |
| 1675 | +}; |
| 1676 | + |
| 1677 | +jasmine.Queue.prototype.addBefore = function(block) { |
| 1678 | + this.blocks.unshift(block); |
| 1679 | +}; |
| 1680 | + |
| 1681 | +jasmine.Queue.prototype.add = function(block) { |
| 1682 | + this.blocks.push(block); |
| 1683 | +}; |
| 1684 | + |
| 1685 | +jasmine.Queue.prototype.insertNext = function(block) { |
| 1686 | + this.blocks.splice((this.index + this.offset + 1), 0, block); |
| 1687 | + this.offset++; |
| 1688 | +}; |
| 1689 | + |
| 1690 | +jasmine.Queue.prototype.start = function(onComplete) { |
| 1691 | + this.running = true; |
| 1692 | + this.onComplete = onComplete; |
| 1693 | + this.next_(); |
| 1694 | +}; |
| 1695 | + |
| 1696 | +jasmine.Queue.prototype.isRunning = function() { |
| 1697 | + return this.running; |
| 1698 | +}; |
| 1699 | + |
| 1700 | +jasmine.Queue.LOOP_DONT_RECURSE = true; |
| 1701 | + |
| 1702 | +jasmine.Queue.prototype.next_ = function() { |
| 1703 | + var self = this; |
| 1704 | + var goAgain = true; |
| 1705 | + |
| 1706 | + while (goAgain) { |
| 1707 | + goAgain = false; |
| 1708 | + |
| 1709 | + if (self.index < self.blocks.length && !this.abort) { |
| 1710 | + var calledSynchronously = true; |
| 1711 | + var completedSynchronously = false; |
| 1712 | + |
| 1713 | + var onComplete = function () { |
| 1714 | + if (jasmine.Queue.LOOP_DONT_RECURSE && calledSynchronously) { |
| 1715 | + completedSynchronously = true; |
| 1716 | + return; |
| 1717 | + } |
| 1718 | + |
| 1719 | + if (self.blocks[self.index].abort) { |
| 1720 | + self.abort = true; |
| 1721 | + } |
| 1722 | + |
| 1723 | + self.offset = 0; |
| 1724 | + self.index++; |
| 1725 | + |
| 1726 | + var now = new Date().getTime(); |
| 1727 | + if (self.env.updateInterval && now - self.env.lastUpdate > self.env.updateInterval) { |
| 1728 | + self.env.lastUpdate = now; |
| 1729 | + self.env.setTimeout(function() { |
| 1730 | + self.next_(); |
| 1731 | + }, 0); |
| 1732 | + } else { |
| 1733 | + if (jasmine.Queue.LOOP_DONT_RECURSE && completedSynchronously) { |
| 1734 | + goAgain = true; |
| 1735 | + } else { |
| 1736 | + self.next_(); |
| 1737 | + } |
| 1738 | + } |
| 1739 | + }; |
| 1740 | + self.blocks[self.index].execute(onComplete); |
| 1741 | + |
| 1742 | + calledSynchronously = false; |
| 1743 | + if (completedSynchronously) { |
| 1744 | + onComplete(); |
| 1745 | + } |
| 1746 | + |
| 1747 | + } else { |
| 1748 | + self.running = false; |
| 1749 | + if (self.onComplete) { |
| 1750 | + self.onComplete(); |
| 1751 | + } |
| 1752 | + } |
| 1753 | + } |
| 1754 | +}; |
| 1755 | + |
| 1756 | +jasmine.Queue.prototype.results = function() { |
| 1757 | + var results = new jasmine.NestedResults(); |
| 1758 | + for (var i = 0; i < this.blocks.length; i++) { |
| 1759 | + if (this.blocks[i].results) { |
| 1760 | + results.addResult(this.blocks[i].results()); |
| 1761 | + } |
| 1762 | + } |
| 1763 | + return results; |
| 1764 | +}; |
| 1765 | + |
| 1766 | + |
| 1767 | +/** |
| 1768 | + * Runner |
| 1769 | + * |
| 1770 | + * @constructor |
| 1771 | + * @param {jasmine.Env} env |
| 1772 | + */ |
| 1773 | +jasmine.Runner = function(env) { |
| 1774 | + var self = this; |
| 1775 | + self.env = env; |
| 1776 | + self.queue = new jasmine.Queue(env); |
| 1777 | + self.before_ = []; |
| 1778 | + self.after_ = []; |
| 1779 | + self.suites_ = []; |
| 1780 | +}; |
| 1781 | + |
| 1782 | +jasmine.Runner.prototype.execute = function() { |
| 1783 | + var self = this; |
| 1784 | + if (self.env.reporter.reportRunnerStarting) { |
| 1785 | + self.env.reporter.reportRunnerStarting(this); |
| 1786 | + } |
| 1787 | + self.queue.start(function () { |
| 1788 | + self.finishCallback(); |
| 1789 | + }); |
| 1790 | +}; |
| 1791 | + |
| 1792 | +jasmine.Runner.prototype.beforeEach = function(beforeEachFunction) { |
| 1793 | + beforeEachFunction.typeName = 'beforeEach'; |
| 1794 | + this.before_.splice(0,0,beforeEachFunction); |
| 1795 | +}; |
| 1796 | + |
| 1797 | +jasmine.Runner.prototype.afterEach = function(afterEachFunction) { |
| 1798 | + afterEachFunction.typeName = 'afterEach'; |
| 1799 | + this.after_.splice(0,0,afterEachFunction); |
| 1800 | +}; |
| 1801 | + |
| 1802 | + |
| 1803 | +jasmine.Runner.prototype.finishCallback = function() { |
| 1804 | + this.env.reporter.reportRunnerResults(this); |
| 1805 | +}; |
| 1806 | + |
| 1807 | +jasmine.Runner.prototype.addSuite = function(suite) { |
| 1808 | + this.suites_.push(suite); |
| 1809 | +}; |
| 1810 | + |
| 1811 | +jasmine.Runner.prototype.add = function(block) { |
| 1812 | + if (block instanceof jasmine.Suite) { |
| 1813 | + this.addSuite(block); |
| 1814 | + } |
| 1815 | + this.queue.add(block); |
| 1816 | +}; |
| 1817 | + |
| 1818 | +jasmine.Runner.prototype.specs = function () { |
| 1819 | + var suites = this.suites(); |
| 1820 | + var specs = []; |
| 1821 | + for (var i = 0; i < suites.length; i++) { |
| 1822 | + specs = specs.concat(suites[i].specs()); |
| 1823 | + } |
| 1824 | + return specs; |
| 1825 | +}; |
| 1826 | + |
| 1827 | +jasmine.Runner.prototype.suites = function() { |
| 1828 | + return this.suites_; |
| 1829 | +}; |
| 1830 | + |
| 1831 | +jasmine.Runner.prototype.topLevelSuites = function() { |
| 1832 | + var topLevelSuites = []; |
| 1833 | + for (var i = 0; i < this.suites_.length; i++) { |
| 1834 | + if (!this.suites_[i].parentSuite) { |
| 1835 | + topLevelSuites.push(this.suites_[i]); |
| 1836 | + } |
| 1837 | + } |
| 1838 | + return topLevelSuites; |
| 1839 | +}; |
| 1840 | + |
| 1841 | +jasmine.Runner.prototype.results = function() { |
| 1842 | + return this.queue.results(); |
| 1843 | +}; |
| 1844 | +/** |
| 1845 | + * Internal representation of a Jasmine specification, or test. |
| 1846 | + * |
| 1847 | + * @constructor |
| 1848 | + * @param {jasmine.Env} env |
| 1849 | + * @param {jasmine.Suite} suite |
| 1850 | + * @param {String} description |
| 1851 | + */ |
| 1852 | +jasmine.Spec = function(env, suite, description) { |
| 1853 | + if (!env) { |
| 1854 | + throw new Error('jasmine.Env() required'); |
| 1855 | + } |
| 1856 | + if (!suite) { |
| 1857 | + throw new Error('jasmine.Suite() required'); |
| 1858 | + } |
| 1859 | + var spec = this; |
| 1860 | + spec.id = env.nextSpecId ? env.nextSpecId() : null; |
| 1861 | + spec.env = env; |
| 1862 | + spec.suite = suite; |
| 1863 | + spec.description = description; |
| 1864 | + spec.queue = new jasmine.Queue(env); |
| 1865 | + |
| 1866 | + spec.afterCallbacks = []; |
| 1867 | + spec.spies_ = []; |
| 1868 | + |
| 1869 | + spec.results_ = new jasmine.NestedResults(); |
| 1870 | + spec.results_.description = description; |
| 1871 | + spec.matchersClass = null; |
| 1872 | +}; |
| 1873 | + |
| 1874 | +jasmine.Spec.prototype.getFullName = function() { |
| 1875 | + return this.suite.getFullName() + ' ' + this.description + '.'; |
| 1876 | +}; |
| 1877 | + |
| 1878 | + |
| 1879 | +jasmine.Spec.prototype.results = function() { |
| 1880 | + return this.results_; |
| 1881 | +}; |
| 1882 | + |
| 1883 | +/** |
| 1884 | + * All parameters are pretty-printed and concatenated together, then written to the spec's output. |
| 1885 | + * |
| 1886 | + * Be careful not to leave calls to <code>jasmine.log</code> in production code. |
| 1887 | + */ |
| 1888 | +jasmine.Spec.prototype.log = function() { |
| 1889 | + return this.results_.log(arguments); |
| 1890 | +}; |
| 1891 | + |
| 1892 | +jasmine.Spec.prototype.runs = function (func) { |
| 1893 | + var block = new jasmine.Block(this.env, func, this); |
| 1894 | + this.addToQueue(block); |
| 1895 | + return this; |
| 1896 | +}; |
| 1897 | + |
| 1898 | +jasmine.Spec.prototype.addToQueue = function (block) { |
| 1899 | + if (this.queue.isRunning()) { |
| 1900 | + this.queue.insertNext(block); |
| 1901 | + } else { |
| 1902 | + this.queue.add(block); |
| 1903 | + } |
| 1904 | +}; |
| 1905 | + |
| 1906 | +/** |
| 1907 | + * @param {jasmine.ExpectationResult} result |
| 1908 | + */ |
| 1909 | +jasmine.Spec.prototype.addMatcherResult = function(result) { |
| 1910 | + this.results_.addResult(result); |
| 1911 | +}; |
| 1912 | + |
| 1913 | +jasmine.Spec.prototype.expect = function(actual) { |
| 1914 | + var positive = new (this.getMatchersClass_())(this.env, actual, this); |
| 1915 | + positive.not = new (this.getMatchersClass_())(this.env, actual, this, true); |
| 1916 | + return positive; |
| 1917 | +}; |
| 1918 | + |
| 1919 | +/** |
| 1920 | + * Waits a fixed time period before moving to the next block. |
| 1921 | + * |
| 1922 | + * @deprecated Use waitsFor() instead |
| 1923 | + * @param {Number} timeout milliseconds to wait |
| 1924 | + */ |
| 1925 | +jasmine.Spec.prototype.waits = function(timeout) { |
| 1926 | + var waitsFunc = new jasmine.WaitsBlock(this.env, timeout, this); |
| 1927 | + this.addToQueue(waitsFunc); |
| 1928 | + return this; |
| 1929 | +}; |
| 1930 | + |
| 1931 | +/** |
| 1932 | + * Waits for the latchFunction to return true before proceeding to the next block. |
| 1933 | + * |
| 1934 | + * @param {Function} latchFunction |
| 1935 | + * @param {String} optional_timeoutMessage |
| 1936 | + * @param {Number} optional_timeout |
| 1937 | + */ |
| 1938 | +jasmine.Spec.prototype.waitsFor = function(latchFunction, optional_timeoutMessage, optional_timeout) { |
| 1939 | + var latchFunction_ = null; |
| 1940 | + var optional_timeoutMessage_ = null; |
| 1941 | + var optional_timeout_ = null; |
| 1942 | + |
| 1943 | + for (var i = 0; i < arguments.length; i++) { |
| 1944 | + var arg = arguments[i]; |
| 1945 | + switch (typeof arg) { |
| 1946 | + case 'function': |
| 1947 | + latchFunction_ = arg; |
| 1948 | + break; |
| 1949 | + case 'string': |
| 1950 | + optional_timeoutMessage_ = arg; |
| 1951 | + break; |
| 1952 | + case 'number': |
| 1953 | + optional_timeout_ = arg; |
| 1954 | + break; |
| 1955 | + } |
| 1956 | + } |
| 1957 | + |
| 1958 | + var waitsForFunc = new jasmine.WaitsForBlock(this.env, optional_timeout_, latchFunction_, optional_timeoutMessage_, this); |
| 1959 | + this.addToQueue(waitsForFunc); |
| 1960 | + return this; |
| 1961 | +}; |
| 1962 | + |
| 1963 | +jasmine.Spec.prototype.fail = function (e) { |
| 1964 | + var expectationResult = new jasmine.ExpectationResult({ |
| 1965 | + passed: false, |
| 1966 | + message: e ? jasmine.util.formatException(e) : 'Exception' |
| 1967 | + }); |
| 1968 | + this.results_.addResult(expectationResult); |
| 1969 | +}; |
| 1970 | + |
| 1971 | +jasmine.Spec.prototype.getMatchersClass_ = function() { |
| 1972 | + return this.matchersClass || this.env.matchersClass; |
| 1973 | +}; |
| 1974 | + |
| 1975 | +jasmine.Spec.prototype.addMatchers = function(matchersPrototype) { |
| 1976 | + var parent = this.getMatchersClass_(); |
| 1977 | + var newMatchersClass = function() { |
| 1978 | + parent.apply(this, arguments); |
| 1979 | + }; |
| 1980 | + jasmine.util.inherit(newMatchersClass, parent); |
| 1981 | + jasmine.Matchers.wrapInto_(matchersPrototype, newMatchersClass); |
| 1982 | + this.matchersClass = newMatchersClass; |
| 1983 | +}; |
| 1984 | + |
| 1985 | +jasmine.Spec.prototype.finishCallback = function() { |
| 1986 | + this.env.reporter.reportSpecResults(this); |
| 1987 | +}; |
| 1988 | + |
| 1989 | +jasmine.Spec.prototype.finish = function(onComplete) { |
| 1990 | + this.removeAllSpies(); |
| 1991 | + this.finishCallback(); |
| 1992 | + if (onComplete) { |
| 1993 | + onComplete(); |
| 1994 | + } |
| 1995 | +}; |
| 1996 | + |
| 1997 | +jasmine.Spec.prototype.after = function(doAfter) { |
| 1998 | + if (this.queue.isRunning()) { |
| 1999 | + this.queue.add(new jasmine.Block(this.env, doAfter, this)); |
| 2000 | + } else { |
| 2001 | + this.afterCallbacks.unshift(doAfter); |
| 2002 | + } |
| 2003 | +}; |
| 2004 | + |
| 2005 | +jasmine.Spec.prototype.execute = function(onComplete) { |
| 2006 | + var spec = this; |
| 2007 | + if (!spec.env.specFilter(spec)) { |
| 2008 | + spec.results_.skipped = true; |
| 2009 | + spec.finish(onComplete); |
| 2010 | + return; |
| 2011 | + } |
| 2012 | + |
| 2013 | + this.env.reporter.reportSpecStarting(this); |
| 2014 | + |
| 2015 | + spec.env.currentSpec = spec; |
| 2016 | + |
| 2017 | + spec.addBeforesAndAftersToQueue(); |
| 2018 | + |
| 2019 | + spec.queue.start(function () { |
| 2020 | + spec.finish(onComplete); |
| 2021 | + }); |
| 2022 | +}; |
| 2023 | + |
| 2024 | +jasmine.Spec.prototype.addBeforesAndAftersToQueue = function() { |
| 2025 | + var runner = this.env.currentRunner(); |
| 2026 | + var i; |
| 2027 | + |
| 2028 | + for (var suite = this.suite; suite; suite = suite.parentSuite) { |
| 2029 | + for (i = 0; i < suite.before_.length; i++) { |
| 2030 | + this.queue.addBefore(new jasmine.Block(this.env, suite.before_[i], this)); |
| 2031 | + } |
| 2032 | + } |
| 2033 | + for (i = 0; i < runner.before_.length; i++) { |
| 2034 | + this.queue.addBefore(new jasmine.Block(this.env, runner.before_[i], this)); |
| 2035 | + } |
| 2036 | + for (i = 0; i < this.afterCallbacks.length; i++) { |
| 2037 | + this.queue.add(new jasmine.Block(this.env, this.afterCallbacks[i], this)); |
| 2038 | + } |
| 2039 | + for (suite = this.suite; suite; suite = suite.parentSuite) { |
| 2040 | + for (i = 0; i < suite.after_.length; i++) { |
| 2041 | + this.queue.add(new jasmine.Block(this.env, suite.after_[i], this)); |
| 2042 | + } |
| 2043 | + } |
| 2044 | + for (i = 0; i < runner.after_.length; i++) { |
| 2045 | + this.queue.add(new jasmine.Block(this.env, runner.after_[i], this)); |
| 2046 | + } |
| 2047 | +}; |
| 2048 | + |
| 2049 | +jasmine.Spec.prototype.explodes = function() { |
| 2050 | + throw 'explodes function should not have been called'; |
| 2051 | +}; |
| 2052 | + |
| 2053 | +jasmine.Spec.prototype.spyOn = function(obj, methodName, ignoreMethodDoesntExist) { |
| 2054 | + if (obj == jasmine.undefined) { |
| 2055 | + throw "spyOn could not find an object to spy upon for " + methodName + "()"; |
| 2056 | + } |
| 2057 | + |
| 2058 | + if (!ignoreMethodDoesntExist && obj[methodName] === jasmine.undefined) { |
| 2059 | + throw methodName + '() method does not exist'; |
| 2060 | + } |
| 2061 | + |
| 2062 | + if (!ignoreMethodDoesntExist && obj[methodName] && obj[methodName].isSpy) { |
| 2063 | + throw new Error(methodName + ' has already been spied upon'); |
| 2064 | + } |
| 2065 | + |
| 2066 | + var spyObj = jasmine.createSpy(methodName); |
| 2067 | + |
| 2068 | + this.spies_.push(spyObj); |
| 2069 | + spyObj.baseObj = obj; |
| 2070 | + spyObj.methodName = methodName; |
| 2071 | + spyObj.originalValue = obj[methodName]; |
| 2072 | + |
| 2073 | + obj[methodName] = spyObj; |
| 2074 | + |
| 2075 | + return spyObj; |
| 2076 | +}; |
| 2077 | + |
| 2078 | +jasmine.Spec.prototype.removeAllSpies = function() { |
| 2079 | + for (var i = 0; i < this.spies_.length; i++) { |
| 2080 | + var spy = this.spies_[i]; |
| 2081 | + spy.baseObj[spy.methodName] = spy.originalValue; |
| 2082 | + } |
| 2083 | + this.spies_ = []; |
| 2084 | +}; |
| 2085 | + |
| 2086 | +/** |
| 2087 | + * Internal representation of a Jasmine suite. |
| 2088 | + * |
| 2089 | + * @constructor |
| 2090 | + * @param {jasmine.Env} env |
| 2091 | + * @param {String} description |
| 2092 | + * @param {Function} specDefinitions |
| 2093 | + * @param {jasmine.Suite} parentSuite |
| 2094 | + */ |
| 2095 | +jasmine.Suite = function(env, description, specDefinitions, parentSuite) { |
| 2096 | + var self = this; |
| 2097 | + self.id = env.nextSuiteId ? env.nextSuiteId() : null; |
| 2098 | + self.description = description; |
| 2099 | + self.queue = new jasmine.Queue(env); |
| 2100 | + self.parentSuite = parentSuite; |
| 2101 | + self.env = env; |
| 2102 | + self.before_ = []; |
| 2103 | + self.after_ = []; |
| 2104 | + self.children_ = []; |
| 2105 | + self.suites_ = []; |
| 2106 | + self.specs_ = []; |
| 2107 | +}; |
| 2108 | + |
| 2109 | +jasmine.Suite.prototype.getFullName = function() { |
| 2110 | + var fullName = this.description; |
| 2111 | + for (var parentSuite = this.parentSuite; parentSuite; parentSuite = parentSuite.parentSuite) { |
| 2112 | + fullName = parentSuite.description + ' ' + fullName; |
| 2113 | + } |
| 2114 | + return fullName; |
| 2115 | +}; |
| 2116 | + |
| 2117 | +jasmine.Suite.prototype.finish = function(onComplete) { |
| 2118 | + this.env.reporter.reportSuiteResults(this); |
| 2119 | + this.finished = true; |
| 2120 | + if (typeof(onComplete) == 'function') { |
| 2121 | + onComplete(); |
| 2122 | + } |
| 2123 | +}; |
| 2124 | + |
| 2125 | +jasmine.Suite.prototype.beforeEach = function(beforeEachFunction) { |
| 2126 | + beforeEachFunction.typeName = 'beforeEach'; |
| 2127 | + this.before_.unshift(beforeEachFunction); |
| 2128 | +}; |
| 2129 | + |
| 2130 | +jasmine.Suite.prototype.afterEach = function(afterEachFunction) { |
| 2131 | + afterEachFunction.typeName = 'afterEach'; |
| 2132 | + this.after_.unshift(afterEachFunction); |
| 2133 | +}; |
| 2134 | + |
| 2135 | +jasmine.Suite.prototype.results = function() { |
| 2136 | + return this.queue.results(); |
| 2137 | +}; |
| 2138 | + |
| 2139 | +jasmine.Suite.prototype.add = function(suiteOrSpec) { |
| 2140 | + this.children_.push(suiteOrSpec); |
| 2141 | + if (suiteOrSpec instanceof jasmine.Suite) { |
| 2142 | + this.suites_.push(suiteOrSpec); |
| 2143 | + this.env.currentRunner().addSuite(suiteOrSpec); |
| 2144 | + } else { |
| 2145 | + this.specs_.push(suiteOrSpec); |
| 2146 | + } |
| 2147 | + this.queue.add(suiteOrSpec); |
| 2148 | +}; |
| 2149 | + |
| 2150 | +jasmine.Suite.prototype.specs = function() { |
| 2151 | + return this.specs_; |
| 2152 | +}; |
| 2153 | + |
| 2154 | +jasmine.Suite.prototype.suites = function() { |
| 2155 | + return this.suites_; |
| 2156 | +}; |
| 2157 | + |
| 2158 | +jasmine.Suite.prototype.children = function() { |
| 2159 | + return this.children_; |
| 2160 | +}; |
| 2161 | + |
| 2162 | +jasmine.Suite.prototype.execute = function(onComplete) { |
| 2163 | + var self = this; |
| 2164 | + this.queue.start(function () { |
| 2165 | + self.finish(onComplete); |
| 2166 | + }); |
| 2167 | +}; |
| 2168 | +jasmine.WaitsBlock = function(env, timeout, spec) { |
| 2169 | + this.timeout = timeout; |
| 2170 | + jasmine.Block.call(this, env, null, spec); |
| 2171 | +}; |
| 2172 | + |
| 2173 | +jasmine.util.inherit(jasmine.WaitsBlock, jasmine.Block); |
| 2174 | + |
| 2175 | +jasmine.WaitsBlock.prototype.execute = function (onComplete) { |
| 2176 | + this.env.reporter.log('>> Jasmine waiting for ' + this.timeout + ' ms...'); |
| 2177 | + this.env.setTimeout(function () { |
| 2178 | + onComplete(); |
| 2179 | + }, this.timeout); |
| 2180 | +}; |
| 2181 | +/** |
| 2182 | + * A block which waits for some condition to become true, with timeout. |
| 2183 | + * |
| 2184 | + * @constructor |
| 2185 | + * @extends jasmine.Block |
| 2186 | + * @param {jasmine.Env} env The Jasmine environment. |
| 2187 | + * @param {Number} timeout The maximum time in milliseconds to wait for the condition to become true. |
| 2188 | + * @param {Function} latchFunction A function which returns true when the desired condition has been met. |
| 2189 | + * @param {String} message The message to display if the desired condition hasn't been met within the given time period. |
| 2190 | + * @param {jasmine.Spec} spec The Jasmine spec. |
| 2191 | + */ |
| 2192 | +jasmine.WaitsForBlock = function(env, timeout, latchFunction, message, spec) { |
| 2193 | + this.timeout = timeout || env.defaultTimeoutInterval; |
| 2194 | + this.latchFunction = latchFunction; |
| 2195 | + this.message = message; |
| 2196 | + this.totalTimeSpentWaitingForLatch = 0; |
| 2197 | + jasmine.Block.call(this, env, null, spec); |
| 2198 | +}; |
| 2199 | +jasmine.util.inherit(jasmine.WaitsForBlock, jasmine.Block); |
| 2200 | + |
| 2201 | +jasmine.WaitsForBlock.TIMEOUT_INCREMENT = 10; |
| 2202 | + |
| 2203 | +jasmine.WaitsForBlock.prototype.execute = function(onComplete) { |
| 2204 | + this.env.reporter.log('>> Jasmine waiting for ' + (this.message || 'something to happen')); |
| 2205 | + var latchFunctionResult; |
| 2206 | + try { |
| 2207 | + latchFunctionResult = this.latchFunction.apply(this.spec); |
| 2208 | + } catch (e) { |
| 2209 | + this.spec.fail(e); |
| 2210 | + onComplete(); |
| 2211 | + return; |
| 2212 | + } |
| 2213 | + |
| 2214 | + if (latchFunctionResult) { |
| 2215 | + onComplete(); |
| 2216 | + } else if (this.totalTimeSpentWaitingForLatch >= this.timeout) { |
| 2217 | + var message = 'timed out after ' + this.timeout + ' msec waiting for ' + (this.message || 'something to happen'); |
| 2218 | + this.spec.fail({ |
| 2219 | + name: 'timeout', |
| 2220 | + message: message |
| 2221 | + }); |
| 2222 | + |
| 2223 | + this.abort = true; |
| 2224 | + onComplete(); |
| 2225 | + } else { |
| 2226 | + this.totalTimeSpentWaitingForLatch += jasmine.WaitsForBlock.TIMEOUT_INCREMENT; |
| 2227 | + var self = this; |
| 2228 | + this.env.setTimeout(function() { |
| 2229 | + self.execute(onComplete); |
| 2230 | + }, jasmine.WaitsForBlock.TIMEOUT_INCREMENT); |
| 2231 | + } |
| 2232 | +}; |
| 2233 | +// Mock setTimeout, clearTimeout |
| 2234 | +// Contributed by Pivotal Computer Systems, www.pivotalsf.com |
| 2235 | + |
| 2236 | +jasmine.FakeTimer = function() { |
| 2237 | + this.reset(); |
| 2238 | + |
| 2239 | + var self = this; |
| 2240 | + self.setTimeout = function(funcToCall, millis) { |
| 2241 | + self.timeoutsMade++; |
| 2242 | + self.scheduleFunction(self.timeoutsMade, funcToCall, millis, false); |
| 2243 | + return self.timeoutsMade; |
| 2244 | + }; |
| 2245 | + |
| 2246 | + self.setInterval = function(funcToCall, millis) { |
| 2247 | + self.timeoutsMade++; |
| 2248 | + self.scheduleFunction(self.timeoutsMade, funcToCall, millis, true); |
| 2249 | + return self.timeoutsMade; |
| 2250 | + }; |
| 2251 | + |
| 2252 | + self.clearTimeout = function(timeoutKey) { |
| 2253 | + self.scheduledFunctions[timeoutKey] = jasmine.undefined; |
| 2254 | + }; |
| 2255 | + |
| 2256 | + self.clearInterval = function(timeoutKey) { |
| 2257 | + self.scheduledFunctions[timeoutKey] = jasmine.undefined; |
| 2258 | + }; |
| 2259 | + |
| 2260 | +}; |
| 2261 | + |
| 2262 | +jasmine.FakeTimer.prototype.reset = function() { |
| 2263 | + this.timeoutsMade = 0; |
| 2264 | + this.scheduledFunctions = {}; |
| 2265 | + this.nowMillis = 0; |
| 2266 | +}; |
| 2267 | + |
| 2268 | +jasmine.FakeTimer.prototype.tick = function(millis) { |
| 2269 | + var oldMillis = this.nowMillis; |
| 2270 | + var newMillis = oldMillis + millis; |
| 2271 | + this.runFunctionsWithinRange(oldMillis, newMillis); |
| 2272 | + this.nowMillis = newMillis; |
| 2273 | +}; |
| 2274 | + |
| 2275 | +jasmine.FakeTimer.prototype.runFunctionsWithinRange = function(oldMillis, nowMillis) { |
| 2276 | + var scheduledFunc; |
| 2277 | + var funcsToRun = []; |
| 2278 | + for (var timeoutKey in this.scheduledFunctions) { |
| 2279 | + scheduledFunc = this.scheduledFunctions[timeoutKey]; |
| 2280 | + if (scheduledFunc != jasmine.undefined && |
| 2281 | + scheduledFunc.runAtMillis >= oldMillis && |
| 2282 | + scheduledFunc.runAtMillis <= nowMillis) { |
| 2283 | + funcsToRun.push(scheduledFunc); |
| 2284 | + this.scheduledFunctions[timeoutKey] = jasmine.undefined; |
| 2285 | + } |
| 2286 | + } |
| 2287 | + |
| 2288 | + if (funcsToRun.length > 0) { |
| 2289 | + funcsToRun.sort(function(a, b) { |
| 2290 | + return a.runAtMillis - b.runAtMillis; |
| 2291 | + }); |
| 2292 | + for (var i = 0; i < funcsToRun.length; ++i) { |
| 2293 | + try { |
| 2294 | + var funcToRun = funcsToRun[i]; |
| 2295 | + this.nowMillis = funcToRun.runAtMillis; |
| 2296 | + funcToRun.funcToCall(); |
| 2297 | + if (funcToRun.recurring) { |
| 2298 | + this.scheduleFunction(funcToRun.timeoutKey, |
| 2299 | + funcToRun.funcToCall, |
| 2300 | + funcToRun.millis, |
| 2301 | + true); |
| 2302 | + } |
| 2303 | + } catch(e) { |
| 2304 | + } |
| 2305 | + } |
| 2306 | + this.runFunctionsWithinRange(oldMillis, nowMillis); |
| 2307 | + } |
| 2308 | +}; |
| 2309 | + |
| 2310 | +jasmine.FakeTimer.prototype.scheduleFunction = function(timeoutKey, funcToCall, millis, recurring) { |
| 2311 | + this.scheduledFunctions[timeoutKey] = { |
| 2312 | + runAtMillis: this.nowMillis + millis, |
| 2313 | + funcToCall: funcToCall, |
| 2314 | + recurring: recurring, |
| 2315 | + timeoutKey: timeoutKey, |
| 2316 | + millis: millis |
| 2317 | + }; |
| 2318 | +}; |
| 2319 | + |
| 2320 | +/** |
| 2321 | + * @namespace |
| 2322 | + */ |
| 2323 | +jasmine.Clock = { |
| 2324 | + defaultFakeTimer: new jasmine.FakeTimer(), |
| 2325 | + |
| 2326 | + reset: function() { |
| 2327 | + jasmine.Clock.assertInstalled(); |
| 2328 | + jasmine.Clock.defaultFakeTimer.reset(); |
| 2329 | + }, |
| 2330 | + |
| 2331 | + tick: function(millis) { |
| 2332 | + jasmine.Clock.assertInstalled(); |
| 2333 | + jasmine.Clock.defaultFakeTimer.tick(millis); |
| 2334 | + }, |
| 2335 | + |
| 2336 | + runFunctionsWithinRange: function(oldMillis, nowMillis) { |
| 2337 | + jasmine.Clock.defaultFakeTimer.runFunctionsWithinRange(oldMillis, nowMillis); |
| 2338 | + }, |
| 2339 | + |
| 2340 | + scheduleFunction: function(timeoutKey, funcToCall, millis, recurring) { |
| 2341 | + jasmine.Clock.defaultFakeTimer.scheduleFunction(timeoutKey, funcToCall, millis, recurring); |
| 2342 | + }, |
| 2343 | + |
| 2344 | + useMock: function() { |
| 2345 | + if (!jasmine.Clock.isInstalled()) { |
| 2346 | + var spec = jasmine.getEnv().currentSpec; |
| 2347 | + spec.after(jasmine.Clock.uninstallMock); |
| 2348 | + |
| 2349 | + jasmine.Clock.installMock(); |
| 2350 | + } |
| 2351 | + }, |
| 2352 | + |
| 2353 | + installMock: function() { |
| 2354 | + jasmine.Clock.installed = jasmine.Clock.defaultFakeTimer; |
| 2355 | + }, |
| 2356 | + |
| 2357 | + uninstallMock: function() { |
| 2358 | + jasmine.Clock.assertInstalled(); |
| 2359 | + jasmine.Clock.installed = jasmine.Clock.real; |
| 2360 | + }, |
| 2361 | + |
| 2362 | + real: { |
| 2363 | + setTimeout: jasmine.getGlobal().setTimeout, |
| 2364 | + clearTimeout: jasmine.getGlobal().clearTimeout, |
| 2365 | + setInterval: jasmine.getGlobal().setInterval, |
| 2366 | + clearInterval: jasmine.getGlobal().clearInterval |
| 2367 | + }, |
| 2368 | + |
| 2369 | + assertInstalled: function() { |
| 2370 | + if (!jasmine.Clock.isInstalled()) { |
| 2371 | + throw new Error("Mock clock is not installed, use jasmine.Clock.useMock()"); |
| 2372 | + } |
| 2373 | + }, |
| 2374 | + |
| 2375 | + isInstalled: function() { |
| 2376 | + return jasmine.Clock.installed == jasmine.Clock.defaultFakeTimer; |
| 2377 | + }, |
| 2378 | + |
| 2379 | + installed: null |
| 2380 | +}; |
| 2381 | +jasmine.Clock.installed = jasmine.Clock.real; |
| 2382 | + |
| 2383 | +//else for IE support |
| 2384 | +jasmine.getGlobal().setTimeout = function(funcToCall, millis) { |
| 2385 | + if (jasmine.Clock.installed.setTimeout.apply) { |
| 2386 | + return jasmine.Clock.installed.setTimeout.apply(this, arguments); |
| 2387 | + } else { |
| 2388 | + return jasmine.Clock.installed.setTimeout(funcToCall, millis); |
| 2389 | + } |
| 2390 | +}; |
| 2391 | + |
| 2392 | +jasmine.getGlobal().setInterval = function(funcToCall, millis) { |
| 2393 | + if (jasmine.Clock.installed.setInterval.apply) { |
| 2394 | + return jasmine.Clock.installed.setInterval.apply(this, arguments); |
| 2395 | + } else { |
| 2396 | + return jasmine.Clock.installed.setInterval(funcToCall, millis); |
| 2397 | + } |
| 2398 | +}; |
| 2399 | + |
| 2400 | +jasmine.getGlobal().clearTimeout = function(timeoutKey) { |
| 2401 | + if (jasmine.Clock.installed.clearTimeout.apply) { |
| 2402 | + return jasmine.Clock.installed.clearTimeout.apply(this, arguments); |
| 2403 | + } else { |
| 2404 | + return jasmine.Clock.installed.clearTimeout(timeoutKey); |
| 2405 | + } |
| 2406 | +}; |
| 2407 | + |
| 2408 | +jasmine.getGlobal().clearInterval = function(timeoutKey) { |
| 2409 | + if (jasmine.Clock.installed.clearTimeout.apply) { |
| 2410 | + return jasmine.Clock.installed.clearInterval.apply(this, arguments); |
| 2411 | + } else { |
| 2412 | + return jasmine.Clock.installed.clearInterval(timeoutKey); |
| 2413 | + } |
| 2414 | +}; |
| 2415 | + |
| 2416 | + |
| 2417 | +jasmine.version_= { |
| 2418 | + "major": 1, |
| 2419 | + "minor": 0, |
| 2420 | + "build": 1, |
| 2421 | + "revision": 1286311016 |
| 2422 | +}; |
Property changes on: trunk/phase3/tests/jasmine/lib/jasmine-1.0.1/jasmine.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 2423 | + native |
Index: trunk/phase3/tests/jasmine/lib/jasmine-1.0.1/jasmine-html.js |
— | — | @@ -0,0 +1,188 @@ |
| 2 | +jasmine.TrivialReporter = function(doc) { |
| 3 | + this.document = doc || document; |
| 4 | + this.suiteDivs = {}; |
| 5 | + this.logRunningSpecs = false; |
| 6 | +}; |
| 7 | + |
| 8 | +jasmine.TrivialReporter.prototype.createDom = function(type, attrs, childrenVarArgs) { |
| 9 | + var el = document.createElement(type); |
| 10 | + |
| 11 | + for (var i = 2; i < arguments.length; i++) { |
| 12 | + var child = arguments[i]; |
| 13 | + |
| 14 | + if (typeof child === 'string') { |
| 15 | + el.appendChild(document.createTextNode(child)); |
| 16 | + } else { |
| 17 | + if (child) { el.appendChild(child); } |
| 18 | + } |
| 19 | + } |
| 20 | + |
| 21 | + for (var attr in attrs) { |
| 22 | + if (attr == "className") { |
| 23 | + el[attr] = attrs[attr]; |
| 24 | + } else { |
| 25 | + el.setAttribute(attr, attrs[attr]); |
| 26 | + } |
| 27 | + } |
| 28 | + |
| 29 | + return el; |
| 30 | +}; |
| 31 | + |
| 32 | +jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) { |
| 33 | + var showPassed, showSkipped; |
| 34 | + |
| 35 | + this.outerDiv = this.createDom('div', { className: 'jasmine_reporter' }, |
| 36 | + this.createDom('div', { className: 'banner' }, |
| 37 | + this.createDom('div', { className: 'logo' }, |
| 38 | + this.createDom('a', { href: 'http://pivotal.github.com/jasmine/', target: "_blank" }, "Jasmine"), |
| 39 | + this.createDom('span', { className: 'version' }, runner.env.versionString())), |
| 40 | + this.createDom('div', { className: 'options' }, |
| 41 | + "Show ", |
| 42 | + showPassed = this.createDom('input', { id: "__jasmine_TrivialReporter_showPassed__", type: 'checkbox' }), |
| 43 | + this.createDom('label', { "for": "__jasmine_TrivialReporter_showPassed__" }, " passed "), |
| 44 | + showSkipped = this.createDom('input', { id: "__jasmine_TrivialReporter_showSkipped__", type: 'checkbox' }), |
| 45 | + this.createDom('label', { "for": "__jasmine_TrivialReporter_showSkipped__" }, " skipped") |
| 46 | + ) |
| 47 | + ), |
| 48 | + |
| 49 | + this.runnerDiv = this.createDom('div', { className: 'runner running' }, |
| 50 | + this.createDom('a', { className: 'run_spec', href: '?' }, "run all"), |
| 51 | + this.runnerMessageSpan = this.createDom('span', {}, "Running..."), |
| 52 | + this.finishedAtSpan = this.createDom('span', { className: 'finished-at' }, "")) |
| 53 | + ); |
| 54 | + |
| 55 | + this.document.body.appendChild(this.outerDiv); |
| 56 | + |
| 57 | + var suites = runner.suites(); |
| 58 | + for (var i = 0; i < suites.length; i++) { |
| 59 | + var suite = suites[i]; |
| 60 | + var suiteDiv = this.createDom('div', { className: 'suite' }, |
| 61 | + this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, "run"), |
| 62 | + this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, suite.description)); |
| 63 | + this.suiteDivs[suite.id] = suiteDiv; |
| 64 | + var parentDiv = this.outerDiv; |
| 65 | + if (suite.parentSuite) { |
| 66 | + parentDiv = this.suiteDivs[suite.parentSuite.id]; |
| 67 | + } |
| 68 | + parentDiv.appendChild(suiteDiv); |
| 69 | + } |
| 70 | + |
| 71 | + this.startedAt = new Date(); |
| 72 | + |
| 73 | + var self = this; |
| 74 | + showPassed.onclick = function(evt) { |
| 75 | + if (showPassed.checked) { |
| 76 | + self.outerDiv.className += ' show-passed'; |
| 77 | + } else { |
| 78 | + self.outerDiv.className = self.outerDiv.className.replace(/ show-passed/, ''); |
| 79 | + } |
| 80 | + }; |
| 81 | + |
| 82 | + showSkipped.onclick = function(evt) { |
| 83 | + if (showSkipped.checked) { |
| 84 | + self.outerDiv.className += ' show-skipped'; |
| 85 | + } else { |
| 86 | + self.outerDiv.className = self.outerDiv.className.replace(/ show-skipped/, ''); |
| 87 | + } |
| 88 | + }; |
| 89 | +}; |
| 90 | + |
| 91 | +jasmine.TrivialReporter.prototype.reportRunnerResults = function(runner) { |
| 92 | + var results = runner.results(); |
| 93 | + var className = (results.failedCount > 0) ? "runner failed" : "runner passed"; |
| 94 | + this.runnerDiv.setAttribute("class", className); |
| 95 | + //do it twice for IE |
| 96 | + this.runnerDiv.setAttribute("className", className); |
| 97 | + var specs = runner.specs(); |
| 98 | + var specCount = 0; |
| 99 | + for (var i = 0; i < specs.length; i++) { |
| 100 | + if (this.specFilter(specs[i])) { |
| 101 | + specCount++; |
| 102 | + } |
| 103 | + } |
| 104 | + var message = "" + specCount + " spec" + (specCount == 1 ? "" : "s" ) + ", " + results.failedCount + " failure" + ((results.failedCount == 1) ? "" : "s"); |
| 105 | + message += " in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s"; |
| 106 | + this.runnerMessageSpan.replaceChild(this.createDom('a', { className: 'description', href: '?'}, message), this.runnerMessageSpan.firstChild); |
| 107 | + |
| 108 | + this.finishedAtSpan.appendChild(document.createTextNode("Finished at " + new Date().toString())); |
| 109 | +}; |
| 110 | + |
| 111 | +jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) { |
| 112 | + var results = suite.results(); |
| 113 | + var status = results.passed() ? 'passed' : 'failed'; |
| 114 | + if (results.totalCount == 0) { // todo: change this to check results.skipped |
| 115 | + status = 'skipped'; |
| 116 | + } |
| 117 | + this.suiteDivs[suite.id].className += " " + status; |
| 118 | +}; |
| 119 | + |
| 120 | +jasmine.TrivialReporter.prototype.reportSpecStarting = function(spec) { |
| 121 | + if (this.logRunningSpecs) { |
| 122 | + this.log('>> Jasmine Running ' + spec.suite.description + ' ' + spec.description + '...'); |
| 123 | + } |
| 124 | +}; |
| 125 | + |
| 126 | +jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) { |
| 127 | + var results = spec.results(); |
| 128 | + var status = results.passed() ? 'passed' : 'failed'; |
| 129 | + if (results.skipped) { |
| 130 | + status = 'skipped'; |
| 131 | + } |
| 132 | + var specDiv = this.createDom('div', { className: 'spec ' + status }, |
| 133 | + this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(spec.getFullName()) }, "run"), |
| 134 | + this.createDom('a', { |
| 135 | + className: 'description', |
| 136 | + href: '?spec=' + encodeURIComponent(spec.getFullName()), |
| 137 | + title: spec.getFullName() |
| 138 | + }, spec.description)); |
| 139 | + |
| 140 | + |
| 141 | + var resultItems = results.getItems(); |
| 142 | + var messagesDiv = this.createDom('div', { className: 'messages' }); |
| 143 | + for (var i = 0; i < resultItems.length; i++) { |
| 144 | + var result = resultItems[i]; |
| 145 | + |
| 146 | + if (result.type == 'log') { |
| 147 | + messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage log'}, result.toString())); |
| 148 | + } else if (result.type == 'expect' && result.passed && !result.passed()) { |
| 149 | + messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message)); |
| 150 | + |
| 151 | + if (result.trace.stack) { |
| 152 | + messagesDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack)); |
| 153 | + } |
| 154 | + } |
| 155 | + } |
| 156 | + |
| 157 | + if (messagesDiv.childNodes.length > 0) { |
| 158 | + specDiv.appendChild(messagesDiv); |
| 159 | + } |
| 160 | + |
| 161 | + this.suiteDivs[spec.suite.id].appendChild(specDiv); |
| 162 | +}; |
| 163 | + |
| 164 | +jasmine.TrivialReporter.prototype.log = function() { |
| 165 | + var console = jasmine.getGlobal().console; |
| 166 | + if (console && console.log) { |
| 167 | + if (console.log.apply) { |
| 168 | + console.log.apply(console, arguments); |
| 169 | + } else { |
| 170 | + console.log(arguments); // ie fix: console.log.apply doesn't exist on ie |
| 171 | + } |
| 172 | + } |
| 173 | +}; |
| 174 | + |
| 175 | +jasmine.TrivialReporter.prototype.getLocation = function() { |
| 176 | + return this.document.location; |
| 177 | +}; |
| 178 | + |
| 179 | +jasmine.TrivialReporter.prototype.specFilter = function(spec) { |
| 180 | + var paramMap = {}; |
| 181 | + var params = this.getLocation().search.substring(1).split('&'); |
| 182 | + for (var i = 0; i < params.length; i++) { |
| 183 | + var p = params[i].split('='); |
| 184 | + paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]); |
| 185 | + } |
| 186 | + |
| 187 | + if (!paramMap["spec"]) return true; |
| 188 | + return spec.getFullName().indexOf(paramMap["spec"]) == 0; |
| 189 | +}; |
Property changes on: trunk/phase3/tests/jasmine/lib/jasmine-1.0.1/jasmine-html.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 190 | + native |
Index: trunk/phase3/tests/jasmine/lib/jasmine-1.0.1/MIT.LICENSE |
— | — | @@ -0,0 +1,20 @@ |
| 2 | +Copyright (c) 2008-2010 Pivotal Labs |
| 3 | + |
| 4 | +Permission is hereby granted, free of charge, to any person obtaining |
| 5 | +a copy of this software and associated documentation files (the |
| 6 | +"Software"), to deal in the Software without restriction, including |
| 7 | +without limitation the rights to use, copy, modify, merge, publish, |
| 8 | +distribute, sublicense, and/or sell copies of the Software, and to |
| 9 | +permit persons to whom the Software is furnished to do so, subject to |
| 10 | +the following conditions: |
| 11 | + |
| 12 | +The above copyright notice and this permission notice shall be |
| 13 | +included in all copies or substantial portions of the Software. |
| 14 | + |
| 15 | +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 16 | +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 17 | +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 18 | +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE |
| 19 | +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
| 20 | +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
| 21 | +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
Property changes on: trunk/phase3/tests/jasmine/lib/jasmine-1.0.1/MIT.LICENSE |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 22 | + native |
Index: trunk/phase3/tests/jasmine/lib/jasmine-1.0.1/jasmine.css |
— | — | @@ -0,0 +1,166 @@ |
| 2 | +body { |
| 3 | + font-family: "Helvetica Neue Light", "Lucida Grande", "Calibri", "Arial", sans-serif; |
| 4 | +} |
| 5 | + |
| 6 | + |
| 7 | +.jasmine_reporter a:visited, .jasmine_reporter a { |
| 8 | + color: #303; |
| 9 | +} |
| 10 | + |
| 11 | +.jasmine_reporter a:hover, .jasmine_reporter a:active { |
| 12 | + color: blue; |
| 13 | +} |
| 14 | + |
| 15 | +.run_spec { |
| 16 | + float:right; |
| 17 | + padding-right: 5px; |
| 18 | + font-size: .8em; |
| 19 | + text-decoration: none; |
| 20 | +} |
| 21 | + |
| 22 | +.jasmine_reporter { |
| 23 | + margin: 0 5px; |
| 24 | +} |
| 25 | + |
| 26 | +.banner { |
| 27 | + color: #303; |
| 28 | + background-color: #fef; |
| 29 | + padding: 5px; |
| 30 | +} |
| 31 | + |
| 32 | +.logo { |
| 33 | + float: left; |
| 34 | + font-size: 1.1em; |
| 35 | + padding-left: 5px; |
| 36 | +} |
| 37 | + |
| 38 | +.logo .version { |
| 39 | + font-size: .6em; |
| 40 | + padding-left: 1em; |
| 41 | +} |
| 42 | + |
| 43 | +.runner.running { |
| 44 | + background-color: yellow; |
| 45 | +} |
| 46 | + |
| 47 | + |
| 48 | +.options { |
| 49 | + text-align: right; |
| 50 | + font-size: .8em; |
| 51 | +} |
| 52 | + |
| 53 | + |
| 54 | + |
| 55 | + |
| 56 | +.suite { |
| 57 | + border: 1px outset gray; |
| 58 | + margin: 5px 0; |
| 59 | + padding-left: 1em; |
| 60 | +} |
| 61 | + |
| 62 | +.suite .suite { |
| 63 | + margin: 5px; |
| 64 | +} |
| 65 | + |
| 66 | +.suite.passed { |
| 67 | + background-color: #dfd; |
| 68 | +} |
| 69 | + |
| 70 | +.suite.failed { |
| 71 | + background-color: #fdd; |
| 72 | +} |
| 73 | + |
| 74 | +.spec { |
| 75 | + margin: 5px; |
| 76 | + padding-left: 1em; |
| 77 | + clear: both; |
| 78 | +} |
| 79 | + |
| 80 | +.spec.failed, .spec.passed, .spec.skipped { |
| 81 | + padding-bottom: 5px; |
| 82 | + border: 1px solid gray; |
| 83 | +} |
| 84 | + |
| 85 | +.spec.failed { |
| 86 | + background-color: #fbb; |
| 87 | + border-color: red; |
| 88 | +} |
| 89 | + |
| 90 | +.spec.passed { |
| 91 | + background-color: #bfb; |
| 92 | + border-color: green; |
| 93 | +} |
| 94 | + |
| 95 | +.spec.skipped { |
| 96 | + background-color: #bbb; |
| 97 | +} |
| 98 | + |
| 99 | +.messages { |
| 100 | + border-left: 1px dashed gray; |
| 101 | + padding-left: 1em; |
| 102 | + padding-right: 1em; |
| 103 | +} |
| 104 | + |
| 105 | +.passed { |
| 106 | + background-color: #cfc; |
| 107 | + display: none; |
| 108 | +} |
| 109 | + |
| 110 | +.failed { |
| 111 | + background-color: #fbb; |
| 112 | +} |
| 113 | + |
| 114 | +.skipped { |
| 115 | + color: #777; |
| 116 | + background-color: #eee; |
| 117 | + display: none; |
| 118 | +} |
| 119 | + |
| 120 | + |
| 121 | +/*.resultMessage {*/ |
| 122 | + /*white-space: pre;*/ |
| 123 | +/*}*/ |
| 124 | + |
| 125 | +.resultMessage span.result { |
| 126 | + display: block; |
| 127 | + line-height: 2em; |
| 128 | + color: black; |
| 129 | +} |
| 130 | + |
| 131 | +.resultMessage .mismatch { |
| 132 | + color: black; |
| 133 | +} |
| 134 | + |
| 135 | +.stackTrace { |
| 136 | + white-space: pre; |
| 137 | + font-size: .8em; |
| 138 | + margin-left: 10px; |
| 139 | + max-height: 5em; |
| 140 | + overflow: auto; |
| 141 | + border: 1px inset red; |
| 142 | + padding: 1em; |
| 143 | + background: #eef; |
| 144 | +} |
| 145 | + |
| 146 | +.finished-at { |
| 147 | + padding-left: 1em; |
| 148 | + font-size: .6em; |
| 149 | +} |
| 150 | + |
| 151 | +.show-passed .passed, |
| 152 | +.show-skipped .skipped { |
| 153 | + display: block; |
| 154 | +} |
| 155 | + |
| 156 | + |
| 157 | +#jasmine_content { |
| 158 | + position:fixed; |
| 159 | + right: 100%; |
| 160 | +} |
| 161 | + |
| 162 | +.runner { |
| 163 | + border: 1px solid gray; |
| 164 | + display: block; |
| 165 | + margin: 5px 0; |
| 166 | + padding: 2px 0 2px 10px; |
| 167 | +} |
Property changes on: trunk/phase3/tests/jasmine/lib/jasmine-1.0.1/jasmine.css |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 168 | + native |
Index: trunk/phase3/includes/Wiki.php |
— | — | @@ -281,8 +281,10 @@ |
282 | 282 | switch( $title->getNamespace() ) { |
283 | 283 | case NS_FILE: |
284 | 284 | $page = new ImagePage( $title ); |
| 285 | + break; |
285 | 286 | case NS_CATEGORY: |
286 | 287 | $page = new CategoryPage( $title ); |
| 288 | + break; |
287 | 289 | default: |
288 | 290 | $page = new Article( $title ); |
289 | 291 | } |
Index: trunk/extensions/UploadWizard/resources/mw.UploadWizardDetails.js |
— | — | @@ -54,7 +54,7 @@ |
55 | 55 | api: _this.upload.api, |
56 | 56 | spinner: function(bool) { _this.toggleDestinationBusy(bool); }, |
57 | 57 | preprocess: function( name ) { |
58 | | - if ( name != '' ) { |
| 58 | + if ( name !== '' ) { |
59 | 59 | // turn the contents of the input into a MediaWiki title ("File:foo_bar.jpg") to look up |
60 | 60 | return _this.upload.title.setNameText( name ).toString(); |
61 | 61 | } else { |
— | — | @@ -760,13 +760,16 @@ |
761 | 761 | _this.completeDetailsSubmission(); |
762 | 762 | }; |
763 | 763 | |
764 | | - var callback = function( result ) { |
| 764 | + var ok = function( result ) { |
765 | 765 | finalCallback( result ); |
766 | 766 | }; |
| 767 | + var err = function( result ) { |
| 768 | + alert( "there was an error!! OMG" ); |
| 769 | + }; |
767 | 770 | |
768 | 771 | _this.upload.state = 'submitting-details'; |
769 | | - // XXX this can still fail with bad filename, or other 'warnings' -- capture these |
770 | | - _this.upload.api.postWithEditToken( params, callback ); |
| 772 | + |
| 773 | + _this.upload.api.postWithEditToken( params, ok, err ); |
771 | 774 | }, |
772 | 775 | |
773 | 776 | completeDetailsSubmission: function() { |