corrade-nucleus-nucleons – Blame information for rev 20

Subversion Repositories:
Rev:
Rev Author Line No. Line
20 office 1 // Initialize a jQuery object
2 define( [
3 "../core",
4 "../var/document",
5 "./var/rsingleTag",
6  
7 "../traversing/findFilter"
8 ], function( jQuery, document, rsingleTag ) {
9  
10 "use strict";
11  
12 // A central reference to the root jQuery(document)
13 var rootjQuery,
14  
15 // A simple way to check for HTML strings
16 // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
17 // Strict HTML recognition (#11290: must start with <)
18 // Shortcut simple #id case for speed
19 rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,
20  
21 <[\w\W]+> init = jQuery.fn.init = function( selector, context, root ) {
22 <[\w\W]+> var match, elem;
23  
24 <[\w\W]+> // HANDLE: $(""), $(null), $(undefined), $(false)
25 <[\w\W]+> if ( !selector ) {
26 <[\w\W]+> return this;
27 <[\w\W]+> }
28  
29 <[\w\W]+> // Method init() accepts an alternate rootjQuery
30 <[\w\W]+> // so migrate can support jQuery.sub (gh-2101)
31 <[\w\W]+> root = root || rootjQuery;
32  
33 <[\w\W]+> // Handle HTML strings
34 <[\w\W]+> if ( typeof selector === "string" ) {
35 <[\w\W]+> if ( selector[ 0 ] === "<" &&
36 <[\w\W]+> selector[ selector.length - 1 ] === ">" &&
37 <[\w\W]+> selector.length >= 3 ) {
38  
39 <[\w\W]+> // Assume that strings that start and end with <> are HTML and skip the regex check
40 <[\w\W]+> match = [ null, selector, null ];
41  
42 <[\w\W]+> } else {
43 <[\w\W]+> match = rquickExpr.exec( selector );
44 <[\w\W]+> }
45  
46 <[\w\W]+> // Match html or make sure no context is specified for #id
47 <[\w\W]+> if ( match && ( match[ 1 ] || !context ) ) {
48  
49 <[\w\W]+> // HANDLE: $(html) -> $(array)
50 <[\w\W]+> if ( match[ 1 ] ) {
51 <[\w\W]+> context = context instanceof jQuery ? context[ 0 ] : context;
52  
53 <[\w\W]+> // Option to run scripts is true for back-compat
54 <[\w\W]+> // Intentionally let the error be thrown if parseHTML is not present
55 <[\w\W]+> jQuery.merge( this, jQuery.parseHTML(
56 <[\w\W]+> match[ 1 ],
57 <[\w\W]+> context && context.nodeType ? context.ownerDocument || context : document,
58 <[\w\W]+> true
59 <[\w\W]+> ) );
60  
61 <[\w\W]+> // HANDLE: $(html, props)
62 <[\w\W]+> if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) {
63 <[\w\W]+> for ( match in context ) {
64  
65 <[\w\W]+> // Properties of context are called as methods if possible
66 <[\w\W]+> if ( jQuery.isFunction( this[ match ] ) ) {
67 <[\w\W]+> this[ match ]( context[ match ] );
68  
69 <[\w\W]+> // ...and otherwise set as attributes
70 <[\w\W]+> } else {
71 <[\w\W]+> this.attr( match, context[ match ] );
72 <[\w\W]+> }
73 <[\w\W]+> }
74 <[\w\W]+> }
75  
76 <[\w\W]+> return this;
77  
78 <[\w\W]+> // HANDLE: $(#id)
79 <[\w\W]+> } else {
80 <[\w\W]+> elem = document.getElementById( match[ 2 ] );
81  
82 <[\w\W]+> if ( elem ) {
83  
84 <[\w\W]+> // Inject the element directly into the jQuery object
85 <[\w\W]+> this[ 0 ] = elem;
86 <[\w\W]+> this.length = 1;
87 <[\w\W]+> }
88 <[\w\W]+> return this;
89 <[\w\W]+> }
90  
91 <[\w\W]+> // HANDLE: $(expr, $(...))
92 <[\w\W]+> } else if ( !context || context.jquery ) {
93 <[\w\W]+> return ( context || root ).find( selector );
94  
95 <[\w\W]+> // HANDLE: $(expr, context)
96 <[\w\W]+> // (which is just equivalent to: $(context).find(expr)
97 <[\w\W]+> } else {
98 <[\w\W]+> return this.constructor( context ).find( selector );
99 <[\w\W]+> }
100  
101 <[\w\W]+> // HANDLE: $(DOMElement)
102 <[\w\W]+> } else if ( selector.nodeType ) {
103 <[\w\W]+> this[ 0 ] = selector;
104 <[\w\W]+> this.length = 1;
105 <[\w\W]+> return this;
106  
107 <[\w\W]+> // HANDLE: $(function)
108 <[\w\W]+> // Shortcut for document ready
109 <[\w\W]+> } else if ( jQuery.isFunction( selector ) ) {
110 <[\w\W]+> return root.ready !== undefined ?
111 <[\w\W]+> root.ready( selector ) :
112  
113 <[\w\W]+> // Execute immediately if ready is not present
114 <[\w\W]+> selector( jQuery );
115 <[\w\W]+> }
116  
117 <[\w\W]+> return jQuery.makeArray( selector, this );
118 <[\w\W]+> };
119  
120 <[\w\W]+>// Give the init function the jQuery prototype for later instantiation
121 <[\w\W]+>init.prototype = jQuery.fn;
122  
123 <[\w\W]+>// Initialize central reference
124 <[\w\W]+>rootjQuery = jQuery( document );
125  
126 <[\w\W]+>return init;
127  
128 <[\w\W]+>} );