+(function( jQuery ) {
+
var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
rleadingWhitespace = /^\s+/,
- rxhtmlTag = /(<([\w:]+)[^>]*?)\/>/g,
- rselfClosing = /^(?:abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i,
+ rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,
rtagName = /<([\w:]+)/,
rtbody = /<tbody/i,
- rhtml = /<|&\w+;/,
- fcloseTag = function(all, front, tag){
- return rselfClosing.test(tag) ?
- all :
- front + "></" + tag + ">";
- },
+ rhtml = /<|&#?\w+;/,
+ rnocache = /<(?:script|object|embed|option|style)/i,
+ rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, // checked="checked" or checked (html5)
+ raction = /\=([^="'>\s]+\/)>/g,
wrapMap = {
option: [ 1, "<select multiple='multiple'>", "</select>" ],
legend: [ 1, "<fieldset>", "</fieldset>" ],
jQuery.fn.extend({
text: function( text ) {
+ if ( jQuery.isFunction(text) ) {
+ return this.each(function(i) {
+ var self = jQuery(this);
+ self.text( text.call(this, i, self.text()) );
+ });
+ }
+
if ( typeof text !== "object" && text !== undefined ) {
return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );
}
- return jQuery.getText( this );
+ return jQuery.text( this );
},
wrapAll: function( html ) {
if ( jQuery.isFunction( html ) ) {
- return this.each(function() {
- jQuery(this).wrapAll( html.apply(this, arguments) );
+ return this.each(function(i) {
+ jQuery(this).wrapAll( html.call(this, i) );
});
}
wrap.insertBefore( this[0] );
}
- wrap.map(function(){
+ wrap.map(function() {
var elem = this;
while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
},
wrapInner: function( html ) {
- return this.each(function(){
- jQuery( this ).contents().wrapAll( html );
+ if ( jQuery.isFunction( html ) ) {
+ return this.each(function(i) {
+ jQuery(this).wrapInner( html.call(this, i) );
+ });
+ }
+
+ return this.each(function() {
+ var self = jQuery( this ), contents = self.contents();
+
+ if ( contents.length ) {
+ contents.wrapAll( html );
+
+ } else {
+ self.append( html );
+ }
});
},
wrap: function( html ) {
- return this.each(function(){
+ return this.each(function() {
jQuery( this ).wrapAll( html );
});
},
unwrap: function() {
- return this.parent().each(function(){
+ return this.parent().each(function() {
if ( !jQuery.nodeName( this, "body" ) ) {
jQuery( this ).replaceWith( this.childNodes );
}
}).end();
},
-
+
append: function() {
- return this.domManip(arguments, true, function(elem){
+ return this.domManip(arguments, true, function( elem ) {
if ( this.nodeType === 1 ) {
this.appendChild( elem );
}
},
prepend: function() {
- return this.domManip(arguments, true, function(elem){
+ return this.domManip(arguments, true, function( elem ) {
if ( this.nodeType === 1 ) {
this.insertBefore( elem, this.firstChild );
}
before: function() {
if ( this[0] && this[0].parentNode ) {
- return this.domManip(arguments, false, function(elem){
+ return this.domManip(arguments, false, function( elem ) {
this.parentNode.insertBefore( elem, this );
});
} else if ( arguments.length ) {
after: function() {
if ( this[0] && this[0].parentNode ) {
- return this.domManip(arguments, false, function(elem){
+ return this.domManip(arguments, false, function( elem ) {
this.parentNode.insertBefore( elem, this.nextSibling );
});
} else if ( arguments.length ) {
return set;
}
},
+
+ // keepData is for internal use only--do not document
+ remove: function( selector, keepData ) {
+ for ( var i = 0, elem; (elem = this[i]) != null; i++ ) {
+ if ( !selector || jQuery.filter( selector, [ elem ] ).length ) {
+ if ( !keepData && elem.nodeType === 1 ) {
+ jQuery.cleanData( elem.getElementsByTagName("*") );
+ jQuery.cleanData( [ elem ] );
+ }
+
+ if ( elem.parentNode ) {
+ elem.parentNode.removeChild( elem );
+ }
+ }
+ }
+
+ return this;
+ },
+
+ empty: function() {
+ for ( var i = 0, elem; (elem = this[i]) != null; i++ ) {
+ // Remove element nodes and prevent memory leaks
+ if ( elem.nodeType === 1 ) {
+ jQuery.cleanData( elem.getElementsByTagName("*") );
+ }
+
+ // Remove any remaining nodes
+ while ( elem.firstChild ) {
+ elem.removeChild( elem.firstChild );
+ }
+ }
+
+ return this;
+ },
clone: function( events ) {
// Do the clone
- var ret = this.map(function(){
+ var ret = this.map(function() {
if ( !jQuery.support.noCloneEvent && !jQuery.isXMLDoc(this) ) {
// IE copies events bound via attachEvent when
// using cloneNode. Calling detachEvent on the
}
return jQuery.clean([html.replace(rinlinejQuery, "")
+ // Handle the case in IE 8 where action=/test/> self-closes a tag
+ .replace(raction, '="$1">')
.replace(rleadingWhitespace, "")], ownerDocument)[0];
} else {
return this.cloneNode(true);
html: function( value ) {
if ( value === undefined ) {
- return this[0] ?
+ return this[0] && this[0].nodeType === 1 ?
this[0].innerHTML.replace(rinlinejQuery, "") :
null;
// See if we can take a shortcut and just use innerHTML
- } else if ( typeof value === "string" && !/<script/i.test( value ) &&
+ } else if ( typeof value === "string" && !rnocache.test( value ) &&
(jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value )) &&
!wrapMap[ (rtagName.exec( value ) || ["", ""])[1].toLowerCase() ] ) {
+ value = value.replace(rxhtmlTag, "<$1></$2>");
+
try {
for ( var i = 0, l = this.length; i < l; i++ ) {
// Remove element nodes and prevent memory leaks
if ( this[i].nodeType === 1 ) {
- cleanData( this[i].getElementsByTagName("*") );
+ jQuery.cleanData( this[i].getElementsByTagName("*") );
this[i].innerHTML = value;
}
}
this.empty().append( value );
}
+ } else if ( jQuery.isFunction( value ) ) {
+ this.each(function(i){
+ var self = jQuery(this), old = self.html();
+ self.empty().append(function(){
+ return value.call( this, i, old );
+ });
+ });
+
} else {
this.empty().append( value );
}
replaceWith: function( value ) {
if ( this[0] && this[0].parentNode ) {
- return this.each(function(){
+ // Make sure that the elements are removed from the DOM before they are inserted
+ // this can help fix replacing a parent with child elements
+ if ( jQuery.isFunction( value ) ) {
+ return this.each(function(i) {
+ var self = jQuery(this), old = self.html();
+ self.replaceWith( value.call( this, i, old ) );
+ });
+ }
+
+ if ( typeof value !== "string" ) {
+ value = jQuery(value).detach();
+ }
+
+ return this.each(function() {
var next = this.nextSibling, parent = this.parentNode;
jQuery(this).remove();
},
domManip: function( args, table, callback ) {
- var results, first, value = args[0], scripts = [];
+ var results, first, value = args[0], scripts = [], fragment, parent;
- if ( jQuery.isFunction(value) ) {
+ // We can't cloneNode fragments that contain checked, in WebKit
+ if ( !jQuery.support.checkClone && arguments.length === 3 && typeof value === "string" && rchecked.test( value ) ) {
return this.each(function() {
- args[0] = value.call(this);
- return jQuery(this).domManip( args, table, callback );
+ jQuery(this).domManip( args, table, callback, true );
+ });
+ }
+
+ if ( jQuery.isFunction(value) ) {
+ return this.each(function(i) {
+ var self = jQuery(this);
+ args[0] = value.call(this, i, table ? self.html() : undefined);
+ self.domManip( args, table, callback );
});
}
if ( this[0] ) {
+ parent = value && value.parentNode;
+
// If we're in a fragment, just use that instead of building a new one
- if ( args[0] && args[0].parentNode && args[0].parentNode.nodeType === 11 ) {
- results = { fragment: args[0].parentNode };
+ if ( jQuery.support.parentNode && parent && parent.nodeType === 11 && parent.childNodes.length === this.length ) {
+ results = { fragment: parent };
+
} else {
- results = buildFragment( args, this, scripts );
+ results = jQuery.buildFragment( args, this, scripts );
+ }
+
+ fragment = results.fragment;
+
+ if ( fragment.childNodes.length === 1 ) {
+ first = fragment = fragment.firstChild;
+ } else {
+ first = fragment.firstChild;
}
-
- first = results.fragment.firstChild;
if ( first ) {
table = table && jQuery.nodeName( first, "tr" );
table ?
root(this[i], first) :
this[i],
- results.cacheable || this.length > 1 || i > 0 ?
- results.fragment.cloneNode(true) :
- results.fragment
+ i > 0 || results.cacheable || this.length > 1 ?
+ fragment.cloneNode(true) :
+ fragment
);
}
}
- if ( scripts ) {
+ if ( scripts.length ) {
jQuery.each( scripts, evalScript );
}
}
return this;
-
- function root( elem, cur ) {
- return jQuery.nodeName(elem, "table") ?
- (elem.getElementsByTagName("tbody")[0] ||
- elem.appendChild(elem.ownerDocument.createElement("tbody"))) :
- elem;
- }
}
});
+function root( elem, cur ) {
+ return jQuery.nodeName(elem, "table") ?
+ (elem.getElementsByTagName("tbody")[0] ||
+ elem.appendChild(elem.ownerDocument.createElement("tbody"))) :
+ elem;
+}
+
function cloneCopyEvent(orig, ret) {
var i = 0;
- ret.each(function(){
- if ( this.nodeName !== orig[i].nodeName ) {
+ ret.each(function() {
+ if ( this.nodeName !== (orig[i] && orig[i].nodeName) ) {
return;
}
- var events = jQuery.data( orig[i], "events" );
+ var oldData = jQuery.data( orig[i++] ), curData = jQuery.data( this, oldData ), events = oldData && oldData.events;
+
+ if ( events ) {
+ delete curData.handle;
+ curData.events = {};
- for ( var type in events ) {
- for ( var handler in events[ type ] ) {
- jQuery.event.add( this, type, events[ type ][ handler ], events[ type ][ handler ].data );
+ for ( var type in events ) {
+ for ( var handler in events[ type ] ) {
+ jQuery.event.add( this, type, events[ type ][ handler ], events[ type ][ handler ].data );
+ }
}
}
});
}
-function buildFragment(args, nodes, scripts){
- var fragment, cacheable, cached, cacheresults, doc;
+jQuery.buildFragment = function( args, nodes, scripts ) {
+ var fragment, cacheable, cacheresults,
+ doc = (nodes && nodes[0] ? nodes[0].ownerDocument || nodes[0] : document);
+
+ // Only cache "small" (1/2 KB) strings that are associated with the main document
+ // Cloning options loses the selected state, so don't cache them
+ // IE 6 doesn't like it when you put <object> or <embed> elements in a fragment
+ // Also, WebKit does not clone 'checked' attributes on cloneNode, so don't cache
+ if ( args.length === 1 && typeof args[0] === "string" && args[0].length < 512 && doc === document &&
+ !rnocache.test( args[0] ) && (jQuery.support.checkClone || !rchecked.test( args[0] )) ) {
- if ( args.length === 1 && typeof args[0] === "string" && args[0].length < 512 && args[0].indexOf("<option") < 0 ) {
cacheable = true;
cacheresults = jQuery.fragments[ args[0] ];
if ( cacheresults ) {
if ( cacheresults !== 1 ) {
fragment = cacheresults;
}
- cached = true;
}
}
if ( !fragment ) {
- doc = (nodes && nodes[0] ? nodes[0].ownerDocument || nodes[0] : document);
fragment = doc.createDocumentFragment();
jQuery.clean( args, doc, fragment, scripts );
}
}
return { fragment: fragment, cacheable: cacheable };
-}
+};
jQuery.fragments = {};
insertBefore: "before",
insertAfter: "after",
replaceAll: "replaceWith"
-}, function(name, original){
+}, function( name, original ) {
jQuery.fn[ name ] = function( selector ) {
- var ret = [], insert = jQuery( selector );
-
- for ( var i = 0, l = insert.length; i < l; i++ ) {
- var elems = (i > 0 ? this.clone(true) : this).get();
- jQuery.fn[ original ].apply( jQuery(insert[i]), elems );
- ret = ret.concat( elems );
- }
- return this.pushStack( ret, name, insert.selector );
- };
-});
-
-jQuery.each({
- // keepData is for internal use only--do not document
- remove: function( selector, keepData ) {
- if ( !selector || jQuery.filter( selector, [ this ] ).length ) {
- if ( !keepData && this.nodeType === 1 ) {
- cleanData( this.getElementsByTagName("*") );
- cleanData( [ this ] );
- }
-
- if ( this.parentNode ) {
- this.parentNode.removeChild( this );
+ var ret = [], insert = jQuery( selector ),
+ parent = this.length === 1 && this[0].parentNode;
+
+ if ( parent && parent.nodeType === 11 && parent.childNodes.length === 1 && insert.length === 1 ) {
+ insert[ original ]( this[0] );
+ return this;
+
+ } else {
+ for ( var i = 0, l = insert.length; i < l; i++ ) {
+ var elems = (i > 0 ? this.clone(true) : this).get();
+ jQuery( insert[i] )[ original ]( elems );
+ ret = ret.concat( elems );
}
+
+ return this.pushStack( ret, name, insert.selector );
}
- },
-
- empty: function() {
- // Remove element nodes and prevent memory leaks
- if ( this.nodeType === 1 ) {
- cleanData( this.getElementsByTagName("*") );
- }
-
- // Remove any remaining nodes
- while ( this.firstChild ) {
- this.removeChild( this.firstChild );
- }
- }
-}, function(name, fn){
- jQuery.fn[ name ] = function(){
- return this.each( fn, arguments );
};
});
var ret = [];
- jQuery.each(elems, function(i, elem){
+ for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
if ( typeof elem === "number" ) {
- elem += '';
+ elem += "";
}
- if ( !elem ) { return; }
+ if ( !elem ) {
+ continue;
+ }
// Convert html string into DOM nodes
if ( typeof elem === "string" && !rhtml.test( elem ) ) {
} else if ( typeof elem === "string" ) {
// Fix "XHTML"-style tags in all browsers
- elem = elem.replace(rxhtmlTag, fcloseTag);
+ elem = elem.replace(rxhtmlTag, "<$1></$2>");
// Trim whitespace, otherwise indexOf won't work as expected
var tag = (rtagName.exec( elem ) || ["", ""])[1].toLowerCase(),
div.firstChild && div.firstChild.childNodes :
// String was a bare <thead> or <tfoot>
- wrap[1] == "<table>" && !hasBody ?
+ wrap[1] === "<table>" && !hasBody ?
div.childNodes :
[];
div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild );
}
- elem = jQuery.makeArray( div.childNodes );
+ elem = div.childNodes;
}
if ( elem.nodeType ) {
} else {
ret = jQuery.merge( ret, elem );
}
-
- });
+ }
if ( fragment ) {
- for ( var i = 0; ret[i]; i++ ) {
+ for ( i = 0; ret[i]; i++ ) {
if ( scripts && jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) {
scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] );
+
} else {
if ( ret[i].nodeType === 1 ) {
ret.splice.apply( ret, [i + 1, 0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))) );
}
return ret;
+ },
+
+ cleanData: function( elems ) {
+ var data, id, cache = jQuery.cache,
+ special = jQuery.event.special,
+ deleteExpando = jQuery.support.deleteExpando;
+
+ for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
+ if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) {
+ continue;
+ }
+
+ id = elem[ jQuery.expando ];
+
+ if ( id ) {
+ data = cache[ id ];
+
+ if ( data && data.events ) {
+ for ( var type in data.events ) {
+ if ( special[ type ] ) {
+ jQuery.event.remove( elem, type );
+
+ } else {
+ jQuery.removeEvent( elem, type, data.handle );
+ }
+ }
+ }
+
+ if ( deleteExpando ) {
+ delete elem[ jQuery.expando ];
+
+ } else if ( elem.removeAttribute ) {
+ elem.removeAttribute( jQuery.expando );
+ }
+
+ delete cache[ id ];
+ }
+ }
}
});
-function cleanData( elems ) {
- for ( var i = 0, elem, id; (elem = elems[i]) != null; i++ ) {
- if ( !jQuery.noData[elem.nodeName.toLowerCase()] && (id = elem[expando]) ) {
- delete jQuery.cache[ id ];
- }
+function evalScript( i, elem ) {
+ if ( elem.src ) {
+ jQuery.ajax({
+ url: elem.src,
+ async: false,
+ dataType: "script"
+ });
+ } else {
+ jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" );
+ }
+
+ if ( elem.parentNode ) {
+ elem.parentNode.removeChild( elem );
}
}
+
+})( jQuery );