You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

753 lines
23 KiB

  1. /*!
  2. * jQuery Migrate - v1.4.1 - 2016-05-19
  3. * Copyright jQuery Foundation and other contributors
  4. */
  5. (function( jQuery, window, undefined ) {
  6. // See http://bugs.jquery.com/ticket/13335
  7. // "use strict";
  8. jQuery.migrateVersion = "1.4.1";
  9. var warnedAbout = {};
  10. // List of warnings already given; public read only
  11. jQuery.migrateWarnings = [];
  12. // Set to true to prevent console output; migrateWarnings still maintained
  13. // jQuery.migrateMute = false;
  14. // Show a message on the console so devs know we're active
  15. if ( window.console && window.console.log ) {
  16. window.console.log( "JQMIGRATE: Migrate is installed" +
  17. ( jQuery.migrateMute ? "" : " with logging active" ) +
  18. ", version " + jQuery.migrateVersion );
  19. }
  20. // Set to false to disable traces that appear with warnings
  21. if ( jQuery.migrateTrace === undefined ) {
  22. jQuery.migrateTrace = true;
  23. }
  24. // Forget any warnings we've already given; public
  25. jQuery.migrateReset = function() {
  26. warnedAbout = {};
  27. jQuery.migrateWarnings.length = 0;
  28. };
  29. function migrateWarn( msg) {
  30. var console = window.console;
  31. if ( !warnedAbout[ msg ] ) {
  32. warnedAbout[ msg ] = true;
  33. jQuery.migrateWarnings.push( msg );
  34. if ( console && console.warn && !jQuery.migrateMute ) {
  35. console.warn( "JQMIGRATE: " + msg );
  36. if ( jQuery.migrateTrace && console.trace ) {
  37. console.trace();
  38. }
  39. }
  40. }
  41. }
  42. function migrateWarnProp( obj, prop, value, msg ) {
  43. if ( Object.defineProperty ) {
  44. // On ES5 browsers (non-oldIE), warn if the code tries to get prop;
  45. // allow property to be overwritten in case some other plugin wants it
  46. try {
  47. Object.defineProperty( obj, prop, {
  48. configurable: true,
  49. enumerable: true,
  50. get: function() {
  51. migrateWarn( msg );
  52. return value;
  53. },
  54. set: function( newValue ) {
  55. migrateWarn( msg );
  56. value = newValue;
  57. }
  58. });
  59. return;
  60. } catch( err ) {
  61. // IE8 is a dope about Object.defineProperty, can't warn there
  62. }
  63. }
  64. // Non-ES5 (or broken) browser; just set the property
  65. jQuery._definePropertyBroken = true;
  66. obj[ prop ] = value;
  67. }
  68. if ( document.compatMode === "BackCompat" ) {
  69. // jQuery has never supported or tested Quirks Mode
  70. migrateWarn( "jQuery is not compatible with Quirks Mode" );
  71. }
  72. var attrFn = jQuery( "<input/>", { size: 1 } ).attr("size") && jQuery.attrFn,
  73. oldAttr = jQuery.attr,
  74. valueAttrGet = jQuery.attrHooks.value && jQuery.attrHooks.value.get ||
  75. function() { return null; },
  76. valueAttrSet = jQuery.attrHooks.value && jQuery.attrHooks.value.set ||
  77. function() { return undefined; },
  78. rnoType = /^(?:input|button)$/i,
  79. rnoAttrNodeType = /^[238]$/,
  80. rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,
  81. ruseDefault = /^(?:checked|selected)$/i;
  82. // jQuery.attrFn
  83. migrateWarnProp( jQuery, "attrFn", attrFn || {}, "jQuery.attrFn is deprecated" );
  84. jQuery.attr = function( elem, name, value, pass ) {
  85. var lowerName = name.toLowerCase(),
  86. nType = elem && elem.nodeType;
  87. if ( pass ) {
  88. // Since pass is used internally, we only warn for new jQuery
  89. // versions where there isn't a pass arg in the formal params
  90. if ( oldAttr.length < 4 ) {
  91. migrateWarn("jQuery.fn.attr( props, pass ) is deprecated");
  92. }
  93. if ( elem && !rnoAttrNodeType.test( nType ) &&
  94. (attrFn ? name in attrFn : jQuery.isFunction(jQuery.fn[name])) ) {
  95. return jQuery( elem )[ name ]( value );
  96. }
  97. }
  98. // Warn if user tries to set `type`, since it breaks on IE 6/7/8; by checking
  99. // for disconnected elements we don't warn on $( "<button>", { type: "button" } ).
  100. if ( name === "type" && value !== undefined && rnoType.test( elem.nodeName ) && elem.parentNode ) {
  101. migrateWarn("Can't change the 'type' of an input or button in IE 6/7/8");
  102. }
  103. // Restore boolHook for boolean property/attribute synchronization
  104. if ( !jQuery.attrHooks[ lowerName ] && rboolean.test( lowerName ) ) {
  105. jQuery.attrHooks[ lowerName ] = {
  106. get: function( elem, name ) {
  107. // Align boolean attributes with corresponding properties
  108. // Fall back to attribute presence where some booleans are not supported
  109. var attrNode,
  110. property = jQuery.prop( elem, name );
  111. return property === true || typeof property !== "boolean" &&
  112. ( attrNode = elem.getAttributeNode(name) ) && attrNode.nodeValue !== false ?
  113. name.toLowerCase() :
  114. undefined;
  115. },
  116. set: function( elem, value, name ) {
  117. var propName;
  118. if ( value === false ) {
  119. // Remove boolean attributes when set to false
  120. jQuery.removeAttr( elem, name );
  121. } else {
  122. // value is true since we know at this point it's type boolean and not false
  123. // Set boolean attributes to the same name and set the DOM property
  124. propName = jQuery.propFix[ name ] || name;
  125. if ( propName in elem ) {
  126. // Only set the IDL specifically if it already exists on the element
  127. elem[ propName ] = true;
  128. }
  129. elem.setAttribute( name, name.toLowerCase() );
  130. }
  131. return name;
  132. }
  133. };
  134. // Warn only for attributes that can remain distinct from their properties post-1.9
  135. if ( ruseDefault.test( lowerName ) ) {
  136. migrateWarn( "jQuery.fn.attr('" + lowerName + "') might use property instead of attribute" );
  137. }
  138. }
  139. return oldAttr.call( jQuery, elem, name, value );
  140. };
  141. // attrHooks: value
  142. jQuery.attrHooks.value = {
  143. get: function( elem, name ) {
  144. var nodeName = ( elem.nodeName || "" ).toLowerCase();
  145. if ( nodeName === "button" ) {
  146. return valueAttrGet.apply( this, arguments );
  147. }
  148. if ( nodeName !== "input" && nodeName !== "option" ) {
  149. migrateWarn("jQuery.fn.attr('value') no longer gets properties");
  150. }
  151. return name in elem ?
  152. elem.value :
  153. null;
  154. },
  155. set: function( elem, value ) {
  156. var nodeName = ( elem.nodeName || "" ).toLowerCase();
  157. if ( nodeName === "button" ) {
  158. return valueAttrSet.apply( this, arguments );
  159. }
  160. if ( nodeName !== "input" && nodeName !== "option" ) {
  161. migrateWarn("jQuery.fn.attr('value', val) no longer sets properties");
  162. }
  163. // Does not return so that setAttribute is also used
  164. elem.value = value;
  165. }
  166. };
  167. var matched, browser,
  168. oldInit = jQuery.fn.init,
  169. oldFind = jQuery.find,
  170. oldParseJSON = jQuery.parseJSON,
  171. rspaceAngle = /^\s*</,
  172. rattrHashTest = /\[(\s*[-\w]+\s*)([~|^$*]?=)\s*([-\w#]*?#[-\w#]*)\s*\]/,
  173. rattrHashGlob = /\[(\s*[-\w]+\s*)([~|^$*]?=)\s*([-\w#]*?#[-\w#]*)\s*\]/g,
  174. // Note: XSS check is done below after string is trimmed
  175. rquickExpr = /^([^<]*)(<[\w\W]+>)([^>]*)$/;
  176. // $(html) "looks like html" rule change
  177. jQuery.fn.init = function( selector, context, rootjQuery ) {
  178. var match, ret;
  179. if ( selector && typeof selector === "string" ) {
  180. if ( !jQuery.isPlainObject( context ) &&
  181. (match = rquickExpr.exec( jQuery.trim( selector ) )) && match[ 0 ] ) {
  182. // This is an HTML string according to the "old" rules; is it still?
  183. if ( !rspaceAngle.test( selector ) ) {
  184. migrateWarn("$(html) HTML strings must start with '<' character");
  185. }
  186. if ( match[ 3 ] ) {
  187. migrateWarn("$(html) HTML text after last tag is ignored");
  188. }
  189. // Consistently reject any HTML-like string starting with a hash (gh-9521)
  190. // Note that this may break jQuery 1.6.x code that otherwise would work.
  191. if ( match[ 0 ].charAt( 0 ) === "#" ) {
  192. migrateWarn("HTML string cannot start with a '#' character");
  193. jQuery.error("JQMIGRATE: Invalid selector string (XSS)");
  194. }
  195. // Now process using loose rules; let pre-1.8 play too
  196. // Is this a jQuery context? parseHTML expects a DOM element (#178)
  197. if ( context && context.context && context.context.nodeType ) {
  198. context = context.context;
  199. }
  200. if ( jQuery.parseHTML ) {
  201. return oldInit.call( this,
  202. jQuery.parseHTML( match[ 2 ], context && context.ownerDocument ||
  203. context || document, true ), context, rootjQuery );
  204. }
  205. }
  206. }
  207. ret = oldInit.apply( this, arguments );
  208. // Fill in selector and context properties so .live() works
  209. if ( selector && selector.selector !== undefined ) {
  210. // A jQuery object, copy its properties
  211. ret.selector = selector.selector;
  212. ret.context = selector.context;
  213. } else {
  214. ret.selector = typeof selector === "string" ? selector : "";
  215. if ( selector ) {
  216. ret.context = selector.nodeType? selector : context || document;
  217. }
  218. }
  219. return ret;
  220. };
  221. jQuery.fn.init.prototype = jQuery.fn;
  222. jQuery.find = function( selector ) {
  223. var args = Array.prototype.slice.call( arguments );
  224. // Support: PhantomJS 1.x
  225. // String#match fails to match when used with a //g RegExp, only on some strings
  226. if ( typeof selector === "string" && rattrHashTest.test( selector ) ) {
  227. // The nonstandard and undocumented unquoted-hash was removed in jQuery 1.12.0
  228. // First see if qS thinks it's a valid selector, if so avoid a false positive
  229. try {
  230. document.querySelector( selector );
  231. } catch ( err1 ) {
  232. // Didn't *look* valid to qSA, warn and try quoting what we think is the value
  233. selector = selector.replace( rattrHashGlob, function( _, attr, op, value ) {
  234. return "[" + attr + op + "\"" + value + "\"]";
  235. } );
  236. // If the regexp *may* have created an invalid selector, don't update it
  237. // Note that there may be false alarms if selector uses jQuery extensions
  238. try {
  239. document.querySelector( selector );
  240. migrateWarn( "Attribute selector with '#' must be quoted: " + args[ 0 ] );
  241. args[ 0 ] = selector;
  242. } catch ( err2 ) {
  243. migrateWarn( "Attribute selector with '#' was not fixed: " + args[ 0 ] );
  244. }
  245. }
  246. }
  247. return oldFind.apply( this, args );
  248. };
  249. // Copy properties attached to original jQuery.find method (e.g. .attr, .isXML)
  250. var findProp;
  251. for ( findProp in oldFind ) {
  252. if ( Object.prototype.hasOwnProperty.call( oldFind, findProp ) ) {
  253. jQuery.find[ findProp ] = oldFind[ findProp ];
  254. }
  255. }
  256. // Let $.parseJSON(falsy_value) return null
  257. jQuery.parseJSON = function( json ) {
  258. if ( !json ) {
  259. migrateWarn("jQuery.parseJSON requires a valid JSON string");
  260. return null;
  261. }
  262. return oldParseJSON.apply( this, arguments );
  263. };
  264. jQuery.uaMatch = function( ua ) {
  265. ua = ua.toLowerCase();
  266. var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) ||
  267. /(webkit)[ \/]([\w.]+)/.exec( ua ) ||
  268. /(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
  269. /(msie) ([\w.]+)/.exec( ua ) ||
  270. ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) ||
  271. [];
  272. return {
  273. browser: match[ 1 ] || "",
  274. version: match[ 2 ] || "0"
  275. };
  276. };
  277. // Don't clobber any existing jQuery.browser in case it's different
  278. if ( !jQuery.browser ) {
  279. matched = jQuery.uaMatch( navigator.userAgent );
  280. browser = {};
  281. if ( matched.browser ) {
  282. browser[ matched.browser ] = true;
  283. browser.version = matched.version;
  284. }
  285. // Chrome is Webkit, but Webkit is also Safari.
  286. if ( browser.chrome ) {
  287. browser.webkit = true;
  288. } else if ( browser.webkit ) {
  289. browser.safari = true;
  290. }
  291. jQuery.browser = browser;
  292. }
  293. // Warn if the code tries to get jQuery.browser
  294. migrateWarnProp( jQuery, "browser", jQuery.browser, "jQuery.browser is deprecated" );
  295. // jQuery.boxModel deprecated in 1.3, jQuery.support.boxModel deprecated in 1.7
  296. jQuery.boxModel = jQuery.support.boxModel = (document.compatMode === "CSS1Compat");
  297. migrateWarnProp( jQuery, "boxModel", jQuery.boxModel, "jQuery.boxModel is deprecated" );
  298. migrateWarnProp( jQuery.support, "boxModel", jQuery.support.boxModel, "jQuery.support.boxModel is deprecated" );
  299. jQuery.sub = function() {
  300. function jQuerySub( selector, context ) {
  301. return new jQuerySub.fn.init( selector, context );
  302. }
  303. jQuery.extend( true, jQuerySub, this );
  304. jQuerySub.superclass = this;
  305. jQuerySub.fn = jQuerySub.prototype = this();
  306. jQuerySub.fn.constructor = jQuerySub;
  307. jQuerySub.sub = this.sub;
  308. jQuerySub.fn.init = function init( selector, context ) {
  309. var instance = jQuery.fn.init.call( this, selector, context, rootjQuerySub );
  310. return instance instanceof jQuerySub ?
  311. instance :
  312. jQuerySub( instance );
  313. };
  314. jQuerySub.fn.init.prototype = jQuerySub.fn;
  315. var rootjQuerySub = jQuerySub(document);
  316. migrateWarn( "jQuery.sub() is deprecated" );
  317. return jQuerySub;
  318. };
  319. // The number of elements contained in the matched element set
  320. jQuery.fn.size = function() {
  321. migrateWarn( "jQuery.fn.size() is deprecated; use the .length property" );
  322. return this.length;
  323. };
  324. var internalSwapCall = false;
  325. // If this version of jQuery has .swap(), don't false-alarm on internal uses
  326. if ( jQuery.swap ) {
  327. jQuery.each( [ "height", "width", "reliableMarginRight" ], function( _, name ) {
  328. var oldHook = jQuery.cssHooks[ name ] && jQuery.cssHooks[ name ].get;
  329. if ( oldHook ) {
  330. jQuery.cssHooks[ name ].get = function() {
  331. var ret;
  332. internalSwapCall = true;
  333. ret = oldHook.apply( this, arguments );
  334. internalSwapCall = false;
  335. return ret;
  336. };
  337. }
  338. });
  339. }
  340. jQuery.swap = function( elem, options, callback, args ) {
  341. var ret, name,
  342. old = {};
  343. if ( !internalSwapCall ) {
  344. migrateWarn( "jQuery.swap() is undocumented and deprecated" );
  345. }
  346. // Remember the old values, and insert the new ones
  347. for ( name in options ) {
  348. old[ name ] = elem.style[ name ];
  349. elem.style[ name ] = options[ name ];
  350. }
  351. ret = callback.apply( elem, args || [] );
  352. // Revert the old values
  353. for ( name in options ) {
  354. elem.style[ name ] = old[ name ];
  355. }
  356. return ret;
  357. };
  358. // Ensure that $.ajax gets the new parseJSON defined in core.js
  359. jQuery.ajaxSetup({
  360. converters: {
  361. "text json": jQuery.parseJSON
  362. }
  363. });
  364. var oldFnData = jQuery.fn.data;
  365. jQuery.fn.data = function( name ) {
  366. var ret, evt,
  367. elem = this[0];
  368. // Handles 1.7 which has this behavior and 1.8 which doesn't
  369. if ( elem && name === "events" && arguments.length === 1 ) {
  370. ret = jQuery.data( elem, name );
  371. evt = jQuery._data( elem, name );
  372. if ( ( ret === undefined || ret === evt ) && evt !== undefined ) {
  373. migrateWarn("Use of jQuery.fn.data('events') is deprecated");
  374. return evt;
  375. }
  376. }
  377. return oldFnData.apply( this, arguments );
  378. };
  379. var rscriptType = /\/(java|ecma)script/i;
  380. // Since jQuery.clean is used internally on older versions, we only shim if it's missing
  381. if ( !jQuery.clean ) {
  382. jQuery.clean = function( elems, context, fragment, scripts ) {
  383. // Set context per 1.8 logic
  384. context = context || document;
  385. context = !context.nodeType && context[0] || context;
  386. context = context.ownerDocument || context;
  387. migrateWarn("jQuery.clean() is deprecated");
  388. var i, elem, handleScript, jsTags,
  389. ret = [];
  390. jQuery.merge( ret, jQuery.buildFragment( elems, context ).childNodes );
  391. // Complex logic lifted directly from jQuery 1.8
  392. if ( fragment ) {
  393. // Special handling of each script element
  394. handleScript = function( elem ) {
  395. // Check if we consider it executable
  396. if ( !elem.type || rscriptType.test( elem.type ) ) {
  397. // Detach the script and store it in the scripts array (if provided) or the fragment
  398. // Return truthy to indicate that it has been handled
  399. return scripts ?
  400. scripts.push( elem.parentNode ? elem.parentNode.removeChild( elem ) : elem ) :
  401. fragment.appendChild( elem );
  402. }
  403. };
  404. for ( i = 0; (elem = ret[i]) != null; i++ ) {
  405. // Check if we're done after handling an executable script
  406. if ( !( jQuery.nodeName( elem, "script" ) && handleScript( elem ) ) ) {
  407. // Append to fragment and handle embedded scripts
  408. fragment.appendChild( elem );
  409. if ( typeof elem.getElementsByTagName !== "undefined" ) {
  410. // handleScript alters the DOM, so use jQuery.merge to ensure snapshot iteration
  411. jsTags = jQuery.grep( jQuery.merge( [], elem.getElementsByTagName("script") ), handleScript );
  412. // Splice the scripts into ret after their former ancestor and advance our index beyond them
  413. ret.splice.apply( ret, [i + 1, 0].concat( jsTags ) );
  414. i += jsTags.length;
  415. }
  416. }
  417. }
  418. }
  419. return ret;
  420. };
  421. }
  422. var eventAdd = jQuery.event.add,
  423. eventRemove = jQuery.event.remove,
  424. eventTrigger = jQuery.event.trigger,
  425. oldToggle = jQuery.fn.toggle,
  426. oldLive = jQuery.fn.live,
  427. oldDie = jQuery.fn.die,
  428. oldLoad = jQuery.fn.load,
  429. ajaxEvents = "ajaxStart|ajaxStop|ajaxSend|ajaxComplete|ajaxError|ajaxSuccess",
  430. rajaxEvent = new RegExp( "\\b(?:" + ajaxEvents + ")\\b" ),
  431. rhoverHack = /(?:^|\s)hover(\.\S+|)\b/,
  432. hoverHack = function( events ) {
  433. if ( typeof( events ) !== "string" || jQuery.event.special.hover ) {
  434. return events;
  435. }
  436. if ( rhoverHack.test( events ) ) {
  437. migrateWarn("'hover' pseudo-event is deprecated, use 'mouseenter mouseleave'");
  438. }
  439. return events && events.replace( rhoverHack, "mouseenter$1 mouseleave$1" );
  440. };
  441. // Event props removed in 1.9, put them back if needed; no practical way to warn them
  442. if ( jQuery.event.props && jQuery.event.props[ 0 ] !== "attrChange" ) {
  443. jQuery.event.props.unshift( "attrChange", "attrName", "relatedNode", "srcElement" );
  444. }
  445. // Undocumented jQuery.event.handle was "deprecated" in jQuery 1.7
  446. if ( jQuery.event.dispatch ) {
  447. migrateWarnProp( jQuery.event, "handle", jQuery.event.dispatch, "jQuery.event.handle is undocumented and deprecated" );
  448. }
  449. // Support for 'hover' pseudo-event and ajax event warnings
  450. jQuery.event.add = function( elem, types, handler, data, selector ){
  451. if ( elem !== document && rajaxEvent.test( types ) ) {
  452. migrateWarn( "AJAX events should be attached to document: " + types );
  453. }
  454. eventAdd.call( this, elem, hoverHack( types || "" ), handler, data, selector );
  455. };
  456. jQuery.event.remove = function( elem, types, handler, selector, mappedTypes ){
  457. eventRemove.call( this, elem, hoverHack( types ) || "", handler, selector, mappedTypes );
  458. };
  459. jQuery.each( [ "load", "unload", "error" ], function( _, name ) {
  460. jQuery.fn[ name ] = function() {
  461. var args = Array.prototype.slice.call( arguments, 0 );
  462. // If this is an ajax load() the first arg should be the string URL;
  463. // technically this could also be the "Anything" arg of the event .load()
  464. // which just goes to show why this dumb signature has been deprecated!
  465. // jQuery custom builds that exclude the Ajax module justifiably die here.
  466. if ( name === "load" && typeof args[ 0 ] === "string" ) {
  467. return oldLoad.apply( this, args );
  468. }
  469. migrateWarn( "jQuery.fn." + name + "() is deprecated" );
  470. args.splice( 0, 0, name );
  471. if ( arguments.length ) {
  472. return this.bind.apply( this, args );
  473. }
  474. // Use .triggerHandler here because:
  475. // - load and unload events don't need to bubble, only applied to window or image
  476. // - error event should not bubble to window, although it does pre-1.7
  477. // See http://bugs.jquery.com/ticket/11820
  478. this.triggerHandler.apply( this, args );
  479. return this;
  480. };
  481. });
  482. jQuery.fn.toggle = function( fn, fn2 ) {
  483. // Don't mess with animation or css toggles
  484. if ( !jQuery.isFunction( fn ) || !jQuery.isFunction( fn2 ) ) {
  485. return oldToggle.apply( this, arguments );
  486. }
  487. migrateWarn("jQuery.fn.toggle(handler, handler...) is deprecated");
  488. // Save reference to arguments for access in closure
  489. var args = arguments,
  490. guid = fn.guid || jQuery.guid++,
  491. i = 0,
  492. toggler = function( event ) {
  493. // Figure out which function to execute
  494. var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i;
  495. jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 );
  496. // Make sure that clicks stop
  497. event.preventDefault();
  498. // and execute the function
  499. return args[ lastToggle ].apply( this, arguments ) || false;
  500. };
  501. // link all the functions, so any of them can unbind this click handler
  502. toggler.guid = guid;
  503. while ( i < args.length ) {
  504. args[ i++ ].guid = guid;
  505. }
  506. return this.click( toggler );
  507. };
  508. jQuery.fn.live = function( types, data, fn ) {
  509. migrateWarn("jQuery.fn.live() is deprecated");
  510. if ( oldLive ) {
  511. return oldLive.apply( this, arguments );
  512. }
  513. jQuery( this.context ).on( types, this.selector, data, fn );
  514. return this;
  515. };
  516. jQuery.fn.die = function( types, fn ) {
  517. migrateWarn("jQuery.fn.die() is deprecated");
  518. if ( oldDie ) {
  519. return oldDie.apply( this, arguments );
  520. }
  521. jQuery( this.context ).off( types, this.selector || "**", fn );
  522. return this;
  523. };
  524. // Turn global events into document-triggered events
  525. jQuery.event.trigger = function( event, data, elem, onlyHandlers ){
  526. if ( !elem && !rajaxEvent.test( event ) ) {
  527. migrateWarn( "Global events are undocumented and deprecated" );
  528. }
  529. return eventTrigger.call( this, event, data, elem || document, onlyHandlers );
  530. };
  531. jQuery.each( ajaxEvents.split("|"),
  532. function( _, name ) {
  533. jQuery.event.special[ name ] = {
  534. setup: function() {
  535. var elem = this;
  536. // The document needs no shimming; must be !== for oldIE
  537. if ( elem !== document ) {
  538. jQuery.event.add( document, name + "." + jQuery.guid, function() {
  539. jQuery.event.trigger( name, Array.prototype.slice.call( arguments, 1 ), elem, true );
  540. });
  541. jQuery._data( this, name, jQuery.guid++ );
  542. }
  543. return false;
  544. },
  545. teardown: function() {
  546. if ( this !== document ) {
  547. jQuery.event.remove( document, name + "." + jQuery._data( this, name ) );
  548. }
  549. return false;
  550. }
  551. };
  552. }
  553. );
  554. jQuery.event.special.ready = {
  555. setup: function() {
  556. if ( this === document ) {
  557. migrateWarn( "'ready' event is deprecated" );
  558. }
  559. }
  560. };
  561. var oldSelf = jQuery.fn.andSelf || jQuery.fn.addBack,
  562. oldFnFind = jQuery.fn.find;
  563. jQuery.fn.andSelf = function() {
  564. migrateWarn("jQuery.fn.andSelf() replaced by jQuery.fn.addBack()");
  565. return oldSelf.apply( this, arguments );
  566. };
  567. jQuery.fn.find = function( selector ) {
  568. var ret = oldFnFind.apply( this, arguments );
  569. ret.context = this.context;
  570. ret.selector = this.selector ? this.selector + " " + selector : selector;
  571. return ret;
  572. };
  573. // jQuery 1.6 did not support Callbacks, do not warn there
  574. if ( jQuery.Callbacks ) {
  575. var oldDeferred = jQuery.Deferred,
  576. tuples = [
  577. // action, add listener, callbacks, .then handlers, final state
  578. [ "resolve", "done", jQuery.Callbacks("once memory"),
  579. jQuery.Callbacks("once memory"), "resolved" ],
  580. [ "reject", "fail", jQuery.Callbacks("once memory"),
  581. jQuery.Callbacks("once memory"), "rejected" ],
  582. [ "notify", "progress", jQuery.Callbacks("memory"),
  583. jQuery.Callbacks("memory") ]
  584. ];
  585. jQuery.Deferred = function( func ) {
  586. var deferred = oldDeferred(),
  587. promise = deferred.promise();
  588. deferred.pipe = promise.pipe = function( /* fnDone, fnFail, fnProgress */ ) {
  589. var fns = arguments;
  590. migrateWarn( "deferred.pipe() is deprecated" );
  591. return jQuery.Deferred(function( newDefer ) {
  592. jQuery.each( tuples, function( i, tuple ) {
  593. var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];
  594. // deferred.done(function() { bind to newDefer or newDefer.resolve })
  595. // deferred.fail(function() { bind to newDefer or newDefer.reject })
  596. // deferred.progress(function() { bind to newDefer or newDefer.notify })
  597. deferred[ tuple[1] ](function() {
  598. var returned = fn && fn.apply( this, arguments );
  599. if ( returned && jQuery.isFunction( returned.promise ) ) {
  600. returned.promise()
  601. .done( newDefer.resolve )
  602. .fail( newDefer.reject )
  603. .progress( newDefer.notify );
  604. } else {
  605. newDefer[ tuple[ 0 ] + "With" ](
  606. this === promise ? newDefer.promise() : this,
  607. fn ? [ returned ] : arguments
  608. );
  609. }
  610. });
  611. });
  612. fns = null;
  613. }).promise();
  614. };
  615. deferred.isResolved = function() {
  616. migrateWarn( "deferred.isResolved is deprecated" );
  617. return deferred.state() === "resolved";
  618. };
  619. deferred.isRejected = function() {
  620. migrateWarn( "deferred.isRejected is deprecated" );
  621. return deferred.state() === "rejected";
  622. };
  623. if ( func ) {
  624. func.call( deferred, deferred );
  625. }
  626. return deferred;
  627. };
  628. }
  629. })( jQuery, window );