JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
register coffeescript compiler
[peach-cgt.git] / external / jquery.ui.core.js
1 /*!
2  * jQuery UI 1.8.17
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.17",
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         $.extend( div.style, {
229                 minHeight: "100px",
230                 height: "auto",
231                 padding: 0,
232                 borderWidth: 0
233         });
234
235         $.support.minHeight = div.offsetHeight === 100;
236         $.support.selectstart = "onselectstart" in div;
237
238         // set display to none to avoid a layout bug in IE
239         // http://dev.jquery.com/ticket/4014
240         body.removeChild( div ).style.display = "none";
241 });
242
243
244
245
246
247 // deprecated
248 $.extend( $.ui, {
249         // $.ui.plugin is deprecated.  Use the proxy pattern instead.
250         plugin: {
251                 add: function( module, option, set ) {
252                         var proto = $.ui[ module ].prototype;
253                         for ( var i in set ) {
254                                 proto.plugins[ i ] = proto.plugins[ i ] || [];
255                                 proto.plugins[ i ].push( [ option, set[ i ] ] );
256                         }
257                 },
258                 call: function( instance, name, args ) {
259                         var set = instance.plugins[ name ];
260                         if ( !set || !instance.element[ 0 ].parentNode ) {
261                                 return;
262                         }
263         
264                         for ( var i = 0; i < set.length; i++ ) {
265                                 if ( instance.options[ set[ i ][ 0 ] ] ) {
266                                         set[ i ][ 1 ].apply( instance.element, args );
267                                 }
268                         }
269                 }
270         },
271         
272         // will be deprecated when we switch to jQuery 1.4 - use jQuery.contains()
273         contains: function( a, b ) {
274                 return document.compareDocumentPosition ?
275                         a.compareDocumentPosition( b ) & 16 :
276                         a !== b && a.contains( b );
277         },
278         
279         // only used by resizable
280         hasScroll: function( el, a ) {
281         
282                 //If overflow is hidden, the element might have extra content, but the user wants to hide it
283                 if ( $( el ).css( "overflow" ) === "hidden") {
284                         return false;
285                 }
286         
287                 var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
288                         has = false;
289         
290                 if ( el[ scroll ] > 0 ) {
291                         return true;
292                 }
293         
294                 // TODO: determine which cases actually cause this to happen
295                 // if the element doesn't have the scroll set, see if it's possible to
296                 // set the scroll
297                 el[ scroll ] = 1;
298                 has = ( el[ scroll ] > 0 );
299                 el[ scroll ] = 0;
300                 return has;
301         },
302         
303         // these are odd functions, fix the API or move into individual plugins
304         isOverAxis: function( x, reference, size ) {
305                 //Determines when x coordinate is over "b" element axis
306                 return ( x > reference ) && ( x < ( reference + size ) );
307         },
308         isOver: function( y, x, top, left, height, width ) {
309                 //Determines when x, y coordinates is over "b" element
310                 return $.ui.isOverAxis( y, top, height ) && $.ui.isOverAxis( x, left, width );
311         }
312 });
313
314 })( jQuery );