5a920362 |
1 | /*! |
2 | * jQuery UI Core 1.9.0 |
3 | * http://jqueryui.com |
4 | * |
5 | * Copyright 2012 jQuery Foundation and other contributors |
6 | * Released under the MIT license. |
7 | * http://jquery.org/license |
8 | * |
9 | * http://api.jqueryui.com/category/ui-core/ |
10 | */ |
11 | (function( $, undefined ) { |
12 | |
13 | var uuid = 0, |
14 | runiqueId = /^ui-id-\d+$/; |
15 | |
16 | // prevent duplicate loading |
17 | // this is only a problem because we proxy existing functions |
18 | // and we don't want to double proxy them |
19 | $.ui = $.ui || {}; |
20 | if ( $.ui.version ) { |
21 | return; |
22 | } |
23 | |
24 | $.extend( $.ui, { |
25 | version: "1.9.0", |
26 | |
27 | keyCode: { |
28 | BACKSPACE: 8, |
29 | COMMA: 188, |
30 | DELETE: 46, |
31 | DOWN: 40, |
32 | END: 35, |
33 | ENTER: 13, |
34 | ESCAPE: 27, |
35 | HOME: 36, |
36 | LEFT: 37, |
37 | NUMPAD_ADD: 107, |
38 | NUMPAD_DECIMAL: 110, |
39 | NUMPAD_DIVIDE: 111, |
40 | NUMPAD_ENTER: 108, |
41 | NUMPAD_MULTIPLY: 106, |
42 | NUMPAD_SUBTRACT: 109, |
43 | PAGE_DOWN: 34, |
44 | PAGE_UP: 33, |
45 | PERIOD: 190, |
46 | RIGHT: 39, |
47 | SPACE: 32, |
48 | TAB: 9, |
49 | UP: 38 |
50 | } |
51 | }); |
52 | |
53 | // plugins |
54 | $.fn.extend({ |
55 | _focus: $.fn.focus, |
56 | focus: function( delay, fn ) { |
57 | return typeof delay === "number" ? |
58 | this.each(function() { |
59 | var elem = this; |
60 | setTimeout(function() { |
61 | $( elem ).focus(); |
62 | if ( fn ) { |
63 | fn.call( elem ); |
64 | } |
65 | }, delay ); |
66 | }) : |
67 | this._focus.apply( this, arguments ); |
68 | }, |
69 | |
70 | scrollParent: function() { |
71 | var scrollParent; |
72 | if (($.browser.msie && (/(static|relative)/).test(this.css('position'))) || (/absolute/).test(this.css('position'))) { |
73 | scrollParent = this.parents().filter(function() { |
74 | return (/(relative|absolute|fixed)/).test($.css(this,'position')) && (/(auto|scroll)/).test($.css(this,'overflow')+$.css(this,'overflow-y')+$.css(this,'overflow-x')); |
75 | }).eq(0); |
76 | } else { |
77 | scrollParent = this.parents().filter(function() { |
78 | return (/(auto|scroll)/).test($.css(this,'overflow')+$.css(this,'overflow-y')+$.css(this,'overflow-x')); |
79 | }).eq(0); |
80 | } |
81 | |
82 | return (/fixed/).test(this.css('position')) || !scrollParent.length ? $(document) : scrollParent; |
83 | }, |
84 | |
85 | zIndex: function( zIndex ) { |
86 | if ( zIndex !== undefined ) { |
87 | return this.css( "zIndex", zIndex ); |
88 | } |
89 | |
90 | if ( this.length ) { |
91 | var elem = $( this[ 0 ] ), position, value; |
92 | while ( elem.length && elem[ 0 ] !== document ) { |
93 | // Ignore z-index if position is set to a value where z-index is ignored by the browser |
94 | // This makes behavior of this function consistent across browsers |
95 | // WebKit always returns auto if the element is positioned |
96 | position = elem.css( "position" ); |
97 | if ( position === "absolute" || position === "relative" || position === "fixed" ) { |
98 | // IE returns 0 when zIndex is not specified |
99 | // other browsers return a string |
100 | // we ignore the case of nested elements with an explicit value of 0 |
101 | // <div style="z-index: -10;"><div style="z-index: 0;"></div></div> |
102 | value = parseInt( elem.css( "zIndex" ), 10 ); |
103 | if ( !isNaN( value ) && value !== 0 ) { |
104 | return value; |
105 | } |
106 | } |
107 | elem = elem.parent(); |
108 | } |
109 | } |
110 | |
111 | return 0; |
112 | }, |
113 | |
114 | uniqueId: function() { |
115 | return this.each(function() { |
116 | if ( !this.id ) { |
117 | this.id = "ui-id-" + (++uuid); |
118 | } |
119 | }); |
120 | }, |
121 | |
122 | removeUniqueId: function() { |
123 | return this.each(function() { |
124 | if ( runiqueId.test( this.id ) ) { |
125 | $( this ).removeAttr( "id" ); |
126 | } |
127 | }); |
128 | } |
129 | }); |
130 | |
131 | // support: jQuery <1.8 |
132 | if ( !$( "<a>" ).outerWidth( 1 ).jquery ) { |
133 | $.each( [ "Width", "Height" ], function( i, name ) { |
134 | var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ], |
135 | type = name.toLowerCase(), |
136 | orig = { |
137 | innerWidth: $.fn.innerWidth, |
138 | innerHeight: $.fn.innerHeight, |
139 | outerWidth: $.fn.outerWidth, |
140 | outerHeight: $.fn.outerHeight |
141 | }; |
142 | |
143 | function reduce( elem, size, border, margin ) { |
144 | $.each( side, function() { |
145 | size -= parseFloat( $.css( elem, "padding" + this ) ) || 0; |
146 | if ( border ) { |
147 | size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0; |
148 | } |
149 | if ( margin ) { |
150 | size -= parseFloat( $.css( elem, "margin" + this ) ) || 0; |
151 | } |
152 | }); |
153 | return size; |
154 | } |
155 | |
156 | $.fn[ "inner" + name ] = function( size ) { |
157 | if ( size === undefined ) { |
158 | return orig[ "inner" + name ].call( this ); |
159 | } |
160 | |
161 | return this.each(function() { |
162 | $( this ).css( type, reduce( this, size ) + "px" ); |
163 | }); |
164 | }; |
165 | |
166 | $.fn[ "outer" + name] = function( size, margin ) { |
167 | if ( typeof size !== "number" ) { |
168 | return orig[ "outer" + name ].call( this, size ); |
169 | } |
170 | |
171 | return this.each(function() { |
172 | $( this).css( type, reduce( this, size, true, margin ) + "px" ); |
173 | }); |
174 | }; |
175 | }); |
176 | } |
177 | |
178 | // selectors |
179 | function focusable( element, isTabIndexNotNaN ) { |
180 | var map, mapName, img, |
181 | nodeName = element.nodeName.toLowerCase(); |
182 | if ( "area" === nodeName ) { |
183 | map = element.parentNode; |
184 | mapName = map.name; |
185 | if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) { |
186 | return false; |
187 | } |
188 | img = $( "img[usemap=#" + mapName + "]" )[0]; |
189 | return !!img && visible( img ); |
190 | } |
191 | return ( /input|select|textarea|button|object/.test( nodeName ) ? |
192 | !element.disabled : |
193 | "a" === nodeName ? |
194 | element.href || isTabIndexNotNaN : |
195 | isTabIndexNotNaN) && |
196 | // the element and all of its ancestors must be visible |
197 | visible( element ); |
198 | } |
199 | |
200 | function visible( element ) { |
201 | return !$( element ).parents().andSelf().filter(function() { |
202 | return $.css( this, "visibility" ) === "hidden" || |
203 | $.expr.filters.hidden( this ); |
204 | }).length; |
205 | } |
206 | |
207 | $.extend( $.expr[ ":" ], { |
208 | data: $.expr.createPseudo ? |
209 | $.expr.createPseudo(function( dataName ) { |
210 | return function( elem ) { |
211 | return !!$.data( elem, dataName ); |
212 | }; |
213 | }) : |
214 | // support: jQuery <1.8 |
215 | function( elem, i, match ) { |
216 | return !!$.data( elem, match[ 3 ] ); |
217 | }, |
218 | |
219 | focusable: function( element ) { |
220 | return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) ); |
221 | }, |
222 | |
223 | tabbable: function( element ) { |
224 | var tabIndex = $.attr( element, "tabindex" ), |
225 | isTabIndexNaN = isNaN( tabIndex ); |
226 | return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN ); |
227 | } |
228 | }); |
229 | |
230 | // support |
231 | $(function() { |
232 | var body = document.body, |
233 | div = body.appendChild( div = document.createElement( "div" ) ); |
234 | |
235 | // access offsetHeight before setting the style to prevent a layout bug |
236 | // in IE 9 which causes the element to continue to take up space even |
237 | // after it is removed from the DOM (#8026) |
238 | div.offsetHeight; |
239 | |
240 | $.extend( div.style, { |
241 | minHeight: "100px", |
242 | height: "auto", |
243 | padding: 0, |
244 | borderWidth: 0 |
245 | }); |
246 | |
247 | $.support.minHeight = div.offsetHeight === 100; |
248 | $.support.selectstart = "onselectstart" in div; |
249 | |
250 | // set display to none to avoid a layout bug in IE |
251 | // http://dev.jquery.com/ticket/4014 |
252 | body.removeChild( div ).style.display = "none"; |
253 | }); |
254 | |
255 | |
256 | |
257 | |
258 | |
259 | // deprecated |
260 | |
261 | $.fn.extend({ |
262 | disableSelection: function() { |
263 | return this.bind( ( $.support.selectstart ? "selectstart" : "mousedown" ) + |
264 | ".ui-disableSelection", function( event ) { |
265 | event.preventDefault(); |
266 | }); |
267 | }, |
268 | |
269 | enableSelection: function() { |
270 | return this.unbind( ".ui-disableSelection" ); |
271 | } |
272 | }); |
273 | |
274 | $.extend( $.ui, { |
275 | // $.ui.plugin is deprecated. Use the proxy pattern instead. |
276 | plugin: { |
277 | add: function( module, option, set ) { |
278 | var i, |
279 | proto = $.ui[ module ].prototype; |
280 | for ( i in set ) { |
281 | proto.plugins[ i ] = proto.plugins[ i ] || []; |
282 | proto.plugins[ i ].push( [ option, set[ i ] ] ); |
283 | } |
284 | }, |
285 | call: function( instance, name, args ) { |
286 | var i, |
287 | set = instance.plugins[ name ]; |
288 | if ( !set || !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) { |
289 | return; |
290 | } |
291 | |
292 | for ( i = 0; i < set.length; i++ ) { |
293 | if ( instance.options[ set[ i ][ 0 ] ] ) { |
294 | set[ i ][ 1 ].apply( instance.element, args ); |
295 | } |
296 | } |
297 | } |
298 | }, |
299 | |
300 | contains: $.contains, |
301 | |
302 | // only used by resizable |
303 | hasScroll: function( el, a ) { |
304 | |
305 | //If overflow is hidden, the element might have extra content, but the user wants to hide it |
306 | if ( $( el ).css( "overflow" ) === "hidden") { |
307 | return false; |
308 | } |
309 | |
310 | var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop", |
311 | has = false; |
312 | |
313 | if ( el[ scroll ] > 0 ) { |
314 | return true; |
315 | } |
316 | |
317 | // TODO: determine which cases actually cause this to happen |
318 | // if the element doesn't have the scroll set, see if it's possible to |
319 | // set the scroll |
320 | el[ scroll ] = 1; |
321 | has = ( el[ scroll ] > 0 ); |
322 | el[ scroll ] = 0; |
323 | return has; |
324 | }, |
325 | |
326 | // these are odd functions, fix the API or move into individual plugins |
327 | isOverAxis: function( x, reference, size ) { |
328 | //Determines when x coordinate is over "b" element axis |
329 | return ( x > reference ) && ( x < ( reference + size ) ); |
330 | }, |
331 | isOver: function( y, x, top, left, height, width ) { |
332 | //Determines when x, y coordinates is over "b" element |
333 | return $.ui.isOverAxis( y, top, height ) && $.ui.isOverAxis( x, left, width ); |
334 | } |
335 | }); |
336 | |
337 | })( jQuery ); |