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