jquery.js 88 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297
  1. (function(){
  2. /*
  3. * jQuery @VERSION - New Wave Javascript
  4. *
  5. * Copyright (c) 2007 John Resig (jquery.com)
  6. * Dual licensed under the MIT (MIT-LICENSE.txt)
  7. * and GPL (GPL-LICENSE.txt) licenses.
  8. *
  9. * $Date: 2007-10-21 01:04:06 +0300 (D, 21 oct. 2007) $
  10. * $Rev: 3701 $
  11. */
  12. // Map over jQuery in case of overwrite
  13. if ( window.jQuery )
  14. var _jQuery = window.jQuery;
  15. var jQuery = window.jQuery = function( selector, context ) {
  16. // If the context is a namespace object, return a new object
  17. return this instanceof jQuery ?
  18. this.init( selector, context ) :
  19. new jQuery( selector, context );
  20. };
  21. // Map over the $ in case of overwrite
  22. if ( window.$ )
  23. var _$ = window.$;
  24. // Map the jQuery namespace to the '$' one
  25. window.$ = jQuery;
  26. // A simple way to check for HTML strings or ID strings
  27. // (both of which we optimize for)
  28. var quickExpr = /^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/;
  29. jQuery.fn = jQuery.prototype = {
  30. init: function( selector, context ) {
  31. // Make sure that a selection was provided
  32. selector = selector || document;
  33. // Handle HTML strings
  34. if ( typeof selector == "string" ) {
  35. // Are we dealing with HTML string or an ID?
  36. var match = quickExpr.exec( selector );
  37. // Verify a match, and that no context was specified for #id
  38. if ( match && (match[1] || !context) ) {
  39. // HANDLE: $(html) -> $(array)
  40. if ( match[1] )
  41. selector = jQuery.clean( [ match[1] ], context );
  42. // HANDLE: $("#id")
  43. else {
  44. var elem = document.getElementById( match[3] );
  45. // Make sure an element was located
  46. if ( elem )
  47. // Handle the case where IE and Opera return items
  48. // by name instead of ID
  49. if ( elem.id != match[3] )
  50. return jQuery().find( selector );
  51. // Otherwise, we inject the element directly into the jQuery object
  52. else {
  53. this[0] = elem;
  54. this.length = 1;
  55. return this;
  56. }
  57. else
  58. selector = [];
  59. }
  60. // HANDLE: $(expr, [context])
  61. // (which is just equivalent to: $(content).find(expr)
  62. } else
  63. return new jQuery( context ).find( selector );
  64. // HANDLE: $(function)
  65. // Shortcut for document ready
  66. } else if ( jQuery.isFunction( selector ) )
  67. return new jQuery( document )[ jQuery.fn.ready ? "ready" : "load" ]( selector );
  68. return this.setArray(
  69. // HANDLE: $(array)
  70. selector.constructor == Array && selector ||
  71. // HANDLE: $(arraylike)
  72. // Watch for when an array-like object, contains DOM nodes, is passed in as the selector
  73. (selector.jquery || selector.length && selector != window && !selector.nodeType && selector[0] != undefined && selector[0].nodeType) && jQuery.makeArray( selector ) ||
  74. // HANDLE: $(*)
  75. [ selector ] );
  76. },
  77. // The current version of jQuery being used
  78. jquery: "@VERSION",
  79. // The number of elements contained in the matched element set
  80. size: function() {
  81. return this.length;
  82. },
  83. // The number of elements contained in the matched element set
  84. length: 0,
  85. // Get the Nth element in the matched element set OR
  86. // Get the whole matched element set as a clean array
  87. get: function( num ) {
  88. return num == undefined ?
  89. // Return a 'clean' array
  90. jQuery.makeArray( this ) :
  91. // Return just the object
  92. this[ num ];
  93. },
  94. // Take an array of elements and push it onto the stack
  95. // (returning the new matched element set)
  96. pushStack: function( elems ) {
  97. // Build a new jQuery matched element set
  98. var ret = jQuery( elems );
  99. // Add the old object onto the stack (as a reference)
  100. ret.prevObject = this;
  101. // Return the newly-formed element set
  102. return ret;
  103. },
  104. // Force the current matched set of elements to become
  105. // the specified array of elements (destroying the stack in the process)
  106. // You should use pushStack() in order to do this, but maintain the stack
  107. setArray: function( elems ) {
  108. // Resetting the length to 0, then using the native Array push
  109. // is a super-fast way to populate an object with array-like properties
  110. this.length = 0;
  111. Array.prototype.push.apply( this, elems );
  112. return this;
  113. },
  114. // Execute a callback for every element in the matched set.
  115. // (You can seed the arguments with an array of args, but this is
  116. // only used internally.)
  117. each: function( callback, args ) {
  118. return jQuery.each( this, callback, args );
  119. },
  120. // Determine the position of an element within
  121. // the matched set of elements
  122. index: function( elem ) {
  123. var ret = -1;
  124. // Locate the position of the desired element
  125. this.each(function(i){
  126. if ( this == elem )
  127. ret = i;
  128. });
  129. return ret;
  130. },
  131. attr: function( name, value, type ) {
  132. var options = name;
  133. // Look for the case where we're accessing a style value
  134. if ( name.constructor == String )
  135. if ( value == undefined )
  136. return this.length && jQuery[ type || "attr" ]( this[0], name ) || undefined;
  137. else {
  138. options = {};
  139. options[ name ] = value;
  140. }
  141. // Check to see if we're setting style values
  142. return this.each(function(i){
  143. // Set all the styles
  144. for ( name in options )
  145. jQuery.attr(
  146. type ?
  147. this.style :
  148. this,
  149. name, jQuery.prop( this, options[ name ], type, i, name )
  150. );
  151. });
  152. },
  153. css: function( key, value ) {
  154. return this.attr( key, value, "curCSS" );
  155. },
  156. text: function( text ) {
  157. if ( typeof text != "object" && text != null )
  158. return this.empty().append( document.createTextNode( text ) );
  159. var ret = "";
  160. jQuery.each( text || this, function(){
  161. jQuery.each( this.childNodes, function(){
  162. if ( this.nodeType != 8 )
  163. ret += this.nodeType != 1 ?
  164. this.nodeValue :
  165. jQuery.fn.text( [ this ] );
  166. });
  167. });
  168. return ret;
  169. },
  170. wrapAll: function( html ) {
  171. if ( this[0] )
  172. // The elements to wrap the target around
  173. jQuery( html, this[0].ownerDocument )
  174. .clone()
  175. .insertBefore( this[0] )
  176. .map(function(){
  177. var elem = this;
  178. while ( elem.firstChild )
  179. elem = elem.firstChild;
  180. return elem;
  181. })
  182. .append(this);
  183. return this;
  184. },
  185. wrapInner: function( html ) {
  186. return this.each(function(){
  187. jQuery( this ).contents().wrapAll( html );
  188. });
  189. },
  190. wrap: function( html ) {
  191. return this.each(function(){
  192. jQuery( this ).wrapAll( html );
  193. });
  194. },
  195. append: function() {
  196. return this.domManip(arguments, true, false, function(elem){
  197. this.appendChild( elem );
  198. });
  199. },
  200. prepend: function() {
  201. return this.domManip(arguments, true, true, function(elem){
  202. this.insertBefore( elem, this.firstChild );
  203. });
  204. },
  205. before: function() {
  206. return this.domManip(arguments, false, false, function(elem){
  207. this.parentNode.insertBefore( elem, this );
  208. });
  209. },
  210. after: function() {
  211. return this.domManip(arguments, false, true, function(elem){
  212. this.parentNode.insertBefore( elem, this.nextSibling );
  213. });
  214. },
  215. end: function() {
  216. return this.prevObject || jQuery( [] );
  217. },
  218. find: function( selector ) {
  219. var elems = jQuery.map(this, function(elem){
  220. return jQuery.find( selector, elem );
  221. });
  222. return this.pushStack( /[^+>] [^+>]/.test( selector ) || selector.indexOf("..") > -1 ?
  223. jQuery.unique( elems ) :
  224. elems );
  225. },
  226. clone: function( events ) {
  227. // Do the clone
  228. var ret = this.map(function(){
  229. return this.outerHTML ?
  230. jQuery( this.outerHTML )[0] :
  231. this.cloneNode( true );
  232. });
  233. // Need to set the expando to null on the cloned set if it exists
  234. // removeData doesn't work here, IE removes it from the original as well
  235. // this is primarily for IE but the data expando shouldn't be copied over in any browser
  236. var clone = ret.find("*").andSelf().each(function(){
  237. if ( this[ expando ] != undefined )
  238. this[ expando ] = null;
  239. });
  240. // Copy the events from the original to the clone
  241. if ( events === true )
  242. this.find("*").andSelf().each(function(i){
  243. var events = jQuery.data( this, "events" );
  244. for ( var type in events )
  245. for ( var handler in events[ type ] )
  246. jQuery.event.add( clone[ i ], type, events[ type ][ handler ], events[ type ][ handler ].data );
  247. });
  248. // Return the cloned set
  249. return ret;
  250. },
  251. filter: function( selector ) {
  252. return this.pushStack(
  253. jQuery.isFunction( selector ) &&
  254. jQuery.grep(this, function(elem, i){
  255. return selector.call( elem, i );
  256. }) ||
  257. jQuery.multiFilter( selector, this ) );
  258. },
  259. not: function( selector ) {
  260. return this.pushStack(
  261. selector.constructor == String &&
  262. jQuery.multiFilter( selector, this, true ) ||
  263. jQuery.grep(this, function(elem) {
  264. return selector.constructor == Array || selector.jquery ?
  265. jQuery.inArray( elem, selector ) < 0 :
  266. elem != selector;
  267. }) );
  268. },
  269. add: function( selector ) {
  270. return this.pushStack( jQuery.merge(
  271. this.get(),
  272. selector.constructor == String ?
  273. jQuery( selector ).get() :
  274. selector.length != undefined && (!selector.nodeName || jQuery.nodeName(selector, "form")) ?
  275. selector : [selector] ) );
  276. },
  277. is: function( selector ) {
  278. return selector ?
  279. jQuery.multiFilter( selector, this ).length > 0 :
  280. false;
  281. },
  282. hasClass: function( selector ) {
  283. return this.is( "." + selector );
  284. },
  285. val: function( value ) {
  286. if ( value == undefined ) {
  287. if ( this.length ) {
  288. var elem = this[0];
  289. // We need to handle select boxes special
  290. if ( jQuery.nodeName( elem, "select" ) ) {
  291. var index = elem.selectedIndex,
  292. values = [],
  293. options = elem.options,
  294. one = elem.type == "select-one";
  295. // Nothing was selected
  296. if ( index < 0 )
  297. return null;
  298. // Loop through all the selected options
  299. for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) {
  300. var option = options[ i ];
  301. if ( option.selected ) {
  302. // Get the specifc value for the option
  303. value = jQuery.browser.msie && !option.attributes.value.specified ? option.text : option.value;
  304. // We don't need an array for one selects
  305. if ( one )
  306. return value;
  307. // Multi-Selects return an array
  308. values.push( value );
  309. }
  310. }
  311. return values;
  312. // Everything else, we just grab the value
  313. } else
  314. return this[0].value.replace(/\r/g, "");
  315. }
  316. } else
  317. return this.each(function(){
  318. if ( value.constructor == Array && /radio|checkbox/.test( this.type ) )
  319. this.checked = (jQuery.inArray(this.value, value) >= 0 ||
  320. jQuery.inArray(this.name, value) >= 0);
  321. else if ( jQuery.nodeName( this, "select" ) ) {
  322. var values = value.constructor == Array ?
  323. value :
  324. [ value ];
  325. jQuery( "option", this ).each(function(){
  326. this.selected = (jQuery.inArray( this.value, values ) >= 0 ||
  327. jQuery.inArray( this.text, values ) >= 0);
  328. });
  329. if ( !values.length )
  330. this.selectedIndex = -1;
  331. } else
  332. this.value = value;
  333. });
  334. },
  335. html: function( value ) {
  336. return value == undefined ?
  337. (this.length ?
  338. this[0].innerHTML :
  339. null) :
  340. this.empty().append( value );
  341. },
  342. replaceWith: function( value ) {
  343. return this.after( value ).remove();
  344. },
  345. eq: function( i ) {
  346. return this.slice( i, i + 1 );
  347. },
  348. slice: function() {
  349. return this.pushStack( Array.prototype.slice.apply( this, arguments ) );
  350. },
  351. map: function( callback ) {
  352. return this.pushStack( jQuery.map(this, function(elem, i){
  353. return callback.call( elem, i, elem );
  354. }));
  355. },
  356. andSelf: function() {
  357. return this.add( this.prevObject );
  358. },
  359. domManip: function( args, table, reverse, callback ) {
  360. var clone = this.length > 1, elems;
  361. return this.each(function(){
  362. if ( !elems ) {
  363. elems = jQuery.clean( args, this.ownerDocument );
  364. if ( reverse )
  365. elems.reverse();
  366. }
  367. var obj = this;
  368. if ( table && jQuery.nodeName( this, "table" ) && jQuery.nodeName( elems[0], "tr" ) )
  369. obj = this.getElementsByTagName("tbody")[0] || this.appendChild( document.createElement("tbody") );
  370. var scripts = jQuery( [] );
  371. jQuery.each(elems, function(){
  372. var elem = clone ?
  373. this.cloneNode( true ) :
  374. this;
  375. if ( jQuery.nodeName( elem, "script" ) ) {
  376. // If scripts are waiting to be executed, wait on this script as well
  377. if ( scripts.length )
  378. scripts = scripts.add( elem );
  379. // If nothing is waiting to be executed, run immediately
  380. else
  381. evalScript( 0, elem );
  382. } else {
  383. // Remove any inner scripts for later evaluation
  384. if ( elem.nodeType == 1 )
  385. scripts = scripts.add( jQuery( "script", elem ).remove() );
  386. // Inject the elements into the document
  387. callback.call( obj, elem );
  388. }
  389. });
  390. scripts.each( evalScript );
  391. });
  392. }
  393. };
  394. function evalScript( i, elem ) {
  395. if ( elem.src )
  396. jQuery.ajax({
  397. url: elem.src,
  398. async: false,
  399. dataType: "script"
  400. });
  401. else
  402. jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" );
  403. if ( elem.parentNode )
  404. elem.parentNode.removeChild( elem );
  405. }
  406. jQuery.extend = jQuery.fn.extend = function() {
  407. // copy reference to target object
  408. var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options;
  409. // Handle a deep copy situation
  410. if ( target.constructor == Boolean ) {
  411. deep = target;
  412. target = arguments[1] || {};
  413. }
  414. // extend jQuery itself if only one argument is passed
  415. if ( length == 1 ) {
  416. target = this;
  417. i = 0;
  418. }
  419. for ( ; i < length; i++ )
  420. // Only deal with non-null/undefined values
  421. if ( (options = arguments[ i ]) != null )
  422. // Extend the base object
  423. for ( var name in options ) {
  424. // Prevent never-ending loop
  425. if ( target == options[ name ] )
  426. continue;
  427. // Recurse if we're merging object values
  428. if ( deep && typeof options[ name ] == "object" && target[ name ] && !options[ name ].nodeType )
  429. jQuery.extend( target[ name ], options[ name ] );
  430. // Don't bring in undefined values
  431. else if ( options[ name ] != undefined )
  432. target[ name ] = options[ name ];
  433. }
  434. // Return the modified object
  435. return target;
  436. };
  437. var expando = "jQuery" + (new Date()).getTime(), uuid = 0, windowData = {};
  438. // exclude the following css properties to add px
  439. var exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i;
  440. jQuery.extend({
  441. noConflict: function( deep ) {
  442. window.$ = _$;
  443. if ( deep )
  444. window.jQuery = _jQuery;
  445. return jQuery;
  446. },
  447. // This may seem like some crazy code, but trust me when I say that this
  448. // is the only cross-browser way to do this. --John
  449. isFunction: function( fn ) {
  450. return !!fn && typeof fn != "string" && !fn.nodeName &&
  451. fn.constructor != Array && /function/i.test( fn + "" );
  452. },
  453. // check if an element is in a (or is an) XML document
  454. isXMLDoc: function( elem ) {
  455. return elem.documentElement && !elem.body ||
  456. elem.tagName && elem.ownerDocument && !elem.ownerDocument.body;
  457. },
  458. // Evalulates a script in a global context
  459. // Evaluates Async. in Safari 2 :-(
  460. globalEval: function( data ) {
  461. data = jQuery.trim( data );
  462. if ( data ) {
  463. // Inspired by code by Andrea Giammarchi
  464. // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
  465. var head = document.getElementsByTagName("head")[0] || document.documentElement,
  466. script = document.createElement("script");
  467. script.type = "text/javascript";
  468. if ( jQuery.browser.msie )
  469. script.text = data;
  470. else
  471. script.appendChild( document.createTextNode( data ) );
  472. head.appendChild( script );
  473. head.removeChild( script );
  474. }
  475. },
  476. nodeName: function( elem, name ) {
  477. return elem.nodeName && elem.nodeName.toUpperCase() == name.toUpperCase();
  478. },
  479. cache: {},
  480. data: function( elem, name, data ) {
  481. elem = elem == window ?
  482. windowData :
  483. elem;
  484. var id = elem[ expando ];
  485. // Compute a unique ID for the element
  486. if ( !id )
  487. id = elem[ expando ] = ++uuid;
  488. // Only generate the data cache if we're
  489. // trying to access or manipulate it
  490. if ( name && !jQuery.cache[ id ] )
  491. jQuery.cache[ id ] = {};
  492. // Prevent overriding the named cache with undefined values
  493. if ( data != undefined )
  494. jQuery.cache[ id ][ name ] = data;
  495. // Return the named cache data, or the ID for the element
  496. return name ?
  497. jQuery.cache[ id ][ name ] :
  498. id;
  499. },
  500. removeData: function( elem, name ) {
  501. elem = elem == window ?
  502. windowData :
  503. elem;
  504. var id = elem[ expando ];
  505. // If we want to remove a specific section of the element's data
  506. if ( name ) {
  507. if ( jQuery.cache[ id ] ) {
  508. // Remove the section of cache data
  509. delete jQuery.cache[ id ][ name ];
  510. // If we've removed all the data, remove the element's cache
  511. name = "";
  512. for ( name in jQuery.cache[ id ] )
  513. break;
  514. if ( !name )
  515. jQuery.removeData( elem );
  516. }
  517. // Otherwise, we want to remove all of the element's data
  518. } else {
  519. // Clean up the element expando
  520. try {
  521. delete elem[ expando ];
  522. } catch(e){
  523. // IE has trouble directly removing the expando
  524. // but it's ok with using removeAttribute
  525. if ( elem.removeAttribute )
  526. elem.removeAttribute( expando );
  527. }
  528. // Completely remove the data cache
  529. delete jQuery.cache[ id ];
  530. }
  531. },
  532. // args is for internal usage only
  533. each: function( object, callback, args ) {
  534. if ( args ) {
  535. if ( object.length == undefined )
  536. for ( var name in object )
  537. callback.apply( object[ name ], args );
  538. else
  539. for ( var i = 0, length = object.length; i < length; i++ )
  540. if ( callback.apply( object[ i ], args ) === false )
  541. break;
  542. // A special, fast, case for the most common use of each
  543. } else {
  544. if ( object.length == undefined )
  545. for ( var name in object )
  546. callback.call( object[ name ], name, object[ name ] );
  547. else
  548. for ( var i = 0, length = object.length, value = object[0];
  549. i < length && callback.call( value, i, value ) !== false; value = object[++i] ){}
  550. }
  551. return object;
  552. },
  553. prop: function( elem, value, type, i, name ) {
  554. // Handle executable functions
  555. if ( jQuery.isFunction( value ) )
  556. value = value.call( elem, i );
  557. // Handle passing in a number to a CSS property
  558. return value && value.constructor == Number && type == "curCSS" && !exclude.test( name ) ?
  559. value + "px" :
  560. value;
  561. },
  562. className: {
  563. // internal only, use addClass("class")
  564. add: function( elem, classNames ) {
  565. jQuery.each((classNames || "").split(/\s+/), function(i, className){
  566. if ( !jQuery.className.has( elem.className, className ) )
  567. elem.className += (elem.className ? " " : "") + className;
  568. });
  569. },
  570. // internal only, use removeClass("class")
  571. remove: function( elem, classNames ) {
  572. elem.className = classNames != undefined ?
  573. jQuery.grep(elem.className.split(/\s+/), function(className){
  574. return !jQuery.className.has( classNames, className );
  575. }).join(" ") :
  576. "";
  577. },
  578. // internal only, use is(".class")
  579. has: function( elem, className ) {
  580. return jQuery.inArray( className, (elem.className || elem).toString().split(/\s+/) ) > -1;
  581. }
  582. },
  583. // A method for quickly swapping in/out CSS properties to get correct calculations
  584. swap: function( elem, options, callback ) {
  585. // Remember the old values, and insert the new ones
  586. for ( var name in options ) {
  587. elem.style[ "old" + name ] = elem.style[ name ];
  588. elem.style[ name ] = options[ name ];
  589. }
  590. callback.call( elem );
  591. // Revert the old values
  592. for ( var name in options )
  593. elem.style[ name ] = elem.style[ "old" + name ];
  594. },
  595. css: function( elem, name ) {
  596. if ( name == "height" || name == "width" ) {
  597. var old = {}, height, width;
  598. // Revert the padding and border widths to get the
  599. // correct height/width values
  600. jQuery.each([ "Top", "Bottom", "Right", "Left" ], function(){
  601. old[ "padding" + this ] = 0;
  602. old[ "border" + this + "Width" ] = 0;
  603. });
  604. // Swap out the padding/border values temporarily
  605. jQuery.swap( elem, old, function() {
  606. // If the element is visible, then the calculation is easy
  607. if ( jQuery( elem ).is(":visible") ) {
  608. height = elem.offsetHeight;
  609. width = elem.offsetWidth;
  610. // Otherwise, we need to flip out more values
  611. } else {
  612. elem = jQuery( elem.cloneNode(true) )
  613. .find(":radio").removeAttr("checked").end()
  614. .css({
  615. visibility: "hidden",
  616. position: "absolute",
  617. display: "block",
  618. right: "0",
  619. left: "0"
  620. }).appendTo( elem.parentNode )[0];
  621. var position = jQuery.css( elem.parentNode, "position" ) || "static";
  622. if ( position == "static" )
  623. elem.parentNode.style.position = "relative";
  624. height = elem.clientHeight;
  625. width = elem.clientWidth;
  626. if ( position == "static" )
  627. elem.parentNode.style.position = "static";
  628. elem.parentNode.removeChild( elem );
  629. }
  630. });
  631. return name == "height" ?
  632. height :
  633. width;
  634. }
  635. return jQuery.curCSS( elem, name );
  636. },
  637. curCSS: function( elem, name, force ) {
  638. var ret;
  639. // A helper method for determining if an element's values are broken
  640. function color( elem ) {
  641. if ( !jQuery.browser.safari )
  642. return false;
  643. var ret = document.defaultView.getComputedStyle( elem, null );
  644. return !ret || ret.getPropertyValue("color") == "";
  645. }
  646. // We need to handle opacity special in IE
  647. if ( name == "opacity" && jQuery.browser.msie ) {
  648. ret = jQuery.attr( elem.style, "opacity" );
  649. return ret == "" ?
  650. "1" :
  651. ret;
  652. }
  653. // Make sure we're using the right name for getting the float value
  654. if ( name.match( /float/i ) )
  655. name = styleFloat;
  656. if ( !force && elem.style[ name ] )
  657. ret = elem.style[ name ];
  658. else if ( document.defaultView && document.defaultView.getComputedStyle ) {
  659. // Only "float" is needed here
  660. if ( name.match( /float/i ) )
  661. name = "float";
  662. name = name.replace( /([A-Z])/g, "-$1" ).toLowerCase();
  663. var getComputedStyle = document.defaultView.getComputedStyle( elem, null );
  664. if ( getComputedStyle && !color( elem ) )
  665. ret = getComputedStyle.getPropertyValue( name );
  666. // If the element isn't reporting its values properly in Safari
  667. // then some display: none elements are involved
  668. else {
  669. var swap = [], stack = [];
  670. // Locate all of the parent display: none elements
  671. for ( var a = elem; a && color(a); a = a.parentNode )
  672. stack.unshift(a);
  673. // Go through and make them visible, but in reverse
  674. // (It would be better if we knew the exact display type that they had)
  675. for ( var i = 0; i < stack.length; i++ )
  676. if ( color( stack[ i ] ) ) {
  677. swap[ i ] = stack[ i ].style.display;
  678. stack[ i ].style.display = "block";
  679. }
  680. // Since we flip the display style, we have to handle that
  681. // one special, otherwise get the value
  682. ret = name == "display" && swap[ stack.length - 1 ] != null ?
  683. "none" :
  684. ( getComputedStyle && getComputedStyle.getPropertyValue( name ) ) || "";
  685. // Finally, revert the display styles back
  686. for ( var i = 0; i < swap.length; i++ )
  687. if ( swap[ i ] != null )
  688. stack[ i ].style.display = swap[ i ];
  689. }
  690. // We should always get a number back from opacity
  691. if ( name == "opacity" && ret == "" )
  692. ret = "1";
  693. } else if ( elem.currentStyle ) {
  694. var camelCase = name.replace(/\-(\w)/g, function(all, letter){
  695. return letter.toUpperCase();
  696. });
  697. ret = elem.currentStyle[ name ] || elem.currentStyle[ camelCase ];
  698. // From the awesome hack by Dean Edwards
  699. // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
  700. // If we're not dealing with a regular pixel number
  701. // but a number that has a weird ending, we need to convert it to pixels
  702. if ( !/^\d+(px)?$/i.test( ret ) && /^\d/.test( ret ) ) {
  703. // Remember the original values
  704. var style = elem.style.left, runtimeStyle = elem.runtimeStyle.left;
  705. // Put in the new values to get a computed value out
  706. elem.runtimeStyle.left = elem.currentStyle.left;
  707. elem.style.left = ret || 0;
  708. ret = elem.style.pixelLeft + "px";
  709. // Revert the changed values
  710. elem.style.left = style;
  711. elem.runtimeStyle.left = runtimeStyle;
  712. }
  713. }
  714. return ret;
  715. },
  716. clean: function( elems, context ) {
  717. var ret = [];
  718. context = context || document;
  719. jQuery.each(elems, function(i, elem){
  720. if ( !elem )
  721. return;
  722. if ( elem.constructor == Number )
  723. elem = elem.toString();
  724. // Convert html string into DOM nodes
  725. if ( typeof elem == "string" ) {
  726. // Fix "XHTML"-style tags in all browsers
  727. elem = elem.replace(/(<(\w+)[^>]*?)\/>/g, function(all, front, tag){
  728. return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area)$/i) ?
  729. all :
  730. front + "></" + tag + ">";
  731. });
  732. // Trim whitespace, otherwise indexOf won't work as expected
  733. var tags = jQuery.trim( elem ).toLowerCase(), div = context.createElement("div");
  734. var wrap =
  735. // option or optgroup
  736. !tags.indexOf("<opt") &&
  737. [ 1, "<select>", "</select>" ] ||
  738. !tags.indexOf("<leg") &&
  739. [ 1, "<fieldset>", "</fieldset>" ] ||
  740. tags.match(/^<(thead|tbody|tfoot|colg|cap)/) &&
  741. [ 1, "<table>", "</table>" ] ||
  742. !tags.indexOf("<tr") &&
  743. [ 2, "<table><tbody>", "</tbody></table>" ] ||
  744. // <thead> matched above
  745. (!tags.indexOf("<td") || !tags.indexOf("<th")) &&
  746. [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ] ||
  747. !tags.indexOf("<col") &&
  748. [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ] ||
  749. // IE can't serialize <link> and <script> tags normally
  750. jQuery.browser.msie &&
  751. [ 1, "div<div>", "</div>" ] ||
  752. [ 0, "", "" ];
  753. // Go to html and back, then peel off extra wrappers
  754. div.innerHTML = wrap[1] + elem + wrap[2];
  755. // Move to the right depth
  756. while ( wrap[0]-- )
  757. div = div.lastChild;
  758. // Remove IE's autoinserted <tbody> from table fragments
  759. if ( jQuery.browser.msie ) {
  760. // String was a <table>, *may* have spurious <tbody>
  761. var tbody = !tags.indexOf("<table") && tags.indexOf("<tbody") < 0 ?
  762. div.firstChild && div.firstChild.childNodes :
  763. // String was a bare <thead> or <tfoot>
  764. wrap[1] == "<table>" && tags.indexOf("<tbody") < 0 ?
  765. div.childNodes :
  766. [];
  767. for ( var i = tbody.length - 1; i >= 0 ; --i )
  768. if ( jQuery.nodeName( tbody[ i ], "tbody" ) && !tbody[ i ].childNodes.length )
  769. tbody[ i ].parentNode.removeChild( tbody[ i ] );
  770. // IE completely kills leading whitespace when innerHTML is used
  771. if ( /^\s/.test( elem ) )
  772. div.insertBefore( context.createTextNode( elem.match(/^\s*/)[0] ), div.firstChild );
  773. }
  774. elem = jQuery.makeArray( div.childNodes );
  775. }
  776. if ( elem.length === 0 && (!jQuery.nodeName( elem, "form" ) && !jQuery.nodeName( elem, "select" )) )
  777. return;
  778. if ( elem[0] == undefined || jQuery.nodeName( elem, "form" ) || elem.options )
  779. ret.push( elem );
  780. else
  781. ret = jQuery.merge( ret, elem );
  782. });
  783. return ret;
  784. },
  785. attr: function( elem, name, value ) {
  786. var fix = jQuery.isXMLDoc( elem ) ?
  787. {} :
  788. jQuery.props;
  789. // Safari mis-reports the default selected property of a hidden option
  790. // Accessing the parent's selectedIndex property fixes it
  791. if ( name == "selected" && jQuery.browser.safari )
  792. elem.parentNode.selectedIndex;
  793. // Certain attributes only work when accessed via the old DOM 0 way
  794. if ( fix[ name ] ) {
  795. if ( value != undefined )
  796. elem[ fix[ name ] ] = value;
  797. return elem[ fix[ name ] ];
  798. } else if ( jQuery.browser.msie && name == "style" )
  799. return jQuery.attr( elem.style, "cssText", value );
  800. else if ( value == undefined && jQuery.browser.msie && jQuery.nodeName( elem, "form" ) && (name == "action" || name == "method") )
  801. return elem.getAttributeNode( name ).nodeValue;
  802. // IE elem.getAttribute passes even for style
  803. else if ( elem.tagName ) {
  804. if ( value != undefined ) {
  805. // We can't allow the type property to be changed (since it causes problems in IE)
  806. if ( name == "type" && jQuery.nodeName( elem, "input" ) && elem.parentNode )
  807. throw "type property can't be changed";
  808. elem.setAttribute( name, value );
  809. }
  810. if ( jQuery.browser.msie && /href|src/.test( name ) && !jQuery.isXMLDoc( elem ) )
  811. return elem.getAttribute( name, 2 );
  812. return elem.getAttribute( name );
  813. // elem is actually elem.style ... set the style
  814. } else {
  815. // IE actually uses filters for opacity
  816. if ( name == "opacity" && jQuery.browser.msie ) {
  817. if ( value != undefined ) {
  818. // IE has trouble with opacity if it does not have layout
  819. // Force it by setting the zoom level
  820. elem.zoom = 1;
  821. // Set the alpha filter to set the opacity
  822. elem.filter = (elem.filter || "").replace( /alpha\([^)]*\)/, "" ) +
  823. (parseFloat( value ).toString() == "NaN" ? "" : "alpha(opacity=" + value * 100 + ")");
  824. }
  825. return elem.filter ?
  826. (parseFloat( elem.filter.match(/opacity=([^)]*)/)[1] ) / 100).toString() :
  827. "";
  828. }
  829. name = name.replace(/-([a-z])/ig, function(all, letter){
  830. return letter.toUpperCase();
  831. });
  832. if ( value != undefined )
  833. elem[ name ] = value;
  834. return elem[ name ];
  835. }
  836. },
  837. trim: function( text ) {
  838. return (text || "").replace( /^\s+|\s+$/g, "" );
  839. },
  840. makeArray: function( array ) {
  841. var ret = [];
  842. // Need to use typeof to fight Safari childNodes crashes
  843. if ( typeof array != "array" )
  844. for ( var i = 0, length = array.length; i < length; i++ )
  845. ret.push( array[ i ] );
  846. else
  847. ret = array.slice( 0 );
  848. return ret;
  849. },
  850. inArray: function( elem, array ) {
  851. for ( var i = 0, length = array.length; i < length; i++ )
  852. if ( array[ i ] == elem )
  853. return i;
  854. return -1;
  855. },
  856. merge: function( first, second ) {
  857. // We have to loop this way because IE & Opera overwrite the length
  858. // expando of getElementsByTagName
  859. // Also, we need to make sure that the correct elements are being returned
  860. // (IE returns comment nodes in a '*' query)
  861. if ( jQuery.browser.msie ) {
  862. for ( var i = 0; second[ i ]; i++ )
  863. if ( second[ i ].nodeType != 8 )
  864. first.push( second[ i ] );
  865. } else
  866. for ( var i = 0; second[ i ]; i++ )
  867. first.push( second[ i ] );
  868. return first;
  869. },
  870. unique: function( array ) {
  871. var ret = [], done = {};
  872. try {
  873. for ( var i = 0, length = array.length; i < length; i++ ) {
  874. var id = jQuery.data( array[ i ] );
  875. if ( !done[ id ] ) {
  876. done[ id ] = true;
  877. ret.push( array[ i ] );
  878. }
  879. }
  880. } catch( e ) {
  881. ret = array;
  882. }
  883. return ret;
  884. },
  885. grep: function( elems, callback, inv ) {
  886. // If a string is passed in for the function, make a function
  887. // for it (a handy shortcut)
  888. if ( typeof callback == "string" )
  889. callback = eval("false||function(a,i){return " + callback + "}");
  890. var ret = [];
  891. // Go through the array, only saving the items
  892. // that pass the validator function
  893. for ( var i = 0, length = elems.length; i < length; i++ )
  894. if ( !inv && callback( elems[ i ], i ) || inv && !callback( elems[ i ], i ) )
  895. ret.push( elems[ i ] );
  896. return ret;
  897. },
  898. map: function( elems, callback ) {
  899. var ret = [];
  900. // Go through the array, translating each of the items to their
  901. // new value (or values).
  902. for ( var i = 0, length = elems.length; i < length; i++ ) {
  903. var value = callback( elems[ i ], i );
  904. if ( value !== null && value != undefined ) {
  905. if ( value.constructor != Array )
  906. value = [ value ];
  907. ret = ret.concat( value );
  908. }
  909. }
  910. return ret;
  911. }
  912. });
  913. var userAgent = navigator.userAgent.toLowerCase();
  914. // Figure out what browser is being used
  915. jQuery.browser = {
  916. version: (userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [])[1],
  917. safari: /webkit/.test( userAgent ),
  918. opera: /opera/.test( userAgent ),
  919. msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ),
  920. mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent )
  921. };
  922. var styleFloat = jQuery.browser.msie ?
  923. "styleFloat" :
  924. "cssFloat";
  925. jQuery.extend({
  926. // Check to see if the W3C box model is being used
  927. boxModel: !jQuery.browser.msie || document.compatMode == "CSS1Compat",
  928. props: {
  929. "for": "htmlFor",
  930. "class": "className",
  931. "float": styleFloat,
  932. cssFloat: styleFloat,
  933. styleFloat: styleFloat,
  934. innerHTML: "innerHTML",
  935. className: "className",
  936. value: "value",
  937. disabled: "disabled",
  938. checked: "checked",
  939. readonly: "readOnly",
  940. selected: "selected",
  941. maxlength: "maxLength",
  942. selectedIndex: "selectedIndex"
  943. }
  944. });
  945. jQuery.each({
  946. parent: "elem.parentNode",
  947. parents: "jQuery.dir(elem,'parentNode')",
  948. next: "jQuery.nth(elem,2,'nextSibling')",
  949. prev: "jQuery.nth(elem,2,'previousSibling')",
  950. nextAll: "jQuery.dir(elem,'nextSibling')",
  951. prevAll: "jQuery.dir(elem,'previousSibling')",
  952. siblings: "jQuery.sibling(elem.parentNode.firstChild,elem)",
  953. children: "jQuery.sibling(elem.firstChild)",
  954. contents: "jQuery.nodeName(elem,'iframe')?elem.contentDocument||elem.contentWindow.document:jQuery.makeArray(elem.childNodes)"
  955. }, function(name, fn){
  956. fn = eval("false||function(elem){return " + fn + "}");
  957. jQuery.fn[ name ] = function( selector ) {
  958. var ret = jQuery.map( this, fn );
  959. if ( selector && typeof selector == "string" )
  960. ret = jQuery.multiFilter( selector, ret );
  961. return this.pushStack( jQuery.unique( ret ) );
  962. };
  963. });
  964. jQuery.each({
  965. appendTo: "append",
  966. prependTo: "prepend",
  967. insertBefore: "before",
  968. insertAfter: "after",
  969. replaceAll: "replaceWith"
  970. }, function(name, original){
  971. jQuery.fn[ name ] = function() {
  972. var args = arguments;
  973. return this.each(function(){
  974. for ( var i = 0, length = args.length; i < length; i++ )
  975. jQuery( args[ i ] )[ original ]( this );
  976. });
  977. };
  978. });
  979. jQuery.each({
  980. removeAttr: function( name ) {
  981. jQuery.attr( this, name, "" );
  982. this.removeAttribute( name );
  983. },
  984. addClass: function( classNames ) {
  985. jQuery.className.add( this, classNames );
  986. },
  987. removeClass: function( classNames ) {
  988. jQuery.className.remove( this, classNames );
  989. },
  990. toggleClass: function( classNames ) {
  991. jQuery.className[ jQuery.className.has( this, classNames ) ? "remove" : "add" ]( this, classNames );
  992. },
  993. remove: function( selector ) {
  994. if ( !selector || jQuery.filter( selector, [ this ] ).r.length ) {
  995. // Prevent memory leaks
  996. jQuery( "*", this ).add(this).each(function(){
  997. jQuery.event.remove(this);
  998. jQuery.removeData(this);
  999. });
  1000. this.parentNode.removeChild( this );
  1001. }
  1002. },
  1003. empty: function() {
  1004. // Remove element nodes and prevent memory leaks
  1005. jQuery( ">*", this ).remove();
  1006. // Remove any remaining nodes
  1007. while ( this.firstChild )
  1008. this.removeChild( this.firstChild );
  1009. }
  1010. }, function(name, fn){
  1011. jQuery.fn[ name ] = function(){
  1012. return this.each( fn, arguments );
  1013. };
  1014. });
  1015. jQuery.each([ "Height", "Width" ], function(i, name){
  1016. var type = name.toLowerCase();
  1017. jQuery.fn[ type ] = function( size ) {
  1018. // Get window width or height
  1019. return this[0] == window ?
  1020. // Opera reports document.body.client[Width/Height] properly in both quirks and standards
  1021. jQuery.browser.opera && document.body[ "client" + name ] ||
  1022. // Safari reports inner[Width/Height] just fine (Mozilla and Opera include scroll bar widths)
  1023. jQuery.browser.safari && window[ "inner" + name ] ||
  1024. // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
  1025. document.compatMode == "CSS1Compat" && document.documentElement[ "client" + name ] || document.body[ "client" + name ] :
  1026. // Get document width or height
  1027. this[0] == document ?
  1028. // Either scroll[Width/Height] or offset[Width/Height], whichever is greater (Mozilla reports scrollWidth the same as offsetWidth)
  1029. Math.max( document.body[ "scroll" + name ], document.body[ "offset" + name ] ) :
  1030. // Get or set width or height on the element
  1031. size == undefined ?
  1032. // Get width or height on the element
  1033. (this.length ? jQuery.css( this[0], type ) : null) :
  1034. // Set the width or height on the element (default to pixels if value is unitless)
  1035. this.css( type, size.constructor == String ? size : size + "px" );
  1036. };
  1037. });
  1038. var chars = jQuery.browser.safari && parseInt(jQuery.browser.version) < 417 ?
  1039. "(?:[\\w*_-]|\\\\.)" :
  1040. "(?:[\\w\u0128-\uFFFF*_-]|\\\\.)",
  1041. quickChild = new RegExp("^>\\s*(" + chars + "+)"),
  1042. quickID = new RegExp("^(" + chars + "+)(#)(" + chars + "+)"),
  1043. quickClass = new RegExp("^([#.]?)(" + chars + "*)");
  1044. jQuery.extend({
  1045. expr: {
  1046. "": "m[2]=='*'||jQuery.nodeName(a,m[2])",
  1047. "#": "a.getAttribute('id')==m[2]",
  1048. ":": {
  1049. // Position Checks
  1050. lt: "i<m[3]-0",
  1051. gt: "i>m[3]-0",
  1052. nth: "m[3]-0==i",
  1053. eq: "m[3]-0==i",
  1054. first: "i==0",
  1055. last: "i==r.length-1",
  1056. even: "i%2==0",
  1057. odd: "i%2",
  1058. // Child Checks
  1059. "first-child": "a.parentNode.getElementsByTagName('*')[0]==a",
  1060. "last-child": "jQuery.nth(a.parentNode.lastChild,1,'previousSibling')==a",
  1061. "only-child": "!jQuery.nth(a.parentNode.lastChild,2,'previousSibling')",
  1062. // Parent Checks
  1063. parent: "a.firstChild",
  1064. empty: "!a.firstChild",
  1065. // Text Check
  1066. contains: "(a.textContent||a.innerText||jQuery(a).text()||'').indexOf(m[3])>=0",
  1067. // Visibility
  1068. visible: '"hidden"!=a.type&&jQuery.css(a,"display")!="none"&&jQuery.css(a,"visibility")!="hidden"',
  1069. hidden: '"hidden"==a.type||jQuery.css(a,"display")=="none"||jQuery.css(a,"visibility")=="hidden"',
  1070. // Form attributes
  1071. enabled: "!a.disabled",
  1072. disabled: "a.disabled",
  1073. checked: "a.checked",
  1074. selected: "a.selected||jQuery.attr(a,'selected')",
  1075. // Form elements
  1076. text: "'text'==a.type",
  1077. radio: "'radio'==a.type",
  1078. checkbox: "'checkbox'==a.type",
  1079. file: "'file'==a.type",
  1080. password: "'password'==a.type",
  1081. submit: "'submit'==a.type",
  1082. image: "'image'==a.type",
  1083. reset: "'reset'==a.type",
  1084. button: '"button"==a.type||jQuery.nodeName(a,"button")',
  1085. input: "/input|select|textarea|button/i.test(a.nodeName)",
  1086. // :has()
  1087. has: "jQuery.find(m[3],a).length",
  1088. // :header
  1089. header: "/h\\d/i.test(a.nodeName)",
  1090. // :animated
  1091. animated: "jQuery.grep(jQuery.timers,function(fn){return a==fn.elem;}).length"
  1092. }
  1093. },
  1094. // The regular expressions that power the parsing engine
  1095. parse: [
  1096. // Match: [@value='test'], [@foo]
  1097. /^(\[) *@?([\w-]+) *([!*$^~=]*) *('?"?)(.*?)\4 *\]/,
  1098. // Match: :contains('foo')
  1099. /^(:)([\w-]+)\("?'?(.*?(\(.*?\))?[^(]*?)"?'?\)/,
  1100. // Match: :even, :last-chlid, #id, .class
  1101. new RegExp("^([:.#]*)(" + chars + "+)")
  1102. ],
  1103. multiFilter: function( expr, elems, not ) {
  1104. var old, cur = [];
  1105. while ( expr && expr != old ) {
  1106. old = expr;
  1107. var f = jQuery.filter( expr, elems, not );
  1108. expr = f.t.replace(/^\s*,\s*/, "" );
  1109. cur = not ? elems = f.r : jQuery.merge( cur, f.r );
  1110. }
  1111. return cur;
  1112. },
  1113. find: function( t, context ) {
  1114. // Quickly handle non-string expressions
  1115. if ( typeof t != "string" )
  1116. return [ t ];
  1117. // Make sure that the context is a DOM Element
  1118. if ( context && !context.nodeType )
  1119. context = null;
  1120. // Set the correct context (if none is provided)
  1121. context = context || document;
  1122. // Initialize the search
  1123. var ret = [context], done = [], last;
  1124. // Continue while a selector expression exists, and while
  1125. // we're no longer looping upon ourselves
  1126. while ( t && last != t ) {
  1127. var r = [];
  1128. last = t;
  1129. t = jQuery.trim(t);
  1130. var foundToken = false;
  1131. // An attempt at speeding up child selectors that
  1132. // point to a specific element tag
  1133. var re = quickChild;
  1134. var m = re.exec(t);
  1135. if ( m ) {
  1136. var nodeName = m[1].toUpperCase();
  1137. // Perform our own iteration and filter
  1138. for ( var i = 0; ret[i]; i++ )
  1139. for ( var c = ret[i].firstChild; c; c = c.nextSibling )
  1140. if ( c.nodeType == 1 && (nodeName == "*" || c.nodeName.toUpperCase() == nodeName.toUpperCase()) )
  1141. r.push( c );
  1142. ret = r;
  1143. t = t.replace( re, "" );
  1144. if ( t.indexOf(" ") == 0 ) continue;
  1145. foundToken = true;
  1146. } else {
  1147. re = /^([>+~])\s*(\w*)/i;
  1148. if ( (m = re.exec(t)) != null ) {
  1149. r = [];
  1150. var nodeName = m[2], merge = {};
  1151. m = m[1];
  1152. for ( var j = 0, rl = ret.length; j < rl; j++ ) {
  1153. var n = m == "~" || m == "+" ? ret[j].nextSibling : ret[j].firstChild;
  1154. for ( ; n; n = n.nextSibling )
  1155. if ( n.nodeType == 1 ) {
  1156. var id = jQuery.data(n);
  1157. if ( m == "~" && merge[id] ) break;
  1158. if (!nodeName || n.nodeName.toUpperCase() == nodeName.toUpperCase() ) {
  1159. if ( m == "~" ) merge[id] = true;
  1160. r.push( n );
  1161. }
  1162. if ( m == "+" ) break;
  1163. }
  1164. }
  1165. ret = r;
  1166. // And remove the token
  1167. t = jQuery.trim( t.replace( re, "" ) );
  1168. foundToken = true;
  1169. }
  1170. }
  1171. // See if there's still an expression, and that we haven't already
  1172. // matched a token
  1173. if ( t && !foundToken ) {
  1174. // Handle multiple expressions
  1175. if ( !t.indexOf(",") ) {
  1176. // Clean the result set
  1177. if ( context == ret[0] ) ret.shift();
  1178. // Merge the result sets
  1179. done = jQuery.merge( done, ret );
  1180. // Reset the context
  1181. r = ret = [context];
  1182. // Touch up the selector string
  1183. t = " " + t.substr(1,t.length);
  1184. } else {
  1185. // Optimize for the case nodeName#idName
  1186. var re2 = quickID;
  1187. var m = re2.exec(t);
  1188. // Re-organize the results, so that they're consistent
  1189. if ( m ) {
  1190. m = [ 0, m[2], m[3], m[1] ];
  1191. } else {
  1192. // Otherwise, do a traditional filter check for
  1193. // ID, class, and element selectors
  1194. re2 = quickClass;
  1195. m = re2.exec(t);
  1196. }
  1197. m[2] = m[2].replace(/\\/g, "");
  1198. var elem = ret[ret.length-1];
  1199. // Try to do a global search by ID, where we can
  1200. if ( m[1] == "#" && elem && elem.getElementById && !jQuery.isXMLDoc(elem) ) {
  1201. // Optimization for HTML document case
  1202. var oid = elem.getElementById(m[2]);
  1203. // Do a quick check for the existence of the actual ID attribute
  1204. // to avoid selecting by the name attribute in IE
  1205. // also check to insure id is a string to avoid selecting an element with the name of 'id' inside a form
  1206. if ( (jQuery.browser.msie||jQuery.browser.opera) && oid && typeof oid.id == "string" && oid.id != m[2] )
  1207. oid = jQuery('[@id="'+m[2]+'"]', elem)[0];
  1208. // Do a quick check for node name (where applicable) so
  1209. // that div#foo searches will be really fast
  1210. ret = r = oid && (!m[3] || jQuery.nodeName(oid, m[3])) ? [oid] : [];
  1211. } else {
  1212. // We need to find all descendant elements
  1213. for ( var i = 0; ret[i]; i++ ) {
  1214. // Grab the tag name being searched for
  1215. var tag = m[1] == "#" && m[3] ? m[3] : m[1] != "" || m[0] == "" ? "*" : m[2];
  1216. // Handle IE7 being really dumb about <object>s
  1217. if ( tag == "*" && ret[i].nodeName.toLowerCase() == "object" )
  1218. tag = "param";
  1219. r = jQuery.merge( r, ret[i].getElementsByTagName( tag ));
  1220. }
  1221. // It's faster to filter by class and be done with it
  1222. if ( m[1] == "." )
  1223. r = jQuery.classFilter( r, m[2] );
  1224. // Same with ID filtering
  1225. if ( m[1] == "#" ) {
  1226. var tmp = [];
  1227. // Try to find the element with the ID
  1228. for ( var i = 0; r[i]; i++ )
  1229. if ( r[i].getAttribute("id") == m[2] ) {
  1230. tmp = [ r[i] ];
  1231. break;
  1232. }
  1233. r = tmp;
  1234. }
  1235. ret = r;
  1236. }
  1237. t = t.replace( re2, "" );
  1238. }
  1239. }
  1240. // If a selector string still exists
  1241. if ( t ) {
  1242. // Attempt to filter it
  1243. var val = jQuery.filter(t,r);
  1244. ret = r = val.r;
  1245. t = jQuery.trim(val.t);
  1246. }
  1247. }
  1248. // An error occurred with the selector;
  1249. // just return an empty set instead
  1250. if ( t )
  1251. ret = [];
  1252. // Remove the root context
  1253. if ( ret && context == ret[0] )
  1254. ret.shift();
  1255. // And combine the results
  1256. done = jQuery.merge( done, ret );
  1257. return done;
  1258. },
  1259. classFilter: function(r,m,not){
  1260. m = " " + m + " ";
  1261. var tmp = [];
  1262. for ( var i = 0; r[i]; i++ ) {
  1263. var pass = (" " + r[i].className + " ").indexOf( m ) >= 0;
  1264. if ( !not && pass || not && !pass )
  1265. tmp.push( r[i] );
  1266. }
  1267. return tmp;
  1268. },
  1269. filter: function(t,r,not) {
  1270. var last;
  1271. // Look for common filter expressions
  1272. while ( t && t != last ) {
  1273. last = t;
  1274. var p = jQuery.parse, m;
  1275. for ( var i = 0; p[i]; i++ ) {
  1276. m = p[i].exec( t );
  1277. if ( m ) {
  1278. // Remove what we just matched
  1279. t = t.substring( m[0].length );
  1280. m[2] = m[2].replace(/\\/g, "");
  1281. break;
  1282. }
  1283. }
  1284. if ( !m )
  1285. break;
  1286. // :not() is a special case that can be optimized by
  1287. // keeping it out of the expression list
  1288. if ( m[1] == ":" && m[2] == "not" )
  1289. r = jQuery.filter(m[3], r, true).r;
  1290. // We can get a big speed boost by filtering by class here
  1291. else if ( m[1] == "." )
  1292. r = jQuery.classFilter(r, m[2], not);
  1293. else if ( m[1] == "[" ) {
  1294. var tmp = [], type = m[3];
  1295. for ( var i = 0, rl = r.length; i < rl; i++ ) {
  1296. var a = r[i], z = a[ jQuery.props[m[2]] || m[2] ];
  1297. if ( z == null || /href|src|selected/.test(m[2]) )
  1298. z = jQuery.attr(a,m[2]) || '';
  1299. if ( (type == "" && !!z ||
  1300. type == "=" && z == m[5] ||
  1301. type == "!=" && z != m[5] ||
  1302. type == "^=" && z && !z.indexOf(m[5]) ||
  1303. type == "$=" && z.substr(z.length - m[5].length) == m[5] ||
  1304. (type == "*=" || type == "~=") && z.indexOf(m[5]) >= 0) ^ not )
  1305. tmp.push( a );
  1306. }
  1307. r = tmp;
  1308. // We can get a speed boost by handling nth-child here
  1309. } else if ( m[1] == ":" && m[2] == "nth-child" ) {
  1310. var merge = {}, tmp = [],
  1311. test = /(\d*)n\+?(\d*)/.exec(
  1312. m[3] == "even" && "2n" || m[3] == "odd" && "2n+1" ||
  1313. !/\D/.test(m[3]) && "n+" + m[3] || m[3]),
  1314. first = (test[1] || 1) - 0, last = test[2] - 0;
  1315. for ( var i = 0, rl = r.length; i < rl; i++ ) {
  1316. var node = r[i], parentNode = node.parentNode, id = jQuery.data(parentNode);
  1317. if ( !merge[id] ) {
  1318. var c = 1;
  1319. for ( var n = parentNode.firstChild; n; n = n.nextSibling )
  1320. if ( n.nodeType == 1 )
  1321. n.nodeIndex = c++;
  1322. merge[id] = true;
  1323. }
  1324. var add = false;
  1325. if ( first == 1 ) {
  1326. if ( last == 0 || node.nodeIndex == last )
  1327. add = true;
  1328. } else if ( (node.nodeIndex + last) % first == 0 )
  1329. add = true;
  1330. if ( add ^ not )
  1331. tmp.push( node );
  1332. }
  1333. r = tmp;
  1334. // Otherwise, find the expression to execute
  1335. } else {
  1336. var f = jQuery.expr[m[1]];
  1337. if ( typeof f != "string" )
  1338. f = jQuery.expr[m[1]][m[2]];
  1339. // Build a custom macro to enclose it
  1340. f = eval("false||function(a,i){return " + f + "}");
  1341. // Execute it against the current filter
  1342. r = jQuery.grep( r, f, not );
  1343. }
  1344. }
  1345. // Return an array of filtered elements (r)
  1346. // and the modified expression string (t)
  1347. return { r: r, t: t };
  1348. },
  1349. dir: function( elem, dir ){
  1350. var matched = [];
  1351. var cur = elem[dir];
  1352. while ( cur && cur != document ) {
  1353. if ( cur.nodeType == 1 )
  1354. matched.push( cur );
  1355. cur = cur[dir];
  1356. }
  1357. return matched;
  1358. },
  1359. nth: function(cur,result,dir,elem){
  1360. result = result || 1;
  1361. var num = 0;
  1362. for ( ; cur; cur = cur[dir] )
  1363. if ( cur.nodeType == 1 && ++num == result )
  1364. break;
  1365. return cur;
  1366. },
  1367. sibling: function( n, elem ) {
  1368. var r = [];
  1369. for ( ; n; n = n.nextSibling ) {
  1370. if ( n.nodeType == 1 && (!elem || n != elem) )
  1371. r.push( n );
  1372. }
  1373. return r;
  1374. }
  1375. });
  1376. /*
  1377. * A number of helper functions used for managing events.
  1378. * Many of the ideas behind this code orignated from
  1379. * Dean Edwards' addEvent library.
  1380. */
  1381. jQuery.event = {
  1382. // Bind an event to an element
  1383. // Original by Dean Edwards
  1384. add: function(element, type, handler, data) {
  1385. // For whatever reason, IE has trouble passing the window object
  1386. // around, causing it to be cloned in the process
  1387. if ( jQuery.browser.msie && element.setInterval != undefined )
  1388. element = window;
  1389. // Make sure that the function being executed has a unique ID
  1390. if ( !handler.guid )
  1391. handler.guid = this.guid++;
  1392. // if data is passed, bind to handler
  1393. if( data != undefined ) {
  1394. // Create temporary function pointer to original handler
  1395. var fn = handler;
  1396. // Create unique handler function, wrapped around original handler
  1397. handler = function() {
  1398. // Pass arguments and context to original handler
  1399. return fn.apply(this, arguments);
  1400. };
  1401. // Store data in unique handler
  1402. handler.data = data;
  1403. // Set the guid of unique handler to the same of original handler, so it can be removed
  1404. handler.guid = fn.guid;
  1405. }
  1406. // Namespaced event handlers
  1407. var parts = type.split(".");
  1408. type = parts[0];
  1409. handler.type = parts[1];
  1410. // Init the element's event structure
  1411. var events = jQuery.data(element, "events") || jQuery.data(element, "events", {});
  1412. var handle = jQuery.data(element, "handle") || jQuery.data(element, "handle", function(){
  1413. // returned undefined or false
  1414. var val;
  1415. // Handle the second event of a trigger and when
  1416. // an event is called after a page has unloaded
  1417. if ( typeof jQuery == "undefined" || jQuery.event.triggered )
  1418. return val;
  1419. val = jQuery.event.handle.apply(element, arguments);
  1420. return val;
  1421. });
  1422. // Get the current list of functions bound to this event
  1423. var handlers = events[type];
  1424. // Init the event handler queue
  1425. if (!handlers) {
  1426. handlers = events[type] = {};
  1427. // And bind the global event handler to the element
  1428. if (element.addEventListener)
  1429. element.addEventListener(type, handle, false);
  1430. else
  1431. element.attachEvent("on" + type, handle);
  1432. }
  1433. // Add the function to the element's handler list
  1434. handlers[handler.guid] = handler;
  1435. // Keep track of which events have been used, for global triggering
  1436. this.global[type] = true;
  1437. },
  1438. guid: 1,
  1439. global: {},
  1440. // Detach an event or set of events from an element
  1441. remove: function(element, type, handler) {
  1442. var events = jQuery.data(element, "events"), ret, index;
  1443. // Namespaced event handlers
  1444. if ( typeof type == "string" ) {
  1445. var parts = type.split(".");
  1446. type = parts[0];
  1447. }
  1448. if ( events ) {
  1449. // type is actually an event object here
  1450. if ( type && type.type ) {
  1451. handler = type.handler;
  1452. type = type.type;
  1453. }
  1454. if ( !type ) {
  1455. for ( type in events )
  1456. this.remove( element, type );
  1457. } else if ( events[type] ) {
  1458. // remove the given handler for the given type
  1459. if ( handler )
  1460. delete events[type][handler.guid];
  1461. // remove all handlers for the given type
  1462. else
  1463. for ( handler in events[type] )
  1464. // Handle the removal of namespaced events
  1465. if ( !parts[1] || events[type][handler].type == parts[1] )
  1466. delete events[type][handler];
  1467. // remove generic event handler if no more handlers exist
  1468. for ( ret in events[type] ) break;
  1469. if ( !ret ) {
  1470. if (element.removeEventListener)
  1471. element.removeEventListener(type, jQuery.data(element, "handle"), false);
  1472. else
  1473. element.detachEvent("on" + type, jQuery.data(element, "handle"));
  1474. ret = null;
  1475. delete events[type];
  1476. }
  1477. }
  1478. // Remove the expando if it's no longer used
  1479. for ( ret in events ) break;
  1480. if ( !ret ) {
  1481. jQuery.removeData( element, "events" );
  1482. jQuery.removeData( element, "handle" );
  1483. }
  1484. }
  1485. },
  1486. trigger: function(type, data, element, donative, extra) {
  1487. // Clone the incoming data, if any
  1488. data = jQuery.makeArray(data || []);
  1489. // Handle a global trigger
  1490. if ( !element ) {
  1491. // Only trigger if we've ever bound an event for it
  1492. if ( this.global[type] )
  1493. jQuery("*").add([window, document]).trigger(type, data);
  1494. // Handle triggering a single element
  1495. } else {
  1496. var val, ret, fn = jQuery.isFunction( element[ type ] || null ),
  1497. // Check to see if we need to provide a fake event, or not
  1498. event = !data[0] || !data[0].preventDefault;
  1499. // Pass along a fake event
  1500. if ( event )
  1501. data.unshift( this.fix({ type: type, target: element }) );
  1502. // Enforce the right trigger type
  1503. data[0].type = type;
  1504. // Trigger the event
  1505. if ( jQuery.isFunction( jQuery.data(element, "handle") ) )
  1506. val = jQuery.data(element, "handle").apply( element, data );
  1507. // Handle triggering native .onfoo handlers
  1508. if ( !fn && element["on"+type] && element["on"+type].apply( element, data ) === false )
  1509. val = false;
  1510. // Extra functions don't get the custom event object
  1511. if ( event )
  1512. data.shift();
  1513. // Handle triggering of extra function
  1514. if ( extra && extra.apply( element, data ) === false )
  1515. val = false;
  1516. // Trigger the native events (except for clicks on links)
  1517. if ( fn && donative !== false && val !== false && !(jQuery.nodeName(element, 'a') && type == "click") ) {
  1518. this.triggered = true;
  1519. element[ type ]();
  1520. }
  1521. this.triggered = false;
  1522. }
  1523. return val;
  1524. },
  1525. handle: function(event) {
  1526. // returned undefined or false
  1527. var val;
  1528. // Empty object is for triggered events with no data
  1529. event = jQuery.event.fix( event || window.event || {} );
  1530. // Namespaced event handlers
  1531. var parts = event.type.split(".");
  1532. event.type = parts[0];
  1533. var handlers = jQuery.data(this, "events") && jQuery.data(this, "events")[event.type], args = Array.prototype.slice.call( arguments, 1 );
  1534. args.unshift( event );
  1535. for ( var j in handlers ) {
  1536. var handler = handlers[j];
  1537. // Pass in a reference to the handler function itself
  1538. // So that we can later remove it
  1539. args[0].handler = handler;
  1540. args[0].data = handler.data;
  1541. // Filter the functions by class
  1542. if ( !parts[1] || handler.type == parts[1] ) {
  1543. var ret = handler.apply( this, args );
  1544. if ( val !== false )
  1545. val = ret;
  1546. if ( ret === false ) {
  1547. event.preventDefault();
  1548. event.stopPropagation();
  1549. }
  1550. }
  1551. }
  1552. // Clean up added properties in IE to prevent memory leak
  1553. if (jQuery.browser.msie)
  1554. event.target = event.preventDefault = event.stopPropagation =
  1555. event.handler = event.data = null;
  1556. return val;
  1557. },
  1558. fix: function(event) {
  1559. // store a copy of the original event object
  1560. // and clone to set read-only properties
  1561. var originalEvent = event;
  1562. event = jQuery.extend({}, originalEvent);
  1563. // add preventDefault and stopPropagation since
  1564. // they will not work on the clone
  1565. event.preventDefault = function() {
  1566. // if preventDefault exists run it on the original event
  1567. if (originalEvent.preventDefault)
  1568. originalEvent.preventDefault();
  1569. // otherwise set the returnValue property of the original event to false (IE)
  1570. originalEvent.returnValue = false;
  1571. };
  1572. event.stopPropagation = function() {
  1573. // if stopPropagation exists run it on the original event
  1574. if (originalEvent.stopPropagation)
  1575. originalEvent.stopPropagation();
  1576. // otherwise set the cancelBubble property of the original event to true (IE)
  1577. originalEvent.cancelBubble = true;
  1578. };
  1579. // Fix target property, if necessary
  1580. if ( !event.target && event.srcElement )
  1581. event.target = event.srcElement;
  1582. // check if target is a textnode (safari)
  1583. if (jQuery.browser.safari && event.target.nodeType == 3)
  1584. event.target = originalEvent.target.parentNode;
  1585. // Add relatedTarget, if necessary
  1586. if ( !event.relatedTarget && event.fromElement )
  1587. event.relatedTarget = event.fromElement == event.target ? event.toElement : event.fromElement;
  1588. // Calculate pageX/Y if missing and clientX/Y available
  1589. if ( event.pageX == null && event.clientX != null ) {
  1590. var doc = document.documentElement, body = document.body;
  1591. event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc.clientLeft || 0);
  1592. event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc.clientLeft || 0);
  1593. }
  1594. // Add which for key events
  1595. if ( !event.which && (event.charCode || event.keyCode) )
  1596. event.which = event.charCode || event.keyCode;
  1597. // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
  1598. if ( !event.metaKey && event.ctrlKey )
  1599. event.metaKey = event.ctrlKey;
  1600. // Add which for click: 1 == left; 2 == middle; 3 == right
  1601. // Note: button is not normalized, so don't use it
  1602. if ( !event.which && event.button )
  1603. event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) ));
  1604. return event;
  1605. }
  1606. };
  1607. jQuery.fn.extend({
  1608. bind: function( type, data, fn ) {
  1609. return type == "unload" ? this.one(type, data, fn) : this.each(function(){
  1610. jQuery.event.add( this, type, fn || data, fn && data );
  1611. });
  1612. },
  1613. one: function( type, data, fn ) {
  1614. return this.each(function(){
  1615. jQuery.event.add( this, type, function(event) {
  1616. jQuery(this).unbind(event);
  1617. return (fn || data).apply( this, arguments);
  1618. }, fn && data);
  1619. });
  1620. },
  1621. unbind: function( type, fn ) {
  1622. return this.each(function(){
  1623. jQuery.event.remove( this, type, fn );
  1624. });
  1625. },
  1626. trigger: function( type, data, fn ) {
  1627. return this.each(function(){
  1628. jQuery.event.trigger( type, data, this, true, fn );
  1629. });
  1630. },
  1631. triggerHandler: function( type, data, fn ) {
  1632. if ( this[0] )
  1633. return jQuery.event.trigger( type, data, this[0], false, fn );
  1634. },
  1635. toggle: function() {
  1636. // Save reference to arguments for access in closure
  1637. var args = arguments;
  1638. return this.click(function(event) {
  1639. // Figure out which function to execute
  1640. this.lastToggle = 0 == this.lastToggle ? 1 : 0;
  1641. // Make sure that clicks stop
  1642. event.preventDefault();
  1643. // and execute the function
  1644. return args[this.lastToggle].apply( this, [event] ) || false;
  1645. });
  1646. },
  1647. hover: function(fnOver, fnOut) {
  1648. // A private function for handling mouse 'hovering'
  1649. function handleHover(event) {
  1650. // Check if mouse(over|out) are still within the same parent element
  1651. var parent = event.relatedTarget;
  1652. // Traverse up the tree
  1653. while ( parent && parent != this ) try { parent = parent.parentNode; } catch(error) { parent = this; };
  1654. // If we actually just moused on to a sub-element, ignore it
  1655. if ( parent == this ) return false;
  1656. // Execute the right function
  1657. return (event.type == "mouseover" ? fnOver : fnOut).apply(this, [event]);
  1658. }
  1659. // Bind the function to the two event listeners
  1660. return this.mouseover(handleHover).mouseout(handleHover);
  1661. },
  1662. ready: function(fn) {
  1663. // Attach the listeners
  1664. bindReady();
  1665. // If the DOM is already ready
  1666. if ( jQuery.isReady )
  1667. // Execute the function immediately
  1668. fn.apply( document, [jQuery] );
  1669. // Otherwise, remember the function for later
  1670. else
  1671. // Add the function to the wait list
  1672. jQuery.readyList.push( function() { return fn.apply(this, [jQuery]); } );
  1673. return this;
  1674. }
  1675. });
  1676. jQuery.extend({
  1677. /*
  1678. * All the code that makes DOM Ready work nicely.
  1679. */
  1680. isReady: false,
  1681. readyList: [],
  1682. // Handle when the DOM is ready
  1683. ready: function() {
  1684. // Make sure that the DOM is not already loaded
  1685. if ( !jQuery.isReady ) {
  1686. // Remember that the DOM is ready
  1687. jQuery.isReady = true;
  1688. // If there are functions bound, to execute
  1689. if ( jQuery.readyList ) {
  1690. // Execute all of them
  1691. jQuery.each( jQuery.readyList, function(){
  1692. this.apply( document );
  1693. });
  1694. // Reset the list of functions
  1695. jQuery.readyList = null;
  1696. }
  1697. // Remove event listener to avoid memory leak
  1698. if ( jQuery.browser.mozilla || jQuery.browser.opera )
  1699. document.removeEventListener( "DOMContentLoaded", jQuery.ready, false );
  1700. }
  1701. }
  1702. });
  1703. jQuery.each( ("blur,focus,load,resize,scroll,unload,click,dblclick," +
  1704. "mousedown,mouseup,mousemove,mouseover,mouseout,change,select," +
  1705. "submit,keydown,keypress,keyup,error").split(","), function(i, name){
  1706. // Handle event binding
  1707. jQuery.fn[name] = function(fn){
  1708. return fn ? this.bind(name, fn) : this.trigger(name);
  1709. };
  1710. });
  1711. var readyBound = false;
  1712. function bindReady(){
  1713. if ( readyBound ) return;
  1714. readyBound = true;
  1715. // If Mozilla is used
  1716. if ( jQuery.browser.mozilla || jQuery.browser.opera )
  1717. // Use the handy event callback
  1718. document.addEventListener( "DOMContentLoaded", jQuery.ready, false );
  1719. // If Safari or IE is used
  1720. // Continually check to see if the document is ready
  1721. else (function(){
  1722. try {
  1723. // If IE is used, use the trick by Diego Perini
  1724. // http://javascript.nwbox.com/IEContentLoaded/
  1725. if ( jQuery.browser.msie || document.readyState != "loaded" && document.readyState != "complete" )
  1726. document.documentElement.doScroll("left");
  1727. } catch( error ) {
  1728. return setTimeout( arguments.callee, 0 );
  1729. }
  1730. // and execute any waiting functions
  1731. jQuery.ready();
  1732. })();
  1733. // A fallback to window.onload, that will always work
  1734. jQuery.event.add( window, "load", jQuery.ready );
  1735. }
  1736. // Prevent memory leaks in IE
  1737. if ( jQuery.browser.msie )
  1738. jQuery(window).bind("unload", function() {
  1739. $("*").add([document, window]).unbind();
  1740. });jQuery.fn.extend({
  1741. load: function( url, params, callback ) {
  1742. if ( jQuery.isFunction( url ) )
  1743. return this.bind("load", url);
  1744. var off = url.indexOf(" ");
  1745. if ( off >= 0 ) {
  1746. var selector = url.slice(off, url.length);
  1747. url = url.slice(0, off);
  1748. }
  1749. callback = callback || function(){};
  1750. // Default to a GET request
  1751. var type = "GET";
  1752. // If the second parameter was provided
  1753. if ( params )
  1754. // If it's a function
  1755. if ( jQuery.isFunction( params ) ) {
  1756. // We assume that it's the callback
  1757. callback = params;
  1758. params = null;
  1759. // Otherwise, build a param string
  1760. } else {
  1761. params = jQuery.param( params );
  1762. type = "POST";
  1763. }
  1764. var self = this;
  1765. // Request the remote document
  1766. jQuery.ajax({
  1767. url: url,
  1768. type: type,
  1769. data: params,
  1770. complete: function(res, status){
  1771. // If successful, inject the HTML into all the matched elements
  1772. if ( status == "success" || status == "notmodified" )
  1773. // See if a selector was specified
  1774. self.html( selector ?
  1775. // Create a dummy div to hold the results
  1776. jQuery("<div/>")
  1777. // inject the contents of the document in, removing the scripts
  1778. // to avoid any 'Permission Denied' errors in IE
  1779. .append(res.responseText.replace(/<script(.|\s)*?\/script>/g, ""))
  1780. // Locate the specified elements
  1781. .find(selector) :
  1782. // If not, just inject the full result
  1783. res.responseText );
  1784. // Add delay to account for Safari's delay in globalEval
  1785. setTimeout(function(){
  1786. self.each( callback, [res.responseText, status, res] );
  1787. }, 13);
  1788. }
  1789. });
  1790. return this;
  1791. },
  1792. serialize: function() {
  1793. return jQuery.param(this.serializeArray());
  1794. },
  1795. serializeArray: function() {
  1796. return this.map(function(){
  1797. return jQuery.nodeName(this, "form") ?
  1798. jQuery.makeArray(this.elements) : this;
  1799. })
  1800. .filter(function(){
  1801. return this.name && !this.disabled &&
  1802. (this.checked || /select|textarea/i.test(this.nodeName) ||
  1803. /text|hidden|password/i.test(this.type));
  1804. })
  1805. .map(function(i, elem){
  1806. var val = jQuery(this).val();
  1807. return val == null ? null :
  1808. val.constructor == Array ?
  1809. jQuery.map( val, function(val, i){
  1810. return {name: elem.name, value: val};
  1811. }) :
  1812. {name: elem.name, value: val};
  1813. }).get();
  1814. }
  1815. });
  1816. // Attach a bunch of functions for handling common AJAX events
  1817. jQuery.each( "ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","), function(i,o){
  1818. jQuery.fn[o] = function(f){
  1819. return this.bind(o, f);
  1820. };
  1821. });
  1822. var jsc = (new Date).getTime();
  1823. jQuery.extend({
  1824. get: function( url, data, callback, type ) {
  1825. // shift arguments if data argument was ommited
  1826. if ( jQuery.isFunction( data ) ) {
  1827. callback = data;
  1828. data = null;
  1829. }
  1830. return jQuery.ajax({
  1831. type: "GET",
  1832. url: url,
  1833. data: data,
  1834. success: callback,
  1835. dataType: type
  1836. });
  1837. },
  1838. getScript: function( url, callback ) {
  1839. return jQuery.get(url, null, callback, "script");
  1840. },
  1841. getJSON: function( url, data, callback ) {
  1842. return jQuery.get(url, data, callback, "json");
  1843. },
  1844. post: function( url, data, callback, type ) {
  1845. if ( jQuery.isFunction( data ) ) {
  1846. callback = data;
  1847. data = {};
  1848. }
  1849. return jQuery.ajax({
  1850. type: "POST",
  1851. url: url,
  1852. data: data,
  1853. success: callback,
  1854. dataType: type
  1855. });
  1856. },
  1857. ajaxSetup: function( settings ) {
  1858. jQuery.extend( jQuery.ajaxSettings, settings );
  1859. },
  1860. ajaxSettings: {
  1861. global: true,
  1862. type: "GET",
  1863. timeout: 0,
  1864. contentType: "application/x-www-form-urlencoded",
  1865. processData: true,
  1866. async: true,
  1867. data: null
  1868. },
  1869. // Last-Modified header cache for next request
  1870. lastModified: {},
  1871. ajax: function( s ) {
  1872. var jsonp, jsre = /=(\?|%3F)/g, status, data;
  1873. // Extend the settings, but re-extend 's' so that it can be
  1874. // checked again later (in the test suite, specifically)
  1875. s = jQuery.extend(true, s, jQuery.extend(true, {}, jQuery.ajaxSettings, s));
  1876. // convert data if not already a string
  1877. if ( s.data && s.processData && typeof s.data != "string" )
  1878. s.data = jQuery.param(s.data);
  1879. // Handle JSONP Parameter Callbacks
  1880. if ( s.dataType == "jsonp" ) {
  1881. if ( s.type.toLowerCase() == "get" ) {
  1882. if ( !s.url.match(jsre) )
  1883. s.url += (s.url.match(/\?/) ? "&" : "?") + (s.jsonp || "callback") + "=?";
  1884. } else if ( !s.data || !s.data.match(jsre) )
  1885. s.data = (s.data ? s.data + "&" : "") + (s.jsonp || "callback") + "=?";
  1886. s.dataType = "json";
  1887. }
  1888. // Build temporary JSONP function
  1889. if ( s.dataType == "json" && (s.data && jsre.test( s.data ) || s.url.match(jsre)) ) {
  1890. jsonp = "jsonp" + jsc++;
  1891. // Replace the =? sequence both in the query string and the data
  1892. if ( s.data )
  1893. s.data = (s.data + "").replace(jsre, "=" + jsonp);
  1894. s.url = s.url.replace(jsre, "=" + jsonp);
  1895. // We need to make sure
  1896. // that a JSONP style response is executed properly
  1897. s.dataType = "script";
  1898. // Handle JSONP-style loading
  1899. window[ jsonp ] = function(tmp){
  1900. data = tmp;
  1901. success();
  1902. complete();
  1903. // Garbage collect
  1904. window[ jsonp ] = undefined;
  1905. try{ delete window[ jsonp ]; } catch(e){}
  1906. };
  1907. }
  1908. if ( s.dataType == "script" && s.cache == null )
  1909. s.cache = false;
  1910. if ( s.cache === false && s.type.toLowerCase() == "get" )
  1911. s.url += (s.url.match(/\?/) ? "&" : "?") + "_=" + (new Date()).getTime();
  1912. // If data is available, append data to url for get requests
  1913. if ( s.data && s.type.toLowerCase() == "get" ) {
  1914. s.url += (s.url.match(/\?/) ? "&" : "?") + s.data;
  1915. // IE likes to send both get and post data, prevent this
  1916. s.data = null;
  1917. }
  1918. // Watch for a new set of requests
  1919. if ( s.global && ! jQuery.active++ )
  1920. jQuery.event.trigger( "ajaxStart" );
  1921. // If we're requesting a remote document
  1922. // and trying to load JSON or Script
  1923. if ( !s.url.indexOf("http") && s.dataType == "script" ) {
  1924. var head = document.getElementsByTagName("head")[0];
  1925. var script = document.createElement("script");
  1926. script.src = s.url;
  1927. // Handle Script loading
  1928. if ( !jsonp ) {
  1929. var done = false;
  1930. // Attach handlers for all browsers
  1931. script.onload = script.onreadystatechange = function(){
  1932. if ( !done && (!this.readyState ||
  1933. this.readyState == "loaded" || this.readyState == "complete") ) {
  1934. done = true;
  1935. success();
  1936. complete();
  1937. head.removeChild( script );
  1938. }
  1939. };
  1940. }
  1941. head.appendChild(script);
  1942. // We handle everything using the script element injection
  1943. return;
  1944. }
  1945. var requestDone = false;
  1946. // Create the request object; Microsoft failed to properly
  1947. // implement the XMLHttpRequest in IE7, so we use the ActiveXObject when it is available
  1948. var xml = window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
  1949. // Open the socket
  1950. xml.open(s.type, s.url, s.async);
  1951. // Set the correct header, if data is being sent
  1952. if ( s.data )
  1953. xml.setRequestHeader("Content-Type", s.contentType);
  1954. // Set the If-Modified-Since header, if ifModified mode.
  1955. if ( s.ifModified )
  1956. xml.setRequestHeader("If-Modified-Since",
  1957. jQuery.lastModified[s.url] || "Thu, 01 Jan 1970 00:00:00 GMT" );
  1958. // Set header so the called script knows that it's an XMLHttpRequest
  1959. xml.setRequestHeader("X-Requested-With", "XMLHttpRequest");
  1960. // Allow custom headers/mimetypes
  1961. if ( s.beforeSend )
  1962. s.beforeSend(xml);
  1963. if ( s.global )
  1964. jQuery.event.trigger("ajaxSend", [xml, s]);
  1965. // Wait for a response to come back
  1966. var onreadystatechange = function(isTimeout){
  1967. // The transfer is complete and the data is available, or the request timed out
  1968. if ( !requestDone && xml && (xml.readyState == 4 || isTimeout == "timeout") ) {
  1969. requestDone = true;
  1970. // clear poll interval
  1971. if (ival) {
  1972. clearInterval(ival);
  1973. ival = null;
  1974. }
  1975. status = isTimeout == "timeout" && "timeout" ||
  1976. !jQuery.httpSuccess( xml ) && "error" ||
  1977. s.ifModified && jQuery.httpNotModified( xml, s.url ) && "notmodified" ||
  1978. "success";
  1979. if ( status == "success" ) {
  1980. // Watch for, and catch, XML document parse errors
  1981. try {
  1982. // process the data (runs the xml through httpData regardless of callback)
  1983. data = jQuery.httpData( xml, s.dataType );
  1984. } catch(e) {
  1985. status = "parsererror";
  1986. }
  1987. }
  1988. // Make sure that the request was successful or notmodified
  1989. if ( status == "success" ) {
  1990. // Cache Last-Modified header, if ifModified mode.
  1991. var modRes;
  1992. try {
  1993. modRes = xml.getResponseHeader("Last-Modified");
  1994. } catch(e) {} // swallow exception thrown by FF if header is not available
  1995. if ( s.ifModified && modRes )
  1996. jQuery.lastModified[s.url] = modRes;
  1997. // JSONP handles its own success callback
  1998. if ( !jsonp )
  1999. success();
  2000. } else
  2001. jQuery.handleError(s, xml, status);
  2002. // Fire the complete handlers
  2003. complete();
  2004. // Stop memory leaks
  2005. if ( s.async )
  2006. xml = null;
  2007. }
  2008. };
  2009. if ( s.async ) {
  2010. // don't attach the handler to the request, just poll it instead
  2011. var ival = setInterval(onreadystatechange, 13);
  2012. // Timeout checker
  2013. if ( s.timeout > 0 )
  2014. setTimeout(function(){
  2015. // Check to see if the request is still happening
  2016. if ( xml ) {
  2017. // Cancel the request
  2018. xml.abort();
  2019. if( !requestDone )
  2020. onreadystatechange( "timeout" );
  2021. }
  2022. }, s.timeout);
  2023. }
  2024. // Send the data
  2025. try {
  2026. xml.send(s.data);
  2027. } catch(e) {
  2028. jQuery.handleError(s, xml, null, e);
  2029. }
  2030. // firefox 1.5 doesn't fire statechange for sync requests
  2031. if ( !s.async )
  2032. onreadystatechange();
  2033. // return XMLHttpRequest to allow aborting the request etc.
  2034. return xml;
  2035. function success(){
  2036. // If a local callback was specified, fire it and pass it the data
  2037. if ( s.success )
  2038. s.success( data, status );
  2039. // Fire the global callback
  2040. if ( s.global )
  2041. jQuery.event.trigger( "ajaxSuccess", [xml, s] );
  2042. }
  2043. function complete(){
  2044. // Process result
  2045. if ( s.complete )
  2046. s.complete(xml, status);
  2047. // The request was completed
  2048. if ( s.global )
  2049. jQuery.event.trigger( "ajaxComplete", [xml, s] );
  2050. // Handle the global AJAX counter
  2051. if ( s.global && ! --jQuery.active )
  2052. jQuery.event.trigger( "ajaxStop" );
  2053. }
  2054. },
  2055. handleError: function( s, xml, status, e ) {
  2056. // If a local callback was specified, fire it
  2057. if ( s.error ) s.error( xml, status, e );
  2058. // Fire the global callback
  2059. if ( s.global )
  2060. jQuery.event.trigger( "ajaxError", [xml, s, e] );
  2061. },
  2062. // Counter for holding the number of active queries
  2063. active: 0,
  2064. // Determines if an XMLHttpRequest was successful or not
  2065. httpSuccess: function( r ) {
  2066. try {
  2067. return !r.status && location.protocol == "file:" ||
  2068. ( r.status >= 200 && r.status < 300 ) || r.status == 304 ||
  2069. jQuery.browser.safari && r.status == undefined;
  2070. } catch(e){}
  2071. return false;
  2072. },
  2073. // Determines if an XMLHttpRequest returns NotModified
  2074. httpNotModified: function( xml, url ) {
  2075. try {
  2076. var xmlRes = xml.getResponseHeader("Last-Modified");
  2077. // Firefox always returns 200. check Last-Modified date
  2078. return xml.status == 304 || xmlRes == jQuery.lastModified[url] ||
  2079. jQuery.browser.safari && xml.status == undefined;
  2080. } catch(e){}
  2081. return false;
  2082. },
  2083. httpData: function( r, type ) {
  2084. var ct = r.getResponseHeader("content-type");
  2085. var xml = type == "xml" || !type && ct && ct.indexOf("xml") >= 0;
  2086. var data = xml ? r.responseXML : r.responseText;
  2087. if ( xml && data.documentElement.tagName == "parsererror" )
  2088. throw "parsererror";
  2089. // If the type is "script", eval it in global context
  2090. if ( type == "script" )
  2091. jQuery.globalEval( data );
  2092. // Get the JavaScript object, if JSON is used.
  2093. if ( type == "json" )
  2094. data = eval("(" + data + ")");
  2095. return data;
  2096. },
  2097. // Serialize an array of form elements or a set of
  2098. // key/values into a query string
  2099. param: function( a ) {
  2100. var s = [];
  2101. // If an array was passed in, assume that it is an array
  2102. // of form elements
  2103. if ( a.constructor == Array || a.jquery )
  2104. // Serialize the form elements
  2105. jQuery.each( a, function(){
  2106. s.push( encodeURIComponent(this.name) + "=" + encodeURIComponent( this.value ) );
  2107. });
  2108. // Otherwise, assume that it's an object of key/value pairs
  2109. else
  2110. // Serialize the key/values
  2111. for ( var j in a )
  2112. // If the value is an array then the key names need to be repeated
  2113. if ( a[j] && a[j].constructor == Array )
  2114. jQuery.each( a[j], function(){
  2115. s.push( encodeURIComponent(j) + "=" + encodeURIComponent( this ) );
  2116. });
  2117. else
  2118. s.push( encodeURIComponent(j) + "=" + encodeURIComponent( a[j] ) );
  2119. // Return the resulting serialization
  2120. return s.join("&").replace(/%20/g, "+");
  2121. }
  2122. });
  2123. jQuery.fn.extend({
  2124. show: function(speed,callback){
  2125. return speed ?
  2126. this.animate({
  2127. height: "show", width: "show", opacity: "show"
  2128. }, speed, callback) :
  2129. this.filter(":hidden").each(function(){
  2130. this.style.display = this.oldblock ? this.oldblock : "";
  2131. if ( jQuery.css(this,"display") == "none" )
  2132. this.style.display = "block";
  2133. }).end();
  2134. },
  2135. hide: function(speed,callback){
  2136. return speed ?
  2137. this.animate({
  2138. height: "hide", width: "hide", opacity: "hide"
  2139. }, speed, callback) :
  2140. this.filter(":visible").each(function(){
  2141. this.oldblock = this.oldblock || jQuery.css(this,"display");
  2142. if ( this.oldblock == "none" )
  2143. this.oldblock = "block";
  2144. this.style.display = "none";
  2145. }).end();
  2146. },
  2147. // Save the old toggle function
  2148. _toggle: jQuery.fn.toggle,
  2149. toggle: function( fn, fn2 ){
  2150. return jQuery.isFunction(fn) && jQuery.isFunction(fn2) ?
  2151. this._toggle( fn, fn2 ) :
  2152. fn ?
  2153. this.animate({
  2154. height: "toggle", width: "toggle", opacity: "toggle"
  2155. }, fn, fn2) :
  2156. this.each(function(){
  2157. jQuery(this)[ jQuery(this).is(":hidden") ? "show" : "hide" ]();
  2158. });
  2159. },
  2160. slideDown: function(speed,callback){
  2161. return this.animate({height: "show"}, speed, callback);
  2162. },
  2163. slideUp: function(speed,callback){
  2164. return this.animate({height: "hide"}, speed, callback);
  2165. },
  2166. slideToggle: function(speed, callback){
  2167. return this.animate({height: "toggle"}, speed, callback);
  2168. },
  2169. fadeIn: function(speed, callback){
  2170. return this.animate({opacity: "show"}, speed, callback);
  2171. },
  2172. fadeOut: function(speed, callback){
  2173. return this.animate({opacity: "hide"}, speed, callback);
  2174. },
  2175. fadeTo: function(speed,to,callback){
  2176. return this.animate({opacity: to}, speed, callback);
  2177. },
  2178. animate: function( prop, speed, easing, callback ) {
  2179. var optall = jQuery.speed(speed, easing, callback);
  2180. return this[ optall.queue === false ? "each" : "queue" ](function(){
  2181. var opt = jQuery.extend({}, optall);
  2182. var hidden = jQuery(this).is(":hidden"), self = this;
  2183. for ( var p in prop ) {
  2184. if ( prop[p] == "hide" && hidden || prop[p] == "show" && !hidden )
  2185. return jQuery.isFunction(opt.complete) && opt.complete.apply(this);
  2186. if ( p == "height" || p == "width" ) {
  2187. // Store display property
  2188. opt.display = jQuery.css(this, "display");
  2189. // Make sure that nothing sneaks out
  2190. opt.overflow = this.style.overflow;
  2191. }
  2192. }
  2193. if ( opt.overflow != null )
  2194. this.style.overflow = "hidden";
  2195. opt.curAnim = jQuery.extend({}, prop);
  2196. jQuery.each( prop, function(name, val){
  2197. var e = new jQuery.fx( self, opt, name );
  2198. if ( /toggle|show|hide/.test(val) )
  2199. e[ val == "toggle" ? hidden ? "show" : "hide" : val ]( prop );
  2200. else {
  2201. var parts = val.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/),
  2202. start = e.cur(true) || 0;
  2203. if ( parts ) {
  2204. var end = parseFloat(parts[2]),
  2205. unit = parts[3] || "px";
  2206. // We need to compute starting value
  2207. if ( unit != "px" ) {
  2208. self.style[ name ] = (end || 1) + unit;
  2209. start = ((end || 1) / e.cur(true)) * start;
  2210. self.style[ name ] = start + unit;
  2211. }
  2212. // If a +=/-= token was provided, we're doing a relative animation
  2213. if ( parts[1] )
  2214. end = ((parts[1] == "-=" ? -1 : 1) * end) + start;
  2215. e.custom( start, end, unit );
  2216. } else
  2217. e.custom( start, val, "" );
  2218. }
  2219. });
  2220. // For JS strict compliance
  2221. return true;
  2222. });
  2223. },
  2224. queue: function(type, fn){
  2225. if ( jQuery.isFunction(type) ) {
  2226. fn = type;
  2227. type = "fx";
  2228. }
  2229. if ( !type || (typeof type == "string" && !fn) )
  2230. return queue( this[0], type );
  2231. return this.each(function(){
  2232. if ( fn.constructor == Array )
  2233. queue(this, type, fn);
  2234. else {
  2235. queue(this, type).push( fn );
  2236. if ( queue(this, type).length == 1 )
  2237. fn.apply(this);
  2238. }
  2239. });
  2240. },
  2241. stop: function(){
  2242. var timers = jQuery.timers;
  2243. return this.each(function(){
  2244. for ( var i = 0; i < timers.length; i++ )
  2245. if ( timers[i].elem == this )
  2246. timers.splice(i--, 1);
  2247. }).dequeue();
  2248. }
  2249. });
  2250. var queue = function( elem, type, array ) {
  2251. if ( !elem )
  2252. return;
  2253. var q = jQuery.data( elem, type + "queue" );
  2254. if ( !q || array )
  2255. q = jQuery.data( elem, type + "queue",
  2256. array ? jQuery.makeArray(array) : [] );
  2257. return q;
  2258. };
  2259. jQuery.fn.dequeue = function(type){
  2260. type = type || "fx";
  2261. return this.each(function(){
  2262. var q = queue(this, type);
  2263. q.shift();
  2264. if ( q.length )
  2265. q[0].apply( this );
  2266. });
  2267. };
  2268. jQuery.extend({
  2269. speed: function(speed, easing, fn) {
  2270. var opt = speed && speed.constructor == Object ? speed : {
  2271. complete: fn || !fn && easing ||
  2272. jQuery.isFunction( speed ) && speed,
  2273. duration: speed,
  2274. easing: fn && easing || easing && easing.constructor != Function && easing
  2275. };
  2276. opt.duration = (opt.duration && opt.duration.constructor == Number ?
  2277. opt.duration :
  2278. { slow: 600, fast: 200 }[opt.duration]) || 400;
  2279. // Queueing
  2280. opt.old = opt.complete;
  2281. opt.complete = function(){
  2282. jQuery(this).dequeue();
  2283. if ( jQuery.isFunction( opt.old ) )
  2284. opt.old.apply( this );
  2285. };
  2286. return opt;
  2287. },
  2288. easing: {
  2289. linear: function( p, n, firstNum, diff ) {
  2290. return firstNum + diff * p;
  2291. },
  2292. swing: function( p, n, firstNum, diff ) {
  2293. return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum;
  2294. }
  2295. },
  2296. timers: [],
  2297. fx: function( elem, options, prop ){
  2298. this.options = options;
  2299. this.elem = elem;
  2300. this.prop = prop;
  2301. if ( !options.orig )
  2302. options.orig = {};
  2303. }
  2304. });
  2305. jQuery.fx.prototype = {
  2306. // Simple function for setting a style value
  2307. update: function(){
  2308. if ( this.options.step )
  2309. this.options.step.apply( this.elem, [ this.now, this ] );
  2310. (jQuery.fx.step[this.prop] || jQuery.fx.step._default)( this );
  2311. // Set display property to block for height/width animations
  2312. if ( this.prop == "height" || this.prop == "width" )
  2313. this.elem.style.display = "block";
  2314. },
  2315. // Get the current size
  2316. cur: function(force){
  2317. if ( this.elem[this.prop] != null && this.elem.style[this.prop] == null )
  2318. return this.elem[ this.prop ];
  2319. var r = parseFloat(jQuery.curCSS(this.elem, this.prop, force));
  2320. return r && r > -10000 ? r : parseFloat(jQuery.css(this.elem, this.prop)) || 0;
  2321. },
  2322. // Start an animation from one number to another
  2323. custom: function(from, to, unit){
  2324. this.startTime = (new Date()).getTime();
  2325. this.start = from;
  2326. this.end = to;
  2327. this.unit = unit || this.unit || "px";
  2328. this.now = this.start;
  2329. this.pos = this.state = 0;
  2330. this.update();
  2331. var self = this;
  2332. function t(){
  2333. return self.step();
  2334. }
  2335. t.elem = this.elem;
  2336. jQuery.timers.push(t);
  2337. if ( jQuery.timers.length == 1 ) {
  2338. var timer = setInterval(function(){
  2339. var timers = jQuery.timers;
  2340. for ( var i = 0; i < timers.length; i++ )
  2341. if ( !timers[i]() )
  2342. timers.splice(i--, 1);
  2343. if ( !timers.length )
  2344. clearInterval( timer );
  2345. }, 13);
  2346. }
  2347. },
  2348. // Simple 'show' function
  2349. show: function(){
  2350. // Remember where we started, so that we can go back to it later
  2351. this.options.orig[this.prop] = jQuery.attr( this.elem.style, this.prop );
  2352. this.options.show = true;
  2353. // Begin the animation
  2354. this.custom(0, this.cur());
  2355. // Make sure that we start at a small width/height to avoid any
  2356. // flash of content
  2357. if ( this.prop == "width" || this.prop == "height" )
  2358. this.elem.style[this.prop] = "1px";
  2359. // Start by showing the element
  2360. jQuery(this.elem).show();
  2361. },
  2362. // Simple 'hide' function
  2363. hide: function(){
  2364. // Remember where we started, so that we can go back to it later
  2365. this.options.orig[this.prop] = jQuery.attr( this.elem.style, this.prop );
  2366. this.options.hide = true;
  2367. // Begin the animation
  2368. this.custom(this.cur(), 0);
  2369. },
  2370. // Each step of an animation
  2371. step: function(){
  2372. var t = (new Date()).getTime();
  2373. if ( t > this.options.duration + this.startTime ) {
  2374. this.now = this.end;
  2375. this.pos = this.state = 1;
  2376. this.update();
  2377. this.options.curAnim[ this.prop ] = true;
  2378. var done = true;
  2379. for ( var i in this.options.curAnim )
  2380. if ( this.options.curAnim[i] !== true )
  2381. done = false;
  2382. if ( done ) {
  2383. if ( this.options.display != null ) {
  2384. // Reset the overflow
  2385. this.elem.style.overflow = this.options.overflow;
  2386. // Reset the display
  2387. this.elem.style.display = this.options.display;
  2388. if ( jQuery.css(this.elem, "display") == "none" )
  2389. this.elem.style.display = "block";
  2390. }
  2391. // Hide the element if the "hide" operation was done
  2392. if ( this.options.hide )
  2393. this.elem.style.display = "none";
  2394. // Reset the properties, if the item has been hidden or shown
  2395. if ( this.options.hide || this.options.show )
  2396. for ( var p in this.options.curAnim )
  2397. jQuery.attr(this.elem.style, p, this.options.orig[p]);
  2398. }
  2399. // If a callback was provided, execute it
  2400. if ( done && jQuery.isFunction( this.options.complete ) )
  2401. // Execute the complete function
  2402. this.options.complete.apply( this.elem );
  2403. return false;
  2404. } else {
  2405. var n = t - this.startTime;
  2406. this.state = n / this.options.duration;
  2407. // Perform the easing function, defaults to swing
  2408. this.pos = jQuery.easing[this.options.easing || (jQuery.easing.swing ? "swing" : "linear")](this.state, n, 0, 1, this.options.duration);
  2409. this.now = this.start + ((this.end - this.start) * this.pos);
  2410. // Perform the next step of the animation
  2411. this.update();
  2412. }
  2413. return true;
  2414. }
  2415. };
  2416. jQuery.fx.step = {
  2417. scrollLeft: function(fx){
  2418. fx.elem.scrollLeft = fx.now;
  2419. },
  2420. scrollTop: function(fx){
  2421. fx.elem.scrollTop = fx.now;
  2422. },
  2423. opacity: function(fx){
  2424. jQuery.attr(fx.elem.style, "opacity", fx.now);
  2425. },
  2426. _default: function(fx){
  2427. fx.elem.style[ fx.prop ] = fx.now + fx.unit;
  2428. }
  2429. };
  2430. // The Offset Method
  2431. // Originally By Brandon Aaron, part of the Dimension Plugin
  2432. // http://jquery.com/plugins/project/dimensions
  2433. jQuery.fn.offset = function() {
  2434. var left = 0, top = 0, elem = this[0], results;
  2435. if ( elem ) with ( jQuery.browser ) {
  2436. var parent = elem.parentNode,
  2437. offsetChild = elem,
  2438. offsetParent = elem.offsetParent,
  2439. doc = elem.ownerDocument,
  2440. safari2 = safari && parseInt(version) < 522,
  2441. fixed = jQuery.css(elem, "position") == "fixed";
  2442. // Use getBoundingClientRect if available
  2443. if ( elem.getBoundingClientRect ) {
  2444. var box = elem.getBoundingClientRect();
  2445. // Add the document scroll offsets
  2446. add(
  2447. box.left + Math.max(doc.documentElement.scrollLeft, doc.body.scrollLeft),
  2448. box.top + Math.max(doc.documentElement.scrollTop, doc.body.scrollTop)
  2449. );
  2450. // IE adds the HTML element's border, by default it is medium which is 2px
  2451. // IE 6 and IE 7 quirks mode the border width is overwritable by the following css html { border: 0; }
  2452. // IE 7 standards mode, the border is always 2px
  2453. if ( msie ) {
  2454. var border = jQuery("html").css("borderWidth");
  2455. border = (border == "medium" || jQuery.boxModel && parseInt(version) >= 7) && 2 || border;
  2456. add( -border, -border );
  2457. }
  2458. // Otherwise loop through the offsetParents and parentNodes
  2459. } else {
  2460. // Initial element offsets
  2461. add( elem.offsetLeft, elem.offsetTop );
  2462. // Get parent offsets
  2463. while ( offsetParent ) {
  2464. // Add offsetParent offsets
  2465. add( offsetParent.offsetLeft, offsetParent.offsetTop );
  2466. // Mozilla and Safari > 2 does not include the border on offset parents
  2467. // However Mozilla adds the border for table or table cells
  2468. if ( mozilla && !/^t(able|d|h)$/i.test(offsetParent.tagName) || safari && !safari2 )
  2469. border( offsetParent );
  2470. // Add the document scroll offsets if position is fixed on any offsetParent
  2471. if ( !fixed && jQuery.css(offsetParent, "position") == "fixed" )
  2472. fixed = true;
  2473. // Set offsetChild to previous offsetParent unless it is the body element
  2474. offsetChild = /^body$/i.test(offsetParent.tagName) ? offsetChild : offsetParent;
  2475. // Get next offsetParent
  2476. offsetParent = offsetParent.offsetParent;
  2477. }
  2478. // Get parent scroll offsets
  2479. while ( parent.tagName && !/^body|html$/i.test(parent.tagName) ) {
  2480. // Remove parent scroll UNLESS that parent is inline or a table-row to work around Opera inline/table scrollLeft/Top bug
  2481. if ( !/^inline|table-row.*$/i.test(jQuery.css(parent, "display")) )
  2482. // Subtract parent scroll offsets
  2483. add( -parent.scrollLeft, -parent.scrollTop );
  2484. // Mozilla does not add the border for a parent that has overflow != visible
  2485. if ( mozilla && jQuery.css(parent, "overflow") != "visible" )
  2486. border( parent );
  2487. // Get next parent
  2488. parent = parent.parentNode;
  2489. }
  2490. // Safari <= 2 doubles body offsets with a fixed position element/offsetParent or absolutely positioned offsetChild
  2491. // Mozilla doubles body offsets with a non-absolutely positioned offsetChild
  2492. if ( (safari2 && (fixed || jQuery.css(offsetChild, "position") == "absolute")) ||
  2493. (mozilla && jQuery.css(offsetChild, "position") != "absoltue") )
  2494. add( -doc.body.offsetLeft, -doc.body.offsetTop );
  2495. // Add the document scroll offsets if position is fixed
  2496. if ( fixed )
  2497. add(
  2498. Math.max(doc.documentElement.scrollLeft, doc.body.scrollLeft),
  2499. Math.max(doc.documentElement.scrollTop, doc.body.scrollTop)
  2500. );
  2501. }
  2502. // Return an object with top and left properties
  2503. results = { top: top, left: left };
  2504. }
  2505. return results;
  2506. function border(elem) {
  2507. add( jQuery.css(elem, "borderLeftWidth"), jQuery.css(elem, "borderTopWidth") );
  2508. }
  2509. function add(l, t) {
  2510. left += parseInt(l) || 0;
  2511. top += parseInt(t) || 0;
  2512. }
  2513. };
  2514. })();
  2515. /*
  2516. * jQuery Color Animations
  2517. * Copyright 2007 John Resig
  2518. * Released under the MIT and GPL licenses.
  2519. */
  2520. (function(jQuery){
  2521. // We override the animation for all of these color styles
  2522. jQuery.each(['backgroundColor', 'borderBottomColor', 'borderLeftColor', 'borderRightColor', 'borderTopColor', 'color', 'outlineColor'], function(i,attr){
  2523. jQuery.fx.step[attr] = function(fx){
  2524. if ( fx.state == 0 ) {
  2525. fx.start = getColor( fx.elem, attr );
  2526. fx.end = getRGB( fx.end );
  2527. }
  2528. fx.elem.style[attr] = "rgb(" + [
  2529. Math.max(Math.min( parseInt((fx.pos * (fx.end[0] - fx.start[0])) + fx.start[0]), 255), 0),
  2530. Math.max(Math.min( parseInt((fx.pos * (fx.end[1] - fx.start[1])) + fx.start[1]), 255), 0),
  2531. Math.max(Math.min( parseInt((fx.pos * (fx.end[2] - fx.start[2])) + fx.start[2]), 255), 0)
  2532. ].join(",") + ")";
  2533. }
  2534. });
  2535. // Color Conversion functions from highlightFade
  2536. // By Blair Mitchelmore
  2537. // http://jquery.offput.ca/highlightFade/
  2538. // Parse strings looking for color tuples [255,255,255]
  2539. function getRGB(color) {
  2540. var result;
  2541. // Check if we're already dealing with an array of colors
  2542. if ( color && color.constructor == Array && color.length == 3 )
  2543. return color;
  2544. // Look for rgb(num,num,num)
  2545. if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color))
  2546. return [parseInt(result[1]), parseInt(result[2]), parseInt(result[3])];
  2547. // Look for rgb(num%,num%,num%)
  2548. if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color))
  2549. return [parseFloat(result[1])*2.55, parseFloat(result[2])*2.55, parseFloat(result[3])*2.55];
  2550. // Look for #a0b1c2
  2551. if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color))
  2552. return [parseInt(result[1],16), parseInt(result[2],16), parseInt(result[3],16)];
  2553. // Look for #fff
  2554. if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color))
  2555. return [parseInt(result[1]+result[1],16), parseInt(result[2]+result[2],16), parseInt(result[3]+result[3],16)];
  2556. // Otherwise, we're most likely dealing with a named color
  2557. return colors[jQuery.trim(color).toLowerCase()];
  2558. }
  2559. function getColor(elem, attr) {
  2560. var color;
  2561. do {
  2562. color = jQuery.curCSS(elem, attr);
  2563. // Keep going until we find an element that has color, or we hit the body
  2564. if ( color != '' && color != 'transparent' || jQuery.nodeName(elem, "body") )
  2565. break;
  2566. attr = "backgroundColor";
  2567. } while ( elem = elem.parentNode );
  2568. return getRGB(color);
  2569. };
  2570. // Some named colors to work with
  2571. // From Interface by Stefan Petre
  2572. // http://interface.eyecon.ro/
  2573. var colors = {
  2574. aqua:[0,255,255],
  2575. azure:[240,255,255],
  2576. beige:[245,245,220],
  2577. black:[0,0,0],
  2578. blue:[0,0,255],
  2579. brown:[165,42,42],
  2580. cyan:[0,255,255],
  2581. darkblue:[0,0,139],
  2582. darkcyan:[0,139,139],
  2583. darkgrey:[169,169,169],
  2584. darkgreen:[0,100,0],
  2585. darkkhaki:[189,183,107],
  2586. darkmagenta:[139,0,139],
  2587. darkolivegreen:[85,107,47],
  2588. darkorange:[255,140,0],
  2589. darkorchid:[153,50,204],
  2590. darkred:[139,0,0],
  2591. darksalmon:[233,150,122],
  2592. darkviolet:[148,0,211],
  2593. fuchsia:[255,0,255],
  2594. gold:[255,215,0],
  2595. green:[0,128,0],
  2596. indigo:[75,0,130],
  2597. khaki:[240,230,140],
  2598. lightblue:[173,216,230],
  2599. lightcyan:[224,255,255],
  2600. lightgreen:[144,238,144],
  2601. lightgrey:[211,211,211],
  2602. lightpink:[255,182,193],
  2603. lightyellow:[255,255,224],
  2604. lime:[0,255,0],
  2605. magenta:[255,0,255],
  2606. maroon:[128,0,0],
  2607. navy:[0,0,128],
  2608. olive:[128,128,0],
  2609. orange:[255,165,0],
  2610. pink:[255,192,203],
  2611. purple:[128,0,128],
  2612. violet:[128,0,128],
  2613. red:[255,0,0],
  2614. silver:[192,192,192],
  2615. white:[255,255,255],
  2616. yellow:[255,255,0]
  2617. };
  2618. })(jQuery);