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, rinsideTable = /^<(thead|tbody|tfoot|colg|cap)/, rtbody = /"; }; jQuery.fn.extend({ text: function( text ) { if ( typeof text !== "object" && text !== undefined ) return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) ); var ret = ""; jQuery.each( text || this, function(){ jQuery.each( this.childNodes, function(){ if ( this.nodeType !== 8 ) { ret += this.nodeType !== 1 ? this.nodeValue : jQuery.fn.text( [ this ] ); } }); }); return ret; }, wrapAll: function( html ) { if ( jQuery.isFunction( html ) ) { return this.each(function() { jQuery(this).wrapAll( html.apply(this, arguments) ); }); } if ( this[0] ) { // The elements to wrap the target around var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(); if ( this[0].parentNode ) { wrap.insertBefore( this[0] ); } wrap.map(function(){ var elem = this; while ( elem.firstChild && elem.firstChild.nodeType === 1 ) { elem = elem.firstChild; } return elem; }).append(this); } return this; }, wrapInner: function( html ) { return this.each(function(){ jQuery( this ).contents().wrapAll( html ); }); }, wrap: function( html ) { return this.each(function(){ jQuery( this ).wrapAll( html ); }); }, append: function() { return this.domManip(arguments, true, function(elem){ if ( this.nodeType === 1 ) { this.appendChild( elem ); } }); }, prepend: function() { return this.domManip(arguments, true, function(elem){ if ( this.nodeType === 1 ) { this.insertBefore( elem, this.firstChild ); } }); }, before: function() { return this.domManip(arguments, false, function(elem){ this.parentNode.insertBefore( elem, this ); }); }, after: function() { return this.domManip(arguments, false, function(elem){ this.parentNode.insertBefore( elem, this.nextSibling ); }); }, clone: function( events ) { // Do the clone 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 // clone will also remove the events from the orignal // In order to get around this, we use innerHTML. // Unfortunately, this means some modifications to // attributes in IE that are actually only stored // as properties will not be copied (such as the // the name attribute on an input). var html = this.outerHTML, ownerDocument = this.ownerDocument; if ( !html ) { var div = ownerDocument.createElement("div"); div.appendChild( this.cloneNode(true) ); html = div.innerHTML; } return jQuery.clean([html.replace(rinlinejQuery, "") .replace(rleadingWhitespace, "")], ownerDocument)[0]; } else { return this.cloneNode(true); } }); // Copy the events from the original to the clone if ( events === true ) { var orig = this.find("*").andSelf(), i = 0; ret.find("*").andSelf().each(function(){ if ( this.nodeName !== orig[i].nodeName ) { return; } var events = jQuery.data( orig[i], "events" ); for ( var type in events ) { for ( var handler in events[ type ] ) { jQuery.event.add( this, type, events[ type ][ handler ], events[ type ][ handler ].data ); } } i++; }); } // Return the cloned set return ret; }, html: function( value ) { return value === undefined ? (this[0] ? this[0].innerHTML.replace(rinlinejQuery, "") : null) : this.empty().append( value ); }, replaceWith: function( value ) { return this.after( value ).remove(); }, detach: function( selector ) { return this.remove( selector, true ); }, domManip: function( args, table, callback ) { var results, first, value = args[0], scripts = []; if ( jQuery.isFunction(value) ) { return this.each(function() { args[0] = value.call(this); return jQuery(this).domManip( args, table, callback ); }); } if ( this[0] ) { // 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 }; } else { results = buildFragment( args, this[0], scripts ); } first = results.fragment.firstChild; if ( first ) { table = table && jQuery.nodeName( first, "tr" ); for ( var i = 0, l = this.length; i < l; i++ ) { callback.call( table ? root(this[i], first) : this[i], results.cacheable || this.length > 1 || i > 0 ? results.fragment.cloneNode(true) : results.fragment ); } } if ( scripts ) { 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 buildFragment(args, nodes, scripts){ var fragment, cacheable, cached, cacheresults, doc; if ( args.length === 1 && typeof args[0] === "string" && args[0].length < 512 && args[0].indexOf(" 0 ? this.clone(true) : this).get(); jQuery.fn[ original ].apply( jQuery(insert[i]), elems ); ret = ret.concat( elems ); } return this.pushStack( ret, name, selector ); }; }); jQuery.each({ // keepData is for internal use only--do not document remove: function( selector, keepData ) { if ( !selector || jQuery.multiFilter( selector, [ this ] ).length ) { if ( !keepData && this.nodeType === 1 ) { cleanData( jQuery("*", this).add(this) ); } if ( this.parentNode ) { this.parentNode.removeChild( this ); } } }, empty: function() { // Remove element nodes and prevent memory leaks if ( this.nodeType === 1 ) { cleanData( jQuery("*", this) ); } // Remove any remaining nodes while ( this.firstChild ) { this.removeChild( this.firstChild ); } } }, function(name, fn){ jQuery.fn[ name ] = function(){ return this.each( fn, arguments ); }; }); jQuery.extend({ clean: function( elems, context, fragment, scripts ) { context = context || document; // !context.createElement fails in IE with an error but returns typeof 'object' if ( typeof context.createElement === "undefined" ) { context = context.ownerDocument || context[0] && context[0].ownerDocument || document; } var ret = [], div = context.createElement("div"); jQuery.each(elems, function(i, elem){ if ( typeof elem === "number" ) { elem += ''; } if ( !elem ) { return; } // Convert html string into DOM nodes if ( typeof elem === "string" ) { // Fix "XHTML"-style tags in all browsers elem = elem.replace(rxhtmlTag, fcloseTag); // Trim whitespace, otherwise indexOf won't work as expected var tags = elem.replace(rleadingWhitespace, "") .substring(0, 10).toLowerCase(); var wrap = // option or optgroup !tags.indexOf("", "" ] || !tags.indexOf("", "" ] || rinsideTable.test(tags) && [ 1, "", "
" ] || !tags.indexOf("", "" ] || // matched above (!tags.indexOf("", "" ] || !tags.indexOf("", "" ] || // IE can't serialize and