|
1 /* |
|
2 * jQuery UI 1.6rc6 |
|
3 * |
|
4 * Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.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 ;(function($) { |
|
11 |
|
12 var _remove = $.fn.remove, |
|
13 isFF2 = $.browser.mozilla && (parseFloat($.browser.version) < 1.9); |
|
14 |
|
15 //Helper functions and ui object |
|
16 $.ui = { |
|
17 version: "1.6rc6", |
|
18 |
|
19 // $.ui.plugin is deprecated. Use the proxy pattern instead. |
|
20 plugin: { |
|
21 add: function(module, option, set) { |
|
22 var proto = $.ui[module].prototype; |
|
23 for(var i in set) { |
|
24 proto.plugins[i] = proto.plugins[i] || []; |
|
25 proto.plugins[i].push([option, set[i]]); |
|
26 } |
|
27 }, |
|
28 call: function(instance, name, args) { |
|
29 var set = instance.plugins[name]; |
|
30 if(!set) { return; } |
|
31 |
|
32 for (var i = 0; i < set.length; i++) { |
|
33 if (instance.options[set[i][0]]) { |
|
34 set[i][1].apply(instance.element, args); |
|
35 } |
|
36 } |
|
37 } |
|
38 }, |
|
39 |
|
40 contains: function(a, b) { |
|
41 return document.compareDocumentPosition |
|
42 ? a.compareDocumentPosition(b) & 16 |
|
43 : a !== b && a.contains(b); |
|
44 }, |
|
45 |
|
46 cssCache: {}, |
|
47 css: function(name) { |
|
48 if ($.ui.cssCache[name]) { return $.ui.cssCache[name]; } |
|
49 var tmp = $('<div class="ui-gen"></div>').addClass(name).css({position:'absolute', top:'-5000px', left:'-5000px', display:'block'}).appendTo('body'); |
|
50 |
|
51 //if (!$.browser.safari) |
|
52 //tmp.appendTo('body'); |
|
53 |
|
54 //Opera and Safari set width and height to 0px instead of auto |
|
55 //Safari returns rgba(0,0,0,0) when bgcolor is not set |
|
56 $.ui.cssCache[name] = !!( |
|
57 (!(/auto|default/).test(tmp.css('cursor')) || (/^[1-9]/).test(tmp.css('height')) || (/^[1-9]/).test(tmp.css('width')) || |
|
58 !(/none/).test(tmp.css('backgroundImage')) || !(/transparent|rgba\(0, 0, 0, 0\)/).test(tmp.css('backgroundColor'))) |
|
59 ); |
|
60 try { $('body').get(0).removeChild(tmp.get(0)); } catch(e){} |
|
61 return $.ui.cssCache[name]; |
|
62 }, |
|
63 |
|
64 hasScroll: function(el, a) { |
|
65 |
|
66 //If overflow is hidden, the element might have extra content, but the user wants to hide it |
|
67 if ($(el).css('overflow') == 'hidden') { return false; } |
|
68 |
|
69 var scroll = (a && a == 'left') ? 'scrollLeft' : 'scrollTop', |
|
70 has = false; |
|
71 |
|
72 if (el[scroll] > 0) { return true; } |
|
73 |
|
74 // TODO: determine which cases actually cause this to happen |
|
75 // if the element doesn't have the scroll set, see if it's possible to |
|
76 // set the scroll |
|
77 el[scroll] = 1; |
|
78 has = (el[scroll] > 0); |
|
79 el[scroll] = 0; |
|
80 return has; |
|
81 }, |
|
82 |
|
83 isOverAxis: function(x, reference, size) { |
|
84 //Determines when x coordinate is over "b" element axis |
|
85 return (x > reference) && (x < (reference + size)); |
|
86 }, |
|
87 |
|
88 isOver: function(y, x, top, left, height, width) { |
|
89 //Determines when x, y coordinates is over "b" element |
|
90 return $.ui.isOverAxis(y, top, height) && $.ui.isOverAxis(x, left, width); |
|
91 }, |
|
92 |
|
93 keyCode: { |
|
94 BACKSPACE: 8, |
|
95 CAPS_LOCK: 20, |
|
96 COMMA: 188, |
|
97 CONTROL: 17, |
|
98 DELETE: 46, |
|
99 DOWN: 40, |
|
100 END: 35, |
|
101 ENTER: 13, |
|
102 ESCAPE: 27, |
|
103 HOME: 36, |
|
104 INSERT: 45, |
|
105 LEFT: 37, |
|
106 NUMPAD_ADD: 107, |
|
107 NUMPAD_DECIMAL: 110, |
|
108 NUMPAD_DIVIDE: 111, |
|
109 NUMPAD_ENTER: 108, |
|
110 NUMPAD_MULTIPLY: 106, |
|
111 NUMPAD_SUBTRACT: 109, |
|
112 PAGE_DOWN: 34, |
|
113 PAGE_UP: 33, |
|
114 PERIOD: 190, |
|
115 RIGHT: 39, |
|
116 SHIFT: 16, |
|
117 SPACE: 32, |
|
118 TAB: 9, |
|
119 UP: 38 |
|
120 } |
|
121 }; |
|
122 |
|
123 // WAI-ARIA normalization |
|
124 if (isFF2) { |
|
125 var attr = $.attr, |
|
126 removeAttr = $.fn.removeAttr, |
|
127 ariaNS = "http://www.w3.org/2005/07/aaa", |
|
128 ariaState = /^aria-/, |
|
129 ariaRole = /^wairole:/; |
|
130 |
|
131 $.attr = function(elem, name, value) { |
|
132 var set = value !== undefined; |
|
133 |
|
134 return (name == 'role' |
|
135 ? (set |
|
136 ? attr.call(this, elem, name, "wairole:" + value) |
|
137 : (attr.apply(this, arguments) || "").replace(ariaRole, "")) |
|
138 : (ariaState.test(name) |
|
139 ? (set |
|
140 ? elem.setAttributeNS(ariaNS, |
|
141 name.replace(ariaState, "aaa:"), value) |
|
142 : attr.call(this, elem, name.replace(ariaState, "aaa:"))) |
|
143 : attr.apply(this, arguments))); |
|
144 }; |
|
145 |
|
146 $.fn.removeAttr = function(name) { |
|
147 return (ariaState.test(name) |
|
148 ? this.each(function() { |
|
149 this.removeAttributeNS(ariaNS, name.replace(ariaState, "")); |
|
150 }) : removeAttr.call(this, name)); |
|
151 }; |
|
152 } |
|
153 |
|
154 //jQuery plugins |
|
155 $.fn.extend({ |
|
156 remove: function() { |
|
157 // Safari has a native remove event which actually removes DOM elements, |
|
158 // so we have to use triggerHandler instead of trigger (#3037). |
|
159 $("*", this).add(this).each(function() { |
|
160 $(this).triggerHandler("remove"); |
|
161 }); |
|
162 return _remove.apply(this, arguments ); |
|
163 }, |
|
164 |
|
165 enableSelection: function() { |
|
166 return this |
|
167 .attr('unselectable', 'off') |
|
168 .css('MozUserSelect', '') |
|
169 .unbind('selectstart.ui'); |
|
170 }, |
|
171 |
|
172 disableSelection: function() { |
|
173 return this |
|
174 .attr('unselectable', 'on') |
|
175 .css('MozUserSelect', 'none') |
|
176 .bind('selectstart.ui', function() { return false; }); |
|
177 }, |
|
178 |
|
179 scrollParent: function() { |
|
180 var scrollParent; |
|
181 if(($.browser.msie && (/(static|relative)/).test(this.css('position'))) || (/absolute/).test(this.css('position'))) { |
|
182 scrollParent = this.parents().filter(function() { |
|
183 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)); |
|
184 }).eq(0); |
|
185 } else { |
|
186 scrollParent = this.parents().filter(function() { |
|
187 return (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1)); |
|
188 }).eq(0); |
|
189 } |
|
190 |
|
191 return (/fixed/).test(this.css('position')) || !scrollParent.length ? $(document) : scrollParent; |
|
192 } |
|
193 }); |
|
194 |
|
195 |
|
196 //Additional selectors |
|
197 $.extend($.expr[':'], { |
|
198 data: function(elem, i, match) { |
|
199 return !!$.data(elem, match[3]); |
|
200 }, |
|
201 |
|
202 focusable: function(element) { |
|
203 var nodeName = element.nodeName.toLowerCase(), |
|
204 tabIndex = $.attr(element, 'tabindex'); |
|
205 return (/input|select|textarea|button|object/.test(nodeName) |
|
206 ? !element.disabled |
|
207 : 'a' == nodeName || 'area' == nodeName |
|
208 ? element.href || !isNaN(tabIndex) |
|
209 : !isNaN(tabIndex)) |
|
210 // the element and all of its ancestors must be visible |
|
211 // the browser may report that the area is hidden |
|
212 && !$(element)['area' == nodeName ? 'parents' : 'closest'](':hidden').length; |
|
213 }, |
|
214 |
|
215 tabbable: function(element) { |
|
216 var tabIndex = $.attr(element, 'tabindex'); |
|
217 return (isNaN(tabIndex) || tabIndex >= 0) && $(element).is(':focusable'); |
|
218 } |
|
219 }); |
|
220 |
|
221 |
|
222 // $.widget is a factory to create jQuery plugins |
|
223 // taking some boilerplate code out of the plugin code |
|
224 function getter(namespace, plugin, method, args) { |
|
225 function getMethods(type) { |
|
226 var methods = $[namespace][plugin][type] || []; |
|
227 return (typeof methods == 'string' ? methods.split(/,?\s+/) : methods); |
|
228 } |
|
229 |
|
230 var methods = getMethods('getter'); |
|
231 if (args.length == 1 && typeof args[0] == 'string') { |
|
232 methods = methods.concat(getMethods('getterSetter')); |
|
233 } |
|
234 return ($.inArray(method, methods) != -1); |
|
235 } |
|
236 |
|
237 $.widget = function(name, prototype) { |
|
238 var namespace = name.split(".")[0]; |
|
239 name = name.split(".")[1]; |
|
240 |
|
241 // create plugin method |
|
242 $.fn[name] = function(options) { |
|
243 var isMethodCall = (typeof options == 'string'), |
|
244 args = Array.prototype.slice.call(arguments, 1); |
|
245 |
|
246 // prevent calls to internal methods |
|
247 if (isMethodCall && options.substring(0, 1) == '_') { |
|
248 return this; |
|
249 } |
|
250 |
|
251 // handle getter methods |
|
252 if (isMethodCall && getter(namespace, name, options, args)) { |
|
253 var instance = $.data(this[0], name); |
|
254 return (instance ? instance[options].apply(instance, args) |
|
255 : undefined); |
|
256 } |
|
257 |
|
258 // handle initialization and non-getter methods |
|
259 return this.each(function() { |
|
260 var instance = $.data(this, name); |
|
261 |
|
262 // constructor |
|
263 (!instance && !isMethodCall && |
|
264 $.data(this, name, new $[namespace][name](this, options))._init()); |
|
265 |
|
266 // method call |
|
267 (instance && isMethodCall && $.isFunction(instance[options]) && |
|
268 instance[options].apply(instance, args)); |
|
269 }); |
|
270 }; |
|
271 |
|
272 // create widget constructor |
|
273 $[namespace] = $[namespace] || {}; |
|
274 $[namespace][name] = function(element, options) { |
|
275 var self = this; |
|
276 |
|
277 this.namespace = namespace; |
|
278 this.widgetName = name; |
|
279 this.widgetEventPrefix = $[namespace][name].eventPrefix || name; |
|
280 this.widgetBaseClass = namespace + '-' + name; |
|
281 |
|
282 this.options = $.extend({}, |
|
283 $.widget.defaults, |
|
284 $[namespace][name].defaults, |
|
285 $.metadata && $.metadata.get(element)[name], |
|
286 options); |
|
287 |
|
288 this.element = $(element) |
|
289 .bind('setData.' + name, function(event, key, value) { |
|
290 if (event.target == element) { |
|
291 return self._setData(key, value); |
|
292 } |
|
293 }) |
|
294 .bind('getData.' + name, function(event, key) { |
|
295 if (event.target == element) { |
|
296 return self._getData(key); |
|
297 } |
|
298 }) |
|
299 .bind('remove', function() { |
|
300 return self.destroy(); |
|
301 }); |
|
302 }; |
|
303 |
|
304 // add widget prototype |
|
305 $[namespace][name].prototype = $.extend({}, $.widget.prototype, prototype); |
|
306 |
|
307 // TODO: merge getter and getterSetter properties from widget prototype |
|
308 // and plugin prototype |
|
309 $[namespace][name].getterSetter = 'option'; |
|
310 }; |
|
311 |
|
312 $.widget.prototype = { |
|
313 _init: function() {}, |
|
314 destroy: function() { |
|
315 this.element.removeData(this.widgetName) |
|
316 .removeClass(this.widgetBaseClass + '-disabled' + ' ' + this.namespace + '-state-disabled') |
|
317 .removeAttr('aria-disabled'); |
|
318 }, |
|
319 |
|
320 option: function(key, value) { |
|
321 var options = key, |
|
322 self = this; |
|
323 |
|
324 if (typeof key == "string") { |
|
325 if (value === undefined) { |
|
326 return this._getData(key); |
|
327 } |
|
328 options = {}; |
|
329 options[key] = value; |
|
330 } |
|
331 |
|
332 $.each(options, function(key, value) { |
|
333 self._setData(key, value); |
|
334 }); |
|
335 }, |
|
336 _getData: function(key) { |
|
337 return this.options[key]; |
|
338 }, |
|
339 _setData: function(key, value) { |
|
340 this.options[key] = value; |
|
341 |
|
342 if (key == 'disabled') { |
|
343 this.element |
|
344 [value ? 'addClass' : 'removeClass']( |
|
345 this.widgetBaseClass + '-disabled' + ' ' + |
|
346 this.namespace + '-state-disabled') |
|
347 .attr("aria-disabled", value); |
|
348 } |
|
349 }, |
|
350 |
|
351 enable: function() { |
|
352 this._setData('disabled', false); |
|
353 }, |
|
354 disable: function() { |
|
355 this._setData('disabled', true); |
|
356 }, |
|
357 |
|
358 _trigger: function(type, event, data) { |
|
359 var callback = this.options[type], |
|
360 eventName = (type == this.widgetEventPrefix |
|
361 ? type : this.widgetEventPrefix + type); |
|
362 |
|
363 event = $.Event(event); |
|
364 event.type = eventName; |
|
365 |
|
366 // copy original event properties over to the new event |
|
367 // this would happen if we could call $.event.fix instead of $.Event |
|
368 // but we don't have a way to force an event to be fixed multiple times |
|
369 if (event.originalEvent) { |
|
370 for (var i = $.event.props.length, prop; i;) { |
|
371 prop = $.event.props[--i]; |
|
372 event[prop] = event.originalEvent[prop]; |
|
373 } |
|
374 } |
|
375 |
|
376 this.element.trigger(event, data); |
|
377 |
|
378 return !($.isFunction(callback) && callback.call(this.element[0], event, data) === false |
|
379 || event.isDefaultPrevented()); |
|
380 } |
|
381 }; |
|
382 |
|
383 $.widget.defaults = { |
|
384 disabled: false |
|
385 }; |
|
386 |
|
387 |
|
388 /** Mouse Interaction Plugin **/ |
|
389 |
|
390 $.ui.mouse = { |
|
391 _mouseInit: function() { |
|
392 var self = this; |
|
393 |
|
394 this.element |
|
395 .bind('mousedown.'+this.widgetName, function(event) { |
|
396 return self._mouseDown(event); |
|
397 }) |
|
398 .bind('click.'+this.widgetName, function(event) { |
|
399 if(self._preventClickEvent) { |
|
400 self._preventClickEvent = false; |
|
401 return false; |
|
402 } |
|
403 }); |
|
404 |
|
405 // Prevent text selection in IE |
|
406 if ($.browser.msie) { |
|
407 this._mouseUnselectable = this.element.attr('unselectable'); |
|
408 this.element.attr('unselectable', 'on'); |
|
409 } |
|
410 |
|
411 this.started = false; |
|
412 }, |
|
413 |
|
414 // TODO: make sure destroying one instance of mouse doesn't mess with |
|
415 // other instances of mouse |
|
416 _mouseDestroy: function() { |
|
417 this.element.unbind('.'+this.widgetName); |
|
418 |
|
419 // Restore text selection in IE |
|
420 ($.browser.msie |
|
421 && this.element.attr('unselectable', this._mouseUnselectable)); |
|
422 }, |
|
423 |
|
424 _mouseDown: function(event) { |
|
425 // don't let more than one widget handle mouseStart |
|
426 if (event.originalEvent.mouseHandled) { return; } |
|
427 |
|
428 // we may have missed mouseup (out of window) |
|
429 (this._mouseStarted && this._mouseUp(event)); |
|
430 |
|
431 this._mouseDownEvent = event; |
|
432 |
|
433 var self = this, |
|
434 btnIsLeft = (event.which == 1), |
|
435 elIsCancel = (typeof this.options.cancel == "string" ? $(event.target).parents().add(event.target).filter(this.options.cancel).length : false); |
|
436 if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) { |
|
437 return true; |
|
438 } |
|
439 |
|
440 this.mouseDelayMet = !this.options.delay; |
|
441 if (!this.mouseDelayMet) { |
|
442 this._mouseDelayTimer = setTimeout(function() { |
|
443 self.mouseDelayMet = true; |
|
444 }, this.options.delay); |
|
445 } |
|
446 |
|
447 if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) { |
|
448 this._mouseStarted = (this._mouseStart(event) !== false); |
|
449 if (!this._mouseStarted) { |
|
450 event.preventDefault(); |
|
451 return true; |
|
452 } |
|
453 } |
|
454 |
|
455 // these delegates are required to keep context |
|
456 this._mouseMoveDelegate = function(event) { |
|
457 return self._mouseMove(event); |
|
458 }; |
|
459 this._mouseUpDelegate = function(event) { |
|
460 return self._mouseUp(event); |
|
461 }; |
|
462 $(document) |
|
463 .bind('mousemove.'+this.widgetName, this._mouseMoveDelegate) |
|
464 .bind('mouseup.'+this.widgetName, this._mouseUpDelegate); |
|
465 |
|
466 // preventDefault() is used to prevent the selection of text here - |
|
467 // however, in Safari, this causes select boxes not to be selectable |
|
468 // anymore, so this fix is needed |
|
469 ($.browser.safari || event.preventDefault()); |
|
470 |
|
471 event.originalEvent.mouseHandled = true; |
|
472 return true; |
|
473 }, |
|
474 |
|
475 _mouseMove: function(event) { |
|
476 // IE mouseup check - mouseup happened when mouse was out of window |
|
477 if ($.browser.msie && !event.button) { |
|
478 return this._mouseUp(event); |
|
479 } |
|
480 |
|
481 if (this._mouseStarted) { |
|
482 this._mouseDrag(event); |
|
483 return event.preventDefault(); |
|
484 } |
|
485 |
|
486 if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) { |
|
487 this._mouseStarted = |
|
488 (this._mouseStart(this._mouseDownEvent, event) !== false); |
|
489 (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event)); |
|
490 } |
|
491 |
|
492 return !this._mouseStarted; |
|
493 }, |
|
494 |
|
495 _mouseUp: function(event) { |
|
496 $(document) |
|
497 .unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate) |
|
498 .unbind('mouseup.'+this.widgetName, this._mouseUpDelegate); |
|
499 |
|
500 if (this._mouseStarted) { |
|
501 this._mouseStarted = false; |
|
502 this._preventClickEvent = true; |
|
503 this._mouseStop(event); |
|
504 } |
|
505 |
|
506 return false; |
|
507 }, |
|
508 |
|
509 _mouseDistanceMet: function(event) { |
|
510 return (Math.max( |
|
511 Math.abs(this._mouseDownEvent.pageX - event.pageX), |
|
512 Math.abs(this._mouseDownEvent.pageY - event.pageY) |
|
513 ) >= this.options.distance |
|
514 ); |
|
515 }, |
|
516 |
|
517 _mouseDelayMet: function(event) { |
|
518 return this.mouseDelayMet; |
|
519 }, |
|
520 |
|
521 // These are placeholder methods, to be overriden by extending plugin |
|
522 _mouseStart: function(event) {}, |
|
523 _mouseDrag: function(event) {}, |
|
524 _mouseStop: function(event) {}, |
|
525 _mouseCapture: function(event) { return true; } |
|
526 }; |
|
527 |
|
528 $.ui.mouse.defaults = { |
|
529 cancel: null, |
|
530 distance: 1, |
|
531 delay: 0 |
|
532 }; |
|
533 |
|
534 })(jQuery); |
|
535 /* |
|
536 * jQuery UI Draggable 1.6rc6 |
|
537 * |
|
538 * Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about) |
|
539 * Dual licensed under the MIT (MIT-LICENSE.txt) |
|
540 * and GPL (GPL-LICENSE.txt) licenses. |
|
541 * |
|
542 * http://docs.jquery.com/UI/Draggables |
|
543 * |
|
544 * Depends: |
|
545 * ui.core.js |
|
546 */ |
|
547 (function($) { |
|
548 |
|
549 $.widget("ui.draggable", $.extend({}, $.ui.mouse, { |
|
550 |
|
551 _init: function() { |
|
552 |
|
553 if (this.options.helper == 'original' && !(/^(?:r|a|f)/).test(this.element.css("position"))) |
|
554 this.element[0].style.position = 'relative'; |
|
555 |
|
556 (this.options.cssNamespace && this.element.addClass(this.options.cssNamespace+"-draggable")); |
|
557 (this.options.disabled && this.element.addClass(this.options.cssNamespace+'-draggable-disabled')); |
|
558 |
|
559 this._mouseInit(); |
|
560 |
|
561 }, |
|
562 |
|
563 destroy: function() { |
|
564 if(!this.element.data('draggable')) return; |
|
565 this.element.removeData("draggable").unbind(".draggable").removeClass(this.options.cssNamespace+'-draggable '+this.options.cssNamespace+'-draggable-dragging '+this.options.cssNamespace+'-draggable-disabled'); |
|
566 this._mouseDestroy(); |
|
567 }, |
|
568 |
|
569 _mouseCapture: function(event) { |
|
570 |
|
571 var o = this.options; |
|
572 |
|
573 if (this.helper || o.disabled || $(event.target).is('.'+this.options.cssNamespace+'-resizable-handle')) |
|
574 return false; |
|
575 |
|
576 //Quit if we're not on a valid handle |
|
577 this.handle = this._getHandle(event); |
|
578 if (!this.handle) |
|
579 return false; |
|
580 |
|
581 return true; |
|
582 |
|
583 }, |
|
584 |
|
585 _mouseStart: function(event) { |
|
586 |
|
587 var o = this.options; |
|
588 |
|
589 //Create and append the visible helper |
|
590 this.helper = this._createHelper(event); |
|
591 |
|
592 //Cache the helper size |
|
593 this._cacheHelperProportions(); |
|
594 |
|
595 //If ddmanager is used for droppables, set the global draggable |
|
596 if($.ui.ddmanager) |
|
597 $.ui.ddmanager.current = this; |
|
598 |
|
599 /* |
|
600 * - Position generation - |
|
601 * This block generates everything position related - it's the core of draggables. |
|
602 */ |
|
603 |
|
604 //Cache the margins of the original element |
|
605 this._cacheMargins(); |
|
606 |
|
607 //Store the helper's css position |
|
608 this.cssPosition = this.helper.css("position"); |
|
609 this.scrollParent = this.helper.scrollParent(); |
|
610 |
|
611 //The element's absolute position on the page minus margins |
|
612 this.offset = this.element.offset(); |
|
613 this.offset = { |
|
614 top: this.offset.top - this.margins.top, |
|
615 left: this.offset.left - this.margins.left |
|
616 }; |
|
617 |
|
618 $.extend(this.offset, { |
|
619 click: { //Where the click happened, relative to the element |
|
620 left: event.pageX - this.offset.left, |
|
621 top: event.pageY - this.offset.top |
|
622 }, |
|
623 parent: this._getParentOffset(), |
|
624 relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper |
|
625 }); |
|
626 |
|
627 //Generate the original position |
|
628 this.originalPosition = this._generatePosition(event); |
|
629 this.originalPageX = event.pageX; |
|
630 this.originalPageY = event.pageY; |
|
631 |
|
632 //Adjust the mouse offset relative to the helper if 'cursorAt' is supplied |
|
633 if(o.cursorAt) |
|
634 this._adjustOffsetFromHelper(o.cursorAt); |
|
635 |
|
636 //Set a containment if given in the options |
|
637 if(o.containment) |
|
638 this._setContainment(); |
|
639 |
|
640 //Call plugins and callbacks |
|
641 this._trigger("start", event); |
|
642 |
|
643 //Recache the helper size |
|
644 this._cacheHelperProportions(); |
|
645 |
|
646 //Prepare the droppable offsets |
|
647 if ($.ui.ddmanager && !o.dropBehaviour) |
|
648 $.ui.ddmanager.prepareOffsets(this, event); |
|
649 |
|
650 this.helper.addClass(o.cssNamespace+"-draggable-dragging"); |
|
651 this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position |
|
652 return true; |
|
653 }, |
|
654 |
|
655 _mouseDrag: function(event, noPropagation) { |
|
656 |
|
657 //Compute the helpers position |
|
658 this.position = this._generatePosition(event); |
|
659 this.positionAbs = this._convertPositionTo("absolute"); |
|
660 |
|
661 //Call plugins and callbacks and use the resulting position if something is returned |
|
662 if (!noPropagation) { |
|
663 var ui = this._uiHash(); |
|
664 this._trigger('drag', event, ui); |
|
665 this.position = ui.position; |
|
666 } |
|
667 |
|
668 if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px'; |
|
669 if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px'; |
|
670 if($.ui.ddmanager) $.ui.ddmanager.drag(this, event); |
|
671 |
|
672 return false; |
|
673 }, |
|
674 |
|
675 _mouseStop: function(event) { |
|
676 |
|
677 //If we are using droppables, inform the manager about the drop |
|
678 var dropped = false; |
|
679 if ($.ui.ddmanager && !this.options.dropBehaviour) |
|
680 dropped = $.ui.ddmanager.drop(this, event); |
|
681 |
|
682 //if a drop comes from outside (a sortable) |
|
683 if(this.dropped) { |
|
684 dropped = this.dropped; |
|
685 this.dropped = false; |
|
686 } |
|
687 |
|
688 if((this.options.revert == "invalid" && !dropped) || (this.options.revert == "valid" && dropped) || this.options.revert === true || ($.isFunction(this.options.revert) && this.options.revert.call(this.element, dropped))) { |
|
689 var self = this; |
|
690 $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() { |
|
691 self._trigger("stop", event); |
|
692 self._clear(); |
|
693 }); |
|
694 } else { |
|
695 this._trigger("stop", event); |
|
696 this._clear(); |
|
697 } |
|
698 |
|
699 return false; |
|
700 }, |
|
701 |
|
702 _getHandle: function(event) { |
|
703 |
|
704 var handle = !this.options.handle || !$(this.options.handle, this.element).length ? true : false; |
|
705 $(this.options.handle, this.element) |
|
706 .find("*") |
|
707 .andSelf() |
|
708 .each(function() { |
|
709 if(this == event.target) handle = true; |
|
710 }); |
|
711 |
|
712 return handle; |
|
713 |
|
714 }, |
|
715 |
|
716 _createHelper: function(event) { |
|
717 |
|
718 var o = this.options; |
|
719 var helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event])) : (o.helper == 'clone' ? this.element.clone() : this.element); |
|
720 |
|
721 if(!helper.parents('body').length) |
|
722 helper.appendTo((o.appendTo == 'parent' ? this.element[0].parentNode : o.appendTo)); |
|
723 |
|
724 if(helper[0] != this.element[0] && !(/(fixed|absolute)/).test(helper.css("position"))) |
|
725 helper.css("position", "absolute"); |
|
726 |
|
727 return helper; |
|
728 |
|
729 }, |
|
730 |
|
731 _adjustOffsetFromHelper: function(obj) { |
|
732 if(obj.left != undefined) this.offset.click.left = obj.left + this.margins.left; |
|
733 if(obj.right != undefined) this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left; |
|
734 if(obj.top != undefined) this.offset.click.top = obj.top + this.margins.top; |
|
735 if(obj.bottom != undefined) this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top; |
|
736 }, |
|
737 |
|
738 _getParentOffset: function() { |
|
739 |
|
740 //Get the offsetParent and cache its position |
|
741 this.offsetParent = this.helper.offsetParent(); |
|
742 var po = this.offsetParent.offset(); |
|
743 |
|
744 // This is a special case where we need to modify a offset calculated on start, since the following happened: |
|
745 // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent |
|
746 // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that |
|
747 // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag |
|
748 if(this.cssPosition == 'absolute' && this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) { |
|
749 po.left += this.scrollParent.scrollLeft(); |
|
750 po.top += this.scrollParent.scrollTop(); |
|
751 } |
|
752 |
|
753 if((this.offsetParent[0] == document.body && $.browser.mozilla) //Ugly FF3 fix |
|
754 || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() == 'html' && $.browser.msie)) //Ugly IE fix |
|
755 po = { top: 0, left: 0 }; |
|
756 |
|
757 return { |
|
758 top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0), |
|
759 left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0) |
|
760 }; |
|
761 |
|
762 }, |
|
763 |
|
764 _getRelativeOffset: function() { |
|
765 |
|
766 if(this.cssPosition == "relative") { |
|
767 var p = this.element.position(); |
|
768 return { |
|
769 top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(), |
|
770 left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft() |
|
771 }; |
|
772 } else { |
|
773 return { top: 0, left: 0 }; |
|
774 } |
|
775 |
|
776 }, |
|
777 |
|
778 _cacheMargins: function() { |
|
779 this.margins = { |
|
780 left: (parseInt(this.element.css("marginLeft"),10) || 0), |
|
781 top: (parseInt(this.element.css("marginTop"),10) || 0) |
|
782 }; |
|
783 }, |
|
784 |
|
785 _cacheHelperProportions: function() { |
|
786 this.helperProportions = { |
|
787 width: this.helper.outerWidth(), |
|
788 height: this.helper.outerHeight() |
|
789 }; |
|
790 }, |
|
791 |
|
792 _setContainment: function() { |
|
793 |
|
794 var o = this.options; |
|
795 if(o.containment == 'parent') o.containment = this.helper[0].parentNode; |
|
796 if(o.containment == 'document' || o.containment == 'window') this.containment = [ |
|
797 0 - this.offset.relative.left - this.offset.parent.left, |
|
798 0 - this.offset.relative.top - this.offset.parent.top, |
|
799 $(o.containment == 'document' ? document : window).width() - this.helperProportions.width - this.margins.left, |
|
800 ($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top |
|
801 ]; |
|
802 |
|
803 if(!(/^(document|window|parent)$/).test(o.containment) && o.containment.constructor != Array) { |
|
804 var ce = $(o.containment)[0]; if(!ce) return; |
|
805 var co = $(o.containment).offset(); |
|
806 var over = ($(ce).css("overflow") != 'hidden'); |
|
807 |
|
808 this.containment = [ |
|
809 co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left, |
|
810 co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top, |
|
811 co.left+(over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left, |
|
812 co.top+(over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top |
|
813 ]; |
|
814 } else if(o.containment.constructor == Array) { |
|
815 this.containment = o.containment; |
|
816 } |
|
817 |
|
818 }, |
|
819 |
|
820 _convertPositionTo: function(d, pos) { |
|
821 |
|
822 if(!pos) pos = this.position; |
|
823 var mod = d == "absolute" ? 1 : -1; |
|
824 var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName); |
|
825 |
|
826 return { |
|
827 top: ( |
|
828 pos.top // The absolute mouse position |
|
829 + this.offset.relative.top * mod // Only for relative positioned nodes: Relative offset from element to offset parent |
|
830 + this.offset.parent.top * mod // The offsetParent's offset without borders (offset + border) |
|
831 - ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod |
|
832 ), |
|
833 left: ( |
|
834 pos.left // The absolute mouse position |
|
835 + this.offset.relative.left * mod // Only for relative positioned nodes: Relative offset from element to offset parent |
|
836 + this.offset.parent.left * mod // The offsetParent's offset without borders (offset + border) |
|
837 - ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod |
|
838 ) |
|
839 }; |
|
840 |
|
841 }, |
|
842 |
|
843 _generatePosition: function(event) { |
|
844 |
|
845 var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName); |
|
846 |
|
847 // This is another very weird special case that only happens for relative elements: |
|
848 // 1. If the css position is relative |
|
849 // 2. and the scroll parent is the document or similar to the offset parent |
|
850 // we have to refresh the relative offset during the scroll so there are no jumps |
|
851 if(this.cssPosition == 'relative' && !(this.scrollParent[0] != document && this.scrollParent[0] != this.offsetParent[0])) { |
|
852 this.offset.relative = this._getRelativeOffset(); |
|
853 } |
|
854 |
|
855 var pageX = event.pageX; |
|
856 var pageY = event.pageY; |
|
857 |
|
858 /* |
|
859 * - Position constraining - |
|
860 * Constrain the position to a mix of grid, containment. |
|
861 */ |
|
862 |
|
863 if(this.originalPosition) { //If we are not dragging yet, we won't check for options |
|
864 |
|
865 if(this.containment) { |
|
866 if(event.pageX - this.offset.click.left < this.containment[0]) pageX = this.containment[0] + this.offset.click.left; |
|
867 if(event.pageY - this.offset.click.top < this.containment[1]) pageY = this.containment[1] + this.offset.click.top; |
|
868 if(event.pageX - this.offset.click.left > this.containment[2]) pageX = this.containment[2] + this.offset.click.left; |
|
869 if(event.pageY - this.offset.click.top > this.containment[3]) pageY = this.containment[3] + this.offset.click.top; |
|
870 } |
|
871 |
|
872 if(o.grid) { |
|
873 var top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1]; |
|
874 pageY = this.containment ? (!(top - this.offset.click.top < this.containment[1] || top - this.offset.click.top > this.containment[3]) ? top : (!(top - this.offset.click.top < this.containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top; |
|
875 |
|
876 var left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0]; |
|
877 pageX = this.containment ? (!(left - this.offset.click.left < this.containment[0] || left - this.offset.click.left > this.containment[2]) ? left : (!(left - this.offset.click.left < this.containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left; |
|
878 } |
|
879 |
|
880 } |
|
881 |
|
882 return { |
|
883 top: ( |
|
884 pageY // The absolute mouse position |
|
885 - this.offset.click.top // Click offset (relative to the element) |
|
886 - this.offset.relative.top // Only for relative positioned nodes: Relative offset from element to offset parent |
|
887 - this.offset.parent.top // The offsetParent's offset without borders (offset + border) |
|
888 + ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) |
|
889 ), |
|
890 left: ( |
|
891 pageX // The absolute mouse position |
|
892 - this.offset.click.left // Click offset (relative to the element) |
|
893 - this.offset.relative.left // Only for relative positioned nodes: Relative offset from element to offset parent |
|
894 - this.offset.parent.left // The offsetParent's offset without borders (offset + border) |
|
895 + ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) |
|
896 ) |
|
897 }; |
|
898 |
|
899 }, |
|
900 |
|
901 _clear: function() { |
|
902 this.helper.removeClass(this.options.cssNamespace+"-draggable-dragging"); |
|
903 if(this.helper[0] != this.element[0] && !this.cancelHelperRemoval) this.helper.remove(); |
|
904 //if($.ui.ddmanager) $.ui.ddmanager.current = null; |
|
905 this.helper = null; |
|
906 this.cancelHelperRemoval = false; |
|
907 }, |
|
908 |
|
909 // From now on bulk stuff - mainly helpers |
|
910 |
|
911 _trigger: function(type, event, ui) { |
|
912 ui = ui || this._uiHash(); |
|
913 $.ui.plugin.call(this, type, [event, ui]); |
|
914 if(type == "drag") this.positionAbs = this._convertPositionTo("absolute"); //The absolute position has to be recalculated after plugins |
|
915 return $.widget.prototype._trigger.call(this, type, event, ui); |
|
916 }, |
|
917 |
|
918 plugins: {}, |
|
919 |
|
920 _uiHash: function(event) { |
|
921 return { |
|
922 helper: this.helper, |
|
923 position: this.position, |
|
924 absolutePosition: this.positionAbs, //deprecated |
|
925 offset: this.positionAbs |
|
926 }; |
|
927 } |
|
928 |
|
929 })); |
|
930 |
|
931 $.extend($.ui.draggable, { |
|
932 version: "1.6rc6", |
|
933 eventPrefix: "drag", |
|
934 defaults: { |
|
935 appendTo: "parent", |
|
936 axis: false, |
|
937 cancel: ":input,option", |
|
938 connectToSortable: false, |
|
939 containment: false, |
|
940 cssNamespace: "ui", |
|
941 cursor: "default", |
|
942 cursorAt: false, |
|
943 delay: 0, |
|
944 distance: 1, |
|
945 grid: false, |
|
946 handle: false, |
|
947 helper: "original", |
|
948 iframeFix: false, |
|
949 opacity: false, |
|
950 refreshPositions: false, |
|
951 revert: false, |
|
952 revertDuration: 500, |
|
953 scope: "default", |
|
954 scroll: true, |
|
955 scrollSensitivity: 20, |
|
956 scrollSpeed: 20, |
|
957 snap: false, |
|
958 snapMode: "both", |
|
959 snapTolerance: 20, |
|
960 stack: false, |
|
961 zIndex: false |
|
962 } |
|
963 }); |
|
964 |
|
965 $.ui.plugin.add("draggable", "connectToSortable", { |
|
966 start: function(event, ui) { |
|
967 |
|
968 var inst = $(this).data("draggable"), o = inst.options; |
|
969 inst.sortables = []; |
|
970 $(o.connectToSortable).each(function() { |
|
971 // 'this' points to a string, and should therefore resolved as query, but instead, if the string is assigned to a variable, it loops through the strings properties, |
|
972 // so we have to append '' to make it anonymous again |
|
973 $(typeof this == 'string' ? this+'': this).each(function() { |
|
974 if($.data(this, 'sortable')) { |
|
975 var sortable = $.data(this, 'sortable'); |
|
976 inst.sortables.push({ |
|
977 instance: sortable, |
|
978 shouldRevert: sortable.options.revert |
|
979 }); |
|
980 sortable._refreshItems(); //Do a one-time refresh at start to refresh the containerCache |
|
981 sortable._trigger("activate", event, inst); |
|
982 } |
|
983 }); |
|
984 }); |
|
985 |
|
986 }, |
|
987 stop: function(event, ui) { |
|
988 |
|
989 //If we are still over the sortable, we fake the stop event of the sortable, but also remove helper |
|
990 var inst = $(this).data("draggable"); |
|
991 |
|
992 $.each(inst.sortables, function() { |
|
993 if(this.instance.isOver) { |
|
994 |
|
995 this.instance.isOver = 0; |
|
996 |
|
997 inst.cancelHelperRemoval = true; //Don't remove the helper in the draggable instance |
|
998 this.instance.cancelHelperRemoval = false; //Remove it in the sortable instance (so sortable plugins like revert still work) |
|
999 |
|
1000 //The sortable revert is supported, and we have to set a temporary dropped variable on the draggable to support revert: 'valid/invalid' |
|
1001 if(this.shouldRevert) this.instance.options.revert = true; |
|
1002 |
|
1003 //Trigger the stop of the sortable |
|
1004 this.instance._mouseStop(event); |
|
1005 |
|
1006 this.instance.options.helper = this.instance.options._helper; |
|
1007 |
|
1008 //If the helper has been the original item, restore properties in the sortable |
|
1009 if(inst.options.helper == 'original') |
|
1010 this.instance.currentItem.css({ top: 'auto', left: 'auto' }); |
|
1011 |
|
1012 } else { |
|
1013 this.instance.cancelHelperRemoval = false; //Remove the helper in the sortable instance |
|
1014 this.instance._trigger("deactivate", event, inst); |
|
1015 } |
|
1016 |
|
1017 }); |
|
1018 |
|
1019 }, |
|
1020 drag: function(event, ui) { |
|
1021 |
|
1022 var inst = $(this).data("draggable"), self = this; |
|
1023 |
|
1024 var checkPos = function(o) { |
|
1025 var dyClick = this.offset.click.top, dxClick = this.offset.click.left; |
|
1026 var helperTop = this.positionAbs.top, helperLeft = this.positionAbs.left; |
|
1027 var itemHeight = o.height, itemWidth = o.width; |
|
1028 var itemTop = o.top, itemLeft = o.left; |
|
1029 |
|
1030 return $.ui.isOver(helperTop + dyClick, helperLeft + dxClick, itemTop, itemLeft, itemHeight, itemWidth); |
|
1031 }; |
|
1032 |
|
1033 $.each(inst.sortables, function(i) { |
|
1034 |
|
1035 if(checkPos.call(inst, this.instance.containerCache)) { |
|
1036 |
|
1037 //If it intersects, we use a little isOver variable and set it once, so our move-in stuff gets fired only once |
|
1038 if(!this.instance.isOver) { |
|
1039 this.instance.isOver = 1; |
|
1040 //Now we fake the start of dragging for the sortable instance, |
|
1041 //by cloning the list group item, appending it to the sortable and using it as inst.currentItem |
|
1042 //We can then fire the start event of the sortable with our passed browser event, and our own helper (so it doesn't create a new one) |
|
1043 this.instance.currentItem = $(self).clone().appendTo(this.instance.element).data("sortable-item", true); |
|
1044 this.instance.options._helper = this.instance.options.helper; //Store helper option to later restore it |
|
1045 this.instance.options.helper = function() { return ui.helper[0]; }; |
|
1046 |
|
1047 event.target = this.instance.currentItem[0]; |
|
1048 this.instance._mouseCapture(event, true); |
|
1049 this.instance._mouseStart(event, true, true); |
|
1050 |
|
1051 //Because the browser event is way off the new appended portlet, we modify a couple of variables to reflect the changes |
|
1052 this.instance.offset.click.top = inst.offset.click.top; |
|
1053 this.instance.offset.click.left = inst.offset.click.left; |
|
1054 this.instance.offset.parent.left -= inst.offset.parent.left - this.instance.offset.parent.left; |
|
1055 this.instance.offset.parent.top -= inst.offset.parent.top - this.instance.offset.parent.top; |
|
1056 |
|
1057 inst._trigger("toSortable", event); |
|
1058 inst.dropped = this.instance.element; //draggable revert needs that |
|
1059 this.instance.fromOutside = inst; //Little hack so receive/update callbacks work |
|
1060 |
|
1061 } |
|
1062 |
|
1063 //Provided we did all the previous steps, we can fire the drag event of the sortable on every draggable drag, when it intersects with the sortable |
|
1064 if(this.instance.currentItem) this.instance._mouseDrag(event); |
|
1065 |
|
1066 } else { |
|
1067 |
|
1068 //If it doesn't intersect with the sortable, and it intersected before, |
|
1069 //we fake the drag stop of the sortable, but make sure it doesn't remove the helper by using cancelHelperRemoval |
|
1070 if(this.instance.isOver) { |
|
1071 this.instance.isOver = 0; |
|
1072 this.instance.cancelHelperRemoval = true; |
|
1073 this.instance.options.revert = false; //No revert here |
|
1074 this.instance._mouseStop(event, true); |
|
1075 this.instance.options.helper = this.instance.options._helper; |
|
1076 |
|
1077 //Now we remove our currentItem, the list group clone again, and the placeholder, and animate the helper back to it's original size |
|
1078 this.instance.currentItem.remove(); |
|
1079 if(this.instance.placeholder) this.instance.placeholder.remove(); |
|
1080 |
|
1081 inst._trigger("fromSortable", event); |
|
1082 inst.dropped = false; //draggable revert needs that |
|
1083 } |
|
1084 |
|
1085 }; |
|
1086 |
|
1087 }); |
|
1088 |
|
1089 } |
|
1090 }); |
|
1091 |
|
1092 $.ui.plugin.add("draggable", "cursor", { |
|
1093 start: function(event, ui) { |
|
1094 var t = $('body'), o = $(this).data('draggable').options; |
|
1095 if (t.css("cursor")) o._cursor = t.css("cursor"); |
|
1096 t.css("cursor", o.cursor); |
|
1097 }, |
|
1098 stop: function(event, ui) { |
|
1099 var o = $(this).data('draggable').options; |
|
1100 if (o._cursor) $('body').css("cursor", o._cursor); |
|
1101 } |
|
1102 }); |
|
1103 |
|
1104 $.ui.plugin.add("draggable", "iframeFix", { |
|
1105 start: function(event, ui) { |
|
1106 var o = $(this).data('draggable').options; |
|
1107 $(o.iframeFix === true ? "iframe" : o.iframeFix).each(function() { |
|
1108 $('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>') |
|
1109 .css({ |
|
1110 width: this.offsetWidth+"px", height: this.offsetHeight+"px", |
|
1111 position: "absolute", opacity: "0.001", zIndex: 1000 |
|
1112 }) |
|
1113 .css($(this).offset()) |
|
1114 .appendTo("body"); |
|
1115 }); |
|
1116 }, |
|
1117 stop: function(event, ui) { |
|
1118 $("div.ui-draggable-iframeFix").each(function() { this.parentNode.removeChild(this); }); //Remove frame helpers |
|
1119 } |
|
1120 }); |
|
1121 |
|
1122 $.ui.plugin.add("draggable", "opacity", { |
|
1123 start: function(event, ui) { |
|
1124 var t = $(ui.helper), o = $(this).data('draggable').options; |
|
1125 if(t.css("opacity")) o._opacity = t.css("opacity"); |
|
1126 t.css('opacity', o.opacity); |
|
1127 }, |
|
1128 stop: function(event, ui) { |
|
1129 var o = $(this).data('draggable').options; |
|
1130 if(o._opacity) $(ui.helper).css('opacity', o._opacity); |
|
1131 } |
|
1132 }); |
|
1133 |
|
1134 $.ui.plugin.add("draggable", "scroll", { |
|
1135 start: function(event, ui) { |
|
1136 var i = $(this).data("draggable"); |
|
1137 if(i.scrollParent[0] != document && i.scrollParent[0].tagName != 'HTML') i.overflowOffset = i.scrollParent.offset(); |
|
1138 }, |
|
1139 drag: function(event, ui) { |
|
1140 |
|
1141 var i = $(this).data("draggable"), o = i.options, scrolled = false; |
|
1142 |
|
1143 if(i.scrollParent[0] != document && i.scrollParent[0].tagName != 'HTML') { |
|
1144 |
|
1145 if(!o.axis || o.axis != 'x') { |
|
1146 if((i.overflowOffset.top + i.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) |
|
1147 i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop + o.scrollSpeed; |
|
1148 else if(event.pageY - i.overflowOffset.top < o.scrollSensitivity) |
|
1149 i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop - o.scrollSpeed; |
|
1150 } |
|
1151 |
|
1152 if(!o.axis || o.axis != 'y') { |
|
1153 if((i.overflowOffset.left + i.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) |
|
1154 i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft + o.scrollSpeed; |
|
1155 else if(event.pageX - i.overflowOffset.left < o.scrollSensitivity) |
|
1156 i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft - o.scrollSpeed; |
|
1157 } |
|
1158 |
|
1159 } else { |
|
1160 |
|
1161 if(!o.axis || o.axis != 'x') { |
|
1162 if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) |
|
1163 scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed); |
|
1164 else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) |
|
1165 scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed); |
|
1166 } |
|
1167 |
|
1168 if(!o.axis || o.axis != 'y') { |
|
1169 if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) |
|
1170 scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed); |
|
1171 else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) |
|
1172 scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed); |
|
1173 } |
|
1174 |
|
1175 } |
|
1176 |
|
1177 if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) |
|
1178 $.ui.ddmanager.prepareOffsets(i, event); |
|
1179 |
|
1180 } |
|
1181 }); |
|
1182 |
|
1183 $.ui.plugin.add("draggable", "snap", { |
|
1184 start: function(event, ui) { |
|
1185 |
|
1186 var i = $(this).data("draggable"), o = i.options; |
|
1187 i.snapElements = []; |
|
1188 |
|
1189 $(o.snap.constructor != String ? ( o.snap.items || ':data(draggable)' ) : o.snap).each(function() { |
|
1190 var $t = $(this); var $o = $t.offset(); |
|
1191 if(this != i.element[0]) i.snapElements.push({ |
|
1192 item: this, |
|
1193 width: $t.outerWidth(), height: $t.outerHeight(), |
|
1194 top: $o.top, left: $o.left |
|
1195 }); |
|
1196 }); |
|
1197 |
|
1198 }, |
|
1199 drag: function(event, ui) { |
|
1200 |
|
1201 var inst = $(this).data("draggable"), o = inst.options; |
|
1202 var d = o.snapTolerance; |
|
1203 |
|
1204 var x1 = ui.absolutePosition.left, x2 = x1 + inst.helperProportions.width, |
|
1205 y1 = ui.absolutePosition.top, y2 = y1 + inst.helperProportions.height; |
|
1206 |
|
1207 for (var i = inst.snapElements.length - 1; i >= 0; i--){ |
|
1208 |
|
1209 var l = inst.snapElements[i].left, r = l + inst.snapElements[i].width, |
|
1210 t = inst.snapElements[i].top, b = t + inst.snapElements[i].height; |
|
1211 |
|
1212 //Yes, I know, this is insane ;) |
|
1213 if(!((l-d < x1 && x1 < r+d && t-d < y1 && y1 < b+d) || (l-d < x1 && x1 < r+d && t-d < y2 && y2 < b+d) || (l-d < x2 && x2 < r+d && t-d < y1 && y1 < b+d) || (l-d < x2 && x2 < r+d && t-d < y2 && y2 < b+d))) { |
|
1214 if(inst.snapElements[i].snapping) (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item }))); |
|
1215 inst.snapElements[i].snapping = false; |
|
1216 continue; |
|
1217 } |
|
1218 |
|
1219 if(o.snapMode != 'inner') { |
|
1220 var ts = Math.abs(t - y2) <= d; |
|
1221 var bs = Math.abs(b - y1) <= d; |
|
1222 var ls = Math.abs(l - x2) <= d; |
|
1223 var rs = Math.abs(r - x1) <= d; |
|
1224 if(ts) ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top - inst.margins.top; |
|
1225 if(bs) ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top - inst.margins.top; |
|
1226 if(ls) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left - inst.margins.left; |
|
1227 if(rs) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left - inst.margins.left; |
|
1228 } |
|
1229 |
|
1230 var first = (ts || bs || ls || rs); |
|
1231 |
|
1232 if(o.snapMode != 'outer') { |
|
1233 var ts = Math.abs(t - y1) <= d; |
|
1234 var bs = Math.abs(b - y2) <= d; |
|
1235 var ls = Math.abs(l - x1) <= d; |
|
1236 var rs = Math.abs(r - x2) <= d; |
|
1237 if(ts) ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top - inst.margins.top; |
|
1238 if(bs) ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top - inst.margins.top; |
|
1239 if(ls) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left - inst.margins.left; |
|
1240 if(rs) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left - inst.margins.left; |
|
1241 } |
|
1242 |
|
1243 if(!inst.snapElements[i].snapping && (ts || bs || ls || rs || first)) |
|
1244 (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item }))); |
|
1245 inst.snapElements[i].snapping = (ts || bs || ls || rs || first); |
|
1246 |
|
1247 }; |
|
1248 |
|
1249 } |
|
1250 }); |
|
1251 |
|
1252 $.ui.plugin.add("draggable", "stack", { |
|
1253 start: function(event, ui) { |
|
1254 |
|
1255 var o = $(this).data("draggable").options; |
|
1256 |
|
1257 var group = $.makeArray($(o.stack.group)).sort(function(a,b) { |
|
1258 return (parseInt($(a).css("zIndex"),10) || o.stack.min) - (parseInt($(b).css("zIndex"),10) || o.stack.min); |
|
1259 }); |
|
1260 |
|
1261 $(group).each(function(i) { |
|
1262 this.style.zIndex = o.stack.min + i; |
|
1263 }); |
|
1264 |
|
1265 this[0].style.zIndex = o.stack.min + group.length; |
|
1266 |
|
1267 } |
|
1268 }); |
|
1269 |
|
1270 $.ui.plugin.add("draggable", "zIndex", { |
|
1271 start: function(event, ui) { |
|
1272 var t = $(ui.helper), o = $(this).data("draggable").options; |
|
1273 if(t.css("zIndex")) o._zIndex = t.css("zIndex"); |
|
1274 t.css('zIndex', o.zIndex); |
|
1275 }, |
|
1276 stop: function(event, ui) { |
|
1277 var o = $(this).data("draggable").options; |
|
1278 if(o._zIndex) $(ui.helper).css('zIndex', o._zIndex); |
|
1279 } |
|
1280 }); |
|
1281 |
|
1282 })(jQuery); |
|
1283 /* |
|
1284 * jQuery UI Droppable 1.6rc6 |
|
1285 * |
|
1286 * Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about) |
|
1287 * Dual licensed under the MIT (MIT-LICENSE.txt) |
|
1288 * and GPL (GPL-LICENSE.txt) licenses. |
|
1289 * |
|
1290 * http://docs.jquery.com/UI/Droppables |
|
1291 * |
|
1292 * Depends: |
|
1293 * ui.core.js |
|
1294 * ui.draggable.js |
|
1295 */ |
|
1296 (function($) { |
|
1297 |
|
1298 $.widget("ui.droppable", { |
|
1299 |
|
1300 _init: function() { |
|
1301 |
|
1302 var o = this.options, accept = o.accept; |
|
1303 this.isover = 0; this.isout = 1; |
|
1304 |
|
1305 this.options.accept = this.options.accept && $.isFunction(this.options.accept) ? this.options.accept : function(d) { |
|
1306 return d.is(accept); |
|
1307 }; |
|
1308 |
|
1309 //Store the droppable's proportions |
|
1310 this.proportions = { width: this.element[0].offsetWidth, height: this.element[0].offsetHeight }; |
|
1311 |
|
1312 // Add the reference and positions to the manager |
|
1313 $.ui.ddmanager.droppables[this.options.scope] = $.ui.ddmanager.droppables[this.options.scope] || []; |
|
1314 $.ui.ddmanager.droppables[this.options.scope].push(this); |
|
1315 |
|
1316 (this.options.cssNamespace && this.element.addClass(this.options.cssNamespace+"-droppable")); |
|
1317 |
|
1318 }, |
|
1319 |
|
1320 destroy: function() { |
|
1321 var drop = $.ui.ddmanager.droppables[this.options.scope]; |
|
1322 for ( var i = 0; i < drop.length; i++ ) |
|
1323 if ( drop[i] == this ) |
|
1324 drop.splice(i, 1); |
|
1325 |
|
1326 this.element |
|
1327 .removeClass(this.options.cssNamespace+"-droppable "+this.options.cssNamespace+"-droppable-disabled") |
|
1328 .removeData("droppable") |
|
1329 .unbind(".droppable"); |
|
1330 }, |
|
1331 |
|
1332 _setData: function(key, value) { |
|
1333 |
|
1334 if(key == 'accept') { |
|
1335 this.options.accept = value && $.isFunction(value) ? value : function(d) { |
|
1336 return d.is(accept); |
|
1337 }; |
|
1338 } else { |
|
1339 $.widget.prototype._setData.apply(this, arguments); |
|
1340 } |
|
1341 |
|
1342 }, |
|
1343 |
|
1344 _activate: function(event) { |
|
1345 var draggable = $.ui.ddmanager.current; |
|
1346 if(this.options.activeClass) this.element.addClass(this.options.activeClass); |
|
1347 (draggable && this._trigger('activate', event, this.ui(draggable))); |
|
1348 }, |
|
1349 |
|
1350 _deactivate: function(event) { |
|
1351 var draggable = $.ui.ddmanager.current; |
|
1352 if(this.options.activeClass) this.element.removeClass(this.options.activeClass); |
|
1353 (draggable && this._trigger('deactivate', event, this.ui(draggable))); |
|
1354 }, |
|
1355 |
|
1356 _over: function(event) { |
|
1357 |
|
1358 var draggable = $.ui.ddmanager.current; |
|
1359 if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return; // Bail if draggable and droppable are same element |
|
1360 |
|
1361 if (this.options.accept.call(this.element[0],(draggable.currentItem || draggable.element))) { |
|
1362 if(this.options.hoverClass) this.element.addClass(this.options.hoverClass); |
|
1363 this._trigger('over', event, this.ui(draggable)); |
|
1364 } |
|
1365 |
|
1366 }, |
|
1367 |
|
1368 _out: function(event) { |
|
1369 |
|
1370 var draggable = $.ui.ddmanager.current; |
|
1371 if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return; // Bail if draggable and droppable are same element |
|
1372 |
|
1373 if (this.options.accept.call(this.element[0],(draggable.currentItem || draggable.element))) { |
|
1374 if(this.options.hoverClass) this.element.removeClass(this.options.hoverClass); |
|
1375 this._trigger('out', event, this.ui(draggable)); |
|
1376 } |
|
1377 |
|
1378 }, |
|
1379 |
|
1380 _drop: function(event,custom) { |
|
1381 |
|
1382 var draggable = custom || $.ui.ddmanager.current; |
|
1383 if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return false; // Bail if draggable and droppable are same element |
|
1384 |
|
1385 var childrenIntersection = false; |
|
1386 this.element.find(":data(droppable)").not("."+draggable.options.cssNamespace+"-draggable-dragging").each(function() { |
|
1387 var inst = $.data(this, 'droppable'); |
|
1388 if(inst.options.greedy && $.ui.intersect(draggable, $.extend(inst, { offset: inst.element.offset() }), inst.options.tolerance)) { |
|
1389 childrenIntersection = true; return false; |
|
1390 } |
|
1391 }); |
|
1392 if(childrenIntersection) return false; |
|
1393 |
|
1394 if(this.options.accept.call(this.element[0],(draggable.currentItem || draggable.element))) { |
|
1395 if(this.options.activeClass) this.element.removeClass(this.options.activeClass); |
|
1396 if(this.options.hoverClass) this.element.removeClass(this.options.hoverClass); |
|
1397 this._trigger('drop', event, this.ui(draggable)); |
|
1398 return this.element; |
|
1399 } |
|
1400 |
|
1401 return false; |
|
1402 |
|
1403 }, |
|
1404 |
|
1405 ui: function(c) { |
|
1406 return { |
|
1407 draggable: (c.currentItem || c.element), |
|
1408 helper: c.helper, |
|
1409 position: c.position, |
|
1410 absolutePosition: c.positionAbs, //deprecated |
|
1411 offset: c.positionAbs |
|
1412 }; |
|
1413 } |
|
1414 |
|
1415 }); |
|
1416 |
|
1417 $.extend($.ui.droppable, { |
|
1418 version: "1.6rc6", |
|
1419 eventPrefix: 'drop', |
|
1420 defaults: { |
|
1421 accept: '*', |
|
1422 activeClass: false, |
|
1423 cssNamespace: 'ui', |
|
1424 greedy: false, |
|
1425 hoverClass: false, |
|
1426 scope: 'default', |
|
1427 tolerance: 'intersect' |
|
1428 } |
|
1429 }); |
|
1430 |
|
1431 $.ui.intersect = function(draggable, droppable, toleranceMode) { |
|
1432 |
|
1433 if (!droppable.offset) return false; |
|
1434 |
|
1435 var x1 = (draggable.positionAbs || draggable.position.absolute).left, x2 = x1 + draggable.helperProportions.width, |
|
1436 y1 = (draggable.positionAbs || draggable.position.absolute).top, y2 = y1 + draggable.helperProportions.height; |
|
1437 var l = droppable.offset.left, r = l + droppable.proportions.width, |
|
1438 t = droppable.offset.top, b = t + droppable.proportions.height; |
|
1439 |
|
1440 switch (toleranceMode) { |
|
1441 case 'fit': |
|
1442 return (l < x1 && x2 < r |
|
1443 && t < y1 && y2 < b); |
|
1444 break; |
|
1445 case 'intersect': |
|
1446 return (l < x1 + (draggable.helperProportions.width / 2) // Right Half |
|
1447 && x2 - (draggable.helperProportions.width / 2) < r // Left Half |
|
1448 && t < y1 + (draggable.helperProportions.height / 2) // Bottom Half |
|
1449 && y2 - (draggable.helperProportions.height / 2) < b ); // Top Half |
|
1450 break; |
|
1451 case 'pointer': |
|
1452 var draggableLeft = ((draggable.positionAbs || draggable.position.absolute).left + (draggable.clickOffset || draggable.offset.click).left), |
|
1453 draggableTop = ((draggable.positionAbs || draggable.position.absolute).top + (draggable.clickOffset || draggable.offset.click).top), |
|
1454 isOver = $.ui.isOver(draggableTop, draggableLeft, t, l, droppable.proportions.height, droppable.proportions.width); |
|
1455 return isOver; |
|
1456 break; |
|
1457 case 'touch': |
|
1458 return ( |
|
1459 (y1 >= t && y1 <= b) || // Top edge touching |
|
1460 (y2 >= t && y2 <= b) || // Bottom edge touching |
|
1461 (y1 < t && y2 > b) // Surrounded vertically |
|
1462 ) && ( |
|
1463 (x1 >= l && x1 <= r) || // Left edge touching |
|
1464 (x2 >= l && x2 <= r) || // Right edge touching |
|
1465 (x1 < l && x2 > r) // Surrounded horizontally |
|
1466 ); |
|
1467 break; |
|
1468 default: |
|
1469 return false; |
|
1470 break; |
|
1471 } |
|
1472 |
|
1473 }; |
|
1474 |
|
1475 /* |
|
1476 This manager tracks offsets of draggables and droppables |
|
1477 */ |
|
1478 $.ui.ddmanager = { |
|
1479 current: null, |
|
1480 droppables: { 'default': [] }, |
|
1481 prepareOffsets: function(t, event) { |
|
1482 |
|
1483 var m = $.ui.ddmanager.droppables[t.options.scope]; |
|
1484 var type = event ? event.type : null; // workaround for #2317 |
|
1485 var list = (t.currentItem || t.element).find(":data(droppable)").andSelf(); |
|
1486 |
|
1487 droppablesLoop: for (var i = 0; i < m.length; i++) { |
|
1488 |
|
1489 if(m[i].options.disabled || (t && !m[i].options.accept.call(m[i].element[0],(t.currentItem || t.element)))) continue; //No disabled and non-accepted |
|
1490 for (var j=0; j < list.length; j++) { if(list[j] == m[i].element[0]) { m[i].proportions.height = 0; continue droppablesLoop; } }; //Filter out elements in the current dragged item |
|
1491 m[i].visible = m[i].element.css("display") != "none"; if(!m[i].visible) continue; //If the element is not visible, continue |
|
1492 |
|
1493 m[i].offset = m[i].element.offset(); |
|
1494 m[i].proportions = { width: m[i].element[0].offsetWidth, height: m[i].element[0].offsetHeight }; |
|
1495 |
|
1496 if(type == "mousedown") m[i]._activate.call(m[i], event); //Activate the droppable if used directly from draggables |
|
1497 |
|
1498 } |
|
1499 |
|
1500 }, |
|
1501 drop: function(draggable, event) { |
|
1502 |
|
1503 var dropped = false; |
|
1504 $.each($.ui.ddmanager.droppables[draggable.options.scope], function() { |
|
1505 |
|
1506 if(!this.options) return; |
|
1507 if (!this.options.disabled && this.visible && $.ui.intersect(draggable, this, this.options.tolerance)) |
|
1508 dropped = this._drop.call(this, event); |
|
1509 |
|
1510 if (!this.options.disabled && this.visible && this.options.accept.call(this.element[0],(draggable.currentItem || draggable.element))) { |
|
1511 this.isout = 1; this.isover = 0; |
|
1512 this._deactivate.call(this, event); |
|
1513 } |
|
1514 |
|
1515 }); |
|
1516 return dropped; |
|
1517 |
|
1518 }, |
|
1519 drag: function(draggable, event) { |
|
1520 |
|
1521 //If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse. |
|
1522 if(draggable.options.refreshPositions) $.ui.ddmanager.prepareOffsets(draggable, event); |
|
1523 |
|
1524 //Run through all droppables and check their positions based on specific tolerance options |
|
1525 |
|
1526 $.each($.ui.ddmanager.droppables[draggable.options.scope], function() { |
|
1527 |
|
1528 if(this.options.disabled || this.greedyChild || !this.visible) return; |
|
1529 var intersects = $.ui.intersect(draggable, this, this.options.tolerance); |
|
1530 |
|
1531 var c = !intersects && this.isover == 1 ? 'isout' : (intersects && this.isover == 0 ? 'isover' : null); |
|
1532 if(!c) return; |
|
1533 |
|
1534 var parentInstance; |
|
1535 if (this.options.greedy) { |
|
1536 var parent = this.element.parents(':data(droppable):eq(0)'); |
|
1537 if (parent.length) { |
|
1538 parentInstance = $.data(parent[0], 'droppable'); |
|
1539 parentInstance.greedyChild = (c == 'isover' ? 1 : 0); |
|
1540 } |
|
1541 } |
|
1542 |
|
1543 // we just moved into a greedy child |
|
1544 if (parentInstance && c == 'isover') { |
|
1545 parentInstance['isover'] = 0; |
|
1546 parentInstance['isout'] = 1; |
|
1547 parentInstance._out.call(parentInstance, event); |
|
1548 } |
|
1549 |
|
1550 this[c] = 1; this[c == 'isout' ? 'isover' : 'isout'] = 0; |
|
1551 this[c == "isover" ? "_over" : "_out"].call(this, event); |
|
1552 |
|
1553 // we just moved out of a greedy child |
|
1554 if (parentInstance && c == 'isout') { |
|
1555 parentInstance['isout'] = 0; |
|
1556 parentInstance['isover'] = 1; |
|
1557 parentInstance._over.call(parentInstance, event); |
|
1558 } |
|
1559 }); |
|
1560 |
|
1561 } |
|
1562 }; |
|
1563 |
|
1564 })(jQuery); |
|
1565 /* |
|
1566 * jQuery UI Resizable 1.6rc6 |
|
1567 * |
|
1568 * Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about) |
|
1569 * Dual licensed under the MIT (MIT-LICENSE.txt) |
|
1570 * and GPL (GPL-LICENSE.txt) licenses. |
|
1571 * |
|
1572 * http://docs.jquery.com/UI/Resizables |
|
1573 * |
|
1574 * Depends: |
|
1575 * ui.core.js |
|
1576 */ |
|
1577 (function($) { |
|
1578 |
|
1579 $.widget("ui.resizable", $.extend({}, $.ui.mouse, { |
|
1580 |
|
1581 _init: function() { |
|
1582 |
|
1583 var self = this, o = this.options; |
|
1584 this.element.addClass("ui-resizable"); |
|
1585 |
|
1586 $.extend(this, { |
|
1587 _aspectRatio: !!(o.aspectRatio), |
|
1588 aspectRatio: o.aspectRatio, |
|
1589 originalElement: this.element, |
|
1590 proportionallyResize: o.proportionallyResize ? [o.proportionallyResize] : [], |
|
1591 _helper: o.helper || o.ghost || o.animate ? o.helper || 'ui-resizable-helper' : null |
|
1592 }); |
|
1593 |
|
1594 //Wrap the element if it cannot hold child nodes |
|
1595 if(this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)) { |
|
1596 |
|
1597 //Opera fix for relative positioning |
|
1598 if (/relative/.test(this.element.css('position')) && $.browser.opera) |
|
1599 this.element.css({ position: 'relative', top: 'auto', left: 'auto' }); |
|
1600 |
|
1601 //Create a wrapper element and set the wrapper to the new current internal element |
|
1602 this.element.wrap( |
|
1603 $('<div class="ui-wrapper" style="overflow: hidden;"></div>').css({ |
|
1604 position: this.element.css('position'), |
|
1605 width: this.element.outerWidth(), |
|
1606 height: this.element.outerHeight(), |
|
1607 top: this.element.css('top'), |
|
1608 left: this.element.css('left') |
|
1609 }) |
|
1610 ); |
|
1611 |
|
1612 //Overwrite the original this.element |
|
1613 this.element = this.element.parent(); |
|
1614 this.elementIsWrapper = true; |
|
1615 |
|
1616 //Move margins to the wrapper |
|
1617 this.element.css({ marginLeft: this.originalElement.css("marginLeft"), marginTop: this.originalElement.css("marginTop"), marginRight: this.originalElement.css("marginRight"), marginBottom: this.originalElement.css("marginBottom") }); |
|
1618 this.originalElement.css({ marginLeft: 0, marginTop: 0, marginRight: 0, marginBottom: 0}); |
|
1619 |
|
1620 //Prevent Safari textarea resize |
|
1621 if ($.browser.safari && o.preventDefault) this.originalElement.css('resize', 'none'); |
|
1622 |
|
1623 //Push the actual element to our proportionallyResize internal array |
|
1624 this.proportionallyResize.push(this.originalElement.css({ position: 'static', zoom: 1, display: 'block' })); |
|
1625 |
|
1626 // avoid IE jump (hard set the margin) |
|
1627 this.originalElement.css({ margin: this.originalElement.css('margin') }); |
|
1628 |
|
1629 // fix handlers offset |
|
1630 this._proportionallyResize(); |
|
1631 |
|
1632 } |
|
1633 |
|
1634 this.handles = o.handles || (!$('.ui-resizable-handle', this.element).length ? "e,s,se" : { n: '.ui-resizable-n', e: '.ui-resizable-e', s: '.ui-resizable-s', w: '.ui-resizable-w', se: '.ui-resizable-se', sw: '.ui-resizable-sw', ne: '.ui-resizable-ne', nw: '.ui-resizable-nw' }); |
|
1635 if(this.handles.constructor == String) { |
|
1636 |
|
1637 if(this.handles == 'all') this.handles = 'n,e,s,w,se,sw,ne,nw'; |
|
1638 var n = this.handles.split(","); this.handles = {}; |
|
1639 |
|
1640 for(var i = 0; i < n.length; i++) { |
|
1641 |
|
1642 var handle = $.trim(n[i]), hname = 'ui-resizable-'+handle; |
|
1643 var axis = $('<div class="ui-resizable-handle ' + hname + '"></div>'); |
|
1644 |
|
1645 // increase zIndex of sw, se, ne, nw axis |
|
1646 //TODO : this modifies original option |
|
1647 if(/sw|se|ne|nw/.test(handle)) axis.css({ zIndex: ++o.zIndex }); |
|
1648 |
|
1649 //TODO : What's going on here? |
|
1650 if ('se' == handle) { |
|
1651 axis.addClass('ui-icon ui-icon-gripsmall-diagonal-se'); |
|
1652 }; |
|
1653 |
|
1654 //Insert into internal handles object and append to element |
|
1655 this.handles[handle] = '.ui-resizable-'+handle; |
|
1656 this.element.append(axis); |
|
1657 } |
|
1658 |
|
1659 } |
|
1660 |
|
1661 this._renderAxis = function(target) { |
|
1662 |
|
1663 target = target || this.element; |
|
1664 |
|
1665 for(var i in this.handles) { |
|
1666 |
|
1667 if(this.handles[i].constructor == String) |
|
1668 this.handles[i] = $(this.handles[i], this.element).show(); |
|
1669 |
|
1670 if (o.transparent) |
|
1671 this.handles[i].css({ opacity: 0 }); |
|
1672 |
|
1673 //Apply pad to wrapper element, needed to fix axis position (textarea, inputs, scrolls) |
|
1674 if (this.elementIsWrapper && this.originalElement[0].nodeName.match(/textarea|input|select|button/i)) { |
|
1675 |
|
1676 var axis = $(this.handles[i], this.element), padWrapper = 0; |
|
1677 |
|
1678 //Checking the correct pad and border |
|
1679 padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth(); |
|
1680 |
|
1681 //The padding type i have to apply... |
|
1682 var padPos = [ 'padding', |
|
1683 /ne|nw|n/.test(i) ? 'Top' : |
|
1684 /se|sw|s/.test(i) ? 'Bottom' : |
|
1685 /^e$/.test(i) ? 'Right' : 'Left' ].join(""); |
|
1686 |
|
1687 if (!o.transparent) |
|
1688 target.css(padPos, padWrapper); |
|
1689 |
|
1690 this._proportionallyResize(); |
|
1691 |
|
1692 } |
|
1693 |
|
1694 //TODO: What's that good for? There's not anything to be executed left |
|
1695 if(!$(this.handles[i]).length) |
|
1696 continue; |
|
1697 |
|
1698 } |
|
1699 }; |
|
1700 |
|
1701 //TODO: make renderAxis a prototype function |
|
1702 this._renderAxis(this.element); |
|
1703 |
|
1704 this._handles = $('.ui-resizable-handle', this.element); |
|
1705 |
|
1706 if (o.disableSelection) |
|
1707 this._handles.disableSelection(); |
|
1708 |
|
1709 //Matching axis name |
|
1710 this._handles.mouseover(function() { |
|
1711 if (!self.resizing) { |
|
1712 if (this.className) |
|
1713 var axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i); |
|
1714 //Axis, default = se |
|
1715 self.axis = axis && axis[1] ? axis[1] : 'se'; |
|
1716 } |
|
1717 }); |
|
1718 |
|
1719 //If we want to auto hide the elements |
|
1720 if (o.autoHide) { |
|
1721 this._handles.hide(); |
|
1722 $(this.element) |
|
1723 .addClass("ui-resizable-autohide") |
|
1724 .hover(function() { |
|
1725 $(this).removeClass("ui-resizable-autohide"); |
|
1726 self._handles.show(); |
|
1727 }, |
|
1728 function(){ |
|
1729 if (!self.resizing) { |
|
1730 $(this).addClass("ui-resizable-autohide"); |
|
1731 self._handles.hide(); |
|
1732 } |
|
1733 }); |
|
1734 } |
|
1735 |
|
1736 //Initialize the mouse interaction |
|
1737 this._mouseInit(); |
|
1738 |
|
1739 }, |
|
1740 |
|
1741 destroy: function() { |
|
1742 |
|
1743 this._mouseDestroy(); |
|
1744 |
|
1745 var _destroy = function(exp) { |
|
1746 $(exp).removeClass("ui-resizable ui-resizable-disabled") |
|
1747 .removeData("resizable").unbind(".resizable").find('.ui-resizable-handle').remove(); |
|
1748 }; |
|
1749 |
|
1750 //TODO: Unwrap at same DOM position |
|
1751 if (this.elementIsWrapper) { |
|
1752 _destroy(this.element); |
|
1753 this.wrapper.parent().append( |
|
1754 this.originalElement.css({ |
|
1755 position: this.wrapper.css('position'), |
|
1756 width: this.wrapper.outerWidth(), |
|
1757 height: this.wrapper.outerHeight(), |
|
1758 top: this.wrapper.css('top'), |
|
1759 left: this.wrapper.css('left') |
|
1760 }) |
|
1761 ).end().remove(); |
|
1762 } |
|
1763 |
|
1764 _destroy(this.originalElement); |
|
1765 |
|
1766 }, |
|
1767 |
|
1768 _mouseCapture: function(event) { |
|
1769 |
|
1770 var handle = false; |
|
1771 for(var i in this.handles) { |
|
1772 if($(this.handles[i])[0] == event.target) handle = true; |
|
1773 } |
|
1774 |
|
1775 return this.options.disabled || !!handle; |
|
1776 |
|
1777 }, |
|
1778 |
|
1779 _mouseStart: function(event) { |
|
1780 |
|
1781 var o = this.options, iniPos = this.element.position(), el = this.element; |
|
1782 |
|
1783 this.resizing = true; |
|
1784 this.documentScroll = { top: $(document).scrollTop(), left: $(document).scrollLeft() }; |
|
1785 |
|
1786 // bugfix for http://dev.jquery.com/ticket/1749 |
|
1787 if (el.is('.ui-draggable') || (/absolute/).test(el.css('position'))) { |
|
1788 el.css({ position: 'absolute', top: iniPos.top, left: iniPos.left }); |
|
1789 } |
|
1790 |
|
1791 //Opera fixing relative position |
|
1792 if ($.browser.opera && (/relative/).test(el.css('position'))) |
|
1793 el.css({ position: 'relative', top: 'auto', left: 'auto' }); |
|
1794 |
|
1795 this._renderProxy(); |
|
1796 |
|
1797 var curleft = num(this.helper.css('left')), curtop = num(this.helper.css('top')); |
|
1798 |
|
1799 if (o.containment) { |
|
1800 curleft += $(o.containment).scrollLeft() || 0; |
|
1801 curtop += $(o.containment).scrollTop() || 0; |
|
1802 } |
|
1803 |
|
1804 //Store needed variables |
|
1805 this.offset = this.helper.offset(); |
|
1806 this.position = { left: curleft, top: curtop }; |
|
1807 this.size = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() }; |
|
1808 this.originalSize = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() }; |
|
1809 this.originalPosition = { left: curleft, top: curtop }; |
|
1810 this.sizeDiff = { width: el.outerWidth() - el.width(), height: el.outerHeight() - el.height() }; |
|
1811 this.originalMousePosition = { left: event.pageX, top: event.pageY }; |
|
1812 |
|
1813 //Aspect Ratio |
|
1814 this.aspectRatio = (typeof o.aspectRatio == 'number') ? o.aspectRatio : ((this.originalSize.width / this.originalSize.height) || 1); |
|
1815 |
|
1816 if (o.preserveCursor) { |
|
1817 var cursor = $('.ui-resizable-' + this.axis).css('cursor'); |
|
1818 $('body').css('cursor', cursor == 'auto' ? this.axis + '-resize' : cursor); |
|
1819 } |
|
1820 |
|
1821 this._propagate("start", event); |
|
1822 return true; |
|
1823 }, |
|
1824 |
|
1825 _mouseDrag: function(event) { |
|
1826 |
|
1827 //Increase performance, avoid regex |
|
1828 var el = this.helper, o = this.options, props = {}, |
|
1829 self = this, smp = this.originalMousePosition, a = this.axis; |
|
1830 |
|
1831 var dx = (event.pageX-smp.left)||0, dy = (event.pageY-smp.top)||0; |
|
1832 var trigger = this._change[a]; |
|
1833 if (!trigger) return false; |
|
1834 |
|
1835 // Calculate the attrs that will be change |
|
1836 var data = trigger.apply(this, [event, dx, dy]), ie6 = $.browser.msie && $.browser.version < 7, csdif = this.sizeDiff; |
|
1837 |
|
1838 if (this._aspectRatio || event.shiftKey) |
|
1839 data = this._updateRatio(data, event); |
|
1840 |
|
1841 data = this._respectSize(data, event); |
|
1842 |
|
1843 // plugins callbacks need to be called first |
|
1844 this._propagate("resize", event); |
|
1845 |
|
1846 el.css({ |
|
1847 top: this.position.top + "px", left: this.position.left + "px", |
|
1848 width: this.size.width + "px", height: this.size.height + "px" |
|
1849 }); |
|
1850 |
|
1851 if (!this._helper && this.proportionallyResize.length) |
|
1852 this._proportionallyResize(); |
|
1853 |
|
1854 this._updateCache(data); |
|
1855 |
|
1856 // calling the user callback at the end |
|
1857 this._trigger('resize', event, this.ui()); |
|
1858 |
|
1859 return false; |
|
1860 }, |
|
1861 |
|
1862 _mouseStop: function(event) { |
|
1863 |
|
1864 this.resizing = false; |
|
1865 var o = this.options, self = this; |
|
1866 |
|
1867 if(this._helper) { |
|
1868 var pr = this.proportionallyResize, ista = pr.length && (/textarea/i).test(pr[0].nodeName), |
|
1869 soffseth = ista && $.ui.hasScroll(pr[0], 'left') /* TODO - jump height */ ? 0 : self.sizeDiff.height, |
|
1870 soffsetw = ista ? 0 : self.sizeDiff.width; |
|
1871 |
|
1872 var s = { width: (self.size.width - soffsetw), height: (self.size.height - soffseth) }, |
|
1873 left = (parseInt(self.element.css('left'), 10) + (self.position.left - self.originalPosition.left)) || null, |
|
1874 top = (parseInt(self.element.css('top'), 10) + (self.position.top - self.originalPosition.top)) || null; |
|
1875 |
|
1876 if (!o.animate) |
|
1877 this.element.css($.extend(s, { top: top, left: left })); |
|
1878 |
|
1879 if (this._helper && !o.animate) this._proportionallyResize(); |
|
1880 } |
|
1881 |
|
1882 if (o.preserveCursor) |
|
1883 $('body').css('cursor', 'auto'); |
|
1884 |
|
1885 this._propagate("stop", event); |
|
1886 |
|
1887 if (this._helper) this.helper.remove(); |
|
1888 return false; |
|
1889 |
|
1890 }, |
|
1891 |
|
1892 _updateCache: function(data) { |
|
1893 var o = this.options; |
|
1894 this.offset = this.helper.offset(); |
|
1895 if (data.left) this.position.left = data.left; |
|
1896 if (data.top) this.position.top = data.top; |
|
1897 if (data.height) this.size.height = data.height; |
|
1898 if (data.width) this.size.width = data.width; |
|
1899 }, |
|
1900 |
|
1901 _updateRatio: function(data, event) { |
|
1902 |
|
1903 var o = this.options, cpos = this.position, csize = this.size, a = this.axis; |
|
1904 |
|
1905 if (data.height) data.width = (csize.height * this.aspectRatio); |
|
1906 else if (data.width) data.height = (csize.width / this.aspectRatio); |
|
1907 |
|
1908 if (a == 'sw') { |
|
1909 data.left = cpos.left + (csize.width - data.width); |
|
1910 data.top = null; |
|
1911 } |
|
1912 if (a == 'nw') { |
|
1913 data.top = cpos.top + (csize.height - data.height); |
|
1914 data.left = cpos.left + (csize.width - data.width); |
|
1915 } |
|
1916 |
|
1917 return data; |
|
1918 }, |
|
1919 |
|
1920 _respectSize: function(data, event) { |
|
1921 |
|
1922 var isNumber = function(value) { |
|
1923 return !isNaN(parseInt(value, 10)) |
|
1924 }; |
|
1925 |
|
1926 var el = this.helper, o = this.options, pRatio = this._aspectRatio || event.shiftKey, a = this.axis, |
|
1927 ismaxw = isNumber(data.width) && o.maxWidth && (o.maxWidth < data.width), ismaxh = isNumber(data.height) && o.maxHeight && (o.maxHeight < data.height), |
|
1928 isminw = isNumber(data.width) && o.minWidth && (o.minWidth > data.width), isminh = isNumber(data.height) && o.minHeight && (o.minHeight > data.height); |
|
1929 |
|
1930 if (isminw) data.width = o.minWidth; |
|
1931 if (isminh) data.height = o.minHeight; |
|
1932 if (ismaxw) data.width = o.maxWidth; |
|
1933 if (ismaxh) data.height = o.maxHeight; |
|
1934 |
|
1935 var dw = this.originalPosition.left + this.originalSize.width, dh = this.position.top + this.size.height; |
|
1936 var cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a); |
|
1937 |
|
1938 if (isminw && cw) data.left = dw - o.minWidth; |
|
1939 if (ismaxw && cw) data.left = dw - o.maxWidth; |
|
1940 if (isminh && ch) data.top = dh - o.minHeight; |
|
1941 if (ismaxh && ch) data.top = dh - o.maxHeight; |
|
1942 |
|
1943 // fixing jump error on top/left - bug #2330 |
|
1944 var isNotwh = !data.width && !data.height; |
|
1945 if (isNotwh && !data.left && data.top) data.top = null; |
|
1946 else if (isNotwh && !data.top && data.left) data.left = null; |
|
1947 |
|
1948 return data; |
|
1949 }, |
|
1950 |
|
1951 _proportionallyResize: function() { |
|
1952 |
|
1953 var o = this.options; |
|
1954 if (!this.proportionallyResize.length) return; |
|
1955 var element = this.helper || this.element; |
|
1956 |
|
1957 for (var i=0; i < this.proportionallyResize.length; i++) { |
|
1958 |
|
1959 var prel = this.proportionallyResize[i]; |
|
1960 |
|
1961 if (!this.borderDif) { |
|
1962 var b = [prel.css('borderTopWidth'), prel.css('borderRightWidth'), prel.css('borderBottomWidth'), prel.css('borderLeftWidth')], |
|
1963 p = [prel.css('paddingTop'), prel.css('paddingRight'), prel.css('paddingBottom'), prel.css('paddingLeft')]; |
|
1964 |
|
1965 this.borderDif = $.map(b, function(v, i) { |
|
1966 var border = parseInt(v,10)||0, padding = parseInt(p[i],10)||0; |
|
1967 return border + padding; |
|
1968 }); |
|
1969 } |
|
1970 |
|
1971 if ($.browser.msie && !(!($(element).is(':hidden') || $(element).parents(':hidden').length))) |
|
1972 continue; |
|
1973 |
|
1974 prel.css({ |
|
1975 height: (element.height() - this.borderDif[0] - this.borderDif[2]) || 0, |
|
1976 width: (element.width() - this.borderDif[1] - this.borderDif[3]) || 0 |
|
1977 }); |
|
1978 |
|
1979 }; |
|
1980 |
|
1981 }, |
|
1982 |
|
1983 _renderProxy: function() { |
|
1984 |
|
1985 var el = this.element, o = this.options; |
|
1986 this.elementOffset = el.offset(); |
|
1987 |
|
1988 if(this._helper) { |
|
1989 |
|
1990 this.helper = this.helper || $('<div style="overflow:hidden;"></div>'); |
|
1991 |
|
1992 // fix ie6 offset TODO: This seems broken |
|
1993 var ie6 = $.browser.msie && $.browser.version < 7, ie6offset = (ie6 ? 1 : 0), |
|
1994 pxyoffset = ( ie6 ? 2 : -1 ); |
|
1995 |
|
1996 this.helper.addClass(this._helper).css({ |
|
1997 width: this.element.outerWidth() + pxyoffset, |
|
1998 height: this.element.outerHeight() + pxyoffset, |
|
1999 position: 'absolute', |
|
2000 left: this.elementOffset.left - ie6offset +'px', |
|
2001 top: this.elementOffset.top - ie6offset +'px', |
|
2002 zIndex: ++o.zIndex //TODO: Don't modify option |
|
2003 }); |
|
2004 |
|
2005 this.helper.appendTo("body"); |
|
2006 |
|
2007 if (o.disableSelection) |
|
2008 this.helper.disableSelection(); |
|
2009 |
|
2010 } else { |
|
2011 this.helper = this.element; |
|
2012 } |
|
2013 |
|
2014 }, |
|
2015 |
|
2016 _change: { |
|
2017 e: function(event, dx, dy) { |
|
2018 return { width: this.originalSize.width + dx }; |
|
2019 }, |
|
2020 w: function(event, dx, dy) { |
|
2021 var o = this.options, cs = this.originalSize, sp = this.originalPosition; |
|
2022 return { left: sp.left + dx, width: cs.width - dx }; |
|
2023 }, |
|
2024 n: function(event, dx, dy) { |
|
2025 var o = this.options, cs = this.originalSize, sp = this.originalPosition; |
|
2026 return { top: sp.top + dy, height: cs.height - dy }; |
|
2027 }, |
|
2028 s: function(event, dx, dy) { |
|
2029 return { height: this.originalSize.height + dy }; |
|
2030 }, |
|
2031 se: function(event, dx, dy) { |
|
2032 return $.extend(this._change.s.apply(this, arguments), this._change.e.apply(this, [event, dx, dy])); |
|
2033 }, |
|
2034 sw: function(event, dx, dy) { |
|
2035 return $.extend(this._change.s.apply(this, arguments), this._change.w.apply(this, [event, dx, dy])); |
|
2036 }, |
|
2037 ne: function(event, dx, dy) { |
|
2038 return $.extend(this._change.n.apply(this, arguments), this._change.e.apply(this, [event, dx, dy])); |
|
2039 }, |
|
2040 nw: function(event, dx, dy) { |
|
2041 return $.extend(this._change.n.apply(this, arguments), this._change.w.apply(this, [event, dx, dy])); |
|
2042 } |
|
2043 }, |
|
2044 |
|
2045 _propagate: function(n, event) { |
|
2046 $.ui.plugin.call(this, n, [event, this.ui()]); |
|
2047 (n != "resize" && this._trigger(n, event, this.ui())); |
|
2048 }, |
|
2049 |
|
2050 plugins: {}, |
|
2051 |
|
2052 ui: function() { |
|
2053 return { |
|
2054 originalElement: this.originalElement, |
|
2055 element: this.element, |
|
2056 helper: this.helper, |
|
2057 position: this.position, |
|
2058 size: this.size, |
|
2059 originalSize: this.originalSize, |
|
2060 originalPosition: this.originalPosition |
|
2061 }; |
|
2062 } |
|
2063 |
|
2064 })); |
|
2065 |
|
2066 $.extend($.ui.resizable, { |
|
2067 version: "1.6rc6", |
|
2068 eventPrefix: "resize", |
|
2069 defaults: { |
|
2070 alsoResize: false, |
|
2071 animate: false, |
|
2072 animateDuration: "slow", |
|
2073 animateEasing: "swing", |
|
2074 aspectRatio: false, |
|
2075 autoHide: false, |
|
2076 cancel: ":input,option", |
|
2077 containment: false, |
|
2078 delay: 0, |
|
2079 disableSelection: true, |
|
2080 distance: 1, |
|
2081 ghost: false, |
|
2082 grid: false, |
|
2083 handles: "e,s,se", |
|
2084 helper: false, |
|
2085 maxHeight: null, |
|
2086 maxWidth: null, |
|
2087 minHeight: 10, |
|
2088 minWidth: 10, |
|
2089 preserveCursor: true, |
|
2090 preventDefault: true, |
|
2091 proportionallyResize: false, |
|
2092 transparent: false, |
|
2093 zIndex: 1000 |
|
2094 } |
|
2095 }); |
|
2096 |
|
2097 /* |
|
2098 * Resizable Extensions |
|
2099 */ |
|
2100 |
|
2101 $.ui.plugin.add("resizable", "alsoResize", { |
|
2102 |
|
2103 start: function(event, ui) { |
|
2104 |
|
2105 var self = $(this).data("resizable"), o = self.options; |
|
2106 |
|
2107 _store = function(exp) { |
|
2108 $(exp).each(function() { |
|
2109 $(this).data("resizable-alsoresize", { |
|
2110 width: parseInt($(this).width(), 10), height: parseInt($(this).height(), 10), |
|
2111 left: parseInt($(this).css('left'), 10), top: parseInt($(this).css('top'), 10) |
|
2112 }); |
|
2113 }); |
|
2114 }; |
|
2115 |
|
2116 if (typeof(o.alsoResize) == 'object' && !o.alsoResize.parentNode) { |
|
2117 if (o.alsoResize.length) { o.alsoResize = o.alsoResize[0]; _store(o.alsoResize); } |
|
2118 else { $.each(o.alsoResize, function(exp, c) { _store(exp); }); } |
|
2119 }else{ |
|
2120 _store(o.alsoResize); |
|
2121 } |
|
2122 }, |
|
2123 |
|
2124 resize: function(event, ui){ |
|
2125 var self = $(this).data("resizable"), o = self.options, os = self.originalSize, op = self.originalPosition; |
|
2126 |
|
2127 var delta = { |
|
2128 height: (self.size.height - os.height) || 0, width: (self.size.width - os.width) || 0, |
|
2129 top: (self.position.top - op.top) || 0, left: (self.position.left - op.left) || 0 |
|
2130 }, |
|
2131 |
|
2132 _alsoResize = function(exp, c) { |
|
2133 $(exp).each(function() { |
|
2134 var el = $(this), start = $(this).data("resizable-alsoresize"), style = {}, css = c && c.length ? c : ['width', 'height', 'top', 'left']; |
|
2135 |
|
2136 $.each(css || ['width', 'height', 'top', 'left'], function(i, prop) { |
|
2137 var sum = (start[prop]||0) + (delta[prop]||0); |
|
2138 if (sum && sum >= 0) |
|
2139 style[prop] = sum || null; |
|
2140 }); |
|
2141 |
|
2142 //Opera fixing relative position |
|
2143 if (/relative/.test(el.css('position')) && $.browser.opera) { |
|
2144 self._revertToRelativePosition = true; |
|
2145 el.css({ position: 'absolute', top: 'auto', left: 'auto' }); |
|
2146 } |
|
2147 |
|
2148 el.css(style); |
|
2149 }); |
|
2150 }; |
|
2151 |
|
2152 if (typeof(o.alsoResize) == 'object' && !o.alsoResize.nodeType) { |
|
2153 $.each(o.alsoResize, function(exp, c) { _alsoResize(exp, c); }); |
|
2154 }else{ |
|
2155 _alsoResize(o.alsoResize); |
|
2156 } |
|
2157 }, |
|
2158 |
|
2159 stop: function(event, ui){ |
|
2160 var self = $(this).data("resizable"); |
|
2161 |
|
2162 //Opera fixing relative position |
|
2163 if (self._revertToRelativePosition && $.browser.opera) { |
|
2164 self._revertToRelativePosition = false; |
|
2165 el.css({ position: 'relative' }); |
|
2166 } |
|
2167 |
|
2168 $(this).removeData("resizable-alsoresize-start"); |
|
2169 } |
|
2170 }); |
|
2171 |
|
2172 $.ui.plugin.add("resizable", "animate", { |
|
2173 |
|
2174 stop: function(event, ui) { |
|
2175 var self = $(this).data("resizable"), o = self.options; |
|
2176 |
|
2177 var pr = o.proportionallyResize, ista = pr && (/textarea/i).test(pr.get(0).nodeName), |
|
2178 soffseth = ista && $.ui.hasScroll(pr.get(0), 'left') /* TODO - jump height */ ? 0 : self.sizeDiff.height, |
|
2179 soffsetw = ista ? 0 : self.sizeDiff.width; |
|
2180 |
|
2181 var style = { width: (self.size.width - soffsetw), height: (self.size.height - soffseth) }, |
|
2182 left = (parseInt(self.element.css('left'), 10) + (self.position.left - self.originalPosition.left)) || null, |
|
2183 top = (parseInt(self.element.css('top'), 10) + (self.position.top - self.originalPosition.top)) || null; |
|
2184 |
|
2185 self.element.animate( |
|
2186 $.extend(style, top && left ? { top: top, left: left } : {}), { |
|
2187 duration: o.animateDuration, |
|
2188 easing: o.animateEasing, |
|
2189 step: function() { |
|
2190 |
|
2191 var data = { |
|
2192 width: parseInt(self.element.css('width'), 10), |
|
2193 height: parseInt(self.element.css('height'), 10), |
|
2194 top: parseInt(self.element.css('top'), 10), |
|
2195 left: parseInt(self.element.css('left'), 10) |
|
2196 }; |
|
2197 |
|
2198 if (pr) pr.css({ width: data.width, height: data.height }); |
|
2199 |
|
2200 // propagating resize, and updating values for each animation step |
|
2201 self._updateCache(data); |
|
2202 self._propagate("resize", event); |
|
2203 |
|
2204 } |
|
2205 } |
|
2206 ); |
|
2207 } |
|
2208 |
|
2209 }); |
|
2210 |
|
2211 $.ui.plugin.add("resizable", "containment", { |
|
2212 |
|
2213 start: function(event, ui) { |
|
2214 var self = $(this).data("resizable"), o = self.options, el = self.element; |
|
2215 var oc = o.containment, ce = (oc instanceof $) ? oc.get(0) : (/parent/.test(oc)) ? el.parent().get(0) : oc; |
|
2216 if (!ce) return; |
|
2217 |
|
2218 self.containerElement = $(ce); |
|
2219 |
|
2220 if (/document/.test(oc) || oc == document) { |
|
2221 self.containerOffset = { left: 0, top: 0 }; |
|
2222 self.containerPosition = { left: 0, top: 0 }; |
|
2223 |
|
2224 self.parentData = { |
|
2225 element: $(document), left: 0, top: 0, |
|
2226 width: $(document).width(), height: $(document).height() || document.body.parentNode.scrollHeight |
|
2227 }; |
|
2228 } |
|
2229 |
|
2230 // i'm a node, so compute top, left, right, bottom |
|
2231 else { |
|
2232 var element = $(ce), p = []; |
|
2233 $([ "Top", "Right", "Left", "Bottom" ]).each(function(i, name) { p[i] = num(element.css("padding" + name)); }); |
|
2234 |
|
2235 self.containerOffset = element.offset(); |
|
2236 self.containerPosition = element.position(); |
|
2237 self.containerSize = { height: (element.innerHeight() - p[3]), width: (element.innerWidth() - p[1]) }; |
|
2238 |
|
2239 var co = self.containerOffset, ch = self.containerSize.height, cw = self.containerSize.width, |
|
2240 width = ($.ui.hasScroll(ce, "left") ? ce.scrollWidth : cw ), height = ($.ui.hasScroll(ce) ? ce.scrollHeight : ch); |
|
2241 |
|
2242 self.parentData = { |
|
2243 element: ce, left: co.left, top: co.top, width: width, height: height |
|
2244 }; |
|
2245 } |
|
2246 }, |
|
2247 |
|
2248 resize: function(event, ui) { |
|
2249 var self = $(this).data("resizable"), o = self.options, |
|
2250 ps = self.containerSize, co = self.containerOffset, cs = self.size, cp = self.position, |
|
2251 pRatio = o._aspectRatio || event.shiftKey, cop = { top:0, left:0 }, ce = self.containerElement; |
|
2252 |
|
2253 if (ce[0] != document && (/static/).test(ce.css('position'))) cop = co; |
|
2254 |
|
2255 if (cp.left < (self._helper ? co.left : 0)) { |
|
2256 self.size.width = self.size.width + (self._helper ? (self.position.left - co.left) : (self.position.left - cop.left)); |
|
2257 if (pRatio) self.size.height = self.size.width / o.aspectRatio; |
|
2258 self.position.left = o.helper ? co.left : 0; |
|
2259 } |
|
2260 |
|
2261 if (cp.top < (self._helper ? co.top : 0)) { |
|
2262 self.size.height = self.size.height + (self._helper ? (self.position.top - co.top) : self.position.top); |
|
2263 if (pRatio) self.size.width = self.size.height * o.aspectRatio; |
|
2264 self.position.top = self._helper ? co.top : 0; |
|
2265 } |
|
2266 |
|
2267 var woset = Math.abs( (self._helper ? self.offset.left - cop.left : (self.offset.left - cop.left)) + self.sizeDiff.width ), |
|
2268 hoset = Math.abs( (self._helper ? self.offset.top - cop.top : (self.offset.top - co.top)) + self.sizeDiff.height ); |
|
2269 |
|
2270 if (woset + self.size.width >= self.parentData.width) { |
|
2271 self.size.width = self.parentData.width - woset; |
|
2272 if (pRatio) self.size.height = self.size.width / o.aspectRatio; |
|
2273 } |
|
2274 |
|
2275 if (hoset + self.size.height >= self.parentData.height) { |
|
2276 self.size.height = self.parentData.height - hoset; |
|
2277 if (pRatio) self.size.width = self.size.height * o.aspectRatio; |
|
2278 } |
|
2279 }, |
|
2280 |
|
2281 stop: function(event, ui){ |
|
2282 var self = $(this).data("resizable"), o = self.options, cp = self.position, |
|
2283 co = self.containerOffset, cop = self.containerPosition, ce = self.containerElement; |
|
2284 |
|
2285 var helper = $(self.helper), ho = helper.offset(), w = helper.outerWidth() - self.sizeDiff.width, h = helper.outerHeight() - self.sizeDiff.height; |
|
2286 |
|
2287 if (self._helper && !o.animate && (/relative/).test(ce.css('position'))) |
|
2288 $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h }); |
|
2289 |
|
2290 if (self._helper && !o.animate && (/static/).test(ce.css('position'))) |
|
2291 $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h }); |
|
2292 |
|
2293 } |
|
2294 }); |
|
2295 |
|
2296 $.ui.plugin.add("resizable", "ghost", { |
|
2297 |
|
2298 start: function(event, ui) { |
|
2299 |
|
2300 var self = $(this).data("resizable"), o = self.options, pr = o.proportionallyResize, cs = self.size; |
|
2301 |
|
2302 self.ghost = self.originalElement.clone(); |
|
2303 self.ghost |
|
2304 .css({ opacity: .25, display: 'block', position: 'relative', height: cs.height, width: cs.width, margin: 0, left: 0, top: 0 }) |
|
2305 .addClass('ui-resizable-ghost') |
|
2306 .addClass(typeof o.ghost == 'string' ? o.ghost : ''); |
|
2307 |
|
2308 self.ghost.appendTo(self.helper); |
|
2309 |
|
2310 }, |
|
2311 |
|
2312 resize: function(event, ui){ |
|
2313 var self = $(this).data("resizable"), o = self.options; |
|
2314 if (self.ghost) self.ghost.css({ position: 'relative', height: self.size.height, width: self.size.width }); |
|
2315 }, |
|
2316 |
|
2317 stop: function(event, ui){ |
|
2318 var self = $(this).data("resizable"), o = self.options; |
|
2319 if (self.ghost && self.helper) self.helper.get(0).removeChild(self.ghost.get(0)); |
|
2320 } |
|
2321 |
|
2322 }); |
|
2323 |
|
2324 $.ui.plugin.add("resizable", "grid", { |
|
2325 |
|
2326 resize: function(event, ui) { |
|
2327 var self = $(this).data("resizable"), o = self.options, cs = self.size, os = self.originalSize, op = self.originalPosition, a = self.axis, ratio = o._aspectRatio || event.shiftKey; |
|
2328 o.grid = typeof o.grid == "number" ? [o.grid, o.grid] : o.grid; |
|
2329 var ox = Math.round((cs.width - os.width) / (o.grid[0]||1)) * (o.grid[0]||1), oy = Math.round((cs.height - os.height) / (o.grid[1]||1)) * (o.grid[1]||1); |
|
2330 |
|
2331 if (/^(se|s|e)$/.test(a)) { |
|
2332 self.size.width = os.width + ox; |
|
2333 self.size.height = os.height + oy; |
|
2334 } |
|
2335 else if (/^(ne)$/.test(a)) { |
|
2336 self.size.width = os.width + ox; |
|
2337 self.size.height = os.height + oy; |
|
2338 self.position.top = op.top - oy; |
|
2339 } |
|
2340 else if (/^(sw)$/.test(a)) { |
|
2341 self.size.width = os.width + ox; |
|
2342 self.size.height = os.height + oy; |
|
2343 self.position.left = op.left - ox; |
|
2344 } |
|
2345 else { |
|
2346 self.size.width = os.width + ox; |
|
2347 self.size.height = os.height + oy; |
|
2348 self.position.top = op.top - oy; |
|
2349 self.position.left = op.left - ox; |
|
2350 } |
|
2351 } |
|
2352 |
|
2353 }); |
|
2354 |
|
2355 var num = function(v) { |
|
2356 return parseInt(v, 10) || 0; |
|
2357 }; |
|
2358 |
|
2359 })(jQuery); |
|
2360 /* |
|
2361 * jQuery UI Selectable 1.6rc6 |
|
2362 * |
|
2363 * Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about) |
|
2364 * Dual licensed under the MIT (MIT-LICENSE.txt) |
|
2365 * and GPL (GPL-LICENSE.txt) licenses. |
|
2366 * |
|
2367 * http://docs.jquery.com/UI/Selectables |
|
2368 * |
|
2369 * Depends: |
|
2370 * ui.core.js |
|
2371 */ |
|
2372 (function($) { |
|
2373 |
|
2374 $.widget("ui.selectable", $.extend({}, $.ui.mouse, { |
|
2375 |
|
2376 _init: function() { |
|
2377 var self = this; |
|
2378 |
|
2379 this.element.addClass("ui-selectable"); |
|
2380 |
|
2381 this.dragged = false; |
|
2382 |
|
2383 // cache selectee children based on filter |
|
2384 var selectees; |
|
2385 this.refresh = function() { |
|
2386 selectees = $(self.options.filter, self.element[0]); |
|
2387 selectees.each(function() { |
|
2388 var $this = $(this); |
|
2389 var pos = $this.offset(); |
|
2390 $.data(this, "selectable-item", { |
|
2391 element: this, |
|
2392 $element: $this, |
|
2393 left: pos.left, |
|
2394 top: pos.top, |
|
2395 right: pos.left + $this.outerWidth(), |
|
2396 bottom: pos.top + $this.outerHeight(), |
|
2397 startselected: false, |
|
2398 selected: $this.hasClass('ui-selected'), |
|
2399 selecting: $this.hasClass('ui-selecting'), |
|
2400 unselecting: $this.hasClass('ui-unselecting') |
|
2401 }); |
|
2402 }); |
|
2403 }; |
|
2404 this.refresh(); |
|
2405 |
|
2406 this.selectees = selectees.addClass("ui-selectee"); |
|
2407 |
|
2408 this._mouseInit(); |
|
2409 |
|
2410 this.helper = $(document.createElement('div')) |
|
2411 .css({border:'1px dotted black'}) |
|
2412 .addClass("ui-selectable-helper"); |
|
2413 }, |
|
2414 |
|
2415 destroy: function() { |
|
2416 this.element |
|
2417 .removeClass("ui-selectable ui-selectable-disabled") |
|
2418 .removeData("selectable") |
|
2419 .unbind(".selectable"); |
|
2420 this._mouseDestroy(); |
|
2421 }, |
|
2422 |
|
2423 _mouseStart: function(event) { |
|
2424 var self = this; |
|
2425 |
|
2426 this.opos = [event.pageX, event.pageY]; |
|
2427 |
|
2428 if (this.options.disabled) |
|
2429 return; |
|
2430 |
|
2431 var options = this.options; |
|
2432 |
|
2433 this.selectees = $(options.filter, this.element[0]); |
|
2434 |
|
2435 this._trigger("start", event); |
|
2436 |
|
2437 $('body').append(this.helper); |
|
2438 // position helper (lasso) |
|
2439 this.helper.css({ |
|
2440 "z-index": 100, |
|
2441 "position": "absolute", |
|
2442 "left": event.clientX, |
|
2443 "top": event.clientY, |
|
2444 "width": 0, |
|
2445 "height": 0 |
|
2446 }); |
|
2447 |
|
2448 if (options.autoRefresh) { |
|
2449 this.refresh(); |
|
2450 } |
|
2451 |
|
2452 this.selectees.filter('.ui-selected').each(function() { |
|
2453 var selectee = $.data(this, "selectable-item"); |
|
2454 selectee.startselected = true; |
|
2455 if (!event.metaKey) { |
|
2456 selectee.$element.removeClass('ui-selected'); |
|
2457 selectee.selected = false; |
|
2458 selectee.$element.addClass('ui-unselecting'); |
|
2459 selectee.unselecting = true; |
|
2460 // selectable UNSELECTING callback |
|
2461 self._trigger("unselecting", event, { |
|
2462 unselecting: selectee.element |
|
2463 }); |
|
2464 } |
|
2465 }); |
|
2466 |
|
2467 $(event.target).parents().andSelf().each(function() { |
|
2468 var selectee = $.data(this, "selectable-item"); |
|
2469 if (selectee) { |
|
2470 selectee.$element.removeClass("ui-unselecting").addClass('ui-selecting'); |
|
2471 selectee.unselecting = false; |
|
2472 selectee.selecting = true; |
|
2473 selectee.selected = true; |
|
2474 // selectable SELECTING callback |
|
2475 self._trigger("selecting", event, { |
|
2476 selecting: selectee.element |
|
2477 }); |
|
2478 return false; |
|
2479 } |
|
2480 }); |
|
2481 |
|
2482 }, |
|
2483 |
|
2484 _mouseDrag: function(event) { |
|
2485 var self = this; |
|
2486 this.dragged = true; |
|
2487 |
|
2488 if (this.options.disabled) |
|
2489 return; |
|
2490 |
|
2491 var options = this.options; |
|
2492 |
|
2493 var x1 = this.opos[0], y1 = this.opos[1], x2 = event.pageX, y2 = event.pageY; |
|
2494 if (x1 > x2) { var tmp = x2; x2 = x1; x1 = tmp; } |
|
2495 if (y1 > y2) { var tmp = y2; y2 = y1; y1 = tmp; } |
|
2496 this.helper.css({left: x1, top: y1, width: x2-x1, height: y2-y1}); |
|
2497 |
|
2498 this.selectees.each(function() { |
|
2499 var selectee = $.data(this, "selectable-item"); |
|
2500 //prevent helper from being selected if appendTo: selectable |
|
2501 if (!selectee || selectee.element == self.element[0]) |
|
2502 return; |
|
2503 var hit = false; |
|
2504 if (options.tolerance == 'touch') { |
|
2505 hit = ( !(selectee.left > x2 || selectee.right < x1 || selectee.top > y2 || selectee.bottom < y1) ); |
|
2506 } else if (options.tolerance == 'fit') { |
|
2507 hit = (selectee.left > x1 && selectee.right < x2 && selectee.top > y1 && selectee.bottom < y2); |
|
2508 } |
|
2509 |
|
2510 if (hit) { |
|
2511 // SELECT |
|
2512 if (selectee.selected) { |
|
2513 selectee.$element.removeClass('ui-selected'); |
|
2514 selectee.selected = false; |
|
2515 } |
|
2516 if (selectee.unselecting) { |
|
2517 selectee.$element.removeClass('ui-unselecting'); |
|
2518 selectee.unselecting = false; |
|
2519 } |
|
2520 if (!selectee.selecting) { |
|
2521 selectee.$element.addClass('ui-selecting'); |
|
2522 selectee.selecting = true; |
|
2523 // selectable SELECTING callback |
|
2524 self._trigger("selecting", event, { |
|
2525 selecting: selectee.element |
|
2526 }); |
|
2527 } |
|
2528 } else { |
|
2529 // UNSELECT |
|
2530 if (selectee.selecting) { |
|
2531 if (event.metaKey && selectee.startselected) { |
|
2532 selectee.$element.removeClass('ui-selecting'); |
|
2533 selectee.selecting = false; |
|
2534 selectee.$element.addClass('ui-selected'); |
|
2535 selectee.selected = true; |
|
2536 } else { |
|
2537 selectee.$element.removeClass('ui-selecting'); |
|
2538 selectee.selecting = false; |
|
2539 if (selectee.startselected) { |
|
2540 selectee.$element.addClass('ui-unselecting'); |
|
2541 selectee.unselecting = true; |
|
2542 } |
|
2543 // selectable UNSELECTING callback |
|
2544 self._trigger("unselecting", event, { |
|
2545 unselecting: selectee.element |
|
2546 }); |
|
2547 } |
|
2548 } |
|
2549 if (selectee.selected) { |
|
2550 if (!event.metaKey && !selectee.startselected) { |
|
2551 selectee.$element.removeClass('ui-selected'); |
|
2552 selectee.selected = false; |
|
2553 |
|
2554 selectee.$element.addClass('ui-unselecting'); |
|
2555 selectee.unselecting = true; |
|
2556 // selectable UNSELECTING callback |
|
2557 self._trigger("unselecting", event, { |
|
2558 unselecting: selectee.element |
|
2559 }); |
|
2560 } |
|
2561 } |
|
2562 } |
|
2563 }); |
|
2564 |
|
2565 return false; |
|
2566 }, |
|
2567 |
|
2568 _mouseStop: function(event) { |
|
2569 var self = this; |
|
2570 |
|
2571 this.dragged = false; |
|
2572 |
|
2573 var options = this.options; |
|
2574 |
|
2575 $('.ui-unselecting', this.element[0]).each(function() { |
|
2576 var selectee = $.data(this, "selectable-item"); |
|
2577 selectee.$element.removeClass('ui-unselecting'); |
|
2578 selectee.unselecting = false; |
|
2579 selectee.startselected = false; |
|
2580 self._trigger("unselected", event, { |
|
2581 unselected: selectee.element |
|
2582 }); |
|
2583 }); |
|
2584 $('.ui-selecting', this.element[0]).each(function() { |
|
2585 var selectee = $.data(this, "selectable-item"); |
|
2586 selectee.$element.removeClass('ui-selecting').addClass('ui-selected'); |
|
2587 selectee.selecting = false; |
|
2588 selectee.selected = true; |
|
2589 selectee.startselected = true; |
|
2590 self._trigger("selected", event, { |
|
2591 selected: selectee.element |
|
2592 }); |
|
2593 }); |
|
2594 this._trigger("stop", event); |
|
2595 |
|
2596 this.helper.remove(); |
|
2597 |
|
2598 return false; |
|
2599 } |
|
2600 |
|
2601 })); |
|
2602 |
|
2603 $.extend($.ui.selectable, { |
|
2604 version: "1.6rc6", |
|
2605 defaults: { |
|
2606 appendTo: 'body', |
|
2607 autoRefresh: true, |
|
2608 cancel: ":input,option", |
|
2609 delay: 0, |
|
2610 distance: 0, |
|
2611 filter: '*', |
|
2612 tolerance: 'touch' |
|
2613 } |
|
2614 }); |
|
2615 |
|
2616 })(jQuery); |
|
2617 /* |
|
2618 * jQuery UI Sortable 1.6rc6 |
|
2619 * |
|
2620 * Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about) |
|
2621 * Dual licensed under the MIT (MIT-LICENSE.txt) |
|
2622 * and GPL (GPL-LICENSE.txt) licenses. |
|
2623 * |
|
2624 * http://docs.jquery.com/UI/Sortables |
|
2625 * |
|
2626 * Depends: |
|
2627 * ui.core.js |
|
2628 */ |
|
2629 (function($) { |
|
2630 |
|
2631 $.widget("ui.sortable", $.extend({}, $.ui.mouse, { |
|
2632 _init: function() { |
|
2633 |
|
2634 var o = this.options; |
|
2635 this.containerCache = {}; |
|
2636 (this.options.cssNamespace && this.element.addClass(this.options.cssNamespace+"-sortable")); |
|
2637 |
|
2638 //Get the items |
|
2639 this.refresh(); |
|
2640 |
|
2641 //Let's determine if the items are floating |
|
2642 this.floating = this.items.length ? (/left|right/).test(this.items[0].item.css('float')) : false; |
|
2643 |
|
2644 //Let's determine the parent's offset |
|
2645 this.offset = this.element.offset(); |
|
2646 |
|
2647 //Initialize mouse events for interaction |
|
2648 this._mouseInit(); |
|
2649 |
|
2650 }, |
|
2651 |
|
2652 destroy: function() { |
|
2653 this.element |
|
2654 .removeClass(this.options.cssNamespace+"-sortable "+this.options.cssNamespace+"-sortable-disabled") |
|
2655 .removeData("sortable") |
|
2656 .unbind(".sortable"); |
|
2657 this._mouseDestroy(); |
|
2658 |
|
2659 for ( var i = this.items.length - 1; i >= 0; i-- ) |
|
2660 this.items[i].item.removeData("sortable-item"); |
|
2661 }, |
|
2662 |
|
2663 _mouseCapture: function(event, overrideHandle) { |
|
2664 |
|
2665 if (this.reverting) { |
|
2666 return false; |
|
2667 } |
|
2668 |
|
2669 if(this.options.disabled || this.options.type == 'static') return false; |
|
2670 |
|
2671 //We have to refresh the items data once first |
|
2672 this._refreshItems(event); |
|
2673 |
|
2674 //Find out if the clicked node (or one of its parents) is a actual item in this.items |
|
2675 var currentItem = null, self = this, nodes = $(event.target).parents().each(function() { |
|
2676 if($.data(this, 'sortable-item') == self) { |
|
2677 currentItem = $(this); |
|
2678 return false; |
|
2679 } |
|
2680 }); |
|
2681 if($.data(event.target, 'sortable-item') == self) currentItem = $(event.target); |
|
2682 |
|
2683 if(!currentItem) return false; |
|
2684 if(this.options.handle && !overrideHandle) { |
|
2685 var validHandle = false; |
|
2686 |
|
2687 $(this.options.handle, currentItem).find("*").andSelf().each(function() { if(this == event.target) validHandle = true; }); |
|
2688 if(!validHandle) return false; |
|
2689 } |
|
2690 |
|
2691 this.currentItem = currentItem; |
|
2692 this._removeCurrentsFromItems(); |
|
2693 return true; |
|
2694 |
|
2695 }, |
|
2696 |
|
2697 _mouseStart: function(event, overrideHandle, noActivation) { |
|
2698 |
|
2699 var o = this.options, self = this; |
|
2700 this.currentContainer = this; |
|
2701 |
|
2702 //We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture |
|
2703 this.refreshPositions(); |
|
2704 |
|
2705 //Create and append the visible helper |
|
2706 this.helper = this._createHelper(event); |
|
2707 |
|
2708 //Cache the helper size |
|
2709 this._cacheHelperProportions(); |
|
2710 |
|
2711 /* |
|
2712 * - Position generation - |
|
2713 * This block generates everything position related - it's the core of draggables. |
|
2714 */ |
|
2715 |
|
2716 //Cache the margins of the original element |
|
2717 this._cacheMargins(); |
|
2718 |
|
2719 //Get the next scrolling parent |
|
2720 this.scrollParent = this.helper.scrollParent(); |
|
2721 |
|
2722 //The element's absolute position on the page minus margins |
|
2723 this.offset = this.currentItem.offset(); |
|
2724 this.offset = { |
|
2725 top: this.offset.top - this.margins.top, |
|
2726 left: this.offset.left - this.margins.left |
|
2727 }; |
|
2728 |
|
2729 // Only after we got the offset, we can change the helper's position to absolute |
|
2730 // TODO: Still need to figure out a way to make relative sorting possible |
|
2731 this.helper.css("position", "absolute"); |
|
2732 this.cssPosition = this.helper.css("position"); |
|
2733 |
|
2734 $.extend(this.offset, { |
|
2735 click: { //Where the click happened, relative to the element |
|
2736 left: event.pageX - this.offset.left, |
|
2737 top: event.pageY - this.offset.top |
|
2738 }, |
|
2739 parent: this._getParentOffset(), |
|
2740 relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper |
|
2741 }); |
|
2742 |
|
2743 //Generate the original position |
|
2744 this.originalPosition = this._generatePosition(event); |
|
2745 this.originalPageX = event.pageX; |
|
2746 this.originalPageY = event.pageY; |
|
2747 |
|
2748 //Adjust the mouse offset relative to the helper if 'cursorAt' is supplied |
|
2749 if(o.cursorAt) |
|
2750 this._adjustOffsetFromHelper(o.cursorAt); |
|
2751 |
|
2752 //Cache the former DOM position |
|
2753 this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] }; |
|
2754 |
|
2755 //If the helper is not the original, hide the original so it's not playing any role during the drag, won't cause anything bad this way |
|
2756 if(this.helper[0] != this.currentItem[0]) { |
|
2757 this.currentItem.hide(); |
|
2758 } |
|
2759 |
|
2760 //Create the placeholder |
|
2761 this._createPlaceholder(); |
|
2762 |
|
2763 //Set a containment if given in the options |
|
2764 if(o.containment) |
|
2765 this._setContainment(); |
|
2766 |
|
2767 if(o.cursor) { // cursor option |
|
2768 if ($('body').css("cursor")) this._storedCursor = $('body').css("cursor"); |
|
2769 $('body').css("cursor", o.cursor); |
|
2770 } |
|
2771 |
|
2772 if(o.opacity) { // opacity option |
|
2773 if (this.helper.css("opacity")) this._storedOpacity = this.helper.css("opacity"); |
|
2774 this.helper.css("opacity", o.opacity); |
|
2775 } |
|
2776 |
|
2777 if(o.zIndex) { // zIndex option |
|
2778 if (this.helper.css("zIndex")) this._storedZIndex = this.helper.css("zIndex"); |
|
2779 this.helper.css("zIndex", o.zIndex); |
|
2780 } |
|
2781 |
|
2782 //Prepare scrolling |
|
2783 if(this.scrollParent[0] != document && this.scrollParent[0].tagName != 'HTML') |
|
2784 this.overflowOffset = this.scrollParent.offset(); |
|
2785 |
|
2786 //Call callbacks |
|
2787 this._trigger("start", event, this._uiHash()); |
|
2788 |
|
2789 //Recache the helper size |
|
2790 if(!this._preserveHelperProportions) |
|
2791 this._cacheHelperProportions(); |
|
2792 |
|
2793 |
|
2794 //Post 'activate' events to possible containers |
|
2795 if(!noActivation) { |
|
2796 for (var i = this.containers.length - 1; i >= 0; i--) { this.containers[i]._trigger("activate", event, self._uiHash(this)); } |
|
2797 } |
|
2798 |
|
2799 //Prepare possible droppables |
|
2800 if($.ui.ddmanager) |
|
2801 $.ui.ddmanager.current = this; |
|
2802 |
|
2803 if ($.ui.ddmanager && !o.dropBehaviour) |
|
2804 $.ui.ddmanager.prepareOffsets(this, event); |
|
2805 |
|
2806 this.dragging = true; |
|
2807 |
|
2808 this.helper.addClass(o.cssNamespace+'-sortable-helper'); |
|
2809 this._mouseDrag(event); //Execute the drag once - this causes the helper not to be visible before getting its correct position |
|
2810 return true; |
|
2811 |
|
2812 }, |
|
2813 |
|
2814 _mouseDrag: function(event) { |
|
2815 |
|
2816 //Compute the helpers position |
|
2817 this.position = this._generatePosition(event); |
|
2818 this.positionAbs = this._convertPositionTo("absolute"); |
|
2819 |
|
2820 if (!this.lastPositionAbs) { |
|
2821 this.lastPositionAbs = this.positionAbs; |
|
2822 } |
|
2823 |
|
2824 //Do scrolling |
|
2825 if(this.options.scroll) { |
|
2826 var o = this.options, scrolled = false; |
|
2827 if(this.scrollParent[0] != document && this.scrollParent[0].tagName != 'HTML') { |
|
2828 |
|
2829 if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) |
|
2830 this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed; |
|
2831 else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity) |
|
2832 this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed; |
|
2833 |
|
2834 if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) |
|
2835 this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed; |
|
2836 else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity) |
|
2837 this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed; |
|
2838 |
|
2839 } else { |
|
2840 |
|
2841 if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) |
|
2842 scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed); |
|
2843 else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) |
|
2844 scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed); |
|
2845 |
|
2846 if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) |
|
2847 scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed); |
|
2848 else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) |
|
2849 scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed); |
|
2850 |
|
2851 } |
|
2852 |
|
2853 if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) |
|
2854 $.ui.ddmanager.prepareOffsets(this, event); |
|
2855 } |
|
2856 |
|
2857 //Regenerate the absolute position used for position checks |
|
2858 this.positionAbs = this._convertPositionTo("absolute"); |
|
2859 |
|
2860 //Set the helper position |
|
2861 if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px'; |
|
2862 if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px'; |
|
2863 |
|
2864 //Rearrange |
|
2865 for (var i = this.items.length - 1; i >= 0; i--) { |
|
2866 |
|
2867 //Cache variables and intersection, continue if no intersection |
|
2868 var item = this.items[i], itemElement = item.item[0], intersection = this._intersectsWithPointer(item); |
|
2869 if (!intersection) continue; |
|
2870 |
|
2871 if(itemElement != this.currentItem[0] //cannot intersect with itself |
|
2872 && this.placeholder[intersection == 1 ? "next" : "prev"]()[0] != itemElement //no useless actions that have been done before |
|
2873 && !$.ui.contains(this.placeholder[0], itemElement) //no action if the item moved is the parent of the item checked |
|
2874 && (this.options.type == 'semi-dynamic' ? !$.ui.contains(this.element[0], itemElement) : true) |
|
2875 ) { |
|
2876 |
|
2877 this.direction = intersection == 1 ? "down" : "up"; |
|
2878 |
|
2879 if (this.options.tolerance == "pointer" || this._intersectsWithSides(item)) { |
|
2880 this.options.sortIndicator.call(this, event, item); |
|
2881 } else { |
|
2882 break; |
|
2883 } |
|
2884 |
|
2885 this._trigger("change", event, this._uiHash()); |
|
2886 break; |
|
2887 } |
|
2888 } |
|
2889 |
|
2890 //Post events to containers |
|
2891 this._contactContainers(event); |
|
2892 |
|
2893 //Interconnect with droppables |
|
2894 if($.ui.ddmanager) $.ui.ddmanager.drag(this, event); |
|
2895 |
|
2896 //Call callbacks |
|
2897 this._trigger('sort', event, this._uiHash()); |
|
2898 |
|
2899 this.lastPositionAbs = this.positionAbs; |
|
2900 return false; |
|
2901 |
|
2902 }, |
|
2903 |
|
2904 _mouseStop: function(event, noPropagation) { |
|
2905 |
|
2906 if(!event) return; |
|
2907 |
|
2908 //If we are using droppables, inform the manager about the drop |
|
2909 if ($.ui.ddmanager && !this.options.dropBehaviour) |
|
2910 $.ui.ddmanager.drop(this, event); |
|
2911 |
|
2912 if(this.options.revert) { |
|
2913 var self = this; |
|
2914 var cur = self.placeholder.offset(); |
|
2915 |
|
2916 self.reverting = true; |
|
2917 |
|
2918 $(this.helper).animate({ |
|
2919 left: cur.left - this.offset.parent.left - self.margins.left + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollLeft), |
|
2920 top: cur.top - this.offset.parent.top - self.margins.top + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollTop) |
|
2921 }, parseInt(this.options.revert, 10) || 500, function() { |
|
2922 self._clear(event); |
|
2923 }); |
|
2924 } else { |
|
2925 this._clear(event, noPropagation); |
|
2926 } |
|
2927 |
|
2928 return false; |
|
2929 |
|
2930 }, |
|
2931 |
|
2932 cancel: function() { |
|
2933 |
|
2934 var self = this; |
|
2935 |
|
2936 if(this.dragging) { |
|
2937 |
|
2938 this._mouseUp(); |
|
2939 |
|
2940 if(this.options.helper == "original") |
|
2941 this.currentItem.css(this._storedCSS).removeClass(this.options.cssNamespace+"-sortable-helper"); |
|
2942 else |
|
2943 this.currentItem.show(); |
|
2944 |
|
2945 //Post deactivating events to containers |
|
2946 for (var i = this.containers.length - 1; i >= 0; i--){ |
|
2947 this.containers[i]._trigger("deactivate", null, self._uiHash(this)); |
|
2948 if(this.containers[i].containerCache.over) { |
|
2949 this.containers[i]._trigger("out", null, self._uiHash(this)); |
|
2950 this.containers[i].containerCache.over = 0; |
|
2951 } |
|
2952 } |
|
2953 |
|
2954 } |
|
2955 |
|
2956 //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node! |
|
2957 if(this.placeholder[0].parentNode) this.placeholder[0].parentNode.removeChild(this.placeholder[0]); |
|
2958 if(this.options.helper != "original" && this.helper && this.helper[0].parentNode) this.helper.remove(); |
|
2959 |
|
2960 $.extend(this, { |
|
2961 helper: null, |
|
2962 dragging: false, |
|
2963 reverting: false, |
|
2964 _noFinalSort: null |
|
2965 }); |
|
2966 |
|
2967 if(this.domPosition.prev) { |
|
2968 $(this.domPosition.prev).after(this.currentItem); |
|
2969 } else { |
|
2970 $(this.domPosition.parent).prepend(this.currentItem); |
|
2971 } |
|
2972 |
|
2973 return true; |
|
2974 |
|
2975 }, |
|
2976 |
|
2977 serialize: function(o) { |
|
2978 |
|
2979 var items = this._getItemsAsjQuery(o && o.connected); |
|
2980 var str = []; o = o || {}; |
|
2981 |
|
2982 $(items).each(function() { |
|
2983 var res = ($(o.item || this).attr(o.attribute || 'id') || '').match(o.expression || (/(.+)[-=_](.+)/)); |
|
2984 if(res) str.push((o.key || res[1]+'[]')+'='+(o.key && o.expression ? res[1] : res[2])); |
|
2985 }); |
|
2986 |
|
2987 return str.join('&'); |
|
2988 |
|
2989 }, |
|
2990 |
|
2991 toArray: function(o) { |
|
2992 |
|
2993 var items = this._getItemsAsjQuery(o && o.connected); |
|
2994 var ret = []; o = o || {}; |
|
2995 |
|
2996 items.each(function() { ret.push($(o.item || this).attr(o.attribute || 'id') || ''); }); |
|
2997 return ret; |
|
2998 |
|
2999 }, |
|
3000 |
|
3001 /* Be careful with the following core functions */ |
|
3002 _intersectsWith: function(item) { |
|
3003 |
|
3004 var x1 = this.positionAbs.left, |
|
3005 x2 = x1 + this.helperProportions.width, |
|
3006 y1 = this.positionAbs.top, |
|
3007 y2 = y1 + this.helperProportions.height; |
|
3008 |
|
3009 var l = item.left, |
|
3010 r = l + item.width, |
|
3011 t = item.top, |
|
3012 b = t + item.height; |
|
3013 |
|
3014 var dyClick = this.offset.click.top, |
|
3015 dxClick = this.offset.click.left; |
|
3016 |
|
3017 var isOverElement = (y1 + dyClick) > t && (y1 + dyClick) < b && (x1 + dxClick) > l && (x1 + dxClick) < r; |
|
3018 |
|
3019 if( this.options.tolerance == "pointer" |
|
3020 || this.options.forcePointerForContainers |
|
3021 || (this.options.tolerance != "pointer" && this.helperProportions[this.floating ? 'width' : 'height'] > item[this.floating ? 'width' : 'height']) |
|
3022 ) { |
|
3023 return isOverElement; |
|
3024 } else { |
|
3025 |
|
3026 return (l < x1 + (this.helperProportions.width / 2) // Right Half |
|
3027 && x2 - (this.helperProportions.width / 2) < r // Left Half |
|
3028 && t < y1 + (this.helperProportions.height / 2) // Bottom Half |
|
3029 && y2 - (this.helperProportions.height / 2) < b ); // Top Half |
|
3030 |
|
3031 } |
|
3032 }, |
|
3033 |
|
3034 _intersectsWithPointer: function(item) { |
|
3035 |
|
3036 var isOverElementHeight = $.ui.isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height), |
|
3037 isOverElementWidth = $.ui.isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width), |
|
3038 isOverElement = isOverElementHeight && isOverElementWidth, |
|
3039 verticalDirection = this._getDragVerticalDirection(), |
|
3040 horizontalDirection = this._getDragHorizontalDirection(); |
|
3041 |
|
3042 if (!isOverElement) |
|
3043 return false; |
|
3044 |
|
3045 return this.floating ? |
|
3046 ( ((horizontalDirection && horizontalDirection == "right") || verticalDirection == "down") ? 2 : 1 ) |
|
3047 : ( verticalDirection && (verticalDirection == "down" ? 2 : 1) ); |
|
3048 |
|
3049 }, |
|
3050 |
|
3051 _intersectsWithSides: function(item) { |
|
3052 |
|
3053 var isOverBottomHalf = $.ui.isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height), |
|
3054 isOverRightHalf = $.ui.isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width), |
|
3055 verticalDirection = this._getDragVerticalDirection(), |
|
3056 horizontalDirection = this._getDragHorizontalDirection(); |
|
3057 |
|
3058 if (this.floating && horizontalDirection) { |
|
3059 return ((horizontalDirection == "right" && isOverRightHalf) || (horizontalDirection == "left" && !isOverRightHalf)); |
|
3060 } else { |
|
3061 return verticalDirection && ((verticalDirection == "down" && isOverBottomHalf) || (verticalDirection == "up" && !isOverBottomHalf)); |
|
3062 } |
|
3063 |
|
3064 }, |
|
3065 |
|
3066 _getDragVerticalDirection: function() { |
|
3067 var delta = this.positionAbs.top - this.lastPositionAbs.top; |
|
3068 return delta != 0 && (delta > 0 ? "down" : "up"); |
|
3069 }, |
|
3070 |
|
3071 _getDragHorizontalDirection: function() { |
|
3072 var delta = this.positionAbs.left - this.lastPositionAbs.left; |
|
3073 return delta != 0 && (delta > 0 ? "right" : "left"); |
|
3074 }, |
|
3075 |
|
3076 refresh: function(event) { |
|
3077 this._refreshItems(event); |
|
3078 this.refreshPositions(); |
|
3079 }, |
|
3080 |
|
3081 _getItemsAsjQuery: function(connected) { |
|
3082 |
|
3083 var self = this; |
|
3084 var items = []; |
|
3085 var queries = []; |
|
3086 |
|
3087 if(this.options.connectWith && connected) { |
|
3088 var connectWith = this.options.connectWith.constructor == String ? [this.options.connectWith] : this.options.connectWith; |
|
3089 for (var i = connectWith.length - 1; i >= 0; i--){ |
|
3090 var cur = $(connectWith[i]); |
|
3091 for (var j = cur.length - 1; j >= 0; j--){ |
|
3092 var inst = $.data(cur[j], 'sortable'); |
|
3093 if(inst && inst != this && !inst.options.disabled) { |
|
3094 queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element) : $(inst.options.items, inst.element).not("."+inst.options.cssNamespace+"-sortable-helper"), inst]); |
|
3095 } |
|
3096 }; |
|
3097 }; |
|
3098 } |
|
3099 |
|
3100 queries.push([$.isFunction(this.options.items) ? this.options.items.call(this.element, null, { options: this.options, item: this.currentItem }) : $(this.options.items, this.element).not("."+this.options.cssNamespace+"-sortable-helper"), this]); |
|
3101 |
|
3102 for (var i = queries.length - 1; i >= 0; i--){ |
|
3103 queries[i][0].each(function() { |
|
3104 items.push(this); |
|
3105 }); |
|
3106 }; |
|
3107 |
|
3108 return $(items); |
|
3109 |
|
3110 }, |
|
3111 |
|
3112 _removeCurrentsFromItems: function() { |
|
3113 |
|
3114 var list = this.currentItem.find(":data(sortable-item)"); |
|
3115 |
|
3116 for (var i=0; i < this.items.length; i++) { |
|
3117 |
|
3118 for (var j=0; j < list.length; j++) { |
|
3119 if(list[j] == this.items[i].item[0]) |
|
3120 this.items.splice(i,1); |
|
3121 }; |
|
3122 |
|
3123 }; |
|
3124 |
|
3125 }, |
|
3126 |
|
3127 _refreshItems: function(event) { |
|
3128 |
|
3129 this.items = []; |
|
3130 this.containers = [this]; |
|
3131 var items = this.items; |
|
3132 var self = this; |
|
3133 var queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]]; |
|
3134 |
|
3135 if(this.options.connectWith) { |
|
3136 for (var i = this.options.connectWith.length - 1; i >= 0; i--){ |
|
3137 var cur = $(this.options.connectWith[i]); |
|
3138 for (var j = cur.length - 1; j >= 0; j--){ |
|
3139 var inst = $.data(cur[j], 'sortable'); |
|
3140 if(inst && inst != this && !inst.options.disabled) { |
|
3141 queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]); |
|
3142 this.containers.push(inst); |
|
3143 } |
|
3144 }; |
|
3145 }; |
|
3146 } |
|
3147 |
|
3148 for (var i = queries.length - 1; i >= 0; i--) { |
|
3149 var targetData = queries[i][1]; |
|
3150 var _queries = queries[i][0]; |
|
3151 |
|
3152 for (var j=0, queriesLength = _queries.length; j < queriesLength; j++) { |
|
3153 var item = $(_queries[j]); |
|
3154 |
|
3155 item.data('sortable-item', targetData); // Data for target checking (mouse manager) |
|
3156 |
|
3157 items.push({ |
|
3158 item: item, |
|
3159 instance: targetData, |
|
3160 width: 0, height: 0, |
|
3161 left: 0, top: 0 |
|
3162 }); |
|
3163 }; |
|
3164 }; |
|
3165 |
|
3166 }, |
|
3167 |
|
3168 refreshPositions: function(fast) { |
|
3169 |
|
3170 //This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change |
|
3171 if(this.offsetParent && this.helper) { |
|
3172 this.offset.parent = this._getParentOffset(); |
|
3173 } |
|
3174 |
|
3175 for (var i = this.items.length - 1; i >= 0; i--){ |
|
3176 var item = this.items[i]; |
|
3177 |
|
3178 //We ignore calculating positions of all connected containers when we're not over them |
|
3179 if(item.instance != this.currentContainer && this.currentContainer && item.item[0] != this.currentItem[0]) |
|
3180 continue; |
|
3181 |
|
3182 var t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item; |
|
3183 |
|
3184 if (!fast) { |
|
3185 if (this.options.accurateIntersection) { |
|
3186 item.width = t.outerWidth(); |
|
3187 item.height = t.outerHeight(); |
|
3188 } |
|
3189 else { |
|
3190 item.width = t[0].offsetWidth; |
|
3191 item.height = t[0].offsetHeight; |
|
3192 } |
|
3193 } |
|
3194 |
|
3195 var p = t.offset(); |
|
3196 item.left = p.left; |
|
3197 item.top = p.top; |
|
3198 }; |
|
3199 |
|
3200 if(this.options.custom && this.options.custom.refreshContainers) { |
|
3201 this.options.custom.refreshContainers.call(this); |
|
3202 } else { |
|
3203 for (var i = this.containers.length - 1; i >= 0; i--){ |
|
3204 var p = this.containers[i].element.offset(); |
|
3205 this.containers[i].containerCache.left = p.left; |
|
3206 this.containers[i].containerCache.top = p.top; |
|
3207 this.containers[i].containerCache.width = this.containers[i].element.outerWidth(); |
|
3208 this.containers[i].containerCache.height = this.containers[i].element.outerHeight(); |
|
3209 }; |
|
3210 } |
|
3211 |
|
3212 }, |
|
3213 |
|
3214 _createPlaceholder: function(that) { |
|
3215 |
|
3216 var self = that || this, o = self.options; |
|
3217 |
|
3218 if(!o.placeholder || o.placeholder.constructor == String) { |
|
3219 var className = o.placeholder; |
|
3220 o.placeholder = { |
|
3221 element: function() { |
|
3222 |
|
3223 var el = $(document.createElement(self.currentItem[0].nodeName)) |
|
3224 .addClass(className || self.currentItem[0].className+" "+self.options.cssNamespace+"-sortable-placeholder") |
|
3225 .removeClass(self.options.cssNamespace+'-sortable-helper')[0]; |
|
3226 |
|
3227 if(!className) |
|
3228 el.style.visibility = "hidden"; |
|
3229 |
|
3230 return el; |
|
3231 }, |
|
3232 update: function(container, p) { |
|
3233 |
|
3234 // 1. If a className is set as 'placeholder option, we don't force sizes - the class is responsible for that |
|
3235 // 2. The option 'forcePlaceholderSize can be enabled to force it even if a class name is specified |
|
3236 if(className && !o.forcePlaceholderSize) return; |
|
3237 |
|
3238 //If the element doesn't have a actual height by itself (without styles coming from a stylesheet), it receives the inline height from the dragged item |
|
3239 if(!p.height()) { p.height(self.currentItem.innerHeight() - parseInt(self.currentItem.css('paddingTop')||0, 10) - parseInt(self.currentItem.css('paddingBottom')||0, 10)); }; |
|
3240 if(!p.width()) { p.width(self.currentItem.innerWidth() - parseInt(self.currentItem.css('paddingLeft')||0, 10) - parseInt(self.currentItem.css('paddingRight')||0, 10)); }; |
|
3241 } |
|
3242 }; |
|
3243 } |
|
3244 |
|
3245 //Create the placeholder |
|
3246 self.placeholder = $(o.placeholder.element.call(self.element, self.currentItem)); |
|
3247 |
|
3248 //Append it after the actual current item |
|
3249 self.currentItem.after(self.placeholder); |
|
3250 |
|
3251 //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317) |
|
3252 o.placeholder.update(self, self.placeholder); |
|
3253 |
|
3254 }, |
|
3255 |
|
3256 _contactContainers: function(event) { |
|
3257 for (var i = this.containers.length - 1; i >= 0; i--){ |
|
3258 |
|
3259 if(this._intersectsWith(this.containers[i].containerCache)) { |
|
3260 if(!this.containers[i].containerCache.over) { |
|
3261 |
|
3262 if(this.currentContainer != this.containers[i]) { |
|
3263 |
|
3264 //When entering a new container, we will find the item with the least distance and append our item near it |
|
3265 var dist = 10000; var itemWithLeastDistance = null; var base = this.positionAbs[this.containers[i].floating ? 'left' : 'top']; |
|
3266 for (var j = this.items.length - 1; j >= 0; j--) { |
|
3267 if(!$.ui.contains(this.containers[i].element[0], this.items[j].item[0])) continue; |
|
3268 var cur = this.items[j][this.containers[i].floating ? 'left' : 'top']; |
|
3269 if(Math.abs(cur - base) < dist) { |
|
3270 dist = Math.abs(cur - base); itemWithLeastDistance = this.items[j]; |
|
3271 } |
|
3272 } |
|
3273 |
|
3274 if(!itemWithLeastDistance && !this.options.dropOnEmpty) //Check if dropOnEmpty is enabled |
|
3275 continue; |
|
3276 |
|
3277 this.currentContainer = this.containers[i]; |
|
3278 itemWithLeastDistance ? this.options.sortIndicator.call(this, event, itemWithLeastDistance, null, true) : this.options.sortIndicator.call(this, event, null, this.containers[i].element, true); |
|
3279 this._trigger("change", event, this._uiHash()); |
|
3280 this.containers[i]._trigger("change", event, this._uiHash(this)); |
|
3281 |
|
3282 //Update the placeholder |
|
3283 this.options.placeholder.update(this.currentContainer, this.placeholder); |
|
3284 |
|
3285 } |
|
3286 |
|
3287 this.containers[i]._trigger("over", event, this._uiHash(this)); |
|
3288 this.containers[i].containerCache.over = 1; |
|
3289 } |
|
3290 } else { |
|
3291 if(this.containers[i].containerCache.over) { |
|
3292 this.containers[i]._trigger("out", event, this._uiHash(this)); |
|
3293 this.containers[i].containerCache.over = 0; |
|
3294 } |
|
3295 } |
|
3296 |
|
3297 }; |
|
3298 }, |
|
3299 |
|
3300 _createHelper: function(event) { |
|
3301 |
|
3302 var o = this.options; |
|
3303 var helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event, this.currentItem])) : (o.helper == 'clone' ? this.currentItem.clone() : this.currentItem); |
|
3304 |
|
3305 if(!helper.parents('body').length) //Add the helper to the DOM if that didn't happen already |
|
3306 $(o.appendTo != 'parent' ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]); |
|
3307 |
|
3308 if(helper[0] == this.currentItem[0]) |
|
3309 this._storedCSS = { width: this.currentItem[0].style.width, height: this.currentItem[0].style.height, position: this.currentItem.css("position"), top: this.currentItem.css("top"), left: this.currentItem.css("left") }; |
|
3310 |
|
3311 if(helper[0].style.width == '' || o.forceHelperSize) helper.width(this.currentItem.width()); |
|
3312 if(helper[0].style.height == '' || o.forceHelperSize) helper.height(this.currentItem.height()); |
|
3313 |
|
3314 return helper; |
|
3315 |
|
3316 }, |
|
3317 |
|
3318 _adjustOffsetFromHelper: function(obj) { |
|
3319 if(obj.left != undefined) this.offset.click.left = obj.left + this.margins.left; |
|
3320 if(obj.right != undefined) this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left; |
|
3321 if(obj.top != undefined) this.offset.click.top = obj.top + this.margins.top; |
|
3322 if(obj.bottom != undefined) this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top; |
|
3323 }, |
|
3324 |
|
3325 _getParentOffset: function() { |
|
3326 |
|
3327 |
|
3328 //Get the offsetParent and cache its position |
|
3329 this.offsetParent = this.helper.offsetParent(); |
|
3330 var po = this.offsetParent.offset(); |
|
3331 |
|
3332 // This is a special case where we need to modify a offset calculated on start, since the following happened: |
|
3333 // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent |
|
3334 // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that |
|
3335 // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag |
|
3336 if(this.cssPosition == 'absolute' && this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) { |
|
3337 po.left += this.scrollParent.scrollLeft(); |
|
3338 po.top += this.scrollParent.scrollTop(); |
|
3339 } |
|
3340 |
|
3341 if((this.offsetParent[0] == document.body && $.browser.mozilla) //Ugly FF3 fix |
|
3342 || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() == 'html' && $.browser.msie)) //Ugly IE fix |
|
3343 po = { top: 0, left: 0 }; |
|
3344 |
|
3345 return { |
|
3346 top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0), |
|
3347 left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0) |
|
3348 }; |
|
3349 |
|
3350 }, |
|
3351 |
|
3352 _getRelativeOffset: function() { |
|
3353 |
|
3354 if(this.cssPosition == "relative") { |
|
3355 var p = this.currentItem.position(); |
|
3356 return { |
|
3357 top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(), |
|
3358 left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft() |
|
3359 }; |
|
3360 } else { |
|
3361 return { top: 0, left: 0 }; |
|
3362 } |
|
3363 |
|
3364 }, |
|
3365 |
|
3366 _cacheMargins: function() { |
|
3367 this.margins = { |
|
3368 left: (parseInt(this.currentItem.css("marginLeft"),10) || 0), |
|
3369 top: (parseInt(this.currentItem.css("marginTop"),10) || 0) |
|
3370 }; |
|
3371 }, |
|
3372 |
|
3373 _cacheHelperProportions: function() { |
|
3374 this.helperProportions = { |
|
3375 width: this.helper.outerWidth(), |
|
3376 height: this.helper.outerHeight() |
|
3377 }; |
|
3378 }, |
|
3379 |
|
3380 _setContainment: function() { |
|
3381 |
|
3382 var o = this.options; |
|
3383 if(o.containment == 'parent') o.containment = this.helper[0].parentNode; |
|
3384 if(o.containment == 'document' || o.containment == 'window') this.containment = [ |
|
3385 0 - this.offset.relative.left - this.offset.parent.left, |
|
3386 0 - this.offset.relative.top - this.offset.parent.top, |
|
3387 $(o.containment == 'document' ? document : window).width() - this.helperProportions.width - this.margins.left, |
|
3388 ($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top |
|
3389 ]; |
|
3390 |
|
3391 if(!(/^(document|window|parent)$/).test(o.containment)) { |
|
3392 var ce = $(o.containment)[0]; |
|
3393 var co = $(o.containment).offset(); |
|
3394 var over = ($(ce).css("overflow") != 'hidden'); |
|
3395 |
|
3396 this.containment = [ |
|
3397 co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left, |
|
3398 co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top, |
|
3399 co.left+(over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left, |
|
3400 co.top+(over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top |
|
3401 ]; |
|
3402 } |
|
3403 |
|
3404 }, |
|
3405 |
|
3406 _convertPositionTo: function(d, pos) { |
|
3407 |
|
3408 if(!pos) pos = this.position; |
|
3409 var mod = d == "absolute" ? 1 : -1; |
|
3410 var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName); |
|
3411 |
|
3412 return { |
|
3413 top: ( |
|
3414 pos.top // The absolute mouse position |
|
3415 + this.offset.relative.top * mod // Only for relative positioned nodes: Relative offset from element to offset parent |
|
3416 + this.offset.parent.top * mod // The offsetParent's offset without borders (offset + border) |
|
3417 - ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod |
|
3418 ), |
|
3419 left: ( |
|
3420 pos.left // The absolute mouse position |
|
3421 + this.offset.relative.left * mod // Only for relative positioned nodes: Relative offset from element to offset parent |
|
3422 + this.offset.parent.left * mod // The offsetParent's offset without borders (offset + border) |
|
3423 - ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod |
|
3424 ) |
|
3425 }; |
|
3426 |
|
3427 }, |
|
3428 |
|
3429 _generatePosition: function(event) { |
|
3430 |
|
3431 var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName); |
|
3432 |
|
3433 // This is another very weird special case that only happens for relative elements: |
|
3434 // 1. If the css position is relative |
|
3435 // 2. and the scroll parent is the document or similar to the offset parent |
|
3436 // we have to refresh the relative offset during the scroll so there are no jumps |
|
3437 if(this.cssPosition == 'relative' && !(this.scrollParent[0] != document && this.scrollParent[0] != this.offsetParent[0])) { |
|
3438 this.offset.relative = this._getRelativeOffset(); |
|
3439 } |
|
3440 |
|
3441 var pageX = event.pageX; |
|
3442 var pageY = event.pageY; |
|
3443 |
|
3444 /* |
|
3445 * - Position constraining - |
|
3446 * Constrain the position to a mix of grid, containment. |
|
3447 */ |
|
3448 |
|
3449 if(this.originalPosition) { //If we are not dragging yet, we won't check for options |
|
3450 |
|
3451 if(this.containment) { |
|
3452 if(event.pageX - this.offset.click.left < this.containment[0]) pageX = this.containment[0] + this.offset.click.left; |
|
3453 if(event.pageY - this.offset.click.top < this.containment[1]) pageY = this.containment[1] + this.offset.click.top; |
|
3454 if(event.pageX - this.offset.click.left > this.containment[2]) pageX = this.containment[2] + this.offset.click.left; |
|
3455 if(event.pageY - this.offset.click.top > this.containment[3]) pageY = this.containment[3] + this.offset.click.top; |
|
3456 } |
|
3457 |
|
3458 if(o.grid) { |
|
3459 var top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1]; |
|
3460 pageY = this.containment ? (!(top - this.offset.click.top < this.containment[1] || top - this.offset.click.top > this.containment[3]) ? top : (!(top - this.offset.click.top < this.containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top; |
|
3461 |
|
3462 var left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0]; |
|
3463 pageX = this.containment ? (!(left - this.offset.click.left < this.containment[0] || left - this.offset.click.left > this.containment[2]) ? left : (!(left - this.offset.click.left < this.containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left; |
|
3464 } |
|
3465 |
|
3466 } |
|
3467 |
|
3468 return { |
|
3469 top: ( |
|
3470 pageY // The absolute mouse position |
|
3471 - this.offset.click.top // Click offset (relative to the element) |
|
3472 - this.offset.relative.top // Only for relative positioned nodes: Relative offset from element to offset parent |
|
3473 - this.offset.parent.top // The offsetParent's offset without borders (offset + border) |
|
3474 + ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) |
|
3475 ), |
|
3476 left: ( |
|
3477 pageX // The absolute mouse position |
|
3478 - this.offset.click.left // Click offset (relative to the element) |
|
3479 - this.offset.relative.left // Only for relative positioned nodes: Relative offset from element to offset parent |
|
3480 - this.offset.parent.left // The offsetParent's offset without borders (offset + border) |
|
3481 + ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) |
|
3482 ) |
|
3483 }; |
|
3484 |
|
3485 }, |
|
3486 |
|
3487 _rearrange: function(event, i, a, hardRefresh) { |
|
3488 |
|
3489 a ? a[0].appendChild(this.placeholder[0]) : i.item[0].parentNode.insertBefore(this.placeholder[0], (this.direction == 'down' ? i.item[0] : i.item[0].nextSibling)); |
|
3490 |
|
3491 //Various things done here to improve the performance: |
|
3492 // 1. we create a setTimeout, that calls refreshPositions |
|
3493 // 2. on the instance, we have a counter variable, that get's higher after every append |
|
3494 // 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same |
|
3495 // 4. this lets only the last addition to the timeout stack through |
|
3496 this.counter = this.counter ? ++this.counter : 1; |
|
3497 var self = this, counter = this.counter; |
|
3498 |
|
3499 window.setTimeout(function() { |
|
3500 if(counter == self.counter) self.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove |
|
3501 },0); |
|
3502 |
|
3503 }, |
|
3504 |
|
3505 _clear: function(event, noPropagation) { |
|
3506 |
|
3507 this.reverting = false; |
|
3508 // We delay all events that have to be triggered to after the point where the placeholder has been removed and |
|
3509 // everything else normalized again |
|
3510 var delayedTriggers = [], self = this; |
|
3511 |
|
3512 //We first have to update the dom position of the actual currentItem |
|
3513 if(!this._noFinalSort) this.placeholder.before(this.currentItem); |
|
3514 this._noFinalSort = null; |
|
3515 |
|
3516 if(this.helper[0] == this.currentItem[0]) { |
|
3517 for(var i in this._storedCSS) { |
|
3518 if(this._storedCSS[i] == 'auto' || this._storedCSS[i] == 'static') this._storedCSS[i] = ''; |
|
3519 } |
|
3520 this.currentItem.css(this._storedCSS).removeClass(this.options.cssNamespace+"-sortable-helper"); |
|
3521 } else { |
|
3522 this.currentItem.show(); |
|
3523 } |
|
3524 |
|
3525 if(this.fromOutside && !noPropagation) delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); }); |
|
3526 if((this.fromOutside || this.domPosition.prev != this.currentItem.prev().not("."+this.options.cssNamespace+"-sortable-helper")[0] || this.domPosition.parent != this.currentItem.parent()[0]) && !noPropagation) delayedTriggers.push(function(event) { this._trigger("update", event, this._uiHash()); }); //Trigger update callback if the DOM position has changed |
|
3527 if(!$.ui.contains(this.element[0], this.currentItem[0])) { //Node was moved out of the current element |
|
3528 if(!noPropagation) delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); }); |
|
3529 for (var i = this.containers.length - 1; i >= 0; i--){ |
|
3530 if($.ui.contains(this.containers[i].element[0], this.currentItem[0]) && !noPropagation) { |
|
3531 delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); }; }).call(this, this.containers[i])); |
|
3532 delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this)); }; }).call(this, this.containers[i])); |
|
3533 } |
|
3534 }; |
|
3535 }; |
|
3536 |
|
3537 //Post events to containers |
|
3538 for (var i = this.containers.length - 1; i >= 0; i--){ |
|
3539 if(!noPropagation) delayedTriggers.push((function(c) { return function(event) { c._trigger("deactivate", event, this._uiHash(this)); }; }).call(this, this.containers[i])); |
|
3540 if(this.containers[i].containerCache.over) { |
|
3541 delayedTriggers.push((function(c) { return function(event) { c._trigger("out", event, this._uiHash(this)); }; }).call(this, this.containers[i])); |
|
3542 this.containers[i].containerCache.over = 0; |
|
3543 } |
|
3544 } |
|
3545 |
|
3546 //Do what was originally in plugins |
|
3547 if(this._storedCursor) $('body').css("cursor", this._storedCursor); //Reset cursor |
|
3548 if(this._storedOpacity) this.helper.css("opacity", this._storedCursor); //Reset cursor |
|
3549 if(this._storedZIndex) this.helper.css("zIndex", this._storedZIndex == 'auto' ? '' : this._storedZIndex); //Reset z-index |
|
3550 |
|
3551 this.dragging = false; |
|
3552 if(this.cancelHelperRemoval) { |
|
3553 if(!noPropagation) { |
|
3554 this._trigger("beforeStop", event, this._uiHash()); |
|
3555 for (var i=0; i < delayedTriggers.length; i++) { delayedTriggers[i].call(this, event); }; //Trigger all delayed events |
|
3556 this._trigger("stop", event, this._uiHash()); |
|
3557 } |
|
3558 return false; |
|
3559 } |
|
3560 |
|
3561 if(!noPropagation) this._trigger("beforeStop", event, this._uiHash()); |
|
3562 |
|
3563 //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node! |
|
3564 this.placeholder[0].parentNode.removeChild(this.placeholder[0]); |
|
3565 |
|
3566 if(this.helper[0] != this.currentItem[0]) this.helper.remove(); this.helper = null; |
|
3567 |
|
3568 if(!noPropagation) { |
|
3569 for (var i=0; i < delayedTriggers.length; i++) { delayedTriggers[i].call(this, event); }; //Trigger all delayed events |
|
3570 this._trigger("stop", event, this._uiHash()); |
|
3571 } |
|
3572 |
|
3573 this.fromOutside = false; |
|
3574 return true; |
|
3575 |
|
3576 }, |
|
3577 |
|
3578 _trigger: function() { |
|
3579 if ($.widget.prototype._trigger.apply(this, arguments) === false) { |
|
3580 this.cancel(); |
|
3581 } |
|
3582 }, |
|
3583 |
|
3584 _uiHash: function(inst) { |
|
3585 var self = inst || this; |
|
3586 return { |
|
3587 helper: self.helper, |
|
3588 placeholder: self.placeholder || $([]), |
|
3589 position: self.position, |
|
3590 absolutePosition: self.positionAbs, //deprecated |
|
3591 offset: self.positionAbs, |
|
3592 item: self.currentItem, |
|
3593 sender: inst ? inst.element : null |
|
3594 }; |
|
3595 } |
|
3596 |
|
3597 })); |
|
3598 |
|
3599 $.extend($.ui.sortable, { |
|
3600 getter: "serialize toArray", |
|
3601 version: "1.6rc6", |
|
3602 defaults: { |
|
3603 accurateIntersection: true, |
|
3604 appendTo: "parent", |
|
3605 cancel: ":input,option", |
|
3606 connectWith: false, |
|
3607 cssNamespace: 'ui', |
|
3608 delay: 0, |
|
3609 distance: 1, |
|
3610 dropOnEmpty: true, |
|
3611 forcePlaceholderSize: false, |
|
3612 forceHelperSize: false, |
|
3613 handle: false, |
|
3614 helper: "original", |
|
3615 items: '> *', |
|
3616 placeholder: false, |
|
3617 scope: "default", |
|
3618 scroll: true, |
|
3619 scrollSensitivity: 20, |
|
3620 scrollSpeed: 20, |
|
3621 sortIndicator: $.ui.sortable.prototype._rearrange, |
|
3622 tolerance: "intersect", |
|
3623 zIndex: 1000 |
|
3624 } |
|
3625 }); |
|
3626 |
|
3627 })(jQuery); |
|
3628 /* |
|
3629 * jQuery UI Accordion 1.6rc6 |
|
3630 * |
|
3631 * Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about) |
|
3632 * Dual licensed under the MIT (MIT-LICENSE.txt) |
|
3633 * and GPL (GPL-LICENSE.txt) licenses. |
|
3634 * |
|
3635 * http://docs.jquery.com/UI/Accordion |
|
3636 * |
|
3637 * Depends: |
|
3638 * ui.core.js |
|
3639 */ |
|
3640 (function($) { |
|
3641 |
|
3642 $.widget("ui.accordion", { |
|
3643 |
|
3644 _init: function() { |
|
3645 |
|
3646 var o = this.options, self = this; |
|
3647 this.running = 0; |
|
3648 |
|
3649 if ( o.navigation ) { |
|
3650 var current = this.element.find("a").filter(o.navigationFilter); |
|
3651 if ( current.length ) { |
|
3652 if ( current.filter(o.header).length ) { |
|
3653 this.active = current; |
|
3654 } else { |
|
3655 this.active = current.parent().parent().prev(); |
|
3656 current.addClass("ui-accordion-content-active"); |
|
3657 } |
|
3658 } |
|
3659 } |
|
3660 |
|
3661 this.element.addClass("ui-accordion ui-widget ui-helper-reset"); |
|
3662 |
|
3663 this.headers = this.element.find(o.header).addClass("ui-accordion-header ui-helper-reset ui-state-default ui-corner-all") |
|
3664 .bind("mouseenter.accordion", function(){ $(this).addClass('ui-state-hover'); }) |
|
3665 .bind("mouseleave.accordion", function(){ $(this).removeClass('ui-state-hover'); }); |
|
3666 |
|
3667 this.headers |
|
3668 .next() |
|
3669 .addClass("ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom"); |
|
3670 |
|
3671 this.active = this._findActive(this.active || o.active).toggleClass("ui-state-default").toggleClass("ui-state-active").toggleClass("ui-corner-all").toggleClass("ui-corner-top"); |
|
3672 this.active.next().addClass('ui-accordion-content-active'); |
|
3673 |
|
3674 //Append icon elements |
|
3675 $("<span/>").addClass("ui-icon " + o.icons.header).prependTo(this.headers); |
|
3676 this.active.find(".ui-icon").toggleClass(o.icons.header).toggleClass(o.icons.headerSelected); |
|
3677 |
|
3678 // IE7-/Win - Extra vertical space in lists fixed |
|
3679 if ($.browser.msie) { |
|
3680 this.element.find('a').css('zoom', '1'); |
|
3681 } |
|
3682 |
|
3683 this.resize(); |
|
3684 |
|
3685 //ARIA |
|
3686 this.element.attr('role','tablist'); |
|
3687 |
|
3688 this.headers |
|
3689 .attr('role','tab') |
|
3690 .bind('keydown', function(event) { return self._keydown(event); }) |
|
3691 .next() |
|
3692 .attr('role','tabpanel'); |
|
3693 |
|
3694 this.headers |
|
3695 .not(this.active || "") |
|
3696 .attr('aria-expanded','false') |
|
3697 .attr("tabIndex", "-1") |
|
3698 .next() |
|
3699 .hide(); |
|
3700 |
|
3701 // make sure at least one header is in the tab order |
|
3702 if (!this.active.length) { |
|
3703 this.headers.eq(0).attr('tabIndex','0'); |
|
3704 } else { |
|
3705 this.active |
|
3706 .attr('aria-expanded','true') |
|
3707 .attr('tabIndex', '0'); |
|
3708 } |
|
3709 |
|
3710 // only need links in taborder for Safari |
|
3711 if (!$.browser.safari) |
|
3712 this.headers.find('a').attr('tabIndex','-1'); |
|
3713 |
|
3714 if (o.event) { |
|
3715 this.element.bind((o.event) + ".accordion", function(event) { return self._clickHandler.call(self, event); }); |
|
3716 } |
|
3717 |
|
3718 }, |
|
3719 |
|
3720 destroy: function() { |
|
3721 |
|
3722 this.element |
|
3723 .removeClass("ui-accordion ui-widget ui-helper-reset") |
|
3724 .removeAttr("role") |
|
3725 .unbind('.accordion') |
|
3726 .removeData('accordion'); |
|
3727 |
|
3728 this.headers |
|
3729 .unbind(".accordion") |
|
3730 .removeClass("ui-accordion-header ui-helper-reset ui-state-default ui-corner-all ui-state-active ui-corner-top") |
|
3731 .removeAttr("role").removeAttr("aria-expanded").removeAttr("tabindex"); |
|
3732 |
|
3733 this.headers.find("a").removeAttr("tabindex"); |
|
3734 this.headers.children(".ui-icon").remove(); |
|
3735 this.headers.next().removeClass("ui-accordion-content ui-accordion-content-active"); |
|
3736 |
|
3737 }, |
|
3738 |
|
3739 _keydown: function(event) { |
|
3740 |
|
3741 var o = this.options, keyCode = $.ui.keyCode; |
|
3742 |
|
3743 if (o.disabled || event.altKey || event.ctrlKey) |
|
3744 return; |
|
3745 |
|
3746 var length = this.headers.length; |
|
3747 var currentIndex = this.headers.index(event.target); |
|
3748 var toFocus = false; |
|
3749 |
|
3750 switch(event.keyCode) { |
|
3751 case keyCode.RIGHT: |
|
3752 case keyCode.DOWN: |
|
3753 toFocus = this.headers[(currentIndex + 1) % length]; |
|
3754 break; |
|
3755 case keyCode.LEFT: |
|
3756 case keyCode.UP: |
|
3757 toFocus = this.headers[(currentIndex - 1 + length) % length]; |
|
3758 break; |
|
3759 case keyCode.SPACE: |
|
3760 case keyCode.ENTER: |
|
3761 return this._clickHandler({ target: event.target }); |
|
3762 } |
|
3763 |
|
3764 if (toFocus) { |
|
3765 $(event.target).attr('tabIndex','-1'); |
|
3766 $(toFocus).attr('tabIndex','0'); |
|
3767 toFocus.focus(); |
|
3768 return false; |
|
3769 } |
|
3770 |
|
3771 return true; |
|
3772 |
|
3773 }, |
|
3774 |
|
3775 resize: function() { |
|
3776 |
|
3777 var o = this.options, maxHeight; |
|
3778 |
|
3779 if (o.fillSpace) { |
|
3780 |
|
3781 if($.browser.msie) { var defOverflow = this.element.parent().css('overflow'); this.element.parent().css('overflow', 'hidden'); } |
|
3782 maxHeight = this.element.parent().height(); |
|
3783 if($.browser.msie) { this.element.parent().css('overflow', defOverflow); } |
|
3784 |
|
3785 this.headers.each(function() { |
|
3786 maxHeight -= $(this).outerHeight(); |
|
3787 }); |
|
3788 |
|
3789 var maxPadding = 0; |
|
3790 this.headers.next().each(function() { |
|
3791 maxPadding = Math.max(maxPadding, $(this).innerHeight() - $(this).height()); |
|
3792 }).height(maxHeight - maxPadding) |
|
3793 .css('overflow', 'auto'); |
|
3794 |
|
3795 } else if ( o.autoHeight ) { |
|
3796 maxHeight = 0; |
|
3797 this.headers.next().each(function() { |
|
3798 maxHeight = Math.max(maxHeight, $(this).outerHeight()); |
|
3799 }).height(maxHeight); |
|
3800 } |
|
3801 |
|
3802 }, |
|
3803 |
|
3804 activate: function(index) { |
|
3805 // call clickHandler with custom event |
|
3806 this._clickHandler({ target: this._findActive(index)[0] }); |
|
3807 }, |
|
3808 |
|
3809 _findActive: function(selector) { |
|
3810 return selector |
|
3811 ? typeof selector == "number" |
|
3812 ? this.headers.filter(":eq(" + selector + ")") |
|
3813 : this.headers.not(this.headers.not(selector)) |
|
3814 : selector === false |
|
3815 ? $([]) |
|
3816 : this.headers.filter(":eq(0)"); |
|
3817 }, |
|
3818 |
|
3819 _clickHandler: function(event) { |
|
3820 |
|
3821 var o = this.options; |
|
3822 if (o.disabled) return false; |
|
3823 |
|
3824 // called only when using activate(false) to close all parts programmatically |
|
3825 if (!event.target && !o.alwaysOpen) { |
|
3826 this.active.removeClass("ui-state-active ui-corner-top").addClass("ui-state-default ui-corner-all") |
|
3827 .find(".ui-icon").removeClass(o.icons.headerSelected).addClass(o.icons.header); |
|
3828 this.active.next().addClass('ui-accordion-content-active'); |
|
3829 var toHide = this.active.next(), |
|
3830 data = { |
|
3831 options: o, |
|
3832 newHeader: $([]), |
|
3833 oldHeader: o.active, |
|
3834 newContent: $([]), |
|
3835 oldContent: toHide |
|
3836 }, |
|
3837 toShow = (this.active = $([])); |
|
3838 this._toggle(toShow, toHide, data); |
|
3839 return false; |
|
3840 } |
|
3841 |
|
3842 // get the click target |
|
3843 var clicked = $(event.target); |
|
3844 |
|
3845 // due to the event delegation model, we have to check if one |
|
3846 // of the parent elements is our actual header, and find that |
|
3847 // otherwise stick with the initial target |
|
3848 clicked = $( clicked.parents(o.header)[0] || clicked ); |
|
3849 var clickedIsActive = clicked[0] == this.active[0]; |
|
3850 |
|
3851 // if animations are still active, or the active header is the target, ignore click |
|
3852 if (this.running || (o.alwaysOpen && clickedIsActive)) { |
|
3853 return false; |
|
3854 } |
|
3855 if (!clicked.is(o.header)) { |
|
3856 return; |
|
3857 } |
|
3858 |
|
3859 // switch classes |
|
3860 this.active.removeClass("ui-state-active ui-corner-top").addClass("ui-state-default ui-corner-all") |
|
3861 .find(".ui-icon").removeClass(o.icons.headerSelected).addClass(o.icons.header); |
|
3862 this.active.next().addClass('ui-accordion-content-active'); |
|
3863 if (!clickedIsActive) { |
|
3864 clicked.removeClass("ui-state-default ui-corner-all").addClass("ui-state-active ui-corner-top") |
|
3865 .find(".ui-icon").removeClass(o.icons.header).addClass(o.icons.headerSelected); |
|
3866 clicked.next().addClass('ui-accordion-content-active'); |
|
3867 } |
|
3868 |
|
3869 // find elements to show and hide |
|
3870 var toShow = clicked.next(), |
|
3871 toHide = this.active.next(), |
|
3872 data = { |
|
3873 options: o, |
|
3874 newHeader: clickedIsActive && !o.alwaysOpen ? $([]) : clicked, |
|
3875 oldHeader: this.active, |
|
3876 newContent: clickedIsActive && !o.alwaysOpen ? $([]) : toShow.find('> *'), |
|
3877 oldContent: toHide.find('> *') |
|
3878 }, |
|
3879 down = this.headers.index( this.active[0] ) > this.headers.index( clicked[0] ); |
|
3880 |
|
3881 this.active = clickedIsActive ? $([]) : clicked; |
|
3882 this._toggle(toShow, toHide, data, clickedIsActive, down); |
|
3883 |
|
3884 return false; |
|
3885 |
|
3886 }, |
|
3887 |
|
3888 _toggle: function(toShow, toHide, data, clickedIsActive, down) { |
|
3889 |
|
3890 var o = this.options, self = this; |
|
3891 |
|
3892 this.toShow = toShow; |
|
3893 this.toHide = toHide; |
|
3894 this.data = data; |
|
3895 |
|
3896 var complete = function() { if(!self) return; return self._completed.apply(self, arguments); }; |
|
3897 |
|
3898 // trigger changestart event |
|
3899 this._trigger("changestart", null, this.data); |
|
3900 |
|
3901 // count elements to animate |
|
3902 this.running = toHide.size() === 0 ? toShow.size() : toHide.size(); |
|
3903 |
|
3904 if (o.animated) { |
|
3905 |
|
3906 var animOptions = {}; |
|
3907 |
|
3908 if ( !o.alwaysOpen && clickedIsActive ) { |
|
3909 animOptions = { |
|
3910 toShow: $([]), |
|
3911 toHide: toHide, |
|
3912 complete: complete, |
|
3913 down: down, |
|
3914 autoHeight: o.autoHeight || o.fillSpace |
|
3915 }; |
|
3916 } else { |
|
3917 animOptions = { |
|
3918 toShow: toShow, |
|
3919 toHide: toHide, |
|
3920 complete: complete, |
|
3921 down: down, |
|
3922 autoHeight: o.autoHeight || o.fillSpace |
|
3923 }; |
|
3924 } |
|
3925 |
|
3926 if (!o.proxied) { |
|
3927 o.proxied = o.animated; |
|
3928 } |
|
3929 |
|
3930 if (!o.proxiedDuration) { |
|
3931 o.proxiedDuration = o.duration; |
|
3932 } |
|
3933 |
|
3934 o.animated = $.isFunction(o.proxied) ? |
|
3935 o.proxied(animOptions) : o.proxied; |
|
3936 |
|
3937 o.duration = $.isFunction(o.proxiedDuration) ? |
|
3938 o.proxiedDuration(animOptions) : o.proxiedDuration; |
|
3939 |
|
3940 var animations = $.ui.accordion.animations, |
|
3941 duration = o.duration, |
|
3942 easing = o.animated; |
|
3943 |
|
3944 if (!animations[easing]) { |
|
3945 animations[easing] = function(options) { |
|
3946 this.slide(options, { |
|
3947 easing: easing, |
|
3948 duration: duration || 700 |
|
3949 }); |
|
3950 }; |
|
3951 } |
|
3952 |
|
3953 animations[easing](animOptions); |
|
3954 |
|
3955 } else { |
|
3956 |
|
3957 if (!o.alwaysOpen && clickedIsActive) { |
|
3958 toShow.toggle(); |
|
3959 } else { |
|
3960 toHide.hide(); |
|
3961 toShow.show(); |
|
3962 } |
|
3963 |
|
3964 complete(true); |
|
3965 |
|
3966 } |
|
3967 |
|
3968 toHide.prev().attr('aria-expanded','false').attr("tabIndex", "-1"); |
|
3969 toShow.prev().attr('aria-expanded','true').attr("tabIndex", "0").focus(); |
|
3970 |
|
3971 }, |
|
3972 |
|
3973 _completed: function(cancel) { |
|
3974 |
|
3975 var o = this.options; |
|
3976 |
|
3977 this.running = cancel ? 0 : --this.running; |
|
3978 if (this.running) return; |
|
3979 |
|
3980 if (o.clearStyle) { |
|
3981 this.toShow.add(this.toHide).css({ |
|
3982 height: "", |
|
3983 overflow: "" |
|
3984 }); |
|
3985 } |
|
3986 |
|
3987 this._trigger('change', null, this.data); |
|
3988 } |
|
3989 |
|
3990 }); |
|
3991 |
|
3992 |
|
3993 $.extend($.ui.accordion, { |
|
3994 version: "1.6rc6", |
|
3995 defaults: { |
|
3996 active: null, |
|
3997 autoHeight: true, |
|
3998 alwaysOpen: true, |
|
3999 animated: 'slide', |
|
4000 clearStyle: false, |
|
4001 event: "click", |
|
4002 fillSpace: false, |
|
4003 header: "a", |
|
4004 icons: { |
|
4005 header: "ui-icon-triangle-1-e", |
|
4006 headerSelected: "ui-icon-triangle-1-s" |
|
4007 }, |
|
4008 navigation: false, |
|
4009 navigationFilter: function() { |
|
4010 return this.href.toLowerCase() == location.href.toLowerCase(); |
|
4011 } |
|
4012 }, |
|
4013 animations: { |
|
4014 slide: function(options, additions) { |
|
4015 options = $.extend({ |
|
4016 easing: "swing", |
|
4017 duration: 300 |
|
4018 }, options, additions); |
|
4019 if ( !options.toHide.size() ) { |
|
4020 options.toShow.animate({height: "show"}, options); |
|
4021 return; |
|
4022 } |
|
4023 var hideHeight = options.toHide.height(), |
|
4024 showHeight = options.toShow.height(), |
|
4025 difference = showHeight / hideHeight, |
|
4026 overflow = options.toShow.css('overflow'), |
|
4027 showProps = {}, |
|
4028 hideProps = {}, |
|
4029 fxAttrs = [ "height", "paddingTop", "paddingBottom" ]; |
|
4030 $.each(fxAttrs, function(i, prop) { |
|
4031 hideProps[prop] = 'hide'; |
|
4032 showProps[prop] = parseFloat(options.toShow.css(prop)); |
|
4033 }); |
|
4034 options.toShow.css({ height: 0, overflow: 'hidden' }).show(); |
|
4035 options.toHide.filter(":hidden").each(options.complete).end().filter(":visible").animate(hideProps,{ |
|
4036 step: function(now, settings) { |
|
4037 // if the alwaysOpen option is set to false, we may not have |
|
4038 // a content pane to show |
|
4039 if (!options.toShow[0]) { return; } |
|
4040 |
|
4041 var percentDone = settings.start != settings.end |
|
4042 ? (settings.now - settings.start) / (settings.end - settings.start) |
|
4043 : 0, |
|
4044 current = percentDone * showProps[settings.prop]; |
|
4045 if ($.browser.msie || $.browser.opera) { |
|
4046 current = Math.ceil(current); |
|
4047 } |
|
4048 options.toShow[0].style[settings.prop] = current + 'px'; |
|
4049 }, |
|
4050 duration: options.duration, |
|
4051 easing: options.easing, |
|
4052 complete: function() { |
|
4053 if ( !options.autoHeight ) { |
|
4054 options.toShow.css("height", "auto"); |
|
4055 } |
|
4056 options.toShow.css({overflow: overflow}); |
|
4057 options.complete(); |
|
4058 } |
|
4059 }); |
|
4060 }, |
|
4061 bounceslide: function(options) { |
|
4062 this.slide(options, { |
|
4063 easing: options.down ? "easeOutBounce" : "swing", |
|
4064 duration: options.down ? 1000 : 200 |
|
4065 }); |
|
4066 }, |
|
4067 easeslide: function(options) { |
|
4068 this.slide(options, { |
|
4069 easing: "easeinout", |
|
4070 duration: 700 |
|
4071 }); |
|
4072 } |
|
4073 } |
|
4074 }); |
|
4075 |
|
4076 })(jQuery); |
|
4077 /* |
|
4078 * jQuery UI Dialog 1.6rc6 |
|
4079 * |
|
4080 * Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about) |
|
4081 * Dual licensed under the MIT (MIT-LICENSE.txt) |
|
4082 * and GPL (GPL-LICENSE.txt) licenses. |
|
4083 * |
|
4084 * http://docs.jquery.com/UI/Dialog |
|
4085 * |
|
4086 * Depends: |
|
4087 * ui.core.js |
|
4088 * ui.draggable.js |
|
4089 * ui.resizable.js |
|
4090 */ |
|
4091 (function($) { |
|
4092 |
|
4093 var setDataSwitch = { |
|
4094 dragStart: "start.draggable", |
|
4095 drag: "drag.draggable", |
|
4096 dragStop: "stop.draggable", |
|
4097 maxHeight: "maxHeight.resizable", |
|
4098 minHeight: "minHeight.resizable", |
|
4099 maxWidth: "maxWidth.resizable", |
|
4100 minWidth: "minWidth.resizable", |
|
4101 resizeStart: "start.resizable", |
|
4102 resize: "drag.resizable", |
|
4103 resizeStop: "stop.resizable" |
|
4104 }; |
|
4105 |
|
4106 $.widget("ui.dialog", { |
|
4107 |
|
4108 _init: function() { |
|
4109 this.originalTitle = this.element.attr('title'); |
|
4110 |
|
4111 var self = this, |
|
4112 options = this.options, |
|
4113 |
|
4114 title = options.title || this.originalTitle || ' ', |
|
4115 titleId = $.ui.dialog.getTitleId(this.element), |
|
4116 |
|
4117 uiDialog = (this.uiDialog = $('<div/>')) |
|
4118 .appendTo(document.body) |
|
4119 .hide() |
|
4120 .addClass( |
|
4121 'ui-dialog ' + |
|
4122 'ui-widget ' + |
|
4123 'ui-widget-content ' + |
|
4124 'ui-corner-all ' + |
|
4125 options.dialogClass |
|
4126 ) |
|
4127 .css({ |
|
4128 position: 'absolute', |
|
4129 overflow: 'hidden', |
|
4130 zIndex: options.zIndex |
|
4131 }) |
|
4132 // setting tabIndex makes the div focusable |
|
4133 // setting outline to 0 prevents a border on focus in Mozilla |
|
4134 .attr('tabIndex', -1).css('outline', 0).keydown(function(event) { |
|
4135 (options.closeOnEscape && event.keyCode |
|
4136 && event.keyCode == $.ui.keyCode.ESCAPE && self.close(event)); |
|
4137 }) |
|
4138 .attr({ |
|
4139 role: 'dialog', |
|
4140 'aria-labelledby': titleId |
|
4141 }) |
|
4142 .mousedown(function(event) { |
|
4143 self.moveToTop(event); |
|
4144 }), |
|
4145 |
|
4146 uiDialogContent = this.element |
|
4147 .show() |
|
4148 .removeAttr('title') |
|
4149 .addClass( |
|
4150 'ui-dialog-content ' + |
|
4151 'ui-widget-content') |
|
4152 .appendTo(uiDialog), |
|
4153 |
|
4154 uiDialogTitlebar = (this.uiDialogTitlebar = $('<div></div>')) |
|
4155 .addClass( |
|
4156 'ui-dialog-titlebar ' + |
|
4157 'ui-widget-header ' + |
|
4158 'ui-corner-all ' + |
|
4159 'ui-helper-clearfix' |
|
4160 ) |
|
4161 .prependTo(uiDialog), |
|
4162 |
|
4163 uiDialogTitlebarClose = $('<a href="#"/>') |
|
4164 .addClass( |
|
4165 'ui-dialog-titlebar-close ' + |
|
4166 'ui-corner-all' |
|
4167 ) |
|
4168 .attr('role', 'button') |
|
4169 .hover( |
|
4170 function() { |
|
4171 uiDialogTitlebarClose.addClass('ui-state-hover'); |
|
4172 }, |
|
4173 function() { |
|
4174 uiDialogTitlebarClose.removeClass('ui-state-hover'); |
|
4175 } |
|
4176 ) |
|
4177 .focus(function() { |
|
4178 uiDialogTitlebarClose.addClass('ui-state-focus'); |
|
4179 }) |
|
4180 .blur(function() { |
|
4181 uiDialogTitlebarClose.removeClass('ui-state-focus'); |
|
4182 }) |
|
4183 .mousedown(function(ev) { |
|
4184 ev.stopPropagation(); |
|
4185 }) |
|
4186 .click(function(event) { |
|
4187 self.close(event); |
|
4188 return false; |
|
4189 }) |
|
4190 .appendTo(uiDialogTitlebar), |
|
4191 |
|
4192 uiDialogTitlebarCloseText = (this.uiDialogTitlebarCloseText = $('<span/>')) |
|
4193 .addClass( |
|
4194 'ui-icon ' + |
|
4195 'ui-icon-closethick' |
|
4196 ) |
|
4197 .text(options.closeText) |
|
4198 .appendTo(uiDialogTitlebarClose), |
|
4199 |
|
4200 uiDialogTitle = $('<span/>') |
|
4201 .addClass('ui-dialog-title') |
|
4202 .attr('id', titleId) |
|
4203 .html(title) |
|
4204 .prependTo(uiDialogTitlebar); |
|
4205 |
|
4206 uiDialogTitlebar.find("*").add(uiDialogTitlebar).disableSelection(); |
|
4207 |
|
4208 (options.draggable && $.fn.draggable && this._makeDraggable()); |
|
4209 (options.resizable && $.fn.resizable && this._makeResizable()); |
|
4210 |
|
4211 this._createButtons(options.buttons); |
|
4212 this._isOpen = false; |
|
4213 |
|
4214 (options.bgiframe && $.fn.bgiframe && uiDialog.bgiframe()); |
|
4215 (options.autoOpen && this.open()); |
|
4216 |
|
4217 }, |
|
4218 |
|
4219 destroy: function() { |
|
4220 (this.overlay && this.overlay.destroy()); |
|
4221 (this.shadow && this._destroyShadow()); |
|
4222 this.uiDialog.hide(); |
|
4223 this.element |
|
4224 .unbind('.dialog') |
|
4225 .removeData('dialog') |
|
4226 .removeClass('ui-dialog-content ui-widget-content') |
|
4227 .hide().appendTo('body'); |
|
4228 this.uiDialog.remove(); |
|
4229 |
|
4230 (this.originalTitle && this.element.attr('title', this.originalTitle)); |
|
4231 }, |
|
4232 |
|
4233 close: function(event) { |
|
4234 if (false === this._trigger('beforeclose', event)) { |
|
4235 return; |
|
4236 } |
|
4237 |
|
4238 (this.overlay && this.overlay.destroy()); |
|
4239 (this.shadow && this._destroyShadow()); |
|
4240 this.uiDialog |
|
4241 .hide(this.options.hide) |
|
4242 .unbind('keypress.ui-dialog'); |
|
4243 |
|
4244 this._trigger('close', event); |
|
4245 $.ui.dialog.overlay.resize(); |
|
4246 |
|
4247 this._isOpen = false; |
|
4248 }, |
|
4249 |
|
4250 isOpen: function() { |
|
4251 return this._isOpen; |
|
4252 }, |
|
4253 |
|
4254 // the force parameter allows us to move modal dialogs to their correct |
|
4255 // position on open |
|
4256 moveToTop: function(force, event) { |
|
4257 |
|
4258 if ((this.options.modal && !force) |
|
4259 || (!this.options.stack && !this.options.modal)) { |
|
4260 return this._trigger('focus', event); |
|
4261 } |
|
4262 |
|
4263 var maxZ = this.options.zIndex, options = this.options; |
|
4264 $('.ui-dialog:visible').each(function() { |
|
4265 maxZ = Math.max(maxZ, parseInt($(this).css('z-index'), 10) || options.zIndex); |
|
4266 }); |
|
4267 (this.overlay && this.overlay.$el.css('z-index', ++maxZ)); |
|
4268 (this.shadow && this.shadow.css('z-index', ++maxZ)); |
|
4269 |
|
4270 //Save and then restore scroll since Opera 9.5+ resets when parent z-Index is changed. |
|
4271 // http://ui.jquery.com/bugs/ticket/3193 |
|
4272 var saveScroll = { scrollTop: this.element.attr('scrollTop'), scrollLeft: this.element.attr('scrollLeft') }; |
|
4273 this.uiDialog.css('z-index', ++maxZ); |
|
4274 this.element.attr(saveScroll); |
|
4275 this._trigger('focus', event); |
|
4276 }, |
|
4277 |
|
4278 open: function(event) { |
|
4279 if (this._isOpen) { return; } |
|
4280 |
|
4281 var options = this.options, |
|
4282 uiDialog = this.uiDialog; |
|
4283 |
|
4284 this.overlay = options.modal ? new $.ui.dialog.overlay(this) : null; |
|
4285 (uiDialog.next().length && uiDialog.appendTo('body')); |
|
4286 this._size(); |
|
4287 this._position(options.position); |
|
4288 uiDialog.show(options.show); |
|
4289 this.moveToTop(true, event); |
|
4290 |
|
4291 // prevent tabbing out of modal dialogs |
|
4292 (options.modal && uiDialog.bind('keypress.ui-dialog', function(event) { |
|
4293 if (event.keyCode != $.ui.keyCode.TAB) { |
|
4294 return; |
|
4295 } |
|
4296 |
|
4297 var tabbables = $(':tabbable', this), |
|
4298 first = tabbables.filter(':first')[0], |
|
4299 last = tabbables.filter(':last')[0]; |
|
4300 |
|
4301 if (event.target == last && !event.shiftKey) { |
|
4302 setTimeout(function() { |
|
4303 first.focus(); |
|
4304 }, 1); |
|
4305 } else if (event.target == first && event.shiftKey) { |
|
4306 setTimeout(function() { |
|
4307 last.focus(); |
|
4308 }, 1); |
|
4309 } |
|
4310 })); |
|
4311 |
|
4312 // set focus to the first tabbable element in: |
|
4313 // - content area |
|
4314 // - button pane |
|
4315 // - title bar |
|
4316 $([]) |
|
4317 .add(uiDialog.find('.ui-dialog-content :tabbable:first')) |
|
4318 .add(uiDialog.find('.ui-dialog-buttonpane :tabbable:first')) |
|
4319 .add(uiDialog.find('.ui-dialog-titlebar :tabbable:first')) |
|
4320 .filter(':first') |
|
4321 .focus(); |
|
4322 |
|
4323 if(options.shadow) |
|
4324 this._createShadow(); |
|
4325 |
|
4326 this._trigger('open', event); |
|
4327 this._isOpen = true; |
|
4328 }, |
|
4329 |
|
4330 _createButtons: function(buttons) { |
|
4331 var self = this, |
|
4332 hasButtons = false, |
|
4333 uiDialogButtonPane = $('<div></div>') |
|
4334 .addClass( |
|
4335 'ui-dialog-buttonpane ' + |
|
4336 'ui-widget-content ' + |
|
4337 'ui-helper-clearfix' |
|
4338 ); |
|
4339 |
|
4340 // if we already have a button pane, remove it |
|
4341 this.uiDialog.find('.ui-dialog-buttonpane').remove(); |
|
4342 |
|
4343 (typeof buttons == 'object' && buttons !== null && |
|
4344 $.each(buttons, function() { return !(hasButtons = true); })); |
|
4345 if (hasButtons) { |
|
4346 $.each(buttons, function(name, fn) { |
|
4347 $('<button type="button"></button>') |
|
4348 .addClass( |
|
4349 'ui-state-default ' + |
|
4350 'ui-corner-all' |
|
4351 ) |
|
4352 .text(name) |
|
4353 .click(function() { fn.apply(self.element[0], arguments); }) |
|
4354 .hover( |
|
4355 function() { |
|
4356 $(this).addClass('ui-state-hover'); |
|
4357 }, |
|
4358 function() { |
|
4359 $(this).removeClass('ui-state-hover'); |
|
4360 } |
|
4361 ) |
|
4362 .focus(function() { |
|
4363 $(this).addClass('ui-state-focus'); |
|
4364 }) |
|
4365 .blur(function() { |
|
4366 $(this).removeClass('ui-state-focus'); |
|
4367 }) |
|
4368 .appendTo(uiDialogButtonPane); |
|
4369 }); |
|
4370 uiDialogButtonPane.appendTo(this.uiDialog); |
|
4371 } |
|
4372 }, |
|
4373 |
|
4374 _makeDraggable: function() { |
|
4375 var self = this, |
|
4376 options = this.options; |
|
4377 |
|
4378 this.uiDialog.draggable({ |
|
4379 cancel: '.ui-dialog-content', |
|
4380 helper: options.dragHelper, |
|
4381 handle: '.ui-dialog-titlebar', |
|
4382 containment: 'document', |
|
4383 start: function() { |
|
4384 (options.dragStart && options.dragStart.apply(self.element[0], arguments)); |
|
4385 if($.browser.msie && $.browser.version < 7 && self.shadow) self.shadow.hide(); |
|
4386 }, |
|
4387 drag: function() { |
|
4388 (options.drag && options.drag.apply(self.element[0], arguments)); |
|
4389 self._refreshShadow(1); |
|
4390 }, |
|
4391 stop: function() { |
|
4392 (options.dragStop && options.dragStop.apply(self.element[0], arguments)); |
|
4393 $.ui.dialog.overlay.resize(); |
|
4394 if($.browser.msie && $.browser.version < 7 && self.shadow) self.shadow.show(); |
|
4395 self._refreshShadow(); |
|
4396 } |
|
4397 }); |
|
4398 }, |
|
4399 |
|
4400 _makeResizable: function(handles) { |
|
4401 handles = (handles === undefined ? this.options.resizable : handles); |
|
4402 var self = this, |
|
4403 options = this.options, |
|
4404 resizeHandles = typeof handles == 'string' |
|
4405 ? handles |
|
4406 : 'n,e,s,w,se,sw,ne,nw'; |
|
4407 |
|
4408 this.uiDialog.resizable({ |
|
4409 cancel: '.ui-dialog-content', |
|
4410 alsoResize: this.element, |
|
4411 helper: options.resizeHelper, |
|
4412 maxWidth: options.maxWidth, |
|
4413 maxHeight: options.maxHeight, |
|
4414 minWidth: options.minWidth, |
|
4415 minHeight: options.minHeight, |
|
4416 start: function() { |
|
4417 (options.resizeStart && options.resizeStart.apply(self.element[0], arguments)); |
|
4418 if($.browser.msie && $.browser.version < 7 && self.shadow) self.shadow.hide(); |
|
4419 }, |
|
4420 resize: function() { |
|
4421 (options.resize && options.resize.apply(self.element[0], arguments)); |
|
4422 self._refreshShadow(1); |
|
4423 }, |
|
4424 handles: resizeHandles, |
|
4425 stop: function() { |
|
4426 (options.resizeStop && options.resizeStop.apply(self.element[0], arguments)); |
|
4427 $.ui.dialog.overlay.resize(); |
|
4428 if($.browser.msie && $.browser.version < 7 && self.shadow) self.shadow.show(); |
|
4429 self._refreshShadow(); |
|
4430 } |
|
4431 }) |
|
4432 .find('.ui-resizable-se').addClass('ui-icon ui-icon-grip-diagonal-se'); |
|
4433 }, |
|
4434 |
|
4435 _position: function(pos) { |
|
4436 var wnd = $(window), doc = $(document), |
|
4437 pTop = doc.scrollTop(), pLeft = doc.scrollLeft(), |
|
4438 minTop = pTop; |
|
4439 |
|
4440 if ($.inArray(pos, ['center','top','right','bottom','left']) >= 0) { |
|
4441 pos = [ |
|
4442 pos == 'right' || pos == 'left' ? pos : 'center', |
|
4443 pos == 'top' || pos == 'bottom' ? pos : 'middle' |
|
4444 ]; |
|
4445 } |
|
4446 if (pos.constructor != Array) { |
|
4447 pos = ['center', 'middle']; |
|
4448 } |
|
4449 if (pos[0].constructor == Number) { |
|
4450 pLeft += pos[0]; |
|
4451 } else { |
|
4452 switch (pos[0]) { |
|
4453 case 'left': |
|
4454 pLeft += 0; |
|
4455 break; |
|
4456 case 'right': |
|
4457 pLeft += wnd.width() - this.uiDialog.outerWidth(); |
|
4458 break; |
|
4459 default: |
|
4460 case 'center': |
|
4461 pLeft += (wnd.width() - this.uiDialog.outerWidth()) / 2; |
|
4462 } |
|
4463 } |
|
4464 if (pos[1].constructor == Number) { |
|
4465 pTop += pos[1]; |
|
4466 } else { |
|
4467 switch (pos[1]) { |
|
4468 case 'top': |
|
4469 pTop += 0; |
|
4470 break; |
|
4471 case 'bottom': |
|
4472 pTop += wnd.height() - this.uiDialog.outerHeight(); |
|
4473 break; |
|
4474 default: |
|
4475 case 'middle': |
|
4476 pTop += (wnd.height() - this.uiDialog.outerHeight()) / 2; |
|
4477 } |
|
4478 } |
|
4479 |
|
4480 // prevent the dialog from being too high (make sure the titlebar |
|
4481 // is accessible) |
|
4482 pTop = Math.max(pTop, minTop); |
|
4483 this.uiDialog.css({top: pTop, left: pLeft}); |
|
4484 }, |
|
4485 |
|
4486 _setData: function(key, value){ |
|
4487 (setDataSwitch[key] && this.uiDialog.data(setDataSwitch[key], value)); |
|
4488 switch (key) { |
|
4489 case "buttons": |
|
4490 this._createButtons(value); |
|
4491 break; |
|
4492 case "closeText": |
|
4493 this.uiDialogTitlebarCloseText.text(value); |
|
4494 break; |
|
4495 case "draggable": |
|
4496 (value |
|
4497 ? this._makeDraggable() |
|
4498 : this.uiDialog.draggable('destroy')); |
|
4499 break; |
|
4500 case "height": |
|
4501 this.uiDialog.height(value); |
|
4502 break; |
|
4503 case "position": |
|
4504 this._position(value); |
|
4505 break; |
|
4506 case "resizable": |
|
4507 var uiDialog = this.uiDialog, |
|
4508 isResizable = this.uiDialog.is(':data(resizable)'); |
|
4509 |
|
4510 // currently resizable, becoming non-resizable |
|
4511 (isResizable && !value && uiDialog.resizable('destroy')); |
|
4512 |
|
4513 // currently resizable, changing handles |
|
4514 (isResizable && typeof value == 'string' && |
|
4515 uiDialog.resizable('option', 'handles', value)); |
|
4516 |
|
4517 // currently non-resizable, becoming resizable |
|
4518 (isResizable || this._makeResizable(value)); |
|
4519 |
|
4520 break; |
|
4521 case "title": |
|
4522 $(".ui-dialog-title", this.uiDialogTitlebar).html(value || ' '); |
|
4523 break; |
|
4524 case "width": |
|
4525 this.uiDialog.width(value); |
|
4526 break; |
|
4527 } |
|
4528 |
|
4529 $.widget.prototype._setData.apply(this, arguments); |
|
4530 }, |
|
4531 |
|
4532 _size: function() { |
|
4533 /* If the user has resized the dialog, the .ui-dialog and .ui-dialog-content |
|
4534 * divs will both have width and height set, so we need to reset them |
|
4535 */ |
|
4536 var options = this.options; |
|
4537 |
|
4538 // reset content sizing |
|
4539 this.element.css({ |
|
4540 height: 0, |
|
4541 minHeight: 0, |
|
4542 width: 'auto' |
|
4543 }); |
|
4544 |
|
4545 // reset wrapper sizing |
|
4546 // determine the height of all the non-content elements |
|
4547 var nonContentHeight = this.uiDialog.css({ |
|
4548 height: 'auto', |
|
4549 width: options.width |
|
4550 }) |
|
4551 .height(); |
|
4552 |
|
4553 this.element |
|
4554 .css({ |
|
4555 minHeight: Math.max(options.minHeight - nonContentHeight, 0), |
|
4556 height: options.height == 'auto' |
|
4557 ? 'auto' |
|
4558 : options.height - nonContentHeight |
|
4559 }); |
|
4560 }, |
|
4561 |
|
4562 _createShadow: function() { |
|
4563 this.shadow = $('<div class="ui-widget-shadow"></div>').css('position', 'absolute').appendTo(document.body); |
|
4564 this._refreshShadow(); |
|
4565 return this.shadow; |
|
4566 }, |
|
4567 |
|
4568 _refreshShadow: function(dragging) { |
|
4569 // IE6 is simply to slow to handle the reflow in a good way, so |
|
4570 // resizing only happens on stop, and the shadow is hidden during drag/resize |
|
4571 if(dragging && $.browser.msie && $.browser.version < 7) return; |
|
4572 |
|
4573 var offset = this.uiDialog.offset(); |
|
4574 this.shadow.css({ |
|
4575 left: offset.left, |
|
4576 top: offset.top, |
|
4577 width: this.uiDialog.outerWidth(), |
|
4578 height: this.uiDialog.outerHeight() |
|
4579 }); |
|
4580 }, |
|
4581 |
|
4582 _destroyShadow: function() { |
|
4583 this.shadow.remove(); |
|
4584 this.shadow = null; |
|
4585 } |
|
4586 |
|
4587 }); |
|
4588 |
|
4589 $.extend($.ui.dialog, { |
|
4590 version: "1.6rc6", |
|
4591 defaults: { |
|
4592 autoOpen: true, |
|
4593 bgiframe: false, |
|
4594 buttons: {}, |
|
4595 closeOnEscape: true, |
|
4596 closeText: 'close', |
|
4597 draggable: true, |
|
4598 height: 'auto', |
|
4599 minHeight: 150, |
|
4600 minWidth: 150, |
|
4601 modal: false, |
|
4602 position: 'center', |
|
4603 resizable: true, |
|
4604 shadow: true, |
|
4605 stack: true, |
|
4606 title: '', |
|
4607 width: 300, |
|
4608 zIndex: 1000 |
|
4609 }, |
|
4610 |
|
4611 getter: 'isOpen', |
|
4612 |
|
4613 uuid: 0, |
|
4614 |
|
4615 getTitleId: function($el) { |
|
4616 return 'ui-dialog-title-' + ($el.attr('id') || ++this.uuid); |
|
4617 }, |
|
4618 |
|
4619 overlay: function(dialog) { |
|
4620 this.$el = $.ui.dialog.overlay.create(dialog); |
|
4621 } |
|
4622 }); |
|
4623 |
|
4624 $.extend($.ui.dialog.overlay, { |
|
4625 instances: [], |
|
4626 events: $.map('focus,mousedown,mouseup,keydown,keypress,click'.split(','), |
|
4627 function(event) { return event + '.dialog-overlay'; }).join(' '), |
|
4628 create: function(dialog) { |
|
4629 if (this.instances.length === 0) { |
|
4630 // prevent use of anchors and inputs |
|
4631 // we use a setTimeout in case the overlay is created from an |
|
4632 // event that we're going to be cancelling (see #2804) |
|
4633 setTimeout(function() { |
|
4634 $('a, :input').bind($.ui.dialog.overlay.events, function() { |
|
4635 // allow use of the element if inside a dialog and |
|
4636 // - there are no modal dialogs |
|
4637 // - there are modal dialogs, but we are in front of the topmost modal |
|
4638 var allow = false; |
|
4639 var $dialog = $(this).parents('.ui-dialog'); |
|
4640 if ($dialog.length) { |
|
4641 var $overlays = $('.ui-dialog-overlay'); |
|
4642 if ($overlays.length) { |
|
4643 var maxZ = parseInt($overlays.css('z-index'), 10); |
|
4644 $overlays.each(function() { |
|
4645 maxZ = Math.max(maxZ, parseInt($(this).css('z-index'), 10)); |
|
4646 }); |
|
4647 allow = parseInt($dialog.css('z-index'), 10) > maxZ; |
|
4648 } else { |
|
4649 allow = true; |
|
4650 } |
|
4651 } |
|
4652 return allow; |
|
4653 }); |
|
4654 }, 1); |
|
4655 |
|
4656 // allow closing by pressing the escape key |
|
4657 $(document).bind('keydown.dialog-overlay', function(event) { |
|
4658 (dialog.options.closeOnEscape && event.keyCode |
|
4659 && event.keyCode == $.ui.keyCode.ESCAPE && dialog.close(event)); |
|
4660 }); |
|
4661 |
|
4662 // handle window resize |
|
4663 $(window).bind('resize.dialog-overlay', $.ui.dialog.overlay.resize); |
|
4664 } |
|
4665 |
|
4666 var $el = $('<div></div>').appendTo(document.body) |
|
4667 .addClass('ui-widget-overlay').css({ |
|
4668 width: this.width(), |
|
4669 height: this.height() |
|
4670 }); |
|
4671 |
|
4672 (dialog.options.bgiframe && $.fn.bgiframe && $el.bgiframe()); |
|
4673 |
|
4674 this.instances.push($el); |
|
4675 return $el; |
|
4676 }, |
|
4677 |
|
4678 destroy: function($el) { |
|
4679 this.instances.splice($.inArray(this.instances, $el), 1); |
|
4680 |
|
4681 if (this.instances.length === 0) { |
|
4682 $('a, :input').add([document, window]).unbind('.dialog-overlay'); |
|
4683 } |
|
4684 |
|
4685 $el.remove(); |
|
4686 }, |
|
4687 |
|
4688 height: function() { |
|
4689 // handle IE 6 |
|
4690 if ($.browser.msie && $.browser.version < 7) { |
|
4691 var scrollHeight = Math.max( |
|
4692 document.documentElement.scrollHeight, |
|
4693 document.body.scrollHeight |
|
4694 ); |
|
4695 var offsetHeight = Math.max( |
|
4696 document.documentElement.offsetHeight, |
|
4697 document.body.offsetHeight |
|
4698 ); |
|
4699 |
|
4700 if (scrollHeight < offsetHeight) { |
|
4701 return $(window).height() + 'px'; |
|
4702 } else { |
|
4703 return scrollHeight + 'px'; |
|
4704 } |
|
4705 // handle "good" browsers |
|
4706 } else { |
|
4707 return $(document).height() + 'px'; |
|
4708 } |
|
4709 }, |
|
4710 |
|
4711 width: function() { |
|
4712 // handle IE 6 |
|
4713 if ($.browser.msie && $.browser.version < 7) { |
|
4714 var scrollWidth = Math.max( |
|
4715 document.documentElement.scrollWidth, |
|
4716 document.body.scrollWidth |
|
4717 ); |
|
4718 var offsetWidth = Math.max( |
|
4719 document.documentElement.offsetWidth, |
|
4720 document.body.offsetWidth |
|
4721 ); |
|
4722 |
|
4723 if (scrollWidth < offsetWidth) { |
|
4724 return $(window).width() + 'px'; |
|
4725 } else { |
|
4726 return scrollWidth + 'px'; |
|
4727 } |
|
4728 // handle "good" browsers |
|
4729 } else { |
|
4730 return $(document).width() + 'px'; |
|
4731 } |
|
4732 }, |
|
4733 |
|
4734 resize: function() { |
|
4735 /* If the dialog is draggable and the user drags it past the |
|
4736 * right edge of the window, the document becomes wider so we |
|
4737 * need to stretch the overlay. If the user then drags the |
|
4738 * dialog back to the left, the document will become narrower, |
|
4739 * so we need to shrink the overlay to the appropriate size. |
|
4740 * This is handled by shrinking the overlay before setting it |
|
4741 * to the full document size. |
|
4742 */ |
|
4743 var $overlays = $([]); |
|
4744 $.each($.ui.dialog.overlay.instances, function() { |
|
4745 $overlays = $overlays.add(this); |
|
4746 }); |
|
4747 |
|
4748 $overlays.css({ |
|
4749 width: 0, |
|
4750 height: 0 |
|
4751 }).css({ |
|
4752 width: $.ui.dialog.overlay.width(), |
|
4753 height: $.ui.dialog.overlay.height() |
|
4754 }); |
|
4755 } |
|
4756 }); |
|
4757 |
|
4758 $.extend($.ui.dialog.overlay.prototype, { |
|
4759 destroy: function() { |
|
4760 $.ui.dialog.overlay.destroy(this.$el); |
|
4761 } |
|
4762 }); |
|
4763 |
|
4764 })(jQuery); |
|
4765 /* |
|
4766 * jQuery UI Slider 1.6rc6 |
|
4767 * |
|
4768 * Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about) |
|
4769 * Dual licensed under the MIT (MIT-LICENSE.txt) |
|
4770 * and GPL (GPL-LICENSE.txt) licenses. |
|
4771 * |
|
4772 * http://docs.jquery.com/UI/Slider |
|
4773 * |
|
4774 * Depends: |
|
4775 * ui.core.js |
|
4776 */ |
|
4777 |
|
4778 (function($) { |
|
4779 |
|
4780 $.widget("ui.slider", $.extend({}, $.ui.mouse, { |
|
4781 |
|
4782 _init: function() { |
|
4783 |
|
4784 var self = this, o = this.options; |
|
4785 this._keySliding = false; |
|
4786 this._handleIndex = null; |
|
4787 this._detectOrientation(); |
|
4788 this._mouseInit(); |
|
4789 |
|
4790 this.element |
|
4791 .addClass("ui-slider" |
|
4792 + " ui-slider-" + this.orientation |
|
4793 + " ui-widget" |
|
4794 + " ui-widget-content" |
|
4795 + " ui-corner-all"); |
|
4796 |
|
4797 this.range = $([]); |
|
4798 |
|
4799 if (o.range) { |
|
4800 |
|
4801 if (o.range === true) { |
|
4802 this.range = $('<div></div>'); |
|
4803 if (!o.values) o.values = [this._valueMin(), this._valueMin()]; |
|
4804 if (o.values.length && o.values.length != 2) { |
|
4805 o.values = [o.values[0], o.values[0]]; |
|
4806 } |
|
4807 } else { |
|
4808 this.range = $('<div></div>'); |
|
4809 } |
|
4810 |
|
4811 this.range |
|
4812 .appendTo(this.element) |
|
4813 .addClass("ui-slider-range" |
|
4814 + " ui-widget-header"); |
|
4815 |
|
4816 (o.range == "min") && (this.orientation == "horizontal") && this.range.css({ left : 0 }); |
|
4817 (o.range == "max") && (this.orientation == "horizontal") && this.range.css({ right : 0 }); |
|
4818 (o.range == "min") && (this.orientation == "vertical") && this.range.css({ bottom : 0 }); |
|
4819 (o.range == "max") && (this.orientation == "vertical") && this.range.css({ top : 0 }); |
|
4820 |
|
4821 } |
|
4822 |
|
4823 if ($(".ui-slider-handle", this.element).length == 0) |
|
4824 $('<a href="#"></a>') |
|
4825 .appendTo(this.element) |
|
4826 .addClass("ui-slider-handle"); |
|
4827 |
|
4828 if (o.values && o.values.length) { |
|
4829 while ($(".ui-slider-handle", this.element).length < o.values.length) |
|
4830 $('<a href="#"></a>') |
|
4831 .appendTo(this.element) |
|
4832 .addClass("ui-slider-handle"); |
|
4833 } |
|
4834 |
|
4835 this.handles = $(".ui-slider-handle", this.element) |
|
4836 .addClass("ui-state-default" |
|
4837 + " ui-corner-all"); |
|
4838 |
|
4839 this.handle = this.handles.eq(0); |
|
4840 |
|
4841 this.handles.add(this.range).filter("a") |
|
4842 .click(function(event) { event.preventDefault(); }) |
|
4843 .hover(function() { $(this).addClass('ui-state-hover'); }, function() { $(this).removeClass('ui-state-hover'); }) |
|
4844 .focus(function() { self.handles.removeClass('ui-state-focus'); $(this).addClass('ui-state-focus'); }) |
|
4845 .blur(function() { $(this).removeClass('ui-state-focus'); }); |
|
4846 |
|
4847 this.handles.each(function(i) { |
|
4848 $(this).data("index.ui-slider-handle", i); |
|
4849 }); |
|
4850 |
|
4851 this.handles.keydown(function(event) { |
|
4852 |
|
4853 var index = $(this).data("index.ui-slider-handle"); |
|
4854 |
|
4855 if (self.options.disabled) |
|
4856 return; |
|
4857 |
|
4858 switch (event.keyCode) { |
|
4859 case $.ui.keyCode.HOME: |
|
4860 case $.ui.keyCode.END: |
|
4861 case $.ui.keyCode.UP: |
|
4862 case $.ui.keyCode.RIGHT: |
|
4863 case $.ui.keyCode.DOWN: |
|
4864 case $.ui.keyCode.LEFT: |
|
4865 if (!self._keySliding) { |
|
4866 self._keySliding = true; |
|
4867 $(this).addClass("ui-state-active"); |
|
4868 self._start(event); |
|
4869 } |
|
4870 break; |
|
4871 } |
|
4872 |
|
4873 var curVal, newVal, step = self._step(); |
|
4874 if (self.options.values && self.options.values.length) { |
|
4875 curVal = newVal = self.values(index); |
|
4876 } else { |
|
4877 curVal = newVal = self.value(); |
|
4878 } |
|
4879 |
|
4880 switch (event.keyCode) { |
|
4881 case $.ui.keyCode.HOME: |
|
4882 newVal = self._valueMin(); |
|
4883 break; |
|
4884 case $.ui.keyCode.END: |
|
4885 newVal = self._valueMax(); |
|
4886 break; |
|
4887 case $.ui.keyCode.UP: |
|
4888 case $.ui.keyCode.RIGHT: |
|
4889 if(curVal == self._valueMax()) return; |
|
4890 newVal = curVal + step; |
|
4891 break; |
|
4892 case $.ui.keyCode.DOWN: |
|
4893 case $.ui.keyCode.LEFT: |
|
4894 if(curVal == self._valueMin()) return; |
|
4895 newVal = curVal - step; |
|
4896 break; |
|
4897 } |
|
4898 |
|
4899 self._slide(event, index, newVal); |
|
4900 |
|
4901 }).keyup(function(event) { |
|
4902 |
|
4903 if (self._keySliding) { |
|
4904 self._stop(event); |
|
4905 self._change(event); |
|
4906 self._keySliding = false; |
|
4907 $(this).removeClass("ui-state-active"); |
|
4908 } |
|
4909 |
|
4910 }); |
|
4911 |
|
4912 this._refreshValue(); |
|
4913 |
|
4914 }, |
|
4915 |
|
4916 destroy: function() { |
|
4917 |
|
4918 this.handles.remove(); |
|
4919 |
|
4920 this.element |
|
4921 .removeClass("ui-slider" |
|
4922 + " ui-slider-horizontal" |
|
4923 + " ui-slider-vertical" |
|
4924 + " ui-slider-disabled" |
|
4925 + " ui-widget" |
|
4926 + " ui-widget-content" |
|
4927 + " ui-corner-all") |
|
4928 .removeData("slider") |
|
4929 .unbind(".slider"); |
|
4930 |
|
4931 this._mouseDestroy(); |
|
4932 |
|
4933 }, |
|
4934 |
|
4935 _mouseCapture: function(event) { |
|
4936 |
|
4937 var o = this.options; |
|
4938 |
|
4939 if (o.disabled) |
|
4940 return false; |
|
4941 |
|
4942 this._start(event); |
|
4943 |
|
4944 this.elementSize = { |
|
4945 width: this.element.outerWidth(), |
|
4946 height: this.element.outerHeight() |
|
4947 }; |
|
4948 this.elementOffset = this.element.offset(); |
|
4949 |
|
4950 var position = { x: event.pageX, y: event.pageY }; |
|
4951 var normValue = this._normValueFromMouse(position); |
|
4952 |
|
4953 var distance = this._valueMax() + 1, closestHandle; |
|
4954 var self = this, index; |
|
4955 this.handles.each(function(i) { |
|
4956 var thisDistance = Math.abs(normValue - self.values(i)); |
|
4957 if (distance > thisDistance) { |
|
4958 distance = thisDistance; |
|
4959 closestHandle = $(this); |
|
4960 index = i; |
|
4961 } |
|
4962 }); |
|
4963 |
|
4964 // workaround for bug #3736 (if both handles of a range are at 0, the first is always used as the one with least distance, |
|
4965 // and moving it is obviously prevented by preventing negative ranges) |
|
4966 if(o.range && (this.values(0) + this.values(1)) == 0) { |
|
4967 closestHandle = $(this.handles[++index]); |
|
4968 } |
|
4969 |
|
4970 self._handleIndex = index; |
|
4971 |
|
4972 closestHandle |
|
4973 .addClass("ui-state-active") |
|
4974 .focus(); |
|
4975 |
|
4976 var offset = closestHandle.offset(); |
|
4977 var mouseOverHandle = !$(event.target).parents().andSelf().is('.ui-slider-handle'); |
|
4978 this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : { |
|
4979 left: event.pageX - offset.left + (parseInt(closestHandle.css('marginLeft'),10) || 0), |
|
4980 top: event.pageY - offset.top + (parseInt(closestHandle.css('marginTop'),10) || 0) |
|
4981 }; |
|
4982 |
|
4983 normValue = this._normValueFromMouse(position); |
|
4984 this._slide(event, index, normValue); |
|
4985 return true; |
|
4986 |
|
4987 }, |
|
4988 |
|
4989 _mouseStart: function(event) { |
|
4990 return true; |
|
4991 }, |
|
4992 |
|
4993 _mouseDrag: function(event) { |
|
4994 |
|
4995 var position = { x: event.pageX, y: event.pageY }; |
|
4996 var normValue = this._normValueFromMouse(position); |
|
4997 |
|
4998 this._slide(event, this._handleIndex, normValue); |
|
4999 |
|
5000 return false; |
|
5001 |
|
5002 }, |
|
5003 |
|
5004 _mouseStop: function(event) { |
|
5005 |
|
5006 this.handles.removeClass("ui-state-active"); |
|
5007 this._stop(event); |
|
5008 this._change(event); |
|
5009 this._handleIndex = null; |
|
5010 this._clickOffset = null; |
|
5011 |
|
5012 return false; |
|
5013 |
|
5014 }, |
|
5015 |
|
5016 _detectOrientation: function() { |
|
5017 this.orientation = this.options.orientation == 'auto' ? (this.element[0].offsetWidth/this.element[0].offsetHeight > 1 ? 'horizontal' : 'vertical') : this.options.orientation; |
|
5018 }, |
|
5019 |
|
5020 _normValueFromMouse: function(position) { |
|
5021 |
|
5022 var pixelTotal, pixelMouse; |
|
5023 if ('horizontal' == this.orientation) { |
|
5024 pixelTotal = this.elementSize.width; |
|
5025 pixelMouse = position.x - this.elementOffset.left - (this._clickOffset ? this._clickOffset.left : 0); |
|
5026 } else { |
|
5027 pixelTotal = this.elementSize.height; |
|
5028 pixelMouse = position.y - this.elementOffset.top - (this._clickOffset ? this._clickOffset.top : 0); |
|
5029 } |
|
5030 |
|
5031 var percentMouse = (pixelMouse / pixelTotal); |
|
5032 if (percentMouse > 1) percentMouse = 1; |
|
5033 if (percentMouse < 0) percentMouse = 0; |
|
5034 if ('vertical' == this.orientation) |
|
5035 percentMouse = 1 - percentMouse; |
|
5036 |
|
5037 var valueTotal = this._valueMax() - this._valueMin(), |
|
5038 valueMouse = percentMouse * valueTotal, |
|
5039 valueMouseModStep = valueMouse % this.options.step, |
|
5040 normValue = this._valueMin() + valueMouse - valueMouseModStep; |
|
5041 |
|
5042 if (valueMouseModStep > (this.options.step / 2)) |
|
5043 normValue += this.options.step; |
|
5044 |
|
5045 return normValue; |
|
5046 |
|
5047 }, |
|
5048 |
|
5049 _start: function(event) { |
|
5050 this._trigger("start", event, { |
|
5051 value: this.value() |
|
5052 }); |
|
5053 }, |
|
5054 |
|
5055 _slide: function(event, index, newVal) { |
|
5056 |
|
5057 var handle = this.handles[index]; |
|
5058 |
|
5059 if (this.options.values && this.options.values.length) { |
|
5060 |
|
5061 var otherVal = this.values(index ? 0 : 1); |
|
5062 |
|
5063 if ((index == 0 && newVal >= otherVal) || (index == 1 && newVal <= otherVal)) |
|
5064 newVal = otherVal; |
|
5065 |
|
5066 if (newVal != this.values(index)) { |
|
5067 var newValues = this.values(); |
|
5068 newValues[index] = newVal; |
|
5069 // A slide can be canceled by returning false from the slide callback |
|
5070 var allowed = this._trigger("slide", event, { |
|
5071 handle: handle, |
|
5072 value: newVal, |
|
5073 values: newValues |
|
5074 }); |
|
5075 var otherVal = this.values(index ? 0 : 1); |
|
5076 if (allowed !== false) { |
|
5077 this.values(index, newVal, !( event.type == 'mousedown' && this.options.animate )); |
|
5078 } |
|
5079 } |
|
5080 |
|
5081 } else { |
|
5082 |
|
5083 if (newVal != this.value()) { |
|
5084 // A slide can be canceled by returning false from the slide callback |
|
5085 var allowed = this._trigger("slide", event, { |
|
5086 handle: handle, |
|
5087 value: newVal |
|
5088 }); |
|
5089 if (allowed !== false) { |
|
5090 this._setData('value', newVal, ( event.type == 'mousedown' && this.options.animate )); |
|
5091 } |
|
5092 |
|
5093 } |
|
5094 |
|
5095 } |
|
5096 |
|
5097 }, |
|
5098 |
|
5099 _stop: function(event) { |
|
5100 this._trigger("stop", event, { |
|
5101 value: this.value() |
|
5102 }); |
|
5103 }, |
|
5104 |
|
5105 _change: function(event) { |
|
5106 this._trigger("change", event, { |
|
5107 value: this.value() |
|
5108 }); |
|
5109 }, |
|
5110 |
|
5111 value: function(newValue) { |
|
5112 |
|
5113 if (arguments.length) { |
|
5114 this._setData("value", newValue); |
|
5115 this._change(); |
|
5116 } |
|
5117 |
|
5118 return this._value(); |
|
5119 |
|
5120 }, |
|
5121 |
|
5122 values: function(index, newValue, noAnimation) { |
|
5123 |
|
5124 if(!this.options.animate) noAnimation = true; |
|
5125 |
|
5126 if (arguments.length > 1) { |
|
5127 this.options.values[index] = newValue; |
|
5128 this._refreshValue(!noAnimation); |
|
5129 this._change(); |
|
5130 } |
|
5131 |
|
5132 if (arguments.length) { |
|
5133 if (this.options.values && this.options.values.length) { |
|
5134 return this._values(index); |
|
5135 } else { |
|
5136 return this.value(); |
|
5137 } |
|
5138 } else { |
|
5139 return this._values(); |
|
5140 } |
|
5141 |
|
5142 }, |
|
5143 |
|
5144 _setData: function(key, value) { |
|
5145 |
|
5146 $.widget.prototype._setData.apply(this, arguments); |
|
5147 |
|
5148 switch (key) { |
|
5149 case 'orientation': |
|
5150 |
|
5151 this._detectOrientation(); |
|
5152 |
|
5153 this.element |
|
5154 .removeClass("ui-slider-horizontal ui-slider-vertical") |
|
5155 .addClass("ui-slider-" + this.orientation); |
|
5156 this._refreshValue(); |
|
5157 break; |
|
5158 case 'value': |
|
5159 this._refreshValue(); |
|
5160 break; |
|
5161 } |
|
5162 |
|
5163 }, |
|
5164 |
|
5165 _step: function() { |
|
5166 var step = this.options.step; |
|
5167 return step; |
|
5168 }, |
|
5169 |
|
5170 _value: function() { |
|
5171 |
|
5172 var val = this.options.value; |
|
5173 if (val < this._valueMin()) val = this._valueMin(); |
|
5174 if (val > this._valueMax()) val = this._valueMax(); |
|
5175 |
|
5176 return val; |
|
5177 |
|
5178 }, |
|
5179 |
|
5180 _values: function(index) { |
|
5181 |
|
5182 if (arguments.length) { |
|
5183 var val = this.options.values[index]; |
|
5184 if (val < this._valueMin()) val = this._valueMin(); |
|
5185 if (val > this._valueMax()) val = this._valueMax(); |
|
5186 |
|
5187 return val; |
|
5188 } else { |
|
5189 return this.options.values; |
|
5190 } |
|
5191 |
|
5192 }, |
|
5193 |
|
5194 _valueMin: function() { |
|
5195 var valueMin = this.options.min; |
|
5196 return valueMin; |
|
5197 }, |
|
5198 |
|
5199 _valueMax: function() { |
|
5200 var valueMax = this.options.max; |
|
5201 return valueMax; |
|
5202 }, |
|
5203 |
|
5204 _refreshValue: function(animate) { |
|
5205 |
|
5206 var oRange = this.options.range, o = this.options, self = this; |
|
5207 |
|
5208 if (this.options.values && this.options.values.length) { |
|
5209 var vp0, vp1; |
|
5210 this.handles.each(function(i, j) { |
|
5211 var valPercent = (self.values(i) - self._valueMin()) / (self._valueMax() - self._valueMin()) * 100; |
|
5212 var _set = {}; _set[self.orientation == 'horizontal' ? 'left' : 'bottom'] = valPercent + '%'; |
|
5213 $(this).stop(1,1)[animate ? 'animate' : 'css'](_set, o.animate); |
|
5214 if (self.options.range === true) { |
|
5215 if (self.orientation == 'horizontal') { |
|
5216 (i == 0) && self.range.stop(1,1)[animate ? 'animate' : 'css']({ left: valPercent + '%' }, o.animate); |
|
5217 (i == 1) && self.range[animate ? 'animate' : 'css']({ width: (valPercent - lastValPercent) + '%' }, { queue: false, duration: o.animate }); |
|
5218 } else { |
|
5219 (i == 0) && self.range.stop(1,1)[animate ? 'animate' : 'css']({ bottom: (valPercent) + '%' }, o.animate); |
|
5220 (i == 1) && self.range[animate ? 'animate' : 'css']({ height: (valPercent - lastValPercent) + '%' }, { queue: false, duration: o.animate }); |
|
5221 } |
|
5222 } |
|
5223 lastValPercent = valPercent; |
|
5224 }); |
|
5225 } else { |
|
5226 var valPercent = (this.value() - this._valueMin()) / (this._valueMax() - this._valueMin()) * 100; |
|
5227 var _set = {}; _set[self.orientation == 'horizontal' ? 'left' : 'bottom'] = valPercent + '%'; |
|
5228 this.handle.stop(1,1)[animate ? 'animate' : 'css'](_set, o.animate); |
|
5229 |
|
5230 (oRange == "min") && (this.orientation == "horizontal") && this.range.stop(1,1)[animate ? 'animate' : 'css']({ left: 0, width: valPercent + '%' }, o.animate); |
|
5231 (oRange == "max") && (this.orientation == "horizontal") && this.range[animate ? 'animate' : 'css']({ left: valPercent + '%', width: (100 - valPercent) + '%' }, { queue: false, duration: o.animate }); |
|
5232 (oRange == "min") && (this.orientation == "vertical") && this.range.stop(1,1)[animate ? 'animate' : 'css']({ top: (100 - valPercent) + '%', height: valPercent + '%' }, o.animate); |
|
5233 (oRange == "max") && (this.orientation == "vertical") && this.range[animate ? 'animate' : 'css']({ bottom: valPercent + '%', height: (100 - valPercent) + '%' }, { queue: false, duration: o.animate }); |
|
5234 } |
|
5235 |
|
5236 } |
|
5237 |
|
5238 })); |
|
5239 |
|
5240 $.extend($.ui.slider, { |
|
5241 getter: "value values", |
|
5242 version: "1.6rc6", |
|
5243 eventPrefix: "slide", |
|
5244 defaults: { |
|
5245 animate: false, |
|
5246 delay: 0, |
|
5247 distance: 0, |
|
5248 max: 100, |
|
5249 min: 0, |
|
5250 orientation: 'auto', |
|
5251 range: false, |
|
5252 step: 1, |
|
5253 value: 0, |
|
5254 values: null |
|
5255 } |
|
5256 }); |
|
5257 |
|
5258 })(jQuery); |
|
5259 /* |
|
5260 * jQuery UI Tabs 1.6rc6 |
|
5261 * |
|
5262 * Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about) |
|
5263 * Dual licensed under the MIT (MIT-LICENSE.txt) |
|
5264 * and GPL (GPL-LICENSE.txt) licenses. |
|
5265 * |
|
5266 * http://docs.jquery.com/UI/Tabs |
|
5267 * |
|
5268 * Depends: |
|
5269 * ui.core.js |
|
5270 */ |
|
5271 (function($) { |
|
5272 |
|
5273 $.widget("ui.tabs", { |
|
5274 |
|
5275 _init: function() { |
|
5276 // create tabs |
|
5277 this._tabify(true); |
|
5278 }, |
|
5279 |
|
5280 _setData: function(key, value) { |
|
5281 if ((/^selected/).test(key)) |
|
5282 this.select(value); |
|
5283 else { |
|
5284 this.options[key] = value; |
|
5285 this._tabify(); |
|
5286 } |
|
5287 }, |
|
5288 |
|
5289 _tabId: function(a) { |
|
5290 return a.title && a.title.replace(/\s/g, '_').replace(/[^A-Za-z0-9\-_:\.]/g, '') |
|
5291 || this.options.idPrefix + $.data(a); |
|
5292 }, |
|
5293 |
|
5294 _sanitizeSelector: function(hash) { |
|
5295 return hash.replace(/:/g, '\\:'); // we need this because an id may contain a ":" |
|
5296 }, |
|
5297 |
|
5298 _cookie: function() { |
|
5299 var cookie = this.cookie || (this.cookie = this.options.cookie.name || 'ui-tabs-' + $.data(this.list[0])); |
|
5300 return $.cookie.apply(null, [cookie].concat($.makeArray(arguments))); |
|
5301 }, |
|
5302 |
|
5303 _ui: function(tab, panel) { |
|
5304 return { |
|
5305 tab: tab, |
|
5306 panel: panel, |
|
5307 index: this.$tabs.index(tab) |
|
5308 }; |
|
5309 }, |
|
5310 |
|
5311 _tabify: function(init) { |
|
5312 |
|
5313 this.list = this.element.is('div') ? this.element.children('ul:first, ol:first').eq(0) : this.element; |
|
5314 this.$lis = $('li:has(a[href])', this.list); |
|
5315 this.$tabs = this.$lis.map(function() { return $('a', this)[0]; }); |
|
5316 this.$panels = $([]); |
|
5317 |
|
5318 var self = this, o = this.options; |
|
5319 |
|
5320 var fragmentId = /^#.+/; // Safari 2 reports '#' for an empty hash |
|
5321 this.$tabs.each(function(i, a) { |
|
5322 var href = $(a).attr('href'); |
|
5323 |
|
5324 // inline tab |
|
5325 if (fragmentId.test(href)) |
|
5326 self.$panels = self.$panels.add(self._sanitizeSelector(href)); |
|
5327 |
|
5328 // remote tab |
|
5329 else if (href != '#') { // prevent loading the page itself if href is just "#" |
|
5330 $.data(a, 'href.tabs', href); // required for restore on destroy |
|
5331 |
|
5332 // TODO until #3808 is fixed strip fragment identifier from url |
|
5333 // (IE fails to load from such url) |
|
5334 $.data(a, 'load.tabs', href.replace(/#.*$/, '')); // mutable data |
|
5335 |
|
5336 var id = self._tabId(a); |
|
5337 a.href = '#' + id; |
|
5338 var $panel = $('#' + id); |
|
5339 if (!$panel.length) { |
|
5340 $panel = $(o.panelTemplate).attr('id', id).addClass('ui-tabs-panel ui-widget-content ui-corner-bottom') |
|
5341 .insertAfter(self.$panels[i - 1] || self.list); |
|
5342 $panel.data('destroy.tabs', true); |
|
5343 } |
|
5344 self.$panels = self.$panels.add($panel); |
|
5345 } |
|
5346 |
|
5347 // invalid tab href |
|
5348 else |
|
5349 o.disabled.push(i + 1); |
|
5350 }); |
|
5351 |
|
5352 // initialization from scratch |
|
5353 if (init) { |
|
5354 |
|
5355 // attach necessary classes for styling |
|
5356 if (this.element.is('div')) { |
|
5357 this.element.addClass('ui-tabs ui-widget ui-widget-content ui-corner-all'); |
|
5358 } |
|
5359 this.list.addClass('ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all'); |
|
5360 this.$lis.addClass('ui-state-default ui-corner-top'); |
|
5361 this.$panels.addClass('ui-tabs-panel ui-widget-content ui-corner-bottom'); |
|
5362 |
|
5363 // Selected tab |
|
5364 // use "selected" option or try to retrieve: |
|
5365 // 1. from fragment identifier in url |
|
5366 // 2. from cookie |
|
5367 // 3. from selected class attribute on <li> |
|
5368 if (o.selected === undefined) { |
|
5369 if (location.hash) { |
|
5370 this.$tabs.each(function(i, a) { |
|
5371 if (a.hash == location.hash) { |
|
5372 o.selected = i; |
|
5373 return false; // break |
|
5374 } |
|
5375 }); |
|
5376 } |
|
5377 else if (o.cookie) |
|
5378 o.selected = parseInt(self._cookie(), 10); |
|
5379 |
|
5380 else if (this.$lis.filter('.ui-tabs-selected').length) |
|
5381 o.selected = this.$lis.index(this.$lis.filter('.ui-tabs-selected')); |
|
5382 |
|
5383 else |
|
5384 o.selected = 0; |
|
5385 |
|
5386 } |
|
5387 else if (o.selected === null) |
|
5388 o.selected = -1; |
|
5389 |
|
5390 // sanity check |
|
5391 o.selected = ((o.selected >= 0 && this.$tabs[o.selected]) || o.selected < 0) ? o.selected : 0; // default to first tab |
|
5392 |
|
5393 // Take disabling tabs via class attribute from HTML |
|
5394 // into account and update option properly. |
|
5395 // A selected tab cannot become disabled. |
|
5396 o.disabled = $.unique(o.disabled.concat( |
|
5397 $.map(this.$lis.filter('.ui-state-disabled'), |
|
5398 function(n, i) { return self.$lis.index(n); } ) |
|
5399 )).sort(); |
|
5400 if ($.inArray(o.selected, o.disabled) != -1) |
|
5401 o.disabled.splice($.inArray(o.selected, o.disabled), 1); |
|
5402 |
|
5403 // highlight selected tab |
|
5404 this.$panels.addClass('ui-tabs-hide'); |
|
5405 this.$lis.removeClass('ui-tabs-selected ui-state-active'); |
|
5406 if (o.selected >= 0 && this.$tabs.length) { // check for length avoids error when initializing empty list |
|
5407 this.$panels.eq(o.selected).removeClass('ui-tabs-hide'); |
|
5408 var classes = ['ui-tabs-selected ui-state-active']; |
|
5409 if (o.deselectable) classes.push('ui-tabs-deselectable'); |
|
5410 this.$lis.eq(o.selected).addClass(classes.join(' ')); |
|
5411 |
|
5412 // seems to be expected behavior that the show callback is fired |
|
5413 var onShow = function() { |
|
5414 self._trigger('show', null, |
|
5415 self._ui(self.$tabs[o.selected], self.$panels[o.selected])); |
|
5416 }; |
|
5417 |
|
5418 // load if remote tab |
|
5419 if ($.data(this.$tabs[o.selected], 'load.tabs')) |
|
5420 this.load(o.selected, onShow); |
|
5421 // just trigger show event |
|
5422 else onShow(); |
|
5423 } |
|
5424 |
|
5425 // states |
|
5426 if (o.event != 'mouseover') { |
|
5427 var handleState = function(state, el) { |
|
5428 if (el.is(':not(.ui-state-disabled)')) el.toggleClass('ui-state-' + state); |
|
5429 }; |
|
5430 this.$lis.bind('mouseover.tabs mouseout.tabs', function() { |
|
5431 handleState('hover', $(this)); |
|
5432 }); |
|
5433 // TODO focus/blur don't seem to work with namespace |
|
5434 this.$tabs.bind('focus.tabs blur.tabs', function() { |
|
5435 handleState('focus', $(this).parents('li:first')); |
|
5436 }); |
|
5437 } |
|
5438 |
|
5439 // clean up to avoid memory leaks in certain versions of IE 6 |
|
5440 $(window).bind('unload', function() { |
|
5441 self.$lis.add(self.$tabs).unbind('.tabs'); |
|
5442 self.$lis = self.$tabs = self.$panels = null; |
|
5443 }); |
|
5444 |
|
5445 } |
|
5446 // update selected after add/remove |
|
5447 else |
|
5448 o.selected = this.$lis.index(this.$lis.filter('.ui-tabs-selected')); |
|
5449 |
|
5450 // set or update cookie after init and add/remove respectively |
|
5451 if (o.cookie) this._cookie(o.selected, o.cookie); |
|
5452 |
|
5453 // disable tabs |
|
5454 for (var i = 0, li; li = this.$lis[i]; i++) |
|
5455 $(li)[$.inArray(i, o.disabled) != -1 && !$(li).hasClass('ui-tabs-selected') ? 'addClass' : 'removeClass']('ui-state-disabled'); |
|
5456 |
|
5457 // reset cache if switching from cached to not cached |
|
5458 if (o.cache === false) this.$tabs.removeData('cache.tabs'); |
|
5459 |
|
5460 // set up animations |
|
5461 var hideFx, showFx; |
|
5462 if (o.fx) { |
|
5463 if ($.isArray(o.fx)) { |
|
5464 hideFx = o.fx[0]; |
|
5465 showFx = o.fx[1]; |
|
5466 } |
|
5467 else hideFx = showFx = o.fx; |
|
5468 } |
|
5469 |
|
5470 // Reset certain styles left over from animation |
|
5471 // and prevent IE's ClearType bug... |
|
5472 function resetStyle($el, fx) { |
|
5473 $el.css({ display: '' }); |
|
5474 if ($.browser.msie && fx.opacity) $el[0].style.removeAttribute('filter'); |
|
5475 } |
|
5476 |
|
5477 // Show a tab... |
|
5478 var showTab = showFx ? |
|
5479 function(clicked, $show) { |
|
5480 $show.hide().removeClass('ui-tabs-hide') // avoid flicker that way |
|
5481 .animate(showFx, 500, function() { |
|
5482 resetStyle($show, showFx); |
|
5483 self._trigger('show', null, self._ui(clicked, $show[0])); |
|
5484 }); |
|
5485 } : |
|
5486 function(clicked, $show) { |
|
5487 $show.removeClass('ui-tabs-hide'); |
|
5488 self._trigger('show', null, self._ui(clicked, $show[0])); |
|
5489 }; |
|
5490 |
|
5491 // Hide a tab, $show is optional... |
|
5492 var hideTab = hideFx ? |
|
5493 function(clicked, $hide, $show) { |
|
5494 $hide.animate(hideFx, hideFx.duration || 'normal', function() { |
|
5495 $hide.addClass('ui-tabs-hide'); |
|
5496 resetStyle($hide, hideFx); |
|
5497 if ($show) showTab(clicked, $show); |
|
5498 }); |
|
5499 } : |
|
5500 function(clicked, $hide, $show) { |
|
5501 $hide.addClass('ui-tabs-hide'); |
|
5502 if ($show) showTab(clicked, $show); |
|
5503 }; |
|
5504 |
|
5505 // Switch a tab... |
|
5506 function switchTab(clicked, $li, $hide, $show) { |
|
5507 var classes = ['ui-tabs-selected ui-state-active']; |
|
5508 if (o.deselectable) classes.push('ui-tabs-deselectable'); |
|
5509 $li.removeClass('ui-state-default').addClass(classes.join(' ')) |
|
5510 .siblings().removeClass(classes.join(' ')).addClass('ui-state-default'); |
|
5511 hideTab(clicked, $hide, $show); |
|
5512 } |
|
5513 |
|
5514 // attach tab event handler, unbind to avoid duplicates from former tabifying... |
|
5515 this.$tabs.unbind('.tabs').bind(o.event + '.tabs', function() { |
|
5516 |
|
5517 var $li = $(this).parents('li:eq(0)'), |
|
5518 $hide = self.$panels.filter(':visible'), |
|
5519 $show = $(self._sanitizeSelector(this.hash)); |
|
5520 |
|
5521 // If tab is already selected and not deselectable or tab disabled or |
|
5522 // or is already loading or click callback returns false stop here. |
|
5523 // Check if click handler returns false last so that it is not executed |
|
5524 // for a disabled or loading tab! |
|
5525 if (($li.hasClass('ui-state-active') && !o.deselectable) |
|
5526 || $li.hasClass('ui-state-disabled') |
|
5527 || $(this).hasClass('ui-tabs-loading') |
|
5528 || self._trigger('select', null, self._ui(this, $show[0])) === false |
|
5529 ) { |
|
5530 this.blur(); |
|
5531 return false; |
|
5532 } |
|
5533 |
|
5534 o.selected = self.$tabs.index(this); |
|
5535 |
|
5536 // if tab may be closed TODO avoid redundant code in this block |
|
5537 if (o.deselectable) { |
|
5538 if ($li.hasClass('ui-state-active')) { |
|
5539 o.selected = -1; |
|
5540 if (o.cookie) self._cookie(o.selected, o.cookie); |
|
5541 $li.removeClass('ui-tabs-selected ui-state-active ui-tabs-deselectable') |
|
5542 .addClass('ui-state-default'); |
|
5543 self.$panels.stop(); |
|
5544 hideTab(this, $hide); |
|
5545 this.blur(); |
|
5546 return false; |
|
5547 } else if (!$hide.length) { |
|
5548 if (o.cookie) self._cookie(o.selected, o.cookie); |
|
5549 self.$panels.stop(); |
|
5550 var a = this; |
|
5551 self.load(self.$tabs.index(this), function() { |
|
5552 $li.addClass('ui-tabs-selected ui-state-active ui-tabs-deselectable') |
|
5553 .removeClass('ui-state-default'); |
|
5554 showTab(a, $show); |
|
5555 }); |
|
5556 this.blur(); |
|
5557 return false; |
|
5558 } |
|
5559 } |
|
5560 |
|
5561 if (o.cookie) self._cookie(o.selected, o.cookie); |
|
5562 |
|
5563 // stop possibly running animations |
|
5564 self.$panels.stop(); |
|
5565 |
|
5566 // show new tab |
|
5567 if ($show.length) { |
|
5568 var a = this; |
|
5569 self.load(self.$tabs.index(this), $hide.length ? |
|
5570 function() { |
|
5571 switchTab(a, $li, $hide, $show); |
|
5572 } : |
|
5573 function() { |
|
5574 $li.addClass('ui-tabs-selected ui-state-active').removeClass('ui-state-default'); |
|
5575 showTab(a, $show); |
|
5576 } |
|
5577 ); |
|
5578 } else |
|
5579 throw 'jQuery UI Tabs: Mismatching fragment identifier.'; |
|
5580 |
|
5581 // Prevent IE from keeping other link focussed when using the back button |
|
5582 // and remove dotted border from clicked link. This is controlled via CSS |
|
5583 // in modern browsers; blur() removes focus from address bar in Firefox |
|
5584 // which can become a usability and annoying problem with tabs('rotate'). |
|
5585 if ($.browser.msie) this.blur(); |
|
5586 |
|
5587 return false; |
|
5588 |
|
5589 }); |
|
5590 |
|
5591 // disable click if event is configured to something else |
|
5592 if (o.event != 'click') this.$tabs.bind('click.tabs', function(){return false;}); |
|
5593 |
|
5594 }, |
|
5595 |
|
5596 destroy: function() { |
|
5597 var o = this.options; |
|
5598 |
|
5599 this.element |
|
5600 .removeClass('ui-tabs ui-widget ui-widget-content ui-corner-all'); |
|
5601 |
|
5602 this.list.unbind('.tabs') |
|
5603 .removeClass('ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all') |
|
5604 .removeData('tabs'); |
|
5605 |
|
5606 this.$tabs.each(function() { |
|
5607 var href = $.data(this, 'href.tabs'); |
|
5608 if (href) |
|
5609 this.href = href; |
|
5610 var $this = $(this).unbind('.tabs'); |
|
5611 $.each(['href', 'load', 'cache'], function(i, prefix) { |
|
5612 $this.removeData(prefix + '.tabs'); |
|
5613 }); |
|
5614 }); |
|
5615 |
|
5616 this.$lis.unbind('.tabs').add(this.$panels).each(function() { |
|
5617 if ($.data(this, 'destroy.tabs')) |
|
5618 $(this).remove(); |
|
5619 else |
|
5620 $(this).removeClass( |
|
5621 'ui-state-default ' + |
|
5622 'ui-corner-top ' + |
|
5623 'ui-tabs-selected ' + |
|
5624 'ui-state-active ' + |
|
5625 'ui-tabs-deselectable ' + |
|
5626 'ui-state-disabled ' + |
|
5627 'ui-tabs-panel ' + |
|
5628 'ui-widget-content ' + |
|
5629 'ui-corner-bottom ' + |
|
5630 'ui-tabs-hide'); |
|
5631 }); |
|
5632 |
|
5633 if (o.cookie) |
|
5634 this._cookie(null, o.cookie); |
|
5635 }, |
|
5636 |
|
5637 add: function(url, label, index) { |
|
5638 if (index == undefined) |
|
5639 index = this.$tabs.length; // append by default |
|
5640 |
|
5641 var self = this, o = this.options; |
|
5642 var $li = $(o.tabTemplate.replace(/#\{href\}/g, url).replace(/#\{label\}/g, label)); |
|
5643 $li.addClass('ui-state-default ui-corner-top').data('destroy.tabs', true); |
|
5644 |
|
5645 var id = url.indexOf('#') == 0 ? url.replace('#', '') : this._tabId( $('a:first-child', $li)[0] ); |
|
5646 |
|
5647 // try to find an existing element before creating a new one |
|
5648 var $panel = $('#' + id); |
|
5649 if (!$panel.length) { |
|
5650 $panel = $(o.panelTemplate).attr('id', id).data('destroy.tabs', true); |
|
5651 } |
|
5652 $panel.addClass('ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide'); |
|
5653 if (index >= this.$lis.length) { |
|
5654 $li.appendTo(this.list); |
|
5655 $panel.appendTo(this.list[0].parentNode); |
|
5656 } |
|
5657 else { |
|
5658 $li.insertBefore(this.$lis[index]); |
|
5659 $panel.insertBefore(this.$panels[index]); |
|
5660 } |
|
5661 |
|
5662 o.disabled = $.map(o.disabled, |
|
5663 function(n, i) { return n >= index ? ++n : n }); |
|
5664 |
|
5665 this._tabify(); |
|
5666 |
|
5667 if (this.$tabs.length == 1) { // after tabify |
|
5668 $li.addClass('ui-tabs-selected ui-state-active'); |
|
5669 $panel.removeClass('ui-tabs-hide'); |
|
5670 var href = $.data(this.$tabs[0], 'load.tabs'); |
|
5671 if (href) this.load(0, function() { |
|
5672 self._trigger('show', null, |
|
5673 self._ui(self.$tabs[0], self.$panels[0])); |
|
5674 }); |
|
5675 } |
|
5676 |
|
5677 // callback |
|
5678 this._trigger('add', null, this._ui(this.$tabs[index], this.$panels[index])); |
|
5679 }, |
|
5680 |
|
5681 remove: function(index) { |
|
5682 var o = this.options, $li = this.$lis.eq(index).remove(), |
|
5683 $panel = this.$panels.eq(index).remove(); |
|
5684 |
|
5685 // If selected tab was removed focus tab to the right or |
|
5686 // in case the last tab was removed the tab to the left. |
|
5687 if ($li.hasClass('ui-tabs-selected') && this.$tabs.length > 1) |
|
5688 this.select(index + (index + 1 < this.$tabs.length ? 1 : -1)); |
|
5689 |
|
5690 o.disabled = $.map($.grep(o.disabled, function(n, i) { return n != index; }), |
|
5691 function(n, i) { return n >= index ? --n : n }); |
|
5692 |
|
5693 this._tabify(); |
|
5694 |
|
5695 // callback |
|
5696 this._trigger('remove', null, this._ui($li.find('a')[0], $panel[0])); |
|
5697 }, |
|
5698 |
|
5699 enable: function(index) { |
|
5700 var o = this.options; |
|
5701 if ($.inArray(index, o.disabled) == -1) |
|
5702 return; |
|
5703 |
|
5704 this.$lis.eq(index).removeClass('ui-state-disabled'); |
|
5705 o.disabled = $.grep(o.disabled, function(n, i) { return n != index; }); |
|
5706 |
|
5707 // callback |
|
5708 this._trigger('enable', null, this._ui(this.$tabs[index], this.$panels[index])); |
|
5709 }, |
|
5710 |
|
5711 disable: function(index) { |
|
5712 var self = this, o = this.options; |
|
5713 if (index != o.selected) { // cannot disable already selected tab |
|
5714 this.$lis.eq(index).addClass('ui-state-disabled'); |
|
5715 |
|
5716 o.disabled.push(index); |
|
5717 o.disabled.sort(); |
|
5718 |
|
5719 // callback |
|
5720 this._trigger('disable', null, this._ui(this.$tabs[index], this.$panels[index])); |
|
5721 } |
|
5722 }, |
|
5723 |
|
5724 select: function(index) { |
|
5725 if (typeof index == 'string') |
|
5726 index = this.$tabs.index(this.$tabs.filter('[href$=' + index + ']')); |
|
5727 this.$tabs.eq(index).trigger(this.options.event + '.tabs'); |
|
5728 }, |
|
5729 |
|
5730 load: function(index, callback) { // callback is for internal usage only |
|
5731 |
|
5732 var self = this, o = this.options, $a = this.$tabs.eq(index), a = $a[0], |
|
5733 bypassCache = callback == undefined || callback === false, url = $a.data('load.tabs'); |
|
5734 // TODO bypassCache == false should work |
|
5735 |
|
5736 callback = callback || function() {}; |
|
5737 |
|
5738 // no remote or from cache - just finish with callback |
|
5739 // TODO in any case: insert cancel running load here..! |
|
5740 |
|
5741 if (!url || !bypassCache && $.data(a, 'cache.tabs')) { |
|
5742 callback(); |
|
5743 return; |
|
5744 } |
|
5745 |
|
5746 // load remote from here on |
|
5747 |
|
5748 var inner = function(parent) { |
|
5749 var $parent = $(parent), $inner = $parent.find('*:last'); |
|
5750 return $inner.length && $inner.is(':not(img)') && $inner || $parent; |
|
5751 }; |
|
5752 var cleanup = function() { |
|
5753 self.$tabs.filter('.ui-tabs-loading').removeClass('ui-tabs-loading') |
|
5754 .each(function() { |
|
5755 if (o.spinner) |
|
5756 inner(this).parent().html(inner(this).data('label.tabs')); |
|
5757 }); |
|
5758 self.xhr = null; |
|
5759 }; |
|
5760 |
|
5761 if (o.spinner) { |
|
5762 var label = inner(a).html(); |
|
5763 inner(a).wrapInner('<em></em>') |
|
5764 .find('em').data('label.tabs', label).html(o.spinner); |
|
5765 } |
|
5766 |
|
5767 var ajaxOptions = $.extend({}, o.ajaxOptions, { |
|
5768 url: url, |
|
5769 success: function(r, s) { |
|
5770 $(self._sanitizeSelector(a.hash)).html(r); |
|
5771 cleanup(); |
|
5772 |
|
5773 if (o.cache) |
|
5774 $.data(a, 'cache.tabs', true); // if loaded once do not load them again |
|
5775 |
|
5776 // callbacks |
|
5777 self._trigger('load', null, self._ui(self.$tabs[index], self.$panels[index])); |
|
5778 try { |
|
5779 o.ajaxOptions.success(r, s); |
|
5780 } |
|
5781 catch (er) {} |
|
5782 |
|
5783 // This callback is required because the switch has to take |
|
5784 // place after loading has completed. Call last in order to |
|
5785 // fire load before show callback... |
|
5786 callback(); |
|
5787 } |
|
5788 }); |
|
5789 if (this.xhr) { |
|
5790 // terminate pending requests from other tabs and restore tab label |
|
5791 this.xhr.abort(); |
|
5792 cleanup(); |
|
5793 } |
|
5794 $a.addClass('ui-tabs-loading'); |
|
5795 self.xhr = $.ajax(ajaxOptions); |
|
5796 }, |
|
5797 |
|
5798 url: function(index, url) { |
|
5799 this.$tabs.eq(index).removeData('cache.tabs').data('load.tabs', url); |
|
5800 }, |
|
5801 |
|
5802 length: function() { |
|
5803 return this.$tabs.length; |
|
5804 } |
|
5805 |
|
5806 }); |
|
5807 |
|
5808 $.extend($.ui.tabs, { |
|
5809 version: '1.6rc6', |
|
5810 getter: 'length', |
|
5811 defaults: { |
|
5812 ajaxOptions: null, |
|
5813 cache: false, |
|
5814 cookie: null, // e.g. { expires: 7, path: '/', domain: 'jquery.com', secure: true } |
|
5815 deselectable: false, |
|
5816 disabled: [], |
|
5817 event: 'click', |
|
5818 fx: null, // e.g. { height: 'toggle', opacity: 'toggle', duration: 200 } |
|
5819 idPrefix: 'ui-tabs-', |
|
5820 panelTemplate: '<div></div>', |
|
5821 spinner: 'Loading…', |
|
5822 tabTemplate: '<li><a href="#{href}"><span>#{label}</span></a></li>' |
|
5823 } |
|
5824 }); |
|
5825 |
|
5826 /* |
|
5827 * Tabs Extensions |
|
5828 */ |
|
5829 |
|
5830 /* |
|
5831 * Rotate |
|
5832 */ |
|
5833 $.extend($.ui.tabs.prototype, { |
|
5834 rotation: null, |
|
5835 rotate: function(ms, continuing) { |
|
5836 |
|
5837 var self = this, t = this.options.selected; |
|
5838 |
|
5839 function rotate() { |
|
5840 clearTimeout(self.rotation); |
|
5841 self.rotation = setTimeout(function() { |
|
5842 t = ++t < self.$tabs.length ? t : 0; |
|
5843 self.select(t); |
|
5844 }, ms); |
|
5845 } |
|
5846 |
|
5847 // start rotation |
|
5848 if (ms) { |
|
5849 this.element.bind('tabsshow', rotate); // will not be attached twice |
|
5850 this.$tabs.bind(this.options.event + '.tabs', !continuing ? |
|
5851 function(e) { |
|
5852 if (e.clientX) { // in case of a true click |
|
5853 clearTimeout(self.rotation); |
|
5854 self.element.unbind('tabsshow', rotate); |
|
5855 } |
|
5856 } : |
|
5857 function(e) { |
|
5858 t = self.options.selected; |
|
5859 rotate(); |
|
5860 } |
|
5861 ); |
|
5862 rotate(); |
|
5863 } |
|
5864 // stop rotation |
|
5865 else { |
|
5866 clearTimeout(self.rotation); |
|
5867 this.element.unbind('tabsshow', rotate); |
|
5868 this.$tabs.unbind(this.options.event + '.tabs', stop); |
|
5869 } |
|
5870 } |
|
5871 }); |
|
5872 |
|
5873 })(jQuery); |
|
5874 /* |
|
5875 * jQuery UI Datepicker 1.6rc6 |
|
5876 * |
|
5877 * Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about) |
|
5878 * Dual licensed under the MIT (MIT-LICENSE.txt) |
|
5879 * and GPL (GPL-LICENSE.txt) licenses. |
|
5880 * |
|
5881 * http://docs.jquery.com/UI/Datepicker |
|
5882 * |
|
5883 * Depends: |
|
5884 * ui.core.js |
|
5885 */ |
|
5886 |
|
5887 (function($) { // hide the namespace |
|
5888 |
|
5889 $.extend($.ui, { datepicker: { version: "1.6rc6" } }); |
|
5890 |
|
5891 var PROP_NAME = 'datepicker'; |
|
5892 |
|
5893 /* Date picker manager. |
|
5894 Use the singleton instance of this class, $.datepicker, to interact with the date picker. |
|
5895 Settings for (groups of) date pickers are maintained in an instance object, |
|
5896 allowing multiple different settings on the same page. */ |
|
5897 |
|
5898 function Datepicker() { |
|
5899 this.debug = false; // Change this to true to start debugging |
|
5900 this._curInst = null; // The current instance in use |
|
5901 this._keyEvent = false; // If the last event was a key event |
|
5902 this._disabledInputs = []; // List of date picker inputs that have been disabled |
|
5903 this._datepickerShowing = false; // True if the popup picker is showing , false if not |
|
5904 this._inDialog = false; // True if showing within a "dialog", false if not |
|
5905 this._mainDivId = 'ui-datepicker-div'; // The ID of the main datepicker division |
|
5906 this._inlineClass = 'ui-datepicker-inline'; // The name of the inline marker class |
|
5907 this._appendClass = 'ui-datepicker-append'; // The name of the append marker class |
|
5908 this._triggerClass = 'ui-datepicker-trigger'; // The name of the trigger marker class |
|
5909 this._dialogClass = 'ui-datepicker-dialog'; // The name of the dialog marker class |
|
5910 this._disableClass = 'ui-datepicker-disabled'; // The name of the disabled covering marker class |
|
5911 this._unselectableClass = 'ui-datepicker-unselectable'; // The name of the unselectable cell marker class |
|
5912 this._currentClass = 'ui-datepicker-current-day'; // The name of the current day marker class |
|
5913 this._dayOverClass = 'ui-datepicker-days-cell-over'; // The name of the day hover marker class |
|
5914 this.regional = []; // Available regional settings, indexed by language code |
|
5915 this.regional[''] = { // Default regional settings |
|
5916 closeText: 'Done', // Display text for close link |
|
5917 prevText: 'Prev', // Display text for previous month link |
|
5918 nextText: 'Next', // Display text for next month link |
|
5919 currentText: 'Today', // Display text for current month link |
|
5920 monthNames: ['January','February','March','April','May','June', |
|
5921 'July','August','September','October','November','December'], // Names of months for drop-down and formatting |
|
5922 monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], // For formatting |
|
5923 dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], // For formatting |
|
5924 dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], // For formatting |
|
5925 dayNamesMin: ['Su','Mo','Tu','We','Th','Fr','Sa'], // Column headings for days starting at Sunday |
|
5926 dateFormat: 'mm/dd/yy', // See format options on parseDate |
|
5927 firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ... |
|
5928 isRTL: false // True if right-to-left language, false if left-to-right |
|
5929 }; |
|
5930 this._defaults = { // Global defaults for all the date picker instances |
|
5931 showOn: 'focus', // 'focus' for popup on focus, |
|
5932 // 'button' for trigger button, or 'both' for either |
|
5933 showAnim: 'show', // Name of jQuery animation for popup |
|
5934 showOptions: {}, // Options for enhanced animations |
|
5935 defaultDate: null, // Used when field is blank: actual date, |
|
5936 // +/-number for offset from today, null for today |
|
5937 appendText: '', // Display text following the input box, e.g. showing the format |
|
5938 buttonText: '...', // Text for trigger button |
|
5939 buttonImage: '', // URL for trigger button image |
|
5940 buttonImageOnly: false, // True if the image appears alone, false if it appears on a button |
|
5941 hideIfNoPrevNext: false, // True to hide next/previous month links |
|
5942 // if not applicable, false to just disable them |
|
5943 navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links |
|
5944 gotoCurrent: false, // True if today link goes back to current selection instead |
|
5945 changeMonth: false, // True if month can be selected directly, false if only prev/next |
|
5946 changeYear: false, // True if year can be selected directly, false if only prev/next |
|
5947 showMonthAfterYear: false, // True if the year select precedes month, false for month then year |
|
5948 yearRange: '-10:+10', // Range of years to display in drop-down, |
|
5949 // either relative to current year (-nn:+nn) or absolute (nnnn:nnnn) |
|
5950 showOtherMonths: false, // True to show dates in other months, false to leave blank |
|
5951 calculateWeek: this.iso8601Week, // How to calculate the week of the year, |
|
5952 // takes a Date and returns the number of the week for it |
|
5953 shortYearCutoff: '+10', // Short year values < this are in the current century, |
|
5954 // > this are in the previous century, |
|
5955 // string value starting with '+' for current year + value |
|
5956 minDate: null, // The earliest selectable date, or null for no limit |
|
5957 maxDate: null, // The latest selectable date, or null for no limit |
|
5958 duration: 'normal', // Duration of display/closure |
|
5959 beforeShowDay: null, // Function that takes a date and returns an array with |
|
5960 // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or '', |
|
5961 // [2] = cell title (optional), e.g. $.datepicker.noWeekends |
|
5962 beforeShow: null, // Function that takes an input field and |
|
5963 // returns a set of custom settings for the date picker |
|
5964 onSelect: null, // Define a callback function when a date is selected |
|
5965 onChangeMonthYear: null, // Define a callback function when the month or year is changed |
|
5966 onClose: null, // Define a callback function when the datepicker is closed |
|
5967 numberOfMonths: 1, // Number of months to show at a time |
|
5968 showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0) |
|
5969 stepMonths: 1, // Number of months to step back/forward |
|
5970 stepBigMonths: 12, // Number of months to step back/forward for the big links |
|
5971 altField: '', // Selector for an alternate field to store selected dates into |
|
5972 altFormat: '', // The date format to use for the alternate field |
|
5973 constrainInput: true, // The input is constrained by the current date format |
|
5974 showButtonPanel: false // True to show button panel, false to not show it |
|
5975 }; |
|
5976 $.extend(this._defaults, this.regional['']); |
|
5977 this.dpDiv = $('<div id="' + this._mainDivId + '" class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all ui-helper-hidden-accessible"></div>'); |
|
5978 } |
|
5979 |
|
5980 $.extend(Datepicker.prototype, { |
|
5981 /* Class name added to elements to indicate already configured with a date picker. */ |
|
5982 markerClassName: 'hasDatepicker', |
|
5983 |
|
5984 /* Debug logging (if enabled). */ |
|
5985 log: function () { |
|
5986 if (this.debug) |
|
5987 console.log.apply('', arguments); |
|
5988 }, |
|
5989 |
|
5990 /* Override the default settings for all instances of the date picker. |
|
5991 @param settings object - the new settings to use as defaults (anonymous object) |
|
5992 @return the manager object */ |
|
5993 setDefaults: function(settings) { |
|
5994 extendRemove(this._defaults, settings || {}); |
|
5995 return this; |
|
5996 }, |
|
5997 |
|
5998 /* Attach the date picker to a jQuery selection. |
|
5999 @param target element - the target input field or division or span |
|
6000 @param settings object - the new settings to use for this date picker instance (anonymous) */ |
|
6001 _attachDatepicker: function(target, settings) { |
|
6002 // check for settings on the control itself - in namespace 'date:' |
|
6003 var inlineSettings = null; |
|
6004 for (var attrName in this._defaults) { |
|
6005 var attrValue = target.getAttribute('date:' + attrName); |
|
6006 if (attrValue) { |
|
6007 inlineSettings = inlineSettings || {}; |
|
6008 try { |
|
6009 inlineSettings[attrName] = eval(attrValue); |
|
6010 } catch (err) { |
|
6011 inlineSettings[attrName] = attrValue; |
|
6012 } |
|
6013 } |
|
6014 } |
|
6015 var nodeName = target.nodeName.toLowerCase(); |
|
6016 var inline = (nodeName == 'div' || nodeName == 'span'); |
|
6017 if (!target.id) |
|
6018 target.id = 'dp' + (++this.uuid); |
|
6019 var inst = this._newInst($(target), inline); |
|
6020 inst.settings = $.extend({}, settings || {}, inlineSettings || {}); |
|
6021 if (nodeName == 'input') { |
|
6022 this._connectDatepicker(target, inst); |
|
6023 } else if (inline) { |
|
6024 this._inlineDatepicker(target, inst); |
|
6025 } |
|
6026 }, |
|
6027 |
|
6028 /* Create a new instance object. */ |
|
6029 _newInst: function(target, inline) { |
|
6030 var id = target[0].id.replace(/([:\[\]\.])/g, '\\\\$1'); // escape jQuery meta chars |
|
6031 return {id: id, input: target, // associated target |
|
6032 selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection |
|
6033 drawMonth: 0, drawYear: 0, // month being drawn |
|
6034 inline: inline, // is datepicker inline or not |
|
6035 dpDiv: (!inline ? this.dpDiv : // presentation div |
|
6036 $('<div class="' + this._inlineClass + ' ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>'))}; |
|
6037 }, |
|
6038 |
|
6039 /* Attach the date picker to an input field. */ |
|
6040 _connectDatepicker: function(target, inst) { |
|
6041 var input = $(target); |
|
6042 if (input.hasClass(this.markerClassName)) |
|
6043 return; |
|
6044 var appendText = this._get(inst, 'appendText'); |
|
6045 var isRTL = this._get(inst, 'isRTL'); |
|
6046 if (appendText) |
|
6047 input[isRTL ? 'before' : 'after']('<span class="' + this._appendClass + '">' + appendText + '</span>'); |
|
6048 var showOn = this._get(inst, 'showOn'); |
|
6049 if (showOn == 'focus' || showOn == 'both') // pop-up date picker when in the marked field |
|
6050 input.focus(this._showDatepicker); |
|
6051 if (showOn == 'button' || showOn == 'both') { // pop-up date picker when button clicked |
|
6052 var buttonText = this._get(inst, 'buttonText'); |
|
6053 var buttonImage = this._get(inst, 'buttonImage'); |
|
6054 var trigger = $(this._get(inst, 'buttonImageOnly') ? |
|
6055 $('<img/>').addClass(this._triggerClass). |
|
6056 attr({ src: buttonImage, alt: buttonText, title: buttonText }) : |
|
6057 $('<button type="button"></button>').addClass(this._triggerClass). |
|
6058 html(buttonImage == '' ? buttonText : $('<img/>').attr( |
|
6059 { src:buttonImage, alt:buttonText, title:buttonText }))); |
|
6060 input[isRTL ? 'before' : 'after'](trigger); |
|
6061 trigger.click(function() { |
|
6062 if ($.datepicker._datepickerShowing && $.datepicker._lastInput == target) |
|
6063 $.datepicker._hideDatepicker(); |
|
6064 else |
|
6065 $.datepicker._showDatepicker(target); |
|
6066 return false; |
|
6067 }); |
|
6068 } |
|
6069 input.addClass(this.markerClassName).keydown(this._doKeyDown).keypress(this._doKeyPress). |
|
6070 bind("setData.datepicker", function(event, key, value) { |
|
6071 inst.settings[key] = value; |
|
6072 }).bind("getData.datepicker", function(event, key) { |
|
6073 return this._get(inst, key); |
|
6074 }); |
|
6075 $.data(target, PROP_NAME, inst); |
|
6076 }, |
|
6077 |
|
6078 /* Attach an inline date picker to a div. */ |
|
6079 _inlineDatepicker: function(target, inst) { |
|
6080 var divSpan = $(target); |
|
6081 if (divSpan.hasClass(this.markerClassName)) |
|
6082 return; |
|
6083 divSpan.addClass(this.markerClassName).append(inst.dpDiv). |
|
6084 bind("setData.datepicker", function(event, key, value){ |
|
6085 inst.settings[key] = value; |
|
6086 }).bind("getData.datepicker", function(event, key){ |
|
6087 return this._get(inst, key); |
|
6088 }); |
|
6089 $.data(target, PROP_NAME, inst); |
|
6090 this._setDate(inst, this._getDefaultDate(inst)); |
|
6091 this._updateDatepicker(inst); |
|
6092 this._updateAlternate(inst); |
|
6093 }, |
|
6094 |
|
6095 /* Pop-up the date picker in a "dialog" box. |
|
6096 @param input element - ignored |
|
6097 @param dateText string - the initial date to display (in the current format) |
|
6098 @param onSelect function - the function(dateText) to call when a date is selected |
|
6099 @param settings object - update the dialog date picker instance's settings (anonymous object) |
|
6100 @param pos int[2] - coordinates for the dialog's position within the screen or |
|
6101 event - with x/y coordinates or |
|
6102 leave empty for default (screen centre) |
|
6103 @return the manager object */ |
|
6104 _dialogDatepicker: function(input, dateText, onSelect, settings, pos) { |
|
6105 var inst = this._dialogInst; // internal instance |
|
6106 if (!inst) { |
|
6107 var id = 'dp' + (++this.uuid); |
|
6108 this._dialogInput = $('<input type="text" id="' + id + |
|
6109 '" size="1" style="position: absolute; top: -100px;"/>'); |
|
6110 this._dialogInput.keydown(this._doKeyDown); |
|
6111 $('body').append(this._dialogInput); |
|
6112 inst = this._dialogInst = this._newInst(this._dialogInput, false); |
|
6113 inst.settings = {}; |
|
6114 $.data(this._dialogInput[0], PROP_NAME, inst); |
|
6115 } |
|
6116 extendRemove(inst.settings, settings || {}); |
|
6117 this._dialogInput.val(dateText); |
|
6118 |
|
6119 this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null); |
|
6120 if (!this._pos) { |
|
6121 var browserWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; |
|
6122 var browserHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight; |
|
6123 var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft; |
|
6124 var scrollY = document.documentElement.scrollTop || document.body.scrollTop; |
|
6125 this._pos = // should use actual width/height below |
|
6126 [(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY]; |
|
6127 } |
|
6128 |
|
6129 // move input on screen for focus, but hidden behind dialog |
|
6130 this._dialogInput.css('left', this._pos[0] + 'px').css('top', this._pos[1] + 'px'); |
|
6131 inst.settings.onSelect = onSelect; |
|
6132 this._inDialog = true; |
|
6133 this.dpDiv.addClass(this._dialogClass); |
|
6134 this._showDatepicker(this._dialogInput[0]); |
|
6135 if ($.blockUI) |
|
6136 $.blockUI(this.dpDiv); |
|
6137 $.data(this._dialogInput[0], PROP_NAME, inst); |
|
6138 return this; |
|
6139 }, |
|
6140 |
|
6141 /* Detach a datepicker from its control. |
|
6142 @param target element - the target input field or division or span */ |
|
6143 _destroyDatepicker: function(target) { |
|
6144 var $target = $(target); |
|
6145 if (!$target.hasClass(this.markerClassName)) { |
|
6146 return; |
|
6147 } |
|
6148 var nodeName = target.nodeName.toLowerCase(); |
|
6149 $.removeData(target, PROP_NAME); |
|
6150 if (nodeName == 'input') { |
|
6151 $target.siblings('.' + this._appendClass).remove().end(). |
|
6152 siblings('.' + this._triggerClass).remove().end(). |
|
6153 removeClass(this.markerClassName). |
|
6154 unbind('focus', this._showDatepicker). |
|
6155 unbind('keydown', this._doKeyDown). |
|
6156 unbind('keypress', this._doKeyPress); |
|
6157 } else if (nodeName == 'div' || nodeName == 'span') |
|
6158 $target.removeClass(this.markerClassName).empty(); |
|
6159 }, |
|
6160 |
|
6161 /* Enable the date picker to a jQuery selection. |
|
6162 @param target element - the target input field or division or span */ |
|
6163 _enableDatepicker: function(target) { |
|
6164 var $target = $(target); |
|
6165 if (!$target.hasClass(this.markerClassName)) { |
|
6166 return; |
|
6167 } |
|
6168 var nodeName = target.nodeName.toLowerCase(); |
|
6169 if (nodeName == 'input') { |
|
6170 target.disabled = false; |
|
6171 $target.siblings('button.' + this._triggerClass). |
|
6172 each(function() { this.disabled = false; }).end(). |
|
6173 siblings('img.' + this._triggerClass). |
|
6174 css({opacity: '1.0', cursor: ''}); |
|
6175 } |
|
6176 else if (nodeName == 'div' || nodeName == 'span') { |
|
6177 var inline = $target.children('.' + this._inlineClass); |
|
6178 inline.children().removeClass('ui-state-disabled'); |
|
6179 } |
|
6180 this._disabledInputs = $.map(this._disabledInputs, |
|
6181 function(value) { return (value == target ? null : value); }); // delete entry |
|
6182 }, |
|
6183 |
|
6184 /* Disable the date picker to a jQuery selection. |
|
6185 @param target element - the target input field or division or span */ |
|
6186 _disableDatepicker: function(target) { |
|
6187 var $target = $(target); |
|
6188 if (!$target.hasClass(this.markerClassName)) { |
|
6189 return; |
|
6190 } |
|
6191 var nodeName = target.nodeName.toLowerCase(); |
|
6192 if (nodeName == 'input') { |
|
6193 target.disabled = true; |
|
6194 $target.siblings('button.' + this._triggerClass). |
|
6195 each(function() { this.disabled = true; }).end(). |
|
6196 siblings('img.' + this._triggerClass). |
|
6197 css({opacity: '0.5', cursor: 'default'}); |
|
6198 } |
|
6199 else if (nodeName == 'div' || nodeName == 'span') { |
|
6200 var inline = $target.children('.' + this._inlineClass); |
|
6201 inline.children().addClass('ui-state-disabled'); |
|
6202 } |
|
6203 this._disabledInputs = $.map(this._disabledInputs, |
|
6204 function(value) { return (value == target ? null : value); }); // delete entry |
|
6205 this._disabledInputs[this._disabledInputs.length] = target; |
|
6206 }, |
|
6207 |
|
6208 /* Is the first field in a jQuery collection disabled as a datepicker? |
|
6209 @param target element - the target input field or division or span |
|
6210 @return boolean - true if disabled, false if enabled */ |
|
6211 _isDisabledDatepicker: function(target) { |
|
6212 if (!target) { |
|
6213 return false; |
|
6214 } |
|
6215 for (var i = 0; i < this._disabledInputs.length; i++) { |
|
6216 if (this._disabledInputs[i] == target) |
|
6217 return true; |
|
6218 } |
|
6219 return false; |
|
6220 }, |
|
6221 |
|
6222 /* Retrieve the instance data for the target control. |
|
6223 @param target element - the target input field or division or span |
|
6224 @return object - the associated instance data |
|
6225 @throws error if a jQuery problem getting data */ |
|
6226 _getInst: function(target) { |
|
6227 try { |
|
6228 return $.data(target, PROP_NAME); |
|
6229 } |
|
6230 catch (err) { |
|
6231 throw 'Missing instance data for this datepicker'; |
|
6232 } |
|
6233 }, |
|
6234 |
|
6235 /* Update the settings for a date picker attached to an input field or division. |
|
6236 @param target element - the target input field or division or span |
|
6237 @param name object - the new settings to update or |
|
6238 string - the name of the setting to change or |
|
6239 @param value any - the new value for the setting (omit if above is an object) */ |
|
6240 _optionDatepicker: function(target, name, value) { |
|
6241 var settings = name || {}; |
|
6242 if (typeof name == 'string') { |
|
6243 settings = {}; |
|
6244 settings[name] = value; |
|
6245 } |
|
6246 var inst = this._getInst(target); |
|
6247 if (inst) { |
|
6248 if (this._curInst == inst) { |
|
6249 this._hideDatepicker(null); |
|
6250 } |
|
6251 extendRemove(inst.settings, settings); |
|
6252 var date = new Date(); |
|
6253 extendRemove(inst, {rangeStart: null, // start of range |
|
6254 endDay: null, endMonth: null, endYear: null, // end of range |
|
6255 selectedDay: date.getDate(), selectedMonth: date.getMonth(), |
|
6256 selectedYear: date.getFullYear(), // starting point |
|
6257 currentDay: date.getDate(), currentMonth: date.getMonth(), |
|
6258 currentYear: date.getFullYear(), // current selection |
|
6259 drawMonth: date.getMonth(), drawYear: date.getFullYear()}); // month being drawn |
|
6260 this._updateDatepicker(inst); |
|
6261 } |
|
6262 }, |
|
6263 |
|
6264 // change method deprecated |
|
6265 _changeDatepicker: function(target, name, value) { |
|
6266 this._optionDatepicker(target, name, value); |
|
6267 }, |
|
6268 |
|
6269 /* Redraw the date picker attached to an input field or division. |
|
6270 @param target element - the target input field or division or span */ |
|
6271 _refreshDatepicker: function(target) { |
|
6272 var inst = this._getInst(target); |
|
6273 if (inst) { |
|
6274 this._updateDatepicker(inst); |
|
6275 } |
|
6276 }, |
|
6277 |
|
6278 /* Set the dates for a jQuery selection. |
|
6279 @param target element - the target input field or division or span |
|
6280 @param date Date - the new date |
|
6281 @param endDate Date - the new end date for a range (optional) */ |
|
6282 _setDateDatepicker: function(target, date, endDate) { |
|
6283 var inst = this._getInst(target); |
|
6284 if (inst) { |
|
6285 this._setDate(inst, date, endDate); |
|
6286 this._updateDatepicker(inst); |
|
6287 this._updateAlternate(inst); |
|
6288 } |
|
6289 }, |
|
6290 |
|
6291 /* Get the date(s) for the first entry in a jQuery selection. |
|
6292 @param target element - the target input field or division or span |
|
6293 @return Date - the current date or |
|
6294 Date[2] - the current dates for a range */ |
|
6295 _getDateDatepicker: function(target) { |
|
6296 var inst = this._getInst(target); |
|
6297 if (inst && !inst.inline) |
|
6298 this._setDateFromField(inst); |
|
6299 return (inst ? this._getDate(inst) : null); |
|
6300 }, |
|
6301 |
|
6302 /* Handle keystrokes. */ |
|
6303 _doKeyDown: function(event) { |
|
6304 var inst = $.datepicker._getInst(event.target); |
|
6305 var handled = true; |
|
6306 var isRTL = inst.dpDiv.is('.ui-datepicker-rtl'); |
|
6307 inst._keyEvent = true; |
|
6308 if ($.datepicker._datepickerShowing) |
|
6309 switch (event.keyCode) { |
|
6310 case 9: $.datepicker._hideDatepicker(null, ''); |
|
6311 break; // hide on tab out |
|
6312 case 13: var sel = $('td.' + $.datepicker._dayOverClass + |
|
6313 ', td.' + $.datepicker._currentClass, inst.dpDiv); |
|
6314 if (sel[0]) |
|
6315 $.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]); |
|
6316 else |
|
6317 $.datepicker._hideDatepicker(null, $.datepicker._get(inst, 'duration')); |
|
6318 return false; // don't submit the form |
|
6319 break; // select the value on enter |
|
6320 case 27: $.datepicker._hideDatepicker(null, $.datepicker._get(inst, 'duration')); |
|
6321 break; // hide on escape |
|
6322 case 33: $.datepicker._adjustDate(event.target, (event.ctrlKey ? |
|
6323 -$.datepicker._get(inst, 'stepBigMonths') : |
|
6324 -$.datepicker._get(inst, 'stepMonths')), 'M'); |
|
6325 break; // previous month/year on page up/+ ctrl |
|
6326 case 34: $.datepicker._adjustDate(event.target, (event.ctrlKey ? |
|
6327 +$.datepicker._get(inst, 'stepBigMonths') : |
|
6328 +$.datepicker._get(inst, 'stepMonths')), 'M'); |
|
6329 break; // next month/year on page down/+ ctrl |
|
6330 case 35: if (event.ctrlKey || event.metaKey) $.datepicker._clearDate(event.target); |
|
6331 handled = event.ctrlKey || event.metaKey; |
|
6332 break; // clear on ctrl or command +end |
|
6333 case 36: if (event.ctrlKey || event.metaKey) $.datepicker._gotoToday(event.target); |
|
6334 handled = event.ctrlKey || event.metaKey; |
|
6335 break; // current on ctrl or command +home |
|
6336 case 37: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, (isRTL ? +1 : -1), 'D'); |
|
6337 handled = event.ctrlKey || event.metaKey; |
|
6338 // -1 day on ctrl or command +left |
|
6339 if (event.originalEvent.altKey) $.datepicker._adjustDate(event.target, (event.ctrlKey ? |
|
6340 -$.datepicker._get(inst, 'stepBigMonths') : |
|
6341 -$.datepicker._get(inst, 'stepMonths')), 'M'); |
|
6342 // next month/year on alt +left on Mac |
|
6343 break; |
|
6344 case 38: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, -7, 'D'); |
|
6345 handled = event.ctrlKey || event.metaKey; |
|
6346 break; // -1 week on ctrl or command +up |
|
6347 case 39: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, (isRTL ? -1 : +1), 'D'); |
|
6348 handled = event.ctrlKey || event.metaKey; |
|
6349 // +1 day on ctrl or command +right |
|
6350 if (event.originalEvent.altKey) $.datepicker._adjustDate(event.target, (event.ctrlKey ? |
|
6351 +$.datepicker._get(inst, 'stepBigMonths') : |
|
6352 +$.datepicker._get(inst, 'stepMonths')), 'M'); |
|
6353 // next month/year on alt +right |
|
6354 break; |
|
6355 case 40: if (event.ctrlKey || event.metaKey) $.datepicker._adjustDate(event.target, +7, 'D'); |
|
6356 handled = event.ctrlKey || event.metaKey; |
|
6357 break; // +1 week on ctrl or command +down |
|
6358 default: handled = false; |
|
6359 } |
|
6360 else if (event.keyCode == 36 && event.ctrlKey) // display the date picker on ctrl+home |
|
6361 $.datepicker._showDatepicker(this); |
|
6362 else { |
|
6363 handled = false; |
|
6364 } |
|
6365 if (handled) { |
|
6366 event.preventDefault(); |
|
6367 event.stopPropagation(); |
|
6368 } |
|
6369 }, |
|
6370 |
|
6371 /* Filter entered characters - based on date format. */ |
|
6372 _doKeyPress: function(event) { |
|
6373 var inst = $.datepicker._getInst(event.target); |
|
6374 if ($.datepicker._get(inst, 'constrainInput')) { |
|
6375 var chars = $.datepicker._possibleChars($.datepicker._get(inst, 'dateFormat')); |
|
6376 var chr = String.fromCharCode(event.charCode == undefined ? event.keyCode : event.charCode); |
|
6377 return event.ctrlKey || (chr < ' ' || !chars || chars.indexOf(chr) > -1); |
|
6378 } |
|
6379 }, |
|
6380 |
|
6381 /* Pop-up the date picker for a given input field. |
|
6382 @param input element - the input field attached to the date picker or |
|
6383 event - if triggered by focus */ |
|
6384 _showDatepicker: function(input) { |
|
6385 input = input.target || input; |
|
6386 if (input.nodeName.toLowerCase() != 'input') // find from button/image trigger |
|
6387 input = $('input', input.parentNode)[0]; |
|
6388 if ($.datepicker._isDisabledDatepicker(input) || $.datepicker._lastInput == input) // already here |
|
6389 return; |
|
6390 var inst = $.datepicker._getInst(input); |
|
6391 var beforeShow = $.datepicker._get(inst, 'beforeShow'); |
|
6392 extendRemove(inst.settings, (beforeShow ? beforeShow.apply(input, [input, inst]) : {})); |
|
6393 $.datepicker._hideDatepicker(null, ''); |
|
6394 $.datepicker._lastInput = input; |
|
6395 $.datepicker._setDateFromField(inst); |
|
6396 if ($.datepicker._inDialog) // hide cursor |
|
6397 input.value = ''; |
|
6398 if (!$.datepicker._pos) { // position below input |
|
6399 $.datepicker._pos = $.datepicker._findPos(input); |
|
6400 $.datepicker._pos[1] += input.offsetHeight; // add the height |
|
6401 } |
|
6402 var isFixed = false; |
|
6403 $(input).parents().each(function() { |
|
6404 isFixed |= $(this).css('position') == 'fixed'; |
|
6405 return !isFixed; |
|
6406 }); |
|
6407 if (isFixed && $.browser.opera) { // correction for Opera when fixed and scrolled |
|
6408 $.datepicker._pos[0] -= document.documentElement.scrollLeft; |
|
6409 $.datepicker._pos[1] -= document.documentElement.scrollTop; |
|
6410 } |
|
6411 var offset = {left: $.datepicker._pos[0], top: $.datepicker._pos[1]}; |
|
6412 $.datepicker._pos = null; |
|
6413 inst.rangeStart = null; |
|
6414 // determine sizing offscreen |
|
6415 inst.dpDiv.css({position: 'absolute', display: 'block', top: '-1000px'}); |
|
6416 $.datepicker._updateDatepicker(inst); |
|
6417 // fix width for dynamic number of date pickers |
|
6418 // and adjust position before showing |
|
6419 offset = $.datepicker._checkOffset(inst, offset, isFixed); |
|
6420 inst.dpDiv.css({position: ($.datepicker._inDialog && $.blockUI ? |
|
6421 'static' : (isFixed ? 'fixed' : 'absolute')), display: 'none', |
|
6422 left: offset.left + 'px', top: offset.top + 'px'}); |
|
6423 if (!inst.inline) { |
|
6424 var showAnim = $.datepicker._get(inst, 'showAnim') || 'show'; |
|
6425 var duration = $.datepicker._get(inst, 'duration'); |
|
6426 var postProcess = function() { |
|
6427 $.datepicker._datepickerShowing = true; |
|
6428 if ($.browser.msie && parseInt($.browser.version,10) < 7) // fix IE < 7 select problems |
|
6429 $('iframe.ui-datepicker-cover').css({width: inst.dpDiv.width() + 4, |
|
6430 height: inst.dpDiv.height() + 4}); |
|
6431 }; |
|
6432 if ($.effects && $.effects[showAnim]) |
|
6433 inst.dpDiv.show(showAnim, $.datepicker._get(inst, 'showOptions'), duration, postProcess); |
|
6434 else |
|
6435 inst.dpDiv[showAnim](duration, postProcess); |
|
6436 if (duration == '') |
|
6437 postProcess(); |
|
6438 if (inst.input[0].type != 'hidden') |
|
6439 inst.input[0].focus(); |
|
6440 $.datepicker._curInst = inst; |
|
6441 } |
|
6442 }, |
|
6443 |
|
6444 /* Generate the date picker content. */ |
|
6445 _updateDatepicker: function(inst) { |
|
6446 var dims = {width: inst.dpDiv.width() + 4, |
|
6447 height: inst.dpDiv.height() + 4}; |
|
6448 var self = this; |
|
6449 inst.dpDiv.empty().append(this._generateHTML(inst)) |
|
6450 .find('iframe.ui-datepicker-cover'). |
|
6451 css({width: dims.width, height: dims.height}) |
|
6452 .end() |
|
6453 .find('button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a') |
|
6454 .bind('mouseout', function(){ |
|
6455 $(this).removeClass('ui-state-hover'); |
|
6456 if(this.className.indexOf('ui-datepicker-prev') != -1) $(this).removeClass('ui-datepicker-prev-hover'); |
|
6457 if(this.className.indexOf('ui-datepicker-next') != -1) $(this).removeClass('ui-datepicker-next-hover'); |
|
6458 }) |
|
6459 .bind('mouseover', function(){ |
|
6460 if (!self._isDisabledDatepicker( inst.inline ? inst.dpDiv.parent()[0] : inst.input[0])) { |
|
6461 $(this).parents('.ui-datepicker-calendar').find('a').removeClass('ui-state-hover'); |
|
6462 $(this).addClass('ui-state-hover'); |
|
6463 if(this.className.indexOf('ui-datepicker-prev') != -1) $(this).addClass('ui-datepicker-prev-hover'); |
|
6464 if(this.className.indexOf('ui-datepicker-next') != -1) $(this).addClass('ui-datepicker-next-hover'); |
|
6465 } |
|
6466 }) |
|
6467 .end() |
|
6468 .find('.' + this._dayOverClass + ' a') |
|
6469 .trigger('mouseover') |
|
6470 .end(); |
|
6471 var numMonths = this._getNumberOfMonths(inst); |
|
6472 var cols = numMonths[1]; |
|
6473 var width = 17; |
|
6474 if (cols > 1) { |
|
6475 inst.dpDiv.addClass('ui-datepicker-multi-' + cols).css('width', (width * cols) + 'em'); |
|
6476 } else { |
|
6477 inst.dpDiv.removeClass('ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4').width(''); |
|
6478 } |
|
6479 inst.dpDiv[(numMonths[0] != 1 || numMonths[1] != 1 ? 'add' : 'remove') + |
|
6480 'Class']('ui-datepicker-multi'); |
|
6481 inst.dpDiv[(this._get(inst, 'isRTL') ? 'add' : 'remove') + |
|
6482 'Class']('ui-datepicker-rtl'); |
|
6483 if (inst.input && inst.input[0].type != 'hidden' && inst == $.datepicker._curInst) |
|
6484 $(inst.input[0]).focus(); |
|
6485 }, |
|
6486 |
|
6487 /* Check positioning to remain on screen. */ |
|
6488 _checkOffset: function(inst, offset, isFixed) { |
|
6489 var dpWidth = inst.dpDiv.outerWidth(); |
|
6490 var dpHeight = inst.dpDiv.outerHeight(); |
|
6491 var inputWidth = inst.input ? inst.input.outerWidth() : 0; |
|
6492 var inputHeight = inst.input ? inst.input.outerHeight() : 0; |
|
6493 var viewWidth = (window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth) + $(document).scrollLeft(); |
|
6494 var viewHeight = (window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight) + $(document).scrollTop(); |
|
6495 |
|
6496 offset.left -= (this._get(inst, 'isRTL') ? (dpWidth - inputWidth) : 0); |
|
6497 offset.left -= (isFixed && offset.left == inst.input.offset().left) ? $(document).scrollLeft() : 0; |
|
6498 offset.top -= (isFixed && offset.top == (inst.input.offset().top + inputHeight)) ? $(document).scrollTop() : 0; |
|
6499 |
|
6500 // now check if datepicker is showing outside window viewport - move to a better place if so. |
|
6501 offset.left -= (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ? Math.abs(offset.left + dpWidth - viewWidth) : 0; |
|
6502 offset.top -= (offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ? Math.abs(offset.top + dpHeight + inputHeight*2 - viewHeight) : 0; |
|
6503 |
|
6504 return offset; |
|
6505 }, |
|
6506 |
|
6507 /* Find an object's position on the screen. */ |
|
6508 _findPos: function(obj) { |
|
6509 while (obj && (obj.type == 'hidden' || obj.nodeType != 1)) { |
|
6510 obj = obj.nextSibling; |
|
6511 } |
|
6512 var position = $(obj).offset(); |
|
6513 return [position.left, position.top]; |
|
6514 }, |
|
6515 |
|
6516 /* Hide the date picker from view. |
|
6517 @param input element - the input field attached to the date picker |
|
6518 @param duration string - the duration over which to close the date picker */ |
|
6519 _hideDatepicker: function(input, duration) { |
|
6520 var inst = this._curInst; |
|
6521 if (!inst || (input && inst != $.data(input, PROP_NAME))) |
|
6522 return; |
|
6523 if (inst.stayOpen) |
|
6524 this._selectDate('#' + inst.id, this._formatDate(inst, |
|
6525 inst.currentDay, inst.currentMonth, inst.currentYear)); |
|
6526 inst.stayOpen = false; |
|
6527 if (this._datepickerShowing) { |
|
6528 duration = (duration != null ? duration : this._get(inst, 'duration')); |
|
6529 var showAnim = this._get(inst, 'showAnim'); |
|
6530 var postProcess = function() { |
|
6531 $.datepicker._tidyDialog(inst); |
|
6532 }; |
|
6533 if (duration != '' && $.effects && $.effects[showAnim]) |
|
6534 inst.dpDiv.hide(showAnim, $.datepicker._get(inst, 'showOptions'), |
|
6535 duration, postProcess); |
|
6536 else |
|
6537 inst.dpDiv[(duration == '' ? 'hide' : (showAnim == 'slideDown' ? 'slideUp' : |
|
6538 (showAnim == 'fadeIn' ? 'fadeOut' : 'hide')))](duration, postProcess); |
|
6539 if (duration == '') |
|
6540 this._tidyDialog(inst); |
|
6541 var onClose = this._get(inst, 'onClose'); |
|
6542 if (onClose) |
|
6543 onClose.apply((inst.input ? inst.input[0] : null), |
|
6544 [(inst.input ? inst.input.val() : ''), inst]); // trigger custom callback |
|
6545 this._datepickerShowing = false; |
|
6546 this._lastInput = null; |
|
6547 if (this._inDialog) { |
|
6548 this._dialogInput.css({ position: 'absolute', left: '0', top: '-100px' }); |
|
6549 if ($.blockUI) { |
|
6550 $.unblockUI(); |
|
6551 $('body').append(this.dpDiv); |
|
6552 } |
|
6553 } |
|
6554 this._inDialog = false; |
|
6555 } |
|
6556 this._curInst = null; |
|
6557 }, |
|
6558 |
|
6559 /* Tidy up after a dialog display. */ |
|
6560 _tidyDialog: function(inst) { |
|
6561 inst.dpDiv.removeClass(this._dialogClass).unbind('.ui-datepicker-calendar'); |
|
6562 }, |
|
6563 |
|
6564 /* Close date picker if clicked elsewhere. */ |
|
6565 _checkExternalClick: function(event) { |
|
6566 if (!$.datepicker._curInst) |
|
6567 return; |
|
6568 var $target = $(event.target); |
|
6569 if (($target.parents('#' + $.datepicker._mainDivId).length == 0) && |
|
6570 !$target.hasClass($.datepicker.markerClassName) && |
|
6571 !$target.hasClass($.datepicker._triggerClass) && |
|
6572 $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI)) |
|
6573 $.datepicker._hideDatepicker(null, ''); |
|
6574 }, |
|
6575 |
|
6576 /* Adjust one of the date sub-fields. */ |
|
6577 _adjustDate: function(id, offset, period) { |
|
6578 var target = $(id); |
|
6579 var inst = this._getInst(target[0]); |
|
6580 if (this._isDisabledDatepicker(target[0])) { |
|
6581 return; |
|
6582 } |
|
6583 this._adjustInstDate(inst, offset + |
|
6584 (period == 'M' ? this._get(inst, 'showCurrentAtPos') : 0), // undo positioning |
|
6585 period); |
|
6586 this._updateDatepicker(inst); |
|
6587 }, |
|
6588 |
|
6589 /* Action for current link. */ |
|
6590 _gotoToday: function(id) { |
|
6591 var target = $(id); |
|
6592 var inst = this._getInst(target[0]); |
|
6593 if (this._get(inst, 'gotoCurrent') && inst.currentDay) { |
|
6594 inst.selectedDay = inst.currentDay; |
|
6595 inst.drawMonth = inst.selectedMonth = inst.currentMonth; |
|
6596 inst.drawYear = inst.selectedYear = inst.currentYear; |
|
6597 } |
|
6598 else { |
|
6599 var date = new Date(); |
|
6600 inst.selectedDay = date.getDate(); |
|
6601 inst.drawMonth = inst.selectedMonth = date.getMonth(); |
|
6602 inst.drawYear = inst.selectedYear = date.getFullYear(); |
|
6603 } |
|
6604 this._notifyChange(inst); |
|
6605 this._adjustDate(target); |
|
6606 }, |
|
6607 |
|
6608 /* Action for selecting a new month/year. */ |
|
6609 _selectMonthYear: function(id, select, period) { |
|
6610 var target = $(id); |
|
6611 var inst = this._getInst(target[0]); |
|
6612 inst._selectingMonthYear = false; |
|
6613 inst['selected' + (period == 'M' ? 'Month' : 'Year')] = |
|
6614 inst['draw' + (period == 'M' ? 'Month' : 'Year')] = |
|
6615 parseInt(select.options[select.selectedIndex].value,10); |
|
6616 this._notifyChange(inst); |
|
6617 this._adjustDate(target); |
|
6618 }, |
|
6619 |
|
6620 /* Restore input focus after not changing month/year. */ |
|
6621 _clickMonthYear: function(id) { |
|
6622 var target = $(id); |
|
6623 var inst = this._getInst(target[0]); |
|
6624 if (inst.input && inst._selectingMonthYear && !$.browser.msie) |
|
6625 inst.input[0].focus(); |
|
6626 inst._selectingMonthYear = !inst._selectingMonthYear; |
|
6627 }, |
|
6628 |
|
6629 /* Action for selecting a day. */ |
|
6630 _selectDay: function(id, month, year, td) { |
|
6631 var target = $(id); |
|
6632 if ($(td).hasClass(this._unselectableClass) || this._isDisabledDatepicker(target[0])) { |
|
6633 return; |
|
6634 } |
|
6635 var inst = this._getInst(target[0]); |
|
6636 inst.selectedDay = inst.currentDay = $('a', td).html(); |
|
6637 inst.selectedMonth = inst.currentMonth = month; |
|
6638 inst.selectedYear = inst.currentYear = year; |
|
6639 if (inst.stayOpen) { |
|
6640 inst.endDay = inst.endMonth = inst.endYear = null; |
|
6641 } |
|
6642 this._selectDate(id, this._formatDate(inst, |
|
6643 inst.currentDay, inst.currentMonth, inst.currentYear)); |
|
6644 if (inst.stayOpen) { |
|
6645 inst.rangeStart = this._daylightSavingAdjust( |
|
6646 new Date(inst.currentYear, inst.currentMonth, inst.currentDay)); |
|
6647 this._updateDatepicker(inst); |
|
6648 } |
|
6649 }, |
|
6650 |
|
6651 /* Erase the input field and hide the date picker. */ |
|
6652 _clearDate: function(id) { |
|
6653 var target = $(id); |
|
6654 var inst = this._getInst(target[0]); |
|
6655 inst.stayOpen = false; |
|
6656 inst.endDay = inst.endMonth = inst.endYear = inst.rangeStart = null; |
|
6657 this._selectDate(target, ''); |
|
6658 }, |
|
6659 |
|
6660 /* Update the input field with the selected date. */ |
|
6661 _selectDate: function(id, dateStr) { |
|
6662 var target = $(id); |
|
6663 var inst = this._getInst(target[0]); |
|
6664 dateStr = (dateStr != null ? dateStr : this._formatDate(inst)); |
|
6665 if (inst.input) |
|
6666 inst.input.val(dateStr); |
|
6667 this._updateAlternate(inst); |
|
6668 var onSelect = this._get(inst, 'onSelect'); |
|
6669 if (onSelect) |
|
6670 onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]); // trigger custom callback |
|
6671 else if (inst.input) |
|
6672 inst.input.trigger('change'); // fire the change event |
|
6673 if (inst.inline) |
|
6674 this._updateDatepicker(inst); |
|
6675 else if (!inst.stayOpen) { |
|
6676 this._hideDatepicker(null, this._get(inst, 'duration')); |
|
6677 this._lastInput = inst.input[0]; |
|
6678 if (typeof(inst.input[0]) != 'object') |
|
6679 inst.input[0].focus(); // restore focus |
|
6680 this._lastInput = null; |
|
6681 } |
|
6682 }, |
|
6683 |
|
6684 /* Update any alternate field to synchronise with the main field. */ |
|
6685 _updateAlternate: function(inst) { |
|
6686 var altField = this._get(inst, 'altField'); |
|
6687 if (altField) { // update alternate field too |
|
6688 var altFormat = this._get(inst, 'altFormat') || this._get(inst, 'dateFormat'); |
|
6689 var date = this._getDate(inst); |
|
6690 dateStr = this.formatDate(altFormat, date, this._getFormatConfig(inst)); |
|
6691 $(altField).each(function() { $(this).val(dateStr); }); |
|
6692 } |
|
6693 }, |
|
6694 |
|
6695 /* Set as beforeShowDay function to prevent selection of weekends. |
|
6696 @param date Date - the date to customise |
|
6697 @return [boolean, string] - is this date selectable?, what is its CSS class? */ |
|
6698 noWeekends: function(date) { |
|
6699 var day = date.getDay(); |
|
6700 return [(day > 0 && day < 6), '']; |
|
6701 }, |
|
6702 |
|
6703 /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition. |
|
6704 @param date Date - the date to get the week for |
|
6705 @return number - the number of the week within the year that contains this date */ |
|
6706 iso8601Week: function(date) { |
|
6707 var checkDate = new Date(date.getFullYear(), date.getMonth(), date.getDate()); |
|
6708 var firstMon = new Date(checkDate.getFullYear(), 1 - 1, 4); // First week always contains 4 Jan |
|
6709 var firstDay = firstMon.getDay() || 7; // Day of week: Mon = 1, ..., Sun = 7 |
|
6710 firstMon.setDate(firstMon.getDate() + 1 - firstDay); // Preceding Monday |
|
6711 if (firstDay < 4 && checkDate < firstMon) { // Adjust first three days in year if necessary |
|
6712 checkDate.setDate(checkDate.getDate() - 3); // Generate for previous year |
|
6713 return $.datepicker.iso8601Week(checkDate); |
|
6714 } else if (checkDate > new Date(checkDate.getFullYear(), 12 - 1, 28)) { // Check last three days in year |
|
6715 firstDay = new Date(checkDate.getFullYear() + 1, 1 - 1, 4).getDay() || 7; |
|
6716 if (firstDay > 4 && (checkDate.getDay() || 7) < firstDay - 3) { // Adjust if necessary |
|
6717 return 1; |
|
6718 } |
|
6719 } |
|
6720 return Math.floor(((checkDate - firstMon) / 86400000) / 7) + 1; // Weeks to given date |
|
6721 }, |
|
6722 |
|
6723 /* Parse a string value into a date object. |
|
6724 See formatDate below for the possible formats. |
|
6725 |
|
6726 @param format string - the expected format of the date |
|
6727 @param value string - the date in the above format |
|
6728 @param settings Object - attributes include: |
|
6729 shortYearCutoff number - the cutoff year for determining the century (optional) |
|
6730 dayNamesShort string[7] - abbreviated names of the days from Sunday (optional) |
|
6731 dayNames string[7] - names of the days from Sunday (optional) |
|
6732 monthNamesShort string[12] - abbreviated names of the months (optional) |
|
6733 monthNames string[12] - names of the months (optional) |
|
6734 @return Date - the extracted date value or null if value is blank */ |
|
6735 parseDate: function (format, value, settings) { |
|
6736 if (format == null || value == null) |
|
6737 throw 'Invalid arguments'; |
|
6738 value = (typeof value == 'object' ? value.toString() : value + ''); |
|
6739 if (value == '') |
|
6740 return null; |
|
6741 var shortYearCutoff = (settings ? settings.shortYearCutoff : null) || this._defaults.shortYearCutoff; |
|
6742 var dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort; |
|
6743 var dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames; |
|
6744 var monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort; |
|
6745 var monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames; |
|
6746 var year = -1; |
|
6747 var month = -1; |
|
6748 var day = -1; |
|
6749 var doy = -1; |
|
6750 var literal = false; |
|
6751 // Check whether a format character is doubled |
|
6752 var lookAhead = function(match) { |
|
6753 var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match); |
|
6754 if (matches) |
|
6755 iFormat++; |
|
6756 return matches; |
|
6757 }; |
|
6758 // Extract a number from the string value |
|
6759 var getNumber = function(match) { |
|
6760 lookAhead(match); |
|
6761 var origSize = (match == '@' ? 14 : (match == 'y' ? 4 : (match == 'o' ? 3 : 2))); |
|
6762 var size = origSize; |
|
6763 var num = 0; |
|
6764 while (size > 0 && iValue < value.length && |
|
6765 value.charAt(iValue) >= '0' && value.charAt(iValue) <= '9') { |
|
6766 num = num * 10 + parseInt(value.charAt(iValue++),10); |
|
6767 size--; |
|
6768 } |
|
6769 if (size == origSize) |
|
6770 throw 'Missing number at position ' + iValue; |
|
6771 return num; |
|
6772 }; |
|
6773 // Extract a name from the string value and convert to an index |
|
6774 var getName = function(match, shortNames, longNames) { |
|
6775 var names = (lookAhead(match) ? longNames : shortNames); |
|
6776 var size = 0; |
|
6777 for (var j = 0; j < names.length; j++) |
|
6778 size = Math.max(size, names[j].length); |
|
6779 var name = ''; |
|
6780 var iInit = iValue; |
|
6781 while (size > 0 && iValue < value.length) { |
|
6782 name += value.charAt(iValue++); |
|
6783 for (var i = 0; i < names.length; i++) |
|
6784 if (name == names[i]) |
|
6785 return i + 1; |
|
6786 size--; |
|
6787 } |
|
6788 throw 'Unknown name at position ' + iInit; |
|
6789 }; |
|
6790 // Confirm that a literal character matches the string value |
|
6791 var checkLiteral = function() { |
|
6792 if (value.charAt(iValue) != format.charAt(iFormat)) |
|
6793 throw 'Unexpected literal at position ' + iValue; |
|
6794 iValue++; |
|
6795 }; |
|
6796 var iValue = 0; |
|
6797 for (var iFormat = 0; iFormat < format.length; iFormat++) { |
|
6798 if (literal) |
|
6799 if (format.charAt(iFormat) == "'" && !lookAhead("'")) |
|
6800 literal = false; |
|
6801 else |
|
6802 checkLiteral(); |
|
6803 else |
|
6804 switch (format.charAt(iFormat)) { |
|
6805 case 'd': |
|
6806 day = getNumber('d'); |
|
6807 break; |
|
6808 case 'D': |
|
6809 getName('D', dayNamesShort, dayNames); |
|
6810 break; |
|
6811 case 'o': |
|
6812 doy = getNumber('o'); |
|
6813 break; |
|
6814 case 'm': |
|
6815 month = getNumber('m'); |
|
6816 break; |
|
6817 case 'M': |
|
6818 month = getName('M', monthNamesShort, monthNames); |
|
6819 break; |
|
6820 case 'y': |
|
6821 year = getNumber('y'); |
|
6822 break; |
|
6823 case '@': |
|
6824 var date = new Date(getNumber('@')); |
|
6825 year = date.getFullYear(); |
|
6826 month = date.getMonth() + 1; |
|
6827 day = date.getDate(); |
|
6828 break; |
|
6829 case "'": |
|
6830 if (lookAhead("'")) |
|
6831 checkLiteral(); |
|
6832 else |
|
6833 literal = true; |
|
6834 break; |
|
6835 default: |
|
6836 checkLiteral(); |
|
6837 } |
|
6838 } |
|
6839 if (year == -1) |
|
6840 year = new Date().getFullYear(); |
|
6841 else if (year < 100) |
|
6842 year += new Date().getFullYear() - new Date().getFullYear() % 100 + |
|
6843 (year <= shortYearCutoff ? 0 : -100); |
|
6844 if (doy > -1) { |
|
6845 month = 1; |
|
6846 day = doy; |
|
6847 do { |
|
6848 var dim = this._getDaysInMonth(year, month - 1); |
|
6849 if (day <= dim) |
|
6850 break; |
|
6851 month++; |
|
6852 day -= dim; |
|
6853 } while (true); |
|
6854 } |
|
6855 var date = this._daylightSavingAdjust(new Date(year, month - 1, day)); |
|
6856 if (date.getFullYear() != year || date.getMonth() + 1 != month || date.getDate() != day) |
|
6857 throw 'Invalid date'; // E.g. 31/02/* |
|
6858 return date; |
|
6859 }, |
|
6860 |
|
6861 /* Standard date formats. */ |
|
6862 ATOM: 'yy-mm-dd', // RFC 3339 (ISO 8601) |
|
6863 COOKIE: 'D, dd M yy', |
|
6864 ISO_8601: 'yy-mm-dd', |
|
6865 RFC_822: 'D, d M y', |
|
6866 RFC_850: 'DD, dd-M-y', |
|
6867 RFC_1036: 'D, d M y', |
|
6868 RFC_1123: 'D, d M yy', |
|
6869 RFC_2822: 'D, d M yy', |
|
6870 RSS: 'D, d M y', // RFC 822 |
|
6871 TIMESTAMP: '@', |
|
6872 W3C: 'yy-mm-dd', // ISO 8601 |
|
6873 |
|
6874 /* Format a date object into a string value. |
|
6875 The format can be combinations of the following: |
|
6876 d - day of month (no leading zero) |
|
6877 dd - day of month (two digit) |
|
6878 o - day of year (no leading zeros) |
|
6879 oo - day of year (three digit) |
|
6880 D - day name short |
|
6881 DD - day name long |
|
6882 m - month of year (no leading zero) |
|
6883 mm - month of year (two digit) |
|
6884 M - month name short |
|
6885 MM - month name long |
|
6886 y - year (two digit) |
|
6887 yy - year (four digit) |
|
6888 @ - Unix timestamp (ms since 01/01/1970) |
|
6889 '...' - literal text |
|
6890 '' - single quote |
|
6891 |
|
6892 @param format string - the desired format of the date |
|
6893 @param date Date - the date value to format |
|
6894 @param settings Object - attributes include: |
|
6895 dayNamesShort string[7] - abbreviated names of the days from Sunday (optional) |
|
6896 dayNames string[7] - names of the days from Sunday (optional) |
|
6897 monthNamesShort string[12] - abbreviated names of the months (optional) |
|
6898 monthNames string[12] - names of the months (optional) |
|
6899 @return string - the date in the above format */ |
|
6900 formatDate: function (format, date, settings) { |
|
6901 if (!date) |
|
6902 return ''; |
|
6903 var dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort; |
|
6904 var dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames; |
|
6905 var monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort; |
|
6906 var monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames; |
|
6907 // Check whether a format character is doubled |
|
6908 var lookAhead = function(match) { |
|
6909 var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match); |
|
6910 if (matches) |
|
6911 iFormat++; |
|
6912 return matches; |
|
6913 }; |
|
6914 // Format a number, with leading zero if necessary |
|
6915 var formatNumber = function(match, value, len) { |
|
6916 var num = '' + value; |
|
6917 if (lookAhead(match)) |
|
6918 while (num.length < len) |
|
6919 num = '0' + num; |
|
6920 return num; |
|
6921 }; |
|
6922 // Format a name, short or long as requested |
|
6923 var formatName = function(match, value, shortNames, longNames) { |
|
6924 return (lookAhead(match) ? longNames[value] : shortNames[value]); |
|
6925 }; |
|
6926 var output = ''; |
|
6927 var literal = false; |
|
6928 if (date) |
|
6929 for (var iFormat = 0; iFormat < format.length; iFormat++) { |
|
6930 if (literal) |
|
6931 if (format.charAt(iFormat) == "'" && !lookAhead("'")) |
|
6932 literal = false; |
|
6933 else |
|
6934 output += format.charAt(iFormat); |
|
6935 else |
|
6936 switch (format.charAt(iFormat)) { |
|
6937 case 'd': |
|
6938 output += formatNumber('d', date.getDate(), 2); |
|
6939 break; |
|
6940 case 'D': |
|
6941 output += formatName('D', date.getDay(), dayNamesShort, dayNames); |
|
6942 break; |
|
6943 case 'o': |
|
6944 var doy = date.getDate(); |
|
6945 for (var m = date.getMonth() - 1; m >= 0; m--) |
|
6946 doy += this._getDaysInMonth(date.getFullYear(), m); |
|
6947 output += formatNumber('o', doy, 3); |
|
6948 break; |
|
6949 case 'm': |
|
6950 output += formatNumber('m', date.getMonth() + 1, 2); |
|
6951 break; |
|
6952 case 'M': |
|
6953 output += formatName('M', date.getMonth(), monthNamesShort, monthNames); |
|
6954 break; |
|
6955 case 'y': |
|
6956 output += (lookAhead('y') ? date.getFullYear() : |
|
6957 (date.getYear() % 100 < 10 ? '0' : '') + date.getYear() % 100); |
|
6958 break; |
|
6959 case '@': |
|
6960 output += date.getTime(); |
|
6961 break; |
|
6962 case "'": |
|
6963 if (lookAhead("'")) |
|
6964 output += "'"; |
|
6965 else |
|
6966 literal = true; |
|
6967 break; |
|
6968 default: |
|
6969 output += format.charAt(iFormat); |
|
6970 } |
|
6971 } |
|
6972 return output; |
|
6973 }, |
|
6974 |
|
6975 /* Extract all possible characters from the date format. */ |
|
6976 _possibleChars: function (format) { |
|
6977 var chars = ''; |
|
6978 var literal = false; |
|
6979 for (var iFormat = 0; iFormat < format.length; iFormat++) |
|
6980 if (literal) |
|
6981 if (format.charAt(iFormat) == "'" && !lookAhead("'")) |
|
6982 literal = false; |
|
6983 else |
|
6984 chars += format.charAt(iFormat); |
|
6985 else |
|
6986 switch (format.charAt(iFormat)) { |
|
6987 case 'd': case 'm': case 'y': case '@': |
|
6988 chars += '0123456789'; |
|
6989 break; |
|
6990 case 'D': case 'M': |
|
6991 return null; // Accept anything |
|
6992 case "'": |
|
6993 if (lookAhead("'")) |
|
6994 chars += "'"; |
|
6995 else |
|
6996 literal = true; |
|
6997 break; |
|
6998 default: |
|
6999 chars += format.charAt(iFormat); |
|
7000 } |
|
7001 return chars; |
|
7002 }, |
|
7003 |
|
7004 /* Get a setting value, defaulting if necessary. */ |
|
7005 _get: function(inst, name) { |
|
7006 return inst.settings[name] !== undefined ? |
|
7007 inst.settings[name] : this._defaults[name]; |
|
7008 }, |
|
7009 |
|
7010 /* Parse existing date and initialise date picker. */ |
|
7011 _setDateFromField: function(inst) { |
|
7012 var dateFormat = this._get(inst, 'dateFormat'); |
|
7013 var dates = inst.input ? inst.input.val() : null; |
|
7014 inst.endDay = inst.endMonth = inst.endYear = null; |
|
7015 var date = defaultDate = this._getDefaultDate(inst); |
|
7016 var settings = this._getFormatConfig(inst); |
|
7017 try { |
|
7018 date = this.parseDate(dateFormat, dates, settings) || defaultDate; |
|
7019 } catch (event) { |
|
7020 this.log(event); |
|
7021 date = defaultDate; |
|
7022 } |
|
7023 inst.selectedDay = date.getDate(); |
|
7024 inst.drawMonth = inst.selectedMonth = date.getMonth(); |
|
7025 inst.drawYear = inst.selectedYear = date.getFullYear(); |
|
7026 inst.currentDay = (dates ? date.getDate() : 0); |
|
7027 inst.currentMonth = (dates ? date.getMonth() : 0); |
|
7028 inst.currentYear = (dates ? date.getFullYear() : 0); |
|
7029 this._adjustInstDate(inst); |
|
7030 }, |
|
7031 |
|
7032 /* Retrieve the default date shown on opening. */ |
|
7033 _getDefaultDate: function(inst) { |
|
7034 var date = this._determineDate(this._get(inst, 'defaultDate'), new Date()); |
|
7035 var minDate = this._getMinMaxDate(inst, 'min', true); |
|
7036 var maxDate = this._getMinMaxDate(inst, 'max'); |
|
7037 date = (minDate && date < minDate ? minDate : date); |
|
7038 date = (maxDate && date > maxDate ? maxDate : date); |
|
7039 return date; |
|
7040 }, |
|
7041 |
|
7042 /* A date may be specified as an exact value or a relative one. */ |
|
7043 _determineDate: function(date, defaultDate) { |
|
7044 var offsetNumeric = function(offset) { |
|
7045 var date = new Date(); |
|
7046 date.setDate(date.getDate() + offset); |
|
7047 return date; |
|
7048 }; |
|
7049 var offsetString = function(offset, getDaysInMonth) { |
|
7050 var date = new Date(); |
|
7051 var year = date.getFullYear(); |
|
7052 var month = date.getMonth(); |
|
7053 var day = date.getDate(); |
|
7054 var pattern = /([+-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g; |
|
7055 var matches = pattern.exec(offset); |
|
7056 while (matches) { |
|
7057 switch (matches[2] || 'd') { |
|
7058 case 'd' : case 'D' : |
|
7059 day += parseInt(matches[1],10); break; |
|
7060 case 'w' : case 'W' : |
|
7061 day += parseInt(matches[1],10) * 7; break; |
|
7062 case 'm' : case 'M' : |
|
7063 month += parseInt(matches[1],10); |
|
7064 day = Math.min(day, getDaysInMonth(year, month)); |
|
7065 break; |
|
7066 case 'y': case 'Y' : |
|
7067 year += parseInt(matches[1],10); |
|
7068 day = Math.min(day, getDaysInMonth(year, month)); |
|
7069 break; |
|
7070 } |
|
7071 matches = pattern.exec(offset); |
|
7072 } |
|
7073 return new Date(year, month, day); |
|
7074 }; |
|
7075 date = (date == null ? defaultDate : |
|
7076 (typeof date == 'string' ? offsetString(date, this._getDaysInMonth) : |
|
7077 (typeof date == 'number' ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : date))); |
|
7078 date = (date && date.toString() == 'Invalid Date' ? defaultDate : date); |
|
7079 if (date) { |
|
7080 date.setHours(0); |
|
7081 date.setMinutes(0); |
|
7082 date.setSeconds(0); |
|
7083 date.setMilliseconds(0); |
|
7084 } |
|
7085 return this._daylightSavingAdjust(date); |
|
7086 }, |
|
7087 |
|
7088 /* Handle switch to/from daylight saving. |
|
7089 Hours may be non-zero on daylight saving cut-over: |
|
7090 > 12 when midnight changeover, but then cannot generate |
|
7091 midnight datetime, so jump to 1AM, otherwise reset. |
|
7092 @param date (Date) the date to check |
|
7093 @return (Date) the corrected date */ |
|
7094 _daylightSavingAdjust: function(date) { |
|
7095 if (!date) return null; |
|
7096 date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0); |
|
7097 return date; |
|
7098 }, |
|
7099 |
|
7100 /* Set the date(s) directly. */ |
|
7101 _setDate: function(inst, date, endDate) { |
|
7102 var clear = !(date); |
|
7103 var origMonth = inst.selectedMonth; |
|
7104 var origYear = inst.selectedYear; |
|
7105 date = this._determineDate(date, new Date()); |
|
7106 inst.selectedDay = inst.currentDay = date.getDate(); |
|
7107 inst.drawMonth = inst.selectedMonth = inst.currentMonth = date.getMonth(); |
|
7108 inst.drawYear = inst.selectedYear = inst.currentYear = date.getFullYear(); |
|
7109 if (origMonth != inst.selectedMonth || origYear != inst.selectedYear) |
|
7110 this._notifyChange(inst); |
|
7111 this._adjustInstDate(inst); |
|
7112 if (inst.input) { |
|
7113 inst.input.val(clear ? '' : this._formatDate(inst)); |
|
7114 } |
|
7115 }, |
|
7116 |
|
7117 /* Retrieve the date(s) directly. */ |
|
7118 _getDate: function(inst) { |
|
7119 var startDate = (!inst.currentYear || (inst.input && inst.input.val() == '') ? null : |
|
7120 this._daylightSavingAdjust(new Date( |
|
7121 inst.currentYear, inst.currentMonth, inst.currentDay))); |
|
7122 return startDate; |
|
7123 }, |
|
7124 |
|
7125 /* Generate the HTML for the current state of the date picker. */ |
|
7126 _generateHTML: function(inst) { |
|
7127 var today = new Date(); |
|
7128 today = this._daylightSavingAdjust( |
|
7129 new Date(today.getFullYear(), today.getMonth(), today.getDate())); // clear time |
|
7130 var isRTL = this._get(inst, 'isRTL'); |
|
7131 var showButtonPanel = this._get(inst, 'showButtonPanel'); |
|
7132 var hideIfNoPrevNext = this._get(inst, 'hideIfNoPrevNext'); |
|
7133 var navigationAsDateFormat = this._get(inst, 'navigationAsDateFormat'); |
|
7134 var numMonths = this._getNumberOfMonths(inst); |
|
7135 var showCurrentAtPos = this._get(inst, 'showCurrentAtPos'); |
|
7136 var stepMonths = this._get(inst, 'stepMonths'); |
|
7137 var stepBigMonths = this._get(inst, 'stepBigMonths'); |
|
7138 var isMultiMonth = (numMonths[0] != 1 || numMonths[1] != 1); |
|
7139 var currentDate = this._daylightSavingAdjust((!inst.currentDay ? new Date(9999, 9, 9) : |
|
7140 new Date(inst.currentYear, inst.currentMonth, inst.currentDay))); |
|
7141 var minDate = this._getMinMaxDate(inst, 'min', true); |
|
7142 var maxDate = this._getMinMaxDate(inst, 'max'); |
|
7143 var drawMonth = inst.drawMonth - showCurrentAtPos; |
|
7144 var drawYear = inst.drawYear; |
|
7145 if (drawMonth < 0) { |
|
7146 drawMonth += 12; |
|
7147 drawYear--; |
|
7148 } |
|
7149 if (maxDate) { |
|
7150 var maxDraw = this._daylightSavingAdjust(new Date(maxDate.getFullYear(), |
|
7151 maxDate.getMonth() - numMonths[1] + 1, maxDate.getDate())); |
|
7152 maxDraw = (minDate && maxDraw < minDate ? minDate : maxDraw); |
|
7153 while (this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1)) > maxDraw) { |
|
7154 drawMonth--; |
|
7155 if (drawMonth < 0) { |
|
7156 drawMonth = 11; |
|
7157 drawYear--; |
|
7158 } |
|
7159 } |
|
7160 } |
|
7161 inst.drawMonth = drawMonth; |
|
7162 inst.drawYear = drawYear; |
|
7163 var prevText = this._get(inst, 'prevText'); |
|
7164 prevText = (!navigationAsDateFormat ? prevText : this.formatDate(prevText, |
|
7165 this._daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)), |
|
7166 this._getFormatConfig(inst))); |
|
7167 var prev = (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ? |
|
7168 '<a class="ui-datepicker-prev ui-corner-all" onclick="jQuery.datepicker._adjustDate(\'#' + inst.id + '\', -' + stepMonths + ', \'M\');"' + |
|
7169 ' title="' + prevText + '"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'e' : 'w') + '">' + prevText + '</span></a>' : |
|
7170 (hideIfNoPrevNext ? '' : '<a class="ui-datepicker-prev ui-corner-all ui-state-disabled" title="'+ prevText +'"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'e' : 'w') + '">' + prevText + '</span></a>')); |
|
7171 var nextText = this._get(inst, 'nextText'); |
|
7172 nextText = (!navigationAsDateFormat ? nextText : this.formatDate(nextText, |
|
7173 this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)), |
|
7174 this._getFormatConfig(inst))); |
|
7175 var next = (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ? |
|
7176 '<a class="ui-datepicker-next ui-corner-all" onclick="jQuery.datepicker._adjustDate(\'#' + inst.id + '\', +' + stepMonths + ', \'M\');"' + |
|
7177 ' title="' + nextText + '"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'w' : 'e') + '">' + nextText + '</span></a>' : |
|
7178 (hideIfNoPrevNext ? '' : '<a class="ui-datepicker-next ui-corner-all ui-state-disabled" title="'+ nextText + '"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'w' : 'e') + '">' + nextText + '</span></a>')); |
|
7179 var currentText = this._get(inst, 'currentText'); |
|
7180 var gotoDate = (this._get(inst, 'gotoCurrent') && inst.currentDay ? currentDate : today); |
|
7181 currentText = (!navigationAsDateFormat ? currentText : |
|
7182 this.formatDate(currentText, gotoDate, this._getFormatConfig(inst))); |
|
7183 var controls = '<button type="button" class="ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all" onclick="jQuery.datepicker._hideDatepicker();">' + this._get(inst, 'closeText') + '</button>'; |
|
7184 var buttonPanel = (showButtonPanel) ? '<div class="ui-datepicker-buttonpane ui-widget-content">' + (isRTL ? controls : '') + |
|
7185 (this._isInRange(inst, gotoDate) ? '<button type="button" class="ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all" onclick="jQuery.datepicker._gotoToday(\'#' + inst.id + '\');"' + |
|
7186 '>' + currentText + '</button>' : '') + (isRTL ? '' : controls) + '</div>' : ''; |
|
7187 var firstDay = parseInt(this._get(inst, 'firstDay'),10); |
|
7188 firstDay = (isNaN(firstDay) ? 0 : firstDay); |
|
7189 var dayNames = this._get(inst, 'dayNames'); |
|
7190 var dayNamesShort = this._get(inst, 'dayNamesShort'); |
|
7191 var dayNamesMin = this._get(inst, 'dayNamesMin'); |
|
7192 var monthNames = this._get(inst, 'monthNames'); |
|
7193 var monthNamesShort = this._get(inst, 'monthNamesShort'); |
|
7194 var beforeShowDay = this._get(inst, 'beforeShowDay'); |
|
7195 var showOtherMonths = this._get(inst, 'showOtherMonths'); |
|
7196 var calculateWeek = this._get(inst, 'calculateWeek') || this.iso8601Week; |
|
7197 var endDate = inst.endDay ? this._daylightSavingAdjust( |
|
7198 new Date(inst.endYear, inst.endMonth, inst.endDay)) : currentDate; |
|
7199 var defaultDate = this._getDefaultDate(inst); |
|
7200 var html = ''; |
|
7201 for (var row = 0; row < numMonths[0]; row++) { |
|
7202 var group = ''; |
|
7203 for (var col = 0; col < numMonths[1]; col++) { |
|
7204 var selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay)); |
|
7205 var cornerClass = ' ui-corner-all'; |
|
7206 var calender = ''; |
|
7207 if (isMultiMonth) { |
|
7208 calender += '<div class="ui-datepicker-group ui-datepicker-group-'; |
|
7209 switch (col) { |
|
7210 case 0: calender += 'first'; cornerClass = ' ui-corner-' + (isRTL ? 'right' : 'left'); break; |
|
7211 case numMonths[1]-1: calender += 'last'; cornerClass = ' ui-corner-' + (isRTL ? 'left' : 'right'); break; |
|
7212 default: calender += 'middle'; cornerClass = ''; break; |
|
7213 } |
|
7214 calender += '">'; |
|
7215 } |
|
7216 calender += '<div class="ui-datepicker-header ui-widget-header ui-helper-clearfix' + cornerClass + '">' + |
|
7217 (/all|left/.test(cornerClass) && row == 0 ? (isRTL ? next : prev) : '') + |
|
7218 (/all|right/.test(cornerClass) && row == 0 ? (isRTL ? prev : next) : '') + |
|
7219 this._generateMonthYearHeader(inst, drawMonth, drawYear, minDate, maxDate, |
|
7220 selectedDate, row > 0 || col > 0, monthNames, monthNamesShort) + // draw month headers |
|
7221 '</div><table class="ui-datepicker-calendar"><thead>' + |
|
7222 '<tr>'; |
|
7223 var thead = ''; |
|
7224 for (var dow = 0; dow < 7; dow++) { // days of the week |
|
7225 var day = (dow + firstDay) % 7; |
|
7226 thead += '<th' + ((dow + firstDay + 6) % 7 >= 5 ? ' class="ui-datepicker-week-end"' : '') + '>' + |
|
7227 '<span title="' + dayNames[day] + '">' + dayNamesMin[day] + '</span></th>'; |
|
7228 } |
|
7229 calender += thead + '</tr></thead><tbody>'; |
|
7230 var daysInMonth = this._getDaysInMonth(drawYear, drawMonth); |
|
7231 if (drawYear == inst.selectedYear && drawMonth == inst.selectedMonth) |
|
7232 inst.selectedDay = Math.min(inst.selectedDay, daysInMonth); |
|
7233 var leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7; |
|
7234 var numRows = (isMultiMonth ? 6 : Math.ceil((leadDays + daysInMonth) / 7)); // calculate the number of rows to generate |
|
7235 var printDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1 - leadDays)); |
|
7236 for (var dRow = 0; dRow < numRows; dRow++) { // create date picker rows |
|
7237 calender += '<tr>'; |
|
7238 var tbody = ''; |
|
7239 for (var dow = 0; dow < 7; dow++) { // create date picker days |
|
7240 var daySettings = (beforeShowDay ? |
|
7241 beforeShowDay.apply((inst.input ? inst.input[0] : null), [printDate]) : [true, '']); |
|
7242 var otherMonth = (printDate.getMonth() != drawMonth); |
|
7243 var unselectable = otherMonth || !daySettings[0] || |
|
7244 (minDate && printDate < minDate) || (maxDate && printDate > maxDate); |
|
7245 tbody += '<td class="' + |
|
7246 ((dow + firstDay + 6) % 7 >= 5 ? ' ui-datepicker-week-end' : '') + // highlight weekends |
|
7247 (otherMonth ? ' ui-datepicker-other-month' : '') + // highlight days from other months |
|
7248 ((printDate.getTime() == selectedDate.getTime() && drawMonth == inst.selectedMonth && inst._keyEvent) || // user pressed key |
|
7249 (defaultDate.getTime() == printDate.getTime() && defaultDate.getTime() == selectedDate.getTime()) ? |
|
7250 // or defaultDate is current printedDate and defaultDate is selectedDate |
|
7251 ' ' + this._dayOverClass : '') + // highlight selected day |
|
7252 (unselectable ? ' ' + this._unselectableClass + ' ui-state-disabled': '') + // highlight unselectable days |
|
7253 (otherMonth && !showOtherMonths ? '' : ' ' + daySettings[1] + // highlight custom dates |
|
7254 (printDate.getTime() >= currentDate.getTime() && printDate.getTime() <= endDate.getTime() ? // in current range |
|
7255 ' ' + this._currentClass : '') + // highlight selected day |
|
7256 (printDate.getTime() == today.getTime() ? ' ui-datepicker-today' : '')) + '"' + // highlight today (if different) |
|
7257 ((!otherMonth || showOtherMonths) && daySettings[2] ? ' title="' + daySettings[2] + '"' : '') + // cell title |
|
7258 (unselectable ? '' : ' onclick="jQuery.datepicker._selectDay(\'#' + |
|
7259 inst.id + '\',' + drawMonth + ',' + drawYear + ', this);return false;"') + '>' + // actions |
|
7260 (otherMonth ? (showOtherMonths ? printDate.getDate() : ' ') : // display for other months |
|
7261 (unselectable ? '<span class="ui-state-default">' + printDate.getDate() + '</span>' : '<a class="ui-state-default' + |
|
7262 (printDate.getTime() == today.getTime() ? ' ui-state-highlight' : '') + |
|
7263 (printDate.getTime() >= currentDate.getTime() && printDate.getTime() <= endDate.getTime() ? // in current range |
|
7264 ' ui-state-active' : '') + // highlight selected day |
|
7265 '" href="#">' + printDate.getDate() + '</a>')) + '</td>'; // display for this month |
|
7266 printDate.setDate(printDate.getDate() + 1); |
|
7267 printDate = this._daylightSavingAdjust(printDate); |
|
7268 } |
|
7269 calender += tbody + '</tr>'; |
|
7270 } |
|
7271 drawMonth++; |
|
7272 if (drawMonth > 11) { |
|
7273 drawMonth = 0; |
|
7274 drawYear++; |
|
7275 } |
|
7276 calender += '</tbody></table>' + (isMultiMonth ? '</div>' : ''); |
|
7277 group += calender; |
|
7278 } |
|
7279 html += group; |
|
7280 } |
|
7281 html += (!inst.inline ? buttonPanel : '') + |
|
7282 ($.browser.msie && parseInt($.browser.version,10) < 7 && !inst.inline ? |
|
7283 '<iframe src="javascript:false;" class="ui-datepicker-cover" frameborder="0"></iframe>' : ''); |
|
7284 inst._keyEvent = false; |
|
7285 return html; |
|
7286 }, |
|
7287 |
|
7288 /* Generate the month and year header. */ |
|
7289 _generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate, |
|
7290 selectedDate, secondary, monthNames, monthNamesShort) { |
|
7291 minDate = (inst.rangeStart && minDate && selectedDate < minDate ? selectedDate : minDate); |
|
7292 var changeMonth = this._get(inst, 'changeMonth'); |
|
7293 var changeYear = this._get(inst, 'changeYear'); |
|
7294 var showMonthAfterYear = this._get(inst, 'showMonthAfterYear'); |
|
7295 var html = '<div class="ui-datepicker-title">'; |
|
7296 var monthHtml = ''; |
|
7297 // month selection |
|
7298 if (secondary || !changeMonth) |
|
7299 monthHtml += '<span class="ui-datepicker-month">' + monthNames[drawMonth] + '</span> '; |
|
7300 else { |
|
7301 var inMinYear = (minDate && minDate.getFullYear() == drawYear); |
|
7302 var inMaxYear = (maxDate && maxDate.getFullYear() == drawYear); |
|
7303 monthHtml += '<select class="ui-datepicker-month" ' + |
|
7304 'onchange="jQuery.datepicker._selectMonthYear(\'#' + inst.id + '\', this, \'M\');" ' + |
|
7305 'onclick="jQuery.datepicker._clickMonthYear(\'#' + inst.id + '\');"' + |
|
7306 '>'; |
|
7307 for (var month = 0; month < 12; month++) { |
|
7308 if ((!inMinYear || month >= minDate.getMonth()) && |
|
7309 (!inMaxYear || month <= maxDate.getMonth())) |
|
7310 monthHtml += '<option value="' + month + '"' + |
|
7311 (month == drawMonth ? ' selected="selected"' : '') + |
|
7312 '>' + monthNamesShort[month] + '</option>'; |
|
7313 } |
|
7314 monthHtml += '</select>'; |
|
7315 } |
|
7316 if (!showMonthAfterYear) |
|
7317 html += monthHtml + ((secondary || changeMonth || changeYear) && (!(changeMonth && changeYear)) ? ' ' : ''); |
|
7318 // year selection |
|
7319 if (secondary || !changeYear) |
|
7320 html += '<span class="ui-datepicker-year">' + drawYear + '</span>'; |
|
7321 else { |
|
7322 // determine range of years to display |
|
7323 var years = this._get(inst, 'yearRange').split(':'); |
|
7324 var year = 0; |
|
7325 var endYear = 0; |
|
7326 if (years.length != 2) { |
|
7327 year = drawYear - 10; |
|
7328 endYear = drawYear + 10; |
|
7329 } else if (years[0].charAt(0) == '+' || years[0].charAt(0) == '-') { |
|
7330 year = drawYear + parseInt(years[0], 10); |
|
7331 endYear = drawYear + parseInt(years[1], 10); |
|
7332 } else { |
|
7333 year = parseInt(years[0], 10); |
|
7334 endYear = parseInt(years[1], 10); |
|
7335 } |
|
7336 year = (minDate ? Math.max(year, minDate.getFullYear()) : year); |
|
7337 endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear); |
|
7338 html += '<select class="ui-datepicker-year" ' + |
|
7339 'onchange="jQuery.datepicker._selectMonthYear(\'#' + inst.id + '\', this, \'Y\');" ' + |
|
7340 'onclick="jQuery.datepicker._clickMonthYear(\'#' + inst.id + '\');"' + |
|
7341 '>'; |
|
7342 for (; year <= endYear; year++) { |
|
7343 html += '<option value="' + year + '"' + |
|
7344 (year == drawYear ? ' selected="selected"' : '') + |
|
7345 '>' + year + '</option>'; |
|
7346 } |
|
7347 html += '</select>'; |
|
7348 } |
|
7349 if (showMonthAfterYear) |
|
7350 html += (secondary || changeMonth || changeYear ? ' ' : '') + monthHtml; |
|
7351 html += '</div>'; // Close datepicker_header |
|
7352 return html; |
|
7353 }, |
|
7354 |
|
7355 /* Adjust one of the date sub-fields. */ |
|
7356 _adjustInstDate: function(inst, offset, period) { |
|
7357 var year = inst.drawYear + (period == 'Y' ? offset : 0); |
|
7358 var month = inst.drawMonth + (period == 'M' ? offset : 0); |
|
7359 var day = Math.min(inst.selectedDay, this._getDaysInMonth(year, month)) + |
|
7360 (period == 'D' ? offset : 0); |
|
7361 var date = this._daylightSavingAdjust(new Date(year, month, day)); |
|
7362 // ensure it is within the bounds set |
|
7363 var minDate = this._getMinMaxDate(inst, 'min', true); |
|
7364 var maxDate = this._getMinMaxDate(inst, 'max'); |
|
7365 date = (minDate && date < minDate ? minDate : date); |
|
7366 date = (maxDate && date > maxDate ? maxDate : date); |
|
7367 inst.selectedDay = date.getDate(); |
|
7368 inst.drawMonth = inst.selectedMonth = date.getMonth(); |
|
7369 inst.drawYear = inst.selectedYear = date.getFullYear(); |
|
7370 if (period == 'M' || period == 'Y') |
|
7371 this._notifyChange(inst); |
|
7372 }, |
|
7373 |
|
7374 /* Notify change of month/year. */ |
|
7375 _notifyChange: function(inst) { |
|
7376 var onChange = this._get(inst, 'onChangeMonthYear'); |
|
7377 if (onChange) |
|
7378 onChange.apply((inst.input ? inst.input[0] : null), |
|
7379 [inst.selectedYear, inst.selectedMonth + 1, inst]); |
|
7380 }, |
|
7381 |
|
7382 /* Determine the number of months to show. */ |
|
7383 _getNumberOfMonths: function(inst) { |
|
7384 var numMonths = this._get(inst, 'numberOfMonths'); |
|
7385 return (numMonths == null ? [1, 1] : (typeof numMonths == 'number' ? [1, numMonths] : numMonths)); |
|
7386 }, |
|
7387 |
|
7388 /* Determine the current maximum date - ensure no time components are set - may be overridden for a range. */ |
|
7389 _getMinMaxDate: function(inst, minMax, checkRange) { |
|
7390 var date = this._determineDate(this._get(inst, minMax + 'Date'), null); |
|
7391 return (!checkRange || !inst.rangeStart ? date : |
|
7392 (!date || inst.rangeStart > date ? inst.rangeStart : date)); |
|
7393 }, |
|
7394 |
|
7395 /* Find the number of days in a given month. */ |
|
7396 _getDaysInMonth: function(year, month) { |
|
7397 return 32 - new Date(year, month, 32).getDate(); |
|
7398 }, |
|
7399 |
|
7400 /* Find the day of the week of the first of a month. */ |
|
7401 _getFirstDayOfMonth: function(year, month) { |
|
7402 return new Date(year, month, 1).getDay(); |
|
7403 }, |
|
7404 |
|
7405 /* Determines if we should allow a "next/prev" month display change. */ |
|
7406 _canAdjustMonth: function(inst, offset, curYear, curMonth) { |
|
7407 var numMonths = this._getNumberOfMonths(inst); |
|
7408 var date = this._daylightSavingAdjust(new Date( |
|
7409 curYear, curMonth + (offset < 0 ? offset : numMonths[1]), 1)); |
|
7410 if (offset < 0) |
|
7411 date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth())); |
|
7412 return this._isInRange(inst, date); |
|
7413 }, |
|
7414 |
|
7415 /* Is the given date in the accepted range? */ |
|
7416 _isInRange: function(inst, date) { |
|
7417 // during range selection, use minimum of selected date and range start |
|
7418 var newMinDate = (!inst.rangeStart ? null : this._daylightSavingAdjust( |
|
7419 new Date(inst.selectedYear, inst.selectedMonth, inst.selectedDay))); |
|
7420 newMinDate = (newMinDate && inst.rangeStart < newMinDate ? inst.rangeStart : newMinDate); |
|
7421 var minDate = newMinDate || this._getMinMaxDate(inst, 'min'); |
|
7422 var maxDate = this._getMinMaxDate(inst, 'max'); |
|
7423 return ((!minDate || date >= minDate) && (!maxDate || date <= maxDate)); |
|
7424 }, |
|
7425 |
|
7426 /* Provide the configuration settings for formatting/parsing. */ |
|
7427 _getFormatConfig: function(inst) { |
|
7428 var shortYearCutoff = this._get(inst, 'shortYearCutoff'); |
|
7429 shortYearCutoff = (typeof shortYearCutoff != 'string' ? shortYearCutoff : |
|
7430 new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10)); |
|
7431 return {shortYearCutoff: shortYearCutoff, |
|
7432 dayNamesShort: this._get(inst, 'dayNamesShort'), dayNames: this._get(inst, 'dayNames'), |
|
7433 monthNamesShort: this._get(inst, 'monthNamesShort'), monthNames: this._get(inst, 'monthNames')}; |
|
7434 }, |
|
7435 |
|
7436 /* Format the given date for display. */ |
|
7437 _formatDate: function(inst, day, month, year) { |
|
7438 if (!day) { |
|
7439 inst.currentDay = inst.selectedDay; |
|
7440 inst.currentMonth = inst.selectedMonth; |
|
7441 inst.currentYear = inst.selectedYear; |
|
7442 } |
|
7443 var date = (day ? (typeof day == 'object' ? day : |
|
7444 this._daylightSavingAdjust(new Date(year, month, day))) : |
|
7445 this._daylightSavingAdjust(new Date(inst.currentYear, inst.currentMonth, inst.currentDay))); |
|
7446 return this.formatDate(this._get(inst, 'dateFormat'), date, this._getFormatConfig(inst)); |
|
7447 } |
|
7448 }); |
|
7449 |
|
7450 /* jQuery extend now ignores nulls! */ |
|
7451 function extendRemove(target, props) { |
|
7452 $.extend(target, props); |
|
7453 for (var name in props) |
|
7454 if (props[name] == null || props[name] == undefined) |
|
7455 target[name] = props[name]; |
|
7456 return target; |
|
7457 }; |
|
7458 |
|
7459 /* Determine whether an object is an array. */ |
|
7460 function isArray(a) { |
|
7461 return (a && (($.browser.safari && typeof a == 'object' && a.length) || |
|
7462 (a.constructor && a.constructor.toString().match(/\Array\(\)/)))); |
|
7463 }; |
|
7464 |
|
7465 /* Invoke the datepicker functionality. |
|
7466 @param options string - a command, optionally followed by additional parameters or |
|
7467 Object - settings for attaching new datepicker functionality |
|
7468 @return jQuery object */ |
|
7469 $.fn.datepicker = function(options){ |
|
7470 |
|
7471 /* Initialise the date picker. */ |
|
7472 if (!$.datepicker.initialized) { |
|
7473 $(document).mousedown($.datepicker._checkExternalClick). |
|
7474 find('body').append($.datepicker.dpDiv); |
|
7475 $.datepicker.initialized = true; |
|
7476 } |
|
7477 |
|
7478 var otherArgs = Array.prototype.slice.call(arguments, 1); |
|
7479 if (typeof options == 'string' && (options == 'isDisabled' || options == 'getDate')) |
|
7480 return $.datepicker['_' + options + 'Datepicker']. |
|
7481 apply($.datepicker, [this[0]].concat(otherArgs)); |
|
7482 return this.each(function() { |
|
7483 typeof options == 'string' ? |
|
7484 $.datepicker['_' + options + 'Datepicker']. |
|
7485 apply($.datepicker, [this].concat(otherArgs)) : |
|
7486 $.datepicker._attachDatepicker(this, options); |
|
7487 }); |
|
7488 }; |
|
7489 |
|
7490 $.datepicker = new Datepicker(); // singleton instance |
|
7491 $.datepicker.initialized = false; |
|
7492 $.datepicker.uuid = new Date().getTime(); |
|
7493 $.datepicker.version = "1.6rc6"; |
|
7494 |
|
7495 })(jQuery); |
|
7496 /* |
|
7497 * jQuery UI Progressbar 1.6rc6 |
|
7498 * |
|
7499 * Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about) |
|
7500 * Dual licensed under the MIT (MIT-LICENSE.txt) |
|
7501 * and GPL (GPL-LICENSE.txt) licenses. |
|
7502 * |
|
7503 * http://docs.jquery.com/UI/Progressbar |
|
7504 * |
|
7505 * Depends: |
|
7506 * ui.core.js |
|
7507 */ |
|
7508 (function($) { |
|
7509 |
|
7510 $.widget("ui.progressbar", { |
|
7511 |
|
7512 _init: function() { |
|
7513 |
|
7514 var self = this, |
|
7515 options = this.options; |
|
7516 |
|
7517 this.element |
|
7518 .addClass("ui-progressbar" |
|
7519 + " ui-widget" |
|
7520 + " ui-widget-content" |
|
7521 + " ui-corner-all") |
|
7522 .attr({ |
|
7523 role: "progressbar", |
|
7524 "aria-valuemin": this._valueMin(), |
|
7525 "aria-valuemax": this._valueMax(), |
|
7526 "aria-valuenow": this._value() |
|
7527 }); |
|
7528 |
|
7529 this.valueDiv = $('<div class="ui-progressbar-value ui-widget-header ui-corner-left"></div>').appendTo(this.element); |
|
7530 |
|
7531 this._refreshValue(); |
|
7532 |
|
7533 }, |
|
7534 |
|
7535 destroy: function() { |
|
7536 |
|
7537 this.element |
|
7538 .removeClass("ui-progressbar" |
|
7539 + " ui-widget" |
|
7540 + " ui-widget-content" |
|
7541 + " ui-corner-all") |
|
7542 .removeAttr("role") |
|
7543 .removeAttr("aria-valuemin") |
|
7544 .removeAttr("aria-valuemax") |
|
7545 .removeAttr("aria-valuenow") |
|
7546 .removeData("progressbar") |
|
7547 .unbind(".progressbar"); |
|
7548 |
|
7549 this.valueDiv.remove(); |
|
7550 |
|
7551 $.widget.prototype.destroy.apply(this, arguments); |
|
7552 |
|
7553 }, |
|
7554 |
|
7555 value: function(newValue) { |
|
7556 arguments.length && this._setData("value", newValue); |
|
7557 |
|
7558 return this._value(); |
|
7559 }, |
|
7560 |
|
7561 _setData: function(key, value){ |
|
7562 switch (key) { |
|
7563 case 'value': |
|
7564 this.options.value = value; |
|
7565 this._refreshValue(); |
|
7566 this._trigger('change', null, {}); |
|
7567 break; |
|
7568 } |
|
7569 |
|
7570 $.widget.prototype._setData.apply(this, arguments); |
|
7571 }, |
|
7572 |
|
7573 _value: function() { |
|
7574 var val = this.options.value; |
|
7575 if (val < this._valueMin()) val = this._valueMin(); |
|
7576 if (val > this._valueMax()) val = this._valueMax(); |
|
7577 |
|
7578 return val; |
|
7579 }, |
|
7580 |
|
7581 _valueMin: function() { |
|
7582 var valueMin = 0; |
|
7583 |
|
7584 return valueMin; |
|
7585 }, |
|
7586 |
|
7587 _valueMax: function() { |
|
7588 var valueMax = 100; |
|
7589 |
|
7590 return valueMax; |
|
7591 }, |
|
7592 |
|
7593 _refreshValue: function() { |
|
7594 var value = this.value(); |
|
7595 this.valueDiv[value == this._valueMax() ? 'addClass' : 'removeClass']("ui-corner-right"); |
|
7596 this.valueDiv.width(value + '%'); |
|
7597 this.element.attr("aria-valuenow", value); |
|
7598 } |
|
7599 |
|
7600 }); |
|
7601 |
|
7602 $.extend($.ui.progressbar, { |
|
7603 version: "1.6rc6", |
|
7604 defaults: { |
|
7605 value: 0 |
|
7606 } |
|
7607 }); |
|
7608 |
|
7609 })(jQuery); |
|
7610 /* |
|
7611 * jQuery UI Effects 1.6rc6 |
|
7612 * |
|
7613 * Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about) |
|
7614 * Dual licensed under the MIT (MIT-LICENSE.txt) |
|
7615 * and GPL (GPL-LICENSE.txt) licenses. |
|
7616 * |
|
7617 * http://docs.jquery.com/UI/Effects/ |
|
7618 */ |
|
7619 ;(function($) { |
|
7620 |
|
7621 $.effects = $.effects || {}; //Add the 'effects' scope |
|
7622 |
|
7623 $.extend($.effects, { |
|
7624 version: "1.6rc6", |
|
7625 |
|
7626 // Saves a set of properties in a data storage |
|
7627 save: function(element, set) { |
|
7628 for(var i=0; i < set.length; i++) { |
|
7629 if(set[i] !== null) element.data("ec.storage."+set[i], element[0].style[set[i]]); |
|
7630 } |
|
7631 }, |
|
7632 |
|
7633 // Restores a set of previously saved properties from a data storage |
|
7634 restore: function(element, set) { |
|
7635 for(var i=0; i < set.length; i++) { |
|
7636 if(set[i] !== null) element.css(set[i], element.data("ec.storage."+set[i])); |
|
7637 } |
|
7638 }, |
|
7639 |
|
7640 setMode: function(el, mode) { |
|
7641 if (mode == 'toggle') mode = el.is(':hidden') ? 'show' : 'hide'; // Set for toggle |
|
7642 return mode; |
|
7643 }, |
|
7644 |
|
7645 getBaseline: function(origin, original) { // Translates a [top,left] array into a baseline value |
|
7646 // this should be a little more flexible in the future to handle a string & hash |
|
7647 var y, x; |
|
7648 switch (origin[0]) { |
|
7649 case 'top': y = 0; break; |
|
7650 case 'middle': y = 0.5; break; |
|
7651 case 'bottom': y = 1; break; |
|
7652 default: y = origin[0] / original.height; |
|
7653 }; |
|
7654 switch (origin[1]) { |
|
7655 case 'left': x = 0; break; |
|
7656 case 'center': x = 0.5; break; |
|
7657 case 'right': x = 1; break; |
|
7658 default: x = origin[1] / original.width; |
|
7659 }; |
|
7660 return {x: x, y: y}; |
|
7661 }, |
|
7662 |
|
7663 // Wraps the element around a wrapper that copies position properties |
|
7664 createWrapper: function(element) { |
|
7665 |
|
7666 //if the element is already wrapped, return it |
|
7667 if (element.parent().is('.ui-effects-wrapper')) |
|
7668 return element.parent(); |
|
7669 |
|
7670 //Cache width,height and float properties of the element, and create a wrapper around it |
|
7671 var props = { width: element.outerWidth(true), height: element.outerHeight(true), 'float': element.css('float') }; |
|
7672 element.wrap('<div class="ui-effects-wrapper" style="font-size:100%;background:transparent;border:none;margin:0;padding:0"></div>'); |
|
7673 var wrapper = element.parent(); |
|
7674 |
|
7675 //Transfer the positioning of the element to the wrapper |
|
7676 if (element.css('position') == 'static') { |
|
7677 wrapper.css({ position: 'relative' }); |
|
7678 element.css({ position: 'relative'} ); |
|
7679 } else { |
|
7680 var top = element.css('top'); if(isNaN(parseInt(top,10))) top = 'auto'; |
|
7681 var left = element.css('left'); if(isNaN(parseInt(left,10))) left = 'auto'; |
|
7682 wrapper.css({ position: element.css('position'), top: top, left: left, zIndex: element.css('z-index') }).show(); |
|
7683 element.css({position: 'relative', top: 0, left: 0 }); |
|
7684 } |
|
7685 |
|
7686 wrapper.css(props); |
|
7687 return wrapper; |
|
7688 }, |
|
7689 |
|
7690 removeWrapper: function(element) { |
|
7691 if (element.parent().is('.ui-effects-wrapper')) |
|
7692 return element.parent().replaceWith(element); |
|
7693 return element; |
|
7694 }, |
|
7695 |
|
7696 setTransition: function(element, list, factor, value) { |
|
7697 value = value || {}; |
|
7698 $.each(list, function(i, x){ |
|
7699 unit = element.cssUnit(x); |
|
7700 if (unit[0] > 0) value[x] = unit[0] * factor + unit[1]; |
|
7701 }); |
|
7702 return value; |
|
7703 }, |
|
7704 |
|
7705 //Base function to animate from one class to another in a seamless transition |
|
7706 animateClass: function(value, duration, easing, callback) { |
|
7707 |
|
7708 var cb = (typeof easing == "function" ? easing : (callback ? callback : null)); |
|
7709 var ea = (typeof easing == "string" ? easing : null); |
|
7710 |
|
7711 return this.each(function() { |
|
7712 |
|
7713 var offset = {}; var that = $(this); var oldStyleAttr = that.attr("style") || ''; |
|
7714 if(typeof oldStyleAttr == 'object') oldStyleAttr = oldStyleAttr["cssText"]; /* Stupidly in IE, style is a object.. */ |
|
7715 if(value.toggle) { that.hasClass(value.toggle) ? value.remove = value.toggle : value.add = value.toggle; } |
|
7716 |
|
7717 //Let's get a style offset |
|
7718 var oldStyle = $.extend({}, (document.defaultView ? document.defaultView.getComputedStyle(this,null) : this.currentStyle)); |
|
7719 if(value.add) that.addClass(value.add); if(value.remove) that.removeClass(value.remove); |
|
7720 var newStyle = $.extend({}, (document.defaultView ? document.defaultView.getComputedStyle(this,null) : this.currentStyle)); |
|
7721 if(value.add) that.removeClass(value.add); if(value.remove) that.addClass(value.remove); |
|
7722 |
|
7723 // The main function to form the object for animation |
|
7724 for(var n in newStyle) { |
|
7725 if( typeof newStyle[n] != "function" && newStyle[n] /* No functions and null properties */ |
|
7726 && n.indexOf("Moz") == -1 && n.indexOf("length") == -1 /* No mozilla spezific render properties. */ |
|
7727 && newStyle[n] != oldStyle[n] /* Only values that have changed are used for the animation */ |
|
7728 && (n.match(/color/i) || (!n.match(/color/i) && !isNaN(parseInt(newStyle[n],10)))) /* Only things that can be parsed to integers or colors */ |
|
7729 && (oldStyle.position != "static" || (oldStyle.position == "static" && !n.match(/left|top|bottom|right/))) /* No need for positions when dealing with static positions */ |
|
7730 ) offset[n] = newStyle[n]; |
|
7731 } |
|
7732 |
|
7733 that.animate(offset, duration, ea, function() { // Animate the newly constructed offset object |
|
7734 // Change style attribute back to original. For stupid IE, we need to clear the damn object. |
|
7735 if(typeof $(this).attr("style") == 'object') { $(this).attr("style")["cssText"] = ""; $(this).attr("style")["cssText"] = oldStyleAttr; } else $(this).attr("style", oldStyleAttr); |
|
7736 if(value.add) $(this).addClass(value.add); if(value.remove) $(this).removeClass(value.remove); |
|
7737 if(cb) cb.apply(this, arguments); |
|
7738 }); |
|
7739 |
|
7740 }); |
|
7741 } |
|
7742 }); |
|
7743 |
|
7744 |
|
7745 function _normalizeArguments(a, m) { |
|
7746 |
|
7747 var o = a[1] && a[1].constructor == Object ? a[1] : {}; if(m) o.mode = m; |
|
7748 var speed = a[1] && a[1].constructor != Object ? a[1] : o.duration; //either comes from options.duration or the second argument |
|
7749 speed = $.fx.off ? 0 : typeof speed === "number" ? speed : $.fx.speeds[speed] || $.fx.speeds._default; |
|
7750 var callback = o.callback || ( $.isFunction(a[2]) && a[2] ) || ( $.isFunction(a[3]) && a[3] ); |
|
7751 |
|
7752 return [a[0], o, speed, callback]; |
|
7753 |
|
7754 } |
|
7755 |
|
7756 //Extend the methods of jQuery |
|
7757 $.fn.extend({ |
|
7758 |
|
7759 //Save old methods |
|
7760 _show: $.fn.show, |
|
7761 _hide: $.fn.hide, |
|
7762 __toggle: $.fn.toggle, |
|
7763 _addClass: $.fn.addClass, |
|
7764 _removeClass: $.fn.removeClass, |
|
7765 _toggleClass: $.fn.toggleClass, |
|
7766 |
|
7767 // New effect methods |
|
7768 effect: function(fx, options, speed, callback) { |
|
7769 return $.effects[fx] ? $.effects[fx].call(this, {method: fx, options: options || {}, duration: speed, callback: callback }) : null; |
|
7770 }, |
|
7771 |
|
7772 show: function() { |
|
7773 if(!arguments[0] || (arguments[0].constructor == Number || (/(slow|normal|fast)/).test(arguments[0]))) |
|
7774 return this._show.apply(this, arguments); |
|
7775 else { |
|
7776 return this.effect.apply(this, _normalizeArguments(arguments, 'show')); |
|
7777 } |
|
7778 }, |
|
7779 |
|
7780 hide: function() { |
|
7781 if(!arguments[0] || (arguments[0].constructor == Number || (/(slow|normal|fast)/).test(arguments[0]))) |
|
7782 return this._hide.apply(this, arguments); |
|
7783 else { |
|
7784 return this.effect.apply(this, _normalizeArguments(arguments, 'hide')); |
|
7785 } |
|
7786 }, |
|
7787 |
|
7788 toggle: function(){ |
|
7789 if(!arguments[0] || (arguments[0].constructor == Number || (/(slow|normal|fast)/).test(arguments[0])) || (arguments[0].constructor == Function)) |
|
7790 return this.__toggle.apply(this, arguments); |
|
7791 else { |
|
7792 return this.effect.apply(this, _normalizeArguments(arguments, 'toggle')); |
|
7793 } |
|
7794 }, |
|
7795 |
|
7796 addClass: function(classNames, speed, easing, callback) { |
|
7797 return speed ? $.effects.animateClass.apply(this, [{ add: classNames },speed,easing,callback]) : this._addClass(classNames); |
|
7798 }, |
|
7799 removeClass: function(classNames,speed,easing,callback) { |
|
7800 return speed ? $.effects.animateClass.apply(this, [{ remove: classNames },speed,easing,callback]) : this._removeClass(classNames); |
|
7801 }, |
|
7802 toggleClass: function(classNames,speed,easing,callback) { |
|
7803 return ( (typeof speed !== "boolean") && speed ) ? $.effects.animateClass.apply(this, [{ toggle: classNames },speed,easing,callback]) : this._toggleClass(classNames, speed); |
|
7804 }, |
|
7805 morph: function(remove,add,speed,easing,callback) { |
|
7806 return $.effects.animateClass.apply(this, [{ add: add, remove: remove },speed,easing,callback]); |
|
7807 }, |
|
7808 switchClass: function() { |
|
7809 return this.morph.apply(this, arguments); |
|
7810 }, |
|
7811 |
|
7812 // helper functions |
|
7813 cssUnit: function(key) { |
|
7814 var style = this.css(key), val = []; |
|
7815 $.each( ['em','px','%','pt'], function(i, unit){ |
|
7816 if(style.indexOf(unit) > 0) |
|
7817 val = [parseFloat(style), unit]; |
|
7818 }); |
|
7819 return val; |
|
7820 } |
|
7821 }); |
|
7822 |
|
7823 /* |
|
7824 * jQuery Color Animations |
|
7825 * Copyright 2007 John Resig |
|
7826 * Released under the MIT and GPL licenses. |
|
7827 */ |
|
7828 |
|
7829 // We override the animation for all of these color styles |
|
7830 $.each(['backgroundColor', 'borderBottomColor', 'borderLeftColor', 'borderRightColor', 'borderTopColor', 'color', 'outlineColor'], function(i,attr){ |
|
7831 $.fx.step[attr] = function(fx) { |
|
7832 if ( fx.state == 0 ) { |
|
7833 fx.start = getColor( fx.elem, attr ); |
|
7834 fx.end = getRGB( fx.end ); |
|
7835 } |
|
7836 |
|
7837 fx.elem.style[attr] = "rgb(" + [ |
|
7838 Math.max(Math.min( parseInt((fx.pos * (fx.end[0] - fx.start[0])) + fx.start[0],10), 255), 0), |
|
7839 Math.max(Math.min( parseInt((fx.pos * (fx.end[1] - fx.start[1])) + fx.start[1],10), 255), 0), |
|
7840 Math.max(Math.min( parseInt((fx.pos * (fx.end[2] - fx.start[2])) + fx.start[2],10), 255), 0) |
|
7841 ].join(",") + ")"; |
|
7842 }; |
|
7843 }); |
|
7844 |
|
7845 // Color Conversion functions from highlightFade |
|
7846 // By Blair Mitchelmore |
|
7847 // http://jquery.offput.ca/highlightFade/ |
|
7848 |
|
7849 // Parse strings looking for color tuples [255,255,255] |
|
7850 function getRGB(color) { |
|
7851 var result; |
|
7852 |
|
7853 // Check if we're already dealing with an array of colors |
|
7854 if ( color && color.constructor == Array && color.length == 3 ) |
|
7855 return color; |
|
7856 |
|
7857 // Look for rgb(num,num,num) |
|
7858 if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color)) |
|
7859 return [parseInt(result[1],10), parseInt(result[2],10), parseInt(result[3],10)]; |
|
7860 |
|
7861 // Look for rgb(num%,num%,num%) |
|
7862 if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color)) |
|
7863 return [parseFloat(result[1])*2.55, parseFloat(result[2])*2.55, parseFloat(result[3])*2.55]; |
|
7864 |
|
7865 // Look for #a0b1c2 |
|
7866 if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color)) |
|
7867 return [parseInt(result[1],16), parseInt(result[2],16), parseInt(result[3],16)]; |
|
7868 |
|
7869 // Look for #fff |
|
7870 if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color)) |
|
7871 return [parseInt(result[1]+result[1],16), parseInt(result[2]+result[2],16), parseInt(result[3]+result[3],16)]; |
|
7872 |
|
7873 // Look for rgba(0, 0, 0, 0) == transparent in Safari 3 |
|
7874 if (result = /rgba\(0, 0, 0, 0\)/.exec(color)) |
|
7875 return colors['transparent']; |
|
7876 |
|
7877 // Otherwise, we're most likely dealing with a named color |
|
7878 return colors[$.trim(color).toLowerCase()]; |
|
7879 } |
|
7880 |
|
7881 function getColor(elem, attr) { |
|
7882 var color; |
|
7883 |
|
7884 do { |
|
7885 color = $.curCSS(elem, attr); |
|
7886 |
|
7887 // Keep going until we find an element that has color, or we hit the body |
|
7888 if ( color != '' && color != 'transparent' || $.nodeName(elem, "body") ) |
|
7889 break; |
|
7890 |
|
7891 attr = "backgroundColor"; |
|
7892 } while ( elem = elem.parentNode ); |
|
7893 |
|
7894 return getRGB(color); |
|
7895 }; |
|
7896 |
|
7897 // Some named colors to work with |
|
7898 // From Interface by Stefan Petre |
|
7899 // http://interface.eyecon.ro/ |
|
7900 |
|
7901 var colors = { |
|
7902 aqua:[0,255,255], |
|
7903 azure:[240,255,255], |
|
7904 beige:[245,245,220], |
|
7905 black:[0,0,0], |
|
7906 blue:[0,0,255], |
|
7907 brown:[165,42,42], |
|
7908 cyan:[0,255,255], |
|
7909 darkblue:[0,0,139], |
|
7910 darkcyan:[0,139,139], |
|
7911 darkgrey:[169,169,169], |
|
7912 darkgreen:[0,100,0], |
|
7913 darkkhaki:[189,183,107], |
|
7914 darkmagenta:[139,0,139], |
|
7915 darkolivegreen:[85,107,47], |
|
7916 darkorange:[255,140,0], |
|
7917 darkorchid:[153,50,204], |
|
7918 darkred:[139,0,0], |
|
7919 darksalmon:[233,150,122], |
|
7920 darkviolet:[148,0,211], |
|
7921 fuchsia:[255,0,255], |
|
7922 gold:[255,215,0], |
|
7923 green:[0,128,0], |
|
7924 indigo:[75,0,130], |
|
7925 khaki:[240,230,140], |
|
7926 lightblue:[173,216,230], |
|
7927 lightcyan:[224,255,255], |
|
7928 lightgreen:[144,238,144], |
|
7929 lightgrey:[211,211,211], |
|
7930 lightpink:[255,182,193], |
|
7931 lightyellow:[255,255,224], |
|
7932 lime:[0,255,0], |
|
7933 magenta:[255,0,255], |
|
7934 maroon:[128,0,0], |
|
7935 navy:[0,0,128], |
|
7936 olive:[128,128,0], |
|
7937 orange:[255,165,0], |
|
7938 pink:[255,192,203], |
|
7939 purple:[128,0,128], |
|
7940 violet:[128,0,128], |
|
7941 red:[255,0,0], |
|
7942 silver:[192,192,192], |
|
7943 white:[255,255,255], |
|
7944 yellow:[255,255,0], |
|
7945 transparent: [255,255,255] |
|
7946 }; |
|
7947 |
|
7948 /* |
|
7949 * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/ |
|
7950 * |
|
7951 * Uses the built in easing capabilities added In jQuery 1.1 |
|
7952 * to offer multiple easing options |
|
7953 * |
|
7954 * TERMS OF USE - jQuery Easing |
|
7955 * |
|
7956 * Open source under the BSD License. |
|
7957 * |
|
7958 * Copyright 2008 George McGinley Smith |
|
7959 * All rights reserved. |
|
7960 * |
|
7961 * Redistribution and use in source and binary forms, with or without modification, |
|
7962 * are permitted provided that the following conditions are met: |
|
7963 * |
|
7964 * Redistributions of source code must retain the above copyright notice, this list of |
|
7965 * conditions and the following disclaimer. |
|
7966 * Redistributions in binary form must reproduce the above copyright notice, this list |
|
7967 * of conditions and the following disclaimer in the documentation and/or other materials |
|
7968 * provided with the distribution. |
|
7969 * |
|
7970 * Neither the name of the author nor the names of contributors may be used to endorse |
|
7971 * or promote products derived from this software without specific prior written permission. |
|
7972 * |
|
7973 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY |
|
7974 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
|
7975 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
|
7976 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
|
7977 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE |
|
7978 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
|
7979 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
|
7980 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
|
7981 * OF THE POSSIBILITY OF SUCH DAMAGE. |
|
7982 * |
|
7983 */ |
|
7984 |
|
7985 // t: current time, b: begInnIng value, c: change In value, d: duration |
|
7986 $.easing.jswing = $.easing.swing; |
|
7987 |
|
7988 $.extend($.easing, |
|
7989 { |
|
7990 def: 'easeOutQuad', |
|
7991 swing: function (x, t, b, c, d) { |
|
7992 //alert($.easing.default); |
|
7993 return $.easing[$.easing.def](x, t, b, c, d); |
|
7994 }, |
|
7995 easeInQuad: function (x, t, b, c, d) { |
|
7996 return c*(t/=d)*t + b; |
|
7997 }, |
|
7998 easeOutQuad: function (x, t, b, c, d) { |
|
7999 return -c *(t/=d)*(t-2) + b; |
|
8000 }, |
|
8001 easeInOutQuad: function (x, t, b, c, d) { |
|
8002 if ((t/=d/2) < 1) return c/2*t*t + b; |
|
8003 return -c/2 * ((--t)*(t-2) - 1) + b; |
|
8004 }, |
|
8005 easeInCubic: function (x, t, b, c, d) { |
|
8006 return c*(t/=d)*t*t + b; |
|
8007 }, |
|
8008 easeOutCubic: function (x, t, b, c, d) { |
|
8009 return c*((t=t/d-1)*t*t + 1) + b; |
|
8010 }, |
|
8011 easeInOutCubic: function (x, t, b, c, d) { |
|
8012 if ((t/=d/2) < 1) return c/2*t*t*t + b; |
|
8013 return c/2*((t-=2)*t*t + 2) + b; |
|
8014 }, |
|
8015 easeInQuart: function (x, t, b, c, d) { |
|
8016 return c*(t/=d)*t*t*t + b; |
|
8017 }, |
|
8018 easeOutQuart: function (x, t, b, c, d) { |
|
8019 return -c * ((t=t/d-1)*t*t*t - 1) + b; |
|
8020 }, |
|
8021 easeInOutQuart: function (x, t, b, c, d) { |
|
8022 if ((t/=d/2) < 1) return c/2*t*t*t*t + b; |
|
8023 return -c/2 * ((t-=2)*t*t*t - 2) + b; |
|
8024 }, |
|
8025 easeInQuint: function (x, t, b, c, d) { |
|
8026 return c*(t/=d)*t*t*t*t + b; |
|
8027 }, |
|
8028 easeOutQuint: function (x, t, b, c, d) { |
|
8029 return c*((t=t/d-1)*t*t*t*t + 1) + b; |
|
8030 }, |
|
8031 easeInOutQuint: function (x, t, b, c, d) { |
|
8032 if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b; |
|
8033 return c/2*((t-=2)*t*t*t*t + 2) + b; |
|
8034 }, |
|
8035 easeInSine: function (x, t, b, c, d) { |
|
8036 return -c * Math.cos(t/d * (Math.PI/2)) + c + b; |
|
8037 }, |
|
8038 easeOutSine: function (x, t, b, c, d) { |
|
8039 return c * Math.sin(t/d * (Math.PI/2)) + b; |
|
8040 }, |
|
8041 easeInOutSine: function (x, t, b, c, d) { |
|
8042 return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b; |
|
8043 }, |
|
8044 easeInExpo: function (x, t, b, c, d) { |
|
8045 return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b; |
|
8046 }, |
|
8047 easeOutExpo: function (x, t, b, c, d) { |
|
8048 return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b; |
|
8049 }, |
|
8050 easeInOutExpo: function (x, t, b, c, d) { |
|
8051 if (t==0) return b; |
|
8052 if (t==d) return b+c; |
|
8053 if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b; |
|
8054 return c/2 * (-Math.pow(2, -10 * --t) + 2) + b; |
|
8055 }, |
|
8056 easeInCirc: function (x, t, b, c, d) { |
|
8057 return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b; |
|
8058 }, |
|
8059 easeOutCirc: function (x, t, b, c, d) { |
|
8060 return c * Math.sqrt(1 - (t=t/d-1)*t) + b; |
|
8061 }, |
|
8062 easeInOutCirc: function (x, t, b, c, d) { |
|
8063 if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b; |
|
8064 return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b; |
|
8065 }, |
|
8066 easeInElastic: function (x, t, b, c, d) { |
|
8067 var s=1.70158;var p=0;var a=c; |
|
8068 if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3; |
|
8069 if (a < Math.abs(c)) { a=c; var s=p/4; } |
|
8070 else var s = p/(2*Math.PI) * Math.asin (c/a); |
|
8071 return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b; |
|
8072 }, |
|
8073 easeOutElastic: function (x, t, b, c, d) { |
|
8074 var s=1.70158;var p=0;var a=c; |
|
8075 if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3; |
|
8076 if (a < Math.abs(c)) { a=c; var s=p/4; } |
|
8077 else var s = p/(2*Math.PI) * Math.asin (c/a); |
|
8078 return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b; |
|
8079 }, |
|
8080 easeInOutElastic: function (x, t, b, c, d) { |
|
8081 var s=1.70158;var p=0;var a=c; |
|
8082 if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5); |
|
8083 if (a < Math.abs(c)) { a=c; var s=p/4; } |
|
8084 else var s = p/(2*Math.PI) * Math.asin (c/a); |
|
8085 if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b; |
|
8086 return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b; |
|
8087 }, |
|
8088 easeInBack: function (x, t, b, c, d, s) { |
|
8089 if (s == undefined) s = 1.70158; |
|
8090 return c*(t/=d)*t*((s+1)*t - s) + b; |
|
8091 }, |
|
8092 easeOutBack: function (x, t, b, c, d, s) { |
|
8093 if (s == undefined) s = 1.70158; |
|
8094 return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b; |
|
8095 }, |
|
8096 easeInOutBack: function (x, t, b, c, d, s) { |
|
8097 if (s == undefined) s = 1.70158; |
|
8098 if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b; |
|
8099 return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b; |
|
8100 }, |
|
8101 easeInBounce: function (x, t, b, c, d) { |
|
8102 return c - $.easing.easeOutBounce (x, d-t, 0, c, d) + b; |
|
8103 }, |
|
8104 easeOutBounce: function (x, t, b, c, d) { |
|
8105 if ((t/=d) < (1/2.75)) { |
|
8106 return c*(7.5625*t*t) + b; |
|
8107 } else if (t < (2/2.75)) { |
|
8108 return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b; |
|
8109 } else if (t < (2.5/2.75)) { |
|
8110 return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b; |
|
8111 } else { |
|
8112 return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b; |
|
8113 } |
|
8114 }, |
|
8115 easeInOutBounce: function (x, t, b, c, d) { |
|
8116 if (t < d/2) return $.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b; |
|
8117 return $.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b; |
|
8118 } |
|
8119 }); |
|
8120 |
|
8121 /* |
|
8122 * |
|
8123 * TERMS OF USE - EASING EQUATIONS |
|
8124 * |
|
8125 * Open source under the BSD License. |
|
8126 * |
|
8127 * Copyright 2001 Robert Penner |
|
8128 * All rights reserved. |
|
8129 * |
|
8130 * Redistribution and use in source and binary forms, with or without modification, |
|
8131 * are permitted provided that the following conditions are met: |
|
8132 * |
|
8133 * Redistributions of source code must retain the above copyright notice, this list of |
|
8134 * conditions and the following disclaimer. |
|
8135 * Redistributions in binary form must reproduce the above copyright notice, this list |
|
8136 * of conditions and the following disclaimer in the documentation and/or other materials |
|
8137 * provided with the distribution. |
|
8138 * |
|
8139 * Neither the name of the author nor the names of contributors may be used to endorse |
|
8140 * or promote products derived from this software without specific prior written permission. |
|
8141 * |
|
8142 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY |
|
8143 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
|
8144 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
|
8145 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
|
8146 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE |
|
8147 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
|
8148 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
|
8149 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
|
8150 * OF THE POSSIBILITY OF SUCH DAMAGE. |
|
8151 * |
|
8152 */ |
|
8153 |
|
8154 })(jQuery); |
|
8155 /* |
|
8156 * jQuery UI Effects Blind 1.6rc6 |
|
8157 * |
|
8158 * Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about) |
|
8159 * Dual licensed under the MIT (MIT-LICENSE.txt) |
|
8160 * and GPL (GPL-LICENSE.txt) licenses. |
|
8161 * |
|
8162 * http://docs.jquery.com/UI/Effects/Blind |
|
8163 * |
|
8164 * Depends: |
|
8165 * effects.core.js |
|
8166 */ |
|
8167 (function($) { |
|
8168 |
|
8169 $.effects.blind = function(o) { |
|
8170 |
|
8171 return this.queue(function() { |
|
8172 |
|
8173 // Create element |
|
8174 var el = $(this), props = ['position','top','left']; |
|
8175 |
|
8176 // Set options |
|
8177 var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode |
|
8178 var direction = o.options.direction || 'vertical'; // Default direction |
|
8179 |
|
8180 // Adjust |
|
8181 $.effects.save(el, props); el.show(); // Save & Show |
|
8182 var wrapper = $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper |
|
8183 var ref = (direction == 'vertical') ? 'height' : 'width'; |
|
8184 var distance = (direction == 'vertical') ? wrapper.height() : wrapper.width(); |
|
8185 if(mode == 'show') wrapper.css(ref, 0); // Shift |
|
8186 |
|
8187 // Animation |
|
8188 var animation = {}; |
|
8189 animation[ref] = mode == 'show' ? distance : 0; |
|
8190 |
|
8191 // Animate |
|
8192 wrapper.animate(animation, o.duration, o.options.easing, function() { |
|
8193 if(mode == 'hide') el.hide(); // Hide |
|
8194 $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore |
|
8195 if(o.callback) o.callback.apply(el[0], arguments); // Callback |
|
8196 el.dequeue(); |
|
8197 }); |
|
8198 |
|
8199 }); |
|
8200 |
|
8201 }; |
|
8202 |
|
8203 })(jQuery); |
|
8204 /* |
|
8205 * jQuery UI Effects Bounce 1.6rc6 |
|
8206 * |
|
8207 * Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about) |
|
8208 * Dual licensed under the MIT (MIT-LICENSE.txt) |
|
8209 * and GPL (GPL-LICENSE.txt) licenses. |
|
8210 * |
|
8211 * http://docs.jquery.com/UI/Effects/Bounce |
|
8212 * |
|
8213 * Depends: |
|
8214 * effects.core.js |
|
8215 */ |
|
8216 (function($) { |
|
8217 |
|
8218 $.effects.bounce = function(o) { |
|
8219 |
|
8220 return this.queue(function() { |
|
8221 |
|
8222 // Create element |
|
8223 var el = $(this), props = ['position','top','left']; |
|
8224 |
|
8225 // Set options |
|
8226 var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode |
|
8227 var direction = o.options.direction || 'up'; // Default direction |
|
8228 var distance = o.options.distance || 20; // Default distance |
|
8229 var times = o.options.times || 5; // Default # of times |
|
8230 var speed = o.duration || 250; // Default speed per bounce |
|
8231 if (/show|hide/.test(mode)) props.push('opacity'); // Avoid touching opacity to prevent clearType and PNG issues in IE |
|
8232 |
|
8233 // Adjust |
|
8234 $.effects.save(el, props); el.show(); // Save & Show |
|
8235 $.effects.createWrapper(el); // Create Wrapper |
|
8236 var ref = (direction == 'up' || direction == 'down') ? 'top' : 'left'; |
|
8237 var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg'; |
|
8238 var distance = o.options.distance || (ref == 'top' ? el.outerHeight({margin:true}) / 3 : el.outerWidth({margin:true}) / 3); |
|
8239 if (mode == 'show') el.css('opacity', 0).css(ref, motion == 'pos' ? -distance : distance); // Shift |
|
8240 if (mode == 'hide') distance = distance / (times * 2); |
|
8241 if (mode != 'hide') times--; |
|
8242 |
|
8243 // Animate |
|
8244 if (mode == 'show') { // Show Bounce |
|
8245 var animation = {opacity: 1}; |
|
8246 animation[ref] = (motion == 'pos' ? '+=' : '-=') + distance; |
|
8247 el.animate(animation, speed / 2, o.options.easing); |
|
8248 distance = distance / 2; |
|
8249 times--; |
|
8250 }; |
|
8251 for (var i = 0; i < times; i++) { // Bounces |
|
8252 var animation1 = {}, animation2 = {}; |
|
8253 animation1[ref] = (motion == 'pos' ? '-=' : '+=') + distance; |
|
8254 animation2[ref] = (motion == 'pos' ? '+=' : '-=') + distance; |
|
8255 el.animate(animation1, speed / 2, o.options.easing).animate(animation2, speed / 2, o.options.easing); |
|
8256 distance = (mode == 'hide') ? distance * 2 : distance / 2; |
|
8257 }; |
|
8258 if (mode == 'hide') { // Last Bounce |
|
8259 var animation = {opacity: 0}; |
|
8260 animation[ref] = (motion == 'pos' ? '-=' : '+=') + distance; |
|
8261 el.animate(animation, speed / 2, o.options.easing, function(){ |
|
8262 el.hide(); // Hide |
|
8263 $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore |
|
8264 if(o.callback) o.callback.apply(this, arguments); // Callback |
|
8265 }); |
|
8266 } else { |
|
8267 var animation1 = {}, animation2 = {}; |
|
8268 animation1[ref] = (motion == 'pos' ? '-=' : '+=') + distance; |
|
8269 animation2[ref] = (motion == 'pos' ? '+=' : '-=') + distance; |
|
8270 el.animate(animation1, speed / 2, o.options.easing).animate(animation2, speed / 2, o.options.easing, function(){ |
|
8271 $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore |
|
8272 if(o.callback) o.callback.apply(this, arguments); // Callback |
|
8273 }); |
|
8274 }; |
|
8275 el.queue('fx', function() { el.dequeue(); }); |
|
8276 el.dequeue(); |
|
8277 }); |
|
8278 |
|
8279 }; |
|
8280 |
|
8281 })(jQuery); |
|
8282 /* |
|
8283 * jQuery UI Effects Clip 1.6rc6 |
|
8284 * |
|
8285 * Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about) |
|
8286 * Dual licensed under the MIT (MIT-LICENSE.txt) |
|
8287 * and GPL (GPL-LICENSE.txt) licenses. |
|
8288 * |
|
8289 * http://docs.jquery.com/UI/Effects/Clip |
|
8290 * |
|
8291 * Depends: |
|
8292 * effects.core.js |
|
8293 */ |
|
8294 (function($) { |
|
8295 |
|
8296 $.effects.clip = function(o) { |
|
8297 |
|
8298 return this.queue(function() { |
|
8299 |
|
8300 // Create element |
|
8301 var el = $(this), props = ['position','top','left','height','width']; |
|
8302 |
|
8303 // Set options |
|
8304 var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode |
|
8305 var direction = o.options.direction || 'vertical'; // Default direction |
|
8306 |
|
8307 // Adjust |
|
8308 $.effects.save(el, props); el.show(); // Save & Show |
|
8309 var wrapper = $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper |
|
8310 var animate = el[0].tagName == 'IMG' ? wrapper : el; |
|
8311 var ref = { |
|
8312 size: (direction == 'vertical') ? 'height' : 'width', |
|
8313 position: (direction == 'vertical') ? 'top' : 'left' |
|
8314 }; |
|
8315 var distance = (direction == 'vertical') ? animate.height() : animate.width(); |
|
8316 if(mode == 'show') { animate.css(ref.size, 0); animate.css(ref.position, distance / 2); } // Shift |
|
8317 |
|
8318 // Animation |
|
8319 var animation = {}; |
|
8320 animation[ref.size] = mode == 'show' ? distance : 0; |
|
8321 animation[ref.position] = mode == 'show' ? 0 : distance / 2; |
|
8322 |
|
8323 // Animate |
|
8324 animate.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() { |
|
8325 if(mode == 'hide') el.hide(); // Hide |
|
8326 $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore |
|
8327 if(o.callback) o.callback.apply(el[0], arguments); // Callback |
|
8328 el.dequeue(); |
|
8329 }}); |
|
8330 |
|
8331 }); |
|
8332 |
|
8333 }; |
|
8334 |
|
8335 })(jQuery); |
|
8336 /* |
|
8337 * jQuery UI Effects Drop 1.6rc6 |
|
8338 * |
|
8339 * Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about) |
|
8340 * Dual licensed under the MIT (MIT-LICENSE.txt) |
|
8341 * and GPL (GPL-LICENSE.txt) licenses. |
|
8342 * |
|
8343 * http://docs.jquery.com/UI/Effects/Drop |
|
8344 * |
|
8345 * Depends: |
|
8346 * effects.core.js |
|
8347 */ |
|
8348 (function($) { |
|
8349 |
|
8350 $.effects.drop = function(o) { |
|
8351 |
|
8352 return this.queue(function() { |
|
8353 |
|
8354 // Create element |
|
8355 var el = $(this), props = ['position','top','left','opacity']; |
|
8356 |
|
8357 // Set options |
|
8358 var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode |
|
8359 var direction = o.options.direction || 'left'; // Default Direction |
|
8360 |
|
8361 // Adjust |
|
8362 $.effects.save(el, props); el.show(); // Save & Show |
|
8363 $.effects.createWrapper(el); // Create Wrapper |
|
8364 var ref = (direction == 'up' || direction == 'down') ? 'top' : 'left'; |
|
8365 var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg'; |
|
8366 var distance = o.options.distance || (ref == 'top' ? el.outerHeight({margin:true}) / 2 : el.outerWidth({margin:true}) / 2); |
|
8367 if (mode == 'show') el.css('opacity', 0).css(ref, motion == 'pos' ? -distance : distance); // Shift |
|
8368 |
|
8369 // Animation |
|
8370 var animation = {opacity: mode == 'show' ? 1 : 0}; |
|
8371 animation[ref] = (mode == 'show' ? (motion == 'pos' ? '+=' : '-=') : (motion == 'pos' ? '-=' : '+=')) + distance; |
|
8372 |
|
8373 // Animate |
|
8374 el.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() { |
|
8375 if(mode == 'hide') el.hide(); // Hide |
|
8376 $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore |
|
8377 if(o.callback) o.callback.apply(this, arguments); // Callback |
|
8378 el.dequeue(); |
|
8379 }}); |
|
8380 |
|
8381 }); |
|
8382 |
|
8383 }; |
|
8384 |
|
8385 })(jQuery); |
|
8386 /* |
|
8387 * jQuery UI Effects Explode 1.6rc6 |
|
8388 * |
|
8389 * Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about) |
|
8390 * Dual licensed under the MIT (MIT-LICENSE.txt) |
|
8391 * and GPL (GPL-LICENSE.txt) licenses. |
|
8392 * |
|
8393 * http://docs.jquery.com/UI/Effects/Explode |
|
8394 * |
|
8395 * Depends: |
|
8396 * effects.core.js |
|
8397 */ |
|
8398 (function($) { |
|
8399 |
|
8400 $.effects.explode = function(o) { |
|
8401 |
|
8402 return this.queue(function() { |
|
8403 |
|
8404 var rows = o.options.pieces ? Math.round(Math.sqrt(o.options.pieces)) : 3; |
|
8405 var cells = o.options.pieces ? Math.round(Math.sqrt(o.options.pieces)) : 3; |
|
8406 |
|
8407 o.options.mode = o.options.mode == 'toggle' ? ($(this).is(':visible') ? 'hide' : 'show') : o.options.mode; |
|
8408 var el = $(this).show().css('visibility', 'hidden'); |
|
8409 var offset = el.offset(); |
|
8410 |
|
8411 //Substract the margins - not fixing the problem yet. |
|
8412 offset.top -= parseInt(el.css("marginTop")) || 0; |
|
8413 offset.left -= parseInt(el.css("marginLeft")) || 0; |
|
8414 |
|
8415 var width = el.outerWidth(true); |
|
8416 var height = el.outerHeight(true); |
|
8417 |
|
8418 for(var i=0;i<rows;i++) { // = |
|
8419 for(var j=0;j<cells;j++) { // || |
|
8420 el |
|
8421 .clone() |
|
8422 .appendTo('body') |
|
8423 .wrap('<div></div>') |
|
8424 .css({ |
|
8425 position: 'absolute', |
|
8426 visibility: 'visible', |
|
8427 left: -j*(width/cells), |
|
8428 top: -i*(height/rows) |
|
8429 }) |
|
8430 .parent() |
|
8431 .addClass('ui-effects-explode') |
|
8432 .css({ |
|
8433 position: 'absolute', |
|
8434 overflow: 'hidden', |
|
8435 width: width/cells, |
|
8436 height: height/rows, |
|
8437 left: offset.left + j*(width/cells) + (o.options.mode == 'show' ? (j-Math.floor(cells/2))*(width/cells) : 0), |
|
8438 top: offset.top + i*(height/rows) + (o.options.mode == 'show' ? (i-Math.floor(rows/2))*(height/rows) : 0), |
|
8439 opacity: o.options.mode == 'show' ? 0 : 1 |
|
8440 }).animate({ |
|
8441 left: offset.left + j*(width/cells) + (o.options.mode == 'show' ? 0 : (j-Math.floor(cells/2))*(width/cells)), |
|
8442 top: offset.top + i*(height/rows) + (o.options.mode == 'show' ? 0 : (i-Math.floor(rows/2))*(height/rows)), |
|
8443 opacity: o.options.mode == 'show' ? 1 : 0 |
|
8444 }, o.duration || 500); |
|
8445 } |
|
8446 } |
|
8447 |
|
8448 // Set a timeout, to call the callback approx. when the other animations have finished |
|
8449 setTimeout(function() { |
|
8450 |
|
8451 o.options.mode == 'show' ? el.css({ visibility: 'visible' }) : el.css({ visibility: 'visible' }).hide(); |
|
8452 if(o.callback) o.callback.apply(el[0]); // Callback |
|
8453 el.dequeue(); |
|
8454 |
|
8455 $('div.ui-effects-explode').remove(); |
|
8456 |
|
8457 }, o.duration || 500); |
|
8458 |
|
8459 |
|
8460 }); |
|
8461 |
|
8462 }; |
|
8463 |
|
8464 })(jQuery); |
|
8465 /* |
|
8466 * jQuery UI Effects Fold 1.6rc6 |
|
8467 * |
|
8468 * Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about) |
|
8469 * Dual licensed under the MIT (MIT-LICENSE.txt) |
|
8470 * and GPL (GPL-LICENSE.txt) licenses. |
|
8471 * |
|
8472 * http://docs.jquery.com/UI/Effects/Fold |
|
8473 * |
|
8474 * Depends: |
|
8475 * effects.core.js |
|
8476 */ |
|
8477 (function($) { |
|
8478 |
|
8479 $.effects.fold = function(o) { |
|
8480 |
|
8481 return this.queue(function() { |
|
8482 |
|
8483 // Create element |
|
8484 var el = $(this), props = ['position','top','left']; |
|
8485 |
|
8486 // Set options |
|
8487 var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode |
|
8488 var size = o.options.size || 15; // Default fold size |
|
8489 var horizFirst = !(!o.options.horizFirst); // Ensure a boolean value |
|
8490 var duration = o.duration ? o.duration / 2 : $.fx.speeds._default / 2; |
|
8491 |
|
8492 // Adjust |
|
8493 $.effects.save(el, props); el.show(); // Save & Show |
|
8494 var wrapper = $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper |
|
8495 var widthFirst = ((mode == 'show') != horizFirst); |
|
8496 var ref = widthFirst ? ['width', 'height'] : ['height', 'width']; |
|
8497 var distance = widthFirst ? [wrapper.width(), wrapper.height()] : [wrapper.height(), wrapper.width()]; |
|
8498 var percent = /([0-9]+)%/.exec(size); |
|
8499 if(percent) size = parseInt(percent[1]) / 100 * distance[mode == 'hide' ? 0 : 1]; |
|
8500 if(mode == 'show') wrapper.css(horizFirst ? {height: 0, width: size} : {height: size, width: 0}); // Shift |
|
8501 |
|
8502 // Animation |
|
8503 var animation1 = {}, animation2 = {}; |
|
8504 animation1[ref[0]] = mode == 'show' ? distance[0] : size; |
|
8505 animation2[ref[1]] = mode == 'show' ? distance[1] : 0; |
|
8506 |
|
8507 // Animate |
|
8508 wrapper.animate(animation1, duration, o.options.easing) |
|
8509 .animate(animation2, duration, o.options.easing, function() { |
|
8510 if(mode == 'hide') el.hide(); // Hide |
|
8511 $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore |
|
8512 if(o.callback) o.callback.apply(el[0], arguments); // Callback |
|
8513 el.dequeue(); |
|
8514 }); |
|
8515 |
|
8516 }); |
|
8517 |
|
8518 }; |
|
8519 |
|
8520 })(jQuery); |
|
8521 /* |
|
8522 * jQuery UI Effects Highlight 1.6rc6 |
|
8523 * |
|
8524 * Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about) |
|
8525 * Dual licensed under the MIT (MIT-LICENSE.txt) |
|
8526 * and GPL (GPL-LICENSE.txt) licenses. |
|
8527 * |
|
8528 * http://docs.jquery.com/UI/Effects/Highlight |
|
8529 * |
|
8530 * Depends: |
|
8531 * effects.core.js |
|
8532 */ |
|
8533 (function($) { |
|
8534 |
|
8535 $.effects.highlight = function(o) { |
|
8536 |
|
8537 return this.queue(function() { |
|
8538 |
|
8539 // Create element |
|
8540 var el = $(this), props = ['backgroundImage','backgroundColor','opacity']; |
|
8541 |
|
8542 // Set options |
|
8543 var mode = $.effects.setMode(el, o.options.mode || 'show'); // Set Mode |
|
8544 var color = o.options.color || "#ffff99"; // Default highlight color |
|
8545 var oldColor = el.css("backgroundColor"); |
|
8546 |
|
8547 // Adjust |
|
8548 $.effects.save(el, props); el.show(); // Save & Show |
|
8549 el.css({backgroundImage: 'none', backgroundColor: color}); // Shift |
|
8550 |
|
8551 // Animation |
|
8552 var animation = {backgroundColor: oldColor }; |
|
8553 if (mode == "hide") animation['opacity'] = 0; |
|
8554 |
|
8555 // Animate |
|
8556 el.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() { |
|
8557 if(mode == "hide") el.hide(); |
|
8558 $.effects.restore(el, props); |
|
8559 if (mode == "show" && $.browser.msie) this.style.removeAttribute('filter'); |
|
8560 if(o.callback) o.callback.apply(this, arguments); |
|
8561 el.dequeue(); |
|
8562 }}); |
|
8563 |
|
8564 }); |
|
8565 |
|
8566 }; |
|
8567 |
|
8568 })(jQuery); |
|
8569 /* |
|
8570 * jQuery UI Effects Pulsate 1.6rc6 |
|
8571 * |
|
8572 * Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about) |
|
8573 * Dual licensed under the MIT (MIT-LICENSE.txt) |
|
8574 * and GPL (GPL-LICENSE.txt) licenses. |
|
8575 * |
|
8576 * http://docs.jquery.com/UI/Effects/Pulsate |
|
8577 * |
|
8578 * Depends: |
|
8579 * effects.core.js |
|
8580 */ |
|
8581 (function($) { |
|
8582 |
|
8583 $.effects.pulsate = function(o) { |
|
8584 |
|
8585 return this.queue(function() { |
|
8586 |
|
8587 // Create element |
|
8588 var el = $(this); |
|
8589 |
|
8590 // Set options |
|
8591 var mode = $.effects.setMode(el, o.options.mode || 'show'); // Set Mode |
|
8592 var times = o.options.times || 5; // Default # of times |
|
8593 var duration = o.duration ? o.duration / 2 : $.fx.speeds._default / 2; |
|
8594 |
|
8595 // Adjust |
|
8596 if (mode == 'hide') times--; |
|
8597 if (el.is(':hidden')) { // Show fadeIn |
|
8598 el.css('opacity', 0); |
|
8599 el.show(); // Show |
|
8600 el.animate({opacity: 1}, duration, o.options.easing); |
|
8601 times = times-2; |
|
8602 } |
|
8603 |
|
8604 // Animate |
|
8605 for (var i = 0; i < times; i++) { // Pulsate |
|
8606 el.animate({opacity: 0}, duration, o.options.easing).animate({opacity: 1}, duration, o.options.easing); |
|
8607 }; |
|
8608 if (mode == 'hide') { // Last Pulse |
|
8609 el.animate({opacity: 0}, duration, o.options.easing, function(){ |
|
8610 el.hide(); // Hide |
|
8611 if(o.callback) o.callback.apply(this, arguments); // Callback |
|
8612 }); |
|
8613 } else { |
|
8614 el.animate({opacity: 0}, duration, o.options.easing).animate({opacity: 1}, duration, o.options.easing, function(){ |
|
8615 if(o.callback) o.callback.apply(this, arguments); // Callback |
|
8616 }); |
|
8617 }; |
|
8618 el.queue('fx', function() { el.dequeue(); }); |
|
8619 el.dequeue(); |
|
8620 }); |
|
8621 |
|
8622 }; |
|
8623 |
|
8624 })(jQuery); |
|
8625 /* |
|
8626 * jQuery UI Effects Scale 1.6rc6 |
|
8627 * |
|
8628 * Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about) |
|
8629 * Dual licensed under the MIT (MIT-LICENSE.txt) |
|
8630 * and GPL (GPL-LICENSE.txt) licenses. |
|
8631 * |
|
8632 * http://docs.jquery.com/UI/Effects/Scale |
|
8633 * |
|
8634 * Depends: |
|
8635 * effects.core.js |
|
8636 */ |
|
8637 (function($) { |
|
8638 |
|
8639 $.effects.puff = function(o) { |
|
8640 |
|
8641 return this.queue(function() { |
|
8642 |
|
8643 // Create element |
|
8644 var el = $(this); |
|
8645 |
|
8646 // Set options |
|
8647 var options = $.extend(true, {}, o.options); |
|
8648 var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode |
|
8649 var percent = parseInt(o.options.percent) || 150; // Set default puff percent |
|
8650 options.fade = true; // It's not a puff if it doesn't fade! :) |
|
8651 var original = {height: el.height(), width: el.width()}; // Save original |
|
8652 |
|
8653 // Adjust |
|
8654 var factor = percent / 100; |
|
8655 el.from = (mode == 'hide') ? original : {height: original.height * factor, width: original.width * factor}; |
|
8656 |
|
8657 // Animation |
|
8658 options.from = el.from; |
|
8659 options.percent = (mode == 'hide') ? percent : 100; |
|
8660 options.mode = mode; |
|
8661 |
|
8662 // Animate |
|
8663 el.effect('scale', options, o.duration, o.callback); |
|
8664 el.dequeue(); |
|
8665 }); |
|
8666 |
|
8667 }; |
|
8668 |
|
8669 $.effects.scale = function(o) { |
|
8670 |
|
8671 return this.queue(function() { |
|
8672 |
|
8673 // Create element |
|
8674 var el = $(this); |
|
8675 |
|
8676 // Set options |
|
8677 var options = $.extend(true, {}, o.options); |
|
8678 var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode |
|
8679 var percent = parseInt(o.options.percent) || (parseInt(o.options.percent) == 0 ? 0 : (mode == 'hide' ? 0 : 100)); // Set default scaling percent |
|
8680 var direction = o.options.direction || 'both'; // Set default axis |
|
8681 var origin = o.options.origin; // The origin of the scaling |
|
8682 if (mode != 'effect') { // Set default origin and restore for show/hide |
|
8683 options.origin = origin || ['middle','center']; |
|
8684 options.restore = true; |
|
8685 } |
|
8686 var original = {height: el.height(), width: el.width()}; // Save original |
|
8687 el.from = o.options.from || (mode == 'show' ? {height: 0, width: 0} : original); // Default from state |
|
8688 |
|
8689 // Adjust |
|
8690 var factor = { // Set scaling factor |
|
8691 y: direction != 'horizontal' ? (percent / 100) : 1, |
|
8692 x: direction != 'vertical' ? (percent / 100) : 1 |
|
8693 }; |
|
8694 el.to = {height: original.height * factor.y, width: original.width * factor.x}; // Set to state |
|
8695 |
|
8696 if (o.options.fade) { // Fade option to support puff |
|
8697 if (mode == 'show') {el.from.opacity = 0; el.to.opacity = 1;}; |
|
8698 if (mode == 'hide') {el.from.opacity = 1; el.to.opacity = 0;}; |
|
8699 }; |
|
8700 |
|
8701 // Animation |
|
8702 options.from = el.from; options.to = el.to; options.mode = mode; |
|
8703 |
|
8704 // Animate |
|
8705 el.effect('size', options, o.duration, o.callback); |
|
8706 el.dequeue(); |
|
8707 }); |
|
8708 |
|
8709 }; |
|
8710 |
|
8711 $.effects.size = function(o) { |
|
8712 |
|
8713 return this.queue(function() { |
|
8714 |
|
8715 // Create element |
|
8716 var el = $(this), props = ['position','top','left','width','height','overflow','opacity']; |
|
8717 var props1 = ['position','top','left','overflow','opacity']; // Always restore |
|
8718 var props2 = ['width','height','overflow']; // Copy for children |
|
8719 var cProps = ['fontSize']; |
|
8720 var vProps = ['borderTopWidth', 'borderBottomWidth', 'paddingTop', 'paddingBottom']; |
|
8721 var hProps = ['borderLeftWidth', 'borderRightWidth', 'paddingLeft', 'paddingRight']; |
|
8722 |
|
8723 // Set options |
|
8724 var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode |
|
8725 var restore = o.options.restore || false; // Default restore |
|
8726 var scale = o.options.scale || 'both'; // Default scale mode |
|
8727 var origin = o.options.origin; // The origin of the sizing |
|
8728 var original = {height: el.height(), width: el.width()}; // Save original |
|
8729 el.from = o.options.from || original; // Default from state |
|
8730 el.to = o.options.to || original; // Default to state |
|
8731 // Adjust |
|
8732 if (origin) { // Calculate baseline shifts |
|
8733 var baseline = $.effects.getBaseline(origin, original); |
|
8734 el.from.top = (original.height - el.from.height) * baseline.y; |
|
8735 el.from.left = (original.width - el.from.width) * baseline.x; |
|
8736 el.to.top = (original.height - el.to.height) * baseline.y; |
|
8737 el.to.left = (original.width - el.to.width) * baseline.x; |
|
8738 }; |
|
8739 var factor = { // Set scaling factor |
|
8740 from: {y: el.from.height / original.height, x: el.from.width / original.width}, |
|
8741 to: {y: el.to.height / original.height, x: el.to.width / original.width} |
|
8742 }; |
|
8743 if (scale == 'box' || scale == 'both') { // Scale the css box |
|
8744 if (factor.from.y != factor.to.y) { // Vertical props scaling |
|
8745 props = props.concat(vProps); |
|
8746 el.from = $.effects.setTransition(el, vProps, factor.from.y, el.from); |
|
8747 el.to = $.effects.setTransition(el, vProps, factor.to.y, el.to); |
|
8748 }; |
|
8749 if (factor.from.x != factor.to.x) { // Horizontal props scaling |
|
8750 props = props.concat(hProps); |
|
8751 el.from = $.effects.setTransition(el, hProps, factor.from.x, el.from); |
|
8752 el.to = $.effects.setTransition(el, hProps, factor.to.x, el.to); |
|
8753 }; |
|
8754 }; |
|
8755 if (scale == 'content' || scale == 'both') { // Scale the content |
|
8756 if (factor.from.y != factor.to.y) { // Vertical props scaling |
|
8757 props = props.concat(cProps); |
|
8758 el.from = $.effects.setTransition(el, cProps, factor.from.y, el.from); |
|
8759 el.to = $.effects.setTransition(el, cProps, factor.to.y, el.to); |
|
8760 }; |
|
8761 }; |
|
8762 $.effects.save(el, restore ? props : props1); el.show(); // Save & Show |
|
8763 $.effects.createWrapper(el); // Create Wrapper |
|
8764 el.css('overflow','hidden').css(el.from); // Shift |
|
8765 |
|
8766 // Animate |
|
8767 if (scale == 'content' || scale == 'both') { // Scale the children |
|
8768 vProps = vProps.concat(['marginTop','marginBottom']).concat(cProps); // Add margins/font-size |
|
8769 hProps = hProps.concat(['marginLeft','marginRight']); // Add margins |
|
8770 props2 = props.concat(vProps).concat(hProps); // Concat |
|
8771 el.find("*[width]").each(function(){ |
|
8772 child = $(this); |
|
8773 if (restore) $.effects.save(child, props2); |
|
8774 var c_original = {height: child.height(), width: child.width()}; // Save original |
|
8775 child.from = {height: c_original.height * factor.from.y, width: c_original.width * factor.from.x}; |
|
8776 child.to = {height: c_original.height * factor.to.y, width: c_original.width * factor.to.x}; |
|
8777 if (factor.from.y != factor.to.y) { // Vertical props scaling |
|
8778 child.from = $.effects.setTransition(child, vProps, factor.from.y, child.from); |
|
8779 child.to = $.effects.setTransition(child, vProps, factor.to.y, child.to); |
|
8780 }; |
|
8781 if (factor.from.x != factor.to.x) { // Horizontal props scaling |
|
8782 child.from = $.effects.setTransition(child, hProps, factor.from.x, child.from); |
|
8783 child.to = $.effects.setTransition(child, hProps, factor.to.x, child.to); |
|
8784 }; |
|
8785 child.css(child.from); // Shift children |
|
8786 child.animate(child.to, o.duration, o.options.easing, function(){ |
|
8787 if (restore) $.effects.restore(child, props2); // Restore children |
|
8788 }); // Animate children |
|
8789 }); |
|
8790 }; |
|
8791 |
|
8792 // Animate |
|
8793 el.animate(el.to, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() { |
|
8794 if(mode == 'hide') el.hide(); // Hide |
|
8795 $.effects.restore(el, restore ? props : props1); $.effects.removeWrapper(el); // Restore |
|
8796 if(o.callback) o.callback.apply(this, arguments); // Callback |
|
8797 el.dequeue(); |
|
8798 }}); |
|
8799 |
|
8800 }); |
|
8801 |
|
8802 }; |
|
8803 |
|
8804 })(jQuery); |
|
8805 /* |
|
8806 * jQuery UI Effects Shake 1.6rc6 |
|
8807 * |
|
8808 * Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about) |
|
8809 * Dual licensed under the MIT (MIT-LICENSE.txt) |
|
8810 * and GPL (GPL-LICENSE.txt) licenses. |
|
8811 * |
|
8812 * http://docs.jquery.com/UI/Effects/Shake |
|
8813 * |
|
8814 * Depends: |
|
8815 * effects.core.js |
|
8816 */ |
|
8817 (function($) { |
|
8818 |
|
8819 $.effects.shake = function(o) { |
|
8820 |
|
8821 return this.queue(function() { |
|
8822 |
|
8823 // Create element |
|
8824 var el = $(this), props = ['position','top','left']; |
|
8825 |
|
8826 // Set options |
|
8827 var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode |
|
8828 var direction = o.options.direction || 'left'; // Default direction |
|
8829 var distance = o.options.distance || 20; // Default distance |
|
8830 var times = o.options.times || 3; // Default # of times |
|
8831 var speed = o.duration || o.options.duration || 140; // Default speed per shake |
|
8832 |
|
8833 // Adjust |
|
8834 $.effects.save(el, props); el.show(); // Save & Show |
|
8835 $.effects.createWrapper(el); // Create Wrapper |
|
8836 var ref = (direction == 'up' || direction == 'down') ? 'top' : 'left'; |
|
8837 var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg'; |
|
8838 |
|
8839 // Animation |
|
8840 var animation = {}, animation1 = {}, animation2 = {}; |
|
8841 animation[ref] = (motion == 'pos' ? '-=' : '+=') + distance; |
|
8842 animation1[ref] = (motion == 'pos' ? '+=' : '-=') + distance * 2; |
|
8843 animation2[ref] = (motion == 'pos' ? '-=' : '+=') + distance * 2; |
|
8844 |
|
8845 // Animate |
|
8846 el.animate(animation, speed, o.options.easing); |
|
8847 for (var i = 1; i < times; i++) { // Shakes |
|
8848 el.animate(animation1, speed, o.options.easing).animate(animation2, speed, o.options.easing); |
|
8849 }; |
|
8850 el.animate(animation1, speed, o.options.easing). |
|
8851 animate(animation, speed / 2, o.options.easing, function(){ // Last shake |
|
8852 $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore |
|
8853 if(o.callback) o.callback.apply(this, arguments); // Callback |
|
8854 }); |
|
8855 el.queue('fx', function() { el.dequeue(); }); |
|
8856 el.dequeue(); |
|
8857 }); |
|
8858 |
|
8859 }; |
|
8860 |
|
8861 })(jQuery); |
|
8862 /* |
|
8863 * jQuery UI Effects Slide 1.6rc6 |
|
8864 * |
|
8865 * Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about) |
|
8866 * Dual licensed under the MIT (MIT-LICENSE.txt) |
|
8867 * and GPL (GPL-LICENSE.txt) licenses. |
|
8868 * |
|
8869 * http://docs.jquery.com/UI/Effects/Slide |
|
8870 * |
|
8871 * Depends: |
|
8872 * effects.core.js |
|
8873 */ |
|
8874 (function($) { |
|
8875 |
|
8876 $.effects.slide = function(o) { |
|
8877 |
|
8878 return this.queue(function() { |
|
8879 |
|
8880 // Create element |
|
8881 var el = $(this), props = ['position','top','left']; |
|
8882 |
|
8883 // Set options |
|
8884 var mode = $.effects.setMode(el, o.options.mode || 'show'); // Set Mode |
|
8885 var direction = o.options.direction || 'left'; // Default Direction |
|
8886 |
|
8887 // Adjust |
|
8888 $.effects.save(el, props); el.show(); // Save & Show |
|
8889 $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper |
|
8890 var ref = (direction == 'up' || direction == 'down') ? 'top' : 'left'; |
|
8891 var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg'; |
|
8892 var distance = o.options.distance || (ref == 'top' ? el.outerHeight({margin:true}) : el.outerWidth({margin:true})); |
|
8893 if (mode == 'show') el.css(ref, motion == 'pos' ? -distance : distance); // Shift |
|
8894 |
|
8895 // Animation |
|
8896 var animation = {}; |
|
8897 animation[ref] = (mode == 'show' ? (motion == 'pos' ? '+=' : '-=') : (motion == 'pos' ? '-=' : '+=')) + distance; |
|
8898 |
|
8899 // Animate |
|
8900 el.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() { |
|
8901 if(mode == 'hide') el.hide(); // Hide |
|
8902 $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore |
|
8903 if(o.callback) o.callback.apply(this, arguments); // Callback |
|
8904 el.dequeue(); |
|
8905 }}); |
|
8906 |
|
8907 }); |
|
8908 |
|
8909 }; |
|
8910 |
|
8911 })(jQuery); |
|
8912 /* |
|
8913 * jQuery UI Effects Transfer 1.6rc6 |
|
8914 * |
|
8915 * Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about) |
|
8916 * Dual licensed under the MIT (MIT-LICENSE.txt) |
|
8917 * and GPL (GPL-LICENSE.txt) licenses. |
|
8918 * |
|
8919 * http://docs.jquery.com/UI/Effects/Transfer |
|
8920 * |
|
8921 * Depends: |
|
8922 * effects.core.js |
|
8923 */ |
|
8924 (function($) { |
|
8925 |
|
8926 $.effects.transfer = function(o) { |
|
8927 |
|
8928 return this.queue(function() { |
|
8929 |
|
8930 // Create element |
|
8931 var el = $(this); |
|
8932 |
|
8933 // Set options |
|
8934 var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode |
|
8935 var target = $(o.options.to); // Find Target |
|
8936 var position = el.offset(); |
|
8937 var transfer = $('<div class="ui-effects-transfer"></div>').appendTo(document.body); |
|
8938 if(o.options.className) transfer.addClass(o.options.className); |
|
8939 |
|
8940 // Set target css |
|
8941 transfer.addClass(o.options.className); |
|
8942 transfer.css({ |
|
8943 top: position.top, |
|
8944 left: position.left, |
|
8945 height: el.outerHeight() - parseInt(transfer.css('borderTopWidth')) - parseInt(transfer.css('borderBottomWidth')), |
|
8946 width: el.outerWidth() - parseInt(transfer.css('borderLeftWidth')) - parseInt(transfer.css('borderRightWidth')), |
|
8947 position: 'absolute' |
|
8948 }); |
|
8949 |
|
8950 // Animation |
|
8951 position = target.offset(); |
|
8952 animation = { |
|
8953 top: position.top, |
|
8954 left: position.left, |
|
8955 height: target.outerHeight() - parseInt(transfer.css('borderTopWidth')) - parseInt(transfer.css('borderBottomWidth')), |
|
8956 width: target.outerWidth() - parseInt(transfer.css('borderLeftWidth')) - parseInt(transfer.css('borderRightWidth')) |
|
8957 }; |
|
8958 |
|
8959 // Animate |
|
8960 transfer.animate(animation, o.duration, o.options.easing, function() { |
|
8961 transfer.remove(); // Remove div |
|
8962 if(o.callback) o.callback.apply(el[0], arguments); // Callback |
|
8963 el.dequeue(); |
|
8964 }); |
|
8965 |
|
8966 }); |
|
8967 |
|
8968 }; |
|
8969 |
|
8970 })(jQuery); |