/*!
* jquery migrate - v1.2.1 - 2013-05-08
* https://github.com/jquery/jquery-migrate
* copyright 2005, 2013 jquery foundation, inc. and other contributors; licensed mit
*/
(function( jquery, window, undefined ) {
// see http://bugs.jquery.com/ticket/13335
// "use strict";
var warnedabout = {};
// list of warnings already given; public read only
jquery.migratewarnings = [];
// set to true to prevent console output; migratewarnings still maintained
// jquery.migratemute = false;
// show a message on the console so devs know we're active
if ( !jquery.migratemute && window.console && window.console.log ) {
window.console.log("jqmigrate: logging is active");
}
// set to false to disable traces that appear with warnings
if ( jquery.migratetrace === undefined ) {
jquery.migratetrace = true;
}
// forget any warnings we've already given; public
jquery.migratereset = function() {
warnedabout = {};
jquery.migratewarnings.length = 0;
};
function migratewarn( msg) {
var console = window.console;
if ( !warnedabout[ msg ] ) {
warnedabout[ msg ] = true;
jquery.migratewarnings.push( msg );
if ( console && console.warn && !jquery.migratemute ) {
console.warn( "jqmigrate: " + msg );
if ( jquery.migratetrace && console.trace ) {
console.trace();
}
}
}
}
function migratewarnprop( obj, prop, value, msg ) {
if ( object.defineproperty ) {
// on es5 browsers (non-oldie), warn if the code tries to get prop;
// allow property to be overwritten in case some other plugin wants it
try {
object.defineproperty( obj, prop, {
configurable: true,
enumerable: true,
get: function() {
migratewarn( msg );
return value;
},
set: function( newvalue ) {
migratewarn( msg );
value = newvalue;
}
});
return;
} catch( err ) {
// ie8 is a dope about object.defineproperty, can't warn there
}
}
// non-es5 (or broken) browser; just set the property
jquery._definepropertybroken = true;
obj[ prop ] = value;
}
if ( document.compatmode === "backcompat" ) {
// jquery has never supported or tested quirks mode
migratewarn( "jquery is not compatible with quirks mode" );
}
var attrfn = jquery( " ", { size: 1 } ).attr("size") && jquery.attrfn,
oldattr = jquery.attr,
valueattrget = jquery.attrhooks.value && jquery.attrhooks.value.get ||
function() { return null; },
valueattrset = jquery.attrhooks.value && jquery.attrhooks.value.set ||
function() { return undefined; },
rnotype = /^(?:input|button)$/i,
rnoattrnodetype = /^[238]$/,
rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,
rusedefault = /^(?:checked|selected)$/i;
// jquery.attrfn
migratewarnprop( jquery, "attrfn", attrfn || {}, "jquery.attrfn is deprecated" );
jquery.attr = function( elem, name, value, pass ) {
var lowername = name.tolowercase(),
ntype = elem && elem.nodetype;
if ( pass ) {
// since pass is used internally, we only warn for new jquery
// versions where there isn't a pass arg in the formal params
if ( oldattr.length < 4 ) {
migratewarn("jquery.fn.attr( props, pass ) is deprecated");
}
if ( elem && !rnoattrnodetype.test( ntype ) &&
(attrfn ? name in attrfn : jquery.isfunction(jquery.fn[name])) ) {
return jquery( elem )[ name ]( value );
}
}
// warn if user tries to set `type`, since it breaks on ie 6/7/8; by checking
// for disconnected elements we don't warn on $( "", { type: "button" } ).
if ( name === "type" && value !== undefined && rnotype.test( elem.nodename ) && elem.parentnode ) {
migratewarn("can't change the 'type' of an input or button in ie 6/7/8");
}
// restore boolhook for boolean property/attribute synchronization
if ( !jquery.attrhooks[ lowername ] && rboolean.test( lowername ) ) {
jquery.attrhooks[ lowername ] = {
get: function( elem, name ) {
// align boolean attributes with corresponding properties
// fall back to attribute presence where some booleans are not supported
var attrnode,
property = jquery.prop( elem, name );
return property === true || typeof property !== "boolean" &&
( attrnode = elem.getattributenode(name) ) && attrnode.nodevalue !== false ?
name.tolowercase() :
undefined;
},
set: function( elem, value, name ) {
var propname;
if ( value === false ) {
// remove boolean attributes when set to false
jquery.removeattr( elem, name );
} else {
// value is true since we know at this point it's type boolean and not false
// set boolean attributes to the same name and set the dom property
propname = jquery.propfix[ name ] || name;
if ( propname in elem ) {
// only set the idl specifically if it already exists on the element
elem[ propname ] = true;
}
elem.setattribute( name, name.tolowercase() );
}
return name;
}
};
// warn only for attributes that can remain distinct from their properties post-1.9
if ( rusedefault.test( lowername ) ) {
migratewarn( "jquery.fn.attr('" + lowername + "') may use property instead of attribute" );
}
}
return oldattr.call( jquery, elem, name, value );
};
// attrhooks: value
jquery.attrhooks.value = {
get: function( elem, name ) {
var nodename = ( elem.nodename || "" ).tolowercase();
if ( nodename === "button" ) {
return valueattrget.apply( this, arguments );
}
if ( nodename !== "input" && nodename !== "option" ) {
migratewarn("jquery.fn.attr('value') no longer gets properties");
}
return name in elem ?
elem.value :
null;
},
set: function( elem, value ) {
var nodename = ( elem.nodename || "" ).tolowercase();
if ( nodename === "button" ) {
return valueattrset.apply( this, arguments );
}
if ( nodename !== "input" && nodename !== "option" ) {
migratewarn("jquery.fn.attr('value', val) no longer sets properties");
}
// does not return so that setattribute is also used
elem.value = value;
}
};
var matched, browser,
oldinit = jquery.fn.init,
oldparsejson = jquery.parsejson,
// note: xss check is done below after string is trimmed
rquickexpr = /^([^<]*)(<[\w\w]+>)([^>]*)$/;
// $(html) "looks like html" rule change
jquery.fn.init = function( selector, context, rootjquery ) {
var match;
if ( selector && typeof selector === "string" && !jquery.isplainobject( context ) &&
(match = rquickexpr.exec( jquery.trim( selector ) )) && match[ 0 ] ) {
// this is an html string according to the "old" rules; is it still?
if ( selector.charat( 0 ) !== "<" ) {
migratewarn("$(html) html strings must start with '<' character");
}
if ( match[ 3 ] ) {
migratewarn("$(html) html text after last tag is ignored");
}
// consistently reject any html-like string starting with a hash (#9521)
// note that this may break jquery 1.6.x code that otherwise would work.
if ( match[ 0 ].charat( 0 ) === "#" ) {
migratewarn("html string cannot start with a '#' character");
jquery.error("jqmigrate: invalid selector string (xss)");
}
// now process using loose rules; let pre-1.8 play too
if ( context && context.context ) {
// jquery object as context; parsehtml expects a dom object
context = context.context;
}
if ( jquery.parsehtml ) {
return oldinit.call( this, jquery.parsehtml( match[ 2 ], context, true ),
context, rootjquery );
}
}
return oldinit.apply( this, arguments );
};
jquery.fn.init.prototype = jquery.fn;
// let $.parsejson(falsy_value) return null
jquery.parsejson = function( json ) {
if ( !json && json !== null ) {
migratewarn("jquery.parsejson requires a valid json string");
return null;
}
return oldparsejson.apply( this, arguments );
};
jquery.uamatch = function( ua ) {
ua = ua.tolowercase();
var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) ||
/(webkit)[ \/]([\w.]+)/.exec( ua ) ||
/(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
/(msie) ([\w.]+)/.exec( ua ) ||
ua.indexof("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) ||
[];
return {
browser: match[ 1 ] || "",
version: match[ 2 ] || "0"
};
};
// don't clobber any existing jquery.browser in case it's different
if ( !jquery.browser ) {
matched = jquery.uamatch( navigator.useragent );
browser = {};
if ( matched.browser ) {
browser[ matched.browser ] = true;
browser.version = matched.version;
}
// chrome is webkit, but webkit is also safari.
if ( browser.chrome ) {
browser.webkit = true;
} else if ( browser.webkit ) {
browser.safari = true;
}
jquery.browser = browser;
}
// warn if the code tries to get jquery.browser
migratewarnprop( jquery, "browser", jquery.browser, "jquery.browser is deprecated" );
jquery.sub = function() {
function jquerysub( selector, context ) {
return new jquerysub.fn.init( selector, context );
}
jquery.extend( true, jquerysub, this );
jquerysub.superclass = this;
jquerysub.fn = jquerysub.prototype = this();
jquerysub.fn.constructor = jquerysub;
jquerysub.sub = this.sub;
jquerysub.fn.init = function init( selector, context ) {
if ( context && context instanceof jquery && !(context instanceof jquerysub) ) {
context = jquerysub( context );
}
return jquery.fn.init.call( this, selector, context, rootjquerysub );
};
jquerysub.fn.init.prototype = jquerysub.fn;
var rootjquerysub = jquerysub(document);
migratewarn( "jquery.sub() is deprecated" );
return jquerysub;
};
// ensure that $.ajax gets the new parsejson defined in core.js
jquery.ajaxsetup({
converters: {
"text json": jquery.parsejson
}
});
var oldfndata = jquery.fn.data;
jquery.fn.data = function( name ) {
var ret, evt,
elem = this[0];
// handles 1.7 which has this behavior and 1.8 which doesn't
if ( elem && name === "events" && arguments.length === 1 ) {
ret = jquery.data( elem, name );
evt = jquery._data( elem, name );
if ( ( ret === undefined || ret === evt ) && evt !== undefined ) {
migratewarn("use of jquery.fn.data('events') is deprecated");
return evt;
}
}
return oldfndata.apply( this, arguments );
};
var rscripttype = /\/(java|ecma)script/i,
oldself = jquery.fn.andself || jquery.fn.addback;
jquery.fn.andself = function() {
migratewarn("jquery.fn.andself() replaced by jquery.fn.addback()");
return oldself.apply( this, arguments );
};
// since jquery.clean is used internally on older versions, we only shim if it's missing
if ( !jquery.clean ) {
jquery.clean = function( elems, context, fragment, scripts ) {
// set context per 1.8 logic
context = context || document;
context = !context.nodetype && context[0] || context;
context = context.ownerdocument || context;
migratewarn("jquery.clean() is deprecated");
var i, elem, handlescript, jstags,
ret = [];
jquery.merge( ret, jquery.buildfragment( elems, context ).childnodes );
// complex logic lifted directly from jquery 1.8
if ( fragment ) {
// special handling of each script element
handlescript = function( elem ) {
// check if we consider it executable
if ( !elem.type || rscripttype.test( elem.type ) ) {
// detach the script and store it in the scripts array (if provided) or the fragment
// return truthy to indicate that it has been handled
return scripts ?
scripts.push( elem.parentnode ? elem.parentnode.removechild( elem ) : elem ) :
fragment.appendchild( elem );
}
};
for ( i = 0; (elem = ret[i]) != null; i++ ) {
// check if we're done after handling an executable script
if ( !( jquery.nodename( elem, "script" ) && handlescript( elem ) ) ) {
// append to fragment and handle embedded scripts
fragment.appendchild( elem );
if ( typeof elem.getelementsbytagname !== "undefined" ) {
// handlescript alters the dom, so use jquery.merge to ensure snapshot iteration
jstags = jquery.grep( jquery.merge( [], elem.getelementsbytagname("script") ), handlescript );
// splice the scripts into ret after their former ancestor and advance our index beyond them
ret.splice.apply( ret, [i + 1, 0].concat( jstags ) );
i += jstags.length;
}
}
}
}
return ret;
};
}
var eventadd = jquery.event.add,
eventremove = jquery.event.remove,
eventtrigger = jquery.event.trigger,
oldtoggle = jquery.fn.toggle,
oldlive = jquery.fn.live,
olddie = jquery.fn.die,
ajaxevents = "ajaxstart|ajaxstop|ajaxsend|ajaxcomplete|ajaxerror|ajaxsuccess",
rajaxevent = new regexp( "\\b(?:" + ajaxevents + ")\\b" ),
rhoverhack = /(?:^|\s)hover(\.\s+|)\b/,
hoverhack = function( events ) {
if ( typeof( events ) !== "string" || jquery.event.special.hover ) {
return events;
}
if ( rhoverhack.test( events ) ) {
migratewarn("'hover' pseudo-event is deprecated, use 'mouseenter mouseleave'");
}
return events && events.replace( rhoverhack, "mouseenter$1 mouseleave$1" );
};
// event props removed in 1.9, put them back if needed; no practical way to warn them
if ( jquery.event.props && jquery.event.props[ 0 ] !== "attrchange" ) {
jquery.event.props.unshift( "attrchange", "attrname", "relatednode", "srcelement" );
}
// undocumented jquery.event.handle was "deprecated" in jquery 1.7
if ( jquery.event.dispatch ) {
migratewarnprop( jquery.event, "handle", jquery.event.dispatch, "jquery.event.handle is undocumented and deprecated" );
}
// support for 'hover' pseudo-event and ajax event warnings
jquery.event.add = function( elem, types, handler, data, selector ){
if ( elem !== document && rajaxevent.test( types ) ) {
migratewarn( "ajax events should be attached to document: " + types );
}
eventadd.call( this, elem, hoverhack( types || "" ), handler, data, selector );
};
jquery.event.remove = function( elem, types, handler, selector, mappedtypes ){
eventremove.call( this, elem, hoverhack( types ) || "", handler, selector, mappedtypes );
};
jquery.fn.error = function() {
var args = array.prototype.slice.call( arguments, 0);
migratewarn("jquery.fn.error() is deprecated");
args.splice( 0, 0, "error" );
if ( arguments.length ) {
return this.bind.apply( this, args );
}
// error event should not bubble to window, although it does pre-1.7
this.triggerhandler.apply( this, args );
return this;
};
jquery.fn.toggle = function( fn, fn2 ) {
// don't mess with animation or css toggles
if ( !jquery.isfunction( fn ) || !jquery.isfunction( fn2 ) ) {
return oldtoggle.apply( this, arguments );
}
migratewarn("jquery.fn.toggle(handler, handler...) is deprecated");
// save reference to arguments for access in closure
var args = arguments,
guid = fn.guid || jquery.guid++,
i = 0,
toggler = function( event ) {
// figure out which function to execute
var lasttoggle = ( jquery._data( this, "lasttoggle" + fn.guid ) || 0 ) % i;
jquery._data( this, "lasttoggle" + fn.guid, lasttoggle + 1 );
// make sure that clicks stop
event.preventdefault();
// and execute the function
return args[ lasttoggle ].apply( this, arguments ) || false;
};
// link all the functions, so any of them can unbind this click handler
toggler.guid = guid;
while ( i < args.length ) {
args[ i++ ].guid = guid;
}
return this.click( toggler );
};
jquery.fn.live = function( types, data, fn ) {
migratewarn("jquery.fn.live() is deprecated");
if ( oldlive ) {
return oldlive.apply( this, arguments );
}
jquery( this.context ).on( types, this.selector, data, fn );
return this;
};
jquery.fn.die = function( types, fn ) {
migratewarn("jquery.fn.die() is deprecated");
if ( olddie ) {
return olddie.apply( this, arguments );
}
jquery( this.context ).off( types, this.selector || "**", fn );
return this;
};
// turn global events into document-triggered events
jquery.event.trigger = function( event, data, elem, onlyhandlers ){
if ( !elem && !rajaxevent.test( event ) ) {
migratewarn( "global events are undocumented and deprecated" );
}
return eventtrigger.call( this, event, data, elem || document, onlyhandlers );
};
jquery.each( ajaxevents.split("|"),
function( _, name ) {
jquery.event.special[ name ] = {
setup: function() {
var elem = this;
// the document needs no shimming; must be !== for oldie
if ( elem !== document ) {
jquery.event.add( document, name + "." + jquery.guid, function() {
jquery.event.trigger( name, null, elem, true );
});
jquery._data( this, name, jquery.guid++ );
}
return false;
},
teardown: function() {
if ( this !== document ) {
jquery.event.remove( document, name + "." + jquery._data( this, name ) );
}
return false;
}
};
}
);
})( jquery, window );