1/*! 2 * jQuery Migrate - v1.2.1 - 2013-05-08 3 * https://github.com/jquery/jquery-migrate 4 * Copyright 2005, 2013 jQuery Foundation, Inc. and other contributors; Licensed MIT 5 */ 6(function( jQuery, window, undefined ) { 7// See http://bugs.jquery.com/ticket/13335 8// "use strict"; 9 10 11var warnedAbout = {}; 12 13// List of warnings already given; public read only 14jQuery.migrateWarnings = []; 15 16// Set to true to prevent console output; migrateWarnings still maintained 17// jQuery.migrateMute = false; 18 19// Show a message on the console so devs know we're active 20if ( !jQuery.migrateMute && window.console && window.console.log ) { 21 window.console.log("JQMIGRATE: Logging is active"); 22} 23 24// Set to false to disable traces that appear with warnings 25if ( jQuery.migrateTrace === undefined ) { 26 jQuery.migrateTrace = true; 27} 28 29// Forget any warnings we've already given; public 30jQuery.migrateReset = function() { 31 warnedAbout = {}; 32 jQuery.migrateWarnings.length = 0; 33}; 34 35function migrateWarn( msg) { 36 var console = window.console; 37 if ( !warnedAbout[ msg ] ) { 38 warnedAbout[ msg ] = true; 39 jQuery.migrateWarnings.push( msg ); 40 if ( console && console.warn && !jQuery.migrateMute ) { 41 console.warn( "JQMIGRATE: " + msg ); 42 if ( jQuery.migrateTrace && console.trace ) { 43 console.trace(); 44 } 45 } 46 } 47} 48 49function migrateWarnProp( obj, prop, value, msg ) { 50 if ( Object.defineProperty ) { 51 // On ES5 browsers (non-oldIE), warn if the code tries to get prop; 52 // allow property to be overwritten in case some other plugin wants it 53 try { 54 Object.defineProperty( obj, prop, { 55 configurable: true, 56 enumerable: true, 57 get: function() { 58 migrateWarn( msg ); 59 return value; 60 }, 61 set: function( newValue ) { 62 migrateWarn( msg ); 63 value = newValue; 64 } 65 }); 66 return; 67 } catch( err ) { 68 // IE8 is a dope about Object.defineProperty, can't warn there 69 } 70 } 71 72 // Non-ES5 (or broken) browser; just set the property 73 jQuery._definePropertyBroken = true; 74 obj[ prop ] = value; 75} 76 77if ( document.compatMode === "BackCompat" ) { 78 // jQuery has never supported or tested Quirks Mode 79 migrateWarn( "jQuery is not compatible with Quirks Mode" ); 80} 81 82 83var attrFn = jQuery( "<input/>", { size: 1 } ).attr("size") && jQuery.attrFn, 84 oldAttr = jQuery.attr, 85 valueAttrGet = jQuery.attrHooks.value && jQuery.attrHooks.value.get || 86 function() { return null; }, 87 valueAttrSet = jQuery.attrHooks.value && jQuery.attrHooks.value.set || 88 function() { return undefined; }, 89 rnoType = /^(?:input|button)$/i, 90 rnoAttrNodeType = /^[238]$/, 91 rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i, 92 ruseDefault = /^(?:checked|selected)$/i; 93 94// jQuery.attrFn 95migrateWarnProp( jQuery, "attrFn", attrFn || {}, "jQuery.attrFn is deprecated" ); 96 97jQuery.attr = function( elem, name, value, pass ) { 98 var lowerName = name.toLowerCase(), 99 nType = elem && elem.nodeType; 100 101 if ( pass ) { 102 // Since pass is used internally, we only warn for new jQuery 103 // versions where there isn't a pass arg in the formal params 104 if ( oldAttr.length < 4 ) { 105 migrateWarn("jQuery.fn.attr( props, pass ) is deprecated"); 106 } 107 if ( elem && !rnoAttrNodeType.test( nType ) && 108 (attrFn ? name in attrFn : jQuery.isFunction(jQuery.fn[name])) ) { 109 return jQuery( elem )[ name ]( value ); 110 } 111 } 112 113 // Warn if user tries to set `type`, since it breaks on IE 6/7/8; by checking 114 // for disconnected elements we don't warn on $( "<button>", { type: "button" } ). 115 if ( name === "type" && value !== undefined && rnoType.test( elem.nodeName ) && elem.parentNode ) { 116 migrateWarn("Can't change the 'type' of an input or button in IE 6/7/8"); 117 } 118 119 // Restore boolHook for boolean property/attribute synchronization 120 if ( !jQuery.attrHooks[ lowerName ] && rboolean.test( lowerName ) ) { 121 jQuery.attrHooks[ lowerName ] = { 122 get: function( elem, name ) { 123 // Align boolean attributes with corresponding properties 124 125 // Fall back to attribute presence where some booleans are not supported 126 var attrNode, 127 property = jQuery.prop( elem, name ); 128 return property === true || typeof property !== "boolean" && 129 ( attrNode = elem.getAttributeNode(name) ) && attrNode.nodeValue !== false ? 130 131 name.toLowerCase() : 132 undefined; 133 },
134 set: function( elem, value, name ) { 135 var propName; 136 if ( value === false ) { 137 // Remove boolean attributes when set to false 138 jQuery.removeAttr( elem, name ); 139 } else { 140 // value is true since we know at this point it's type boolean and not false 141 // Set boolean attributes to the same name and set the DOM property 142 propName = jQuery.propFix[ name ] || name; 143 if ( propName in elem ) { 144 // Only set the IDL specifically if it already exists on the element 145 elem[ propName ] = true; 146 } 147 148 elem.setAttribute( name, name.toLowerCase() ); 149 } 150 return name; 151 } 152 }; 153 154 // Warn only for attributes that can remain distinct from their properties post-1.9 155 if ( ruseDefault.test( lowerName ) ) { 156 migrateWarn( "jQuery.fn.attr('" + lowerName + "') may use property instead of attribute" ); 157 } 158 } 159 160 return oldAttr.call( jQuery, elem, name, value ); 161}; 162 163// attrHooks: value 164jQuery.attrHooks.value = { 165 get: function( elem, name ) { 166 var nodeName = ( elem.nodeName || "" ).toLowerCase(); 167 if ( nodeName === "button" ) { 168 return valueAttrGet.apply( this, arguments ); 169 } 170 if ( nodeName !== "input" && nodeName !== "option" ) { 171 migrateWarn("jQuery.fn.attr('value') no longer gets properties"); 172 } 173 return name in elem ? 174 elem.value : 175 null; 176 }, 177 set: function( elem, value ) { 178 var nodeName = ( elem.nodeName || "" ).toLowerCase(); 179 if ( nodeName === "button" ) { 180 return valueAttrSet.apply( this, arguments ); 181 } 182 if ( nodeName !== "input" && nodeName !== "option" ) { 183 migrateWarn("jQuery.fn.attr('value', val) no longer sets properties"); 184 } 185 // Does not return so that setAttribute is also used 186 elem.value = value; 187 } 188}; 189 190 191var matched, browser, 192 oldInit = jQuery.fn.init, 193 oldParseJSON = jQuery.parseJSON, 194 // Note: XSS check is done below after string is trimmed 195 rquickExpr = /^([^<]*)(<[\w\W]+>)([^>]*)$/; 196 197// $(html) "looks like html" rule change 198jQuery.fn.init = function( selector, context, rootjQuery ) { 199 var match; 200 201 if ( selector && typeof selector === "string" && !jQuery.isPlainObject( context ) && 202 (match = rquickExpr.exec( jQuery.trim( selector ) )) && match[ 0 ] ) { 203 // This is an HTML string according to the "old" rules; is it still? 204 if ( selector.charAt( 0 ) !== "<" ) { 205 migrateWarn("$(html) HTML strings must start with '<' character"); 206 } 207 if ( match[ 3 ] ) { 208 migrateWarn("$(html) HTML text after last tag is ignored"); 209 } 210 // Consistently reject any HTML-like string starting with a hash (#9521) 211 // Note that this may break jQuery 1.6.x code that otherwise would work. 212 if ( match[ 0 ].charAt( 0 ) === "#" ) { 213 migrateWarn("HTML string cannot start with a '#' character"); 214 jQuery.error("JQMIGRATE: Invalid selector string (XSS)"); 215 } 216 // Now process using loose rules; let pre-1.8 play too 217 if ( context && context.context ) { 218 // jQuery object as context; parseHTML expects a DOM object 219 context = context.context; 220 } 221 if ( jQuery.parseHTML ) { 222 return oldInit.call( this, jQuery.parseHTML( match[ 2 ], context, true ), 223 context, rootjQuery ); 224 } 225 } 226 return oldInit.apply( this, arguments ); 227}; 228jQuery.fn.init.prototype = jQuery.fn; 229 230// Let $.parseJSON(falsy_value) return null 231jQuery.parseJSON = function( json ) { 232 if ( !json && json !== null ) { 233 migrateWarn("jQuery.parseJSON requires a valid JSON string"); 234 return null; 235 } 236 return oldParseJSON.apply( this, arguments ); 237}; 238 239jQuery.uaMatch = function( ua ) { 240 ua = ua.toLowerCase(); 241 242 var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) || 243 /(webkit)[ \/]([\w.]+)/.exec( ua ) || 244 /(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) || 245 /(msie) ([\w.]+)/.exec( ua ) || 246 ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) || 247 []; 248 249 return { 250 browser: match[ 1 ] || "", 251 version: match[ 2 ] || "0" 252 }; 253}; 254 255// Don't clobber any existing jQuery.browser in case it's different 256if ( !jQuery.browser ) { 257 matched = jQuery.uaMatch( navigator.userAgent ); 258 browser = {}; 259 260 if ( matched.browser ) { 261 browser[ matched.browser ] = true; 262 browser.version = matched.version; 263 } 264 265 // Chrome is Webkit, but Webkit is also Safari. 266 if ( browser.chrome ) { 267 browser.webkit = true; 268 } else if ( browser.webkit ) { 269 browser.safari = true; 270 } 271 272 jQuery.browser = browser; 273} 274 275// Warn if the code tries to get jQuery.browser 276migrateWarnProp( jQuery, "browser", jQuery.browser, "jQuery.browser is deprecated" ); 277 278jQuery.sub = function() { 279 function jQuerySub( selector, context ) { 280 return new jQuerySub.fn.init( selector, context ); 281 } 282 jQuery.extend( true, jQuerySub, this ); 283 jQuerySub.superclass = this; 284 jQuerySub.fn = jQuerySub.prototype = this(); 285 jQuerySub.fn.constructor = jQuerySub; 286 jQuerySub.sub = this.sub; 287 jQuerySub.fn.init = function init( selector, context ) { 288 if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) { 289 context = jQuerySub( context ); 290 } 291 292 return jQuery.fn.init.call( this, selector, context, rootjQuerySub ); 293 }; 294 jQuerySub.fn.init.prototype = jQuerySub.fn; 295 var rootjQuerySub = jQuerySub(document); 296 migrateWarn( "jQuery.sub() is deprecated" ); 297 return jQuerySub; 298}; 299 300 301// Ensure that $.ajax gets the new parseJSON defined in core.js 302jQuery.ajaxSetup({ 303 converters: { 304 "text json": jQuery.parseJSON 305 } 306}); 307 308 309var oldFnData = jQuery.fn.data; 310 311jQuery.fn.data = function( name ) { 312 var ret, evt, 313 elem = this[0]; 314 315 // Handles 1.7 which has this behavior and 1.8 which doesn't 316 if ( elem && name === "events" && arguments.length === 1 ) { 317 ret = jQuery.data( elem, name ); 318 evt = jQuery._data( elem, name ); 319 if ( ( ret === undefined || ret === evt ) && evt !== undefined ) { 320 migrateWarn("Use of jQuery.fn.data('events') is deprecated"); 321 return evt; 322 } 323 } 324 return oldFnData.apply( this, arguments ); 325}; 326 327 328var rscriptType = /\/(java|ecma)script/i, 329 oldSelf = jQuery.fn.andSelf || jQuery.fn.addBack; 330 331jQuery.fn.andSelf = function() { 332 migrateWarn("jQuery.fn.andSelf() replaced by jQuery.fn.addBack()"); 333 return oldSelf.apply( this, arguments ); 334}; 335 336// Since jQuery.clean is used internally on older versions, we only shim if it's missing 337if ( !jQuery.clean ) { 338 jQuery.clean = function( elems, context, fragment, scripts ) { 339 // Set context per 1.8 logic 340 context = context || document; 341 context = !context.nodeType && context[0] || context; 342 context = context.ownerDocument || context; 343 344 migrateWarn("jQuery.clean() is deprecated"); 345 346 var i, elem, handleScript, jsTags, 347 ret = []; 348 349 jQuery.merge( ret, jQuery.buildFragment( elems, context ).childNodes ); 350 351 // Complex logic lifted directly from jQuery 1.8 352 if ( fragment ) { 353 // Special handling of each script element 354 handleScript = function( elem ) { 355 // Check if we consider it executable 356 if ( !elem.type || rscriptType.test( elem.type ) ) { 357 // Detach the script and store it in the scripts array (if provided) or the fragment 358 // Return truthy to indicate that it has been handled 359 return scripts ? 360 scripts.push( elem.parentNode ? elem.parentNode.removeChild( elem ) : elem ) : 361 fragment.appendChild( elem ); 362 } 363 }; 364 365 for ( i = 0; (elem = ret[i]) != null; i++ ) { 366 // Check if we're done after handling an executable script 367 if ( !( jQuery.nodeName( elem, "script" ) && handleScript( elem ) ) ) { 368 // Append to fragment and handle embedded scripts 369 fragment.appendChild( elem ); 370 if ( typeof elem.getElementsByTagName !== "undefined" ) { 371 // handleScript alters the DOM, so use jQuery.merge to ensure snapshot iteration 372 jsTags = jQuery.grep( jQuery.merge( [], elem.getElementsByTagName("script") ), handleScript ); 373 374 // Splice the scripts into ret after their former ancestor and advance our index beyond them 375 ret.splice.apply( ret, [i + 1, 0].concat( jsTags ) ); 376 i += jsTags.length; 377 } 378 } 379 } 380 } 381 382 return ret; 383 }; 384} 385 386var eventAdd = jQuery.event.add, 387 eventRemove = jQuery.event.remove, 388 eventTrigger = jQuery.event.trigger, 389 oldToggle = jQuery.fn.toggle, 390 oldLive = jQuery.fn.live, 391 oldDie = jQuery.fn.die, 392 ajaxEvents = "ajaxStart|ajaxStop|ajaxSend|ajaxComplete|ajaxError|ajaxSuccess", 393 rajaxEvent = new RegExp( "\\b(?:" + ajaxEvents + ")\\b" ), 394 rhoverHack = /(?:^|\s)hover(\.\S+|)\b/, 395 hoverHack = function( events ) { 396 if ( typeof( events ) !== "string" || jQuery.event.special.hover ) { 397 return events; 398 } 399 if ( rhoverHack.test( events ) ) { 400 migrateWarn("'hover' pseudo-event is deprecated, use 'mouseenter mouseleave'"); 401 } 402 return events && events.replace( rhoverHack, "mouseenter$1 mouseleave$1" ); 403 }; 404 405// Event props removed in 1.9, put them back if needed; no practical way to warn them 406if ( jQuery.event.props && jQuery.event.props[ 0 ] !== "attrChange" ) { 407 jQuery.event.props.unshift( "attrChange", "attrName", "relatedNode", "srcElement" ); 408} 409 410// Undocumented jQuery.event.handle was "deprecated" in jQuery 1.7 411if ( jQuery.event.dispatch ) { 412 migrateWarnProp( jQuery.event, "handle", jQuery.event.dispatch, "jQuery.event.handle is undocumented and deprecated" ); 413} 414 415// Support for 'hover' pseudo-event and ajax event warnings 416jQuery.event.add = function( elem, types, handler, data, selector ){ 417 if ( elem !== document && rajaxEvent.test( types ) ) { 418 migrateWarn( "AJAX events should be attached to document: " + types ); 419 } 420 eventAdd.call( this, elem, hoverHack( types || "" ), handler, data, selector ); 421}; 422jQuery.event.remove = function( elem, types, handler, selector, mappedTypes ){ 423 eventRemove.call( this, elem, hoverHack( types ) || "", handler, selector, mappedTypes ); 424}; 425 426jQuery.fn.error = function() { 427 var args = Array.prototype.slice.call( arguments, 0); 428 migrateWarn("jQuery.fn.error() is deprecated"); 429 args.splice( 0, 0, "error" ); 430 if ( arguments.length ) { 431 return this.bind.apply( this, args ); 432 } 433 // error event should not bubble to window, although it does pre-1.7 434 this.triggerHandler.apply( this, args ); 435 return this; 436}; 437 438jQuery.fn.toggle = function( fn, fn2 ) { 439 440 // Don't mess with animation or css toggles 441 if ( !jQuery.isFunction( fn ) || !jQuery.isFunction( fn2 ) ) { 442 return oldToggle.apply( this, arguments ); 443 } 444 migrateWarn("jQuery.fn.toggle(handler, handler...) is deprecated"); 445 446 // Save reference to arguments for access in closure 447 var args = arguments, 448 guid = fn.guid || jQuery.guid++, 449 i = 0, 450 toggler = function( event ) { 451 // Figure out which function to execute 452 var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i; 453 jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 ); 454 455 // Make sure that clicks stop 456 event.preventDefault(); 457 458 // and execute the function 459 return args[ lastToggle ].apply( this, arguments ) || false; 460 }; 461 462 // link all the functions, so any of them can unbind this click handler 463 toggler.guid = guid; 464 while ( i < args.length ) { 465 args[ i++ ].guid = guid; 466 } 467 468 return this.click( toggler ); 469}; 470 471jQuery.fn.live = function( types, data, fn ) { 472 migrateWarn("jQuery.fn.live() is deprecated"); 473 if ( oldLive ) { 474 return oldLive.apply( this, arguments ); 475 } 476 jQuery( this.context ).on( types, this.selector, data, fn ); 477 return this; 478}; 479 480jQuery.fn.die = function( types, fn ) { 481 migrateWarn("jQuery.fn.die() is deprecated"); 482 if ( oldDie ) { 483 return oldDie.apply( this, arguments ); 484 } 485 jQuery( this.context ).off( types, this.selector || "**", fn ); 486 return this; 487}; 488 489// Turn global events into document-triggered events 490jQuery.event.trigger = function( event, data, elem, onlyHandlers ){ 491 if ( !elem && !rajaxEvent.test( event ) ) { 492 migrateWarn( "Global events are undocumented and deprecated" ); 493 } 494 return eventTrigger.call( this, event, data, elem || document, onlyHandlers ); 495}; 496jQuery.each( ajaxEvents.split("|"), 497 function( _, name ) { 498 jQuery.event.special[ name ] = { 499 setup: function() { 500 var elem = this; 501 502 // The document needs no shimming; must be !== for oldIE 503 if ( elem !== document ) { 504 jQuery.event.add( document, name + "." + jQuery.guid, function() { 505 jQuery.event.trigger( name, null, elem, true ); 506 }); 507 jQuery._data( this, name, jQuery.guid++ ); 508 } 509 return false;
510 }, 511 teardown: function() { 512 if ( this !== document ) { 513 jQuery.event.remove( document, name + "." + jQuery._data( this, name ) ); 514 } 515 return false; 516 } 517 }; 518 } 519); 520 521 522})( jQuery, window );
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.