2 * jQuery UI Core 1.10.3
5 * Copyright 2013 jQuery Foundation and other contributors
6 * Released under the MIT license.
7 * http://jquery.org/license
9 * http://api.jqueryui.com/category/ui-core/
11 (function( $, undefined ) {
14 runiqueId = /^ui-id-\d+$/;
16 // $.ui might exist from components with no dependencies, e.g., $.ui.position
50 focus: (function( orig ) {
51 return function( delay, fn ) {
52 return typeof delay === "number" ?
53 this.each(function() {
55 setTimeout(function() {
62 orig.apply( this, arguments );
66 scrollParent: function() {
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"));
73 scrollParent = this.parents().filter(function() {
74 return (/(auto|scroll)/).test($.css(this,"overflow")+$.css(this,"overflow-y")+$.css(this,"overflow-x"));
78 return (/fixed/).test(this.css("position")) || !scrollParent.length ? $(document) : scrollParent;
81 zIndex: function( zIndex ) {
82 if ( zIndex !== undefined ) {
83 return this.css( "zIndex", zIndex );
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 ) {
103 elem = elem.parent();
110 uniqueId: function() {
111 return this.each(function() {
113 this.id = "ui-id-" + (++uuid);
118 removeUniqueId: function() {
119 return this.each(function() {
120 if ( runiqueId.test( this.id ) ) {
121 $( this ).removeAttr( "id" );
128 function focusable( element, isTabIndexNotNaN ) {
129 var map, mapName, img,
130 nodeName = element.nodeName.toLowerCase();
131 if ( "area" === nodeName ) {
132 map = element.parentNode;
134 if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
137 img = $( "img[usemap=#" + mapName + "]" )[0];
138 return !!img && visible( img );
140 return ( /input|select|textarea|button|object/.test( nodeName ) ?
143 element.href || isTabIndexNotNaN :
145 // the element and all of its ancestors must be visible
149 function visible( element ) {
150 return $.expr.filters.visible( element ) &&
151 !$( element ).parents().addBack().filter(function() {
152 return $.css( this, "visibility" ) === "hidden";
156 $.extend( $.expr[ ":" ], {
157 data: $.expr.createPseudo ?
158 $.expr.createPseudo(function( dataName ) {
159 return function( elem ) {
160 return !!$.data( elem, dataName );
163 // support: jQuery <1.8
164 function( elem, i, match ) {
165 return !!$.data( elem, match[ 3 ] );
168 focusable: function( element ) {
169 return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) );
172 tabbable: function( element ) {
173 var tabIndex = $.attr( element, "tabindex" ),
174 isTabIndexNaN = isNaN( tabIndex );
175 return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN );
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(),
185 innerWidth: $.fn.innerWidth,
186 innerHeight: $.fn.innerHeight,
187 outerWidth: $.fn.outerWidth,
188 outerHeight: $.fn.outerHeight
191 function reduce( elem, size, border, margin ) {
192 $.each( side, function() {
193 size -= parseFloat( $.css( elem, "padding" + this ) ) || 0;
195 size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0;
198 size -= parseFloat( $.css( elem, "margin" + this ) ) || 0;
204 $.fn[ "inner" + name ] = function( size ) {
205 if ( size === undefined ) {
206 return orig[ "inner" + name ].call( this );
209 return this.each(function() {
210 $( this ).css( type, reduce( this, size ) + "px" );
214 $.fn[ "outer" + name] = function( size, margin ) {
215 if ( typeof size !== "number" ) {
216 return orig[ "outer" + name ].call( this, size );
219 return this.each(function() {
220 $( this).css( type, reduce( this, size, true, margin ) + "px" );
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 )
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 ) );
242 return removeData.call( this );
245 })( $.fn.removeData );
253 $.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() );
255 $.support.selectstart = "onselectstart" in document.createElement( "div" );
257 disableSelection: function() {
258 return this.bind( ( $.support.selectstart ? "selectstart" : "mousedown" ) +
259 ".ui-disableSelection", function( event ) {
260 event.preventDefault();
264 enableSelection: function() {
265 return this.unbind( ".ui-disableSelection" );
270 // $.ui.plugin is deprecated. Use $.widget() extensions instead.
272 add: function( module, option, set ) {
274 proto = $.ui[ module ].prototype;
276 proto.plugins[ i ] = proto.plugins[ i ] || [];
277 proto.plugins[ i ].push( [ option, set[ i ] ] );
280 call: function( instance, name, args ) {
282 set = instance.plugins[ name ];
283 if ( !set || !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) {
287 for ( i = 0; i < set.length; i++ ) {
288 if ( instance.options[ set[ i ][ 0 ] ] ) {
289 set[ i ][ 1 ].apply( instance.element, args );
295 // only used by resizable
296 hasScroll: function( el, a ) {
298 //If overflow is hidden, the element might have extra content, but the user wants to hide it
299 if ( $( el ).css( "overflow" ) === "hidden") {
303 var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
306 if ( el[ scroll ] > 0 ) {
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
314 has = ( el[ scroll ] > 0 );