2010-09-08 19:54:33 +02:00
|
|
|
(function( jQuery ) {
|
|
|
|
|
2009-07-19 17:48:30 +02:00
|
|
|
var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
|
|
|
|
rleadingWhitespace = /^\s+/,
|
2010-09-22 15:16:28 +02:00
|
|
|
rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,
|
2009-10-12 18:26:01 +02:00
|
|
|
rtagName = /<([\w:]+)/,
|
2009-07-19 17:57:43 +02:00
|
|
|
rtbody = /<tbody/i,
|
2010-02-06 01:58:08 +01:00
|
|
|
rhtml = /<|&#?\w+;/,
|
2010-09-22 15:16:28 +02:00
|
|
|
rnocache = /<(?:script|object|embed|option|style)/i,
|
2010-11-09 16:34:32 +01:00
|
|
|
// checked="checked" or checked (html5)
|
|
|
|
rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
|
2009-09-07 22:55:36 +02:00
|
|
|
wrapMap = {
|
|
|
|
option: [ 1, "<select multiple='multiple'>", "</select>" ],
|
|
|
|
legend: [ 1, "<fieldset>", "</fieldset>" ],
|
|
|
|
thead: [ 1, "<table>", "</table>" ],
|
|
|
|
tr: [ 2, "<table><tbody>", "</tbody></table>" ],
|
|
|
|
td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
|
|
|
|
col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
|
2009-12-07 02:26:39 +01:00
|
|
|
area: [ 1, "<map>", "</map>" ],
|
2009-09-07 22:55:36 +02:00
|
|
|
_default: [ 0, "", "" ]
|
2009-07-19 18:21:08 +02:00
|
|
|
};
|
2009-07-19 17:48:30 +02:00
|
|
|
|
2009-09-07 22:55:36 +02:00
|
|
|
wrapMap.optgroup = wrapMap.option;
|
|
|
|
wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
|
|
|
|
wrapMap.th = wrapMap.td;
|
|
|
|
|
|
|
|
// IE can't serialize <link> and <script> tags normally
|
|
|
|
if ( !jQuery.support.htmlSerialize ) {
|
|
|
|
wrapMap._default = [ 1, "div<div>", "</div>" ];
|
|
|
|
}
|
|
|
|
|
2009-03-18 22:15:38 +01:00
|
|
|
jQuery.fn.extend({
|
|
|
|
text: function( text ) {
|
2009-12-22 01:58:13 +01:00
|
|
|
if ( jQuery.isFunction(text) ) {
|
2010-01-06 21:08:07 +01:00
|
|
|
return this.each(function(i) {
|
2010-11-09 17:09:07 +01:00
|
|
|
var self = jQuery( this );
|
|
|
|
|
2010-01-26 00:43:33 +01:00
|
|
|
self.text( text.call(this, i, self.text()) );
|
2009-12-10 06:15:49 +01:00
|
|
|
});
|
|
|
|
}
|
2009-12-10 05:57:19 +01:00
|
|
|
|
2009-11-17 20:52:08 +01:00
|
|
|
if ( typeof text !== "object" && text !== undefined ) {
|
2009-03-18 22:15:38 +01:00
|
|
|
return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );
|
2009-11-17 20:52:08 +01:00
|
|
|
}
|
2009-03-18 22:15:38 +01:00
|
|
|
|
2010-02-13 08:26:50 +01:00
|
|
|
return jQuery.text( this );
|
2009-03-18 22:15:38 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
wrapAll: function( html ) {
|
2009-07-19 17:29:03 +02:00
|
|
|
if ( jQuery.isFunction( html ) ) {
|
2010-01-06 21:08:07 +01:00
|
|
|
return this.each(function(i) {
|
|
|
|
jQuery(this).wrapAll( html.call(this, i) );
|
2009-07-19 17:29:03 +02:00
|
|
|
});
|
2009-07-12 23:08:54 +02:00
|
|
|
}
|
2009-07-21 11:17:33 +02:00
|
|
|
|
2009-03-18 22:15:38 +01:00
|
|
|
if ( this[0] ) {
|
|
|
|
// The elements to wrap the target around
|
2009-12-08 20:21:24 +01:00
|
|
|
var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
|
2009-03-18 22:15:38 +01:00
|
|
|
|
2009-07-19 17:29:03 +02:00
|
|
|
if ( this[0].parentNode ) {
|
2009-03-18 22:15:38 +01:00
|
|
|
wrap.insertBefore( this[0] );
|
2009-07-19 17:29:03 +02:00
|
|
|
}
|
2009-03-18 22:15:38 +01:00
|
|
|
|
2009-12-22 01:58:13 +01:00
|
|
|
wrap.map(function() {
|
2009-03-18 22:15:38 +01:00
|
|
|
var elem = this;
|
|
|
|
|
2009-07-19 17:29:03 +02:00
|
|
|
while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
|
2009-03-18 22:15:38 +01:00
|
|
|
elem = elem.firstChild;
|
2009-07-19 17:29:03 +02:00
|
|
|
}
|
2009-03-18 22:15:38 +01:00
|
|
|
|
|
|
|
return elem;
|
|
|
|
}).append(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
wrapInner: function( html ) {
|
2010-01-26 01:16:23 +01:00
|
|
|
if ( jQuery.isFunction( html ) ) {
|
|
|
|
return this.each(function(i) {
|
|
|
|
jQuery(this).wrapInner( html.call(this, i) );
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2009-12-22 01:58:13 +01:00
|
|
|
return this.each(function() {
|
2010-11-09 17:09:07 +01:00
|
|
|
var self = jQuery( this ),
|
|
|
|
contents = self.contents();
|
2010-01-11 22:31:31 +01:00
|
|
|
|
|
|
|
if ( contents.length ) {
|
|
|
|
contents.wrapAll( html );
|
|
|
|
|
|
|
|
} else {
|
|
|
|
self.append( html );
|
|
|
|
}
|
2009-03-18 22:15:38 +01:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
wrap: function( html ) {
|
2009-12-22 01:58:13 +01:00
|
|
|
return this.each(function() {
|
2009-03-18 22:15:38 +01:00
|
|
|
jQuery( this ).wrapAll( html );
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2009-09-25 23:41:21 +02:00
|
|
|
unwrap: function() {
|
2009-12-22 01:58:13 +01:00
|
|
|
return this.parent().each(function() {
|
2009-09-25 23:41:21 +02:00
|
|
|
if ( !jQuery.nodeName( this, "body" ) ) {
|
|
|
|
jQuery( this ).replaceWith( this.childNodes );
|
|
|
|
}
|
|
|
|
}).end();
|
|
|
|
},
|
2009-12-10 05:57:19 +01:00
|
|
|
|
2009-03-18 22:15:38 +01:00
|
|
|
append: function() {
|
2009-12-22 01:58:13 +01:00
|
|
|
return this.domManip(arguments, true, function( elem ) {
|
2009-07-19 17:29:03 +02:00
|
|
|
if ( this.nodeType === 1 ) {
|
2009-03-18 22:15:38 +01:00
|
|
|
this.appendChild( elem );
|
2009-07-19 17:29:03 +02:00
|
|
|
}
|
2009-03-18 22:15:38 +01:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
prepend: function() {
|
2009-12-22 01:58:13 +01:00
|
|
|
return this.domManip(arguments, true, function( elem ) {
|
2009-07-19 17:29:03 +02:00
|
|
|
if ( this.nodeType === 1 ) {
|
2009-03-18 22:15:38 +01:00
|
|
|
this.insertBefore( elem, this.firstChild );
|
2009-07-19 17:29:03 +02:00
|
|
|
}
|
2009-03-18 22:15:38 +01:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
before: function() {
|
2009-09-15 00:09:42 +02:00
|
|
|
if ( this[0] && this[0].parentNode ) {
|
2009-12-22 01:58:13 +01:00
|
|
|
return this.domManip(arguments, false, function( elem ) {
|
2009-09-15 00:09:42 +02:00
|
|
|
this.parentNode.insertBefore( elem, this );
|
|
|
|
});
|
A follow-up to [6578] (which stopped adding expandos to elements that didn't have data). That broke jQuery.unique() (so we're now using the unique from Sizzle). Using Sizzle's unique (which also sorts in document order) changed how add, andSelf, parents, nextAll, prevAll, and siblings work. after and before were changed to not use .add() (in order to guarantee their position in the jQuery set). Also, jQuery.data(elem) was updated to return that element's data object (instead of its ID).
$("<div/>").after("<span/>")
=> [ div, span ]
(calling after on a disconnected DOM node adds the nodes to the end of the jQuery set)
$("<div/>").before("<span/>")
=> [ span, div ]
(calling before on a disconnected DOM node adds the nodes to the beginning of the jQuery set)
$("div").add("span")
=> [ div, span, span, div, span ]
(results now come out in document order)
$("div").find("code").andSelf();
=> [ div, code, code ]
(results now come out in document order)
Same goes for .parents(), .nextAll(), .prevAll(), and .siblings().
Exception: .parents() will still return the results in reverse document order.
jQuery.data(elem)
=> { object of data }
(no longer returns the unique ID assigned to the node)
2009-09-25 19:55:20 +02:00
|
|
|
} else if ( arguments.length ) {
|
|
|
|
var set = jQuery(arguments[0]);
|
|
|
|
set.push.apply( set, this.toArray() );
|
|
|
|
return this.pushStack( set, "before", arguments );
|
2009-09-15 00:09:42 +02:00
|
|
|
}
|
2009-03-18 22:15:38 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
after: function() {
|
2009-09-15 00:09:42 +02:00
|
|
|
if ( this[0] && this[0].parentNode ) {
|
2009-12-22 01:58:13 +01:00
|
|
|
return this.domManip(arguments, false, function( elem ) {
|
2009-09-15 00:09:42 +02:00
|
|
|
this.parentNode.insertBefore( elem, this.nextSibling );
|
|
|
|
});
|
A follow-up to [6578] (which stopped adding expandos to elements that didn't have data). That broke jQuery.unique() (so we're now using the unique from Sizzle). Using Sizzle's unique (which also sorts in document order) changed how add, andSelf, parents, nextAll, prevAll, and siblings work. after and before were changed to not use .add() (in order to guarantee their position in the jQuery set). Also, jQuery.data(elem) was updated to return that element's data object (instead of its ID).
$("<div/>").after("<span/>")
=> [ div, span ]
(calling after on a disconnected DOM node adds the nodes to the end of the jQuery set)
$("<div/>").before("<span/>")
=> [ span, div ]
(calling before on a disconnected DOM node adds the nodes to the beginning of the jQuery set)
$("div").add("span")
=> [ div, span, span, div, span ]
(results now come out in document order)
$("div").find("code").andSelf();
=> [ div, code, code ]
(results now come out in document order)
Same goes for .parents(), .nextAll(), .prevAll(), and .siblings().
Exception: .parents() will still return the results in reverse document order.
jQuery.data(elem)
=> { object of data }
(no longer returns the unique ID assigned to the node)
2009-09-25 19:55:20 +02:00
|
|
|
} else if ( arguments.length ) {
|
|
|
|
var set = this.pushStack( this, "after", arguments );
|
|
|
|
set.push.apply( set, jQuery(arguments[0]).toArray() );
|
|
|
|
return set;
|
2009-09-15 00:09:42 +02:00
|
|
|
}
|
2009-03-18 22:15:38 +01:00
|
|
|
},
|
2010-12-07 02:36:42 +01:00
|
|
|
|
2010-01-28 21:25:52 +01:00
|
|
|
// 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 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-12-07 02:36:42 +01:00
|
|
|
|
2010-01-28 21:25:52 +01:00
|
|
|
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 );
|
|
|
|
}
|
|
|
|
}
|
2010-12-07 02:36:42 +01:00
|
|
|
|
2010-01-28 21:25:52 +01:00
|
|
|
return this;
|
|
|
|
},
|
2009-03-18 22:15:38 +01:00
|
|
|
|
2011-01-20 21:25:04 +01:00
|
|
|
clone: function( dataAndEvents, deepDataAndEvents ) {
|
|
|
|
dataAndEvents = dataAndEvents == null ? true : dataAndEvents;
|
|
|
|
deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
|
|
|
|
|
2011-01-20 20:25:56 +01:00
|
|
|
return this.map( function () {
|
2011-01-20 21:25:04 +01:00
|
|
|
return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
|
2009-03-18 22:15:38 +01:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
html: function( value ) {
|
2009-09-07 22:55:36 +02:00
|
|
|
if ( value === undefined ) {
|
2010-01-07 15:53:16 +01:00
|
|
|
return this[0] && this[0].nodeType === 1 ?
|
2009-07-19 17:48:30 +02:00
|
|
|
this[0].innerHTML.replace(rinlinejQuery, "") :
|
2009-09-07 22:55:36 +02:00
|
|
|
null;
|
|
|
|
|
|
|
|
// See if we can take a shortcut and just use innerHTML
|
2010-02-02 00:52:12 +01:00
|
|
|
} else if ( typeof value === "string" && !rnocache.test( value ) &&
|
2009-12-02 21:20:33 +01:00
|
|
|
(jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value )) &&
|
2009-09-07 22:55:36 +02:00
|
|
|
!wrapMap[ (rtagName.exec( value ) || ["", ""])[1].toLowerCase() ] ) {
|
|
|
|
|
2010-09-22 15:16:28 +02:00
|
|
|
value = value.replace(rxhtmlTag, "<$1></$2>");
|
2010-01-25 03:37:05 +01:00
|
|
|
|
2009-09-15 18:46:15 +02:00
|
|
|
try {
|
|
|
|
for ( var i = 0, l = this.length; i < l; i++ ) {
|
|
|
|
// Remove element nodes and prevent memory leaks
|
|
|
|
if ( this[i].nodeType === 1 ) {
|
2010-01-24 03:20:19 +01:00
|
|
|
jQuery.cleanData( this[i].getElementsByTagName("*") );
|
2009-09-15 18:46:15 +02:00
|
|
|
this[i].innerHTML = value;
|
|
|
|
}
|
2009-09-07 22:55:36 +02:00
|
|
|
}
|
2009-09-15 18:46:15 +02:00
|
|
|
|
|
|
|
// If using innerHTML throws an exception, use the fallback method
|
|
|
|
} catch(e) {
|
|
|
|
this.empty().append( value );
|
2009-09-07 22:55:36 +02:00
|
|
|
}
|
|
|
|
|
2010-01-07 19:33:30 +01:00
|
|
|
} else if ( jQuery.isFunction( value ) ) {
|
|
|
|
this.each(function(i){
|
2010-11-09 17:09:07 +01:00
|
|
|
var self = jQuery( this );
|
|
|
|
|
2010-09-28 18:50:44 +02:00
|
|
|
self.html( value.call(this, i, self.html()) );
|
2010-01-07 19:33:30 +01:00
|
|
|
});
|
|
|
|
|
2009-09-07 22:55:36 +02:00
|
|
|
} else {
|
2009-03-18 22:15:38 +01:00
|
|
|
this.empty().append( value );
|
2009-09-07 22:55:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return this;
|
2009-03-18 22:15:38 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
replaceWith: function( value ) {
|
2009-09-15 00:09:42 +02:00
|
|
|
if ( this[0] && this[0].parentNode ) {
|
2010-01-11 22:25:01 +01:00
|
|
|
// Make sure that the elements are removed from the DOM before they are inserted
|
|
|
|
// this can help fix replacing a parent with child elements
|
2010-02-02 03:48:05 +01:00
|
|
|
if ( jQuery.isFunction( value ) ) {
|
2010-01-26 01:22:28 +01:00
|
|
|
return this.each(function(i) {
|
|
|
|
var self = jQuery(this), old = self.html();
|
|
|
|
self.replaceWith( value.call( this, i, old ) );
|
|
|
|
});
|
2010-01-11 22:25:01 +01:00
|
|
|
}
|
|
|
|
|
2010-02-02 03:48:05 +01:00
|
|
|
if ( typeof value !== "string" ) {
|
2010-11-09 17:09:07 +01:00
|
|
|
value = jQuery( value ).detach();
|
2010-02-02 03:48:05 +01:00
|
|
|
}
|
|
|
|
|
2009-12-22 01:58:13 +01:00
|
|
|
return this.each(function() {
|
2010-11-09 17:09:07 +01:00
|
|
|
var next = this.nextSibling,
|
|
|
|
parent = this.parentNode;
|
2009-12-05 21:30:36 +01:00
|
|
|
|
2010-11-09 17:09:07 +01:00
|
|
|
jQuery( this ).remove();
|
2009-12-05 21:30:36 +01:00
|
|
|
|
|
|
|
if ( next ) {
|
|
|
|
jQuery(next).before( value );
|
|
|
|
} else {
|
|
|
|
jQuery(parent).append( value );
|
|
|
|
}
|
|
|
|
});
|
2009-09-15 00:09:42 +02:00
|
|
|
} else {
|
|
|
|
return this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value );
|
|
|
|
}
|
2009-03-18 22:15:38 +01:00
|
|
|
},
|
|
|
|
|
2009-07-21 17:57:51 +02:00
|
|
|
detach: function( selector ) {
|
|
|
|
return this.remove( selector, true );
|
|
|
|
},
|
|
|
|
|
2009-03-18 22:15:38 +01:00
|
|
|
domManip: function( args, table, callback ) {
|
2010-11-09 17:09:07 +01:00
|
|
|
var results, first, fragment, parent,
|
|
|
|
value = args[0],
|
|
|
|
scripts = [];
|
2009-07-12 22:19:43 +02:00
|
|
|
|
2010-01-26 00:43:33 +01:00
|
|
|
// 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() {
|
|
|
|
jQuery(this).domManip( args, table, callback, true );
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2009-07-12 22:19:43 +02:00
|
|
|
if ( jQuery.isFunction(value) ) {
|
2010-01-06 21:08:07 +01:00
|
|
|
return this.each(function(i) {
|
|
|
|
var self = jQuery(this);
|
|
|
|
args[0] = value.call(this, i, table ? self.html() : undefined);
|
2010-01-26 00:43:33 +01:00
|
|
|
self.domManip( args, table, callback );
|
2009-07-12 22:19:43 +02:00
|
|
|
});
|
2009-07-19 17:48:30 +02:00
|
|
|
}
|
2009-07-11 15:49:46 +02:00
|
|
|
|
2009-03-18 22:15:38 +01:00
|
|
|
if ( this[0] ) {
|
2010-02-13 08:49:04 +01:00
|
|
|
parent = value && value.parentNode;
|
|
|
|
|
2009-09-07 20:58:01 +02:00
|
|
|
// If we're in a fragment, just use that instead of building a new one
|
2010-02-13 09:14:00 +01:00
|
|
|
if ( jQuery.support.parentNode && parent && parent.nodeType === 11 && parent.childNodes.length === this.length ) {
|
2010-02-13 08:49:04 +01:00
|
|
|
results = { fragment: parent };
|
|
|
|
|
2009-09-07 20:58:01 +02:00
|
|
|
} else {
|
2010-09-09 00:13:35 +02:00
|
|
|
results = jQuery.buildFragment( args, this, scripts );
|
2009-07-11 15:49:46 +02:00
|
|
|
}
|
2010-12-07 02:36:42 +01:00
|
|
|
|
2010-01-28 23:18:27 +01:00
|
|
|
fragment = results.fragment;
|
2010-12-07 02:36:42 +01:00
|
|
|
|
2010-01-28 23:18:27 +01:00
|
|
|
if ( fragment.childNodes.length === 1 ) {
|
|
|
|
first = fragment = fragment.firstChild;
|
|
|
|
} else {
|
|
|
|
first = fragment.firstChild;
|
|
|
|
}
|
2009-03-18 22:15:38 +01:00
|
|
|
|
2009-07-11 15:49:46 +02:00
|
|
|
if ( first ) {
|
|
|
|
table = table && jQuery.nodeName( first, "tr" );
|
2009-03-23 02:55:17 +01:00
|
|
|
|
2009-07-11 15:49:46 +02:00
|
|
|
for ( var i = 0, l = this.length; i < l; i++ ) {
|
|
|
|
callback.call(
|
|
|
|
table ?
|
|
|
|
root(this[i], first) :
|
|
|
|
this[i],
|
2011-01-09 22:56:40 +01:00
|
|
|
i > 0 || results.cacheable || (this.length > 1 && i > 0) ?
|
2011-01-20 20:25:56 +01:00
|
|
|
jQuery.clone( fragment, true, true ) :
|
2010-01-28 23:18:27 +01:00
|
|
|
fragment
|
2009-07-11 15:49:46 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-01-28 23:18:27 +01:00
|
|
|
if ( scripts.length ) {
|
2009-03-18 22:15:38 +01:00
|
|
|
jQuery.each( scripts, evalScript );
|
2009-07-11 15:49:46 +02:00
|
|
|
}
|
2009-03-18 22:15:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2010-03-02 03:24:49 +01:00
|
|
|
function root( elem, cur ) {
|
|
|
|
return jQuery.nodeName(elem, "table") ?
|
|
|
|
(elem.getElementsByTagName("tbody")[0] ||
|
|
|
|
elem.appendChild(elem.ownerDocument.createElement("tbody"))) :
|
|
|
|
elem;
|
|
|
|
}
|
|
|
|
|
2011-01-20 20:25:56 +01:00
|
|
|
function cloneCopyEvent( src, dest ) {
|
2009-12-02 23:15:09 +01:00
|
|
|
|
2011-01-20 20:25:56 +01:00
|
|
|
if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) {
|
|
|
|
return;
|
|
|
|
}
|
2010-12-22 16:13:28 +01:00
|
|
|
|
2011-01-20 20:25:56 +01:00
|
|
|
var internalKey = jQuery.expando,
|
|
|
|
oldData = jQuery.data( src ),
|
|
|
|
curData = jQuery.data( dest, oldData );
|
2009-12-22 18:04:17 +01:00
|
|
|
|
2011-01-20 20:25:56 +01:00
|
|
|
// Switch to use the internal data object, if it exists, for the next
|
|
|
|
// stage of data copying
|
|
|
|
if ( (oldData = oldData[ internalKey ]) ) {
|
|
|
|
var events = oldData.events;
|
|
|
|
curData = curData[ internalKey ] = jQuery.extend({}, oldData);
|
2009-12-22 18:04:17 +01:00
|
|
|
|
2011-01-20 20:25:56 +01:00
|
|
|
if ( events ) {
|
|
|
|
delete curData.handle;
|
|
|
|
curData.events = {};
|
2011-01-09 22:52:33 +01:00
|
|
|
|
2011-01-20 20:25:56 +01:00
|
|
|
for ( var type in events ) {
|
|
|
|
for ( var i = 0, l = events[ type ].length; i < l; i++ ) {
|
|
|
|
jQuery.event.add( dest, type, events[ type ][ i ], events[ type ][ i ].data );
|
2009-12-22 18:04:17 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-01-20 20:25:56 +01:00
|
|
|
}
|
2009-12-02 23:15:09 +01:00
|
|
|
}
|
|
|
|
|
2010-12-13 02:23:22 +01:00
|
|
|
function cloneFixAttributes(src, dest) {
|
|
|
|
// We do not need to do anything for non-Elements
|
|
|
|
if ( dest.nodeType !== 1 ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var nodeName = dest.nodeName.toLowerCase();
|
|
|
|
|
|
|
|
// clearAttributes removes the attributes, which we don't want,
|
|
|
|
// but also removes the attachEvent events, which we *do* want
|
|
|
|
dest.clearAttributes();
|
|
|
|
|
|
|
|
// mergeAttributes, in contrast, only merges back on the
|
|
|
|
// original attributes, not the events
|
|
|
|
dest.mergeAttributes(src);
|
|
|
|
|
|
|
|
// IE6-8 fail to clone children inside object elements that use
|
|
|
|
// the proprietary classid attribute value (rather than the type
|
|
|
|
// attribute) to identify the type of content to display
|
|
|
|
if ( nodeName === "object" ) {
|
|
|
|
dest.outerHTML = src.outerHTML;
|
|
|
|
|
2011-01-10 01:38:44 +01:00
|
|
|
} else if ( nodeName === "input" && (src.type === "checkbox" || src.type === "radio") ) {
|
|
|
|
// IE6-8 fails to persist the checked state of a cloned checkbox
|
|
|
|
// or radio button. Worse, IE6-7 fail to give the cloned element
|
|
|
|
// a checked appearance if the defaultChecked value isn't also set
|
|
|
|
if ( src.checked ) {
|
|
|
|
dest.defaultChecked = dest.checked = src.checked;
|
|
|
|
}
|
|
|
|
|
|
|
|
// IE6-7 get confused and end up setting the value of a cloned
|
|
|
|
// checkbox/radio button to an empty string instead of "on"
|
|
|
|
if ( dest.value !== src.value ) {
|
|
|
|
dest.value = src.value;
|
|
|
|
}
|
2010-12-13 02:23:22 +01:00
|
|
|
|
2010-12-13 03:01:47 +01:00
|
|
|
// IE6-8 fails to return the selected option to the default selected
|
2010-12-13 02:23:22 +01:00
|
|
|
// state when cloning options
|
2010-12-16 08:29:06 +01:00
|
|
|
} else if ( nodeName === "option" ) {
|
2010-12-13 02:23:22 +01:00
|
|
|
dest.selected = src.defaultSelected;
|
2011-01-10 01:38:44 +01:00
|
|
|
|
|
|
|
// IE6-8 fails to set the defaultValue to the correct value when
|
|
|
|
// cloning other types of input fields
|
|
|
|
} else if ( nodeName === "input" || nodeName === "textarea" ) {
|
|
|
|
dest.defaultValue = src.defaultValue;
|
2010-12-13 02:23:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Event data gets referenced instead of copied if the expando
|
|
|
|
// gets copied too
|
|
|
|
dest.removeAttribute( jQuery.expando );
|
|
|
|
}
|
|
|
|
|
2010-09-09 00:13:35 +02:00
|
|
|
jQuery.buildFragment = function( args, nodes, scripts ) {
|
2010-01-29 06:22:20 +01:00
|
|
|
var fragment, cacheable, cacheresults,
|
|
|
|
doc = (nodes && nodes[0] ? nodes[0].ownerDocument || nodes[0] : document);
|
|
|
|
|
2010-12-27 20:43:52 +01:00
|
|
|
// Only cache "small" (1/2 KB) HTML strings that are associated with the main document
|
2010-01-29 06:22:20 +01:00
|
|
|
// Cloning options loses the selected state, so don't cache them
|
2010-02-02 00:52:12 +01:00
|
|
|
// IE 6 doesn't like it when you put <object> or <embed> elements in a fragment
|
2010-01-29 06:22:20 +01:00
|
|
|
// 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 &&
|
2010-12-27 20:43:52 +01:00
|
|
|
args[0].charAt(0) === "<" && !rnocache.test( args[0] ) && (jQuery.support.checkClone || !rchecked.test( args[0] )) ) {
|
2009-09-07 20:58:01 +02:00
|
|
|
|
|
|
|
cacheable = true;
|
|
|
|
cacheresults = jQuery.fragments[ args[0] ];
|
|
|
|
if ( cacheresults ) {
|
|
|
|
if ( cacheresults !== 1 ) {
|
|
|
|
fragment = cacheresults;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !fragment ) {
|
|
|
|
fragment = doc.createDocumentFragment();
|
|
|
|
jQuery.clean( args, doc, fragment, scripts );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( cacheable ) {
|
|
|
|
jQuery.fragments[ args[0] ] = cacheresults ? fragment : 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return { fragment: fragment, cacheable: cacheable };
|
2010-09-09 00:13:35 +02:00
|
|
|
};
|
2009-09-07 20:58:01 +02:00
|
|
|
|
2009-07-11 15:49:46 +02:00
|
|
|
jQuery.fragments = {};
|
|
|
|
|
2009-03-18 22:15:38 +01:00
|
|
|
jQuery.each({
|
|
|
|
appendTo: "append",
|
|
|
|
prependTo: "prepend",
|
|
|
|
insertBefore: "before",
|
|
|
|
insertAfter: "after",
|
|
|
|
replaceAll: "replaceWith"
|
2009-12-22 01:58:13 +01:00
|
|
|
}, function( name, original ) {
|
2009-03-18 22:15:38 +01:00
|
|
|
jQuery.fn[ name ] = function( selector ) {
|
2010-11-09 17:09:07 +01:00
|
|
|
var ret = [],
|
|
|
|
insert = jQuery( selector ),
|
2010-02-13 08:49:04 +01:00
|
|
|
parent = this.length === 1 && this[0].parentNode;
|
2010-12-07 02:36:42 +01:00
|
|
|
|
2010-02-13 08:49:04 +01:00
|
|
|
if ( parent && parent.nodeType === 11 && parent.childNodes.length === 1 && insert.length === 1 ) {
|
2010-01-28 22:30:37 +01:00
|
|
|
insert[ original ]( this[0] );
|
|
|
|
return this;
|
2010-12-07 02:36:42 +01:00
|
|
|
|
2010-01-28 22:30:37 +01:00
|
|
|
} else {
|
|
|
|
for ( var i = 0, l = insert.length; i < l; i++ ) {
|
|
|
|
var elems = (i > 0 ? this.clone(true) : this).get();
|
2010-03-05 15:59:58 +01:00
|
|
|
jQuery( insert[i] )[ original ]( elems );
|
2010-01-28 22:30:37 +01:00
|
|
|
ret = ret.concat( elems );
|
|
|
|
}
|
2010-12-07 02:36:42 +01:00
|
|
|
|
2010-01-28 22:30:37 +01:00
|
|
|
return this.pushStack( ret, name, insert.selector );
|
2009-03-18 22:15:38 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
jQuery.extend({
|
2011-01-20 21:25:04 +01:00
|
|
|
clone: function( elem, dataAndEvents, deepDataAndEvents ) {
|
2011-01-20 20:25:56 +01:00
|
|
|
var clone = elem.cloneNode(true),
|
|
|
|
srcElements,
|
2011-01-22 00:41:42 +01:00
|
|
|
destElements,
|
|
|
|
i;
|
2011-01-20 20:25:56 +01:00
|
|
|
|
2011-01-20 21:25:04 +01:00
|
|
|
if ( !jQuery.support.noCloneEvent && (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
|
2011-01-20 20:25:56 +01:00
|
|
|
// IE copies events bound via attachEvent when using cloneNode.
|
|
|
|
// Calling detachEvent on the clone will also remove the events
|
|
|
|
// from the original. In order to get around this, we use some
|
|
|
|
// proprietary methods to clear the events. Thanks to MooTools
|
|
|
|
// guys for this hotness.
|
|
|
|
|
|
|
|
// Using Sizzle here is crazy slow, so we use getElementsByTagName
|
|
|
|
// instead
|
|
|
|
srcElements = elem.getElementsByTagName("*");
|
|
|
|
destElements = clone.getElementsByTagName("*");
|
|
|
|
|
|
|
|
// Weird iteration because IE will replace the length property
|
|
|
|
// with an element if you are cloning the body and one of the
|
|
|
|
// elements on the page has a name or id of "length"
|
2011-01-22 00:41:42 +01:00
|
|
|
for ( i = 0; srcElements[i]; ++i ) {
|
2011-01-20 20:25:56 +01:00
|
|
|
cloneFixAttributes( srcElements[i], destElements[i] );
|
|
|
|
}
|
|
|
|
|
|
|
|
cloneFixAttributes( elem, clone );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Copy the events from the original to the clone
|
2011-01-20 21:25:04 +01:00
|
|
|
if ( dataAndEvents ) {
|
2011-01-20 20:25:56 +01:00
|
|
|
|
2011-01-20 21:25:04 +01:00
|
|
|
cloneCopyEvent( elem, clone );
|
2011-01-20 20:25:56 +01:00
|
|
|
|
2011-01-20 21:25:04 +01:00
|
|
|
if ( deepDataAndEvents && "getElementsByTagName" in elem ) {
|
2011-01-20 20:25:56 +01:00
|
|
|
|
|
|
|
srcElements = elem.getElementsByTagName("*");
|
|
|
|
destElements = clone.getElementsByTagName("*");
|
|
|
|
|
|
|
|
if ( srcElements.length ) {
|
2011-01-22 00:41:42 +01:00
|
|
|
for ( i = 0; srcElements[i]; ++i ) {
|
2011-01-20 20:25:56 +01:00
|
|
|
cloneCopyEvent( srcElements[i], destElements[i] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Return the cloned set
|
|
|
|
return clone;
|
|
|
|
},
|
2009-09-07 20:58:01 +02:00
|
|
|
clean: function( elems, context, fragment, scripts ) {
|
2009-03-18 22:15:38 +01:00
|
|
|
context = context || document;
|
|
|
|
|
|
|
|
// !context.createElement fails in IE with an error but returns typeof 'object'
|
2009-07-19 17:29:03 +02:00
|
|
|
if ( typeof context.createElement === "undefined" ) {
|
2009-03-18 22:15:38 +01:00
|
|
|
context = context.ownerDocument || context[0] && context[0].ownerDocument || document;
|
2009-07-19 17:29:03 +02:00
|
|
|
}
|
2009-03-18 22:15:38 +01:00
|
|
|
|
2009-12-06 02:06:00 +01:00
|
|
|
var ret = [];
|
2009-03-18 22:15:38 +01:00
|
|
|
|
2010-01-28 22:30:37 +01:00
|
|
|
for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
|
2009-07-19 17:29:03 +02:00
|
|
|
if ( typeof elem === "number" ) {
|
2009-12-22 02:13:16 +01:00
|
|
|
elem += "";
|
2009-07-19 17:29:03 +02:00
|
|
|
}
|
2009-03-18 22:15:38 +01:00
|
|
|
|
2009-12-22 01:58:13 +01:00
|
|
|
if ( !elem ) {
|
2010-01-28 22:30:37 +01:00
|
|
|
continue;
|
2009-12-22 01:58:13 +01:00
|
|
|
}
|
2009-03-18 22:15:38 +01:00
|
|
|
|
|
|
|
// Convert html string into DOM nodes
|
2009-09-15 01:12:06 +02:00
|
|
|
if ( typeof elem === "string" && !rhtml.test( elem ) ) {
|
|
|
|
elem = context.createTextNode( elem );
|
|
|
|
|
|
|
|
} else if ( typeof elem === "string" ) {
|
2009-03-18 22:15:38 +01:00
|
|
|
// Fix "XHTML"-style tags in all browsers
|
2010-09-22 15:16:28 +02:00
|
|
|
elem = elem.replace(rxhtmlTag, "<$1></$2>");
|
2009-03-18 22:15:38 +01:00
|
|
|
|
|
|
|
// Trim whitespace, otherwise indexOf won't work as expected
|
2009-09-07 22:55:36 +02:00
|
|
|
var tag = (rtagName.exec( elem ) || ["", ""])[1].toLowerCase(),
|
|
|
|
wrap = wrapMap[ tag ] || wrapMap._default,
|
2009-12-06 02:06:00 +01:00
|
|
|
depth = wrap[0],
|
|
|
|
div = context.createElement("div");
|
2009-03-18 22:15:38 +01:00
|
|
|
|
|
|
|
// Go to html and back, then peel off extra wrappers
|
|
|
|
div.innerHTML = wrap[1] + elem + wrap[2];
|
|
|
|
|
|
|
|
// Move to the right depth
|
2009-09-07 22:55:36 +02:00
|
|
|
while ( depth-- ) {
|
2009-03-18 22:15:38 +01:00
|
|
|
div = div.lastChild;
|
2009-07-19 17:29:03 +02:00
|
|
|
}
|
2009-03-18 22:15:38 +01:00
|
|
|
|
|
|
|
// Remove IE's autoinserted <tbody> from table fragments
|
|
|
|
if ( !jQuery.support.tbody ) {
|
|
|
|
|
|
|
|
// String was a <table>, *may* have spurious <tbody>
|
2009-07-19 17:48:30 +02:00
|
|
|
var hasBody = rtbody.test(elem),
|
2009-09-07 22:55:36 +02:00
|
|
|
tbody = tag === "table" && !hasBody ?
|
2009-03-18 22:15:38 +01:00
|
|
|
div.firstChild && div.firstChild.childNodes :
|
|
|
|
|
2009-07-19 17:29:03 +02:00
|
|
|
// String was a bare <thead> or <tfoot>
|
2009-12-22 00:02:02 +01:00
|
|
|
wrap[1] === "<table>" && !hasBody ?
|
2009-07-19 17:29:03 +02:00
|
|
|
div.childNodes :
|
|
|
|
[];
|
2009-03-18 22:15:38 +01:00
|
|
|
|
2009-07-19 17:29:03 +02:00
|
|
|
for ( var j = tbody.length - 1; j >= 0 ; --j ) {
|
|
|
|
if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) {
|
2009-03-18 22:15:38 +01:00
|
|
|
tbody[ j ].parentNode.removeChild( tbody[ j ] );
|
2009-07-19 17:29:03 +02:00
|
|
|
}
|
2009-03-18 22:15:38 +01:00
|
|
|
}
|
|
|
|
|
2009-07-19 17:29:03 +02:00
|
|
|
}
|
|
|
|
|
2009-03-18 22:15:38 +01:00
|
|
|
// IE completely kills leading whitespace when innerHTML is used
|
2009-07-19 17:51:00 +02:00
|
|
|
if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
|
|
|
|
div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild );
|
2009-07-19 17:29:03 +02:00
|
|
|
}
|
2009-03-23 02:55:17 +01:00
|
|
|
|
2010-01-28 22:30:37 +01:00
|
|
|
elem = div.childNodes;
|
2009-03-18 22:15:38 +01:00
|
|
|
}
|
|
|
|
|
2009-07-19 17:29:03 +02:00
|
|
|
if ( elem.nodeType ) {
|
2009-03-18 22:15:38 +01:00
|
|
|
ret.push( elem );
|
2009-07-19 17:29:03 +02:00
|
|
|
} else {
|
2009-03-18 22:15:38 +01:00
|
|
|
ret = jQuery.merge( ret, elem );
|
2009-07-19 17:29:03 +02:00
|
|
|
}
|
2010-01-28 22:30:37 +01:00
|
|
|
}
|
2009-03-18 22:15:38 +01:00
|
|
|
|
|
|
|
if ( fragment ) {
|
2010-03-02 03:24:49 +01:00
|
|
|
for ( i = 0; ret[i]; i++ ) {
|
2009-09-07 20:58:01 +02:00
|
|
|
if ( scripts && jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) {
|
2009-03-18 22:15:38 +01:00
|
|
|
scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] );
|
2010-12-07 02:36:42 +01:00
|
|
|
|
2009-03-18 22:15:38 +01:00
|
|
|
} else {
|
2009-07-19 17:48:30 +02:00
|
|
|
if ( ret[i].nodeType === 1 ) {
|
2009-03-18 22:15:38 +01:00
|
|
|
ret.splice.apply( ret, [i + 1, 0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))) );
|
2009-07-19 17:48:30 +02:00
|
|
|
}
|
2009-03-18 22:15:38 +01:00
|
|
|
fragment.appendChild( ret[i] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
2010-01-24 03:20:19 +01:00
|
|
|
},
|
2010-12-07 02:36:42 +01:00
|
|
|
|
2010-01-24 03:20:19 +01:00
|
|
|
cleanData: function( elems ) {
|
2011-01-09 22:52:33 +01:00
|
|
|
var data, id, cache = jQuery.cache, internalKey = jQuery.expando, special = jQuery.event.special,
|
2010-02-13 12:32:20 +01:00
|
|
|
deleteExpando = jQuery.support.deleteExpando;
|
2010-12-07 02:36:42 +01:00
|
|
|
|
2010-01-28 21:25:52 +01:00
|
|
|
for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
|
2010-03-02 19:56:15 +01:00
|
|
|
if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2010-01-28 21:25:52 +01:00
|
|
|
id = elem[ jQuery.expando ];
|
2010-12-07 02:36:42 +01:00
|
|
|
|
2010-01-28 21:25:52 +01:00
|
|
|
if ( id ) {
|
2011-01-09 22:52:33 +01:00
|
|
|
data = cache[ id ] && cache[ id ][ internalKey ];
|
2010-12-07 02:36:42 +01:00
|
|
|
|
2010-03-09 18:22:25 +01:00
|
|
|
if ( data && data.events ) {
|
2010-02-13 12:10:43 +01:00
|
|
|
for ( var type in data.events ) {
|
|
|
|
if ( special[ type ] ) {
|
|
|
|
jQuery.event.remove( elem, type );
|
|
|
|
|
2011-01-09 22:52:33 +01:00
|
|
|
// This is a shortcut to avoid jQuery.event.remove's overhead
|
2010-02-13 12:10:43 +01:00
|
|
|
} else {
|
2010-09-09 00:13:35 +02:00
|
|
|
jQuery.removeEvent( elem, type, data.handle );
|
2010-02-13 12:10:43 +01:00
|
|
|
}
|
2010-01-28 21:25:52 +01:00
|
|
|
}
|
2011-01-09 23:25:44 +01:00
|
|
|
|
|
|
|
// Null the DOM reference to avoid IE6/7/8 leak (#7054)
|
|
|
|
if ( data.handle ) {
|
|
|
|
data.handle.elem = null;
|
|
|
|
}
|
2010-01-28 21:25:52 +01:00
|
|
|
}
|
2010-12-07 02:36:42 +01:00
|
|
|
|
2010-02-13 12:32:20 +01:00
|
|
|
if ( deleteExpando ) {
|
2010-02-13 12:57:58 +01:00
|
|
|
delete elem[ jQuery.expando ];
|
|
|
|
|
|
|
|
} else if ( elem.removeAttribute ) {
|
|
|
|
elem.removeAttribute( jQuery.expando );
|
2010-02-13 12:32:20 +01:00
|
|
|
}
|
2010-12-07 02:36:42 +01:00
|
|
|
|
2010-01-28 21:25:52 +01:00
|
|
|
delete cache[ id ];
|
|
|
|
}
|
2009-03-18 22:15:38 +01:00
|
|
|
}
|
|
|
|
}
|
2010-01-25 03:37:05 +01:00
|
|
|
});
|
2010-03-23 17:12:16 +01:00
|
|
|
|
|
|
|
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 );
|
|
|
|
}
|
2010-09-08 19:54:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
})( jQuery );
|