Produced by Araxis Merge on 12/7/2018 11:36:19 AM Central Standard Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | C:\SCRUB\MHED\MHED\VATS 2.3.0\var-utility-web-2.3.0@19406cb7810\app\libs\jquery\js | jquery.js | Thu Sep 13 18:55:48 2018 UTC |
| 2 | C:\MHED-scrubbed\MHED\MHED\VATS 2.3.0\var-utility-web-2.3.0@19406cb7810\app\libs\jquery\js | jquery.js | Fri Dec 7 13:49:16 2018 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 5 | 20604 |
| Changed | 4 | 12 |
| Inserted | 0 | 0 |
| Removed | 0 | 0 |
| Whitespace | |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
| 1 | /*! | |
| 2 | * jQuery JavaScript Library v 1.11.1 | |
| 3 | * http:// jquery.com / | |
| 4 | * | |
| 5 | * Include s Sizzle.j s | |
| 6 | * http:// sizzlejs.c om/ | |
| 7 | * | |
| 8 | * Copyrig ht 2005, 2 014 jQuery Foundatio n, Inc. an d other co ntributors | |
| 9 | * Release d under th e MIT lice nse | |
| 10 | * http:// jquery.org /license | |
| 11 | * | |
| 12 | * Date: 2 014-05-01T 17:42Z | |
| 13 | */ | |
| 14 | ||
| 15 | (function( global, f actory ) { | |
| 16 | ||
| 17 | if ( typeof module === "object" && typeof module.exp orts === " object" ) { | |
| 18 | // F or CommonJ S and Comm onJS-like environmen ts where a proper wi ndow is pr esent, | |
| 19 | // e xecute the factory a nd get jQu ery | |
| 20 | // F or environ ments that do not in herently p osses a wi ndow with a document | |
| 21 | // ( such as No de.js), ex pose a jQu ery-making factory a s module.e xports | |
| 22 | // T his accent uates the need for t he creatio n of a rea l window | |
| 23 | // e .g. var jQ uery = req uire("jque ry")(windo w); | |
| 24 | // S ee ticket #14549 for more info | |
| 25 | modu le.exports = global. document ? | |
| 26 | factor y( global, true ) : | |
| 27 | functi on( w ) { | |
| 28 | if ( !w. document ) { | |
| 29 | throw new Error( "jQ uery requi res a wind ow with a document" ); | |
| 30 | } | |
| 31 | return f actory( w ); | |
| 32 | }; | |
| 33 | } else { | |
| 34 | fact ory( globa l ); | |
| 35 | } | |
| 36 | ||
| 37 | // Pass th is if wind ow is not defined ye t | |
| 38 | }(typeof w indow !== "undefined " ? window : this, f unction( w indow, noG lobal ) { | |
| 39 | ||
| 40 | // Can't d o this bec ause sever al apps in cluding AS P.NET trac e | |
| 41 | // the sta ck via arg uments.cal ler.callee and Firef ox dies if | |
| 42 | // you try to trace through "u se strict" call chai ns. (#1333 5) | |
| 43 | // Support : Firefox 18+ | |
| 44 | // | |
| 45 | ||
| 46 | var delete dIds = []; | |
| 47 | ||
| 48 | var slice = deletedI ds.slice; | |
| 49 | ||
| 50 | var concat = deleted Ids.concat ; | |
| 51 | ||
| 52 | var push = deletedId s.push; | |
| 53 | ||
| 54 | var indexO f = delete dIds.index Of; | |
| 55 | ||
| 56 | var class2 type = {}; | |
| 57 | ||
| 58 | var toStri ng = class 2type.toSt ring; | |
| 59 | ||
| 60 | var hasOwn = class2t ype.hasOwn Property; | |
| 61 | ||
| 62 | var suppor t = {}; | |
| 63 | ||
| 64 | ||
| 65 | ||
| 66 | var | |
| 67 | ve rsion = "1 .11.1", | |
| 68 | ||
| 69 | // Define a local copy of jQuery | |
| 70 | jQ uery = fun ction( sel ector, con text ) { | |
| 71 | // T he jQuery object is actually j ust the in it constru ctor 'enha nced' | |
| 72 | // N eed init i f jQuery i s called ( just allow error to be thrown if not inc luded) | |
| 73 | retu rn new jQu ery.fn.ini t( selecto r, context ); | |
| 74 | }, | |
| 75 | ||
| 76 | // Support: Android<4. 1, IE<9 | |
| 77 | // Make sure we trim B OM and NBS P | |
| 78 | rt rim = /^[\ s\uFEFF\xA 0]+|[\s\uF EFF\xA0]+$ /g, | |
| 79 | ||
| 80 | // Matches d ashed stri ng for cam elizing | |
| 81 | rm sPrefix = /^-ms-/, | |
| 82 | rd ashAlpha = /-([\da-z ])/gi, | |
| 83 | ||
| 84 | // Used by j Query.came lCase as c allback to replace() | |
| 85 | fc amelCase = function( all, lett er ) { | |
| 86 | retu rn letter. toUpperCas e(); | |
| 87 | }; | |
| 88 | ||
| 89 | jQuery.fn = jQuery.p rototype = { | |
| 90 | // The curre nt version of jQuery being use d | |
| 91 | jq uery: vers ion, | |
| 92 | ||
| 93 | co nstructor: jQuery, | |
| 94 | ||
| 95 | // Start wit h an empty selector | |
| 96 | se lector: "" , | |
| 97 | ||
| 98 | // The defau lt length of a jQuer y object i s 0 | |
| 99 | le ngth: 0, | |
| 100 | ||
| 101 | to Array: fun ction() { | |
| 102 | retu rn slice.c all( this ); | |
| 103 | }, | |
| 104 | ||
| 105 | // Get the N th element in the ma tched elem ent set OR | |
| 106 | // Get the w hole match ed element set as a clean arra y | |
| 107 | ge t: functio n( num ) { | |
| 108 | retu rn num != null ? | |
| 109 | ||
| 110 | // Ret urn just t he one ele ment from the set | |
| 111 | ( num < 0 ? this [ num + th is.length ] : this[ num ] ) : | |
| 112 | ||
| 113 | // Ret urn all th e elements in a clea n array | |
| 114 | slice. call( this ); | |
| 115 | }, | |
| 116 | ||
| 117 | // Take an a rray of el ements and push it o nto the st ack | |
| 118 | // (returnin g the new matched el ement set) | |
| 119 | pu shStack: f unction( e lems ) { | |
| 120 | ||
| 121 | // B uild a new jQuery ma tched elem ent set | |
| 122 | var ret = jQue ry.merge( this.const ructor(), elems ); | |
| 123 | ||
| 124 | // A dd the old object on to the sta ck (as a r eference) | |
| 125 | ret. prevObject = this; | |
| 126 | ret. context = this.conte xt; | |
| 127 | ||
| 128 | // R eturn the newly-form ed element set | |
| 129 | retu rn ret; | |
| 130 | }, | |
| 131 | ||
| 132 | // Execute a callback for every element in the match ed set. | |
| 133 | // (You can seed the a rguments w ith an arr ay of args , but this is | |
| 134 | // only used internall y.) | |
| 135 | ea ch: functi on( callba ck, args ) { | |
| 136 | retu rn jQuery. each( this , callback , args ); | |
| 137 | }, | |
| 138 | ||
| 139 | ma p: functio n( callbac k ) { | |
| 140 | retu rn this.pu shStack( j Query.map( this, func tion( elem , i ) { | |
| 141 | return callback. call( elem , i, elem ); | |
| 142 | })); | |
| 143 | }, | |
| 144 | ||
| 145 | sl ice: funct ion() { | |
| 146 | retu rn this.pu shStack( s lice.apply ( this, ar guments ) ); | |
| 147 | }, | |
| 148 | ||
| 149 | fi rst: funct ion() { | |
| 150 | retu rn this.eq ( 0 ); | |
| 151 | }, | |
| 152 | ||
| 153 | la st: functi on() { | |
| 154 | retu rn this.eq ( -1 ); | |
| 155 | }, | |
| 156 | ||
| 157 | eq : function ( i ) { | |
| 158 | var len = this .length, | |
| 159 | j = +i + ( i < 0 ? len : 0 ); | |
| 160 | retu rn this.pu shStack( j >= 0 && j < len ? [ this[j] ] : [] ); | |
| 161 | }, | |
| 162 | ||
| 163 | en d: functio n() { | |
| 164 | retu rn this.pr evObject | | this.con structor(n ull); | |
| 165 | }, | |
| 166 | ||
| 167 | // For inter nal use on ly. | |
| 168 | // Behaves l ike an Arr ay's metho d, not lik e a jQuery method. | |
| 169 | pu sh: push, | |
| 170 | so rt: delete dIds.sort, | |
| 171 | sp lice: dele tedIds.spl ice | |
| 172 | }; | |
| 173 | ||
| 174 | jQuery.ext end = jQue ry.fn.exte nd = funct ion() { | |
| 175 | va r src, cop yIsArray, copy, name , options, clone, | |
| 176 | targ et = argum ents[0] || {}, | |
| 177 | i = 1, | |
| 178 | leng th = argum ents.lengt h, | |
| 179 | deep = false; | |
| 180 | ||
| 181 | // Handle a deep copy situation | |
| 182 | if ( typeof target === "boolean" ) { | |
| 183 | deep = target; | |
| 184 | ||
| 185 | // s kip the bo olean and the target | |
| 186 | targ et = argum ents[ i ] || {}; | |
| 187 | i++; | |
| 188 | } | |
| 189 | ||
| 190 | // Handle ca se when ta rget is a string or something (possible in deep co py) | |
| 191 | if ( typeof target !== "object" && !jQuery .isFunctio n(target) ) { | |
| 192 | targ et = {}; | |
| 193 | } | |
| 194 | ||
| 195 | // extend jQ uery itsel f if only one argume nt is pass ed | |
| 196 | if ( i === l ength ) { | |
| 197 | targ et = this; | |
| 198 | i--; | |
| 199 | } | |
| 200 | ||
| 201 | fo r ( ; i < length; i+ + ) { | |
| 202 | // O nly deal w ith non-nu ll/undefin ed values | |
| 203 | if ( (options = argument s[ i ]) != null ) { | |
| 204 | // Ext end the ba se object | |
| 205 | for ( name in op tions ) { | |
| 206 | src = ta rget[ name ]; | |
| 207 | copy = o ptions[ na me ]; | |
| 208 | ||
| 209 | // Preve nt never-e nding loop | |
| 210 | if ( tar get === co py ) { | |
| 211 | continue; | |
| 212 | } | |
| 213 | ||
| 214 | // Recur se if we'r e merging plain obje cts or arr ays | |
| 215 | if ( dee p && copy && ( jQuer y.isPlainO bject(copy ) || (copy IsArray = jQuery.isA rray(copy) ) ) ) { | |
| 216 | if ( copyI sArray ) { | |
| 217 | co pyIsArray = false; | |
| 218 | cl one = src && jQuery. isArray(sr c) ? src : []; | |
| 219 | ||
| 220 | } else { | |
| 221 | cl one = src && jQuery. isPlainObj ect(src) ? src : {}; | |
| 222 | } | |
| 223 | ||
| 224 | // Never m ove origin al objects , clone th em | |
| 225 | target[ na me ] = jQu ery.extend ( deep, cl one, copy ); | |
| 226 | ||
| 227 | // Don't bring in undefined values | |
| 228 | } else i f ( copy ! == undefin ed ) { | |
| 229 | target[ na me ] = cop y; | |
| 230 | } | |
| 231 | } | |
| 232 | } | |
| 233 | } | |
| 234 | ||
| 235 | // Return th e modified object | |
| 236 | re turn targe t; | |
| 237 | }; | |
| 238 | ||
| 239 | jQuery.ext end({ | |
| 240 | // Unique fo r each cop y of jQuer y on the p age | |
| 241 | ex pando: "jQ uery" + ( version + Math.rando m() ).repl ace( /\D/g , "" ), | |
| 242 | ||
| 243 | // Assume jQ uery is re ady withou t the read y module | |
| 244 | is Ready: tru e, | |
| 245 | ||
| 246 | er ror: funct ion( msg ) { | |
| 247 | thro w new Erro r( msg ); | |
| 248 | }, | |
| 249 | ||
| 250 | no op: functi on() {}, | |
| 251 | ||
| 252 | // See test/ unit/core. js for det ails conce rning isFu nction. | |
| 253 | // Since ver sion 1.3, DOM method s and func tions like alert | |
| 254 | // aren't su pported. T hey return false on IE (#2968) . | |
| 255 | is Function: function( obj ) { | |
| 256 | retu rn jQuery. type(obj) === "funct ion"; | |
| 257 | }, | |
| 258 | ||
| 259 | is Array: Arr ay.isArray || functi on( obj ) { | |
| 260 | retu rn jQuery. type(obj) === "array "; | |
| 261 | }, | |
| 262 | ||
| 263 | is Window: fu nction( ob j ) { | |
| 264 | /* j shint eqeq eq: false */ | |
| 265 | retu rn obj != null && ob j == obj.w indow; | |
| 266 | }, | |
| 267 | ||
| 268 | is Numeric: f unction( o bj ) { | |
| 269 | // p arseFloat NaNs numer ic-cast fa lse positi ves (null| true|false |"") | |
| 270 | // . ..but misi nterprets leading-nu mber strin gs, partic ularly hex literals ("0x...") | |
| 271 | // s ubtraction forces in finities t o NaN | |
| 272 | retu rn !jQuery .isArray( obj ) && o bj - parse Float( obj ) >= 0; | |
| 273 | }, | |
| 274 | ||
| 275 | is EmptyObjec t: functio n( obj ) { | |
| 276 | var name; | |
| 277 | for ( name in obj ) { | |
| 278 | return false; | |
| 279 | } | |
| 280 | retu rn true; | |
| 281 | }, | |
| 282 | ||
| 283 | is PlainObjec t: functio n( obj ) { | |
| 284 | var key; | |
| 285 | ||
| 286 | // M ust be an Object. | |
| 287 | // B ecause of IE, we als o have to check the presence o f the cons tructor pr operty. | |
| 288 | // M ake sure t hat DOM no des and wi ndow objec ts don't p ass throug h, as well | |
| 289 | if ( !obj || j Query.type (obj) !== "object" | | obj.node Type || jQ uery.isWin dow( obj ) ) { | |
| 290 | return false; | |
| 291 | } | |
| 292 | ||
| 293 | try { | |
| 294 | // Not own const ructor pro perty must be Object | |
| 295 | if ( o bj.constru ctor && | |
| 296 | !hasOwn. call(obj, "construct or") && | |
| 297 | !hasOwn. call(obj.c onstructor .prototype , "isProto typeOf") ) { | |
| 298 | return f alse; | |
| 299 | } | |
| 300 | } ca tch ( e ) { | |
| 301 | // IE8 ,9 Will th row except ions on ce rtain host objects # 9897 | |
| 302 | return false; | |
| 303 | } | |
| 304 | ||
| 305 | // S upport: IE <9 | |
| 306 | // H andle iter ation over inherited propertie s before o wn propert ies. | |
| 307 | if ( support.o wnLast ) { | |
| 308 | for ( key in obj ) { | |
| 309 | return h asOwn.call ( obj, key ); | |
| 310 | } | |
| 311 | } | |
| 312 | ||
| 313 | // O wn propert ies are en umerated f irstly, so to speed up, | |
| 314 | // i f last one is own, t hen all pr operties a re own. | |
| 315 | for ( key in o bj ) {} | |
| 316 | ||
| 317 | retu rn key === undefined || hasOwn .call( obj , key ); | |
| 318 | }, | |
| 319 | ||
| 320 | ty pe: functi on( obj ) { | |
| 321 | if ( obj == nu ll ) { | |
| 322 | return obj + ""; | |
| 323 | } | |
| 324 | retu rn typeof obj === "o bject" || typeof obj === "func tion" ? | |
| 325 | class2 type[ toSt ring.call( obj) ] || "object" : | |
| 326 | typeof obj; | |
| 327 | }, | |
| 328 | ||
| 329 | // Evaluates a script in a globa l context | |
| 330 | // Workaroun ds based o n findings by Jim Dr iscoll | |
| 331 | // http://we blogs.java .net/blog/ driscoll/a rchive/200 9/09/08/ev al-javascr ipt-global -context | |
| 332 | gl obalEval: function( data ) { | |
| 333 | if ( data && j Query.trim ( data ) ) { | |
| 334 | // We use execSc ript on In ternet Exp lorer | |
| 335 | // We use an ano nymous fun ction so t hat contex t is windo w | |
| 336 | // rat her than j Query in F irefox | |
| 337 | ( wind ow.execScr ipt || fun ction( dat a ) { | |
| 338 | window[ "eval" ].c all( windo w, data ); | |
| 339 | } )( d ata ); | |
| 340 | } | |
| 341 | }, | |
| 342 | ||
| 343 | // Convert d ashed to c amelCase; used by th e css and data modul es | |
| 344 | // Microsoft forgot to hump thei r vendor p refix (#95 72) | |
| 345 | ca melCase: f unction( s tring ) { | |
| 346 | retu rn string. replace( r msPrefix, "ms-" ).re place( rda shAlpha, f camelCase ); | |
| 347 | }, | |
| 348 | ||
| 349 | no deName: fu nction( el em, name ) { | |
| 350 | retu rn elem.no deName && elem.nodeN ame.toLowe rCase() == = name.toL owerCase() ; | |
| 351 | }, | |
| 352 | ||
| 353 | // args is f or interna l usage on ly | |
| 354 | ea ch: functi on( obj, c allback, a rgs ) { | |
| 355 | var value, | |
| 356 | i = 0, | |
| 357 | length = obj.len gth, | |
| 358 | isArra y = isArra ylike( obj ); | |
| 359 | ||
| 360 | if ( args ) { | |
| 361 | if ( i sArray ) { | |
| 362 | for ( ; i < length ; i++ ) { | |
| 363 | value = ca llback.app ly( obj[ i ], args ) ; | |
| 364 | ||
| 365 | if ( value === false ) { | |
| 366 | br eak; | |
| 367 | } | |
| 368 | } | |
| 369 | } else { | |
| 370 | for ( i in obj ) { | |
| 371 | value = ca llback.app ly( obj[ i ], args ) ; | |
| 372 | ||
| 373 | if ( value === false ) { | |
| 374 | br eak; | |
| 375 | } | |
| 376 | } | |
| 377 | } | |
| 378 | ||
| 379 | // A special, fast, case for the m ost common use of ea ch | |
| 380 | } el se { | |
| 381 | if ( i sArray ) { | |
| 382 | for ( ; i < length ; i++ ) { | |
| 383 | value = ca llback.cal l( obj[ i ], i, obj[ i ] ); | |
| 384 | ||
| 385 | if ( value === false ) { | |
| 386 | br eak; | |
| 387 | } | |
| 388 | } | |
| 389 | } else { | |
| 390 | for ( i in obj ) { | |
| 391 | value = ca llback.cal l( obj[ i ], i, obj[ i ] ); | |
| 392 | ||
| 393 | if ( value === false ) { | |
| 394 | br eak; | |
| 395 | } | |
| 396 | } | |
| 397 | } | |
| 398 | } | |
| 399 | ||
| 400 | retu rn obj; | |
| 401 | }, | |
| 402 | ||
| 403 | // Support: Android<4. 1, IE<9 | |
| 404 | tr im: functi on( text ) { | |
| 405 | retu rn text == null ? | |
| 406 | "" : | |
| 407 | ( text + "" ).re place( rtr im, "" ); | |
| 408 | }, | |
| 409 | ||
| 410 | // results i s for inte rnal usage only | |
| 411 | ma keArray: f unction( a rr, result s ) { | |
| 412 | var ret = resu lts || []; | |
| 413 | ||
| 414 | if ( arr != nu ll ) { | |
| 415 | if ( i sArraylike ( Object(a rr) ) ) { | |
| 416 | jQuery.m erge( ret, | |
| 417 | typeof arr === "stri ng" ? | |
| 418 | [ arr ] : arr | |
| 419 | ); | |
| 420 | } else { | |
| 421 | push.cal l( ret, ar r ); | |
| 422 | } | |
| 423 | } | |
| 424 | ||
| 425 | retu rn ret; | |
| 426 | }, | |
| 427 | ||
| 428 | in Array: fun ction( ele m, arr, i ) { | |
| 429 | var len; | |
| 430 | ||
| 431 | if ( arr ) { | |
| 432 | if ( i ndexOf ) { | |
| 433 | return i ndexOf.cal l( arr, el em, i ); | |
| 434 | } | |
| 435 | ||
| 436 | len = arr.length ; | |
| 437 | i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0 ; | |
| 438 | ||
| 439 | for ( ; i < len; i++ ) { | |
| 440 | // Skip accessing in sparse arrays | |
| 441 | if ( i i n arr && a rr[ i ] == = elem ) { | |
| 442 | return i; | |
| 443 | } | |
| 444 | } | |
| 445 | } | |
| 446 | ||
| 447 | retu rn -1; | |
| 448 | }, | |
| 449 | ||
| 450 | me rge: funct ion( first , second ) { | |
| 451 | var len = +sec ond.length , | |
| 452 | j = 0, | |
| 453 | i = fi rst.length ; | |
| 454 | ||
| 455 | whil e ( j < le n ) { | |
| 456 | first[ i++ ] = s econd[ j++ ]; | |
| 457 | } | |
| 458 | ||
| 459 | // S upport: IE <9 | |
| 460 | // W orkaround casting of .length t o NaN on o therwise a rraylike o bjects (e. g., NodeLi sts) | |
| 461 | if ( len !== l en ) { | |
| 462 | while ( second[j ] !== unde fined ) { | |
| 463 | first[ i ++ ] = sec ond[ j++ ] ; | |
| 464 | } | |
| 465 | } | |
| 466 | ||
| 467 | firs t.length = i; | |
| 468 | ||
| 469 | retu rn first; | |
| 470 | }, | |
| 471 | ||
| 472 | gr ep: functi on( elems, callback, invert ) { | |
| 473 | var callbackIn verse, | |
| 474 | matche s = [], | |
| 475 | i = 0, | |
| 476 | length = elems.l ength, | |
| 477 | callba ckExpect = !invert; | |
| 478 | ||
| 479 | // G o through the array, only savi ng the ite ms | |
| 480 | // t hat pass t he validat or functio n | |
| 481 | for ( ; i < le ngth; i++ ) { | |
| 482 | callba ckInverse = !callbac k( elems[ i ], i ); | |
| 483 | if ( c allbackInv erse !== c allbackExp ect ) { | |
| 484 | matches. push( elem s[ i ] ); | |
| 485 | } | |
| 486 | } | |
| 487 | ||
| 488 | retu rn matches ; | |
| 489 | }, | |
| 490 | ||
| 491 | // arg is fo r internal usage onl y | |
| 492 | ma p: functio n( elems, callback, arg ) { | |
| 493 | var value, | |
| 494 | i = 0, | |
| 495 | length = elems.l ength, | |
| 496 | isArra y = isArra ylike( ele ms ), | |
| 497 | ret = []; | |
| 498 | ||
| 499 | // G o through the array, translati ng each of the items to their new values | |
| 500 | if ( isArray ) { | |
| 501 | for ( ; i < leng th; i++ ) { | |
| 502 | value = callback( elems[ i ] , i, arg ) ; | |
| 503 | ||
| 504 | if ( val ue != null ) { | |
| 505 | ret.push( value ); | |
| 506 | } | |
| 507 | } | |
| 508 | ||
| 509 | // G o through every key on the obj ect, | |
| 510 | } el se { | |
| 511 | for ( i in elems ) { | |
| 512 | value = callback( elems[ i ] , i, arg ) ; | |
| 513 | ||
| 514 | if ( val ue != null ) { | |
| 515 | ret.push( value ); | |
| 516 | } | |
| 517 | } | |
| 518 | } | |
| 519 | ||
| 520 | // F latten any nested ar rays | |
| 521 | retu rn concat. apply( [], ret ); | |
| 522 | }, | |
| 523 | ||
| 524 | // A global GUID count er for obj ects | |
| 525 | gu id: 1, | |
| 526 | ||
| 527 | // Bind a fu nction to a context, optionall y partiall y applying any | |
| 528 | // arguments . | |
| 529 | pr oxy: funct ion( fn, c ontext ) { | |
| 530 | var args, prox y, tmp; | |
| 531 | ||
| 532 | if ( typeof co ntext === "string" ) { | |
| 533 | tmp = fn[ contex t ]; | |
| 534 | contex t = fn; | |
| 535 | fn = t mp; | |
| 536 | } | |
| 537 | ||
| 538 | // Q uick check to determ ine if tar get is cal lable, in the spec | |
| 539 | // t his throws a TypeErr or, but we will just return un defined. | |
| 540 | if ( !jQuery.i sFunction( fn ) ) { | |
| 541 | return undefined ; | |
| 542 | } | |
| 543 | ||
| 544 | // S imulated b ind | |
| 545 | args = slice.c all( argum ents, 2 ); | |
| 546 | prox y = functi on() { | |
| 547 | return fn.apply( context | | this, ar gs.concat( slice.cal l( argumen ts ) ) ); | |
| 548 | }; | |
| 549 | ||
| 550 | // S et the gui d of uniqu e handler to the sam e of origi nal handle r, so it c an be remo ved | |
| 551 | prox y.guid = f n.guid = f n.guid || jQuery.gui d++; | |
| 552 | ||
| 553 | retu rn proxy; | |
| 554 | }, | |
| 555 | ||
| 556 | no w: functio n() { | |
| 557 | retu rn +( new Date() ); | |
| 558 | }, | |
| 559 | ||
| 560 | // jQuery.su pport is n ot used in Core but other proj ects attac h their | |
| 561 | // propertie s to it so it needs to exist. | |
| 562 | su pport: sup port | |
| 563 | }); | |
| 564 | ||
| 565 | // Populat e the clas s2type map | |
| 566 | jQuery.eac h("Boolean Number St ring Funct ion Array Date RegEx p Object E rror".spli t(" "), fu nction(i, name) { | |
| 567 | cl ass2type[ "[object " + name + "]" ] = na me.toLower Case(); | |
| 568 | }); | |
| 569 | ||
| 570 | function i sArraylike ( obj ) { | |
| 571 | va r length = obj.lengt h, | |
| 572 | type = jQuery. type( obj ); | |
| 573 | ||
| 574 | if ( type == = "functio n" || jQue ry.isWindo w( obj ) ) { | |
| 575 | retu rn false; | |
| 576 | } | |
| 577 | ||
| 578 | if ( obj.nod eType === 1 && lengt h ) { | |
| 579 | retu rn true; | |
| 580 | } | |
| 581 | ||
| 582 | re turn type === "array " || lengt h === 0 || | |
| 583 | type of length === "numbe r" && leng th > 0 && ( length - 1 ) in ob j; | |
| 584 | } | |
| 585 | var Sizzle = | |
| 586 | /*! | |
| 587 | * Sizzle CSS Select or Engine v1.10.19 | |
| 588 | * http:// sizzlejs.c om/ | |
| 589 | * | |
| 590 | * Copyrig ht 2013 jQ uery Found ation, Inc . and othe r contribu tors | |
| 591 | * Release d under th e MIT lice nse | |
| 592 | * http:// jquery.org /license | |
| 593 | * | |
| 594 | * Date: 2 014-04-18 | |
| 595 | */ | |
| 596 | (function( window ) { | |
| 597 | ||
| 598 | var i, | |
| 599 | su pport, | |
| 600 | Ex pr, | |
| 601 | ge tText, | |
| 602 | is XML, | |
| 603 | to kenize, | |
| 604 | co mpile, | |
| 605 | se lect, | |
| 606 | ou termostCon text, | |
| 607 | so rtInput, | |
| 608 | ha sDuplicate , | |
| 609 | ||
| 610 | // Local doc ument vars | |
| 611 | se tDocument, | |
| 612 | do cument, | |
| 613 | do cElem, | |
| 614 | do cumentIsHT ML, | |
| 615 | rb uggyQSA, | |
| 616 | rb uggyMatche s, | |
| 617 | ma tches, | |
| 618 | co ntains, | |
| 619 | ||
| 620 | // Instance- specific d ata | |
| 621 | ex pando = "s izzle" + - (new Date( )), | |
| 622 | pr eferredDoc = window. document, | |
| 623 | di rruns = 0, | |
| 624 | do ne = 0, | |
| 625 | cl assCache = createCac he(), | |
| 626 | to kenCache = createCac he(), | |
| 627 | co mpilerCach e = create Cache(), | |
| 628 | so rtOrder = function( a, b ) { | |
| 629 | if ( a === b ) { | |
| 630 | hasDup licate = t rue; | |
| 631 | } | |
| 632 | retu rn 0; | |
| 633 | }, | |
| 634 | ||
| 635 | // General-p urpose con stants | |
| 636 | st rundefined = typeof undefined, | |
| 637 | MA X_NEGATIVE = 1 << 31 , | |
| 638 | ||
| 639 | // Instance methods | |
| 640 | ha sOwn = ({} ).hasOwnPr operty, | |
| 641 | ar r = [], | |
| 642 | po p = arr.po p, | |
| 643 | pu sh_native = arr.push , | |
| 644 | pu sh = arr.p ush, | |
| 645 | sl ice = arr. slice, | |
| 646 | // Use a str ipped-down indexOf i f we can't use a nat ive one | |
| 647 | in dexOf = ar r.indexOf || functio n( elem ) { | |
| 648 | var i = 0, | |
| 649 | len = this.lengt h; | |
| 650 | for ( ; i < le n; i++ ) { | |
| 651 | if ( t his[i] === elem ) { | |
| 652 | return i ; | |
| 653 | } | |
| 654 | } | |
| 655 | retu rn -1; | |
| 656 | }, | |
| 657 | ||
| 658 | bo oleans = " checked|se lected|asy nc|autofoc us|autopla y|controls |defer|dis abled|hidd en|ismap|l oop|multip le|open|re adonly|req uired|scop ed", | |
| 659 | ||
| 660 | // Regular e xpressions | |
| 661 | ||
| 662 | // Whitespac e characte rs http:// www.w3.org /TR/css3-s electors/# whitespace | |
| 663 | wh itespace = "[\\x20\\ t\\r\\n\\f ]", | |
| 664 | // http://ww w.w3.org/T R/css3-syn tax/#chara cters | |
| 665 | ch aracterEnc oding = "( ?:\\\\.|[\ \w-]|[^\\x 00-\\xa0]) +", | |
| 666 | ||
| 667 | // Loosely m odeled on CSS identi fier chara cters | |
| 668 | // An unquot ed value s hould be a CSS ident ifier http ://www.w3. org/TR/css 3-selector s/#attribu te-selecto rs | |
| 669 | // Proper sy ntax: http ://www.w3. org/TR/CSS 21/syndata .html#valu e-def-iden tifier | |
| 670 | id entifier = character Encoding.r eplace( "w ", "w#" ), | |
| 671 | ||
| 672 | // Attribute selectors : http://w ww.w3.org/ TR/selecto rs/#attrib ute-select ors | |
| 673 | at tributes = "\\[" + w hitespace + "*(" + c haracterEn coding + " )(?:" + wh itespace + | |
| 674 | // O perator (c apture 2) | |
| 675 | "*([ *^$|!~]?=) " + whites pace + | |
| 676 | // " Attribute values mus t be CSS i dentifiers [capture 5] or stri ngs [captu re 3 or ca pture 4]" | |
| 677 | "*(? :'((?:\\\\ .|[^\\\\'] )*)'|\"((? :\\\\.|[^\ \\\\"])*)\ "|(" + ide ntifier + "))|)" + w hitespace + | |
| 678 | "*\\ ]", | |
| 679 | ||
| 680 | ps eudos = ": (" + chara cterEncodi ng + ")(?: \\((" + | |
| 681 | // T o reduce t he number of selecto rs needing tokenize in the pre Filter, pr efer argum ents: | |
| 682 | // 1 . quoted ( capture 3; capture 4 or captur e 5) | |
| 683 | "('( (?:\\\\.|[ ^\\\\'])*) '|\"((?:\\ \\.|[^\\\\ \"])*)\")| " + | |
| 684 | // 2 . simple ( capture 6) | |
| 685 | "((? :\\\\.|[^\ \\\()[\\]] |" + attri butes + ") *)|" + | |
| 686 | // 3 . anything else (cap ture 2) | |
| 687 | ".*" + | |
| 688 | ")\\ )|)", | |
| 689 | ||
| 690 | // Leading a nd non-esc aped trail ing whites pace, capt uring some non-white space char acters pre ceding the latter | |
| 691 | rt rim = new RegExp( "^ " + whites pace + "+| ((?:^|[^\\ \\])(?:\\\ \.)*)" + w hitespace + "+$", "g " ), | |
| 692 | ||
| 693 | rc omma = new RegExp( " ^" + white space + "* ," + white space + "* " ), | |
| 694 | rc ombinators = new Reg Exp( "^" + whitespac e + "*([>+ ~]|" + whi tespace + ")" + whit espace + " *" ), | |
| 695 | ||
| 696 | ra ttributeQu otes = new RegExp( " =" + white space + "* ([^\\]'\"] *?)" + whi tespace + "*\\]", "g " ), | |
| 697 | ||
| 698 | rp seudo = ne w RegExp( pseudos ), | |
| 699 | ri dentifier = new RegE xp( "^" + identifier + "$" ), | |
| 700 | ||
| 701 | ma tchExpr = { | |
| 702 | "ID" : new RegE xp( "^#(" + characte rEncoding + ")" ), | |
| 703 | "CLA SS": new R egExp( "^\ \.(" + cha racterEnco ding + ")" ), | |
| 704 | "TAG ": new Reg Exp( "^(" + characte rEncoding. replace( " w", "w*" ) + ")" ), | |
| 705 | "ATT R": new Re gExp( "^" + attribut es ), | |
| 706 | "PSE UDO": new RegExp( "^ " + pseudo s ), | |
| 707 | "CHI LD": new R egExp( "^: (only|firs t|last|nth |nth-last) -(child|of -type)(?:\ \(" + whit espace + | |
| 708 | "*(eve n|odd|(([+ -]|)(\\d*) n|)" + whi tespace + "*(?:([+-] |)" + whit espace + | |
| 709 | "*(\\d +)|))" + w hitespace + "*\\)|)" , "i" ), | |
| 710 | "boo l": new Re gExp( "^(? :" + boole ans + ")$" , "i" ), | |
| 711 | // F or use in libraries implementi ng .is() | |
| 712 | // W e use this for POS m atching in `select` | |
| 713 | "nee dsContext" : new RegE xp( "^" + whitespace + "*[>+~] |:(even|od d|eq|gt|lt |nth|first |last)(?:\ \(" + | |
| 714 | whites pace + "*( (?:-\\d)?\ \d*)" + wh itespace + "*\\)|)(? =[^-]|$)", "i" ) | |
| 715 | }, | |
| 716 | ||
| 717 | ri nputs = /^ (?:input|s elect|text area|butto n)$/i, | |
| 718 | rh eader = /^ h\d$/i, | |
| 719 | ||
| 720 | rn ative = /^ [^{]+\{\s* \[native \ w/, | |
| 721 | ||
| 722 | // Easily-pa rseable/re trievable ID or TAG or CLASS s electors | |
| 723 | rq uickExpr = /^(?:#([\ w-]+)|(\w+ )|\.([\w-] +))$/, | |
| 724 | ||
| 725 | rs ibling = / [+~]/, | |
| 726 | re scape = /' |\\/g, | |
| 727 | ||
| 728 | // CSS escap es http:// www.w3.org /TR/CSS21/ syndata.ht ml#escaped -character s | |
| 729 | ru nescape = new RegExp ( "\\\\([\ \da-f]{1,6 }" + white space + "? |(" + whit espace + " )|.)", "ig " ), | |
| 730 | fu nescape = function( _, escaped , escapedW hitespace ) { | |
| 731 | var high = "0x " + escape d - 0x1000 0; | |
| 732 | // N aN means n on-codepoi nt | |
| 733 | // S upport: Fi refox<24 | |
| 734 | // W orkaround erroneous numeric in terpretati on of +"0x " | |
| 735 | retu rn high != = high || escapedWhi tespace ? | |
| 736 | escape d : | |
| 737 | high < 0 ? | |
| 738 | // BMP c odepoint | |
| 739 | String.f romCharCod e( high + 0x10000 ) : | |
| 740 | // Suppl emental Pl ane codepo int (surro gate pair) | |
| 741 | String.f romCharCod e( high >> 10 | 0xD8 00, high & 0x3FF | 0 xDC00 ); | |
| 742 | }; | |
| 743 | ||
| 744 | // Optimiz e for push .apply( _, NodeList ) | |
| 745 | try { | |
| 746 | pu sh.apply( | |
| 747 | (arr = slice.c all( prefe rredDoc.ch ildNodes ) ), | |
| 748 | pref erredDoc.c hildNodes | |
| 749 | ); | |
| 750 | // Support: Android<4. 0 | |
| 751 | // Detect si lently fai ling push. apply | |
| 752 | ar r[ preferr edDoc.chil dNodes.len gth ].node Type; | |
| 753 | } catch ( e ) { | |
| 754 | pu sh = { app ly: arr.le ngth ? | |
| 755 | ||
| 756 | // L everage sl ice if pos sible | |
| 757 | func tion( targ et, els ) { | |
| 758 | push_n ative.appl y( target, slice.cal l(els) ); | |
| 759 | } : | |
| 760 | ||
| 761 | // S upport: IE <9 | |
| 762 | // O therwise a ppend dire ctly | |
| 763 | func tion( targ et, els ) { | |
| 764 | var j = target.l ength, | |
| 765 | i = 0; | |
| 766 | // Can 't trust N odeList.le ngth | |
| 767 | while ( (target[ j++] = els [i++]) ) { } | |
| 768 | target .length = j - 1; | |
| 769 | } | |
| 770 | }; | |
| 771 | } | |
| 772 | ||
| 773 | function S izzle( sel ector, con text, resu lts, seed ) { | |
| 774 | va r match, e lem, m, no deType, | |
| 775 | // Q SA vars | |
| 776 | i, g roups, old , nid, new Context, n ewSelector ; | |
| 777 | ||
| 778 | if ( ( conte xt ? conte xt.ownerDo cument || context : preferredD oc ) !== d ocument ) { | |
| 779 | setD ocument( c ontext ); | |
| 780 | } | |
| 781 | ||
| 782 | co ntext = co ntext || d ocument; | |
| 783 | re sults = re sults || [ ]; | |
| 784 | ||
| 785 | if ( !select or || type of selecto r !== "str ing" ) { | |
| 786 | retu rn results ; | |
| 787 | } | |
| 788 | ||
| 789 | if ( (nodeTy pe = conte xt.nodeTyp e) !== 1 & & nodeType !== 9 ) { | |
| 790 | retu rn []; | |
| 791 | } | |
| 792 | ||
| 793 | if ( documen tIsHTML && !seed ) { | |
| 794 | ||
| 795 | // S hortcuts | |
| 796 | if ( (match = rquickExpr .exec( sel ector )) ) { | |
| 797 | // Spe ed-up: Siz zle("#ID") | |
| 798 | if ( ( m = match[ 1]) ) { | |
| 799 | if ( nod eType === 9 ) { | |
| 800 | elem = con text.getEl ementById( m ); | |
| 801 | // Check p arentNode to catch w hen Blackb erry 4.6 r eturns | |
| 802 | // nodes t hat are no longer in the docum ent (jQuer y #6963) | |
| 803 | if ( elem && elem.pa rentNode ) { | |
| 804 | // Handle th e case whe re IE, Ope ra, and We bkit retur n items | |
| 805 | // by name i nstead of ID | |
| 806 | if ( elem.id === m ) { | |
| 807 | resu lts.push( elem ); | |
| 808 | retu rn results ; | |
| 809 | } | |
| 810 | } else { | |
| 811 | re turn resul ts; | |
| 812 | } | |
| 813 | } else { | |
| 814 | // Context is not a document | |
| 815 | if ( conte xt.ownerDo cument && (elem = co ntext.owne rDocument. getElement ById( m )) && | |
| 816 | co ntains( co ntext, ele m ) && ele m.id === m ) { | |
| 817 | re sults.push ( elem ); | |
| 818 | re turn resul ts; | |
| 819 | } | |
| 820 | } | |
| 821 | ||
| 822 | // Spe ed-up: Siz zle("TAG") | |
| 823 | } else if ( matc h[2] ) { | |
| 824 | push.app ly( result s, context .getElemen tsByTagNam e( selecto r ) ); | |
| 825 | return r esults; | |
| 826 | ||
| 827 | // Spe ed-up: Siz zle(".CLAS S") | |
| 828 | } else if ( (m = match[3]) && suppor t.getEleme ntsByClass Name && co ntext.getE lementsByC lassName ) { | |
| 829 | push.app ly( result s, context .getElemen tsByClassN ame( m ) ) ; | |
| 830 | return r esults; | |
| 831 | } | |
| 832 | } | |
| 833 | ||
| 834 | // Q SA path | |
| 835 | if ( support.q sa && (!rb uggyQSA || !rbuggyQS A.test( se lector )) ) { | |
| 836 | nid = old = expa ndo; | |
| 837 | newCon text = con text; | |
| 838 | newSel ector = no deType === 9 && sele ctor; | |
| 839 | ||
| 840 | // qSA works str angely on Element-ro oted queri es | |
| 841 | // We can work a round this by specif ying an ex tra ID on the root | |
| 842 | // and working u p from the re (Thanks to Andrew Dupont fo r the tech nique) | |
| 843 | // IE 8 doesn't work on ob ject eleme nts | |
| 844 | if ( n odeType == = 1 && con text.nodeN ame.toLowe rCase() != = "object" ) { | |
| 845 | groups = tokenize( selector ); | |
| 846 | ||
| 847 | if ( (ol d = contex t.getAttri bute("id") ) ) { | |
| 848 | nid = old. replace( r escape, "\ \$&" ); | |
| 849 | } else { | |
| 850 | context.se tAttribute ( "id", ni d ); | |
| 851 | } | |
| 852 | nid = "[ id='" + ni d + "'] "; | |
| 853 | ||
| 854 | i = grou ps.length; | |
| 855 | while ( i-- ) { | |
| 856 | groups[i] = nid + to Selector( groups[i] ); | |
| 857 | } | |
| 858 | newConte xt = rsibl ing.test( selector ) && testCo ntext( con text.paren tNode ) || context; | |
| 859 | newSelec tor = grou ps.join(", "); | |
| 860 | } | |
| 861 | ||
| 862 | if ( n ewSelector ) { | |
| 863 | try { | |
| 864 | push.apply ( results, | |
| 865 | ne wContext.q uerySelect orAll( new Selector ) | |
| 866 | ); | |
| 867 | return res ults; | |
| 868 | } catch( qsaError) { | |
| 869 | } finall y { | |
| 870 | if ( !old ) { | |
| 871 | co ntext.remo veAttribut e("id"); | |
| 872 | } | |
| 873 | } | |
| 874 | } | |
| 875 | } | |
| 876 | } | |
| 877 | ||
| 878 | // All other s | |
| 879 | re turn selec t( selecto r.replace( rtrim, "$ 1" ), cont ext, resul ts, seed ) ; | |
| 880 | } | |
| 881 | ||
| 882 | /** | |
| 883 | * Create key-value caches of limited si ze | |
| 884 | * @return s {Functio n(string, Object)} R eturns the Object da ta after s toring it on itself with | |
| 885 | * pr operty nam e the (spa ce-suffixe d) string and (if th e cache is larger th an Expr.ca cheLength) | |
| 886 | * de leting the oldest en try | |
| 887 | */ | |
| 888 | function c reateCache () { | |
| 889 | va r keys = [ ]; | |
| 890 | ||
| 891 | fu nction cac he( key, v alue ) { | |
| 892 | // U se (key + " ") to av oid collis ion with n ative prot otype prop erties (se e Issue #1 57) | |
| 893 | if ( keys.push ( key + " " ) > Expr .cacheLeng th ) { | |
| 894 | // Onl y keep the most rece nt entries | |
| 895 | delete cache[ ke ys.shift() ]; | |
| 896 | } | |
| 897 | retu rn (cache[ key + " " ] = value ); | |
| 898 | } | |
| 899 | re turn cache ; | |
| 900 | } | |
| 901 | ||
| 902 | /** | |
| 903 | * Mark a function f or special use by Si zzle | |
| 904 | * @param {Function} fn The fu nction to mark | |
| 905 | */ | |
| 906 | function m arkFunctio n( fn ) { | |
| 907 | fn [ expando ] = true; | |
| 908 | re turn fn; | |
| 909 | } | |
| 910 | ||
| 911 | /** | |
| 912 | * Support testing u sing an el ement | |
| 913 | * @param {Function} fn Passed the creat ed div and expects a boolean r esult | |
| 914 | */ | |
| 915 | function a ssert( fn ) { | |
| 916 | va r div = do cument.cre ateElement ("div"); | |
| 917 | ||
| 918 | tr y { | |
| 919 | retu rn !!fn( d iv ); | |
| 920 | } catch (e) { | |
| 921 | retu rn false; | |
| 922 | } finally { | |
| 923 | // R emove from its paren t by defau lt | |
| 924 | if ( div.paren tNode ) { | |
| 925 | div.pa rentNode.r emoveChild ( div ); | |
| 926 | } | |
| 927 | // r elease mem ory in IE | |
| 928 | div = null; | |
| 929 | } | |
| 930 | } | |
| 931 | ||
| 932 | /** | |
| 933 | * Adds th e same han dler for a ll of the specified attrs | |
| 934 | * @param {String} a ttrs Pipe- separated list of at tributes | |
| 935 | * @param {Function} handler T he method that will be applied | |
| 936 | */ | |
| 937 | function a ddHandle( attrs, han dler ) { | |
| 938 | va r arr = at trs.split( "|"), | |
| 939 | i = attrs.leng th; | |
| 940 | ||
| 941 | wh ile ( i-- ) { | |
| 942 | Expr .attrHandl e[ arr[i] ] = handle r; | |
| 943 | } | |
| 944 | } | |
| 945 | ||
| 946 | /** | |
| 947 | * Checks document o rder of tw o siblings | |
| 948 | * @param {Element} a | |
| 949 | * @param {Element} b | |
| 950 | * @return s {Number} Returns l ess than 0 if a prec edes b, gr eater than 0 if a fo llows b | |
| 951 | */ | |
| 952 | function s iblingChec k( a, b ) { | |
| 953 | va r cur = b && a, | |
| 954 | diff = cur && a.nodeType === 1 && b.nodeType === 1 && | |
| 955 | ( ~b.s ourceIndex || MAX_NE GATIVE ) - | |
| 956 | ( ~a.s ourceIndex || MAX_NE GATIVE ); | |
| 957 | ||
| 958 | // Use IE so urceIndex if availab le on both nodes | |
| 959 | if ( diff ) { | |
| 960 | retu rn diff; | |
| 961 | } | |
| 962 | ||
| 963 | // Check if b follows a | |
| 964 | if ( cur ) { | |
| 965 | whil e ( (cur = cur.nextS ibling) ) { | |
| 966 | if ( c ur === b ) { | |
| 967 | return - 1; | |
| 968 | } | |
| 969 | } | |
| 970 | } | |
| 971 | ||
| 972 | re turn a ? 1 : -1; | |
| 973 | } | |
| 974 | ||
| 975 | /** | |
| 976 | * Returns a functio n to use i n pseudos for input types | |
| 977 | * @param {String} t ype | |
| 978 | */ | |
| 979 | function c reateInput Pseudo( ty pe ) { | |
| 980 | re turn funct ion( elem ) { | |
| 981 | var name = ele m.nodeName .toLowerCa se(); | |
| 982 | retu rn name == = "input" && elem.ty pe === typ e; | |
| 983 | }; | |
| 984 | } | |
| 985 | ||
| 986 | /** | |
| 987 | * Returns a functio n to use i n pseudos for button s | |
| 988 | * @param {String} t ype | |
| 989 | */ | |
| 990 | function c reateButto nPseudo( t ype ) { | |
| 991 | re turn funct ion( elem ) { | |
| 992 | var name = ele m.nodeName .toLowerCa se(); | |
| 993 | retu rn (name = == "input" || name = == "button ") && elem .type === type; | |
| 994 | }; | |
| 995 | } | |
| 996 | ||
| 997 | /** | |
| 998 | * Returns a functio n to use i n pseudos for positi onals | |
| 999 | * @param {Function} fn | |
| 1000 | */ | |
| 1001 | function c reatePosit ionalPseud o( fn ) { | |
| 1002 | re turn markF unction(fu nction( ar gument ) { | |
| 1003 | argu ment = +ar gument; | |
| 1004 | retu rn markFun ction(func tion( seed , matches ) { | |
| 1005 | var j, | |
| 1006 | matchInd exes = fn( [], seed. length, ar gument ), | |
| 1007 | i = matc hIndexes.l ength; | |
| 1008 | ||
| 1009 | // Mat ch element s found at the speci fied index es | |
| 1010 | while ( i-- ) { | |
| 1011 | if ( see d[ (j = ma tchIndexes [i]) ] ) { | |
| 1012 | seed[j] = !(matches[ j] = seed[ j]); | |
| 1013 | } | |
| 1014 | } | |
| 1015 | }); | |
| 1016 | }) ; | |
| 1017 | } | |
| 1018 | ||
| 1019 | /** | |
| 1020 | * Checks a node for validity as a Sizzl e context | |
| 1021 | * @param {Element|O bject=} co ntext | |
| 1022 | * @return s {Element |Object|Bo olean} The input nod e if accep table, oth erwise a f alsy value | |
| 1023 | */ | |
| 1024 | function t estContext ( context ) { | |
| 1025 | re turn conte xt && type of context .getElemen tsByTagNam e !== stru ndefined & & context; | |
| 1026 | } | |
| 1027 | ||
| 1028 | // Expose support va rs for con venience | |
| 1029 | support = Sizzle.sup port = {}; | |
| 1030 | ||
| 1031 | /** | |
| 1032 | * Detects XML nodes | |
| 1033 | * @param {Element|O bject} ele m An eleme nt or a do cument | |
| 1034 | * @return s {Boolean } True iff elem is a non-HTML XML node | |
| 1035 | */ | |
| 1036 | isXML = Si zzle.isXML = functio n( elem ) { | |
| 1037 | // documentE lement is verified f or cases w here it do esn't yet exist | |
| 1038 | // (such as loading if rames in I E - #4833) | |
| 1039 | va r document Element = elem && (e lem.ownerD ocument || elem).doc umentEleme nt; | |
| 1040 | re turn docum entElement ? documen tElement.n odeName != = "HTML" : false; | |
| 1041 | }; | |
| 1042 | ||
| 1043 | /** | |
| 1044 | * Sets do cument-rel ated varia bles once based on t he current document | |
| 1045 | * @param {Element|O bject} [do c] An elem ent or doc ument obje ct to use to set the document | |
| 1046 | * @return s {Object} Returns t he current document | |
| 1047 | */ | |
| 1048 | setDocumen t = Sizzle .setDocume nt = funct ion( node ) { | |
| 1049 | va r hasCompa re, | |
| 1050 | doc = node ? n ode.ownerD ocument || node : pr eferredDoc , | |
| 1051 | pare nt = doc.d efaultView ; | |
| 1052 | ||
| 1053 | // If no doc ument and documentEl ement is a vailable, return | |
| 1054 | if ( doc === document || doc.nod eType !== 9 || !doc. documentEl ement ) { | |
| 1055 | retu rn documen t; | |
| 1056 | } | |
| 1057 | ||
| 1058 | // Set our d ocument | |
| 1059 | do cument = d oc; | |
| 1060 | do cElem = do c.document Element; | |
| 1061 | ||
| 1062 | // Support t ests | |
| 1063 | do cumentIsHT ML = !isXM L( doc ); | |
| 1064 | ||
| 1065 | // Support: IE>8 | |
| 1066 | // If iframe document is assigne d to "docu ment" vari able and i f iframe h as been re loaded, | |
| 1067 | // IE will t hrow "perm ission den ied" error when acce ssing "doc ument" var iable, see jQuery #1 3936 | |
| 1068 | // IE6-8 do not suppor t the defa ultView pr operty so parent wil l be undef ined | |
| 1069 | if ( parent && parent !== parent .top ) { | |
| 1070 | // I E11 does n ot have at tachEvent, so all mu st suffer | |
| 1071 | if ( parent.ad dEventList ener ) { | |
| 1072 | parent .addEventL istener( " unload", f unction() { | |
| 1073 | setDocum ent(); | |
| 1074 | }, fal se ); | |
| 1075 | } el se if ( pa rent.attac hEvent ) { | |
| 1076 | parent .attachEve nt( "onunl oad", func tion() { | |
| 1077 | setDocum ent(); | |
| 1078 | }); | |
| 1079 | } | |
| 1080 | } | |
| 1081 | ||
| 1082 | /* Attribute s | |
| 1083 | -- ---------- ---------- ---------- ---------- ---------- ---------- -------- * / | |
| 1084 | ||
| 1085 | // Support: IE<8 | |
| 1086 | // Verify th at getAttr ibute real ly returns attribute s and not properties (exceptin g IE8 bool eans) | |
| 1087 | su pport.attr ibutes = a ssert(func tion( div ) { | |
| 1088 | div. className = "i"; | |
| 1089 | retu rn !div.ge tAttribute ("classNam e"); | |
| 1090 | }) ; | |
| 1091 | ||
| 1092 | /* getElemen t(s)By* | |
| 1093 | -- ---------- ---------- ---------- ---------- ---------- ---------- -------- * / | |
| 1094 | ||
| 1095 | // Check if getElement sByTagName ("*") retu rns only e lements | |
| 1096 | su pport.getE lementsByT agName = a ssert(func tion( div ) { | |
| 1097 | div. appendChil d( doc.cre ateComment ("") ); | |
| 1098 | retu rn !div.ge tElementsB yTagName(" *").length ; | |
| 1099 | }) ; | |
| 1100 | ||
| 1101 | // Check if getElement sByClassNa me can be trusted | |
| 1102 | su pport.getE lementsByC lassName = rnative.t est( doc.g etElements ByClassNam e ) && ass ert(functi on( div ) { | |
| 1103 | div. innerHTML = "<div cl ass='a'></ div><div c lass='a i' ></div>"; | |
| 1104 | ||
| 1105 | // S upport: Sa fari<4 | |
| 1106 | // C atch class over-cach ing | |
| 1107 | div. firstChild .className = "i"; | |
| 1108 | // S upport: Op era<10 | |
| 1109 | // C atch gEBCN failure t o find non -leading c lasses | |
| 1110 | retu rn div.get ElementsBy ClassName( "i").lengt h === 2; | |
| 1111 | }) ; | |
| 1112 | ||
| 1113 | // Support: IE<10 | |
| 1114 | // Check if getElement ById retur ns element s by name | |
| 1115 | // The broke n getEleme ntById met hods don't pick up p rogramatic ally-set n ames, | |
| 1116 | // so use a roundabout getElemen tsByName t est | |
| 1117 | su pport.getB yId = asse rt(functio n( div ) { | |
| 1118 | docE lem.append Child( div ).id = ex pando; | |
| 1119 | retu rn !doc.ge tElementsB yName || ! doc.getEle mentsByNam e( expando ).length; | |
| 1120 | }) ; | |
| 1121 | ||
| 1122 | // ID find a nd filter | |
| 1123 | if ( support .getById ) { | |
| 1124 | Expr .find["ID" ] = functi on( id, co ntext ) { | |
| 1125 | if ( t ypeof cont ext.getEle mentById ! == strunde fined && d ocumentIsH TML ) { | |
| 1126 | var m = context.ge tElementBy Id( id ); | |
| 1127 | // Check parentNod e to catch when Blac kberry 4.6 returns | |
| 1128 | // nodes that are no longer in the doc ument #696 3 | |
| 1129 | return m && m.pare ntNode ? [ m ] : []; | |
| 1130 | } | |
| 1131 | }; | |
| 1132 | Expr .filter["I D"] = func tion( id ) { | |
| 1133 | var at trId = id. replace( r unescape, funescape ); | |
| 1134 | return function( elem ) { | |
| 1135 | return e lem.getAtt ribute("id ") === att rId; | |
| 1136 | }; | |
| 1137 | }; | |
| 1138 | } else { | |
| 1139 | // S upport: IE 6/7 | |
| 1140 | // g etElementB yId is not reliable as a find shortcut | |
| 1141 | dele te Expr.fi nd["ID"]; | |
| 1142 | ||
| 1143 | Expr .filter["I D"] = fun ction( id ) { | |
| 1144 | var at trId = id. replace( r unescape, funescape ); | |
| 1145 | return function( elem ) { | |
| 1146 | var node = typeof elem.getAt tributeNod e !== stru ndefined & & elem.get AttributeN ode("id"); | |
| 1147 | return n ode && nod e.value == = attrId; | |
| 1148 | }; | |
| 1149 | }; | |
| 1150 | } | |
| 1151 | ||
| 1152 | // Tag | |
| 1153 | Ex pr.find["T AG"] = sup port.getEl ementsByTa gName ? | |
| 1154 | func tion( tag, context ) { | |
| 1155 | if ( t ypeof cont ext.getEle mentsByTag Name !== s trundefine d ) { | |
| 1156 | return c ontext.get ElementsBy TagName( t ag ); | |
| 1157 | } | |
| 1158 | } : | |
| 1159 | func tion( tag, context ) { | |
| 1160 | var el em, | |
| 1161 | tmp = [] , | |
| 1162 | i = 0, | |
| 1163 | results = context. getElement sByTagName ( tag ); | |
| 1164 | ||
| 1165 | // Fil ter out po ssible com ments | |
| 1166 | if ( t ag === "*" ) { | |
| 1167 | while ( (elem = re sults[i++] ) ) { | |
| 1168 | if ( elem. nodeType = == 1 ) { | |
| 1169 | tm p.push( el em ); | |
| 1170 | } | |
| 1171 | } | |
| 1172 | ||
| 1173 | return t mp; | |
| 1174 | } | |
| 1175 | return results; | |
| 1176 | }; | |
| 1177 | ||
| 1178 | // Class | |
| 1179 | Ex pr.find["C LASS"] = s upport.get ElementsBy ClassName && functio n( classNa me, contex t ) { | |
| 1180 | if ( typeof co ntext.getE lementsByC lassName ! == strunde fined && d ocumentIsH TML ) { | |
| 1181 | return context.g etElements ByClassNam e( classNa me ); | |
| 1182 | } | |
| 1183 | }; | |
| 1184 | ||
| 1185 | /* QSA/match esSelector | |
| 1186 | -- ---------- ---------- ---------- ---------- ---------- ---------- -------- * / | |
| 1187 | ||
| 1188 | // QSA and m atchesSele ctor suppo rt | |
| 1189 | ||
| 1190 | // matchesSe lector(:ac tive) repo rts false when true (IE9/Opera 11.5) | |
| 1191 | rb uggyMatche s = []; | |
| 1192 | ||
| 1193 | // qSa(:focu s) reports false whe n true (Ch rome 21) | |
| 1194 | // We allow this becau se of a bu g in IE8/9 that thro ws an erro r | |
| 1195 | // whenever `document. activeElem ent` is ac cessed on an iframe | |
| 1196 | // So, we al low :focus to pass t hrough QSA all the t ime to avo id the IE error | |
| 1197 | // See http: //bugs.jqu ery.com/ti cket/13378 | |
| 1198 | rb uggyQSA = []; | |
| 1199 | ||
| 1200 | if ( (suppor t.qsa = rn ative.test ( doc.quer ySelectorA ll )) ) { | |
| 1201 | // B uild QSA r egex | |
| 1202 | // R egex strat egy adopte d from Die go Perini | |
| 1203 | asse rt(functio n( div ) { | |
| 1204 | // Sel ect is set to empty string on purpose | |
| 1205 | // Thi s is to te st IE's tr eatment of not expli citly | |
| 1206 | // set ting a boo lean conte nt attribu te, | |
| 1207 | // sin ce its pre sence shou ld be enou gh | |
| 1208 | // htt p://bugs.j query.com/ ticket/123 59 | |
| 1209 | div.in nerHTML = "<select m sallowclip =''><optio n selected =''></opti on></selec t>"; | |
| 1210 | ||
| 1211 | // Sup port: IE8, Opera 11- 12.16 | |
| 1212 | // Not hing shoul d be selec ted when e mpty strin gs follow ^= or $= o r *= | |
| 1213 | // The test attr ibute must be unknow n in Opera but "safe " for WinR T | |
| 1214 | // htt p://msdn.m icrosoft.c om/en-us/l ibrary/ie/ hh465388.a spx#attrib ute_sectio n | |
| 1215 | if ( d iv.querySe lectorAll( "[msallowc lip^='']") .length ) { | |
| 1216 | rbuggyQS A.push( "[ *^$]=" + w hitespace + "*(?:''| \"\")" ); | |
| 1217 | } | |
| 1218 | ||
| 1219 | // Sup port: IE8 | |
| 1220 | // Boo lean attri butes and "value" ar e not trea ted correc tly | |
| 1221 | if ( ! div.queryS electorAll ("[selecte d]").lengt h ) { | |
| 1222 | rbuggyQS A.push( "\ \[" + whit espace + " *(?:value| " + boolea ns + ")" ) ; | |
| 1223 | } | |
| 1224 | ||
| 1225 | // Web kit/Opera - :checked should re turn selec ted option elements | |
| 1226 | // htt p://www.w3 .org/TR/20 11/REC-css 3-selector s-20110929 /#checked | |
| 1227 | // IE8 throws er ror here a nd will no t see late r tests | |
| 1228 | if ( ! div.queryS electorAll (":checked ").length ) { | |
| 1229 | rbuggyQS A.push(":c hecked"); | |
| 1230 | } | |
| 1231 | }); | |
| 1232 | ||
| 1233 | asse rt(functio n( div ) { | |
| 1234 | // Sup port: Wind ows 8 Nati ve Apps | |
| 1235 | // The type and name attri butes are restricted during .i nnerHTML a ssignment | |
| 1236 | var in put = doc. createElem ent("input "); | |
| 1237 | input. setAttribu te( "type" , "hidden" ); | |
| 1238 | div.ap pendChild( input ).s etAttribut e( "name", "D" ); | |
| 1239 | ||
| 1240 | // Sup port: IE8 | |
| 1241 | // Enf orce case- sensitivit y of name attribute | |
| 1242 | if ( d iv.querySe lectorAll( "[name=d]" ).length ) { | |
| 1243 | rbuggyQS A.push( "n ame" + whi tespace + "*[*^$|!~] ?=" ); | |
| 1244 | } | |
| 1245 | ||
| 1246 | // FF 3.5 - :ena bled/:disa bled and h idden elem ents (hidd en element s are stil l enabled) | |
| 1247 | // IE8 throws er ror here a nd will no t see late r tests | |
| 1248 | if ( ! div.queryS electorAll (":enabled ").length ) { | |
| 1249 | rbuggyQS A.push( ": enabled", ":disabled " ); | |
| 1250 | } | |
| 1251 | ||
| 1252 | // Ope ra 10-11 d oes not th row on pos t-comma in valid pseu dos | |
| 1253 | div.qu erySelecto rAll("*,:x "); | |
| 1254 | rbuggy QSA.push(" ,.*:"); | |
| 1255 | }); | |
| 1256 | } | |
| 1257 | ||
| 1258 | if ( (suppor t.matchesS elector = rnative.te st( (match es = docEl em.matches || | |
| 1259 | docE lem.webkit MatchesSel ector || | |
| 1260 | docE lem.mozMat chesSelect or || | |
| 1261 | docE lem.oMatch esSelector || | |
| 1262 | docE lem.msMatc hesSelecto r) )) ) { | |
| 1263 | ||
| 1264 | asse rt(functio n( div ) { | |
| 1265 | // Che ck to see if it's po ssible to do matches Selector | |
| 1266 | // on a disconne cted node (IE 9) | |
| 1267 | suppor t.disconne ctedMatch = matches. call( div, "div" ); | |
| 1268 | ||
| 1269 | // Thi s should f ail with a n exceptio n | |
| 1270 | // Gec ko does no t error, r eturns fal se instead | |
| 1271 | matche s.call( di v, "[s!='' ]:x" ); | |
| 1272 | rbuggy Matches.pu sh( "!=", pseudos ); | |
| 1273 | }); | |
| 1274 | } | |
| 1275 | ||
| 1276 | rb uggyQSA = rbuggyQSA. length && new RegExp ( rbuggyQS A.join("|" ) ); | |
| 1277 | rb uggyMatche s = rbuggy Matches.le ngth && ne w RegExp( rbuggyMatc hes.join(" |") ); | |
| 1278 | ||
| 1279 | /* Contains | |
| 1280 | -- ---------- ---------- ---------- ---------- ---------- ---------- -------- * / | |
| 1281 | ha sCompare = rnative.t est( docEl em.compare DocumentPo sition ); | |
| 1282 | ||
| 1283 | // Element c ontains an other | |
| 1284 | // Purposefu lly does n ot impleme nt inclusi ve descend ent | |
| 1285 | // As in, an element d oes not co ntain itse lf | |
| 1286 | co ntains = h asCompare || rnative .test( doc Elem.conta ins ) ? | |
| 1287 | func tion( a, b ) { | |
| 1288 | var ad own = a.no deType === 9 ? a.doc umentEleme nt : a, | |
| 1289 | bup = b && b.paren tNode; | |
| 1290 | return a === bup || !!( bu p && bup.n odeType == = 1 && ( | |
| 1291 | adown.co ntains ? | |
| 1292 | adown.cont ains( bup ) : | |
| 1293 | a.compareD ocumentPos ition && a .compareDo cumentPosi tion( bup ) & 16 | |
| 1294 | )); | |
| 1295 | } : | |
| 1296 | func tion( a, b ) { | |
| 1297 | if ( b ) { | |
| 1298 | while ( (b = b.par entNode) ) { | |
| 1299 | if ( b === a ) { | |
| 1300 | re turn true; | |
| 1301 | } | |
| 1302 | } | |
| 1303 | } | |
| 1304 | return false; | |
| 1305 | }; | |
| 1306 | ||
| 1307 | /* Sorting | |
| 1308 | -- ---------- ---------- ---------- ---------- ---------- ---------- -------- * / | |
| 1309 | ||
| 1310 | // Document order sort ing | |
| 1311 | so rtOrder = hasCompare ? | |
| 1312 | fu nction( a, b ) { | |
| 1313 | ||
| 1314 | // F lag for du plicate re moval | |
| 1315 | if ( a === b ) { | |
| 1316 | hasDup licate = t rue; | |
| 1317 | return 0; | |
| 1318 | } | |
| 1319 | ||
| 1320 | // S ort on met hod existe nce if onl y one inpu t has comp areDocumen tPosition | |
| 1321 | var compare = !a.compare DocumentPo sition - ! b.compareD ocumentPos ition; | |
| 1322 | if ( compare ) { | |
| 1323 | return compare; | |
| 1324 | } | |
| 1325 | ||
| 1326 | // C alculate p osition if both inpu ts belong to the sam e document | |
| 1327 | comp are = ( a. ownerDocum ent || a ) === ( b.o wnerDocume nt || b ) ? | |
| 1328 | a.comp areDocumen tPosition( b ) : | |
| 1329 | ||
| 1330 | // Oth erwise we know they are discon nected | |
| 1331 | 1; | |
| 1332 | ||
| 1333 | // D isconnecte d nodes | |
| 1334 | if ( compare & 1 || | |
| 1335 | (!supp ort.sortDe tached && b.compareD ocumentPos ition( a ) === compa re) ) { | |
| 1336 | ||
| 1337 | // Cho ose the fi rst elemen t that is related to our prefe rred docum ent | |
| 1338 | if ( a === doc | | a.ownerD ocument == = preferre dDoc && co ntains(pre ferredDoc, a) ) { | |
| 1339 | return - 1; | |
| 1340 | } | |
| 1341 | if ( b === doc | | b.ownerD ocument == = preferre dDoc && co ntains(pre ferredDoc, b) ) { | |
| 1342 | return 1 ; | |
| 1343 | } | |
| 1344 | ||
| 1345 | // Mai ntain orig inal order | |
| 1346 | return sortInput ? | |
| 1347 | ( indexO f.call( so rtInput, a ) - index Of.call( s ortInput, b ) ) : | |
| 1348 | 0; | |
| 1349 | } | |
| 1350 | ||
| 1351 | retu rn compare & 4 ? -1 : 1; | |
| 1352 | } : | |
| 1353 | fu nction( a, b ) { | |
| 1354 | // E xit early if the nod es are ide ntical | |
| 1355 | if ( a === b ) { | |
| 1356 | hasDup licate = t rue; | |
| 1357 | return 0; | |
| 1358 | } | |
| 1359 | ||
| 1360 | var cur, | |
| 1361 | i = 0, | |
| 1362 | aup = a.parentNo de, | |
| 1363 | bup = b.parentNo de, | |
| 1364 | ap = [ a ], | |
| 1365 | bp = [ b ]; | |
| 1366 | ||
| 1367 | // P arentless nodes are either doc uments or disconnect ed | |
| 1368 | if ( !aup || ! bup ) { | |
| 1369 | return a === doc ? -1 : | |
| 1370 | b === do c ? 1 : | |
| 1371 | aup ? -1 : | |
| 1372 | bup ? 1 : | |
| 1373 | sortInpu t ? | |
| 1374 | ( indexO f.call( so rtInput, a ) - index Of.call( s ortInput, b ) ) : | |
| 1375 | 0; | |
| 1376 | ||
| 1377 | // I f the node s are sibl ings, we c an do a qu ick check | |
| 1378 | } el se if ( au p === bup ) { | |
| 1379 | return siblingCh eck( a, b ); | |
| 1380 | } | |
| 1381 | ||
| 1382 | // O therwise w e need ful l lists of their anc estors for compariso n | |
| 1383 | cur = a; | |
| 1384 | whil e ( (cur = cur.paren tNode) ) { | |
| 1385 | ap.uns hift( cur ); | |
| 1386 | } | |
| 1387 | cur = b; | |
| 1388 | whil e ( (cur = cur.paren tNode) ) { | |
| 1389 | bp.uns hift( cur ); | |
| 1390 | } | |
| 1391 | ||
| 1392 | // W alk down t he tree lo oking for a discrepa ncy | |
| 1393 | whil e ( ap[i] === bp[i] ) { | |
| 1394 | i++; | |
| 1395 | } | |
| 1396 | ||
| 1397 | retu rn i ? | |
| 1398 | // Do a sibling check if t he nodes h ave a comm on ancesto r | |
| 1399 | siblin gCheck( ap [i], bp[i] ) : | |
| 1400 | ||
| 1401 | // Oth erwise nod es in our document s ort first | |
| 1402 | ap[i] === prefer redDoc ? - 1 : | |
| 1403 | bp[i] === prefer redDoc ? 1 : | |
| 1404 | 0; | |
| 1405 | }; | |
| 1406 | ||
| 1407 | re turn doc; | |
| 1408 | }; | |
| 1409 | ||
| 1410 | Sizzle.mat ches = fun ction( exp r, element s ) { | |
| 1411 | re turn Sizzl e( expr, n ull, null, elements ); | |
| 1412 | }; | |
| 1413 | ||
| 1414 | Sizzle.mat chesSelect or = funct ion( elem, expr ) { | |
| 1415 | // Set docum ent vars i f needed | |
| 1416 | if ( ( elem. ownerDocum ent || ele m ) !== do cument ) { | |
| 1417 | setD ocument( e lem ); | |
| 1418 | } | |
| 1419 | ||
| 1420 | // Make sure that attr ibute sele ctors are quoted | |
| 1421 | ex pr = expr. replace( r attributeQ uotes, "=' $1']" ); | |
| 1422 | ||
| 1423 | if ( support .matchesSe lector && documentIs HTML && | |
| 1424 | ( !r buggyMatch es || !rbu ggyMatches .test( exp r ) ) && | |
| 1425 | ( !r buggyQSA || !rbu ggyQSA.tes t( expr ) ) ) { | |
| 1426 | ||
| 1427 | try { | |
| 1428 | var re t = matche s.call( el em, expr ) ; | |
| 1429 | ||
| 1430 | // IE 9's matche sSelector returns fa lse on dis connected nodes | |
| 1431 | if ( r et || supp ort.discon nectedMatc h || | |
| 1432 | // As well , disconne cted nodes are said to be in a document | |
| 1433 | // fragmen t in IE 9 | |
| 1434 | elem.docum ent && ele m.document .nodeType !== 11 ) { | |
| 1435 | return r et; | |
| 1436 | } | |
| 1437 | } ca tch(e) {} | |
| 1438 | } | |
| 1439 | ||
| 1440 | re turn Sizzl e( expr, d ocument, n ull, [ ele m ] ).leng th > 0; | |
| 1441 | }; | |
| 1442 | ||
| 1443 | Sizzle.con tains = fu nction( co ntext, ele m ) { | |
| 1444 | // Set docum ent vars i f needed | |
| 1445 | if ( ( conte xt.ownerDo cument || context ) !== docume nt ) { | |
| 1446 | setD ocument( c ontext ); | |
| 1447 | } | |
| 1448 | re turn conta ins( conte xt, elem ) ; | |
| 1449 | }; | |
| 1450 | ||
| 1451 | Sizzle.att r = functi on( elem, name ) { | |
| 1452 | // Set docum ent vars i f needed | |
| 1453 | if ( ( elem. ownerDocum ent || ele m ) !== do cument ) { | |
| 1454 | setD ocument( e lem ); | |
| 1455 | } | |
| 1456 | ||
| 1457 | va r fn = Exp r.attrHand le[ name.t oLowerCase () ], | |
| 1458 | // D on't get f ooled by O bject.prot otype prop erties (jQ uery #1380 7) | |
| 1459 | val = fn && ha sOwn.call( Expr.attr Handle, na me.toLower Case() ) ? | |
| 1460 | fn( el em, name, !documentI sHTML ) : | |
| 1461 | undefi ned; | |
| 1462 | ||
| 1463 | re turn val ! == undefin ed ? | |
| 1464 | val : | |
| 1465 | supp ort.attrib utes || !d ocumentIsH TML ? | |
| 1466 | elem.g etAttribut e( name ) : | |
| 1467 | (val = elem.getA ttributeNo de(name)) && val.spe cified ? | |
| 1468 | val.valu e : | |
| 1469 | null; | |
| 1470 | }; | |
| 1471 | ||
| 1472 | Sizzle.err or = funct ion( msg ) { | |
| 1473 | th row new Er ror( "Synt ax error, unrecogniz ed express ion: " + m sg ); | |
| 1474 | }; | |
| 1475 | ||
| 1476 | /** | |
| 1477 | * Documen t sorting and removi ng duplica tes | |
| 1478 | * @param {ArrayLike } results | |
| 1479 | */ | |
| 1480 | Sizzle.uni queSort = function( results ) { | |
| 1481 | va r elem, | |
| 1482 | dupl icates = [ ], | |
| 1483 | j = 0, | |
| 1484 | i = 0; | |
| 1485 | ||
| 1486 | // Unless we *know* we can detec t duplicat es, assume their pre sence | |
| 1487 | ha sDuplicate = !suppor t.detectDu plicates; | |
| 1488 | so rtInput = !support.s ortStable && results .slice( 0 ); | |
| 1489 | re sults.sort ( sortOrde r ); | |
| 1490 | ||
| 1491 | if ( hasDupl icate ) { | |
| 1492 | whil e ( (elem = results[ i++]) ) { | |
| 1493 | if ( e lem === re sults[ i ] ) { | |
| 1494 | j = dupl icates.pus h( i ); | |
| 1495 | } | |
| 1496 | } | |
| 1497 | whil e ( j-- ) { | |
| 1498 | result s.splice( duplicates [ j ], 1 ) ; | |
| 1499 | } | |
| 1500 | } | |
| 1501 | ||
| 1502 | // Clear inp ut after s orting to release ob jects | |
| 1503 | // See https ://github. com/jquery /sizzle/pu ll/225 | |
| 1504 | so rtInput = null; | |
| 1505 | ||
| 1506 | re turn resul ts; | |
| 1507 | }; | |
| 1508 | ||
| 1509 | /** | |
| 1510 | * Utility function for retrie ving the t ext value of an arra y of DOM n odes | |
| 1511 | * @param {Array|Ele ment} elem | |
| 1512 | */ | |
| 1513 | getText = Sizzle.get Text = fun ction( ele m ) { | |
| 1514 | va r node, | |
| 1515 | ret = "", | |
| 1516 | i = 0, | |
| 1517 | node Type = ele m.nodeType ; | |
| 1518 | ||
| 1519 | if ( !nodeTy pe ) { | |
| 1520 | // I f no nodeT ype, this is expecte d to be an array | |
| 1521 | whil e ( (node = elem[i++ ]) ) { | |
| 1522 | // Do not traver se comment nodes | |
| 1523 | ret += getText( node ); | |
| 1524 | } | |
| 1525 | } else if ( nodeType = == 1 || no deType === 9 || node Type === 1 1 ) { | |
| 1526 | // U se textCon tent for e lements | |
| 1527 | // i nnerText u sage remov ed for con sistency o f new line s (jQuery #11153) | |
| 1528 | if ( typeof el em.textCon tent === " string" ) { | |
| 1529 | return elem.text Content; | |
| 1530 | } el se { | |
| 1531 | // Tra verse its children | |
| 1532 | for ( elem = ele m.firstChi ld; elem; elem = ele m.nextSibl ing ) { | |
| 1533 | ret += g etText( el em ); | |
| 1534 | } | |
| 1535 | } | |
| 1536 | } else if ( nodeType = == 3 || no deType === 4 ) { | |
| 1537 | retu rn elem.no deValue; | |
| 1538 | } | |
| 1539 | // Do not in clude comm ent or pro cessing in struction nodes | |
| 1540 | ||
| 1541 | re turn ret; | |
| 1542 | }; | |
| 1543 | ||
| 1544 | Expr = Siz zle.select ors = { | |
| 1545 | ||
| 1546 | // Can be ad justed by the user | |
| 1547 | ca cheLength: 50, | |
| 1548 | ||
| 1549 | cr eatePseudo : markFunc tion, | |
| 1550 | ||
| 1551 | ma tch: match Expr, | |
| 1552 | ||
| 1553 | at trHandle: {}, | |
| 1554 | ||
| 1555 | fi nd: {}, | |
| 1556 | ||
| 1557 | re lative: { | |
| 1558 | ">": { dir: "p arentNode" , first: t rue }, | |
| 1559 | " ": { dir: "p arentNode" }, | |
| 1560 | "+": { dir: "p reviousSib ling", fir st: true } , | |
| 1561 | "~": { dir: "p reviousSib ling" } | |
| 1562 | }, | |
| 1563 | ||
| 1564 | pr eFilter: { | |
| 1565 | "ATT R": functi on( match ) { | |
| 1566 | match[ 1] = match [1].replac e( runesca pe, funesc ape ); | |
| 1567 | ||
| 1568 | // Mov e the give n value to match[3] whether qu oted or un quoted | |
| 1569 | match[ 3] = ( mat ch[3] || m atch[4] || match[5] || "" ).re place( run escape, fu nescape ); | |
| 1570 | ||
| 1571 | if ( m atch[2] == = "~=" ) { | |
| 1572 | match[3] = " " + m atch[3] + " "; | |
| 1573 | } | |
| 1574 | ||
| 1575 | return match.sli ce( 0, 4 ) ; | |
| 1576 | }, | |
| 1577 | ||
| 1578 | "CHI LD": funct ion( match ) { | |
| 1579 | /* mat ches from matchExpr[ "CHILD"] | |
| 1580 | 1 type ( only|nth|. ..) | |
| 1581 | 2 what ( child|of-t ype) | |
| 1582 | 3 argume nt (even|o dd|\d*|\d* n([+-]\d+) ?|...) | |
| 1583 | 4 xn-com ponent of xn+y argum ent ([+-]? \d*n|) | |
| 1584 | 5 sign o f xn-compo nent | |
| 1585 | 6 x of x n-componen t | |
| 1586 | 7 sign o f y-compon ent | |
| 1587 | 8 y of y -component | |
| 1588 | */ | |
| 1589 | match[ 1] = match [1].toLowe rCase(); | |
| 1590 | ||
| 1591 | if ( m atch[1].sl ice( 0, 3 ) === "nth " ) { | |
| 1592 | // nth-* requires argument | |
| 1593 | if ( !ma tch[3] ) { | |
| 1594 | Sizzle.err or( match[ 0] ); | |
| 1595 | } | |
| 1596 | ||
| 1597 | // numer ic x and y parameter s for Expr .filter.CH ILD | |
| 1598 | // remem ber that f alse/true cast respe ctively to 0/1 | |
| 1599 | match[4] = +( matc h[4] ? mat ch[5] + (m atch[6] || 1) : 2 * ( match[3] === "even " || match [3] === "o dd" ) ); | |
| 1600 | match[5] = +( ( ma tch[7] + m atch[8] ) || match[3 ] === "odd " ); | |
| 1601 | ||
| 1602 | // oth er types p rohibit ar guments | |
| 1603 | } else if ( matc h[3] ) { | |
| 1604 | Sizzle.e rror( matc h[0] ); | |
| 1605 | } | |
| 1606 | ||
| 1607 | return match; | |
| 1608 | }, | |
| 1609 | ||
| 1610 | "PSE UDO": func tion( matc h ) { | |
| 1611 | var ex cess, | |
| 1612 | unquoted = !match[ 6] && matc h[2]; | |
| 1613 | ||
| 1614 | if ( m atchExpr[" CHILD"].te st( match[ 0] ) ) { | |
| 1615 | return n ull; | |
| 1616 | } | |
| 1617 | ||
| 1618 | // Acc ept quoted arguments as-is | |
| 1619 | if ( m atch[3] ) { | |
| 1620 | match[2] = match[4 ] || match [5] || ""; | |
| 1621 | ||
| 1622 | // Str ip excess characters from unqu oted argum ents | |
| 1623 | } else if ( unqu oted && rp seudo.test ( unquoted ) && | |
| 1624 | // Get e xcess from tokenize (recursive ly) | |
| 1625 | (excess = tokenize ( unquoted , true )) && | |
| 1626 | // advan ce to the next closi ng parenth esis | |
| 1627 | (excess = unquoted .indexOf( ")", unquo ted.length - excess ) - unquot ed.length) ) { | |
| 1628 | ||
| 1629 | // exces s is a neg ative inde x | |
| 1630 | match[0] = match[0 ].slice( 0 , excess ) ; | |
| 1631 | match[2] = unquote d.slice( 0 , excess ) ; | |
| 1632 | } | |
| 1633 | ||
| 1634 | // Ret urn only c aptures ne eded by th e pseudo f ilter meth od (type a nd argumen t) | |
| 1635 | return match.sli ce( 0, 3 ) ; | |
| 1636 | } | |
| 1637 | }, | |
| 1638 | ||
| 1639 | fi lter: { | |
| 1640 | ||
| 1641 | "TAG ": functio n( nodeNam eSelector ) { | |
| 1642 | var no deName = n odeNameSel ector.repl ace( runes cape, fune scape ).to LowerCase( ); | |
| 1643 | return nodeNameS elector == = "*" ? | |
| 1644 | function () { retur n true; } : | |
| 1645 | function ( elem ) { | |
| 1646 | return ele m.nodeName && elem.n odeName.to LowerCase( ) === node Name; | |
| 1647 | }; | |
| 1648 | }, | |
| 1649 | ||
| 1650 | "CLA SS": funct ion( class Name ) { | |
| 1651 | var pa ttern = cl assCache[ className + " " ]; | |
| 1652 | ||
| 1653 | return pattern | | | |
| 1654 | (pattern = new Reg Exp( "(^|" + whitesp ace + ")" + classNam e + "(" + whitespace + "|$)" ) ) && | |
| 1655 | classCac he( classN ame, funct ion( elem ) { | |
| 1656 | return pat tern.test( typeof el em.classNa me === "st ring" && e lem.classN ame || typ eof elem.g etAttribut e !== stru ndefined & & elem.get Attribute( "class") | | "" ); | |
| 1657 | }); | |
| 1658 | }, | |
| 1659 | ||
| 1660 | "ATT R": functi on( name, operator, check ) { | |
| 1661 | return function( elem ) { | |
| 1662 | var resu lt = Sizzl e.attr( el em, name ) ; | |
| 1663 | ||
| 1664 | if ( res ult == nul l ) { | |
| 1665 | return ope rator === "!="; | |
| 1666 | } | |
| 1667 | if ( !op erator ) { | |
| 1668 | return tru e; | |
| 1669 | } | |
| 1670 | ||
| 1671 | result + = ""; | |
| 1672 | ||
| 1673 | return o perator == = "=" ? re sult === c heck : | |
| 1674 | operator = == "!=" ? result !== check : | |
| 1675 | operator = == "^=" ? check && r esult.inde xOf( check ) === 0 : | |
| 1676 | operator = == "*=" ? check && r esult.inde xOf( check ) > -1 : | |
| 1677 | operator = == "$=" ? check && r esult.slic e( -check. length ) = == check : | |
| 1678 | operator = == "~=" ? ( " " + re sult + " " ).indexOf ( check ) > -1 : | |
| 1679 | operator = == "|=" ? result === check || result.sli ce( 0, che ck.length + 1 ) === check + "- " : | |
| 1680 | false; | |
| 1681 | }; | |
| 1682 | }, | |
| 1683 | ||
| 1684 | "CHI LD": funct ion( type, what, arg ument, fir st, last ) { | |
| 1685 | var si mple = typ e.slice( 0 , 3 ) !== "nth", | |
| 1686 | forward = type.sli ce( -4 ) ! == "last", | |
| 1687 | ofType = what === "of-type"; | |
| 1688 | ||
| 1689 | return first === 1 && last === 0 ? | |
| 1690 | ||
| 1691 | // Short cut for :n th-*(n) | |
| 1692 | function ( elem ) { | |
| 1693 | return !!e lem.parent Node; | |
| 1694 | } : | |
| 1695 | ||
| 1696 | function ( elem, co ntext, xml ) { | |
| 1697 | var cache, outerCach e, node, d iff, nodeI ndex, star t, | |
| 1698 | di r = simple !== forwa rd ? "next Sibling" : "previous Sibling", | |
| 1699 | pa rent = ele m.parentNo de, | |
| 1700 | na me = ofTyp e && elem. nodeName.t oLowerCase (), | |
| 1701 | us eCache = ! xml && !of Type; | |
| 1702 | ||
| 1703 | if ( paren t ) { | |
| 1704 | ||
| 1705 | // :(first|l ast|only)- (child|of- type) | |
| 1706 | if ( simple ) { | |
| 1707 | whil e ( dir ) { | |
| 1708 | node = elem; | |
| 1709 | while ( (node = node[ dir ]) ) { | |
| 1710 | if ( ofT ype ? node .nodeName. toLowerCas e() === na me : node. nodeType = == 1 ) { | |
| 1711 | return fal se; | |
| 1712 | } | |
| 1713 | } | |
| 1714 | // Rev erse direc tion for : only-* (if we haven' t yet done so) | |
| 1715 | start = dir = ty pe === "on ly" && !st art && "ne xtSibling" ; | |
| 1716 | } | |
| 1717 | retu rn true; | |
| 1718 | } | |
| 1719 | ||
| 1720 | st art = [ fo rward ? pa rent.first Child : pa rent.lastC hild ]; | |
| 1721 | ||
| 1722 | // non-xml : nth-child( ...) store s cache da ta on `par ent` | |
| 1723 | if ( forward && useCac he ) { | |
| 1724 | // S eek `elem` from a pr eviously-c ached inde x | |
| 1725 | oute rCache = p arent[ exp ando ] || (parent[ e xpando ] = {}); | |
| 1726 | cach e = outerC ache[ type ] || []; | |
| 1727 | node Index = ca che[0] === dirruns & & cache[1] ; | |
| 1728 | diff = cache[0 ] === dirr uns && cac he[2]; | |
| 1729 | node = nodeInd ex && pare nt.childNo des[ nodeI ndex ]; | |
| 1730 | ||
| 1731 | whil e ( (node = ++nodeIn dex && nod e && node[ dir ] || | |
| 1732 | ||
| 1733 | // Fal lback to s eeking `el em` from t he start | |
| 1734 | (diff = nodeInde x = 0) || start.pop( )) ) { | |
| 1735 | ||
| 1736 | // Whe n found, c ache index es on `par ent` and b reak | |
| 1737 | if ( n ode.nodeTy pe === 1 & & ++diff & & node === elem ) { | |
| 1738 | outerCac he[ type ] = [ dirru ns, nodeIn dex, diff ]; | |
| 1739 | break; | |
| 1740 | } | |
| 1741 | } | |
| 1742 | ||
| 1743 | // Use previ ously-cach ed element index if available | |
| 1744 | } else if ( useCache & & (cache = (elem[ ex pando ] || (elem[ ex pando ] = {}))[ type ]) && cac he[0] === dirruns ) { | |
| 1745 | diff = cache[1 ]; | |
| 1746 | ||
| 1747 | // xml :nth- child(...) or :nth-l ast-child( ...) or :n th(-last)? -of-type(. ..) | |
| 1748 | } else { | |
| 1749 | // U se the sam e loop as above to s eek `elem` from the start | |
| 1750 | whil e ( (node = ++nodeIn dex && nod e && node[ dir ] || | |
| 1751 | (diff = nodeInde x = 0) || start.pop( )) ) { | |
| 1752 | ||
| 1753 | if ( ( ofType ? node.nodeN ame.toLowe rCase() == = name : n ode.nodeTy pe === 1 ) && ++diff ) { | |
| 1754 | // Cache the index of each e ncountered element | |
| 1755 | if ( use Cache ) { | |
| 1756 | (node[ exp ando ] || (node[ exp ando ] = { }))[ type ] = [ dirr uns, diff ]; | |
| 1757 | } | |
| 1758 | ||
| 1759 | if ( nod e === elem ) { | |
| 1760 | break; | |
| 1761 | } | |
| 1762 | } | |
| 1763 | } | |
| 1764 | } | |
| 1765 | ||
| 1766 | // Incorpora te the off set, then check agai nst cycle size | |
| 1767 | di ff -= last ; | |
| 1768 | re turn diff === first || ( diff % first == = 0 && dif f / first >= 0 ); | |
| 1769 | } | |
| 1770 | }; | |
| 1771 | }, | |
| 1772 | ||
| 1773 | "PSE UDO": func tion( pseu do, argume nt ) { | |
| 1774 | // pse udo-class names are case-insen sitive | |
| 1775 | // htt p://www.w3 .org/TR/se lectors/#p seudo-clas ses | |
| 1776 | // Pri oritize by case sens itivity in case cust om pseudos are added with uppe rcase lett ers | |
| 1777 | // Rem ember that setFilter s inherits from pseu dos | |
| 1778 | var ar gs, | |
| 1779 | fn = Exp r.pseudos[ pseudo ] || Expr.se tFilters[ pseudo.toL owerCase() ] || | |
| 1780 | Sizzle.err or( "unsup ported pse udo: " + p seudo ); | |
| 1781 | ||
| 1782 | // The user may use create Pseudo to indicate t hat | |
| 1783 | // arg uments are needed to create th e filter f unction | |
| 1784 | // jus t as Sizzl e does | |
| 1785 | if ( f n[ expando ] ) { | |
| 1786 | return f n( argumen t ); | |
| 1787 | } | |
| 1788 | ||
| 1789 | // But maintain support fo r old sign atures | |
| 1790 | if ( f n.length > 1 ) { | |
| 1791 | args = [ pseudo, p seudo, "", argument ]; | |
| 1792 | return E xpr.setFil ters.hasOw nProperty( pseudo.to LowerCase( ) ) ? | |
| 1793 | markFuncti on(functio n( seed, m atches ) { | |
| 1794 | va r idx, | |
| 1795 | matc hed = fn( seed, argu ment ), | |
| 1796 | i = matched.le ngth; | |
| 1797 | wh ile ( i-- ) { | |
| 1798 | idx = indexOf. call( seed , matched[ i] ); | |
| 1799 | seed [ idx ] = !( matches [ idx ] = matched[i] ); | |
| 1800 | } | |
| 1801 | }) : | |
| 1802 | function( elem ) { | |
| 1803 | re turn fn( e lem, 0, ar gs ); | |
| 1804 | }; | |
| 1805 | } | |
| 1806 | ||
| 1807 | return fn; | |
| 1808 | } | |
| 1809 | }, | |
| 1810 | ||
| 1811 | ps eudos: { | |
| 1812 | // P otentially complex p seudos | |
| 1813 | "not ": markFun ction(func tion( sele ctor ) { | |
| 1814 | // Tri m the sele ctor passe d to compi le | |
| 1815 | // to avoid trea ting leadi ng and tra iling | |
| 1816 | // spa ces as com binators | |
| 1817 | var in put = [], | |
| 1818 | results = [], | |
| 1819 | matcher = compile( selector. replace( r trim, "$1" ) ); | |
| 1820 | ||
| 1821 | return matcher[ expando ] ? | |
| 1822 | markFunc tion(funct ion( seed, matches, context, x ml ) { | |
| 1823 | var elem, | |
| 1824 | un matched = matcher( s eed, null, xml, [] ) , | |
| 1825 | i = seed.len gth; | |
| 1826 | ||
| 1827 | // Match e lements un matched by `matcher` | |
| 1828 | while ( i- - ) { | |
| 1829 | if ( (elem = unmatched [i]) ) { | |
| 1830 | seed [i] = !(ma tches[i] = elem); | |
| 1831 | } | |
| 1832 | } | |
| 1833 | }) : | |
| 1834 | function ( elem, co ntext, xml ) { | |
| 1835 | input[0] = elem; | |
| 1836 | matcher( i nput, null , xml, res ults ); | |
| 1837 | return !re sults.pop( ); | |
| 1838 | }; | |
| 1839 | }), | |
| 1840 | ||
| 1841 | "has ": markFun ction(func tion( sele ctor ) { | |
| 1842 | return function( elem ) { | |
| 1843 | return S izzle( sel ector, ele m ).length > 0; | |
| 1844 | }; | |
| 1845 | }), | |
| 1846 | ||
| 1847 | "con tains": ma rkFunction (function( text ) { | |
| 1848 | return function( elem ) { | |
| 1849 | return ( elem.text Content || elem.inne rText || g etText( el em ) ).ind exOf( text ) > -1; | |
| 1850 | }; | |
| 1851 | }), | |
| 1852 | ||
| 1853 | // " Whether an element i s represen ted by a : lang() sel ector | |
| 1854 | // i s based so lely on th e element' s language value | |
| 1855 | // b eing equal to the id entifier C , | |
| 1856 | // o r beginnin g with the identifie r C immedi ately foll owed by "- ". | |
| 1857 | // T he matchin g of C aga inst the e lement's l anguage va lue is per formed cas e-insensit ively. | |
| 1858 | // T he identif ier C does not have to be a va lid langua ge name." | |
| 1859 | // h ttp://www. w3.org/TR/ selectors/ #lang-pseu do | |
| 1860 | "lan g": markFu nction( fu nction( la ng ) { | |
| 1861 | // lan g value mu st be a va lid identi fier | |
| 1862 | if ( ! ridentifie r.test(lan g || "") ) { | |
| 1863 | Sizzle.e rror( "uns upported l ang: " + l ang ); | |
| 1864 | } | |
| 1865 | lang = lang.repl ace( runes cape, fune scape ).to LowerCase( ); | |
| 1866 | return function( elem ) { | |
| 1867 | var elem Lang; | |
| 1868 | do { | |
| 1869 | if ( (elem Lang = doc umentIsHTM L ? | |
| 1870 | el em.lang : | |
| 1871 | el em.getAttr ibute("xml :lang") || elem.getA ttribute(" lang")) ) { | |
| 1872 | ||
| 1873 | el emLang = e lemLang.to LowerCase( ); | |
| 1874 | re turn elemL ang === la ng || elem Lang.index Of( lang + "-" ) === 0; | |
| 1875 | } | |
| 1876 | } while ( (elem = elem.paren tNode) && elem.nodeT ype === 1 ); | |
| 1877 | return f alse; | |
| 1878 | }; | |
| 1879 | }), | |
| 1880 | ||
| 1881 | // M iscellaneo us | |
| 1882 | "tar get": func tion( elem ) { | |
| 1883 | var ha sh = windo w.location && window .location. hash; | |
| 1884 | return hash && h ash.slice( 1 ) === e lem.id; | |
| 1885 | }, | |
| 1886 | ||
| 1887 | "roo t": functi on( elem ) { | |
| 1888 | return elem === docElem; | |
| 1889 | }, | |
| 1890 | ||
| 1891 | "foc us": funct ion( elem ) { | |
| 1892 | return elem === document.a ctiveEleme nt && (!do cument.has Focus || d ocument.ha sFocus()) && !!(elem .type || e lem.href | | ~elem.ta bIndex); | |
| 1893 | }, | |
| 1894 | ||
| 1895 | // B oolean pro perties | |
| 1896 | "ena bled": fun ction( ele m ) { | |
| 1897 | return elem.disa bled === f alse; | |
| 1898 | }, | |
| 1899 | ||
| 1900 | "dis abled": fu nction( el em ) { | |
| 1901 | return elem.disa bled === t rue; | |
| 1902 | }, | |
| 1903 | ||
| 1904 | "che cked": fun ction( ele m ) { | |
| 1905 | // In CSS3, :che cked shoul d return b oth checke d and sele cted eleme nts | |
| 1906 | // htt p://www.w3 .org/TR/20 11/REC-css 3-selector s-20110929 /#checked | |
| 1907 | var no deName = e lem.nodeNa me.toLower Case(); | |
| 1908 | return (nodeName === "inpu t" && !!el em.checked ) || (node Name === " option" && !!elem.se lected); | |
| 1909 | }, | |
| 1910 | ||
| 1911 | "sel ected": fu nction( el em ) { | |
| 1912 | // Acc essing thi s property makes sel ected-by-d efault | |
| 1913 | // opt ions in Sa fari work properly | |
| 1914 | if ( e lem.parent Node ) { | |
| 1915 | elem.par entNode.se lectedInde x; | |
| 1916 | } | |
| 1917 | ||
| 1918 | return elem.sele cted === t rue; | |
| 1919 | }, | |
| 1920 | ||
| 1921 | // C ontents | |
| 1922 | "emp ty": funct ion( elem ) { | |
| 1923 | // htt p://www.w3 .org/TR/se lectors/#e mpty-pseud o | |
| 1924 | // :em pty is neg ated by el ement (1) or content nodes (te xt: 3; cda ta: 4; ent ity ref: 5 ), | |
| 1925 | // b ut not by others (co mment: 8; processing instructi on: 7; etc .) | |
| 1926 | // nod eType < 6 works beca use attrib utes (2) d o not appe ar as chil dren | |
| 1927 | for ( elem = ele m.firstChi ld; elem; elem = ele m.nextSibl ing ) { | |
| 1928 | if ( ele m.nodeType < 6 ) { | |
| 1929 | return fal se; | |
| 1930 | } | |
| 1931 | } | |
| 1932 | return true; | |
| 1933 | }, | |
| 1934 | ||
| 1935 | "par ent": func tion( elem ) { | |
| 1936 | return !Expr.pse udos["empt y"]( elem ); | |
| 1937 | }, | |
| 1938 | ||
| 1939 | // E lement/inp ut types | |
| 1940 | "hea der": func tion( elem ) { | |
| 1941 | return rheader.t est( elem. nodeName ) ; | |
| 1942 | }, | |
| 1943 | ||
| 1944 | "inp ut": funct ion( elem ) { | |
| 1945 | return rinputs.t est( elem. nodeName ) ; | |
| 1946 | }, | |
| 1947 | ||
| 1948 | "but ton": func tion( elem ) { | |
| 1949 | var na me = elem. nodeName.t oLowerCase (); | |
| 1950 | return name === "input" && elem.type === "butt on" || nam e === "but ton"; | |
| 1951 | }, | |
| 1952 | ||
| 1953 | "tex t": functi on( elem ) { | |
| 1954 | var at tr; | |
| 1955 | return elem.node Name.toLow erCase() = == "input" && | |
| 1956 | elem.typ e === "tex t" && | |
| 1957 | ||
| 1958 | // Suppo rt: IE<8 | |
| 1959 | // New H TML5 attri bute value s (e.g., " search") a ppear with elem.type === "text " | |
| 1960 | ( (attr = elem.get Attribute( "type")) = = null || attr.toLow erCase() = == "text" ); | |
| 1961 | }, | |
| 1962 | ||
| 1963 | // P osition-in -collectio n | |
| 1964 | "fir st": creat ePositiona lPseudo(fu nction() { | |
| 1965 | return [ 0 ]; | |
| 1966 | }), | |
| 1967 | ||
| 1968 | "las t": create Positional Pseudo(fun ction( mat chIndexes, length ) { | |
| 1969 | return [ length - 1 ]; | |
| 1970 | }), | |
| 1971 | ||
| 1972 | "eq" : createPo sitionalPs eudo(funct ion( match Indexes, l ength, arg ument ) { | |
| 1973 | return [ argumen t < 0 ? ar gument + l ength : ar gument ]; | |
| 1974 | }), | |
| 1975 | ||
| 1976 | "eve n": create Positional Pseudo(fun ction( mat chIndexes, length ) { | |
| 1977 | var i = 0; | |
| 1978 | for ( ; i < leng th; i += 2 ) { | |
| 1979 | matchInd exes.push( i ); | |
| 1980 | } | |
| 1981 | return matchInde xes; | |
| 1982 | }), | |
| 1983 | ||
| 1984 | "odd ": createP ositionalP seudo(func tion( matc hIndexes, length ) { | |
| 1985 | var i = 1; | |
| 1986 | for ( ; i < leng th; i += 2 ) { | |
| 1987 | matchInd exes.push( i ); | |
| 1988 | } | |
| 1989 | return matchInde xes; | |
| 1990 | }), | |
| 1991 | ||
| 1992 | "lt" : createPo sitionalPs eudo(funct ion( match Indexes, l ength, arg ument ) { | |
| 1993 | var i = argument < 0 ? arg ument + le ngth : arg ument; | |
| 1994 | for ( ; --i >= 0 ; ) { | |
| 1995 | matchInd exes.push( i ); | |
| 1996 | } | |
| 1997 | return matchInde xes; | |
| 1998 | }), | |
| 1999 | ||
| 2000 | "gt" : createPo sitionalPs eudo(funct ion( match Indexes, l ength, arg ument ) { | |
| 2001 | var i = argument < 0 ? arg ument + le ngth : arg ument; | |
| 2002 | for ( ; ++i < le ngth; ) { | |
| 2003 | matchInd exes.push( i ); | |
| 2004 | } | |
| 2005 | return matchInde xes; | |
| 2006 | }) | |
| 2007 | } | |
| 2008 | }; | |
| 2009 | ||
| 2010 | Expr.pseud os["nth"] = Expr.pse udos["eq"] ; | |
| 2011 | ||
| 2012 | // Add but ton/input type pseud os | |
| 2013 | for ( i in { radio: true, chec kbox: true , file: tr ue, V s ID image: tru e } ) { | |
| 2014 | Ex pr.pseudos [ i ] = cr eateInputP seudo( i ) ; | |
| 2015 | } | |
| 2016 | for ( i in { submit: true, res et: true } ) { | |
| 2017 | Ex pr.pseudos [ i ] = cr eateButton Pseudo( i ); | |
| 2018 | } | |
| 2019 | ||
| 2020 | // Easy AP I for crea ting new s etFilters | |
| 2021 | function s etFilters( ) {} | |
| 2022 | setFilters .prototype = Expr.fi lters = Ex pr.pseudos ; | |
| 2023 | Expr.setFi lters = ne w setFilte rs(); | |
| 2024 | ||
| 2025 | tokenize = Sizzle.to kenize = f unction( s elector, p arseOnly ) { | |
| 2026 | va r matched, match, to kens, type , | |
| 2027 | soFa r, groups, preFilter s, | |
| 2028 | cach ed = token Cache[ sel ector + " " ]; | |
| 2029 | ||
| 2030 | if ( cached ) { | |
| 2031 | retu rn parseOn ly ? 0 : c ached.slic e( 0 ); | |
| 2032 | } | |
| 2033 | ||
| 2034 | so Far = sele ctor; | |
| 2035 | gr oups = []; | |
| 2036 | pr eFilters = Expr.preF ilter; | |
| 2037 | ||
| 2038 | wh ile ( soFa r ) { | |
| 2039 | ||
| 2040 | // C omma and f irst run | |
| 2041 | if ( !matched || (match = rcomma.e xec( soFar )) ) { | |
| 2042 | if ( m atch ) { | |
| 2043 | // Don't consume t railing co mmas as va lid | |
| 2044 | soFar = soFar.slic e( match[0 ].length ) || soFar; | |
| 2045 | } | |
| 2046 | groups .push( (to kens = []) ); | |
| 2047 | } | |
| 2048 | ||
| 2049 | matc hed = fals e; | |
| 2050 | ||
| 2051 | // C ombinators | |
| 2052 | if ( (match = rcombinato rs.exec( s oFar )) ) { | |
| 2053 | matche d = match. shift(); | |
| 2054 | tokens .push({ | |
| 2055 | value: m atched, | |
| 2056 | // Cast descendant combinato rs to spac e | |
| 2057 | type: ma tch[0].rep lace( rtri m, " " ) | |
| 2058 | }); | |
| 2059 | soFar = soFar.sl ice( match ed.length ); | |
| 2060 | } | |
| 2061 | ||
| 2062 | // F ilters | |
| 2063 | for ( type in Expr.filte r ) { | |
| 2064 | if ( ( match = ma tchExpr[ t ype ].exec ( soFar )) && (!preF ilters[ ty pe ] || | |
| 2065 | (match = preFilter s[ type ]( match ))) ) { | |
| 2066 | matched = match.sh ift(); | |
| 2067 | tokens.p ush({ | |
| 2068 | value: mat ched, | |
| 2069 | type: type , | |
| 2070 | matches: m atch | |
| 2071 | }); | |
| 2072 | soFar = soFar.slic e( matched .length ); | |
| 2073 | } | |
| 2074 | } | |
| 2075 | ||
| 2076 | if ( !matched ) { | |
| 2077 | break; | |
| 2078 | } | |
| 2079 | } | |
| 2080 | ||
| 2081 | // Return th e length o f the inva lid excess | |
| 2082 | // if we're just parsi ng | |
| 2083 | // Otherwise , throw an error or return tok ens | |
| 2084 | re turn parse Only ? | |
| 2085 | soFa r.length : | |
| 2086 | soFa r ? | |
| 2087 | Sizzle .error( se lector ) : | |
| 2088 | // Cac he the tok ens | |
| 2089 | tokenC ache( sele ctor, grou ps ).slice ( 0 ); | |
| 2090 | }; | |
| 2091 | ||
| 2092 | function t oSelector( tokens ) { | |
| 2093 | va r i = 0, | |
| 2094 | len = tokens.l ength, | |
| 2095 | sele ctor = ""; | |
| 2096 | fo r ( ; i < len; i++ ) { | |
| 2097 | sele ctor += to kens[i].va lue; | |
| 2098 | } | |
| 2099 | re turn selec tor; | |
| 2100 | } | |
| 2101 | ||
| 2102 | function a ddCombinat or( matche r, combina tor, base ) { | |
| 2103 | va r dir = co mbinator.d ir, | |
| 2104 | chec kNonElemen ts = base && dir === "parentNo de", | |
| 2105 | done Name = don e++; | |
| 2106 | ||
| 2107 | re turn combi nator.firs t ? | |
| 2108 | // C heck again st closest ancestor/ preceding element | |
| 2109 | func tion( elem , context, xml ) { | |
| 2110 | while ( (elem = elem[ dir ]) ) { | |
| 2111 | if ( ele m.nodeType === 1 || checkNonEl ements ) { | |
| 2112 | return mat cher( elem , context, xml ); | |
| 2113 | } | |
| 2114 | } | |
| 2115 | } : | |
| 2116 | ||
| 2117 | // C heck again st all anc estor/prec eding elem ents | |
| 2118 | func tion( elem , context, xml ) { | |
| 2119 | var ol dCache, ou terCache, | |
| 2120 | newCache = [ dirru ns, doneNa me ]; | |
| 2121 | ||
| 2122 | // We can't set arbitrary data on XM L nodes, s o they don 't benefit from dir caching | |
| 2123 | if ( x ml ) { | |
| 2124 | while ( (elem = el em[ dir ]) ) { | |
| 2125 | if ( elem. nodeType = == 1 || ch eckNonElem ents ) { | |
| 2126 | if ( matcher ( elem, co ntext, xml ) ) { | |
| 2127 | retu rn true; | |
| 2128 | } | |
| 2129 | } | |
| 2130 | } | |
| 2131 | } else { | |
| 2132 | while ( (elem = el em[ dir ]) ) { | |
| 2133 | if ( elem. nodeType = == 1 || ch eckNonElem ents ) { | |
| 2134 | ou terCache = elem[ exp ando ] || (elem[ exp ando ] = { }); | |
| 2135 | if ( (oldCac he = outer Cache[ dir ]) && | |
| 2136 | oldC ache[ 0 ] === dirrun s && oldCa che[ 1 ] = == doneNam e ) { | |
| 2137 | ||
| 2138 | // A ssign to n ewCache so results b ack-propag ate to pre vious elem ents | |
| 2139 | retu rn (newCac he[ 2 ] = oldCache[ 2 ]); | |
| 2140 | } else { | |
| 2141 | // R euse newca che so res ults back- propagate to previou s elements | |
| 2142 | oute rCache[ di r ] = newC ache; | |
| 2143 | ||
| 2144 | // A match mea ns we're d one; a fai l means we have to k eep checki ng | |
| 2145 | if ( (newCache [ 2 ] = ma tcher( ele m, context , xml )) ) { | |
| 2146 | return true; | |
| 2147 | } | |
| 2148 | } | |
| 2149 | } | |
| 2150 | } | |
| 2151 | } | |
| 2152 | }; | |
| 2153 | } | |
| 2154 | ||
| 2155 | function e lementMatc her( match ers ) { | |
| 2156 | re turn match ers.length > 1 ? | |
| 2157 | func tion( elem , context, xml ) { | |
| 2158 | var i = matchers .length; | |
| 2159 | while ( i-- ) { | |
| 2160 | if ( !ma tchers[i]( elem, con text, xml ) ) { | |
| 2161 | return fal se; | |
| 2162 | } | |
| 2163 | } | |
| 2164 | return true; | |
| 2165 | } : | |
| 2166 | matc hers[0]; | |
| 2167 | } | |
| 2168 | ||
| 2169 | function m ultipleCon texts( sel ector, con texts, res ults ) { | |
| 2170 | va r i = 0, | |
| 2171 | len = contexts .length; | |
| 2172 | fo r ( ; i < len; i++ ) { | |
| 2173 | Sizz le( select or, contex ts[i], res ults ); | |
| 2174 | } | |
| 2175 | re turn resul ts; | |
| 2176 | } | |
| 2177 | ||
| 2178 | function c ondense( u nmatched, map, filte r, context , xml ) { | |
| 2179 | va r elem, | |
| 2180 | newU nmatched = [], | |
| 2181 | i = 0, | |
| 2182 | len = unmatche d.length, | |
| 2183 | mapp ed = map ! = null; | |
| 2184 | ||
| 2185 | fo r ( ; i < len; i++ ) { | |
| 2186 | if ( (elem = u nmatched[i ]) ) { | |
| 2187 | if ( ! filter || filter( el em, contex t, xml ) ) { | |
| 2188 | newUnmat ched.push( elem ); | |
| 2189 | if ( map ped ) { | |
| 2190 | map.push( i ); | |
| 2191 | } | |
| 2192 | } | |
| 2193 | } | |
| 2194 | } | |
| 2195 | ||
| 2196 | re turn newUn matched; | |
| 2197 | } | |
| 2198 | ||
| 2199 | function s etMatcher( preFilter , selector , matcher, postFilte r, postFin der, postS elector ) { | |
| 2200 | if ( postFil ter && !po stFilter[ expando ] ) { | |
| 2201 | post Filter = s etMatcher( postFilte r ); | |
| 2202 | } | |
| 2203 | if ( postFin der && !po stFinder[ expando ] ) { | |
| 2204 | post Finder = s etMatcher( postFinde r, postSel ector ); | |
| 2205 | } | |
| 2206 | re turn markF unction(fu nction( se ed, result s, context , xml ) { | |
| 2207 | var temp, i, e lem, | |
| 2208 | preMap = [], | |
| 2209 | postMa p = [], | |
| 2210 | preexi sting = re sults.leng th, | |
| 2211 | ||
| 2212 | // Get initial e lements fr om seed or context | |
| 2213 | elems = seed || multipleCo ntexts( se lector || "*", conte xt.nodeTyp e ? [ cont ext ] : co ntext, [] ), | |
| 2214 | ||
| 2215 | // Pre filter to get matche r input, p reserving a map for seed-resul ts synchro nization | |
| 2216 | matche rIn = preF ilter && ( seed || ! selector ) ? | |
| 2217 | condense ( elems, p reMap, pre Filter, co ntext, xml ) : | |
| 2218 | elems, | |
| 2219 | ||
| 2220 | matche rOut = mat cher ? | |
| 2221 | // If we have a po stFinder, or filtere d seed, or non-seed postFilter or preexi sting resu lts, | |
| 2222 | postFind er || ( se ed ? preFi lter : pre existing | | postFilt er ) ? | |
| 2223 | ||
| 2224 | // ...inte rmediate p rocessing is necessa ry | |
| 2225 | [] : | |
| 2226 | ||
| 2227 | // ...othe rwise use results di rectly | |
| 2228 | results : | |
| 2229 | matcherI n; | |
| 2230 | ||
| 2231 | // F ind primar y matches | |
| 2232 | if ( matcher ) { | |
| 2233 | matche r( matcher In, matche rOut, cont ext, xml ) ; | |
| 2234 | } | |
| 2235 | ||
| 2236 | // A pply postF ilter | |
| 2237 | if ( postFilte r ) { | |
| 2238 | temp = condense( matcherOu t, postMap ); | |
| 2239 | postFi lter( temp , [], cont ext, xml ) ; | |
| 2240 | ||
| 2241 | // Un- match fail ing elemen ts by movi ng them ba ck to matc herIn | |
| 2242 | i = te mp.length; | |
| 2243 | while ( i-- ) { | |
| 2244 | if ( (el em = temp[ i]) ) { | |
| 2245 | matcherOut [ postMap[ i] ] = !(m atcherIn[ postMap[i] ] = elem) ; | |
| 2246 | } | |
| 2247 | } | |
| 2248 | } | |
| 2249 | ||
| 2250 | if ( seed ) { | |
| 2251 | if ( p ostFinder || preFilt er ) { | |
| 2252 | if ( pos tFinder ) { | |
| 2253 | // Get the final mat cherOut by condensin g this int ermediate into postF inder cont exts | |
| 2254 | temp = []; | |
| 2255 | i = matche rOut.lengt h; | |
| 2256 | while ( i- - ) { | |
| 2257 | if ( (elem = matcherOu t[i]) ) { | |
| 2258 | // R estore mat cherIn sin ce elem is not yet a final mat ch | |
| 2259 | temp .push( (ma tcherIn[i] = elem) ) ; | |
| 2260 | } | |
| 2261 | } | |
| 2262 | postFinder ( null, (m atcherOut = []), tem p, xml ); | |
| 2263 | } | |
| 2264 | ||
| 2265 | // Move matched el ements fro m seed to results to keep them synchroni zed | |
| 2266 | i = matc herOut.len gth; | |
| 2267 | while ( i-- ) { | |
| 2268 | if ( (elem = matcher Out[i]) && | |
| 2269 | (t emp = post Finder ? i ndexOf.cal l( seed, e lem ) : pr eMap[i]) > -1 ) { | |
| 2270 | ||
| 2271 | se ed[temp] = !(results [temp] = e lem); | |
| 2272 | } | |
| 2273 | } | |
| 2274 | } | |
| 2275 | ||
| 2276 | // A dd element s to resul ts, throug h postFind er if defi ned | |
| 2277 | } el se { | |
| 2278 | matche rOut = con dense( | |
| 2279 | matcherO ut === res ults ? | |
| 2280 | matcherOut .splice( p reexisting , matcherO ut.length ) : | |
| 2281 | matcherOut | |
| 2282 | ); | |
| 2283 | if ( p ostFinder ) { | |
| 2284 | postFind er( null, results, m atcherOut, xml ); | |
| 2285 | } else { | |
| 2286 | push.app ly( result s, matcher Out ); | |
| 2287 | } | |
| 2288 | } | |
| 2289 | }) ; | |
| 2290 | } | |
| 2291 | ||
| 2292 | function m atcherFrom Tokens( to kens ) { | |
| 2293 | va r checkCon text, matc her, j, | |
| 2294 | len = tokens.l ength, | |
| 2295 | lead ingRelativ e = Expr.r elative[ t okens[0].t ype ], | |
| 2296 | impl icitRelati ve = leadi ngRelative || Expr.r elative[" "], | |
| 2297 | i = leadingRel ative ? 1 : 0, | |
| 2298 | ||
| 2299 | // T he foundat ional matc her ensure s that ele ments are reachable from top-l evel conte xt(s) | |
| 2300 | matc hContext = addCombin ator( func tion( elem ) { | |
| 2301 | return elem === checkConte xt; | |
| 2302 | }, i mplicitRel ative, tru e ), | |
| 2303 | matc hAnyContex t = addCom binator( f unction( e lem ) { | |
| 2304 | return indexOf.c all( check Context, e lem ) > -1 ; | |
| 2305 | }, i mplicitRel ative, tru e ), | |
| 2306 | matc hers = [ f unction( e lem, conte xt, xml ) { | |
| 2307 | return ( !leadin gRelative && ( xml | | context !== outerm ostContext ) ) || ( | |
| 2308 | (checkCo ntext = co ntext).nod eType ? | |
| 2309 | matchConte xt( elem, context, x ml ) : | |
| 2310 | matchAnyCo ntext( ele m, context , xml ) ); | |
| 2311 | } ]; | |
| 2312 | ||
| 2313 | fo r ( ; i < len; i++ ) { | |
| 2314 | if ( (matcher = Expr.rel ative[ tok ens[i].typ e ]) ) { | |
| 2315 | matche rs = [ add Combinator (elementMa tcher( mat chers ), m atcher) ]; | |
| 2316 | } el se { | |
| 2317 | matche r = Expr.f ilter[ tok ens[i].typ e ].apply( null, tok ens[i].mat ches ); | |
| 2318 | ||
| 2319 | // Ret urn specia l upon see ing a posi tional mat cher | |
| 2320 | if ( m atcher[ ex pando ] ) { | |
| 2321 | // Find the next r elative op erator (if any) for proper han dling | |
| 2322 | j = ++i; | |
| 2323 | for ( ; j < len; j ++ ) { | |
| 2324 | if ( Expr. relative[ tokens[j]. type ] ) { | |
| 2325 | br eak; | |
| 2326 | } | |
| 2327 | } | |
| 2328 | return s etMatcher( | |
| 2329 | i > 1 && e lementMatc her( match ers ), | |
| 2330 | i > 1 && t oSelector( | |
| 2331 | // If the pr eceding to ken was a descendant combinato r, insert an implici t any-elem ent `*` | |
| 2332 | to kens.slice ( 0, i - 1 ).concat( { value: t okens[ i - 2 ].type === " " ? "*" : "" } ) | |
| 2333 | ).replace( rtrim, "$ 1" ), | |
| 2334 | matcher, | |
| 2335 | i < j && m atcherFrom Tokens( to kens.slice ( i, j ) ) , | |
| 2336 | j < len && matcherFr omTokens( (tokens = tokens.sli ce( j )) ) , | |
| 2337 | j < len && toSelecto r( tokens ) | |
| 2338 | ); | |
| 2339 | } | |
| 2340 | matche rs.push( m atcher ); | |
| 2341 | } | |
| 2342 | } | |
| 2343 | ||
| 2344 | re turn eleme ntMatcher( matchers ); | |
| 2345 | } | |
| 2346 | ||
| 2347 | function m atcherFrom GroupMatch ers( eleme ntMatchers , setMatch ers ) { | |
| 2348 | va r bySet = setMatcher s.length > 0, | |
| 2349 | byEl ement = el ementMatch ers.length > 0, | |
| 2350 | supe rMatcher = function( seed, con text, xml, results, outermost ) { | |
| 2351 | var el em, j, mat cher, | |
| 2352 | matchedC ount = 0, | |
| 2353 | i = "0", | |
| 2354 | unmatche d = seed & & [], | |
| 2355 | setMatch ed = [], | |
| 2356 | contextB ackup = ou termostCon text, | |
| 2357 | // We mu st always have eithe r seed ele ments or o utermost c ontext | |
| 2358 | elems = seed || by Element && Expr.find ["TAG"]( " *", outerm ost ), | |
| 2359 | // Use i nteger dir runs iff t his is the outermost matcher | |
| 2360 | dirrunsU nique = (d irruns += contextBac kup == nul l ? 1 : Ma th.random( ) || 0.1), | |
| 2361 | len = el ems.length ; | |
| 2362 | ||
| 2363 | if ( o utermost ) { | |
| 2364 | outermos tContext = context ! == documen t && conte xt; | |
| 2365 | } | |
| 2366 | ||
| 2367 | // Add elements passing el ementMatch ers direct ly to resu lts | |
| 2368 | // Kee p `i` a st ring if th ere are no elements so `matche dCount` wi ll be "00" below | |
| 2369 | // Sup port: IE<9 , Safari | |
| 2370 | // Tol erate Node List prope rties (IE: "length"; Safari: < number>) m atching el ements by id | |
| 2371 | for ( ; i !== le n && (elem = elems[i ]) != null ; i++ ) { | |
| 2372 | if ( byE lement && elem ) { | |
| 2373 | j = 0; | |
| 2374 | while ( (m atcher = e lementMatc hers[j++]) ) { | |
| 2375 | if ( matcher ( elem, co ntext, xml ) ) { | |
| 2376 | resu lts.push( elem ); | |
| 2377 | brea k; | |
| 2378 | } | |
| 2379 | } | |
| 2380 | if ( outer most ) { | |
| 2381 | di rruns = di rrunsUniqu e; | |
| 2382 | } | |
| 2383 | } | |
| 2384 | ||
| 2385 | // Track unmatched elements for set fi lters | |
| 2386 | if ( byS et ) { | |
| 2387 | // They wi ll have go ne through all possi ble matche rs | |
| 2388 | if ( (elem = !matche r && elem) ) { | |
| 2389 | ma tchedCount --; | |
| 2390 | } | |
| 2391 | ||
| 2392 | // Lengthe n the arra y for ever y element, matched o r not | |
| 2393 | if ( seed ) { | |
| 2394 | un matched.pu sh( elem ) ; | |
| 2395 | } | |
| 2396 | } | |
| 2397 | } | |
| 2398 | ||
| 2399 | // App ly set fil ters to un matched el ements | |
| 2400 | matche dCount += i; | |
| 2401 | if ( b ySet && i !== matche dCount ) { | |
| 2402 | j = 0; | |
| 2403 | while ( (matcher = setMatche rs[j++]) ) { | |
| 2404 | matcher( u nmatched, setMatched , context, xml ); | |
| 2405 | } | |
| 2406 | ||
| 2407 | if ( see d ) { | |
| 2408 | // Reinteg rate eleme nt matches to elimin ate the ne ed for sor ting | |
| 2409 | if ( match edCount > 0 ) { | |
| 2410 | wh ile ( i-- ) { | |
| 2411 | if ( !(unmatch ed[i] || s etMatched[ i]) ) { | |
| 2412 | setMat ched[i] = pop.call( results ); | |
| 2413 | } | |
| 2414 | } | |
| 2415 | } | |
| 2416 | ||
| 2417 | // Discard index pla ceholder v alues to g et only ac tual match es | |
| 2418 | setMatched = condens e( setMatc hed ); | |
| 2419 | } | |
| 2420 | ||
| 2421 | // Add m atches to results | |
| 2422 | push.app ly( result s, setMatc hed ); | |
| 2423 | ||
| 2424 | // Seedl ess set ma tches succ eeding mul tiple succ essful mat chers stip ulate sort ing | |
| 2425 | if ( out ermost && !seed && s etMatched. length > 0 && | |
| 2426 | ( matchedC ount + set Matchers.l ength ) > 1 ) { | |
| 2427 | ||
| 2428 | Sizzle.uni queSort( r esults ); | |
| 2429 | } | |
| 2430 | } | |
| 2431 | ||
| 2432 | // Ove rride mani pulation o f globals by nested matchers | |
| 2433 | if ( o utermost ) { | |
| 2434 | dirruns = dirrunsU nique; | |
| 2435 | outermos tContext = contextBa ckup; | |
| 2436 | } | |
| 2437 | ||
| 2438 | return unmatched ; | |
| 2439 | }; | |
| 2440 | ||
| 2441 | re turn bySet ? | |
| 2442 | mark Function( superMatch er ) : | |
| 2443 | supe rMatcher; | |
| 2444 | } | |
| 2445 | ||
| 2446 | compile = Sizzle.com pile = fun ction( sel ector, mat ch /* Inte rnal Use O nly */ ) { | |
| 2447 | va r i, | |
| 2448 | setM atchers = [], | |
| 2449 | elem entMatcher s = [], | |
| 2450 | cach ed = compi lerCache[ selector + " " ]; | |
| 2451 | ||
| 2452 | if ( !cached ) { | |
| 2453 | // G enerate a function o f recursiv e function s that can be used t o check ea ch element | |
| 2454 | if ( !match ) { | |
| 2455 | match = tokenize ( selector ); | |
| 2456 | } | |
| 2457 | i = match.leng th; | |
| 2458 | whil e ( i-- ) { | |
| 2459 | cached = matcher FromTokens ( match[i] ); | |
| 2460 | if ( c ached[ exp ando ] ) { | |
| 2461 | setMatch ers.push( cached ); | |
| 2462 | } else { | |
| 2463 | elementM atchers.pu sh( cached ); | |
| 2464 | } | |
| 2465 | } | |
| 2466 | ||
| 2467 | // C ache the c ompiled fu nction | |
| 2468 | cach ed = compi lerCache( selector, matcherFro mGroupMatc hers( elem entMatcher s, setMatc hers ) ); | |
| 2469 | ||
| 2470 | // S ave select or and tok enization | |
| 2471 | cach ed.selecto r = select or; | |
| 2472 | } | |
| 2473 | re turn cache d; | |
| 2474 | }; | |
| 2475 | ||
| 2476 | /** | |
| 2477 | * A low-l evel selec tion funct ion that w orks with Sizzle's c ompiled | |
| 2478 | * select or functio ns | |
| 2479 | * @param {String|Fu nction} se lector A s elector or a pre-com piled | |
| 2480 | * select or functio n built wi th Sizzle. compile | |
| 2481 | * @param {Element} context | |
| 2482 | * @param {Array} [r esults] | |
| 2483 | * @param {Array} [s eed] A set of elemen ts to matc h against | |
| 2484 | */ | |
| 2485 | select = S izzle.sele ct = funct ion( selec tor, conte xt, result s, seed ) { | |
| 2486 | va r i, token s, token, type, find , | |
| 2487 | comp iled = typ eof select or === "fu nction" && selector, | |
| 2488 | matc h = !seed && tokeniz e( (select or = compi led.select or || sele ctor) ); | |
| 2489 | ||
| 2490 | re sults = re sults || [ ]; | |
| 2491 | ||
| 2492 | // Try to mi nimize ope rations if there is no seed an d only one group | |
| 2493 | if ( match.l ength === 1 ) { | |
| 2494 | ||
| 2495 | // T ake a shor tcut and s et the con text if th e root sel ector is a n ID | |
| 2496 | toke ns = match [0] = matc h[0].slice ( 0 ); | |
| 2497 | if ( tokens.le ngth > 2 & & (token = tokens[0] ).type === "ID" && | |
| 2498 | support. getById && context.n odeType == = 9 && doc umentIsHTM L && | |
| 2499 | Expr.rel ative[ tok ens[1].typ e ] ) { | |
| 2500 | ||
| 2501 | contex t = ( Expr .find["ID" ]( token.m atches[0]. replace(ru nescape, f unescape), context ) || [] )[0 ]; | |
| 2502 | if ( ! context ) { | |
| 2503 | return r esults; | |
| 2504 | ||
| 2505 | // Pre compiled m atchers wi ll still v erify ance stry, so s tep up a l evel | |
| 2506 | } else if ( comp iled ) { | |
| 2507 | context = context. parentNode ; | |
| 2508 | } | |
| 2509 | ||
| 2510 | select or = selec tor.slice( tokens.sh ift().valu e.length ) ; | |
| 2511 | } | |
| 2512 | ||
| 2513 | // F etch a see d set for right-to-l eft matchi ng | |
| 2514 | i = matchExpr[ "needsCont ext"].test ( selector ) ? 0 : t okens.leng th; | |
| 2515 | whil e ( i-- ) { | |
| 2516 | token = tokens[i ]; | |
| 2517 | ||
| 2518 | // Abo rt if we h it a combi nator | |
| 2519 | if ( E xpr.relati ve[ (type = token.ty pe) ] ) { | |
| 2520 | break; | |
| 2521 | } | |
| 2522 | if ( ( find = Exp r.find[ ty pe ]) ) { | |
| 2523 | // Searc h, expandi ng context for leadi ng sibling combinato rs | |
| 2524 | if ( (se ed = find( | |
| 2525 | token.matc hes[0].rep lace( rune scape, fun escape ), | |
| 2526 | rsibling.t est( token s[0].type ) && testC ontext( co ntext.pare ntNode ) | | context | |
| 2527 | )) ) { | |
| 2528 | ||
| 2529 | // If seed is empty or no toke ns remain, we can re turn early | |
| 2530 | tokens.spl ice( i, 1 ); | |
| 2531 | selector = seed.leng th && toSe lector( to kens ); | |
| 2532 | if ( !sele ctor ) { | |
| 2533 | pu sh.apply( results, s eed ); | |
| 2534 | re turn resul ts; | |
| 2535 | } | |
| 2536 | ||
| 2537 | break; | |
| 2538 | } | |
| 2539 | } | |
| 2540 | } | |
| 2541 | } | |
| 2542 | ||
| 2543 | // Compile a nd execute a filteri ng functio n if one i s not prov ided | |
| 2544 | // Provide ` match` to avoid reto kenization if we mod ified the selector a bove | |
| 2545 | ( compiled | | compile( selector, match ) ) ( | |
| 2546 | seed , | |
| 2547 | cont ext, | |
| 2548 | !doc umentIsHTM L, | |
| 2549 | resu lts, | |
| 2550 | rsib ling.test( selector ) && testC ontext( co ntext.pare ntNode ) | | context | |
| 2551 | ); | |
| 2552 | re turn resul ts; | |
| 2553 | }; | |
| 2554 | ||
| 2555 | // One-tim e assignme nts | |
| 2556 | ||
| 2557 | // Sort st ability | |
| 2558 | support.so rtStable = expando.s plit("").s ort( sortO rder ).joi n("") === expando; | |
| 2559 | ||
| 2560 | // Support : Chrome<1 4 | |
| 2561 | // Always assume dup licates if they aren 't passed to the com parison fu nction | |
| 2562 | support.de tectDuplic ates = !!h asDuplicat e; | |
| 2563 | ||
| 2564 | // Initial ize agains t the defa ult docume nt | |
| 2565 | setDocumen t(); | |
| 2566 | ||
| 2567 | // Support : Webkit<5 37.32 - Sa fari 6.0.3 /Chrome 25 (fixed in Chrome 27 ) | |
| 2568 | // Detache d nodes co nfoundingl y follow * each other * | |
| 2569 | support.so rtDetached = assert( function( div1 ) { | |
| 2570 | // Should re turn 1, bu t returns 4 (followi ng) | |
| 2571 | re turn div1. compareDoc umentPosit ion( docum ent.create Element("d iv") ) & 1 ; | |
| 2572 | }); | |
| 2573 | ||
| 2574 | // Support : IE<8 | |
| 2575 | // Prevent attribute /property "interpola tion" | |
| 2576 | // http:// msdn.micro soft.com/e n-us/libra ry/ms53642 9%28VS.85% 29.aspx | |
| 2577 | if ( !asse rt(functio n( div ) { | |
| 2578 | di v.innerHTM L = "<a hr ef='#'></a >"; | |
| 2579 | re turn div.f irstChild. getAttribu te("href") === "#" ; | |
| 2580 | }) ) { | |
| 2581 | ad dHandle( " type|href| height|wid th", funct ion( elem, name, isX ML ) { | |
| 2582 | if ( !isXML ) { | |
| 2583 | return elem.getA ttribute( name, name .toLowerCa se() === " type" ? 1 : 2 ); | |
| 2584 | } | |
| 2585 | }) ; | |
| 2586 | } | |
| 2587 | ||
| 2588 | // Support : IE<9 | |
| 2589 | // Use def aultValue in place o f getAttri bute("valu e") | |
| 2590 | if ( !supp ort.attrib utes || !a ssert(func tion( div ) { | |
| 2591 | di v.innerHTM L = "<inpu t/>"; | |
| 2592 | di v.firstChi ld.setAttr ibute( "va lue", "" ) ; | |
| 2593 | re turn div.f irstChild. getAttribu te( "value " ) === "" ; | |
| 2594 | }) ) { | |
| 2595 | ad dHandle( " value", fu nction( el em, name, isXML ) { | |
| 2596 | if ( !isXML && elem.node Name.toLow erCase() = == "input" ) { | |
| 2597 | return elem.defa ultValue; | |
| 2598 | } | |
| 2599 | }) ; | |
| 2600 | } | |
| 2601 | ||
| 2602 | // Support : IE<9 | |
| 2603 | // Use get AttributeN ode to fet ch boolean s when get Attribute lies | |
| 2604 | if ( !asse rt(functio n( div ) { | |
| 2605 | re turn div.g etAttribut e("disable d") == nul l; | |
| 2606 | }) ) { | |
| 2607 | ad dHandle( b ooleans, f unction( e lem, name, isXML ) { | |
| 2608 | var val; | |
| 2609 | if ( !isXML ) { | |
| 2610 | return elem[ nam e ] === tr ue ? name. toLowerCas e() : | |
| 2611 | (val = ele m.getAttri buteNode( name )) && val.speci fied ? | |
| 2612 | val.value : | |
| 2613 | null; | |
| 2614 | } | |
| 2615 | }) ; | |
| 2616 | } | |
| 2617 | ||
| 2618 | return Siz zle; | |
| 2619 | ||
| 2620 | })( window ); | |
| 2621 | ||
| 2622 | ||
| 2623 | ||
| 2624 | jQuery.fin d = Sizzle ; | |
| 2625 | jQuery.exp r = Sizzle .selectors ; | |
| 2626 | jQuery.exp r[":"] = j Query.expr .pseudos; | |
| 2627 | jQuery.uni que = Sizz le.uniqueS ort; | |
| 2628 | jQuery.tex t = Sizzle .getText; | |
| 2629 | jQuery.isX MLDoc = Si zzle.isXML ; | |
| 2630 | jQuery.con tains = Si zzle.conta ins; | |
| 2631 | ||
| 2632 | ||
| 2633 | ||
| 2634 | var rneeds Context = jQuery.exp r.match.ne edsContext ; | |
| 2635 | ||
| 2636 | var rsingl eTag = (/^ <(\w+)\s*\ /?>(?:<\/\ 1>|)$/); | |
| 2637 | ||
| 2638 | ||
| 2639 | ||
| 2640 | var risSim ple = /^.[ ^:#\[\.,]* $/; | |
| 2641 | ||
| 2642 | // Impleme nt the ide ntical fun ctionality for filte r and not | |
| 2643 | function w innow( ele ments, qua lifier, no t ) { | |
| 2644 | if ( jQuery. isFunction ( qualifie r ) ) { | |
| 2645 | retu rn jQuery. grep( elem ents, func tion( elem , i ) { | |
| 2646 | /* jsh int -W018 */ | |
| 2647 | return !!qualifi er.call( e lem, i, el em ) !== n ot; | |
| 2648 | }); | |
| 2649 | ||
| 2650 | } | |
| 2651 | ||
| 2652 | if ( qualifi er.nodeTyp e ) { | |
| 2653 | retu rn jQuery. grep( elem ents, func tion( elem ) { | |
| 2654 | return ( elem == = qualifie r ) !== no t; | |
| 2655 | }); | |
| 2656 | ||
| 2657 | } | |
| 2658 | ||
| 2659 | if ( typeof qualifier === "strin g" ) { | |
| 2660 | if ( risSimple .test( qua lifier ) ) { | |
| 2661 | return jQuery.fi lter( qual ifier, ele ments, not ); | |
| 2662 | } | |
| 2663 | ||
| 2664 | qual ifier = jQ uery.filte r( qualifi er, elemen ts ); | |
| 2665 | } | |
| 2666 | ||
| 2667 | re turn jQuer y.grep( el ements, fu nction( el em ) { | |
| 2668 | retu rn ( jQuer y.inArray( elem, qua lifier ) > = 0 ) !== not; | |
| 2669 | }) ; | |
| 2670 | } | |
| 2671 | ||
| 2672 | jQuery.fil ter = func tion( expr , elems, n ot ) { | |
| 2673 | va r elem = e lems[ 0 ]; | |
| 2674 | ||
| 2675 | if ( not ) { | |
| 2676 | expr = ":not(" + expr + ")"; | |
| 2677 | } | |
| 2678 | ||
| 2679 | re turn elems .length == = 1 && ele m.nodeType === 1 ? | |
| 2680 | jQue ry.find.ma tchesSelec tor( elem, expr ) ? [ elem ] : [] : | |
| 2681 | jQue ry.find.ma tches( exp r, jQuery. grep( elem s, functio n( elem ) { | |
| 2682 | return elem.node Type === 1 ; | |
| 2683 | })); | |
| 2684 | }; | |
| 2685 | ||
| 2686 | jQuery.fn. extend({ | |
| 2687 | fi nd: functi on( select or ) { | |
| 2688 | var i, | |
| 2689 | ret = [], | |
| 2690 | self = this, | |
| 2691 | len = self.lengt h; | |
| 2692 | ||
| 2693 | if ( typeof se lector !== "string" ) { | |
| 2694 | return this.push Stack( jQu ery( selec tor ).filt er(functio n() { | |
| 2695 | for ( i = 0; i < l en; i++ ) { | |
| 2696 | if ( jQuer y.contains ( self[ i ], this ) ) { | |
| 2697 | re turn true; | |
| 2698 | } | |
| 2699 | } | |
| 2700 | }) ); | |
| 2701 | } | |
| 2702 | ||
| 2703 | for ( i = 0; i < len; i+ + ) { | |
| 2704 | jQuery .find( sel ector, sel f[ i ], re t ); | |
| 2705 | } | |
| 2706 | ||
| 2707 | // N eeded beca use $( sel ector, con text ) bec omes $( co ntext ).fi nd( select or ) | |
| 2708 | ret = this.pus hStack( le n > 1 ? jQ uery.uniqu e( ret ) : ret ); | |
| 2709 | ret. selector = this.sele ctor ? thi s.selector + " " + s elector : selector; | |
| 2710 | retu rn ret; | |
| 2711 | }, | |
| 2712 | fi lter: func tion( sele ctor ) { | |
| 2713 | retu rn this.pu shStack( w innow(this , selector || [], fa lse) ); | |
| 2714 | }, | |
| 2715 | no t: functio n( selecto r ) { | |
| 2716 | retu rn this.pu shStack( w innow(this , selector || [], tr ue) ); | |
| 2717 | }, | |
| 2718 | is : function ( selector ) { | |
| 2719 | retu rn !!winno w( | |
| 2720 | this, | |
| 2721 | ||
| 2722 | // If this is a positional /relative selector, check memb ership in the return ed set | |
| 2723 | // so $("p:first ").is("p:l ast") won' t return t rue for a doc with t wo "p". | |
| 2724 | typeof selector === "strin g" && rnee dsContext. test( sele ctor ) ? | |
| 2725 | jQuery( selector ) : | |
| 2726 | selector || [], | |
| 2727 | false | |
| 2728 | ).le ngth; | |
| 2729 | } | |
| 2730 | }); | |
| 2731 | ||
| 2732 | ||
| 2733 | // Initial ize a jQue ry object | |
| 2734 | ||
| 2735 | ||
| 2736 | // A centr al referen ce to the root jQuer y(document ) | |
| 2737 | var rootjQ uery, | |
| 2738 | ||
| 2739 | // Use the c orrect doc ument acco rdingly wi th window argument ( sandbox) | |
| 2740 | do cument = w indow.docu ment, | |
| 2741 | ||
| 2742 | // A simple way to che ck for HTM L strings | |
| 2743 | // Prioritiz e #id over <tag> to avoid XSS via locati on.hash (# 9521) | |
| 2744 | // Strict HT ML recogni tion (#112 90: must s tart with <) | |
| 2745 | rq uickExpr = /^(?:\s*( <[\w\W]+>) [^>]*|#([\ w-]*))$/, | |
| 2746 | ||
| 2747 | in it = jQuer y.fn.init = function ( selector , context ) { | |
| 2748 | var match, ele m; | |
| 2749 | ||
| 2750 | // H ANDLE: $(" "), $(null ), $(undef ined), $(f alse) | |
| 2751 | if ( !selector ) { | |
| 2752 | return this; | |
| 2753 | } | |
| 2754 | ||
| 2755 | // H andle HTML strings | |
| 2756 | if ( typeof se lector === "string" ) { | |
| 2757 | if ( s elector.ch arAt(0) == = "<" && s elector.ch arAt( sele ctor.lengt h - 1 ) == = ">" && s elector.le ngth >= 3 ) { | |
| 2758 | // Assum e that str ings that start and end with < > are HTML and skip the regex check | |
| 2759 | match = [ null, se lector, nu ll ]; | |
| 2760 | ||
| 2761 | } else { | |
| 2762 | match = rquickExpr .exec( sel ector ); | |
| 2763 | } | |
| 2764 | ||
| 2765 | // Mat ch html or make sure no contex t is speci fied for # id | |
| 2766 | if ( m atch && (m atch[1] || !context) ) { | |
| 2767 | ||
| 2768 | // HANDL E: $(html) -> $(arra y) | |
| 2769 | if ( mat ch[1] ) { | |
| 2770 | context = context in stanceof j Query ? co ntext[0] : context; | |
| 2771 | ||
| 2772 | // scripts is true f or back-co mpat | |
| 2773 | // Intenti onally let the error be thrown if parseH TML is not present | |
| 2774 | jQuery.mer ge( this, jQuery.par seHTML( | |
| 2775 | ma tch[1], | |
| 2776 | co ntext && c ontext.nod eType ? co ntext.owne rDocument || context : documen t, | |
| 2777 | tr ue | |
| 2778 | ) ); | |
| 2779 | ||
| 2780 | // HANDLE: $(html, p rops) | |
| 2781 | if ( rsing leTag.test ( match[1] ) && jQue ry.isPlain Object( co ntext ) ) { | |
| 2782 | fo r ( match in context ) { | |
| 2783 | // P roperties of context are calle d as metho ds if poss ible | |
| 2784 | if ( jQuery.is Function( this[ matc h ] ) ) { | |
| 2785 | this[ match ]( c ontext[ ma tch ] ); | |
| 2786 | ||
| 2787 | // . ..and othe rwise set as attribu tes | |
| 2788 | } el se { | |
| 2789 | this.a ttr( match , context[ match ] ) ; | |
| 2790 | } | |
| 2791 | } | |
| 2792 | } | |
| 2793 | ||
| 2794 | return thi s; | |
| 2795 | ||
| 2796 | // HANDL E: $(#id) | |
| 2797 | } else { | |
| 2798 | elem = doc ument.getE lementById ( match[2] ); | |
| 2799 | ||
| 2800 | // Check p arentNode to catch w hen Blackb erry 4.6 r eturns | |
| 2801 | // nodes t hat are no longer in the docum ent #6963 | |
| 2802 | if ( elem && elem.pa rentNode ) { | |
| 2803 | // Handle th e case whe re IE and Opera retu rn items | |
| 2804 | // by name i nstead of ID | |
| 2805 | if ( elem.id !== match [2] ) { | |
| 2806 | retu rn rootjQu ery.find( selector ) ; | |
| 2807 | } | |
| 2808 | ||
| 2809 | // Otherwise , we injec t the elem ent direct ly into th e jQuery o bject | |
| 2810 | th is.length = 1; | |
| 2811 | th is[0] = el em; | |
| 2812 | } | |
| 2813 | ||
| 2814 | this.conte xt = docum ent; | |
| 2815 | this.selec tor = sele ctor; | |
| 2816 | return thi s; | |
| 2817 | } | |
| 2818 | ||
| 2819 | // HAN DLE: $(exp r, $(...)) | |
| 2820 | } else if ( !con text || co ntext.jque ry ) { | |
| 2821 | return ( context | | rootjQue ry ).find( selector ); | |
| 2822 | ||
| 2823 | // HAN DLE: $(exp r, context ) | |
| 2824 | // (wh ich is jus t equivale nt to: $(c ontext).fi nd(expr) | |
| 2825 | } else { | |
| 2826 | return t his.constr uctor( con text ).fin d( selecto r ); | |
| 2827 | } | |
| 2828 | ||
| 2829 | // H ANDLE: $(D OMElement) | |
| 2830 | } el se if ( se lector.nod eType ) { | |
| 2831 | this.c ontext = t his[0] = s elector; | |
| 2832 | this.l ength = 1; | |
| 2833 | return this; | |
| 2834 | ||
| 2835 | // H ANDLE: $(f unction) | |
| 2836 | // S hortcut fo r document ready | |
| 2837 | } el se if ( jQ uery.isFun ction( sel ector ) ) { | |
| 2838 | return typeof ro otjQuery.r eady !== " undefined" ? | |
| 2839 | rootjQue ry.ready( selector ) : | |
| 2840 | // Execu te immedia tely if re ady is not present | |
| 2841 | selector ( jQuery ) ; | |
| 2842 | } | |
| 2843 | ||
| 2844 | if ( selector. selector ! == undefin ed ) { | |
| 2845 | this.s elector = selector.s elector; | |
| 2846 | this.c ontext = s elector.co ntext; | |
| 2847 | } | |
| 2848 | ||
| 2849 | retu rn jQuery. makeArray( selector, this ); | |
| 2850 | }; | |
| 2851 | ||
| 2852 | // Give th e init fun ction the jQuery pro totype for later ins tantiation | |
| 2853 | init.proto type = jQu ery.fn; | |
| 2854 | ||
| 2855 | // Initial ize centra l referenc e | |
| 2856 | rootjQuery = jQuery( document ); | |
| 2857 | ||
| 2858 | ||
| 2859 | var rparen tsprev = / ^(?:parent s|prev(?:U ntil|All)) /, | |
| 2860 | // methods g uaranteed to produce a unique set when s tarting fr om a uniqu e set | |
| 2861 | gu aranteedUn ique = { | |
| 2862 | chil dren: true , | |
| 2863 | cont ents: true , | |
| 2864 | next : true, | |
| 2865 | prev : true | |
| 2866 | }; | |
| 2867 | ||
| 2868 | jQuery.ext end({ | |
| 2869 | di r: functio n( elem, d ir, until ) { | |
| 2870 | var matched = [], | |
| 2871 | cur = elem[ dir ]; | |
| 2872 | ||
| 2873 | whil e ( cur && cur.nodeT ype !== 9 && (until === undefi ned || cur .nodeType !== 1 || ! jQuery( cu r ).is( un til )) ) { | |
| 2874 | if ( c ur.nodeTyp e === 1 ) { | |
| 2875 | matched. push( cur ); | |
| 2876 | } | |
| 2877 | cur = cur[dir]; | |
| 2878 | } | |
| 2879 | retu rn matched ; | |
| 2880 | }, | |
| 2881 | ||
| 2882 | si bling: fun ction( n, elem ) { | |
| 2883 | var r = []; | |
| 2884 | ||
| 2885 | for ( ; n; n = n.nextSib ling ) { | |
| 2886 | if ( n .nodeType === 1 && n !== elem ) { | |
| 2887 | r.push( n ); | |
| 2888 | } | |
| 2889 | } | |
| 2890 | ||
| 2891 | retu rn r; | |
| 2892 | } | |
| 2893 | }); | |
| 2894 | ||
| 2895 | jQuery.fn. extend({ | |
| 2896 | ha s: functio n( target ) { | |
| 2897 | var i, | |
| 2898 | target s = jQuery ( target, this ), | |
| 2899 | len = targets.le ngth; | |
| 2900 | ||
| 2901 | retu rn this.fi lter(funct ion() { | |
| 2902 | for ( i = 0; i < len; i++ ) { | |
| 2903 | if ( jQu ery.contai ns( this, targets[i] ) ) { | |
| 2904 | return tru e; | |
| 2905 | } | |
| 2906 | } | |
| 2907 | }); | |
| 2908 | }, | |
| 2909 | ||
| 2910 | cl osest: fun ction( sel ectors, co ntext ) { | |
| 2911 | var cur, | |
| 2912 | i = 0, | |
| 2913 | l = th is.length, | |
| 2914 | matche d = [], | |
| 2915 | pos = rneedsCont ext.test( selectors ) || typeo f selector s !== "str ing" ? | |
| 2916 | jQuery( selectors, context | | this.con text ) : | |
| 2917 | 0; | |
| 2918 | ||
| 2919 | for ( ; i < l; i++ ) { | |
| 2920 | for ( cur = this [i]; cur & & cur !== context; c ur = cur.p arentNode ) { | |
| 2921 | // Alway s skip doc ument frag ments | |
| 2922 | if ( cur .nodeType < 11 && (p os ? | |
| 2923 | pos.index( cur) > -1 : | |
| 2924 | ||
| 2925 | // Don't p ass non-el ements to Sizzle | |
| 2926 | cur.nodeTy pe === 1 & & | |
| 2927 | jQ uery.find. matchesSel ector(cur, selectors )) ) { | |
| 2928 | ||
| 2929 | matched.pu sh( cur ); | |
| 2930 | break; | |
| 2931 | } | |
| 2932 | } | |
| 2933 | } | |
| 2934 | ||
| 2935 | retu rn this.pu shStack( m atched.len gth > 1 ? jQuery.uni que( match ed ) : mat ched ); | |
| 2936 | }, | |
| 2937 | ||
| 2938 | // Determine the posit ion of an element wi thin | |
| 2939 | // the match ed set of elements | |
| 2940 | in dex: funct ion( elem ) { | |
| 2941 | ||
| 2942 | // N o argument , return i ndex in pa rent | |
| 2943 | if ( !elem ) { | |
| 2944 | return ( this[0] && this[0 ].parentNo de ) ? thi s.first(). prevAll(). length : - 1; | |
| 2945 | } | |
| 2946 | ||
| 2947 | // i ndex in se lector | |
| 2948 | if ( typeof el em === "st ring" ) { | |
| 2949 | return jQuery.in Array( thi s[0], jQue ry( elem ) ); | |
| 2950 | } | |
| 2951 | ||
| 2952 | // L ocate the position o f the desi red elemen t | |
| 2953 | retu rn jQuery. inArray( | |
| 2954 | // If it receive s a jQuery object, t he first e lement is used | |
| 2955 | elem.j query ? el em[0] : el em, this ) ; | |
| 2956 | }, | |
| 2957 | ||
| 2958 | ad d: functio n( selecto r, context ) { | |
| 2959 | retu rn this.pu shStack( | |
| 2960 | jQuery .unique( | |
| 2961 | jQuery.m erge( this .get(), jQ uery( sele ctor, cont ext ) ) | |
| 2962 | ) | |
| 2963 | ); | |
| 2964 | }, | |
| 2965 | ||
| 2966 | ad dBack: fun ction( sel ector ) { | |
| 2967 | retu rn this.ad d( selecto r == null ? | |
| 2968 | this.p revObject : this.pre vObject.fi lter(selec tor) | |
| 2969 | ); | |
| 2970 | } | |
| 2971 | }); | |
| 2972 | ||
| 2973 | function s ibling( cu r, dir ) { | |
| 2974 | do { | |
| 2975 | cur = cur[ dir ]; | |
| 2976 | } while ( cu r && cur.n odeType != = 1 ); | |
| 2977 | ||
| 2978 | re turn cur; | |
| 2979 | } | |
| 2980 | ||
| 2981 | jQuery.eac h({ | |
| 2982 | pa rent: func tion( elem ) { | |
| 2983 | var parent = e lem.parent Node; | |
| 2984 | retu rn parent && parent. nodeType ! == 11 ? pa rent : nul l; | |
| 2985 | }, | |
| 2986 | pa rents: fun ction( ele m ) { | |
| 2987 | retu rn jQuery. dir( elem, "parentNo de" ); | |
| 2988 | }, | |
| 2989 | pa rentsUntil : function ( elem, i, until ) { | |
| 2990 | retu rn jQuery. dir( elem, "parentNo de", until ); | |
| 2991 | }, | |
| 2992 | ne xt: functi on( elem ) { | |
| 2993 | retu rn sibling ( elem, "n extSibling " ); | |
| 2994 | }, | |
| 2995 | pr ev: functi on( elem ) { | |
| 2996 | retu rn sibling ( elem, "p reviousSib ling" ); | |
| 2997 | }, | |
| 2998 | ne xtAll: fun ction( ele m ) { | |
| 2999 | retu rn jQuery. dir( elem, "nextSibl ing" ); | |
| 3000 | }, | |
| 3001 | pr evAll: fun ction( ele m ) { | |
| 3002 | retu rn jQuery. dir( elem, "previous Sibling" ) ; | |
| 3003 | }, | |
| 3004 | ne xtUntil: f unction( e lem, i, un til ) { | |
| 3005 | retu rn jQuery. dir( elem, "nextSibl ing", unti l ); | |
| 3006 | }, | |
| 3007 | pr evUntil: f unction( e lem, i, un til ) { | |
| 3008 | retu rn jQuery. dir( elem, "previous Sibling", until ); | |
| 3009 | }, | |
| 3010 | si blings: fu nction( el em ) { | |
| 3011 | retu rn jQuery. sibling( ( elem.pare ntNode || {} ).first Child, ele m ); | |
| 3012 | }, | |
| 3013 | ch ildren: fu nction( el em ) { | |
| 3014 | retu rn jQuery. sibling( e lem.firstC hild ); | |
| 3015 | }, | |
| 3016 | co ntents: fu nction( el em ) { | |
| 3017 | retu rn jQuery. nodeName( elem, "ifr ame" ) ? | |
| 3018 | elem.c ontentDocu ment || el em.content Window.doc ument : | |
| 3019 | jQuery .merge( [] , elem.chi ldNodes ); | |
| 3020 | } | |
| 3021 | }, functio n( name, f n ) { | |
| 3022 | jQ uery.fn[ n ame ] = fu nction( un til, selec tor ) { | |
| 3023 | var ret = jQue ry.map( th is, fn, un til ); | |
| 3024 | ||
| 3025 | if ( name.slic e( -5 ) != = "Until" ) { | |
| 3026 | select or = until ; | |
| 3027 | } | |
| 3028 | ||
| 3029 | if ( selector && typeof selector = == "string " ) { | |
| 3030 | ret = jQuery.fil ter( selec tor, ret ) ; | |
| 3031 | } | |
| 3032 | ||
| 3033 | if ( this.leng th > 1 ) { | |
| 3034 | // Rem ove duplic ates | |
| 3035 | if ( ! guaranteed Unique[ na me ] ) { | |
| 3036 | ret = jQ uery.uniqu e( ret ); | |
| 3037 | } | |
| 3038 | ||
| 3039 | // Rev erse order for paren ts* and pr ev-derivat ives | |
| 3040 | if ( r parentspre v.test( na me ) ) { | |
| 3041 | ret = re t.reverse( ); | |
| 3042 | } | |
| 3043 | } | |
| 3044 | ||
| 3045 | retu rn this.pu shStack( r et ); | |
| 3046 | }; | |
| 3047 | }); | |
| 3048 | var rnotwh ite = (/\S +/g); | |
| 3049 | ||
| 3050 | ||
| 3051 | ||
| 3052 | // String to Object options fo rmat cache | |
| 3053 | var option sCache = { }; | |
| 3054 | ||
| 3055 | // Convert String-fo rmatted op tions into Object-fo rmatted on es and sto re in cach e | |
| 3056 | function c reateOptio ns( option s ) { | |
| 3057 | va r object = optionsCa che[ optio ns ] = {}; | |
| 3058 | jQ uery.each( options.m atch( rnot white ) || [], funct ion( _, fl ag ) { | |
| 3059 | obje ct[ flag ] = true; | |
| 3060 | }) ; | |
| 3061 | re turn objec t; | |
| 3062 | } | |
| 3063 | ||
| 3064 | /* | |
| 3065 | * Create a callback list usin g the foll owing para meters: | |
| 3066 | * | |
| 3067 | * op tions: an optional l ist of spa ce-separat ed options that will change ho w | |
| 3068 | * the ca llback lis t behaves or a more traditiona l option o bject | |
| 3069 | * | |
| 3070 | * By defa ult a call back list will act l ike an eve nt callbac k list and can be | |
| 3071 | * "fired" multiple times. | |
| 3072 | * | |
| 3073 | * Possibl e options: | |
| 3074 | * | |
| 3075 | * on ce: will ens ure the ca llback lis t can only be fired once (like a Deferre d) | |
| 3076 | * | |
| 3077 | * me mory: will kee p track of previous values and will call any callb ack added | |
| 3078 | * after the list has b een fired right away with the latest "me morized" | |
| 3079 | * values (li ke a Defer red) | |
| 3080 | * | |
| 3081 | * un ique: will ens ure a call back can o nly be add ed once (n o duplicat e in the l ist) | |
| 3082 | * | |
| 3083 | * st opOnFalse: interr upt callin gs when a callback r eturns fal se | |
| 3084 | * | |
| 3085 | */ | |
| 3086 | jQuery.Cal lbacks = f unction( o ptions ) { | |
| 3087 | ||
| 3088 | // Convert o ptions fro m String-f ormatted t o Object-f ormatted i f needed | |
| 3089 | // (we check in cache first) | |
| 3090 | op tions = ty peof optio ns === "st ring" ? | |
| 3091 | ( op tionsCache [ options ] || creat eOptions( options ) ) : | |
| 3092 | jQue ry.extend( {}, optio ns ); | |
| 3093 | ||
| 3094 | va r // Flag to know if list is c urrently f iring | |
| 3095 | firi ng, | |
| 3096 | // L ast fire v alue (for non-forget table list s) | |
| 3097 | memo ry, | |
| 3098 | // F lag to kno w if list was alread y fired | |
| 3099 | fire d, | |
| 3100 | // E nd of the loop when firing | |
| 3101 | firi ngLength, | |
| 3102 | // I ndex of cu rrently fi ring callb ack (modif ied by rem ove if nee ded) | |
| 3103 | firi ngIndex, | |
| 3104 | // F irst callb ack to fir e (used in ternally b y add and fireWith) | |
| 3105 | firi ngStart, | |
| 3106 | // A ctual call back list | |
| 3107 | list = [], | |
| 3108 | // S tack of fi re calls f or repeata ble lists | |
| 3109 | stac k = !optio ns.once && [], | |
| 3110 | // F ire callba cks | |
| 3111 | fire = functio n( data ) { | |
| 3112 | memory = options .memory && data; | |
| 3113 | fired = true; | |
| 3114 | firing Index = fi ringStart || 0; | |
| 3115 | firing Start = 0; | |
| 3116 | firing Length = l ist.length ; | |
| 3117 | firing = true; | |
| 3118 | for ( ; list && firingInde x < firing Length; fi ringIndex+ + ) { | |
| 3119 | if ( lis t[ firingI ndex ].app ly( data[ 0 ], data[ 1 ] ) === false && options.st opOnFalse ) { | |
| 3120 | memory = f alse; // T o prevent further ca lls using add | |
| 3121 | break; | |
| 3122 | } | |
| 3123 | } | |
| 3124 | firing = false; | |
| 3125 | if ( l ist ) { | |
| 3126 | if ( sta ck ) { | |
| 3127 | if ( stack .length ) { | |
| 3128 | fi re( stack. shift() ); | |
| 3129 | } | |
| 3130 | } else i f ( memory ) { | |
| 3131 | list = []; | |
| 3132 | } else { | |
| 3133 | self.disab le(); | |
| 3134 | } | |
| 3135 | } | |
| 3136 | }, | |
| 3137 | // A ctual Call backs obje ct | |
| 3138 | self = { | |
| 3139 | // Add a callbac k or a col lection of callbacks to the li st | |
| 3140 | add: f unction() { | |
| 3141 | if ( lis t ) { | |
| 3142 | // First, we save th e current length | |
| 3143 | var start = list.len gth; | |
| 3144 | (function add( args ) { | |
| 3145 | jQ uery.each( args, fun ction( _, arg ) { | |
| 3146 | var type = jQu ery.type( arg ); | |
| 3147 | if ( type === "function" ) { | |
| 3148 | if ( ! options.un ique || !s elf.has( a rg ) ) { | |
| 3149 | list.pus h( arg ); | |
| 3150 | } | |
| 3151 | } el se if ( ar g && arg.l ength && t ype !== "s tring" ) { | |
| 3152 | // Ins pect recur sively | |
| 3153 | add( a rg ); | |
| 3154 | } | |
| 3155 | }) ; | |
| 3156 | })( argume nts ); | |
| 3157 | // Do we n eed to add the callb acks to th e | |
| 3158 | // current firing ba tch? | |
| 3159 | if ( firin g ) { | |
| 3160 | fi ringLength = list.le ngth; | |
| 3161 | // With me mory, if w e're not f iring then | |
| 3162 | // we shou ld call ri ght away | |
| 3163 | } else if ( memory ) { | |
| 3164 | fi ringStart = start; | |
| 3165 | fi re( memory ); | |
| 3166 | } | |
| 3167 | } | |
| 3168 | return t his; | |
| 3169 | }, | |
| 3170 | // Rem ove a call back from the list | |
| 3171 | remove : function () { | |
| 3172 | if ( lis t ) { | |
| 3173 | jQuery.eac h( argumen ts, functi on( _, arg ) { | |
| 3174 | va r index; | |
| 3175 | wh ile ( ( in dex = jQue ry.inArray ( arg, lis t, index ) ) > -1 ) { | |
| 3176 | list .splice( i ndex, 1 ); | |
| 3177 | // H andle firi ng indexes | |
| 3178 | if ( firing ) { | |
| 3179 | if ( i ndex <= fi ringLength ) { | |
| 3180 | firingLe ngth--; | |
| 3181 | } | |
| 3182 | if ( i ndex <= fi ringIndex ) { | |
| 3183 | firingIn dex--; | |
| 3184 | } | |
| 3185 | } | |
| 3186 | } | |
| 3187 | }); | |
| 3188 | } | |
| 3189 | return t his; | |
| 3190 | }, | |
| 3191 | // Che ck if a gi ven callba ck is in t he list. | |
| 3192 | // If no argumen t is given , return w hether or not list h as callbac ks attache d. | |
| 3193 | has: f unction( f n ) { | |
| 3194 | return f n ? jQuery .inArray( fn, list ) > -1 : !! ( list && list.lengt h ); | |
| 3195 | }, | |
| 3196 | // Rem ove all ca llbacks fr om the lis t | |
| 3197 | empty: function( ) { | |
| 3198 | list = [ ]; | |
| 3199 | firingLe ngth = 0; | |
| 3200 | return t his; | |
| 3201 | }, | |
| 3202 | // Hav e the list do nothin g anymore | |
| 3203 | disabl e: functio n() { | |
| 3204 | list = s tack = mem ory = unde fined; | |
| 3205 | return t his; | |
| 3206 | }, | |
| 3207 | // Is it disable d? | |
| 3208 | disabl ed: functi on() { | |
| 3209 | return ! list; | |
| 3210 | }, | |
| 3211 | // Loc k the list in its cu rrent stat e | |
| 3212 | lock: function() { | |
| 3213 | stack = undefined; | |
| 3214 | if ( !me mory ) { | |
| 3215 | self.disab le(); | |
| 3216 | } | |
| 3217 | return t his; | |
| 3218 | }, | |
| 3219 | // Is it locked? | |
| 3220 | locked : function () { | |
| 3221 | return ! stack; | |
| 3222 | }, | |
| 3223 | // Cal l all call backs with the given context a nd argumen ts | |
| 3224 | fireWi th: functi on( contex t, args ) { | |
| 3225 | if ( lis t && ( !fi red || sta ck ) ) { | |
| 3226 | args = arg s || []; | |
| 3227 | args = [ c ontext, ar gs.slice ? args.slic e() : args ]; | |
| 3228 | if ( firin g ) { | |
| 3229 | st ack.push( args ); | |
| 3230 | } else { | |
| 3231 | fi re( args ) ; | |
| 3232 | } | |
| 3233 | } | |
| 3234 | return t his; | |
| 3235 | }, | |
| 3236 | // Cal l all the callbacks with the g iven argum ents | |
| 3237 | fire: function() { | |
| 3238 | self.fir eWith( thi s, argumen ts ); | |
| 3239 | return t his; | |
| 3240 | }, | |
| 3241 | // To know if th e callback s have alr eady been called at least once | |
| 3242 | fired: function( ) { | |
| 3243 | return ! !fired; | |
| 3244 | } | |
| 3245 | }; | |
| 3246 | ||
| 3247 | re turn self; | |
| 3248 | }; | |
| 3249 | ||
| 3250 | ||
| 3251 | jQuery.ext end({ | |
| 3252 | ||
| 3253 | De ferred: fu nction( fu nc ) { | |
| 3254 | var tuples = [ | |
| 3255 | // actio n, add lis tener, lis tener list , final st ate | |
| 3256 | [ "resol ve", "done ", jQuery. Callbacks( "once memo ry"), "res olved" ], | |
| 3257 | [ "rejec t", "fail" , jQuery.C allbacks(" once memor y"), "reje cted" ], | |
| 3258 | [ "notif y", "progr ess", jQue ry.Callbac ks("memory ") ] | |
| 3259 | ], | |
| 3260 | state = "pending ", | |
| 3261 | promis e = { | |
| 3262 | state: f unction() { | |
| 3263 | return sta te; | |
| 3264 | }, | |
| 3265 | always: function() { | |
| 3266 | deferred.d one( argum ents ).fai l( argumen ts ); | |
| 3267 | return thi s; | |
| 3268 | }, | |
| 3269 | then: fu nction( /* fnDone, f nFail, fnP rogress */ ) { | |
| 3270 | var fns = arguments; | |
| 3271 | return jQu ery.Deferr ed(functio n( newDefe r ) { | |
| 3272 | jQ uery.each( tuples, f unction( i , tuple ) { | |
| 3273 | var fn = jQuer y.isFuncti on( fns[ i ] ) && fn s[ i ]; | |
| 3274 | // d eferred[ d one | fail | progres s ] for fo rwarding a ctions to newDefer | |
| 3275 | defe rred[ tupl e[1] ](fun ction() { | |
| 3276 | var re turned = f n && fn.ap ply( this, arguments ); | |
| 3277 | if ( r eturned && jQuery.is Function( returned.p romise ) ) { | |
| 3278 | returned .promise() | |
| 3279 | .done( new Defer.reso lve ) | |
| 3280 | .fail( new Defer.reje ct ) | |
| 3281 | .progress( newDefer. notify ); | |
| 3282 | } else { | |
| 3283 | newDefer [ tuple[ 0 ] + "With " ]( this === promis e ? newDef er.promise () : this, fn ? [ re turned ] : arguments ); | |
| 3284 | } | |
| 3285 | }); | |
| 3286 | }) ; | |
| 3287 | fn s = null; | |
| 3288 | }).promise (); | |
| 3289 | }, | |
| 3290 | // Get a promise f or this de ferred | |
| 3291 | // If ob j is provi ded, the p romise asp ect is add ed to the object | |
| 3292 | promise: function( obj ) { | |
| 3293 | return obj != null ? jQuery.ex tend( obj, promise ) : promise ; | |
| 3294 | } | |
| 3295 | }, | |
| 3296 | deferr ed = {}; | |
| 3297 | ||
| 3298 | // K eep pipe f or back-co mpat | |
| 3299 | prom ise.pipe = promise.t hen; | |
| 3300 | ||
| 3301 | // A dd list-sp ecific met hods | |
| 3302 | jQue ry.each( t uples, fun ction( i, tuple ) { | |
| 3303 | var li st = tuple [ 2 ], | |
| 3304 | stateStr ing = tupl e[ 3 ]; | |
| 3305 | ||
| 3306 | // pro mise[ done | fail | progress ] = list.ad d | |
| 3307 | promis e[ tuple[1 ] ] = list .add; | |
| 3308 | ||
| 3309 | // Han dle state | |
| 3310 | if ( s tateString ) { | |
| 3311 | list.add (function( ) { | |
| 3312 | // state = [ resolve d | reject ed ] | |
| 3313 | state = st ateString; | |
| 3314 | ||
| 3315 | // [ rej ect_list | resolve_l ist ].disa ble; progr ess_list.l ock | |
| 3316 | }, tuple s[ i ^ 1 ] [ 2 ].disa ble, tuple s[ 2 ][ 2 ].lock ); | |
| 3317 | } | |
| 3318 | ||
| 3319 | // def erred[ res olve | rej ect | noti fy ] | |
| 3320 | deferr ed[ tuple[ 0] ] = fun ction() { | |
| 3321 | deferred [ tuple[0] + "With" ]( this == = deferred ? promise : this, a rguments ) ; | |
| 3322 | return t his; | |
| 3323 | }; | |
| 3324 | deferr ed[ tuple[ 0] + "With " ] = list .fireWith; | |
| 3325 | }); | |
| 3326 | ||
| 3327 | // M ake the de ferred a p romise | |
| 3328 | prom ise.promis e( deferre d ); | |
| 3329 | ||
| 3330 | // C all given func if an y | |
| 3331 | if ( func ) { | |
| 3332 | func.c all( defer red, defer red ); | |
| 3333 | } | |
| 3334 | ||
| 3335 | // A ll done! | |
| 3336 | retu rn deferre d; | |
| 3337 | }, | |
| 3338 | ||
| 3339 | // Deferred helper | |
| 3340 | wh en: functi on( subord inate /* , ..., subo rdinateN * / ) { | |
| 3341 | var i = 0, | |
| 3342 | resolv eValues = slice.call ( argument s ), | |
| 3343 | length = resolve Values.len gth, | |
| 3344 | ||
| 3345 | // the count of uncomplete d subordin ates | |
| 3346 | remain ing = leng th !== 1 | | ( subord inate && j Query.isFu nction( su bordinate. promise ) ) ? length : 0, | |
| 3347 | ||
| 3348 | // the master De ferred. If resolveVa lues consi st of only a single Deferred, just use t hat. | |
| 3349 | deferr ed = remai ning === 1 ? subordi nate : jQu ery.Deferr ed(), | |
| 3350 | ||
| 3351 | // Upd ate functi on for bot h resolve and progre ss values | |
| 3352 | update Func = fun ction( i, contexts, values ) { | |
| 3353 | return f unction( v alue ) { | |
| 3354 | contexts[ i ] = this ; | |
| 3355 | values[ i ] = argume nts.length > 1 ? sli ce.call( a rguments ) : value; | |
| 3356 | if ( value s === prog ressValues ) { | |
| 3357 | de ferred.not ifyWith( c ontexts, v alues ); | |
| 3358 | ||
| 3359 | } else if ( !(--rema ining) ) { | |
| 3360 | de ferred.res olveWith( contexts, values ); | |
| 3361 | } | |
| 3362 | }; | |
| 3363 | }, | |
| 3364 | ||
| 3365 | progre ssValues, progressCo ntexts, re solveConte xts; | |
| 3366 | ||
| 3367 | // a dd listene rs to Defe rred subor dinates; t reat other s as resol ved | |
| 3368 | if ( length > 1 ) { | |
| 3369 | progre ssValues = new Array ( length ) ; | |
| 3370 | progre ssContexts = new Arr ay( length ); | |
| 3371 | resolv eContexts = new Arra y( length ); | |
| 3372 | for ( ; i < leng th; i++ ) { | |
| 3373 | if ( res olveValues [ i ] && j Query.isFu nction( re solveValue s[ i ].pro mise ) ) { | |
| 3374 | resolveVal ues[ i ].p romise() | |
| 3375 | .d one( updat eFunc( i, resolveCon texts, res olveValues ) ) | |
| 3376 | .f ail( defer red.reject ) | |
| 3377 | .p rogress( u pdateFunc( i, progre ssContexts , progress Values ) ) ; | |
| 3378 | } else { | |
| 3379 | --remainin g; | |
| 3380 | } | |
| 3381 | } | |
| 3382 | } | |
| 3383 | ||
| 3384 | // i f we're no t waiting on anythin g, resolve the maste r | |
| 3385 | if ( !remainin g ) { | |
| 3386 | deferr ed.resolve With( reso lveContext s, resolve Values ); | |
| 3387 | } | |
| 3388 | ||
| 3389 | retu rn deferre d.promise( ); | |
| 3390 | } | |
| 3391 | }); | |
| 3392 | ||
| 3393 | ||
| 3394 | // The def erred used on DOM re ady | |
| 3395 | var readyL ist; | |
| 3396 | ||
| 3397 | jQuery.fn. ready = fu nction( fn ) { | |
| 3398 | // Add the c allback | |
| 3399 | jQ uery.ready .promise() .done( fn ); | |
| 3400 | ||
| 3401 | re turn this; | |
| 3402 | }; | |
| 3403 | ||
| 3404 | jQuery.ext end({ | |
| 3405 | // Is the DO M ready to be used? Set to tru e once it occurs. | |
| 3406 | is Ready: fal se, | |
| 3407 | ||
| 3408 | // A counter to track how many i tems to wa it for bef ore | |
| 3409 | // the ready event fir es. See #6 781 | |
| 3410 | re adyWait: 1 , | |
| 3411 | ||
| 3412 | // Hold (or release) t he ready e vent | |
| 3413 | ho ldReady: f unction( h old ) { | |
| 3414 | if ( hold ) { | |
| 3415 | jQuery .readyWait ++; | |
| 3416 | } el se { | |
| 3417 | jQuery .ready( tr ue ); | |
| 3418 | } | |
| 3419 | }, | |
| 3420 | ||
| 3421 | // Handle wh en the DOM is ready | |
| 3422 | re ady: funct ion( wait ) { | |
| 3423 | ||
| 3424 | // A bort if th ere are pe nding hold s or we're already r eady | |
| 3425 | if ( wait === true ? --j Query.read yWait : jQ uery.isRea dy ) { | |
| 3426 | return ; | |
| 3427 | } | |
| 3428 | ||
| 3429 | // M ake sure b ody exists , at least , in case IE gets a little ove rzealous ( ticket #54 43). | |
| 3430 | if ( !document .body ) { | |
| 3431 | return setTimeou t( jQuery. ready ); | |
| 3432 | } | |
| 3433 | ||
| 3434 | // R emember th at the DOM is ready | |
| 3435 | jQue ry.isReady = true; | |
| 3436 | ||
| 3437 | // I f a normal DOM Ready event fir ed, decrem ent, and w ait if nee d be | |
| 3438 | if ( wait !== true && -- jQuery.rea dyWait > 0 ) { | |
| 3439 | return ; | |
| 3440 | } | |
| 3441 | ||
| 3442 | // I f there ar e function s bound, t o execute | |
| 3443 | read yList.reso lveWith( d ocument, [ jQuery ] ); | |
| 3444 | ||
| 3445 | // T rigger any bound rea dy events | |
| 3446 | if ( jQuery.fn .triggerHa ndler ) { | |
| 3447 | jQuery ( document ).trigger Handler( " ready" ); | |
| 3448 | jQuery ( document ).off( "r eady" ); | |
| 3449 | } | |
| 3450 | } | |
| 3451 | }); | |
| 3452 | ||
| 3453 | /** | |
| 3454 | * Clean-u p method f or dom rea dy events | |
| 3455 | */ | |
| 3456 | function d etach() { | |
| 3457 | if ( documen t.addEvent Listener ) { | |
| 3458 | docu ment.remov eEventList ener( "DOM ContentLoa ded", comp leted, fal se ); | |
| 3459 | wind ow.removeE ventListen er( "load" , complete d, false ) ; | |
| 3460 | ||
| 3461 | } else { | |
| 3462 | docu ment.detac hEvent( "o nreadystat echange", completed ); | |
| 3463 | wind ow.detachE vent( "onl oad", comp leted ); | |
| 3464 | } | |
| 3465 | } | |
| 3466 | ||
| 3467 | /** | |
| 3468 | * The rea dy event h andler and self clea nup method | |
| 3469 | */ | |
| 3470 | function c ompleted() { | |
| 3471 | // readyStat e === "com plete" is good enoug h for us t o call the dom ready in oldIE | |
| 3472 | if ( documen t.addEvent Listener | | event.ty pe === "lo ad" || doc ument.read yState === "complete " ) { | |
| 3473 | deta ch(); | |
| 3474 | jQue ry.ready() ; | |
| 3475 | } | |
| 3476 | } | |
| 3477 | ||
| 3478 | jQuery.rea dy.promise = functio n( obj ) { | |
| 3479 | if ( !readyL ist ) { | |
| 3480 | ||
| 3481 | read yList = jQ uery.Defer red(); | |
| 3482 | ||
| 3483 | // C atch cases where $(d ocument).r eady() is called aft er the bro wser event has alrea dy occurre d. | |
| 3484 | // w e once tri ed to use readyState "interact ive" here, but it ca used issue s like the one | |
| 3485 | // d iscovered by ChrisS here: http ://bugs.jq uery.com/t icket/1228 2#comment: 15 | |
| 3486 | if ( document. readyState === "comp lete" ) { | |
| 3487 | // Han dle it asy nchronousl y to allow scripts t he opportu nity to de lay ready | |
| 3488 | setTim eout( jQue ry.ready ) ; | |
| 3489 | ||
| 3490 | // S tandards-b ased brows ers suppor t DOMConte ntLoaded | |
| 3491 | } el se if ( do cument.add EventListe ner ) { | |
| 3492 | // Use the handy event cal lback | |
| 3493 | docume nt.addEven tListener( "DOMConte ntLoaded", completed , false ); | |
| 3494 | ||
| 3495 | // A f allback to window.on load, that will alwa ys work | |
| 3496 | window .addEventL istener( " load", com pleted, fa lse ); | |
| 3497 | ||
| 3498 | // I f IE event model is used | |
| 3499 | } el se { | |
| 3500 | // Ens ure firing before on load, mayb e late but safe also for ifram es | |
| 3501 | docume nt.attachE vent( "onr eadystatec hange", co mpleted ); | |
| 3502 | ||
| 3503 | // A f allback to window.on load, that will alwa ys work | |
| 3504 | window .attachEve nt( "onloa d", comple ted ); | |
| 3505 | ||
| 3506 | // If IE and not a frame | |
| 3507 | // con tinually c heck to se e if the d ocument is ready | |
| 3508 | var to p = false; | |
| 3509 | ||
| 3510 | try { | |
| 3511 | top = wi ndow.frame Element == null && d ocument.do cumentElem ent; | |
| 3512 | } catc h(e) {} | |
| 3513 | ||
| 3514 | if ( t op && top. doScroll ) { | |
| 3515 | (functio n doScroll Check() { | |
| 3516 | if ( !jQue ry.isReady ) { | |
| 3517 | ||
| 3518 | tr y { | |
| 3519 | // U se the tri ck by Dieg o Perini | |
| 3520 | // h ttp://java script.nwb ox.com/IEC ontentLoad ed/ | |
| 3521 | top. doScroll(" left"); | |
| 3522 | } catch(e) { | |
| 3523 | retu rn setTime out( doScr ollCheck, 50 ); | |
| 3524 | } | |
| 3525 | ||
| 3526 | // detach al l dom read y events | |
| 3527 | de tach(); | |
| 3528 | ||
| 3529 | // and execu te any wai ting funct ions | |
| 3530 | jQ uery.ready (); | |
| 3531 | } | |
| 3532 | })(); | |
| 3533 | } | |
| 3534 | } | |
| 3535 | } | |
| 3536 | re turn ready List.promi se( obj ); | |
| 3537 | }; | |
| 3538 | ||
| 3539 | ||
| 3540 | var strund efined = t ypeof unde fined; | |
| 3541 | ||
| 3542 | ||
| 3543 | ||
| 3544 | // Support : IE<9 | |
| 3545 | // Iterati on over ob ject's inh erited pro perties be fore its o wn | |
| 3546 | var i; | |
| 3547 | for ( i in jQuery( s upport ) ) { | |
| 3548 | br eak; | |
| 3549 | } | |
| 3550 | support.ow nLast = i !== "0"; | |
| 3551 | ||
| 3552 | // Note: m ost suppor t tests ar e defined in their r espective modules. | |
| 3553 | // false u ntil the t est is run | |
| 3554 | support.in lineBlockN eedsLayout = false; | |
| 3555 | ||
| 3556 | // Execute ASAP in c ase we nee d to set b ody.style. zoom | |
| 3557 | jQuery(fun ction() { | |
| 3558 | // Minified: var a,b,c ,d | |
| 3559 | va r val, div , body, co ntainer; | |
| 3560 | ||
| 3561 | bo dy = docum ent.getEle mentsByTag Name( "bod y" )[ 0 ]; | |
| 3562 | if ( !body | | !body.st yle ) { | |
| 3563 | // R eturn for frameset d ocs that d on't have a body | |
| 3564 | retu rn; | |
| 3565 | } | |
| 3566 | ||
| 3567 | // Setup | |
| 3568 | di v = docume nt.createE lement( "d iv" ); | |
| 3569 | co ntainer = document.c reateEleme nt( "div" ); | |
| 3570 | co ntainer.st yle.cssTex t = "posit ion:absolu te;border: 0;width:0; height:0;t op:0;left: -9999px"; | |
| 3571 | bo dy.appendC hild( cont ainer ).ap pendChild( div ); | |
| 3572 | ||
| 3573 | if ( typeof div.style. zoom !== s trundefine d ) { | |
| 3574 | // S upport: IE <8 | |
| 3575 | // C heck if na tively blo ck-level e lements ac t like inl ine-block | |
| 3576 | // e lements wh en setting their dis play to 'i nline' and giving | |
| 3577 | // t hem layout | |
| 3578 | div. style.cssT ext = "dis play:inlin e;margin:0 ;border:0; padding:1p x;width:1p x;zoom:1"; | |
| 3579 | ||
| 3580 | supp ort.inline BlockNeeds Layout = v al = div.o ffsetWidth === 3; | |
| 3581 | if ( val ) { | |
| 3582 | // Pre vent IE 6 from affec ting layou t for posi tioned ele ments #110 48 | |
| 3583 | // Pre vent IE fr om shrinki ng the bod y in IE 7 mode #1286 9 | |
| 3584 | // Sup port: IE<8 | |
| 3585 | body.s tyle.zoom = 1; | |
| 3586 | } | |
| 3587 | } | |
| 3588 | ||
| 3589 | bo dy.removeC hild( cont ainer ); | |
| 3590 | }); | |
| 3591 | ||
| 3592 | ||
| 3593 | ||
| 3594 | ||
| 3595 | (function( ) { | |
| 3596 | va r div = do cument.cre ateElement ( "div" ); | |
| 3597 | ||
| 3598 | // Execute t he test on ly if not already ex ecuted in another mo dule. | |
| 3599 | if (support. deleteExpa ndo == nul l) { | |
| 3600 | // S upport: IE <9 | |
| 3601 | supp ort.delete Expando = true; | |
| 3602 | try { | |
| 3603 | delete div.test; | |
| 3604 | } ca tch( e ) { | |
| 3605 | suppor t.deleteEx pando = fa lse; | |
| 3606 | } | |
| 3607 | } | |
| 3608 | ||
| 3609 | // Null elem ents to av oid leaks in IE. | |
| 3610 | di v = null; | |
| 3611 | })(); | |
| 3612 | ||
| 3613 | ||
| 3614 | /** | |
| 3615 | * Determi nes whethe r an objec t can have data | |
| 3616 | */ | |
| 3617 | jQuery.acc eptData = function( elem ) { | |
| 3618 | va r noData = jQuery.no Data[ (ele m.nodeName + " ").to LowerCase( ) ], | |
| 3619 | node Type = +el em.nodeTyp e || 1; | |
| 3620 | ||
| 3621 | // Do not se t data on non-elemen t DOM node s because it will no t be clear ed (#8335) . | |
| 3622 | re turn nodeT ype !== 1 && nodeTyp e !== 9 ? | |
| 3623 | fals e : | |
| 3624 | ||
| 3625 | // N odes accep t data unl ess otherw ise specif ied; rejec tion can b e conditio nal | |
| 3626 | !noD ata || noD ata !== tr ue && elem .getAttrib ute("class id") === n oData; | |
| 3627 | }; | |
| 3628 | ||
| 3629 | ||
| 3630 | var rbrace = /^(?:\{ [\w\W]*\}| \[[\w\W]*\ ])$/, | |
| 3631 | rm ultiDash = /([A-Z])/ g; | |
| 3632 | ||
| 3633 | function d ataAttr( e lem, key, data ) { | |
| 3634 | // If nothin g was foun d internal ly, try to fetch any | |
| 3635 | // data from the HTML5 data-* at tribute | |
| 3636 | if ( data == = undefine d && elem. nodeType = == 1 ) { | |
| 3637 | ||
| 3638 | var name = "da ta-" + key .replace( rmultiDash , "-$1" ). toLowerCas e(); | |
| 3639 | ||
| 3640 | data = elem.ge tAttribute ( name ); | |
| 3641 | ||
| 3642 | if ( typeof da ta === "st ring" ) { | |
| 3643 | try { | |
| 3644 | data = d ata === "t rue" ? tru e : | |
| 3645 | data === " false" ? f alse : | |
| 3646 | data === " null" ? nu ll : | |
| 3647 | // Only co nvert to a number if it doesn' t change t he string | |
| 3648 | +data + "" === data ? +data : | |
| 3649 | rbrace.tes t( data ) ? jQuery.p arseJSON( data ) : | |
| 3650 | data; | |
| 3651 | } catc h( e ) {} | |
| 3652 | ||
| 3653 | // Mak e sure we set the da ta so it i sn't chang ed later | |
| 3654 | jQuery .data( ele m, key, da ta ); | |
| 3655 | ||
| 3656 | } el se { | |
| 3657 | data = undefined ; | |
| 3658 | } | |
| 3659 | } | |
| 3660 | ||
| 3661 | re turn data; | |
| 3662 | } | |
| 3663 | ||
| 3664 | // checks a cache ob ject for e mptiness | |
| 3665 | function i sEmptyData Object( ob j ) { | |
| 3666 | va r name; | |
| 3667 | fo r ( name i n obj ) { | |
| 3668 | ||
| 3669 | // i f the publ ic data ob ject is em pty, the p rivate is still empt y | |
| 3670 | if ( name === "data" && jQuery.isE mptyObject ( obj[name ] ) ) { | |
| 3671 | contin ue; | |
| 3672 | } | |
| 3673 | if ( name !== "toJSON" ) { | |
| 3674 | return false; | |
| 3675 | } | |
| 3676 | } | |
| 3677 | ||
| 3678 | re turn true; | |
| 3679 | } | |
| 3680 | ||
| 3681 | function i nternalDat a( elem, n ame, data, pvt /* In ternal Use Only */ ) { | |
| 3682 | if ( !jQuery .acceptDat a( elem ) ) { | |
| 3683 | retu rn; | |
| 3684 | } | |
| 3685 | ||
| 3686 | va r ret, thi sCache, | |
| 3687 | inte rnalKey = jQuery.exp ando, | |
| 3688 | ||
| 3689 | // W e have to handle DOM nodes and JS object s differen tly becaus e IE6-7 | |
| 3690 | // c an't GC ob ject refer ences prop erly acros s the DOM- JS boundar y | |
| 3691 | isNo de = elem. nodeType, | |
| 3692 | ||
| 3693 | // O nly DOM no des need t he global jQuery cac he; JS obj ect data i s | |
| 3694 | // a ttached di rectly to the object so GC can occur aut omatically | |
| 3695 | cach e = isNode ? jQuery. cache : el em, | |
| 3696 | ||
| 3697 | // O nly defini ng an ID f or JS obje cts if its cache alr eady exist s allows | |
| 3698 | // t he code to shortcut on the sam e path as a DOM node with no c ache | |
| 3699 | id = isNode ? elem[ inte rnalKey ] : elem[ in ternalKey ] && inter nalKey; | |
| 3700 | ||
| 3701 | // Avoid doi ng any mor e work tha n we need to when tr ying to ge t data on an | |
| 3702 | // object th at has no data at al l | |
| 3703 | if ( (!id || !cache[id ] || (!pvt && !cache [id].data) ) && data === undefi ned && typ eof name = == "string " ) { | |
| 3704 | retu rn; | |
| 3705 | } | |
| 3706 | ||
| 3707 | if ( !id ) { | |
| 3708 | // O nly DOM no des need a new uniqu e ID for e ach elemen t since th eir data | |
| 3709 | // e nds up in the global cache | |
| 3710 | if ( isNode ) { | |
| 3711 | id = e lem[ inter nalKey ] = deletedId s.pop() || jQuery.gu id++; | |
| 3712 | } el se { | |
| 3713 | id = i nternalKey ; | |
| 3714 | } | |
| 3715 | } | |
| 3716 | ||
| 3717 | if ( !cache[ id ] ) { | |
| 3718 | // A void expos ing jQuery metadata on plain J S objects when the o bject | |
| 3719 | // i s serializ ed using J SON.string ify | |
| 3720 | cach e[ id ] = isNode ? { } : { toJS ON: jQuery .noop }; | |
| 3721 | } | |
| 3722 | ||
| 3723 | // An object can be pa ssed to jQ uery.data instead of a key/val ue pair; t his gets | |
| 3724 | // shallow c opied over onto the existing c ache | |
| 3725 | if ( typeof name === " object" || typeof na me === "fu nction" ) { | |
| 3726 | if ( pvt ) { | |
| 3727 | cache[ id ] = jQ uery.exten d( cache[ id ], name ); | |
| 3728 | } el se { | |
| 3729 | cache[ id ].data = jQuery. extend( ca che[ id ]. data, name ); | |
| 3730 | } | |
| 3731 | } | |
| 3732 | ||
| 3733 | th isCache = cache[ id ]; | |
| 3734 | ||
| 3735 | // jQuery da ta() is st ored in a separate o bject insi de the obj ect's inte rnal data | |
| 3736 | // cache in order to a void key c ollisions between in ternal dat a and user -defined | |
| 3737 | // data. | |
| 3738 | if ( !pvt ) { | |
| 3739 | if ( !thisCach e.data ) { | |
| 3740 | thisCa che.data = {}; | |
| 3741 | } | |
| 3742 | ||
| 3743 | this Cache = th isCache.da ta; | |
| 3744 | } | |
| 3745 | ||
| 3746 | if ( data != = undefine d ) { | |
| 3747 | this Cache[ jQu ery.camelC ase( name ) ] = data ; | |
| 3748 | } | |
| 3749 | ||
| 3750 | // Check for both conv erted-to-c amel and n on-convert ed data pr operty nam es | |
| 3751 | // If a data property was specif ied | |
| 3752 | if ( typeof name === " string" ) { | |
| 3753 | ||
| 3754 | // F irst Try t o find as- is propert y data | |
| 3755 | ret = thisCach e[ name ]; | |
| 3756 | ||
| 3757 | // T est for nu ll|undefin ed propert y data | |
| 3758 | if ( ret == nu ll ) { | |
| 3759 | ||
| 3760 | // Try to find t he camelCa sed proper ty | |
| 3761 | ret = thisCache[ jQuery.ca melCase( n ame ) ]; | |
| 3762 | } | |
| 3763 | } else { | |
| 3764 | ret = thisCach e; | |
| 3765 | } | |
| 3766 | ||
| 3767 | re turn ret; | |
| 3768 | } | |
| 3769 | ||
| 3770 | function i nternalRem oveData( e lem, name, pvt ) { | |
| 3771 | if ( !jQuery .acceptDat a( elem ) ) { | |
| 3772 | retu rn; | |
| 3773 | } | |
| 3774 | ||
| 3775 | va r thisCach e, i, | |
| 3776 | isNo de = elem. nodeType, | |
| 3777 | ||
| 3778 | // S ee jQuery. data for m ore inform ation | |
| 3779 | cach e = isNode ? jQuery. cache : el em, | |
| 3780 | id = isNode ? elem[ jQue ry.expando ] : jQuer y.expando; | |
| 3781 | ||
| 3782 | // If there is already no cache entry for this objec t, there i s no | |
| 3783 | // purpose i n continui ng | |
| 3784 | if ( !cache[ id ] ) { | |
| 3785 | retu rn; | |
| 3786 | } | |
| 3787 | ||
| 3788 | if ( name ) { | |
| 3789 | ||
| 3790 | this Cache = pv t ? cache[ id ] : ca che[ id ]. data; | |
| 3791 | ||
| 3792 | if ( thisCache ) { | |
| 3793 | ||
| 3794 | // Sup port array or space separated string nam es for dat a keys | |
| 3795 | if ( ! jQuery.isA rray( name ) ) { | |
| 3796 | ||
| 3797 | // try t he string as a key b efore any manipulati on | |
| 3798 | if ( nam e in thisC ache ) { | |
| 3799 | name = [ n ame ]; | |
| 3800 | } else { | |
| 3801 | ||
| 3802 | // split t he camel c ased versi on by spac es unless a key with the space s exists | |
| 3803 | name = jQu ery.camelC ase( name ); | |
| 3804 | if ( name in thisCac he ) { | |
| 3805 | na me = [ nam e ]; | |
| 3806 | } else { | |
| 3807 | na me = name. split(" ") ; | |
| 3808 | } | |
| 3809 | } | |
| 3810 | } else { | |
| 3811 | // If "n ame" is an array of keys... | |
| 3812 | // When data is in itially cr eated, via ("key", " val") sign ature, | |
| 3813 | // keys will be co nverted to camelCase . | |
| 3814 | // Since there is no way to tell _how_ a key was added, re move | |
| 3815 | // both plain key and camelC ase key. # 12786 | |
| 3816 | // This will only penalize t he array a rgument pa th. | |
| 3817 | name = n ame.concat ( jQuery.m ap( name, jQuery.cam elCase ) ) ; | |
| 3818 | } | |
| 3819 | ||
| 3820 | i = na me.length; | |
| 3821 | while ( i-- ) { | |
| 3822 | delete t hisCache[ name[i] ]; | |
| 3823 | } | |
| 3824 | ||
| 3825 | // If there is n o data lef t in the c ache, we w ant to con tinue | |
| 3826 | // and let the c ache objec t itself g et destroy ed | |
| 3827 | if ( p vt ? !isEm ptyDataObj ect(thisCa che) : !jQ uery.isEmp tyObject(t hisCache) ) { | |
| 3828 | return; | |
| 3829 | } | |
| 3830 | } | |
| 3831 | } | |
| 3832 | ||
| 3833 | // See jQuer y.data for more info rmation | |
| 3834 | if ( !pvt ) { | |
| 3835 | dele te cache[ id ].data; | |
| 3836 | ||
| 3837 | // D on't destr oy the par ent cache unless the internal data objec t | |
| 3838 | // h ad been th e only thi ng left in it | |
| 3839 | if ( !isEmptyD ataObject( cache[ id ] ) ) { | |
| 3840 | return ; | |
| 3841 | } | |
| 3842 | } | |
| 3843 | ||
| 3844 | // Destroy t he cache | |
| 3845 | if ( isNode ) { | |
| 3846 | jQue ry.cleanDa ta( [ elem ], true ) ; | |
| 3847 | ||
| 3848 | // Use delet e when sup ported for expandos or `cache` is not a window per isWindow (#10080) | |
| 3849 | /* jshint eq eqeq: fals e */ | |
| 3850 | } else if ( support.de leteExpand o || cache != cache. window ) { | |
| 3851 | /* j shint eqeq eq: true * / | |
| 3852 | dele te cache[ id ]; | |
| 3853 | ||
| 3854 | // When all else fails , null | |
| 3855 | } else { | |
| 3856 | cach e[ id ] = null; | |
| 3857 | } | |
| 3858 | } | |
| 3859 | ||
| 3860 | jQuery.ext end({ | |
| 3861 | ca che: {}, | |
| 3862 | ||
| 3863 | // The follo wing eleme nts (space -suffixed to avoid O bject.prot otype coll isions) | |
| 3864 | // throw unc atchable e xceptions if you att empt to se t expando properties | |
| 3865 | no Data: { | |
| 3866 | "app let ": tru e, | |
| 3867 | "emb ed ": true , | |
| 3868 | // . ..but Flas h objects (which hav e this cla ssid) *can * handle e xpandos | |
| 3869 | "obj ect ": "cl sid:D27CDB 6E-AE6D-11 cf-96B8-44 4553540000 " | |
| 3870 | }, | |
| 3871 | ||
| 3872 | ha sData: fun ction( ele m ) { | |
| 3873 | elem = elem.no deType ? j Query.cach e[ elem[jQ uery.expan do] ] : el em[ jQuery .expando ] ; | |
| 3874 | retu rn !!elem && !isEmpt yDataObjec t( elem ); | |
| 3875 | }, | |
| 3876 | ||
| 3877 | da ta: functi on( elem, name, data ) { | |
| 3878 | retu rn interna lData( ele m, name, d ata ); | |
| 3879 | }, | |
| 3880 | ||
| 3881 | re moveData: function( elem, name ) { | |
| 3882 | retu rn interna lRemoveDat a( elem, n ame ); | |
| 3883 | }, | |
| 3884 | ||
| 3885 | // For inter nal use on ly. | |
| 3886 | _d ata: funct ion( elem, name, dat a ) { | |
| 3887 | retu rn interna lData( ele m, name, d ata, true ); | |
| 3888 | }, | |
| 3889 | ||
| 3890 | _r emoveData: function( elem, nam e ) { | |
| 3891 | retu rn interna lRemoveDat a( elem, n ame, true ); | |
| 3892 | } | |
| 3893 | }); | |
| 3894 | ||
| 3895 | jQuery.fn. extend({ | |
| 3896 | da ta: functi on( key, v alue ) { | |
| 3897 | var i, name, d ata, | |
| 3898 | elem = this[0], | |
| 3899 | attrs = elem && elem.attri butes; | |
| 3900 | ||
| 3901 | // S pecial exp ections of .data bas ically thw art jQuery .access, | |
| 3902 | // s o implemen t the rele vant behav ior oursel ves | |
| 3903 | ||
| 3904 | // G ets all va lues | |
| 3905 | if ( key === u ndefined ) { | |
| 3906 | if ( t his.length ) { | |
| 3907 | data = j Query.data ( elem ); | |
| 3908 | ||
| 3909 | if ( ele m.nodeType === 1 && !jQuery._d ata( elem, "parsedAt trs" ) ) { | |
| 3910 | i = attrs. length; | |
| 3911 | while ( i- - ) { | |
| 3912 | ||
| 3913 | // Support: IE11+ | |
| 3914 | // The attrs elements can be nul l (#14894) | |
| 3915 | if ( attrs[ i ] ) { | |
| 3916 | name = attrs[ i ].name; | |
| 3917 | if ( name.inde xOf( "data -" ) === 0 ) { | |
| 3918 | name = jQuery.ca melCase( n ame.slice( 5) ); | |
| 3919 | dataAt tr( elem, name, data [ name ] ) ; | |
| 3920 | } | |
| 3921 | } | |
| 3922 | } | |
| 3923 | jQuery._da ta( elem, "parsedAtt rs", true ); | |
| 3924 | } | |
| 3925 | } | |
| 3926 | ||
| 3927 | return data; | |
| 3928 | } | |
| 3929 | ||
| 3930 | // S ets multip le values | |
| 3931 | if ( typeof ke y === "obj ect" ) { | |
| 3932 | return this.each (function( ) { | |
| 3933 | jQuery.d ata( this, key ); | |
| 3934 | }); | |
| 3935 | } | |
| 3936 | ||
| 3937 | retu rn argumen ts.length > 1 ? | |
| 3938 | ||
| 3939 | // Set s one valu e | |
| 3940 | this.e ach(functi on() { | |
| 3941 | jQuery.d ata( this, key, valu e ); | |
| 3942 | }) : | |
| 3943 | ||
| 3944 | // Get s one valu e | |
| 3945 | // Try to fetch any intern ally store d data fir st | |
| 3946 | elem ? dataAttr( elem, key , jQuery.d ata( elem, key ) ) : undefined ; | |
| 3947 | }, | |
| 3948 | ||
| 3949 | re moveData: function( key ) { | |
| 3950 | retu rn this.ea ch(functio n() { | |
| 3951 | jQuery .removeDat a( this, k ey ); | |
| 3952 | }); | |
| 3953 | } | |
| 3954 | }); | |
| 3955 | ||
| 3956 | ||
| 3957 | jQuery.ext end({ | |
| 3958 | qu eue: funct ion( elem, type, dat a ) { | |
| 3959 | var queue; | |
| 3960 | ||
| 3961 | if ( elem ) { | |
| 3962 | type = ( type || "fx" ) + "queue"; | |
| 3963 | queue = jQuery._ data( elem , type ); | |
| 3964 | ||
| 3965 | // Spe ed up dequ eue by get ting out q uickly if this is ju st a looku p | |
| 3966 | if ( d ata ) { | |
| 3967 | if ( !qu eue || jQu ery.isArra y(data) ) { | |
| 3968 | queue = jQ uery._data ( elem, ty pe, jQuery .makeArray (data) ); | |
| 3969 | } else { | |
| 3970 | queue.push ( data ); | |
| 3971 | } | |
| 3972 | } | |
| 3973 | return queue || []; | |
| 3974 | } | |
| 3975 | }, | |
| 3976 | ||
| 3977 | de queue: fun ction( ele m, type ) { | |
| 3978 | type = type || "fx"; | |
| 3979 | ||
| 3980 | var queue = jQ uery.queue ( elem, ty pe ), | |
| 3981 | startL ength = qu eue.length , | |
| 3982 | fn = q ueue.shift (), | |
| 3983 | hooks = jQuery._ queueHooks ( elem, ty pe ), | |
| 3984 | next = function( ) { | |
| 3985 | jQuery.d equeue( el em, type ) ; | |
| 3986 | }; | |
| 3987 | ||
| 3988 | // I f the fx q ueue is de queued, al ways remov e the prog ress senti nel | |
| 3989 | if ( fn === "i nprogress" ) { | |
| 3990 | fn = q ueue.shift (); | |
| 3991 | startL ength--; | |
| 3992 | } | |
| 3993 | ||
| 3994 | if ( fn ) { | |
| 3995 | ||
| 3996 | // Add a progres s sentinel to preven t the fx q ueue from being | |
| 3997 | // aut omatically dequeued | |
| 3998 | if ( t ype === "f x" ) { | |
| 3999 | queue.un shift( "in progress" ); | |
| 4000 | } | |
| 4001 | ||
| 4002 | // cle ar up the last queue stop func tion | |
| 4003 | delete hooks.sto p; | |
| 4004 | fn.cal l( elem, n ext, hooks ); | |
| 4005 | } | |
| 4006 | ||
| 4007 | if ( !startLen gth && hoo ks ) { | |
| 4008 | hooks. empty.fire (); | |
| 4009 | } | |
| 4010 | }, | |
| 4011 | ||
| 4012 | // not inten ded for pu blic consu mption - g enerates a queueHook s object, or returns the curre nt one | |
| 4013 | _q ueueHooks: function( elem, typ e ) { | |
| 4014 | var key = type + "queueH ooks"; | |
| 4015 | retu rn jQuery. _data( ele m, key ) | | jQuery._ data( elem , key, { | |
| 4016 | empty: jQuery.Ca llbacks("o nce memory ").add(fun ction() { | |
| 4017 | jQuery._ removeData ( elem, ty pe + "queu e" ); | |
| 4018 | jQuery._ removeData ( elem, ke y ); | |
| 4019 | }) | |
| 4020 | }); | |
| 4021 | } | |
| 4022 | }); | |
| 4023 | ||
| 4024 | jQuery.fn. extend({ | |
| 4025 | qu eue: funct ion( type, data ) { | |
| 4026 | var setter = 2 ; | |
| 4027 | ||
| 4028 | if ( typeof ty pe !== "st ring" ) { | |
| 4029 | data = type; | |
| 4030 | type = "fx"; | |
| 4031 | setter --; | |
| 4032 | } | |
| 4033 | ||
| 4034 | if ( arguments .length < setter ) { | |
| 4035 | return jQuery.qu eue( this[ 0], type ) ; | |
| 4036 | } | |
| 4037 | ||
| 4038 | retu rn data == = undefine d ? | |
| 4039 | this : | |
| 4040 | this.e ach(functi on() { | |
| 4041 | var queu e = jQuery .queue( th is, type, data ); | |
| 4042 | ||
| 4043 | // ensur e a hooks for this q ueue | |
| 4044 | jQuery._ queueHooks ( this, ty pe ); | |
| 4045 | ||
| 4046 | if ( typ e === "fx" && queue[ 0] !== "in progress" ) { | |
| 4047 | jQuery.deq ueue( this , type ); | |
| 4048 | } | |
| 4049 | }); | |
| 4050 | }, | |
| 4051 | de queue: fun ction( typ e ) { | |
| 4052 | retu rn this.ea ch(functio n() { | |
| 4053 | jQuery .dequeue( this, type ); | |
| 4054 | }); | |
| 4055 | }, | |
| 4056 | cl earQueue: function( type ) { | |
| 4057 | retu rn this.qu eue( type || "fx", [ ] ); | |
| 4058 | }, | |
| 4059 | // Get a pro mise resol ved when q ueues of a certain t ype | |
| 4060 | // are empti ed (fx is the type b y default) | |
| 4061 | pr omise: fun ction( typ e, obj ) { | |
| 4062 | var tmp, | |
| 4063 | count = 1, | |
| 4064 | defer = jQuery.D eferred(), | |
| 4065 | elemen ts = this, | |
| 4066 | i = th is.length, | |
| 4067 | resolv e = functi on() { | |
| 4068 | if ( !( --count ) ) { | |
| 4069 | defer.reso lveWith( e lements, [ elements ] ); | |
| 4070 | } | |
| 4071 | }; | |
| 4072 | ||
| 4073 | if ( typeof ty pe !== "st ring" ) { | |
| 4074 | obj = type; | |
| 4075 | type = undefined ; | |
| 4076 | } | |
| 4077 | type = type || "fx"; | |
| 4078 | ||
| 4079 | whil e ( i-- ) { | |
| 4080 | tmp = jQuery._da ta( elemen ts[ i ], t ype + "que ueHooks" ) ; | |
| 4081 | if ( t mp && tmp. empty ) { | |
| 4082 | count++; | |
| 4083 | tmp.empt y.add( res olve ); | |
| 4084 | } | |
| 4085 | } | |
| 4086 | reso lve(); | |
| 4087 | retu rn defer.p romise( ob j ); | |
| 4088 | } | |
| 4089 | }); | |
| 4090 | var pnum = (/[+-]?(? :\d*\.|)\d +(?:[eE][+ -]?\d+|)/) .source; | |
| 4091 | ||
| 4092 | var cssExp and = [ "T op", "Righ t", "Botto m", "Left" ]; | |
| 4093 | ||
| 4094 | var isHidd en = funct ion( elem, el ) { | |
| 4095 | // i sHidden mi ght be cal led from j Query#filt er functio n; | |
| 4096 | // i n that cas e, element will be s econd argu ment | |
| 4097 | elem = el || e lem; | |
| 4098 | retu rn jQuery. css( elem, "display" ) === "no ne" || !jQ uery.conta ins( elem. ownerDocum ent, elem ); | |
| 4099 | }; | |
| 4100 | ||
| 4101 | ||
| 4102 | ||
| 4103 | // Multifu nctional m ethod to g et and set values of a collect ion | |
| 4104 | // The val ue/s can o ptionally be execute d if it's a function | |
| 4105 | var access = jQuery. access = f unction( e lems, fn, key, value , chainabl e, emptyGe t, raw ) { | |
| 4106 | va r i = 0, | |
| 4107 | leng th = elems .length, | |
| 4108 | bulk = key == null; | |
| 4109 | ||
| 4110 | // Sets many values | |
| 4111 | if ( jQuery. type( key ) === "obj ect" ) { | |
| 4112 | chai nable = tr ue; | |
| 4113 | for ( i in key ) { | |
| 4114 | jQuery .access( e lems, fn, i, key[i], true, emp tyGet, raw ); | |
| 4115 | } | |
| 4116 | ||
| 4117 | // Sets one value | |
| 4118 | } else if ( value !== undefined ) { | |
| 4119 | chai nable = tr ue; | |
| 4120 | ||
| 4121 | if ( !jQuery.i sFunction( value ) ) { | |
| 4122 | raw = true; | |
| 4123 | } | |
| 4124 | ||
| 4125 | if ( bulk ) { | |
| 4126 | // Bul k operatio ns run aga inst the e ntire set | |
| 4127 | if ( r aw ) { | |
| 4128 | fn.call( elems, va lue ); | |
| 4129 | fn = nul l; | |
| 4130 | ||
| 4131 | // ... except whe n executin g function values | |
| 4132 | } else { | |
| 4133 | bulk = f n; | |
| 4134 | fn = fun ction( ele m, key, va lue ) { | |
| 4135 | return bul k.call( jQ uery( elem ), value ); | |
| 4136 | }; | |
| 4137 | } | |
| 4138 | } | |
| 4139 | ||
| 4140 | if ( fn ) { | |
| 4141 | for ( ; i < leng th; i++ ) { | |
| 4142 | fn( elem s[i], key, raw ? val ue : value .call( ele ms[i], i, fn( elems[ i], key ) ) ); | |
| 4143 | } | |
| 4144 | } | |
| 4145 | } | |
| 4146 | ||
| 4147 | re turn chain able ? | |
| 4148 | elem s : | |
| 4149 | ||
| 4150 | // G ets | |
| 4151 | bulk ? | |
| 4152 | fn.cal l( elems ) : | |
| 4153 | length ? fn( ele ms[0], key ) : empty Get; | |
| 4154 | }; | |
| 4155 | var rcheck ableType = (/^(?:che ckbox|radi o)$/i); | |
| 4156 | ||
| 4157 | ||
| 4158 | ||
| 4159 | (function( ) { | |
| 4160 | // Minified: var a,b,c | |
| 4161 | va r input = document.c reateEleme nt( "input " ), | |
| 4162 | div = document .createEle ment( "div " ), | |
| 4163 | frag ment = doc ument.crea teDocument Fragment() ; | |
| 4164 | ||
| 4165 | // Setup | |
| 4166 | di v.innerHTM L = " <li nk/><table ></table>< a href='/a '>a</a><in put type=' checkbox'/ >"; | |
| 4167 | ||
| 4168 | // IE strips leading w hitespace when .inne rHTML is u sed | |
| 4169 | su pport.lead ingWhitesp ace = div. firstChild .nodeType === 3; | |
| 4170 | ||
| 4171 | // Make sure that tbod y elements aren't au tomaticall y inserted | |
| 4172 | // IE will i nsert them into empt y tables | |
| 4173 | su pport.tbod y = !div.g etElements ByTagName( "tbody" ) .length; | |
| 4174 | ||
| 4175 | // Make sure that link elements get serial ized corre ctly by in nerHTML | |
| 4176 | // This requ ires a wra pper eleme nt in IE | |
| 4177 | su pport.html Serialize = !!div.ge tElementsB yTagName( "link" ).l ength; | |
| 4178 | ||
| 4179 | // Makes sur e cloning an html5 e lement doe s not caus e problems | |
| 4180 | // Where out erHTML is undefined, this stil l works | |
| 4181 | su pport.html 5Clone = | |
| 4182 | docu ment.creat eElement( "nav" ).cl oneNode( t rue ).oute rHTML !== "<:nav></: nav>"; | |
| 4183 | ||
| 4184 | // Check if a disconne cted check box will r etain its checked | |
| 4185 | // value of true after appended to the DOM (IE6/7) | |
| 4186 | in put.type = "checkbox "; | |
| 4187 | in put.checke d = true; | |
| 4188 | fr agment.app endChild( input ); | |
| 4189 | su pport.appe ndChecked = input.ch ecked; | |
| 4190 | ||
| 4191 | // Make sure textarea (and check box) defau ltValue is properly cloned | |
| 4192 | // Support: IE6-IE11+ | |
| 4193 | di v.innerHTM L = "<text area>x</te xtarea>"; | |
| 4194 | su pport.noCl oneChecked = !!div.c loneNode( true ).las tChild.def aultValue; | |
| 4195 | ||
| 4196 | // #11217 - WebKit los es check w hen the na me is afte r the chec ked attrib ute | |
| 4197 | fr agment.app endChild( div ); | |
| 4198 | di v.innerHTM L = "<inpu t type='ra dio' check ed='checke d' name='t '/>"; | |
| 4199 | ||
| 4200 | // Support: Safari 5.1 , iOS 5.1, Android 4 .x, Androi d 2.3 | |
| 4201 | // old WebKi t doesn't clone chec ked state correctly in fragmen ts | |
| 4202 | su pport.chec kClone = d iv.cloneNo de( true ) .cloneNode ( true ).l astChild.c hecked; | |
| 4203 | ||
| 4204 | // Support: IE<9 | |
| 4205 | // Opera doe s not clon e events ( and typeof div.attac hEvent === undefined ). | |
| 4206 | // IE9-10 cl ones event s bound vi a attachEv ent, but t hey don't trigger wi th .click( ) | |
| 4207 | su pport.noCl oneEvent = true; | |
| 4208 | if ( div.att achEvent ) { | |
| 4209 | div. attachEven t( "onclic k", functi on() { | |
| 4210 | suppor t.noCloneE vent = fal se; | |
| 4211 | }); | |
| 4212 | ||
| 4213 | div. cloneNode( true ).cl ick(); | |
| 4214 | } | |
| 4215 | ||
| 4216 | // Execute t he test on ly if not already ex ecuted in another mo dule. | |
| 4217 | if (support. deleteExpa ndo == nul l) { | |
| 4218 | // S upport: IE <9 | |
| 4219 | supp ort.delete Expando = true; | |
| 4220 | try { | |
| 4221 | delete div.test; | |
| 4222 | } ca tch( e ) { | |
| 4223 | suppor t.deleteEx pando = fa lse; | |
| 4224 | } | |
| 4225 | } | |
| 4226 | })(); | |
| 4227 | ||
| 4228 | ||
| 4229 | (function( ) { | |
| 4230 | va r i, event Name, | |
| 4231 | div = document .createEle ment( "div " ); | |
| 4232 | ||
| 4233 | // Support: IE<9 (lack submit/ch ange bubbl e), Firefo x 23+ (lac k focusin event) | |
| 4234 | fo r ( i in { submit: t rue, chang e: true, f ocusin: tr ue }) { | |
| 4235 | even tName = "o n" + i; | |
| 4236 | ||
| 4237 | if ( !(support [ i + "Bub bles" ] = eventName in window) ) { | |
| 4238 | // Bew are of CSP restricti ons (https ://develop er.mozilla .org/en/Se curity/CSP ) | |
| 4239 | div.se tAttribute ( eventNam e, "t" ); | |
| 4240 | suppor t[ i + "Bu bbles" ] = div.attri butes[ eve ntName ].e xpando === false; | |
| 4241 | } | |
| 4242 | } | |
| 4243 | ||
| 4244 | // Null elem ents to av oid leaks in IE. | |
| 4245 | di v = null; | |
| 4246 | })(); | |
| 4247 | ||
| 4248 | ||
| 4249 | var rformE lems = /^( ?:input|se lect|texta rea)$/i, | |
| 4250 | rk eyEvent = /^key/, | |
| 4251 | rm ouseEvent = /^(?:mou se|pointer |contextme nu)|click/ , | |
| 4252 | rf ocusMorph = /^(?:foc usinfocus| focusoutbl ur)$/, | |
| 4253 | rt ypenamespa ce = /^([^ .]*)(?:\.( .+)|)$/; | |
| 4254 | ||
| 4255 | function r eturnTrue( ) { | |
| 4256 | re turn true; | |
| 4257 | } | |
| 4258 | ||
| 4259 | function r eturnFalse () { | |
| 4260 | re turn false ; | |
| 4261 | } | |
| 4262 | ||
| 4263 | function s afeActiveE lement() { | |
| 4264 | tr y { | |
| 4265 | retu rn documen t.activeEl ement; | |
| 4266 | } catch ( er r ) { } | |
| 4267 | } | |
| 4268 | ||
| 4269 | /* | |
| 4270 | * Helper functions for managi ng events -- not par t of the p ublic inte rface. | |
| 4271 | * Props t o Dean Edw ards' addE vent libra ry for man y of the i deas. | |
| 4272 | */ | |
| 4273 | jQuery.eve nt = { | |
| 4274 | ||
| 4275 | gl obal: {}, | |
| 4276 | ||
| 4277 | ad d: functio n( elem, t ypes, hand ler, data, selector ) { | |
| 4278 | var tmp, event s, t, hand leObjIn, | |
| 4279 | specia l, eventHa ndle, hand leObj, | |
| 4280 | handle rs, type, namespaces , origType , | |
| 4281 | elemDa ta = jQuer y._data( e lem ); | |
| 4282 | ||
| 4283 | // D on't attac h events t o noData o r text/com ment nodes (but allo w plain ob jects) | |
| 4284 | if ( !elemData ) { | |
| 4285 | return ; | |
| 4286 | } | |
| 4287 | ||
| 4288 | // C aller can pass in an object of custom da ta in lieu of the ha ndler | |
| 4289 | if ( handler.h andler ) { | |
| 4290 | handle ObjIn = ha ndler; | |
| 4291 | handle r = handle ObjIn.hand ler; | |
| 4292 | select or = handl eObjIn.sel ector; | |
| 4293 | } | |
| 4294 | ||
| 4295 | // M ake sure t hat the ha ndler has a unique I D, used to find/remo ve it late r | |
| 4296 | if ( !handler. guid ) { | |
| 4297 | handle r.guid = j Query.guid ++; | |
| 4298 | } | |
| 4299 | ||
| 4300 | // I nit the el ement's ev ent struct ure and ma in handler , if this is the fir st | |
| 4301 | if ( !(events = elemData .events) ) { | |
| 4302 | events = elemDat a.events = {}; | |
| 4303 | } | |
| 4304 | if ( !(eventHa ndle = ele mData.hand le) ) { | |
| 4305 | eventH andle = el emData.han dle = func tion( e ) { | |
| 4306 | // Disca rd the sec ond event of a jQuer y.event.tr igger() an d | |
| 4307 | // when an event i s called a fter a pag e has unlo aded | |
| 4308 | return t ypeof jQue ry !== str undefined && (!e || jQuery.eve nt.trigger ed !== e.t ype) ? | |
| 4309 | jQuery.eve nt.dispatc h.apply( e ventHandle .elem, arg uments ) : | |
| 4310 | undefined; | |
| 4311 | }; | |
| 4312 | // Add elem as a property of the han dle fn to prevent a memory lea k with IE non-native events | |
| 4313 | eventH andle.elem = elem; | |
| 4314 | } | |
| 4315 | ||
| 4316 | // H andle mult iple event s separate d by a spa ce | |
| 4317 | type s = ( type s || "" ). match( rno twhite ) | | [ "" ]; | |
| 4318 | t = types.leng th; | |
| 4319 | whil e ( t-- ) { | |
| 4320 | tmp = rtypenames pace.exec( types[t] ) || []; | |
| 4321 | type = origType = tmp[1]; | |
| 4322 | namesp aces = ( t mp[2] || " " ).split( "." ).sor t(); | |
| 4323 | ||
| 4324 | // The re *must* be a type, no attach ing namesp ace-only h andlers | |
| 4325 | if ( ! type ) { | |
| 4326 | continue ; | |
| 4327 | } | |
| 4328 | ||
| 4329 | // If event chan ges its ty pe, use th e special event hand lers for t he changed type | |
| 4330 | specia l = jQuery .event.spe cial[ type ] || {}; | |
| 4331 | ||
| 4332 | // If selector d efined, de termine sp ecial even t api type , otherwis e given ty pe | |
| 4333 | type = ( selecto r ? specia l.delegate Type : spe cial.bindT ype ) || t ype; | |
| 4334 | ||
| 4335 | // Upd ate specia l based on newly res et type | |
| 4336 | specia l = jQuery .event.spe cial[ type ] || {}; | |
| 4337 | ||
| 4338 | // han dleObj is passed to all event handlers | |
| 4339 | handle Obj = jQue ry.extend( { | |
| 4340 | type: ty pe, | |
| 4341 | origType : origType , | |
| 4342 | data: da ta, | |
| 4343 | handler: handler, | |
| 4344 | guid: ha ndler.guid , | |
| 4345 | selector : selector , | |
| 4346 | needsCon text: sele ctor && jQ uery.expr. match.need sContext.t est( selec tor ), | |
| 4347 | namespac e: namespa ces.join(" .") | |
| 4348 | }, han dleObjIn ) ; | |
| 4349 | ||
| 4350 | // Ini t the even t handler queue if w e're the f irst | |
| 4351 | if ( ! (handlers = events[ type ]) ) { | |
| 4352 | handlers = events[ type ] = []; | |
| 4353 | handlers .delegateC ount = 0; | |
| 4354 | ||
| 4355 | // Only use addEve ntListener /attachEve nt if the special ev ents handl er returns false | |
| 4356 | if ( !sp ecial.setu p || speci al.setup.c all( elem, data, nam espaces, e ventHandle ) === fal se ) { | |
| 4357 | // Bind th e global e vent handl er to the element | |
| 4358 | if ( elem. addEventLi stener ) { | |
| 4359 | el em.addEven tListener( type, eve ntHandle, false ); | |
| 4360 | ||
| 4361 | } else if ( elem.att achEvent ) { | |
| 4362 | el em.attachE vent( "on" + type, e ventHandle ); | |
| 4363 | } | |
| 4364 | } | |
| 4365 | } | |
| 4366 | ||
| 4367 | if ( s pecial.add ) { | |
| 4368 | special. add.call( elem, hand leObj ); | |
| 4369 | ||
| 4370 | if ( !ha ndleObj.ha ndler.guid ) { | |
| 4371 | handleObj. handler.gu id = handl er.guid; | |
| 4372 | } | |
| 4373 | } | |
| 4374 | ||
| 4375 | // Add to the el ement's ha ndler list , delegate s in front | |
| 4376 | if ( s elector ) { | |
| 4377 | handlers .splice( h andlers.de legateCoun t++, 0, ha ndleObj ); | |
| 4378 | } else { | |
| 4379 | handlers .push( han dleObj ); | |
| 4380 | } | |
| 4381 | ||
| 4382 | // Kee p track of which eve nts have e ver been u sed, for e vent optim ization | |
| 4383 | jQuery .event.glo bal[ type ] = true; | |
| 4384 | } | |
| 4385 | ||
| 4386 | // N ullify ele m to preve nt memory leaks in I E | |
| 4387 | elem = null; | |
| 4388 | }, | |
| 4389 | ||
| 4390 | // Detach an event or set of eve nts from a n element | |
| 4391 | re move: func tion( elem , types, h andler, se lector, ma ppedTypes ) { | |
| 4392 | var j, handleO bj, tmp, | |
| 4393 | origCo unt, t, ev ents, | |
| 4394 | specia l, handler s, type, | |
| 4395 | namesp aces, orig Type, | |
| 4396 | elemDa ta = jQuer y.hasData( elem ) && jQuery._d ata( elem ); | |
| 4397 | ||
| 4398 | if ( !elemData || !(even ts = elemD ata.events ) ) { | |
| 4399 | return ; | |
| 4400 | } | |
| 4401 | ||
| 4402 | // O nce for ea ch type.na mespace in types; ty pe may be omitted | |
| 4403 | type s = ( type s || "" ). match( rno twhite ) | | [ "" ]; | |
| 4404 | t = types.leng th; | |
| 4405 | whil e ( t-- ) { | |
| 4406 | tmp = rtypenames pace.exec( types[t] ) || []; | |
| 4407 | type = origType = tmp[1]; | |
| 4408 | namesp aces = ( t mp[2] || " " ).split( "." ).sor t(); | |
| 4409 | ||
| 4410 | // Unb ind all ev ents (on t his namesp ace, if pr ovided) fo r the elem ent | |
| 4411 | if ( ! type ) { | |
| 4412 | for ( ty pe in even ts ) { | |
| 4413 | jQuery.eve nt.remove( elem, typ e + types[ t ], hand ler, selec tor, true ); | |
| 4414 | } | |
| 4415 | continue ; | |
| 4416 | } | |
| 4417 | ||
| 4418 | specia l = jQuery .event.spe cial[ type ] || {}; | |
| 4419 | type = ( selecto r ? specia l.delegate Type : spe cial.bindT ype ) || t ype; | |
| 4420 | handle rs = event s[ type ] || []; | |
| 4421 | tmp = tmp[2] && new RegExp ( "(^|\\.) " + namesp aces.join( "\\.(?:.*\ \.|)") + " (\\.|$)" ) ; | |
| 4422 | ||
| 4423 | // Rem ove matchi ng events | |
| 4424 | origCo unt = j = handlers.l ength; | |
| 4425 | while ( j-- ) { | |
| 4426 | handleOb j = handle rs[ j ]; | |
| 4427 | ||
| 4428 | if ( ( m appedTypes || origTy pe === han dleObj.ori gType ) && | |
| 4429 | ( !handler || handle r.guid === handleObj .guid ) && | |
| 4430 | ( !tmp || tmp.test( handleObj. namespace ) ) && | |
| 4431 | ( !selecto r || selec tor === ha ndleObj.se lector || selector = == "**" && handleObj .selector ) ) { | |
| 4432 | handlers.s plice( j, 1 ); | |
| 4433 | ||
| 4434 | if ( handl eObj.selec tor ) { | |
| 4435 | ha ndlers.del egateCount --; | |
| 4436 | } | |
| 4437 | if ( speci al.remove ) { | |
| 4438 | sp ecial.remo ve.call( e lem, handl eObj ); | |
| 4439 | } | |
| 4440 | } | |
| 4441 | } | |
| 4442 | ||
| 4443 | // Rem ove generi c event ha ndler if w e removed something and no mor e handlers exist | |
| 4444 | // (av oids poten tial for e ndless rec ursion dur ing remova l of speci al event h andlers) | |
| 4445 | if ( o rigCount & & !handler s.length ) { | |
| 4446 | if ( !sp ecial.tear down || sp ecial.tear down.call( elem, nam espaces, e lemData.ha ndle ) === false ) { | |
| 4447 | jQuery.rem oveEvent( elem, type , elemData .handle ); | |
| 4448 | } | |
| 4449 | ||
| 4450 | delete e vents[ typ e ]; | |
| 4451 | } | |
| 4452 | } | |
| 4453 | ||
| 4454 | // R emove the expando if it's no l onger used | |
| 4455 | if ( jQuery.is EmptyObjec t( events ) ) { | |
| 4456 | delete elemData. handle; | |
| 4457 | ||
| 4458 | // rem oveData al so checks for emptin ess and cl ears the e xpando if empty | |
| 4459 | // so use it ins tead of de lete | |
| 4460 | jQuery ._removeDa ta( elem, "events" ) ; | |
| 4461 | } | |
| 4462 | }, | |
| 4463 | ||
| 4464 | tr igger: fun ction( eve nt, data, elem, only Handlers ) { | |
| 4465 | var handle, on type, cur, | |
| 4466 | bubble Type, spec ial, tmp, i, | |
| 4467 | eventP ath = [ el em || docu ment ], | |
| 4468 | type = hasOwn.ca ll( event, "type" ) ? event.ty pe : event , | |
| 4469 | namesp aces = has Own.call( event, "na mespace" ) ? event.n amespace.s plit(".") : []; | |
| 4470 | ||
| 4471 | cur = tmp = el em = elem || documen t; | |
| 4472 | ||
| 4473 | // D on't do ev ents on te xt and com ment nodes | |
| 4474 | if ( elem.node Type === 3 || elem.n odeType == = 8 ) { | |
| 4475 | return ; | |
| 4476 | } | |
| 4477 | ||
| 4478 | // f ocus/blur morphs to focusin/ou t; ensure we're not firing the m right no w | |
| 4479 | if ( rfocusMor ph.test( t ype + jQue ry.event.t riggered ) ) { | |
| 4480 | return ; | |
| 4481 | } | |
| 4482 | ||
| 4483 | if ( type.inde xOf(".") > = 0 ) { | |
| 4484 | // Nam espaced tr igger; cre ate a rege xp to matc h event ty pe in hand le() | |
| 4485 | namesp aces = typ e.split(". "); | |
| 4486 | type = namespace s.shift(); | |
| 4487 | namesp aces.sort( ); | |
| 4488 | } | |
| 4489 | onty pe = type. indexOf(": ") < 0 && "on" + typ e; | |
| 4490 | ||
| 4491 | // C aller can pass in a jQuery.Eve nt object, Object, o r just an event type string | |
| 4492 | even t = event[ jQuery.ex pando ] ? | |
| 4493 | event : | |
| 4494 | new jQ uery.Event ( type, ty peof event === "obje ct" && eve nt ); | |
| 4495 | ||
| 4496 | // T rigger bit mask: & 1 for native handlers; & 2 for j Query (alw ays true) | |
| 4497 | even t.isTrigge r = onlyHa ndlers ? 2 : 3; | |
| 4498 | even t.namespac e = namesp aces.join( "."); | |
| 4499 | even t.namespac e_re = eve nt.namespa ce ? | |
| 4500 | new Re gExp( "(^| \\.)" + na mespaces.j oin("\\.(? :.*\\.|)") + "(\\.|$ )" ) : | |
| 4501 | null; | |
| 4502 | ||
| 4503 | // C lean up th e event in case it i s being re used | |
| 4504 | even t.result = undefined ; | |
| 4505 | if ( !event.ta rget ) { | |
| 4506 | event. target = e lem; | |
| 4507 | } | |
| 4508 | ||
| 4509 | // C lone any i ncoming da ta and pre pend the e vent, crea ting the h andler arg list | |
| 4510 | data = data == null ? | |
| 4511 | [ even t ] : | |
| 4512 | jQuery .makeArray ( data, [ event ] ); | |
| 4513 | ||
| 4514 | // A llow speci al events to draw ou tside the lines | |
| 4515 | spec ial = jQue ry.event.s pecial[ ty pe ] || {} ; | |
| 4516 | if ( !onlyHand lers && sp ecial.trig ger && spe cial.trigg er.apply( elem, data ) === fal se ) { | |
| 4517 | return ; | |
| 4518 | } | |
| 4519 | ||
| 4520 | // D etermine e vent propa gation pat h in advan ce, per W3 C events s pec (#9951 ) | |
| 4521 | // B ubble up t o document , then to window; wa tch for a global own erDocument var (#972 4) | |
| 4522 | if ( !onlyHand lers && !s pecial.noB ubble && ! jQuery.isW indow( ele m ) ) { | |
| 4523 | ||
| 4524 | bubble Type = spe cial.deleg ateType || type; | |
| 4525 | if ( ! rfocusMorp h.test( bu bbleType + type ) ) { | |
| 4526 | cur = cu r.parentNo de; | |
| 4527 | } | |
| 4528 | for ( ; cur; cur = cur.par entNode ) { | |
| 4529 | eventPat h.push( cu r ); | |
| 4530 | tmp = cu r; | |
| 4531 | } | |
| 4532 | ||
| 4533 | // Onl y add wind ow if we g ot to docu ment (e.g. , not plai n obj or d etached DO M) | |
| 4534 | if ( t mp === (el em.ownerDo cument || document) ) { | |
| 4535 | eventPat h.push( tm p.defaultV iew || tmp .parentWin dow || win dow ); | |
| 4536 | } | |
| 4537 | } | |
| 4538 | ||
| 4539 | // F ire handle rs on the event path | |
| 4540 | i = 0; | |
| 4541 | whil e ( (cur = eventPath [i++]) && !event.isP ropagation Stopped() ) { | |
| 4542 | ||
| 4543 | event. type = i > 1 ? | |
| 4544 | bubbleTy pe : | |
| 4545 | special. bindType | | type; | |
| 4546 | ||
| 4547 | // jQu ery handle r | |
| 4548 | handle = ( jQuer y._data( c ur, "event s" ) || {} )[ event. type ] && jQuery._da ta( cur, " handle" ); | |
| 4549 | if ( h andle ) { | |
| 4550 | handle.a pply( cur, data ); | |
| 4551 | } | |
| 4552 | ||
| 4553 | // Nat ive handle r | |
| 4554 | handle = ontype && cur[ on type ]; | |
| 4555 | if ( h andle && h andle.appl y && jQuer y.acceptDa ta( cur ) ) { | |
| 4556 | event.re sult = han dle.apply( cur, data ); | |
| 4557 | if ( eve nt.result === false ) { | |
| 4558 | event.prev entDefault (); | |
| 4559 | } | |
| 4560 | } | |
| 4561 | } | |
| 4562 | even t.type = t ype; | |
| 4563 | ||
| 4564 | // I f nobody p revented t he default action, d o it now | |
| 4565 | if ( !onlyHand lers && !e vent.isDef aultPreven ted() ) { | |
| 4566 | ||
| 4567 | if ( ( !special._ default || special._ default.ap ply( event Path.pop() , data ) = == false) && | |
| 4568 | jQuery.a cceptData( elem ) ) { | |
| 4569 | ||
| 4570 | // Call a native D OM method on the tar get with t he same na me name as the event . | |
| 4571 | // Can't use an .i sFunction( ) check he re because IE6/7 fai ls that te st. | |
| 4572 | // Don't do defaul t actions on window, that's wh ere global variables be (#6170 ) | |
| 4573 | if ( ont ype && ele m[ type ] && !jQuery .isWindow( elem ) ) { | |
| 4574 | ||
| 4575 | // Don't r e-trigger an onFOO e vent when we call it s FOO() me thod | |
| 4576 | tmp = elem [ ontype ] ; | |
| 4577 | ||
| 4578 | if ( tmp ) { | |
| 4579 | el em[ ontype ] = null; | |
| 4580 | } | |
| 4581 | ||
| 4582 | // Prevent re-trigge ring of th e same eve nt, since we already bubbled i t above | |
| 4583 | jQuery.eve nt.trigger ed = type; | |
| 4584 | try { | |
| 4585 | el em[ type ] (); | |
| 4586 | } catch ( e ) { | |
| 4587 | // IE<9 dies on focus/ blur to hi dden eleme nt (#1486, #12518) | |
| 4588 | // only repr oducible o n winXP IE 8 native, not IE9 in IE8 mode | |
| 4589 | } | |
| 4590 | jQuery.eve nt.trigger ed = undef ined; | |
| 4591 | ||
| 4592 | if ( tmp ) { | |
| 4593 | el em[ ontype ] = tmp; | |
| 4594 | } | |
| 4595 | } | |
| 4596 | } | |
| 4597 | } | |
| 4598 | ||
| 4599 | retu rn event.r esult; | |
| 4600 | }, | |
| 4601 | ||
| 4602 | di spatch: fu nction( ev ent ) { | |
| 4603 | ||
| 4604 | // M ake a writ able jQuer y.Event fr om the nat ive event object | |
| 4605 | even t = jQuery .event.fix ( event ); | |
| 4606 | ||
| 4607 | var i, ret, ha ndleObj, m atched, j, | |
| 4608 | handle rQueue = [ ], | |
| 4609 | args = slice.cal l( argumen ts ), | |
| 4610 | handle rs = ( jQu ery._data( this, "ev ents" ) || {} )[ eve nt.type ] || [], | |
| 4611 | specia l = jQuery .event.spe cial[ even t.type ] | | {}; | |
| 4612 | ||
| 4613 | // U se the fix -ed jQuery .Event rat her than t he (read-o nly) nativ e event | |
| 4614 | args [0] = even t; | |
| 4615 | even t.delegate Target = t his; | |
| 4616 | ||
| 4617 | // C all the pr eDispatch hook for t he mapped type, and let it bai l if desir ed | |
| 4618 | if ( special.p reDispatch && specia l.preDispa tch.call( this, even t ) === fa lse ) { | |
| 4619 | return ; | |
| 4620 | } | |
| 4621 | ||
| 4622 | // D etermine h andlers | |
| 4623 | hand lerQueue = jQuery.ev ent.handle rs.call( t his, event , handlers ); | |
| 4624 | ||
| 4625 | // R un delegat es first; they may w ant to sto p propagat ion beneat h us | |
| 4626 | i = 0; | |
| 4627 | whil e ( (match ed = handl erQueue[ i ++ ]) && ! event.isPr opagationS topped() ) { | |
| 4628 | event. currentTar get = matc hed.elem; | |
| 4629 | ||
| 4630 | j = 0; | |
| 4631 | while ( (handleO bj = match ed.handler s[ j++ ]) && !event. isImmediat ePropagati onStopped( ) ) { | |
| 4632 | ||
| 4633 | // Trigg ered event must eith er 1) have no namesp ace, or | |
| 4634 | // 2) ha ve namespa ce(s) a su bset or eq ual to tho se in the bound even t (both ca n have no namespace) . | |
| 4635 | if ( !ev ent.namesp ace_re || event.name space_re.t est( handl eObj.names pace ) ) { | |
| 4636 | ||
| 4637 | event.hand leObj = ha ndleObj; | |
| 4638 | event.data = handleO bj.data; | |
| 4639 | ||
| 4640 | ret = ( (j Query.even t.special[ handleObj .origType ] || {}).h andle || h andleObj.h andler ) | |
| 4641 | .app ly( matche d.elem, ar gs ); | |
| 4642 | ||
| 4643 | if ( ret ! == undefin ed ) { | |
| 4644 | if ( (event. result = r et) === fa lse ) { | |
| 4645 | even t.preventD efault(); | |
| 4646 | even t.stopProp agation(); | |
| 4647 | } | |
| 4648 | } | |
| 4649 | } | |
| 4650 | } | |
| 4651 | } | |
| 4652 | ||
| 4653 | // C all the po stDispatch hook for the mapped type | |
| 4654 | if ( special.p ostDispatc h ) { | |
| 4655 | specia l.postDisp atch.call( this, eve nt ); | |
| 4656 | } | |
| 4657 | ||
| 4658 | retu rn event.r esult; | |
| 4659 | }, | |
| 4660 | ||
| 4661 | ha ndlers: fu nction( ev ent, handl ers ) { | |
| 4662 | var sel, handl eObj, matc hes, i, | |
| 4663 | handle rQueue = [ ], | |
| 4664 | delega teCount = handlers.d elegateCou nt, | |
| 4665 | cur = event.targ et; | |
| 4666 | ||
| 4667 | // F ind delega te handler s | |
| 4668 | // B lack-hole SVG <use> instance t rees (#131 80) | |
| 4669 | // A void non-l eft-click bubbling i n Firefox (#3861) | |
| 4670 | if ( delegateC ount && cu r.nodeType && (!even t.button | | event.ty pe !== "cl ick") ) { | |
| 4671 | ||
| 4672 | /* jsh int eqeqeq : false */ | |
| 4673 | for ( ; cur != t his; cur = cur.paren tNode || t his ) { | |
| 4674 | /* jshin t eqeqeq: true */ | |
| 4675 | ||
| 4676 | // Don't check non -elements (#13208) | |
| 4677 | // Don't process c licks on d isabled el ements (#6 911, #8165 , #11382, #11764) | |
| 4678 | if ( cur .nodeType === 1 && ( cur.disabl ed !== tru e || event .type !== "click") ) { | |
| 4679 | matches = []; | |
| 4680 | for ( i = 0; i < del egateCount ; i++ ) { | |
| 4681 | ha ndleObj = handlers[ i ]; | |
| 4682 | ||
| 4683 | // Don't con flict with Object.pr ototype pr operties ( #13203) | |
| 4684 | se l = handle Obj.select or + " "; | |
| 4685 | ||
| 4686 | if ( matches [ sel ] == = undefine d ) { | |
| 4687 | matc hes[ sel ] = handleO bj.needsCo ntext ? | |
| 4688 | jQuery ( sel, thi s ).index( cur ) >= 0 : | |
| 4689 | jQuery .find( sel , this, nu ll, [ cur ] ).length ; | |
| 4690 | } | |
| 4691 | if ( matches [ sel ] ) { | |
| 4692 | matc hes.push( handleObj ); | |
| 4693 | } | |
| 4694 | } | |
| 4695 | if ( match es.length ) { | |
| 4696 | ha ndlerQueue .push({ el em: cur, h andlers: m atches }); | |
| 4697 | } | |
| 4698 | } | |
| 4699 | } | |
| 4700 | } | |
| 4701 | ||
| 4702 | // A dd the rem aining (di rectly-bou nd) handle rs | |
| 4703 | if ( delegateC ount < han dlers.leng th ) { | |
| 4704 | handle rQueue.pus h({ elem: this, hand lers: hand lers.slice ( delegate Count ) }) ; | |
| 4705 | } | |
| 4706 | ||
| 4707 | retu rn handler Queue; | |
| 4708 | }, | |
| 4709 | ||
| 4710 | fi x: functio n( event ) { | |
| 4711 | if ( event[ jQ uery.expan do ] ) { | |
| 4712 | return event; | |
| 4713 | } | |
| 4714 | ||
| 4715 | // C reate a wr itable cop y of the e vent objec t and norm alize some propertie s | |
| 4716 | var i, prop, c opy, | |
| 4717 | type = event.typ e, | |
| 4718 | origin alEvent = event, | |
| 4719 | fixHoo k = this.f ixHooks[ t ype ]; | |
| 4720 | ||
| 4721 | if ( !fixHook ) { | |
| 4722 | this.f ixHooks[ t ype ] = fi xHook = | |
| 4723 | rmouseEv ent.test( type ) ? t his.mouseH ooks : | |
| 4724 | rkeyEven t.test( ty pe ) ? thi s.keyHooks : | |
| 4725 | {}; | |
| 4726 | } | |
| 4727 | copy = fixHook .props ? t his.props. concat( fi xHook.prop s ) : this .props; | |
| 4728 | ||
| 4729 | even t = new jQ uery.Event ( original Event ); | |
| 4730 | ||
| 4731 | i = copy.lengt h; | |
| 4732 | whil e ( i-- ) { | |
| 4733 | prop = copy[ i ] ; | |
| 4734 | event[ prop ] = originalEv ent[ prop ]; | |
| 4735 | } | |
| 4736 | ||
| 4737 | // S upport: IE <9 | |
| 4738 | // F ix target property ( #1925) | |
| 4739 | if ( !event.ta rget ) { | |
| 4740 | event. target = o riginalEve nt.srcElem ent || doc ument; | |
| 4741 | } | |
| 4742 | ||
| 4743 | // S upport: Ch rome 23+, Safari? | |
| 4744 | // T arget shou ld not be a text nod e (#504, # 13143) | |
| 4745 | if ( event.tar get.nodeTy pe === 3 ) { | |
| 4746 | event. target = e vent.targe t.parentNo de; | |
| 4747 | } | |
| 4748 | ||
| 4749 | // S upport: IE <9 | |
| 4750 | // F or mouse/k ey events, metaKey== false if i t's undefi ned (#3368 , #11328) | |
| 4751 | even t.metaKey = !!event. metaKey; | |
| 4752 | ||
| 4753 | retu rn fixHook .filter ? fixHook.fi lter( even t, origina lEvent ) : event; | |
| 4754 | }, | |
| 4755 | ||
| 4756 | // Includes some event props sha red by Key Event and MouseEvent | |
| 4757 | pr ops: "altK ey bubbles cancelabl e ctrlKey currentTar get eventP hase metaK ey related Target shi ftKey targ et timeSta mp view wh ich".split (" "), | |
| 4758 | ||
| 4759 | fi xHooks: {} , | |
| 4760 | ||
| 4761 | ke yHooks: { | |
| 4762 | prop s: "char c harCode ke y keyCode" .split(" " ), | |
| 4763 | filt er: functi on( event, original ) { | |
| 4764 | ||
| 4765 | // Add which for key event s | |
| 4766 | if ( e vent.which == null ) { | |
| 4767 | event.wh ich = orig inal.charC ode != nul l ? origin al.charCod e : origin al.keyCode ; | |
| 4768 | } | |
| 4769 | ||
| 4770 | return event; | |
| 4771 | } | |
| 4772 | }, | |
| 4773 | ||
| 4774 | mo useHooks: { | |
| 4775 | prop s: "button buttons c lientX cli entY fromE lement off setX offse tY pageX p ageY scree nX screenY toElement ".split(" "), | |
| 4776 | filt er: functi on( event, original ) { | |
| 4777 | var bo dy, eventD oc, doc, | |
| 4778 | button = original. button, | |
| 4779 | fromElem ent = orig inal.fromE lement; | |
| 4780 | ||
| 4781 | // Cal culate pag eX/Y if mi ssing and clientX/Y available | |
| 4782 | if ( e vent.pageX == null & & original .clientX ! = null ) { | |
| 4783 | eventDoc = event.t arget.owne rDocument || documen t; | |
| 4784 | doc = ev entDoc.doc umentEleme nt; | |
| 4785 | body = e ventDoc.bo dy; | |
| 4786 | ||
| 4787 | event.pa geX = orig inal.clien tX + ( doc && doc.sc rollLeft | | body && body.scrol lLeft || 0 ) - ( doc && doc.cl ientLeft | | body && body.clien tLeft || 0 ); | |
| 4788 | event.pa geY = orig inal.clien tY + ( doc && doc.sc rollTop | | body && body.scrol lTop || 0 ) - ( doc && doc.cl ientTop | | body && body.clien tTop || 0 ); | |
| 4789 | } | |
| 4790 | ||
| 4791 | // Add relatedTa rget, if n ecessary | |
| 4792 | if ( ! event.rela tedTarget && fromEle ment ) { | |
| 4793 | event.re latedTarge t = fromEl ement === event.targ et ? origi nal.toElem ent : from Element; | |
| 4794 | } | |
| 4795 | ||
| 4796 | // Add which for click: 1 === left; 2 === midd le; 3 === right | |
| 4797 | // Not e: button is not nor malized, s o don't us e it | |
| 4798 | if ( ! event.whic h && butto n !== unde fined ) { | |
| 4799 | event.wh ich = ( bu tton & 1 ? 1 : ( but ton & 2 ? 3 : ( butt on & 4 ? 2 : 0 ) ) ) ; | |
| 4800 | } | |
| 4801 | ||
| 4802 | return event; | |
| 4803 | } | |
| 4804 | }, | |
| 4805 | ||
| 4806 | sp ecial: { | |
| 4807 | load : { | |
| 4808 | // Pre vent trigg ered image .load even ts from bu bbling to window.loa d | |
| 4809 | noBubb le: true | |
| 4810 | }, | |
| 4811 | focu s: { | |
| 4812 | // Fir e native e vent if po ssible so blur/focus sequence is correct | |
| 4813 | trigge r: functio n() { | |
| 4814 | if ( thi s !== safe ActiveElem ent() && t his.focus ) { | |
| 4815 | try { | |
| 4816 | th is.focus() ; | |
| 4817 | re turn false ; | |
| 4818 | } catch ( e ) { | |
| 4819 | // Support: IE<9 | |
| 4820 | // If we err or on focu s to hidde n element (#1486, #1 2518), | |
| 4821 | // let .trig ger() run the handle rs | |
| 4822 | } | |
| 4823 | } | |
| 4824 | }, | |
| 4825 | delega teType: "f ocusin" | |
| 4826 | }, | |
| 4827 | blur : { | |
| 4828 | trigge r: functio n() { | |
| 4829 | if ( thi s === safe ActiveElem ent() && t his.blur ) { | |
| 4830 | this.blur( ); | |
| 4831 | return fal se; | |
| 4832 | } | |
| 4833 | }, | |
| 4834 | delega teType: "f ocusout" | |
| 4835 | }, | |
| 4836 | clic k: { | |
| 4837 | // For checkbox, fire nati ve event s o checked state will be right | |
| 4838 | trigge r: functio n() { | |
| 4839 | if ( jQu ery.nodeNa me( this, "input" ) && this.ty pe === "ch eckbox" && this.clic k ) { | |
| 4840 | this.click (); | |
| 4841 | return fal se; | |
| 4842 | } | |
| 4843 | }, | |
| 4844 | ||
| 4845 | // For cross-bro wser consi stency, do n't fire n ative .cli ck() on li nks | |
| 4846 | _defau lt: functi on( event ) { | |
| 4847 | return j Query.node Name( even t.target, "a" ); | |
| 4848 | } | |
| 4849 | }, | |
| 4850 | ||
| 4851 | befo reunload: { | |
| 4852 | postDi spatch: fu nction( ev ent ) { | |
| 4853 | ||
| 4854 | // Suppo rt: Firefo x 20+ | |
| 4855 | // Firef ox doesn't alert if the return Value fiel d is not s et. | |
| 4856 | if ( eve nt.result !== undefi ned && eve nt.origina lEvent ) { | |
| 4857 | event.orig inalEvent. returnValu e = event. result; | |
| 4858 | } | |
| 4859 | } | |
| 4860 | } | |
| 4861 | }, | |
| 4862 | ||
| 4863 | si mulate: fu nction( ty pe, elem, event, bub ble ) { | |
| 4864 | // P iggyback o n a donor event to s imulate a different one. | |
| 4865 | // F ake origin alEvent to avoid don or's stopP ropagation , but if t he | |
| 4866 | // s imulated e vent preve nts defaul t then we do the sam e on the d onor. | |
| 4867 | var e = jQuery .extend( | |
| 4868 | new jQ uery.Event (), | |
| 4869 | event, | |
| 4870 | { | |
| 4871 | type: ty pe, | |
| 4872 | isSimula ted: true, | |
| 4873 | original Event: {} | |
| 4874 | } | |
| 4875 | ); | |
| 4876 | if ( bubble ) { | |
| 4877 | jQuery .event.tri gger( e, n ull, elem ); | |
| 4878 | } el se { | |
| 4879 | jQuery .event.dis patch.call ( elem, e ); | |
| 4880 | } | |
| 4881 | if ( e.isDefau ltPrevente d() ) { | |
| 4882 | event. preventDef ault(); | |
| 4883 | } | |
| 4884 | } | |
| 4885 | }; | |
| 4886 | ||
| 4887 | jQuery.rem oveEvent = document. removeEven tListener ? | |
| 4888 | fu nction( el em, type, handle ) { | |
| 4889 | if ( elem.remo veEventLis tener ) { | |
| 4890 | elem.r emoveEvent Listener( type, hand le, false ); | |
| 4891 | } | |
| 4892 | } : | |
| 4893 | fu nction( el em, type, handle ) { | |
| 4894 | var name = "on " + type; | |
| 4895 | ||
| 4896 | if ( elem.deta chEvent ) { | |
| 4897 | ||
| 4898 | // #85 45, #7054, preventin g memory l eaks for c ustom even ts in IE6- 8 | |
| 4899 | // det achEvent n eeded prop erty on el ement, by name of th at event, to properl y expose i t to GC | |
| 4900 | if ( t ypeof elem [ name ] = == strunde fined ) { | |
| 4901 | elem[ na me ] = nul l; | |
| 4902 | } | |
| 4903 | ||
| 4904 | elem.d etachEvent ( name, ha ndle ); | |
| 4905 | } | |
| 4906 | }; | |
| 4907 | ||
| 4908 | jQuery.Eve nt = funct ion( src, props ) { | |
| 4909 | // Allow ins tantiation without t he 'new' k eyword | |
| 4910 | if ( !(this instanceof jQuery.Ev ent) ) { | |
| 4911 | retu rn new jQu ery.Event( src, prop s ); | |
| 4912 | } | |
| 4913 | ||
| 4914 | // Event obj ect | |
| 4915 | if ( src && src.type ) { | |
| 4916 | this .originalE vent = src ; | |
| 4917 | this .type = sr c.type; | |
| 4918 | ||
| 4919 | // E vents bubb ling up th e document may have been marke d as preve nted | |
| 4920 | // b y a handle r lower do wn the tre e; reflect the corre ct value. | |
| 4921 | this .isDefault Prevented = src.defa ultPrevent ed || | |
| 4922 | src.defa ultPrevent ed === und efined && | |
| 4923 | // Suppo rt: IE < 9 , Android < 4.0 | |
| 4924 | src.retu rnValue == = false ? | |
| 4925 | return True : | |
| 4926 | return False; | |
| 4927 | ||
| 4928 | // Event typ e | |
| 4929 | } else { | |
| 4930 | this .type = sr c; | |
| 4931 | } | |
| 4932 | ||
| 4933 | // Put expli citly prov ided prope rties onto the event object | |
| 4934 | if ( props ) { | |
| 4935 | jQue ry.extend( this, pro ps ); | |
| 4936 | } | |
| 4937 | ||
| 4938 | // Create a timestamp if incomin g event do esn't have one | |
| 4939 | th is.timeSta mp = src & & src.time Stamp || j Query.now( ); | |
| 4940 | ||
| 4941 | // Mark it a s fixed | |
| 4942 | th is[ jQuery .expando ] = true; | |
| 4943 | }; | |
| 4944 | ||
| 4945 | // jQuery. Event is b ased on DO M3 Events as specifi ed by the ECMAScript Language Binding | |
| 4946 | // http:// www.w3.org /TR/2003/W D-DOM-Leve l-3-Events -20030331/ ecma-scrip t-binding. html | |
| 4947 | jQuery.Eve nt.prototy pe = { | |
| 4948 | is DefaultPre vented: re turnFalse, | |
| 4949 | is Propagatio nStopped: returnFals e, | |
| 4950 | is ImmediateP ropagation Stopped: r eturnFalse , | |
| 4951 | ||
| 4952 | pr eventDefau lt: functi on() { | |
| 4953 | var e = this.o riginalEve nt; | |
| 4954 | ||
| 4955 | this .isDefault Prevented = returnTr ue; | |
| 4956 | if ( !e ) { | |
| 4957 | return ; | |
| 4958 | } | |
| 4959 | ||
| 4960 | // I f preventD efault exi sts, run i t on the o riginal ev ent | |
| 4961 | if ( e.prevent Default ) { | |
| 4962 | e.prev entDefault (); | |
| 4963 | ||
| 4964 | // S upport: IE | |
| 4965 | // O therwise s et the ret urnValue p roperty of the origi nal event to false | |
| 4966 | } el se { | |
| 4967 | e.retu rnValue = false; | |
| 4968 | } | |
| 4969 | }, | |
| 4970 | st opPropagat ion: funct ion() { | |
| 4971 | var e = this.o riginalEve nt; | |
| 4972 | ||
| 4973 | this .isPropaga tionStoppe d = return True; | |
| 4974 | if ( !e ) { | |
| 4975 | return ; | |
| 4976 | } | |
| 4977 | // I f stopProp agation ex ists, run it on the original e vent | |
| 4978 | if ( e.stopPro pagation ) { | |
| 4979 | e.stop Propagatio n(); | |
| 4980 | } | |
| 4981 | ||
| 4982 | // S upport: IE | |
| 4983 | // S et the can celBubble property o f the orig inal event to true | |
| 4984 | e.ca ncelBubble = true; | |
| 4985 | }, | |
| 4986 | st opImmediat ePropagati on: functi on() { | |
| 4987 | var e = this.o riginalEve nt; | |
| 4988 | ||
| 4989 | this .isImmedia tePropagat ionStopped = returnT rue; | |
| 4990 | ||
| 4991 | if ( e && e.st opImmediat ePropagati on ) { | |
| 4992 | e.stop ImmediateP ropagation (); | |
| 4993 | } | |
| 4994 | ||
| 4995 | this .stopPropa gation(); | |
| 4996 | } | |
| 4997 | }; | |
| 4998 | ||
| 4999 | // Create mouseenter /leave eve nts using mouseover/ out and ev ent-time c hecks | |
| 5000 | jQuery.eac h({ | |
| 5001 | mo useenter: "mouseover ", | |
| 5002 | mo useleave: "mouseout" , | |
| 5003 | po interenter : "pointer over", | |
| 5004 | po interleave : "pointer out" | |
| 5005 | }, functio n( orig, f ix ) { | |
| 5006 | jQ uery.event .special[ orig ] = { | |
| 5007 | dele gateType: fix, | |
| 5008 | bind Type: fix, | |
| 5009 | ||
| 5010 | hand le: functi on( event ) { | |
| 5011 | var re t, | |
| 5012 | target = this, | |
| 5013 | related = event.re latedTarge t, | |
| 5014 | handleOb j = event. handleObj; | |
| 5015 | ||
| 5016 | // For mousenter /leave cal l the hand ler if rel ated is ou tside the target. | |
| 5017 | // NB: No relate dTarget if the mouse left/ente red the br owser wind ow | |
| 5018 | if ( ! related || (related !== target && !jQuer y.contains ( target, related )) ) { | |
| 5019 | event.ty pe = handl eObj.origT ype; | |
| 5020 | ret = ha ndleObj.ha ndler.appl y( this, a rguments ) ; | |
| 5021 | event.ty pe = fix; | |
| 5022 | } | |
| 5023 | return ret; | |
| 5024 | } | |
| 5025 | }; | |
| 5026 | }); | |
| 5027 | ||
| 5028 | // IE subm it delegat ion | |
| 5029 | if ( !supp ort.submit Bubbles ) { | |
| 5030 | ||
| 5031 | jQ uery.event .special.s ubmit = { | |
| 5032 | setu p: functio n() { | |
| 5033 | // Onl y need thi s for dele gated form submit ev ents | |
| 5034 | if ( j Query.node Name( this , "form" ) ) { | |
| 5035 | return f alse; | |
| 5036 | } | |
| 5037 | ||
| 5038 | // Laz y-add a su bmit handl er when a descendant form may potentiall y be submi tted | |
| 5039 | jQuery .event.add ( this, "c lick._subm it keypres s._submit" , function ( e ) { | |
| 5040 | // Node name check avoids a VML-relate d crash in IE (#9807 ) | |
| 5041 | var elem = e.targe t, | |
| 5042 | form = jQu ery.nodeNa me( elem, "input" ) || jQuery. nodeName( elem, "but ton" ) ? e lem.form : undefined ; | |
| 5043 | if ( for m && !jQue ry._data( form, "sub mitBubbles " ) ) { | |
| 5044 | jQuery.eve nt.add( fo rm, "submi t._submit" , function ( event ) { | |
| 5045 | ev ent._submi t_bubble = true; | |
| 5046 | }); | |
| 5047 | jQuery._da ta( form, "submitBub bles", tru e ); | |
| 5048 | } | |
| 5049 | }); | |
| 5050 | // ret urn undefi ned since we don't n eed an eve nt listene r | |
| 5051 | }, | |
| 5052 | ||
| 5053 | post Dispatch: function( event ) { | |
| 5054 | // If form was s ubmitted b y the user , bubble t he event u p the tree | |
| 5055 | if ( e vent._subm it_bubble ) { | |
| 5056 | delete e vent._subm it_bubble; | |
| 5057 | if ( thi s.parentNo de && !eve nt.isTrigg er ) { | |
| 5058 | jQuery.eve nt.simulat e( "submit ", this.pa rentNode, event, tru e ); | |
| 5059 | } | |
| 5060 | } | |
| 5061 | }, | |
| 5062 | ||
| 5063 | tear down: func tion() { | |
| 5064 | // Onl y need thi s for dele gated form submit ev ents | |
| 5065 | if ( j Query.node Name( this , "form" ) ) { | |
| 5066 | return f alse; | |
| 5067 | } | |
| 5068 | ||
| 5069 | // Rem ove delega ted handle rs; cleanD ata eventu ally reaps submit ha ndlers att ached abov e | |
| 5070 | jQuery .event.rem ove( this, "._submit " ); | |
| 5071 | } | |
| 5072 | }; | |
| 5073 | } | |
| 5074 | ||
| 5075 | // IE chan ge delegat ion and ch eckbox/rad io fix | |
| 5076 | if ( !supp ort.change Bubbles ) { | |
| 5077 | ||
| 5078 | jQ uery.event .special.c hange = { | |
| 5079 | ||
| 5080 | setu p: functio n() { | |
| 5081 | ||
| 5082 | if ( r formElems. test( this .nodeName ) ) { | |
| 5083 | // IE do esn't fire change on a check/r adio until blur; tri gger it on click | |
| 5084 | // after a propert ychange. E at the blu r-change i n special. change.han dle. | |
| 5085 | // This still fire s onchange a second time for c heck/radio after blu r. | |
| 5086 | if ( thi s.type === "checkbox " || this. type === " radio" ) { | |
| 5087 | jQuery.eve nt.add( th is, "prope rtychange. _change", function( event ) { | |
| 5088 | if ( event.o riginalEve nt.propert yName === "checked" ) { | |
| 5089 | this ._just_cha nged = tru e; | |
| 5090 | } | |
| 5091 | }); | |
| 5092 | jQuery.eve nt.add( th is, "click ._change", function( event ) { | |
| 5093 | if ( this._j ust_change d && !even t.isTrigge r ) { | |
| 5094 | this ._just_cha nged = fal se; | |
| 5095 | } | |
| 5096 | // Allow tri ggered, si mulated ch ange event s (#11500) | |
| 5097 | jQ uery.event .simulate( "change", this, eve nt, true ) ; | |
| 5098 | }); | |
| 5099 | } | |
| 5100 | return f alse; | |
| 5101 | } | |
| 5102 | // Del egated eve nt; lazy-a dd a chang e handler on descend ant inputs | |
| 5103 | jQuery .event.add ( this, "b eforeactiv ate._chang e", functi on( e ) { | |
| 5104 | var elem = e.targe t; | |
| 5105 | ||
| 5106 | if ( rfo rmElems.te st( elem.n odeName ) && !jQuery ._data( el em, "chang eBubbles" ) ) { | |
| 5107 | jQuery.eve nt.add( el em, "chang e._change" , function ( event ) { | |
| 5108 | if ( this.pa rentNode & & !event.i sSimulated && !event .isTrigger ) { | |
| 5109 | jQue ry.event.s imulate( " change", t his.parent Node, even t, true ); | |
| 5110 | } | |
| 5111 | }); | |
| 5112 | jQuery._da ta( elem, "changeBub bles", tru e ); | |
| 5113 | } | |
| 5114 | }); | |
| 5115 | }, | |
| 5116 | ||
| 5117 | hand le: functi on( event ) { | |
| 5118 | var el em = event .target; | |
| 5119 | ||
| 5120 | // Swa llow nativ e change e vents from checkbox/ radio, we already tr iggered th em above | |
| 5121 | if ( t his !== el em || even t.isSimula ted || eve nt.isTrigg er || (ele m.type !== "radio" & & elem.typ e !== "che ckbox") ) { | |
| 5122 | return e vent.handl eObj.handl er.apply( this, argu ments ); | |
| 5123 | } | |
| 5124 | }, | |
| 5125 | ||
| 5126 | tear down: func tion() { | |
| 5127 | jQuery .event.rem ove( this, "._change " ); | |
| 5128 | ||
| 5129 | return !rformEle ms.test( t his.nodeNa me ); | |
| 5130 | } | |
| 5131 | }; | |
| 5132 | } | |
| 5133 | ||
| 5134 | // Create "bubbling" focus and blur even ts | |
| 5135 | if ( !supp ort.focusi nBubbles ) { | |
| 5136 | jQ uery.each( { focus: " focusin", blur: "foc usout" }, function( orig, fix ) { | |
| 5137 | ||
| 5138 | // A ttach a si ngle captu ring handl er on the document w hile someo ne wants f ocusin/foc usout | |
| 5139 | var handler = function( event ) { | |
| 5140 | jQuery.e vent.simul ate( fix, event.targ et, jQuery .event.fix ( event ), true ); | |
| 5141 | }; | |
| 5142 | ||
| 5143 | jQue ry.event.s pecial[ fi x ] = { | |
| 5144 | setup: function( ) { | |
| 5145 | var doc = this.own erDocument || this, | |
| 5146 | attaches = jQuery._d ata( doc, fix ); | |
| 5147 | ||
| 5148 | if ( !at taches ) { | |
| 5149 | doc.addEve ntListener ( orig, ha ndler, tru e ); | |
| 5150 | } | |
| 5151 | jQuery._ data( doc, fix, ( at taches || 0 ) + 1 ); | |
| 5152 | }, | |
| 5153 | teardo wn: functi on() { | |
| 5154 | var doc = this.own erDocument || this, | |
| 5155 | attaches = jQuery._d ata( doc, fix ) - 1; | |
| 5156 | ||
| 5157 | if ( !at taches ) { | |
| 5158 | doc.remove EventListe ner( orig, handler, true ); | |
| 5159 | jQuery._re moveData( doc, fix ) ; | |
| 5160 | } else { | |
| 5161 | jQuery._da ta( doc, f ix, attach es ); | |
| 5162 | } | |
| 5163 | } | |
| 5164 | }; | |
| 5165 | }) ; | |
| 5166 | } | |
| 5167 | ||
| 5168 | jQuery.fn. extend({ | |
| 5169 | ||
| 5170 | on : function ( types, s elector, d ata, fn, / *INTERNAL* / one ) { | |
| 5171 | var type, orig Fn; | |
| 5172 | ||
| 5173 | // T ypes can b e a map of types/han dlers | |
| 5174 | if ( typeof ty pes === "o bject" ) { | |
| 5175 | // ( t ypes-Objec t, selecto r, data ) | |
| 5176 | if ( t ypeof sele ctor !== " string" ) { | |
| 5177 | // ( typ es-Object, data ) | |
| 5178 | data = d ata || sel ector; | |
| 5179 | selector = undefin ed; | |
| 5180 | } | |
| 5181 | for ( type in ty pes ) { | |
| 5182 | this.on( type, sel ector, dat a, types[ type ], on e ); | |
| 5183 | } | |
| 5184 | return this; | |
| 5185 | } | |
| 5186 | ||
| 5187 | if ( data == n ull && fn == null ) { | |
| 5188 | // ( t ypes, fn ) | |
| 5189 | fn = s elector; | |
| 5190 | data = selector = undefine d; | |
| 5191 | } el se if ( fn == null ) { | |
| 5192 | if ( t ypeof sele ctor === " string" ) { | |
| 5193 | // ( typ es, select or, fn ) | |
| 5194 | fn = dat a; | |
| 5195 | data = u ndefined; | |
| 5196 | } else { | |
| 5197 | // ( typ es, data, fn ) | |
| 5198 | fn = dat a; | |
| 5199 | data = s elector; | |
| 5200 | selector = undefin ed; | |
| 5201 | } | |
| 5202 | } | |
| 5203 | if ( fn === fa lse ) { | |
| 5204 | fn = r eturnFalse ; | |
| 5205 | } el se if ( !f n ) { | |
| 5206 | return this; | |
| 5207 | } | |
| 5208 | ||
| 5209 | if ( one === 1 ) { | |
| 5210 | origFn = fn; | |
| 5211 | fn = f unction( e vent ) { | |
| 5212 | // Can u se an empt y set, sin ce event c ontains th e info | |
| 5213 | jQuery() .off( even t ); | |
| 5214 | return o rigFn.appl y( this, a rguments ) ; | |
| 5215 | }; | |
| 5216 | // Use same guid so caller can remov e using or igFn | |
| 5217 | fn.gui d = origFn .guid || ( origFn.gu id = jQuer y.guid++ ) ; | |
| 5218 | } | |
| 5219 | retu rn this.ea ch( functi on() { | |
| 5220 | jQuery .event.add ( this, ty pes, fn, d ata, selec tor ); | |
| 5221 | }); | |
| 5222 | }, | |
| 5223 | on e: functio n( types, selector, data, fn ) { | |
| 5224 | retu rn this.on ( types, s elector, d ata, fn, 1 ); | |
| 5225 | }, | |
| 5226 | of f: functio n( types, selector, fn ) { | |
| 5227 | var handleObj, type; | |
| 5228 | if ( types && types.prev entDefault && types. handleObj ) { | |
| 5229 | // ( e vent ) di spatched j Query.Even t | |
| 5230 | handle Obj = type s.handleOb j; | |
| 5231 | jQuery ( types.de legateTarg et ).off( | |
| 5232 | handleOb j.namespac e ? handle Obj.origTy pe + "." + handleObj .namespace : handleO bj.origTyp e, | |
| 5233 | handleOb j.selector , | |
| 5234 | handleOb j.handler | |
| 5235 | ); | |
| 5236 | return this; | |
| 5237 | } | |
| 5238 | if ( typeof ty pes === "o bject" ) { | |
| 5239 | // ( t ypes-objec t [, selec tor] ) | |
| 5240 | for ( type in ty pes ) { | |
| 5241 | this.off ( type, se lector, ty pes[ type ] ); | |
| 5242 | } | |
| 5243 | return this; | |
| 5244 | } | |
| 5245 | if ( selector === false || typeof selector = == "functi on" ) { | |
| 5246 | // ( t ypes [, fn ] ) | |
| 5247 | fn = s elector; | |
| 5248 | select or = undef ined; | |
| 5249 | } | |
| 5250 | if ( fn === fa lse ) { | |
| 5251 | fn = r eturnFalse ; | |
| 5252 | } | |
| 5253 | retu rn this.ea ch(functio n() { | |
| 5254 | jQuery .event.rem ove( this, types, fn , selector ); | |
| 5255 | }); | |
| 5256 | }, | |
| 5257 | ||
| 5258 | tr igger: fun ction( typ e, data ) { | |
| 5259 | retu rn this.ea ch(functio n() { | |
| 5260 | jQuery .event.tri gger( type , data, th is ); | |
| 5261 | }); | |
| 5262 | }, | |
| 5263 | tr iggerHandl er: functi on( type, data ) { | |
| 5264 | var elem = thi s[0]; | |
| 5265 | if ( elem ) { | |
| 5266 | return jQuery.ev ent.trigge r( type, d ata, elem, true ); | |
| 5267 | } | |
| 5268 | } | |
| 5269 | }); | |
| 5270 | ||
| 5271 | ||
| 5272 | function c reateSafeF ragment( d ocument ) { | |
| 5273 | va r list = n odeNames.s plit( "|" ), | |
| 5274 | safe Frag = doc ument.crea teDocument Fragment() ; | |
| 5275 | ||
| 5276 | if ( safeFra g.createEl ement ) { | |
| 5277 | whil e ( list.l ength ) { | |
| 5278 | safeFr ag.createE lement( | |
| 5279 | list.pop () | |
| 5280 | ); | |
| 5281 | } | |
| 5282 | } | |
| 5283 | re turn safeF rag; | |
| 5284 | } | |
| 5285 | ||
| 5286 | var nodeNa mes = "abb r|article| aside|audi o|bdi|canv as|data|da talist|det ails|figca ption|figu re|footer| " + | |
| 5287 | "hea der|hgroup |mark|mete r|nav|outp ut|progres s|section| summary|ti me|video", | |
| 5288 | ri nlinejQuer y = / jQue ry\d+="(?: null|\d+)" /g, | |
| 5289 | rn oshimcache = new Reg Exp("<(?:" + nodeNam es + ")[\\ s/>]", "i" ), | |
| 5290 | rl eadingWhit espace = / ^\s+/, | |
| 5291 | rx htmlTag = /<(?!area| br|col|emb ed|hr|img| input|link |meta|para m)(([\w:]+ )[^>]*)\/> /gi, | |
| 5292 | rt agName = / <([\w:]+)/ , | |
| 5293 | rt body = /<t body/i, | |
| 5294 | rh tml = /<|& #?\w+;/, | |
| 5295 | rn oInnerhtml = /<(?:sc ript|style |link)/i, | |
| 5296 | // checked=" checked" o r checked | |
| 5297 | rc hecked = / checked\s* (?:[^=]|=\ s*.checked .)/i, | |
| 5298 | rs criptType = /^$|\/(? :java|ecma )script/i, | |
| 5299 | rs criptTypeM asked = /^ true\/(.*) /, | |
| 5300 | rc leanScript = /^\s*<! (?:\[CDATA \[|--)|(?: \]\]|--)>\ s*$/g, | |
| 5301 | ||
| 5302 | // We have t o close th ese tags t o support XHTML (#13 200) | |
| 5303 | wr apMap = { | |
| 5304 | opti on: [ 1, " <select mu ltiple='mu ltiple'>", "</select >" ], | |
| 5305 | lege nd: [ 1, " <fieldset> ", "</fiel dset>" ], | |
| 5306 | area : [ 1, "<m ap>", "</m ap>" ], | |
| 5307 | para m: [ 1, "< object>", "</object> " ], | |
| 5308 | thea d: [ 1, "< table>", " </table>" ], | |
| 5309 | tr: [ 2, "<tab le><tbody> ", "</tbod y></table> " ], | |
| 5310 | col: [ 2, "<ta ble><tbody ></tbody>< colgroup>" , "</colgr oup></tabl e>" ], | |
| 5311 | td: [ 3, "<tab le><tbody> <tr>", "</ tr></tbody ></table>" ], | |
| 5312 | ||
| 5313 | // I E6-8 can't serialize link, scr ipt, style , or any h tml5 (NoSc ope) tags, | |
| 5314 | // u nless wrap ped in a d iv with no n-breaking character s in front of it. | |
| 5315 | _def ault: supp ort.htmlSe rialize ? [ 0, "", " " ] : [ 1, "X<div>", "</div>" ] | |
| 5316 | }, | |
| 5317 | sa feFragment = createS afeFragmen t( documen t ), | |
| 5318 | fr agmentDiv = safeFrag ment.appen dChild( do cument.cre ateElement ("div") ); | |
| 5319 | ||
| 5320 | wrapMap.op tgroup = w rapMap.opt ion; | |
| 5321 | wrapMap.tb ody = wrap Map.tfoot = wrapMap. colgroup = wrapMap.c aption = w rapMap.the ad; | |
| 5322 | wrapMap.th = wrapMap .td; | |
| 5323 | ||
| 5324 | function g etAll( con text, tag ) { | |
| 5325 | va r elems, e lem, | |
| 5326 | i = 0, | |
| 5327 | foun d = typeof context.g etElements ByTagName !== strund efined ? c ontext.get ElementsBy TagName( t ag || "*" ) : | |
| 5328 | typeof context.q uerySelect orAll !== strundefin ed ? conte xt.querySe lectorAll( tag || "* " ) : | |
| 5329 | undefi ned; | |
| 5330 | ||
| 5331 | if ( !found ) { | |
| 5332 | for ( found = [], elems = context. childNodes || contex t; (elem = elems[i]) != null; i++ ) { | |
| 5333 | if ( ! tag || jQu ery.nodeNa me( elem, tag ) ) { | |
| 5334 | found.pu sh( elem ) ; | |
| 5335 | } else { | |
| 5336 | jQuery.m erge( foun d, getAll( elem, tag ) ); | |
| 5337 | } | |
| 5338 | } | |
| 5339 | } | |
| 5340 | ||
| 5341 | re turn tag = == undefin ed || tag && jQuery. nodeName( context, t ag ) ? | |
| 5342 | jQue ry.merge( [ context ], found ) : | |
| 5343 | foun d; | |
| 5344 | } | |
| 5345 | ||
| 5346 | // Used in buildFrag ment, fixe s the defa ultChecked property | |
| 5347 | function f ixDefaultC hecked( el em ) { | |
| 5348 | if ( rchecka bleType.te st( elem.t ype ) ) { | |
| 5349 | elem .defaultCh ecked = el em.checked ; | |
| 5350 | } | |
| 5351 | } | |
| 5352 | ||
| 5353 | // Support : IE<8 | |
| 5354 | // Manipul ating tabl es require s a tbody | |
| 5355 | function m anipulatio nTarget( e lem, conte nt ) { | |
| 5356 | re turn jQuer y.nodeName ( elem, "t able" ) && | |
| 5357 | jQue ry.nodeNam e( content .nodeType !== 11 ? c ontent : c ontent.fir stChild, " tr" ) ? | |
| 5358 | ||
| 5359 | elem .getElemen tsByTagNam e("tbody") [0] || | |
| 5360 | elem.a ppendChild ( elem.own erDocument .createEle ment("tbod y") ) : | |
| 5361 | elem ; | |
| 5362 | } | |
| 5363 | ||
| 5364 | // Replace /restore t he type at tribute of script el ements for safe DOM manipulati on | |
| 5365 | function d isableScri pt( elem ) { | |
| 5366 | el em.type = (jQuery.fi nd.attr( e lem, "type " ) !== nu ll) + "/" + elem.typ e; | |
| 5367 | re turn elem; | |
| 5368 | } | |
| 5369 | function r estoreScri pt( elem ) { | |
| 5370 | va r match = rscriptTyp eMasked.ex ec( elem.t ype ); | |
| 5371 | if ( match ) { | |
| 5372 | elem .type = ma tch[1]; | |
| 5373 | } else { | |
| 5374 | elem .removeAtt ribute("ty pe"); | |
| 5375 | } | |
| 5376 | re turn elem; | |
| 5377 | } | |
| 5378 | ||
| 5379 | // Mark sc ripts as h aving alre ady been e valuated | |
| 5380 | function s etGlobalEv al( elems, refElemen ts ) { | |
| 5381 | va r elem, | |
| 5382 | i = 0; | |
| 5383 | fo r ( ; (ele m = elems[ i]) != nul l; i++ ) { | |
| 5384 | jQue ry._data( elem, "glo balEval", !refElemen ts || jQue ry._data( refElement s[i], "glo balEval" ) ); | |
| 5385 | } | |
| 5386 | } | |
| 5387 | ||
| 5388 | function c loneCopyEv ent( src, dest ) { | |
| 5389 | ||
| 5390 | if ( dest.no deType !== 1 || !jQu ery.hasDat a( src ) ) { | |
| 5391 | retu rn; | |
| 5392 | } | |
| 5393 | ||
| 5394 | va r type, i, l, | |
| 5395 | oldD ata = jQue ry._data( src ), | |
| 5396 | curD ata = jQue ry._data( dest, oldD ata ), | |
| 5397 | even ts = oldDa ta.events; | |
| 5398 | ||
| 5399 | if ( events ) { | |
| 5400 | dele te curData .handle; | |
| 5401 | curD ata.events = {}; | |
| 5402 | ||
| 5403 | for ( type in events ) { | |
| 5404 | for ( i = 0, l = events[ t ype ].leng th; i < l; i++ ) { | |
| 5405 | jQuery.e vent.add( dest, type , events[ type ][ i ] ); | |
| 5406 | } | |
| 5407 | } | |
| 5408 | } | |
| 5409 | ||
| 5410 | // make the cloned pub lic data o bject a co py from th e original | |
| 5411 | if ( curData .data ) { | |
| 5412 | curD ata.data = jQuery.ex tend( {}, curData.da ta ); | |
| 5413 | } | |
| 5414 | } | |
| 5415 | ||
| 5416 | function f ixCloneNod eIssues( s rc, dest ) { | |
| 5417 | va r nodeName , e, data; | |
| 5418 | ||
| 5419 | // We do not need to d o anything for non-E lements | |
| 5420 | if ( dest.no deType !== 1 ) { | |
| 5421 | retu rn; | |
| 5422 | } | |
| 5423 | ||
| 5424 | no deName = d est.nodeNa me.toLower Case(); | |
| 5425 | ||
| 5426 | // IE6-8 cop ies events bound via attachEve nt when us ing cloneN ode. | |
| 5427 | if ( !suppor t.noCloneE vent && de st[ jQuery .expando ] ) { | |
| 5428 | data = jQuery. _data( des t ); | |
| 5429 | ||
| 5430 | for ( e in dat a.events ) { | |
| 5431 | jQuery .removeEve nt( dest, e, data.ha ndle ); | |
| 5432 | } | |
| 5433 | ||
| 5434 | // E vent data gets refer enced inst ead of cop ied if the expando g ets copied too | |
| 5435 | dest .removeAtt ribute( jQ uery.expan do ); | |
| 5436 | } | |
| 5437 | ||
| 5438 | // IE blanks contents when cloni ng scripts , and trie s to evalu ate newly- set text | |
| 5439 | if ( nodeNam e === "scr ipt" && de st.text != = src.text ) { | |
| 5440 | disa bleScript( dest ).te xt = src.t ext; | |
| 5441 | rest oreScript( dest ); | |
| 5442 | ||
| 5443 | // IE6-10 im properly c lones chil dren of ob ject eleme nts using classid. | |
| 5444 | // IE10 thro ws NoModif icationAll owedError if parent is null, # 12132. | |
| 5445 | } else if ( nodeName = == "object " ) { | |
| 5446 | if ( dest.pare ntNode ) { | |
| 5447 | dest.o uterHTML = src.outer HTML; | |
| 5448 | } | |
| 5449 | ||
| 5450 | // T his path a ppears una voidable f or IE9. Wh en cloning an object | |
| 5451 | // e lement in IE9, the o uterHTML s trategy ab ove is not sufficien t. | |
| 5452 | // I f the src has innerH TML and th e destinat ion does n ot, | |
| 5453 | // c opy the sr c.innerHTM L into the dest.inne rHTML. #10 324 | |
| 5454 | if ( support.h tml5Clone && ( src.i nnerHTML & & !jQuery. trim(dest. innerHTML) ) ) { | |
| 5455 | dest.i nnerHTML = src.inner HTML; | |
| 5456 | } | |
| 5457 | ||
| 5458 | } else if ( nodeName = == "input" && rcheck ableType.t est( src.t ype ) ) { | |
| 5459 | // I E6-8 fails to persis t the chec ked state of a clone d checkbox | |
| 5460 | // o r radio bu tton. Wors e, IE6-7 f ail to giv e the clon ed element | |
| 5461 | // a checked a ppearance if the def aultChecke d value is n't also s et | |
| 5462 | ||
| 5463 | dest .defaultCh ecked = de st.checked = src.che cked; | |
| 5464 | ||
| 5465 | // I E6-7 get c onfused an d end up s etting the value of a cloned | |
| 5466 | // c heckbox/ra dio button to an emp ty string instead of "on" | |
| 5467 | if ( dest.valu e !== src. value ) { | |
| 5468 | dest.v alue = src .value; | |
| 5469 | } | |
| 5470 | ||
| 5471 | // IE6-8 fai ls to retu rn the sel ected opti on to the default se lected | |
| 5472 | // state whe n cloning options | |
| 5473 | } else if ( nodeName = == "option " ) { | |
| 5474 | dest .defaultSe lected = d est.select ed = src.d efaultSele cted; | |
| 5475 | ||
| 5476 | // IE6-8 fai ls to set the defaul tValue to the correc t value wh en | |
| 5477 | // cloning o ther types of input fields | |
| 5478 | } else if ( nodeName = == "input" || nodeNa me === "te xtarea" ) { | |
| 5479 | dest .defaultVa lue = src. defaultVal ue; | |
| 5480 | } | |
| 5481 | } | |
| 5482 | ||
| 5483 | jQuery.ext end({ | |
| 5484 | cl one: funct ion( elem, dataAndEv ents, deep DataAndEve nts ) { | |
| 5485 | var destElemen ts, node, clone, i, srcElement s, | |
| 5486 | inPage = jQuery. contains( elem.owner Document, elem ); | |
| 5487 | ||
| 5488 | if ( support.h tml5Clone || jQuery. isXMLDoc(e lem) || !r noshimcach e.test( "< " + elem.n odeName + ">" ) ) { | |
| 5489 | clone = elem.clo neNode( tr ue ); | |
| 5490 | ||
| 5491 | // I E<=8 does not proper ly clone d etached, u nknown ele ment nodes | |
| 5492 | } el se { | |
| 5493 | fragme ntDiv.inne rHTML = el em.outerHT ML; | |
| 5494 | fragme ntDiv.remo veChild( c lone = fra gmentDiv.f irstChild ); | |
| 5495 | } | |
| 5496 | ||
| 5497 | if ( (!support .noCloneEv ent || !su pport.noCl oneChecked ) && | |
| 5498 | (elem.no deType === 1 || elem .nodeType === 11) && !jQuery.i sXMLDoc(el em) ) { | |
| 5499 | ||
| 5500 | // We eschew Siz zle here f or perform ance reaso ns: http:/ /jsperf.co m/getall-v s-sizzle/2 | |
| 5501 | destEl ements = g etAll( clo ne ); | |
| 5502 | srcEle ments = ge tAll( elem ); | |
| 5503 | ||
| 5504 | // Fix all IE cl oning issu es | |
| 5505 | for ( i = 0; (no de = srcEl ements[i]) != null; ++i ) { | |
| 5506 | // Ensur e that the destinati on node is not null; Fixes #95 87 | |
| 5507 | if ( des tElements[ i] ) { | |
| 5508 | fixCloneNo deIssues( node, dest Elements[i ] ); | |
| 5509 | } | |
| 5510 | } | |
| 5511 | } | |
| 5512 | ||
| 5513 | // C opy the ev ents from the origin al to the clone | |
| 5514 | if ( dataAndEv ents ) { | |
| 5515 | if ( d eepDataAnd Events ) { | |
| 5516 | srcEleme nts = srcE lements || getAll( e lem ); | |
| 5517 | destElem ents = des tElements || getAll( clone ); | |
| 5518 | ||
| 5519 | for ( i = 0; (node = srcElem ents[i]) ! = null; i+ + ) { | |
| 5520 | cloneCopyE vent( node , destElem ents[i] ); | |
| 5521 | } | |
| 5522 | } else { | |
| 5523 | cloneCop yEvent( el em, clone ); | |
| 5524 | } | |
| 5525 | } | |
| 5526 | ||
| 5527 | // P reserve sc ript evalu ation hist ory | |
| 5528 | dest Elements = getAll( c lone, "scr ipt" ); | |
| 5529 | if ( destEleme nts.length > 0 ) { | |
| 5530 | setGlo balEval( d estElement s, !inPage && getAll ( elem, "s cript" ) ) ; | |
| 5531 | } | |
| 5532 | ||
| 5533 | dest Elements = srcElemen ts = node = null; | |
| 5534 | ||
| 5535 | // R eturn the cloned set | |
| 5536 | retu rn clone; | |
| 5537 | }, | |
| 5538 | ||
| 5539 | bu ildFragmen t: functio n( elems, context, s cripts, se lection ) { | |
| 5540 | var j, elem, c ontains, | |
| 5541 | tmp, t ag, tbody, wrap, | |
| 5542 | l = el ems.length , | |
| 5543 | ||
| 5544 | // Ens ure a safe fragment | |
| 5545 | safe = createSaf eFragment( context ) , | |
| 5546 | ||
| 5547 | nodes = [], | |
| 5548 | i = 0; | |
| 5549 | ||
| 5550 | for ( ; i < l; i++ ) { | |
| 5551 | elem = elems[ i ]; | |
| 5552 | ||
| 5553 | if ( e lem || ele m === 0 ) { | |
| 5554 | ||
| 5555 | // Add n odes direc tly | |
| 5556 | if ( jQu ery.type( elem ) === "object" ) { | |
| 5557 | jQuery.mer ge( nodes, elem.node Type ? [ e lem ] : el em ); | |
| 5558 | ||
| 5559 | // Conve rt non-htm l into a t ext node | |
| 5560 | } else i f ( !rhtml .test( ele m ) ) { | |
| 5561 | nodes.push ( context. createText Node( elem ) ); | |
| 5562 | ||
| 5563 | // Conve rt html in to DOM nod es | |
| 5564 | } else { | |
| 5565 | tmp = tmp || safe.ap pendChild( context.c reateEleme nt("div") ); | |
| 5566 | ||
| 5567 | // Deseria lize a sta ndard repr esentation | |
| 5568 | tag = (rta gName.exec ( elem ) | | [ "", "" ])[ 1 ].t oLowerCase (); | |
| 5569 | wrap = wra pMap[ tag ] || wrapM ap._defaul t; | |
| 5570 | ||
| 5571 | tmp.innerH TML = wrap [1] + elem .replace( rxhtmlTag, "<$1></$2 >" ) + wra p[2]; | |
| 5572 | ||
| 5573 | // Descend through w rappers to the right content | |
| 5574 | j = wrap[0 ]; | |
| 5575 | while ( j- - ) { | |
| 5576 | tm p = tmp.la stChild; | |
| 5577 | } | |
| 5578 | ||
| 5579 | // Manuall y add lead ing whites pace remov ed by IE | |
| 5580 | if ( !supp ort.leadin gWhitespac e && rlead ingWhitesp ace.test( elem ) ) { | |
| 5581 | no des.push( context.cr eateTextNo de( rleadi ngWhitespa ce.exec( e lem )[0] ) ); | |
| 5582 | } | |
| 5583 | ||
| 5584 | // Remove IE's autoi nserted <t body> from table fra gments | |
| 5585 | if ( !supp ort.tbody ) { | |
| 5586 | ||
| 5587 | // String wa s a <table >, *may* h ave spurio us <tbody> | |
| 5588 | el em = tag = == "table" && !rtbod y.test( el em ) ? | |
| 5589 | tmp. firstChild : | |
| 5590 | ||
| 5591 | // S tring was a bare <th ead> or <t foot> | |
| 5592 | wrap [1] === "< table>" && !rtbody.t est( elem ) ? | |
| 5593 | tmp : | |
| 5594 | 0; | |
| 5595 | ||
| 5596 | j = elem && elem.child Nodes.leng th; | |
| 5597 | wh ile ( j-- ) { | |
| 5598 | if ( jQuery.no deName( (t body = ele m.childNod es[j]), "t body" ) && !tbody.ch ildNodes.l ength ) { | |
| 5599 | elem.r emoveChild ( tbody ); | |
| 5600 | } | |
| 5601 | } | |
| 5602 | } | |
| 5603 | ||
| 5604 | jQuery.mer ge( nodes, tmp.child Nodes ); | |
| 5605 | ||
| 5606 | // Fix #12 392 for We bKit and I E > 9 | |
| 5607 | tmp.textCo ntent = "" ; | |
| 5608 | ||
| 5609 | // Fix #12 392 for ol dIE | |
| 5610 | while ( tm p.firstChi ld ) { | |
| 5611 | tm p.removeCh ild( tmp.f irstChild ); | |
| 5612 | } | |
| 5613 | ||
| 5614 | // Remembe r the top- level cont ainer for proper cle anup | |
| 5615 | tmp = safe .lastChild ; | |
| 5616 | } | |
| 5617 | } | |
| 5618 | } | |
| 5619 | ||
| 5620 | // F ix #11356: Clear ele ments from fragment | |
| 5621 | if ( tmp ) { | |
| 5622 | safe.r emoveChild ( tmp ); | |
| 5623 | } | |
| 5624 | ||
| 5625 | // R eset defau ltChecked for any ra dios and c heckboxes | |
| 5626 | // a bout to be appended to the DOM in IE 6/7 (#8060) | |
| 5627 | if ( !support. appendChec ked ) { | |
| 5628 | jQuery .grep( get All( nodes , "input" ), fixDefa ultChecked ); | |
| 5629 | } | |
| 5630 | ||
| 5631 | i = 0; | |
| 5632 | whil e ( (elem = nodes[ i ++ ]) ) { | |
| 5633 | ||
| 5634 | // #40 87 - If or igin and d estination elements are the sa me, and th is is | |
| 5635 | // tha t element, do not do anything | |
| 5636 | if ( s election & & jQuery.i nArray( el em, select ion ) !== -1 ) { | |
| 5637 | continue ; | |
| 5638 | } | |
| 5639 | ||
| 5640 | contai ns = jQuer y.contains ( elem.own erDocument , elem ); | |
| 5641 | ||
| 5642 | // App end to fra gment | |
| 5643 | tmp = getAll( sa fe.appendC hild( elem ), "scrip t" ); | |
| 5644 | ||
| 5645 | // Pre serve scri pt evaluat ion histor y | |
| 5646 | if ( c ontains ) { | |
| 5647 | setGloba lEval( tmp ); | |
| 5648 | } | |
| 5649 | ||
| 5650 | // Cap ture execu tables | |
| 5651 | if ( s cripts ) { | |
| 5652 | j = 0; | |
| 5653 | while ( (elem = tm p[ j++ ]) ) { | |
| 5654 | if ( rscri ptType.tes t( elem.ty pe || "" ) ) { | |
| 5655 | sc ripts.push ( elem ); | |
| 5656 | } | |
| 5657 | } | |
| 5658 | } | |
| 5659 | } | |
| 5660 | ||
| 5661 | tmp = null; | |
| 5662 | ||
| 5663 | retu rn safe; | |
| 5664 | }, | |
| 5665 | ||
| 5666 | cl eanData: f unction( e lems, /* i nternal */ acceptDat a ) { | |
| 5667 | var elem, type , id, data , | |
| 5668 | i = 0, | |
| 5669 | intern alKey = jQ uery.expan do, | |
| 5670 | cache = jQuery.c ache, | |
| 5671 | delete Expando = support.de leteExpand o, | |
| 5672 | specia l = jQuery .event.spe cial; | |
| 5673 | ||
| 5674 | for ( ; (elem = elems[i] ) != null; i++ ) { | |
| 5675 | if ( a cceptData || jQuery. acceptData ( elem ) ) { | |
| 5676 | ||
| 5677 | id = ele m[ interna lKey ]; | |
| 5678 | data = i d && cache [ id ]; | |
| 5679 | ||
| 5680 | if ( dat a ) { | |
| 5681 | if ( data. events ) { | |
| 5682 | fo r ( type i n data.eve nts ) { | |
| 5683 | if ( special[ type ] ) { | |
| 5684 | jQuery .event.rem ove( elem, type ); | |
| 5685 | ||
| 5686 | // T his is a s hortcut to avoid jQu ery.event. remove's o verhead | |
| 5687 | } el se { | |
| 5688 | jQuery .removeEve nt( elem, type, data .handle ); | |
| 5689 | } | |
| 5690 | } | |
| 5691 | } | |
| 5692 | ||
| 5693 | // Remove cache only if it was not alrea dy removed by jQuery .event.rem ove | |
| 5694 | if ( cache [ id ] ) { | |
| 5695 | ||
| 5696 | de lete cache [ id ]; | |
| 5697 | ||
| 5698 | // IE does n ot allow u s to delet e expando properties from node s, | |
| 5699 | // nor does it have a removeAttr ibute func tion on Do cument nod es; | |
| 5700 | // we must h andle all of these c ases | |
| 5701 | if ( deleteE xpando ) { | |
| 5702 | dele te elem[ i nternalKey ]; | |
| 5703 | ||
| 5704 | } else if ( typeof ele m.removeAt tribute != = strundef ined ) { | |
| 5705 | elem .removeAtt ribute( in ternalKey ); | |
| 5706 | ||
| 5707 | } else { | |
| 5708 | elem [ internal Key ] = nu ll; | |
| 5709 | } | |
| 5710 | ||
| 5711 | de letedIds.p ush( id ); | |
| 5712 | } | |
| 5713 | } | |
| 5714 | } | |
| 5715 | } | |
| 5716 | } | |
| 5717 | }); | |
| 5718 | ||
| 5719 | jQuery.fn. extend({ | |
| 5720 | te xt: functi on( value ) { | |
| 5721 | retu rn access( this, fun ction( val ue ) { | |
| 5722 | return value === undefined ? | |
| 5723 | jQuery.t ext( this ) : | |
| 5724 | this.emp ty().appen d( ( this[ 0] && this [0].ownerD ocument || document ).createTe xtNode( va lue ) ); | |
| 5725 | }, n ull, value , argument s.length ) ; | |
| 5726 | }, | |
| 5727 | ||
| 5728 | ap pend: func tion() { | |
| 5729 | retu rn this.do mManip( ar guments, f unction( e lem ) { | |
| 5730 | if ( t his.nodeTy pe === 1 | | this.nod eType === 11 || this .nodeType === 9 ) { | |
| 5731 | var targ et = manip ulationTar get( this, elem ); | |
| 5732 | target.a ppendChild ( elem ); | |
| 5733 | } | |
| 5734 | }); | |
| 5735 | }, | |
| 5736 | ||
| 5737 | pr epend: fun ction() { | |
| 5738 | retu rn this.do mManip( ar guments, f unction( e lem ) { | |
| 5739 | if ( t his.nodeTy pe === 1 | | this.nod eType === 11 || this .nodeType === 9 ) { | |
| 5740 | var targ et = manip ulationTar get( this, elem ); | |
| 5741 | target.i nsertBefor e( elem, t arget.firs tChild ); | |
| 5742 | } | |
| 5743 | }); | |
| 5744 | }, | |
| 5745 | ||
| 5746 | be fore: func tion() { | |
| 5747 | retu rn this.do mManip( ar guments, f unction( e lem ) { | |
| 5748 | if ( t his.parent Node ) { | |
| 5749 | this.par entNode.in sertBefore ( elem, th is ); | |
| 5750 | } | |
| 5751 | }); | |
| 5752 | }, | |
| 5753 | ||
| 5754 | af ter: funct ion() { | |
| 5755 | retu rn this.do mManip( ar guments, f unction( e lem ) { | |
| 5756 | if ( t his.parent Node ) { | |
| 5757 | this.par entNode.in sertBefore ( elem, th is.nextSib ling ); | |
| 5758 | } | |
| 5759 | }); | |
| 5760 | }, | |
| 5761 | ||
| 5762 | re move: func tion( sele ctor, keep Data /* In ternal Use Only */ ) { | |
| 5763 | var elem, | |
| 5764 | elems = selector ? jQuery. filter( se lector, th is ) : thi s, | |
| 5765 | i = 0; | |
| 5766 | ||
| 5767 | for ( ; (elem = elems[i] ) != null; i++ ) { | |
| 5768 | ||
| 5769 | if ( ! keepData & & elem.nod eType === 1 ) { | |
| 5770 | jQuery.c leanData( getAll( el em ) ); | |
| 5771 | } | |
| 5772 | ||
| 5773 | if ( e lem.parent Node ) { | |
| 5774 | if ( kee pData && j Query.cont ains( elem .ownerDocu ment, elem ) ) { | |
| 5775 | setGlobalE val( getAl l( elem, " script" ) ); | |
| 5776 | } | |
| 5777 | elem.par entNode.re moveChild( elem ); | |
| 5778 | } | |
| 5779 | } | |
| 5780 | ||
| 5781 | retu rn this; | |
| 5782 | }, | |
| 5783 | ||
| 5784 | em pty: funct ion() { | |
| 5785 | var elem, | |
| 5786 | i = 0; | |
| 5787 | ||
| 5788 | for ( ; (elem = this[i]) != null; i++ ) { | |
| 5789 | // Rem ove elemen t nodes an d prevent memory lea ks | |
| 5790 | if ( e lem.nodeTy pe === 1 ) { | |
| 5791 | jQuery.c leanData( getAll( el em, false ) ); | |
| 5792 | } | |
| 5793 | ||
| 5794 | // Rem ove any re maining no des | |
| 5795 | while ( elem.fir stChild ) { | |
| 5796 | elem.rem oveChild( elem.first Child ); | |
| 5797 | } | |
| 5798 | ||
| 5799 | // If this is a select, en sure that it display s empty (# 12336) | |
| 5800 | // Sup port: IE<9 | |
| 5801 | if ( e lem.option s && jQuer y.nodeName ( elem, "s elect" ) ) { | |
| 5802 | elem.opt ions.lengt h = 0; | |
| 5803 | } | |
| 5804 | } | |
| 5805 | ||
| 5806 | retu rn this; | |
| 5807 | }, | |
| 5808 | ||
| 5809 | cl one: funct ion( dataA ndEvents, deepDataAn dEvents ) { | |
| 5810 | data AndEvents = dataAndE vents == n ull ? fals e : dataAn dEvents; | |
| 5811 | deep DataAndEve nts = deep DataAndEve nts == nul l ? dataAn dEvents : deepDataAn dEvents; | |
| 5812 | ||
| 5813 | retu rn this.ma p(function () { | |
| 5814 | return jQuery.cl one( this, dataAndEv ents, deep DataAndEve nts ); | |
| 5815 | }); | |
| 5816 | }, | |
| 5817 | ||
| 5818 | ht ml: functi on( value ) { | |
| 5819 | retu rn access( this, fun ction( val ue ) { | |
| 5820 | var el em = this[ 0 ] || {} , | |
| 5821 | i = 0, | |
| 5822 | l = this .length; | |
| 5823 | ||
| 5824 | if ( v alue === u ndefined ) { | |
| 5825 | return e lem.nodeTy pe === 1 ? | |
| 5826 | elem.inner HTML.repla ce( rinlin ejQuery, " " ) : | |
| 5827 | undefined; | |
| 5828 | } | |
| 5829 | ||
| 5830 | // See if we can take a sh ortcut and just use innerHTML | |
| 5831 | if ( t ypeof valu e === "str ing" && !r noInnerhtm l.test( va lue ) && | |
| 5832 | ( suppor t.htmlSeri alize || ! rnoshimcac he.test( v alue ) ) && | |
| 5833 | ( suppor t.leadingW hitespace || !rleadi ngWhitespa ce.test( v alue ) ) & & | |
| 5834 | !wrapMap [ (rtagNam e.exec( va lue ) || [ "", "" ]) [ 1 ].toLo werCase() ] ) { | |
| 5835 | ||
| 5836 | value = value.repl ace( rxhtm lTag, "<$1 ></$2>" ); | |
| 5837 | ||
| 5838 | try { | |
| 5839 | for (; i < l; i++ ) { | |
| 5840 | // Remove el ement node s and prev ent memory leaks | |
| 5841 | el em = this[ i] || {}; | |
| 5842 | if ( elem.no deType === 1 ) { | |
| 5843 | jQue ry.cleanDa ta( getAll ( elem, fa lse ) ); | |
| 5844 | elem .innerHTML = value; | |
| 5845 | } | |
| 5846 | } | |
| 5847 | ||
| 5848 | elem = 0; | |
| 5849 | ||
| 5850 | // If us ing innerH TML throws an except ion, use t he fallbac k method | |
| 5851 | } catch( e) {} | |
| 5852 | } | |
| 5853 | ||
| 5854 | if ( e lem ) { | |
| 5855 | this.emp ty().appen d( value ) ; | |
| 5856 | } | |
| 5857 | }, n ull, value , argument s.length ) ; | |
| 5858 | }, | |
| 5859 | ||
| 5860 | re placeWith: function( ) { | |
| 5861 | var arg = argu ments[ 0 ] ; | |
| 5862 | ||
| 5863 | // M ake the ch anges, rep lacing eac h context element wi th the new content | |
| 5864 | this .domManip( arguments , function ( elem ) { | |
| 5865 | arg = this.paren tNode; | |
| 5866 | ||
| 5867 | jQuery .cleanData ( getAll( this ) ); | |
| 5868 | ||
| 5869 | if ( a rg ) { | |
| 5870 | arg.repl aceChild( elem, this ); | |
| 5871 | } | |
| 5872 | }); | |
| 5873 | ||
| 5874 | // F orce remov al if ther e was no n ew content (e.g., fr om empty a rguments) | |
| 5875 | retu rn arg && (arg.lengt h || arg.n odeType) ? this : th is.remove( ); | |
| 5876 | }, | |
| 5877 | ||
| 5878 | de tach: func tion( sele ctor ) { | |
| 5879 | retu rn this.re move( sele ctor, true ); | |
| 5880 | }, | |
| 5881 | ||
| 5882 | do mManip: fu nction( ar gs, callba ck ) { | |
| 5883 | ||
| 5884 | // F latten any nested ar rays | |
| 5885 | args = concat. apply( [], args ); | |
| 5886 | ||
| 5887 | var first, nod e, hasScri pts, | |
| 5888 | script s, doc, fr agment, | |
| 5889 | i = 0, | |
| 5890 | l = th is.length, | |
| 5891 | set = this, | |
| 5892 | iNoClo ne = l - 1 , | |
| 5893 | value = args[0], | |
| 5894 | isFunc tion = jQu ery.isFunc tion( valu e ); | |
| 5895 | ||
| 5896 | // W e can't cl oneNode fr agments th at contain checked, in WebKit | |
| 5897 | if ( isFunctio n || | |
| 5898 | ( l > 1 && typeof value === "string" & & | |
| 5899 | !support.c heckClone && rchecke d.test( va lue ) ) ) { | |
| 5900 | return this.each (function( index ) { | |
| 5901 | var self = set.eq( index ); | |
| 5902 | if ( isF unction ) { | |
| 5903 | args[0] = value.call ( this, in dex, self. html() ); | |
| 5904 | } | |
| 5905 | self.dom Manip( arg s, callbac k ); | |
| 5906 | }); | |
| 5907 | } | |
| 5908 | ||
| 5909 | if ( l ) { | |
| 5910 | fragme nt = jQuer y.buildFra gment( arg s, this[ 0 ].ownerDo cument, fa lse, this ); | |
| 5911 | first = fragment .firstChil d; | |
| 5912 | ||
| 5913 | if ( f ragment.ch ildNodes.l ength === 1 ) { | |
| 5914 | fragment = first; | |
| 5915 | } | |
| 5916 | ||
| 5917 | if ( f irst ) { | |
| 5918 | scripts = jQuery.m ap( getAll ( fragment , "script" ), disabl eScript ); | |
| 5919 | hasScrip ts = scrip ts.length; | |
| 5920 | ||
| 5921 | // Use t he origina l fragment for the l ast item i nstead of the first because it can end u p | |
| 5922 | // being emptied i ncorrectly in certai n situatio ns (#8070) . | |
| 5923 | for ( ; i < l; i++ ) { | |
| 5924 | node = fra gment; | |
| 5925 | ||
| 5926 | if ( i !== iNoClone ) { | |
| 5927 | no de = jQuer y.clone( n ode, true, true ); | |
| 5928 | ||
| 5929 | // Keep refe rences to cloned scr ipts for l ater resto ration | |
| 5930 | if ( hasScri pts ) { | |
| 5931 | jQue ry.merge( scripts, g etAll( nod e, "script " ) ); | |
| 5932 | } | |
| 5933 | } | |
| 5934 | ||
| 5935 | callback.c all( this[ i], node, i ); | |
| 5936 | } | |
| 5937 | ||
| 5938 | if ( has Scripts ) { | |
| 5939 | doc = scri pts[ scrip ts.length - 1 ].owne rDocument; | |
| 5940 | ||
| 5941 | // Reenabl e scripts | |
| 5942 | jQuery.map ( scripts, restoreSc ript ); | |
| 5943 | ||
| 5944 | // Evaluat e executab le scripts on first document i nsertion | |
| 5945 | for ( i = 0; i < has Scripts; i ++ ) { | |
| 5946 | no de = scrip ts[ i ]; | |
| 5947 | if ( rscript Type.test( node.type || "" ) & & | |
| 5948 | !jQu ery._data( node, "gl obalEval" ) && jQuer y.contains ( doc, nod e ) ) { | |
| 5949 | ||
| 5950 | if ( node.src ) { | |
| 5951 | // Opt ional AJAX dependenc y, but won 't run scr ipts if no t present | |
| 5952 | if ( j Query._eva lUrl ) { | |
| 5953 | jQuery._ evalUrl( n ode.src ); | |
| 5954 | } | |
| 5955 | } el se { | |
| 5956 | jQuery .globalEva l( ( node. text || no de.textCon tent || no de.innerHT ML || "" ) .replace( rcleanScri pt, "" ) ) ; | |
| 5957 | } | |
| 5958 | } | |
| 5959 | } | |
| 5960 | } | |
| 5961 | ||
| 5962 | // Fix # 11809: Avo id leaking memory | |
| 5963 | fragment = first = null; | |
| 5964 | } | |
| 5965 | } | |
| 5966 | ||
| 5967 | retu rn this; | |
| 5968 | } | |
| 5969 | }); | |
| 5970 | ||
| 5971 | jQuery.eac h({ | |
| 5972 | ap pendTo: "a ppend", | |
| 5973 | pr ependTo: " prepend", | |
| 5974 | in sertBefore : "before" , | |
| 5975 | in sertAfter: "after", | |
| 5976 | re placeAll: "replaceWi th" | |
| 5977 | }, functio n( name, o riginal ) { | |
| 5978 | jQ uery.fn[ n ame ] = fu nction( se lector ) { | |
| 5979 | var elems, | |
| 5980 | i = 0, | |
| 5981 | ret = [], | |
| 5982 | insert = jQuery( selector ), | |
| 5983 | last = insert.le ngth - 1; | |
| 5984 | ||
| 5985 | for ( ; i <= l ast; i++ ) { | |
| 5986 | elems = i === la st ? this : this.clo ne(true); | |
| 5987 | jQuery ( insert[i ] )[ origi nal ]( ele ms ); | |
| 5988 | ||
| 5989 | // Mod ern browse rs can app ly jQuery collection s as array s, but old IE needs a .get() | |
| 5990 | push.a pply( ret, elems.get () ); | |
| 5991 | } | |
| 5992 | ||
| 5993 | retu rn this.pu shStack( r et ); | |
| 5994 | }; | |
| 5995 | }); | |
| 5996 | ||
| 5997 | ||
| 5998 | var iframe , | |
| 5999 | el emdisplay = {}; | |
| 6000 | ||
| 6001 | /** | |
| 6002 | * Retriev e the actu al display of a elem ent | |
| 6003 | * @param {String} n ame nodeNa me of the element | |
| 6004 | * @param {Object} d oc Documen t object | |
| 6005 | */ | |
| 6006 | // Called only from within def aultDispla y | |
| 6007 | function a ctualDispl ay( name, doc ) { | |
| 6008 | va r style, | |
| 6009 | elem = jQuery( doc.creat eElement( name ) ).a ppendTo( d oc.body ), | |
| 6010 | ||
| 6011 | // g etDefaultC omputedSty le might b e reliably used only on attach ed element | |
| 6012 | disp lay = wind ow.getDefa ultCompute dStyle && ( style = window.get DefaultCom putedStyle ( elem[ 0 ] ) ) ? | |
| 6013 | ||
| 6014 | // Use of this m ethod is a temporary fix (more like optm ization) u ntil somet hing bette r comes al ong, | |
| 6015 | // sin ce it was removed fr om specifi cation and supported only in F F | |
| 6016 | style. display : jQuery.css ( elem[ 0 ], "displa y" ); | |
| 6017 | ||
| 6018 | // We don't have any d ata stored on the el ement, | |
| 6019 | // so use "d etach" met hod as fas t way to g et rid of the elemen t | |
| 6020 | el em.detach( ); | |
| 6021 | ||
| 6022 | re turn displ ay; | |
| 6023 | } | |
| 6024 | ||
| 6025 | /** | |
| 6026 | * Try to determine the defaul t display value of a n element | |
| 6027 | * @param {String} n odeName | |
| 6028 | */ | |
| 6029 | function d efaultDisp lay( nodeN ame ) { | |
| 6030 | va r doc = do cument, | |
| 6031 | disp lay = elem display[ n odeName ]; | |
| 6032 | ||
| 6033 | if ( !displa y ) { | |
| 6034 | disp lay = actu alDisplay( nodeName, doc ); | |
| 6035 | ||
| 6036 | // I f the simp le way fai ls, read f rom inside an iframe | |
| 6037 | if ( display = == "none" || !displa y ) { | |
| 6038 | ||
| 6039 | // Use the alrea dy-created iframe if possible | |
| 6040 | iframe = (iframe || jQuery ( "<iframe framebord er='0' wid th='0' hei ght='0'/>" )).append To( doc.do cumentElem ent ); | |
| 6041 | ||
| 6042 | // Alw ays write a new HTML skeleton so Webkit and Firefo x don't ch oke on reu se | |
| 6043 | doc = ( iframe[ 0 ].conten tWindow || iframe[ 0 ].content Document ) .document; | |
| 6044 | ||
| 6045 | // Sup port: IE | |
| 6046 | doc.wr ite(); | |
| 6047 | doc.cl ose(); | |
| 6048 | ||
| 6049 | displa y = actual Display( n odeName, d oc ); | |
| 6050 | iframe .detach(); | |
| 6051 | } | |
| 6052 | ||
| 6053 | // S tore the c orrect def ault displ ay | |
| 6054 | elem display[ n odeName ] = display; | |
| 6055 | } | |
| 6056 | ||
| 6057 | re turn displ ay; | |
| 6058 | } | |
| 6059 | ||
| 6060 | ||
| 6061 | (function( ) { | |
| 6062 | va r shrinkWr apBlocksVa l; | |
| 6063 | ||
| 6064 | su pport.shri nkWrapBloc ks = funct ion() { | |
| 6065 | if ( shrinkWra pBlocksVal != null ) { | |
| 6066 | return shrinkWra pBlocksVal ; | |
| 6067 | } | |
| 6068 | ||
| 6069 | // W ill be cha nged later if needed . | |
| 6070 | shri nkWrapBloc ksVal = fa lse; | |
| 6071 | ||
| 6072 | // M inified: v ar b,c,d | |
| 6073 | var div, body, container ; | |
| 6074 | ||
| 6075 | body = documen t.getEleme ntsByTagNa me( "body" )[ 0 ]; | |
| 6076 | if ( !body || !body.styl e ) { | |
| 6077 | // Tes t fired to o early or in an uns upported e nvironment , exit. | |
| 6078 | return ; | |
| 6079 | } | |
| 6080 | ||
| 6081 | // S etup | |
| 6082 | div = document .createEle ment( "div " ); | |
| 6083 | cont ainer = do cument.cre ateElement ( "div" ); | |
| 6084 | cont ainer.styl e.cssText = "positio n:absolute ;border:0; width:0;he ight:0;top :0;left:-9 999px"; | |
| 6085 | body .appendChi ld( contai ner ).appe ndChild( d iv ); | |
| 6086 | ||
| 6087 | // S upport: IE 6 | |
| 6088 | // C heck if el ements wit h layout s hrink-wrap their chi ldren | |
| 6089 | if ( typeof di v.style.zo om !== str undefined ) { | |
| 6090 | // Res et CSS: bo x-sizing; display; m argin; bor der | |
| 6091 | div.st yle.cssTex t = | |
| 6092 | // Suppo rt: Firefo x<29, Andr oid 2.3 | |
| 6093 | // Vendo r-prefix b ox-sizing | |
| 6094 | "-webkit -box-sizin g:content- box;-moz-b ox-sizing: content-bo x;" + | |
| 6095 | "box-siz ing:conten t-box;disp lay:block; margin:0;b order:0;" + | |
| 6096 | "padding :1px;width :1px;zoom: 1"; | |
| 6097 | div.ap pendChild( document. createElem ent( "div" ) ).style .width = " 5px"; | |
| 6098 | shrink WrapBlocks Val = div. offsetWidt h !== 3; | |
| 6099 | } | |
| 6100 | ||
| 6101 | body .removeChi ld( contai ner ); | |
| 6102 | ||
| 6103 | retu rn shrinkW rapBlocksV al; | |
| 6104 | }; | |
| 6105 | ||
| 6106 | })(); | |
| 6107 | var rmargi n = (/^mar gin/); | |
| 6108 | ||
| 6109 | var rnumno npx = new RegExp( "^ (" + pnum + ")(?!px) [a-z%]+$", "i" ); | |
| 6110 | ||
| 6111 | ||
| 6112 | ||
| 6113 | var getSty les, curCS S, | |
| 6114 | rp osition = /^(top|rig ht|bottom| left)$/; | |
| 6115 | ||
| 6116 | if ( windo w.getCompu tedStyle ) { | |
| 6117 | ge tStyles = function( elem ) { | |
| 6118 | retu rn elem.ow nerDocumen t.defaultV iew.getCom putedStyle ( elem, nu ll ); | |
| 6119 | }; | |
| 6120 | ||
| 6121 | cu rCSS = fun ction( ele m, name, c omputed ) { | |
| 6122 | var width, min Width, max Width, ret , | |
| 6123 | style = elem.sty le; | |
| 6124 | ||
| 6125 | comp uted = com puted || g etStyles( elem ); | |
| 6126 | ||
| 6127 | // g etProperty Value is o nly needed for .css( 'filter') in IE9, se e #12537 | |
| 6128 | ret = computed ? compute d.getPrope rtyValue( name ) || computed[ name ] : u ndefined; | |
| 6129 | ||
| 6130 | if ( computed ) { | |
| 6131 | ||
| 6132 | if ( r et === "" && !jQuery .contains( elem.owne rDocument, elem ) ) { | |
| 6133 | ret = jQ uery.style ( elem, na me ); | |
| 6134 | } | |
| 6135 | ||
| 6136 | // A t ribute to the "aweso me hack by Dean Edwa rds" | |
| 6137 | // Chr ome < 17 a nd Safari 5.0 uses " computed v alue" inst ead of "us ed value" for margin -right | |
| 6138 | // Saf ari 5.1.7 (at least) returns p ercentage for a larg er set of values, bu t width se ems to be reliably p ixels | |
| 6139 | // thi s is again st the CSS OM draft s pec: http: //dev.w3.o rg/csswg/c ssom/#reso lved-value s | |
| 6140 | if ( r numnonpx.t est( ret ) && rmargi n.test( na me ) ) { | |
| 6141 | ||
| 6142 | // Remem ber the or iginal val ues | |
| 6143 | width = style.widt h; | |
| 6144 | minWidth = style.m inWidth; | |
| 6145 | maxWidth = style.m axWidth; | |
| 6146 | ||
| 6147 | // Put i n the new values to get a comp uted value out | |
| 6148 | style.mi nWidth = s tyle.maxWi dth = styl e.width = ret; | |
| 6149 | ret = co mputed.wid th; | |
| 6150 | ||
| 6151 | // Rever t the chan ged values | |
| 6152 | style.wi dth = widt h; | |
| 6153 | style.mi nWidth = m inWidth; | |
| 6154 | style.ma xWidth = m axWidth; | |
| 6155 | } | |
| 6156 | } | |
| 6157 | ||
| 6158 | // S upport: IE | |
| 6159 | // I E returns zIndex val ue as an i nteger. | |
| 6160 | retu rn ret === undefined ? | |
| 6161 | ret : | |
| 6162 | ret + ""; | |
| 6163 | }; | |
| 6164 | } else if ( document .documentE lement.cur rentStyle ) { | |
| 6165 | ge tStyles = function( elem ) { | |
| 6166 | retu rn elem.cu rrentStyle ; | |
| 6167 | }; | |
| 6168 | ||
| 6169 | cu rCSS = fun ction( ele m, name, c omputed ) { | |
| 6170 | var left, rs, rsLeft, re t, | |
| 6171 | style = elem.sty le; | |
| 6172 | ||
| 6173 | comp uted = com puted || g etStyles( elem ); | |
| 6174 | ret = computed ? compute d[ name ] : undefine d; | |
| 6175 | ||
| 6176 | // A void setti ng ret to empty stri ng here | |
| 6177 | // s o we don't default t o auto | |
| 6178 | if ( ret == nu ll && styl e && style [ name ] ) { | |
| 6179 | ret = style[ nam e ]; | |
| 6180 | } | |
| 6181 | ||
| 6182 | // F rom the aw esome hack by Dean E dwards | |
| 6183 | // h ttp://erik .eae.net/a rchives/20 07/07/27/1 8.54.15/#c omment-102 291 | |
| 6184 | ||
| 6185 | // I f we're no t dealing with a reg ular pixel number | |
| 6186 | // b ut a numbe r that has a weird e nding, we need to co nvert it t o pixels | |
| 6187 | // b ut not pos ition css attributes , as those are propo rtional to the paren t element instead | |
| 6188 | // a nd we can' t measure the parent instead b ecause it might trig ger a "sta cking doll s" problem | |
| 6189 | if ( rnumnonpx .test( ret ) && !rpo sition.tes t( name ) ) { | |
| 6190 | ||
| 6191 | // Rem ember the original v alues | |
| 6192 | left = style.lef t; | |
| 6193 | rs = e lem.runtim eStyle; | |
| 6194 | rsLeft = rs && r s.left; | |
| 6195 | ||
| 6196 | // Put in the ne w values t o get a co mputed val ue out | |
| 6197 | if ( r sLeft ) { | |
| 6198 | rs.left = elem.cur rentStyle. left; | |
| 6199 | } | |
| 6200 | style. left = nam e === "fon tSize" ? " 1em" : ret ; | |
| 6201 | ret = style.pixe lLeft + "p x"; | |
| 6202 | ||
| 6203 | // Rev ert the ch anged valu es | |
| 6204 | style. left = lef t; | |
| 6205 | if ( r sLeft ) { | |
| 6206 | rs.left = rsLeft; | |
| 6207 | } | |
| 6208 | } | |
| 6209 | ||
| 6210 | // S upport: IE | |
| 6211 | // I E returns zIndex val ue as an i nteger. | |
| 6212 | retu rn ret === undefined ? | |
| 6213 | ret : | |
| 6214 | ret + "" || "aut o"; | |
| 6215 | }; | |
| 6216 | } | |
| 6217 | ||
| 6218 | ||
| 6219 | ||
| 6220 | ||
| 6221 | function a ddGetHookI f( conditi onFn, hook Fn ) { | |
| 6222 | // Define th e hook, we 'll check on the fir st run if it's reall y needed. | |
| 6223 | re turn { | |
| 6224 | get: function( ) { | |
| 6225 | var co ndition = conditionF n(); | |
| 6226 | ||
| 6227 | if ( c ondition = = null ) { | |
| 6228 | // The t est was no t ready at this poin t; screw t he hook th is time | |
| 6229 | // but c heck again when need ed next ti me. | |
| 6230 | return; | |
| 6231 | } | |
| 6232 | ||
| 6233 | if ( c ondition ) { | |
| 6234 | // Hook not needed (or it's not possib le to use it due to missing de pendency), | |
| 6235 | // remov e it. | |
| 6236 | // Since there are no other hooks for marginRigh t, remove the whole object. | |
| 6237 | delete t his.get; | |
| 6238 | return; | |
| 6239 | } | |
| 6240 | ||
| 6241 | // Hoo k needed; redefine i t so that the suppor t test is not execut ed again. | |
| 6242 | ||
| 6243 | return (this.get = hookFn) .apply( th is, argume nts ); | |
| 6244 | } | |
| 6245 | }; | |
| 6246 | } | |
| 6247 | ||
| 6248 | ||
| 6249 | (function( ) { | |
| 6250 | // Minified: var b,c,d ,e,f,g, h, i | |
| 6251 | va r div, sty le, a, pix elPosition Val, boxSi zingReliab leVal, | |
| 6252 | reli ableHidden OffsetsVal , reliable MarginRigh tVal; | |
| 6253 | ||
| 6254 | // Setup | |
| 6255 | di v = docume nt.createE lement( "d iv" ); | |
| 6256 | di v.innerHTM L = " <li nk/><table ></table>< a href='/a '>a</a><in put type=' checkbox'/ >"; | |
| 6257 | a = div.getE lementsByT agName( "a " )[ 0 ]; | |
| 6258 | st yle = a && a.style; | |
| 6259 | ||
| 6260 | // Finish ea rly in lim ited (non- browser) e nvironment s | |
| 6261 | if ( !style ) { | |
| 6262 | retu rn; | |
| 6263 | } | |
| 6264 | ||
| 6265 | st yle.cssTex t = "float :left;opac ity:.5"; | |
| 6266 | ||
| 6267 | // Support: IE<9 | |
| 6268 | // Make sure that elem ent opacit y exists ( as opposed to filter ) | |
| 6269 | su pport.opac ity = styl e.opacity === "0.5"; | |
| 6270 | ||
| 6271 | // Verify st yle float existence | |
| 6272 | // (IE uses styleFloat instead o f cssFloat ) | |
| 6273 | su pport.cssF loat = !!s tyle.cssFl oat; | |
| 6274 | ||
| 6275 | di v.style.ba ckgroundCl ip = "cont ent-box"; | |
| 6276 | di v.cloneNod e( true ). style.back groundClip = ""; | |
| 6277 | su pport.clea rCloneStyl e = div.st yle.backgr oundClip = == "conten t-box"; | |
| 6278 | ||
| 6279 | // Support: Firefox<29 , Android 2.3 | |
| 6280 | // Vendor-pr efix box-s izing | |
| 6281 | su pport.boxS izing = st yle.boxSiz ing === "" || style. MozBoxSizi ng === "" || | |
| 6282 | styl e.WebkitBo xSizing == = ""; | |
| 6283 | ||
| 6284 | jQ uery.exten d(support, { | |
| 6285 | reli ableHidden Offsets: f unction() { | |
| 6286 | if ( r eliableHid denOffsets Val == nul l ) { | |
| 6287 | computeS tyleTests( ); | |
| 6288 | } | |
| 6289 | return reliableH iddenOffse tsVal; | |
| 6290 | }, | |
| 6291 | ||
| 6292 | boxS izingRelia ble: funct ion() { | |
| 6293 | if ( b oxSizingRe liableVal == null ) { | |
| 6294 | computeS tyleTests( ); | |
| 6295 | } | |
| 6296 | return boxSizing ReliableVa l; | |
| 6297 | }, | |
| 6298 | ||
| 6299 | pixe lPosition: function( ) { | |
| 6300 | if ( p ixelPositi onVal == n ull ) { | |
| 6301 | computeS tyleTests( ); | |
| 6302 | } | |
| 6303 | return pixelPosi tionVal; | |
| 6304 | }, | |
| 6305 | ||
| 6306 | // S upport: An droid 2.3 | |
| 6307 | reli ableMargin Right: fun ction() { | |
| 6308 | if ( r eliableMar ginRightVa l == null ) { | |
| 6309 | computeS tyleTests( ); | |
| 6310 | } | |
| 6311 | return reliableM arginRight Val; | |
| 6312 | } | |
| 6313 | }) ; | |
| 6314 | ||
| 6315 | fu nction com puteStyleT ests() { | |
| 6316 | // M inified: v ar b,c,d,j | |
| 6317 | var div, body, container , contents ; | |
| 6318 | ||
| 6319 | body = documen t.getEleme ntsByTagNa me( "body" )[ 0 ]; | |
| 6320 | if ( !body || !body.styl e ) { | |
| 6321 | // Tes t fired to o early or in an uns upported e nvironment , exit. | |
| 6322 | return ; | |
| 6323 | } | |
| 6324 | ||
| 6325 | // S etup | |
| 6326 | div = document .createEle ment( "div " ); | |
| 6327 | cont ainer = do cument.cre ateElement ( "div" ); | |
| 6328 | cont ainer.styl e.cssText = "positio n:absolute ;border:0; width:0;he ight:0;top :0;left:-9 999px"; | |
| 6329 | body .appendChi ld( contai ner ).appe ndChild( d iv ); | |
| 6330 | ||
| 6331 | div. style.cssT ext = | |
| 6332 | // Sup port: Fire fox<29, An droid 2.3 | |
| 6333 | // Ven dor-prefix box-sizin g | |
| 6334 | "-webk it-box-siz ing:border -box;-moz- box-sizing :border-bo x;" + | |
| 6335 | "box-s izing:bord er-box;dis play:block ;margin-to p:1%;top:1 %;" + | |
| 6336 | "borde r:1px;padd ing:1px;wi dth:4px;po sition:abs olute"; | |
| 6337 | ||
| 6338 | // S upport: IE <9 | |
| 6339 | // A ssume reas onable val ues in the absence o f getCompu tedStyle | |
| 6340 | pixe lPositionV al = boxSi zingReliab leVal = fa lse; | |
| 6341 | reli ableMargin RightVal = true; | |
| 6342 | ||
| 6343 | // C heck for g etComputed Style so t hat this c ode is not run in IE <9. | |
| 6344 | if ( window.ge tComputedS tyle ) { | |
| 6345 | pixelP ositionVal = ( windo w.getCompu tedStyle( div, null ) || {} ). top !== "1 %"; | |
| 6346 | boxSiz ingReliabl eVal = | |
| 6347 | ( window .getComput edStyle( d iv, null ) || { widt h: "4px" } ).width = == "4px"; | |
| 6348 | ||
| 6349 | // Sup port: Andr oid 2.3 | |
| 6350 | // Div with expl icit width and no ma rgin-right incorrect ly | |
| 6351 | // get s computed margin-ri ght based on width o f containe r (#3333) | |
| 6352 | // Web Kit Bug 13 343 - getC omputedSty le returns wrong val ue for mar gin-right | |
| 6353 | conten ts = div.a ppendChild ( document .createEle ment( "div " ) ); | |
| 6354 | ||
| 6355 | // Res et CSS: bo x-sizing; display; m argin; bor der; paddi ng | |
| 6356 | conten ts.style.c ssText = d iv.style.c ssText = | |
| 6357 | // Suppo rt: Firefo x<29, Andr oid 2.3 | |
| 6358 | // Vendo r-prefix b ox-sizing | |
| 6359 | "-webkit -box-sizin g:content- box;-moz-b ox-sizing: content-bo x;" + | |
| 6360 | "box-siz ing:conten t-box;disp lay:block; margin:0;b order:0;pa dding:0"; | |
| 6361 | conten ts.style.m arginRight = content s.style.wi dth = "0"; | |
| 6362 | div.st yle.width = "1px"; | |
| 6363 | ||
| 6364 | reliab leMarginRi ghtVal = | |
| 6365 | !parseFl oat( ( win dow.getCom putedStyle ( contents , null ) | | {} ).mar ginRight ) ; | |
| 6366 | } | |
| 6367 | ||
| 6368 | // S upport: IE 8 | |
| 6369 | // C heck if ta ble cells still have offsetWid th/Height when they are set | |
| 6370 | // t o display: none and t here are s till other visible t able cells in a | |
| 6371 | // t able row; if so, off setWidth/H eight are not reliab le for use when | |
| 6372 | // d etermining if an ele ment has b een hidden directly using | |
| 6373 | // d isplay:non e (it is s till safe to use off sets if a parent ele ment is | |
| 6374 | // h idden; don safety go ggles and see bug #4 512 for mo re informa tion). | |
| 6375 | div. innerHTML = "<table> <tr><td></ td><td>t</ td></tr></ table>"; | |
| 6376 | cont ents = div .getElemen tsByTagNam e( "td" ); | |
| 6377 | cont ents[ 0 ]. style.cssT ext = "mar gin:0;bord er:0;paddi ng:0;displ ay:none"; | |
| 6378 | reli ableHidden OffsetsVal = content s[ 0 ].off setHeight === 0; | |
| 6379 | if ( reliableH iddenOffse tsVal ) { | |
| 6380 | conten ts[ 0 ].st yle.displa y = ""; | |
| 6381 | conten ts[ 1 ].st yle.displa y = "none" ; | |
| 6382 | reliab leHiddenOf fsetsVal = contents[ 0 ].offse tHeight == = 0; | |
| 6383 | } | |
| 6384 | ||
| 6385 | body .removeChi ld( contai ner ); | |
| 6386 | } | |
| 6387 | ||
| 6388 | })(); | |
| 6389 | ||
| 6390 | ||
| 6391 | // A metho d for quic kly swappi ng in/out CSS proper ties to ge t correct calculatio ns. | |
| 6392 | jQuery.swa p = functi on( elem, options, c allback, a rgs ) { | |
| 6393 | va r ret, nam e, | |
| 6394 | old = {}; | |
| 6395 | ||
| 6396 | // Remember the old va lues, and insert the new ones | |
| 6397 | fo r ( name i n options ) { | |
| 6398 | old[ name ] = elem.style [ name ]; | |
| 6399 | elem .style[ na me ] = opt ions[ name ]; | |
| 6400 | } | |
| 6401 | ||
| 6402 | re t = callba ck.apply( elem, args || [] ); | |
| 6403 | ||
| 6404 | // Revert th e old valu es | |
| 6405 | fo r ( name i n options ) { | |
| 6406 | elem .style[ na me ] = old [ name ]; | |
| 6407 | } | |
| 6408 | ||
| 6409 | re turn ret; | |
| 6410 | }; | |
| 6411 | ||
| 6412 | ||
| 6413 | var | |
| 6414 | ralp ha = /alph a\([^)]*\) /i, | |
| 6415 | ro pacity = / opacity\s* =\s*([^)]* )/, | |
| 6416 | ||
| 6417 | // swappable if displa y is none or starts with table except "t able", "ta ble-cell", or "table -caption" | |
| 6418 | // see here for displa y values: https://de veloper.mo zilla.org/ en-US/docs /CSS/displ ay | |
| 6419 | rd isplayswap = /^(none |table(?!- c[ea]).+)/ , | |
| 6420 | rn umsplit = new RegExp ( "^(" + p num + ")(. *)$", "i" ), | |
| 6421 | rr elNum = ne w RegExp( "^([+-])=( " + pnum + ")", "i" ), | |
| 6422 | ||
| 6423 | cs sShow = { position: "absolute" , visibili ty: "hidde n", displa y: "block" }, | |
| 6424 | cs sN DNS ransform = { | |
| 6425 | lett erSpacing: "0", | |
| 6426 | font Weight: "4 00" | |
| 6427 | }, | |
| 6428 | ||
| 6429 | cs sPrefixes = [ "Webki t", "O", " Moz", "ms" ]; | |
| 6430 | ||
| 6431 | ||
| 6432 | // return a css prop erty mappe d to a pot entially v endor pref ixed prope rty | |
| 6433 | function v endorPropN ame( style , name ) { | |
| 6434 | ||
| 6435 | // shortcut for names that are n ot vendor prefixed | |
| 6436 | if ( name in style ) { | |
| 6437 | retu rn name; | |
| 6438 | } | |
| 6439 | ||
| 6440 | // check for vendor pr efixed nam es | |
| 6441 | va r capName = name.cha rAt(0).toU pperCase() + name.sl ice(1), | |
| 6442 | orig Name = nam e, | |
| 6443 | i = cssPrefixe s.length; | |
| 6444 | ||
| 6445 | wh ile ( i-- ) { | |
| 6446 | name = cssPref ixes[ i ] + capName; | |
| 6447 | if ( name in s tyle ) { | |
| 6448 | return name; | |
| 6449 | } | |
| 6450 | } | |
| 6451 | ||
| 6452 | re turn origN ame; | |
| 6453 | } | |
| 6454 | ||
| 6455 | function s howHide( e lements, s how ) { | |
| 6456 | va r display, elem, hid den, | |
| 6457 | valu es = [], | |
| 6458 | inde x = 0, | |
| 6459 | leng th = eleme nts.length ; | |
| 6460 | ||
| 6461 | fo r ( ; inde x < length ; index++ ) { | |
| 6462 | elem = element s[ index ] ; | |
| 6463 | if ( !elem.sty le ) { | |
| 6464 | contin ue; | |
| 6465 | } | |
| 6466 | ||
| 6467 | valu es[ index ] = jQuery ._data( el em, "olddi splay" ); | |
| 6468 | disp lay = elem .style.dis play; | |
| 6469 | if ( show ) { | |
| 6470 | // Res et the inl ine displa y of this element to learn if it is | |
| 6471 | // bei ng hidden by cascade d rules or not | |
| 6472 | if ( ! values[ in dex ] && d isplay === "none" ) { | |
| 6473 | elem.sty le.display = ""; | |
| 6474 | } | |
| 6475 | ||
| 6476 | // Set elements which have been over ridden wit h display: none | |
| 6477 | // in a styleshe et to what ever the d efault bro wser style is | |
| 6478 | // for such an e lement | |
| 6479 | if ( e lem.style. display == = "" && is Hidden( el em ) ) { | |
| 6480 | values[ index ] = jQuery._da ta( elem, "olddispla y", defaul tDisplay(e lem.nodeNa me) ); | |
| 6481 | } | |
| 6482 | } el se { | |
| 6483 | hidden = isHidde n( elem ); | |
| 6484 | ||
| 6485 | if ( d isplay && display != = "none" | | !hidden ) { | |
| 6486 | jQuery._ data( elem , "olddisp lay", hidd en ? displ ay : jQuer y.css( ele m, "displa y" ) ); | |
| 6487 | } | |
| 6488 | } | |
| 6489 | } | |
| 6490 | ||
| 6491 | // Set the d isplay of most of th e elements in a seco nd loop | |
| 6492 | // to avoid the consta nt reflow | |
| 6493 | fo r ( index = 0; index < length; index++ ) { | |
| 6494 | elem = element s[ index ] ; | |
| 6495 | if ( !elem.sty le ) { | |
| 6496 | contin ue; | |
| 6497 | } | |
| 6498 | if ( !show || elem.style .display = == "none" || elem.st yle.displa y === "" ) { | |
| 6499 | elem.s tyle.displ ay = show ? values[ index ] || "" : "non e"; | |
| 6500 | } | |
| 6501 | } | |
| 6502 | ||
| 6503 | re turn eleme nts; | |
| 6504 | } | |
| 6505 | ||
| 6506 | function s etPositive Number( el em, value, subtract ) { | |
| 6507 | va r matches = rnumspli t.exec( va lue ); | |
| 6508 | re turn match es ? | |
| 6509 | // G uard again st undefin ed "subtra ct", e.g., when used as in css Hooks | |
| 6510 | Math .max( 0, m atches[ 1 ] - ( subt ract || 0 ) ) + ( ma tches[ 2 ] || "px" ) : | |
| 6511 | valu e; | |
| 6512 | } | |
| 6513 | ||
| 6514 | function a ugmentWidt hOrHeight( elem, nam e, extra, isBorderBo x, styles ) { | |
| 6515 | va r i = extr a === ( is BorderBox ? "border" : "conten t" ) ? | |
| 6516 | // I f we alrea dy have th e right me asurement, avoid aug mentation | |
| 6517 | 4 : | |
| 6518 | // O therwise i nitialize for horizo ntal or ve rtical pro perties | |
| 6519 | name === "widt h" ? 1 : 0 , | |
| 6520 | ||
| 6521 | val = 0; | |
| 6522 | ||
| 6523 | fo r ( ; i < 4; i += 2 ) { | |
| 6524 | // b oth box mo dels exclu de margin, so add it if we wan t it | |
| 6525 | if ( extra === "margin" ) { | |
| 6526 | val += jQuery.cs s( elem, e xtra + css Expand[ i ], true, s tyles ); | |
| 6527 | } | |
| 6528 | ||
| 6529 | if ( isBorderB ox ) { | |
| 6530 | // bor der-box in cludes pad ding, so r emove it i f we want content | |
| 6531 | if ( e xtra === " content" ) { | |
| 6532 | val -= j Query.css( elem, "pa dding" + c ssExpand[ i ], true, styles ); | |
| 6533 | } | |
| 6534 | ||
| 6535 | // at this point , extra is n't border nor margi n, so remo ve border | |
| 6536 | if ( e xtra !== " margin" ) { | |
| 6537 | val -= j Query.css( elem, "bo rder" + cs sExpand[ i ] + "Widt h", true, styles ); | |
| 6538 | } | |
| 6539 | } el se { | |
| 6540 | // at this point , extra is n't conten t, so add padding | |
| 6541 | val += jQuery.cs s( elem, " padding" + cssExpand [ i ], tru e, styles ); | |
| 6542 | ||
| 6543 | // at this point , extra is n't conten t nor padd ing, so ad d border | |
| 6544 | if ( e xtra !== " padding" ) { | |
| 6545 | val += j Query.css( elem, "bo rder" + cs sExpand[ i ] + "Widt h", true, styles ); | |
| 6546 | } | |
| 6547 | } | |
| 6548 | } | |
| 6549 | ||
| 6550 | re turn val; | |
| 6551 | } | |
| 6552 | ||
| 6553 | function g etWidthOrH eight( ele m, name, e xtra ) { | |
| 6554 | ||
| 6555 | // Start wit h offset p roperty, w hich is eq uivalent t o the bord er-box val ue | |
| 6556 | va r valueIsB orderBox = true, | |
| 6557 | val = name === "width" ? elem.offs etWidth : elem.offse tHeight, | |
| 6558 | styl es = getSt yles( elem ), | |
| 6559 | isBo rderBox = support.bo xSizing && jQuery.cs s( elem, " boxSizing" , false, s tyles ) == = "border- box"; | |
| 6560 | ||
| 6561 | // some non- html eleme nts return undefined for offse tWidth, so check for null/unde fined | |
| 6562 | // svg - htt ps://bugzi lla.mozill a.org/show _bug.cgi?i d=649285 | |
| 6563 | // MathML - https://bu gzilla.moz illa.org/s how_bug.cg i?id=49166 8 | |
| 6564 | if ( val <= 0 || val = = null ) { | |
| 6565 | // F all back t o computed then unco mputed css if necess ary | |
| 6566 | val = curCSS( elem, name , styles ) ; | |
| 6567 | if ( val < 0 | | val == n ull ) { | |
| 6568 | val = elem.style [ name ]; | |
| 6569 | } | |
| 6570 | ||
| 6571 | // C omputed un it is not pixels. St op here an d return. | |
| 6572 | if ( rnumnonpx .test(val) ) { | |
| 6573 | return val; | |
| 6574 | } | |
| 6575 | ||
| 6576 | // w e need the check for style in case a bro wser which returns u nreliable values | |
| 6577 | // f or getComp utedStyle silently f alls back to the rel iable elem .style | |
| 6578 | valu eIsBorderB ox = isBor derBox && ( support. boxSizingR eliable() || val === elem.styl e[ name ] ); | |
| 6579 | ||
| 6580 | // N ormalize " ", auto, a nd prepare for extra | |
| 6581 | val = parseFlo at( val ) || 0; | |
| 6582 | } | |
| 6583 | ||
| 6584 | // use the a ctive box- sizing mod el to add/ subtract i rrelevant styles | |
| 6585 | re turn ( val + | |
| 6586 | augm entWidthOr Height( | |
| 6587 | elem, | |
| 6588 | name, | |
| 6589 | extra || ( isBor derBox ? " border" : "content" ), | |
| 6590 | valueI sBorderBox , | |
| 6591 | styles | |
| 6592 | ) | |
| 6593 | ) + "px"; | |
| 6594 | } | |
| 6595 | ||
| 6596 | jQuery.ext end({ | |
| 6597 | // Add in st yle proper ty hooks f or overrid ing the de fault | |
| 6598 | // behavior of getting and setti ng a style property | |
| 6599 | cs sHooks: { | |
| 6600 | opac ity: { | |
| 6601 | get: f unction( e lem, compu ted ) { | |
| 6602 | if ( com puted ) { | |
| 6603 | // We shou ld always get a numb er back fr om opacity | |
| 6604 | var ret = curCSS( el em, "opaci ty" ); | |
| 6605 | return ret === "" ? "1" : ret; | |
| 6606 | } | |
| 6607 | } | |
| 6608 | } | |
| 6609 | }, | |
| 6610 | ||
| 6611 | // Don't aut omatically add "px" to these p ossibly-un itless pro perties | |
| 6612 | cs sNumber: { | |
| 6613 | "col umnCount": true, | |
| 6614 | "fil lOpacity": true, | |
| 6615 | "fle xGrow": tr ue, | |
| 6616 | "fle xShrink": true, | |
| 6617 | "fon tWeight": true, | |
| 6618 | "lin eHeight": true, | |
| 6619 | "opa city": tru e, | |
| 6620 | "ord er": true, | |
| 6621 | "orp hans": tru e, | |
| 6622 | "wid ows": true , | |
| 6623 | "zIn dex": true , | |
| 6624 | "zoo m": true | |
| 6625 | }, | |
| 6626 | ||
| 6627 | // Add in pr operties w hose names you wish to fix bef ore | |
| 6628 | // setting o r getting the value | |
| 6629 | cs sProps: { | |
| 6630 | // n ormalize f loat css p roperty | |
| 6631 | "flo at": suppo rt.cssFloa t ? "cssFl oat" : "st yleFloat" | |
| 6632 | }, | |
| 6633 | ||
| 6634 | // Get and s et the sty le propert y on a DOM Node | |
| 6635 | st yle: funct ion( elem, name, val ue, extra ) { | |
| 6636 | // D on't set s tyles on t ext and co mment node s | |
| 6637 | if ( !elem || elem.nodeT ype === 3 || elem.no deType === 8 || !ele m.style ) { | |
| 6638 | return ; | |
| 6639 | } | |
| 6640 | ||
| 6641 | // M ake sure t hat we're working wi th the rig ht name | |
| 6642 | var ret, type, hooks, | |
| 6643 | origNa me = jQuer y.camelCas e( name ), | |
| 6644 | style = elem.sty le; | |
| 6645 | ||
| 6646 | name = jQuery. cssProps[ origName ] || ( jQue ry.cssProp s[ origNam e ] = vend orPropName ( style, o rigName ) ); | |
| 6647 | ||
| 6648 | // g ets hook f or the pre fixed vers ion | |
| 6649 | // f ollowed by the unpre fixed vers ion | |
| 6650 | hook s = jQuery .cssHooks[ name ] || jQuery.cs sHooks[ or igName ]; | |
| 6651 | ||
| 6652 | // C heck if we 're settin g a value | |
| 6653 | if ( value !== undefined ) { | |
| 6654 | type = typeof va lue; | |
| 6655 | ||
| 6656 | // con vert relat ive number strings ( += or -=) to relativ e numbers. #7345 | |
| 6657 | if ( t ype === "s tring" && (ret = rre lNum.exec( value )) ) { | |
| 6658 | value = ( ret[1] + 1 ) * ret [2] + pars eFloat( jQ uery.css( elem, name ) ); | |
| 6659 | // Fixes bug #9237 | |
| 6660 | type = " number"; | |
| 6661 | } | |
| 6662 | ||
| 6663 | // Mak e sure tha t null and NaN value s aren't s et. See: # 7116 | |
| 6664 | if ( v alue == nu ll || valu e !== valu e ) { | |
| 6665 | return; | |
| 6666 | } | |
| 6667 | ||
| 6668 | // If a number w as passed in, add 'p x' to the (except fo r certain CSS proper ties) | |
| 6669 | if ( t ype === "n umber" && !jQuery.cs sNumber[ o rigName ] ) { | |
| 6670 | value += "px"; | |
| 6671 | } | |
| 6672 | ||
| 6673 | // Fix es #8908, it can be done more correctly by specifi ng setters in cssHoo ks, | |
| 6674 | // but it would mean to de fine eight (for ever y problema tic proper ty) identi cal functi ons | |
| 6675 | if ( ! support.cl earCloneSt yle && val ue === "" && name.in dexOf("bac kground") === 0 ) { | |
| 6676 | style[ n ame ] = "i nherit"; | |
| 6677 | } | |
| 6678 | ||
| 6679 | // If a hook was provided, use that value, oth erwise jus t set the specified value | |
| 6680 | if ( ! hooks || ! ("set" in hooks) || (value = h ooks.set( elem, valu e, extra ) ) !== unde fined ) { | |
| 6681 | ||
| 6682 | // Suppo rt: IE | |
| 6683 | // Swall ow errors from 'inva lid' CSS v alues (#55 09) | |
| 6684 | try { | |
| 6685 | style[ nam e ] = valu e; | |
| 6686 | } catch( e) {} | |
| 6687 | } | |
| 6688 | ||
| 6689 | } el se { | |
| 6690 | // If a hook was provided get the no n-computed value fro m there | |
| 6691 | if ( h ooks && "g et" in hoo ks && (ret = hooks.g et( elem, false, ext ra )) !== undefined ) { | |
| 6692 | return r et; | |
| 6693 | } | |
| 6694 | ||
| 6695 | // Oth erwise jus t get the value from the style object | |
| 6696 | return style[ na me ]; | |
| 6697 | } | |
| 6698 | }, | |
| 6699 | ||
| 6700 | cs s: functio n( elem, n ame, extra , styles ) { | |
| 6701 | var num, val, hooks, | |
| 6702 | origNa me = jQuer y.camelCas e( name ); | |
| 6703 | ||
| 6704 | // M ake sure t hat we're working wi th the rig ht name | |
| 6705 | name = jQuery. cssProps[ origName ] || ( jQue ry.cssProp s[ origNam e ] = vend orPropName ( elem.sty le, origNa me ) ); | |
| 6706 | ||
| 6707 | // g ets hook f or the pre fixed vers ion | |
| 6708 | // f ollowed by the unpre fixed vers ion | |
| 6709 | hook s = jQuery .cssHooks[ name ] || jQuery.cs sHooks[ or igName ]; | |
| 6710 | ||
| 6711 | // I f a hook w as provide d get the computed v alue from there | |
| 6712 | if ( hooks && "get" in h ooks ) { | |
| 6713 | val = hooks.get( elem, tru e, extra ) ; | |
| 6714 | } | |
| 6715 | ||
| 6716 | // O therwise, if a way t o get the computed v alue exist s, use tha t | |
| 6717 | if ( val === u ndefined ) { | |
| 6718 | val = curCSS( el em, name, styles ); | |
| 6719 | } | |
| 6720 | ||
| 6721 | //co nvert "nor mal" to co mputed val ue | |
| 6722 | if ( val = == "normal " && name in cssN DNS ransform ) { | |
| 6723 | val = cssN DNS ransform[ name ]; | |
| 6724 | } | |
| 6725 | ||
| 6726 | // R eturn, con verting to number if forced or a qualifi er was pro vided and val looks numeric | |
| 6727 | if ( extra === "" || ext ra ) { | |
| 6728 | num = parseFloat ( val ); | |
| 6729 | return extra === true || j Query.isNu meric( num ) ? num | | 0 : val; | |
| 6730 | } | |
| 6731 | retu rn val; | |
| 6732 | } | |
| 6733 | }); | |
| 6734 | ||
| 6735 | jQuery.eac h([ "heigh t", "width " ], funct ion( i, na me ) { | |
| 6736 | jQ uery.cssHo oks[ name ] = { | |
| 6737 | get: function( elem, com puted, ext ra ) { | |
| 6738 | if ( c omputed ) { | |
| 6739 | // certa in element s can have dimension info if w e invisibl y show the m | |
| 6740 | // howev er, it mus t have a c urrent dis play style that woul d benefit from this | |
| 6741 | return r displayswa p.test( jQ uery.css( elem, "dis play" ) ) && elem.of fsetWidth === 0 ? | |
| 6742 | jQuery.swa p( elem, c ssShow, fu nction() { | |
| 6743 | re turn getWi dthOrHeigh t( elem, n ame, extra ); | |
| 6744 | }) : | |
| 6745 | getWidthOr Height( el em, name, extra ); | |
| 6746 | } | |
| 6747 | }, | |
| 6748 | ||
| 6749 | set: function( elem, val ue, extra ) { | |
| 6750 | var st yles = ext ra && getS tyles( ele m ); | |
| 6751 | return setPositi veNumber( elem, valu e, extra ? | |
| 6752 | augmentW idthOrHeig ht( | |
| 6753 | elem, | |
| 6754 | name, | |
| 6755 | extra, | |
| 6756 | support.bo xSizing && jQuery.cs s( elem, " boxSizing" , false, s tyles ) == = "border- box", | |
| 6757 | styles | |
| 6758 | ) : 0 | |
| 6759 | ); | |
| 6760 | } | |
| 6761 | }; | |
| 6762 | }); | |
| 6763 | ||
| 6764 | if ( !supp ort.opacit y ) { | |
| 6765 | jQ uery.cssHo oks.opacit y = { | |
| 6766 | get: function( elem, com puted ) { | |
| 6767 | // IE uses filte rs for opa city | |
| 6768 | return ropacity. test( (com puted && e lem.curren tStyle ? e lem.curren tStyle.fil ter : elem .style.fil ter) || "" ) ? | |
| 6769 | ( 0.01 * parseFloa t( RegExp. $1 ) ) + " " : | |
| 6770 | computed ? "1" : " "; | |
| 6771 | }, | |
| 6772 | ||
| 6773 | set: function( elem, val ue ) { | |
| 6774 | var st yle = elem .style, | |
| 6775 | currentS tyle = ele m.currentS tyle, | |
| 6776 | opacity = jQuery.i sNumeric( value ) ? "alpha(opa city=" + v alue * 100 + ")" : " ", | |
| 6777 | filter = currentSt yle && cur rentStyle. filter || style.filt er || ""; | |
| 6778 | ||
| 6779 | // IE has troubl e with opa city if it does not have layou t | |
| 6780 | // For ce it by s etting the zoom leve l | |
| 6781 | style. zoom = 1; | |
| 6782 | ||
| 6783 | // if setting op acity to 1 , and no o ther filte rs exist - attempt t o remove f ilter attr ibute #665 2 | |
| 6784 | // if value === "", then r emove inli ne opacity #12685 | |
| 6785 | if ( ( value >= 1 || value === "" ) && | |
| 6786 | jQuery.tri m( filter. replace( r alpha, "" ) ) === "" && | |
| 6787 | style.remo veAttribut e ) { | |
| 6788 | ||
| 6789 | // Setti ng style.f ilter to n ull, "" & " " still leave "fil ter:" in t he cssText | |
| 6790 | // if "f ilter:" is present a t all, cle arType is disabled, we want to avoid thi s | |
| 6791 | // style .removeAtt ribute is IE Only, b ut so appa rently is this code path... | |
| 6792 | style.re moveAttrib ute( "filt er" ); | |
| 6793 | ||
| 6794 | // if th ere is no filter sty le applied in a css rule or un set inline opacity, we are don e | |
| 6795 | if ( val ue === "" || current Style && ! currentSty le.filter ) { | |
| 6796 | return; | |
| 6797 | } | |
| 6798 | } | |
| 6799 | ||
| 6800 | // oth erwise, se t new filt er values | |
| 6801 | style. filter = r alpha.test ( filter ) ? | |
| 6802 | filter.r eplace( ra lpha, opac ity ) : | |
| 6803 | filter + " " + opa city; | |
| 6804 | } | |
| 6805 | }; | |
| 6806 | } | |
| 6807 | ||
| 6808 | jQuery.css Hooks.marg inRight = addGetHook If( suppor t.reliable MarginRigh t, | |
| 6809 | fu nction( el em, comput ed ) { | |
| 6810 | if ( computed ) { | |
| 6811 | // Web Kit Bug 13 343 - getC omputedSty le returns wrong val ue for mar gin-right | |
| 6812 | // Wor k around b y temporar ily settin g element display to inline-bl ock | |
| 6813 | return jQuery.sw ap( elem, { "display ": "inline -block" }, | |
| 6814 | curCSS, [ elem, "m arginRight " ] ); | |
| 6815 | } | |
| 6816 | } | |
| 6817 | ); | |
| 6818 | ||
| 6819 | // These h ooks are u sed by ani mate to ex pand prope rties | |
| 6820 | jQuery.eac h({ | |
| 6821 | ma rgin: "", | |
| 6822 | pa dding: "", | |
| 6823 | bo rder: "Wid th" | |
| 6824 | }, functio n( prefix, suffix ) { | |
| 6825 | jQ uery.cssHo oks[ prefi x + suffix ] = { | |
| 6826 | expa nd: functi on( value ) { | |
| 6827 | var i = 0, | |
| 6828 | expanded = {}, | |
| 6829 | ||
| 6830 | // assum es a singl e number i f not a st ring | |
| 6831 | parts = typeof val ue === "st ring" ? va lue.split( " ") : [ v alue ]; | |
| 6832 | ||
| 6833 | for ( ; i < 4; i ++ ) { | |
| 6834 | expanded [ prefix + cssExpand [ i ] + su ffix ] = | |
| 6835 | parts[ i ] || parts[ i - 2 ] | | parts[ 0 ]; | |
| 6836 | } | |
| 6837 | ||
| 6838 | return expanded; | |
| 6839 | } | |
| 6840 | }; | |
| 6841 | ||
| 6842 | if ( !rmargi n.test( pr efix ) ) { | |
| 6843 | jQue ry.cssHook s[ prefix + suffix ] .set = set PositiveNu mber; | |
| 6844 | } | |
| 6845 | }); | |
| 6846 | ||
| 6847 | jQuery.fn. extend({ | |
| 6848 | cs s: functio n( name, v alue ) { | |
| 6849 | retu rn access( this, fun ction( ele m, name, v alue ) { | |
| 6850 | var st yles, len, | |
| 6851 | map = {} , | |
| 6852 | i = 0; | |
| 6853 | ||
| 6854 | if ( j Query.isAr ray( name ) ) { | |
| 6855 | styles = getStyles ( elem ); | |
| 6856 | len = na me.length; | |
| 6857 | ||
| 6858 | for ( ; i < len; i ++ ) { | |
| 6859 | map[ name[ i ] ] = j Query.css( elem, nam e[ i ], fa lse, style s ); | |
| 6860 | } | |
| 6861 | ||
| 6862 | return m ap; | |
| 6863 | } | |
| 6864 | ||
| 6865 | return value !== undefined ? | |
| 6866 | jQuery.s tyle( elem , name, va lue ) : | |
| 6867 | jQuery.c ss( elem, name ); | |
| 6868 | }, n ame, value , argument s.length > 1 ); | |
| 6869 | }, | |
| 6870 | sh ow: functi on() { | |
| 6871 | retu rn showHid e( this, t rue ); | |
| 6872 | }, | |
| 6873 | hi de: functi on() { | |
| 6874 | retu rn showHid e( this ); | |
| 6875 | }, | |
| 6876 | to ggle: func tion( stat e ) { | |
| 6877 | if ( typeof st ate === "b oolean" ) { | |
| 6878 | return state ? t his.show() : this.hi de(); | |
| 6879 | } | |
| 6880 | ||
| 6881 | retu rn this.ea ch(functio n() { | |
| 6882 | if ( i sHidden( t his ) ) { | |
| 6883 | jQuery( this ).sho w(); | |
| 6884 | } else { | |
| 6885 | jQuery( this ).hid e(); | |
| 6886 | } | |
| 6887 | }); | |
| 6888 | } | |
| 6889 | }); | |
| 6890 | ||
| 6891 | ||
| 6892 | function T ween( elem , options, prop, end , easing ) { | |
| 6893 | re turn new T ween.proto type.init( elem, opt ions, prop , end, eas ing ); | |
| 6894 | } | |
| 6895 | jQuery.Twe en = Tween ; | |
| 6896 | ||
| 6897 | Tween.prot otype = { | |
| 6898 | co nstructor: Tween, | |
| 6899 | in it: functi on( elem, options, p rop, end, easing, un it ) { | |
| 6900 | this .elem = el em; | |
| 6901 | this .prop = pr op; | |
| 6902 | this .easing = easing || "swing"; | |
| 6903 | this .options = options; | |
| 6904 | this .start = t his.now = this.cur() ; | |
| 6905 | this .end = end ; | |
| 6906 | this .unit = un it || ( jQ uery.cssNu mber[ prop ] ? "" : "px" ); | |
| 6907 | }, | |
| 6908 | cu r: functio n() { | |
| 6909 | var hooks = Tw een.propHo oks[ this. prop ]; | |
| 6910 | ||
| 6911 | retu rn hooks & & hooks.ge t ? | |
| 6912 | hooks. get( this ) : | |
| 6913 | Tween. propHooks. _default.g et( this ) ; | |
| 6914 | }, | |
| 6915 | ru n: functio n( percent ) { | |
| 6916 | var eased, | |
| 6917 | hooks = Tween.pr opHooks[ t his.prop ] ; | |
| 6918 | ||
| 6919 | if ( this.opti ons.durati on ) { | |
| 6920 | this.p os = eased = jQuery. easing[ th is.easing ]( | |
| 6921 | percent, this.opti ons.durati on * perce nt, 0, 1, this.optio ns.duratio n | |
| 6922 | ); | |
| 6923 | } el se { | |
| 6924 | this.p os = eased = percent ; | |
| 6925 | } | |
| 6926 | this .now = ( t his.end - this.start ) * eased + this.st art; | |
| 6927 | ||
| 6928 | if ( this.opti ons.step ) { | |
| 6929 | this.o ptions.ste p.call( th is.elem, t his.now, t his ); | |
| 6930 | } | |
| 6931 | ||
| 6932 | if ( hooks && hooks.set ) { | |
| 6933 | hooks. set( this ); | |
| 6934 | } el se { | |
| 6935 | Tween. propHooks. _default.s et( this ) ; | |
| 6936 | } | |
| 6937 | retu rn this; | |
| 6938 | } | |
| 6939 | }; | |
| 6940 | ||
| 6941 | Tween.prot otype.init .prototype = Tween.p rototype; | |
| 6942 | ||
| 6943 | Tween.prop Hooks = { | |
| 6944 | _d efault: { | |
| 6945 | get: function( tween ) { | |
| 6946 | var re sult; | |
| 6947 | ||
| 6948 | if ( t ween.elem[ tween.pro p ] != nul l && | |
| 6949 | (!tween. elem.style || tween. elem.style [ tween.pr op ] == nu ll) ) { | |
| 6950 | return t ween.elem[ tween.pro p ]; | |
| 6951 | } | |
| 6952 | ||
| 6953 | // pas sing an em pty string as a 3rd parameter to .css wi ll automat ically | |
| 6954 | // att empt a par seFloat an d fallback to a stri ng if the parse fail s | |
| 6955 | // so, simple va lues such as "10px" are parsed to Float. | |
| 6956 | // com plex value s such as "rotate(1r ad)" are r eturned as is. | |
| 6957 | result = jQuery. css( tween .elem, twe en.prop, " " ); | |
| 6958 | // Emp ty strings , null, un defined an d "auto" a re convert ed to 0. | |
| 6959 | return !result | | result = == "auto" ? 0 : resu lt; | |
| 6960 | }, | |
| 6961 | set: function( tween ) { | |
| 6962 | // use step hook for back compat - u se cssHook if its th ere - use .style if its | |
| 6963 | // ava ilable and use plain propertie s where av ailable | |
| 6964 | if ( j Query.fx.s tep[ tween .prop ] ) { | |
| 6965 | jQuery.f x.step[ tw een.prop ] ( tween ); | |
| 6966 | } else if ( twee n.elem.sty le && ( tw een.elem.s tyle[ jQue ry.cssProp s[ tween.p rop ] ] != null || j Query.cssH ooks[ twee n.prop ] ) ) { | |
| 6967 | jQuery.s tyle( twee n.elem, tw een.prop, tween.now + tween.un it ); | |
| 6968 | } else { | |
| 6969 | tween.el em[ tween. prop ] = t ween.now; | |
| 6970 | } | |
| 6971 | } | |
| 6972 | } | |
| 6973 | }; | |
| 6974 | ||
| 6975 | // Support : IE <=9 | |
| 6976 | // Panic b ased appro ach to set ting thing s on disco nnected no des | |
| 6977 | ||
| 6978 | Tween.prop Hooks.scro llTop = Tw een.propHo oks.scroll Left = { | |
| 6979 | se t: functio n( tween ) { | |
| 6980 | if ( tween.ele m.nodeType && tween. elem.paren tNode ) { | |
| 6981 | tween. elem[ twee n.prop ] = tween.now ; | |
| 6982 | } | |
| 6983 | } | |
| 6984 | }; | |
| 6985 | ||
| 6986 | jQuery.eas ing = { | |
| 6987 | li near: func tion( p ) { | |
| 6988 | retu rn p; | |
| 6989 | }, | |
| 6990 | sw ing: funct ion( p ) { | |
| 6991 | retu rn 0.5 - M ath.cos( p * Math.PI ) / 2; | |
| 6992 | } | |
| 6993 | }; | |
| 6994 | ||
| 6995 | jQuery.fx = Tween.pr ototype.in it; | |
| 6996 | ||
| 6997 | // Back Co mpat <1.8 extension point | |
| 6998 | jQuery.fx. step = {}; | |
| 6999 | ||
| 7000 | ||
| 7001 | ||
| 7002 | ||
| 7003 | var | |
| 7004 | fx Now, timer Id, | |
| 7005 | rf xtypes = / ^(?:toggle |show|hide )$/, | |
| 7006 | rf xnum = new RegExp( " ^(?:([+-]) =|)(" + pn um + ")([a -z%]*)$", "i" ), | |
| 7007 | rr un = /queu eHooks$/, | |
| 7008 | an imationPre filters = [ defaultP refilter ] , | |
| 7009 | tw eeners = { | |
| 7010 | "*": [ functio n( prop, v alue ) { | |
| 7011 | var tw een = this .createTwe en( prop, value ), | |
| 7012 | target = tween.cur (), | |
| 7013 | parts = rfxnum.exe c( value ) , | |
| 7014 | unit = p arts && pa rts[ 3 ] | | ( jQuery .cssNumber [ prop ] ? "" : "px" ), | |
| 7015 | ||
| 7016 | // Start ing value computatio n is requi red for po tential un it mismatc hes | |
| 7017 | start = ( jQuery.c ssNumber[ prop ] || unit !== " px" && +ta rget ) && | |
| 7018 | rfxnum.exe c( jQuery. css( tween .elem, pro p ) ), | |
| 7019 | scale = 1, | |
| 7020 | maxItera tions = 20 ; | |
| 7021 | ||
| 7022 | if ( s tart && st art[ 3 ] ! == unit ) { | |
| 7023 | // Trust units rep orted by j Query.css | |
| 7024 | unit = u nit || sta rt[ 3 ]; | |
| 7025 | ||
| 7026 | // Make sure we up date the t ween prope rties late r on | |
| 7027 | parts = parts || [ ]; | |
| 7028 | ||
| 7029 | // Itera tively app roximate f rom a nonz ero starti ng point | |
| 7030 | start = +target || 1; | |
| 7031 | ||
| 7032 | do { | |
| 7033 | // If prev ious itera tion zeroe d out, dou ble until we get *so mething* | |
| 7034 | // Use a s tring for doubling f actor so w e don't ac cidentally see scale as unchan ged below | |
| 7035 | scale = sc ale || ".5 "; | |
| 7036 | ||
| 7037 | // Adjust and apply | |
| 7038 | start = st art / scal e; | |
| 7039 | jQuery.sty le( tween. elem, prop , start + unit ); | |
| 7040 | ||
| 7041 | // Updat e scale, t olerating zero or Na N from twe en.cur() | |
| 7042 | // And b reaking th e loop if scale is u nchanged o r perfect, or if we' ve just ha d enough | |
| 7043 | } while ( scale != = (scale = tween.cur () / targe t) && scal e !== 1 && --maxIter ations ); | |
| 7044 | } | |
| 7045 | ||
| 7046 | // Upd ate tween properties | |
| 7047 | if ( p arts ) { | |
| 7048 | start = tween.star t = +start || +targe t || 0; | |
| 7049 | tween.un it = unit; | |
| 7050 | // If a +=/-= toke n was prov ided, we'r e doing a relative a nimation | |
| 7051 | tween.en d = parts[ 1 ] ? | |
| 7052 | start + ( parts[ 1 ] + 1 ) * p arts[ 2 ] : | |
| 7053 | +parts[ 2 ]; | |
| 7054 | } | |
| 7055 | ||
| 7056 | return tween; | |
| 7057 | } ] | |
| 7058 | }; | |
| 7059 | ||
| 7060 | // Animati ons create d synchron ously will run synch ronously | |
| 7061 | function c reateFxNow () { | |
| 7062 | se tTimeout(f unction() { | |
| 7063 | fxNo w = undefi ned; | |
| 7064 | }) ; | |
| 7065 | re turn ( fxN ow = jQuer y.now() ); | |
| 7066 | } | |
| 7067 | ||
| 7068 | // Generat e paramete rs to crea te a stand ard animat ion | |
| 7069 | function g enFx( type , includeW idth ) { | |
| 7070 | va r which, | |
| 7071 | attr s = { heig ht: type } , | |
| 7072 | i = 0; | |
| 7073 | ||
| 7074 | // if we inc lude width , step val ue is 1 to do all cs sExpand va lues, | |
| 7075 | // if we don 't include width, st ep value i s 2 to ski p over Lef t and Righ t | |
| 7076 | in cludeWidth = include Width ? 1 : 0; | |
| 7077 | fo r ( ; i < 4 ; i += 2 - include Width ) { | |
| 7078 | whic h = cssExp and[ i ]; | |
| 7079 | attr s[ "margin " + which ] = attrs[ "padding" + which ] = type; | |
| 7080 | } | |
| 7081 | ||
| 7082 | if ( include Width ) { | |
| 7083 | attr s.opacity = attrs.wi dth = type ; | |
| 7084 | } | |
| 7085 | ||
| 7086 | re turn attrs ; | |
| 7087 | } | |
| 7088 | ||
| 7089 | function c reateTween ( value, p rop, anima tion ) { | |
| 7090 | va r tween, | |
| 7091 | coll ection = ( tweeners[ prop ] || [] ).conc at( tweene rs[ "*" ] ), | |
| 7092 | inde x = 0, | |
| 7093 | leng th = colle ction.leng th; | |
| 7094 | fo r ( ; inde x < length ; index++ ) { | |
| 7095 | if ( (tween = collection [ index ]. call( anim ation, pro p, value ) ) ) { | |
| 7096 | ||
| 7097 | // we' re done wi th this pr operty | |
| 7098 | return tween; | |
| 7099 | } | |
| 7100 | } | |
| 7101 | } | |
| 7102 | ||
| 7103 | function d efaultPref ilter( ele m, props, opts ) { | |
| 7104 | /* jshint va lidthis: t rue */ | |
| 7105 | va r prop, va lue, toggl e, tween, hooks, old fire, disp lay, check Display, | |
| 7106 | anim = this, | |
| 7107 | orig = {}, | |
| 7108 | styl e = elem.s tyle, | |
| 7109 | hidd en = elem. nodeType & & isHidden ( elem ), | |
| 7110 | data Show = jQu ery._data( elem, "fx show" ); | |
| 7111 | ||
| 7112 | // handle qu eue: false promises | |
| 7113 | if ( !opts.q ueue ) { | |
| 7114 | hook s = jQuery ._queueHoo ks( elem, "fx" ); | |
| 7115 | if ( hooks.unq ueued == n ull ) { | |
| 7116 | hooks. unqueued = 0; | |
| 7117 | oldfir e = hooks. empty.fire ; | |
| 7118 | hooks. empty.fire = functio n() { | |
| 7119 | if ( !ho oks.unqueu ed ) { | |
| 7120 | oldfire(); | |
| 7121 | } | |
| 7122 | }; | |
| 7123 | } | |
| 7124 | hook s.unqueued ++; | |
| 7125 | ||
| 7126 | anim .always(fu nction() { | |
| 7127 | // doi ng this ma kes sure t hat the co mplete han dler will be called | |
| 7128 | // bef ore this c ompletes | |
| 7129 | anim.a lways(func tion() { | |
| 7130 | hooks.un queued--; | |
| 7131 | if ( !jQ uery.queue ( elem, "f x" ).lengt h ) { | |
| 7132 | hooks.empt y.fire(); | |
| 7133 | } | |
| 7134 | }); | |
| 7135 | }); | |
| 7136 | } | |
| 7137 | ||
| 7138 | // height/wi dth overfl ow pass | |
| 7139 | if ( elem.no deType === 1 && ( "h eight" in props || " width" in props ) ) { | |
| 7140 | // M ake sure t hat nothin g sneaks o ut | |
| 7141 | // R ecord all 3 overflow attribute s because IE does no t | |
| 7142 | // c hange the overflow a ttribute w hen overfl owX and | |
| 7143 | // o verflowY a re set to the same v alue | |
| 7144 | opts .overflow = [ style. overflow, style.over flowX, sty le.overflo wY ]; | |
| 7145 | ||
| 7146 | // S et display property to inline- block for height/wid th | |
| 7147 | // a nimations on inline elements t hat are ha ving width /height an imated | |
| 7148 | disp lay = jQue ry.css( el em, "displ ay" ); | |
| 7149 | ||
| 7150 | // T est defaul t display if display is curren tly "none" | |
| 7151 | chec kDisplay = display = == "none" ? | |
| 7152 | jQuery ._data( el em, "olddi splay" ) | | defaultD isplay( el em.nodeNam e ) : disp lay; | |
| 7153 | ||
| 7154 | if ( checkDisp lay === "i nline" && jQuery.css ( elem, "f loat" ) == = "none" ) { | |
| 7155 | ||
| 7156 | // inl ine-level elements a ccept inli ne-block; | |
| 7157 | // blo ck-level e lements ne ed to be i nline with layout | |
| 7158 | if ( ! support.in lineBlockN eedsLayout || defaul tDisplay( elem.nodeN ame ) === "inline" ) { | |
| 7159 | style.di splay = "i nline-bloc k"; | |
| 7160 | } else { | |
| 7161 | style.zo om = 1; | |
| 7162 | } | |
| 7163 | } | |
| 7164 | } | |
| 7165 | ||
| 7166 | if ( opts.ov erflow ) { | |
| 7167 | styl e.overflow = "hidden "; | |
| 7168 | if ( !support. shrinkWrap Blocks() ) { | |
| 7169 | anim.a lways(func tion() { | |
| 7170 | style.ov erflow = o pts.overfl ow[ 0 ]; | |
| 7171 | style.ov erflowX = opts.overf low[ 1 ]; | |
| 7172 | style.ov erflowY = opts.overf low[ 2 ]; | |
| 7173 | }); | |
| 7174 | } | |
| 7175 | } | |
| 7176 | ||
| 7177 | // show/hide pass | |
| 7178 | fo r ( prop i n props ) { | |
| 7179 | valu e = props[ prop ]; | |
| 7180 | if ( rfxtypes. exec( valu e ) ) { | |
| 7181 | delete props[ pr op ]; | |
| 7182 | toggle = toggle || value = == "toggle "; | |
| 7183 | if ( v alue === ( hidden ? "hide" : " show" ) ) { | |
| 7184 | ||
| 7185 | // If th ere is dat aShow left over from a stopped hide or s how and we are going to procee d with sho w, we shou ld pretend to be hid den | |
| 7186 | if ( val ue === "sh ow" && dat aShow && d ataShow[ p rop ] !== undefined ) { | |
| 7187 | hidden = t rue; | |
| 7188 | } else { | |
| 7189 | continue; | |
| 7190 | } | |
| 7191 | } | |
| 7192 | orig[ prop ] = d ataShow && dataShow[ prop ] || jQuery.st yle( elem, prop ); | |
| 7193 | ||
| 7194 | // A ny non-fx value stop s us from restoring the origin al display value | |
| 7195 | } el se { | |
| 7196 | displa y = undefi ned; | |
| 7197 | } | |
| 7198 | } | |
| 7199 | ||
| 7200 | if ( !jQuery .isEmptyOb ject( orig ) ) { | |
| 7201 | if ( dataShow ) { | |
| 7202 | if ( " hidden" in dataShow ) { | |
| 7203 | hidden = dataShow. hidden; | |
| 7204 | } | |
| 7205 | } el se { | |
| 7206 | dataSh ow = jQuer y._data( e lem, "fxsh ow", {} ); | |
| 7207 | } | |
| 7208 | ||
| 7209 | // s tore state if its to ggle - ena bles .stop ().toggle( ) to "reve rse" | |
| 7210 | if ( toggle ) { | |
| 7211 | dataSh ow.hidden = !hidden; | |
| 7212 | } | |
| 7213 | if ( hidden ) { | |
| 7214 | jQuery ( elem ).s how(); | |
| 7215 | } el se { | |
| 7216 | anim.d one(functi on() { | |
| 7217 | jQuery( elem ).hid e(); | |
| 7218 | }); | |
| 7219 | } | |
| 7220 | anim .done(func tion() { | |
| 7221 | var pr op; | |
| 7222 | jQuery ._removeDa ta( elem, "fxshow" ) ; | |
| 7223 | for ( prop in or ig ) { | |
| 7224 | jQuery.s tyle( elem , prop, or ig[ prop ] ); | |
| 7225 | } | |
| 7226 | }); | |
| 7227 | for ( prop in orig ) { | |
| 7228 | tween = createTw een( hidde n ? dataSh ow[ prop ] : 0, prop , anim ); | |
| 7229 | ||
| 7230 | if ( ! ( prop in dataShow ) ) { | |
| 7231 | dataShow [ prop ] = tween.sta rt; | |
| 7232 | if ( hid den ) { | |
| 7233 | tween.end = tween.st art; | |
| 7234 | tween.star t = prop = == "width" || prop = == "height " ? 1 : 0; | |
| 7235 | } | |
| 7236 | } | |
| 7237 | } | |
| 7238 | ||
| 7239 | // If this i s a noop l ike .hide( ).hide(), restore an overwritt en display value | |
| 7240 | } else if ( (display = == "none" ? defaultD isplay( el em.nodeNam e ) : disp lay) === " inline" ) { | |
| 7241 | styl e.display = display; | |
| 7242 | } | |
| 7243 | } | |
| 7244 | ||
| 7245 | function p ropFilter( props, sp ecialEasin g ) { | |
| 7246 | va r index, n ame, easin g, value, hooks; | |
| 7247 | ||
| 7248 | // camelCase , specialE asing and expand css Hook pass | |
| 7249 | fo r ( index in props ) { | |
| 7250 | name = jQuery. camelCase( index ); | |
| 7251 | easi ng = speci alEasing[ name ]; | |
| 7252 | valu e = props[ index ]; | |
| 7253 | if ( jQuery.is Array( val ue ) ) { | |
| 7254 | easing = value[ 1 ]; | |
| 7255 | value = props[ i ndex ] = v alue[ 0 ]; | |
| 7256 | } | |
| 7257 | ||
| 7258 | if ( index !== name ) { | |
| 7259 | props[ name ] = value; | |
| 7260 | delete props[ in dex ]; | |
| 7261 | } | |
| 7262 | ||
| 7263 | hook s = jQuery .cssHooks[ name ]; | |
| 7264 | if ( hooks && "expand" i n hooks ) { | |
| 7265 | value = hooks.ex pand( valu e ); | |
| 7266 | delete props[ na me ]; | |
| 7267 | ||
| 7268 | // not quite $.e xtend, thi s wont ove rwrite key s already present. | |
| 7269 | // als o - reusin g 'index' from above because w e have the correct " name" | |
| 7270 | for ( index in v alue ) { | |
| 7271 | if ( !( index in p rops ) ) { | |
| 7272 | props[ ind ex ] = val ue[ index ]; | |
| 7273 | specialEas ing[ index ] = easin g; | |
| 7274 | } | |
| 7275 | } | |
| 7276 | } el se { | |
| 7277 | specia lEasing[ n ame ] = ea sing; | |
| 7278 | } | |
| 7279 | } | |
| 7280 | } | |
| 7281 | ||
| 7282 | function A nimation( elem, prop erties, op tions ) { | |
| 7283 | va r result, | |
| 7284 | stop ped, | |
| 7285 | inde x = 0, | |
| 7286 | leng th = anima tionPrefil ters.lengt h, | |
| 7287 | defe rred = jQu ery.Deferr ed().alway s( functio n() { | |
| 7288 | // don 't match e lem in the :animated selector | |
| 7289 | delete tick.elem ; | |
| 7290 | }), | |
| 7291 | tick = functio n() { | |
| 7292 | if ( s topped ) { | |
| 7293 | return f alse; | |
| 7294 | } | |
| 7295 | var cu rrentTime = fxNow || createFxN ow(), | |
| 7296 | remainin g = Math.m ax( 0, ani mation.sta rtTime + a nimation.d uration - currentTim e ), | |
| 7297 | // archa ic crash b ug won't a llow us to use 1 - ( 0.5 || 0 ) (#12497) | |
| 7298 | temp = r emaining / animation .duration || 0, | |
| 7299 | percent = 1 - temp , | |
| 7300 | index = 0, | |
| 7301 | length = animation .tweens.le ngth; | |
| 7302 | ||
| 7303 | for ( ; index < length ; i ndex++ ) { | |
| 7304 | animatio n.tweens[ index ].ru n( percent ); | |
| 7305 | } | |
| 7306 | ||
| 7307 | deferr ed.notifyW ith( elem, [ animati on, percen t, remaini ng ]); | |
| 7308 | ||
| 7309 | if ( p ercent < 1 && length ) { | |
| 7310 | return r emaining; | |
| 7311 | } else { | |
| 7312 | deferred .resolveWi th( elem, [ animatio n ] ); | |
| 7313 | return f alse; | |
| 7314 | } | |
| 7315 | }, | |
| 7316 | anim ation = de ferred.pro mise({ | |
| 7317 | elem: elem, | |
| 7318 | props: jQuery.ex tend( {}, properties ), | |
| 7319 | opts: jQuery.ext end( true, { special Easing: {} }, option s ), | |
| 7320 | origin alProperti es: proper ties, | |
| 7321 | origin alOptions: options, | |
| 7322 | startT ime: fxNow || create FxNow(), | |
| 7323 | durati on: option s.duration , | |
| 7324 | tweens : [], | |
| 7325 | create Tween: fun ction( pro p, end ) { | |
| 7326 | var twee n = jQuery .Tween( el em, animat ion.opts, prop, end, | |
| 7327 | an imation.op ts.special Easing[ pr op ] || an imation.op ts.easing ); | |
| 7328 | animatio n.tweens.p ush( tween ); | |
| 7329 | return t ween; | |
| 7330 | }, | |
| 7331 | stop: function( gotoEnd ) { | |
| 7332 | var inde x = 0, | |
| 7333 | // if we a re going t o the end, we want t o run all the tweens | |
| 7334 | // otherwi se we skip this part | |
| 7335 | length = g otoEnd ? a nimation.t weens.leng th : 0; | |
| 7336 | if ( sto pped ) { | |
| 7337 | return thi s; | |
| 7338 | } | |
| 7339 | stopped = true; | |
| 7340 | for ( ; index < le ngth ; ind ex++ ) { | |
| 7341 | animation. tweens[ in dex ].run( 1 ); | |
| 7342 | } | |
| 7343 | ||
| 7344 | // resol ve when we played th e last fra me | |
| 7345 | // other wise, reje ct | |
| 7346 | if ( got oEnd ) { | |
| 7347 | deferred.r esolveWith ( elem, [ animation, gotoEnd ] ); | |
| 7348 | } else { | |
| 7349 | deferred.r ejectWith( elem, [ a nimation, gotoEnd ] ); | |
| 7350 | } | |
| 7351 | return t his; | |
| 7352 | } | |
| 7353 | }), | |
| 7354 | prop s = animat ion.props; | |
| 7355 | ||
| 7356 | pr opFilter( props, ani mation.opt s.specialE asing ); | |
| 7357 | ||
| 7358 | fo r ( ; inde x < length ; index++ ) { | |
| 7359 | resu lt = anima tionPrefil ters[ inde x ].call( animation, elem, pro ps, animat ion.opts ) ; | |
| 7360 | if ( result ) { | |
| 7361 | return result; | |
| 7362 | } | |
| 7363 | } | |
| 7364 | ||
| 7365 | jQ uery.map( props, cre ateTween, animation ); | |
| 7366 | ||
| 7367 | if ( jQuery. isFunction ( animatio n.opts.sta rt ) ) { | |
| 7368 | anim ation.opts .start.cal l( elem, a nimation ) ; | |
| 7369 | } | |
| 7370 | ||
| 7371 | jQ uery.fx.ti mer( | |
| 7372 | jQue ry.extend( tick, { | |
| 7373 | elem: elem, | |
| 7374 | anim: animation, | |
| 7375 | queue: animation .opts.queu e | |
| 7376 | }) | |
| 7377 | ); | |
| 7378 | ||
| 7379 | // attach ca llbacks fr om options | |
| 7380 | re turn anima tion.progr ess( anima tion.opts. progress ) | |
| 7381 | .don e( animati on.opts.do ne, animat ion.opts.c omplete ) | |
| 7382 | .fai l( animati on.opts.fa il ) | |
| 7383 | .alw ays( anima tion.opts. always ); | |
| 7384 | } | |
| 7385 | ||
| 7386 | jQuery.Ani mation = j Query.exte nd( Animat ion, { | |
| 7387 | tw eener: fun ction( pro ps, callba ck ) { | |
| 7388 | if ( jQuery.is Function( props ) ) { | |
| 7389 | callba ck = props ; | |
| 7390 | props = [ "*" ]; | |
| 7391 | } el se { | |
| 7392 | props = props.sp lit(" "); | |
| 7393 | } | |
| 7394 | ||
| 7395 | var prop, | |
| 7396 | index = 0, | |
| 7397 | length = props.l ength; | |
| 7398 | ||
| 7399 | for ( ; index < length ; index++ ) { | |
| 7400 | prop = props[ in dex ]; | |
| 7401 | tweene rs[ prop ] = tweener s[ prop ] || []; | |
| 7402 | tweene rs[ prop ] .unshift( callback ) ; | |
| 7403 | } | |
| 7404 | }, | |
| 7405 | ||
| 7406 | pr efilter: f unction( c allback, p repend ) { | |
| 7407 | if ( prepend ) { | |
| 7408 | animat ionPrefilt ers.unshif t( callbac k ); | |
| 7409 | } el se { | |
| 7410 | animat ionPrefilt ers.push( callback ) ; | |
| 7411 | } | |
| 7412 | } | |
| 7413 | }); | |
| 7414 | ||
| 7415 | jQuery.spe ed = funct ion( speed , easing, fn ) { | |
| 7416 | va r opt = sp eed && typ eof speed === "objec t" ? jQuer y.extend( {}, speed ) : { | |
| 7417 | comp lete: fn | | !fn && e asing || | |
| 7418 | jQuery .isFunctio n( speed ) && speed, | |
| 7419 | dura tion: spee d, | |
| 7420 | easi ng: fn && easing || easing && !jQuery.is Function( easing ) & & easing | |
| 7421 | }; | |
| 7422 | ||
| 7423 | op t.duration = jQuery. fx.off ? 0 : typeof opt.durati on === "nu mber" ? op t.duration : | |
| 7424 | opt. duration i n jQuery.f x.speeds ? jQuery.fx .speeds[ o pt.duratio n ] : jQue ry.fx.spee ds._defaul t; | |
| 7425 | ||
| 7426 | // normalize opt.queue - true/un defined/nu ll -> "fx" | |
| 7427 | if ( opt.que ue == null || opt.qu eue === tr ue ) { | |
| 7428 | opt. queue = "f x"; | |
| 7429 | } | |
| 7430 | ||
| 7431 | // Queueing | |
| 7432 | op t.old = op t.complete ; | |
| 7433 | ||
| 7434 | op t.complete = functio n() { | |
| 7435 | if ( jQuery.is Function( opt.old ) ) { | |
| 7436 | opt.ol d.call( th is ); | |
| 7437 | } | |
| 7438 | ||
| 7439 | if ( opt.queue ) { | |
| 7440 | jQuery .dequeue( this, opt. queue ); | |
| 7441 | } | |
| 7442 | }; | |
| 7443 | ||
| 7444 | re turn opt; | |
| 7445 | }; | |
| 7446 | ||
| 7447 | jQuery.fn. extend({ | |
| 7448 | fa deTo: func tion( spee d, to, eas ing, callb ack ) { | |
| 7449 | ||
| 7450 | // s how any hi dden eleme nts after setting op acity to 0 | |
| 7451 | retu rn this.fi lter( isHi dden ).css ( "opacity ", 0 ).sho w() | |
| 7452 | ||
| 7453 | // ani mate to th e value sp ecified | |
| 7454 | .end() .animate({ opacity: to }, spee d, easing, callback ); | |
| 7455 | }, | |
| 7456 | an imate: fun ction( pro p, speed, easing, ca llback ) { | |
| 7457 | var empty = jQ uery.isEmp tyObject( prop ), | |
| 7458 | optall = jQuery. speed( spe ed, easing , callback ), | |
| 7459 | doAnim ation = fu nction() { | |
| 7460 | // Opera te on a co py of prop so per-pr operty eas ing won't be lost | |
| 7461 | var anim = Animati on( this, jQuery.ext end( {}, p rop ), opt all ); | |
| 7462 | ||
| 7463 | // Empty animation s, or fini shing reso lves immed iately | |
| 7464 | if ( emp ty || jQue ry._data( this, "fin ish" ) ) { | |
| 7465 | anim.stop( true ); | |
| 7466 | } | |
| 7467 | }; | |
| 7468 | doAnim ation.fini sh = doAni mation; | |
| 7469 | ||
| 7470 | retu rn empty | | optall.q ueue === f alse ? | |
| 7471 | this.e ach( doAni mation ) : | |
| 7472 | this.q ueue( opta ll.queue, doAnimatio n ); | |
| 7473 | }, | |
| 7474 | st op: functi on( type, clearQueue , gotoEnd ) { | |
| 7475 | var stopQueue = function ( hooks ) { | |
| 7476 | var st op = hooks .stop; | |
| 7477 | delete hooks.sto p; | |
| 7478 | stop( gotoEnd ); | |
| 7479 | }; | |
| 7480 | ||
| 7481 | if ( typeof ty pe !== "st ring" ) { | |
| 7482 | gotoEn d = clearQ ueue; | |
| 7483 | clearQ ueue = typ e; | |
| 7484 | type = undefined ; | |
| 7485 | } | |
| 7486 | if ( clearQueu e && type !== false ) { | |
| 7487 | this.q ueue( type || "fx", [] ); | |
| 7488 | } | |
| 7489 | ||
| 7490 | retu rn this.ea ch(functio n() { | |
| 7491 | var de queue = tr ue, | |
| 7492 | index = type != nu ll && type + "queueH ooks", | |
| 7493 | timers = jQuery.ti mers, | |
| 7494 | data = j Query._dat a( this ); | |
| 7495 | ||
| 7496 | if ( i ndex ) { | |
| 7497 | if ( dat a[ index ] && data[ index ].st op ) { | |
| 7498 | stopQueue( data[ ind ex ] ); | |
| 7499 | } | |
| 7500 | } else { | |
| 7501 | for ( in dex in dat a ) { | |
| 7502 | if ( data[ index ] & & data[ in dex ].stop && rrun.t est( index ) ) { | |
| 7503 | st opQueue( d ata[ index ] ); | |
| 7504 | } | |
| 7505 | } | |
| 7506 | } | |
| 7507 | ||
| 7508 | for ( index = ti mers.lengt h; index-- ; ) { | |
| 7509 | if ( tim ers[ index ].elem == = this && (type == n ull || tim ers[ index ].queue = == type) ) { | |
| 7510 | timers[ in dex ].anim .stop( got oEnd ); | |
| 7511 | dequeue = false; | |
| 7512 | timers.spl ice( index , 1 ); | |
| 7513 | } | |
| 7514 | } | |
| 7515 | ||
| 7516 | // sta rt the nex t in the q ueue if th e last ste p wasn't f orced | |
| 7517 | // tim ers curren tly will c all their complete c allbacks, which will dequeue | |
| 7518 | // but only if t hey were g otoEnd | |
| 7519 | if ( d equeue || !gotoEnd ) { | |
| 7520 | jQuery.d equeue( th is, type ) ; | |
| 7521 | } | |
| 7522 | }); | |
| 7523 | }, | |
| 7524 | fi nish: func tion( type ) { | |
| 7525 | if ( type !== false ) { | |
| 7526 | type = type || " fx"; | |
| 7527 | } | |
| 7528 | retu rn this.ea ch(functio n() { | |
| 7529 | var in dex, | |
| 7530 | data = j Query._dat a( this ), | |
| 7531 | queue = data[ type + "queue" ], | |
| 7532 | hooks = data[ type + "queueH ooks" ], | |
| 7533 | timers = jQuery.ti mers, | |
| 7534 | length = queue ? q ueue.lengt h : 0; | |
| 7535 | ||
| 7536 | // ena ble finish ing flag o n private data | |
| 7537 | data.f inish = tr ue; | |
| 7538 | ||
| 7539 | // emp ty the que ue first | |
| 7540 | jQuery .queue( th is, type, [] ); | |
| 7541 | ||
| 7542 | if ( h ooks && ho oks.stop ) { | |
| 7543 | hooks.st op.call( t his, true ); | |
| 7544 | } | |
| 7545 | ||
| 7546 | // loo k for any active ani mations, a nd finish them | |
| 7547 | for ( index = ti mers.lengt h; index-- ; ) { | |
| 7548 | if ( tim ers[ index ].elem == = this && timers[ in dex ].queu e === type ) { | |
| 7549 | timers[ in dex ].anim .stop( tru e ); | |
| 7550 | timers.spl ice( index , 1 ); | |
| 7551 | } | |
| 7552 | } | |
| 7553 | ||
| 7554 | // loo k for any animations in the ol d queue an d finish t hem | |
| 7555 | for ( index = 0; index < l ength; ind ex++ ) { | |
| 7556 | if ( que ue[ index ] && queue [ index ]. finish ) { | |
| 7557 | queue[ ind ex ].finis h.call( th is ); | |
| 7558 | } | |
| 7559 | } | |
| 7560 | ||
| 7561 | // tur n off fini shing flag | |
| 7562 | delete data.fini sh; | |
| 7563 | }); | |
| 7564 | } | |
| 7565 | }); | |
| 7566 | ||
| 7567 | jQuery.eac h([ "toggl e", "show" , "hide" ] , function ( i, name ) { | |
| 7568 | va r cssFn = jQuery.fn[ name ]; | |
| 7569 | jQ uery.fn[ n ame ] = fu nction( sp eed, easin g, callbac k ) { | |
| 7570 | retu rn speed = = null || typeof spe ed === "bo olean" ? | |
| 7571 | cssFn. apply( thi s, argumen ts ) : | |
| 7572 | this.a nimate( ge nFx( name, true ), s peed, easi ng, callba ck ); | |
| 7573 | }; | |
| 7574 | }); | |
| 7575 | ||
| 7576 | // Generat e shortcut s for cust om animati ons | |
| 7577 | jQuery.eac h({ | |
| 7578 | sl ideDown: g enFx("show "), | |
| 7579 | sl ideUp: gen Fx("hide") , | |
| 7580 | sl ideToggle: genFx("to ggle"), | |
| 7581 | fa deIn: { op acity: "sh ow" }, | |
| 7582 | fa deOut: { o pacity: "h ide" }, | |
| 7583 | fa deToggle: { opacity: "toggle" } | |
| 7584 | }, functio n( name, p rops ) { | |
| 7585 | jQ uery.fn[ n ame ] = fu nction( sp eed, easin g, callbac k ) { | |
| 7586 | retu rn this.an imate( pro ps, speed, easing, c allback ); | |
| 7587 | }; | |
| 7588 | }); | |
| 7589 | ||
| 7590 | jQuery.tim ers = []; | |
| 7591 | jQuery.fx. tick = fun ction() { | |
| 7592 | va r timer, | |
| 7593 | time rs = jQuer y.timers, | |
| 7594 | i = 0; | |
| 7595 | ||
| 7596 | fx Now = jQue ry.now(); | |
| 7597 | ||
| 7598 | fo r ( ; i < timers.len gth; i++ ) { | |
| 7599 | time r = timers [ i ]; | |
| 7600 | // C hecks the timer has not alread y been rem oved | |
| 7601 | if ( !timer() && timers[ i ] === t imer ) { | |
| 7602 | timers .splice( i --, 1 ); | |
| 7603 | } | |
| 7604 | } | |
| 7605 | ||
| 7606 | if ( !timers .length ) { | |
| 7607 | jQue ry.fx.stop (); | |
| 7608 | } | |
| 7609 | fx Now = unde fined; | |
| 7610 | }; | |
| 7611 | ||
| 7612 | jQuery.fx. timer = fu nction( ti mer ) { | |
| 7613 | jQ uery.timer s.push( ti mer ); | |
| 7614 | if ( timer() ) { | |
| 7615 | jQue ry.fx.star t(); | |
| 7616 | } else { | |
| 7617 | jQue ry.timers. pop(); | |
| 7618 | } | |
| 7619 | }; | |
| 7620 | ||
| 7621 | jQuery.fx. interval = 13; | |
| 7622 | ||
| 7623 | jQuery.fx. start = fu nction() { | |
| 7624 | if ( !timerI d ) { | |
| 7625 | time rId = setI nterval( j Query.fx.t ick, jQuer y.fx.inter val ); | |
| 7626 | } | |
| 7627 | }; | |
| 7628 | ||
| 7629 | jQuery.fx. stop = fun ction() { | |
| 7630 | cl earInterva l( timerId ); | |
| 7631 | ti merId = nu ll; | |
| 7632 | }; | |
| 7633 | ||
| 7634 | jQuery.fx. speeds = { | |
| 7635 | sl ow: 600, | |
| 7636 | fa st: 200, | |
| 7637 | // Default s peed | |
| 7638 | _d efault: 40 0 | |
| 7639 | }; | |
| 7640 | ||
| 7641 | ||
| 7642 | // Based o ff of the plugin by Clint Helf ers, with permission . | |
| 7643 | // http:// blindsigna ls.com/ind ex.php/200 9/07/jquer y-delay/ | |
| 7644 | jQuery.fn. delay = fu nction( ti me, type ) { | |
| 7645 | ti me = jQuer y.fx ? jQu ery.fx.spe eds[ time ] || time : time; | |
| 7646 | ty pe = type || "fx"; | |
| 7647 | ||
| 7648 | re turn this. queue( typ e, functio n( next, h ooks ) { | |
| 7649 | var timeout = setTimeout ( next, ti me ); | |
| 7650 | hook s.stop = f unction() { | |
| 7651 | clearT imeout( ti meout ); | |
| 7652 | }; | |
| 7653 | }) ; | |
| 7654 | }; | |
| 7655 | ||
| 7656 | ||
| 7657 | (function( ) { | |
| 7658 | // Minified: var a,b,c ,d,e | |
| 7659 | va r input, d iv, select , a, opt; | |
| 7660 | ||
| 7661 | // Setup | |
| 7662 | di v = docume nt.createE lement( "d iv" ); | |
| 7663 | di v.setAttri bute( "cla ssName", " t" ); | |
| 7664 | di v.innerHTM L = " <li nk/><table ></table>< a href='/a '>a</a><in put type=' checkbox'/ >"; | |
| 7665 | a = div.getE lementsByT agName("a" )[ 0 ]; | |
| 7666 | ||
| 7667 | // First bat ch of test s. | |
| 7668 | se lect = doc ument.crea teElement( "select"); | |
| 7669 | op t = select .appendChi ld( docume nt.createE lement("op tion") ); | |
| 7670 | in put = div. getElement sByTagName ("input")[ 0 ]; | |
| 7671 | ||
| 7672 | a. style.cssT ext = "top :1px"; | |
| 7673 | ||
| 7674 | // Test setA ttribute o n camelCas e class. I f it works , we need attrFixes when doing get/setAt tribute (i e6/7) | |
| 7675 | su pport.getS etAttribut e = div.cl assName != = "t"; | |
| 7676 | ||
| 7677 | // Get the s tyle infor mation fro m getAttri bute | |
| 7678 | // (IE uses .cssText i nstead) | |
| 7679 | su pport.styl e = /top/. test( a.ge tAttribute ("style") ); | |
| 7680 | ||
| 7681 | // Make sure that URLs aren't ma nipulated | |
| 7682 | // (IE norma lizes it b y default) | |
| 7683 | su pport.href Normalized = a.getAt tribute("h ref") === "/a"; | |
| 7684 | ||
| 7685 | // Check the default c heckbox/ra dio value ("" on Web Kit; "on" elsewhere) | |
| 7686 | su pport.chec kOn = !!in put.value; | |
| 7687 | ||
| 7688 | // Make sure that a se lected-by- default op tion has a working s elected pr operty. | |
| 7689 | // (WebKit d efaults to false ins tead of tr ue, IE too , if it's in an optg roup) | |
| 7690 | su pport.optS elected = opt.select ed; | |
| 7691 | ||
| 7692 | // Tests for enctype s upport on a form (#6 743) | |
| 7693 | su pport.enct ype = !!do cument.cre ateElement ("form").e nctype; | |
| 7694 | ||
| 7695 | // Make sure that the options in side disab led select s aren't m arked as d isabled | |
| 7696 | // (WebKit m arks them as disable d) | |
| 7697 | se lect.disab led = true ; | |
| 7698 | su pport.optD isabled = !opt.disab led; | |
| 7699 | ||
| 7700 | // Support: IE8 only | |
| 7701 | // Check if we can tru st getAttr ibute("val ue") | |
| 7702 | in put = docu ment.creat eElement( "input" ); | |
| 7703 | in put.setAtt ribute( "v alue", "" ); | |
| 7704 | su pport.inpu t = input. getAttribu te( "value " ) === "" ; | |
| 7705 | ||
| 7706 | // Check if an input m aintains i ts value a fter becom ing a radi o | |
| 7707 | in put.value = "t"; | |
| 7708 | in put.setAtt ribute( "t ype", "rad io" ); | |
| 7709 | su pport.radi oValue = i nput.value === "t"; | |
| 7710 | })(); | |
| 7711 | ||
| 7712 | ||
| 7713 | var rretur n = /\r/g; | |
| 7714 | ||
| 7715 | jQuery.fn. extend({ | |
| 7716 | va l: functio n( value ) { | |
| 7717 | var hooks, ret , isFuncti on, | |
| 7718 | elem = this[0]; | |
| 7719 | ||
| 7720 | if ( !argument s.length ) { | |
| 7721 | if ( e lem ) { | |
| 7722 | hooks = jQuery.val Hooks[ ele m.type ] | | jQuery.v alHooks[ e lem.nodeNa me.toLower Case() ]; | |
| 7723 | ||
| 7724 | if ( hoo ks && "get " in hooks && (ret = hooks.get ( elem, "v alue" )) ! == undefin ed ) { | |
| 7725 | return ret ; | |
| 7726 | } | |
| 7727 | ||
| 7728 | ret = el em.value; | |
| 7729 | ||
| 7730 | return t ypeof ret === "strin g" ? | |
| 7731 | // handle most commo n string c ases | |
| 7732 | ret.replac e(rreturn, "") : | |
| 7733 | // handle cases wher e value is null/unde f or numbe r | |
| 7734 | ret == nul l ? "" : r et; | |
| 7735 | } | |
| 7736 | ||
| 7737 | return ; | |
| 7738 | } | |
| 7739 | ||
| 7740 | isFu nction = j Query.isFu nction( va lue ); | |
| 7741 | ||
| 7742 | retu rn this.ea ch(functio n( i ) { | |
| 7743 | var va l; | |
| 7744 | ||
| 7745 | if ( t his.nodeTy pe !== 1 ) { | |
| 7746 | return; | |
| 7747 | } | |
| 7748 | ||
| 7749 | if ( i sFunction ) { | |
| 7750 | val = va lue.call( this, i, j Query( thi s ).val() ); | |
| 7751 | } else { | |
| 7752 | val = va lue; | |
| 7753 | } | |
| 7754 | ||
| 7755 | // Tre at null/un defined as ""; conve rt numbers to string | |
| 7756 | if ( v al == null ) { | |
| 7757 | val = "" ; | |
| 7758 | } else if ( type of val === "number" ) { | |
| 7759 | val += " "; | |
| 7760 | } else if ( jQue ry.isArray ( val ) ) { | |
| 7761 | val = jQ uery.map( val, funct ion( value ) { | |
| 7762 | return val ue == null ? "" : va lue + ""; | |
| 7763 | }); | |
| 7764 | } | |
| 7765 | ||
| 7766 | hooks = jQuery.v alHooks[ t his.type ] || jQuery .valHooks[ this.node Name.toLow erCase() ] ; | |
| 7767 | ||
| 7768 | // If set return s undefine d, fall ba ck to norm al setting | |
| 7769 | if ( ! hooks || ! ("set" in hooks) || hooks.set( this, val , "value" ) === unde fined ) { | |
| 7770 | this.val ue = val; | |
| 7771 | } | |
| 7772 | }); | |
| 7773 | } | |
| 7774 | }); | |
| 7775 | ||
| 7776 | jQuery.ext end({ | |
| 7777 | va lHooks: { | |
| 7778 | opti on: { | |
| 7779 | get: f unction( e lem ) { | |
| 7780 | var val = jQuery.f ind.attr( elem, "val ue" ); | |
| 7781 | return v al != null ? | |
| 7782 | val : | |
| 7783 | // Support : IE10-11+ | |
| 7784 | // option. text throw s exceptio ns (#14686 , #14858) | |
| 7785 | jQuery.tri m( jQuery. text( elem ) ); | |
| 7786 | } | |
| 7787 | }, | |
| 7788 | sele ct: { | |
| 7789 | get: f unction( e lem ) { | |
| 7790 | var valu e, option, | |
| 7791 | options = elem.optio ns, | |
| 7792 | index = el em.selecte dIndex, | |
| 7793 | one = elem .type === "select-on e" || inde x < 0, | |
| 7794 | values = o ne ? null : [], | |
| 7795 | max = one ? index + 1 : option s.length, | |
| 7796 | i = index < 0 ? | |
| 7797 | ma x : | |
| 7798 | on e ? index : 0; | |
| 7799 | ||
| 7800 | // Loop through al l the sele cted optio ns | |
| 7801 | for ( ; i < max; i ++ ) { | |
| 7802 | option = o ptions[ i ]; | |
| 7803 | ||
| 7804 | // oldIE d oesn't upd ate select ed after f orm reset (#2551) | |
| 7805 | if ( ( opt ion.select ed || i == = index ) && | |
| 7806 | // D on't retur n options that are d isabled or in a disa bled optgr oup | |
| 7807 | ( su pport.optD isabled ? !option.di sabled : o ption.getA ttribute(" disabled") === null ) && | |
| 7808 | ( !o ption.pare ntNode.dis abled || ! jQuery.nod eName( opt ion.parent Node, "opt group" ) ) ) { | |
| 7809 | ||
| 7810 | // Get the s pecific va lue for th e option | |
| 7811 | va lue = jQue ry( option ).val(); | |
| 7812 | ||
| 7813 | // We don't need an ar ray for on e selects | |
| 7814 | if ( one ) { | |
| 7815 | retu rn value; | |
| 7816 | } | |
| 7817 | ||
| 7818 | // Multi-Sel ects retur n an array | |
| 7819 | va lues.push( value ); | |
| 7820 | } | |
| 7821 | } | |
| 7822 | ||
| 7823 | return v alues; | |
| 7824 | }, | |
| 7825 | ||
| 7826 | set: f unction( e lem, value ) { | |
| 7827 | var opti onSet, opt ion, | |
| 7828 | options = elem.optio ns, | |
| 7829 | values = j Query.make Array( val ue ), | |
| 7830 | i = option s.length; | |
| 7831 | ||
| 7832 | while ( i-- ) { | |
| 7833 | option = o ptions[ i ]; | |
| 7834 | ||
| 7835 | if ( jQuer y.inArray( jQuery.va lHooks.opt ion.get( o ption ), v alues ) >= 0 ) { | |
| 7836 | ||
| 7837 | // Support: IE6 | |
| 7838 | // When new option ele ment is ad ded to sel ect box we need to | |
| 7839 | // force ref low of new ly added n ode in ord er to work around del ay | |
| 7840 | // of initia lization p roperties | |
| 7841 | tr y { | |
| 7842 | opti on.selecte d = option Set = true ; | |
| 7843 | ||
| 7844 | } catch ( _ ) { | |
| 7845 | ||
| 7846 | // W ill be exe cuted only in IE6 | |
| 7847 | opti on.scrollH eight; | |
| 7848 | } | |
| 7849 | ||
| 7850 | } else { | |
| 7851 | op tion.selec ted = fals e; | |
| 7852 | } | |
| 7853 | } | |
| 7854 | ||
| 7855 | // Force browsers to behave consistent ly when no n-matching value is set | |
| 7856 | if ( !op tionSet ) { | |
| 7857 | elem.selec tedIndex = -1; | |
| 7858 | } | |
| 7859 | ||
| 7860 | return o ptions; | |
| 7861 | } | |
| 7862 | } | |
| 7863 | } | |
| 7864 | }); | |
| 7865 | ||
| 7866 | // Radios and checkb oxes gette r/setter | |
| 7867 | jQuery.eac h([ "radio ", "checkb ox" ], fun ction() { | |
| 7868 | jQ uery.valHo oks[ this ] = { | |
| 7869 | set: function( elem, val ue ) { | |
| 7870 | if ( j Query.isAr ray( value ) ) { | |
| 7871 | return ( elem.chec ked = jQue ry.inArray ( jQuery(e lem).val() , value ) >= 0 ); | |
| 7872 | } | |
| 7873 | } | |
| 7874 | }; | |
| 7875 | if ( !suppor t.checkOn ) { | |
| 7876 | jQue ry.valHook s[ this ]. get = func tion( elem ) { | |
| 7877 | // Sup port: Webk it | |
| 7878 | // "" is returne d instead of "on" if a value i sn't speci fied | |
| 7879 | return elem.getA ttribute(" value") == = null ? " on" : elem .value; | |
| 7880 | }; | |
| 7881 | } | |
| 7882 | }); | |
| 7883 | ||
| 7884 | ||
| 7885 | ||
| 7886 | ||
| 7887 | var nodeHo ok, boolHo ok, | |
| 7888 | at trHandle = jQuery.ex pr.attrHan dle, | |
| 7889 | ru seDefault = /^(?:che cked|selec ted)$/i, | |
| 7890 | ge tSetAttrib ute = supp ort.getSet Attribute, | |
| 7891 | ge tSetInput = support. input; | |
| 7892 | ||
| 7893 | jQuery.fn. extend({ | |
| 7894 | at tr: functi on( name, value ) { | |
| 7895 | retu rn access( this, jQu ery.attr, name, valu e, argumen ts.length > 1 ); | |
| 7896 | }, | |
| 7897 | ||
| 7898 | re moveAttr: function( name ) { | |
| 7899 | retu rn this.ea ch(functio n() { | |
| 7900 | jQuery .removeAtt r( this, n ame ); | |
| 7901 | }); | |
| 7902 | } | |
| 7903 | }); | |
| 7904 | ||
| 7905 | jQuery.ext end({ | |
| 7906 | at tr: functi on( elem, name, valu e ) { | |
| 7907 | var hooks, ret , | |
| 7908 | nType = elem.nod eType; | |
| 7909 | ||
| 7910 | // d on't get/s et attribu tes on tex t, comment and attri bute nodes | |
| 7911 | if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { | |
| 7912 | return ; | |
| 7913 | } | |
| 7914 | ||
| 7915 | // F allback to prop when attribute s are not supported | |
| 7916 | if ( typeof el em.getAttr ibute === strundefin ed ) { | |
| 7917 | return jQuery.pr op( elem, name, valu e ); | |
| 7918 | } | |
| 7919 | ||
| 7920 | // A ll attribu tes are lo wercase | |
| 7921 | // G rab necess ary hook i f one is d efined | |
| 7922 | if ( nType !== 1 || !jQu ery.isXMLD oc( elem ) ) { | |
| 7923 | name = name.toLo werCase(); | |
| 7924 | hooks = jQuery.a ttrHooks[ name ] || | |
| 7925 | ( jQuery .expr.matc h.bool.tes t( name ) ? boolHook : nodeHoo k ); | |
| 7926 | } | |
| 7927 | ||
| 7928 | if ( value !== undefined ) { | |
| 7929 | ||
| 7930 | if ( v alue === n ull ) { | |
| 7931 | jQuery.r emoveAttr( elem, nam e ); | |
| 7932 | ||
| 7933 | } else if ( hook s && "set" in hooks && (ret = hooks.set( elem, val ue, name ) ) !== unde fined ) { | |
| 7934 | return r et; | |
| 7935 | ||
| 7936 | } else { | |
| 7937 | elem.set Attribute( name, val ue + "" ); | |
| 7938 | return v alue; | |
| 7939 | } | |
| 7940 | ||
| 7941 | } el se if ( ho oks && "ge t" in hook s && (ret = hooks.ge t( elem, n ame )) !== null ) { | |
| 7942 | return ret; | |
| 7943 | ||
| 7944 | } el se { | |
| 7945 | ret = jQuery.fin d.attr( el em, name ) ; | |
| 7946 | ||
| 7947 | // Non -existent attributes return nu ll, we nor malize to undefined | |
| 7948 | return ret == nu ll ? | |
| 7949 | undefine d : | |
| 7950 | ret; | |
| 7951 | } | |
| 7952 | }, | |
| 7953 | ||
| 7954 | re moveAttr: function( elem, valu e ) { | |
| 7955 | var name, prop Name, | |
| 7956 | i = 0, | |
| 7957 | attrNa mes = valu e && value .match( rn otwhite ); | |
| 7958 | ||
| 7959 | if ( attrNames && elem.n odeType == = 1 ) { | |
| 7960 | while ( (name = attrNames[ i++]) ) { | |
| 7961 | propName = jQuery. propFix[ n ame ] || n ame; | |
| 7962 | ||
| 7963 | // Boole an attribu tes get sp ecial trea tment (#10 870) | |
| 7964 | if ( jQu ery.expr.m atch.bool. test( name ) ) { | |
| 7965 | // Set cor responding property to false | |
| 7966 | if ( getSe tInput && getSetAttr ibute || ! ruseDefaul t.test( na me ) ) { | |
| 7967 | el em[ propNa me ] = fal se; | |
| 7968 | // Support : IE<9 | |
| 7969 | // Also cl ear defaul tChecked/d efaultSele cted (if a ppropriate ) | |
| 7970 | } else { | |
| 7971 | el em[ jQuery .camelCase ( "default -" + name ) ] = | |
| 7972 | elem [ propName ] = false ; | |
| 7973 | } | |
| 7974 | ||
| 7975 | // See # 9699 for e xplanation of this a pproach (s etting fir st, then r emoval) | |
| 7976 | } else { | |
| 7977 | jQuery.att r( elem, n ame, "" ); | |
| 7978 | } | |
| 7979 | ||
| 7980 | elem.rem oveAttribu te( getSet Attribute ? name : p ropName ); | |
| 7981 | } | |
| 7982 | } | |
| 7983 | }, | |
| 7984 | ||
| 7985 | at trHooks: { | |
| 7986 | type : { | |
| 7987 | set: f unction( e lem, value ) { | |
| 7988 | if ( !su pport.radi oValue && value === "radio" && jQuery.no deName(ele m, "input" ) ) { | |
| 7989 | // Setting the type on a radio button af ter the va lue resets the value in IE6-9 | |
| 7990 | // Reset v alue to de fault in c ase type i s set afte r value du ring creat ion | |
| 7991 | var val = elem.value ; | |
| 7992 | elem.setAt tribute( " type", val ue ); | |
| 7993 | if ( val ) { | |
| 7994 | el em.value = val; | |
| 7995 | } | |
| 7996 | return val ue; | |
| 7997 | } | |
| 7998 | } | |
| 7999 | } | |
| 8000 | } | |
| 8001 | }); | |
| 8002 | ||
| 8003 | // Hook fo r boolean attributes | |
| 8004 | boolHook = { | |
| 8005 | se t: functio n( elem, v alue, name ) { | |
| 8006 | if ( value === false ) { | |
| 8007 | // Rem ove boolea n attribut es when se t to false | |
| 8008 | jQuery .removeAtt r( elem, n ame ); | |
| 8009 | } el se if ( ge tSetInput && getSetA ttribute | | !ruseDef ault.test( name ) ) { | |
| 8010 | // IE< 8 needs th e *propert y* name | |
| 8011 | elem.s etAttribut e( !getSet Attribute && jQuery. propFix[ n ame ] || n ame, name ); | |
| 8012 | ||
| 8013 | // U se default Checked an d defaultS elected fo r oldIE | |
| 8014 | } el se { | |
| 8015 | elem[ jQuery.cam elCase( "d efault-" + name ) ] = elem[ na me ] = tru e; | |
| 8016 | } | |
| 8017 | ||
| 8018 | retu rn name; | |
| 8019 | } | |
| 8020 | }; | |
| 8021 | ||
| 8022 | // Retriev e booleans specially | |
| 8023 | jQuery.eac h( jQuery. expr.match .bool.sour ce.match( /\w+/g ), function( i, name ) { | |
| 8024 | ||
| 8025 | va r getter = attrHandl e[ name ] || jQuery. find.attr; | |
| 8026 | ||
| 8027 | at trHandle[ name ] = g etSetInput && getSet Attribute || !ruseDe fault.test ( name ) ? | |
| 8028 | func tion( elem , name, is XML ) { | |
| 8029 | var re t, handle; | |
| 8030 | if ( ! isXML ) { | |
| 8031 | // Avoid an infini te loop by temporari ly removin g this fun ction from the gette r | |
| 8032 | handle = attrHandl e[ name ]; | |
| 8033 | attrHand le[ name ] = ret; | |
| 8034 | ret = ge tter( elem , name, is XML ) != n ull ? | |
| 8035 | name.toLow erCase() : | |
| 8036 | null; | |
| 8037 | attrHand le[ name ] = handle; | |
| 8038 | } | |
| 8039 | return ret; | |
| 8040 | } : | |
| 8041 | func tion( elem , name, is XML ) { | |
| 8042 | if ( ! isXML ) { | |
| 8043 | return e lem[ jQuer y.camelCas e( "defaul t-" + name ) ] ? | |
| 8044 | name.toLow erCase() : | |
| 8045 | null; | |
| 8046 | } | |
| 8047 | }; | |
| 8048 | }); | |
| 8049 | ||
| 8050 | // fix old IE attrope rties | |
| 8051 | if ( !getS etInput || !getSetAt tribute ) { | |
| 8052 | jQ uery.attrH ooks.value = { | |
| 8053 | set: function( elem, val ue, name ) { | |
| 8054 | if ( j Query.node Name( elem , "input" ) ) { | |
| 8055 | // Does not return so that s etAttribut e is also used | |
| 8056 | elem.def aultValue = value; | |
| 8057 | } else { | |
| 8058 | // Use n odeHook if defined ( #1954); ot herwise se tAttribute is fine | |
| 8059 | return n odeHook && nodeHook. set( elem, value, na me ); | |
| 8060 | } | |
| 8061 | } | |
| 8062 | }; | |
| 8063 | } | |
| 8064 | ||
| 8065 | // IE6/7 d o not supp ort gettin g/setting some attri butes with get/setAt tribute | |
| 8066 | if ( !getS etAttribut e ) { | |
| 8067 | ||
| 8068 | // Use this for any at tribute in IE6/7 | |
| 8069 | // This fixe s almost e very IE6/7 issue | |
| 8070 | no deHook = { | |
| 8071 | set: function( elem, val ue, name ) { | |
| 8072 | // Set the exist ing or cre ate a new attribute node | |
| 8073 | var re t = elem.g etAttribut eNode( nam e ); | |
| 8074 | if ( ! ret ) { | |
| 8075 | elem.set AttributeN ode( | |
| 8076 | (ret = ele m.ownerDoc ument.crea teAttribut e( name )) | |
| 8077 | ); | |
| 8078 | } | |
| 8079 | ||
| 8080 | ret.va lue = valu e += ""; | |
| 8081 | ||
| 8082 | // Bre ak associa tion with cloned ele ments by a lso using setAttribu te (#9646) | |
| 8083 | if ( n ame === "v alue" || v alue === e lem.getAtt ribute( na me ) ) { | |
| 8084 | return v alue; | |
| 8085 | } | |
| 8086 | } | |
| 8087 | }; | |
| 8088 | ||
| 8089 | // Some attr ibutes are construct ed with em pty-string values wh en not def ined | |
| 8090 | at trHandle.i d = attrHa ndle.name = attrHand le.coords = | |
| 8091 | func tion( elem , name, is XML ) { | |
| 8092 | var re t; | |
| 8093 | if ( ! isXML ) { | |
| 8094 | return ( ret = elem .getAttrib uteNode( n ame )) && ret.value !== "" ? | |
| 8095 | ret.value : | |
| 8096 | null; | |
| 8097 | } | |
| 8098 | }; | |
| 8099 | ||
| 8100 | // Fixing va lue retrie val on a b utton requ ires this module | |
| 8101 | jQ uery.valHo oks.button = { | |
| 8102 | get: function( elem, nam e ) { | |
| 8103 | var re t = elem.g etAttribut eNode( nam e ); | |
| 8104 | if ( r et && ret. specified ) { | |
| 8105 | return r et.value; | |
| 8106 | } | |
| 8107 | }, | |
| 8108 | set: nodeHook. set | |
| 8109 | }; | |
| 8110 | ||
| 8111 | // Set conte nteditable to false on removal s(#10429) | |
| 8112 | // Setting t o empty st ring throw s an error as an inv alid value | |
| 8113 | jQ uery.attrH ooks.conte nteditable = { | |
| 8114 | set: function( elem, val ue, name ) { | |
| 8115 | nodeHo ok.set( el em, value === "" ? f alse : val ue, name ) ; | |
| 8116 | } | |
| 8117 | }; | |
| 8118 | ||
| 8119 | // Set width and heigh t to auto instead of 0 on empt y string( Bug #8150 ) | |
| 8120 | // This is f or removal s | |
| 8121 | jQ uery.each( [ "width", "height" ], functio n( i, name ) { | |
| 8122 | jQue ry.attrHoo ks[ name ] = { | |
| 8123 | set: f unction( e lem, value ) { | |
| 8124 | if ( val ue === "" ) { | |
| 8125 | elem.setAt tribute( n ame, "auto " ); | |
| 8126 | return val ue; | |
| 8127 | } | |
| 8128 | } | |
| 8129 | }; | |
| 8130 | }) ; | |
| 8131 | } | |
| 8132 | ||
| 8133 | if ( !supp ort.style ) { | |
| 8134 | jQ uery.attrH ooks.style = { | |
| 8135 | get: function( elem ) { | |
| 8136 | // Ret urn undefi ned in the case of e mpty strin g | |
| 8137 | // Not e: IE uppe rcases css property names, but if we wer e to .toLo werCase() | |
| 8138 | // .cs sText, tha t would de stroy case senstitiv ity in URL 's, like i n "backgro und" | |
| 8139 | return elem.styl e.cssText || undefin ed; | |
| 8140 | }, | |
| 8141 | set: function( elem, val ue ) { | |
| 8142 | return ( elem.st yle.cssTex t = value + "" ); | |
| 8143 | } | |
| 8144 | }; | |
| 8145 | } | |
| 8146 | ||
| 8147 | ||
| 8148 | ||
| 8149 | ||
| 8150 | var rfocus able = /^( ?:input|se lect|texta rea|button |object)$/ i, | |
| 8151 | rc lickable = /^(?:a|ar ea)$/i; | |
| 8152 | ||
| 8153 | jQuery.fn. extend({ | |
| 8154 | pr op: functi on( name, value ) { | |
| 8155 | retu rn access( this, jQu ery.prop, name, valu e, argumen ts.length > 1 ); | |
| 8156 | }, | |
| 8157 | ||
| 8158 | re moveProp: function( name ) { | |
| 8159 | name = jQuery. propFix[ n ame ] || n ame; | |
| 8160 | retu rn this.ea ch(functio n() { | |
| 8161 | // try /catch han dles cases where IE balks (suc h as remov ing a prop erty on wi ndow) | |
| 8162 | try { | |
| 8163 | this[ na me ] = und efined; | |
| 8164 | delete t his[ name ]; | |
| 8165 | } catc h( e ) {} | |
| 8166 | }); | |
| 8167 | } | |
| 8168 | }); | |
| 8169 | ||
| 8170 | jQuery.ext end({ | |
| 8171 | pr opFix: { | |
| 8172 | "for ": "htmlFo r", | |
| 8173 | "cla ss": "clas sName" | |
| 8174 | }, | |
| 8175 | ||
| 8176 | pr op: functi on( elem, name, valu e ) { | |
| 8177 | var ret, hooks , notxml, | |
| 8178 | nType = elem.nod eType; | |
| 8179 | ||
| 8180 | // d on't get/s et propert ies on tex t, comment and attri bute nodes | |
| 8181 | if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { | |
| 8182 | return ; | |
| 8183 | } | |
| 8184 | ||
| 8185 | notx ml = nType !== 1 || !jQuery.is XMLDoc( el em ); | |
| 8186 | ||
| 8187 | if ( notxml ) { | |
| 8188 | // Fix name and attach hoo ks | |
| 8189 | name = jQuery.pr opFix[ nam e ] || nam e; | |
| 8190 | hooks = jQuery.p ropHooks[ name ]; | |
| 8191 | } | |
| 8192 | ||
| 8193 | if ( value !== undefined ) { | |
| 8194 | return hooks && "set" in h ooks && (r et = hooks .set( elem , value, n ame )) !== undefined ? | |
| 8195 | ret : | |
| 8196 | ( elem[ name ] = v alue ); | |
| 8197 | ||
| 8198 | } el se { | |
| 8199 | return hooks && "get" in h ooks && (r et = hooks .get( elem , name )) !== null ? | |
| 8200 | ret : | |
| 8201 | elem[ na me ]; | |
| 8202 | } | |
| 8203 | }, | |
| 8204 | ||
| 8205 | pr opHooks: { | |
| 8206 | tabI ndex: { | |
| 8207 | get: f unction( e lem ) { | |
| 8208 | // elem. tabIndex d oesn't alw ays return the corre ct value w hen it has n't been e xplicitly set | |
| 8209 | // http: //fluidpro ject.org/b log/2008/0 1/09/getti ng-setting -and-remov ing-tabind ex-values- with-javas cript/ | |
| 8210 | // Use p roper attr ibute retr ieval(#120 72) | |
| 8211 | var tabi ndex = jQu ery.find.a ttr( elem, "tabindex " ); | |
| 8212 | ||
| 8213 | return t abindex ? | |
| 8214 | parseInt( tabindex, 10 ) : | |
| 8215 | rfocusable .test( ele m.nodeName ) || rcli ckable.tes t( elem.no deName ) & & elem.hre f ? | |
| 8216 | 0 : | |
| 8217 | -1 ; | |
| 8218 | } | |
| 8219 | } | |
| 8220 | } | |
| 8221 | }); | |
| 8222 | ||
| 8223 | // Some at tributes r equire a s pecial cal l on IE | |
| 8224 | // http:// msdn.micro soft.com/e n-us/libra ry/ms53642 9%28VS.85% 29.aspx | |
| 8225 | if ( !supp ort.hrefNo rmalized ) { | |
| 8226 | // href/src property s hould get the full n ormalized URL (#1029 9/#12915) | |
| 8227 | jQ uery.each( [ "href", "src" ], f unction( i , name ) { | |
| 8228 | jQue ry.propHoo ks[ name ] = { | |
| 8229 | get: f unction( e lem ) { | |
| 8230 | return e lem.getAtt ribute( na me, 4 ); | |
| 8231 | } | |
| 8232 | }; | |
| 8233 | }) ; | |
| 8234 | } | |
| 8235 | ||
| 8236 | // Support : Safari, IE9+ | |
| 8237 | // mis-rep orts the d efault sel ected prop erty of an option | |
| 8238 | // Accessi ng the par ent's sele ctedIndex property f ixes it | |
| 8239 | if ( !supp ort.optSel ected ) { | |
| 8240 | jQ uery.propH ooks.selec ted = { | |
| 8241 | get: function( elem ) { | |
| 8242 | var pa rent = ele m.parentNo de; | |
| 8243 | ||
| 8244 | if ( p arent ) { | |
| 8245 | parent.s electedInd ex; | |
| 8246 | ||
| 8247 | // Make sure that it also wo rks with o ptgroups, see #5701 | |
| 8248 | if ( par ent.parent Node ) { | |
| 8249 | parent.par entNode.se lectedInde x; | |
| 8250 | } | |
| 8251 | } | |
| 8252 | return null; | |
| 8253 | } | |
| 8254 | }; | |
| 8255 | } | |
| 8256 | ||
| 8257 | jQuery.eac h([ | |
| 8258 | "t abIndex", | |
| 8259 | "r eadOnly", | |
| 8260 | "m axLength", | |
| 8261 | "c ellSpacing ", | |
| 8262 | "c ellPadding ", | |
| 8263 | "r owSpan", | |
| 8264 | "c olSpan", | |
| 8265 | "u seMap", | |
| 8266 | "f rameBorder ", | |
| 8267 | "c ontentEdit able" | |
| 8268 | ], functio n() { | |
| 8269 | jQ uery.propF ix[ this.t oLowerCase () ] = thi s; | |
| 8270 | }); | |
| 8271 | ||
| 8272 | // IE6/7 c all enctyp e encoding | |
| 8273 | if ( !supp ort.enctyp e ) { | |
| 8274 | jQ uery.propF ix.enctype = "encodi ng"; | |
| 8275 | } | |
| 8276 | ||
| 8277 | ||
| 8278 | ||
| 8279 | ||
| 8280 | var rclass = /[\t\r\ n\f]/g; | |
| 8281 | ||
| 8282 | jQuery.fn. extend({ | |
| 8283 | ad dClass: fu nction( va lue ) { | |
| 8284 | var classes, e lem, cur, clazz, j, finalValue , | |
| 8285 | i = 0, | |
| 8286 | len = this.lengt h, | |
| 8287 | procee d = typeof value === "string" && value; | |
| 8288 | ||
| 8289 | if ( jQuery.is Function( value ) ) { | |
| 8290 | return this.each (function( j ) { | |
| 8291 | jQuery( this ).add Class( val ue.call( t his, j, th is.classNa me ) ); | |
| 8292 | }); | |
| 8293 | } | |
| 8294 | ||
| 8295 | if ( proceed ) { | |
| 8296 | // The disjuncti on here is for bette r compress ibility (s ee removeC lass) | |
| 8297 | classe s = ( valu e || "" ). match( rno twhite ) | | []; | |
| 8298 | ||
| 8299 | for ( ; i < len; i++ ) { | |
| 8300 | elem = t his[ i ]; | |
| 8301 | cur = el em.nodeTyp e === 1 && ( elem.cl assName ? | |
| 8302 | ( " " + el em.classNa me + " " ) .replace( rclass, " " ) : | |
| 8303 | " " | |
| 8304 | ); | |
| 8305 | ||
| 8306 | if ( cur ) { | |
| 8307 | j = 0; | |
| 8308 | while ( (c lazz = cla sses[j++]) ) { | |
| 8309 | if ( cur.ind exOf( " " + clazz + " " ) < 0 ) { | |
| 8310 | cur += clazz + " "; | |
| 8311 | } | |
| 8312 | } | |
| 8313 | ||
| 8314 | // only as sign if di fferent to avoid unn eeded rend ering. | |
| 8315 | finalValue = jQuery. trim( cur ); | |
| 8316 | if ( elem. className !== finalV alue ) { | |
| 8317 | el em.classNa me = final Value; | |
| 8318 | } | |
| 8319 | } | |
| 8320 | } | |
| 8321 | } | |
| 8322 | ||
| 8323 | retu rn this; | |
| 8324 | }, | |
| 8325 | ||
| 8326 | re moveClass: function( value ) { | |
| 8327 | var classes, e lem, cur, clazz, j, finalValue , | |
| 8328 | i = 0, | |
| 8329 | len = this.lengt h, | |
| 8330 | procee d = argume nts.length === 0 || typeof val ue === "st ring" && v alue; | |
| 8331 | ||
| 8332 | if ( jQuery.is Function( value ) ) { | |
| 8333 | return this.each (function( j ) { | |
| 8334 | jQuery( this ).rem oveClass( value.call ( this, j, this.clas sName ) ); | |
| 8335 | }); | |
| 8336 | } | |
| 8337 | if ( proceed ) { | |
| 8338 | classe s = ( valu e || "" ). match( rno twhite ) | | []; | |
| 8339 | ||
| 8340 | for ( ; i < len; i++ ) { | |
| 8341 | elem = t his[ i ]; | |
| 8342 | // This expression is here f or better compressib ility (see addClass) | |
| 8343 | cur = el em.nodeTyp e === 1 && ( elem.cl assName ? | |
| 8344 | ( " " + el em.classNa me + " " ) .replace( rclass, " " ) : | |
| 8345 | "" | |
| 8346 | ); | |
| 8347 | ||
| 8348 | if ( cur ) { | |
| 8349 | j = 0; | |
| 8350 | while ( (c lazz = cla sses[j++]) ) { | |
| 8351 | // Remove *a ll* instan ces | |
| 8352 | wh ile ( cur. indexOf( " " + clazz + " " ) > = 0 ) { | |
| 8353 | cur = cur.repl ace( " " + clazz + " ", " " ); | |
| 8354 | } | |
| 8355 | } | |
| 8356 | ||
| 8357 | // only as sign if di fferent to avoid unn eeded rend ering. | |
| 8358 | finalValue = value ? jQuery.tr im( cur ) : ""; | |
| 8359 | if ( elem. className !== finalV alue ) { | |
| 8360 | el em.classNa me = final Value; | |
| 8361 | } | |
| 8362 | } | |
| 8363 | } | |
| 8364 | } | |
| 8365 | ||
| 8366 | retu rn this; | |
| 8367 | }, | |
| 8368 | ||
| 8369 | to ggleClass: function( value, st ateVal ) { | |
| 8370 | var type = typ eof value; | |
| 8371 | ||
| 8372 | if ( typeof st ateVal === "boolean" && type = == "string " ) { | |
| 8373 | return stateVal ? this.add Class( val ue ) : thi s.removeCl ass( value ); | |
| 8374 | } | |
| 8375 | ||
| 8376 | if ( jQuery.is Function( value ) ) { | |
| 8377 | return this.each (function( i ) { | |
| 8378 | jQuery( this ).tog gleClass( value.call (this, i, this.class Name, stat eVal), sta teVal ); | |
| 8379 | }); | |
| 8380 | } | |
| 8381 | ||
| 8382 | retu rn this.ea ch(functio n() { | |
| 8383 | if ( t ype === "s tring" ) { | |
| 8384 | // toggl e individu al class n ames | |
| 8385 | var clas sName, | |
| 8386 | i = 0, | |
| 8387 | self = jQu ery( this ), | |
| 8388 | classNames = value.m atch( rnot white ) || []; | |
| 8389 | ||
| 8390 | while ( (className = classNa mes[ i++ ] ) ) { | |
| 8391 | // check e ach classN ame given, space sep arated lis t | |
| 8392 | if ( self. hasClass( className ) ) { | |
| 8393 | se lf.removeC lass( clas sName ); | |
| 8394 | } else { | |
| 8395 | se lf.addClas s( classNa me ); | |
| 8396 | } | |
| 8397 | } | |
| 8398 | ||
| 8399 | // Tog gle whole class name | |
| 8400 | } else if ( type === strun defined || type === "boolean" ) { | |
| 8401 | if ( thi s.classNam e ) { | |
| 8402 | // store c lassName i f set | |
| 8403 | jQuery._da ta( this, "__classNa me__", thi s.classNam e ); | |
| 8404 | } | |
| 8405 | ||
| 8406 | // If th e element has a clas s name or if we're p assed "fal se", | |
| 8407 | // then remove the whole cla ssname (if there was one, the above save d it). | |
| 8408 | // Other wise bring back what ever was p reviously saved (if anything), | |
| 8409 | // falli ng back to the empty string if nothing w as stored. | |
| 8410 | this.cla ssName = t his.classN ame || val ue === fal se ? "" : jQuery._da ta( this, "__classNa me__" ) || ""; | |
| 8411 | } | |
| 8412 | }); | |
| 8413 | }, | |
| 8414 | ||
| 8415 | ha sClass: fu nction( se lector ) { | |
| 8416 | var className = " " + se lector + " ", | |
| 8417 | i = 0, | |
| 8418 | l = th is.length; | |
| 8419 | for ( ; i < l; i++ ) { | |
| 8420 | if ( t his[i].nod eType === 1 && (" " + this[i]. className + " ").rep lace(rclas s, " ").in dexOf( cla ssName ) > = 0 ) { | |
| 8421 | return t rue; | |
| 8422 | } | |
| 8423 | } | |
| 8424 | ||
| 8425 | retu rn false; | |
| 8426 | } | |
| 8427 | }); | |
| 8428 | ||
| 8429 | ||
| 8430 | ||
| 8431 | ||
| 8432 | // Return jQuery for attribute s-only inc lusion | |
| 8433 | ||
| 8434 | ||
| 8435 | jQuery.eac h( ("blur focus focu sin focuso ut load re size scrol l unload c lick dblcl ick " + | |
| 8436 | "m ousedown m ouseup mou semove mou seover mou seout mous eenter mou seleave " + | |
| 8437 | "c hange sele ct submit keydown ke ypress key up error c ontextmenu ").split(" "), funct ion( i, na me ) { | |
| 8438 | ||
| 8439 | // Handle ev ent bindin g | |
| 8440 | jQ uery.fn[ n ame ] = fu nction( da ta, fn ) { | |
| 8441 | retu rn argumen ts.length > 0 ? | |
| 8442 | this.o n( name, n ull, data, fn ) : | |
| 8443 | this.t rigger( na me ); | |
| 8444 | }; | |
| 8445 | }); | |
| 8446 | ||
| 8447 | jQuery.fn. extend({ | |
| 8448 | ho ver: funct ion( fnOve r, fnOut ) { | |
| 8449 | retu rn this.mo useenter( fnOver ).m ouseleave( fnOut || fnOver ); | |
| 8450 | }, | |
| 8451 | ||
| 8452 | bi nd: functi on( types, data, fn ) { | |
| 8453 | retu rn this.on ( types, n ull, data, fn ); | |
| 8454 | }, | |
| 8455 | un bind: func tion( type s, fn ) { | |
| 8456 | retu rn this.of f( types, null, fn ) ; | |
| 8457 | }, | |
| 8458 | ||
| 8459 | de legate: fu nction( se lector, ty pes, data, fn ) { | |
| 8460 | retu rn this.on ( types, s elector, d ata, fn ); | |
| 8461 | }, | |
| 8462 | un delegate: function( selector, types, fn ) { | |
| 8463 | // ( namespace ) or ( se lector, ty pes [, fn] ) | |
| 8464 | retu rn argumen ts.length === 1 ? th is.off( se lector, "* *" ) : thi s.off( typ es, select or || "**" , fn ); | |
| 8465 | } | |
| 8466 | }); | |
| 8467 | ||
| 8468 | ||
| 8469 | var nonce = jQuery.n ow(); | |
| 8470 | ||
| 8471 | var rquery = (/\?/); | |
| 8472 | ||
| 8473 | ||
| 8474 | ||
| 8475 | var rvalid tokens = / (,)|(\[|{) |(}|])|"(? :[^"\\\r\n ]|\\["\\\/ bfnrt]|\\u [\da-fA-F] {4})*"\s*: ?|true|fal se|null|-? (?!0\d)\d+ (?:\.\d+|) (?:[eE][+- ]?\d+|)/g; | |
| 8476 | ||
| 8477 | jQuery.par seJSON = f unction( d ata ) { | |
| 8478 | // Attempt t o parse us ing the na tive JSON parser fir st | |
| 8479 | if ( window. JSON && wi ndow.JSON. parse ) { | |
| 8480 | // S upport: An droid 2.3 | |
| 8481 | // W orkaround failure to string-ca st null in put | |
| 8482 | retu rn window. JSON.parse ( data + " " ); | |
| 8483 | } | |
| 8484 | ||
| 8485 | va r requireN onComma, | |
| 8486 | dept h = null, | |
| 8487 | str = jQuery.t rim( data + "" ); | |
| 8488 | ||
| 8489 | // Guard aga inst inval id (and po ssibly dan gerous) in put by ens uring that nothing r emains | |
| 8490 | // after rem oving vali d tokens | |
| 8491 | re turn str & & !jQuery. trim( str. replace( r validtoken s, functio n( token, comma, ope n, close ) { | |
| 8492 | ||
| 8493 | // F orce termi nation if we see a m isplaced c omma | |
| 8494 | if ( requireNo nComma && comma ) { | |
| 8495 | depth = 0; | |
| 8496 | } | |
| 8497 | ||
| 8498 | // P erform no more repla cements af ter return ing to out ermost dep th | |
| 8499 | if ( depth === 0 ) { | |
| 8500 | return token; | |
| 8501 | } | |
| 8502 | ||
| 8503 | // C ommas must not follo w "[", "{" , or "," | |
| 8504 | requ ireNonComm a = open | | comma; | |
| 8505 | ||
| 8506 | // D etermine n ew depth | |
| 8507 | // a rray/objec t open ("[ " or "{"): depth += true - fal se (increm ent) | |
| 8508 | // a rray/objec t close (" ]" or "}") : depth += false - t rue (decre ment) | |
| 8509 | // o ther cases ("," or p rimitive): depth += true - tru e (numeric cast) | |
| 8510 | dept h += !clos e - !open; | |
| 8511 | ||
| 8512 | // R emove this token | |
| 8513 | retu rn ""; | |
| 8514 | }) ) ? | |
| 8515 | ( Fu nction( "r eturn " + str ) )() : | |
| 8516 | jQue ry.error( "Invalid J SON: " + d ata ); | |
| 8517 | }; | |
| 8518 | ||
| 8519 | ||
| 8520 | // Cross-b rowser xml parsing | |
| 8521 | jQuery.par seXML = fu nction( da ta ) { | |
| 8522 | va r xml, tmp ; | |
| 8523 | if ( !data | | typeof d ata !== "s tring" ) { | |
| 8524 | retu rn null; | |
| 8525 | } | |
| 8526 | tr y { | |
| 8527 | if ( window.DO MParser ) { // Stand ard | |
| 8528 | tmp = new DOMPar ser(); | |
| 8529 | xml = tmp.parseF romString( data, "te xt/xml" ); | |
| 8530 | } el se { // IE | |
| 8531 | xml = new Active XObject( " Microsoft. XMLDOM" ); | |
| 8532 | xml.as ync = "fal se"; | |
| 8533 | xml.lo adXML( dat a ); | |
| 8534 | } | |
| 8535 | } catch( e ) { | |
| 8536 | xml = undefine d; | |
| 8537 | } | |
| 8538 | if ( !xml || !xml.docu mentElemen t || xml.g etElements ByTagName( "parserer ror" ).len gth ) { | |
| 8539 | jQue ry.error( "Invalid X ML: " + da ta ); | |
| 8540 | } | |
| 8541 | re turn xml; | |
| 8542 | }; | |
| 8543 | ||
| 8544 | ||
| 8545 | var | |
| 8546 | // Document location | |
| 8547 | aj axLocParts , | |
| 8548 | aj axLocation , | |
| 8549 | ||
| 8550 | rh ash = /#.* $/, | |
| 8551 | rt s = /([?&] )_=[^&]*/, | |
| 8552 | rh eaders = / ^(.*?):[ \ t]*([^\r\n ]*)\r?$/mg , // IE le aves an \r character at EOL | |
| 8553 | // #7653, #8 125, #8152 : local pr otocol det ection | |
| 8554 | rl ocalProtoc ol = /^(?: about|app| app-storag e|.+-exten sion|file| res|widget ):$/, | |
| 8555 | rn oContent = /^(?:GET| HEAD)$/, | |
| 8556 | rp rotocol = /^\/\//, | |
| 8557 | ru rl = /^([\ w.+-]+:)(? :\/\/(?:[^ \/?#]*@|)( [^\/?#:]*) (?::(\d+)| )|)/, | |
| 8558 | ||
| 8559 | /* Prefilter s | |
| 8560 | * 1) They a re useful to introdu ce custom dataTypes (see ajax/ jsonp.js f or an exam ple) | |
| 8561 | * 2) These are called : | |
| 8562 | * - BEFO RE asking for a tran sport | |
| 8563 | * - AFTE R param se rializatio n (s.data is a strin g if s.pro cessData i s true) | |
| 8564 | * 3) key is the dataT ype | |
| 8565 | * 4) the ca tchall sym bol "*" ca n be used | |
| 8566 | * 5) execut ion will s tart with transport dataType a nd THEN co ntinue dow n to "*" i f needed | |
| 8567 | * / | |
| 8568 | pr efilters = {}, | |
| 8569 | ||
| 8570 | /* Transport s bindings | |
| 8571 | * 1) key is the dataT ype | |
| 8572 | * 2) the ca tchall sym bol "*" ca n be used | |
| 8573 | * 3) select ion will s tart with transport dataType a nd THEN go to "*" if needed | |
| 8574 | * / | |
| 8575 | tr ansports = {}, | |
| 8576 | ||
| 8577 | // Avoid com ment-prolo g char seq uence (#10 098); must appease l int and ev ade compre ssion | |
| 8578 | al lTypes = " */".concat ("*"); | |
| 8579 | ||
| 8580 | // #8138, IE may thr ow an exce ption when accessing | |
| 8581 | // a field from wind ow.locatio n if docum ent.domain has been set | |
| 8582 | try { | |
| 8583 | aj axLocation = locatio n.href; | |
| 8584 | } catch( e ) { | |
| 8585 | // Use the h ref attrib ute of an A element | |
| 8586 | // since IE will modif y it given document. location | |
| 8587 | aj axLocation = documen t.createEl ement( "a" ); | |
| 8588 | aj axLocation .href = "" ; | |
| 8589 | aj axLocation = ajaxLoc ation.href ; | |
| 8590 | } | |
| 8591 | ||
| 8592 | // Segment location into parts | |
| 8593 | ajaxLocPar ts = rurl. exec( ajax Location.t oLowerCase () ) || [] ; | |
| 8594 | ||
| 8595 | // Base "c onstructor " for jQue ry.ajaxPre filter and jQuery.aj axTranspor t | |
| 8596 | function a ddToPrefil tersOrTran sports( st ructure ) { | |
| 8597 | ||
| 8598 | // dataTypeE xpression is optiona l and defa ults to "* " | |
| 8599 | re turn funct ion( dataT ypeExpress ion, func ) { | |
| 8600 | ||
| 8601 | if ( typeof da taTypeExpr ession !== "string" ) { | |
| 8602 | func = dataTypeE xpression; | |
| 8603 | dataTy peExpressi on = "*"; | |
| 8604 | } | |
| 8605 | ||
| 8606 | var dataType, | |
| 8607 | i = 0, | |
| 8608 | dataTy pes = data TypeExpres sion.toLow erCase().m atch( rnot white ) || []; | |
| 8609 | ||
| 8610 | if ( jQuery.is Function( func ) ) { | |
| 8611 | // For each data Type in th e dataType Expression | |
| 8612 | while ( (dataTyp e = dataTy pes[i++]) ) { | |
| 8613 | // Prepe nd if requ ested | |
| 8614 | if ( dat aType.char At( 0 ) == = "+" ) { | |
| 8615 | dataType = dataType. slice( 1 ) || "*"; | |
| 8616 | (structure [ dataType ] = struc ture[ data Type ] || []).unshif t( func ); | |
| 8617 | ||
| 8618 | // Other wise appen d | |
| 8619 | } else { | |
| 8620 | (structure [ dataType ] = struc ture[ data Type ] || []).push( func ); | |
| 8621 | } | |
| 8622 | } | |
| 8623 | } | |
| 8624 | }; | |
| 8625 | } | |
| 8626 | ||
| 8627 | // Base in spection f unction fo r prefilte rs and tra nsports | |
| 8628 | function i nspectPref iltersOrTr ansports( structure, options, originalOp tions, jqX HR ) { | |
| 8629 | ||
| 8630 | va r inspecte d = {}, | |
| 8631 | seek ingTranspo rt = ( str ucture === transport s ); | |
| 8632 | ||
| 8633 | fu nction ins pect( data Type ) { | |
| 8634 | var selected; | |
| 8635 | insp ected[ dat aType ] = true; | |
| 8636 | jQue ry.each( s tructure[ dataType ] || [], fu nction( _, prefilter OrFactory ) { | |
| 8637 | var da taTypeOrTr ansport = prefilterO rFactory( options, o riginalOpt ions, jqXH R ); | |
| 8638 | if ( t ypeof data TypeOrTran sport === "string" & & !seeking Transport && !inspec ted[ dataT ypeOrTrans port ] ) { | |
| 8639 | options. dataTypes. unshift( d ataTypeOrT ransport ) ; | |
| 8640 | inspect( dataTypeO rTransport ); | |
| 8641 | return f alse; | |
| 8642 | } else if ( seek ingTranspo rt ) { | |
| 8643 | return ! ( selected = dataTyp eOrTranspo rt ); | |
| 8644 | } | |
| 8645 | }); | |
| 8646 | retu rn selecte d; | |
| 8647 | } | |
| 8648 | ||
| 8649 | re turn inspe ct( option s.dataType s[ 0 ] ) | | !inspect ed[ "*" ] && inspect ( "*" ); | |
| 8650 | } | |
| 8651 | ||
| 8652 | // A speci al extend for ajax o ptions | |
| 8653 | // that ta kes "flat" options ( not to be deep exten ded) | |
| 8654 | // Fixes # 9887 | |
| 8655 | function a jaxExtend( target, s rc ) { | |
| 8656 | va r deep, ke y, | |
| 8657 | flat Options = jQuery.aja xSettings. flatOption s || {}; | |
| 8658 | ||
| 8659 | fo r ( key in src ) { | |
| 8660 | if ( src[ key ] !== unde fined ) { | |
| 8661 | ( flat Options[ k ey ] ? tar get : ( de ep || (dee p = {}) ) )[ key ] = src[ key ]; | |
| 8662 | } | |
| 8663 | } | |
| 8664 | if ( deep ) { | |
| 8665 | jQue ry.extend( true, tar get, deep ); | |
| 8666 | } | |
| 8667 | ||
| 8668 | re turn targe t; | |
| 8669 | } | |
| 8670 | ||
| 8671 | /* Handles responses to an aja x request: | |
| 8672 | * - finds the right dataType (mediates between co ntent-type and expec ted dataTy pe) | |
| 8673 | * - retur ns the cor responding response | |
| 8674 | */ | |
| 8675 | function a jaxHandleR esponses( s, jqXHR, responses ) { | |
| 8676 | va r firstDat aType, ct, finalData Type, type , | |
| 8677 | cont ents = s.c ontents, | |
| 8678 | data Types = s. dataTypes; | |
| 8679 | ||
| 8680 | // Remove au to dataTyp e and get content-ty pe in the process | |
| 8681 | wh ile ( data Types[ 0 ] === "*" ) { | |
| 8682 | data Types.shif t(); | |
| 8683 | if ( ct === un defined ) { | |
| 8684 | ct = s .mimeType || jqXHR.g etResponse Header("Co ntent-Type "); | |
| 8685 | } | |
| 8686 | } | |
| 8687 | ||
| 8688 | // Check if we're deal ing with a known con tent-type | |
| 8689 | if ( ct ) { | |
| 8690 | for ( type in contents ) { | |
| 8691 | if ( c ontents[ t ype ] && c ontents[ t ype ].test ( ct ) ) { | |
| 8692 | dataType s.unshift( type ); | |
| 8693 | break; | |
| 8694 | } | |
| 8695 | } | |
| 8696 | } | |
| 8697 | ||
| 8698 | // Check to see if we have a res ponse for the expect ed dataTyp e | |
| 8699 | if ( dataTyp es[ 0 ] in responses ) { | |
| 8700 | fina lDataType = dataType s[ 0 ]; | |
| 8701 | } else { | |
| 8702 | // T ry convert ible dataT ypes | |
| 8703 | for ( type in responses ) { | |
| 8704 | if ( ! dataTypes[ 0 ] || s. converters [ type + " " + dataT ypes[0] ] ) { | |
| 8705 | finalDat aType = ty pe; | |
| 8706 | break; | |
| 8707 | } | |
| 8708 | if ( ! firstDataT ype ) { | |
| 8709 | firstDat aType = ty pe; | |
| 8710 | } | |
| 8711 | } | |
| 8712 | // O r just use first one | |
| 8713 | fina lDataType = finalDat aType || f irstDataTy pe; | |
| 8714 | } | |
| 8715 | ||
| 8716 | // If we fou nd a dataT ype | |
| 8717 | // We add th e dataType to the li st if need ed | |
| 8718 | // and retur n the corr esponding response | |
| 8719 | if ( finalDa taType ) { | |
| 8720 | if ( finalData Type !== d ataTypes[ 0 ] ) { | |
| 8721 | dataTy pes.unshif t( finalDa taType ); | |
| 8722 | } | |
| 8723 | retu rn respons es[ finalD ataType ]; | |
| 8724 | } | |
| 8725 | } | |
| 8726 | ||
| 8727 | /* Chain c onversions given the request a nd the ori ginal resp onse | |
| 8728 | * Also se ts the res ponseXXX f ields on t he jqXHR i nstance | |
| 8729 | */ | |
| 8730 | function a jaxConvert ( s, respo nse, jqXHR , isSucces s ) { | |
| 8731 | va r conv2, c urrent, co nv, tmp, p rev, | |
| 8732 | conv erters = { }, | |
| 8733 | // W ork with a copy of d ataTypes i n case we need to mo dify it fo r conversi on | |
| 8734 | data Types = s. dataTypes. slice(); | |
| 8735 | ||
| 8736 | // Create co nverters m ap with lo wercased k eys | |
| 8737 | if ( dataTyp es[ 1 ] ) { | |
| 8738 | for ( conv in s.converte rs ) { | |
| 8739 | conver ters[ conv .toLowerCa se() ] = s .converter s[ conv ]; | |
| 8740 | } | |
| 8741 | } | |
| 8742 | ||
| 8743 | cu rrent = da taTypes.sh ift(); | |
| 8744 | ||
| 8745 | // Convert t o each seq uential da taType | |
| 8746 | wh ile ( curr ent ) { | |
| 8747 | ||
| 8748 | if ( s.respons eFields[ c urrent ] ) { | |
| 8749 | jqXHR[ s.respons eFields[ c urrent ] ] = respons e; | |
| 8750 | } | |
| 8751 | ||
| 8752 | // A pply the d ataFilter if provide d | |
| 8753 | if ( !prev && isSuccess && s.dataF ilter ) { | |
| 8754 | respon se = s.dat aFilter( r esponse, s .dataType ); | |
| 8755 | } | |
| 8756 | ||
| 8757 | prev = current ; | |
| 8758 | curr ent = data Types.shif t(); | |
| 8759 | ||
| 8760 | if ( current ) { | |
| 8761 | ||
| 8762 | // The re's only work to do if curren t dataType is non-au to | |
| 8763 | if ( c urrent === "*" ) { | |
| 8764 | ||
| 8765 | current = prev; | |
| 8766 | ||
| 8767 | // Con vert respo nse if pre v dataType is non-au to and dif fers from current | |
| 8768 | } else if ( prev !== "*" & & prev !== current ) { | |
| 8769 | ||
| 8770 | // Seek a direct c onverter | |
| 8771 | conv = c onverters[ prev + " " + curren t ] || con verters[ " * " + curr ent ]; | |
| 8772 | ||
| 8773 | // If no ne found, seek a pai r | |
| 8774 | if ( !co nv ) { | |
| 8775 | for ( conv 2 in conve rters ) { | |
| 8776 | ||
| 8777 | // If conv2 outputs cu rrent | |
| 8778 | tm p = conv2. split( " " ); | |
| 8779 | if ( tmp[ 1 ] === curr ent ) { | |
| 8780 | ||
| 8781 | // I f prev can be conver ted to acc epted inpu t | |
| 8782 | conv = convert ers[ prev + " " + tm p[ 0 ] ] | | | |
| 8783 | conver ters[ "* " + tmp[ 0 ] ]; | |
| 8784 | if ( conv ) { | |
| 8785 | // Con dense equi valence co nverters | |
| 8786 | if ( c onv === tr ue ) { | |
| 8787 | conv = c onverters[ conv2 ]; | |
| 8788 | ||
| 8789 | // Oth erwise, in sert the i ntermediat e dataType | |
| 8790 | } else if ( conv erters[ co nv2 ] !== true ) { | |
| 8791 | current = tmp[ 0 ] ; | |
| 8792 | dataType s.unshift( tmp[ 1 ] ); | |
| 8793 | } | |
| 8794 | break; | |
| 8795 | } | |
| 8796 | } | |
| 8797 | } | |
| 8798 | } | |
| 8799 | ||
| 8800 | // Apply converter (if not a n equivale nce) | |
| 8801 | if ( con v !== true ) { | |
| 8802 | ||
| 8803 | // Unless errors are allowed t o bubble, catch and return the m | |
| 8804 | if ( conv && s[ "thr ows" ] ) { | |
| 8805 | re sponse = c onv( respo nse ); | |
| 8806 | } else { | |
| 8807 | tr y { | |
| 8808 | resp onse = con v( respons e ); | |
| 8809 | } catch ( e ) { | |
| 8810 | retu rn { state : "parsere rror", err or: conv ? e : "No c onversion from " + p rev + " to " + curre nt }; | |
| 8811 | } | |
| 8812 | } | |
| 8813 | } | |
| 8814 | } | |
| 8815 | } | |
| 8816 | } | |
| 8817 | ||
| 8818 | re turn { sta te: "succe ss", data: response }; | |
| 8819 | } | |
| 8820 | ||
| 8821 | jQuery.ext end({ | |
| 8822 | ||
| 8823 | // Counter f or holding the numbe r of activ e queries | |
| 8824 | ac tive: 0, | |
| 8825 | ||
| 8826 | // Last-Modi fied heade r cache fo r next req uest | |
| 8827 | la stModified : {}, | |
| 8828 | et ag: {}, | |
| 8829 | ||
| 8830 | aj axSettings : { | |
| 8831 | url: ajaxLocat ion, | |
| 8832 | type : "GET", | |
| 8833 | isLo cal: rloca lProtocol. test( ajax LocParts[ 1 ] ), | |
| 8834 | glob al: true, | |
| 8835 | proc essData: t rue, | |
| 8836 | asyn c: true, | |
| 8837 | cont entType: " applicatio n/x-www-fo rm-urlenco ded; chars et=UTF-8", | |
| 8838 | /* | |
| 8839 | time out: 0, | |
| 8840 | data : null, | |
| 8841 | data Type: null , | |
| 8842 | V s ID
|
|
| 8843 | V s ID
|
|
| 8844 | cach e: null, | |
| 8845 | thro ws: false, | |
| 8846 | trad itional: f alse, | |
| 8847 | head ers: {}, | |
| 8848 | */ | |
| 8849 | ||
| 8850 | acce pts: { | |
| 8851 | "*": a llTypes, | |
| 8852 | text: "text/plai n", | |
| 8853 | html: "text/html ", | |
| 8854 | xml: " applicatio n/xml, tex t/xml", | |
| 8855 | json: "applicati on/json, t ext/javasc ript" | |
| 8856 | }, | |
| 8857 | ||
| 8858 | cont ents: { | |
| 8859 | xml: / xml/, | |
| 8860 | html: /html/, | |
| 8861 | json: /json/ | |
| 8862 | }, | |
| 8863 | ||
| 8864 | resp onseFields : { | |
| 8865 | xml: " responseXM L", | |
| 8866 | text: "responseT ext", | |
| 8867 | json: "responseJ SON" | |
| 8868 | }, | |
| 8869 | ||
| 8870 | // D ata conver ters | |
| 8871 | // K eys separa te source (or catcha ll "*") an d destinat ion types with a sin gle space | |
| 8872 | conv erters: { | |
| 8873 | ||
| 8874 | // Con vert anyth ing to tex t | |
| 8875 | "* tex t": String , | |
| 8876 | ||
| 8877 | // Tex t to html (true = no transform ation) | |
| 8878 | "text html": tru e, | |
| 8879 | ||
| 8880 | // Eva luate text as a json expressio n | |
| 8881 | "text json": jQu ery.parseJ SON, | |
| 8882 | ||
| 8883 | // Par se text as xml | |
| 8884 | "text xml": jQue ry.parseXM L | |
| 8885 | }, | |
| 8886 | ||
| 8887 | // F or options that shou ldn't be d eep extend ed: | |
| 8888 | // y ou can add your own custom opt ions here if | |
| 8889 | // a nd when yo u create o ne that sh ouldn't be | |
| 8890 | // d eep extend ed (see aj axExtend) | |
| 8891 | flat Options: { | |
| 8892 | url: t rue, | |
| 8893 | contex t: true | |
| 8894 | } | |
| 8895 | }, | |
| 8896 | ||
| 8897 | // Creates a full fled ged settin gs object into targe t | |
| 8898 | // with both ajaxSetti ngs and se ttings fie lds. | |
| 8899 | // If target is omitte d, writes into ajaxS ettings. | |
| 8900 | aj axSetup: f unction( t arget, set tings ) { | |
| 8901 | retu rn setting s ? | |
| 8902 | ||
| 8903 | // Bui lding a se ttings obj ect | |
| 8904 | ajaxEx tend( ajax Extend( ta rget, jQue ry.ajaxSet tings ), s ettings ) : | |
| 8905 | ||
| 8906 | // Ext ending aja xSettings | |
| 8907 | ajaxEx tend( jQue ry.ajaxSet tings, tar get ); | |
| 8908 | }, | |
| 8909 | ||
| 8910 | aj axPrefilte r: addToPr efiltersOr Transports ( prefilte rs ), | |
| 8911 | aj axTranspor t: addToPr efiltersOr Transports ( transpor ts ), | |
| 8912 | ||
| 8913 | // Main meth od | |
| 8914 | aj ax: functi on( url, o ptions ) { | |
| 8915 | ||
| 8916 | // I f url is a n object, simulate p re-1.5 sig nature | |
| 8917 | if ( typeof ur l === "obj ect" ) { | |
| 8918 | option s = url; | |
| 8919 | url = undefined; | |
| 8920 | } | |
| 8921 | ||
| 8922 | // F orce optio ns to be a n object | |
| 8923 | opti ons = opti ons || {}; | |
| 8924 | ||
| 8925 | var // Cross-d omain dete ction vars | |
| 8926 | parts, | |
| 8927 | // Loo p variable | |
| 8928 | i, | |
| 8929 | // URL without a nti-cache param | |
| 8930 | cacheU RL, | |
| 8931 | // Res ponse head ers as str ing | |
| 8932 | respon seHeadersS tring, | |
| 8933 | // tim eout handl e | |
| 8934 | timeou tTimer, | |
| 8935 | ||
| 8936 | // To know if gl obal event s are to b e dispatch ed | |
| 8937 | fireGl obals, | |
| 8938 | ||
| 8939 | transp ort, | |
| 8940 | // Res ponse head ers | |
| 8941 | respon seHeaders, | |
| 8942 | // Cre ate the fi nal option s object | |
| 8943 | s = jQ uery.ajaxS etup( {}, options ), | |
| 8944 | // Cal lbacks con text | |
| 8945 | callba ckContext = s.contex t || s, | |
| 8946 | // Con text for g lobal even ts is call backContex t if it is a DOM nod e or jQuer y collecti on | |
| 8947 | global EventConte xt = s.con text && ( callbackCo ntext.node Type || ca llbackCont ext.jquery ) ? | |
| 8948 | jQuery( callbackCo ntext ) : | |
| 8949 | jQuery.e vent, | |
| 8950 | // Def erreds | |
| 8951 | deferr ed = jQuer y.Deferred (), | |
| 8952 | comple teDeferred = jQuery. Callbacks( "once memo ry"), | |
| 8953 | // Sta tus-depend ent callba cks | |
| 8954 | status Code = s.s tatusCode || {}, | |
| 8955 | // Hea ders (they are sent all at onc e) | |
| 8956 | reques tHeaders = {}, | |
| 8957 | reques tHeadersNa mes = {}, | |
| 8958 | // The jqXHR sta te | |
| 8959 | state = 0, | |
| 8960 | // Def ault abort message | |
| 8961 | strAbo rt = "canc eled", | |
| 8962 | // Fak e xhr | |
| 8963 | jqXHR = { | |
| 8964 | readySta te: 0, | |
| 8965 | ||
| 8966 | // Build s headers hashtable if needed | |
| 8967 | getRespo nseHeader: function( key ) { | |
| 8968 | var match; | |
| 8969 | if ( state === 2 ) { | |
| 8970 | if ( !respon seHeaders ) { | |
| 8971 | resp onseHeader s = {}; | |
| 8972 | whil e ( (match = rheader s.exec( re sponseHead ersString )) ) { | |
| 8973 | respon seHeaders[ match[1]. toLowerCas e() ] = ma tch[ 2 ]; | |
| 8974 | } | |
| 8975 | } | |
| 8976 | ma tch = resp onseHeader s[ key.toL owerCase() ]; | |
| 8977 | } | |
| 8978 | return mat ch == null ? null : match; | |
| 8979 | }, | |
| 8980 | ||
| 8981 | // Raw s tring | |
| 8982 | getAllRe sponseHead ers: funct ion() { | |
| 8983 | return sta te === 2 ? responseH eadersStri ng : null; | |
| 8984 | }, | |
| 8985 | ||
| 8986 | // Cache s the head er | |
| 8987 | setReque stHeader: function( name, valu e ) { | |
| 8988 | var lname = name.toL owerCase() ; | |
| 8989 | if ( !stat e ) { | |
| 8990 | na me = reque stHeadersN ames[ lnam e ] = requ estHeaders Names[ lna me ] || na me; | |
| 8991 | re questHeade rs[ name ] = value; | |
| 8992 | } | |
| 8993 | return thi s; | |
| 8994 | }, | |
| 8995 | ||
| 8996 | // Overr ides respo nse conten t-type hea der | |
| 8997 | override MimeType: function( type ) { | |
| 8998 | if ( !stat e ) { | |
| 8999 | s. mimeType = type; | |
| 9000 | } | |
| 9001 | return thi s; | |
| 9002 | }, | |
| 9003 | ||
| 9004 | // Statu s-dependen t callback s | |
| 9005 | statusCo de: functi on( map ) { | |
| 9006 | var code; | |
| 9007 | if ( map ) { | |
| 9008 | if ( state < 2 ) { | |
| 9009 | for ( code in map ) { | |
| 9010 | // Laz y-add the new callba ck in a wa y that pre serves old ones | |
| 9011 | status Code[ code ] = [ sta tusCode[ c ode ], map [ code ] ] ; | |
| 9012 | } | |
| 9013 | } else { | |
| 9014 | // E xecute the appropria te callbac ks | |
| 9015 | jqXH R.always( map[ jqXHR .status ] ); | |
| 9016 | } | |
| 9017 | } | |
| 9018 | return thi s; | |
| 9019 | }, | |
| 9020 | ||
| 9021 | // Cance l the requ est | |
| 9022 | abort: f unction( s tatusText ) { | |
| 9023 | var finalT ext = stat usText || strAbort; | |
| 9024 | if ( trans port ) { | |
| 9025 | tr ansport.ab ort( final Text ); | |
| 9026 | } | |
| 9027 | done( 0, f inalText ) ; | |
| 9028 | return thi s; | |
| 9029 | } | |
| 9030 | }; | |
| 9031 | ||
| 9032 | // A ttach defe rreds | |
| 9033 | defe rred.promi se( jqXHR ).complete = complet eDeferred. add; | |
| 9034 | jqXH R.success = jqXHR.do ne; | |
| 9035 | jqXH R.error = jqXHR.fail ; | |
| 9036 | ||
| 9037 | // R emove hash character (#7531: a nd string promotion) | |
| 9038 | // A dd protoco l if not p rovided (# 5866: IE7 issue with protocol- less urls) | |
| 9039 | // H andle fals y url in t he setting s object ( #10093: co nsistency with old s ignature) | |
| 9040 | // W e also use the url p arameter i f availabl e | |
| 9041 | s.ur l = ( ( ur l || s.url || ajaxLo cation ) + "" ).repl ace( rhash , "" ).rep lace( rpro tocol, aja xLocParts[ 1 ] + "// " ); | |
| 9042 | ||
| 9043 | // A lias metho d option t o type as per ticket #12004 | |
| 9044 | s.ty pe = optio ns.method || options .type || s .method || s.type; | |
| 9045 | ||
| 9046 | // E xtract dat aTypes lis t | |
| 9047 | s.da taTypes = jQuery.tri m( s.dataT ype || "*" ).toLower Case().mat ch( rnotwh ite ) || [ "" ]; | |
| 9048 | ||
| 9049 | // A cross-dom ain reques t is in or der when w e have a p rotocol:ho st:port mi smatch | |
| 9050 | if ( s.crossDo main == nu ll ) { | |
| 9051 | parts = rurl.exe c( s.url.t oLowerCase () ); | |
| 9052 | s.cros sDomain = !!( parts && | |
| 9053 | ( parts[ 1 ] !== a jaxLocPart s[ 1 ] || parts[ 2 ] !== ajaxL ocParts[ 2 ] || | |
| 9054 | ( parts[ 3 ] || ( pa rts[ 1 ] = == "http:" ? "80" : "443" ) ) !== | |
| 9055 | ( ajaxLocPar ts[ 3 ] || ( ajaxLoc Parts[ 1 ] === "http :" ? "80" : "443" ) ) ) | |
| 9056 | ); | |
| 9057 | } | |
| 9058 | ||
| 9059 | // C onvert dat a if not a lready a s tring | |
| 9060 | if ( s.data && s.process Data && ty peof s.dat a !== "str ing" ) { | |
| 9061 | s.data = jQuery. param( s.d ata, s.tra ditional ) ; | |
| 9062 | } | |
| 9063 | ||
| 9064 | // A pply prefi lters | |
| 9065 | insp ectPrefilt ersOrTrans ports( pre filters, s , options, jqXHR ); | |
| 9066 | ||
| 9067 | // I f request was aborte d inside a prefilter , stop the re | |
| 9068 | if ( state === 2 ) { | |
| 9069 | return jqXHR; | |
| 9070 | } | |
| 9071 | ||
| 9072 | // W e can fire global ev ents as of now if as ked to | |
| 9073 | fire Globals = s.global; | |
| 9074 | ||
| 9075 | // W atch for a new set o f requests | |
| 9076 | if ( fireGloba ls && jQue ry.active+ + === 0 ) { | |
| 9077 | jQuery .event.tri gger("ajax Start"); | |
| 9078 | } | |
| 9079 | ||
| 9080 | // U ppercase t he type | |
| 9081 | s.ty pe = s.typ e.toUpperC ase(); | |
| 9082 | ||
| 9083 | // D etermine i f request has conten t | |
| 9084 | s.ha sContent = !rnoConte nt.test( s .type ); | |
| 9085 | ||
| 9086 | // S ave the UR L in case we're toyi ng with th e If-Modif ied-Since | |
| 9087 | // a nd/or If-N one-Match header lat er on | |
| 9088 | cach eURL = s.u rl; | |
| 9089 | ||
| 9090 | // M ore option s handling for reque sts with n o content | |
| 9091 | if ( !s.hasCon tent ) { | |
| 9092 | ||
| 9093 | // If data is av ailable, a ppend data to url | |
| 9094 | if ( s .data ) { | |
| 9095 | cacheURL = ( s.url += ( rque ry.test( c acheURL ) ? "&" : "? " ) + s.da ta ); | |
| 9096 | // #9682 : remove d ata so tha t it's not used in a n eventual retry | |
| 9097 | delete s .data; | |
| 9098 | } | |
| 9099 | ||
| 9100 | // Add anti-cach e in url i f needed | |
| 9101 | if ( s .cache === false ) { | |
| 9102 | s.url = rts.test( cacheURL ) ? | |
| 9103 | ||
| 9104 | // If ther e is alrea dy a '_' p arameter, set its va lue | |
| 9105 | cacheURL.r eplace( rt s, "$1_=" + nonce++ ) : | |
| 9106 | ||
| 9107 | // Otherwi se add one to the en d | |
| 9108 | cacheURL + ( rquery. test( cach eURL ) ? " &" : "?" ) + "_=" + nonce++; | |
| 9109 | } | |
| 9110 | } | |
| 9111 | ||
| 9112 | // S et the If- Modified-S ince and/o r If-None- Match head er, if in ifModified mode. | |
| 9113 | if ( s.ifModif ied ) { | |
| 9114 | if ( j Query.last Modified[ cacheURL ] ) { | |
| 9115 | jqXHR.se tRequestHe ader( "If- Modified-S ince", jQu ery.lastMo dified[ ca cheURL ] ) ; | |
| 9116 | } | |
| 9117 | if ( j Query.etag [ cacheURL ] ) { | |
| 9118 | jqXHR.se tRequestHe ader( "If- None-Match ", jQuery. etag[ cach eURL ] ); | |
| 9119 | } | |
| 9120 | } | |
| 9121 | ||
| 9122 | // S et the cor rect heade r, if data is being sent | |
| 9123 | if ( s.data && s.hasCont ent && s.c ontentType !== false || option s.contentT ype ) { | |
| 9124 | jqXHR. setRequest Header( "C ontent-Typ e", s.cont entType ); | |
| 9125 | } | |
| 9126 | ||
| 9127 | // S et the Acc epts heade r for the server, de pending on the dataT ype | |
| 9128 | jqXH R.setReque stHeader( | |
| 9129 | "Accep t", | |
| 9130 | s.data Types[ 0 ] && s.acce pts[ s.dat aTypes[0] ] ? | |
| 9131 | s.accept s[ s.dataT ypes[0] ] + ( s.data Types[ 0 ] !== "*" ? ", " + al lTypes + " ; q=0.01" : "" ) : | |
| 9132 | s.accept s[ "*" ] | |
| 9133 | ); | |
| 9134 | ||
| 9135 | // C heck for h eaders opt ion | |
| 9136 | for ( i in s.h eaders ) { | |
| 9137 | jqXHR. setRequest Header( i, s.headers [ i ] ); | |
| 9138 | } | |
| 9139 | ||
| 9140 | // A llow custo m headers/ mimetypes and early abort | |
| 9141 | if ( s.beforeS end && ( s .beforeSen d.call( ca llbackCont ext, jqXHR , s ) === false || s tate === 2 ) ) { | |
| 9142 | // Abo rt if not done alrea dy and ret urn | |
| 9143 | return jqXHR.abo rt(); | |
| 9144 | } | |
| 9145 | ||
| 9146 | // a borting is no longer a cancell ation | |
| 9147 | strA bort = "ab ort"; | |
| 9148 | ||
| 9149 | // I nstall cal lbacks on deferreds | |
| 9150 | for ( i in { s uccess: 1, error: 1, complete: 1 } ) { | |
| 9151 | jqXHR[ i ]( s[ i ] ); | |
| 9152 | } | |
| 9153 | ||
| 9154 | // G et transpo rt | |
| 9155 | tran sport = in spectPrefi ltersOrTra nsports( t ransports, s, option s, jqXHR ) ; | |
| 9156 | ||
| 9157 | // I f no trans port, we a uto-abort | |
| 9158 | if ( !transpor t ) { | |
| 9159 | done( -1, "No Tr ansport" ) ; | |
| 9160 | } el se { | |
| 9161 | jqXHR. readyState = 1; | |
| 9162 | ||
| 9163 | // Sen d global e vent | |
| 9164 | if ( f ireGlobals ) { | |
| 9165 | globalEv entContext .trigger( "ajaxSend" , [ jqXHR, s ] ); | |
| 9166 | } | |
| 9167 | // Tim eout | |
| 9168 | if ( s .async && s.timeout > 0 ) { | |
| 9169 | timeoutT imer = set Timeout(fu nction() { | |
| 9170 | jqXHR.abor t("timeout "); | |
| 9171 | }, s.tim eout ); | |
| 9172 | } | |
| 9173 | ||
| 9174 | try { | |
| 9175 | state = 1; | |
| 9176 | transpor t.send( re questHeade rs, done ) ; | |
| 9177 | } catc h ( e ) { | |
| 9178 | // Propa gate excep tion as er ror if not done | |
| 9179 | if ( sta te < 2 ) { | |
| 9180 | done( -1, e ); | |
| 9181 | // Simpl y rethrow otherwise | |
| 9182 | } else { | |
| 9183 | throw e; | |
| 9184 | } | |
| 9185 | } | |
| 9186 | } | |
| 9187 | ||
| 9188 | // C allback fo r when eve rything is done | |
| 9189 | func tion done( status, n ativeStatu sText, res ponses, he aders ) { | |
| 9190 | var is Success, s uccess, er ror, respo nse, modif ied, | |
| 9191 | statusTe xt = nativ eStatusTex t; | |
| 9192 | ||
| 9193 | // Cal led once | |
| 9194 | if ( s tate === 2 ) { | |
| 9195 | return; | |
| 9196 | } | |
| 9197 | ||
| 9198 | // Sta te is "don e" now | |
| 9199 | state = 2; | |
| 9200 | ||
| 9201 | // Cle ar timeout if it exi sts | |
| 9202 | if ( t imeoutTime r ) { | |
| 9203 | clearTim eout( time outTimer ) ; | |
| 9204 | } | |
| 9205 | ||
| 9206 | // Der eference t ransport f or early g arbage col lection | |
| 9207 | // (no matter ho w long the jqXHR obj ect will b e used) | |
| 9208 | transp ort = unde fined; | |
| 9209 | ||
| 9210 | // Cac he respons e headers | |
| 9211 | respon seHeadersS tring = he aders || " "; | |
| 9212 | ||
| 9213 | // Set readyStat e | |
| 9214 | jqXHR. readyState = status > 0 ? 4 : 0; | |
| 9215 | ||
| 9216 | // Det ermine if successful | |
| 9217 | isSucc ess = stat us >= 200 && status < 300 || s tatus === 304; | |
| 9218 | ||
| 9219 | // Get response data | |
| 9220 | if ( r esponses ) { | |
| 9221 | response = ajaxHan dleRespons es( s, jqX HR, respon ses ); | |
| 9222 | } | |
| 9223 | ||
| 9224 | // Con vert no ma tter what (that way responseXX X fields a re always set) | |
| 9225 | respon se = ajaxC onvert( s, response, jqXHR, is Success ); | |
| 9226 | ||
| 9227 | // If successful , handle t ype chaini ng | |
| 9228 | if ( i sSuccess ) { | |
| 9229 | ||
| 9230 | // Set t he If-Modi fied-Since and/or If -None-Matc h header, if in ifMo dified mod e. | |
| 9231 | if ( s.i fModified ) { | |
| 9232 | modified = jqXHR.get ResponseHe ader("Last -Modified" ); | |
| 9233 | if ( modif ied ) { | |
| 9234 | jQ uery.lastM odified[ c acheURL ] = modified ; | |
| 9235 | } | |
| 9236 | modified = jqXHR.get ResponseHe ader("etag "); | |
| 9237 | if ( modif ied ) { | |
| 9238 | jQ uery.etag[ cacheURL ] = modifi ed; | |
| 9239 | } | |
| 9240 | } | |
| 9241 | ||
| 9242 | // if no content | |
| 9243 | if ( sta tus === 20 4 || s.typ e === "HEA D" ) { | |
| 9244 | statusText = "nocont ent"; | |
| 9245 | ||
| 9246 | // if no t modified | |
| 9247 | } else i f ( status === 304 ) { | |
| 9248 | statusText = "notmod ified"; | |
| 9249 | ||
| 9250 | // If we have data , let's co nvert it | |
| 9251 | } else { | |
| 9252 | statusText = respons e.state; | |
| 9253 | success = response.d ata; | |
| 9254 | error = re sponse.err or; | |
| 9255 | isSuccess = !error; | |
| 9256 | } | |
| 9257 | } else { | |
| 9258 | // We ex tract erro r from sta tusText | |
| 9259 | // then normalize statusText and statu s for non- aborts | |
| 9260 | error = statusText ; | |
| 9261 | if ( sta tus || !st atusText ) { | |
| 9262 | statusText = "error" ; | |
| 9263 | if ( statu s < 0 ) { | |
| 9264 | st atus = 0; | |
| 9265 | } | |
| 9266 | } | |
| 9267 | } | |
| 9268 | ||
| 9269 | // Set data for the fake x hr object | |
| 9270 | jqXHR. status = s tatus; | |
| 9271 | jqXHR. statusText = ( nativ eStatusTex t || statu sText ) + ""; | |
| 9272 | ||
| 9273 | // Suc cess/Error | |
| 9274 | if ( i sSuccess ) { | |
| 9275 | deferred .resolveWi th( callba ckContext, [ success , statusTe xt, jqXHR ] ); | |
| 9276 | } else { | |
| 9277 | deferred .rejectWit h( callbac kContext, [ jqXHR, s tatusText, error ] ) ; | |
| 9278 | } | |
| 9279 | ||
| 9280 | // Sta tus-depend ent callba cks | |
| 9281 | jqXHR. statusCode ( statusCo de ); | |
| 9282 | status Code = und efined; | |
| 9283 | ||
| 9284 | if ( f ireGlobals ) { | |
| 9285 | globalEv entContext .trigger( isSuccess ? "ajaxSuc cess" : "a jaxError", | |
| 9286 | [ jqXHR, s , isSucces s ? succes s : error ] ); | |
| 9287 | } | |
| 9288 | ||
| 9289 | // Com plete | |
| 9290 | comple teDeferred .fireWith( callbackC ontext, [ jqXHR, sta tusText ] ); | |
| 9291 | ||
| 9292 | if ( f ireGlobals ) { | |
| 9293 | globalEv entContext .trigger( "ajaxCompl ete", [ jq XHR, s ] ) ; | |
| 9294 | // Handl e the glob al AJAX co unter | |
| 9295 | if ( !( --jQuery.a ctive ) ) { | |
| 9296 | jQuery.eve nt.trigger ("ajaxStop "); | |
| 9297 | } | |
| 9298 | } | |
| 9299 | } | |
| 9300 | ||
| 9301 | retu rn jqXHR; | |
| 9302 | }, | |
| 9303 | ||
| 9304 | ge tJSON: fun ction( url , data, ca llback ) { | |
| 9305 | retu rn jQuery. get( url, data, call back, "jso n" ); | |
| 9306 | }, | |
| 9307 | ||
| 9308 | ge tScript: f unction( u rl, callba ck ) { | |
| 9309 | retu rn jQuery. get( url, undefined, callback, "script" ); | |
| 9310 | } | |
| 9311 | }); | |
| 9312 | ||
| 9313 | jQuery.eac h( [ "get" , "post" ] , function ( i, metho d ) { | |
| 9314 | jQ uery[ meth od ] = fun ction( url , data, ca llback, ty pe ) { | |
| 9315 | // s hift argum ents if da ta argumen t was omit ted | |
| 9316 | if ( jQuery.is Function( data ) ) { | |
| 9317 | type = type || c allback; | |
| 9318 | callba ck = data; | |
| 9319 | data = undefined ; | |
| 9320 | } | |
| 9321 | ||
| 9322 | retu rn jQuery. ajax({ | |
| 9323 | url: u rl, | |
| 9324 | type: method, | |
| 9325 | dataTy pe: type, | |
| 9326 | data: data, | |
| 9327 | succes s: callbac k | |
| 9328 | }); | |
| 9329 | }; | |
| 9330 | }); | |
| 9331 | ||
| 9332 | // Attach a bunch of functions for handl ing common AJAX even ts | |
| 9333 | jQuery.eac h( [ "ajax Start", "a jaxStop", "ajaxCompl ete", "aja xError", " ajaxSucces s", "ajaxS end" ], fu nction( i, type ) { | |
| 9334 | jQ uery.fn[ t ype ] = fu nction( fn ) { | |
| 9335 | retu rn this.on ( type, fn ); | |
| 9336 | }; | |
| 9337 | }); | |
| 9338 | ||
| 9339 | ||
| 9340 | jQuery._ev alUrl = fu nction( ur l ) { | |
| 9341 | re turn jQuer y.ajax({ | |
| 9342 | url: url, | |
| 9343 | type : "GET", | |
| 9344 | data Type: "scr ipt", | |
| 9345 | asyn c: false, | |
| 9346 | glob al: false, | |
| 9347 | "thr ows": true | |
| 9348 | }) ; | |
| 9349 | }; | |
| 9350 | ||
| 9351 | ||
| 9352 | jQuery.fn. extend({ | |
| 9353 | wr apAll: fun ction( htm l ) { | |
| 9354 | if ( jQuery.is Function( html ) ) { | |
| 9355 | return this.each (function( i) { | |
| 9356 | jQuery(t his).wrapA ll( html.c all(this, i) ); | |
| 9357 | }); | |
| 9358 | } | |
| 9359 | ||
| 9360 | if ( this[0] ) { | |
| 9361 | // The elements to wrap th e target a round | |
| 9362 | var wr ap = jQuer y( html, t his[0].own erDocument ).eq(0).c lone(true) ; | |
| 9363 | ||
| 9364 | if ( t his[0].par entNode ) { | |
| 9365 | wrap.ins ertBefore( this[0] ) ; | |
| 9366 | } | |
| 9367 | ||
| 9368 | wrap.m ap(functio n() { | |
| 9369 | var elem = this; | |
| 9370 | ||
| 9371 | while ( elem.first Child && e lem.firstC hild.nodeT ype === 1 ) { | |
| 9372 | elem = ele m.firstChi ld; | |
| 9373 | } | |
| 9374 | ||
| 9375 | return e lem; | |
| 9376 | }).app end( this ); | |
| 9377 | } | |
| 9378 | ||
| 9379 | retu rn this; | |
| 9380 | }, | |
| 9381 | ||
| 9382 | wr apInner: f unction( h tml ) { | |
| 9383 | if ( jQuery.is Function( html ) ) { | |
| 9384 | return this.each (function( i) { | |
| 9385 | jQuery(t his).wrapI nner( html .call(this , i) ); | |
| 9386 | }); | |
| 9387 | } | |
| 9388 | ||
| 9389 | retu rn this.ea ch(functio n() { | |
| 9390 | var se lf = jQuer y( this ), | |
| 9391 | contents = self.co ntents(); | |
| 9392 | ||
| 9393 | if ( c ontents.le ngth ) { | |
| 9394 | contents .wrapAll( html ); | |
| 9395 | ||
| 9396 | } else { | |
| 9397 | self.app end( html ); | |
| 9398 | } | |
| 9399 | }); | |
| 9400 | }, | |
| 9401 | ||
| 9402 | wr ap: functi on( html ) { | |
| 9403 | var isFunction = jQuery. isFunction ( html ); | |
| 9404 | ||
| 9405 | retu rn this.ea ch(functio n(i) { | |
| 9406 | jQuery ( this ).w rapAll( is Function ? html.call (this, i) : html ); | |
| 9407 | }); | |
| 9408 | }, | |
| 9409 | ||
| 9410 | un wrap: func tion() { | |
| 9411 | retu rn this.pa rent().eac h(function () { | |
| 9412 | if ( ! jQuery.nod eName( thi s, "body" ) ) { | |
| 9413 | jQuery( this ).rep laceWith( this.child Nodes ); | |
| 9414 | } | |
| 9415 | }).e nd(); | |
| 9416 | } | |
| 9417 | }); | |
| 9418 | ||
| 9419 | ||
| 9420 | jQuery.exp r.filters. hidden = f unction( e lem ) { | |
| 9421 | // Support: Opera <= 1 2.12 | |
| 9422 | // Opera rep orts offse tWidths an d offsetHe ights less than zero on some e lements | |
| 9423 | re turn elem. offsetWidt h <= 0 && elem.offse tHeight <= 0 || | |
| 9424 | (!su pport.reli ableHidden Offsets() && | |
| 9425 | ((elem .style && elem.style .display) || jQuery. css( elem, "display" )) === "n one"); | |
| 9426 | }; | |
| 9427 | ||
| 9428 | jQuery.exp r.filters. visible = function( elem ) { | |
| 9429 | re turn !jQue ry.expr.fi lters.hidd en( elem ) ; | |
| 9430 | }; | |
| 9431 | ||
| 9432 | ||
| 9433 | ||
| 9434 | ||
| 9435 | var r20 = /%20/g, | |
| 9436 | rb racket = / \[\]$/, | |
| 9437 | rC RLF = /\r? \n/g, | |
| 9438 | rs ubmitterTy pes = /^(? :submit|bu tton|image |reset|fil e)$/i, | |
| 9439 | rs ubmittable = /^(?:in put|select |textarea| keygen)/i; | |
| 9440 | ||
| 9441 | function b uildParams ( prefix, obj, tradi tional, ad d ) { | |
| 9442 | va r name; | |
| 9443 | ||
| 9444 | if ( jQuery. isArray( o bj ) ) { | |
| 9445 | // S erialize a rray item. | |
| 9446 | jQue ry.each( o bj, functi on( i, v ) { | |
| 9447 | if ( t raditional || rbrack et.test( p refix ) ) { | |
| 9448 | // Treat each arra y item as a scalar. | |
| 9449 | add( pre fix, v ); | |
| 9450 | ||
| 9451 | } else { | |
| 9452 | // Item is non-sca lar (array or object ), encode its numeri c index. | |
| 9453 | buildPar ams( prefi x + "[" + ( typeof v === "obje ct" ? i : "" ) + "]" , v, tradi tional, ad d ); | |
| 9454 | } | |
| 9455 | }); | |
| 9456 | ||
| 9457 | } else if ( !tradition al && jQue ry.type( o bj ) === " object" ) { | |
| 9458 | // S erialize o bject item . | |
| 9459 | for ( name in obj ) { | |
| 9460 | buildP arams( pre fix + "[" + name + " ]", obj[ n ame ], tra ditional, add ); | |
| 9461 | } | |
| 9462 | ||
| 9463 | } else { | |
| 9464 | // S erialize s calar item . | |
| 9465 | add( prefix, o bj ); | |
| 9466 | } | |
| 9467 | } | |
| 9468 | ||
| 9469 | // Seriali ze an arra y of form elements o r a set of | |
| 9470 | // key/val ues into a query str ing | |
| 9471 | jQuery.par am = funct ion( a, tr aditional ) { | |
| 9472 | va r prefix, | |
| 9473 | s = [], | |
| 9474 | add = function ( key, val ue ) { | |
| 9475 | // If value is a function, invoke it and retur n its valu e | |
| 9476 | value = jQuery.i sFunction( value ) ? value() : ( value = = null ? " " : value ); | |
| 9477 | s[ s.l ength ] = encodeURIC omponent( key ) + "= " + encode URICompone nt( value ); | |
| 9478 | }; | |
| 9479 | ||
| 9480 | // Set tradi tional to true for j Query <= 1 .3.2 behav ior. | |
| 9481 | if ( traditi onal === u ndefined ) { | |
| 9482 | trad itional = jQuery.aja xSettings && jQuery. ajaxSettin gs.traditi onal; | |
| 9483 | } | |
| 9484 | ||
| 9485 | // If an arr ay was pas sed in, as sume that it is an a rray of fo rm element s. | |
| 9486 | if ( jQuery. isArray( a ) || ( a. jquery && !jQuery.is PlainObjec t( a ) ) ) { | |
| 9487 | // S erialize t he form el ements | |
| 9488 | jQue ry.each( a , function () { | |
| 9489 | add( t his.name, this.value ); | |
| 9490 | }); | |
| 9491 | ||
| 9492 | } else { | |
| 9493 | // I f traditio nal, encod e the "old " way (the way 1.3.2 or older | |
| 9494 | // d id it), ot herwise en code param s recursiv ely. | |
| 9495 | for ( prefix i n a ) { | |
| 9496 | buildP arams( pre fix, a[ pr efix ], tr aditional, add ); | |
| 9497 | } | |
| 9498 | } | |
| 9499 | ||
| 9500 | // Return th e resultin g serializ ation | |
| 9501 | re turn s.joi n( "&" ).r eplace( r2 0, "+" ); | |
| 9502 | }; | |
| 9503 | ||
| 9504 | jQuery.fn. extend({ | |
| 9505 | se rialize: f unction() { | |
| 9506 | retu rn jQuery. param( thi s.serializ eArray() ) ; | |
| 9507 | }, | |
| 9508 | se rializeArr ay: functi on() { | |
| 9509 | retu rn this.ma p(function () { | |
| 9510 | // Can add propH ook for "e lements" t o filter o r add form elements | |
| 9511 | var el ements = j Query.prop ( this, "e lements" ) ; | |
| 9512 | return elements ? jQuery.m akeArray( elements ) : this; | |
| 9513 | }) | |
| 9514 | .fil ter(functi on() { | |
| 9515 | var ty pe = this. type; | |
| 9516 | // Use .is(":dis abled") so that fiel dset[disab led] works | |
| 9517 | return this.name && !jQuer y( this ). is( ":disa bled" ) && | |
| 9518 | rsubmitt able.test( this.node Name ) && !rsubmitte rTypes.tes t( type ) && | |
| 9519 | ( this.c hecked || !rcheckabl eType.test ( type ) ) ; | |
| 9520 | }) | |
| 9521 | .map (function( i, elem ) { | |
| 9522 | var va l = jQuery ( this ).v al(); | |
| 9523 | ||
| 9524 | return val == nu ll ? | |
| 9525 | null : | |
| 9526 | jQuery.i sArray( va l ) ? | |
| 9527 | jQuery.map ( val, fun ction( val ) { | |
| 9528 | re turn { nam e: elem.na me, value: val.repla ce( rCRLF, "\r\n" ) }; | |
| 9529 | }) : | |
| 9530 | { name: el em.name, v alue: val. replace( r CRLF, "\r\ n" ) }; | |
| 9531 | }).g et(); | |
| 9532 | } | |
| 9533 | }); | |
| 9534 | ||
| 9535 | ||
| 9536 | // Create the reques t object | |
| 9537 | // (This i s still at tached to ajaxSettin gs for bac kward comp atibility) | |
| 9538 | jQuery.aja xSettings. xhr = wind ow.ActiveX Object !== undefined ? | |
| 9539 | // Support: IE6+ | |
| 9540 | fu nction() { | |
| 9541 | ||
| 9542 | // X HR cannot access loc al files, always use ActiveX f or that ca se | |
| 9543 | retu rn !this.i sLocal && | |
| 9544 | ||
| 9545 | // Sup port: IE7- 8 | |
| 9546 | // old IE XHR doe s not supp ort non-RF C2616 meth ods (#1324 0) | |
| 9547 | // See http://ms dn.microso ft.com/en- us/library /ie/ms5366 48(v=vs.85 ).aspx | |
| 9548 | // and http://ww w.w3.org/P rotocols/r fc2616/rfc 2616-sec9. html#sec9 | |
| 9549 | // Alt hough this check for six metho ds instead of eight | |
| 9550 | // sin ce IE also does not support "t race" and "connect" | |
| 9551 | /^(get |post|head |put|delet e|options) $/i.test( this.type ) && | |
| 9552 | ||
| 9553 | create StandardXH R() || cre ateActiveX HR(); | |
| 9554 | } : | |
| 9555 | // For all o ther brows ers, use t he standar d XMLHttpR equest obj ect | |
| 9556 | cr eateStanda rdXHR; | |
| 9557 | ||
| 9558 | var xhrId = 0, | |
| 9559 | xh rCallbacks = {}, | |
| 9560 | xh rSupported = jQuery. ajaxSettin gs.xhr(); | |
| 9561 | ||
| 9562 | // Support : IE<10 | |
| 9563 | // Open re quests mus t be manua lly aborte d on unloa d (#5280) | |
| 9564 | if ( windo w.ActiveXO bject ) { | |
| 9565 | jQ uery( wind ow ).on( " unload", f unction() { | |
| 9566 | for ( var key in xhrCall backs ) { | |
| 9567 | xhrCal lbacks[ ke y ]( undef ined, true ); | |
| 9568 | } | |
| 9569 | }) ; | |
| 9570 | } | |
| 9571 | ||
| 9572 | // Determi ne support propertie s | |
| 9573 | support.co rs = !!xhr Supported && ( "with Credential s" in xhrS upported ) ; | |
| 9574 | xhrSupport ed = suppo rt.ajax = !!xhrSuppo rted; | |
| 9575 | ||
| 9576 | // Create transport if the bro wser can p rovide an xhr | |
| 9577 | if ( xhrSu pported ) { | |
| 9578 | ||
| 9579 | jQ uery.ajaxT ransport(f unction( o ptions ) { | |
| 9580 | // C ross domai n only all owed if su pported th rough XMLH ttpRequest | |
| 9581 | if ( !options. crossDomai n || suppo rt.cors ) { | |
| 9582 | ||
| 9583 | var ca llback; | |
| 9584 | ||
| 9585 | return { | |
| 9586 | send: fu nction( he aders, com plete ) { | |
| 9587 | var i, | |
| 9588 | xh r = option s.xhr(), | |
| 9589 | id = ++xhrId ; | |
| 9590 | ||
| 9591 | // Open th e socket | |
| 9592 | xhr.open( options.ty pe, option s.url, opt ions.async , options. username, options.pa ssword ); | |
| 9593 | ||
| 9594 | // Apply c ustom fiel ds if prov ided | |
| 9595 | if ( optio ns.xhrFiel ds ) { | |
| 9596 | fo r ( i in o ptions.xhr Fields ) { | |
| 9597 | xhr[ i ] = opt ions.xhrFi elds[ i ]; | |
| 9598 | } | |
| 9599 | } | |
| 9600 | ||
| 9601 | // Overrid e mime typ e if neede d | |
| 9602 | if ( optio ns.mimeTyp e && xhr.o verrideMim eType ) { | |
| 9603 | xh r.override MimeType( options.mi meType ); | |
| 9604 | } | |
| 9605 | ||
| 9606 | // X-Reque sted-With header | |
| 9607 | // For cro ss-domain requests, seeing as conditions for a pre flight are | |
| 9608 | // akin to a jigsaw puzzle, we simply ne ver set it to be sur e. | |
| 9609 | // (it can always be set on a per-reques t basis or even usin g ajaxSetu p) | |
| 9610 | // For sam e-domain r equests, w on't chang e header i f already provided. | |
| 9611 | if ( !opti ons.crossD omain && ! headers["X -Requested -With"] ) { | |
| 9612 | he aders["X-R equested-W ith"] = "X MLHttpRequ est"; | |
| 9613 | } | |
| 9614 | ||
| 9615 | // Set hea ders | |
| 9616 | for ( i in headers ) { | |
| 9617 | // Support: IE<9 | |
| 9618 | // IE's Acti veXObject throws a ' Type Misma tch' excep tion when setting | |
| 9619 | // request h eader to a null-valu e. | |
| 9620 | // | |
| 9621 | // To keep c onsistent with other XHR imple mentations , cast the value | |
| 9622 | // to string and ignor e `undefin ed`. | |
| 9623 | if ( headers [ i ] !== undefined ) { | |
| 9624 | xhr. setRequest Header( i, headers[ i ] + "" ) ; | |
| 9625 | } | |
| 9626 | } | |
| 9627 | ||
| 9628 | // Do send the reque st | |
| 9629 | // This ma y raise an exception which is actually | |
| 9630 | // handled in jQuery .ajax (so no try/cat ch here) | |
| 9631 | xhr.send( ( options. hasContent && option s.data ) | | null ); | |
| 9632 | ||
| 9633 | // Listene r | |
| 9634 | callback = function( _, isAbor t ) { | |
| 9635 | va r status, statusText , response s; | |
| 9636 | ||
| 9637 | // Was never called an d is abort ed or comp lete | |
| 9638 | if ( callbac k && ( isA bort || xh r.readySta te === 4 ) ) { | |
| 9639 | // C lean up | |
| 9640 | dele te xhrCall backs[ id ]; | |
| 9641 | call back = und efined; | |
| 9642 | xhr. onreadysta techange = jQuery.no op; | |
| 9643 | ||
| 9644 | // A bort manua lly if nee ded | |
| 9645 | if ( isAbort ) { | |
| 9646 | if ( x hr.readySt ate !== 4 ) { | |
| 9647 | xhr.abor t(); | |
| 9648 | } | |
| 9649 | } el se { | |
| 9650 | respon ses = {}; | |
| 9651 | status = xhr.sta tus; | |
| 9652 | ||
| 9653 | // Sup port: IE<1 0 | |
| 9654 | // Acc essing bin ary-data r esponseTex t throws a n exceptio n | |
| 9655 | // (#1 1426) | |
| 9656 | if ( t ypeof xhr. responseTe xt === "st ring" ) { | |
| 9657 | response s.text = x hr.respons eText; | |
| 9658 | } | |
| 9659 | ||
| 9660 | // Fir efox throw s an excep tion when accessing | |
| 9661 | // sta tusText fo r faulty c ross-domai n requests | |
| 9662 | try { | |
| 9663 | statusTe xt = xhr.s tatusText; | |
| 9664 | } catc h( e ) { | |
| 9665 | // We no rmalize wi th Webkit giving an empty stat usText | |
| 9666 | statusTe xt = ""; | |
| 9667 | } | |
| 9668 | ||
| 9669 | // Fil ter status for non s tandard be haviors | |
| 9670 | ||
| 9671 | // If the reques t is local and we ha ve data: a ssume a su ccess | |
| 9672 | // (su ccess with no data w on't get n otified, t hat's the best we | |
| 9673 | // can do given current im plementati ons) | |
| 9674 | if ( ! status && options.is Local && ! options.cr ossDomain ) { | |
| 9675 | status = responses .text ? 20 0 : 404; | |
| 9676 | // IE - #1450: s ometimes r eturns 122 3 when it should be 204 | |
| 9677 | } else if ( stat us === 122 3 ) { | |
| 9678 | status = 204; | |
| 9679 | } | |
| 9680 | } | |
| 9681 | } | |
| 9682 | ||
| 9683 | // Call comp lete if ne eded | |
| 9684 | if ( respons es ) { | |
| 9685 | comp lete( stat us, status Text, resp onses, xhr .getAllRes ponseHeade rs() ); | |
| 9686 | } | |
| 9687 | }; | |
| 9688 | ||
| 9689 | if ( !opti ons.async ) { | |
| 9690 | // if we're in sync mo de we fire the callb ack | |
| 9691 | ca llback(); | |
| 9692 | } else if ( xhr.read yState === 4 ) { | |
| 9693 | // (IE6 & IE 7) if it's in cache and has be en | |
| 9694 | // retrieved directly we need to fire the callback | |
| 9695 | se tTimeout( callback ) ; | |
| 9696 | } else { | |
| 9697 | // Add to th e list of active xhr callbacks | |
| 9698 | xh r.onreadys tatechange = xhrCall backs[ id ] = callba ck; | |
| 9699 | } | |
| 9700 | }, | |
| 9701 | ||
| 9702 | abort: f unction() { | |
| 9703 | if ( callb ack ) { | |
| 9704 | ca llback( un defined, t rue ); | |
| 9705 | } | |
| 9706 | } | |
| 9707 | }; | |
| 9708 | } | |
| 9709 | }) ; | |
| 9710 | } | |
| 9711 | ||
| 9712 | // Functio ns to crea te xhrs | |
| 9713 | function c reateStand ardXHR() { | |
| 9714 | tr y { | |
| 9715 | retu rn new win dow.XMLHtt pRequest() ; | |
| 9716 | } catch( e ) {} | |
| 9717 | } | |
| 9718 | ||
| 9719 | function c reateActiv eXHR() { | |
| 9720 | tr y { | |
| 9721 | retu rn new win dow.Active XObject( " Microsoft. XMLHTTP" ) ; | |
| 9722 | } catch( e ) {} | |
| 9723 | } | |
| 9724 | ||
| 9725 | ||
| 9726 | ||
| 9727 | ||
| 9728 | // Install script da taType | |
| 9729 | jQuery.aja xSetup({ | |
| 9730 | ac cepts: { | |
| 9731 | scri pt: "text/ javascript , applicat ion/javasc ript, appl ication/ec mascript, applicatio n/x-ecmasc ript" | |
| 9732 | }, | |
| 9733 | co ntents: { | |
| 9734 | scri pt: /(?:ja va|ecma)sc ript/ | |
| 9735 | }, | |
| 9736 | co nverters: { | |
| 9737 | "tex t script": function( text ) { | |
| 9738 | jQuery .globalEva l( text ); | |
| 9739 | return text; | |
| 9740 | } | |
| 9741 | } | |
| 9742 | }); | |
| 9743 | ||
| 9744 | // Handle cache's sp ecial case and globa l | |
| 9745 | jQuery.aja xPrefilter ( "script" , function ( s ) { | |
| 9746 | if ( s.cache === undef ined ) { | |
| 9747 | s.ca che = fals e; | |
| 9748 | } | |
| 9749 | if ( s.cross Domain ) { | |
| 9750 | s.ty pe = "GET" ; | |
| 9751 | s.gl obal = fal se; | |
| 9752 | } | |
| 9753 | }); | |
| 9754 | ||
| 9755 | // Bind sc ript tag h ack transp ort | |
| 9756 | jQuery.aja xTransport ( "script" , function (s) { | |
| 9757 | ||
| 9758 | // This tran sport only deals wit h cross do main reque sts | |
| 9759 | if ( s.cross Domain ) { | |
| 9760 | ||
| 9761 | var script, | |
| 9762 | head = document. head || jQ uery("head ")[0] || d ocument.do cumentElem ent; | |
| 9763 | ||
| 9764 | retu rn { | |
| 9765 | ||
| 9766 | send: function( _, callbac k ) { | |
| 9767 | ||
| 9768 | script = document. createElem ent("scrip t"); | |
| 9769 | ||
| 9770 | script.a sync = tru e; | |
| 9771 | ||
| 9772 | if ( s.s criptChars et ) { | |
| 9773 | script.cha rset = s.s criptChars et; | |
| 9774 | } | |
| 9775 | ||
| 9776 | script.s rc = s.url ; | |
| 9777 | ||
| 9778 | // Attac h handlers for all b rowsers | |
| 9779 | script.o nload = sc ript.onrea dystatecha nge = func tion( _, i sAbort ) { | |
| 9780 | ||
| 9781 | if ( isAbo rt || !scr ipt.readyS tate || /l oaded|comp lete/.test ( script.r eadyState ) ) { | |
| 9782 | ||
| 9783 | // Handle me mory leak in IE | |
| 9784 | sc ript.onloa d = script .onreadyst atechange = null; | |
| 9785 | ||
| 9786 | // Remove th e script | |
| 9787 | if ( script. parentNode ) { | |
| 9788 | scri pt.parentN ode.remove Child( scr ipt ); | |
| 9789 | } | |
| 9790 | ||
| 9791 | // Dereferen ce the scr ipt | |
| 9792 | sc ript = nul l; | |
| 9793 | ||
| 9794 | // Callback if not abo rt | |
| 9795 | if ( !isAbor t ) { | |
| 9796 | call back( 200, "success" ); | |
| 9797 | } | |
| 9798 | } | |
| 9799 | }; | |
| 9800 | ||
| 9801 | // Circu mvent IE6 bugs with base eleme nts (#2709 and #4378 ) by prepe nding | |
| 9802 | // Use n ative DOM manipulati on to avoi d our domM anip AJAX trickery | |
| 9803 | head.ins ertBefore( script, h ead.firstC hild ); | |
| 9804 | }, | |
| 9805 | ||
| 9806 | abort: function( ) { | |
| 9807 | if ( scr ipt ) { | |
| 9808 | script.onl oad( undef ined, true ); | |
| 9809 | } | |
| 9810 | } | |
| 9811 | }; | |
| 9812 | } | |
| 9813 | }); | |
| 9814 | ||
| 9815 | ||
| 9816 | ||
| 9817 | ||
| 9818 | var oldCal lbacks = [ ], | |
| 9819 | rj sonp = /(= )\?(?=&|$) |\?\?/; | |
| 9820 | ||
| 9821 | // Default jsonp set tings | |
| 9822 | jQuery.aja xSetup({ | |
| 9823 | js onp: "call back", | |
| 9824 | js onpCallbac k: functio n() { | |
| 9825 | var callback = oldCallba cks.pop() || ( jQuer y.expando + "_" + ( nonce++ ) ); | |
| 9826 | this [ callback ] = true; | |
| 9827 | retu rn callbac k; | |
| 9828 | } | |
| 9829 | }); | |
| 9830 | ||
| 9831 | // Detect, normalize options a nd install callbacks for jsonp requests | |
| 9832 | jQuery.aja xPrefilter ( "json js onp", func tion( s, o riginalSet tings, jqX HR ) { | |
| 9833 | ||
| 9834 | va r callback Name, over written, r esponseCon tainer, | |
| 9835 | json Prop = s.j sonp !== f alse && ( rjsonp.tes t( s.url ) ? | |
| 9836 | "url" : | |
| 9837 | typeof s.data == = "string" && !( s.c ontentType || "" ).i ndexOf("ap plication/ x-www-form -urlencode d") && rjs onp.test( s.data ) & & "data" | |
| 9838 | ); | |
| 9839 | ||
| 9840 | // Handle if f the expe cted data type is "j sonp" or w e have a p arameter t o set | |
| 9841 | if ( jsonPro p || s.dat aTypes[ 0 ] === "jso np" ) { | |
| 9842 | ||
| 9843 | // G et callbac k name, re membering preexistin g value as sociated w ith it | |
| 9844 | call backName = s.jsonpCa llback = j Query.isFu nction( s. jsonpCallb ack ) ? | |
| 9845 | s.json pCallback( ) : | |
| 9846 | s.json pCallback; | |
| 9847 | ||
| 9848 | // I nsert call back into url or for m data | |
| 9849 | if ( jsonProp ) { | |
| 9850 | s[ jso nProp ] = s[ jsonPro p ].replac e( rjsonp, "$1" + ca llbackName ); | |
| 9851 | } el se if ( s. jsonp !== false ) { | |
| 9852 | s.url += ( rquer y.test( s. url ) ? "& " : "?" ) + s.jsonp + "=" + ca llbackName ; | |
| 9853 | } | |
| 9854 | ||
| 9855 | // U se data co nverter to retrieve json after script ex ecution | |
| 9856 | s.co nverters[" script jso n"] = func tion() { | |
| 9857 | if ( ! responseCo ntainer ) { | |
| 9858 | jQuery.e rror( call backName + " was not called" ) ; | |
| 9859 | } | |
| 9860 | return responseC ontainer[ 0 ]; | |
| 9861 | }; | |
| 9862 | ||
| 9863 | // f orce json dataType | |
| 9864 | s.da taTypes[ 0 ] = "json "; | |
| 9865 | ||
| 9866 | // I nstall cal lback | |
| 9867 | over written = window[ ca llbackName ]; | |
| 9868 | wind ow[ callba ckName ] = function( ) { | |
| 9869 | respon seContaine r = argume nts; | |
| 9870 | }; | |
| 9871 | ||
| 9872 | // C lean-up fu nction (fi res after converters ) | |
| 9873 | jqXH R.always(f unction() { | |
| 9874 | // Res tore preex isting val ue | |
| 9875 | window [ callback Name ] = o verwritten ; | |
| 9876 | ||
| 9877 | // Sav e back as free | |
| 9878 | if ( s [ callback Name ] ) { | |
| 9879 | // make sure that re-using t he options doesn't s crew thing s around | |
| 9880 | s.jsonpC allback = originalSe ttings.jso npCallback ; | |
| 9881 | ||
| 9882 | // save the callba ck name fo r future u se | |
| 9883 | oldCallb acks.push( callbackN ame ); | |
| 9884 | } | |
| 9885 | ||
| 9886 | // Cal l if it wa s a functi on and we have a res ponse | |
| 9887 | if ( r esponseCon tainer && jQuery.isF unction( o verwritten ) ) { | |
| 9888 | overwrit ten( respo nseContain er[ 0 ] ); | |
| 9889 | } | |
| 9890 | ||
| 9891 | respon seContaine r = overwr itten = un defined; | |
| 9892 | }); | |
| 9893 | ||
| 9894 | // D elegate to script | |
| 9895 | retu rn "script "; | |
| 9896 | } | |
| 9897 | }); | |
| 9898 | ||
| 9899 | ||
| 9900 | ||
| 9901 | ||
| 9902 | // data: s tring of h tml | |
| 9903 | // context (optional ): If spec ified, the fragment will be cr eated in t his contex t, default s to docum ent | |
| 9904 | // keepScr ipts (opti onal): If true, will include s cripts pas sed in the html stri ng | |
| 9905 | jQuery.par seHTML = f unction( d ata, conte xt, keepSc ripts ) { | |
| 9906 | if ( !data | | typeof d ata !== "s tring" ) { | |
| 9907 | retu rn null; | |
| 9908 | } | |
| 9909 | if ( typeof context == = "boolean " ) { | |
| 9910 | keep Scripts = context; | |
| 9911 | cont ext = fals e; | |
| 9912 | } | |
| 9913 | co ntext = co ntext || d ocument; | |
| 9914 | ||
| 9915 | va r parsed = rsingleTa g.exec( da ta ), | |
| 9916 | scri pts = !kee pScripts & & []; | |
| 9917 | ||
| 9918 | // Single ta g | |
| 9919 | if ( parsed ) { | |
| 9920 | retu rn [ conte xt.createE lement( pa rsed[1] ) ]; | |
| 9921 | } | |
| 9922 | ||
| 9923 | pa rsed = jQu ery.buildF ragment( [ data ], c ontext, sc ripts ); | |
| 9924 | ||
| 9925 | if ( scripts && script s.length ) { | |
| 9926 | jQue ry( script s ).remove (); | |
| 9927 | } | |
| 9928 | ||
| 9929 | re turn jQuer y.merge( [ ], parsed. childNodes ); | |
| 9930 | }; | |
| 9931 | ||
| 9932 | ||
| 9933 | // Keep a copy of th e old load method | |
| 9934 | var _load = jQuery.f n.load; | |
| 9935 | ||
| 9936 | /** | |
| 9937 | * Load a url into a page | |
| 9938 | */ | |
| 9939 | jQuery.fn. load = fun ction( url , params, callback ) { | |
| 9940 | if ( typeof url !== "s tring" && _load ) { | |
| 9941 | retu rn _load.a pply( this , argument s ); | |
| 9942 | } | |
| 9943 | ||
| 9944 | va r selector , response , type, | |
| 9945 | self = this, | |
| 9946 | off = url.inde xOf(" "); | |
| 9947 | ||
| 9948 | if ( off >= 0 ) { | |
| 9949 | sele ctor = jQu ery.trim( url.slice( off, url. length ) ) ; | |
| 9950 | url = url.slic e( 0, off ); | |
| 9951 | } | |
| 9952 | ||
| 9953 | // If it's a function | |
| 9954 | if ( jQuery. isFunction ( params ) ) { | |
| 9955 | ||
| 9956 | // W e assume t hat it's t he callbac k | |
| 9957 | call back = par ams; | |
| 9958 | para ms = undef ined; | |
| 9959 | ||
| 9960 | // Otherwise , build a param stri ng | |
| 9961 | } else if ( params && typeof par ams === "o bject" ) { | |
| 9962 | type = "POST"; | |
| 9963 | } | |
| 9964 | ||
| 9965 | // If we hav e elements to modify , make the request | |
| 9966 | if ( self.le ngth > 0 ) { | |
| 9967 | jQue ry.ajax({ | |
| 9968 | url: u rl, | |
| 9969 | ||
| 9970 | // if "type" var iable is u ndefined, then "GET" method wi ll be used | |
| 9971 | type: type, | |
| 9972 | dataTy pe: "html" , | |
| 9973 | data: params | |
| 9974 | }).d one(functi on( respon seText ) { | |
| 9975 | ||
| 9976 | // Sav e response for use i n complete callback | |
| 9977 | respon se = argum ents; | |
| 9978 | ||
| 9979 | self.h tml( selec tor ? | |
| 9980 | ||
| 9981 | // If a selector w as specifi ed, locate the right elements in a dummy div | |
| 9982 | // Exclu de scripts to avoid IE 'Permis sion Denie d' errors | |
| 9983 | jQuery(" <div>").ap pend( jQue ry.parseHT ML( respon seText ) ) .find( sel ector ) : | |
| 9984 | ||
| 9985 | // Other wise use t he full re sult | |
| 9986 | response Text ); | |
| 9987 | ||
| 9988 | }).c omplete( c allback && function( jqXHR, st atus ) { | |
| 9989 | self.e ach( callb ack, respo nse || [ j qXHR.respo nseText, s tatus, jqX HR ] ); | |
| 9990 | }); | |
| 9991 | } | |
| 9992 | ||
| 9993 | re turn this; | |
| 9994 | }; | |
| 9995 | ||
| 9996 | ||
| 9997 | ||
| 9998 | ||
| 9999 | jQuery.exp r.filters. animated = function( elem ) { | |
| 10000 | re turn jQuer y.grep(jQu ery.timers , function ( fn ) { | |
| 10001 | retu rn elem == = fn.elem; | |
| 10002 | }) .length; | |
| 10003 | }; | |
| 10004 | ||
| 10005 | ||
| 10006 | ||
| 10007 | ||
| 10008 | ||
| 10009 | var docEle m = window .document. documentEl ement; | |
| 10010 | ||
| 10011 | /** | |
| 10012 | * Gets a window fro m an eleme nt | |
| 10013 | */ | |
| 10014 | function g etWindow( elem ) { | |
| 10015 | re turn jQuer y.isWindow ( elem ) ? | |
| 10016 | elem : | |
| 10017 | elem .nodeType === 9 ? | |
| 10018 | elem.d efaultView || elem.p arentWindo w : | |
| 10019 | false; | |
| 10020 | } | |
| 10021 | ||
| 10022 | jQuery.off set = { | |
| 10023 | se tOffset: f unction( e lem, optio ns, i ) { | |
| 10024 | var curPositio n, curLeft , curCSSTo p, curTop, curOffset , curCSSLe ft, calcul atePositio n, | |
| 10025 | positi on = jQuer y.css( ele m, "positi on" ), | |
| 10026 | curEle m = jQuery ( elem ), | |
| 10027 | props = {}; | |
| 10028 | ||
| 10029 | // s et positio n first, i n-case top /left are set even o n static e lem | |
| 10030 | if ( position === "stati c" ) { | |
| 10031 | elem.s tyle.posit ion = "rel ative"; | |
| 10032 | } | |
| 10033 | ||
| 10034 | curO ffset = cu rElem.offs et(); | |
| 10035 | curC SSTop = jQ uery.css( elem, "top " ); | |
| 10036 | curC SSLeft = j Query.css( elem, "le ft" ); | |
| 10037 | calc ulatePosit ion = ( po sition === "absolute " || posit ion === "f ixed" ) && | |
| 10038 | jQuery .inArray(" auto", [ c urCSSTop, curCSSLeft ] ) > -1; | |
| 10039 | ||
| 10040 | // n eed to be able to ca lculate po sition if either top or left i s auto and position is either absolute o r fixed | |
| 10041 | if ( calculate Position ) { | |
| 10042 | curPos ition = cu rElem.posi tion(); | |
| 10043 | curTop = curPosi tion.top; | |
| 10044 | curLef t = curPos ition.left ; | |
| 10045 | } el se { | |
| 10046 | curTop = parseFl oat( curCS STop ) || 0; | |
| 10047 | curLef t = parseF loat( curC SSLeft ) | | 0; | |
| 10048 | } | |
| 10049 | ||
| 10050 | if ( jQuery.is Function( options ) ) { | |
| 10051 | option s = option s.call( el em, i, cur Offset ); | |
| 10052 | } | |
| 10053 | ||
| 10054 | if ( options.t op != null ) { | |
| 10055 | props. top = ( op tions.top - curOffse t.top ) + curTop; | |
| 10056 | } | |
| 10057 | if ( options.l eft != nul l ) { | |
| 10058 | props. left = ( o ptions.lef t - curOff set.left ) + curLeft ; | |
| 10059 | } | |
| 10060 | ||
| 10061 | if ( "using" i n options ) { | |
| 10062 | option s.using.ca ll( elem, props ); | |
| 10063 | } el se { | |
| 10064 | curEle m.css( pro ps ); | |
| 10065 | } | |
| 10066 | } | |
| 10067 | }; | |
| 10068 | ||
| 10069 | jQuery.fn. extend({ | |
| 10070 | of fset: func tion( opti ons ) { | |
| 10071 | if ( arguments .length ) { | |
| 10072 | return options = == undefin ed ? | |
| 10073 | this : | |
| 10074 | this.eac h(function ( i ) { | |
| 10075 | jQuery.off set.setOff set( this, options, i ); | |
| 10076 | }); | |
| 10077 | } | |
| 10078 | ||
| 10079 | var docElem, w in, | |
| 10080 | box = { top: 0, left: 0 }, | |
| 10081 | elem = this[ 0 ] , | |
| 10082 | doc = elem && el em.ownerDo cument; | |
| 10083 | ||
| 10084 | if ( !doc ) { | |
| 10085 | return ; | |
| 10086 | } | |
| 10087 | ||
| 10088 | docE lem = doc. documentEl ement; | |
| 10089 | ||
| 10090 | // M ake sure i t's not a disconnect ed DOM nod e | |
| 10091 | if ( !jQuery.c ontains( d ocElem, el em ) ) { | |
| 10092 | return box; | |
| 10093 | } | |
| 10094 | ||
| 10095 | // I f we don't have gBCR , just use 0,0 rathe r than err or | |
| 10096 | // B lackBerry 5, iOS 3 ( original i Phone) | |
| 10097 | if ( typeof el em.getBoun dingClient Rect !== s trundefine d ) { | |
| 10098 | box = elem.getBo undingClie ntRect(); | |
| 10099 | } | |
| 10100 | win = getWindo w( doc ); | |
| 10101 | retu rn { | |
| 10102 | top: b ox.top + ( win.page YOffset || docElem.s crollTop ) - ( docE lem.client Top || 0 ), | |
| 10103 | left: box.left + ( win.pag eXOffset | | docElem. scrollLeft ) - ( doc Elem.clien tLeft || 0 ) | |
| 10104 | }; | |
| 10105 | }, | |
| 10106 | ||
| 10107 | po sition: fu nction() { | |
| 10108 | if ( !this[ 0 ] ) { | |
| 10109 | return ; | |
| 10110 | } | |
| 10111 | ||
| 10112 | var offsetPare nt, offset , | |
| 10113 | parent Offset = { top: 0, l eft: 0 }, | |
| 10114 | elem = this[ 0 ] ; | |
| 10115 | ||
| 10116 | // f ixed eleme nts are of fset from window (pa rentOffset = {top:0, left: 0}, because i t is its o nly offset parent | |
| 10117 | if ( jQuery.cs s( elem, " position" ) === "fix ed" ) { | |
| 10118 | // we assume tha t getBound ingClientR ect is ava ilable whe n computed position is fixed | |
| 10119 | offset = elem.ge tBoundingC lientRect( ); | |
| 10120 | } el se { | |
| 10121 | // Get *real* of fsetParent | |
| 10122 | offset Parent = t his.offset Parent(); | |
| 10123 | ||
| 10124 | // Get correct o ffsets | |
| 10125 | offset = this.of fset(); | |
| 10126 | if ( ! jQuery.nod eName( off setParent[ 0 ], "htm l" ) ) { | |
| 10127 | parentOf fset = off setParent. offset(); | |
| 10128 | } | |
| 10129 | ||
| 10130 | // Add offsetPar ent border s | |
| 10131 | parent Offset.top += jQuer y.css( off setParent[ 0 ], "bor derTopWidt h", true ) ; | |
| 10132 | parent Offset.lef t += jQuer y.css( off setParent[ 0 ], "bor derLeftWid th", true ); | |
| 10133 | } | |
| 10134 | ||
| 10135 | // S ubtract pa rent offse ts and ele ment margi ns | |
| 10136 | // n ote: when an element has margi n: auto th e offsetLe ft and mar ginLeft | |
| 10137 | // a re the sam e in Safar i causing offset.lef t to incor rectly be 0 | |
| 10138 | retu rn { | |
| 10139 | top: offset.top - parent Offset.top - jQuery. css( elem, "marginTo p", true ) , | |
| 10140 | left: offset.lef t - parent Offset.lef t - jQuery .css( elem , "marginL eft", true ) | |
| 10141 | }; | |
| 10142 | }, | |
| 10143 | ||
| 10144 | of fsetParent : function () { | |
| 10145 | retu rn this.ma p(function () { | |
| 10146 | var of fsetParent = this.of fsetParent || docEle m; | |
| 10147 | ||
| 10148 | while ( offsetPa rent && ( !jQuery.no deName( of fsetParent , "html" ) && jQuery .css( offs etParent, "position" ) === "st atic" ) ) { | |
| 10149 | offsetPa rent = off setParent. offsetPare nt; | |
| 10150 | } | |
| 10151 | return offsetPar ent || doc Elem; | |
| 10152 | }); | |
| 10153 | } | |
| 10154 | }); | |
| 10155 | ||
| 10156 | // Create scrollLeft and scrol lTop metho ds | |
| 10157 | jQuery.eac h( { scrol lLeft: "pa geXOffset" , scrollTo p: "pageYO ffset" }, function( method, pr op ) { | |
| 10158 | va r top = /Y /.test( pr op ); | |
| 10159 | ||
| 10160 | jQ uery.fn[ m ethod ] = function( val ) { | |
| 10161 | retu rn access( this, fun ction( ele m, method, val ) { | |
| 10162 | var wi n = getWin dow( elem ); | |
| 10163 | ||
| 10164 | if ( v al === und efined ) { | |
| 10165 | return w in ? (prop in win) ? win[ prop ] : | |
| 10166 | win.docume nt.documen tElement[ method ] : | |
| 10167 | elem[ meth od ]; | |
| 10168 | } | |
| 10169 | ||
| 10170 | if ( w in ) { | |
| 10171 | win.scro llTo( | |
| 10172 | !top ? val : jQuery( win ).scr ollLeft(), | |
| 10173 | top ? val : jQuery( win ).scro llTop() | |
| 10174 | ); | |
| 10175 | ||
| 10176 | } else { | |
| 10177 | elem[ me thod ] = v al; | |
| 10178 | } | |
| 10179 | }, m ethod, val , argument s.length, null ); | |
| 10180 | }; | |
| 10181 | }); | |
| 10182 | ||
| 10183 | // Add the top/left cssHooks u sing jQuer y.fn.posit ion | |
| 10184 | // Webkit bug: https ://bugs.we bkit.org/s how_bug.cg i?id=29084 | |
| 10185 | // getComp utedStyle returns pe rcent when specified for top/l eft/bottom /right | |
| 10186 | // rather than make the css mo dule depen d on the o ffset modu le, we jus t check fo r it here | |
| 10187 | jQuery.eac h( [ "top" , "left" ] , function ( i, prop ) { | |
| 10188 | jQ uery.cssHo oks[ prop ] = addGet HookIf( su pport.pixe lPosition, | |
| 10189 | func tion( elem , computed ) { | |
| 10190 | if ( c omputed ) { | |
| 10191 | computed = curCSS( elem, pro p ); | |
| 10192 | // if cu rCSS retur ns percent age, fallb ack to off set | |
| 10193 | return r numnonpx.t est( compu ted ) ? | |
| 10194 | jQuery( el em ).posit ion()[ pro p ] + "px" : | |
| 10195 | computed; | |
| 10196 | } | |
| 10197 | } | |
| 10198 | ); | |
| 10199 | }); | |
| 10200 | ||
| 10201 | ||
| 10202 | // Create innerHeigh t, innerWi dth, heigh t, width, outerHeigh t and oute rWidth met hods | |
| 10203 | jQuery.eac h( { Heigh t: "height ", Width: "width" }, function( name, typ e ) { | |
| 10204 | jQ uery.each( { padding : "inner" + name, co ntent: typ e, "": "ou ter" + nam e }, funct ion( defau ltExtra, f uncName ) { | |
| 10205 | // m argin is o nly for ou terHeight, outerWidt h | |
| 10206 | jQue ry.fn[ fun cName ] = function( margin, va lue ) { | |
| 10207 | var ch ainable = arguments. length && ( defaultE xtra || ty peof margi n !== "boo lean" ), | |
| 10208 | extra = defaultExt ra || ( ma rgin === t rue || val ue === tru e ? "margi n" : "bord er" ); | |
| 10209 | ||
| 10210 | return access( t his, funct ion( elem, type, val ue ) { | |
| 10211 | var doc; | |
| 10212 | ||
| 10213 | if ( jQu ery.isWind ow( elem ) ) { | |
| 10214 | // As of 5 /8/2012 th is will yi eld incorr ect result s for Mobi le Safari, but there | |
| 10215 | // isn't a whole lot we can do . See pull request a t this URL for discu ssion: | |
| 10216 | // https:/ /github.co m/jquery/j query/pull /764 | |
| 10217 | return ele m.document .documentE lement[ "c lient" + n ame ]; | |
| 10218 | } | |
| 10219 | ||
| 10220 | // Get d ocument wi dth or hei ght | |
| 10221 | if ( ele m.nodeType === 9 ) { | |
| 10222 | doc = elem .documentE lement; | |
| 10223 | ||
| 10224 | // Either scroll[Wid th/Height] or offset [Width/Hei ght] or cl ient[Width /Height], whichever is greates t | |
| 10225 | // unfortu nately, th is causes bug #3838 in IE6/8 o nly, but t here is cu rrently no good, sma ll way to fix it. | |
| 10226 | return Mat h.max( | |
| 10227 | el em.body[ " scroll" + name ], do c[ "scroll " + name ] , | |
| 10228 | el em.body[ " offset" + name ], do c[ "offset " + name ] , | |
| 10229 | do c[ "client " + name ] | |
| 10230 | ); | |
| 10231 | } | |
| 10232 | ||
| 10233 | return v alue === u ndefined ? | |
| 10234 | // Get wid th or heig ht on the element, r equesting but not fo rcing pars eFloat | |
| 10235 | jQuery.css ( elem, ty pe, extra ) : | |
| 10236 | ||
| 10237 | // Set wid th or heig ht on the element | |
| 10238 | jQuery.sty le( elem, type, valu e, extra ) ; | |
| 10239 | }, typ e, chainab le ? margi n : undefi ned, chain able, null ); | |
| 10240 | }; | |
| 10241 | }) ; | |
| 10242 | }); | |
| 10243 | ||
| 10244 | ||
| 10245 | // The num ber of ele ments cont ained in t he matched element s et | |
| 10246 | jQuery.fn. size = fun ction() { | |
| 10247 | re turn this. length; | |
| 10248 | }; | |
| 10249 | ||
| 10250 | jQuery.fn. andSelf = jQuery.fn. addBack; | |
| 10251 | ||
| 10252 | ||
| 10253 | ||
| 10254 | ||
| 10255 | // Registe r as a nam ed AMD mod ule, since jQuery ca n be conca tenated wi th other | |
| 10256 | // files t hat may us e define, but not vi a a proper concatena tion scrip t that | |
| 10257 | // underst ands anony mous AMD m odules. A named AMD is safest and most r obust | |
| 10258 | // way to register. Lowercase jquery is used becau se AMD mod ule names are | |
| 10259 | // derived from file names, an d jQuery i s normally delivered in a lowe rcase | |
| 10260 | // file na me. Do thi s after cr eating the global so that if a n AMD modu le wants | |
| 10261 | // to call noConflic t to hide this versi on of jQue ry, it wil l work. | |
| 10262 | ||
| 10263 | // Note th at for max imum porta bility, li braries th at are not jQuery sh ould | |
| 10264 | // declare themselve s as anony mous modul es, and av oid settin g a global if an | |
| 10265 | // AMD loa der is pre sent. jQue ry is a sp ecial case . For more informati on, see | |
| 10266 | // https:/ /github.co m/jrburke/ requirejs/ wiki/Updat ing-existi ng-librari es#wiki-an on | |
| 10267 | ||
| 10268 | if ( typeo f define = == "functi on" && def ine.amd ) { | |
| 10269 | de fine( "jqu ery", [], function() { | |
| 10270 | retu rn jQuery; | |
| 10271 | }) ; | |
| 10272 | } | |
| 10273 | ||
| 10274 | ||
| 10275 | ||
| 10276 | ||
| 10277 | var | |
| 10278 | // Map over jQuery in case of ov erwrite | |
| 10279 | _j Query = wi ndow.jQuer y, | |
| 10280 | ||
| 10281 | // Map over the $ in c ase of ove rwrite | |
| 10282 | _$ = window. $; | |
| 10283 | ||
| 10284 | jQuery.noC onflict = function( deep ) { | |
| 10285 | if ( window. $ === jQue ry ) { | |
| 10286 | wind ow.$ = _$; | |
| 10287 | } | |
| 10288 | ||
| 10289 | if ( deep && window.jQ uery === j Query ) { | |
| 10290 | wind ow.jQuery = _jQuery; | |
| 10291 | } | |
| 10292 | ||
| 10293 | re turn jQuer y; | |
| 10294 | }; | |
| 10295 | ||
| 10296 | // Expose jQuery and $ identif iers, even in | |
| 10297 | // AMD (#7 102#commen t:10, http s://github .com/jquer y/jquery/p ull/557) | |
| 10298 | // and Com monJS for browser em ulators (# 13566) | |
| 10299 | if ( typeo f noGlobal === strun defined ) { | |
| 10300 | wi ndow.jQuer y = window .$ = jQuer y; | |
| 10301 | } | |
| 10302 | ||
| 10303 | ||
| 10304 | ||
| 10305 | ||
| 10306 | return jQu ery; | |
| 10307 | ||
| 10308 | })); |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.