Index: trunk/extensions/jQueryMsg/test/jasmine/SpecRunner.html |
— | — | @@ -0,0 +1,37 @@ |
| 2 | +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" |
| 3 | + "http://www.w3.org/TR/html4/loose.dtd"> |
| 4 | +<html> |
| 5 | +<head> |
| 6 | + <title>Jasmine Test Runner</title> |
| 7 | + <link rel="stylesheet" type="text/css" href="lib/jasmine-1.0.1/jasmine.css"> |
| 8 | + <script type="text/javascript" src="lib/jasmine-1.0.1/jasmine.js"></script> |
| 9 | + <script type="text/javascript" src="lib/jasmine-1.0.1/jasmine-html.js"></script> |
| 10 | + |
| 11 | + <!-- include source files here... --> |
| 12 | + <script type="text/javascript" src="../../../../load.php?debug=true&lang=en&modules=jquery%7Cmediawiki&only=scripts&skin=vector"></script> |
| 13 | + <script type="text/javascript" src="lib/appendto-jquery-mockjax/jquery.mockjax.js"></script> |
| 14 | + |
| 15 | + <script type="text/javascript" src="../../../../resources/mediawiki/mediawiki.js"></script> |
| 16 | + <script type="text/javascript" src="../../../../resources/mediawiki.language/mediawiki.language.js"></script> |
| 17 | + <script type="text/javascript" src="../../resources/mediawiki.language.parser.js"></script> |
| 18 | + <script type="text/javascript" src="../../resources/jquery/jquery.pubsub.js"></script> |
| 19 | + |
| 20 | + <script type="text/javascript" src="spec/mediawiki.language.parser.spec.data.js"></script> |
| 21 | + |
| 22 | + |
| 23 | + <!-- include spec files here... --> |
| 24 | + |
| 25 | + |
| 26 | + <script type="text/javascript" src="spec/mediawiki.language.parser.spec.js"></script> |
| 27 | + |
| 28 | + |
| 29 | +</head> |
| 30 | +<body> |
| 31 | +<script type="text/javascript"> |
| 32 | + jasmine.getEnv().addReporter(new jasmine.TrivialReporter()); |
| 33 | + jasmine.getEnv().execute(); |
| 34 | +</script> |
| 35 | + |
| 36 | +</body> |
| 37 | +</html> |
| 38 | + |
Index: trunk/extensions/jQueryMsg/test/jasmine/spec/mediawiki.language.parser.spec.js |
— | — | @@ -0,0 +1,308 @@ |
| 2 | +/* spec for language & message behaviour in MediaWiki */ |
| 3 | + |
| 4 | + |
| 5 | +mediaWiki.messages.set( { |
| 6 | + "en_empty": "", |
| 7 | + "en_simple": "Simple message", |
| 8 | + "en_replace": "Simple $1 replacement", |
| 9 | + "en_replace2": "Simple $1 $2 replacements", |
| 10 | + "en_link": "Simple [http://example.com link to example].", |
| 11 | + "en_link_replace": "Complex [$1 $2] behaviour.", |
| 12 | + "en_simple_magic": "Simple {{ALOHOMORA}} message", |
| 13 | + "en_undelete_short": "Undelete {{PLURAL:$1|one edit|$1 edits}}", |
| 14 | + "en_undelete_empty_param": "Undelete{{PLURAL:$1|| multiple edits}}", |
| 15 | + "en_category-subcat-count": "{{PLURAL:$2|This category has only the following subcategory.|This category has the following {{PLURAL:$1|subcategory|$1 subcategories}}, out of $2 total.}}", |
| 16 | + "en_escape0": "Escape \\to fantasy island", |
| 17 | + "en_escape1": "I had \\$2.50 in my pocket", |
| 18 | + "en_escape2": "I had {{PLURAL:$1|the absolute \\|$1\\| which came out to \\$3.00 in my C:\\\\drive| some stuff}}", |
| 19 | + "en_fail": "This should fail to {{parse" |
| 20 | +} ); |
| 21 | + |
| 22 | +/** |
| 23 | + * Tests |
| 24 | + */ |
| 25 | +( function( $j ) { |
| 26 | + describe( "mediaWiki.language.parser", function() { |
| 27 | + |
| 28 | + describe( "basic message functionality", function() { |
| 29 | + |
| 30 | + it( "should return identity for empty string", function() { |
| 31 | + var parser = new mediaWiki.language.parser(); |
| 32 | + expect( parser.parse( 'en_empty' ).html() ).toEqual( '' ); |
| 33 | + } ); |
| 34 | + |
| 35 | + |
| 36 | + it( "should return identity for simple string", function() { |
| 37 | + var parser = new mediaWiki.language.parser(); |
| 38 | + expect( parser.parse( 'en_simple' ).html() ).toEqual( 'Simple message' ); |
| 39 | + } ); |
| 40 | + |
| 41 | + } ); |
| 42 | + |
| 43 | + describe( "escaping", function() { |
| 44 | + |
| 45 | + it ( "should handle simple escaping", function() { |
| 46 | + var parser = new mediaWiki.language.parser(); |
| 47 | + expect( parser.parse( 'en_escape0' ).html() ).toEqual( 'Escape to fantasy island' ); |
| 48 | + } ); |
| 49 | + |
| 50 | + it ( "should escape dollar signs found in ordinary text when backslashed", function() { |
| 51 | + var parser = new mediaWiki.language.parser(); |
| 52 | + expect( parser.parse( 'en_escape1' ).html() ).toEqual( 'I had $2.50 in my pocket' ); |
| 53 | + } ); |
| 54 | + |
| 55 | + it ( "should handle a complicated escaping case, including escaped pipe chars in template args", function() { |
| 56 | + var parser = new mediaWiki.language.parser(); |
| 57 | + expect( parser.parse( 'en_escape2', [ 1 ] ).html() ).toEqual( 'I had the absolute |1| which came out to $3.00 in my C:\\drive' ); |
| 58 | + } ); |
| 59 | + |
| 60 | + } ); |
| 61 | + |
| 62 | + describe( "replacing", function() { |
| 63 | + |
| 64 | + it ( "should handle simple replacing", function() { |
| 65 | + var parser = new mediaWiki.language.parser(); |
| 66 | + expect( parser.parse( 'en_replace', [ 'foo' ] ).html() ).toEqual( 'Simple foo replacement' ); |
| 67 | + } ); |
| 68 | + |
| 69 | + it ( "should return $n if replacement not there", function() { |
| 70 | + var parser = new mediaWiki.language.parser(); |
| 71 | + expect( parser.parse( 'en_replace', [] ).html() ).toEqual( 'Simple $1 replacement' ); |
| 72 | + expect( parser.parse( 'en_replace2', [ 'bar' ] ).html() ).toEqual( 'Simple bar $2 replacements' ); |
| 73 | + } ); |
| 74 | + |
| 75 | + } ); |
| 76 | + |
| 77 | + describe( "linking", function() { |
| 78 | + |
| 79 | + it ( "should handle a simple link", function() { |
| 80 | + var parser = new mediaWiki.language.parser(); |
| 81 | + var parsed = parser.parse( 'en_link' ); |
| 82 | + var contents = parsed.contents(); |
| 83 | + expect( contents.length ).toEqual( 3 ); |
| 84 | + expect( contents[0].nodeName ).toEqual( '#text' ); |
| 85 | + expect( contents[0].nodeValue ).toEqual( 'Simple ' ); |
| 86 | + expect( contents[1].nodeName ).toEqual( 'A' ); |
| 87 | + expect( contents[1].getAttribute( 'href' ) ).toEqual( 'http://example.com' ); |
| 88 | + expect( contents[1].childNodes[0].nodeValue ).toEqual( 'link to example' ); |
| 89 | + expect( contents[2].nodeName ).toEqual( '#text' ); |
| 90 | + expect( contents[2].nodeValue ).toEqual( '.' ); |
| 91 | + } ); |
| 92 | + |
| 93 | + it ( "should replace a URL into a link", function() { |
| 94 | + var parser = new mediaWiki.language.parser(); |
| 95 | + var parsed = parser.parse( 'en_link_replace', [ 'http://example.com/foo', 'linking' ] ); |
| 96 | + var contents = parsed.contents(); |
| 97 | + expect( contents.length ).toEqual( 3 ); |
| 98 | + expect( contents[0].nodeName ).toEqual( '#text' ); |
| 99 | + expect( contents[0].nodeValue ).toEqual( 'Complex ' ); |
| 100 | + expect( contents[1].nodeName ).toEqual( 'A' ); |
| 101 | + expect( contents[1].getAttribute( 'href' ) ).toEqual( 'http://example.com/foo' ); |
| 102 | + expect( contents[1].childNodes[0].nodeValue ).toEqual( 'linking' ); |
| 103 | + expect( contents[2].nodeName ).toEqual( '#text' ); |
| 104 | + expect( contents[2].nodeValue ).toEqual( ' behaviour.' ); |
| 105 | + } ); |
| 106 | + |
| 107 | + it ( "should bind a click handler into a link", function() { |
| 108 | + var parser = new mediaWiki.language.parser(); |
| 109 | + var clicked = false; |
| 110 | + var click = function() { clicked = true; }; |
| 111 | + var parsed = parser.parse( 'en_link_replace', [ click, 'linking' ] ); |
| 112 | + var contents = parsed.contents(); |
| 113 | + expect( contents.length ).toEqual( 3 ); |
| 114 | + expect( contents[0].nodeName ).toEqual( '#text' ); |
| 115 | + expect( contents[0].nodeValue ).toEqual( 'Complex ' ); |
| 116 | + expect( contents[1].nodeName ).toEqual( 'A' ); |
| 117 | + expect( contents[1].getAttribute( 'href' ) ).toEqual( '#' ); |
| 118 | + expect( contents[1].childNodes[0].nodeValue ).toEqual( 'linking' ); |
| 119 | + expect( contents[2].nodeName ).toEqual( '#text' ); |
| 120 | + expect( contents[2].nodeValue ).toEqual( ' behaviour.' ); |
| 121 | + // determining bindings is hard in IE |
| 122 | + var anchor = parsed.find( 'a' ); |
| 123 | + if ( ( $j.browser.mozilla || $j.browser.webkit ) && anchor.click ) { |
| 124 | + expect( clicked ).toEqual( false ); |
| 125 | + anchor.click(); |
| 126 | + expect( clicked ).toEqual( true ); |
| 127 | + } |
| 128 | + } ); |
| 129 | + |
| 130 | + it ( "should wrap a jquery arg around link contents -- even another element", function() { |
| 131 | + var parser = new mediaWiki.language.parser(); |
| 132 | + var clicked = false; |
| 133 | + var click = function() { clicked = true; }; |
| 134 | + var button = $j( '<button>' ).click( click ); |
| 135 | + var parsed = parser.parse( 'en_link_replace', [ button, 'buttoning' ] ); |
| 136 | + var contents = parsed.contents(); |
| 137 | + expect( contents.length ).toEqual( 3 ); |
| 138 | + expect( contents[0].nodeName ).toEqual( '#text' ); |
| 139 | + expect( contents[0].nodeValue ).toEqual( 'Complex ' ); |
| 140 | + expect( contents[1].nodeName ).toEqual( 'BUTTON' ); |
| 141 | + expect( contents[1].childNodes[0].nodeValue ).toEqual( 'buttoning' ); |
| 142 | + expect( contents[2].nodeName ).toEqual( '#text' ); |
| 143 | + expect( contents[2].nodeValue ).toEqual( ' behaviour.' ); |
| 144 | + // determining bindings is hard in IE |
| 145 | + if ( ( $j.browser.mozilla || $j.browser.webkit ) && button.click ) { |
| 146 | + expect( clicked ).toEqual( false ); |
| 147 | + parsed.find( 'button' ).click(); |
| 148 | + expect( clicked ).toEqual( true ); |
| 149 | + } |
| 150 | + } ); |
| 151 | + |
| 152 | + |
| 153 | + } ); |
| 154 | + |
| 155 | + |
| 156 | + describe( "magic keywords", function() { |
| 157 | + it( "should substitute magic keywords", function() { |
| 158 | + var options = { |
| 159 | + magic: { |
| 160 | + 'alohomora' : 'open' |
| 161 | + } |
| 162 | + }; |
| 163 | + var parser = new mediaWiki.language.parser( options ); |
| 164 | + expect( parser.parse( 'en_simple_magic' ).html() ).toEqual( 'Simple open message' ); |
| 165 | + } ); |
| 166 | + } ); |
| 167 | + |
| 168 | + describe( "error conditions", function() { |
| 169 | + it( "should return non-existent key in square brackets", function() { |
| 170 | + var parser = new mediaWiki.language.parser(); |
| 171 | + expect( parser.parse( 'en_does_not_exist' ).html() ).toEqual( '[en_does_not_exist]' ); |
| 172 | + } ); |
| 173 | + |
| 174 | + |
| 175 | + it( "should fail to parse", function() { |
| 176 | + var parser = new mediaWiki.language.parser(); |
| 177 | + expect( function() { parser.parse( 'en_fail' ); } ).toThrow( |
| 178 | + 'Parse error at position 20 in input: This should fail to {{parse' |
| 179 | + ); |
| 180 | + } ); |
| 181 | + } ); |
| 182 | + |
| 183 | + describe( "empty parameters", function() { |
| 184 | + it( "should deal with empty parameters", function() { |
| 185 | + var parser = new mediaWiki.language.parser(); |
| 186 | + var ast = parser.getAst( 'en_undelete_empty_param' ); |
| 187 | + expect( parser.parse( 'en_undelete_empty_param', [ 1 ] ).html() ).toEqual( 'Undelete' ); |
| 188 | + expect( parser.parse( 'en_undelete_empty_param', [ 3 ] ).html() ).toEqual( 'Undelete multiple edits' ); |
| 189 | + |
| 190 | + } ); |
| 191 | + } ); |
| 192 | + |
| 193 | + describe( "easy message interface functions", function() { |
| 194 | + it( "should allow a global that returns strings", function() { |
| 195 | + var gM = mediaWiki.language.getMessageFunction(); |
| 196 | + // passing this through jQuery and back to string, because browsers may have subtle differences, like the case of tag names. |
| 197 | + // a surrounding <SPAN> is needed for html() to work right |
| 198 | + var expectedHtml = $j( '<span>Complex <a href="http://example.com/foo">linking</a> behaviour.</span>' ).html(); |
| 199 | + var result = gM( 'en_link_replace', 'http://example.com/foo', 'linking' ); |
| 200 | + expect( typeof result ).toEqual( 'string' ); |
| 201 | + expect( result ).toEqual( expectedHtml ); |
| 202 | + } ); |
| 203 | + |
| 204 | + it( "should allow a jQuery plugin that appends to nodes", function() { |
| 205 | + $j.fn.msg = mediaWiki.language.getJqueryMessagePlugin(); |
| 206 | + var $div = $j( '<div>' ).append( $j( '<p>' ).addClass( 'foo' ) ); |
| 207 | + var clicked = false; |
| 208 | + var $button = $j( '<button>' ).click( function() { clicked = true; } ); |
| 209 | + $div.find( '.foo' ).msg( 'en_link_replace', $button, 'buttoning' ); |
| 210 | + // passing this through jQuery and back to string, because browsers may have subtle differences, like the case of tag names. |
| 211 | + // a surrounding <SPAN> is needed for html() to work right |
| 212 | + var expectedHtml = $j( '<span>Complex <button>buttoning</button> behaviour.</span>' ).html(); |
| 213 | + var createdHtml = $div.find( '.foo' ).html(); |
| 214 | + // it is hard to test for clicks with IE; also it inserts or removes spaces around nodes when creating HTML tags, depending on their type. |
| 215 | + // so need to check the strings stripped of spaces. |
| 216 | + if ( ( $j.browser.mozilla || $j.browser.webkit ) && $button.click ) { |
| 217 | + expect( createdHtml ).toEqual( expectedHtml ); |
| 218 | + $div.find( 'button ').click(); |
| 219 | + expect( clicked ).toEqual( true ); |
| 220 | + } else if ( $j.browser.ie ) { |
| 221 | + expect( createdHtml.replace( /\s/, '' ) ).toEqual( expectedHtml.replace( /\s/, '' ) ); |
| 222 | + } |
| 223 | + delete $j.fn.msg; |
| 224 | + } ); |
| 225 | + |
| 226 | + } ); |
| 227 | + |
| 228 | + describe( "test plurals and other language-specific functions", function() { |
| 229 | + /* copying some language definitions in here -- it's hard to make this test fast and reliable |
| 230 | + otherwise, and we don't want to have to know the mediawiki URL from this kind of test either. |
| 231 | + We also can't preload the langs for the test since they clobber the same namespace. |
| 232 | + In principle Roan said it was okay to change how languages worked so that didn't happen... maybe |
| 233 | + someday. We'd have to the same kind of importing of the default rules for most rules, or maybe |
| 234 | + come up with some kind of subclassing scheme for languages */ |
| 235 | + var languageClasses = { |
| 236 | + ar: { |
| 237 | + /** |
| 238 | + * Arabic (العربية) language functions |
| 239 | + */ |
| 240 | + |
| 241 | + convertPlural: function( count, forms ) { |
| 242 | + forms = mediaWiki.language.preConvertPlural( forms, 6 ); |
| 243 | + if ( count === 0 ) { |
| 244 | + return forms[0]; |
| 245 | + } |
| 246 | + if ( count == 1 ) { |
| 247 | + return forms[1]; |
| 248 | + } |
| 249 | + if ( count == 2 ) { |
| 250 | + return forms[2]; |
| 251 | + } |
| 252 | + if ( count % 100 >= 3 && count % 100 <= 10 ) { |
| 253 | + return forms[3]; |
| 254 | + } |
| 255 | + if ( count % 100 >= 11 && count % 100 <= 99 ) { |
| 256 | + return forms[4]; |
| 257 | + } |
| 258 | + return forms[5]; |
| 259 | + }, |
| 260 | + |
| 261 | + digitTransformTable: { |
| 262 | + '0': '٠', // ٠ |
| 263 | + '1': '١', // ١ |
| 264 | + '2': '٢', // ٢ |
| 265 | + '3': '٣', // ٣ |
| 266 | + '4': '٤', // ٤ |
| 267 | + '5': '٥', // ٥ |
| 268 | + '6': '٦', // ٦ |
| 269 | + '7': '٧', // ٧ |
| 270 | + '8': '٨', // ٨ |
| 271 | + '9': '٩', // ٩ |
| 272 | + '.': '٫', // ٫ wrong table ? |
| 273 | + ',': '٬' // ٬ |
| 274 | + } |
| 275 | + |
| 276 | + }, |
| 277 | + en: { }, |
| 278 | + fr: { |
| 279 | + convertPlural: function( count, forms ) { |
| 280 | + forms = mediaWiki.language.preConvertPlural( forms, 2 ); |
| 281 | + return ( count <= 1 ) ? forms[0] : forms[1]; |
| 282 | + } |
| 283 | + }, |
| 284 | + jp: { }, |
| 285 | + zh: { } |
| 286 | + }; |
| 287 | + |
| 288 | + /* simulate how the language classes override, or don't, the standard functions in mediaWiki.language */ |
| 289 | + $j.each( languageClasses, function( langCode, rules ) { |
| 290 | + $j.each( [ 'convertPlural', 'convertNumber' ], function( i, propertyName ) { |
| 291 | + if ( typeof rules[ propertyName ] === 'undefined' ) { |
| 292 | + rules[ propertyName ] = mediaWiki.language[ propertyName ]; |
| 293 | + } |
| 294 | + } ); |
| 295 | + } ); |
| 296 | + |
| 297 | + $j.each( jasmineMsgSpec, function( i, test ) { |
| 298 | + it( "should parse " + test.name, function() { |
| 299 | + // using language override so we don't have to muck with global namespace |
| 300 | + var parser = new mediaWiki.language.parser( { language: languageClasses[ test.lang ] } ); |
| 301 | + var parsedHtml = parser.parse( test.key, test.args ).html(); |
| 302 | + expect( parsedHtml ).toEqual( test.result ); |
| 303 | + } ); |
| 304 | + } ); |
| 305 | + |
| 306 | + } ); |
| 307 | + |
| 308 | + } ); |
| 309 | +} )( jQuery ); |
Property changes on: trunk/extensions/jQueryMsg/test/jasmine/spec/mediawiki.language.parser.spec.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 310 | + native |
Index: trunk/extensions/jQueryMsg/test/jasmine/spec/mediawiki.language.parser.spec.data.js |
— | — | @@ -0,0 +1,488 @@ |
| 2 | +// This file stores the results from the PHP parser for certain messages and arguments, |
| 3 | +// so we can test the equivalent Javascript libraries. |
| 4 | +// Last generated with makeLanguageSpec.php at 2011-01-28T02:04:09+00:00 |
| 5 | + |
| 6 | +mediaWiki.messages.set( { |
| 7 | + "en_undelete_short": "Undelete {{PLURAL:$1|one edit|$1 edits}}", |
| 8 | + "en_category-subcat-count": "{{PLURAL:$2|This category has only the following subcategory.|This category has the following {{PLURAL:$1|subcategory|$1 subcategories}}, out of $2 total.}}", |
| 9 | + "fr_undelete_short": "Restaurer $1 modification{{PLURAL:$1||s}}", |
| 10 | + "fr_category-subcat-count": "Cette cat\u00e9gorie comprend {{PLURAL:$2|la sous-cat\u00e9gorie|$2 sous-cat\u00e9gories, dont {{PLURAL:$1|celle|les $1}}}} ci-dessous.", |
| 11 | + "ar_undelete_short": "\u0627\u0633\u062a\u0631\u062c\u0627\u0639 {{PLURAL:$1|\u062a\u0639\u062f\u064a\u0644 \u0648\u0627\u062d\u062f|\u062a\u0639\u062f\u064a\u0644\u064a\u0646|$1 \u062a\u0639\u062f\u064a\u0644\u0627\u062a|$1 \u062a\u0639\u062f\u064a\u0644|$1 \u062a\u0639\u062f\u064a\u0644\u0627}}", |
| 12 | + "ar_category-subcat-count": "{{PLURAL:$2|\u0644\u0627 \u062a\u0635\u0627\u0646\u064a\u0641 \u0641\u0631\u0639\u064a\u0629 \u0641\u064a \u0647\u0630\u0627 \u0627\u0644\u062a\u0635\u0646\u064a\u0641|\u0647\u0630\u0627 \u0627\u0644\u062a\u0635\u0646\u064a\u0641 \u0641\u064a\u0647 \u0627\u0644\u062a\u0635\u0646\u064a\u0641 \u0627\u0644\u0641\u0631\u0639\u064a \u0627\u0644\u062a\u0627\u0644\u064a \u0641\u0642\u0637.|\u0647\u0630\u0627 \u0627\u0644\u062a\u0635\u0646\u064a\u0641 \u0641\u064a\u0647 {{PLURAL:$1||\u0647\u0630\u0627 \u0627\u0644\u062a\u0635\u0646\u064a\u0641 \u0627\u0644\u0641\u0631\u0639\u064a|\u0647\u0630\u064a\u0646 \u0627\u0644\u062a\u0635\u0646\u064a\u0641\u064a\u0646 \u0627\u0644\u0641\u0631\u0639\u064a\u064a\u0646|\u0647\u0630\u0647 \u0627\u0644$1 \u062a\u0635\u0627\u0646\u064a\u0641 \u0627\u0644\u0641\u0631\u0639\u064a\u0629|\u0647\u0630\u0647 \u0627\u0644$1 \u062a\u0635\u0646\u064a\u0641\u0627 \u0641\u0631\u0639\u064a\u0627|\u0647\u0630\u0647 \u0627\u0644$1 \u062a\u0635\u0646\u064a\u0641 \u0641\u0631\u0639\u064a}}\u060c \u0645\u0646 \u0625\u062c\u0645\u0627\u0644\u064a $2.}}", |
| 13 | + "jp_undelete_short": "Undelete {{PLURAL:$1|one edit|$1 edits}}", |
| 14 | + "jp_category-subcat-count": "{{PLURAL:$2|This category has only the following subcategory.|This category has the following {{PLURAL:$1|subcategory|$1 subcategories}}, out of $2 total.}}", |
| 15 | + "zh_undelete_short": "\u6062\u590d\u88ab\u5220\u9664\u7684$1\u9879\u4fee\u8ba2", |
| 16 | + "zh_category-subcat-count": "{{PLURAL:$2|\u672c\u5206\u7c7b\u53ea\u6709\u4e0b\u5217\u4e00\u4e2a\u5b50\u5206\u7c7b\u3002|\u672c\u5206\u7c7b\u5305\u542b\u4e0b\u5217$1\u4e2a\u5b50\u5206\u7c7b\uff0c\u5171\u6709$2\u4e2a\u5b50\u5206\u7c7b\u3002}}" |
| 17 | +} ); |
| 18 | +var jasmineMsgSpec = [ |
| 19 | + { |
| 20 | + "name": "en undelete_short 0", |
| 21 | + "key": "en_undelete_short", |
| 22 | + "args": [ |
| 23 | + 0 |
| 24 | + ], |
| 25 | + "result": "Undelete 0 edits", |
| 26 | + "lang": "en" |
| 27 | + }, |
| 28 | + { |
| 29 | + "name": "en undelete_short 1", |
| 30 | + "key": "en_undelete_short", |
| 31 | + "args": [ |
| 32 | + 1 |
| 33 | + ], |
| 34 | + "result": "Undelete one edit", |
| 35 | + "lang": "en" |
| 36 | + }, |
| 37 | + { |
| 38 | + "name": "en undelete_short 2", |
| 39 | + "key": "en_undelete_short", |
| 40 | + "args": [ |
| 41 | + 2 |
| 42 | + ], |
| 43 | + "result": "Undelete 2 edits", |
| 44 | + "lang": "en" |
| 45 | + }, |
| 46 | + { |
| 47 | + "name": "en undelete_short 5", |
| 48 | + "key": "en_undelete_short", |
| 49 | + "args": [ |
| 50 | + 5 |
| 51 | + ], |
| 52 | + "result": "Undelete 5 edits", |
| 53 | + "lang": "en" |
| 54 | + }, |
| 55 | + { |
| 56 | + "name": "en undelete_short 21", |
| 57 | + "key": "en_undelete_short", |
| 58 | + "args": [ |
| 59 | + 21 |
| 60 | + ], |
| 61 | + "result": "Undelete 21 edits", |
| 62 | + "lang": "en" |
| 63 | + }, |
| 64 | + { |
| 65 | + "name": "en undelete_short 101", |
| 66 | + "key": "en_undelete_short", |
| 67 | + "args": [ |
| 68 | + 101 |
| 69 | + ], |
| 70 | + "result": "Undelete 101 edits", |
| 71 | + "lang": "en" |
| 72 | + }, |
| 73 | + { |
| 74 | + "name": "en category-subcat-count 0,10", |
| 75 | + "key": "en_category-subcat-count", |
| 76 | + "args": [ |
| 77 | + 0, |
| 78 | + 10 |
| 79 | + ], |
| 80 | + "result": "This category has the following 0 subcategories, out of 10 total.", |
| 81 | + "lang": "en" |
| 82 | + }, |
| 83 | + { |
| 84 | + "name": "en category-subcat-count 1,1", |
| 85 | + "key": "en_category-subcat-count", |
| 86 | + "args": [ |
| 87 | + 1, |
| 88 | + 1 |
| 89 | + ], |
| 90 | + "result": "This category has only the following subcategory.", |
| 91 | + "lang": "en" |
| 92 | + }, |
| 93 | + { |
| 94 | + "name": "en category-subcat-count 1,2", |
| 95 | + "key": "en_category-subcat-count", |
| 96 | + "args": [ |
| 97 | + 1, |
| 98 | + 2 |
| 99 | + ], |
| 100 | + "result": "This category has the following subcategory, out of 2 total.", |
| 101 | + "lang": "en" |
| 102 | + }, |
| 103 | + { |
| 104 | + "name": "en category-subcat-count 3,30", |
| 105 | + "key": "en_category-subcat-count", |
| 106 | + "args": [ |
| 107 | + 3, |
| 108 | + 30 |
| 109 | + ], |
| 110 | + "result": "This category has the following 3 subcategories, out of 30 total.", |
| 111 | + "lang": "en" |
| 112 | + }, |
| 113 | + { |
| 114 | + "name": "fr undelete_short 0", |
| 115 | + "key": "fr_undelete_short", |
| 116 | + "args": [ |
| 117 | + 0 |
| 118 | + ], |
| 119 | + "result": "Restaurer 0 modification", |
| 120 | + "lang": "fr" |
| 121 | + }, |
| 122 | + { |
| 123 | + "name": "fr undelete_short 1", |
| 124 | + "key": "fr_undelete_short", |
| 125 | + "args": [ |
| 126 | + 1 |
| 127 | + ], |
| 128 | + "result": "Restaurer 1 modification", |
| 129 | + "lang": "fr" |
| 130 | + }, |
| 131 | + { |
| 132 | + "name": "fr undelete_short 2", |
| 133 | + "key": "fr_undelete_short", |
| 134 | + "args": [ |
| 135 | + 2 |
| 136 | + ], |
| 137 | + "result": "Restaurer 2 modifications", |
| 138 | + "lang": "fr" |
| 139 | + }, |
| 140 | + { |
| 141 | + "name": "fr undelete_short 5", |
| 142 | + "key": "fr_undelete_short", |
| 143 | + "args": [ |
| 144 | + 5 |
| 145 | + ], |
| 146 | + "result": "Restaurer 5 modifications", |
| 147 | + "lang": "fr" |
| 148 | + }, |
| 149 | + { |
| 150 | + "name": "fr undelete_short 21", |
| 151 | + "key": "fr_undelete_short", |
| 152 | + "args": [ |
| 153 | + 21 |
| 154 | + ], |
| 155 | + "result": "Restaurer 21 modifications", |
| 156 | + "lang": "fr" |
| 157 | + }, |
| 158 | + { |
| 159 | + "name": "fr undelete_short 101", |
| 160 | + "key": "fr_undelete_short", |
| 161 | + "args": [ |
| 162 | + 101 |
| 163 | + ], |
| 164 | + "result": "Restaurer 101 modifications", |
| 165 | + "lang": "fr" |
| 166 | + }, |
| 167 | + { |
| 168 | + "name": "fr category-subcat-count 0,10", |
| 169 | + "key": "fr_category-subcat-count", |
| 170 | + "args": [ |
| 171 | + 0, |
| 172 | + 10 |
| 173 | + ], |
| 174 | + "result": "Cette cat\u00e9gorie comprend 10 sous-cat\u00e9gories, dont celle ci-dessous.", |
| 175 | + "lang": "fr" |
| 176 | + }, |
| 177 | + { |
| 178 | + "name": "fr category-subcat-count 1,1", |
| 179 | + "key": "fr_category-subcat-count", |
| 180 | + "args": [ |
| 181 | + 1, |
| 182 | + 1 |
| 183 | + ], |
| 184 | + "result": "Cette cat\u00e9gorie comprend la sous-cat\u00e9gorie ci-dessous.", |
| 185 | + "lang": "fr" |
| 186 | + }, |
| 187 | + { |
| 188 | + "name": "fr category-subcat-count 1,2", |
| 189 | + "key": "fr_category-subcat-count", |
| 190 | + "args": [ |
| 191 | + 1, |
| 192 | + 2 |
| 193 | + ], |
| 194 | + "result": "Cette cat\u00e9gorie comprend 2 sous-cat\u00e9gories, dont celle ci-dessous.", |
| 195 | + "lang": "fr" |
| 196 | + }, |
| 197 | + { |
| 198 | + "name": "fr category-subcat-count 3,30", |
| 199 | + "key": "fr_category-subcat-count", |
| 200 | + "args": [ |
| 201 | + 3, |
| 202 | + 30 |
| 203 | + ], |
| 204 | + "result": "Cette cat\u00e9gorie comprend 30 sous-cat\u00e9gories, dont les 3 ci-dessous.", |
| 205 | + "lang": "fr" |
| 206 | + }, |
| 207 | + { |
| 208 | + "name": "ar undelete_short 0", |
| 209 | + "key": "ar_undelete_short", |
| 210 | + "args": [ |
| 211 | + 0 |
| 212 | + ], |
| 213 | + "result": "\u0627\u0633\u062a\u0631\u062c\u0627\u0639 \u062a\u0639\u062f\u064a\u0644 \u0648\u0627\u062d\u062f", |
| 214 | + "lang": "ar" |
| 215 | + }, |
| 216 | + { |
| 217 | + "name": "ar undelete_short 1", |
| 218 | + "key": "ar_undelete_short", |
| 219 | + "args": [ |
| 220 | + 1 |
| 221 | + ], |
| 222 | + "result": "\u0627\u0633\u062a\u0631\u062c\u0627\u0639 \u062a\u0639\u062f\u064a\u0644\u064a\u0646", |
| 223 | + "lang": "ar" |
| 224 | + }, |
| 225 | + { |
| 226 | + "name": "ar undelete_short 2", |
| 227 | + "key": "ar_undelete_short", |
| 228 | + "args": [ |
| 229 | + 2 |
| 230 | + ], |
| 231 | + "result": "\u0627\u0633\u062a\u0631\u062c\u0627\u0639 2 \u062a\u0639\u062f\u064a\u0644\u0627\u062a", |
| 232 | + "lang": "ar" |
| 233 | + }, |
| 234 | + { |
| 235 | + "name": "ar undelete_short 5", |
| 236 | + "key": "ar_undelete_short", |
| 237 | + "args": [ |
| 238 | + 5 |
| 239 | + ], |
| 240 | + "result": "\u0627\u0633\u062a\u0631\u062c\u0627\u0639 5 \u062a\u0639\u062f\u064a\u0644", |
| 241 | + "lang": "ar" |
| 242 | + }, |
| 243 | + { |
| 244 | + "name": "ar undelete_short 21", |
| 245 | + "key": "ar_undelete_short", |
| 246 | + "args": [ |
| 247 | + 21 |
| 248 | + ], |
| 249 | + "result": "\u0627\u0633\u062a\u0631\u062c\u0627\u0639 21 \u062a\u0639\u062f\u064a\u0644\u0627", |
| 250 | + "lang": "ar" |
| 251 | + }, |
| 252 | + { |
| 253 | + "name": "ar undelete_short 101", |
| 254 | + "key": "ar_undelete_short", |
| 255 | + "args": [ |
| 256 | + 101 |
| 257 | + ], |
| 258 | + "result": "\u0627\u0633\u062a\u0631\u062c\u0627\u0639 101 \u062a\u0639\u062f\u064a\u0644\u0627", |
| 259 | + "lang": "ar" |
| 260 | + }, |
| 261 | + { |
| 262 | + "name": "ar category-subcat-count 0,10", |
| 263 | + "key": "ar_category-subcat-count", |
| 264 | + "args": [ |
| 265 | + 0, |
| 266 | + 10 |
| 267 | + ], |
| 268 | + "result": "\u0647\u0630\u0627 \u0627\u0644\u062a\u0635\u0646\u064a\u0641 \u0641\u064a\u0647 \u060c \u0645\u0646 \u0625\u062c\u0645\u0627\u0644\u064a 10.", |
| 269 | + "lang": "ar" |
| 270 | + }, |
| 271 | + { |
| 272 | + "name": "ar category-subcat-count 1,1", |
| 273 | + "key": "ar_category-subcat-count", |
| 274 | + "args": [ |
| 275 | + 1, |
| 276 | + 1 |
| 277 | + ], |
| 278 | + "result": "\u0647\u0630\u0627 \u0627\u0644\u062a\u0635\u0646\u064a\u0641 \u0641\u064a\u0647 \u0627\u0644\u062a\u0635\u0646\u064a\u0641 \u0627\u0644\u0641\u0631\u0639\u064a \u0627\u0644\u062a\u0627\u0644\u064a \u0641\u0642\u0637.", |
| 279 | + "lang": "ar" |
| 280 | + }, |
| 281 | + { |
| 282 | + "name": "ar category-subcat-count 1,2", |
| 283 | + "key": "ar_category-subcat-count", |
| 284 | + "args": [ |
| 285 | + 1, |
| 286 | + 2 |
| 287 | + ], |
| 288 | + "result": "\u0647\u0630\u0627 \u0627\u0644\u062a\u0635\u0646\u064a\u0641 \u0641\u064a\u0647 \u0647\u0630\u0627 \u0627\u0644\u062a\u0635\u0646\u064a\u0641 \u0627\u0644\u0641\u0631\u0639\u064a\u060c \u0645\u0646 \u0625\u062c\u0645\u0627\u0644\u064a 2.", |
| 289 | + "lang": "ar" |
| 290 | + }, |
| 291 | + { |
| 292 | + "name": "ar category-subcat-count 3,30", |
| 293 | + "key": "ar_category-subcat-count", |
| 294 | + "args": [ |
| 295 | + 3, |
| 296 | + 30 |
| 297 | + ], |
| 298 | + "result": "\u0647\u0630\u0627 \u0627\u0644\u062a\u0635\u0646\u064a\u0641 \u0641\u064a\u0647 \u0647\u0630\u0647 \u0627\u06443 \u062a\u0635\u0627\u0646\u064a\u0641 \u0627\u0644\u0641\u0631\u0639\u064a\u0629\u060c \u0645\u0646 \u0625\u062c\u0645\u0627\u0644\u064a 30.", |
| 299 | + "lang": "ar" |
| 300 | + }, |
| 301 | + { |
| 302 | + "name": "jp undelete_short 0", |
| 303 | + "key": "jp_undelete_short", |
| 304 | + "args": [ |
| 305 | + 0 |
| 306 | + ], |
| 307 | + "result": "Undelete 0 edits", |
| 308 | + "lang": "jp" |
| 309 | + }, |
| 310 | + { |
| 311 | + "name": "jp undelete_short 1", |
| 312 | + "key": "jp_undelete_short", |
| 313 | + "args": [ |
| 314 | + 1 |
| 315 | + ], |
| 316 | + "result": "Undelete one edit", |
| 317 | + "lang": "jp" |
| 318 | + }, |
| 319 | + { |
| 320 | + "name": "jp undelete_short 2", |
| 321 | + "key": "jp_undelete_short", |
| 322 | + "args": [ |
| 323 | + 2 |
| 324 | + ], |
| 325 | + "result": "Undelete 2 edits", |
| 326 | + "lang": "jp" |
| 327 | + }, |
| 328 | + { |
| 329 | + "name": "jp undelete_short 5", |
| 330 | + "key": "jp_undelete_short", |
| 331 | + "args": [ |
| 332 | + 5 |
| 333 | + ], |
| 334 | + "result": "Undelete 5 edits", |
| 335 | + "lang": "jp" |
| 336 | + }, |
| 337 | + { |
| 338 | + "name": "jp undelete_short 21", |
| 339 | + "key": "jp_undelete_short", |
| 340 | + "args": [ |
| 341 | + 21 |
| 342 | + ], |
| 343 | + "result": "Undelete 21 edits", |
| 344 | + "lang": "jp" |
| 345 | + }, |
| 346 | + { |
| 347 | + "name": "jp undelete_short 101", |
| 348 | + "key": "jp_undelete_short", |
| 349 | + "args": [ |
| 350 | + 101 |
| 351 | + ], |
| 352 | + "result": "Undelete 101 edits", |
| 353 | + "lang": "jp" |
| 354 | + }, |
| 355 | + { |
| 356 | + "name": "jp category-subcat-count 0,10", |
| 357 | + "key": "jp_category-subcat-count", |
| 358 | + "args": [ |
| 359 | + 0, |
| 360 | + 10 |
| 361 | + ], |
| 362 | + "result": "This category has the following 0 subcategories, out of 10 total.", |
| 363 | + "lang": "jp" |
| 364 | + }, |
| 365 | + { |
| 366 | + "name": "jp category-subcat-count 1,1", |
| 367 | + "key": "jp_category-subcat-count", |
| 368 | + "args": [ |
| 369 | + 1, |
| 370 | + 1 |
| 371 | + ], |
| 372 | + "result": "This category has only the following subcategory.", |
| 373 | + "lang": "jp" |
| 374 | + }, |
| 375 | + { |
| 376 | + "name": "jp category-subcat-count 1,2", |
| 377 | + "key": "jp_category-subcat-count", |
| 378 | + "args": [ |
| 379 | + 1, |
| 380 | + 2 |
| 381 | + ], |
| 382 | + "result": "This category has the following subcategory, out of 2 total.", |
| 383 | + "lang": "jp" |
| 384 | + }, |
| 385 | + { |
| 386 | + "name": "jp category-subcat-count 3,30", |
| 387 | + "key": "jp_category-subcat-count", |
| 388 | + "args": [ |
| 389 | + 3, |
| 390 | + 30 |
| 391 | + ], |
| 392 | + "result": "This category has the following 3 subcategories, out of 30 total.", |
| 393 | + "lang": "jp" |
| 394 | + }, |
| 395 | + { |
| 396 | + "name": "zh undelete_short 0", |
| 397 | + "key": "zh_undelete_short", |
| 398 | + "args": [ |
| 399 | + 0 |
| 400 | + ], |
| 401 | + "result": "\u6062\u590d\u88ab\u5220\u9664\u76840\u9879\u4fee\u8ba2", |
| 402 | + "lang": "zh" |
| 403 | + }, |
| 404 | + { |
| 405 | + "name": "zh undelete_short 1", |
| 406 | + "key": "zh_undelete_short", |
| 407 | + "args": [ |
| 408 | + 1 |
| 409 | + ], |
| 410 | + "result": "\u6062\u590d\u88ab\u5220\u9664\u76841\u9879\u4fee\u8ba2", |
| 411 | + "lang": "zh" |
| 412 | + }, |
| 413 | + { |
| 414 | + "name": "zh undelete_short 2", |
| 415 | + "key": "zh_undelete_short", |
| 416 | + "args": [ |
| 417 | + 2 |
| 418 | + ], |
| 419 | + "result": "\u6062\u590d\u88ab\u5220\u9664\u76842\u9879\u4fee\u8ba2", |
| 420 | + "lang": "zh" |
| 421 | + }, |
| 422 | + { |
| 423 | + "name": "zh undelete_short 5", |
| 424 | + "key": "zh_undelete_short", |
| 425 | + "args": [ |
| 426 | + 5 |
| 427 | + ], |
| 428 | + "result": "\u6062\u590d\u88ab\u5220\u9664\u76845\u9879\u4fee\u8ba2", |
| 429 | + "lang": "zh" |
| 430 | + }, |
| 431 | + { |
| 432 | + "name": "zh undelete_short 21", |
| 433 | + "key": "zh_undelete_short", |
| 434 | + "args": [ |
| 435 | + 21 |
| 436 | + ], |
| 437 | + "result": "\u6062\u590d\u88ab\u5220\u9664\u768421\u9879\u4fee\u8ba2", |
| 438 | + "lang": "zh" |
| 439 | + }, |
| 440 | + { |
| 441 | + "name": "zh undelete_short 101", |
| 442 | + "key": "zh_undelete_short", |
| 443 | + "args": [ |
| 444 | + 101 |
| 445 | + ], |
| 446 | + "result": "\u6062\u590d\u88ab\u5220\u9664\u7684101\u9879\u4fee\u8ba2", |
| 447 | + "lang": "zh" |
| 448 | + }, |
| 449 | + { |
| 450 | + "name": "zh category-subcat-count 0,10", |
| 451 | + "key": "zh_category-subcat-count", |
| 452 | + "args": [ |
| 453 | + 0, |
| 454 | + 10 |
| 455 | + ], |
| 456 | + "result": "\u672c\u5206\u7c7b\u5305\u542b\u4e0b\u52170\u4e2a\u5b50\u5206\u7c7b\uff0c\u5171\u670910\u4e2a\u5b50\u5206\u7c7b\u3002", |
| 457 | + "lang": "zh" |
| 458 | + }, |
| 459 | + { |
| 460 | + "name": "zh category-subcat-count 1,1", |
| 461 | + "key": "zh_category-subcat-count", |
| 462 | + "args": [ |
| 463 | + 1, |
| 464 | + 1 |
| 465 | + ], |
| 466 | + "result": "\u672c\u5206\u7c7b\u53ea\u6709\u4e0b\u5217\u4e00\u4e2a\u5b50\u5206\u7c7b\u3002", |
| 467 | + "lang": "zh" |
| 468 | + }, |
| 469 | + { |
| 470 | + "name": "zh category-subcat-count 1,2", |
| 471 | + "key": "zh_category-subcat-count", |
| 472 | + "args": [ |
| 473 | + 1, |
| 474 | + 2 |
| 475 | + ], |
| 476 | + "result": "\u672c\u5206\u7c7b\u5305\u542b\u4e0b\u52171\u4e2a\u5b50\u5206\u7c7b\uff0c\u5171\u67092\u4e2a\u5b50\u5206\u7c7b\u3002", |
| 477 | + "lang": "zh" |
| 478 | + }, |
| 479 | + { |
| 480 | + "name": "zh category-subcat-count 3,30", |
| 481 | + "key": "zh_category-subcat-count", |
| 482 | + "args": [ |
| 483 | + 3, |
| 484 | + 30 |
| 485 | + ], |
| 486 | + "result": "\u672c\u5206\u7c7b\u5305\u542b\u4e0b\u52173\u4e2a\u5b50\u5206\u7c7b\uff0c\u5171\u670930\u4e2a\u5b50\u5206\u7c7b\u3002", |
| 487 | + "lang": "zh" |
| 488 | + } |
| 489 | +]; |
Property changes on: trunk/extensions/jQueryMsg/test/jasmine/spec/mediawiki.language.parser.spec.data.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 490 | + native |
Index: trunk/extensions/jQueryMsg/test/jasmine/makeLanguageSpec.php |
— | — | @@ -0,0 +1,114 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * This PHP script defines the spec that the Javascript message parser should conform to. |
| 6 | + * |
| 7 | + * It does this by looking up the results of various string kinds of string parsing, with various languages, |
| 8 | + * in the current installation of MediaWiki. It then outputs a static specification, mapping expected inputs to outputs, |
| 9 | + * which can be used with the JasmineBDD framework. This specification can then be used by simply including it into |
| 10 | + * the SpecRunner.html file. |
| 11 | + * |
| 12 | + * This is similar to Michael Dale (mdale@mediawiki.org)'s parser tests, except that it doesn't look up the |
| 13 | + * API results while doing the test, so the Jasmine run is much faster(at the cost of being out of date in rare |
| 14 | + * circumstances. But mostly the parsing that we are doing in Javascript doesn't change much.) |
| 15 | + * |
| 16 | + */ |
| 17 | + |
| 18 | +$maintenanceDir = dirname( dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) ) . '/maintenance'; |
| 19 | + |
| 20 | +require( "$maintenanceDir/Maintenance.php" ); |
| 21 | + |
| 22 | +class MakeLanguageSpec extends Maintenance { |
| 23 | + |
| 24 | + static $keyToTestArgs = array( |
| 25 | + 'undelete_short' => array( |
| 26 | + array( 0 ), |
| 27 | + array( 1 ), |
| 28 | + array( 2 ), |
| 29 | + array( 5 ), |
| 30 | + array( 21 ), |
| 31 | + array( 101 ) |
| 32 | + ), |
| 33 | + 'category-subcat-count' => array( |
| 34 | + array( 0, 10 ), |
| 35 | + array( 1, 1 ), |
| 36 | + array( 1, 2 ), |
| 37 | + array( 3, 30 ) |
| 38 | + ) |
| 39 | + ); |
| 40 | + |
| 41 | + public function __construct() { |
| 42 | + parent::__construct(); |
| 43 | + $this->mDescription = "Create a JasmineBDD-compatible specification for message parsing"; |
| 44 | + // add any other options here |
| 45 | + } |
| 46 | + |
| 47 | + public function execute() { |
| 48 | + list( $messages, $tests ) = $this->getMessagesAndTests(); |
| 49 | + $this->writeJavascriptFile( $messages, $tests, "spec/mediawiki.language.parser.spec.data.js" ); |
| 50 | + } |
| 51 | + |
| 52 | + private function getMessagesAndTests() { |
| 53 | + $messages = array(); |
| 54 | + $tests = array(); |
| 55 | + $wfMsgExtOptions = array( 'parsemag' ); |
| 56 | + foreach ( array( 'en', 'fr', 'ar', 'jp', 'zh' ) as $languageCode ) { |
| 57 | + $wfMsgExtOptions['language'] = $languageCode; |
| 58 | + foreach ( self::$keyToTestArgs as $key => $testArgs ) { |
| 59 | + foreach ($testArgs as $args) { |
| 60 | + // get the raw template, without any transformations |
| 61 | + $template = wfMsgGetKey( $key, /* useDb */ true, $languageCode, /* transform */ false ); |
| 62 | + |
| 63 | + // get the magic-parsed version with args |
| 64 | + $wfMsgExtArgs = array_merge( array( $key, $wfMsgExtOptions ), $args ); |
| 65 | + $result = call_user_func_array( 'wfMsgExt', $wfMsgExtArgs ); |
| 66 | + |
| 67 | + // record the template, args, language, and expected result |
| 68 | + // fake multiple languages by flattening them together |
| 69 | + $langKey = $languageCode . '_' . $key; |
| 70 | + $messages[ $langKey ] = $template; |
| 71 | + $tests[] = array( |
| 72 | + 'name' => $languageCode . " " . $key . " " . join( ",", $args ), |
| 73 | + 'key' => $langKey, |
| 74 | + 'args' => $args, |
| 75 | + 'result' => $result, |
| 76 | + 'lang' => $languageCode |
| 77 | + ); |
| 78 | + } |
| 79 | + } |
| 80 | + } |
| 81 | + return array( $messages, $tests ); |
| 82 | + } |
| 83 | + |
| 84 | + private function writeJavascriptFile( $messages, $tests, $dataSpecFile ) { |
| 85 | + global $argv; |
| 86 | + $arguments = count($argv) ? $argv : $_SERVER[ 'argv' ]; |
| 87 | + |
| 88 | + $json = new Services_JSON; |
| 89 | + $json->pretty = true; |
| 90 | + $javascriptPrologue = "// This file stores the results from the PHP parser for certain messages and arguments,\n" |
| 91 | + . "// so we can test the equivalent Javascript libraries.\n" |
| 92 | + . '// Last generated with ' . join(' ', $arguments) . ' at ' . gmdate('c') . "\n\n"; |
| 93 | + $javascriptMessages = "mediaWiki.messages.set( " . $json->encode( $messages, true ) . " );\n"; |
| 94 | + $javascriptTests = 'var jasmineMsgSpec = ' . $json->encode( $tests, true ) . ";\n"; |
| 95 | + |
| 96 | + $fp = fopen( $dataSpecFile, 'w' ); |
| 97 | + if ( !$fp ) { |
| 98 | + die( "couldn't open $dataSpecFile for writing" ); |
| 99 | + } |
| 100 | + $success = fwrite( $fp, $javascriptPrologue . $javascriptMessages . $javascriptTests ); |
| 101 | + if ( !$success ) { |
| 102 | + die( "couldn't write to $dataSpecFile" ); |
| 103 | + } |
| 104 | + $success = fclose( $fp ); |
| 105 | + if ( !$success ) { |
| 106 | + die( "couldn't close $dataSpecFile" ); |
| 107 | + } |
| 108 | + } |
| 109 | +} |
| 110 | + |
| 111 | +$maintClass = "MakeLanguageSpec"; |
| 112 | +require_once( "$maintenanceDir/doMaintenance.php" ); |
| 113 | + |
| 114 | + |
| 115 | + |
Property changes on: trunk/extensions/jQueryMsg/test/jasmine/makeLanguageSpec.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 116 | + native |
Index: trunk/extensions/jQueryMsg/test/jasmine/lib/appendto-jquery-mockjax/jquery.mockjax.js |
— | — | @@ -0,0 +1,326 @@ |
| 2 | +/*! |
| 3 | + * MockJax - jQuery Plugin to Mock Ajax requests |
| 4 | + * |
| 5 | + * Version: 1.3.3 |
| 6 | + * Released: 2010-11-05 |
| 7 | + * Source: http://github.com/appendto/jquery-mockjax |
| 8 | + * Docs: http://enterprisejquery.com/2010/07/mock-your-ajax-requests-with-mockjax-for-rapid-development |
| 9 | + * Plugin: mockjax |
| 10 | + * Author: Jonathan Sharp (http://jdsharp.com) |
| 11 | + * License: MIT,GPL |
| 12 | + * |
| 13 | + * Copyright (c) 2010 appendTo LLC. |
| 14 | + * Dual licensed under the MIT or GPL licenses. |
| 15 | + * http://appendto.com/open-source-licenses |
| 16 | + */ |
| 17 | +(function($) { |
| 18 | + var _ajax = $.ajax, |
| 19 | + mockHandlers = []; |
| 20 | + |
| 21 | + $.extend({ |
| 22 | + ajax: function(origSettings) { |
| 23 | + var s = jQuery.extend(true, {}, jQuery.ajaxSettings, origSettings), |
| 24 | + mock = false; |
| 25 | + // Iterate over our mock handlers (in registration order) until we find |
| 26 | + // one that is willing to intercept the request |
| 27 | + $.each(mockHandlers, function(k, v) { |
| 28 | + if ( !mockHandlers[k] ) { |
| 29 | + return; |
| 30 | + } |
| 31 | + var m = null; |
| 32 | + // If the mock was registered with a function, let the function decide if we |
| 33 | + // want to mock this request |
| 34 | + if ( $.isFunction(mockHandlers[k]) ) { |
| 35 | + m = mockHandlers[k](s); |
| 36 | + } else { |
| 37 | + m = mockHandlers[k]; |
| 38 | + // Inspect the URL of the request and check if the mock handler's url |
| 39 | + // matches the url for this ajax request |
| 40 | + if ( $.isFunction(m.url.test) ) { |
| 41 | + // The user provided a regex for the url, test it |
| 42 | + if ( !m.url.test( s.url ) ) { |
| 43 | + m = null; |
| 44 | + } |
| 45 | + } else { |
| 46 | + // Look for a simple wildcard '*' or a direct URL match |
| 47 | + var star = m.url.indexOf('*'); |
| 48 | + if ( ( m.url != '*' && m.url != s.url && star == -1 ) || |
| 49 | + ( star > -1 && m.url.substr(0, star) != s.url.substr(0, star) ) ) { |
| 50 | + // The url we tested did not match the wildcard * |
| 51 | + m = null; |
| 52 | + } |
| 53 | + } |
| 54 | + if ( m ) { |
| 55 | + // Inspect the data submitted in the request (either POST body or GET query string) |
| 56 | + if ( m.data && s.data ) { |
| 57 | + var identical = false; |
| 58 | + // Deep inspect the identity of the objects |
| 59 | + (function ident(mock, live) { |
| 60 | + // Test for situations where the data is a querystring (not an object) |
| 61 | + if (typeof live === 'string') { |
| 62 | + // Querystring may be a regex |
| 63 | + identical = $.isFunction( mock.test ) ? mock.test(live) : mock == live; |
| 64 | + return identical; |
| 65 | + } |
| 66 | + $.each(mock, function(k, v) { |
| 67 | + if ( live[k] === undefined ) { |
| 68 | + identical = false; |
| 69 | + return false; |
| 70 | + } else { |
| 71 | + identical = true; |
| 72 | + if ( typeof live[k] == 'object' ) { |
| 73 | + return ident(mock[k], live[k]); |
| 74 | + } else { |
| 75 | + if ( $.isFunction( mock[k].test ) ) { |
| 76 | + identical = mock[k].test(live[k]); |
| 77 | + } else { |
| 78 | + identical = ( mock[k] == live[k] ); |
| 79 | + } |
| 80 | + return identical; |
| 81 | + } |
| 82 | + } |
| 83 | + }); |
| 84 | + })(m.data, s.data); |
| 85 | + // They're not identical, do not mock this request |
| 86 | + if ( identical == false ) { |
| 87 | + m = null; |
| 88 | + } |
| 89 | + } |
| 90 | + // Inspect the request type |
| 91 | + if ( m && m.type && m.type != s.type ) { |
| 92 | + // The request type doesn't match (GET vs. POST) |
| 93 | + m = null; |
| 94 | + } |
| 95 | + } |
| 96 | + } |
| 97 | + if ( m ) { |
| 98 | + if ( typeof console !== 'undefined' && console.log ) { |
| 99 | + console.log('MOCK ' + s.type + ': ' + s.url); |
| 100 | + } |
| 101 | + mock = true; |
| 102 | + |
| 103 | + // Handle JSONP Parameter Callbacks, we need to replicate some of the jQuery core here |
| 104 | + // because there isn't an easy hook for the cross domain script tag of jsonp |
| 105 | + if ( s.dataType === "jsonp" ) { |
| 106 | + if ( s.type.toUpperCase() === "GET" ) { |
| 107 | + if ( !jsre.test( s.url ) ) { |
| 108 | + s.url += (rquery.test( s.url ) ? "&" : "?") + (s.jsonp || "callback") + "=?"; |
| 109 | + } |
| 110 | + } else if ( !s.data || !jsre.test(s.data) ) { |
| 111 | + s.data = (s.data ? s.data + "&" : "") + (s.jsonp || "callback") + "=?"; |
| 112 | + } |
| 113 | + s.dataType = "json"; |
| 114 | + } |
| 115 | + |
| 116 | + // Build temporary JSONP function |
| 117 | + var jsre = /=\?(&|$)/; |
| 118 | + if ( s.dataType === "json" && (s.data && jsre.test(s.data) || jsre.test(s.url)) ) { |
| 119 | + jsonp = s.jsonpCallback || ("jsonp" + jsc++); |
| 120 | + |
| 121 | + // Replace the =? sequence both in the query string and the data |
| 122 | + if ( s.data ) { |
| 123 | + s.data = (s.data + "").replace(jsre, "=" + jsonp + "$1"); |
| 124 | + } |
| 125 | + |
| 126 | + s.url = s.url.replace(jsre, "=" + jsonp + "$1"); |
| 127 | + |
| 128 | + // We need to make sure |
| 129 | + // that a JSONP style response is executed properly |
| 130 | + s.dataType = "script"; |
| 131 | + |
| 132 | + // Handle JSONP-style loading |
| 133 | + window[ jsonp ] = window[ jsonp ] || function( tmp ) { |
| 134 | + data = tmp; |
| 135 | + success(); |
| 136 | + complete(); |
| 137 | + // Garbage collect |
| 138 | + window[ jsonp ] = undefined; |
| 139 | + |
| 140 | + try { |
| 141 | + delete window[ jsonp ]; |
| 142 | + } catch(e) {} |
| 143 | + |
| 144 | + if ( head ) { |
| 145 | + head.removeChild( script ); |
| 146 | + } |
| 147 | + }; |
| 148 | + } |
| 149 | + |
| 150 | + var rurl = /^(\w+:)?\/\/([^\/?#]+)/, |
| 151 | + parts = rurl.exec( s.url ), |
| 152 | + remote = parts && (parts[1] && parts[1] !== location.protocol || parts[2] !== location.host); |
| 153 | + |
| 154 | + // Test if we are going to create a script tag (if so, intercept & mock) |
| 155 | + if ( s.dataType === "script" && s.type.toUpperCase() === "GET" && remote ) { |
| 156 | + // Synthesize the mock request for adding a script tag |
| 157 | + var callbackContext = origSettings && origSettings.context || s; |
| 158 | + |
| 159 | + function success() { |
| 160 | + // If a local callback was specified, fire it and pass it the data |
| 161 | + if ( s.success ) { |
| 162 | + s.success.call( callbackContext, ( m.response ? m.response.toString() : m.responseText || ''), status, {} ); |
| 163 | + } |
| 164 | + |
| 165 | + // Fire the global callback |
| 166 | + if ( s.global ) { |
| 167 | + trigger( "ajaxSuccess", [{}, s] ); |
| 168 | + } |
| 169 | + } |
| 170 | + |
| 171 | + function complete() { |
| 172 | + // Process result |
| 173 | + if ( s.complete ) { |
| 174 | + s.complete.call( callbackContext, {} , status ); |
| 175 | + } |
| 176 | + |
| 177 | + // The request was completed |
| 178 | + if ( s.global ) { |
| 179 | + trigger( "ajaxComplete", [{}, s] ); |
| 180 | + } |
| 181 | + |
| 182 | + // Handle the global AJAX counter |
| 183 | + if ( s.global && ! --jQuery.active ) { |
| 184 | + jQuery.event.trigger( "ajaxStop" ); |
| 185 | + } |
| 186 | + } |
| 187 | + |
| 188 | + function trigger(type, args) { |
| 189 | + (s.context ? jQuery(s.context) : jQuery.event).trigger(type, args); |
| 190 | + } |
| 191 | + |
| 192 | + if ( m.response && $.isFunction(m.response) ) { |
| 193 | + m.response(origSettings); |
| 194 | + } else { |
| 195 | + $.globalEval(m.responseText); |
| 196 | + } |
| 197 | + success(); |
| 198 | + complete(); |
| 199 | + return false; |
| 200 | + } |
| 201 | + mock = _ajax.call($, $.extend(true, {}, origSettings, { |
| 202 | + // Mock the XHR object |
| 203 | + xhr: function() { |
| 204 | + // Extend with our default mockjax settings |
| 205 | + m = $.extend({}, $.mockjaxSettings, m); |
| 206 | + // Return our mock xhr object |
| 207 | + return { |
| 208 | + status: m.status, |
| 209 | + readyState: 1, |
| 210 | + open: function() { }, |
| 211 | + send: function() { |
| 212 | + var process = $.proxy(function() { |
| 213 | + // The request has returned |
| 214 | + this.status = m.status; |
| 215 | + this.readyState = 4; |
| 216 | + |
| 217 | + // We have an executable function, call it to give |
| 218 | + // the mock a chance to update it's data |
| 219 | + if ( $.isFunction(m.response) ) { |
| 220 | + m.response(origSettings); |
| 221 | + } |
| 222 | + // Copy over our mock to our xhr object before passing control back to |
| 223 | + // jQuery's onreadystatechange callback |
| 224 | + if ( s.dataType == 'json' && ( typeof m.responseText == 'object' ) ) { |
| 225 | + this.responseText = JSON.stringify(m.responseText); |
| 226 | + } else if ( s.dataType == 'xml' ) { |
| 227 | + if ( $.xmlDOM && typeof m.responseXML == 'string' ) { |
| 228 | + // Parse the XML from a string into a DOM |
| 229 | + this.responseXML = $.xmlDOM( m.responseXML )[0]; |
| 230 | + } else { |
| 231 | + this.responseXML = m.responseXML; |
| 232 | + } |
| 233 | + } else { |
| 234 | + this.responseText = m.responseText; |
| 235 | + } |
| 236 | + this.onreadystatechange( m.isTimeout ? 'timeout' : undefined ); |
| 237 | + }, this); |
| 238 | + |
| 239 | + if ( m.proxy ) { |
| 240 | + // We're proxying this request and loading in an external file instead |
| 241 | + _ajax({ |
| 242 | + global: false, |
| 243 | + url: m.proxy, |
| 244 | + type: m.type, |
| 245 | + data: m.data, |
| 246 | + dataType: s.dataType, |
| 247 | + complete: function(xhr, txt) { |
| 248 | + m.responseXML = xhr.responseXML; |
| 249 | + m.responseText = xhr.responseText; |
| 250 | + this.responseTimer = setTimeout(process, m.responseTime || 0); |
| 251 | + } |
| 252 | + }); |
| 253 | + } else { |
| 254 | + // type == 'POST' || 'GET' || 'DELETE' |
| 255 | + if ( s.async === false ) { |
| 256 | + // TODO: Blocking delay |
| 257 | + process(); |
| 258 | + } else { |
| 259 | + this.responseTimer = setTimeout(process, m.responseTime || 50); |
| 260 | + } |
| 261 | + } |
| 262 | + }, |
| 263 | + abort: function() { |
| 264 | + clearTimeout(this.responseTimer); |
| 265 | + }, |
| 266 | + setRequestHeader: function() { }, |
| 267 | + getResponseHeader: function(header) { |
| 268 | + // 'Last-modified', 'Etag', 'content-type' are all checked by jQuery |
| 269 | + if ( m.headers && m.headers[header] ) { |
| 270 | + // Return arbitrary headers |
| 271 | + return m.headers[header]; |
| 272 | + } else if ( header == 'Last-modified' ) { |
| 273 | + return m.lastModified || (new Date()).toString(); |
| 274 | + } else if ( header == 'Etag' ) { |
| 275 | + return m.etag || ''; |
| 276 | + } else if ( header == 'content-type' ) { |
| 277 | + return m.contentType || 'text/plain'; |
| 278 | + } |
| 279 | + } |
| 280 | + }; |
| 281 | + } |
| 282 | + })); |
| 283 | + return false; |
| 284 | + } |
| 285 | + }); |
| 286 | + // We don't have a mock request, trigger a normal request |
| 287 | + if ( !mock ) { |
| 288 | + return _ajax.apply($, arguments); |
| 289 | + } else { |
| 290 | + return mock; |
| 291 | + } |
| 292 | + } |
| 293 | + }); |
| 294 | + |
| 295 | + $.mockjaxSettings = { |
| 296 | + //url: null, |
| 297 | + //type: 'GET', |
| 298 | + status: 200, |
| 299 | + responseTime: 500, |
| 300 | + isTimeout: false, |
| 301 | + contentType: 'text/plain', |
| 302 | + response: '', |
| 303 | + responseText: '', |
| 304 | + responseXML: '', |
| 305 | + proxy: '', |
| 306 | + |
| 307 | + lastModified: null, |
| 308 | + etag: '', |
| 309 | + headers: { |
| 310 | + etag: 'IJF@H#@923uf8023hFO@I#H#', |
| 311 | + 'content-type' : 'text/plain' |
| 312 | + } |
| 313 | + }; |
| 314 | + |
| 315 | + $.mockjax = function(settings) { |
| 316 | + var i = mockHandlers.length; |
| 317 | + mockHandlers[i] = settings; |
| 318 | + return i; |
| 319 | + }; |
| 320 | + $.mockjaxClear = function(i) { |
| 321 | + if ( arguments.length == 1 ) { |
| 322 | + mockHandlers[i] = null; |
| 323 | + } else { |
| 324 | + mockHandlers = []; |
| 325 | + } |
| 326 | + }; |
| 327 | +})(jQuery); |
Property changes on: trunk/extensions/jQueryMsg/test/jasmine/lib/appendto-jquery-mockjax/jquery.mockjax.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 328 | + native |
Index: trunk/extensions/jQueryMsg/test/jasmine/lib/appendto-jquery-mockjax/lib/jquery.xmldom.js |
— | — | @@ -0,0 +1,46 @@ |
| 2 | +/*! |
| 3 | + * jQuery xmlDOM Plugin v1.0 |
| 4 | + * http://outwestmedia.com/jquery-plugins/xmldom/ |
| 5 | + * |
| 6 | + * Released: 2009-04-06 |
| 7 | + * Version: 1.0 |
| 8 | + * |
| 9 | + * Copyright (c) 2009 Jonathan Sharp, Out West Media LLC. |
| 10 | + * Dual licensed under the MIT and GPL licenses. |
| 11 | + * http://docs.jquery.com/License |
| 12 | + */ |
| 13 | +(function($) { |
| 14 | + // IE DOMParser wrapper |
| 15 | + if ( window['DOMParser'] == undefined && window.ActiveXObject ) { |
| 16 | + DOMParser = function() { }; |
| 17 | + DOMParser.prototype.parseFromString = function( xmlString ) { |
| 18 | + var doc = new ActiveXObject('Microsoft.XMLDOM'); |
| 19 | + doc.async = 'false'; |
| 20 | + doc.loadXML( xmlString ); |
| 21 | + return doc; |
| 22 | + }; |
| 23 | + } |
| 24 | + |
| 25 | + $.xmlDOM = function(xml, onErrorFn) { |
| 26 | + try { |
| 27 | + var xmlDoc = ( new DOMParser() ).parseFromString( xml, 'text/xml' ); |
| 28 | + if ( $.isXMLDoc( xmlDoc ) ) { |
| 29 | + var err = $('parsererror', xmlDoc); |
| 30 | + if ( err.length == 1 ) { |
| 31 | + throw('Error: ' + $(xmlDoc).text() ); |
| 32 | + } |
| 33 | + } else { |
| 34 | + throw('Unable to parse XML'); |
| 35 | + } |
| 36 | + } catch( e ) { |
| 37 | + var msg = ( e.name == undefined ? e : e.name + ': ' + e.message ); |
| 38 | + if ( $.isFunction( onErrorFn ) ) { |
| 39 | + onErrorFn( msg ); |
| 40 | + } else { |
| 41 | + $(document).trigger('xmlParseError', [ msg ]); |
| 42 | + } |
| 43 | + return $([]); |
| 44 | + } |
| 45 | + return $( xmlDoc ); |
| 46 | + }; |
| 47 | +})(jQuery); |
\ No newline at end of file |
Property changes on: trunk/extensions/jQueryMsg/test/jasmine/lib/appendto-jquery-mockjax/lib/jquery.xmldom.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 48 | + native |
Index: trunk/extensions/jQueryMsg/test/jasmine/lib/appendto-jquery-mockjax/lib/jquery-1.4.2.js |
— | — | @@ -0,0 +1,6240 @@ |
| 2 | +/*! |
| 3 | + * jQuery JavaScript Library v1.4.2 |
| 4 | + * http://jquery.com/ |
| 5 | + * |
| 6 | + * Copyright 2010, John Resig |
| 7 | + * Dual licensed under the MIT or GPL Version 2 licenses. |
| 8 | + * http://jquery.org/license |
| 9 | + * |
| 10 | + * Includes Sizzle.js |
| 11 | + * http://sizzlejs.com/ |
| 12 | + * Copyright 2010, The Dojo Foundation |
| 13 | + * Released under the MIT, BSD, and GPL Licenses. |
| 14 | + * |
| 15 | + * Date: Sat Feb 13 22:33:48 2010 -0500 |
| 16 | + */ |
| 17 | +(function( window, undefined ) { |
| 18 | + |
| 19 | +// Define a local copy of jQuery |
| 20 | +var jQuery = function( selector, context ) { |
| 21 | + // The jQuery object is actually just the init constructor 'enhanced' |
| 22 | + return new jQuery.fn.init( selector, context ); |
| 23 | + }, |
| 24 | + |
| 25 | + // Map over jQuery in case of overwrite |
| 26 | + _jQuery = window.jQuery, |
| 27 | + |
| 28 | + // Map over the $ in case of overwrite |
| 29 | + _$ = window.$, |
| 30 | + |
| 31 | + // Use the correct document accordingly with window argument (sandbox) |
| 32 | + document = window.document, |
| 33 | + |
| 34 | + // A central reference to the root jQuery(document) |
| 35 | + rootjQuery, |
| 36 | + |
| 37 | + // A simple way to check for HTML strings or ID strings |
| 38 | + // (both of which we optimize for) |
| 39 | + quickExpr = /^[^<]*(<[\w\W]+>)[^>]*$|^#([\w-]+)$/, |
| 40 | + |
| 41 | + // Is it a simple selector |
| 42 | + isSimple = /^.[^:#\[\.,]*$/, |
| 43 | + |
| 44 | + // Check if a string has a non-whitespace character in it |
| 45 | + rnotwhite = /\S/, |
| 46 | + |
| 47 | + // Used for trimming whitespace |
| 48 | + rtrim = /^(\s|\u00A0)+|(\s|\u00A0)+$/g, |
| 49 | + |
| 50 | + // Match a standalone tag |
| 51 | + rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/, |
| 52 | + |
| 53 | + // Keep a UserAgent string for use with jQuery.browser |
| 54 | + userAgent = navigator.userAgent, |
| 55 | + |
| 56 | + // For matching the engine and version of the browser |
| 57 | + browserMatch, |
| 58 | + |
| 59 | + // Has the ready events already been bound? |
| 60 | + readyBound = false, |
| 61 | + |
| 62 | + // The functions to execute on DOM ready |
| 63 | + readyList = [], |
| 64 | + |
| 65 | + // The ready event handler |
| 66 | + DOMContentLoaded, |
| 67 | + |
| 68 | + // Save a reference to some core methods |
| 69 | + toString = Object.prototype.toString, |
| 70 | + hasOwnProperty = Object.prototype.hasOwnProperty, |
| 71 | + push = Array.prototype.push, |
| 72 | + slice = Array.prototype.slice, |
| 73 | + indexOf = Array.prototype.indexOf; |
| 74 | + |
| 75 | +jQuery.fn = jQuery.prototype = { |
| 76 | + init: function( selector, context ) { |
| 77 | + var match, elem, ret, doc; |
| 78 | + |
| 79 | + // Handle $(""), $(null), or $(undefined) |
| 80 | + if ( !selector ) { |
| 81 | + return this; |
| 82 | + } |
| 83 | + |
| 84 | + // Handle $(DOMElement) |
| 85 | + if ( selector.nodeType ) { |
| 86 | + this.context = this[0] = selector; |
| 87 | + this.length = 1; |
| 88 | + return this; |
| 89 | + } |
| 90 | + |
| 91 | + // The body element only exists once, optimize finding it |
| 92 | + if ( selector === "body" && !context ) { |
| 93 | + this.context = document; |
| 94 | + this[0] = document.body; |
| 95 | + this.selector = "body"; |
| 96 | + this.length = 1; |
| 97 | + return this; |
| 98 | + } |
| 99 | + |
| 100 | + // Handle HTML strings |
| 101 | + if ( typeof selector === "string" ) { |
| 102 | + // Are we dealing with HTML string or an ID? |
| 103 | + match = quickExpr.exec( selector ); |
| 104 | + |
| 105 | + // Verify a match, and that no context was specified for #id |
| 106 | + if ( match && (match[1] || !context) ) { |
| 107 | + |
| 108 | + // HANDLE: $(html) -> $(array) |
| 109 | + if ( match[1] ) { |
| 110 | + doc = (context ? context.ownerDocument || context : document); |
| 111 | + |
| 112 | + // If a single string is passed in and it's a single tag |
| 113 | + // just do a createElement and skip the rest |
| 114 | + ret = rsingleTag.exec( selector ); |
| 115 | + |
| 116 | + if ( ret ) { |
| 117 | + if ( jQuery.isPlainObject( context ) ) { |
| 118 | + selector = [ document.createElement( ret[1] ) ]; |
| 119 | + jQuery.fn.attr.call( selector, context, true ); |
| 120 | + |
| 121 | + } else { |
| 122 | + selector = [ doc.createElement( ret[1] ) ]; |
| 123 | + } |
| 124 | + |
| 125 | + } else { |
| 126 | + ret = buildFragment( [ match[1] ], [ doc ] ); |
| 127 | + selector = (ret.cacheable ? ret.fragment.cloneNode(true) : ret.fragment).childNodes; |
| 128 | + } |
| 129 | + |
| 130 | + return jQuery.merge( this, selector ); |
| 131 | + |
| 132 | + // HANDLE: $("#id") |
| 133 | + } else { |
| 134 | + elem = document.getElementById( match[2] ); |
| 135 | + |
| 136 | + if ( elem ) { |
| 137 | + // Handle the case where IE and Opera return items |
| 138 | + // by name instead of ID |
| 139 | + if ( elem.id !== match[2] ) { |
| 140 | + return rootjQuery.find( selector ); |
| 141 | + } |
| 142 | + |
| 143 | + // Otherwise, we inject the element directly into the jQuery object |
| 144 | + this.length = 1; |
| 145 | + this[0] = elem; |
| 146 | + } |
| 147 | + |
| 148 | + this.context = document; |
| 149 | + this.selector = selector; |
| 150 | + return this; |
| 151 | + } |
| 152 | + |
| 153 | + // HANDLE: $("TAG") |
| 154 | + } else if ( !context && /^\w+$/.test( selector ) ) { |
| 155 | + this.selector = selector; |
| 156 | + this.context = document; |
| 157 | + selector = document.getElementsByTagName( selector ); |
| 158 | + return jQuery.merge( this, selector ); |
| 159 | + |
| 160 | + // HANDLE: $(expr, $(...)) |
| 161 | + } else if ( !context || context.jquery ) { |
| 162 | + return (context || rootjQuery).find( selector ); |
| 163 | + |
| 164 | + // HANDLE: $(expr, context) |
| 165 | + // (which is just equivalent to: $(context).find(expr) |
| 166 | + } else { |
| 167 | + return jQuery( context ).find( selector ); |
| 168 | + } |
| 169 | + |
| 170 | + // HANDLE: $(function) |
| 171 | + // Shortcut for document ready |
| 172 | + } else if ( jQuery.isFunction( selector ) ) { |
| 173 | + return rootjQuery.ready( selector ); |
| 174 | + } |
| 175 | + |
| 176 | + if (selector.selector !== undefined) { |
| 177 | + this.selector = selector.selector; |
| 178 | + this.context = selector.context; |
| 179 | + } |
| 180 | + |
| 181 | + return jQuery.makeArray( selector, this ); |
| 182 | + }, |
| 183 | + |
| 184 | + // Start with an empty selector |
| 185 | + selector: "", |
| 186 | + |
| 187 | + // The current version of jQuery being used |
| 188 | + jquery: "1.4.2", |
| 189 | + |
| 190 | + // The default length of a jQuery object is 0 |
| 191 | + length: 0, |
| 192 | + |
| 193 | + // The number of elements contained in the matched element set |
| 194 | + size: function() { |
| 195 | + return this.length; |
| 196 | + }, |
| 197 | + |
| 198 | + toArray: function() { |
| 199 | + return slice.call( this, 0 ); |
| 200 | + }, |
| 201 | + |
| 202 | + // Get the Nth element in the matched element set OR |
| 203 | + // Get the whole matched element set as a clean array |
| 204 | + get: function( num ) { |
| 205 | + return num == null ? |
| 206 | + |
| 207 | + // Return a 'clean' array |
| 208 | + this.toArray() : |
| 209 | + |
| 210 | + // Return just the object |
| 211 | + ( num < 0 ? this.slice(num)[ 0 ] : this[ num ] ); |
| 212 | + }, |
| 213 | + |
| 214 | + // Take an array of elements and push it onto the stack |
| 215 | + // (returning the new matched element set) |
| 216 | + pushStack: function( elems, name, selector ) { |
| 217 | + // Build a new jQuery matched element set |
| 218 | + var ret = jQuery(); |
| 219 | + |
| 220 | + if ( jQuery.isArray( elems ) ) { |
| 221 | + push.apply( ret, elems ); |
| 222 | + |
| 223 | + } else { |
| 224 | + jQuery.merge( ret, elems ); |
| 225 | + } |
| 226 | + |
| 227 | + // Add the old object onto the stack (as a reference) |
| 228 | + ret.prevObject = this; |
| 229 | + |
| 230 | + ret.context = this.context; |
| 231 | + |
| 232 | + if ( name === "find" ) { |
| 233 | + ret.selector = this.selector + (this.selector ? " " : "") + selector; |
| 234 | + } else if ( name ) { |
| 235 | + ret.selector = this.selector + "." + name + "(" + selector + ")"; |
| 236 | + } |
| 237 | + |
| 238 | + // Return the newly-formed element set |
| 239 | + return ret; |
| 240 | + }, |
| 241 | + |
| 242 | + // Execute a callback for every element in the matched set. |
| 243 | + // (You can seed the arguments with an array of args, but this is |
| 244 | + // only used internally.) |
| 245 | + each: function( callback, args ) { |
| 246 | + return jQuery.each( this, callback, args ); |
| 247 | + }, |
| 248 | + |
| 249 | + ready: function( fn ) { |
| 250 | + // Attach the listeners |
| 251 | + jQuery.bindReady(); |
| 252 | + |
| 253 | + // If the DOM is already ready |
| 254 | + if ( jQuery.isReady ) { |
| 255 | + // Execute the function immediately |
| 256 | + fn.call( document, jQuery ); |
| 257 | + |
| 258 | + // Otherwise, remember the function for later |
| 259 | + } else if ( readyList ) { |
| 260 | + // Add the function to the wait list |
| 261 | + readyList.push( fn ); |
| 262 | + } |
| 263 | + |
| 264 | + return this; |
| 265 | + }, |
| 266 | + |
| 267 | + eq: function( i ) { |
| 268 | + return i === -1 ? |
| 269 | + this.slice( i ) : |
| 270 | + this.slice( i, +i + 1 ); |
| 271 | + }, |
| 272 | + |
| 273 | + first: function() { |
| 274 | + return this.eq( 0 ); |
| 275 | + }, |
| 276 | + |
| 277 | + last: function() { |
| 278 | + return this.eq( -1 ); |
| 279 | + }, |
| 280 | + |
| 281 | + slice: function() { |
| 282 | + return this.pushStack( slice.apply( this, arguments ), |
| 283 | + "slice", slice.call(arguments).join(",") ); |
| 284 | + }, |
| 285 | + |
| 286 | + map: function( callback ) { |
| 287 | + return this.pushStack( jQuery.map(this, function( elem, i ) { |
| 288 | + return callback.call( elem, i, elem ); |
| 289 | + })); |
| 290 | + }, |
| 291 | + |
| 292 | + end: function() { |
| 293 | + return this.prevObject || jQuery(null); |
| 294 | + }, |
| 295 | + |
| 296 | + // For internal use only. |
| 297 | + // Behaves like an Array's method, not like a jQuery method. |
| 298 | + push: push, |
| 299 | + sort: [].sort, |
| 300 | + splice: [].splice |
| 301 | +}; |
| 302 | + |
| 303 | +// Give the init function the jQuery prototype for later instantiation |
| 304 | +jQuery.fn.init.prototype = jQuery.fn; |
| 305 | + |
| 306 | +jQuery.extend = jQuery.fn.extend = function() { |
| 307 | + // copy reference to target object |
| 308 | + var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options, name, src, copy; |
| 309 | + |
| 310 | + // Handle a deep copy situation |
| 311 | + if ( typeof target === "boolean" ) { |
| 312 | + deep = target; |
| 313 | + target = arguments[1] || {}; |
| 314 | + // skip the boolean and the target |
| 315 | + i = 2; |
| 316 | + } |
| 317 | + |
| 318 | + // Handle case when target is a string or something (possible in deep copy) |
| 319 | + if ( typeof target !== "object" && !jQuery.isFunction(target) ) { |
| 320 | + target = {}; |
| 321 | + } |
| 322 | + |
| 323 | + // extend jQuery itself if only one argument is passed |
| 324 | + if ( length === i ) { |
| 325 | + target = this; |
| 326 | + --i; |
| 327 | + } |
| 328 | + |
| 329 | + for ( ; i < length; i++ ) { |
| 330 | + // Only deal with non-null/undefined values |
| 331 | + if ( (options = arguments[ i ]) != null ) { |
| 332 | + // Extend the base object |
| 333 | + for ( name in options ) { |
| 334 | + src = target[ name ]; |
| 335 | + copy = options[ name ]; |
| 336 | + |
| 337 | + // Prevent never-ending loop |
| 338 | + if ( target === copy ) { |
| 339 | + continue; |
| 340 | + } |
| 341 | + |
| 342 | + // Recurse if we're merging object literal values or arrays |
| 343 | + if ( deep && copy && ( jQuery.isPlainObject(copy) || jQuery.isArray(copy) ) ) { |
| 344 | + var clone = src && ( jQuery.isPlainObject(src) || jQuery.isArray(src) ) ? src |
| 345 | + : jQuery.isArray(copy) ? [] : {}; |
| 346 | + |
| 347 | + // Never move original objects, clone them |
| 348 | + target[ name ] = jQuery.extend( deep, clone, copy ); |
| 349 | + |
| 350 | + // Don't bring in undefined values |
| 351 | + } else if ( copy !== undefined ) { |
| 352 | + target[ name ] = copy; |
| 353 | + } |
| 354 | + } |
| 355 | + } |
| 356 | + } |
| 357 | + |
| 358 | + // Return the modified object |
| 359 | + return target; |
| 360 | +}; |
| 361 | + |
| 362 | +jQuery.extend({ |
| 363 | + noConflict: function( deep ) { |
| 364 | + window.$ = _$; |
| 365 | + |
| 366 | + if ( deep ) { |
| 367 | + window.jQuery = _jQuery; |
| 368 | + } |
| 369 | + |
| 370 | + return jQuery; |
| 371 | + }, |
| 372 | + |
| 373 | + // Is the DOM ready to be used? Set to true once it occurs. |
| 374 | + isReady: false, |
| 375 | + |
| 376 | + // Handle when the DOM is ready |
| 377 | + ready: function() { |
| 378 | + // Make sure that the DOM is not already loaded |
| 379 | + if ( !jQuery.isReady ) { |
| 380 | + // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). |
| 381 | + if ( !document.body ) { |
| 382 | + return setTimeout( jQuery.ready, 13 ); |
| 383 | + } |
| 384 | + |
| 385 | + // Remember that the DOM is ready |
| 386 | + jQuery.isReady = true; |
| 387 | + |
| 388 | + // If there are functions bound, to execute |
| 389 | + if ( readyList ) { |
| 390 | + // Execute all of them |
| 391 | + var fn, i = 0; |
| 392 | + while ( (fn = readyList[ i++ ]) ) { |
| 393 | + fn.call( document, jQuery ); |
| 394 | + } |
| 395 | + |
| 396 | + // Reset the list of functions |
| 397 | + readyList = null; |
| 398 | + } |
| 399 | + |
| 400 | + // Trigger any bound ready events |
| 401 | + if ( jQuery.fn.triggerHandler ) { |
| 402 | + jQuery( document ).triggerHandler( "ready" ); |
| 403 | + } |
| 404 | + } |
| 405 | + }, |
| 406 | + |
| 407 | + bindReady: function() { |
| 408 | + if ( readyBound ) { |
| 409 | + return; |
| 410 | + } |
| 411 | + |
| 412 | + readyBound = true; |
| 413 | + |
| 414 | + // Catch cases where $(document).ready() is called after the |
| 415 | + // browser event has already occurred. |
| 416 | + if ( document.readyState === "complete" ) { |
| 417 | + return jQuery.ready(); |
| 418 | + } |
| 419 | + |
| 420 | + // Mozilla, Opera and webkit nightlies currently support this event |
| 421 | + if ( document.addEventListener ) { |
| 422 | + // Use the handy event callback |
| 423 | + document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false ); |
| 424 | + |
| 425 | + // A fallback to window.onload, that will always work |
| 426 | + window.addEventListener( "load", jQuery.ready, false ); |
| 427 | + |
| 428 | + // If IE event model is used |
| 429 | + } else if ( document.attachEvent ) { |
| 430 | + // ensure firing before onload, |
| 431 | + // maybe late but safe also for iframes |
| 432 | + document.attachEvent("onreadystatechange", DOMContentLoaded); |
| 433 | + |
| 434 | + // A fallback to window.onload, that will always work |
| 435 | + window.attachEvent( "onload", jQuery.ready ); |
| 436 | + |
| 437 | + // If IE and not a frame |
| 438 | + // continually check to see if the document is ready |
| 439 | + var toplevel = false; |
| 440 | + |
| 441 | + try { |
| 442 | + toplevel = window.frameElement == null; |
| 443 | + } catch(e) {} |
| 444 | + |
| 445 | + if ( document.documentElement.doScroll && toplevel ) { |
| 446 | + doScrollCheck(); |
| 447 | + } |
| 448 | + } |
| 449 | + }, |
| 450 | + |
| 451 | + // See test/unit/core.js for details concerning isFunction. |
| 452 | + // Since version 1.3, DOM methods and functions like alert |
| 453 | + // aren't supported. They return false on IE (#2968). |
| 454 | + isFunction: function( obj ) { |
| 455 | + return toString.call(obj) === "[object Function]"; |
| 456 | + }, |
| 457 | + |
| 458 | + isArray: function( obj ) { |
| 459 | + return toString.call(obj) === "[object Array]"; |
| 460 | + }, |
| 461 | + |
| 462 | + isPlainObject: function( obj ) { |
| 463 | + // Must be an Object. |
| 464 | + // Because of IE, we also have to check the presence of the constructor property. |
| 465 | + // Make sure that DOM nodes and window objects don't pass through, as well |
| 466 | + if ( !obj || toString.call(obj) !== "[object Object]" || obj.nodeType || obj.setInterval ) { |
| 467 | + return false; |
| 468 | + } |
| 469 | + |
| 470 | + // Not own constructor property must be Object |
| 471 | + if ( obj.constructor |
| 472 | + && !hasOwnProperty.call(obj, "constructor") |
| 473 | + && !hasOwnProperty.call(obj.constructor.prototype, "isPrototypeOf") ) { |
| 474 | + return false; |
| 475 | + } |
| 476 | + |
| 477 | + // Own properties are enumerated firstly, so to speed up, |
| 478 | + // if last one is own, then all properties are own. |
| 479 | + |
| 480 | + var key; |
| 481 | + for ( key in obj ) {} |
| 482 | + |
| 483 | + return key === undefined || hasOwnProperty.call( obj, key ); |
| 484 | + }, |
| 485 | + |
| 486 | + isEmptyObject: function( obj ) { |
| 487 | + for ( var name in obj ) { |
| 488 | + return false; |
| 489 | + } |
| 490 | + return true; |
| 491 | + }, |
| 492 | + |
| 493 | + error: function( msg ) { |
| 494 | + throw msg; |
| 495 | + }, |
| 496 | + |
| 497 | + parseJSON: function( data ) { |
| 498 | + if ( typeof data !== "string" || !data ) { |
| 499 | + return null; |
| 500 | + } |
| 501 | + |
| 502 | + // Make sure leading/trailing whitespace is removed (IE can't handle it) |
| 503 | + data = jQuery.trim( data ); |
| 504 | + |
| 505 | + // Make sure the incoming data is actual JSON |
| 506 | + // Logic borrowed from http://json.org/json2.js |
| 507 | + if ( /^[\],:{}\s]*$/.test(data.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, "@") |
| 508 | + .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, "]") |
| 509 | + .replace(/(?:^|:|,)(?:\s*\[)+/g, "")) ) { |
| 510 | + |
| 511 | + // Try to use the native JSON parser first |
| 512 | + return window.JSON && window.JSON.parse ? |
| 513 | + window.JSON.parse( data ) : |
| 514 | + (new Function("return " + data))(); |
| 515 | + |
| 516 | + } else { |
| 517 | + jQuery.error( "Invalid JSON: " + data ); |
| 518 | + } |
| 519 | + }, |
| 520 | + |
| 521 | + noop: function() {}, |
| 522 | + |
| 523 | + // Evalulates a script in a global context |
| 524 | + globalEval: function( data ) { |
| 525 | + if ( data && rnotwhite.test(data) ) { |
| 526 | + // Inspired by code by Andrea Giammarchi |
| 527 | + // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html |
| 528 | + var head = document.getElementsByTagName("head")[0] || document.documentElement, |
| 529 | + script = document.createElement("script"); |
| 530 | + |
| 531 | + script.type = "text/javascript"; |
| 532 | + |
| 533 | + if ( jQuery.support.scriptEval ) { |
| 534 | + script.appendChild( document.createTextNode( data ) ); |
| 535 | + } else { |
| 536 | + script.text = data; |
| 537 | + } |
| 538 | + |
| 539 | + // Use insertBefore instead of appendChild to circumvent an IE6 bug. |
| 540 | + // This arises when a base node is used (#2709). |
| 541 | + head.insertBefore( script, head.firstChild ); |
| 542 | + head.removeChild( script ); |
| 543 | + } |
| 544 | + }, |
| 545 | + |
| 546 | + nodeName: function( elem, name ) { |
| 547 | + return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase(); |
| 548 | + }, |
| 549 | + |
| 550 | + // args is for internal usage only |
| 551 | + each: function( object, callback, args ) { |
| 552 | + var name, i = 0, |
| 553 | + length = object.length, |
| 554 | + isObj = length === undefined || jQuery.isFunction(object); |
| 555 | + |
| 556 | + if ( args ) { |
| 557 | + if ( isObj ) { |
| 558 | + for ( name in object ) { |
| 559 | + if ( callback.apply( object[ name ], args ) === false ) { |
| 560 | + break; |
| 561 | + } |
| 562 | + } |
| 563 | + } else { |
| 564 | + for ( ; i < length; ) { |
| 565 | + if ( callback.apply( object[ i++ ], args ) === false ) { |
| 566 | + break; |
| 567 | + } |
| 568 | + } |
| 569 | + } |
| 570 | + |
| 571 | + // A special, fast, case for the most common use of each |
| 572 | + } else { |
| 573 | + if ( isObj ) { |
| 574 | + for ( name in object ) { |
| 575 | + if ( callback.call( object[ name ], name, object[ name ] ) === false ) { |
| 576 | + break; |
| 577 | + } |
| 578 | + } |
| 579 | + } else { |
| 580 | + for ( var value = object[0]; |
| 581 | + i < length && callback.call( value, i, value ) !== false; value = object[++i] ) {} |
| 582 | + } |
| 583 | + } |
| 584 | + |
| 585 | + return object; |
| 586 | + }, |
| 587 | + |
| 588 | + trim: function( text ) { |
| 589 | + return (text || "").replace( rtrim, "" ); |
| 590 | + }, |
| 591 | + |
| 592 | + // results is for internal usage only |
| 593 | + makeArray: function( array, results ) { |
| 594 | + var ret = results || []; |
| 595 | + |
| 596 | + if ( array != null ) { |
| 597 | + // The window, strings (and functions) also have 'length' |
| 598 | + // The extra typeof function check is to prevent crashes |
| 599 | + // in Safari 2 (See: #3039) |
| 600 | + if ( array.length == null || typeof array === "string" || jQuery.isFunction(array) || (typeof array !== "function" && array.setInterval) ) { |
| 601 | + push.call( ret, array ); |
| 602 | + } else { |
| 603 | + jQuery.merge( ret, array ); |
| 604 | + } |
| 605 | + } |
| 606 | + |
| 607 | + return ret; |
| 608 | + }, |
| 609 | + |
| 610 | + inArray: function( elem, array ) { |
| 611 | + if ( array.indexOf ) { |
| 612 | + return array.indexOf( elem ); |
| 613 | + } |
| 614 | + |
| 615 | + for ( var i = 0, length = array.length; i < length; i++ ) { |
| 616 | + if ( array[ i ] === elem ) { |
| 617 | + return i; |
| 618 | + } |
| 619 | + } |
| 620 | + |
| 621 | + return -1; |
| 622 | + }, |
| 623 | + |
| 624 | + merge: function( first, second ) { |
| 625 | + var i = first.length, j = 0; |
| 626 | + |
| 627 | + if ( typeof second.length === "number" ) { |
| 628 | + for ( var l = second.length; j < l; j++ ) { |
| 629 | + first[ i++ ] = second[ j ]; |
| 630 | + } |
| 631 | + |
| 632 | + } else { |
| 633 | + while ( second[j] !== undefined ) { |
| 634 | + first[ i++ ] = second[ j++ ]; |
| 635 | + } |
| 636 | + } |
| 637 | + |
| 638 | + first.length = i; |
| 639 | + |
| 640 | + return first; |
| 641 | + }, |
| 642 | + |
| 643 | + grep: function( elems, callback, inv ) { |
| 644 | + var ret = []; |
| 645 | + |
| 646 | + // Go through the array, only saving the items |
| 647 | + // that pass the validator function |
| 648 | + for ( var i = 0, length = elems.length; i < length; i++ ) { |
| 649 | + if ( !inv !== !callback( elems[ i ], i ) ) { |
| 650 | + ret.push( elems[ i ] ); |
| 651 | + } |
| 652 | + } |
| 653 | + |
| 654 | + return ret; |
| 655 | + }, |
| 656 | + |
| 657 | + // arg is for internal usage only |
| 658 | + map: function( elems, callback, arg ) { |
| 659 | + var ret = [], value; |
| 660 | + |
| 661 | + // Go through the array, translating each of the items to their |
| 662 | + // new value (or values). |
| 663 | + for ( var i = 0, length = elems.length; i < length; i++ ) { |
| 664 | + value = callback( elems[ i ], i, arg ); |
| 665 | + |
| 666 | + if ( value != null ) { |
| 667 | + ret[ ret.length ] = value; |
| 668 | + } |
| 669 | + } |
| 670 | + |
| 671 | + return ret.concat.apply( [], ret ); |
| 672 | + }, |
| 673 | + |
| 674 | + // A global GUID counter for objects |
| 675 | + guid: 1, |
| 676 | + |
| 677 | + proxy: function( fn, proxy, thisObject ) { |
| 678 | + if ( arguments.length === 2 ) { |
| 679 | + if ( typeof proxy === "string" ) { |
| 680 | + thisObject = fn; |
| 681 | + fn = thisObject[ proxy ]; |
| 682 | + proxy = undefined; |
| 683 | + |
| 684 | + } else if ( proxy && !jQuery.isFunction( proxy ) ) { |
| 685 | + thisObject = proxy; |
| 686 | + proxy = undefined; |
| 687 | + } |
| 688 | + } |
| 689 | + |
| 690 | + if ( !proxy && fn ) { |
| 691 | + proxy = function() { |
| 692 | + return fn.apply( thisObject || this, arguments ); |
| 693 | + }; |
| 694 | + } |
| 695 | + |
| 696 | + // Set the guid of unique handler to the same of original handler, so it can be removed |
| 697 | + if ( fn ) { |
| 698 | + proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++; |
| 699 | + } |
| 700 | + |
| 701 | + // So proxy can be declared as an argument |
| 702 | + return proxy; |
| 703 | + }, |
| 704 | + |
| 705 | + // Use of jQuery.browser is frowned upon. |
| 706 | + // More details: http://docs.jquery.com/Utilities/jQuery.browser |
| 707 | + uaMatch: function( ua ) { |
| 708 | + ua = ua.toLowerCase(); |
| 709 | + |
| 710 | + var match = /(webkit)[ \/]([\w.]+)/.exec( ua ) || |
| 711 | + /(opera)(?:.*version)?[ \/]([\w.]+)/.exec( ua ) || |
| 712 | + /(msie) ([\w.]+)/.exec( ua ) || |
| 713 | + !/compatible/.test( ua ) && /(mozilla)(?:.*? rv:([\w.]+))?/.exec( ua ) || |
| 714 | + []; |
| 715 | + |
| 716 | + return { browser: match[1] || "", version: match[2] || "0" }; |
| 717 | + }, |
| 718 | + |
| 719 | + browser: {} |
| 720 | +}); |
| 721 | + |
| 722 | +browserMatch = jQuery.uaMatch( userAgent ); |
| 723 | +if ( browserMatch.browser ) { |
| 724 | + jQuery.browser[ browserMatch.browser ] = true; |
| 725 | + jQuery.browser.version = browserMatch.version; |
| 726 | +} |
| 727 | + |
| 728 | +// Deprecated, use jQuery.browser.webkit instead |
| 729 | +if ( jQuery.browser.webkit ) { |
| 730 | + jQuery.browser.safari = true; |
| 731 | +} |
| 732 | + |
| 733 | +if ( indexOf ) { |
| 734 | + jQuery.inArray = function( elem, array ) { |
| 735 | + return indexOf.call( array, elem ); |
| 736 | + }; |
| 737 | +} |
| 738 | + |
| 739 | +// All jQuery objects should point back to these |
| 740 | +rootjQuery = jQuery(document); |
| 741 | + |
| 742 | +// Cleanup functions for the document ready method |
| 743 | +if ( document.addEventListener ) { |
| 744 | + DOMContentLoaded = function() { |
| 745 | + document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false ); |
| 746 | + jQuery.ready(); |
| 747 | + }; |
| 748 | + |
| 749 | +} else if ( document.attachEvent ) { |
| 750 | + DOMContentLoaded = function() { |
| 751 | + // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). |
| 752 | + if ( document.readyState === "complete" ) { |
| 753 | + document.detachEvent( "onreadystatechange", DOMContentLoaded ); |
| 754 | + jQuery.ready(); |
| 755 | + } |
| 756 | + }; |
| 757 | +} |
| 758 | + |
| 759 | +// The DOM ready check for Internet Explorer |
| 760 | +function doScrollCheck() { |
| 761 | + if ( jQuery.isReady ) { |
| 762 | + return; |
| 763 | + } |
| 764 | + |
| 765 | + try { |
| 766 | + // If IE is used, use the trick by Diego Perini |
| 767 | + // http://javascript.nwbox.com/IEContentLoaded/ |
| 768 | + document.documentElement.doScroll("left"); |
| 769 | + } catch( error ) { |
| 770 | + setTimeout( doScrollCheck, 1 ); |
| 771 | + return; |
| 772 | + } |
| 773 | + |
| 774 | + // and execute any waiting functions |
| 775 | + jQuery.ready(); |
| 776 | +} |
| 777 | + |
| 778 | +function evalScript( i, elem ) { |
| 779 | + if ( elem.src ) { |
| 780 | + jQuery.ajax({ |
| 781 | + url: elem.src, |
| 782 | + async: false, |
| 783 | + dataType: "script" |
| 784 | + }); |
| 785 | + } else { |
| 786 | + jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" ); |
| 787 | + } |
| 788 | + |
| 789 | + if ( elem.parentNode ) { |
| 790 | + elem.parentNode.removeChild( elem ); |
| 791 | + } |
| 792 | +} |
| 793 | + |
| 794 | +// Mutifunctional method to get and set values to a collection |
| 795 | +// The value/s can be optionally by executed if its a function |
| 796 | +function access( elems, key, value, exec, fn, pass ) { |
| 797 | + var length = elems.length; |
| 798 | + |
| 799 | + // Setting many attributes |
| 800 | + if ( typeof key === "object" ) { |
| 801 | + for ( var k in key ) { |
| 802 | + access( elems, k, key[k], exec, fn, value ); |
| 803 | + } |
| 804 | + return elems; |
| 805 | + } |
| 806 | + |
| 807 | + // Setting one attribute |
| 808 | + if ( value !== undefined ) { |
| 809 | + // Optionally, function values get executed if exec is true |
| 810 | + exec = !pass && exec && jQuery.isFunction(value); |
| 811 | + |
| 812 | + for ( var i = 0; i < length; i++ ) { |
| 813 | + fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass ); |
| 814 | + } |
| 815 | + |
| 816 | + return elems; |
| 817 | + } |
| 818 | + |
| 819 | + // Getting an attribute |
| 820 | + return length ? fn( elems[0], key ) : undefined; |
| 821 | +} |
| 822 | + |
| 823 | +function now() { |
| 824 | + return (new Date).getTime(); |
| 825 | +} |
| 826 | +(function() { |
| 827 | + |
| 828 | + jQuery.support = {}; |
| 829 | + |
| 830 | + var root = document.documentElement, |
| 831 | + script = document.createElement("script"), |
| 832 | + div = document.createElement("div"), |
| 833 | + id = "script" + now(); |
| 834 | + |
| 835 | + div.style.display = "none"; |
| 836 | + div.innerHTML = " <link/><table></table><a href='/a' style='color:red;float:left;opacity:.55;'>a</a><input type='checkbox'/>"; |
| 837 | + |
| 838 | + var all = div.getElementsByTagName("*"), |
| 839 | + a = div.getElementsByTagName("a")[0]; |
| 840 | + |
| 841 | + // Can't get basic test support |
| 842 | + if ( !all || !all.length || !a ) { |
| 843 | + return; |
| 844 | + } |
| 845 | + |
| 846 | + jQuery.support = { |
| 847 | + // IE strips leading whitespace when .innerHTML is used |
| 848 | + leadingWhitespace: div.firstChild.nodeType === 3, |
| 849 | + |
| 850 | + // Make sure that tbody elements aren't automatically inserted |
| 851 | + // IE will insert them into empty tables |
| 852 | + tbody: !div.getElementsByTagName("tbody").length, |
| 853 | + |
| 854 | + // Make sure that link elements get serialized correctly by innerHTML |
| 855 | + // This requires a wrapper element in IE |
| 856 | + htmlSerialize: !!div.getElementsByTagName("link").length, |
| 857 | + |
| 858 | + // Get the style information from getAttribute |
| 859 | + // (IE uses .cssText insted) |
| 860 | + style: /red/.test( a.getAttribute("style") ), |
| 861 | + |
| 862 | + // Make sure that URLs aren't manipulated |
| 863 | + // (IE normalizes it by default) |
| 864 | + hrefNormalized: a.getAttribute("href") === "/a", |
| 865 | + |
| 866 | + // Make sure that element opacity exists |
| 867 | + // (IE uses filter instead) |
| 868 | + // Use a regex to work around a WebKit issue. See #5145 |
| 869 | + opacity: /^0.55$/.test( a.style.opacity ), |
| 870 | + |
| 871 | + // Verify style float existence |
| 872 | + // (IE uses styleFloat instead of cssFloat) |
| 873 | + cssFloat: !!a.style.cssFloat, |
| 874 | + |
| 875 | + // Make sure that if no value is specified for a checkbox |
| 876 | + // that it defaults to "on". |
| 877 | + // (WebKit defaults to "" instead) |
| 878 | + checkOn: div.getElementsByTagName("input")[0].value === "on", |
| 879 | + |
| 880 | + // Make sure that a selected-by-default option has a working selected property. |
| 881 | + // (WebKit defaults to false instead of true, IE too, if it's in an optgroup) |
| 882 | + optSelected: document.createElement("select").appendChild( document.createElement("option") ).selected, |
| 883 | + |
| 884 | + parentNode: div.removeChild( div.appendChild( document.createElement("div") ) ).parentNode === null, |
| 885 | + |
| 886 | + // Will be defined later |
| 887 | + deleteExpando: true, |
| 888 | + checkClone: false, |
| 889 | + scriptEval: false, |
| 890 | + noCloneEvent: true, |
| 891 | + boxModel: null |
| 892 | + }; |
| 893 | + |
| 894 | + script.type = "text/javascript"; |
| 895 | + try { |
| 896 | + script.appendChild( document.createTextNode( "window." + id + "=1;" ) ); |
| 897 | + } catch(e) {} |
| 898 | + |
| 899 | + root.insertBefore( script, root.firstChild ); |
| 900 | + |
| 901 | + // Make sure that the execution of code works by injecting a script |
| 902 | + // tag with appendChild/createTextNode |
| 903 | + // (IE doesn't support this, fails, and uses .text instead) |
| 904 | + if ( window[ id ] ) { |
| 905 | + jQuery.support.scriptEval = true; |
| 906 | + delete window[ id ]; |
| 907 | + } |
| 908 | + |
| 909 | + // Test to see if it's possible to delete an expando from an element |
| 910 | + // Fails in Internet Explorer |
| 911 | + try { |
| 912 | + delete script.test; |
| 913 | + |
| 914 | + } catch(e) { |
| 915 | + jQuery.support.deleteExpando = false; |
| 916 | + } |
| 917 | + |
| 918 | + root.removeChild( script ); |
| 919 | + |
| 920 | + if ( div.attachEvent && div.fireEvent ) { |
| 921 | + div.attachEvent("onclick", function click() { |
| 922 | + // Cloning a node shouldn't copy over any |
| 923 | + // bound event handlers (IE does this) |
| 924 | + jQuery.support.noCloneEvent = false; |
| 925 | + div.detachEvent("onclick", click); |
| 926 | + }); |
| 927 | + div.cloneNode(true).fireEvent("onclick"); |
| 928 | + } |
| 929 | + |
| 930 | + div = document.createElement("div"); |
| 931 | + div.innerHTML = "<input type='radio' name='radiotest' checked='checked'/>"; |
| 932 | + |
| 933 | + var fragment = document.createDocumentFragment(); |
| 934 | + fragment.appendChild( div.firstChild ); |
| 935 | + |
| 936 | + // WebKit doesn't clone checked state correctly in fragments |
| 937 | + jQuery.support.checkClone = fragment.cloneNode(true).cloneNode(true).lastChild.checked; |
| 938 | + |
| 939 | + // Figure out if the W3C box model works as expected |
| 940 | + // document.body must exist before we can do this |
| 941 | + jQuery(function() { |
| 942 | + var div = document.createElement("div"); |
| 943 | + div.style.width = div.style.paddingLeft = "1px"; |
| 944 | + |
| 945 | + document.body.appendChild( div ); |
| 946 | + jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2; |
| 947 | + document.body.removeChild( div ).style.display = 'none'; |
| 948 | + |
| 949 | + div = null; |
| 950 | + }); |
| 951 | + |
| 952 | + // Technique from Juriy Zaytsev |
| 953 | + // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/ |
| 954 | + var eventSupported = function( eventName ) { |
| 955 | + var el = document.createElement("div"); |
| 956 | + eventName = "on" + eventName; |
| 957 | + |
| 958 | + var isSupported = (eventName in el); |
| 959 | + if ( !isSupported ) { |
| 960 | + el.setAttribute(eventName, "return;"); |
| 961 | + isSupported = typeof el[eventName] === "function"; |
| 962 | + } |
| 963 | + el = null; |
| 964 | + |
| 965 | + return isSupported; |
| 966 | + }; |
| 967 | + |
| 968 | + jQuery.support.submitBubbles = eventSupported("submit"); |
| 969 | + jQuery.support.changeBubbles = eventSupported("change"); |
| 970 | + |
| 971 | + // release memory in IE |
| 972 | + root = script = div = all = a = null; |
| 973 | +})(); |
| 974 | + |
| 975 | +jQuery.props = { |
| 976 | + "for": "htmlFor", |
| 977 | + "class": "className", |
| 978 | + readonly: "readOnly", |
| 979 | + maxlength: "maxLength", |
| 980 | + cellspacing: "cellSpacing", |
| 981 | + rowspan: "rowSpan", |
| 982 | + colspan: "colSpan", |
| 983 | + tabindex: "tabIndex", |
| 984 | + usemap: "useMap", |
| 985 | + frameborder: "frameBorder" |
| 986 | +}; |
| 987 | +var expando = "jQuery" + now(), uuid = 0, windowData = {}; |
| 988 | + |
| 989 | +jQuery.extend({ |
| 990 | + cache: {}, |
| 991 | + |
| 992 | + expando:expando, |
| 993 | + |
| 994 | + // The following elements throw uncatchable exceptions if you |
| 995 | + // attempt to add expando properties to them. |
| 996 | + noData: { |
| 997 | + "embed": true, |
| 998 | + "object": true, |
| 999 | + "applet": true |
| 1000 | + }, |
| 1001 | + |
| 1002 | + data: function( elem, name, data ) { |
| 1003 | + if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) { |
| 1004 | + return; |
| 1005 | + } |
| 1006 | + |
| 1007 | + elem = elem == window ? |
| 1008 | + windowData : |
| 1009 | + elem; |
| 1010 | + |
| 1011 | + var id = elem[ expando ], cache = jQuery.cache, thisCache; |
| 1012 | + |
| 1013 | + if ( !id && typeof name === "string" && data === undefined ) { |
| 1014 | + return null; |
| 1015 | + } |
| 1016 | + |
| 1017 | + // Compute a unique ID for the element |
| 1018 | + if ( !id ) { |
| 1019 | + id = ++uuid; |
| 1020 | + } |
| 1021 | + |
| 1022 | + // Avoid generating a new cache unless none exists and we |
| 1023 | + // want to manipulate it. |
| 1024 | + if ( typeof name === "object" ) { |
| 1025 | + elem[ expando ] = id; |
| 1026 | + thisCache = cache[ id ] = jQuery.extend(true, {}, name); |
| 1027 | + |
| 1028 | + } else if ( !cache[ id ] ) { |
| 1029 | + elem[ expando ] = id; |
| 1030 | + cache[ id ] = {}; |
| 1031 | + } |
| 1032 | + |
| 1033 | + thisCache = cache[ id ]; |
| 1034 | + |
| 1035 | + // Prevent overriding the named cache with undefined values |
| 1036 | + if ( data !== undefined ) { |
| 1037 | + thisCache[ name ] = data; |
| 1038 | + } |
| 1039 | + |
| 1040 | + return typeof name === "string" ? thisCache[ name ] : thisCache; |
| 1041 | + }, |
| 1042 | + |
| 1043 | + removeData: function( elem, name ) { |
| 1044 | + if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) { |
| 1045 | + return; |
| 1046 | + } |
| 1047 | + |
| 1048 | + elem = elem == window ? |
| 1049 | + windowData : |
| 1050 | + elem; |
| 1051 | + |
| 1052 | + var id = elem[ expando ], cache = jQuery.cache, thisCache = cache[ id ]; |
| 1053 | + |
| 1054 | + // If we want to remove a specific section of the element's data |
| 1055 | + if ( name ) { |
| 1056 | + if ( thisCache ) { |
| 1057 | + // Remove the section of cache data |
| 1058 | + delete thisCache[ name ]; |
| 1059 | + |
| 1060 | + // If we've removed all the data, remove the element's cache |
| 1061 | + if ( jQuery.isEmptyObject(thisCache) ) { |
| 1062 | + jQuery.removeData( elem ); |
| 1063 | + } |
| 1064 | + } |
| 1065 | + |
| 1066 | + // Otherwise, we want to remove all of the element's data |
| 1067 | + } else { |
| 1068 | + if ( jQuery.support.deleteExpando ) { |
| 1069 | + delete elem[ jQuery.expando ]; |
| 1070 | + |
| 1071 | + } else if ( elem.removeAttribute ) { |
| 1072 | + elem.removeAttribute( jQuery.expando ); |
| 1073 | + } |
| 1074 | + |
| 1075 | + // Completely remove the data cache |
| 1076 | + delete cache[ id ]; |
| 1077 | + } |
| 1078 | + } |
| 1079 | +}); |
| 1080 | + |
| 1081 | +jQuery.fn.extend({ |
| 1082 | + data: function( key, value ) { |
| 1083 | + if ( typeof key === "undefined" && this.length ) { |
| 1084 | + return jQuery.data( this[0] ); |
| 1085 | + |
| 1086 | + } else if ( typeof key === "object" ) { |
| 1087 | + return this.each(function() { |
| 1088 | + jQuery.data( this, key ); |
| 1089 | + }); |
| 1090 | + } |
| 1091 | + |
| 1092 | + var parts = key.split("."); |
| 1093 | + parts[1] = parts[1] ? "." + parts[1] : ""; |
| 1094 | + |
| 1095 | + if ( value === undefined ) { |
| 1096 | + var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]); |
| 1097 | + |
| 1098 | + if ( data === undefined && this.length ) { |
| 1099 | + data = jQuery.data( this[0], key ); |
| 1100 | + } |
| 1101 | + return data === undefined && parts[1] ? |
| 1102 | + this.data( parts[0] ) : |
| 1103 | + data; |
| 1104 | + } else { |
| 1105 | + return this.trigger("setData" + parts[1] + "!", [parts[0], value]).each(function() { |
| 1106 | + jQuery.data( this, key, value ); |
| 1107 | + }); |
| 1108 | + } |
| 1109 | + }, |
| 1110 | + |
| 1111 | + removeData: function( key ) { |
| 1112 | + return this.each(function() { |
| 1113 | + jQuery.removeData( this, key ); |
| 1114 | + }); |
| 1115 | + } |
| 1116 | +}); |
| 1117 | +jQuery.extend({ |
| 1118 | + queue: function( elem, type, data ) { |
| 1119 | + if ( !elem ) { |
| 1120 | + return; |
| 1121 | + } |
| 1122 | + |
| 1123 | + type = (type || "fx") + "queue"; |
| 1124 | + var q = jQuery.data( elem, type ); |
| 1125 | + |
| 1126 | + // Speed up dequeue by getting out quickly if this is just a lookup |
| 1127 | + if ( !data ) { |
| 1128 | + return q || []; |
| 1129 | + } |
| 1130 | + |
| 1131 | + if ( !q || jQuery.isArray(data) ) { |
| 1132 | + q = jQuery.data( elem, type, jQuery.makeArray(data) ); |
| 1133 | + |
| 1134 | + } else { |
| 1135 | + q.push( data ); |
| 1136 | + } |
| 1137 | + |
| 1138 | + return q; |
| 1139 | + }, |
| 1140 | + |
| 1141 | + dequeue: function( elem, type ) { |
| 1142 | + type = type || "fx"; |
| 1143 | + |
| 1144 | + var queue = jQuery.queue( elem, type ), fn = queue.shift(); |
| 1145 | + |
| 1146 | + // If the fx queue is dequeued, always remove the progress sentinel |
| 1147 | + if ( fn === "inprogress" ) { |
| 1148 | + fn = queue.shift(); |
| 1149 | + } |
| 1150 | + |
| 1151 | + if ( fn ) { |
| 1152 | + // Add a progress sentinel to prevent the fx queue from being |
| 1153 | + // automatically dequeued |
| 1154 | + if ( type === "fx" ) { |
| 1155 | + queue.unshift("inprogress"); |
| 1156 | + } |
| 1157 | + |
| 1158 | + fn.call(elem, function() { |
| 1159 | + jQuery.dequeue(elem, type); |
| 1160 | + }); |
| 1161 | + } |
| 1162 | + } |
| 1163 | +}); |
| 1164 | + |
| 1165 | +jQuery.fn.extend({ |
| 1166 | + queue: function( type, data ) { |
| 1167 | + if ( typeof type !== "string" ) { |
| 1168 | + data = type; |
| 1169 | + type = "fx"; |
| 1170 | + } |
| 1171 | + |
| 1172 | + if ( data === undefined ) { |
| 1173 | + return jQuery.queue( this[0], type ); |
| 1174 | + } |
| 1175 | + return this.each(function( i, elem ) { |
| 1176 | + var queue = jQuery.queue( this, type, data ); |
| 1177 | + |
| 1178 | + if ( type === "fx" && queue[0] !== "inprogress" ) { |
| 1179 | + jQuery.dequeue( this, type ); |
| 1180 | + } |
| 1181 | + }); |
| 1182 | + }, |
| 1183 | + dequeue: function( type ) { |
| 1184 | + return this.each(function() { |
| 1185 | + jQuery.dequeue( this, type ); |
| 1186 | + }); |
| 1187 | + }, |
| 1188 | + |
| 1189 | + // Based off of the plugin by Clint Helfers, with permission. |
| 1190 | + // http://blindsignals.com/index.php/2009/07/jquery-delay/ |
| 1191 | + delay: function( time, type ) { |
| 1192 | + time = jQuery.fx ? jQuery.fx.speeds[time] || time : time; |
| 1193 | + type = type || "fx"; |
| 1194 | + |
| 1195 | + return this.queue( type, function() { |
| 1196 | + var elem = this; |
| 1197 | + setTimeout(function() { |
| 1198 | + jQuery.dequeue( elem, type ); |
| 1199 | + }, time ); |
| 1200 | + }); |
| 1201 | + }, |
| 1202 | + |
| 1203 | + clearQueue: function( type ) { |
| 1204 | + return this.queue( type || "fx", [] ); |
| 1205 | + } |
| 1206 | +}); |
| 1207 | +var rclass = /[\n\t]/g, |
| 1208 | + rspace = /\s+/, |
| 1209 | + rreturn = /\r/g, |
| 1210 | + rspecialurl = /href|src|style/, |
| 1211 | + rtype = /(button|input)/i, |
| 1212 | + rfocusable = /(button|input|object|select|textarea)/i, |
| 1213 | + rclickable = /^(a|area)$/i, |
| 1214 | + rradiocheck = /radio|checkbox/; |
| 1215 | + |
| 1216 | +jQuery.fn.extend({ |
| 1217 | + attr: function( name, value ) { |
| 1218 | + return access( this, name, value, true, jQuery.attr ); |
| 1219 | + }, |
| 1220 | + |
| 1221 | + removeAttr: function( name, fn ) { |
| 1222 | + return this.each(function(){ |
| 1223 | + jQuery.attr( this, name, "" ); |
| 1224 | + if ( this.nodeType === 1 ) { |
| 1225 | + this.removeAttribute( name ); |
| 1226 | + } |
| 1227 | + }); |
| 1228 | + }, |
| 1229 | + |
| 1230 | + addClass: function( value ) { |
| 1231 | + if ( jQuery.isFunction(value) ) { |
| 1232 | + return this.each(function(i) { |
| 1233 | + var self = jQuery(this); |
| 1234 | + self.addClass( value.call(this, i, self.attr("class")) ); |
| 1235 | + }); |
| 1236 | + } |
| 1237 | + |
| 1238 | + if ( value && typeof value === "string" ) { |
| 1239 | + var classNames = (value || "").split( rspace ); |
| 1240 | + |
| 1241 | + for ( var i = 0, l = this.length; i < l; i++ ) { |
| 1242 | + var elem = this[i]; |
| 1243 | + |
| 1244 | + if ( elem.nodeType === 1 ) { |
| 1245 | + if ( !elem.className ) { |
| 1246 | + elem.className = value; |
| 1247 | + |
| 1248 | + } else { |
| 1249 | + var className = " " + elem.className + " ", setClass = elem.className; |
| 1250 | + for ( var c = 0, cl = classNames.length; c < cl; c++ ) { |
| 1251 | + if ( className.indexOf( " " + classNames[c] + " " ) < 0 ) { |
| 1252 | + setClass += " " + classNames[c]; |
| 1253 | + } |
| 1254 | + } |
| 1255 | + elem.className = jQuery.trim( setClass ); |
| 1256 | + } |
| 1257 | + } |
| 1258 | + } |
| 1259 | + } |
| 1260 | + |
| 1261 | + return this; |
| 1262 | + }, |
| 1263 | + |
| 1264 | + removeClass: function( value ) { |
| 1265 | + if ( jQuery.isFunction(value) ) { |
| 1266 | + return this.each(function(i) { |
| 1267 | + var self = jQuery(this); |
| 1268 | + self.removeClass( value.call(this, i, self.attr("class")) ); |
| 1269 | + }); |
| 1270 | + } |
| 1271 | + |
| 1272 | + if ( (value && typeof value === "string") || value === undefined ) { |
| 1273 | + var classNames = (value || "").split(rspace); |
| 1274 | + |
| 1275 | + for ( var i = 0, l = this.length; i < l; i++ ) { |
| 1276 | + var elem = this[i]; |
| 1277 | + |
| 1278 | + if ( elem.nodeType === 1 && elem.className ) { |
| 1279 | + if ( value ) { |
| 1280 | + var className = (" " + elem.className + " ").replace(rclass, " "); |
| 1281 | + for ( var c = 0, cl = classNames.length; c < cl; c++ ) { |
| 1282 | + className = className.replace(" " + classNames[c] + " ", " "); |
| 1283 | + } |
| 1284 | + elem.className = jQuery.trim( className ); |
| 1285 | + |
| 1286 | + } else { |
| 1287 | + elem.className = ""; |
| 1288 | + } |
| 1289 | + } |
| 1290 | + } |
| 1291 | + } |
| 1292 | + |
| 1293 | + return this; |
| 1294 | + }, |
| 1295 | + |
| 1296 | + toggleClass: function( value, stateVal ) { |
| 1297 | + var type = typeof value, isBool = typeof stateVal === "boolean"; |
| 1298 | + |
| 1299 | + if ( jQuery.isFunction( value ) ) { |
| 1300 | + return this.each(function(i) { |
| 1301 | + var self = jQuery(this); |
| 1302 | + self.toggleClass( value.call(this, i, self.attr("class"), stateVal), stateVal ); |
| 1303 | + }); |
| 1304 | + } |
| 1305 | + |
| 1306 | + return this.each(function() { |
| 1307 | + if ( type === "string" ) { |
| 1308 | + // toggle individual class names |
| 1309 | + var className, i = 0, self = jQuery(this), |
| 1310 | + state = stateVal, |
| 1311 | + classNames = value.split( rspace ); |
| 1312 | + |
| 1313 | + while ( (className = classNames[ i++ ]) ) { |
| 1314 | + // check each className given, space seperated list |
| 1315 | + state = isBool ? state : !self.hasClass( className ); |
| 1316 | + self[ state ? "addClass" : "removeClass" ]( className ); |
| 1317 | + } |
| 1318 | + |
| 1319 | + } else if ( type === "undefined" || type === "boolean" ) { |
| 1320 | + if ( this.className ) { |
| 1321 | + // store className if set |
| 1322 | + jQuery.data( this, "__className__", this.className ); |
| 1323 | + } |
| 1324 | + |
| 1325 | + // toggle whole className |
| 1326 | + this.className = this.className || value === false ? "" : jQuery.data( this, "__className__" ) || ""; |
| 1327 | + } |
| 1328 | + }); |
| 1329 | + }, |
| 1330 | + |
| 1331 | + hasClass: function( selector ) { |
| 1332 | + var className = " " + selector + " "; |
| 1333 | + for ( var i = 0, l = this.length; i < l; i++ ) { |
| 1334 | + if ( (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) { |
| 1335 | + return true; |
| 1336 | + } |
| 1337 | + } |
| 1338 | + |
| 1339 | + return false; |
| 1340 | + }, |
| 1341 | + |
| 1342 | + val: function( value ) { |
| 1343 | + if ( value === undefined ) { |
| 1344 | + var elem = this[0]; |
| 1345 | + |
| 1346 | + if ( elem ) { |
| 1347 | + if ( jQuery.nodeName( elem, "option" ) ) { |
| 1348 | + return (elem.attributes.value || {}).specified ? elem.value : elem.text; |
| 1349 | + } |
| 1350 | + |
| 1351 | + // We need to handle select boxes special |
| 1352 | + if ( jQuery.nodeName( elem, "select" ) ) { |
| 1353 | + var index = elem.selectedIndex, |
| 1354 | + values = [], |
| 1355 | + options = elem.options, |
| 1356 | + one = elem.type === "select-one"; |
| 1357 | + |
| 1358 | + // Nothing was selected |
| 1359 | + if ( index < 0 ) { |
| 1360 | + return null; |
| 1361 | + } |
| 1362 | + |
| 1363 | + // Loop through all the selected options |
| 1364 | + for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) { |
| 1365 | + var option = options[ i ]; |
| 1366 | + |
| 1367 | + if ( option.selected ) { |
| 1368 | + // Get the specifc value for the option |
| 1369 | + value = jQuery(option).val(); |
| 1370 | + |
| 1371 | + // We don't need an array for one selects |
| 1372 | + if ( one ) { |
| 1373 | + return value; |
| 1374 | + } |
| 1375 | + |
| 1376 | + // Multi-Selects return an array |
| 1377 | + values.push( value ); |
| 1378 | + } |
| 1379 | + } |
| 1380 | + |
| 1381 | + return values; |
| 1382 | + } |
| 1383 | + |
| 1384 | + // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified |
| 1385 | + if ( rradiocheck.test( elem.type ) && !jQuery.support.checkOn ) { |
| 1386 | + return elem.getAttribute("value") === null ? "on" : elem.value; |
| 1387 | + } |
| 1388 | + |
| 1389 | + |
| 1390 | + // Everything else, we just grab the value |
| 1391 | + return (elem.value || "").replace(rreturn, ""); |
| 1392 | + |
| 1393 | + } |
| 1394 | + |
| 1395 | + return undefined; |
| 1396 | + } |
| 1397 | + |
| 1398 | + var isFunction = jQuery.isFunction(value); |
| 1399 | + |
| 1400 | + return this.each(function(i) { |
| 1401 | + var self = jQuery(this), val = value; |
| 1402 | + |
| 1403 | + if ( this.nodeType !== 1 ) { |
| 1404 | + return; |
| 1405 | + } |
| 1406 | + |
| 1407 | + if ( isFunction ) { |
| 1408 | + val = value.call(this, i, self.val()); |
| 1409 | + } |
| 1410 | + |
| 1411 | + // Typecast each time if the value is a Function and the appended |
| 1412 | + // value is therefore different each time. |
| 1413 | + if ( typeof val === "number" ) { |
| 1414 | + val += ""; |
| 1415 | + } |
| 1416 | + |
| 1417 | + if ( jQuery.isArray(val) && rradiocheck.test( this.type ) ) { |
| 1418 | + this.checked = jQuery.inArray( self.val(), val ) >= 0; |
| 1419 | + |
| 1420 | + } else if ( jQuery.nodeName( this, "select" ) ) { |
| 1421 | + var values = jQuery.makeArray(val); |
| 1422 | + |
| 1423 | + jQuery( "option", this ).each(function() { |
| 1424 | + this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0; |
| 1425 | + }); |
| 1426 | + |
| 1427 | + if ( !values.length ) { |
| 1428 | + this.selectedIndex = -1; |
| 1429 | + } |
| 1430 | + |
| 1431 | + } else { |
| 1432 | + this.value = val; |
| 1433 | + } |
| 1434 | + }); |
| 1435 | + } |
| 1436 | +}); |
| 1437 | + |
| 1438 | +jQuery.extend({ |
| 1439 | + attrFn: { |
| 1440 | + val: true, |
| 1441 | + css: true, |
| 1442 | + html: true, |
| 1443 | + text: true, |
| 1444 | + data: true, |
| 1445 | + width: true, |
| 1446 | + height: true, |
| 1447 | + offset: true |
| 1448 | + }, |
| 1449 | + |
| 1450 | + attr: function( elem, name, value, pass ) { |
| 1451 | + // don't set attributes on text and comment nodes |
| 1452 | + if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) { |
| 1453 | + return undefined; |
| 1454 | + } |
| 1455 | + |
| 1456 | + if ( pass && name in jQuery.attrFn ) { |
| 1457 | + return jQuery(elem)[name](value); |
| 1458 | + } |
| 1459 | + |
| 1460 | + var notxml = elem.nodeType !== 1 || !jQuery.isXMLDoc( elem ), |
| 1461 | + // Whether we are setting (or getting) |
| 1462 | + set = value !== undefined; |
| 1463 | + |
| 1464 | + // Try to normalize/fix the name |
| 1465 | + name = notxml && jQuery.props[ name ] || name; |
| 1466 | + |
| 1467 | + // Only do all the following if this is a node (faster for style) |
| 1468 | + if ( elem.nodeType === 1 ) { |
| 1469 | + // These attributes require special treatment |
| 1470 | + var special = rspecialurl.test( name ); |
| 1471 | + |
| 1472 | + // Safari mis-reports the default selected property of an option |
| 1473 | + // Accessing the parent's selectedIndex property fixes it |
| 1474 | + if ( name === "selected" && !jQuery.support.optSelected ) { |
| 1475 | + var parent = elem.parentNode; |
| 1476 | + if ( parent ) { |
| 1477 | + parent.selectedIndex; |
| 1478 | + |
| 1479 | + // Make sure that it also works with optgroups, see #5701 |
| 1480 | + if ( parent.parentNode ) { |
| 1481 | + parent.parentNode.selectedIndex; |
| 1482 | + } |
| 1483 | + } |
| 1484 | + } |
| 1485 | + |
| 1486 | + // If applicable, access the attribute via the DOM 0 way |
| 1487 | + if ( name in elem && notxml && !special ) { |
| 1488 | + if ( set ) { |
| 1489 | + // We can't allow the type property to be changed (since it causes problems in IE) |
| 1490 | + if ( name === "type" && rtype.test( elem.nodeName ) && elem.parentNode ) { |
| 1491 | + jQuery.error( "type property can't be changed" ); |
| 1492 | + } |
| 1493 | + |
| 1494 | + elem[ name ] = value; |
| 1495 | + } |
| 1496 | + |
| 1497 | + // browsers index elements by id/name on forms, give priority to attributes. |
| 1498 | + if ( jQuery.nodeName( elem, "form" ) && elem.getAttributeNode(name) ) { |
| 1499 | + return elem.getAttributeNode( name ).nodeValue; |
| 1500 | + } |
| 1501 | + |
| 1502 | + // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set |
| 1503 | + // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ |
| 1504 | + if ( name === "tabIndex" ) { |
| 1505 | + var attributeNode = elem.getAttributeNode( "tabIndex" ); |
| 1506 | + |
| 1507 | + return attributeNode && attributeNode.specified ? |
| 1508 | + attributeNode.value : |
| 1509 | + rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ? |
| 1510 | + 0 : |
| 1511 | + undefined; |
| 1512 | + } |
| 1513 | + |
| 1514 | + return elem[ name ]; |
| 1515 | + } |
| 1516 | + |
| 1517 | + if ( !jQuery.support.style && notxml && name === "style" ) { |
| 1518 | + if ( set ) { |
| 1519 | + elem.style.cssText = "" + value; |
| 1520 | + } |
| 1521 | + |
| 1522 | + return elem.style.cssText; |
| 1523 | + } |
| 1524 | + |
| 1525 | + if ( set ) { |
| 1526 | + // convert the value to a string (all browsers do this but IE) see #1070 |
| 1527 | + elem.setAttribute( name, "" + value ); |
| 1528 | + } |
| 1529 | + |
| 1530 | + var attr = !jQuery.support.hrefNormalized && notxml && special ? |
| 1531 | + // Some attributes require a special call on IE |
| 1532 | + elem.getAttribute( name, 2 ) : |
| 1533 | + elem.getAttribute( name ); |
| 1534 | + |
| 1535 | + // Non-existent attributes return null, we normalize to undefined |
| 1536 | + return attr === null ? undefined : attr; |
| 1537 | + } |
| 1538 | + |
| 1539 | + // elem is actually elem.style ... set the style |
| 1540 | + // Using attr for specific style information is now deprecated. Use style instead. |
| 1541 | + return jQuery.style( elem, name, value ); |
| 1542 | + } |
| 1543 | +}); |
| 1544 | +var rnamespaces = /\.(.*)$/, |
| 1545 | + fcleanup = function( nm ) { |
| 1546 | + return nm.replace(/[^\w\s\.\|`]/g, function( ch ) { |
| 1547 | + return "\\" + ch; |
| 1548 | + }); |
| 1549 | + }; |
| 1550 | + |
| 1551 | +/* |
| 1552 | + * A number of helper functions used for managing events. |
| 1553 | + * Many of the ideas behind this code originated from |
| 1554 | + * Dean Edwards' addEvent library. |
| 1555 | + */ |
| 1556 | +jQuery.event = { |
| 1557 | + |
| 1558 | + // Bind an event to an element |
| 1559 | + // Original by Dean Edwards |
| 1560 | + add: function( elem, types, handler, data ) { |
| 1561 | + if ( elem.nodeType === 3 || elem.nodeType === 8 ) { |
| 1562 | + return; |
| 1563 | + } |
| 1564 | + |
| 1565 | + // For whatever reason, IE has trouble passing the window object |
| 1566 | + // around, causing it to be cloned in the process |
| 1567 | + if ( elem.setInterval && ( elem !== window && !elem.frameElement ) ) { |
| 1568 | + elem = window; |
| 1569 | + } |
| 1570 | + |
| 1571 | + var handleObjIn, handleObj; |
| 1572 | + |
| 1573 | + if ( handler.handler ) { |
| 1574 | + handleObjIn = handler; |
| 1575 | + handler = handleObjIn.handler; |
| 1576 | + } |
| 1577 | + |
| 1578 | + // Make sure that the function being executed has a unique ID |
| 1579 | + if ( !handler.guid ) { |
| 1580 | + handler.guid = jQuery.guid++; |
| 1581 | + } |
| 1582 | + |
| 1583 | + // Init the element's event structure |
| 1584 | + var elemData = jQuery.data( elem ); |
| 1585 | + |
| 1586 | + // If no elemData is found then we must be trying to bind to one of the |
| 1587 | + // banned noData elements |
| 1588 | + if ( !elemData ) { |
| 1589 | + return; |
| 1590 | + } |
| 1591 | + |
| 1592 | + var events = elemData.events = elemData.events || {}, |
| 1593 | + eventHandle = elemData.handle, eventHandle; |
| 1594 | + |
| 1595 | + if ( !eventHandle ) { |
| 1596 | + elemData.handle = eventHandle = function() { |
| 1597 | + // Handle the second event of a trigger and when |
| 1598 | + // an event is called after a page has unloaded |
| 1599 | + return typeof jQuery !== "undefined" && !jQuery.event.triggered ? |
| 1600 | + jQuery.event.handle.apply( eventHandle.elem, arguments ) : |
| 1601 | + undefined; |
| 1602 | + }; |
| 1603 | + } |
| 1604 | + |
| 1605 | + // Add elem as a property of the handle function |
| 1606 | + // This is to prevent a memory leak with non-native events in IE. |
| 1607 | + eventHandle.elem = elem; |
| 1608 | + |
| 1609 | + // Handle multiple events separated by a space |
| 1610 | + // jQuery(...).bind("mouseover mouseout", fn); |
| 1611 | + types = types.split(" "); |
| 1612 | + |
| 1613 | + var type, i = 0, namespaces; |
| 1614 | + |
| 1615 | + while ( (type = types[ i++ ]) ) { |
| 1616 | + handleObj = handleObjIn ? |
| 1617 | + jQuery.extend({}, handleObjIn) : |
| 1618 | + { handler: handler, data: data }; |
| 1619 | + |
| 1620 | + // Namespaced event handlers |
| 1621 | + if ( type.indexOf(".") > -1 ) { |
| 1622 | + namespaces = type.split("."); |
| 1623 | + type = namespaces.shift(); |
| 1624 | + handleObj.namespace = namespaces.slice(0).sort().join("."); |
| 1625 | + |
| 1626 | + } else { |
| 1627 | + namespaces = []; |
| 1628 | + handleObj.namespace = ""; |
| 1629 | + } |
| 1630 | + |
| 1631 | + handleObj.type = type; |
| 1632 | + handleObj.guid = handler.guid; |
| 1633 | + |
| 1634 | + // Get the current list of functions bound to this event |
| 1635 | + var handlers = events[ type ], |
| 1636 | + special = jQuery.event.special[ type ] || {}; |
| 1637 | + |
| 1638 | + // Init the event handler queue |
| 1639 | + if ( !handlers ) { |
| 1640 | + handlers = events[ type ] = []; |
| 1641 | + |
| 1642 | + // Check for a special event handler |
| 1643 | + // Only use addEventListener/attachEvent if the special |
| 1644 | + // events handler returns false |
| 1645 | + if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) { |
| 1646 | + // Bind the global event handler to the element |
| 1647 | + if ( elem.addEventListener ) { |
| 1648 | + elem.addEventListener( type, eventHandle, false ); |
| 1649 | + |
| 1650 | + } else if ( elem.attachEvent ) { |
| 1651 | + elem.attachEvent( "on" + type, eventHandle ); |
| 1652 | + } |
| 1653 | + } |
| 1654 | + } |
| 1655 | + |
| 1656 | + if ( special.add ) { |
| 1657 | + special.add.call( elem, handleObj ); |
| 1658 | + |
| 1659 | + if ( !handleObj.handler.guid ) { |
| 1660 | + handleObj.handler.guid = handler.guid; |
| 1661 | + } |
| 1662 | + } |
| 1663 | + |
| 1664 | + // Add the function to the element's handler list |
| 1665 | + handlers.push( handleObj ); |
| 1666 | + |
| 1667 | + // Keep track of which events have been used, for global triggering |
| 1668 | + jQuery.event.global[ type ] = true; |
| 1669 | + } |
| 1670 | + |
| 1671 | + // Nullify elem to prevent memory leaks in IE |
| 1672 | + elem = null; |
| 1673 | + }, |
| 1674 | + |
| 1675 | + global: {}, |
| 1676 | + |
| 1677 | + // Detach an event or set of events from an element |
| 1678 | + remove: function( elem, types, handler, pos ) { |
| 1679 | + // don't do events on text and comment nodes |
| 1680 | + if ( elem.nodeType === 3 || elem.nodeType === 8 ) { |
| 1681 | + return; |
| 1682 | + } |
| 1683 | + |
| 1684 | + var ret, type, fn, i = 0, all, namespaces, namespace, special, eventType, handleObj, origType, |
| 1685 | + elemData = jQuery.data( elem ), |
| 1686 | + events = elemData && elemData.events; |
| 1687 | + |
| 1688 | + if ( !elemData || !events ) { |
| 1689 | + return; |
| 1690 | + } |
| 1691 | + |
| 1692 | + // types is actually an event object here |
| 1693 | + if ( types && types.type ) { |
| 1694 | + handler = types.handler; |
| 1695 | + types = types.type; |
| 1696 | + } |
| 1697 | + |
| 1698 | + // Unbind all events for the element |
| 1699 | + if ( !types || typeof types === "string" && types.charAt(0) === "." ) { |
| 1700 | + types = types || ""; |
| 1701 | + |
| 1702 | + for ( type in events ) { |
| 1703 | + jQuery.event.remove( elem, type + types ); |
| 1704 | + } |
| 1705 | + |
| 1706 | + return; |
| 1707 | + } |
| 1708 | + |
| 1709 | + // Handle multiple events separated by a space |
| 1710 | + // jQuery(...).unbind("mouseover mouseout", fn); |
| 1711 | + types = types.split(" "); |
| 1712 | + |
| 1713 | + while ( (type = types[ i++ ]) ) { |
| 1714 | + origType = type; |
| 1715 | + handleObj = null; |
| 1716 | + all = type.indexOf(".") < 0; |
| 1717 | + namespaces = []; |
| 1718 | + |
| 1719 | + if ( !all ) { |
| 1720 | + // Namespaced event handlers |
| 1721 | + namespaces = type.split("."); |
| 1722 | + type = namespaces.shift(); |
| 1723 | + |
| 1724 | + namespace = new RegExp("(^|\\.)" + |
| 1725 | + jQuery.map( namespaces.slice(0).sort(), fcleanup ).join("\\.(?:.*\\.)?") + "(\\.|$)") |
| 1726 | + } |
| 1727 | + |
| 1728 | + eventType = events[ type ]; |
| 1729 | + |
| 1730 | + if ( !eventType ) { |
| 1731 | + continue; |
| 1732 | + } |
| 1733 | + |
| 1734 | + if ( !handler ) { |
| 1735 | + for ( var j = 0; j < eventType.length; j++ ) { |
| 1736 | + handleObj = eventType[ j ]; |
| 1737 | + |
| 1738 | + if ( all || namespace.test( handleObj.namespace ) ) { |
| 1739 | + jQuery.event.remove( elem, origType, handleObj.handler, j ); |
| 1740 | + eventType.splice( j--, 1 ); |
| 1741 | + } |
| 1742 | + } |
| 1743 | + |
| 1744 | + continue; |
| 1745 | + } |
| 1746 | + |
| 1747 | + special = jQuery.event.special[ type ] || {}; |
| 1748 | + |
| 1749 | + for ( var j = pos || 0; j < eventType.length; j++ ) { |
| 1750 | + handleObj = eventType[ j ]; |
| 1751 | + |
| 1752 | + if ( handler.guid === handleObj.guid ) { |
| 1753 | + // remove the given handler for the given type |
| 1754 | + if ( all || namespace.test( handleObj.namespace ) ) { |
| 1755 | + if ( pos == null ) { |
| 1756 | + eventType.splice( j--, 1 ); |
| 1757 | + } |
| 1758 | + |
| 1759 | + if ( special.remove ) { |
| 1760 | + special.remove.call( elem, handleObj ); |
| 1761 | + } |
| 1762 | + } |
| 1763 | + |
| 1764 | + if ( pos != null ) { |
| 1765 | + break; |
| 1766 | + } |
| 1767 | + } |
| 1768 | + } |
| 1769 | + |
| 1770 | + // remove generic event handler if no more handlers exist |
| 1771 | + if ( eventType.length === 0 || pos != null && eventType.length === 1 ) { |
| 1772 | + if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) { |
| 1773 | + removeEvent( elem, type, elemData.handle ); |
| 1774 | + } |
| 1775 | + |
| 1776 | + ret = null; |
| 1777 | + delete events[ type ]; |
| 1778 | + } |
| 1779 | + } |
| 1780 | + |
| 1781 | + // Remove the expando if it's no longer used |
| 1782 | + if ( jQuery.isEmptyObject( events ) ) { |
| 1783 | + var handle = elemData.handle; |
| 1784 | + if ( handle ) { |
| 1785 | + handle.elem = null; |
| 1786 | + } |
| 1787 | + |
| 1788 | + delete elemData.events; |
| 1789 | + delete elemData.handle; |
| 1790 | + |
| 1791 | + if ( jQuery.isEmptyObject( elemData ) ) { |
| 1792 | + jQuery.removeData( elem ); |
| 1793 | + } |
| 1794 | + } |
| 1795 | + }, |
| 1796 | + |
| 1797 | + // bubbling is internal |
| 1798 | + trigger: function( event, data, elem /*, bubbling */ ) { |
| 1799 | + // Event object or event type |
| 1800 | + var type = event.type || event, |
| 1801 | + bubbling = arguments[3]; |
| 1802 | + |
| 1803 | + if ( !bubbling ) { |
| 1804 | + event = typeof event === "object" ? |
| 1805 | + // jQuery.Event object |
| 1806 | + event[expando] ? event : |
| 1807 | + // Object literal |
| 1808 | + jQuery.extend( jQuery.Event(type), event ) : |
| 1809 | + // Just the event type (string) |
| 1810 | + jQuery.Event(type); |
| 1811 | + |
| 1812 | + if ( type.indexOf("!") >= 0 ) { |
| 1813 | + event.type = type = type.slice(0, -1); |
| 1814 | + event.exclusive = true; |
| 1815 | + } |
| 1816 | + |
| 1817 | + // Handle a global trigger |
| 1818 | + if ( !elem ) { |
| 1819 | + // Don't bubble custom events when global (to avoid too much overhead) |
| 1820 | + event.stopPropagation(); |
| 1821 | + |
| 1822 | + // Only trigger if we've ever bound an event for it |
| 1823 | + if ( jQuery.event.global[ type ] ) { |
| 1824 | + jQuery.each( jQuery.cache, function() { |
| 1825 | + if ( this.events && this.events[type] ) { |
| 1826 | + jQuery.event.trigger( event, data, this.handle.elem ); |
| 1827 | + } |
| 1828 | + }); |
| 1829 | + } |
| 1830 | + } |
| 1831 | + |
| 1832 | + // Handle triggering a single element |
| 1833 | + |
| 1834 | + // don't do events on text and comment nodes |
| 1835 | + if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) { |
| 1836 | + return undefined; |
| 1837 | + } |
| 1838 | + |
| 1839 | + // Clean up in case it is reused |
| 1840 | + event.result = undefined; |
| 1841 | + event.target = elem; |
| 1842 | + |
| 1843 | + // Clone the incoming data, if any |
| 1844 | + data = jQuery.makeArray( data ); |
| 1845 | + data.unshift( event ); |
| 1846 | + } |
| 1847 | + |
| 1848 | + event.currentTarget = elem; |
| 1849 | + |
| 1850 | + // Trigger the event, it is assumed that "handle" is a function |
| 1851 | + var handle = jQuery.data( elem, "handle" ); |
| 1852 | + if ( handle ) { |
| 1853 | + handle.apply( elem, data ); |
| 1854 | + } |
| 1855 | + |
| 1856 | + var parent = elem.parentNode || elem.ownerDocument; |
| 1857 | + |
| 1858 | + // Trigger an inline bound script |
| 1859 | + try { |
| 1860 | + if ( !(elem && elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()]) ) { |
| 1861 | + if ( elem[ "on" + type ] && elem[ "on" + type ].apply( elem, data ) === false ) { |
| 1862 | + event.result = false; |
| 1863 | + } |
| 1864 | + } |
| 1865 | + |
| 1866 | + // prevent IE from throwing an error for some elements with some event types, see #3533 |
| 1867 | + } catch (e) {} |
| 1868 | + |
| 1869 | + if ( !event.isPropagationStopped() && parent ) { |
| 1870 | + jQuery.event.trigger( event, data, parent, true ); |
| 1871 | + |
| 1872 | + } else if ( !event.isDefaultPrevented() ) { |
| 1873 | + var target = event.target, old, |
| 1874 | + isClick = jQuery.nodeName(target, "a") && type === "click", |
| 1875 | + special = jQuery.event.special[ type ] || {}; |
| 1876 | + |
| 1877 | + if ( (!special._default || special._default.call( elem, event ) === false) && |
| 1878 | + !isClick && !(target && target.nodeName && jQuery.noData[target.nodeName.toLowerCase()]) ) { |
| 1879 | + |
| 1880 | + try { |
| 1881 | + if ( target[ type ] ) { |
| 1882 | + // Make sure that we don't accidentally re-trigger the onFOO events |
| 1883 | + old = target[ "on" + type ]; |
| 1884 | + |
| 1885 | + if ( old ) { |
| 1886 | + target[ "on" + type ] = null; |
| 1887 | + } |
| 1888 | + |
| 1889 | + jQuery.event.triggered = true; |
| 1890 | + target[ type ](); |
| 1891 | + } |
| 1892 | + |
| 1893 | + // prevent IE from throwing an error for some elements with some event types, see #3533 |
| 1894 | + } catch (e) {} |
| 1895 | + |
| 1896 | + if ( old ) { |
| 1897 | + target[ "on" + type ] = old; |
| 1898 | + } |
| 1899 | + |
| 1900 | + jQuery.event.triggered = false; |
| 1901 | + } |
| 1902 | + } |
| 1903 | + }, |
| 1904 | + |
| 1905 | + handle: function( event ) { |
| 1906 | + var all, handlers, namespaces, namespace, events; |
| 1907 | + |
| 1908 | + event = arguments[0] = jQuery.event.fix( event || window.event ); |
| 1909 | + event.currentTarget = this; |
| 1910 | + |
| 1911 | + // Namespaced event handlers |
| 1912 | + all = event.type.indexOf(".") < 0 && !event.exclusive; |
| 1913 | + |
| 1914 | + if ( !all ) { |
| 1915 | + namespaces = event.type.split("."); |
| 1916 | + event.type = namespaces.shift(); |
| 1917 | + namespace = new RegExp("(^|\\.)" + namespaces.slice(0).sort().join("\\.(?:.*\\.)?") + "(\\.|$)"); |
| 1918 | + } |
| 1919 | + |
| 1920 | + var events = jQuery.data(this, "events"), handlers = events[ event.type ]; |
| 1921 | + |
| 1922 | + if ( events && handlers ) { |
| 1923 | + // Clone the handlers to prevent manipulation |
| 1924 | + handlers = handlers.slice(0); |
| 1925 | + |
| 1926 | + for ( var j = 0, l = handlers.length; j < l; j++ ) { |
| 1927 | + var handleObj = handlers[ j ]; |
| 1928 | + |
| 1929 | + // Filter the functions by class |
| 1930 | + if ( all || namespace.test( handleObj.namespace ) ) { |
| 1931 | + // Pass in a reference to the handler function itself |
| 1932 | + // So that we can later remove it |
| 1933 | + event.handler = handleObj.handler; |
| 1934 | + event.data = handleObj.data; |
| 1935 | + event.handleObj = handleObj; |
| 1936 | + |
| 1937 | + var ret = handleObj.handler.apply( this, arguments ); |
| 1938 | + |
| 1939 | + if ( ret !== undefined ) { |
| 1940 | + event.result = ret; |
| 1941 | + if ( ret === false ) { |
| 1942 | + event.preventDefault(); |
| 1943 | + event.stopPropagation(); |
| 1944 | + } |
| 1945 | + } |
| 1946 | + |
| 1947 | + if ( event.isImmediatePropagationStopped() ) { |
| 1948 | + break; |
| 1949 | + } |
| 1950 | + } |
| 1951 | + } |
| 1952 | + } |
| 1953 | + |
| 1954 | + return event.result; |
| 1955 | + }, |
| 1956 | + |
| 1957 | + props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "), |
| 1958 | + |
| 1959 | + fix: function( event ) { |
| 1960 | + if ( event[ expando ] ) { |
| 1961 | + return event; |
| 1962 | + } |
| 1963 | + |
| 1964 | + // store a copy of the original event object |
| 1965 | + // and "clone" to set read-only properties |
| 1966 | + var originalEvent = event; |
| 1967 | + event = jQuery.Event( originalEvent ); |
| 1968 | + |
| 1969 | + for ( var i = this.props.length, prop; i; ) { |
| 1970 | + prop = this.props[ --i ]; |
| 1971 | + event[ prop ] = originalEvent[ prop ]; |
| 1972 | + } |
| 1973 | + |
| 1974 | + // Fix target property, if necessary |
| 1975 | + if ( !event.target ) { |
| 1976 | + event.target = event.srcElement || document; // Fixes #1925 where srcElement might not be defined either |
| 1977 | + } |
| 1978 | + |
| 1979 | + // check if target is a textnode (safari) |
| 1980 | + if ( event.target.nodeType === 3 ) { |
| 1981 | + event.target = event.target.parentNode; |
| 1982 | + } |
| 1983 | + |
| 1984 | + // Add relatedTarget, if necessary |
| 1985 | + if ( !event.relatedTarget && event.fromElement ) { |
| 1986 | + event.relatedTarget = event.fromElement === event.target ? event.toElement : event.fromElement; |
| 1987 | + } |
| 1988 | + |
| 1989 | + // Calculate pageX/Y if missing and clientX/Y available |
| 1990 | + if ( event.pageX == null && event.clientX != null ) { |
| 1991 | + var doc = document.documentElement, body = document.body; |
| 1992 | + event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0); |
| 1993 | + event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0); |
| 1994 | + } |
| 1995 | + |
| 1996 | + // Add which for key events |
| 1997 | + if ( !event.which && ((event.charCode || event.charCode === 0) ? event.charCode : event.keyCode) ) { |
| 1998 | + event.which = event.charCode || event.keyCode; |
| 1999 | + } |
| 2000 | + |
| 2001 | + // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs) |
| 2002 | + if ( !event.metaKey && event.ctrlKey ) { |
| 2003 | + event.metaKey = event.ctrlKey; |
| 2004 | + } |
| 2005 | + |
| 2006 | + // Add which for click: 1 === left; 2 === middle; 3 === right |
| 2007 | + // Note: button is not normalized, so don't use it |
| 2008 | + if ( !event.which && event.button !== undefined ) { |
| 2009 | + event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) )); |
| 2010 | + } |
| 2011 | + |
| 2012 | + return event; |
| 2013 | + }, |
| 2014 | + |
| 2015 | + // Deprecated, use jQuery.guid instead |
| 2016 | + guid: 1E8, |
| 2017 | + |
| 2018 | + // Deprecated, use jQuery.proxy instead |
| 2019 | + proxy: jQuery.proxy, |
| 2020 | + |
| 2021 | + special: { |
| 2022 | + ready: { |
| 2023 | + // Make sure the ready event is setup |
| 2024 | + setup: jQuery.bindReady, |
| 2025 | + teardown: jQuery.noop |
| 2026 | + }, |
| 2027 | + |
| 2028 | + live: { |
| 2029 | + add: function( handleObj ) { |
| 2030 | + jQuery.event.add( this, handleObj.origType, jQuery.extend({}, handleObj, {handler: liveHandler}) ); |
| 2031 | + }, |
| 2032 | + |
| 2033 | + remove: function( handleObj ) { |
| 2034 | + var remove = true, |
| 2035 | + type = handleObj.origType.replace(rnamespaces, ""); |
| 2036 | + |
| 2037 | + jQuery.each( jQuery.data(this, "events").live || [], function() { |
| 2038 | + if ( type === this.origType.replace(rnamespaces, "") ) { |
| 2039 | + remove = false; |
| 2040 | + return false; |
| 2041 | + } |
| 2042 | + }); |
| 2043 | + |
| 2044 | + if ( remove ) { |
| 2045 | + jQuery.event.remove( this, handleObj.origType, liveHandler ); |
| 2046 | + } |
| 2047 | + } |
| 2048 | + |
| 2049 | + }, |
| 2050 | + |
| 2051 | + beforeunload: { |
| 2052 | + setup: function( data, namespaces, eventHandle ) { |
| 2053 | + // We only want to do this special case on windows |
| 2054 | + if ( this.setInterval ) { |
| 2055 | + this.onbeforeunload = eventHandle; |
| 2056 | + } |
| 2057 | + |
| 2058 | + return false; |
| 2059 | + }, |
| 2060 | + teardown: function( namespaces, eventHandle ) { |
| 2061 | + if ( this.onbeforeunload === eventHandle ) { |
| 2062 | + this.onbeforeunload = null; |
| 2063 | + } |
| 2064 | + } |
| 2065 | + } |
| 2066 | + } |
| 2067 | +}; |
| 2068 | + |
| 2069 | +var removeEvent = document.removeEventListener ? |
| 2070 | + function( elem, type, handle ) { |
| 2071 | + elem.removeEventListener( type, handle, false ); |
| 2072 | + } : |
| 2073 | + function( elem, type, handle ) { |
| 2074 | + elem.detachEvent( "on" + type, handle ); |
| 2075 | + }; |
| 2076 | + |
| 2077 | +jQuery.Event = function( src ) { |
| 2078 | + // Allow instantiation without the 'new' keyword |
| 2079 | + if ( !this.preventDefault ) { |
| 2080 | + return new jQuery.Event( src ); |
| 2081 | + } |
| 2082 | + |
| 2083 | + // Event object |
| 2084 | + if ( src && src.type ) { |
| 2085 | + this.originalEvent = src; |
| 2086 | + this.type = src.type; |
| 2087 | + // Event type |
| 2088 | + } else { |
| 2089 | + this.type = src; |
| 2090 | + } |
| 2091 | + |
| 2092 | + // timeStamp is buggy for some events on Firefox(#3843) |
| 2093 | + // So we won't rely on the native value |
| 2094 | + this.timeStamp = now(); |
| 2095 | + |
| 2096 | + // Mark it as fixed |
| 2097 | + this[ expando ] = true; |
| 2098 | +}; |
| 2099 | + |
| 2100 | +function returnFalse() { |
| 2101 | + return false; |
| 2102 | +} |
| 2103 | +function returnTrue() { |
| 2104 | + return true; |
| 2105 | +} |
| 2106 | + |
| 2107 | +// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding |
| 2108 | +// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html |
| 2109 | +jQuery.Event.prototype = { |
| 2110 | + preventDefault: function() { |
| 2111 | + this.isDefaultPrevented = returnTrue; |
| 2112 | + |
| 2113 | + var e = this.originalEvent; |
| 2114 | + if ( !e ) { |
| 2115 | + return; |
| 2116 | + } |
| 2117 | + |
| 2118 | + // if preventDefault exists run it on the original event |
| 2119 | + if ( e.preventDefault ) { |
| 2120 | + e.preventDefault(); |
| 2121 | + } |
| 2122 | + // otherwise set the returnValue property of the original event to false (IE) |
| 2123 | + e.returnValue = false; |
| 2124 | + }, |
| 2125 | + stopPropagation: function() { |
| 2126 | + this.isPropagationStopped = returnTrue; |
| 2127 | + |
| 2128 | + var e = this.originalEvent; |
| 2129 | + if ( !e ) { |
| 2130 | + return; |
| 2131 | + } |
| 2132 | + // if stopPropagation exists run it on the original event |
| 2133 | + if ( e.stopPropagation ) { |
| 2134 | + e.stopPropagation(); |
| 2135 | + } |
| 2136 | + // otherwise set the cancelBubble property of the original event to true (IE) |
| 2137 | + e.cancelBubble = true; |
| 2138 | + }, |
| 2139 | + stopImmediatePropagation: function() { |
| 2140 | + this.isImmediatePropagationStopped = returnTrue; |
| 2141 | + this.stopPropagation(); |
| 2142 | + }, |
| 2143 | + isDefaultPrevented: returnFalse, |
| 2144 | + isPropagationStopped: returnFalse, |
| 2145 | + isImmediatePropagationStopped: returnFalse |
| 2146 | +}; |
| 2147 | + |
| 2148 | +// Checks if an event happened on an element within another element |
| 2149 | +// Used in jQuery.event.special.mouseenter and mouseleave handlers |
| 2150 | +var withinElement = function( event ) { |
| 2151 | + // Check if mouse(over|out) are still within the same parent element |
| 2152 | + var parent = event.relatedTarget; |
| 2153 | + |
| 2154 | + // Firefox sometimes assigns relatedTarget a XUL element |
| 2155 | + // which we cannot access the parentNode property of |
| 2156 | + try { |
| 2157 | + // Traverse up the tree |
| 2158 | + while ( parent && parent !== this ) { |
| 2159 | + parent = parent.parentNode; |
| 2160 | + } |
| 2161 | + |
| 2162 | + if ( parent !== this ) { |
| 2163 | + // set the correct event type |
| 2164 | + event.type = event.data; |
| 2165 | + |
| 2166 | + // handle event if we actually just moused on to a non sub-element |
| 2167 | + jQuery.event.handle.apply( this, arguments ); |
| 2168 | + } |
| 2169 | + |
| 2170 | + // assuming we've left the element since we most likely mousedover a xul element |
| 2171 | + } catch(e) { } |
| 2172 | +}, |
| 2173 | + |
| 2174 | +// In case of event delegation, we only need to rename the event.type, |
| 2175 | +// liveHandler will take care of the rest. |
| 2176 | +delegate = function( event ) { |
| 2177 | + event.type = event.data; |
| 2178 | + jQuery.event.handle.apply( this, arguments ); |
| 2179 | +}; |
| 2180 | + |
| 2181 | +// Create mouseenter and mouseleave events |
| 2182 | +jQuery.each({ |
| 2183 | + mouseenter: "mouseover", |
| 2184 | + mouseleave: "mouseout" |
| 2185 | +}, function( orig, fix ) { |
| 2186 | + jQuery.event.special[ orig ] = { |
| 2187 | + setup: function( data ) { |
| 2188 | + jQuery.event.add( this, fix, data && data.selector ? delegate : withinElement, orig ); |
| 2189 | + }, |
| 2190 | + teardown: function( data ) { |
| 2191 | + jQuery.event.remove( this, fix, data && data.selector ? delegate : withinElement ); |
| 2192 | + } |
| 2193 | + }; |
| 2194 | +}); |
| 2195 | + |
| 2196 | +// submit delegation |
| 2197 | +if ( !jQuery.support.submitBubbles ) { |
| 2198 | + |
| 2199 | + jQuery.event.special.submit = { |
| 2200 | + setup: function( data, namespaces ) { |
| 2201 | + if ( this.nodeName.toLowerCase() !== "form" ) { |
| 2202 | + jQuery.event.add(this, "click.specialSubmit", function( e ) { |
| 2203 | + var elem = e.target, type = elem.type; |
| 2204 | + |
| 2205 | + if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) { |
| 2206 | + return trigger( "submit", this, arguments ); |
| 2207 | + } |
| 2208 | + }); |
| 2209 | + |
| 2210 | + jQuery.event.add(this, "keypress.specialSubmit", function( e ) { |
| 2211 | + var elem = e.target, type = elem.type; |
| 2212 | + |
| 2213 | + if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) { |
| 2214 | + return trigger( "submit", this, arguments ); |
| 2215 | + } |
| 2216 | + }); |
| 2217 | + |
| 2218 | + } else { |
| 2219 | + return false; |
| 2220 | + } |
| 2221 | + }, |
| 2222 | + |
| 2223 | + teardown: function( namespaces ) { |
| 2224 | + jQuery.event.remove( this, ".specialSubmit" ); |
| 2225 | + } |
| 2226 | + }; |
| 2227 | + |
| 2228 | +} |
| 2229 | + |
| 2230 | +// change delegation, happens here so we have bind. |
| 2231 | +if ( !jQuery.support.changeBubbles ) { |
| 2232 | + |
| 2233 | + var formElems = /textarea|input|select/i, |
| 2234 | + |
| 2235 | + changeFilters, |
| 2236 | + |
| 2237 | + getVal = function( elem ) { |
| 2238 | + var type = elem.type, val = elem.value; |
| 2239 | + |
| 2240 | + if ( type === "radio" || type === "checkbox" ) { |
| 2241 | + val = elem.checked; |
| 2242 | + |
| 2243 | + } else if ( type === "select-multiple" ) { |
| 2244 | + val = elem.selectedIndex > -1 ? |
| 2245 | + jQuery.map( elem.options, function( elem ) { |
| 2246 | + return elem.selected; |
| 2247 | + }).join("-") : |
| 2248 | + ""; |
| 2249 | + |
| 2250 | + } else if ( elem.nodeName.toLowerCase() === "select" ) { |
| 2251 | + val = elem.selectedIndex; |
| 2252 | + } |
| 2253 | + |
| 2254 | + return val; |
| 2255 | + }, |
| 2256 | + |
| 2257 | + testChange = function testChange( e ) { |
| 2258 | + var elem = e.target, data, val; |
| 2259 | + |
| 2260 | + if ( !formElems.test( elem.nodeName ) || elem.readOnly ) { |
| 2261 | + return; |
| 2262 | + } |
| 2263 | + |
| 2264 | + data = jQuery.data( elem, "_change_data" ); |
| 2265 | + val = getVal(elem); |
| 2266 | + |
| 2267 | + // the current data will be also retrieved by beforeactivate |
| 2268 | + if ( e.type !== "focusout" || elem.type !== "radio" ) { |
| 2269 | + jQuery.data( elem, "_change_data", val ); |
| 2270 | + } |
| 2271 | + |
| 2272 | + if ( data === undefined || val === data ) { |
| 2273 | + return; |
| 2274 | + } |
| 2275 | + |
| 2276 | + if ( data != null || val ) { |
| 2277 | + e.type = "change"; |
| 2278 | + return jQuery.event.trigger( e, arguments[1], elem ); |
| 2279 | + } |
| 2280 | + }; |
| 2281 | + |
| 2282 | + jQuery.event.special.change = { |
| 2283 | + filters: { |
| 2284 | + focusout: testChange, |
| 2285 | + |
| 2286 | + click: function( e ) { |
| 2287 | + var elem = e.target, type = elem.type; |
| 2288 | + |
| 2289 | + if ( type === "radio" || type === "checkbox" || elem.nodeName.toLowerCase() === "select" ) { |
| 2290 | + return testChange.call( this, e ); |
| 2291 | + } |
| 2292 | + }, |
| 2293 | + |
| 2294 | + // Change has to be called before submit |
| 2295 | + // Keydown will be called before keypress, which is used in submit-event delegation |
| 2296 | + keydown: function( e ) { |
| 2297 | + var elem = e.target, type = elem.type; |
| 2298 | + |
| 2299 | + if ( (e.keyCode === 13 && elem.nodeName.toLowerCase() !== "textarea") || |
| 2300 | + (e.keyCode === 32 && (type === "checkbox" || type === "radio")) || |
| 2301 | + type === "select-multiple" ) { |
| 2302 | + return testChange.call( this, e ); |
| 2303 | + } |
| 2304 | + }, |
| 2305 | + |
| 2306 | + // Beforeactivate happens also before the previous element is blurred |
| 2307 | + // with this event you can't trigger a change event, but you can store |
| 2308 | + // information/focus[in] is not needed anymore |
| 2309 | + beforeactivate: function( e ) { |
| 2310 | + var elem = e.target; |
| 2311 | + jQuery.data( elem, "_change_data", getVal(elem) ); |
| 2312 | + } |
| 2313 | + }, |
| 2314 | + |
| 2315 | + setup: function( data, namespaces ) { |
| 2316 | + if ( this.type === "file" ) { |
| 2317 | + return false; |
| 2318 | + } |
| 2319 | + |
| 2320 | + for ( var type in changeFilters ) { |
| 2321 | + jQuery.event.add( this, type + ".specialChange", changeFilters[type] ); |
| 2322 | + } |
| 2323 | + |
| 2324 | + return formElems.test( this.nodeName ); |
| 2325 | + }, |
| 2326 | + |
| 2327 | + teardown: function( namespaces ) { |
| 2328 | + jQuery.event.remove( this, ".specialChange" ); |
| 2329 | + |
| 2330 | + return formElems.test( this.nodeName ); |
| 2331 | + } |
| 2332 | + }; |
| 2333 | + |
| 2334 | + changeFilters = jQuery.event.special.change.filters; |
| 2335 | +} |
| 2336 | + |
| 2337 | +function trigger( type, elem, args ) { |
| 2338 | + args[0].type = type; |
| 2339 | + return jQuery.event.handle.apply( elem, args ); |
| 2340 | +} |
| 2341 | + |
| 2342 | +// Create "bubbling" focus and blur events |
| 2343 | +if ( document.addEventListener ) { |
| 2344 | + jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) { |
| 2345 | + jQuery.event.special[ fix ] = { |
| 2346 | + setup: function() { |
| 2347 | + this.addEventListener( orig, handler, true ); |
| 2348 | + }, |
| 2349 | + teardown: function() { |
| 2350 | + this.removeEventListener( orig, handler, true ); |
| 2351 | + } |
| 2352 | + }; |
| 2353 | + |
| 2354 | + function handler( e ) { |
| 2355 | + e = jQuery.event.fix( e ); |
| 2356 | + e.type = fix; |
| 2357 | + return jQuery.event.handle.call( this, e ); |
| 2358 | + } |
| 2359 | + }); |
| 2360 | +} |
| 2361 | + |
| 2362 | +jQuery.each(["bind", "one"], function( i, name ) { |
| 2363 | + jQuery.fn[ name ] = function( type, data, fn ) { |
| 2364 | + // Handle object literals |
| 2365 | + if ( typeof type === "object" ) { |
| 2366 | + for ( var key in type ) { |
| 2367 | + this[ name ](key, data, type[key], fn); |
| 2368 | + } |
| 2369 | + return this; |
| 2370 | + } |
| 2371 | + |
| 2372 | + if ( jQuery.isFunction( data ) ) { |
| 2373 | + fn = data; |
| 2374 | + data = undefined; |
| 2375 | + } |
| 2376 | + |
| 2377 | + var handler = name === "one" ? jQuery.proxy( fn, function( event ) { |
| 2378 | + jQuery( this ).unbind( event, handler ); |
| 2379 | + return fn.apply( this, arguments ); |
| 2380 | + }) : fn; |
| 2381 | + |
| 2382 | + if ( type === "unload" && name !== "one" ) { |
| 2383 | + this.one( type, data, fn ); |
| 2384 | + |
| 2385 | + } else { |
| 2386 | + for ( var i = 0, l = this.length; i < l; i++ ) { |
| 2387 | + jQuery.event.add( this[i], type, handler, data ); |
| 2388 | + } |
| 2389 | + } |
| 2390 | + |
| 2391 | + return this; |
| 2392 | + }; |
| 2393 | +}); |
| 2394 | + |
| 2395 | +jQuery.fn.extend({ |
| 2396 | + unbind: function( type, fn ) { |
| 2397 | + // Handle object literals |
| 2398 | + if ( typeof type === "object" && !type.preventDefault ) { |
| 2399 | + for ( var key in type ) { |
| 2400 | + this.unbind(key, type[key]); |
| 2401 | + } |
| 2402 | + |
| 2403 | + } else { |
| 2404 | + for ( var i = 0, l = this.length; i < l; i++ ) { |
| 2405 | + jQuery.event.remove( this[i], type, fn ); |
| 2406 | + } |
| 2407 | + } |
| 2408 | + |
| 2409 | + return this; |
| 2410 | + }, |
| 2411 | + |
| 2412 | + delegate: function( selector, types, data, fn ) { |
| 2413 | + return this.live( types, data, fn, selector ); |
| 2414 | + }, |
| 2415 | + |
| 2416 | + undelegate: function( selector, types, fn ) { |
| 2417 | + if ( arguments.length === 0 ) { |
| 2418 | + return this.unbind( "live" ); |
| 2419 | + |
| 2420 | + } else { |
| 2421 | + return this.die( types, null, fn, selector ); |
| 2422 | + } |
| 2423 | + }, |
| 2424 | + |
| 2425 | + trigger: function( type, data ) { |
| 2426 | + return this.each(function() { |
| 2427 | + jQuery.event.trigger( type, data, this ); |
| 2428 | + }); |
| 2429 | + }, |
| 2430 | + |
| 2431 | + triggerHandler: function( type, data ) { |
| 2432 | + if ( this[0] ) { |
| 2433 | + var event = jQuery.Event( type ); |
| 2434 | + event.preventDefault(); |
| 2435 | + event.stopPropagation(); |
| 2436 | + jQuery.event.trigger( event, data, this[0] ); |
| 2437 | + return event.result; |
| 2438 | + } |
| 2439 | + }, |
| 2440 | + |
| 2441 | + toggle: function( fn ) { |
| 2442 | + // Save reference to arguments for access in closure |
| 2443 | + var args = arguments, i = 1; |
| 2444 | + |
| 2445 | + // link all the functions, so any of them can unbind this click handler |
| 2446 | + while ( i < args.length ) { |
| 2447 | + jQuery.proxy( fn, args[ i++ ] ); |
| 2448 | + } |
| 2449 | + |
| 2450 | + return this.click( jQuery.proxy( fn, function( event ) { |
| 2451 | + // Figure out which function to execute |
| 2452 | + var lastToggle = ( jQuery.data( this, "lastToggle" + fn.guid ) || 0 ) % i; |
| 2453 | + jQuery.data( this, "lastToggle" + fn.guid, lastToggle + 1 ); |
| 2454 | + |
| 2455 | + // Make sure that clicks stop |
| 2456 | + event.preventDefault(); |
| 2457 | + |
| 2458 | + // and execute the function |
| 2459 | + return args[ lastToggle ].apply( this, arguments ) || false; |
| 2460 | + })); |
| 2461 | + }, |
| 2462 | + |
| 2463 | + hover: function( fnOver, fnOut ) { |
| 2464 | + return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); |
| 2465 | + } |
| 2466 | +}); |
| 2467 | + |
| 2468 | +var liveMap = { |
| 2469 | + focus: "focusin", |
| 2470 | + blur: "focusout", |
| 2471 | + mouseenter: "mouseover", |
| 2472 | + mouseleave: "mouseout" |
| 2473 | +}; |
| 2474 | + |
| 2475 | +jQuery.each(["live", "die"], function( i, name ) { |
| 2476 | + jQuery.fn[ name ] = function( types, data, fn, origSelector /* Internal Use Only */ ) { |
| 2477 | + var type, i = 0, match, namespaces, preType, |
| 2478 | + selector = origSelector || this.selector, |
| 2479 | + context = origSelector ? this : jQuery( this.context ); |
| 2480 | + |
| 2481 | + if ( jQuery.isFunction( data ) ) { |
| 2482 | + fn = data; |
| 2483 | + data = undefined; |
| 2484 | + } |
| 2485 | + |
| 2486 | + types = (types || "").split(" "); |
| 2487 | + |
| 2488 | + while ( (type = types[ i++ ]) != null ) { |
| 2489 | + match = rnamespaces.exec( type ); |
| 2490 | + namespaces = ""; |
| 2491 | + |
| 2492 | + if ( match ) { |
| 2493 | + namespaces = match[0]; |
| 2494 | + type = type.replace( rnamespaces, "" ); |
| 2495 | + } |
| 2496 | + |
| 2497 | + if ( type === "hover" ) { |
| 2498 | + types.push( "mouseenter" + namespaces, "mouseleave" + namespaces ); |
| 2499 | + continue; |
| 2500 | + } |
| 2501 | + |
| 2502 | + preType = type; |
| 2503 | + |
| 2504 | + if ( type === "focus" || type === "blur" ) { |
| 2505 | + types.push( liveMap[ type ] + namespaces ); |
| 2506 | + type = type + namespaces; |
| 2507 | + |
| 2508 | + } else { |
| 2509 | + type = (liveMap[ type ] || type) + namespaces; |
| 2510 | + } |
| 2511 | + |
| 2512 | + if ( name === "live" ) { |
| 2513 | + // bind live handler |
| 2514 | + context.each(function(){ |
| 2515 | + jQuery.event.add( this, liveConvert( type, selector ), |
| 2516 | + { data: data, selector: selector, handler: fn, origType: type, origHandler: fn, preType: preType } ); |
| 2517 | + }); |
| 2518 | + |
| 2519 | + } else { |
| 2520 | + // unbind live handler |
| 2521 | + context.unbind( liveConvert( type, selector ), fn ); |
| 2522 | + } |
| 2523 | + } |
| 2524 | + |
| 2525 | + return this; |
| 2526 | + } |
| 2527 | +}); |
| 2528 | + |
| 2529 | +function liveHandler( event ) { |
| 2530 | + var stop, elems = [], selectors = [], args = arguments, |
| 2531 | + related, match, handleObj, elem, j, i, l, data, |
| 2532 | + events = jQuery.data( this, "events" ); |
| 2533 | + |
| 2534 | + // Make sure we avoid non-left-click bubbling in Firefox (#3861) |
| 2535 | + if ( event.liveFired === this || !events || !events.live || event.button && event.type === "click" ) { |
| 2536 | + return; |
| 2537 | + } |
| 2538 | + |
| 2539 | + event.liveFired = this; |
| 2540 | + |
| 2541 | + var live = events.live.slice(0); |
| 2542 | + |
| 2543 | + for ( j = 0; j < live.length; j++ ) { |
| 2544 | + handleObj = live[j]; |
| 2545 | + |
| 2546 | + if ( handleObj.origType.replace( rnamespaces, "" ) === event.type ) { |
| 2547 | + selectors.push( handleObj.selector ); |
| 2548 | + |
| 2549 | + } else { |
| 2550 | + live.splice( j--, 1 ); |
| 2551 | + } |
| 2552 | + } |
| 2553 | + |
| 2554 | + match = jQuery( event.target ).closest( selectors, event.currentTarget ); |
| 2555 | + |
| 2556 | + for ( i = 0, l = match.length; i < l; i++ ) { |
| 2557 | + for ( j = 0; j < live.length; j++ ) { |
| 2558 | + handleObj = live[j]; |
| 2559 | + |
| 2560 | + if ( match[i].selector === handleObj.selector ) { |
| 2561 | + elem = match[i].elem; |
| 2562 | + related = null; |
| 2563 | + |
| 2564 | + // Those two events require additional checking |
| 2565 | + if ( handleObj.preType === "mouseenter" || handleObj.preType === "mouseleave" ) { |
| 2566 | + related = jQuery( event.relatedTarget ).closest( handleObj.selector )[0]; |
| 2567 | + } |
| 2568 | + |
| 2569 | + if ( !related || related !== elem ) { |
| 2570 | + elems.push({ elem: elem, handleObj: handleObj }); |
| 2571 | + } |
| 2572 | + } |
| 2573 | + } |
| 2574 | + } |
| 2575 | + |
| 2576 | + for ( i = 0, l = elems.length; i < l; i++ ) { |
| 2577 | + match = elems[i]; |
| 2578 | + event.currentTarget = match.elem; |
| 2579 | + event.data = match.handleObj.data; |
| 2580 | + event.handleObj = match.handleObj; |
| 2581 | + |
| 2582 | + if ( match.handleObj.origHandler.apply( match.elem, args ) === false ) { |
| 2583 | + stop = false; |
| 2584 | + break; |
| 2585 | + } |
| 2586 | + } |
| 2587 | + |
| 2588 | + return stop; |
| 2589 | +} |
| 2590 | + |
| 2591 | +function liveConvert( type, selector ) { |
| 2592 | + return "live." + (type && type !== "*" ? type + "." : "") + selector.replace(/\./g, "`").replace(/ /g, "&"); |
| 2593 | +} |
| 2594 | + |
| 2595 | +jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " + |
| 2596 | + "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + |
| 2597 | + "change select submit keydown keypress keyup error").split(" "), function( i, name ) { |
| 2598 | + |
| 2599 | + // Handle event binding |
| 2600 | + jQuery.fn[ name ] = function( fn ) { |
| 2601 | + return fn ? this.bind( name, fn ) : this.trigger( name ); |
| 2602 | + }; |
| 2603 | + |
| 2604 | + if ( jQuery.attrFn ) { |
| 2605 | + jQuery.attrFn[ name ] = true; |
| 2606 | + } |
| 2607 | +}); |
| 2608 | + |
| 2609 | +// Prevent memory leaks in IE |
| 2610 | +// Window isn't included so as not to unbind existing unload events |
| 2611 | +// More info: |
| 2612 | +// - http://isaacschlueter.com/2006/10/msie-memory-leaks/ |
| 2613 | +if ( window.attachEvent && !window.addEventListener ) { |
| 2614 | + window.attachEvent("onunload", function() { |
| 2615 | + for ( var id in jQuery.cache ) { |
| 2616 | + if ( jQuery.cache[ id ].handle ) { |
| 2617 | + // Try/Catch is to handle iframes being unloaded, see #4280 |
| 2618 | + try { |
| 2619 | + jQuery.event.remove( jQuery.cache[ id ].handle.elem ); |
| 2620 | + } catch(e) {} |
| 2621 | + } |
| 2622 | + } |
| 2623 | + }); |
| 2624 | +} |
| 2625 | +/*! |
| 2626 | + * Sizzle CSS Selector Engine - v1.0 |
| 2627 | + * Copyright 2009, The Dojo Foundation |
| 2628 | + * Released under the MIT, BSD, and GPL Licenses. |
| 2629 | + * More information: http://sizzlejs.com/ |
| 2630 | + */ |
| 2631 | +(function(){ |
| 2632 | + |
| 2633 | +var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g, |
| 2634 | + done = 0, |
| 2635 | + toString = Object.prototype.toString, |
| 2636 | + hasDuplicate = false, |
| 2637 | + baseHasDuplicate = true; |
| 2638 | + |
| 2639 | +// Here we check if the JavaScript engine is using some sort of |
| 2640 | +// optimization where it does not always call our comparision |
| 2641 | +// function. If that is the case, discard the hasDuplicate value. |
| 2642 | +// Thus far that includes Google Chrome. |
| 2643 | +[0, 0].sort(function(){ |
| 2644 | + baseHasDuplicate = false; |
| 2645 | + return 0; |
| 2646 | +}); |
| 2647 | + |
| 2648 | +var Sizzle = function(selector, context, results, seed) { |
| 2649 | + results = results || []; |
| 2650 | + var origContext = context = context || document; |
| 2651 | + |
| 2652 | + if ( context.nodeType !== 1 && context.nodeType !== 9 ) { |
| 2653 | + return []; |
| 2654 | + } |
| 2655 | + |
| 2656 | + if ( !selector || typeof selector !== "string" ) { |
| 2657 | + return results; |
| 2658 | + } |
| 2659 | + |
| 2660 | + var parts = [], m, set, checkSet, extra, prune = true, contextXML = isXML(context), |
| 2661 | + soFar = selector; |
| 2662 | + |
| 2663 | + // Reset the position of the chunker regexp (start from head) |
| 2664 | + while ( (chunker.exec(""), m = chunker.exec(soFar)) !== null ) { |
| 2665 | + soFar = m[3]; |
| 2666 | + |
| 2667 | + parts.push( m[1] ); |
| 2668 | + |
| 2669 | + if ( m[2] ) { |
| 2670 | + extra = m[3]; |
| 2671 | + break; |
| 2672 | + } |
| 2673 | + } |
| 2674 | + |
| 2675 | + if ( parts.length > 1 && origPOS.exec( selector ) ) { |
| 2676 | + if ( parts.length === 2 && Expr.relative[ parts[0] ] ) { |
| 2677 | + set = posProcess( parts[0] + parts[1], context ); |
| 2678 | + } else { |
| 2679 | + set = Expr.relative[ parts[0] ] ? |
| 2680 | + [ context ] : |
| 2681 | + Sizzle( parts.shift(), context ); |
| 2682 | + |
| 2683 | + while ( parts.length ) { |
| 2684 | + selector = parts.shift(); |
| 2685 | + |
| 2686 | + if ( Expr.relative[ selector ] ) { |
| 2687 | + selector += parts.shift(); |
| 2688 | + } |
| 2689 | + |
| 2690 | + set = posProcess( selector, set ); |
| 2691 | + } |
| 2692 | + } |
| 2693 | + } else { |
| 2694 | + // Take a shortcut and set the context if the root selector is an ID |
| 2695 | + // (but not if it'll be faster if the inner selector is an ID) |
| 2696 | + if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML && |
| 2697 | + Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) { |
| 2698 | + var ret = Sizzle.find( parts.shift(), context, contextXML ); |
| 2699 | + context = ret.expr ? Sizzle.filter( ret.expr, ret.set )[0] : ret.set[0]; |
| 2700 | + } |
| 2701 | + |
| 2702 | + if ( context ) { |
| 2703 | + var ret = seed ? |
| 2704 | + { expr: parts.pop(), set: makeArray(seed) } : |
| 2705 | + Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML ); |
| 2706 | + set = ret.expr ? Sizzle.filter( ret.expr, ret.set ) : ret.set; |
| 2707 | + |
| 2708 | + if ( parts.length > 0 ) { |
| 2709 | + checkSet = makeArray(set); |
| 2710 | + } else { |
| 2711 | + prune = false; |
| 2712 | + } |
| 2713 | + |
| 2714 | + while ( parts.length ) { |
| 2715 | + var cur = parts.pop(), pop = cur; |
| 2716 | + |
| 2717 | + if ( !Expr.relative[ cur ] ) { |
| 2718 | + cur = ""; |
| 2719 | + } else { |
| 2720 | + pop = parts.pop(); |
| 2721 | + } |
| 2722 | + |
| 2723 | + if ( pop == null ) { |
| 2724 | + pop = context; |
| 2725 | + } |
| 2726 | + |
| 2727 | + Expr.relative[ cur ]( checkSet, pop, contextXML ); |
| 2728 | + } |
| 2729 | + } else { |
| 2730 | + checkSet = parts = []; |
| 2731 | + } |
| 2732 | + } |
| 2733 | + |
| 2734 | + if ( !checkSet ) { |
| 2735 | + checkSet = set; |
| 2736 | + } |
| 2737 | + |
| 2738 | + if ( !checkSet ) { |
| 2739 | + Sizzle.error( cur || selector ); |
| 2740 | + } |
| 2741 | + |
| 2742 | + if ( toString.call(checkSet) === "[object Array]" ) { |
| 2743 | + if ( !prune ) { |
| 2744 | + results.push.apply( results, checkSet ); |
| 2745 | + } else if ( context && context.nodeType === 1 ) { |
| 2746 | + for ( var i = 0; checkSet[i] != null; i++ ) { |
| 2747 | + if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && contains(context, checkSet[i])) ) { |
| 2748 | + results.push( set[i] ); |
| 2749 | + } |
| 2750 | + } |
| 2751 | + } else { |
| 2752 | + for ( var i = 0; checkSet[i] != null; i++ ) { |
| 2753 | + if ( checkSet[i] && checkSet[i].nodeType === 1 ) { |
| 2754 | + results.push( set[i] ); |
| 2755 | + } |
| 2756 | + } |
| 2757 | + } |
| 2758 | + } else { |
| 2759 | + makeArray( checkSet, results ); |
| 2760 | + } |
| 2761 | + |
| 2762 | + if ( extra ) { |
| 2763 | + Sizzle( extra, origContext, results, seed ); |
| 2764 | + Sizzle.uniqueSort( results ); |
| 2765 | + } |
| 2766 | + |
| 2767 | + return results; |
| 2768 | +}; |
| 2769 | + |
| 2770 | +Sizzle.uniqueSort = function(results){ |
| 2771 | + if ( sortOrder ) { |
| 2772 | + hasDuplicate = baseHasDuplicate; |
| 2773 | + results.sort(sortOrder); |
| 2774 | + |
| 2775 | + if ( hasDuplicate ) { |
| 2776 | + for ( var i = 1; i < results.length; i++ ) { |
| 2777 | + if ( results[i] === results[i-1] ) { |
| 2778 | + results.splice(i--, 1); |
| 2779 | + } |
| 2780 | + } |
| 2781 | + } |
| 2782 | + } |
| 2783 | + |
| 2784 | + return results; |
| 2785 | +}; |
| 2786 | + |
| 2787 | +Sizzle.matches = function(expr, set){ |
| 2788 | + return Sizzle(expr, null, null, set); |
| 2789 | +}; |
| 2790 | + |
| 2791 | +Sizzle.find = function(expr, context, isXML){ |
| 2792 | + var set, match; |
| 2793 | + |
| 2794 | + if ( !expr ) { |
| 2795 | + return []; |
| 2796 | + } |
| 2797 | + |
| 2798 | + for ( var i = 0, l = Expr.order.length; i < l; i++ ) { |
| 2799 | + var type = Expr.order[i], match; |
| 2800 | + |
| 2801 | + if ( (match = Expr.leftMatch[ type ].exec( expr )) ) { |
| 2802 | + var left = match[1]; |
| 2803 | + match.splice(1,1); |
| 2804 | + |
| 2805 | + if ( left.substr( left.length - 1 ) !== "\\" ) { |
| 2806 | + match[1] = (match[1] || "").replace(/\\/g, ""); |
| 2807 | + set = Expr.find[ type ]( match, context, isXML ); |
| 2808 | + if ( set != null ) { |
| 2809 | + expr = expr.replace( Expr.match[ type ], "" ); |
| 2810 | + break; |
| 2811 | + } |
| 2812 | + } |
| 2813 | + } |
| 2814 | + } |
| 2815 | + |
| 2816 | + if ( !set ) { |
| 2817 | + set = context.getElementsByTagName("*"); |
| 2818 | + } |
| 2819 | + |
| 2820 | + return {set: set, expr: expr}; |
| 2821 | +}; |
| 2822 | + |
| 2823 | +Sizzle.filter = function(expr, set, inplace, not){ |
| 2824 | + var old = expr, result = [], curLoop = set, match, anyFound, |
| 2825 | + isXMLFilter = set && set[0] && isXML(set[0]); |
| 2826 | + |
| 2827 | + while ( expr && set.length ) { |
| 2828 | + for ( var type in Expr.filter ) { |
| 2829 | + if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) { |
| 2830 | + var filter = Expr.filter[ type ], found, item, left = match[1]; |
| 2831 | + anyFound = false; |
| 2832 | + |
| 2833 | + match.splice(1,1); |
| 2834 | + |
| 2835 | + if ( left.substr( left.length - 1 ) === "\\" ) { |
| 2836 | + continue; |
| 2837 | + } |
| 2838 | + |
| 2839 | + if ( curLoop === result ) { |
| 2840 | + result = []; |
| 2841 | + } |
| 2842 | + |
| 2843 | + if ( Expr.preFilter[ type ] ) { |
| 2844 | + match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter ); |
| 2845 | + |
| 2846 | + if ( !match ) { |
| 2847 | + anyFound = found = true; |
| 2848 | + } else if ( match === true ) { |
| 2849 | + continue; |
| 2850 | + } |
| 2851 | + } |
| 2852 | + |
| 2853 | + if ( match ) { |
| 2854 | + for ( var i = 0; (item = curLoop[i]) != null; i++ ) { |
| 2855 | + if ( item ) { |
| 2856 | + found = filter( item, match, i, curLoop ); |
| 2857 | + var pass = not ^ !!found; |
| 2858 | + |
| 2859 | + if ( inplace && found != null ) { |
| 2860 | + if ( pass ) { |
| 2861 | + anyFound = true; |
| 2862 | + } else { |
| 2863 | + curLoop[i] = false; |
| 2864 | + } |
| 2865 | + } else if ( pass ) { |
| 2866 | + result.push( item ); |
| 2867 | + anyFound = true; |
| 2868 | + } |
| 2869 | + } |
| 2870 | + } |
| 2871 | + } |
| 2872 | + |
| 2873 | + if ( found !== undefined ) { |
| 2874 | + if ( !inplace ) { |
| 2875 | + curLoop = result; |
| 2876 | + } |
| 2877 | + |
| 2878 | + expr = expr.replace( Expr.match[ type ], "" ); |
| 2879 | + |
| 2880 | + if ( !anyFound ) { |
| 2881 | + return []; |
| 2882 | + } |
| 2883 | + |
| 2884 | + break; |
| 2885 | + } |
| 2886 | + } |
| 2887 | + } |
| 2888 | + |
| 2889 | + // Improper expression |
| 2890 | + if ( expr === old ) { |
| 2891 | + if ( anyFound == null ) { |
| 2892 | + Sizzle.error( expr ); |
| 2893 | + } else { |
| 2894 | + break; |
| 2895 | + } |
| 2896 | + } |
| 2897 | + |
| 2898 | + old = expr; |
| 2899 | + } |
| 2900 | + |
| 2901 | + return curLoop; |
| 2902 | +}; |
| 2903 | + |
| 2904 | +Sizzle.error = function( msg ) { |
| 2905 | + throw "Syntax error, unrecognized expression: " + msg; |
| 2906 | +}; |
| 2907 | + |
| 2908 | +var Expr = Sizzle.selectors = { |
| 2909 | + order: [ "ID", "NAME", "TAG" ], |
| 2910 | + match: { |
| 2911 | + ID: /#((?:[\w\u00c0-\uFFFF-]|\\.)+)/, |
| 2912 | + CLASS: /\.((?:[\w\u00c0-\uFFFF-]|\\.)+)/, |
| 2913 | + NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF-]|\\.)+)['"]*\]/, |
| 2914 | + ATTR: /\[\s*((?:[\w\u00c0-\uFFFF-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/, |
| 2915 | + TAG: /^((?:[\w\u00c0-\uFFFF\*-]|\\.)+)/, |
| 2916 | + CHILD: /:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/, |
| 2917 | + POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/, |
| 2918 | + PSEUDO: /:((?:[\w\u00c0-\uFFFF-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/ |
| 2919 | + }, |
| 2920 | + leftMatch: {}, |
| 2921 | + attrMap: { |
| 2922 | + "class": "className", |
| 2923 | + "for": "htmlFor" |
| 2924 | + }, |
| 2925 | + attrHandle: { |
| 2926 | + href: function(elem){ |
| 2927 | + return elem.getAttribute("href"); |
| 2928 | + } |
| 2929 | + }, |
| 2930 | + relative: { |
| 2931 | + "+": function(checkSet, part){ |
| 2932 | + var isPartStr = typeof part === "string", |
| 2933 | + isTag = isPartStr && !/\W/.test(part), |
| 2934 | + isPartStrNotTag = isPartStr && !isTag; |
| 2935 | + |
| 2936 | + if ( isTag ) { |
| 2937 | + part = part.toLowerCase(); |
| 2938 | + } |
| 2939 | + |
| 2940 | + for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) { |
| 2941 | + if ( (elem = checkSet[i]) ) { |
| 2942 | + while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {} |
| 2943 | + |
| 2944 | + checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ? |
| 2945 | + elem || false : |
| 2946 | + elem === part; |
| 2947 | + } |
| 2948 | + } |
| 2949 | + |
| 2950 | + if ( isPartStrNotTag ) { |
| 2951 | + Sizzle.filter( part, checkSet, true ); |
| 2952 | + } |
| 2953 | + }, |
| 2954 | + ">": function(checkSet, part){ |
| 2955 | + var isPartStr = typeof part === "string"; |
| 2956 | + |
| 2957 | + if ( isPartStr && !/\W/.test(part) ) { |
| 2958 | + part = part.toLowerCase(); |
| 2959 | + |
| 2960 | + for ( var i = 0, l = checkSet.length; i < l; i++ ) { |
| 2961 | + var elem = checkSet[i]; |
| 2962 | + if ( elem ) { |
| 2963 | + var parent = elem.parentNode; |
| 2964 | + checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false; |
| 2965 | + } |
| 2966 | + } |
| 2967 | + } else { |
| 2968 | + for ( var i = 0, l = checkSet.length; i < l; i++ ) { |
| 2969 | + var elem = checkSet[i]; |
| 2970 | + if ( elem ) { |
| 2971 | + checkSet[i] = isPartStr ? |
| 2972 | + elem.parentNode : |
| 2973 | + elem.parentNode === part; |
| 2974 | + } |
| 2975 | + } |
| 2976 | + |
| 2977 | + if ( isPartStr ) { |
| 2978 | + Sizzle.filter( part, checkSet, true ); |
| 2979 | + } |
| 2980 | + } |
| 2981 | + }, |
| 2982 | + "": function(checkSet, part, isXML){ |
| 2983 | + var doneName = done++, checkFn = dirCheck; |
| 2984 | + |
| 2985 | + if ( typeof part === "string" && !/\W/.test(part) ) { |
| 2986 | + var nodeCheck = part = part.toLowerCase(); |
| 2987 | + checkFn = dirNodeCheck; |
| 2988 | + } |
| 2989 | + |
| 2990 | + checkFn("parentNode", part, doneName, checkSet, nodeCheck, isXML); |
| 2991 | + }, |
| 2992 | + "~": function(checkSet, part, isXML){ |
| 2993 | + var doneName = done++, checkFn = dirCheck; |
| 2994 | + |
| 2995 | + if ( typeof part === "string" && !/\W/.test(part) ) { |
| 2996 | + var nodeCheck = part = part.toLowerCase(); |
| 2997 | + checkFn = dirNodeCheck; |
| 2998 | + } |
| 2999 | + |
| 3000 | + checkFn("previousSibling", part, doneName, checkSet, nodeCheck, isXML); |
| 3001 | + } |
| 3002 | + }, |
| 3003 | + find: { |
| 3004 | + ID: function(match, context, isXML){ |
| 3005 | + if ( typeof context.getElementById !== "undefined" && !isXML ) { |
| 3006 | + var m = context.getElementById(match[1]); |
| 3007 | + return m ? [m] : []; |
| 3008 | + } |
| 3009 | + }, |
| 3010 | + NAME: function(match, context){ |
| 3011 | + if ( typeof context.getElementsByName !== "undefined" ) { |
| 3012 | + var ret = [], results = context.getElementsByName(match[1]); |
| 3013 | + |
| 3014 | + for ( var i = 0, l = results.length; i < l; i++ ) { |
| 3015 | + if ( results[i].getAttribute("name") === match[1] ) { |
| 3016 | + ret.push( results[i] ); |
| 3017 | + } |
| 3018 | + } |
| 3019 | + |
| 3020 | + return ret.length === 0 ? null : ret; |
| 3021 | + } |
| 3022 | + }, |
| 3023 | + TAG: function(match, context){ |
| 3024 | + return context.getElementsByTagName(match[1]); |
| 3025 | + } |
| 3026 | + }, |
| 3027 | + preFilter: { |
| 3028 | + CLASS: function(match, curLoop, inplace, result, not, isXML){ |
| 3029 | + match = " " + match[1].replace(/\\/g, "") + " "; |
| 3030 | + |
| 3031 | + if ( isXML ) { |
| 3032 | + return match; |
| 3033 | + } |
| 3034 | + |
| 3035 | + for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) { |
| 3036 | + if ( elem ) { |
| 3037 | + if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n]/g, " ").indexOf(match) >= 0) ) { |
| 3038 | + if ( !inplace ) { |
| 3039 | + result.push( elem ); |
| 3040 | + } |
| 3041 | + } else if ( inplace ) { |
| 3042 | + curLoop[i] = false; |
| 3043 | + } |
| 3044 | + } |
| 3045 | + } |
| 3046 | + |
| 3047 | + return false; |
| 3048 | + }, |
| 3049 | + ID: function(match){ |
| 3050 | + return match[1].replace(/\\/g, ""); |
| 3051 | + }, |
| 3052 | + TAG: function(match, curLoop){ |
| 3053 | + return match[1].toLowerCase(); |
| 3054 | + }, |
| 3055 | + CHILD: function(match){ |
| 3056 | + if ( match[1] === "nth" ) { |
| 3057 | + // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6' |
| 3058 | + var test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec( |
| 3059 | + match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" || |
| 3060 | + !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]); |
| 3061 | + |
| 3062 | + // calculate the numbers (first)n+(last) including if they are negative |
| 3063 | + match[2] = (test[1] + (test[2] || 1)) - 0; |
| 3064 | + match[3] = test[3] - 0; |
| 3065 | + } |
| 3066 | + |
| 3067 | + // TODO: Move to normal caching system |
| 3068 | + match[0] = done++; |
| 3069 | + |
| 3070 | + return match; |
| 3071 | + }, |
| 3072 | + ATTR: function(match, curLoop, inplace, result, not, isXML){ |
| 3073 | + var name = match[1].replace(/\\/g, ""); |
| 3074 | + |
| 3075 | + if ( !isXML && Expr.attrMap[name] ) { |
| 3076 | + match[1] = Expr.attrMap[name]; |
| 3077 | + } |
| 3078 | + |
| 3079 | + if ( match[2] === "~=" ) { |
| 3080 | + match[4] = " " + match[4] + " "; |
| 3081 | + } |
| 3082 | + |
| 3083 | + return match; |
| 3084 | + }, |
| 3085 | + PSEUDO: function(match, curLoop, inplace, result, not){ |
| 3086 | + if ( match[1] === "not" ) { |
| 3087 | + // If we're dealing with a complex expression, or a simple one |
| 3088 | + if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) { |
| 3089 | + match[3] = Sizzle(match[3], null, null, curLoop); |
| 3090 | + } else { |
| 3091 | + var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not); |
| 3092 | + if ( !inplace ) { |
| 3093 | + result.push.apply( result, ret ); |
| 3094 | + } |
| 3095 | + return false; |
| 3096 | + } |
| 3097 | + } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) { |
| 3098 | + return true; |
| 3099 | + } |
| 3100 | + |
| 3101 | + return match; |
| 3102 | + }, |
| 3103 | + POS: function(match){ |
| 3104 | + match.unshift( true ); |
| 3105 | + return match; |
| 3106 | + } |
| 3107 | + }, |
| 3108 | + filters: { |
| 3109 | + enabled: function(elem){ |
| 3110 | + return elem.disabled === false && elem.type !== "hidden"; |
| 3111 | + }, |
| 3112 | + disabled: function(elem){ |
| 3113 | + return elem.disabled === true; |
| 3114 | + }, |
| 3115 | + checked: function(elem){ |
| 3116 | + return elem.checked === true; |
| 3117 | + }, |
| 3118 | + selected: function(elem){ |
| 3119 | + // Accessing this property makes selected-by-default |
| 3120 | + // options in Safari work properly |
| 3121 | + elem.parentNode.selectedIndex; |
| 3122 | + return elem.selected === true; |
| 3123 | + }, |
| 3124 | + parent: function(elem){ |
| 3125 | + return !!elem.firstChild; |
| 3126 | + }, |
| 3127 | + empty: function(elem){ |
| 3128 | + return !elem.firstChild; |
| 3129 | + }, |
| 3130 | + has: function(elem, i, match){ |
| 3131 | + return !!Sizzle( match[3], elem ).length; |
| 3132 | + }, |
| 3133 | + header: function(elem){ |
| 3134 | + return /h\d/i.test( elem.nodeName ); |
| 3135 | + }, |
| 3136 | + text: function(elem){ |
| 3137 | + return "text" === elem.type; |
| 3138 | + }, |
| 3139 | + radio: function(elem){ |
| 3140 | + return "radio" === elem.type; |
| 3141 | + }, |
| 3142 | + checkbox: function(elem){ |
| 3143 | + return "checkbox" === elem.type; |
| 3144 | + }, |
| 3145 | + file: function(elem){ |
| 3146 | + return "file" === elem.type; |
| 3147 | + }, |
| 3148 | + password: function(elem){ |
| 3149 | + return "password" === elem.type; |
| 3150 | + }, |
| 3151 | + submit: function(elem){ |
| 3152 | + return "submit" === elem.type; |
| 3153 | + }, |
| 3154 | + image: function(elem){ |
| 3155 | + return "image" === elem.type; |
| 3156 | + }, |
| 3157 | + reset: function(elem){ |
| 3158 | + return "reset" === elem.type; |
| 3159 | + }, |
| 3160 | + button: function(elem){ |
| 3161 | + return "button" === elem.type || elem.nodeName.toLowerCase() === "button"; |
| 3162 | + }, |
| 3163 | + input: function(elem){ |
| 3164 | + return /input|select|textarea|button/i.test(elem.nodeName); |
| 3165 | + } |
| 3166 | + }, |
| 3167 | + setFilters: { |
| 3168 | + first: function(elem, i){ |
| 3169 | + return i === 0; |
| 3170 | + }, |
| 3171 | + last: function(elem, i, match, array){ |
| 3172 | + return i === array.length - 1; |
| 3173 | + }, |
| 3174 | + even: function(elem, i){ |
| 3175 | + return i % 2 === 0; |
| 3176 | + }, |
| 3177 | + odd: function(elem, i){ |
| 3178 | + return i % 2 === 1; |
| 3179 | + }, |
| 3180 | + lt: function(elem, i, match){ |
| 3181 | + return i < match[3] - 0; |
| 3182 | + }, |
| 3183 | + gt: function(elem, i, match){ |
| 3184 | + return i > match[3] - 0; |
| 3185 | + }, |
| 3186 | + nth: function(elem, i, match){ |
| 3187 | + return match[3] - 0 === i; |
| 3188 | + }, |
| 3189 | + eq: function(elem, i, match){ |
| 3190 | + return match[3] - 0 === i; |
| 3191 | + } |
| 3192 | + }, |
| 3193 | + filter: { |
| 3194 | + PSEUDO: function(elem, match, i, array){ |
| 3195 | + var name = match[1], filter = Expr.filters[ name ]; |
| 3196 | + |
| 3197 | + if ( filter ) { |
| 3198 | + return filter( elem, i, match, array ); |
| 3199 | + } else if ( name === "contains" ) { |
| 3200 | + return (elem.textContent || elem.innerText || getText([ elem ]) || "").indexOf(match[3]) >= 0; |
| 3201 | + } else if ( name === "not" ) { |
| 3202 | + var not = match[3]; |
| 3203 | + |
| 3204 | + for ( var i = 0, l = not.length; i < l; i++ ) { |
| 3205 | + if ( not[i] === elem ) { |
| 3206 | + return false; |
| 3207 | + } |
| 3208 | + } |
| 3209 | + |
| 3210 | + return true; |
| 3211 | + } else { |
| 3212 | + Sizzle.error( "Syntax error, unrecognized expression: " + name ); |
| 3213 | + } |
| 3214 | + }, |
| 3215 | + CHILD: function(elem, match){ |
| 3216 | + var type = match[1], node = elem; |
| 3217 | + switch (type) { |
| 3218 | + case 'only': |
| 3219 | + case 'first': |
| 3220 | + while ( (node = node.previousSibling) ) { |
| 3221 | + if ( node.nodeType === 1 ) { |
| 3222 | + return false; |
| 3223 | + } |
| 3224 | + } |
| 3225 | + if ( type === "first" ) { |
| 3226 | + return true; |
| 3227 | + } |
| 3228 | + node = elem; |
| 3229 | + case 'last': |
| 3230 | + while ( (node = node.nextSibling) ) { |
| 3231 | + if ( node.nodeType === 1 ) { |
| 3232 | + return false; |
| 3233 | + } |
| 3234 | + } |
| 3235 | + return true; |
| 3236 | + case 'nth': |
| 3237 | + var first = match[2], last = match[3]; |
| 3238 | + |
| 3239 | + if ( first === 1 && last === 0 ) { |
| 3240 | + return true; |
| 3241 | + } |
| 3242 | + |
| 3243 | + var doneName = match[0], |
| 3244 | + parent = elem.parentNode; |
| 3245 | + |
| 3246 | + if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) { |
| 3247 | + var count = 0; |
| 3248 | + for ( node = parent.firstChild; node; node = node.nextSibling ) { |
| 3249 | + if ( node.nodeType === 1 ) { |
| 3250 | + node.nodeIndex = ++count; |
| 3251 | + } |
| 3252 | + } |
| 3253 | + parent.sizcache = doneName; |
| 3254 | + } |
| 3255 | + |
| 3256 | + var diff = elem.nodeIndex - last; |
| 3257 | + if ( first === 0 ) { |
| 3258 | + return diff === 0; |
| 3259 | + } else { |
| 3260 | + return ( diff % first === 0 && diff / first >= 0 ); |
| 3261 | + } |
| 3262 | + } |
| 3263 | + }, |
| 3264 | + ID: function(elem, match){ |
| 3265 | + return elem.nodeType === 1 && elem.getAttribute("id") === match; |
| 3266 | + }, |
| 3267 | + TAG: function(elem, match){ |
| 3268 | + return (match === "*" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match; |
| 3269 | + }, |
| 3270 | + CLASS: function(elem, match){ |
| 3271 | + return (" " + (elem.className || elem.getAttribute("class")) + " ") |
| 3272 | + .indexOf( match ) > -1; |
| 3273 | + }, |
| 3274 | + ATTR: function(elem, match){ |
| 3275 | + var name = match[1], |
| 3276 | + result = Expr.attrHandle[ name ] ? |
| 3277 | + Expr.attrHandle[ name ]( elem ) : |
| 3278 | + elem[ name ] != null ? |
| 3279 | + elem[ name ] : |
| 3280 | + elem.getAttribute( name ), |
| 3281 | + value = result + "", |
| 3282 | + type = match[2], |
| 3283 | + check = match[4]; |
| 3284 | + |
| 3285 | + return result == null ? |
| 3286 | + type === "!=" : |
| 3287 | + type === "=" ? |
| 3288 | + value === check : |
| 3289 | + type === "*=" ? |
| 3290 | + value.indexOf(check) >= 0 : |
| 3291 | + type === "~=" ? |
| 3292 | + (" " + value + " ").indexOf(check) >= 0 : |
| 3293 | + !check ? |
| 3294 | + value && result !== false : |
| 3295 | + type === "!=" ? |
| 3296 | + value !== check : |
| 3297 | + type === "^=" ? |
| 3298 | + value.indexOf(check) === 0 : |
| 3299 | + type === "$=" ? |
| 3300 | + value.substr(value.length - check.length) === check : |
| 3301 | + type === "|=" ? |
| 3302 | + value === check || value.substr(0, check.length + 1) === check + "-" : |
| 3303 | + false; |
| 3304 | + }, |
| 3305 | + POS: function(elem, match, i, array){ |
| 3306 | + var name = match[2], filter = Expr.setFilters[ name ]; |
| 3307 | + |
| 3308 | + if ( filter ) { |
| 3309 | + return filter( elem, i, match, array ); |
| 3310 | + } |
| 3311 | + } |
| 3312 | + } |
| 3313 | +}; |
| 3314 | + |
| 3315 | +var origPOS = Expr.match.POS; |
| 3316 | + |
| 3317 | +for ( var type in Expr.match ) { |
| 3318 | + Expr.match[ type ] = new RegExp( Expr.match[ type ].source + /(?![^\[]*\])(?![^\(]*\))/.source ); |
| 3319 | + Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, function(all, num){ |
| 3320 | + return "\\" + (num - 0 + 1); |
| 3321 | + })); |
| 3322 | +} |
| 3323 | + |
| 3324 | +var makeArray = function(array, results) { |
| 3325 | + array = Array.prototype.slice.call( array, 0 ); |
| 3326 | + |
| 3327 | + if ( results ) { |
| 3328 | + results.push.apply( results, array ); |
| 3329 | + return results; |
| 3330 | + } |
| 3331 | + |
| 3332 | + return array; |
| 3333 | +}; |
| 3334 | + |
| 3335 | +// Perform a simple check to determine if the browser is capable of |
| 3336 | +// converting a NodeList to an array using builtin methods. |
| 3337 | +// Also verifies that the returned array holds DOM nodes |
| 3338 | +// (which is not the case in the Blackberry browser) |
| 3339 | +try { |
| 3340 | + Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType; |
| 3341 | + |
| 3342 | +// Provide a fallback method if it does not work |
| 3343 | +} catch(e){ |
| 3344 | + makeArray = function(array, results) { |
| 3345 | + var ret = results || []; |
| 3346 | + |
| 3347 | + if ( toString.call(array) === "[object Array]" ) { |
| 3348 | + Array.prototype.push.apply( ret, array ); |
| 3349 | + } else { |
| 3350 | + if ( typeof array.length === "number" ) { |
| 3351 | + for ( var i = 0, l = array.length; i < l; i++ ) { |
| 3352 | + ret.push( array[i] ); |
| 3353 | + } |
| 3354 | + } else { |
| 3355 | + for ( var i = 0; array[i]; i++ ) { |
| 3356 | + ret.push( array[i] ); |
| 3357 | + } |
| 3358 | + } |
| 3359 | + } |
| 3360 | + |
| 3361 | + return ret; |
| 3362 | + }; |
| 3363 | +} |
| 3364 | + |
| 3365 | +var sortOrder; |
| 3366 | + |
| 3367 | +if ( document.documentElement.compareDocumentPosition ) { |
| 3368 | + sortOrder = function( a, b ) { |
| 3369 | + if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) { |
| 3370 | + if ( a == b ) { |
| 3371 | + hasDuplicate = true; |
| 3372 | + } |
| 3373 | + return a.compareDocumentPosition ? -1 : 1; |
| 3374 | + } |
| 3375 | + |
| 3376 | + var ret = a.compareDocumentPosition(b) & 4 ? -1 : a === b ? 0 : 1; |
| 3377 | + if ( ret === 0 ) { |
| 3378 | + hasDuplicate = true; |
| 3379 | + } |
| 3380 | + return ret; |
| 3381 | + }; |
| 3382 | +} else if ( "sourceIndex" in document.documentElement ) { |
| 3383 | + sortOrder = function( a, b ) { |
| 3384 | + if ( !a.sourceIndex || !b.sourceIndex ) { |
| 3385 | + if ( a == b ) { |
| 3386 | + hasDuplicate = true; |
| 3387 | + } |
| 3388 | + return a.sourceIndex ? -1 : 1; |
| 3389 | + } |
| 3390 | + |
| 3391 | + var ret = a.sourceIndex - b.sourceIndex; |
| 3392 | + if ( ret === 0 ) { |
| 3393 | + hasDuplicate = true; |
| 3394 | + } |
| 3395 | + return ret; |
| 3396 | + }; |
| 3397 | +} else if ( document.createRange ) { |
| 3398 | + sortOrder = function( a, b ) { |
| 3399 | + if ( !a.ownerDocument || !b.ownerDocument ) { |
| 3400 | + if ( a == b ) { |
| 3401 | + hasDuplicate = true; |
| 3402 | + } |
| 3403 | + return a.ownerDocument ? -1 : 1; |
| 3404 | + } |
| 3405 | + |
| 3406 | + var aRange = a.ownerDocument.createRange(), bRange = b.ownerDocument.createRange(); |
| 3407 | + aRange.setStart(a, 0); |
| 3408 | + aRange.setEnd(a, 0); |
| 3409 | + bRange.setStart(b, 0); |
| 3410 | + bRange.setEnd(b, 0); |
| 3411 | + var ret = aRange.compareBoundaryPoints(Range.START_TO_END, bRange); |
| 3412 | + if ( ret === 0 ) { |
| 3413 | + hasDuplicate = true; |
| 3414 | + } |
| 3415 | + return ret; |
| 3416 | + }; |
| 3417 | +} |
| 3418 | + |
| 3419 | +// Utility function for retreiving the text value of an array of DOM nodes |
| 3420 | +function getText( elems ) { |
| 3421 | + var ret = "", elem; |
| 3422 | + |
| 3423 | + for ( var i = 0; elems[i]; i++ ) { |
| 3424 | + elem = elems[i]; |
| 3425 | + |
| 3426 | + // Get the text from text nodes and CDATA nodes |
| 3427 | + if ( elem.nodeType === 3 || elem.nodeType === 4 ) { |
| 3428 | + ret += elem.nodeValue; |
| 3429 | + |
| 3430 | + // Traverse everything else, except comment nodes |
| 3431 | + } else if ( elem.nodeType !== 8 ) { |
| 3432 | + ret += getText( elem.childNodes ); |
| 3433 | + } |
| 3434 | + } |
| 3435 | + |
| 3436 | + return ret; |
| 3437 | +} |
| 3438 | + |
| 3439 | +// Check to see if the browser returns elements by name when |
| 3440 | +// querying by getElementById (and provide a workaround) |
| 3441 | +(function(){ |
| 3442 | + // We're going to inject a fake input element with a specified name |
| 3443 | + var form = document.createElement("div"), |
| 3444 | + id = "script" + (new Date).getTime(); |
| 3445 | + form.innerHTML = "<a name='" + id + "'/>"; |
| 3446 | + |
| 3447 | + // Inject it into the root element, check its status, and remove it quickly |
| 3448 | + var root = document.documentElement; |
| 3449 | + root.insertBefore( form, root.firstChild ); |
| 3450 | + |
| 3451 | + // The workaround has to do additional checks after a getElementById |
| 3452 | + // Which slows things down for other browsers (hence the branching) |
| 3453 | + if ( document.getElementById( id ) ) { |
| 3454 | + Expr.find.ID = function(match, context, isXML){ |
| 3455 | + if ( typeof context.getElementById !== "undefined" && !isXML ) { |
| 3456 | + var m = context.getElementById(match[1]); |
| 3457 | + return m ? m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ? [m] : undefined : []; |
| 3458 | + } |
| 3459 | + }; |
| 3460 | + |
| 3461 | + Expr.filter.ID = function(elem, match){ |
| 3462 | + var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id"); |
| 3463 | + return elem.nodeType === 1 && node && node.nodeValue === match; |
| 3464 | + }; |
| 3465 | + } |
| 3466 | + |
| 3467 | + root.removeChild( form ); |
| 3468 | + root = form = null; // release memory in IE |
| 3469 | +})(); |
| 3470 | + |
| 3471 | +(function(){ |
| 3472 | + // Check to see if the browser returns only elements |
| 3473 | + // when doing getElementsByTagName("*") |
| 3474 | + |
| 3475 | + // Create a fake element |
| 3476 | + var div = document.createElement("div"); |
| 3477 | + div.appendChild( document.createComment("") ); |
| 3478 | + |
| 3479 | + // Make sure no comments are found |
| 3480 | + if ( div.getElementsByTagName("*").length > 0 ) { |
| 3481 | + Expr.find.TAG = function(match, context){ |
| 3482 | + var results = context.getElementsByTagName(match[1]); |
| 3483 | + |
| 3484 | + // Filter out possible comments |
| 3485 | + if ( match[1] === "*" ) { |
| 3486 | + var tmp = []; |
| 3487 | + |
| 3488 | + for ( var i = 0; results[i]; i++ ) { |
| 3489 | + if ( results[i].nodeType === 1 ) { |
| 3490 | + tmp.push( results[i] ); |
| 3491 | + } |
| 3492 | + } |
| 3493 | + |
| 3494 | + results = tmp; |
| 3495 | + } |
| 3496 | + |
| 3497 | + return results; |
| 3498 | + }; |
| 3499 | + } |
| 3500 | + |
| 3501 | + // Check to see if an attribute returns normalized href attributes |
| 3502 | + div.innerHTML = "<a href='#'></a>"; |
| 3503 | + if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" && |
| 3504 | + div.firstChild.getAttribute("href") !== "#" ) { |
| 3505 | + Expr.attrHandle.href = function(elem){ |
| 3506 | + return elem.getAttribute("href", 2); |
| 3507 | + }; |
| 3508 | + } |
| 3509 | + |
| 3510 | + div = null; // release memory in IE |
| 3511 | +})(); |
| 3512 | + |
| 3513 | +if ( document.querySelectorAll ) { |
| 3514 | + (function(){ |
| 3515 | + var oldSizzle = Sizzle, div = document.createElement("div"); |
| 3516 | + div.innerHTML = "<p class='TEST'></p>"; |
| 3517 | + |
| 3518 | + // Safari can't handle uppercase or unicode characters when |
| 3519 | + // in quirks mode. |
| 3520 | + if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) { |
| 3521 | + return; |
| 3522 | + } |
| 3523 | + |
| 3524 | + Sizzle = function(query, context, extra, seed){ |
| 3525 | + context = context || document; |
| 3526 | + |
| 3527 | + // Only use querySelectorAll on non-XML documents |
| 3528 | + // (ID selectors don't work in non-HTML documents) |
| 3529 | + if ( !seed && context.nodeType === 9 && !isXML(context) ) { |
| 3530 | + try { |
| 3531 | + return makeArray( context.querySelectorAll(query), extra ); |
| 3532 | + } catch(e){} |
| 3533 | + } |
| 3534 | + |
| 3535 | + return oldSizzle(query, context, extra, seed); |
| 3536 | + }; |
| 3537 | + |
| 3538 | + for ( var prop in oldSizzle ) { |
| 3539 | + Sizzle[ prop ] = oldSizzle[ prop ]; |
| 3540 | + } |
| 3541 | + |
| 3542 | + div = null; // release memory in IE |
| 3543 | + })(); |
| 3544 | +} |
| 3545 | + |
| 3546 | +(function(){ |
| 3547 | + var div = document.createElement("div"); |
| 3548 | + |
| 3549 | + div.innerHTML = "<div class='test e'></div><div class='test'></div>"; |
| 3550 | + |
| 3551 | + // Opera can't find a second classname (in 9.6) |
| 3552 | + // Also, make sure that getElementsByClassName actually exists |
| 3553 | + if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) { |
| 3554 | + return; |
| 3555 | + } |
| 3556 | + |
| 3557 | + // Safari caches class attributes, doesn't catch changes (in 3.2) |
| 3558 | + div.lastChild.className = "e"; |
| 3559 | + |
| 3560 | + if ( div.getElementsByClassName("e").length === 1 ) { |
| 3561 | + return; |
| 3562 | + } |
| 3563 | + |
| 3564 | + Expr.order.splice(1, 0, "CLASS"); |
| 3565 | + Expr.find.CLASS = function(match, context, isXML) { |
| 3566 | + if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) { |
| 3567 | + return context.getElementsByClassName(match[1]); |
| 3568 | + } |
| 3569 | + }; |
| 3570 | + |
| 3571 | + div = null; // release memory in IE |
| 3572 | +})(); |
| 3573 | + |
| 3574 | +function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { |
| 3575 | + for ( var i = 0, l = checkSet.length; i < l; i++ ) { |
| 3576 | + var elem = checkSet[i]; |
| 3577 | + if ( elem ) { |
| 3578 | + elem = elem[dir]; |
| 3579 | + var match = false; |
| 3580 | + |
| 3581 | + while ( elem ) { |
| 3582 | + if ( elem.sizcache === doneName ) { |
| 3583 | + match = checkSet[elem.sizset]; |
| 3584 | + break; |
| 3585 | + } |
| 3586 | + |
| 3587 | + if ( elem.nodeType === 1 && !isXML ){ |
| 3588 | + elem.sizcache = doneName; |
| 3589 | + elem.sizset = i; |
| 3590 | + } |
| 3591 | + |
| 3592 | + if ( elem.nodeName.toLowerCase() === cur ) { |
| 3593 | + match = elem; |
| 3594 | + break; |
| 3595 | + } |
| 3596 | + |
| 3597 | + elem = elem[dir]; |
| 3598 | + } |
| 3599 | + |
| 3600 | + checkSet[i] = match; |
| 3601 | + } |
| 3602 | + } |
| 3603 | +} |
| 3604 | + |
| 3605 | +function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { |
| 3606 | + for ( var i = 0, l = checkSet.length; i < l; i++ ) { |
| 3607 | + var elem = checkSet[i]; |
| 3608 | + if ( elem ) { |
| 3609 | + elem = elem[dir]; |
| 3610 | + var match = false; |
| 3611 | + |
| 3612 | + while ( elem ) { |
| 3613 | + if ( elem.sizcache === doneName ) { |
| 3614 | + match = checkSet[elem.sizset]; |
| 3615 | + break; |
| 3616 | + } |
| 3617 | + |
| 3618 | + if ( elem.nodeType === 1 ) { |
| 3619 | + if ( !isXML ) { |
| 3620 | + elem.sizcache = doneName; |
| 3621 | + elem.sizset = i; |
| 3622 | + } |
| 3623 | + if ( typeof cur !== "string" ) { |
| 3624 | + if ( elem === cur ) { |
| 3625 | + match = true; |
| 3626 | + break; |
| 3627 | + } |
| 3628 | + |
| 3629 | + } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) { |
| 3630 | + match = elem; |
| 3631 | + break; |
| 3632 | + } |
| 3633 | + } |
| 3634 | + |
| 3635 | + elem = elem[dir]; |
| 3636 | + } |
| 3637 | + |
| 3638 | + checkSet[i] = match; |
| 3639 | + } |
| 3640 | + } |
| 3641 | +} |
| 3642 | + |
| 3643 | +var contains = document.compareDocumentPosition ? function(a, b){ |
| 3644 | + return !!(a.compareDocumentPosition(b) & 16); |
| 3645 | +} : function(a, b){ |
| 3646 | + return a !== b && (a.contains ? a.contains(b) : true); |
| 3647 | +}; |
| 3648 | + |
| 3649 | +var isXML = function(elem){ |
| 3650 | + // documentElement is verified for cases where it doesn't yet exist |
| 3651 | + // (such as loading iframes in IE - #4833) |
| 3652 | + var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement; |
| 3653 | + return documentElement ? documentElement.nodeName !== "HTML" : false; |
| 3654 | +}; |
| 3655 | + |
| 3656 | +var posProcess = function(selector, context){ |
| 3657 | + var tmpSet = [], later = "", match, |
| 3658 | + root = context.nodeType ? [context] : context; |
| 3659 | + |
| 3660 | + // Position selectors must be done after the filter |
| 3661 | + // And so must :not(positional) so we move all PSEUDOs to the end |
| 3662 | + while ( (match = Expr.match.PSEUDO.exec( selector )) ) { |
| 3663 | + later += match[0]; |
| 3664 | + selector = selector.replace( Expr.match.PSEUDO, "" ); |
| 3665 | + } |
| 3666 | + |
| 3667 | + selector = Expr.relative[selector] ? selector + "*" : selector; |
| 3668 | + |
| 3669 | + for ( var i = 0, l = root.length; i < l; i++ ) { |
| 3670 | + Sizzle( selector, root[i], tmpSet ); |
| 3671 | + } |
| 3672 | + |
| 3673 | + return Sizzle.filter( later, tmpSet ); |
| 3674 | +}; |
| 3675 | + |
| 3676 | +// EXPOSE |
| 3677 | +jQuery.find = Sizzle; |
| 3678 | +jQuery.expr = Sizzle.selectors; |
| 3679 | +jQuery.expr[":"] = jQuery.expr.filters; |
| 3680 | +jQuery.unique = Sizzle.uniqueSort; |
| 3681 | +jQuery.text = getText; |
| 3682 | +jQuery.isXMLDoc = isXML; |
| 3683 | +jQuery.contains = contains; |
| 3684 | + |
| 3685 | +return; |
| 3686 | + |
| 3687 | +window.Sizzle = Sizzle; |
| 3688 | + |
| 3689 | +})(); |
| 3690 | +var runtil = /Until$/, |
| 3691 | + rparentsprev = /^(?:parents|prevUntil|prevAll)/, |
| 3692 | + // Note: This RegExp should be improved, or likely pulled from Sizzle |
| 3693 | + rmultiselector = /,/, |
| 3694 | + slice = Array.prototype.slice; |
| 3695 | + |
| 3696 | +// Implement the identical functionality for filter and not |
| 3697 | +var winnow = function( elements, qualifier, keep ) { |
| 3698 | + if ( jQuery.isFunction( qualifier ) ) { |
| 3699 | + return jQuery.grep(elements, function( elem, i ) { |
| 3700 | + return !!qualifier.call( elem, i, elem ) === keep; |
| 3701 | + }); |
| 3702 | + |
| 3703 | + } else if ( qualifier.nodeType ) { |
| 3704 | + return jQuery.grep(elements, function( elem, i ) { |
| 3705 | + return (elem === qualifier) === keep; |
| 3706 | + }); |
| 3707 | + |
| 3708 | + } else if ( typeof qualifier === "string" ) { |
| 3709 | + var filtered = jQuery.grep(elements, function( elem ) { |
| 3710 | + return elem.nodeType === 1; |
| 3711 | + }); |
| 3712 | + |
| 3713 | + if ( isSimple.test( qualifier ) ) { |
| 3714 | + return jQuery.filter(qualifier, filtered, !keep); |
| 3715 | + } else { |
| 3716 | + qualifier = jQuery.filter( qualifier, filtered ); |
| 3717 | + } |
| 3718 | + } |
| 3719 | + |
| 3720 | + return jQuery.grep(elements, function( elem, i ) { |
| 3721 | + return (jQuery.inArray( elem, qualifier ) >= 0) === keep; |
| 3722 | + }); |
| 3723 | +}; |
| 3724 | + |
| 3725 | +jQuery.fn.extend({ |
| 3726 | + find: function( selector ) { |
| 3727 | + var ret = this.pushStack( "", "find", selector ), length = 0; |
| 3728 | + |
| 3729 | + for ( var i = 0, l = this.length; i < l; i++ ) { |
| 3730 | + length = ret.length; |
| 3731 | + jQuery.find( selector, this[i], ret ); |
| 3732 | + |
| 3733 | + if ( i > 0 ) { |
| 3734 | + // Make sure that the results are unique |
| 3735 | + for ( var n = length; n < ret.length; n++ ) { |
| 3736 | + for ( var r = 0; r < length; r++ ) { |
| 3737 | + if ( ret[r] === ret[n] ) { |
| 3738 | + ret.splice(n--, 1); |
| 3739 | + break; |
| 3740 | + } |
| 3741 | + } |
| 3742 | + } |
| 3743 | + } |
| 3744 | + } |
| 3745 | + |
| 3746 | + return ret; |
| 3747 | + }, |
| 3748 | + |
| 3749 | + has: function( target ) { |
| 3750 | + var targets = jQuery( target ); |
| 3751 | + return this.filter(function() { |
| 3752 | + for ( var i = 0, l = targets.length; i < l; i++ ) { |
| 3753 | + if ( jQuery.contains( this, targets[i] ) ) { |
| 3754 | + return true; |
| 3755 | + } |
| 3756 | + } |
| 3757 | + }); |
| 3758 | + }, |
| 3759 | + |
| 3760 | + not: function( selector ) { |
| 3761 | + return this.pushStack( winnow(this, selector, false), "not", selector); |
| 3762 | + }, |
| 3763 | + |
| 3764 | + filter: function( selector ) { |
| 3765 | + return this.pushStack( winnow(this, selector, true), "filter", selector ); |
| 3766 | + }, |
| 3767 | + |
| 3768 | + is: function( selector ) { |
| 3769 | + return !!selector && jQuery.filter( selector, this ).length > 0; |
| 3770 | + }, |
| 3771 | + |
| 3772 | + closest: function( selectors, context ) { |
| 3773 | + if ( jQuery.isArray( selectors ) ) { |
| 3774 | + var ret = [], cur = this[0], match, matches = {}, selector; |
| 3775 | + |
| 3776 | + if ( cur && selectors.length ) { |
| 3777 | + for ( var i = 0, l = selectors.length; i < l; i++ ) { |
| 3778 | + selector = selectors[i]; |
| 3779 | + |
| 3780 | + if ( !matches[selector] ) { |
| 3781 | + matches[selector] = jQuery.expr.match.POS.test( selector ) ? |
| 3782 | + jQuery( selector, context || this.context ) : |
| 3783 | + selector; |
| 3784 | + } |
| 3785 | + } |
| 3786 | + |
| 3787 | + while ( cur && cur.ownerDocument && cur !== context ) { |
| 3788 | + for ( selector in matches ) { |
| 3789 | + match = matches[selector]; |
| 3790 | + |
| 3791 | + if ( match.jquery ? match.index(cur) > -1 : jQuery(cur).is(match) ) { |
| 3792 | + ret.push({ selector: selector, elem: cur }); |
| 3793 | + delete matches[selector]; |
| 3794 | + } |
| 3795 | + } |
| 3796 | + cur = cur.parentNode; |
| 3797 | + } |
| 3798 | + } |
| 3799 | + |
| 3800 | + return ret; |
| 3801 | + } |
| 3802 | + |
| 3803 | + var pos = jQuery.expr.match.POS.test( selectors ) ? |
| 3804 | + jQuery( selectors, context || this.context ) : null; |
| 3805 | + |
| 3806 | + return this.map(function( i, cur ) { |
| 3807 | + while ( cur && cur.ownerDocument && cur !== context ) { |
| 3808 | + if ( pos ? pos.index(cur) > -1 : jQuery(cur).is(selectors) ) { |
| 3809 | + return cur; |
| 3810 | + } |
| 3811 | + cur = cur.parentNode; |
| 3812 | + } |
| 3813 | + return null; |
| 3814 | + }); |
| 3815 | + }, |
| 3816 | + |
| 3817 | + // Determine the position of an element within |
| 3818 | + // the matched set of elements |
| 3819 | + index: function( elem ) { |
| 3820 | + if ( !elem || typeof elem === "string" ) { |
| 3821 | + return jQuery.inArray( this[0], |
| 3822 | + // If it receives a string, the selector is used |
| 3823 | + // If it receives nothing, the siblings are used |
| 3824 | + elem ? jQuery( elem ) : this.parent().children() ); |
| 3825 | + } |
| 3826 | + // Locate the position of the desired element |
| 3827 | + return jQuery.inArray( |
| 3828 | + // If it receives a jQuery object, the first element is used |
| 3829 | + elem.jquery ? elem[0] : elem, this ); |
| 3830 | + }, |
| 3831 | + |
| 3832 | + add: function( selector, context ) { |
| 3833 | + var set = typeof selector === "string" ? |
| 3834 | + jQuery( selector, context || this.context ) : |
| 3835 | + jQuery.makeArray( selector ), |
| 3836 | + all = jQuery.merge( this.get(), set ); |
| 3837 | + |
| 3838 | + return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ? |
| 3839 | + all : |
| 3840 | + jQuery.unique( all ) ); |
| 3841 | + }, |
| 3842 | + |
| 3843 | + andSelf: function() { |
| 3844 | + return this.add( this.prevObject ); |
| 3845 | + } |
| 3846 | +}); |
| 3847 | + |
| 3848 | +// A painfully simple check to see if an element is disconnected |
| 3849 | +// from a document (should be improved, where feasible). |
| 3850 | +function isDisconnected( node ) { |
| 3851 | + return !node || !node.parentNode || node.parentNode.nodeType === 11; |
| 3852 | +} |
| 3853 | + |
| 3854 | +jQuery.each({ |
| 3855 | + parent: function( elem ) { |
| 3856 | + var parent = elem.parentNode; |
| 3857 | + return parent && parent.nodeType !== 11 ? parent : null; |
| 3858 | + }, |
| 3859 | + parents: function( elem ) { |
| 3860 | + return jQuery.dir( elem, "parentNode" ); |
| 3861 | + }, |
| 3862 | + parentsUntil: function( elem, i, until ) { |
| 3863 | + return jQuery.dir( elem, "parentNode", until ); |
| 3864 | + }, |
| 3865 | + next: function( elem ) { |
| 3866 | + return jQuery.nth( elem, 2, "nextSibling" ); |
| 3867 | + }, |
| 3868 | + prev: function( elem ) { |
| 3869 | + return jQuery.nth( elem, 2, "previousSibling" ); |
| 3870 | + }, |
| 3871 | + nextAll: function( elem ) { |
| 3872 | + return jQuery.dir( elem, "nextSibling" ); |
| 3873 | + }, |
| 3874 | + prevAll: function( elem ) { |
| 3875 | + return jQuery.dir( elem, "previousSibling" ); |
| 3876 | + }, |
| 3877 | + nextUntil: function( elem, i, until ) { |
| 3878 | + return jQuery.dir( elem, "nextSibling", until ); |
| 3879 | + }, |
| 3880 | + prevUntil: function( elem, i, until ) { |
| 3881 | + return jQuery.dir( elem, "previousSibling", until ); |
| 3882 | + }, |
| 3883 | + siblings: function( elem ) { |
| 3884 | + return jQuery.sibling( elem.parentNode.firstChild, elem ); |
| 3885 | + }, |
| 3886 | + children: function( elem ) { |
| 3887 | + return jQuery.sibling( elem.firstChild ); |
| 3888 | + }, |
| 3889 | + contents: function( elem ) { |
| 3890 | + return jQuery.nodeName( elem, "iframe" ) ? |
| 3891 | + elem.contentDocument || elem.contentWindow.document : |
| 3892 | + jQuery.makeArray( elem.childNodes ); |
| 3893 | + } |
| 3894 | +}, function( name, fn ) { |
| 3895 | + jQuery.fn[ name ] = function( until, selector ) { |
| 3896 | + var ret = jQuery.map( this, fn, until ); |
| 3897 | + |
| 3898 | + if ( !runtil.test( name ) ) { |
| 3899 | + selector = until; |
| 3900 | + } |
| 3901 | + |
| 3902 | + if ( selector && typeof selector === "string" ) { |
| 3903 | + ret = jQuery.filter( selector, ret ); |
| 3904 | + } |
| 3905 | + |
| 3906 | + ret = this.length > 1 ? jQuery.unique( ret ) : ret; |
| 3907 | + |
| 3908 | + if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) { |
| 3909 | + ret = ret.reverse(); |
| 3910 | + } |
| 3911 | + |
| 3912 | + return this.pushStack( ret, name, slice.call(arguments).join(",") ); |
| 3913 | + }; |
| 3914 | +}); |
| 3915 | + |
| 3916 | +jQuery.extend({ |
| 3917 | + filter: function( expr, elems, not ) { |
| 3918 | + if ( not ) { |
| 3919 | + expr = ":not(" + expr + ")"; |
| 3920 | + } |
| 3921 | + |
| 3922 | + return jQuery.find.matches(expr, elems); |
| 3923 | + }, |
| 3924 | + |
| 3925 | + dir: function( elem, dir, until ) { |
| 3926 | + var matched = [], cur = elem[dir]; |
| 3927 | + while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) { |
| 3928 | + if ( cur.nodeType === 1 ) { |
| 3929 | + matched.push( cur ); |
| 3930 | + } |
| 3931 | + cur = cur[dir]; |
| 3932 | + } |
| 3933 | + return matched; |
| 3934 | + }, |
| 3935 | + |
| 3936 | + nth: function( cur, result, dir, elem ) { |
| 3937 | + result = result || 1; |
| 3938 | + var num = 0; |
| 3939 | + |
| 3940 | + for ( ; cur; cur = cur[dir] ) { |
| 3941 | + if ( cur.nodeType === 1 && ++num === result ) { |
| 3942 | + break; |
| 3943 | + } |
| 3944 | + } |
| 3945 | + |
| 3946 | + return cur; |
| 3947 | + }, |
| 3948 | + |
| 3949 | + sibling: function( n, elem ) { |
| 3950 | + var r = []; |
| 3951 | + |
| 3952 | + for ( ; n; n = n.nextSibling ) { |
| 3953 | + if ( n.nodeType === 1 && n !== elem ) { |
| 3954 | + r.push( n ); |
| 3955 | + } |
| 3956 | + } |
| 3957 | + |
| 3958 | + return r; |
| 3959 | + } |
| 3960 | +}); |
| 3961 | +var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g, |
| 3962 | + rleadingWhitespace = /^\s+/, |
| 3963 | + rxhtmlTag = /(<([\w:]+)[^>]*?)\/>/g, |
| 3964 | + rselfClosing = /^(?:area|br|col|embed|hr|img|input|link|meta|param)$/i, |
| 3965 | + rtagName = /<([\w:]+)/, |
| 3966 | + rtbody = /<tbody/i, |
| 3967 | + rhtml = /<|&#?\w+;/, |
| 3968 | + rnocache = /<script|<object|<embed|<option|<style/i, |
| 3969 | + rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, // checked="checked" or checked (html5) |
| 3970 | + fcloseTag = function( all, front, tag ) { |
| 3971 | + return rselfClosing.test( tag ) ? |
| 3972 | + all : |
| 3973 | + front + "></" + tag + ">"; |
| 3974 | + }, |
| 3975 | + wrapMap = { |
| 3976 | + option: [ 1, "<select multiple='multiple'>", "</select>" ], |
| 3977 | + legend: [ 1, "<fieldset>", "</fieldset>" ], |
| 3978 | + thead: [ 1, "<table>", "</table>" ], |
| 3979 | + tr: [ 2, "<table><tbody>", "</tbody></table>" ], |
| 3980 | + td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ], |
| 3981 | + col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ], |
| 3982 | + area: [ 1, "<map>", "</map>" ], |
| 3983 | + _default: [ 0, "", "" ] |
| 3984 | + }; |
| 3985 | + |
| 3986 | +wrapMap.optgroup = wrapMap.option; |
| 3987 | +wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; |
| 3988 | +wrapMap.th = wrapMap.td; |
| 3989 | + |
| 3990 | +// IE can't serialize <link> and <script> tags normally |
| 3991 | +if ( !jQuery.support.htmlSerialize ) { |
| 3992 | + wrapMap._default = [ 1, "div<div>", "</div>" ]; |
| 3993 | +} |
| 3994 | + |
| 3995 | +jQuery.fn.extend({ |
| 3996 | + text: function( text ) { |
| 3997 | + if ( jQuery.isFunction(text) ) { |
| 3998 | + return this.each(function(i) { |
| 3999 | + var self = jQuery(this); |
| 4000 | + self.text( text.call(this, i, self.text()) ); |
| 4001 | + }); |
| 4002 | + } |
| 4003 | + |
| 4004 | + if ( typeof text !== "object" && text !== undefined ) { |
| 4005 | + return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) ); |
| 4006 | + } |
| 4007 | + |
| 4008 | + return jQuery.text( this ); |
| 4009 | + }, |
| 4010 | + |
| 4011 | + wrapAll: function( html ) { |
| 4012 | + if ( jQuery.isFunction( html ) ) { |
| 4013 | + return this.each(function(i) { |
| 4014 | + jQuery(this).wrapAll( html.call(this, i) ); |
| 4015 | + }); |
| 4016 | + } |
| 4017 | + |
| 4018 | + if ( this[0] ) { |
| 4019 | + // The elements to wrap the target around |
| 4020 | + var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true); |
| 4021 | + |
| 4022 | + if ( this[0].parentNode ) { |
| 4023 | + wrap.insertBefore( this[0] ); |
| 4024 | + } |
| 4025 | + |
| 4026 | + wrap.map(function() { |
| 4027 | + var elem = this; |
| 4028 | + |
| 4029 | + while ( elem.firstChild && elem.firstChild.nodeType === 1 ) { |
| 4030 | + elem = elem.firstChild; |
| 4031 | + } |
| 4032 | + |
| 4033 | + return elem; |
| 4034 | + }).append(this); |
| 4035 | + } |
| 4036 | + |
| 4037 | + return this; |
| 4038 | + }, |
| 4039 | + |
| 4040 | + wrapInner: function( html ) { |
| 4041 | + if ( jQuery.isFunction( html ) ) { |
| 4042 | + return this.each(function(i) { |
| 4043 | + jQuery(this).wrapInner( html.call(this, i) ); |
| 4044 | + }); |
| 4045 | + } |
| 4046 | + |
| 4047 | + return this.each(function() { |
| 4048 | + var self = jQuery( this ), contents = self.contents(); |
| 4049 | + |
| 4050 | + if ( contents.length ) { |
| 4051 | + contents.wrapAll( html ); |
| 4052 | + |
| 4053 | + } else { |
| 4054 | + self.append( html ); |
| 4055 | + } |
| 4056 | + }); |
| 4057 | + }, |
| 4058 | + |
| 4059 | + wrap: function( html ) { |
| 4060 | + return this.each(function() { |
| 4061 | + jQuery( this ).wrapAll( html ); |
| 4062 | + }); |
| 4063 | + }, |
| 4064 | + |
| 4065 | + unwrap: function() { |
| 4066 | + return this.parent().each(function() { |
| 4067 | + if ( !jQuery.nodeName( this, "body" ) ) { |
| 4068 | + jQuery( this ).replaceWith( this.childNodes ); |
| 4069 | + } |
| 4070 | + }).end(); |
| 4071 | + }, |
| 4072 | + |
| 4073 | + append: function() { |
| 4074 | + return this.domManip(arguments, true, function( elem ) { |
| 4075 | + if ( this.nodeType === 1 ) { |
| 4076 | + this.appendChild( elem ); |
| 4077 | + } |
| 4078 | + }); |
| 4079 | + }, |
| 4080 | + |
| 4081 | + prepend: function() { |
| 4082 | + return this.domManip(arguments, true, function( elem ) { |
| 4083 | + if ( this.nodeType === 1 ) { |
| 4084 | + this.insertBefore( elem, this.firstChild ); |
| 4085 | + } |
| 4086 | + }); |
| 4087 | + }, |
| 4088 | + |
| 4089 | + before: function() { |
| 4090 | + if ( this[0] && this[0].parentNode ) { |
| 4091 | + return this.domManip(arguments, false, function( elem ) { |
| 4092 | + this.parentNode.insertBefore( elem, this ); |
| 4093 | + }); |
| 4094 | + } else if ( arguments.length ) { |
| 4095 | + var set = jQuery(arguments[0]); |
| 4096 | + set.push.apply( set, this.toArray() ); |
| 4097 | + return this.pushStack( set, "before", arguments ); |
| 4098 | + } |
| 4099 | + }, |
| 4100 | + |
| 4101 | + after: function() { |
| 4102 | + if ( this[0] && this[0].parentNode ) { |
| 4103 | + return this.domManip(arguments, false, function( elem ) { |
| 4104 | + this.parentNode.insertBefore( elem, this.nextSibling ); |
| 4105 | + }); |
| 4106 | + } else if ( arguments.length ) { |
| 4107 | + var set = this.pushStack( this, "after", arguments ); |
| 4108 | + set.push.apply( set, jQuery(arguments[0]).toArray() ); |
| 4109 | + return set; |
| 4110 | + } |
| 4111 | + }, |
| 4112 | + |
| 4113 | + // keepData is for internal use only--do not document |
| 4114 | + remove: function( selector, keepData ) { |
| 4115 | + for ( var i = 0, elem; (elem = this[i]) != null; i++ ) { |
| 4116 | + if ( !selector || jQuery.filter( selector, [ elem ] ).length ) { |
| 4117 | + if ( !keepData && elem.nodeType === 1 ) { |
| 4118 | + jQuery.cleanData( elem.getElementsByTagName("*") ); |
| 4119 | + jQuery.cleanData( [ elem ] ); |
| 4120 | + } |
| 4121 | + |
| 4122 | + if ( elem.parentNode ) { |
| 4123 | + elem.parentNode.removeChild( elem ); |
| 4124 | + } |
| 4125 | + } |
| 4126 | + } |
| 4127 | + |
| 4128 | + return this; |
| 4129 | + }, |
| 4130 | + |
| 4131 | + empty: function() { |
| 4132 | + for ( var i = 0, elem; (elem = this[i]) != null; i++ ) { |
| 4133 | + // Remove element nodes and prevent memory leaks |
| 4134 | + if ( elem.nodeType === 1 ) { |
| 4135 | + jQuery.cleanData( elem.getElementsByTagName("*") ); |
| 4136 | + } |
| 4137 | + |
| 4138 | + // Remove any remaining nodes |
| 4139 | + while ( elem.firstChild ) { |
| 4140 | + elem.removeChild( elem.firstChild ); |
| 4141 | + } |
| 4142 | + } |
| 4143 | + |
| 4144 | + return this; |
| 4145 | + }, |
| 4146 | + |
| 4147 | + clone: function( events ) { |
| 4148 | + // Do the clone |
| 4149 | + var ret = this.map(function() { |
| 4150 | + if ( !jQuery.support.noCloneEvent && !jQuery.isXMLDoc(this) ) { |
| 4151 | + // IE copies events bound via attachEvent when |
| 4152 | + // using cloneNode. Calling detachEvent on the |
| 4153 | + // clone will also remove the events from the orignal |
| 4154 | + // In order to get around this, we use innerHTML. |
| 4155 | + // Unfortunately, this means some modifications to |
| 4156 | + // attributes in IE that are actually only stored |
| 4157 | + // as properties will not be copied (such as the |
| 4158 | + // the name attribute on an input). |
| 4159 | + var html = this.outerHTML, ownerDocument = this.ownerDocument; |
| 4160 | + if ( !html ) { |
| 4161 | + var div = ownerDocument.createElement("div"); |
| 4162 | + div.appendChild( this.cloneNode(true) ); |
| 4163 | + html = div.innerHTML; |
| 4164 | + } |
| 4165 | + |
| 4166 | + return jQuery.clean([html.replace(rinlinejQuery, "") |
| 4167 | + // Handle the case in IE 8 where action=/test/> self-closes a tag |
| 4168 | + .replace(/=([^="'>\s]+\/)>/g, '="$1">') |
| 4169 | + .replace(rleadingWhitespace, "")], ownerDocument)[0]; |
| 4170 | + } else { |
| 4171 | + return this.cloneNode(true); |
| 4172 | + } |
| 4173 | + }); |
| 4174 | + |
| 4175 | + // Copy the events from the original to the clone |
| 4176 | + if ( events === true ) { |
| 4177 | + cloneCopyEvent( this, ret ); |
| 4178 | + cloneCopyEvent( this.find("*"), ret.find("*") ); |
| 4179 | + } |
| 4180 | + |
| 4181 | + // Return the cloned set |
| 4182 | + return ret; |
| 4183 | + }, |
| 4184 | + |
| 4185 | + html: function( value ) { |
| 4186 | + if ( value === undefined ) { |
| 4187 | + return this[0] && this[0].nodeType === 1 ? |
| 4188 | + this[0].innerHTML.replace(rinlinejQuery, "") : |
| 4189 | + null; |
| 4190 | + |
| 4191 | + // See if we can take a shortcut and just use innerHTML |
| 4192 | + } else if ( typeof value === "string" && !rnocache.test( value ) && |
| 4193 | + (jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value )) && |
| 4194 | + !wrapMap[ (rtagName.exec( value ) || ["", ""])[1].toLowerCase() ] ) { |
| 4195 | + |
| 4196 | + value = value.replace(rxhtmlTag, fcloseTag); |
| 4197 | + |
| 4198 | + try { |
| 4199 | + for ( var i = 0, l = this.length; i < l; i++ ) { |
| 4200 | + // Remove element nodes and prevent memory leaks |
| 4201 | + if ( this[i].nodeType === 1 ) { |
| 4202 | + jQuery.cleanData( this[i].getElementsByTagName("*") ); |
| 4203 | + this[i].innerHTML = value; |
| 4204 | + } |
| 4205 | + } |
| 4206 | + |
| 4207 | + // If using innerHTML throws an exception, use the fallback method |
| 4208 | + } catch(e) { |
| 4209 | + this.empty().append( value ); |
| 4210 | + } |
| 4211 | + |
| 4212 | + } else if ( jQuery.isFunction( value ) ) { |
| 4213 | + this.each(function(i){ |
| 4214 | + var self = jQuery(this), old = self.html(); |
| 4215 | + self.empty().append(function(){ |
| 4216 | + return value.call( this, i, old ); |
| 4217 | + }); |
| 4218 | + }); |
| 4219 | + |
| 4220 | + } else { |
| 4221 | + this.empty().append( value ); |
| 4222 | + } |
| 4223 | + |
| 4224 | + return this; |
| 4225 | + }, |
| 4226 | + |
| 4227 | + replaceWith: function( value ) { |
| 4228 | + if ( this[0] && this[0].parentNode ) { |
| 4229 | + // Make sure that the elements are removed from the DOM before they are inserted |
| 4230 | + // this can help fix replacing a parent with child elements |
| 4231 | + if ( jQuery.isFunction( value ) ) { |
| 4232 | + return this.each(function(i) { |
| 4233 | + var self = jQuery(this), old = self.html(); |
| 4234 | + self.replaceWith( value.call( this, i, old ) ); |
| 4235 | + }); |
| 4236 | + } |
| 4237 | + |
| 4238 | + if ( typeof value !== "string" ) { |
| 4239 | + value = jQuery(value).detach(); |
| 4240 | + } |
| 4241 | + |
| 4242 | + return this.each(function() { |
| 4243 | + var next = this.nextSibling, parent = this.parentNode; |
| 4244 | + |
| 4245 | + jQuery(this).remove(); |
| 4246 | + |
| 4247 | + if ( next ) { |
| 4248 | + jQuery(next).before( value ); |
| 4249 | + } else { |
| 4250 | + jQuery(parent).append( value ); |
| 4251 | + } |
| 4252 | + }); |
| 4253 | + } else { |
| 4254 | + return this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value ); |
| 4255 | + } |
| 4256 | + }, |
| 4257 | + |
| 4258 | + detach: function( selector ) { |
| 4259 | + return this.remove( selector, true ); |
| 4260 | + }, |
| 4261 | + |
| 4262 | + domManip: function( args, table, callback ) { |
| 4263 | + var results, first, value = args[0], scripts = [], fragment, parent; |
| 4264 | + |
| 4265 | + // We can't cloneNode fragments that contain checked, in WebKit |
| 4266 | + if ( !jQuery.support.checkClone && arguments.length === 3 && typeof value === "string" && rchecked.test( value ) ) { |
| 4267 | + return this.each(function() { |
| 4268 | + jQuery(this).domManip( args, table, callback, true ); |
| 4269 | + }); |
| 4270 | + } |
| 4271 | + |
| 4272 | + if ( jQuery.isFunction(value) ) { |
| 4273 | + return this.each(function(i) { |
| 4274 | + var self = jQuery(this); |
| 4275 | + args[0] = value.call(this, i, table ? self.html() : undefined); |
| 4276 | + self.domManip( args, table, callback ); |
| 4277 | + }); |
| 4278 | + } |
| 4279 | + |
| 4280 | + if ( this[0] ) { |
| 4281 | + parent = value && value.parentNode; |
| 4282 | + |
| 4283 | + // If we're in a fragment, just use that instead of building a new one |
| 4284 | + if ( jQuery.support.parentNode && parent && parent.nodeType === 11 && parent.childNodes.length === this.length ) { |
| 4285 | + results = { fragment: parent }; |
| 4286 | + |
| 4287 | + } else { |
| 4288 | + results = buildFragment( args, this, scripts ); |
| 4289 | + } |
| 4290 | + |
| 4291 | + fragment = results.fragment; |
| 4292 | + |
| 4293 | + if ( fragment.childNodes.length === 1 ) { |
| 4294 | + first = fragment = fragment.firstChild; |
| 4295 | + } else { |
| 4296 | + first = fragment.firstChild; |
| 4297 | + } |
| 4298 | + |
| 4299 | + if ( first ) { |
| 4300 | + table = table && jQuery.nodeName( first, "tr" ); |
| 4301 | + |
| 4302 | + for ( var i = 0, l = this.length; i < l; i++ ) { |
| 4303 | + callback.call( |
| 4304 | + table ? |
| 4305 | + root(this[i], first) : |
| 4306 | + this[i], |
| 4307 | + i > 0 || results.cacheable || this.length > 1 ? |
| 4308 | + fragment.cloneNode(true) : |
| 4309 | + fragment |
| 4310 | + ); |
| 4311 | + } |
| 4312 | + } |
| 4313 | + |
| 4314 | + if ( scripts.length ) { |
| 4315 | + jQuery.each( scripts, evalScript ); |
| 4316 | + } |
| 4317 | + } |
| 4318 | + |
| 4319 | + return this; |
| 4320 | + |
| 4321 | + function root( elem, cur ) { |
| 4322 | + return jQuery.nodeName(elem, "table") ? |
| 4323 | + (elem.getElementsByTagName("tbody")[0] || |
| 4324 | + elem.appendChild(elem.ownerDocument.createElement("tbody"))) : |
| 4325 | + elem; |
| 4326 | + } |
| 4327 | + } |
| 4328 | +}); |
| 4329 | + |
| 4330 | +function cloneCopyEvent(orig, ret) { |
| 4331 | + var i = 0; |
| 4332 | + |
| 4333 | + ret.each(function() { |
| 4334 | + if ( this.nodeName !== (orig[i] && orig[i].nodeName) ) { |
| 4335 | + return; |
| 4336 | + } |
| 4337 | + |
| 4338 | + var oldData = jQuery.data( orig[i++] ), curData = jQuery.data( this, oldData ), events = oldData && oldData.events; |
| 4339 | + |
| 4340 | + if ( events ) { |
| 4341 | + delete curData.handle; |
| 4342 | + curData.events = {}; |
| 4343 | + |
| 4344 | + for ( var type in events ) { |
| 4345 | + for ( var handler in events[ type ] ) { |
| 4346 | + jQuery.event.add( this, type, events[ type ][ handler ], events[ type ][ handler ].data ); |
| 4347 | + } |
| 4348 | + } |
| 4349 | + } |
| 4350 | + }); |
| 4351 | +} |
| 4352 | + |
| 4353 | +function buildFragment( args, nodes, scripts ) { |
| 4354 | + var fragment, cacheable, cacheresults, |
| 4355 | + doc = (nodes && nodes[0] ? nodes[0].ownerDocument || nodes[0] : document); |
| 4356 | + |
| 4357 | + // Only cache "small" (1/2 KB) strings that are associated with the main document |
| 4358 | + // Cloning options loses the selected state, so don't cache them |
| 4359 | + // IE 6 doesn't like it when you put <object> or <embed> elements in a fragment |
| 4360 | + // Also, WebKit does not clone 'checked' attributes on cloneNode, so don't cache |
| 4361 | + if ( args.length === 1 && typeof args[0] === "string" && args[0].length < 512 && doc === document && |
| 4362 | + !rnocache.test( args[0] ) && (jQuery.support.checkClone || !rchecked.test( args[0] )) ) { |
| 4363 | + |
| 4364 | + cacheable = true; |
| 4365 | + cacheresults = jQuery.fragments[ args[0] ]; |
| 4366 | + if ( cacheresults ) { |
| 4367 | + if ( cacheresults !== 1 ) { |
| 4368 | + fragment = cacheresults; |
| 4369 | + } |
| 4370 | + } |
| 4371 | + } |
| 4372 | + |
| 4373 | + if ( !fragment ) { |
| 4374 | + fragment = doc.createDocumentFragment(); |
| 4375 | + jQuery.clean( args, doc, fragment, scripts ); |
| 4376 | + } |
| 4377 | + |
| 4378 | + if ( cacheable ) { |
| 4379 | + jQuery.fragments[ args[0] ] = cacheresults ? fragment : 1; |
| 4380 | + } |
| 4381 | + |
| 4382 | + return { fragment: fragment, cacheable: cacheable }; |
| 4383 | +} |
| 4384 | + |
| 4385 | +jQuery.fragments = {}; |
| 4386 | + |
| 4387 | +jQuery.each({ |
| 4388 | + appendTo: "append", |
| 4389 | + prependTo: "prepend", |
| 4390 | + insertBefore: "before", |
| 4391 | + insertAfter: "after", |
| 4392 | + replaceAll: "replaceWith" |
| 4393 | +}, function( name, original ) { |
| 4394 | + jQuery.fn[ name ] = function( selector ) { |
| 4395 | + var ret = [], insert = jQuery( selector ), |
| 4396 | + parent = this.length === 1 && this[0].parentNode; |
| 4397 | + |
| 4398 | + if ( parent && parent.nodeType === 11 && parent.childNodes.length === 1 && insert.length === 1 ) { |
| 4399 | + insert[ original ]( this[0] ); |
| 4400 | + return this; |
| 4401 | + |
| 4402 | + } else { |
| 4403 | + for ( var i = 0, l = insert.length; i < l; i++ ) { |
| 4404 | + var elems = (i > 0 ? this.clone(true) : this).get(); |
| 4405 | + jQuery.fn[ original ].apply( jQuery(insert[i]), elems ); |
| 4406 | + ret = ret.concat( elems ); |
| 4407 | + } |
| 4408 | + |
| 4409 | + return this.pushStack( ret, name, insert.selector ); |
| 4410 | + } |
| 4411 | + }; |
| 4412 | +}); |
| 4413 | + |
| 4414 | +jQuery.extend({ |
| 4415 | + clean: function( elems, context, fragment, scripts ) { |
| 4416 | + context = context || document; |
| 4417 | + |
| 4418 | + // !context.createElement fails in IE with an error but returns typeof 'object' |
| 4419 | + if ( typeof context.createElement === "undefined" ) { |
| 4420 | + context = context.ownerDocument || context[0] && context[0].ownerDocument || document; |
| 4421 | + } |
| 4422 | + |
| 4423 | + var ret = []; |
| 4424 | + |
| 4425 | + for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) { |
| 4426 | + if ( typeof elem === "number" ) { |
| 4427 | + elem += ""; |
| 4428 | + } |
| 4429 | + |
| 4430 | + if ( !elem ) { |
| 4431 | + continue; |
| 4432 | + } |
| 4433 | + |
| 4434 | + // Convert html string into DOM nodes |
| 4435 | + if ( typeof elem === "string" && !rhtml.test( elem ) ) { |
| 4436 | + elem = context.createTextNode( elem ); |
| 4437 | + |
| 4438 | + } else if ( typeof elem === "string" ) { |
| 4439 | + // Fix "XHTML"-style tags in all browsers |
| 4440 | + elem = elem.replace(rxhtmlTag, fcloseTag); |
| 4441 | + |
| 4442 | + // Trim whitespace, otherwise indexOf won't work as expected |
| 4443 | + var tag = (rtagName.exec( elem ) || ["", ""])[1].toLowerCase(), |
| 4444 | + wrap = wrapMap[ tag ] || wrapMap._default, |
| 4445 | + depth = wrap[0], |
| 4446 | + div = context.createElement("div"); |
| 4447 | + |
| 4448 | + // Go to html and back, then peel off extra wrappers |
| 4449 | + div.innerHTML = wrap[1] + elem + wrap[2]; |
| 4450 | + |
| 4451 | + // Move to the right depth |
| 4452 | + while ( depth-- ) { |
| 4453 | + div = div.lastChild; |
| 4454 | + } |
| 4455 | + |
| 4456 | + // Remove IE's autoinserted <tbody> from table fragments |
| 4457 | + if ( !jQuery.support.tbody ) { |
| 4458 | + |
| 4459 | + // String was a <table>, *may* have spurious <tbody> |
| 4460 | + var hasBody = rtbody.test(elem), |
| 4461 | + tbody = tag === "table" && !hasBody ? |
| 4462 | + div.firstChild && div.firstChild.childNodes : |
| 4463 | + |
| 4464 | + // String was a bare <thead> or <tfoot> |
| 4465 | + wrap[1] === "<table>" && !hasBody ? |
| 4466 | + div.childNodes : |
| 4467 | + []; |
| 4468 | + |
| 4469 | + for ( var j = tbody.length - 1; j >= 0 ; --j ) { |
| 4470 | + if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) { |
| 4471 | + tbody[ j ].parentNode.removeChild( tbody[ j ] ); |
| 4472 | + } |
| 4473 | + } |
| 4474 | + |
| 4475 | + } |
| 4476 | + |
| 4477 | + // IE completely kills leading whitespace when innerHTML is used |
| 4478 | + if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) { |
| 4479 | + div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild ); |
| 4480 | + } |
| 4481 | + |
| 4482 | + elem = div.childNodes; |
| 4483 | + } |
| 4484 | + |
| 4485 | + if ( elem.nodeType ) { |
| 4486 | + ret.push( elem ); |
| 4487 | + } else { |
| 4488 | + ret = jQuery.merge( ret, elem ); |
| 4489 | + } |
| 4490 | + } |
| 4491 | + |
| 4492 | + if ( fragment ) { |
| 4493 | + for ( var i = 0; ret[i]; i++ ) { |
| 4494 | + if ( scripts && jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) { |
| 4495 | + scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] ); |
| 4496 | + |
| 4497 | + } else { |
| 4498 | + if ( ret[i].nodeType === 1 ) { |
| 4499 | + ret.splice.apply( ret, [i + 1, 0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))) ); |
| 4500 | + } |
| 4501 | + fragment.appendChild( ret[i] ); |
| 4502 | + } |
| 4503 | + } |
| 4504 | + } |
| 4505 | + |
| 4506 | + return ret; |
| 4507 | + }, |
| 4508 | + |
| 4509 | + cleanData: function( elems ) { |
| 4510 | + var data, id, cache = jQuery.cache, |
| 4511 | + special = jQuery.event.special, |
| 4512 | + deleteExpando = jQuery.support.deleteExpando; |
| 4513 | + |
| 4514 | + for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) { |
| 4515 | + id = elem[ jQuery.expando ]; |
| 4516 | + |
| 4517 | + if ( id ) { |
| 4518 | + data = cache[ id ]; |
| 4519 | + |
| 4520 | + if ( data.events ) { |
| 4521 | + for ( var type in data.events ) { |
| 4522 | + if ( special[ type ] ) { |
| 4523 | + jQuery.event.remove( elem, type ); |
| 4524 | + |
| 4525 | + } else { |
| 4526 | + removeEvent( elem, type, data.handle ); |
| 4527 | + } |
| 4528 | + } |
| 4529 | + } |
| 4530 | + |
| 4531 | + if ( deleteExpando ) { |
| 4532 | + delete elem[ jQuery.expando ]; |
| 4533 | + |
| 4534 | + } else if ( elem.removeAttribute ) { |
| 4535 | + elem.removeAttribute( jQuery.expando ); |
| 4536 | + } |
| 4537 | + |
| 4538 | + delete cache[ id ]; |
| 4539 | + } |
| 4540 | + } |
| 4541 | + } |
| 4542 | +}); |
| 4543 | +// exclude the following css properties to add px |
| 4544 | +var rexclude = /z-?index|font-?weight|opacity|zoom|line-?height/i, |
| 4545 | + ralpha = /alpha\([^)]*\)/, |
| 4546 | + ropacity = /opacity=([^)]*)/, |
| 4547 | + rfloat = /float/i, |
| 4548 | + rdashAlpha = /-([a-z])/ig, |
| 4549 | + rupper = /([A-Z])/g, |
| 4550 | + rnumpx = /^-?\d+(?:px)?$/i, |
| 4551 | + rnum = /^-?\d/, |
| 4552 | + |
| 4553 | + cssShow = { position: "absolute", visibility: "hidden", display:"block" }, |
| 4554 | + cssWidth = [ "Left", "Right" ], |
| 4555 | + cssHeight = [ "Top", "Bottom" ], |
| 4556 | + |
| 4557 | + // cache check for defaultView.getComputedStyle |
| 4558 | + getComputedStyle = document.defaultView && document.defaultView.getComputedStyle, |
| 4559 | + // normalize float css property |
| 4560 | + styleFloat = jQuery.support.cssFloat ? "cssFloat" : "styleFloat", |
| 4561 | + fcamelCase = function( all, letter ) { |
| 4562 | + return letter.toUpperCase(); |
| 4563 | + }; |
| 4564 | + |
| 4565 | +jQuery.fn.css = function( name, value ) { |
| 4566 | + return access( this, name, value, true, function( elem, name, value ) { |
| 4567 | + if ( value === undefined ) { |
| 4568 | + return jQuery.curCSS( elem, name ); |
| 4569 | + } |
| 4570 | + |
| 4571 | + if ( typeof value === "number" && !rexclude.test(name) ) { |
| 4572 | + value += "px"; |
| 4573 | + } |
| 4574 | + |
| 4575 | + jQuery.style( elem, name, value ); |
| 4576 | + }); |
| 4577 | +}; |
| 4578 | + |
| 4579 | +jQuery.extend({ |
| 4580 | + style: function( elem, name, value ) { |
| 4581 | + // don't set styles on text and comment nodes |
| 4582 | + if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) { |
| 4583 | + return undefined; |
| 4584 | + } |
| 4585 | + |
| 4586 | + // ignore negative width and height values #1599 |
| 4587 | + if ( (name === "width" || name === "height") && parseFloat(value) < 0 ) { |
| 4588 | + value = undefined; |
| 4589 | + } |
| 4590 | + |
| 4591 | + var style = elem.style || elem, set = value !== undefined; |
| 4592 | + |
| 4593 | + // IE uses filters for opacity |
| 4594 | + if ( !jQuery.support.opacity && name === "opacity" ) { |
| 4595 | + if ( set ) { |
| 4596 | + // IE has trouble with opacity if it does not have layout |
| 4597 | + // Force it by setting the zoom level |
| 4598 | + style.zoom = 1; |
| 4599 | + |
| 4600 | + // Set the alpha filter to set the opacity |
| 4601 | + var opacity = parseInt( value, 10 ) + "" === "NaN" ? "" : "alpha(opacity=" + value * 100 + ")"; |
| 4602 | + var filter = style.filter || jQuery.curCSS( elem, "filter" ) || ""; |
| 4603 | + style.filter = ralpha.test(filter) ? filter.replace(ralpha, opacity) : opacity; |
| 4604 | + } |
| 4605 | + |
| 4606 | + return style.filter && style.filter.indexOf("opacity=") >= 0 ? |
| 4607 | + (parseFloat( ropacity.exec(style.filter)[1] ) / 100) + "": |
| 4608 | + ""; |
| 4609 | + } |
| 4610 | + |
| 4611 | + // Make sure we're using the right name for getting the float value |
| 4612 | + if ( rfloat.test( name ) ) { |
| 4613 | + name = styleFloat; |
| 4614 | + } |
| 4615 | + |
| 4616 | + name = name.replace(rdashAlpha, fcamelCase); |
| 4617 | + |
| 4618 | + if ( set ) { |
| 4619 | + style[ name ] = value; |
| 4620 | + } |
| 4621 | + |
| 4622 | + return style[ name ]; |
| 4623 | + }, |
| 4624 | + |
| 4625 | + css: function( elem, name, force, extra ) { |
| 4626 | + if ( name === "width" || name === "height" ) { |
| 4627 | + var val, props = cssShow, which = name === "width" ? cssWidth : cssHeight; |
| 4628 | + |
| 4629 | + function getWH() { |
| 4630 | + val = name === "width" ? elem.offsetWidth : elem.offsetHeight; |
| 4631 | + |
| 4632 | + if ( extra === "border" ) { |
| 4633 | + return; |
| 4634 | + } |
| 4635 | + |
| 4636 | + jQuery.each( which, function() { |
| 4637 | + if ( !extra ) { |
| 4638 | + val -= parseFloat(jQuery.curCSS( elem, "padding" + this, true)) || 0; |
| 4639 | + } |
| 4640 | + |
| 4641 | + if ( extra === "margin" ) { |
| 4642 | + val += parseFloat(jQuery.curCSS( elem, "margin" + this, true)) || 0; |
| 4643 | + } else { |
| 4644 | + val -= parseFloat(jQuery.curCSS( elem, "border" + this + "Width", true)) || 0; |
| 4645 | + } |
| 4646 | + }); |
| 4647 | + } |
| 4648 | + |
| 4649 | + if ( elem.offsetWidth !== 0 ) { |
| 4650 | + getWH(); |
| 4651 | + } else { |
| 4652 | + jQuery.swap( elem, props, getWH ); |
| 4653 | + } |
| 4654 | + |
| 4655 | + return Math.max(0, Math.round(val)); |
| 4656 | + } |
| 4657 | + |
| 4658 | + return jQuery.curCSS( elem, name, force ); |
| 4659 | + }, |
| 4660 | + |
| 4661 | + curCSS: function( elem, name, force ) { |
| 4662 | + var ret, style = elem.style, filter; |
| 4663 | + |
| 4664 | + // IE uses filters for opacity |
| 4665 | + if ( !jQuery.support.opacity && name === "opacity" && elem.currentStyle ) { |
| 4666 | + ret = ropacity.test(elem.currentStyle.filter || "") ? |
| 4667 | + (parseFloat(RegExp.$1) / 100) + "" : |
| 4668 | + ""; |
| 4669 | + |
| 4670 | + return ret === "" ? |
| 4671 | + "1" : |
| 4672 | + ret; |
| 4673 | + } |
| 4674 | + |
| 4675 | + // Make sure we're using the right name for getting the float value |
| 4676 | + if ( rfloat.test( name ) ) { |
| 4677 | + name = styleFloat; |
| 4678 | + } |
| 4679 | + |
| 4680 | + if ( !force && style && style[ name ] ) { |
| 4681 | + ret = style[ name ]; |
| 4682 | + |
| 4683 | + } else if ( getComputedStyle ) { |
| 4684 | + |
| 4685 | + // Only "float" is needed here |
| 4686 | + if ( rfloat.test( name ) ) { |
| 4687 | + name = "float"; |
| 4688 | + } |
| 4689 | + |
| 4690 | + name = name.replace( rupper, "-$1" ).toLowerCase(); |
| 4691 | + |
| 4692 | + var defaultView = elem.ownerDocument.defaultView; |
| 4693 | + |
| 4694 | + if ( !defaultView ) { |
| 4695 | + return null; |
| 4696 | + } |
| 4697 | + |
| 4698 | + var computedStyle = defaultView.getComputedStyle( elem, null ); |
| 4699 | + |
| 4700 | + if ( computedStyle ) { |
| 4701 | + ret = computedStyle.getPropertyValue( name ); |
| 4702 | + } |
| 4703 | + |
| 4704 | + // We should always get a number back from opacity |
| 4705 | + if ( name === "opacity" && ret === "" ) { |
| 4706 | + ret = "1"; |
| 4707 | + } |
| 4708 | + |
| 4709 | + } else if ( elem.currentStyle ) { |
| 4710 | + var camelCase = name.replace(rdashAlpha, fcamelCase); |
| 4711 | + |
| 4712 | + ret = elem.currentStyle[ name ] || elem.currentStyle[ camelCase ]; |
| 4713 | + |
| 4714 | + // From the awesome hack by Dean Edwards |
| 4715 | + // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291 |
| 4716 | + |
| 4717 | + // If we're not dealing with a regular pixel number |
| 4718 | + // but a number that has a weird ending, we need to convert it to pixels |
| 4719 | + if ( !rnumpx.test( ret ) && rnum.test( ret ) ) { |
| 4720 | + // Remember the original values |
| 4721 | + var left = style.left, rsLeft = elem.runtimeStyle.left; |
| 4722 | + |
| 4723 | + // Put in the new values to get a computed value out |
| 4724 | + elem.runtimeStyle.left = elem.currentStyle.left; |
| 4725 | + style.left = camelCase === "fontSize" ? "1em" : (ret || 0); |
| 4726 | + ret = style.pixelLeft + "px"; |
| 4727 | + |
| 4728 | + // Revert the changed values |
| 4729 | + style.left = left; |
| 4730 | + elem.runtimeStyle.left = rsLeft; |
| 4731 | + } |
| 4732 | + } |
| 4733 | + |
| 4734 | + return ret; |
| 4735 | + }, |
| 4736 | + |
| 4737 | + // A method for quickly swapping in/out CSS properties to get correct calculations |
| 4738 | + swap: function( elem, options, callback ) { |
| 4739 | + var old = {}; |
| 4740 | + |
| 4741 | + // Remember the old values, and insert the new ones |
| 4742 | + for ( var name in options ) { |
| 4743 | + old[ name ] = elem.style[ name ]; |
| 4744 | + elem.style[ name ] = options[ name ]; |
| 4745 | + } |
| 4746 | + |
| 4747 | + callback.call( elem ); |
| 4748 | + |
| 4749 | + // Revert the old values |
| 4750 | + for ( var name in options ) { |
| 4751 | + elem.style[ name ] = old[ name ]; |
| 4752 | + } |
| 4753 | + } |
| 4754 | +}); |
| 4755 | + |
| 4756 | +if ( jQuery.expr && jQuery.expr.filters ) { |
| 4757 | + jQuery.expr.filters.hidden = function( elem ) { |
| 4758 | + var width = elem.offsetWidth, height = elem.offsetHeight, |
| 4759 | + skip = elem.nodeName.toLowerCase() === "tr"; |
| 4760 | + |
| 4761 | + return width === 0 && height === 0 && !skip ? |
| 4762 | + true : |
| 4763 | + width > 0 && height > 0 && !skip ? |
| 4764 | + false : |
| 4765 | + jQuery.curCSS(elem, "display") === "none"; |
| 4766 | + }; |
| 4767 | + |
| 4768 | + jQuery.expr.filters.visible = function( elem ) { |
| 4769 | + return !jQuery.expr.filters.hidden( elem ); |
| 4770 | + }; |
| 4771 | +} |
| 4772 | +var jsc = now(), |
| 4773 | + rscript = /<script(.|\s)*?\/script>/gi, |
| 4774 | + rselectTextarea = /select|textarea/i, |
| 4775 | + rinput = /color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week/i, |
| 4776 | + jsre = /=\?(&|$)/, |
| 4777 | + rquery = /\?/, |
| 4778 | + rts = /(\?|&)_=.*?(&|$)/, |
| 4779 | + rurl = /^(\w+:)?\/\/([^\/?#]+)/, |
| 4780 | + r20 = /%20/g, |
| 4781 | + |
| 4782 | + // Keep a copy of the old load method |
| 4783 | + _load = jQuery.fn.load; |
| 4784 | + |
| 4785 | +jQuery.fn.extend({ |
| 4786 | + load: function( url, params, callback ) { |
| 4787 | + if ( typeof url !== "string" ) { |
| 4788 | + return _load.call( this, url ); |
| 4789 | + |
| 4790 | + // Don't do a request if no elements are being requested |
| 4791 | + } else if ( !this.length ) { |
| 4792 | + return this; |
| 4793 | + } |
| 4794 | + |
| 4795 | + var off = url.indexOf(" "); |
| 4796 | + if ( off >= 0 ) { |
| 4797 | + var selector = url.slice(off, url.length); |
| 4798 | + url = url.slice(0, off); |
| 4799 | + } |
| 4800 | + |
| 4801 | + // Default to a GET request |
| 4802 | + var type = "GET"; |
| 4803 | + |
| 4804 | + // If the second parameter was provided |
| 4805 | + if ( params ) { |
| 4806 | + // If it's a function |
| 4807 | + if ( jQuery.isFunction( params ) ) { |
| 4808 | + // We assume that it's the callback |
| 4809 | + callback = params; |
| 4810 | + params = null; |
| 4811 | + |
| 4812 | + // Otherwise, build a param string |
| 4813 | + } else if ( typeof params === "object" ) { |
| 4814 | + params = jQuery.param( params, jQuery.ajaxSettings.traditional ); |
| 4815 | + type = "POST"; |
| 4816 | + } |
| 4817 | + } |
| 4818 | + |
| 4819 | + var self = this; |
| 4820 | + |
| 4821 | + // Request the remote document |
| 4822 | + jQuery.ajax({ |
| 4823 | + url: url, |
| 4824 | + type: type, |
| 4825 | + dataType: "html", |
| 4826 | + data: params, |
| 4827 | + complete: function( res, status ) { |
| 4828 | + // If successful, inject the HTML into all the matched elements |
| 4829 | + if ( status === "success" || status === "notmodified" ) { |
| 4830 | + // See if a selector was specified |
| 4831 | + self.html( selector ? |
| 4832 | + // Create a dummy div to hold the results |
| 4833 | + jQuery("<div />") |
| 4834 | + // inject the contents of the document in, removing the scripts |
| 4835 | + // to avoid any 'Permission Denied' errors in IE |
| 4836 | + .append(res.responseText.replace(rscript, "")) |
| 4837 | + |
| 4838 | + // Locate the specified elements |
| 4839 | + .find(selector) : |
| 4840 | + |
| 4841 | + // If not, just inject the full result |
| 4842 | + res.responseText ); |
| 4843 | + } |
| 4844 | + |
| 4845 | + if ( callback ) { |
| 4846 | + self.each( callback, [res.responseText, status, res] ); |
| 4847 | + } |
| 4848 | + } |
| 4849 | + }); |
| 4850 | + |
| 4851 | + return this; |
| 4852 | + }, |
| 4853 | + |
| 4854 | + serialize: function() { |
| 4855 | + return jQuery.param(this.serializeArray()); |
| 4856 | + }, |
| 4857 | + serializeArray: function() { |
| 4858 | + return this.map(function() { |
| 4859 | + return this.elements ? jQuery.makeArray(this.elements) : this; |
| 4860 | + }) |
| 4861 | + .filter(function() { |
| 4862 | + return this.name && !this.disabled && |
| 4863 | + (this.checked || rselectTextarea.test(this.nodeName) || |
| 4864 | + rinput.test(this.type)); |
| 4865 | + }) |
| 4866 | + .map(function( i, elem ) { |
| 4867 | + var val = jQuery(this).val(); |
| 4868 | + |
| 4869 | + return val == null ? |
| 4870 | + null : |
| 4871 | + jQuery.isArray(val) ? |
| 4872 | + jQuery.map( val, function( val, i ) { |
| 4873 | + return { name: elem.name, value: val }; |
| 4874 | + }) : |
| 4875 | + { name: elem.name, value: val }; |
| 4876 | + }).get(); |
| 4877 | + } |
| 4878 | +}); |
| 4879 | + |
| 4880 | +// Attach a bunch of functions for handling common AJAX events |
| 4881 | +jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "), function( i, o ) { |
| 4882 | + jQuery.fn[o] = function( f ) { |
| 4883 | + return this.bind(o, f); |
| 4884 | + }; |
| 4885 | +}); |
| 4886 | + |
| 4887 | +jQuery.extend({ |
| 4888 | + |
| 4889 | + get: function( url, data, callback, type ) { |
| 4890 | + // shift arguments if data argument was omited |
| 4891 | + if ( jQuery.isFunction( data ) ) { |
| 4892 | + type = type || callback; |
| 4893 | + callback = data; |
| 4894 | + data = null; |
| 4895 | + } |
| 4896 | + |
| 4897 | + return jQuery.ajax({ |
| 4898 | + type: "GET", |
| 4899 | + url: url, |
| 4900 | + data: data, |
| 4901 | + success: callback, |
| 4902 | + dataType: type |
| 4903 | + }); |
| 4904 | + }, |
| 4905 | + |
| 4906 | + getScript: function( url, callback ) { |
| 4907 | + return jQuery.get(url, null, callback, "script"); |
| 4908 | + }, |
| 4909 | + |
| 4910 | + getJSON: function( url, data, callback ) { |
| 4911 | + return jQuery.get(url, data, callback, "json"); |
| 4912 | + }, |
| 4913 | + |
| 4914 | + post: function( url, data, callback, type ) { |
| 4915 | + // shift arguments if data argument was omited |
| 4916 | + if ( jQuery.isFunction( data ) ) { |
| 4917 | + type = type || callback; |
| 4918 | + callback = data; |
| 4919 | + data = {}; |
| 4920 | + } |
| 4921 | + |
| 4922 | + return jQuery.ajax({ |
| 4923 | + type: "POST", |
| 4924 | + url: url, |
| 4925 | + data: data, |
| 4926 | + success: callback, |
| 4927 | + dataType: type |
| 4928 | + }); |
| 4929 | + }, |
| 4930 | + |
| 4931 | + ajaxSetup: function( settings ) { |
| 4932 | + jQuery.extend( jQuery.ajaxSettings, settings ); |
| 4933 | + }, |
| 4934 | + |
| 4935 | + ajaxSettings: { |
| 4936 | + url: location.href, |
| 4937 | + global: true, |
| 4938 | + type: "GET", |
| 4939 | + contentType: "application/x-www-form-urlencoded", |
| 4940 | + processData: true, |
| 4941 | + async: true, |
| 4942 | + /* |
| 4943 | + timeout: 0, |
| 4944 | + data: null, |
| 4945 | + username: null, |
| 4946 | + password: null, |
| 4947 | + traditional: false, |
| 4948 | + */ |
| 4949 | + // Create the request object; Microsoft failed to properly |
| 4950 | + // implement the XMLHttpRequest in IE7 (can't request local files), |
| 4951 | + // so we use the ActiveXObject when it is available |
| 4952 | + // This function can be overriden by calling jQuery.ajaxSetup |
| 4953 | + xhr: window.XMLHttpRequest && (window.location.protocol !== "file:" || !window.ActiveXObject) ? |
| 4954 | + function() { |
| 4955 | + return new window.XMLHttpRequest(); |
| 4956 | + } : |
| 4957 | + function() { |
| 4958 | + try { |
| 4959 | + return new window.ActiveXObject("Microsoft.XMLHTTP"); |
| 4960 | + } catch(e) {} |
| 4961 | + }, |
| 4962 | + accepts: { |
| 4963 | + xml: "application/xml, text/xml", |
| 4964 | + html: "text/html", |
| 4965 | + script: "text/javascript, application/javascript", |
| 4966 | + json: "application/json, text/javascript", |
| 4967 | + text: "text/plain", |
| 4968 | + _default: "*/*" |
| 4969 | + } |
| 4970 | + }, |
| 4971 | + |
| 4972 | + // Last-Modified header cache for next request |
| 4973 | + lastModified: {}, |
| 4974 | + etag: {}, |
| 4975 | + |
| 4976 | + ajax: function( origSettings ) { |
| 4977 | + var s = jQuery.extend(true, {}, jQuery.ajaxSettings, origSettings); |
| 4978 | + |
| 4979 | + var jsonp, status, data, |
| 4980 | + callbackContext = origSettings && origSettings.context || s, |
| 4981 | + type = s.type.toUpperCase(); |
| 4982 | + |
| 4983 | + // convert data if not already a string |
| 4984 | + if ( s.data && s.processData && typeof s.data !== "string" ) { |
| 4985 | + s.data = jQuery.param( s.data, s.traditional ); |
| 4986 | + } |
| 4987 | + |
| 4988 | + // Handle JSONP Parameter Callbacks |
| 4989 | + if ( s.dataType === "jsonp" ) { |
| 4990 | + if ( type === "GET" ) { |
| 4991 | + if ( !jsre.test( s.url ) ) { |
| 4992 | + s.url += (rquery.test( s.url ) ? "&" : "?") + (s.jsonp || "callback") + "=?"; |
| 4993 | + } |
| 4994 | + } else if ( !s.data || !jsre.test(s.data) ) { |
| 4995 | + s.data = (s.data ? s.data + "&" : "") + (s.jsonp || "callback") + "=?"; |
| 4996 | + } |
| 4997 | + s.dataType = "json"; |
| 4998 | + } |
| 4999 | + |
| 5000 | + // Build temporary JSONP function |
| 5001 | + if ( s.dataType === "json" && (s.data && jsre.test(s.data) || jsre.test(s.url)) ) { |
| 5002 | + jsonp = s.jsonpCallback || ("jsonp" + jsc++); |
| 5003 | + |
| 5004 | + // Replace the =? sequence both in the query string and the data |
| 5005 | + if ( s.data ) { |
| 5006 | + s.data = (s.data + "").replace(jsre, "=" + jsonp + "$1"); |
| 5007 | + } |
| 5008 | + |
| 5009 | + s.url = s.url.replace(jsre, "=" + jsonp + "$1"); |
| 5010 | + |
| 5011 | + // We need to make sure |
| 5012 | + // that a JSONP style response is executed properly |
| 5013 | + s.dataType = "script"; |
| 5014 | + |
| 5015 | + // Handle JSONP-style loading |
| 5016 | + window[ jsonp ] = window[ jsonp ] || function( tmp ) { |
| 5017 | + data = tmp; |
| 5018 | + success(); |
| 5019 | + complete(); |
| 5020 | + // Garbage collect |
| 5021 | + window[ jsonp ] = undefined; |
| 5022 | + |
| 5023 | + try { |
| 5024 | + delete window[ jsonp ]; |
| 5025 | + } catch(e) {} |
| 5026 | + |
| 5027 | + if ( head ) { |
| 5028 | + head.removeChild( script ); |
| 5029 | + } |
| 5030 | + }; |
| 5031 | + } |
| 5032 | + |
| 5033 | + if ( s.dataType === "script" && s.cache === null ) { |
| 5034 | + s.cache = false; |
| 5035 | + } |
| 5036 | + |
| 5037 | + if ( s.cache === false && type === "GET" ) { |
| 5038 | + var ts = now(); |
| 5039 | + |
| 5040 | + // try replacing _= if it is there |
| 5041 | + var ret = s.url.replace(rts, "$1_=" + ts + "$2"); |
| 5042 | + |
| 5043 | + // if nothing was replaced, add timestamp to the end |
| 5044 | + s.url = ret + ((ret === s.url) ? (rquery.test(s.url) ? "&" : "?") + "_=" + ts : ""); |
| 5045 | + } |
| 5046 | + |
| 5047 | + // If data is available, append data to url for get requests |
| 5048 | + if ( s.data && type === "GET" ) { |
| 5049 | + s.url += (rquery.test(s.url) ? "&" : "?") + s.data; |
| 5050 | + } |
| 5051 | + |
| 5052 | + // Watch for a new set of requests |
| 5053 | + if ( s.global && ! jQuery.active++ ) { |
| 5054 | + jQuery.event.trigger( "ajaxStart" ); |
| 5055 | + } |
| 5056 | + |
| 5057 | + // Matches an absolute URL, and saves the domain |
| 5058 | + var parts = rurl.exec( s.url ), |
| 5059 | + remote = parts && (parts[1] && parts[1] !== location.protocol || parts[2] !== location.host); |
| 5060 | + |
| 5061 | + // If we're requesting a remote document |
| 5062 | + // and trying to load JSON or Script with a GET |
| 5063 | + if ( s.dataType === "script" && type === "GET" && remote ) { |
| 5064 | + var head = document.getElementsByTagName("head")[0] || document.documentElement; |
| 5065 | + var script = document.createElement("script"); |
| 5066 | + script.src = s.url; |
| 5067 | + if ( s.scriptCharset ) { |
| 5068 | + script.charset = s.scriptCharset; |
| 5069 | + } |
| 5070 | + |
| 5071 | + // Handle Script loading |
| 5072 | + if ( !jsonp ) { |
| 5073 | + var done = false; |
| 5074 | + |
| 5075 | + // Attach handlers for all browsers |
| 5076 | + script.onload = script.onreadystatechange = function() { |
| 5077 | + if ( !done && (!this.readyState || |
| 5078 | + this.readyState === "loaded" || this.readyState === "complete") ) { |
| 5079 | + done = true; |
| 5080 | + success(); |
| 5081 | + complete(); |
| 5082 | + |
| 5083 | + // Handle memory leak in IE |
| 5084 | + script.onload = script.onreadystatechange = null; |
| 5085 | + if ( head && script.parentNode ) { |
| 5086 | + head.removeChild( script ); |
| 5087 | + } |
| 5088 | + } |
| 5089 | + }; |
| 5090 | + } |
| 5091 | + |
| 5092 | + // Use insertBefore instead of appendChild to circumvent an IE6 bug. |
| 5093 | + // This arises when a base node is used (#2709 and #4378). |
| 5094 | + head.insertBefore( script, head.firstChild ); |
| 5095 | + |
| 5096 | + // We handle everything using the script element injection |
| 5097 | + return undefined; |
| 5098 | + } |
| 5099 | + |
| 5100 | + var requestDone = false; |
| 5101 | + |
| 5102 | + // Create the request object |
| 5103 | + var xhr = s.xhr(); |
| 5104 | + |
| 5105 | + if ( !xhr ) { |
| 5106 | + return; |
| 5107 | + } |
| 5108 | + |
| 5109 | + // Open the socket |
| 5110 | + // Passing null username, generates a login popup on Opera (#2865) |
| 5111 | + if ( s.username ) { |
| 5112 | + xhr.open(type, s.url, s.async, s.username, s.password); |
| 5113 | + } else { |
| 5114 | + xhr.open(type, s.url, s.async); |
| 5115 | + } |
| 5116 | + |
| 5117 | + // Need an extra try/catch for cross domain requests in Firefox 3 |
| 5118 | + try { |
| 5119 | + // Set the correct header, if data is being sent |
| 5120 | + if ( s.data || origSettings && origSettings.contentType ) { |
| 5121 | + xhr.setRequestHeader("Content-Type", s.contentType); |
| 5122 | + } |
| 5123 | + |
| 5124 | + // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. |
| 5125 | + if ( s.ifModified ) { |
| 5126 | + if ( jQuery.lastModified[s.url] ) { |
| 5127 | + xhr.setRequestHeader("If-Modified-Since", jQuery.lastModified[s.url]); |
| 5128 | + } |
| 5129 | + |
| 5130 | + if ( jQuery.etag[s.url] ) { |
| 5131 | + xhr.setRequestHeader("If-None-Match", jQuery.etag[s.url]); |
| 5132 | + } |
| 5133 | + } |
| 5134 | + |
| 5135 | + // Set header so the called script knows that it's an XMLHttpRequest |
| 5136 | + // Only send the header if it's not a remote XHR |
| 5137 | + if ( !remote ) { |
| 5138 | + xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest"); |
| 5139 | + } |
| 5140 | + |
| 5141 | + // Set the Accepts header for the server, depending on the dataType |
| 5142 | + xhr.setRequestHeader("Accept", s.dataType && s.accepts[ s.dataType ] ? |
| 5143 | + s.accepts[ s.dataType ] + ", */*" : |
| 5144 | + s.accepts._default ); |
| 5145 | + } catch(e) {} |
| 5146 | + |
| 5147 | + // Allow custom headers/mimetypes and early abort |
| 5148 | + if ( s.beforeSend && s.beforeSend.call(callbackContext, xhr, s) === false ) { |
| 5149 | + // Handle the global AJAX counter |
| 5150 | + if ( s.global && ! --jQuery.active ) { |
| 5151 | + jQuery.event.trigger( "ajaxStop" ); |
| 5152 | + } |
| 5153 | + |
| 5154 | + // close opended socket |
| 5155 | + xhr.abort(); |
| 5156 | + return false; |
| 5157 | + } |
| 5158 | + |
| 5159 | + if ( s.global ) { |
| 5160 | + trigger("ajaxSend", [xhr, s]); |
| 5161 | + } |
| 5162 | + |
| 5163 | + // Wait for a response to come back |
| 5164 | + var onreadystatechange = xhr.onreadystatechange = function( isTimeout ) { |
| 5165 | + // The request was aborted |
| 5166 | + if ( !xhr || xhr.readyState === 0 || isTimeout === "abort" ) { |
| 5167 | + // Opera doesn't call onreadystatechange before this point |
| 5168 | + // so we simulate the call |
| 5169 | + if ( !requestDone ) { |
| 5170 | + complete(); |
| 5171 | + } |
| 5172 | + |
| 5173 | + requestDone = true; |
| 5174 | + if ( xhr ) { |
| 5175 | + xhr.onreadystatechange = jQuery.noop; |
| 5176 | + } |
| 5177 | + |
| 5178 | + // The transfer is complete and the data is available, or the request timed out |
| 5179 | + } else if ( !requestDone && xhr && (xhr.readyState === 4 || isTimeout === "timeout") ) { |
| 5180 | + requestDone = true; |
| 5181 | + xhr.onreadystatechange = jQuery.noop; |
| 5182 | + |
| 5183 | + status = isTimeout === "timeout" ? |
| 5184 | + "timeout" : |
| 5185 | + !jQuery.httpSuccess( xhr ) ? |
| 5186 | + "error" : |
| 5187 | + s.ifModified && jQuery.httpNotModified( xhr, s.url ) ? |
| 5188 | + "notmodified" : |
| 5189 | + "success"; |
| 5190 | + |
| 5191 | + var errMsg; |
| 5192 | + |
| 5193 | + if ( status === "success" ) { |
| 5194 | + // Watch for, and catch, XML document parse errors |
| 5195 | + try { |
| 5196 | + // process the data (runs the xml through httpData regardless of callback) |
| 5197 | + data = jQuery.httpData( xhr, s.dataType, s ); |
| 5198 | + } catch(err) { |
| 5199 | + status = "parsererror"; |
| 5200 | + errMsg = err; |
| 5201 | + } |
| 5202 | + } |
| 5203 | + |
| 5204 | + // Make sure that the request was successful or notmodified |
| 5205 | + if ( status === "success" || status === "notmodified" ) { |
| 5206 | + // JSONP handles its own success callback |
| 5207 | + if ( !jsonp ) { |
| 5208 | + success(); |
| 5209 | + } |
| 5210 | + } else { |
| 5211 | + jQuery.handleError(s, xhr, status, errMsg); |
| 5212 | + } |
| 5213 | + |
| 5214 | + // Fire the complete handlers |
| 5215 | + complete(); |
| 5216 | + |
| 5217 | + if ( isTimeout === "timeout" ) { |
| 5218 | + xhr.abort(); |
| 5219 | + } |
| 5220 | + |
| 5221 | + // Stop memory leaks |
| 5222 | + if ( s.async ) { |
| 5223 | + xhr = null; |
| 5224 | + } |
| 5225 | + } |
| 5226 | + }; |
| 5227 | + |
| 5228 | + // Override the abort handler, if we can (IE doesn't allow it, but that's OK) |
| 5229 | + // Opera doesn't fire onreadystatechange at all on abort |
| 5230 | + try { |
| 5231 | + var oldAbort = xhr.abort; |
| 5232 | + xhr.abort = function() { |
| 5233 | + if ( xhr ) { |
| 5234 | + oldAbort.call( xhr ); |
| 5235 | + } |
| 5236 | + |
| 5237 | + onreadystatechange( "abort" ); |
| 5238 | + }; |
| 5239 | + } catch(e) { } |
| 5240 | + |
| 5241 | + // Timeout checker |
| 5242 | + if ( s.async && s.timeout > 0 ) { |
| 5243 | + setTimeout(function() { |
| 5244 | + // Check to see if the request is still happening |
| 5245 | + if ( xhr && !requestDone ) { |
| 5246 | + onreadystatechange( "timeout" ); |
| 5247 | + } |
| 5248 | + }, s.timeout); |
| 5249 | + } |
| 5250 | + |
| 5251 | + // Send the data |
| 5252 | + try { |
| 5253 | + xhr.send( type === "POST" || type === "PUT" || type === "DELETE" ? s.data : null ); |
| 5254 | + } catch(e) { |
| 5255 | + jQuery.handleError(s, xhr, null, e); |
| 5256 | + // Fire the complete handlers |
| 5257 | + complete(); |
| 5258 | + } |
| 5259 | + |
| 5260 | + // firefox 1.5 doesn't fire statechange for sync requests |
| 5261 | + if ( !s.async ) { |
| 5262 | + onreadystatechange(); |
| 5263 | + } |
| 5264 | + |
| 5265 | + function success() { |
| 5266 | + // If a local callback was specified, fire it and pass it the data |
| 5267 | + if ( s.success ) { |
| 5268 | + s.success.call( callbackContext, data, status, xhr ); |
| 5269 | + } |
| 5270 | + |
| 5271 | + // Fire the global callback |
| 5272 | + if ( s.global ) { |
| 5273 | + trigger( "ajaxSuccess", [xhr, s] ); |
| 5274 | + } |
| 5275 | + } |
| 5276 | + |
| 5277 | + function complete() { |
| 5278 | + // Process result |
| 5279 | + if ( s.complete ) { |
| 5280 | + s.complete.call( callbackContext, xhr, status); |
| 5281 | + } |
| 5282 | + |
| 5283 | + // The request was completed |
| 5284 | + if ( s.global ) { |
| 5285 | + trigger( "ajaxComplete", [xhr, s] ); |
| 5286 | + } |
| 5287 | + |
| 5288 | + // Handle the global AJAX counter |
| 5289 | + if ( s.global && ! --jQuery.active ) { |
| 5290 | + jQuery.event.trigger( "ajaxStop" ); |
| 5291 | + } |
| 5292 | + } |
| 5293 | + |
| 5294 | + function trigger(type, args) { |
| 5295 | + (s.context ? jQuery(s.context) : jQuery.event).trigger(type, args); |
| 5296 | + } |
| 5297 | + |
| 5298 | + // return XMLHttpRequest to allow aborting the request etc. |
| 5299 | + return xhr; |
| 5300 | + }, |
| 5301 | + |
| 5302 | + handleError: function( s, xhr, status, e ) { |
| 5303 | + // If a local callback was specified, fire it |
| 5304 | + if ( s.error ) { |
| 5305 | + s.error.call( s.context || s, xhr, status, e ); |
| 5306 | + } |
| 5307 | + |
| 5308 | + // Fire the global callback |
| 5309 | + if ( s.global ) { |
| 5310 | + (s.context ? jQuery(s.context) : jQuery.event).trigger( "ajaxError", [xhr, s, e] ); |
| 5311 | + } |
| 5312 | + }, |
| 5313 | + |
| 5314 | + // Counter for holding the number of active queries |
| 5315 | + active: 0, |
| 5316 | + |
| 5317 | + // Determines if an XMLHttpRequest was successful or not |
| 5318 | + httpSuccess: function( xhr ) { |
| 5319 | + try { |
| 5320 | + // IE error sometimes returns 1223 when it should be 204 so treat it as success, see #1450 |
| 5321 | + return !xhr.status && location.protocol === "file:" || |
| 5322 | + // Opera returns 0 when status is 304 |
| 5323 | + ( xhr.status >= 200 && xhr.status < 300 ) || |
| 5324 | + xhr.status === 304 || xhr.status === 1223 || xhr.status === 0; |
| 5325 | + } catch(e) {} |
| 5326 | + |
| 5327 | + return false; |
| 5328 | + }, |
| 5329 | + |
| 5330 | + // Determines if an XMLHttpRequest returns NotModified |
| 5331 | + httpNotModified: function( xhr, url ) { |
| 5332 | + var lastModified = xhr.getResponseHeader("Last-Modified"), |
| 5333 | + etag = xhr.getResponseHeader("Etag"); |
| 5334 | + |
| 5335 | + if ( lastModified ) { |
| 5336 | + jQuery.lastModified[url] = lastModified; |
| 5337 | + } |
| 5338 | + |
| 5339 | + if ( etag ) { |
| 5340 | + jQuery.etag[url] = etag; |
| 5341 | + } |
| 5342 | + |
| 5343 | + // Opera returns 0 when status is 304 |
| 5344 | + return xhr.status === 304 || xhr.status === 0; |
| 5345 | + }, |
| 5346 | + |
| 5347 | + httpData: function( xhr, type, s ) { |
| 5348 | + var ct = xhr.getResponseHeader("content-type") || "", |
| 5349 | + xml = type === "xml" || !type && ct.indexOf("xml") >= 0, |
| 5350 | + data = xml ? xhr.responseXML : xhr.responseText; |
| 5351 | + |
| 5352 | + if ( xml && data.documentElement.nodeName === "parsererror" ) { |
| 5353 | + jQuery.error( "parsererror" ); |
| 5354 | + } |
| 5355 | + |
| 5356 | + // Allow a pre-filtering function to sanitize the response |
| 5357 | + // s is checked to keep backwards compatibility |
| 5358 | + if ( s && s.dataFilter ) { |
| 5359 | + data = s.dataFilter( data, type ); |
| 5360 | + } |
| 5361 | + |
| 5362 | + // The filter can actually parse the response |
| 5363 | + if ( typeof data === "string" ) { |
| 5364 | + // Get the JavaScript object, if JSON is used. |
| 5365 | + if ( type === "json" || !type && ct.indexOf("json") >= 0 ) { |
| 5366 | + data = jQuery.parseJSON( data ); |
| 5367 | + |
| 5368 | + // If the type is "script", eval it in global context |
| 5369 | + } else if ( type === "script" || !type && ct.indexOf("javascript") >= 0 ) { |
| 5370 | + jQuery.globalEval( data ); |
| 5371 | + } |
| 5372 | + } |
| 5373 | + |
| 5374 | + return data; |
| 5375 | + }, |
| 5376 | + |
| 5377 | + // Serialize an array of form elements or a set of |
| 5378 | + // key/values into a query string |
| 5379 | + param: function( a, traditional ) { |
| 5380 | + var s = []; |
| 5381 | + |
| 5382 | + // Set traditional to true for jQuery <= 1.3.2 behavior. |
| 5383 | + if ( traditional === undefined ) { |
| 5384 | + traditional = jQuery.ajaxSettings.traditional; |
| 5385 | + } |
| 5386 | + |
| 5387 | + // If an array was passed in, assume that it is an array of form elements. |
| 5388 | + if ( jQuery.isArray(a) || a.jquery ) { |
| 5389 | + // Serialize the form elements |
| 5390 | + jQuery.each( a, function() { |
| 5391 | + add( this.name, this.value ); |
| 5392 | + }); |
| 5393 | + |
| 5394 | + } else { |
| 5395 | + // If traditional, encode the "old" way (the way 1.3.2 or older |
| 5396 | + // did it), otherwise encode params recursively. |
| 5397 | + for ( var prefix in a ) { |
| 5398 | + buildParams( prefix, a[prefix] ); |
| 5399 | + } |
| 5400 | + } |
| 5401 | + |
| 5402 | + // Return the resulting serialization |
| 5403 | + return s.join("&").replace(r20, "+"); |
| 5404 | + |
| 5405 | + function buildParams( prefix, obj ) { |
| 5406 | + if ( jQuery.isArray(obj) ) { |
| 5407 | + // Serialize array item. |
| 5408 | + jQuery.each( obj, function( i, v ) { |
| 5409 | + if ( traditional || /\[\]$/.test( prefix ) ) { |
| 5410 | + // Treat each array item as a scalar. |
| 5411 | + add( prefix, v ); |
| 5412 | + } else { |
| 5413 | + // If array item is non-scalar (array or object), encode its |
| 5414 | + // numeric index to resolve deserialization ambiguity issues. |
| 5415 | + // Note that rack (as of 1.0.0) can't currently deserialize |
| 5416 | + // nested arrays properly, and attempting to do so may cause |
| 5417 | + // a server error. Possible fixes are to modify rack's |
| 5418 | + // deserialization algorithm or to provide an option or flag |
| 5419 | + // to force array serialization to be shallow. |
| 5420 | + buildParams( prefix + "[" + ( typeof v === "object" || jQuery.isArray(v) ? i : "" ) + "]", v ); |
| 5421 | + } |
| 5422 | + }); |
| 5423 | + |
| 5424 | + } else if ( !traditional && obj != null && typeof obj === "object" ) { |
| 5425 | + // Serialize object item. |
| 5426 | + jQuery.each( obj, function( k, v ) { |
| 5427 | + buildParams( prefix + "[" + k + "]", v ); |
| 5428 | + }); |
| 5429 | + |
| 5430 | + } else { |
| 5431 | + // Serialize scalar item. |
| 5432 | + add( prefix, obj ); |
| 5433 | + } |
| 5434 | + } |
| 5435 | + |
| 5436 | + function add( key, value ) { |
| 5437 | + // If value is a function, invoke it and return its value |
| 5438 | + value = jQuery.isFunction(value) ? value() : value; |
| 5439 | + s[ s.length ] = encodeURIComponent(key) + "=" + encodeURIComponent(value); |
| 5440 | + } |
| 5441 | + } |
| 5442 | +}); |
| 5443 | +var elemdisplay = {}, |
| 5444 | + rfxtypes = /toggle|show|hide/, |
| 5445 | + rfxnum = /^([+-]=)?([\d+-.]+)(.*)$/, |
| 5446 | + timerId, |
| 5447 | + fxAttrs = [ |
| 5448 | + // height animations |
| 5449 | + [ "height", "marginTop", "marginBottom", "paddingTop", "paddingBottom" ], |
| 5450 | + // width animations |
| 5451 | + [ "width", "marginLeft", "marginRight", "paddingLeft", "paddingRight" ], |
| 5452 | + // opacity animations |
| 5453 | + [ "opacity" ] |
| 5454 | + ]; |
| 5455 | + |
| 5456 | +jQuery.fn.extend({ |
| 5457 | + show: function( speed, callback ) { |
| 5458 | + if ( speed || speed === 0) { |
| 5459 | + return this.animate( genFx("show", 3), speed, callback); |
| 5460 | + |
| 5461 | + } else { |
| 5462 | + for ( var i = 0, l = this.length; i < l; i++ ) { |
| 5463 | + var old = jQuery.data(this[i], "olddisplay"); |
| 5464 | + |
| 5465 | + this[i].style.display = old || ""; |
| 5466 | + |
| 5467 | + if ( jQuery.css(this[i], "display") === "none" ) { |
| 5468 | + var nodeName = this[i].nodeName, display; |
| 5469 | + |
| 5470 | + if ( elemdisplay[ nodeName ] ) { |
| 5471 | + display = elemdisplay[ nodeName ]; |
| 5472 | + |
| 5473 | + } else { |
| 5474 | + var elem = jQuery("<" + nodeName + " />").appendTo("body"); |
| 5475 | + |
| 5476 | + display = elem.css("display"); |
| 5477 | + |
| 5478 | + if ( display === "none" ) { |
| 5479 | + display = "block"; |
| 5480 | + } |
| 5481 | + |
| 5482 | + elem.remove(); |
| 5483 | + |
| 5484 | + elemdisplay[ nodeName ] = display; |
| 5485 | + } |
| 5486 | + |
| 5487 | + jQuery.data(this[i], "olddisplay", display); |
| 5488 | + } |
| 5489 | + } |
| 5490 | + |
| 5491 | + // Set the display of the elements in a second loop |
| 5492 | + // to avoid the constant reflow |
| 5493 | + for ( var j = 0, k = this.length; j < k; j++ ) { |
| 5494 | + this[j].style.display = jQuery.data(this[j], "olddisplay") || ""; |
| 5495 | + } |
| 5496 | + |
| 5497 | + return this; |
| 5498 | + } |
| 5499 | + }, |
| 5500 | + |
| 5501 | + hide: function( speed, callback ) { |
| 5502 | + if ( speed || speed === 0 ) { |
| 5503 | + return this.animate( genFx("hide", 3), speed, callback); |
| 5504 | + |
| 5505 | + } else { |
| 5506 | + for ( var i = 0, l = this.length; i < l; i++ ) { |
| 5507 | + var old = jQuery.data(this[i], "olddisplay"); |
| 5508 | + if ( !old && old !== "none" ) { |
| 5509 | + jQuery.data(this[i], "olddisplay", jQuery.css(this[i], "display")); |
| 5510 | + } |
| 5511 | + } |
| 5512 | + |
| 5513 | + // Set the display of the elements in a second loop |
| 5514 | + // to avoid the constant reflow |
| 5515 | + for ( var j = 0, k = this.length; j < k; j++ ) { |
| 5516 | + this[j].style.display = "none"; |
| 5517 | + } |
| 5518 | + |
| 5519 | + return this; |
| 5520 | + } |
| 5521 | + }, |
| 5522 | + |
| 5523 | + // Save the old toggle function |
| 5524 | + _toggle: jQuery.fn.toggle, |
| 5525 | + |
| 5526 | + toggle: function( fn, fn2 ) { |
| 5527 | + var bool = typeof fn === "boolean"; |
| 5528 | + |
| 5529 | + if ( jQuery.isFunction(fn) && jQuery.isFunction(fn2) ) { |
| 5530 | + this._toggle.apply( this, arguments ); |
| 5531 | + |
| 5532 | + } else if ( fn == null || bool ) { |
| 5533 | + this.each(function() { |
| 5534 | + var state = bool ? fn : jQuery(this).is(":hidden"); |
| 5535 | + jQuery(this)[ state ? "show" : "hide" ](); |
| 5536 | + }); |
| 5537 | + |
| 5538 | + } else { |
| 5539 | + this.animate(genFx("toggle", 3), fn, fn2); |
| 5540 | + } |
| 5541 | + |
| 5542 | + return this; |
| 5543 | + }, |
| 5544 | + |
| 5545 | + fadeTo: function( speed, to, callback ) { |
| 5546 | + return this.filter(":hidden").css("opacity", 0).show().end() |
| 5547 | + .animate({opacity: to}, speed, callback); |
| 5548 | + }, |
| 5549 | + |
| 5550 | + animate: function( prop, speed, easing, callback ) { |
| 5551 | + var optall = jQuery.speed(speed, easing, callback); |
| 5552 | + |
| 5553 | + if ( jQuery.isEmptyObject( prop ) ) { |
| 5554 | + return this.each( optall.complete ); |
| 5555 | + } |
| 5556 | + |
| 5557 | + return this[ optall.queue === false ? "each" : "queue" ](function() { |
| 5558 | + var opt = jQuery.extend({}, optall), p, |
| 5559 | + hidden = this.nodeType === 1 && jQuery(this).is(":hidden"), |
| 5560 | + self = this; |
| 5561 | + |
| 5562 | + for ( p in prop ) { |
| 5563 | + var name = p.replace(rdashAlpha, fcamelCase); |
| 5564 | + |
| 5565 | + if ( p !== name ) { |
| 5566 | + prop[ name ] = prop[ p ]; |
| 5567 | + delete prop[ p ]; |
| 5568 | + p = name; |
| 5569 | + } |
| 5570 | + |
| 5571 | + if ( prop[p] === "hide" && hidden || prop[p] === "show" && !hidden ) { |
| 5572 | + return opt.complete.call(this); |
| 5573 | + } |
| 5574 | + |
| 5575 | + if ( ( p === "height" || p === "width" ) && this.style ) { |
| 5576 | + // Store display property |
| 5577 | + opt.display = jQuery.css(this, "display"); |
| 5578 | + |
| 5579 | + // Make sure that nothing sneaks out |
| 5580 | + opt.overflow = this.style.overflow; |
| 5581 | + } |
| 5582 | + |
| 5583 | + if ( jQuery.isArray( prop[p] ) ) { |
| 5584 | + // Create (if needed) and add to specialEasing |
| 5585 | + (opt.specialEasing = opt.specialEasing || {})[p] = prop[p][1]; |
| 5586 | + prop[p] = prop[p][0]; |
| 5587 | + } |
| 5588 | + } |
| 5589 | + |
| 5590 | + if ( opt.overflow != null ) { |
| 5591 | + this.style.overflow = "hidden"; |
| 5592 | + } |
| 5593 | + |
| 5594 | + opt.curAnim = jQuery.extend({}, prop); |
| 5595 | + |
| 5596 | + jQuery.each( prop, function( name, val ) { |
| 5597 | + var e = new jQuery.fx( self, opt, name ); |
| 5598 | + |
| 5599 | + if ( rfxtypes.test(val) ) { |
| 5600 | + e[ val === "toggle" ? hidden ? "show" : "hide" : val ]( prop ); |
| 5601 | + |
| 5602 | + } else { |
| 5603 | + var parts = rfxnum.exec(val), |
| 5604 | + start = e.cur(true) || 0; |
| 5605 | + |
| 5606 | + if ( parts ) { |
| 5607 | + var end = parseFloat( parts[2] ), |
| 5608 | + unit = parts[3] || "px"; |
| 5609 | + |
| 5610 | + // We need to compute starting value |
| 5611 | + if ( unit !== "px" ) { |
| 5612 | + self.style[ name ] = (end || 1) + unit; |
| 5613 | + start = ((end || 1) / e.cur(true)) * start; |
| 5614 | + self.style[ name ] = start + unit; |
| 5615 | + } |
| 5616 | + |
| 5617 | + // If a +=/-= token was provided, we're doing a relative animation |
| 5618 | + if ( parts[1] ) { |
| 5619 | + end = ((parts[1] === "-=" ? -1 : 1) * end) + start; |
| 5620 | + } |
| 5621 | + |
| 5622 | + e.custom( start, end, unit ); |
| 5623 | + |
| 5624 | + } else { |
| 5625 | + e.custom( start, val, "" ); |
| 5626 | + } |
| 5627 | + } |
| 5628 | + }); |
| 5629 | + |
| 5630 | + // For JS strict compliance |
| 5631 | + return true; |
| 5632 | + }); |
| 5633 | + }, |
| 5634 | + |
| 5635 | + stop: function( clearQueue, gotoEnd ) { |
| 5636 | + var timers = jQuery.timers; |
| 5637 | + |
| 5638 | + if ( clearQueue ) { |
| 5639 | + this.queue([]); |
| 5640 | + } |
| 5641 | + |
| 5642 | + this.each(function() { |
| 5643 | + // go in reverse order so anything added to the queue during the loop is ignored |
| 5644 | + for ( var i = timers.length - 1; i >= 0; i-- ) { |
| 5645 | + if ( timers[i].elem === this ) { |
| 5646 | + if (gotoEnd) { |
| 5647 | + // force the next step to be the last |
| 5648 | + timers[i](true); |
| 5649 | + } |
| 5650 | + |
| 5651 | + timers.splice(i, 1); |
| 5652 | + } |
| 5653 | + } |
| 5654 | + }); |
| 5655 | + |
| 5656 | + // start the next in the queue if the last step wasn't forced |
| 5657 | + if ( !gotoEnd ) { |
| 5658 | + this.dequeue(); |
| 5659 | + } |
| 5660 | + |
| 5661 | + return this; |
| 5662 | + } |
| 5663 | + |
| 5664 | +}); |
| 5665 | + |
| 5666 | +// Generate shortcuts for custom animations |
| 5667 | +jQuery.each({ |
| 5668 | + slideDown: genFx("show", 1), |
| 5669 | + slideUp: genFx("hide", 1), |
| 5670 | + slideToggle: genFx("toggle", 1), |
| 5671 | + fadeIn: { opacity: "show" }, |
| 5672 | + fadeOut: { opacity: "hide" } |
| 5673 | +}, function( name, props ) { |
| 5674 | + jQuery.fn[ name ] = function( speed, callback ) { |
| 5675 | + return this.animate( props, speed, callback ); |
| 5676 | + }; |
| 5677 | +}); |
| 5678 | + |
| 5679 | +jQuery.extend({ |
| 5680 | + speed: function( speed, easing, fn ) { |
| 5681 | + var opt = speed && typeof speed === "object" ? speed : { |
| 5682 | + complete: fn || !fn && easing || |
| 5683 | + jQuery.isFunction( speed ) && speed, |
| 5684 | + duration: speed, |
| 5685 | + easing: fn && easing || easing && !jQuery.isFunction(easing) && easing |
| 5686 | + }; |
| 5687 | + |
| 5688 | + opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration : |
| 5689 | + jQuery.fx.speeds[opt.duration] || jQuery.fx.speeds._default; |
| 5690 | + |
| 5691 | + // Queueing |
| 5692 | + opt.old = opt.complete; |
| 5693 | + opt.complete = function() { |
| 5694 | + if ( opt.queue !== false ) { |
| 5695 | + jQuery(this).dequeue(); |
| 5696 | + } |
| 5697 | + if ( jQuery.isFunction( opt.old ) ) { |
| 5698 | + opt.old.call( this ); |
| 5699 | + } |
| 5700 | + }; |
| 5701 | + |
| 5702 | + return opt; |
| 5703 | + }, |
| 5704 | + |
| 5705 | + easing: { |
| 5706 | + linear: function( p, n, firstNum, diff ) { |
| 5707 | + return firstNum + diff * p; |
| 5708 | + }, |
| 5709 | + swing: function( p, n, firstNum, diff ) { |
| 5710 | + return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum; |
| 5711 | + } |
| 5712 | + }, |
| 5713 | + |
| 5714 | + timers: [], |
| 5715 | + |
| 5716 | + fx: function( elem, options, prop ) { |
| 5717 | + this.options = options; |
| 5718 | + this.elem = elem; |
| 5719 | + this.prop = prop; |
| 5720 | + |
| 5721 | + if ( !options.orig ) { |
| 5722 | + options.orig = {}; |
| 5723 | + } |
| 5724 | + } |
| 5725 | + |
| 5726 | +}); |
| 5727 | + |
| 5728 | +jQuery.fx.prototype = { |
| 5729 | + // Simple function for setting a style value |
| 5730 | + update: function() { |
| 5731 | + if ( this.options.step ) { |
| 5732 | + this.options.step.call( this.elem, this.now, this ); |
| 5733 | + } |
| 5734 | + |
| 5735 | + (jQuery.fx.step[this.prop] || jQuery.fx.step._default)( this ); |
| 5736 | + |
| 5737 | + // Set display property to block for height/width animations |
| 5738 | + if ( ( this.prop === "height" || this.prop === "width" ) && this.elem.style ) { |
| 5739 | + this.elem.style.display = "block"; |
| 5740 | + } |
| 5741 | + }, |
| 5742 | + |
| 5743 | + // Get the current size |
| 5744 | + cur: function( force ) { |
| 5745 | + if ( this.elem[this.prop] != null && (!this.elem.style || this.elem.style[this.prop] == null) ) { |
| 5746 | + return this.elem[ this.prop ]; |
| 5747 | + } |
| 5748 | + |
| 5749 | + var r = parseFloat(jQuery.css(this.elem, this.prop, force)); |
| 5750 | + return r && r > -10000 ? r : parseFloat(jQuery.curCSS(this.elem, this.prop)) || 0; |
| 5751 | + }, |
| 5752 | + |
| 5753 | + // Start an animation from one number to another |
| 5754 | + custom: function( from, to, unit ) { |
| 5755 | + this.startTime = now(); |
| 5756 | + this.start = from; |
| 5757 | + this.end = to; |
| 5758 | + this.unit = unit || this.unit || "px"; |
| 5759 | + this.now = this.start; |
| 5760 | + this.pos = this.state = 0; |
| 5761 | + |
| 5762 | + var self = this; |
| 5763 | + function t( gotoEnd ) { |
| 5764 | + return self.step(gotoEnd); |
| 5765 | + } |
| 5766 | + |
| 5767 | + t.elem = this.elem; |
| 5768 | + |
| 5769 | + if ( t() && jQuery.timers.push(t) && !timerId ) { |
| 5770 | + timerId = setInterval(jQuery.fx.tick, 13); |
| 5771 | + } |
| 5772 | + }, |
| 5773 | + |
| 5774 | + // Simple 'show' function |
| 5775 | + show: function() { |
| 5776 | + // Remember where we started, so that we can go back to it later |
| 5777 | + this.options.orig[this.prop] = jQuery.style( this.elem, this.prop ); |
| 5778 | + this.options.show = true; |
| 5779 | + |
| 5780 | + // Begin the animation |
| 5781 | + // Make sure that we start at a small width/height to avoid any |
| 5782 | + // flash of content |
| 5783 | + this.custom(this.prop === "width" || this.prop === "height" ? 1 : 0, this.cur()); |
| 5784 | + |
| 5785 | + // Start by showing the element |
| 5786 | + jQuery( this.elem ).show(); |
| 5787 | + }, |
| 5788 | + |
| 5789 | + // Simple 'hide' function |
| 5790 | + hide: function() { |
| 5791 | + // Remember where we started, so that we can go back to it later |
| 5792 | + this.options.orig[this.prop] = jQuery.style( this.elem, this.prop ); |
| 5793 | + this.options.hide = true; |
| 5794 | + |
| 5795 | + // Begin the animation |
| 5796 | + this.custom(this.cur(), 0); |
| 5797 | + }, |
| 5798 | + |
| 5799 | + // Each step of an animation |
| 5800 | + step: function( gotoEnd ) { |
| 5801 | + var t = now(), done = true; |
| 5802 | + |
| 5803 | + if ( gotoEnd || t >= this.options.duration + this.startTime ) { |
| 5804 | + this.now = this.end; |
| 5805 | + this.pos = this.state = 1; |
| 5806 | + this.update(); |
| 5807 | + |
| 5808 | + this.options.curAnim[ this.prop ] = true; |
| 5809 | + |
| 5810 | + for ( var i in this.options.curAnim ) { |
| 5811 | + if ( this.options.curAnim[i] !== true ) { |
| 5812 | + done = false; |
| 5813 | + } |
| 5814 | + } |
| 5815 | + |
| 5816 | + if ( done ) { |
| 5817 | + if ( this.options.display != null ) { |
| 5818 | + // Reset the overflow |
| 5819 | + this.elem.style.overflow = this.options.overflow; |
| 5820 | + |
| 5821 | + // Reset the display |
| 5822 | + var old = jQuery.data(this.elem, "olddisplay"); |
| 5823 | + this.elem.style.display = old ? old : this.options.display; |
| 5824 | + |
| 5825 | + if ( jQuery.css(this.elem, "display") === "none" ) { |
| 5826 | + this.elem.style.display = "block"; |
| 5827 | + } |
| 5828 | + } |
| 5829 | + |
| 5830 | + // Hide the element if the "hide" operation was done |
| 5831 | + if ( this.options.hide ) { |
| 5832 | + jQuery(this.elem).hide(); |
| 5833 | + } |
| 5834 | + |
| 5835 | + // Reset the properties, if the item has been hidden or shown |
| 5836 | + if ( this.options.hide || this.options.show ) { |
| 5837 | + for ( var p in this.options.curAnim ) { |
| 5838 | + jQuery.style(this.elem, p, this.options.orig[p]); |
| 5839 | + } |
| 5840 | + } |
| 5841 | + |
| 5842 | + // Execute the complete function |
| 5843 | + this.options.complete.call( this.elem ); |
| 5844 | + } |
| 5845 | + |
| 5846 | + return false; |
| 5847 | + |
| 5848 | + } else { |
| 5849 | + var n = t - this.startTime; |
| 5850 | + this.state = n / this.options.duration; |
| 5851 | + |
| 5852 | + // Perform the easing function, defaults to swing |
| 5853 | + var specialEasing = this.options.specialEasing && this.options.specialEasing[this.prop]; |
| 5854 | + var defaultEasing = this.options.easing || (jQuery.easing.swing ? "swing" : "linear"); |
| 5855 | + this.pos = jQuery.easing[specialEasing || defaultEasing](this.state, n, 0, 1, this.options.duration); |
| 5856 | + this.now = this.start + ((this.end - this.start) * this.pos); |
| 5857 | + |
| 5858 | + // Perform the next step of the animation |
| 5859 | + this.update(); |
| 5860 | + } |
| 5861 | + |
| 5862 | + return true; |
| 5863 | + } |
| 5864 | +}; |
| 5865 | + |
| 5866 | +jQuery.extend( jQuery.fx, { |
| 5867 | + tick: function() { |
| 5868 | + var timers = jQuery.timers; |
| 5869 | + |
| 5870 | + for ( var i = 0; i < timers.length; i++ ) { |
| 5871 | + if ( !timers[i]() ) { |
| 5872 | + timers.splice(i--, 1); |
| 5873 | + } |
| 5874 | + } |
| 5875 | + |
| 5876 | + if ( !timers.length ) { |
| 5877 | + jQuery.fx.stop(); |
| 5878 | + } |
| 5879 | + }, |
| 5880 | + |
| 5881 | + stop: function() { |
| 5882 | + clearInterval( timerId ); |
| 5883 | + timerId = null; |
| 5884 | + }, |
| 5885 | + |
| 5886 | + speeds: { |
| 5887 | + slow: 600, |
| 5888 | + fast: 200, |
| 5889 | + // Default speed |
| 5890 | + _default: 400 |
| 5891 | + }, |
| 5892 | + |
| 5893 | + step: { |
| 5894 | + opacity: function( fx ) { |
| 5895 | + jQuery.style(fx.elem, "opacity", fx.now); |
| 5896 | + }, |
| 5897 | + |
| 5898 | + _default: function( fx ) { |
| 5899 | + if ( fx.elem.style && fx.elem.style[ fx.prop ] != null ) { |
| 5900 | + fx.elem.style[ fx.prop ] = (fx.prop === "width" || fx.prop === "height" ? Math.max(0, fx.now) : fx.now) + fx.unit; |
| 5901 | + } else { |
| 5902 | + fx.elem[ fx.prop ] = fx.now; |
| 5903 | + } |
| 5904 | + } |
| 5905 | + } |
| 5906 | +}); |
| 5907 | + |
| 5908 | +if ( jQuery.expr && jQuery.expr.filters ) { |
| 5909 | + jQuery.expr.filters.animated = function( elem ) { |
| 5910 | + return jQuery.grep(jQuery.timers, function( fn ) { |
| 5911 | + return elem === fn.elem; |
| 5912 | + }).length; |
| 5913 | + }; |
| 5914 | +} |
| 5915 | + |
| 5916 | +function genFx( type, num ) { |
| 5917 | + var obj = {}; |
| 5918 | + |
| 5919 | + jQuery.each( fxAttrs.concat.apply([], fxAttrs.slice(0,num)), function() { |
| 5920 | + obj[ this ] = type; |
| 5921 | + }); |
| 5922 | + |
| 5923 | + return obj; |
| 5924 | +} |
| 5925 | +if ( "getBoundingClientRect" in document.documentElement ) { |
| 5926 | + jQuery.fn.offset = function( options ) { |
| 5927 | + var elem = this[0]; |
| 5928 | + |
| 5929 | + if ( options ) { |
| 5930 | + return this.each(function( i ) { |
| 5931 | + jQuery.offset.setOffset( this, options, i ); |
| 5932 | + }); |
| 5933 | + } |
| 5934 | + |
| 5935 | + if ( !elem || !elem.ownerDocument ) { |
| 5936 | + return null; |
| 5937 | + } |
| 5938 | + |
| 5939 | + if ( elem === elem.ownerDocument.body ) { |
| 5940 | + return jQuery.offset.bodyOffset( elem ); |
| 5941 | + } |
| 5942 | + |
| 5943 | + var box = elem.getBoundingClientRect(), doc = elem.ownerDocument, body = doc.body, docElem = doc.documentElement, |
| 5944 | + clientTop = docElem.clientTop || body.clientTop || 0, clientLeft = docElem.clientLeft || body.clientLeft || 0, |
| 5945 | + top = box.top + (self.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop ) - clientTop, |
| 5946 | + left = box.left + (self.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft) - clientLeft; |
| 5947 | + |
| 5948 | + return { top: top, left: left }; |
| 5949 | + }; |
| 5950 | + |
| 5951 | +} else { |
| 5952 | + jQuery.fn.offset = function( options ) { |
| 5953 | + var elem = this[0]; |
| 5954 | + |
| 5955 | + if ( options ) { |
| 5956 | + return this.each(function( i ) { |
| 5957 | + jQuery.offset.setOffset( this, options, i ); |
| 5958 | + }); |
| 5959 | + } |
| 5960 | + |
| 5961 | + if ( !elem || !elem.ownerDocument ) { |
| 5962 | + return null; |
| 5963 | + } |
| 5964 | + |
| 5965 | + if ( elem === elem.ownerDocument.body ) { |
| 5966 | + return jQuery.offset.bodyOffset( elem ); |
| 5967 | + } |
| 5968 | + |
| 5969 | + jQuery.offset.initialize(); |
| 5970 | + |
| 5971 | + var offsetParent = elem.offsetParent, prevOffsetParent = elem, |
| 5972 | + doc = elem.ownerDocument, computedStyle, docElem = doc.documentElement, |
| 5973 | + body = doc.body, defaultView = doc.defaultView, |
| 5974 | + prevComputedStyle = defaultView ? defaultView.getComputedStyle( elem, null ) : elem.currentStyle, |
| 5975 | + top = elem.offsetTop, left = elem.offsetLeft; |
| 5976 | + |
| 5977 | + while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) { |
| 5978 | + if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) { |
| 5979 | + break; |
| 5980 | + } |
| 5981 | + |
| 5982 | + computedStyle = defaultView ? defaultView.getComputedStyle(elem, null) : elem.currentStyle; |
| 5983 | + top -= elem.scrollTop; |
| 5984 | + left -= elem.scrollLeft; |
| 5985 | + |
| 5986 | + if ( elem === offsetParent ) { |
| 5987 | + top += elem.offsetTop; |
| 5988 | + left += elem.offsetLeft; |
| 5989 | + |
| 5990 | + if ( jQuery.offset.doesNotAddBorder && !(jQuery.offset.doesAddBorderForTableAndCells && /^t(able|d|h)$/i.test(elem.nodeName)) ) { |
| 5991 | + top += parseFloat( computedStyle.borderTopWidth ) || 0; |
| 5992 | + left += parseFloat( computedStyle.borderLeftWidth ) || 0; |
| 5993 | + } |
| 5994 | + |
| 5995 | + prevOffsetParent = offsetParent, offsetParent = elem.offsetParent; |
| 5996 | + } |
| 5997 | + |
| 5998 | + if ( jQuery.offset.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" ) { |
| 5999 | + top += parseFloat( computedStyle.borderTopWidth ) || 0; |
| 6000 | + left += parseFloat( computedStyle.borderLeftWidth ) || 0; |
| 6001 | + } |
| 6002 | + |
| 6003 | + prevComputedStyle = computedStyle; |
| 6004 | + } |
| 6005 | + |
| 6006 | + if ( prevComputedStyle.position === "relative" || prevComputedStyle.position === "static" ) { |
| 6007 | + top += body.offsetTop; |
| 6008 | + left += body.offsetLeft; |
| 6009 | + } |
| 6010 | + |
| 6011 | + if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) { |
| 6012 | + top += Math.max( docElem.scrollTop, body.scrollTop ); |
| 6013 | + left += Math.max( docElem.scrollLeft, body.scrollLeft ); |
| 6014 | + } |
| 6015 | + |
| 6016 | + return { top: top, left: left }; |
| 6017 | + }; |
| 6018 | +} |
| 6019 | + |
| 6020 | +jQuery.offset = { |
| 6021 | + initialize: function() { |
| 6022 | + var body = document.body, container = document.createElement("div"), innerDiv, checkDiv, table, td, bodyMarginTop = parseFloat( jQuery.curCSS(body, "marginTop", true) ) || 0, |
| 6023 | + html = "<div style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;'><div></div></div><table style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;' cellpadding='0' cellspacing='0'><tr><td></td></tr></table>"; |
| 6024 | + |
| 6025 | + jQuery.extend( container.style, { position: "absolute", top: 0, left: 0, margin: 0, border: 0, width: "1px", height: "1px", visibility: "hidden" } ); |
| 6026 | + |
| 6027 | + container.innerHTML = html; |
| 6028 | + body.insertBefore( container, body.firstChild ); |
| 6029 | + innerDiv = container.firstChild; |
| 6030 | + checkDiv = innerDiv.firstChild; |
| 6031 | + td = innerDiv.nextSibling.firstChild.firstChild; |
| 6032 | + |
| 6033 | + this.doesNotAddBorder = (checkDiv.offsetTop !== 5); |
| 6034 | + this.doesAddBorderForTableAndCells = (td.offsetTop === 5); |
| 6035 | + |
| 6036 | + checkDiv.style.position = "fixed", checkDiv.style.top = "20px"; |
| 6037 | + // safari subtracts parent border width here which is 5px |
| 6038 | + this.supportsFixedPosition = (checkDiv.offsetTop === 20 || checkDiv.offsetTop === 15); |
| 6039 | + checkDiv.style.position = checkDiv.style.top = ""; |
| 6040 | + |
| 6041 | + innerDiv.style.overflow = "hidden", innerDiv.style.position = "relative"; |
| 6042 | + this.subtractsBorderForOverflowNotVisible = (checkDiv.offsetTop === -5); |
| 6043 | + |
| 6044 | + this.doesNotIncludeMarginInBodyOffset = (body.offsetTop !== bodyMarginTop); |
| 6045 | + |
| 6046 | + body.removeChild( container ); |
| 6047 | + body = container = innerDiv = checkDiv = table = td = null; |
| 6048 | + jQuery.offset.initialize = jQuery.noop; |
| 6049 | + }, |
| 6050 | + |
| 6051 | + bodyOffset: function( body ) { |
| 6052 | + var top = body.offsetTop, left = body.offsetLeft; |
| 6053 | + |
| 6054 | + jQuery.offset.initialize(); |
| 6055 | + |
| 6056 | + if ( jQuery.offset.doesNotIncludeMarginInBodyOffset ) { |
| 6057 | + top += parseFloat( jQuery.curCSS(body, "marginTop", true) ) || 0; |
| 6058 | + left += parseFloat( jQuery.curCSS(body, "marginLeft", true) ) || 0; |
| 6059 | + } |
| 6060 | + |
| 6061 | + return { top: top, left: left }; |
| 6062 | + }, |
| 6063 | + |
| 6064 | + setOffset: function( elem, options, i ) { |
| 6065 | + // set position first, in-case top/left are set even on static elem |
| 6066 | + if ( /static/.test( jQuery.curCSS( elem, "position" ) ) ) { |
| 6067 | + elem.style.position = "relative"; |
| 6068 | + } |
| 6069 | + var curElem = jQuery( elem ), |
| 6070 | + curOffset = curElem.offset(), |
| 6071 | + curTop = parseInt( jQuery.curCSS( elem, "top", true ), 10 ) || 0, |
| 6072 | + curLeft = parseInt( jQuery.curCSS( elem, "left", true ), 10 ) || 0; |
| 6073 | + |
| 6074 | + if ( jQuery.isFunction( options ) ) { |
| 6075 | + options = options.call( elem, i, curOffset ); |
| 6076 | + } |
| 6077 | + |
| 6078 | + var props = { |
| 6079 | + top: (options.top - curOffset.top) + curTop, |
| 6080 | + left: (options.left - curOffset.left) + curLeft |
| 6081 | + }; |
| 6082 | + |
| 6083 | + if ( "using" in options ) { |
| 6084 | + options.using.call( elem, props ); |
| 6085 | + } else { |
| 6086 | + curElem.css( props ); |
| 6087 | + } |
| 6088 | + } |
| 6089 | +}; |
| 6090 | + |
| 6091 | + |
| 6092 | +jQuery.fn.extend({ |
| 6093 | + position: function() { |
| 6094 | + if ( !this[0] ) { |
| 6095 | + return null; |
| 6096 | + } |
| 6097 | + |
| 6098 | + var elem = this[0], |
| 6099 | + |
| 6100 | + // Get *real* offsetParent |
| 6101 | + offsetParent = this.offsetParent(), |
| 6102 | + |
| 6103 | + // Get correct offsets |
| 6104 | + offset = this.offset(), |
| 6105 | + parentOffset = /^body|html$/i.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset(); |
| 6106 | + |
| 6107 | + // Subtract element margins |
| 6108 | + // note: when an element has margin: auto the offsetLeft and marginLeft |
| 6109 | + // are the same in Safari causing offset.left to incorrectly be 0 |
| 6110 | + offset.top -= parseFloat( jQuery.curCSS(elem, "marginTop", true) ) || 0; |
| 6111 | + offset.left -= parseFloat( jQuery.curCSS(elem, "marginLeft", true) ) || 0; |
| 6112 | + |
| 6113 | + // Add offsetParent borders |
| 6114 | + parentOffset.top += parseFloat( jQuery.curCSS(offsetParent[0], "borderTopWidth", true) ) || 0; |
| 6115 | + parentOffset.left += parseFloat( jQuery.curCSS(offsetParent[0], "borderLeftWidth", true) ) || 0; |
| 6116 | + |
| 6117 | + // Subtract the two offsets |
| 6118 | + return { |
| 6119 | + top: offset.top - parentOffset.top, |
| 6120 | + left: offset.left - parentOffset.left |
| 6121 | + }; |
| 6122 | + }, |
| 6123 | + |
| 6124 | + offsetParent: function() { |
| 6125 | + return this.map(function() { |
| 6126 | + var offsetParent = this.offsetParent || document.body; |
| 6127 | + while ( offsetParent && (!/^body|html$/i.test(offsetParent.nodeName) && jQuery.css(offsetParent, "position") === "static") ) { |
| 6128 | + offsetParent = offsetParent.offsetParent; |
| 6129 | + } |
| 6130 | + return offsetParent; |
| 6131 | + }); |
| 6132 | + } |
| 6133 | +}); |
| 6134 | + |
| 6135 | + |
| 6136 | +// Create scrollLeft and scrollTop methods |
| 6137 | +jQuery.each( ["Left", "Top"], function( i, name ) { |
| 6138 | + var method = "scroll" + name; |
| 6139 | + |
| 6140 | + jQuery.fn[ method ] = function(val) { |
| 6141 | + var elem = this[0], win; |
| 6142 | + |
| 6143 | + if ( !elem ) { |
| 6144 | + return null; |
| 6145 | + } |
| 6146 | + |
| 6147 | + if ( val !== undefined ) { |
| 6148 | + // Set the scroll offset |
| 6149 | + return this.each(function() { |
| 6150 | + win = getWindow( this ); |
| 6151 | + |
| 6152 | + if ( win ) { |
| 6153 | + win.scrollTo( |
| 6154 | + !i ? val : jQuery(win).scrollLeft(), |
| 6155 | + i ? val : jQuery(win).scrollTop() |
| 6156 | + ); |
| 6157 | + |
| 6158 | + } else { |
| 6159 | + this[ method ] = val; |
| 6160 | + } |
| 6161 | + }); |
| 6162 | + } else { |
| 6163 | + win = getWindow( elem ); |
| 6164 | + |
| 6165 | + // Return the scroll offset |
| 6166 | + return win ? ("pageXOffset" in win) ? win[ i ? "pageYOffset" : "pageXOffset" ] : |
| 6167 | + jQuery.support.boxModel && win.document.documentElement[ method ] || |
| 6168 | + win.document.body[ method ] : |
| 6169 | + elem[ method ]; |
| 6170 | + } |
| 6171 | + }; |
| 6172 | +}); |
| 6173 | + |
| 6174 | +function getWindow( elem ) { |
| 6175 | + return ("scrollTo" in elem && elem.document) ? |
| 6176 | + elem : |
| 6177 | + elem.nodeType === 9 ? |
| 6178 | + elem.defaultView || elem.parentWindow : |
| 6179 | + false; |
| 6180 | +} |
| 6181 | +// Create innerHeight, innerWidth, outerHeight and outerWidth methods |
| 6182 | +jQuery.each([ "Height", "Width" ], function( i, name ) { |
| 6183 | + |
| 6184 | + var type = name.toLowerCase(); |
| 6185 | + |
| 6186 | + // innerHeight and innerWidth |
| 6187 | + jQuery.fn["inner" + name] = function() { |
| 6188 | + return this[0] ? |
| 6189 | + jQuery.css( this[0], type, false, "padding" ) : |
| 6190 | + null; |
| 6191 | + }; |
| 6192 | + |
| 6193 | + // outerHeight and outerWidth |
| 6194 | + jQuery.fn["outer" + name] = function( margin ) { |
| 6195 | + return this[0] ? |
| 6196 | + jQuery.css( this[0], type, false, margin ? "margin" : "border" ) : |
| 6197 | + null; |
| 6198 | + }; |
| 6199 | + |
| 6200 | + jQuery.fn[ type ] = function( size ) { |
| 6201 | + // Get window width or height |
| 6202 | + var elem = this[0]; |
| 6203 | + if ( !elem ) { |
| 6204 | + return size == null ? null : this; |
| 6205 | + } |
| 6206 | + |
| 6207 | + if ( jQuery.isFunction( size ) ) { |
| 6208 | + return this.each(function( i ) { |
| 6209 | + var self = jQuery( this ); |
| 6210 | + self[ type ]( size.call( this, i, self[ type ]() ) ); |
| 6211 | + }); |
| 6212 | + } |
| 6213 | + |
| 6214 | + return ("scrollTo" in elem && elem.document) ? // does it walk and quack like a window? |
| 6215 | + // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode |
| 6216 | + elem.document.compatMode === "CSS1Compat" && elem.document.documentElement[ "client" + name ] || |
| 6217 | + elem.document.body[ "client" + name ] : |
| 6218 | + |
| 6219 | + // Get document width or height |
| 6220 | + (elem.nodeType === 9) ? // is it a document |
| 6221 | + // Either scroll[Width/Height] or offset[Width/Height], whichever is greater |
| 6222 | + Math.max( |
| 6223 | + elem.documentElement["client" + name], |
| 6224 | + elem.body["scroll" + name], elem.documentElement["scroll" + name], |
| 6225 | + elem.body["offset" + name], elem.documentElement["offset" + name] |
| 6226 | + ) : |
| 6227 | + |
| 6228 | + // Get or set width or height on the element |
| 6229 | + size === undefined ? |
| 6230 | + // Get width or height on the element |
| 6231 | + jQuery.css( elem, type ) : |
| 6232 | + |
| 6233 | + // Set the width or height on the element (default to pixels if value is unitless) |
| 6234 | + this.css( type, typeof size === "string" ? size : size + "px" ); |
| 6235 | + }; |
| 6236 | + |
| 6237 | +}); |
| 6238 | +// Expose jQuery to the global object |
| 6239 | +window.jQuery = window.$ = jQuery; |
| 6240 | + |
| 6241 | +})(window); |
Property changes on: trunk/extensions/jQueryMsg/test/jasmine/lib/appendto-jquery-mockjax/lib/jquery-1.4.2.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 6242 | + native |
Index: trunk/extensions/jQueryMsg/test/jasmine/lib/appendto-jquery-mockjax/lib/json2.js |
— | — | @@ -0,0 +1,483 @@ |
| 2 | +/* |
| 3 | + http://www.JSON.org/json2.js |
| 4 | + 2010-03-20 |
| 5 | + |
| 6 | + Public Domain. |
| 7 | + |
| 8 | + NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. |
| 9 | + |
| 10 | + See http://www.JSON.org/js.html |
| 11 | + |
| 12 | + |
| 13 | + This code should be minified before deployment. |
| 14 | + See http://javascript.crockford.com/jsmin.html |
| 15 | + |
| 16 | + USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO |
| 17 | + NOT CONTROL. |
| 18 | + |
| 19 | + |
| 20 | + This file creates a global JSON object containing two methods: stringify |
| 21 | + and parse. |
| 22 | + |
| 23 | + JSON.stringify(value, replacer, space) |
| 24 | + value any JavaScript value, usually an object or array. |
| 25 | + |
| 26 | + replacer an optional parameter that determines how object |
| 27 | + values are stringified for objects. It can be a |
| 28 | + function or an array of strings. |
| 29 | + |
| 30 | + space an optional parameter that specifies the indentation |
| 31 | + of nested structures. If it is omitted, the text will |
| 32 | + be packed without extra whitespace. If it is a number, |
| 33 | + it will specify the number of spaces to indent at each |
| 34 | + level. If it is a string (such as '\t' or ' '), |
| 35 | + it contains the characters used to indent at each level. |
| 36 | + |
| 37 | + This method produces a JSON text from a JavaScript value. |
| 38 | + |
| 39 | + When an object value is found, if the object contains a toJSON |
| 40 | + method, its toJSON method will be called and the result will be |
| 41 | + stringified. A toJSON method does not serialize: it returns the |
| 42 | + value represented by the name/value pair that should be serialized, |
| 43 | + or undefined if nothing should be serialized. The toJSON method |
| 44 | + will be passed the key associated with the value, and this will be |
| 45 | + bound to the value |
| 46 | + |
| 47 | + For example, this would serialize Dates as ISO strings. |
| 48 | + |
| 49 | + Date.prototype.toJSON = function (key) { |
| 50 | + function f(n) { |
| 51 | + // Format integers to have at least two digits. |
| 52 | + return n < 10 ? '0' + n : n; |
| 53 | + } |
| 54 | + |
| 55 | + return this.getUTCFullYear() + '-' + |
| 56 | + f(this.getUTCMonth() + 1) + '-' + |
| 57 | + f(this.getUTCDate()) + 'T' + |
| 58 | + f(this.getUTCHours()) + ':' + |
| 59 | + f(this.getUTCMinutes()) + ':' + |
| 60 | + f(this.getUTCSeconds()) + 'Z'; |
| 61 | + }; |
| 62 | + |
| 63 | + You can provide an optional replacer method. It will be passed the |
| 64 | + key and value of each member, with this bound to the containing |
| 65 | + object. The value that is returned from your method will be |
| 66 | + serialized. If your method returns undefined, then the member will |
| 67 | + be excluded from the serialization. |
| 68 | + |
| 69 | + If the replacer parameter is an array of strings, then it will be |
| 70 | + used to select the members to be serialized. It filters the results |
| 71 | + such that only members with keys listed in the replacer array are |
| 72 | + stringified. |
| 73 | + |
| 74 | + Values that do not have JSON representations, such as undefined or |
| 75 | + functions, will not be serialized. Such values in objects will be |
| 76 | + dropped; in arrays they will be replaced with null. You can use |
| 77 | + a replacer function to replace those with JSON values. |
| 78 | + JSON.stringify(undefined) returns undefined. |
| 79 | + |
| 80 | + The optional space parameter produces a stringification of the |
| 81 | + value that is filled with line breaks and indentation to make it |
| 82 | + easier to read. |
| 83 | + |
| 84 | + If the space parameter is a non-empty string, then that string will |
| 85 | + be used for indentation. If the space parameter is a number, then |
| 86 | + the indentation will be that many spaces. |
| 87 | + |
| 88 | + Example: |
| 89 | + |
| 90 | + text = JSON.stringify(['e', {pluribus: 'unum'}]); |
| 91 | + // text is '["e",{"pluribus":"unum"}]' |
| 92 | + |
| 93 | + |
| 94 | + text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t'); |
| 95 | + // text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]' |
| 96 | + |
| 97 | + text = JSON.stringify([new Date()], function (key, value) { |
| 98 | + return this[key] instanceof Date ? |
| 99 | + 'Date(' + this[key] + ')' : value; |
| 100 | + }); |
| 101 | + // text is '["Date(---current time---)"]' |
| 102 | + |
| 103 | + |
| 104 | + JSON.parse(text, reviver) |
| 105 | + This method parses a JSON text to produce an object or array. |
| 106 | + It can throw a SyntaxError exception. |
| 107 | + |
| 108 | + The optional reviver parameter is a function that can filter and |
| 109 | + transform the results. It receives each of the keys and values, |
| 110 | + and its return value is used instead of the original value. |
| 111 | + If it returns what it received, then the structure is not modified. |
| 112 | + If it returns undefined then the member is deleted. |
| 113 | + |
| 114 | + Example: |
| 115 | + |
| 116 | + // Parse the text. Values that look like ISO date strings will |
| 117 | + // be converted to Date objects. |
| 118 | + |
| 119 | + myData = JSON.parse(text, function (key, value) { |
| 120 | + var a; |
| 121 | + if (typeof value === 'string') { |
| 122 | + a = |
| 123 | +/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value); |
| 124 | + if (a) { |
| 125 | + return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4], |
| 126 | + +a[5], +a[6])); |
| 127 | + } |
| 128 | + } |
| 129 | + return value; |
| 130 | + }); |
| 131 | + |
| 132 | + myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) { |
| 133 | + var d; |
| 134 | + if (typeof value === 'string' && |
| 135 | + value.slice(0, 5) === 'Date(' && |
| 136 | + value.slice(-1) === ')') { |
| 137 | + d = new Date(value.slice(5, -1)); |
| 138 | + if (d) { |
| 139 | + return d; |
| 140 | + } |
| 141 | + } |
| 142 | + return value; |
| 143 | + }); |
| 144 | + |
| 145 | + |
| 146 | + This is a reference implementation. You are free to copy, modify, or |
| 147 | + redistribute. |
| 148 | +*/ |
| 149 | + |
| 150 | +/*jslint evil: true, strict: false */ |
| 151 | + |
| 152 | +/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply, |
| 153 | + call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours, |
| 154 | + getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join, |
| 155 | + lastIndex, length, parse, prototype, push, replace, slice, stringify, |
| 156 | + test, toJSON, toString, valueOf |
| 157 | +*/ |
| 158 | + |
| 159 | + |
| 160 | +// Create a JSON object only if one does not already exist. We create the |
| 161 | +// methods in a closure to avoid creating global variables. |
| 162 | + |
| 163 | +if (!this.JSON) { |
| 164 | + this.JSON = {}; |
| 165 | +} |
| 166 | + |
| 167 | +(function () { |
| 168 | + |
| 169 | + function f(n) { |
| 170 | + // Format integers to have at least two digits. |
| 171 | + return n < 10 ? '0' + n : n; |
| 172 | + } |
| 173 | + |
| 174 | + if (typeof Date.prototype.toJSON !== 'function') { |
| 175 | + |
| 176 | + Date.prototype.toJSON = function (key) { |
| 177 | + |
| 178 | + return isFinite(this.valueOf()) ? |
| 179 | + this.getUTCFullYear() + '-' + |
| 180 | + f(this.getUTCMonth() + 1) + '-' + |
| 181 | + f(this.getUTCDate()) + 'T' + |
| 182 | + f(this.getUTCHours()) + ':' + |
| 183 | + f(this.getUTCMinutes()) + ':' + |
| 184 | + f(this.getUTCSeconds()) + 'Z' : null; |
| 185 | + }; |
| 186 | + |
| 187 | + String.prototype.toJSON = |
| 188 | + Number.prototype.toJSON = |
| 189 | + Boolean.prototype.toJSON = function (key) { |
| 190 | + return this.valueOf(); |
| 191 | + }; |
| 192 | + } |
| 193 | + |
| 194 | + var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, |
| 195 | + escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, |
| 196 | + gap, |
| 197 | + indent, |
| 198 | + meta = { // table of character substitutions |
| 199 | + '\b': '\\b', |
| 200 | + '\t': '\\t', |
| 201 | + '\n': '\\n', |
| 202 | + '\f': '\\f', |
| 203 | + '\r': '\\r', |
| 204 | + '"' : '\\"', |
| 205 | + '\\': '\\\\' |
| 206 | + }, |
| 207 | + rep; |
| 208 | + |
| 209 | + |
| 210 | + function quote(string) { |
| 211 | + |
| 212 | +// If the string contains no control characters, no quote characters, and no |
| 213 | +// backslash characters, then we can safely slap some quotes around it. |
| 214 | +// Otherwise we must also replace the offending characters with safe escape |
| 215 | +// sequences. |
| 216 | + |
| 217 | + escapable.lastIndex = 0; |
| 218 | + return escapable.test(string) ? |
| 219 | + '"' + string.replace(escapable, function (a) { |
| 220 | + var c = meta[a]; |
| 221 | + return typeof c === 'string' ? c : |
| 222 | + '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); |
| 223 | + }) + '"' : |
| 224 | + '"' + string + '"'; |
| 225 | + } |
| 226 | + |
| 227 | + |
| 228 | + function str(key, holder) { |
| 229 | + |
| 230 | +// Produce a string from holder[key]. |
| 231 | + |
| 232 | + var i, // The loop counter. |
| 233 | + k, // The member key. |
| 234 | + v, // The member value. |
| 235 | + length, |
| 236 | + mind = gap, |
| 237 | + partial, |
| 238 | + value = holder[key]; |
| 239 | + |
| 240 | +// If the value has a toJSON method, call it to obtain a replacement value. |
| 241 | + |
| 242 | + if (value && typeof value === 'object' && |
| 243 | + typeof value.toJSON === 'function') { |
| 244 | + value = value.toJSON(key); |
| 245 | + } |
| 246 | + |
| 247 | +// If we were called with a replacer function, then call the replacer to |
| 248 | +// obtain a replacement value. |
| 249 | + |
| 250 | + if (typeof rep === 'function') { |
| 251 | + value = rep.call(holder, key, value); |
| 252 | + } |
| 253 | + |
| 254 | +// What happens next depends on the value's type. |
| 255 | + |
| 256 | + switch (typeof value) { |
| 257 | + case 'string': |
| 258 | + return quote(value); |
| 259 | + |
| 260 | + case 'number': |
| 261 | + |
| 262 | +// JSON numbers must be finite. Encode non-finite numbers as null. |
| 263 | + |
| 264 | + return isFinite(value) ? String(value) : 'null'; |
| 265 | + |
| 266 | + case 'boolean': |
| 267 | + case 'null': |
| 268 | + |
| 269 | +// If the value is a boolean or null, convert it to a string. Note: |
| 270 | +// typeof null does not produce 'null'. The case is included here in |
| 271 | +// the remote chance that this gets fixed someday. |
| 272 | + |
| 273 | + return String(value); |
| 274 | + |
| 275 | +// If the type is 'object', we might be dealing with an object or an array or |
| 276 | +// null. |
| 277 | + |
| 278 | + case 'object': |
| 279 | + |
| 280 | +// Due to a specification blunder in ECMAScript, typeof null is 'object', |
| 281 | +// so watch out for that case. |
| 282 | + |
| 283 | + if (!value) { |
| 284 | + return 'null'; |
| 285 | + } |
| 286 | + |
| 287 | +// Make an array to hold the partial results of stringifying this object value. |
| 288 | + |
| 289 | + gap += indent; |
| 290 | + partial = []; |
| 291 | + |
| 292 | +// Is the value an array? |
| 293 | + |
| 294 | + if (Object.prototype.toString.apply(value) === '[object Array]') { |
| 295 | + |
| 296 | +// The value is an array. Stringify every element. Use null as a placeholder |
| 297 | +// for non-JSON values. |
| 298 | + |
| 299 | + length = value.length; |
| 300 | + for (i = 0; i < length; i += 1) { |
| 301 | + partial[i] = str(i, value) || 'null'; |
| 302 | + } |
| 303 | + |
| 304 | +// Join all of the elements together, separated with commas, and wrap them in |
| 305 | +// brackets. |
| 306 | + |
| 307 | + v = partial.length === 0 ? '[]' : |
| 308 | + gap ? '[\n' + gap + |
| 309 | + partial.join(',\n' + gap) + '\n' + |
| 310 | + mind + ']' : |
| 311 | + '[' + partial.join(',') + ']'; |
| 312 | + gap = mind; |
| 313 | + return v; |
| 314 | + } |
| 315 | + |
| 316 | +// If the replacer is an array, use it to select the members to be stringified. |
| 317 | + |
| 318 | + if (rep && typeof rep === 'object') { |
| 319 | + length = rep.length; |
| 320 | + for (i = 0; i < length; i += 1) { |
| 321 | + k = rep[i]; |
| 322 | + if (typeof k === 'string') { |
| 323 | + v = str(k, value); |
| 324 | + if (v) { |
| 325 | + partial.push(quote(k) + (gap ? ': ' : ':') + v); |
| 326 | + } |
| 327 | + } |
| 328 | + } |
| 329 | + } else { |
| 330 | + |
| 331 | +// Otherwise, iterate through all of the keys in the object. |
| 332 | + |
| 333 | + for (k in value) { |
| 334 | + if (Object.hasOwnProperty.call(value, k)) { |
| 335 | + v = str(k, value); |
| 336 | + if (v) { |
| 337 | + partial.push(quote(k) + (gap ? ': ' : ':') + v); |
| 338 | + } |
| 339 | + } |
| 340 | + } |
| 341 | + } |
| 342 | + |
| 343 | +// Join all of the member texts together, separated with commas, |
| 344 | +// and wrap them in braces. |
| 345 | + |
| 346 | + v = partial.length === 0 ? '{}' : |
| 347 | + gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' + |
| 348 | + mind + '}' : '{' + partial.join(',') + '}'; |
| 349 | + gap = mind; |
| 350 | + return v; |
| 351 | + } |
| 352 | + } |
| 353 | + |
| 354 | +// If the JSON object does not yet have a stringify method, give it one. |
| 355 | + |
| 356 | + if (typeof JSON.stringify !== 'function') { |
| 357 | + JSON.stringify = function (value, replacer, space) { |
| 358 | + |
| 359 | +// The stringify method takes a value and an optional replacer, and an optional |
| 360 | +// space parameter, and returns a JSON text. The replacer can be a function |
| 361 | +// that can replace values, or an array of strings that will select the keys. |
| 362 | +// A default replacer method can be provided. Use of the space parameter can |
| 363 | +// produce text that is more easily readable. |
| 364 | + |
| 365 | + var i; |
| 366 | + gap = ''; |
| 367 | + indent = ''; |
| 368 | + |
| 369 | +// If the space parameter is a number, make an indent string containing that |
| 370 | +// many spaces. |
| 371 | + |
| 372 | + if (typeof space === 'number') { |
| 373 | + for (i = 0; i < space; i += 1) { |
| 374 | + indent += ' '; |
| 375 | + } |
| 376 | + |
| 377 | +// If the space parameter is a string, it will be used as the indent string. |
| 378 | + |
| 379 | + } else if (typeof space === 'string') { |
| 380 | + indent = space; |
| 381 | + } |
| 382 | + |
| 383 | +// If there is a replacer, it must be a function or an array. |
| 384 | +// Otherwise, throw an error. |
| 385 | + |
| 386 | + rep = replacer; |
| 387 | + if (replacer && typeof replacer !== 'function' && |
| 388 | + (typeof replacer !== 'object' || |
| 389 | + typeof replacer.length !== 'number')) { |
| 390 | + throw new Error('JSON.stringify'); |
| 391 | + } |
| 392 | + |
| 393 | +// Make a fake root object containing our value under the key of ''. |
| 394 | +// Return the result of stringifying the value. |
| 395 | + |
| 396 | + return str('', {'': value}); |
| 397 | + }; |
| 398 | + } |
| 399 | + |
| 400 | + |
| 401 | +// If the JSON object does not yet have a parse method, give it one. |
| 402 | + |
| 403 | + if (typeof JSON.parse !== 'function') { |
| 404 | + JSON.parse = function (text, reviver) { |
| 405 | + |
| 406 | +// The parse method takes a text and an optional reviver function, and returns |
| 407 | +// a JavaScript value if the text is a valid JSON text. |
| 408 | + |
| 409 | + var j; |
| 410 | + |
| 411 | + function walk(holder, key) { |
| 412 | + |
| 413 | +// The walk method is used to recursively walk the resulting structure so |
| 414 | +// that modifications can be made. |
| 415 | + |
| 416 | + var k, v, value = holder[key]; |
| 417 | + if (value && typeof value === 'object') { |
| 418 | + for (k in value) { |
| 419 | + if (Object.hasOwnProperty.call(value, k)) { |
| 420 | + v = walk(value, k); |
| 421 | + if (v !== undefined) { |
| 422 | + value[k] = v; |
| 423 | + } else { |
| 424 | + delete value[k]; |
| 425 | + } |
| 426 | + } |
| 427 | + } |
| 428 | + } |
| 429 | + return reviver.call(holder, key, value); |
| 430 | + } |
| 431 | + |
| 432 | + |
| 433 | +// Parsing happens in four stages. In the first stage, we replace certain |
| 434 | +// Unicode characters with escape sequences. JavaScript handles many characters |
| 435 | +// incorrectly, either silently deleting them, or treating them as line endings. |
| 436 | + |
| 437 | + text = String(text); |
| 438 | + cx.lastIndex = 0; |
| 439 | + if (cx.test(text)) { |
| 440 | + text = text.replace(cx, function (a) { |
| 441 | + return '\\u' + |
| 442 | + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); |
| 443 | + }); |
| 444 | + } |
| 445 | + |
| 446 | +// In the second stage, we run the text against regular expressions that look |
| 447 | +// for non-JSON patterns. We are especially concerned with '()' and 'new' |
| 448 | +// because they can cause invocation, and '=' because it can cause mutation. |
| 449 | +// But just to be safe, we want to reject all unexpected forms. |
| 450 | + |
| 451 | +// We split the second stage into 4 regexp operations in order to work around |
| 452 | +// crippling inefficiencies in IE's and Safari's regexp engines. First we |
| 453 | +// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we |
| 454 | +// replace all simple value tokens with ']' characters. Third, we delete all |
| 455 | +// open brackets that follow a colon or comma or that begin the text. Finally, |
| 456 | +// we look to see that the remaining characters are only whitespace or ']' or |
| 457 | +// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval. |
| 458 | + |
| 459 | + if (/^[\],:{}\s]*$/. |
| 460 | +test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@'). |
| 461 | +replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']'). |
| 462 | +replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) { |
| 463 | + |
| 464 | +// In the third stage we use the eval function to compile the text into a |
| 465 | +// JavaScript structure. The '{' operator is subject to a syntactic ambiguity |
| 466 | +// in JavaScript: it can begin a block or an object literal. We wrap the text |
| 467 | +// in parens to eliminate the ambiguity. |
| 468 | + |
| 469 | + j = eval('(' + text + ')'); |
| 470 | + |
| 471 | +// In the optional fourth stage, we recursively walk the new structure, passing |
| 472 | +// each name/value pair to a reviver function for possible transformation. |
| 473 | + |
| 474 | + return typeof reviver === 'function' ? |
| 475 | + walk({'': j}, '') : j; |
| 476 | + } |
| 477 | + |
| 478 | +// If the text is not JSON parseable, then a SyntaxError is thrown. |
| 479 | + |
| 480 | + throw new SyntaxError('JSON.parse'); |
| 481 | + }; |
| 482 | + } |
| 483 | +}()); |
| 484 | + |
Property changes on: trunk/extensions/jQueryMsg/test/jasmine/lib/appendto-jquery-mockjax/lib/json2.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 485 | + native |
Index: trunk/extensions/jQueryMsg/jQueryMsg.js |
— | — | @@ -0,0 +1,8 @@ |
| 2 | + |
| 3 | +jQuery( document ).ready( function() { |
| 4 | + // add "magic" to Language template parser for keywords |
| 5 | + var options = { magic: { 'SITENAME' : wgSiteName } }; |
| 6 | + |
| 7 | + window.gM = mediaWiki.language.getMessageFunction( options ); |
| 8 | + $j.fn.msg = mediaWiki.language.getJqueryMessagePlugin( options ); |
| 9 | +} ); |
Property changes on: trunk/extensions/jQueryMsg/jQueryMsg.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 10 | + native |
Index: trunk/extensions/jQueryMsg/jQueryMsg.i18n.php |
— | — | @@ -0,0 +1,16 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Internationalisation file for extension EditSectionClearerLink. |
| 5 | + * |
| 6 | + * @file |
| 7 | + * @ingroup Extensions |
| 8 | + */ |
| 9 | + |
| 10 | +$messages = array(); |
| 11 | + |
| 12 | +/** English |
| 13 | + * @author Ian Baker |
| 14 | + */ |
| 15 | +$messages['en'] = array( |
| 16 | + 'jquerymsg-desc' => 'Provides a jQuery method for loading and parsing localization strings', |
| 17 | +); |
Property changes on: trunk/extensions/jQueryMsg/jQueryMsg.i18n.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 18 | + native |
Index: trunk/extensions/jQueryMsg/resources/mediawiki.language.parser.peg |
— | — | @@ -0,0 +1,76 @@ |
| 2 | +/* PEG grammar for a subset of wikitext, useful in the MediaWiki frontend */ |
| 3 | + |
| 4 | +start |
| 5 | + = e:expression* { return e.length > 1 ? [ "CONCAT" ].concat(e) : e[0]; } |
| 6 | + |
| 7 | +expression |
| 8 | + = template |
| 9 | + / link |
| 10 | + / extlink |
| 11 | + / replacement |
| 12 | + / literal |
| 13 | + |
| 14 | +paramExpression |
| 15 | + = template |
| 16 | + / link |
| 17 | + / extlink |
| 18 | + / replacement |
| 19 | + / literalWithoutBar |
| 20 | + |
| 21 | +template |
| 22 | + = "{{" t:templateContents "}}" { return t; } |
| 23 | + |
| 24 | +templateContents |
| 25 | + = twr:templateWithReplacement p:templateParam* { return twr.concat(p) } |
| 26 | + / t:templateName p:templateParam* { return p.length ? [ t, p ] : [ t ] } |
| 27 | + |
| 28 | +templateWithReplacement |
| 29 | + = t:templateName ":" r:replacement { return [ t, r ] } |
| 30 | + |
| 31 | +templateParam |
| 32 | + = "|" e:paramExpression* { return e.length > 1 ? [ "CONCAT" ].concat(e) : e[0]; } |
| 33 | + |
| 34 | +templateName |
| 35 | + = tn:[A-Za-z_]+ { return tn.join('').toUpperCase() } |
| 36 | + |
| 37 | +link |
| 38 | + = "[[" w:expression "]]" { return [ 'WLINK', w ]; } |
| 39 | + |
| 40 | +extlink |
| 41 | + = "[" url:url whitespace text:expression "]" { return [ 'LINK', url, text ] } |
| 42 | + |
| 43 | +url |
| 44 | + = url:[^ ]+ { return url.join(''); } |
| 45 | + |
| 46 | +whitespace |
| 47 | + = [ ]+ |
| 48 | + |
| 49 | +replacement |
| 50 | + = '$' digits:digits { return [ 'REPLACE', parseInt( digits, 10 ) - 1 ] } |
| 51 | + |
| 52 | +digits |
| 53 | + = [0-9]+ |
| 54 | + |
| 55 | +literal |
| 56 | + = lit:escapedOrRegularLiteral+ { return lit.join(''); } |
| 57 | + |
| 58 | +literalWithoutBar |
| 59 | + = lit:escapedOrLiteralWithoutBar+ { return lit.join(''); } |
| 60 | + |
| 61 | +escapedOrRegularLiteral |
| 62 | + = escapedLiteral |
| 63 | + / regularLiteral |
| 64 | + |
| 65 | +escapedOrLiteralWithoutBar |
| 66 | + = escapedLiteral |
| 67 | + / regularLiteralWithoutBar |
| 68 | + |
| 69 | +escapedLiteral |
| 70 | + = "\\" escaped:. { return escaped; } |
| 71 | + |
| 72 | +regularLiteral |
| 73 | + = [^{}\[\]$\\] |
| 74 | + |
| 75 | +regularLiteralWithoutBar |
| 76 | + = [^{}\[\]$\\|] |
| 77 | + |
Index: trunk/extensions/jQueryMsg/resources/mediawiki.language.parser.js |
— | — | @@ -0,0 +1,615 @@ |
| 2 | +/** |
| 3 | + * Experimental advanced wikitext parser-emitter. |
| 4 | + * See: http://www.mediawiki.org/wiki/Extension:UploadWizard/MessageParser for docs |
| 5 | + * |
| 6 | + * @author neilk@wikimedia.org |
| 7 | + */ |
| 8 | + |
| 9 | +( function( mw, $j ) { |
| 10 | + |
| 11 | + /** |
| 12 | + * Helper for functions that want to accept variadic arguments after a certain argument offset, to have it |
| 13 | + * be equivalent to an array. |
| 14 | + * |
| 15 | + * In other words: |
| 16 | + * somefunction(a, b, c, d) |
| 17 | + * is equivalent to |
| 18 | + * somefunction(a, [b, c, d]) |
| 19 | + * |
| 20 | + * @param {Integer} first offset where one finds the variadic args |
| 21 | + * @param {Array} all arguments from caller |
| 22 | + * @return {Array} array of arguments desired, whether were variadic or not |
| 23 | + */ |
| 24 | + function getVariadicArgs( args, offset ) { |
| 25 | + return $j.isArray( args[offset] ) ? args[offset] : $j.makeArray( args ).slice( offset ); |
| 26 | + } |
| 27 | + |
| 28 | + /** |
| 29 | + * Class method. |
| 30 | + * Returns a function suitable for use as a global, to construct strings from the message key (and optional replacements). |
| 31 | + * e.g. |
| 32 | + * window.gM = mediaWiki.parser.getMessageFunction( options ); |
| 33 | + * $j( 'p#headline' ).html( gM( 'hello-user', username ) ); |
| 34 | + * |
| 35 | + * Like the old gM() function this returns only strings, so it destroys any bindings. If you want to preserve bindings use the |
| 36 | + * jQuery plugin version instead. This is only included for backwards compatibility with gM(). |
| 37 | + * |
| 38 | + * @param {Array} parser options |
| 39 | + * @return {Function} function suitable for assigning to window.gM |
| 40 | + */ |
| 41 | + mw.language.getMessageFunction = function( options ) { |
| 42 | + var parser = new mw.language.parser( options ); |
| 43 | + /** |
| 44 | + * Note replacements are gleaned from 2nd parameter, or variadic args starting with 2nd parameter. |
| 45 | + * @param {String} message key |
| 46 | + * @param {Array} optional replacements (can also specify variadically) |
| 47 | + * @return {String} rendered HTML as string |
| 48 | + */ |
| 49 | + return function( key /* , replacements */ ) { |
| 50 | + return parser.parse( key, getVariadicArgs( arguments, 1 ) ).html(); |
| 51 | + }; |
| 52 | + }; |
| 53 | + |
| 54 | + /** |
| 55 | + * Class method. |
| 56 | + * Returns a jQuery plugin which parses the message in the message key, doing replacements optionally, and appends the nodes to |
| 57 | + * the current selector. Bindings to passed-in jquery elements are preserved. Functions become click handlers for [$1 linktext] links. |
| 58 | + * e.g. |
| 59 | + * $j.fn.msg = mediaWiki.parser.getJqueryPlugin( options ); |
| 60 | + * var userlink = $j( '<a>' ).click( function() { alert( "hello!!") } ); |
| 61 | + * $j( 'p#headline' ).msg( 'hello-user', userlink ); |
| 62 | + * |
| 63 | + * @param {Array} parser options |
| 64 | + * @return {Function} function suitable for assigning to jQuery plugin, such as $j.fn.msg |
| 65 | + */ |
| 66 | + mw.language.getJqueryMessagePlugin = function( options ) { |
| 67 | + var parser = new mw.language.parser( options ); |
| 68 | + /** |
| 69 | + * Note replacements are gleaned from 2nd parameter, or variadic args starting with 2nd parameter. |
| 70 | + * We append to 'this', which in a jQuery plugin context will be the selected elements. |
| 71 | + * @param {String} message key |
| 72 | + * @param {Array} optional replacements (can also specify variadically) |
| 73 | + * @return {jQuery} this |
| 74 | + */ |
| 75 | + return function( key /* , replacements */ ) { |
| 76 | + var $target = this.empty(); |
| 77 | + $j.each( parser.parse( key, getVariadicArgs( arguments, 1 ) ).contents(), function( i, node ) { |
| 78 | + $target.append( node ); |
| 79 | + } ); |
| 80 | + return $target; |
| 81 | + }; |
| 82 | + }; |
| 83 | + |
| 84 | + |
| 85 | + |
| 86 | + var parserDefaults = { |
| 87 | + 'magic' : {}, |
| 88 | + 'messages' : mw.messages, |
| 89 | + 'language' : mw.language |
| 90 | + }; |
| 91 | + |
| 92 | + /** |
| 93 | + * The parser itself. |
| 94 | + * Describes an object, whose primary duty is to .parse() message keys. |
| 95 | + * @param {Array} options |
| 96 | + */ |
| 97 | + mw.language.parser = function( options ) { |
| 98 | + this.settings = $j.extend( {}, parserDefaults, options ); |
| 99 | + this.emitter = new mw.language.htmlEmitter( this.settings.language, this.settings.magic ); |
| 100 | + }; |
| 101 | + |
| 102 | + mw.language.parser.prototype = { |
| 103 | + |
| 104 | + // cache, map of mediaWiki message key to the AST of the message. In most cases, the message is a string so this is identical. |
| 105 | + // (This is why we would like to move this functionality server-side). |
| 106 | + astCache: {}, |
| 107 | + |
| 108 | + /** |
| 109 | + * Where the magic happens. |
| 110 | + * Parses a message from the key, and swaps in replacements as necessary, wraps in jQuery |
| 111 | + * @param {String} message key |
| 112 | + * @param {Array} replacements for $1, $2... $n |
| 113 | + * @return {jQuery} |
| 114 | + */ |
| 115 | + parse: function( key, replacements ) { |
| 116 | + return this.emitter.emit( this.getAst( key ), replacements ); |
| 117 | + }, |
| 118 | + |
| 119 | + /** |
| 120 | + * Fetch the message string associated with a key, return parsed structure. Memoized. |
| 121 | + * Note that we pass '[' + key + ']' back for a missing message here. |
| 122 | + * @param {String} key |
| 123 | + * @return {String|Array} string of '[key]' if message missing, simple string if possible, array of arrays if needs parsing |
| 124 | + */ |
| 125 | + getAst: function( key ) { |
| 126 | + if ( typeof this.astCache[ key ] === 'undefined' ) { |
| 127 | + var wikiText = this.settings.messages.get( key ); |
| 128 | + if ( typeof wikiText !== 'string' ) { |
| 129 | + wikiText = "\\[" + key + "\\]"; |
| 130 | + } |
| 131 | + this.astCache[ key ] = this.wikiTextToAst( wikiText ); |
| 132 | + } |
| 133 | + return this.astCache[ key ]; |
| 134 | + }, |
| 135 | + |
| 136 | + /* |
| 137 | + * Parses the input wikiText into an abstract syntax tree, essentially an s-expression. |
| 138 | + * |
| 139 | + * CAVEAT: This does not parse all wikitext. It could be more efficient, but it's pretty good already. |
| 140 | + * n.b. We want to move this functionality to the server. Nothing here is required to be on the client. |
| 141 | + * |
| 142 | + * @param {String} message string wikitext |
| 143 | + * @throws Error |
| 144 | + * @return {Mixed} abstract syntax tree |
| 145 | + */ |
| 146 | + wikiTextToAst: function( input ) { |
| 147 | + |
| 148 | + // Indicates current position in input as we parse through it. |
| 149 | + // Shared among all parsing functions below. |
| 150 | + var pos = 0; |
| 151 | + |
| 152 | + // ========================================================= |
| 153 | + // parsing combinators - could be a library on its own |
| 154 | + // ========================================================= |
| 155 | + |
| 156 | + |
| 157 | + // Try parsers until one works, if none work return null |
| 158 | + function choice( ps ) { |
| 159 | + return function() { |
| 160 | + for ( var i = 0; i < ps.length; i++ ) { |
| 161 | + var result = ps[i](); |
| 162 | + if ( result !== null ) { |
| 163 | + return result; |
| 164 | + } |
| 165 | + } |
| 166 | + return null; |
| 167 | + }; |
| 168 | + } |
| 169 | + |
| 170 | + // try several ps in a row, all must succeed or return null |
| 171 | + // this is the only eager one |
| 172 | + function sequence( ps ) { |
| 173 | + var originalPos = pos; |
| 174 | + var result = []; |
| 175 | + for ( var i = 0; i < ps.length; i++ ) { |
| 176 | + var res = ps[i](); |
| 177 | + if ( res === null ) { |
| 178 | + pos = originalPos; |
| 179 | + return null; |
| 180 | + } |
| 181 | + result.push( res ); |
| 182 | + } |
| 183 | + return result; |
| 184 | + } |
| 185 | + |
| 186 | + // run the same parser over and over until it fails. |
| 187 | + // must succeed a minimum of n times or return null |
| 188 | + function nOrMore( n, p ) { |
| 189 | + return function() { |
| 190 | + var originalPos = pos; |
| 191 | + var result = []; |
| 192 | + var parsed = p(); |
| 193 | + while ( parsed !== null ) { |
| 194 | + result.push( parsed ); |
| 195 | + parsed = p(); |
| 196 | + } |
| 197 | + if ( result.length < n ) { |
| 198 | + pos = originalPos; |
| 199 | + return null; |
| 200 | + } |
| 201 | + return result; |
| 202 | + }; |
| 203 | + } |
| 204 | + |
| 205 | + // There is a general pattern -- parse a thing, if that worked, apply transform, otherwise return null. |
| 206 | + // But using this as a combinator seems to cause problems when combined with nOrMore(). |
| 207 | + // May be some scoping issue |
| 208 | + function transform( p, fn ) { |
| 209 | + return function() { |
| 210 | + var result = p(); |
| 211 | + return result === null ? null : fn( result ); |
| 212 | + }; |
| 213 | + } |
| 214 | + |
| 215 | + // Helpers -- just make ps out of simpler JS builtin types |
| 216 | + |
| 217 | + function makeStringParser( s ) { |
| 218 | + var len = s.length; |
| 219 | + return function() { |
| 220 | + var result = null; |
| 221 | + if ( input.substr( pos, len ) === s ) { |
| 222 | + result = s; |
| 223 | + pos += len; |
| 224 | + } |
| 225 | + return result; |
| 226 | + }; |
| 227 | + } |
| 228 | + |
| 229 | + function makeRegexParser( regex ) { |
| 230 | + return function() { |
| 231 | + var matches = input.substr( pos ).match( regex ); |
| 232 | + if ( matches === null ) { |
| 233 | + return null; |
| 234 | + } |
| 235 | + pos += matches[0].length; |
| 236 | + return matches[0]; |
| 237 | + }; |
| 238 | + } |
| 239 | + |
| 240 | + |
| 241 | + /** |
| 242 | + * =================================================================== |
| 243 | + * General patterns above this line -- wikitext specific parsers below |
| 244 | + * =================================================================== |
| 245 | + */ |
| 246 | + |
| 247 | + // Parsing functions follow. All parsing functions work like this: |
| 248 | + // They don't accept any arguments. |
| 249 | + // Instead, they just operate non destructively on the string 'input' |
| 250 | + // As they can consume parts of the string, they advance the shared variable pos, |
| 251 | + // and return tokens (or whatever else they want to return). |
| 252 | + |
| 253 | + // some things are defined as closures and other things as ordinary functions |
| 254 | + // converting everything to a closure makes it a lot harder to debug... errors pop up |
| 255 | + // but some debuggers can't tell you exactly where they come from. Also the mutually |
| 256 | + // recursive functions seem not to work in all browsers then. (Tested IE6-7, Opera, Safari, FF) |
| 257 | + // This may be because, to save code, memoization was removed |
| 258 | + |
| 259 | + |
| 260 | + var regularLiteral = makeRegexParser( /^[^{}[\]$\\]/ ); |
| 261 | + var regularLiteralWithoutBar = makeRegexParser(/^[^{}[\]$\\|]/); |
| 262 | + var regularLiteralWithoutSpace = makeRegexParser(/^[^{}[\]$\s]/); |
| 263 | + |
| 264 | + var backslash = makeStringParser( "\\" ); |
| 265 | + var anyCharacter = makeRegexParser( /^./ ); |
| 266 | + |
| 267 | + function escapedLiteral() { |
| 268 | + var result = sequence( [ |
| 269 | + backslash, |
| 270 | + anyCharacter |
| 271 | + ] ); |
| 272 | + return result === null ? null : result[1]; |
| 273 | + } |
| 274 | + |
| 275 | + var escapedOrLiteralWithoutSpace = choice( [ |
| 276 | + escapedLiteral, |
| 277 | + regularLiteralWithoutSpace |
| 278 | + ] ); |
| 279 | + |
| 280 | + var escapedOrLiteralWithoutBar = choice( [ |
| 281 | + escapedLiteral, |
| 282 | + regularLiteralWithoutBar |
| 283 | + ] ); |
| 284 | + |
| 285 | + var escapedOrRegularLiteral = choice( [ |
| 286 | + escapedLiteral, |
| 287 | + regularLiteral |
| 288 | + ] ); |
| 289 | + |
| 290 | + // Used to define "literals" without spaces, in space-delimited situations |
| 291 | + function literalWithoutSpace() { |
| 292 | + var result = nOrMore( 1, escapedOrLiteralWithoutSpace )(); |
| 293 | + return result === null ? null : result.join(''); |
| 294 | + } |
| 295 | + |
| 296 | + // Used to define "literals" within template parameters. The pipe character is the parameter delimeter, so by default |
| 297 | + // it is not a literal in the parameter |
| 298 | + function literalWithoutBar() { |
| 299 | + var result = nOrMore( 1, escapedOrLiteralWithoutBar )(); |
| 300 | + return result === null ? null : result.join(''); |
| 301 | + } |
| 302 | + |
| 303 | + function literal() { |
| 304 | + var result = nOrMore( 1, escapedOrRegularLiteral )(); |
| 305 | + return result === null ? null : result.join(''); |
| 306 | + } |
| 307 | + |
| 308 | + var whitespace = makeRegexParser( /^\s+/ ); |
| 309 | + var dollar = makeStringParser( '$' ); |
| 310 | + var digits = makeRegexParser( /^\d+/ ); |
| 311 | + |
| 312 | + function replacement() { |
| 313 | + var result = sequence( [ |
| 314 | + dollar, |
| 315 | + digits |
| 316 | + ] ); |
| 317 | + if ( result === null ) { |
| 318 | + return null; |
| 319 | + } |
| 320 | + return [ 'REPLACE', parseInt( result[1], 10 ) - 1 ]; |
| 321 | + } |
| 322 | + |
| 323 | + |
| 324 | + var openExtlink = makeStringParser( '[' ); |
| 325 | + var closeExtlink = makeStringParser( ']' ); |
| 326 | + |
| 327 | + // this extlink MUST have inner text, e.g. [foo] not allowed; [foo bar] is allowed |
| 328 | + function extlink() { |
| 329 | + var result = null; |
| 330 | + var parsedResult = sequence( [ |
| 331 | + openExtlink, |
| 332 | + nonWhitespaceExpression, |
| 333 | + whitespace, |
| 334 | + expression, |
| 335 | + closeExtlink |
| 336 | + ] ); |
| 337 | + if ( parsedResult !== null ) { |
| 338 | + result = [ 'LINK', parsedResult[1], parsedResult[3] ]; |
| 339 | + } |
| 340 | + return result; |
| 341 | + } |
| 342 | + |
| 343 | + var openLink = makeStringParser( '[[' ); |
| 344 | + var closeLink = makeStringParser( ']]' ); |
| 345 | + |
| 346 | + function link() { |
| 347 | + var result = null; |
| 348 | + var parsedResult = sequence( [ |
| 349 | + openLink, |
| 350 | + expression, |
| 351 | + closeLink |
| 352 | + ] ); |
| 353 | + if ( parsedResult !== null ) { |
| 354 | + result = [ 'WLINK', parsedResult[1] ]; |
| 355 | + } |
| 356 | + return result; |
| 357 | + } |
| 358 | + |
| 359 | + var templateName = transform( |
| 360 | + makeRegexParser( /^[A-Za-z]\w+/ ), |
| 361 | + function( result ) { return result.toString().toUpperCase(); } |
| 362 | + ); |
| 363 | + |
| 364 | + function templateParam() { |
| 365 | + var result = sequence( [ |
| 366 | + pipe, |
| 367 | + nOrMore( 0, paramExpression ) |
| 368 | + ] ); |
| 369 | + if ( result === null ) { |
| 370 | + return null; |
| 371 | + } |
| 372 | + var expr = result[1]; |
| 373 | + // use a "CONCAT" operator if there are multiple nodes, otherwise return the first node, raw. |
| 374 | + return expr.length > 1 ? [ "CONCAT" ].concat( expr ) : expr[0]; |
| 375 | + } |
| 376 | + |
| 377 | + var pipe = makeStringParser( '|' ); |
| 378 | + |
| 379 | + function templateWithReplacement() { |
| 380 | + var result = sequence( [ |
| 381 | + templateName, |
| 382 | + colon, |
| 383 | + replacement |
| 384 | + ] ); |
| 385 | + return result === null ? null : [ result[0], result[2] ]; |
| 386 | + } |
| 387 | + |
| 388 | + var colon = makeStringParser(':'); |
| 389 | + |
| 390 | + var templateContents = choice( [ |
| 391 | + function() { |
| 392 | + var res = sequence( [ |
| 393 | + templateWithReplacement, |
| 394 | + nOrMore( 0, templateParam ) |
| 395 | + ] ); |
| 396 | + return res === null ? null : res[0].concat( res[1] ); |
| 397 | + }, |
| 398 | + function() { |
| 399 | + var res = sequence( [ |
| 400 | + templateName, |
| 401 | + nOrMore( 0, templateParam ) |
| 402 | + ] ); |
| 403 | + if ( res === null ) { |
| 404 | + return null; |
| 405 | + } |
| 406 | + return res[1].length ? [ res[0], res[1] ] : [ res[0] ]; |
| 407 | + } |
| 408 | + ] ); |
| 409 | + |
| 410 | + var openTemplate = makeStringParser('{{'); |
| 411 | + var closeTemplate = makeStringParser('}}'); |
| 412 | + |
| 413 | + function template() { |
| 414 | + var result = sequence( [ |
| 415 | + openTemplate, |
| 416 | + templateContents, |
| 417 | + closeTemplate |
| 418 | + ] ); |
| 419 | + return result === null ? null : result[1]; |
| 420 | + } |
| 421 | + |
| 422 | + var nonWhitespaceExpression = choice( [ |
| 423 | + template, |
| 424 | + link, |
| 425 | + extlink, |
| 426 | + replacement, |
| 427 | + literalWithoutSpace |
| 428 | + ] ); |
| 429 | + |
| 430 | + var paramExpression = choice( [ |
| 431 | + template, |
| 432 | + link, |
| 433 | + extlink, |
| 434 | + replacement, |
| 435 | + literalWithoutBar |
| 436 | + ] ); |
| 437 | + |
| 438 | + var expression = choice( [ |
| 439 | + template, |
| 440 | + link, |
| 441 | + extlink, |
| 442 | + replacement, |
| 443 | + literal |
| 444 | + ] ); |
| 445 | + |
| 446 | + function start() { |
| 447 | + var result = nOrMore( 0, expression )(); |
| 448 | + if ( result === null ) { |
| 449 | + return null; |
| 450 | + } |
| 451 | + return [ "CONCAT" ].concat( result ); |
| 452 | + } |
| 453 | + |
| 454 | + // everything above this point is supposed to be stateless/static, but |
| 455 | + // I am deferring the work of turning it into prototypes & objects. It's quite fast enough |
| 456 | + |
| 457 | + // finally let's do some actual work... |
| 458 | + |
| 459 | + var result = start(); |
| 460 | + |
| 461 | + /* |
| 462 | + * For success, the p must have gotten to the end of the input |
| 463 | + * and returned a non-null. |
| 464 | + * n.b. This is part of language infrastructure, so we do not throw an internationalizable message. |
| 465 | + */ |
| 466 | + if (result === null || pos !== input.length) { |
| 467 | + throw new Error( "Parse error at position " + pos.toString() + " in input: " + input ); |
| 468 | + } |
| 469 | + return result; |
| 470 | + } |
| 471 | + |
| 472 | + }; |
| 473 | + |
| 474 | + /** |
| 475 | + * htmlEmitter - object which primarily exists to emit HTML from parser ASTs |
| 476 | + */ |
| 477 | + mw.language.htmlEmitter = function( language, magic ) { |
| 478 | + this.language = language; |
| 479 | + var _this = this; |
| 480 | + |
| 481 | + $j.each( magic, function( key, val ) { |
| 482 | + _this[ key.toLowerCase() ] = function() { return val; }; |
| 483 | + } ); |
| 484 | + |
| 485 | + /** |
| 486 | + * (We put this method definition here, and not in prototype, to make sure it's not overwritten by any magic.) |
| 487 | + * Walk entire node structure, applying replacements and template functions when appropriate |
| 488 | + * @param {Mixed} abstract syntax tree (top node or subnode) |
| 489 | + * @param {Array} replacements for $1, $2, ... $n |
| 490 | + * @return {Mixed} single-string node or array of nodes suitable for jQuery appending |
| 491 | + */ |
| 492 | + this.emit = function( node, replacements ) { |
| 493 | + var ret = null; |
| 494 | + var _this = this; |
| 495 | + switch( typeof node ) { |
| 496 | + case 'string': |
| 497 | + case 'number': |
| 498 | + ret = node; |
| 499 | + break; |
| 500 | + case 'object': // node is an array of nodes |
| 501 | + var subnodes = $j.map( node.slice( 1 ), function( n ) { |
| 502 | + return _this.emit( n, replacements ); |
| 503 | + } ); |
| 504 | + var operation = node[0].toLowerCase(); |
| 505 | + ret = _this[ operation ]( subnodes, replacements ); |
| 506 | + break; |
| 507 | + case 'undefined': |
| 508 | + // Parsing the empty string (as an entire expression, or as a paramExpression in a template) results in undefined |
| 509 | + // Perhaps a more clever parser can detect this, and return the empty string? Or is that useful information? |
| 510 | + // The logical thing is probably to return the empty string here when we encounter undefined. |
| 511 | + ret = ''; |
| 512 | + break; |
| 513 | + default: |
| 514 | + throw new Error( 'unexpected type in AST: ' + typeof node ); |
| 515 | + } |
| 516 | + return ret; |
| 517 | + }; |
| 518 | + |
| 519 | + }; |
| 520 | + |
| 521 | + // For everything in input that follows double-open-curly braces, there should be an equivalent parser |
| 522 | + // function. For instance {{PLURAL ... }} will be processed by 'plural'. |
| 523 | + // If you have 'magic words' then configure the parser to have them upon creation. |
| 524 | + // |
| 525 | + // An emitter method takes the parent node, the array of subnodes and the array of replacements (the values that $1, $2... should translate to). |
| 526 | + // Note: all such functions must be pure, with the exception of referring to other pure functions via this.language (convertPlural and so on) |
| 527 | + mw.language.htmlEmitter.prototype = { |
| 528 | + |
| 529 | + /** |
| 530 | + * Parsing has been applied depth-first we can assume that all nodes here are single nodes |
| 531 | + * Must return a single node to parents -- a jQuery with synthetic span |
| 532 | + * However, unwrap any other synthetic spans in our children and pass them upwards |
| 533 | + * @param {Array} nodes - mixed, some single nodes, some arrays of nodes |
| 534 | + * @return {jQuery} |
| 535 | + */ |
| 536 | + concat: function( nodes ) { |
| 537 | + var span = $j( '<span>' ).addClass( 'mediaWiki_htmlEmitter' ); |
| 538 | + $j.each( nodes, function( i, node ) { |
| 539 | + if ( node instanceof jQuery && node.hasClass( 'mediaWiki_htmlEmitter' ) ) { |
| 540 | + $j.each( node.contents(), function( j, childNode ) { |
| 541 | + span.append( childNode ); |
| 542 | + } ); |
| 543 | + } else { |
| 544 | + // strings, integers, anything else |
| 545 | + span.append( node ); |
| 546 | + } |
| 547 | + } ); |
| 548 | + return span; |
| 549 | + }, |
| 550 | + |
| 551 | + /** |
| 552 | + * Return replacement of correct index, or string if unavailable. |
| 553 | + * Note that we expect the parsed parameter to be zero-based. i.e. $1 should have become [ 0 ]. |
| 554 | + * if the specified parameter is not found return the same string |
| 555 | + * (e.g. "$99" -> parameter 98 -> not found -> return "$99" ) |
| 556 | + * TODO throw error if nodes.length > 1 ? |
| 557 | + * @param {Array} of one element, integer, n >= 0 |
| 558 | + * @return {String} replacement |
| 559 | + */ |
| 560 | + replace: function( nodes, replacements ) { |
| 561 | + var index = parseInt( nodes[0], 10 ); |
| 562 | + return index < replacements.length ? replacements[index] : '$' + ( index + 1 ); |
| 563 | + }, |
| 564 | + |
| 565 | + /** |
| 566 | + * Transform wiki-link |
| 567 | + * TODO unimplemented |
| 568 | + */ |
| 569 | + wlink: function( nodes ) { |
| 570 | + return "unimplemented"; |
| 571 | + }, |
| 572 | + |
| 573 | + /** |
| 574 | + * Transform parsed structure into external link |
| 575 | + * If the href is a jQuery object, treat it as "enclosing" the link text. |
| 576 | + * ... function, treat it as the click handler |
| 577 | + * ... string, treat it as a URI |
| 578 | + * TODO: throw an error if nodes.length > 2 ? |
| 579 | + * @param {Array} of two elements, {jQuery|Function|String} and {String} |
| 580 | + * @return {jQuery} |
| 581 | + */ |
| 582 | + link: function( nodes ) { |
| 583 | + var arg = nodes[0]; |
| 584 | + var contents = nodes[1]; |
| 585 | + var $el; |
| 586 | + if ( arg instanceof jQuery ) { |
| 587 | + $el = arg; |
| 588 | + } else { |
| 589 | + $el = $j( '<a>' ); |
| 590 | + if ( typeof arg === 'function' ) { |
| 591 | + $el.click( arg ).attr( 'href', '#' ); |
| 592 | + } else { |
| 593 | + $el.attr( 'href', arg.toString() ); |
| 594 | + } |
| 595 | + } |
| 596 | + $el.append( contents ); |
| 597 | + return $el; |
| 598 | + }, |
| 599 | + |
| 600 | + /** |
| 601 | + * Transform parsed structure into pluralization |
| 602 | + * n.b. The first node may be a non-integer (for instance, a string representing an Arabic number). |
| 603 | + * So convert it back with the current language's convertNumber. |
| 604 | + * @param {Array} of nodes, [ {String|Number}, {String}, {String} ... ] |
| 605 | + * @return {String} selected pluralized form according to current language |
| 606 | + */ |
| 607 | + plural: function( nodes ) { |
| 608 | + var count = parseInt( this.language.convertNumber( nodes[0], true ), 10 ); |
| 609 | + var forms = nodes.slice(1); |
| 610 | + return forms.length ? this.language.convertPlural( count, forms ) : ''; |
| 611 | + } |
| 612 | + |
| 613 | + }; |
| 614 | + |
| 615 | + |
| 616 | +} )( mediaWiki, jQuery ); |
Property changes on: trunk/extensions/jQueryMsg/resources/mediawiki.language.parser.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 617 | + native |
Index: trunk/extensions/jQueryMsg/jQueryMsg.php |
— | — | @@ -0,0 +1,69 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * jQueryMsg extension |
| 5 | + * |
| 6 | + * @file |
| 7 | + * @ingroup Extensions |
| 8 | + * |
| 9 | + * This extension creates a $.msg() function. It's based on Neilk's similar code |
| 10 | + * from UploadWizard, and is pretty awesome. |
| 11 | + * |
| 12 | + * It is also similar to Wikia's JSMessaging extension, except its parser is much |
| 13 | + * more comprehensive. |
| 14 | + * |
| 15 | + * Usage: Add the following line in LocalSettings.php: |
| 16 | + * require_once( "$IP/extensions/jQueryMsg/jQueryMsg.php" ); |
| 17 | + * |
| 18 | + * @author Neil Kandalgaonkar <neilk@wikimedia.org> and Ian Baker <ian@wikimedia.org> |
| 19 | + * @license GPL v2 |
| 20 | + * @version 0.1.0 |
| 21 | + */ |
| 22 | + |
| 23 | +// Check environment |
| 24 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 25 | + echo( "This is an extension to MediaWiki and cannot be run standalone.\n" ); |
| 26 | + die( - 1 ); |
| 27 | +} |
| 28 | + |
| 29 | +// Credits |
| 30 | +$wgExtensionCredits['other'][] = array( |
| 31 | + 'path' => __FILE__, |
| 32 | + 'name' => 'jQueryMsg', |
| 33 | + 'author' => 'Neil Kandalgaonkar and Ian Baker', |
| 34 | + 'version' => '0.1.0', |
| 35 | + 'url' => 'http://www.mediawiki.org/wiki/Extension:jQueryMsg', |
| 36 | + 'descriptionmsg' => 'jquerymsg-desc', |
| 37 | +); |
| 38 | + |
| 39 | +// Shortcut to this extension directory |
| 40 | +$dir = dirname( __FILE__ ) . '/'; |
| 41 | + |
| 42 | +// resources that need loading |
| 43 | +$wgResourceModules['ext.jQueryMsg'] = array( |
| 44 | + 'scripts' => array( |
| 45 | + 'resources/mediawiki.language.parser.js', |
| 46 | + 'jQueryMsg.js' |
| 47 | + ), |
| 48 | + 'dependencies' => array( |
| 49 | + 'jquery', |
| 50 | + 'mediawiki.language', |
| 51 | + 'mediawiki.util' |
| 52 | + ), |
| 53 | + 'localBasePath' => $dir, |
| 54 | + 'remoteExtPath' => 'jQueryMsg' |
| 55 | +); |
| 56 | + |
| 57 | +$wgExtensionMessagesFiles['jQueryMsg'] = $dir . 'jQueryMsg.i18n.php'; |
| 58 | + |
| 59 | +/* |
| 60 | +$wgAutoloadClasses['EditSectionClearerLinkHooks'] = $dir . 'EditSectionClearerLink.hooks.php'; |
| 61 | + |
| 62 | +// Register edit link create hook |
| 63 | +$wgHooks['DoEditSectionLink'][] = 'EditSectionClearerLinkHooks::reviseLink'; |
| 64 | + |
| 65 | +// Register section create hook |
| 66 | +$wgHooks['ParserSectionCreate'][] = 'EditSectionClearerLinkHooks::reviseSection'; |
| 67 | + |
| 68 | +// Register css add script hook |
| 69 | +$wgHooks['OutputPageParserOutput'][] = 'EditSectionClearerLinkHooks::addPageResources'; |
| 70 | +*/ |
Property changes on: trunk/extensions/jQueryMsg/jQueryMsg.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 71 | + native |