Projet

Général

Profil

Paste
Télécharger (8 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / jquery_update / replace / ui / ui / jquery.ui.core.js @ 503b3f7b

1
/*!
2
 * jQuery UI Core 1.10.2
3
 * http://jqueryui.com
4
 *
5
 * Copyright 2013 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
// $.ui might exist from components with no dependencies, e.g., $.ui.position
17
$.ui = $.ui || {};
18

    
19
$.extend( $.ui, {
20
        version: "1.10.2",
21

    
22
        keyCode: {
23
                BACKSPACE: 8,
24
                COMMA: 188,
25
                DELETE: 46,
26
                DOWN: 40,
27
                END: 35,
28
                ENTER: 13,
29
                ESCAPE: 27,
30
                HOME: 36,
31
                LEFT: 37,
32
                NUMPAD_ADD: 107,
33
                NUMPAD_DECIMAL: 110,
34
                NUMPAD_DIVIDE: 111,
35
                NUMPAD_ENTER: 108,
36
                NUMPAD_MULTIPLY: 106,
37
                NUMPAD_SUBTRACT: 109,
38
                PAGE_DOWN: 34,
39
                PAGE_UP: 33,
40
                PERIOD: 190,
41
                RIGHT: 39,
42
                SPACE: 32,
43
                TAB: 9,
44
                UP: 38
45
        }
46
});
47

    
48
// plugins
49
$.fn.extend({
50
        focus: (function( orig ) {
51
                return function( delay, fn ) {
52
                        return typeof delay === "number" ?
53
                                this.each(function() {
54
                                        var elem = this;
55
                                        setTimeout(function() {
56
                                                $( elem ).focus();
57
                                                if ( fn ) {
58
                                                        fn.call( elem );
59
                                                }
60
                                        }, delay );
61
                                }) :
62
                                orig.apply( this, arguments );
63
                };
64
        })( $.fn.focus ),
65

    
66
        scrollParent: function() {
67
                var scrollParent;
68
                if (($.ui.ie && (/(static|relative)/).test(this.css("position"))) || (/absolute/).test(this.css("position"))) {
69
                        scrollParent = this.parents().filter(function() {
70
                                return (/(relative|absolute|fixed)/).test($.css(this,"position")) && (/(auto|scroll)/).test($.css(this,"overflow")+$.css(this,"overflow-y")+$.css(this,"overflow-x"));
71
                        }).eq(0);
72
                } else {
73
                        scrollParent = this.parents().filter(function() {
74
                                return (/(auto|scroll)/).test($.css(this,"overflow")+$.css(this,"overflow-y")+$.css(this,"overflow-x"));
75
                        }).eq(0);
76
                }
77

    
78
                return (/fixed/).test(this.css("position")) || !scrollParent.length ? $(document) : scrollParent;
79
        },
80

    
81
        zIndex: function( zIndex ) {
82
                if ( zIndex !== undefined ) {
83
                        return this.css( "zIndex", zIndex );
84
                }
85

    
86
                if ( this.length ) {
87
                        var elem = $( this[ 0 ] ), position, value;
88
                        while ( elem.length && elem[ 0 ] !== document ) {
89
                                // Ignore z-index if position is set to a value where z-index is ignored by the browser
90
                                // This makes behavior of this function consistent across browsers
91
                                // WebKit always returns auto if the element is positioned
92
                                position = elem.css( "position" );
93
                                if ( position === "absolute" || position === "relative" || position === "fixed" ) {
94
                                        // IE returns 0 when zIndex is not specified
95
                                        // other browsers return a string
96
                                        // we ignore the case of nested elements with an explicit value of 0
97
                                        // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
98
                                        value = parseInt( elem.css( "zIndex" ), 10 );
99
                                        if ( !isNaN( value ) && value !== 0 ) {
100
                                                return value;
101
                                        }
102
                                }
103
                                elem = elem.parent();
104
                        }
105
                }
106

    
107
                return 0;
108
        },
109

    
110
        uniqueId: function() {
111
                return this.each(function() {
112
                        if ( !this.id ) {
113
                                this.id = "ui-id-" + (++uuid);
114
                        }
115
                });
116
        },
117

    
118
        removeUniqueId: function() {
119
                return this.each(function() {
120
                        if ( runiqueId.test( this.id ) ) {
121
                                $( this ).removeAttr( "id" );
122
                        }
123
                });
124
        }
125
});
126

    
127
// selectors
128
function focusable( element, isTabIndexNotNaN ) {
129
        var map, mapName, img,
130
                nodeName = element.nodeName.toLowerCase();
131
        if ( "area" === nodeName ) {
132
                map = element.parentNode;
133
                mapName = map.name;
134
                if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
135
                        return false;
136
                }
137
                img = $( "img[usemap=#" + mapName + "]" )[0];
138
                return !!img && visible( img );
139
        }
140
        return ( /input|select|textarea|button|object/.test( nodeName ) ?
141
                !element.disabled :
142
                "a" === nodeName ?
143
                        element.href || isTabIndexNotNaN :
144
                        isTabIndexNotNaN) &&
145
                // the element and all of its ancestors must be visible
146
                visible( element );
147
}
148

    
149
function visible( element ) {
150
        return $.expr.filters.visible( element ) &&
151
                !$( element ).parents().addBack().filter(function() {
152
                        return $.css( this, "visibility" ) === "hidden";
153
                }).length;
154
}
155

    
156
$.extend( $.expr[ ":" ], {
157
        data: $.expr.createPseudo ?
158
                $.expr.createPseudo(function( dataName ) {
159
                        return function( elem ) {
160
                                return !!$.data( elem, dataName );
161
                        };
162
                }) :
163
                // support: jQuery <1.8
164
                function( elem, i, match ) {
165
                        return !!$.data( elem, match[ 3 ] );
166
                },
167

    
168
        focusable: function( element ) {
169
                return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) );
170
        },
171

    
172
        tabbable: function( element ) {
173
                var tabIndex = $.attr( element, "tabindex" ),
174
                        isTabIndexNaN = isNaN( tabIndex );
175
                return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN );
176
        }
177
});
178

    
179
// support: jQuery <1.8
180
if ( !$( "<a>" ).outerWidth( 1 ).jquery ) {
181
        $.each( [ "Width", "Height" ], function( i, name ) {
182
                var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
183
                        type = name.toLowerCase(),
184
                        orig = {
185
                                innerWidth: $.fn.innerWidth,
186
                                innerHeight: $.fn.innerHeight,
187
                                outerWidth: $.fn.outerWidth,
188
                                outerHeight: $.fn.outerHeight
189
                        };
190

    
191
                function reduce( elem, size, border, margin ) {
192
                        $.each( side, function() {
193
                                size -= parseFloat( $.css( elem, "padding" + this ) ) || 0;
194
                                if ( border ) {
195
                                        size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0;
196
                                }
197
                                if ( margin ) {
198
                                        size -= parseFloat( $.css( elem, "margin" + this ) ) || 0;
199
                                }
200
                        });
201
                        return size;
202
                }
203

    
204
                $.fn[ "inner" + name ] = function( size ) {
205
                        if ( size === undefined ) {
206
                                return orig[ "inner" + name ].call( this );
207
                        }
208

    
209
                        return this.each(function() {
210
                                $( this ).css( type, reduce( this, size ) + "px" );
211
                        });
212
                };
213

    
214
                $.fn[ "outer" + name] = function( size, margin ) {
215
                        if ( typeof size !== "number" ) {
216
                                return orig[ "outer" + name ].call( this, size );
217
                        }
218

    
219
                        return this.each(function() {
220
                                $( this).css( type, reduce( this, size, true, margin ) + "px" );
221
                        });
222
                };
223
        });
224
}
225

    
226
// support: jQuery <1.8
227
if ( !$.fn.addBack ) {
228
        $.fn.addBack = function( selector ) {
229
                return this.add( selector == null ?
230
                        this.prevObject : this.prevObject.filter( selector )
231
                );
232
        };
233
}
234

    
235
// support: jQuery 1.6.1, 1.6.2 (http://bugs.jquery.com/ticket/9413)
236
if ( $( "<a>" ).data( "a-b", "a" ).removeData( "a-b" ).data( "a-b" ) ) {
237
        $.fn.removeData = (function( removeData ) {
238
                return function( key ) {
239
                        if ( arguments.length ) {
240
                                return removeData.call( this, $.camelCase( key ) );
241
                        } else {
242
                                return removeData.call( this );
243
                        }
244
                };
245
        })( $.fn.removeData );
246
}
247

    
248

    
249

    
250

    
251

    
252
// deprecated
253
$.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() );
254

    
255
$.support.selectstart = "onselectstart" in document.createElement( "div" );
256
$.fn.extend({
257
        disableSelection: function() {
258
                return this.bind( ( $.support.selectstart ? "selectstart" : "mousedown" ) +
259
                        ".ui-disableSelection", function( event ) {
260
                                event.preventDefault();
261
                        });
262
        },
263

    
264
        enableSelection: function() {
265
                return this.unbind( ".ui-disableSelection" );
266
        }
267
});
268

    
269
$.extend( $.ui, {
270
        // $.ui.plugin is deprecated.  Use the proxy pattern instead.
271
        plugin: {
272
                add: function( module, option, set ) {
273
                        var i,
274
                                proto = $.ui[ module ].prototype;
275
                        for ( i in set ) {
276
                                proto.plugins[ i ] = proto.plugins[ i ] || [];
277
                                proto.plugins[ i ].push( [ option, set[ i ] ] );
278
                        }
279
                },
280
                call: function( instance, name, args ) {
281
                        var i,
282
                                set = instance.plugins[ name ];
283
                        if ( !set || !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) {
284
                                return;
285
                        }
286

    
287
                        for ( i = 0; i < set.length; i++ ) {
288
                                if ( instance.options[ set[ i ][ 0 ] ] ) {
289
                                        set[ i ][ 1 ].apply( instance.element, args );
290
                                }
291
                        }
292
                }
293
        },
294

    
295
        // only used by resizable
296
        hasScroll: function( el, a ) {
297

    
298
                //If overflow is hidden, the element might have extra content, but the user wants to hide it
299
                if ( $( el ).css( "overflow" ) === "hidden") {
300
                        return false;
301
                }
302

    
303
                var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
304
                        has = false;
305

    
306
                if ( el[ scroll ] > 0 ) {
307
                        return true;
308
                }
309

    
310
                // TODO: determine which cases actually cause this to happen
311
                // if the element doesn't have the scroll set, see if it's possible to
312
                // set the scroll
313
                el[ scroll ] = 1;
314
                has = ( el[ scroll ] > 0 );
315
                el[ scroll ] = 0;
316
                return has;
317
        }
318
});
319

    
320
})( jQuery );