A tumblelog CMS built on AJAX, PHP and MySQL.

jquery.js 79KB

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