c5169e0e
Renato De Donato
a new hope
|
1
|
define([
|
74249687
Luigi Serra
Cross browser con...
|
2
3
4
5
6
|
"./core",
"./var/concat",
"./var/push",
"./core/access",
"./manipulation/var/rcheckableType",
|
74249687
Luigi Serra
Cross browser con...
|
7
|
"./manipulation/support",
|
c5169e0e
Renato De Donato
a new hope
|
8
9
|
"./data/var/data_priv",
"./data/var/data_user",
|
74249687
Luigi Serra
Cross browser con...
|
10
11
|
"./core/init",
|
c5169e0e
Renato De Donato
a new hope
|
12
|
"./data/accepts",
|
74249687
Luigi Serra
Cross browser con...
|
13
14
15
|
"./traversing",
"./selector",
"./event"
|
c5169e0e
Renato De Donato
a new hope
|
16
|
], function( jQuery, concat, push, access, rcheckableType, support, data_priv, data_user ) {
|
74249687
Luigi Serra
Cross browser con...
|
17
18
|
var
|
c5169e0e
Renato De Donato
a new hope
|
19
20
21
22
|
rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
rtagName = /<([\w:]+)/,
rhtml = /<|&#?\w+;/,
rnoInnerhtml = /<(?:script|style|link)/i,
|
74249687
Luigi Serra
Cross browser con...
|
23
24
|
// checked="checked" or checked
rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
|
c5169e0e
Renato De Donato
a new hope
|
25
|
rscriptType = /^$|\/(?:java|ecma)script/i,
|
74249687
Luigi Serra
Cross browser con...
|
26
|
rscriptTypeMasked = /^true\/(.*)/,
|
c5169e0e
Renato De Donato
a new hope
|
27
|
rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,
|
74249687
Luigi Serra
Cross browser con...
|
28
|
|
c5169e0e
Renato De Donato
a new hope
|
29
30
|
// We have to close these tags to support XHTML (#13200)
wrapMap = {
|
a1a3bc73
Luigi Serra
graphs updates
|
31
|
|
c5169e0e
Renato De Donato
a new hope
|
32
33
|
// Support: IE9
option: [ 1, "<select multiple='multiple'>", "</select>" ],
|
74249687
Luigi Serra
Cross browser con...
|
34
|
|
c5169e0e
Renato De Donato
a new hope
|
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
thead: [ 1, "<table>", "</table>" ],
col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
tr: [ 2, "<table><tbody>", "</tbody></table>" ],
td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
_default: [ 0, "", "" ]
};
// Support: IE9
wrapMap.optgroup = wrapMap.option;
wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
wrapMap.th = wrapMap.td;
// Support: 1.x compatibility
// Manipulating tables requires a tbody
function manipulationTarget( elem, content ) {
return jQuery.nodeName( elem, "table" ) &&
jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ?
elem.getElementsByTagName("tbody")[0] ||
elem.appendChild( elem.ownerDocument.createElement("tbody") ) :
elem;
|
74249687
Luigi Serra
Cross browser con...
|
58
59
60
61
|
}
// Replace/restore the type attribute of script elements for safe DOM manipulation
function disableScript( elem ) {
|
c5169e0e
Renato De Donato
a new hope
|
62
|
elem.type = (elem.getAttribute("type") !== null) + "/" + elem.type;
|
74249687
Luigi Serra
Cross browser con...
|
63
64
65
66
67
68
69
70
|
return elem;
}
function restoreScript( elem ) {
var match = rscriptTypeMasked.exec( elem.type );
if ( match ) {
elem.type = match[ 1 ];
} else {
|
c5169e0e
Renato De Donato
a new hope
|
71
|
elem.removeAttribute("type");
|
74249687
Luigi Serra
Cross browser con...
|
72
73
74
75
76
|
}
return elem;
}
|
c5169e0e
Renato De Donato
a new hope
|
77
78
79
80
81
82
83
84
85
86
87
88
|
// Mark scripts as having already been evaluated
function setGlobalEval( elems, refElements ) {
var i = 0,
l = elems.length;
for ( ; i < l; i++ ) {
data_priv.set(
elems[ i ], "globalEval", !refElements || data_priv.get( refElements[ i ], "globalEval" )
);
}
}
|
74249687
Luigi Serra
Cross browser con...
|
89
90
91
92
93
94
95
96
|
function cloneCopyEvent( src, dest ) {
var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events;
if ( dest.nodeType !== 1 ) {
return;
}
// 1. Copy private data: events, handlers, etc.
|
c5169e0e
Renato De Donato
a new hope
|
97
98
99
|
if ( data_priv.hasData( src ) ) {
pdataOld = data_priv.access( src );
pdataCur = data_priv.set( dest, pdataOld );
|
74249687
Luigi Serra
Cross browser con...
|
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
events = pdataOld.events;
if ( events ) {
delete pdataCur.handle;
pdataCur.events = {};
for ( type in events ) {
for ( i = 0, l = events[ type ].length; i < l; i++ ) {
jQuery.event.add( dest, type, events[ type ][ i ] );
}
}
}
}
// 2. Copy user data
|
c5169e0e
Renato De Donato
a new hope
|
115
116
|
if ( data_user.hasData( src ) ) {
udataOld = data_user.access( src );
|
74249687
Luigi Serra
Cross browser con...
|
117
118
|
udataCur = jQuery.extend( {}, udataOld );
|
c5169e0e
Renato De Donato
a new hope
|
119
|
data_user.set( dest, udataCur );
|
74249687
Luigi Serra
Cross browser con...
|
120
121
122
|
}
}
|
c5169e0e
Renato De Donato
a new hope
|
123
124
125
126
127
128
129
130
131
132
|
function getAll( context, tag ) {
var ret = context.getElementsByTagName ? context.getElementsByTagName( tag || "*" ) :
context.querySelectorAll ? context.querySelectorAll( tag || "*" ) :
[];
return tag === undefined || tag && jQuery.nodeName( context, tag ) ?
jQuery.merge( [ context ], ret ) :
ret;
}
|
74249687
Luigi Serra
Cross browser con...
|
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
// Fix IE bugs, see support tests
function fixInput( src, dest ) {
var nodeName = dest.nodeName.toLowerCase();
// Fails to persist the checked state of a cloned checkbox or radio button.
if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
dest.checked = src.checked;
// Fails to return the selected option to the default selected state when cloning options
} else if ( nodeName === "input" || nodeName === "textarea" ) {
dest.defaultValue = src.defaultValue;
}
}
|
c5169e0e
Renato De Donato
a new hope
|
147
|
jQuery.extend({
|
74249687
Luigi Serra
Cross browser con...
|
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
|
clone: function( elem, dataAndEvents, deepDataAndEvents ) {
var i, l, srcElements, destElements,
clone = elem.cloneNode( true ),
inPage = jQuery.contains( elem.ownerDocument, elem );
// Fix IE cloning issues
if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&
!jQuery.isXMLDoc( elem ) ) {
// We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2
destElements = getAll( clone );
srcElements = getAll( elem );
for ( i = 0, l = srcElements.length; i < l; i++ ) {
fixInput( srcElements[ i ], destElements[ i ] );
}
}
// Copy the events from the original to the clone
if ( dataAndEvents ) {
if ( deepDataAndEvents ) {
srcElements = srcElements || getAll( elem );
destElements = destElements || getAll( clone );
for ( i = 0, l = srcElements.length; i < l; i++ ) {
cloneCopyEvent( srcElements[ i ], destElements[ i ] );
}
} else {
cloneCopyEvent( elem, clone );
}
}
// Preserve script evaluation history
destElements = getAll( clone, "script" );
if ( destElements.length > 0 ) {
setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
}
// Return the cloned set
return clone;
},
|
c5169e0e
Renato De Donato
a new hope
|
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
|
buildFragment: function( elems, context, scripts, selection ) {
var elem, tmp, tag, wrap, contains, j,
fragment = context.createDocumentFragment(),
nodes = [],
i = 0,
l = elems.length;
for ( ; i < l; i++ ) {
elem = elems[ i ];
if ( elem || elem === 0 ) {
// Add nodes directly
if ( jQuery.type( elem ) === "object" ) {
// Support: QtWebKit, PhantomJS
// push.apply(_, arraylike) throws on ancient WebKit
jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
// Convert non-html into a text node
} else if ( !rhtml.test( elem ) ) {
nodes.push( context.createTextNode( elem ) );
// Convert html into DOM nodes
} else {
tmp = tmp || fragment.appendChild( context.createElement("div") );
// Deserialize a standard representation
tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
wrap = wrapMap[ tag ] || wrapMap._default;
tmp.innerHTML = wrap[ 1 ] + elem.replace( rxhtmlTag, "<$1></$2>" ) + wrap[ 2 ];
// Descend through wrappers to the right content
j = wrap[ 0 ];
while ( j-- ) {
tmp = tmp.lastChild;
}
// Support: QtWebKit, PhantomJS
// push.apply(_, arraylike) throws on ancient WebKit
jQuery.merge( nodes, tmp.childNodes );
// Remember the top-level container
tmp = fragment.firstChild;
// Ensure the created nodes are orphaned (#12392)
tmp.textContent = "";
}
}
}
// Remove wrapper from fragment
fragment.textContent = "";
i = 0;
while ( (elem = nodes[ i++ ]) ) {
// #4087 - If origin and destination elements are the same, and this is
// that element, do not do anything
if ( selection && jQuery.inArray( elem, selection ) !== -1 ) {
continue;
}
contains = jQuery.contains( elem.ownerDocument, elem );
// Append to fragment
tmp = getAll( fragment.appendChild( elem ), "script" );
// Preserve script evaluation history
if ( contains ) {
setGlobalEval( tmp );
}
// Capture executables
if ( scripts ) {
j = 0;
while ( (elem = tmp[ j++ ]) ) {
if ( rscriptType.test( elem.type || "" ) ) {
scripts.push( elem );
}
}
}
}
return fragment;
},
|
74249687
Luigi Serra
Cross browser con...
|
276
|
cleanData: function( elems ) {
|
c5169e0e
Renato De Donato
a new hope
|
277
|
var data, elem, type, key,
|
74249687
Luigi Serra
Cross browser con...
|
278
279
280
|
special = jQuery.event.special,
i = 0;
|
c5169e0e
Renato De Donato
a new hope
|
281
282
283
284
285
|
for ( ; (elem = elems[ i ]) !== undefined; i++ ) {
if ( jQuery.acceptData( elem ) ) {
key = elem[ data_priv.expando ];
if ( key && (data = data_priv.cache[ key ]) ) {
|
74249687
Luigi Serra
Cross browser con...
|
286
287
288
289
290
291
292
293
294
295
296
|
if ( data.events ) {
for ( type in data.events ) {
if ( special[ type ] ) {
jQuery.event.remove( elem, type );
// This is a shortcut to avoid jQuery.event.remove's overhead
} else {
jQuery.removeEvent( elem, type, data.handle );
}
}
}
|
c5169e0e
Renato De Donato
a new hope
|
297
298
299
300
|
if ( data_priv.cache[ key ] ) {
// Discard any remaining `private` data
delete data_priv.cache[ key ];
}
|
74249687
Luigi Serra
Cross browser con...
|
301
302
|
}
}
|
c5169e0e
Renato De Donato
a new hope
|
303
304
|
// Discard any remaining `user` data
delete data_user.cache[ elem[ data_user.expando ] ];
|
74249687
Luigi Serra
Cross browser con...
|
305
306
|
}
}
|
c5169e0e
Renato De Donato
a new hope
|
307
|
});
|
74249687
Luigi Serra
Cross browser con...
|
308
|
|
c5169e0e
Renato De Donato
a new hope
|
309
|
jQuery.fn.extend({
|
74249687
Luigi Serra
Cross browser con...
|
310
311
312
313
|
text: function( value ) {
return access( this, function( value ) {
return value === undefined ?
jQuery.text( this ) :
|
c5169e0e
Renato De Donato
a new hope
|
314
|
this.empty().each(function() {
|
74249687
Luigi Serra
Cross browser con...
|
315
316
317
|
if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
this.textContent = value;
}
|
c5169e0e
Renato De Donato
a new hope
|
318
|
});
|
74249687
Luigi Serra
Cross browser con...
|
319
320
321
322
|
}, null, value, arguments.length );
},
append: function() {
|
c5169e0e
Renato De Donato
a new hope
|
323
|
return this.domManip( arguments, function( elem ) {
|
74249687
Luigi Serra
Cross browser con...
|
324
325
326
327
|
if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
var target = manipulationTarget( this, elem );
target.appendChild( elem );
}
|
c5169e0e
Renato De Donato
a new hope
|
328
|
});
|
74249687
Luigi Serra
Cross browser con...
|
329
330
331
|
},
prepend: function() {
|
c5169e0e
Renato De Donato
a new hope
|
332
|
return this.domManip( arguments, function( elem ) {
|
74249687
Luigi Serra
Cross browser con...
|
333
334
335
336
|
if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
var target = manipulationTarget( this, elem );
target.insertBefore( elem, target.firstChild );
}
|
c5169e0e
Renato De Donato
a new hope
|
337
|
});
|
74249687
Luigi Serra
Cross browser con...
|
338
339
340
|
},
before: function() {
|
c5169e0e
Renato De Donato
a new hope
|
341
|
return this.domManip( arguments, function( elem ) {
|
74249687
Luigi Serra
Cross browser con...
|
342
343
344
|
if ( this.parentNode ) {
this.parentNode.insertBefore( elem, this );
}
|
c5169e0e
Renato De Donato
a new hope
|
345
|
});
|
74249687
Luigi Serra
Cross browser con...
|
346
347
348
|
},
after: function() {
|
c5169e0e
Renato De Donato
a new hope
|
349
|
return this.domManip( arguments, function( elem ) {
|
74249687
Luigi Serra
Cross browser con...
|
350
351
352
|
if ( this.parentNode ) {
this.parentNode.insertBefore( elem, this.nextSibling );
}
|
c5169e0e
Renato De Donato
a new hope
|
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
|
});
},
remove: function( selector, keepData /* Internal Use Only */ ) {
var elem,
elems = selector ? jQuery.filter( selector, this ) : this,
i = 0;
for ( ; (elem = elems[i]) != null; i++ ) {
if ( !keepData && elem.nodeType === 1 ) {
jQuery.cleanData( getAll( elem ) );
}
if ( elem.parentNode ) {
if ( keepData && jQuery.contains( elem.ownerDocument, elem ) ) {
setGlobalEval( getAll( elem, "script" ) );
}
elem.parentNode.removeChild( elem );
}
}
return this;
|
74249687
Luigi Serra
Cross browser con...
|
375
376
377
378
379
380
|
},
empty: function() {
var elem,
i = 0;
|
c5169e0e
Renato De Donato
a new hope
|
381
|
for ( ; (elem = this[i]) != null; i++ ) {
|
74249687
Luigi Serra
Cross browser con...
|
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
|
if ( elem.nodeType === 1 ) {
// Prevent memory leaks
jQuery.cleanData( getAll( elem, false ) );
// Remove any remaining nodes
elem.textContent = "";
}
}
return this;
},
clone: function( dataAndEvents, deepDataAndEvents ) {
dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
|
c5169e0e
Renato De Donato
a new hope
|
399
|
return this.map(function() {
|
74249687
Luigi Serra
Cross browser con...
|
400
|
return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
|
c5169e0e
Renato De Donato
a new hope
|
401
|
});
|
74249687
Luigi Serra
Cross browser con...
|
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
|
},
html: function( value ) {
return access( this, function( value ) {
var elem = this[ 0 ] || {},
i = 0,
l = this.length;
if ( value === undefined && elem.nodeType === 1 ) {
return elem.innerHTML;
}
// See if we can take a shortcut and just use innerHTML
if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
!wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
|
c5169e0e
Renato De Donato
a new hope
|
418
|
value = value.replace( rxhtmlTag, "<$1></$2>" );
|
74249687
Luigi Serra
Cross browser con...
|
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
|
try {
for ( ; i < l; i++ ) {
elem = this[ i ] || {};
// Remove element nodes and prevent memory leaks
if ( elem.nodeType === 1 ) {
jQuery.cleanData( getAll( elem, false ) );
elem.innerHTML = value;
}
}
elem = 0;
// If using innerHTML throws an exception, use the fallback method
|
c5169e0e
Renato De Donato
a new hope
|
434
|
} catch( e ) {}
|
74249687
Luigi Serra
Cross browser con...
|
435
436
437
438
439
440
441
442
443
|
}
if ( elem ) {
this.empty().append( value );
}
}, null, value, arguments.length );
},
replaceWith: function() {
|
c5169e0e
Renato De Donato
a new hope
|
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
|
var arg = arguments[ 0 ];
// Make the changes, replacing each context element with the new content
this.domManip( arguments, function( elem ) {
arg = this.parentNode;
jQuery.cleanData( getAll( this ) );
if ( arg ) {
arg.replaceChild( elem, this );
}
});
// Force removal if there was no new content (e.g., from empty arguments)
return arg && (arg.length || arg.nodeType) ? this : this.remove();
},
|
74249687
Luigi Serra
Cross browser con...
|
460
|
|
c5169e0e
Renato De Donato
a new hope
|
461
462
463
|
detach: function( selector ) {
return this.remove( selector, true );
},
|
74249687
Luigi Serra
Cross browser con...
|
464
|
|
c5169e0e
Renato De Donato
a new hope
|
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
|
domManip: function( args, callback ) {
// Flatten any nested arrays
args = concat.apply( [], args );
var fragment, first, scripts, hasScripts, node, doc,
i = 0,
l = this.length,
set = this,
iNoClone = l - 1,
value = args[ 0 ],
isFunction = jQuery.isFunction( value );
// We can't cloneNode fragments that contain checked, in WebKit
if ( isFunction ||
( l > 1 && typeof value === "string" &&
!support.checkClone && rchecked.test( value ) ) ) {
return this.each(function( index ) {
var self = set.eq( index );
if ( isFunction ) {
args[ 0 ] = value.call( this, index, self.html() );
|
74249687
Luigi Serra
Cross browser con...
|
486
|
}
|
c5169e0e
Renato De Donato
a new hope
|
487
488
489
490
491
492
493
494
495
496
|
self.domManip( args, callback );
});
}
if ( l ) {
fragment = jQuery.buildFragment( args, this[ 0 ].ownerDocument, false, this );
first = fragment.firstChild;
if ( fragment.childNodes.length === 1 ) {
fragment = first;
|
74249687
Luigi Serra
Cross browser con...
|
497
498
|
}
|
c5169e0e
Renato De Donato
a new hope
|
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
|
if ( first ) {
scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
hasScripts = scripts.length;
// Use the original fragment for the last item instead of the first because it can end up
// being emptied incorrectly in certain situations (#8070).
for ( ; i < l; i++ ) {
node = fragment;
if ( i !== iNoClone ) {
node = jQuery.clone( node, true, true );
// Keep references to cloned scripts for later restoration
if ( hasScripts ) {
// Support: QtWebKit
// jQuery.merge because push.apply(_, arraylike) throws
jQuery.merge( scripts, getAll( node, "script" ) );
}
}
callback.call( this[ i ], node, i );
}
if ( hasScripts ) {
doc = scripts[ scripts.length - 1 ].ownerDocument;
// Reenable scripts
jQuery.map( scripts, restoreScript );
// Evaluate executable scripts on first document insertion
for ( i = 0; i < hasScripts; i++ ) {
node = scripts[ i ];
if ( rscriptType.test( node.type || "" ) &&
!data_priv.access( node, "globalEval" ) && jQuery.contains( doc, node ) ) {
if ( node.src ) {
// Optional AJAX dependency, but won't run scripts if not present
if ( jQuery._evalUrl ) {
jQuery._evalUrl( node.src );
}
} else {
jQuery.globalEval( node.textContent.replace( rcleanScript, "" ) );
}
}
}
}
}
}
return this;
|
74249687
Luigi Serra
Cross browser con...
|
549
|
}
|
c5169e0e
Renato De Donato
a new hope
|
550
|
});
|
74249687
Luigi Serra
Cross browser con...
|
551
|
|
c5169e0e
Renato De Donato
a new hope
|
552
|
jQuery.each({
|
74249687
Luigi Serra
Cross browser con...
|
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
|
appendTo: "append",
prependTo: "prepend",
insertBefore: "before",
insertAfter: "after",
replaceAll: "replaceWith"
}, function( name, original ) {
jQuery.fn[ name ] = function( selector ) {
var elems,
ret = [],
insert = jQuery( selector ),
last = insert.length - 1,
i = 0;
for ( ; i <= last; i++ ) {
elems = i === last ? this : this.clone( true );
jQuery( insert[ i ] )[ original ]( elems );
// Support: QtWebKit
// .get() because push.apply(_, arraylike) throws
push.apply( ret, elems.get() );
}
return this.pushStack( ret );
};
|
c5169e0e
Renato De Donato
a new hope
|
577
|
});
|
74249687
Luigi Serra
Cross browser con...
|
578
579
|
return jQuery;
|
c5169e0e
Renato De Donato
a new hope
|
580
|
});
|