corrade-nucleus-nucleons – Blame information for rev 20

Subversion Repositories:
Rev:
Rev Author Line No. Line
20 office 1 define([
2 "./core"
3 ], function( jQuery ) {
4  
5 /*
6 * Optional (non-Sizzle) selector module for custom builds.
7 *
8 * Note that this DOES NOT SUPPORT many documented jQuery
9 * features in exchange for its smaller size:
10 *
11 * Attribute not equal selector
12 * Positional selectors (:first; :eq(n); :odd; etc.)
13 * Type selectors (:input; :checkbox; :button; etc.)
14 * State-based selectors (:animated; :visible; :hidden; etc.)
15 * :has(selector)
16 * :not(complex selector)
17 * custom selectors via Sizzle extensions
18 * Leading combinators (e.g., $collection.find("> *"))
19 * Reliable functionality on XML fragments
20 * Requiring all parts of a selector to match elements under context
21 * (e.g., $div.find("div > *") now matches children of $div)
22 * Matching against non-elements
23 * Reliable sorting of disconnected nodes
24 * querySelectorAll bug fixes (e.g., unreliable :focus on WebKit)
25 *
26 * If any of these are unacceptable tradeoffs, either use Sizzle or
27 * customize this stub for the project's specific needs.
28 */
29  
30 var docElem = window.document.documentElement,
31 selector_hasDuplicate,
32 matches = docElem.webkitMatchesSelector ||
33 docElem.mozMatchesSelector ||
34 docElem.oMatchesSelector ||
35 docElem.msMatchesSelector,
36 selector_sortOrder = function( a, b ) {
37 // Flag for duplicate removal
38 if ( a === b ) {
39 selector_hasDuplicate = true;
40 return 0;
41 }
42  
43 var compare = b.compareDocumentPosition && a.compareDocumentPosition && a.compareDocumentPosition( b );
44  
45 if ( compare ) {
46 // Disconnected nodes
47 if ( compare & 1 ) {
48  
49 // Choose the first element that is related to our document
50 if ( a === document || jQuery.contains(document, a) ) {
51 return -1;
52 }
53 if ( b === document || jQuery.contains(document, b) ) {
54 return 1;
55 }
56  
57 // Maintain original order
58 return 0;
59 }
60  
61 return compare & 4 ? -1 : 1;
62 }
63  
64 // Not directly comparable, sort on existence of method
65 return a.compareDocumentPosition ? -1 : 1;
66 };
67  
68 jQuery.extend({
69 find: function( selector, context, results, seed ) {
70 var elem, nodeType,
71 i = 0;
72  
73 results = results || [];
74 context = context || document;
75  
76 // Same basic safeguard as Sizzle
77 if ( !selector || typeof selector !== "string" ) {
78 return results;
79 }
80  
81 // Early return if context is not an element or document
82 if ( (nodeType = context.nodeType) !== 1 && nodeType !== 9 ) {
83 return [];
84 }
85  
86 if ( seed ) {
87 while ( (elem = seed[i++]) ) {
88 if ( jQuery.find.matchesSelector(elem, selector) ) {
89 results.push( elem );
90 }
91 }
92 } else {
93 jQuery.merge( results, context.querySelectorAll(selector) );
94 }
95  
96 return results;
97 },
98 unique: function( results ) {
99 var elem,
100 duplicates = [],
101 i = 0,
102 j = 0;
103  
104 selector_hasDuplicate = false;
105 results.sort( selector_sortOrder );
106  
107 if ( selector_hasDuplicate ) {
108 while ( (elem = results[i++]) ) {
109 if ( elem === results[ i ] ) {
110 j = duplicates.push( i );
111 }
112 }
113 while ( j-- ) {
114 results.splice( duplicates[ j ], 1 );
115 }
116 }
117  
118 return results;
119 },
120 text: function( elem ) {
121 var node,
122 ret = "",
123 i = 0,
124 nodeType = elem.nodeType;
125  
126 if ( !nodeType ) {
127 // If no nodeType, this is expected to be an array
128 while ( (node = elem[i++]) ) {
129 // Do not traverse comment nodes
130 ret += jQuery.text( node );
131 }
132 } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
133 // Use textContent for elements
134 return elem.textContent;
135 } else if ( nodeType === 3 || nodeType === 4 ) {
136 return elem.nodeValue;
137 }
138 // Do not include comment or processing instruction nodes
139  
140 return ret;
141 },
142 contains: function( a, b ) {
143 var adown = a.nodeType === 9 ? a.documentElement : a,
144 bup = b && b.parentNode;
145 return a === bup || !!( bup && bup.nodeType === 1 && adown.contains(bup) );
146 },
147 isXMLDoc: function( elem ) {
148 return (elem.ownerDocument || elem).documentElement.nodeName !== "HTML";
149 },
150 expr: {
151 attrHandle: {},
152 match: {
153 bool: /^(?:checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped)$/i,
154 needsContext: /^[\x20\t\r\n\f]*[>+~]/
155 }
156 }
157 });
158  
159 jQuery.extend( jQuery.find, {
160 matches: function( expr, elements ) {
161 return jQuery.find( expr, null, null, elements );
162 },
163 matchesSelector: function( elem, expr ) {
164 return matches.call( elem, expr );
165 },
166 attr: function( elem, name ) {
167 return elem.getAttribute( name );
168 }
169 });
170  
171 });