PageRenderTime 68ms CodeModel.GetById 18ms app.highlight 42ms RepoModel.GetById 1ms app.codeStats 0ms

/application/static/libs/adminlte/bower_components/jquery-ui/ui/core.js

https://bitbucket.org/tin_gimranoff/docstar
JavaScript | 304 lines | 239 code | 36 blank | 29 comment | 49 complexity | 3be59cdda109af700e3e788fe8cf9fde MD5 | raw file
  1/*!
  2 * jQuery UI Core 1.11.4
  3 * http://jqueryui.com
  4 *
  5 * Copyright 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( factory ) {
 12	if ( typeof define === "function" && define.amd ) {
 13
 14		// AMD. Register as an anonymous module.
 15		define( [ "jquery" ], factory );
 16	} else {
 17
 18		// Browser globals
 19		factory( jQuery );
 20	}
 21}(function( $ ) {
 22
 23// $.ui might exist from components with no dependencies, e.g., $.ui.position
 24$.ui = $.ui || {};
 25
 26$.extend( $.ui, {
 27	version: "1.11.4",
 28
 29	keyCode: {
 30		BACKSPACE: 8,
 31		COMMA: 188,
 32		DELETE: 46,
 33		DOWN: 40,
 34		END: 35,
 35		ENTER: 13,
 36		ESCAPE: 27,
 37		HOME: 36,
 38		LEFT: 37,
 39		PAGE_DOWN: 34,
 40		PAGE_UP: 33,
 41		PERIOD: 190,
 42		RIGHT: 39,
 43		SPACE: 32,
 44		TAB: 9,
 45		UP: 38
 46	}
 47});
 48
 49// plugins
 50$.fn.extend({
 51	scrollParent: function( includeHidden ) {
 52		var position = this.css( "position" ),
 53			excludeStaticParent = position === "absolute",
 54			overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/,
 55			scrollParent = this.parents().filter( function() {
 56				var parent = $( this );
 57				if ( excludeStaticParent && parent.css( "position" ) === "static" ) {
 58					return false;
 59				}
 60				return overflowRegex.test( parent.css( "overflow" ) + parent.css( "overflow-y" ) + parent.css( "overflow-x" ) );
 61			}).eq( 0 );
 62
 63		return position === "fixed" || !scrollParent.length ? $( this[ 0 ].ownerDocument || document ) : scrollParent;
 64	},
 65
 66	uniqueId: (function() {
 67		var uuid = 0;
 68
 69		return function() {
 70			return this.each(function() {
 71				if ( !this.id ) {
 72					this.id = "ui-id-" + ( ++uuid );
 73				}
 74			});
 75		};
 76	})(),
 77
 78	removeUniqueId: function() {
 79		return this.each(function() {
 80			if ( /^ui-id-\d+$/.test( this.id ) ) {
 81				$( this ).removeAttr( "id" );
 82			}
 83		});
 84	}
 85});
 86
 87// selectors
 88function focusable( element, isTabIndexNotNaN ) {
 89	var map, mapName, img,
 90		nodeName = element.nodeName.toLowerCase();
 91	if ( "area" === nodeName ) {
 92		map = element.parentNode;
 93		mapName = map.name;
 94		if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
 95			return false;
 96		}
 97		img = $( "img[usemap='#" + mapName + "']" )[ 0 ];
 98		return !!img && visible( img );
 99	}
100	return ( /^(input|select|textarea|button|object)$/.test( nodeName ) ?
101		!element.disabled :
102		"a" === nodeName ?
103			element.href || isTabIndexNotNaN :
104			isTabIndexNotNaN) &&
105		// the element and all of its ancestors must be visible
106		visible( element );
107}
108
109function visible( element ) {
110	return $.expr.filters.visible( element ) &&
111		!$( element ).parents().addBack().filter(function() {
112			return $.css( this, "visibility" ) === "hidden";
113		}).length;
114}
115
116$.extend( $.expr[ ":" ], {
117	data: $.expr.createPseudo ?
118		$.expr.createPseudo(function( dataName ) {
119			return function( elem ) {
120				return !!$.data( elem, dataName );
121			};
122		}) :
123		// support: jQuery <1.8
124		function( elem, i, match ) {
125			return !!$.data( elem, match[ 3 ] );
126		},
127
128	focusable: function( element ) {
129		return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) );
130	},
131
132	tabbable: function( element ) {
133		var tabIndex = $.attr( element, "tabindex" ),
134			isTabIndexNaN = isNaN( tabIndex );
135		return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN );
136	}
137});
138
139// support: jQuery <1.8
140if ( !$( "<a>" ).outerWidth( 1 ).jquery ) {
141	$.each( [ "Width", "Height" ], function( i, name ) {
142		var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
143			type = name.toLowerCase(),
144			orig = {
145				innerWidth: $.fn.innerWidth,
146				innerHeight: $.fn.innerHeight,
147				outerWidth: $.fn.outerWidth,
148				outerHeight: $.fn.outerHeight
149			};
150
151		function reduce( elem, size, border, margin ) {
152			$.each( side, function() {
153				size -= parseFloat( $.css( elem, "padding" + this ) ) || 0;
154				if ( border ) {
155					size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0;
156				}
157				if ( margin ) {
158					size -= parseFloat( $.css( elem, "margin" + this ) ) || 0;
159				}
160			});
161			return size;
162		}
163
164		$.fn[ "inner" + name ] = function( size ) {
165			if ( size === undefined ) {
166				return orig[ "inner" + name ].call( this );
167			}
168
169			return this.each(function() {
170				$( this ).css( type, reduce( this, size ) + "px" );
171			});
172		};
173
174		$.fn[ "outer" + name] = function( size, margin ) {
175			if ( typeof size !== "number" ) {
176				return orig[ "outer" + name ].call( this, size );
177			}
178
179			return this.each(function() {
180				$( this).css( type, reduce( this, size, true, margin ) + "px" );
181			});
182		};
183	});
184}
185
186// support: jQuery <1.8
187if ( !$.fn.addBack ) {
188	$.fn.addBack = function( selector ) {
189		return this.add( selector == null ?
190			this.prevObject : this.prevObject.filter( selector )
191		);
192	};
193}
194
195// support: jQuery 1.6.1, 1.6.2 (http://bugs.jquery.com/ticket/9413)
196if ( $( "<a>" ).data( "a-b", "a" ).removeData( "a-b" ).data( "a-b" ) ) {
197	$.fn.removeData = (function( removeData ) {
198		return function( key ) {
199			if ( arguments.length ) {
200				return removeData.call( this, $.camelCase( key ) );
201			} else {
202				return removeData.call( this );
203			}
204		};
205	})( $.fn.removeData );
206}
207
208// deprecated
209$.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() );
210
211$.fn.extend({
212	focus: (function( orig ) {
213		return function( delay, fn ) {
214			return typeof delay === "number" ?
215				this.each(function() {
216					var elem = this;
217					setTimeout(function() {
218						$( elem ).focus();
219						if ( fn ) {
220							fn.call( elem );
221						}
222					}, delay );
223				}) :
224				orig.apply( this, arguments );
225		};
226	})( $.fn.focus ),
227
228	disableSelection: (function() {
229		var eventType = "onselectstart" in document.createElement( "div" ) ?
230			"selectstart" :
231			"mousedown";
232
233		return function() {
234			return this.bind( eventType + ".ui-disableSelection", function( event ) {
235				event.preventDefault();
236			});
237		};
238	})(),
239
240	enableSelection: function() {
241		return this.unbind( ".ui-disableSelection" );
242	},
243
244	zIndex: function( zIndex ) {
245		if ( zIndex !== undefined ) {
246			return this.css( "zIndex", zIndex );
247		}
248
249		if ( this.length ) {
250			var elem = $( this[ 0 ] ), position, value;
251			while ( elem.length && elem[ 0 ] !== document ) {
252				// Ignore z-index if position is set to a value where z-index is ignored by the browser
253				// This makes behavior of this function consistent across browsers
254				// WebKit always returns auto if the element is positioned
255				position = elem.css( "position" );
256				if ( position === "absolute" || position === "relative" || position === "fixed" ) {
257					// IE returns 0 when zIndex is not specified
258					// other browsers return a string
259					// we ignore the case of nested elements with an explicit value of 0
260					// <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
261					value = parseInt( elem.css( "zIndex" ), 10 );
262					if ( !isNaN( value ) && value !== 0 ) {
263						return value;
264					}
265				}
266				elem = elem.parent();
267			}
268		}
269
270		return 0;
271	}
272});
273
274// $.ui.plugin is deprecated. Use $.widget() extensions instead.
275$.ui.plugin = {
276	add: function( module, option, set ) {
277		var i,
278			proto = $.ui[ module ].prototype;
279		for ( i in set ) {
280			proto.plugins[ i ] = proto.plugins[ i ] || [];
281			proto.plugins[ i ].push( [ option, set[ i ] ] );
282		}
283	},
284	call: function( instance, name, args, allowDisconnected ) {
285		var i,
286			set = instance.plugins[ name ];
287
288		if ( !set ) {
289			return;
290		}
291
292		if ( !allowDisconnected && ( !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) ) {
293			return;
294		}
295
296		for ( i = 0; i < set.length; i++ ) {
297			if ( instance.options[ set[ i ][ 0 ] ] ) {
298				set[ i ][ 1 ].apply( instance.element, args );
299			}
300		}
301	}
302};
303
304}));