Subversion Repositories SmartDukaan

Rev

Rev 162 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
162 naveen 1
/*!
2
 * jQuery UI 1.8.1
3
 *
4
 * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
5
 * Dual licensed under the MIT (MIT-LICENSE.txt)
6
 * and GPL (GPL-LICENSE.txt) licenses.
7
 *
8
 * http://docs.jquery.com/UI
9
 */
10
;jQuery.ui || (function($) {
11
 
12
//Helper functions and ui object
13
$.ui = {
14
	version: "1.8.1",
15
 
16
	// $.ui.plugin is deprecated.  Use the proxy pattern instead.
17
	plugin: {
18
		add: function(module, option, set) {
19
			var proto = $.ui[module].prototype;
20
			for(var i in set) {
21
				proto.plugins[i] = proto.plugins[i] || [];
22
				proto.plugins[i].push([option, set[i]]);
23
			}
24
		},
25
		call: function(instance, name, args) {
26
			var set = instance.plugins[name];
27
			if(!set || !instance.element[0].parentNode) { return; }
28
 
29
			for (var i = 0; i < set.length; i++) {
30
				if (instance.options[set[i][0]]) {
31
					set[i][1].apply(instance.element, args);
32
				}
33
			}
34
		}
35
	},
36
 
37
	contains: function(a, b) {
38
		return document.compareDocumentPosition
39
			? a.compareDocumentPosition(b) & 16
40
			: a !== b && a.contains(b);
41
	},
42
 
43
	hasScroll: function(el, a) {
44
 
45
		//If overflow is hidden, the element might have extra content, but the user wants to hide it
46
		if ($(el).css('overflow') == 'hidden') { return false; }
47
 
48
		var scroll = (a && a == 'left') ? 'scrollLeft' : 'scrollTop',
49
			has = false;
50
 
51
		if (el[scroll] > 0) { return true; }
52
 
53
		// TODO: determine which cases actually cause this to happen
54
		// if the element doesn't have the scroll set, see if it's possible to
55
		// set the scroll
56
		el[scroll] = 1;
57
		has = (el[scroll] > 0);
58
		el[scroll] = 0;
59
		return has;
60
	},
61
 
62
	isOverAxis: function(x, reference, size) {
63
		//Determines when x coordinate is over "b" element axis
64
		return (x > reference) && (x < (reference + size));
65
	},
66
 
67
	isOver: function(y, x, top, left, height, width) {
68
		//Determines when x, y coordinates is over "b" element
69
		return $.ui.isOverAxis(y, top, height) && $.ui.isOverAxis(x, left, width);
70
	},
71
 
72
	keyCode: {
73
		ALT: 18,
74
		BACKSPACE: 8,
75
		CAPS_LOCK: 20,
76
		COMMA: 188,
77
		CONTROL: 17,
78
		DELETE: 46,
79
		DOWN: 40,
80
		END: 35,
81
		ENTER: 13,
82
		ESCAPE: 27,
83
		HOME: 36,
84
		INSERT: 45,
85
		LEFT: 37,
86
		NUMPAD_ADD: 107,
87
		NUMPAD_DECIMAL: 110,
88
		NUMPAD_DIVIDE: 111,
89
		NUMPAD_ENTER: 108,
90
		NUMPAD_MULTIPLY: 106,
91
		NUMPAD_SUBTRACT: 109,
92
		PAGE_DOWN: 34,
93
		PAGE_UP: 33,
94
		PERIOD: 190,
95
		RIGHT: 39,
96
		SHIFT: 16,
97
		SPACE: 32,
98
		TAB: 9,
99
		UP: 38
100
	}
101
};
102
 
103
//jQuery plugins
104
$.fn.extend({
105
	_focus: $.fn.focus,
106
	focus: function(delay, fn) {
107
		return typeof delay === 'number'
108
			? this.each(function() {
109
				var elem = this;
110
				setTimeout(function() {
111
					$(elem).focus();
112
					(fn && fn.call(elem));
113
				}, delay);
114
			})
115
			: this._focus.apply(this, arguments);
116
	},
117
 
118
	enableSelection: function() {
119
		return this
120
			.attr('unselectable', 'off')
121
			.css('MozUserSelect', '');
122
	},
123
 
124
	disableSelection: function() {
125
		return this
126
			.attr('unselectable', 'on')
127
			.css('MozUserSelect', 'none');
128
	},
129
 
130
	scrollParent: function() {
131
		var scrollParent;
132
		if(($.browser.msie && (/(static|relative)/).test(this.css('position'))) || (/absolute/).test(this.css('position'))) {
133
			scrollParent = this.parents().filter(function() {
134
				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));
135
			}).eq(0);
136
		} else {
137
			scrollParent = this.parents().filter(function() {
138
				return (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1));
139
			}).eq(0);
140
		}
141
 
142
		return (/fixed/).test(this.css('position')) || !scrollParent.length ? $(document) : scrollParent;
143
	},
144
 
145
	zIndex: function(zIndex) {
146
		if (zIndex !== undefined) {
147
			return this.css('zIndex', zIndex);
148
		}
149
 
150
		if (this.length) {
151
			var elem = $(this[0]), position, value;
152
			while (elem.length && elem[0] !== document) {
153
				// Ignore z-index if position is set to a value where z-index is ignored by the browser
154
				// This makes behavior of this function consistent across browsers
155
				// WebKit always returns auto if the element is positioned
156
				position = elem.css('position');
157
				if (position == 'absolute' || position == 'relative' || position == 'fixed')
158
				{
159
					// IE returns 0 when zIndex is not specified
160
					// other browsers return a string
161
					// we ignore the case of nested elements with an explicit value of 0
162
					// <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
163
					value = parseInt(elem.css('zIndex'));
164
					if (!isNaN(value) && value != 0) {
165
						return value;
166
					}
167
				}
168
				elem = elem.parent();
169
			}
170
		}
171
 
172
		return 0;
173
	}
174
});
175
 
176
 
177
//Additional selectors
178
$.extend($.expr[':'], {
179
	data: function(elem, i, match) {
180
		return !!$.data(elem, match[3]);
181
	},
182
 
183
	focusable: function(element) {
184
		var nodeName = element.nodeName.toLowerCase(),
185
			tabIndex = $.attr(element, 'tabindex');
186
		return (/input|select|textarea|button|object/.test(nodeName)
187
			? !element.disabled
188
			: 'a' == nodeName || 'area' == nodeName
189
				? element.href || !isNaN(tabIndex)
190
				: !isNaN(tabIndex))
191
			// the element and all of its ancestors must be visible
192
			// the browser may report that the area is hidden
193
			&& !$(element)['area' == nodeName ? 'parents' : 'closest'](':hidden').length;
194
	},
195
 
196
	tabbable: function(element) {
197
		var tabIndex = $.attr(element, 'tabindex');
198
		return (isNaN(tabIndex) || tabIndex >= 0) && $(element).is(':focusable');
199
	}
200
});
201
 
202
})(jQuery);