4
* Copyright (c) 2008 Paul Bakaus (ui.jquery.com)
5
* Dual licensed under the MIT (MIT-LICENSE.txt)
6
* and GPL (GPL-LICENSE.txt) licenses.
8
* http://docs.jquery.com/UI
12
/** jQuery core modifications and additions **/
14
var _remove = $.fn.remove;
15
$.fn.remove = function() {
16
$("*", this).add(this).triggerHandler("remove");
17
return _remove.apply(this, arguments );
20
function isVisible(element) {
21
function checkStyles(element) {
22
var style = element.style;
23
return (style.display != 'none' && style.visibility != 'hidden');
26
var visible = checkStyles(element);
28
(visible && $.each($.dir(element, 'parentNode'), function() {
29
return (visible = checkStyles(this));
35
$.extend($.expr[':'], {
36
data: function(a, i, m) {
37
return $.data(a, m[3]);
40
// TODO: add support for object, area
41
tabbable: function(a, i, m) {
42
var nodeName = a.nodeName.toLowerCase();
48
( // filter node types that participate in the tab order
51
('a' == nodeName && a.href) ||
53
// enabled form element
54
(/input|select|textarea|button/.test(nodeName) &&
55
'hidden' != a.type && !a.disabled)
93
// $.widget is a factory to create jQuery plugins
94
// taking some boilerplate code out of the plugin code
95
// created by Scott González and Jörn Zaefferer
96
function getter(namespace, plugin, method, args) {
97
function getMethods(type) {
98
var methods = $[namespace][plugin][type] || [];
99
return (typeof methods == 'string' ? methods.split(/,?\s+/) : methods);
102
var methods = getMethods('getter');
103
if (args.length == 1 && typeof args[0] == 'string') {
104
methods = methods.concat(getMethods('getterSetter'));
106
return ($.inArray(method, methods) != -1);
109
$.widget = function(name, prototype) {
110
var namespace = name.split(".")[0];
111
name = name.split(".")[1];
113
// create plugin method
114
$.fn[name] = function(options) {
115
var isMethodCall = (typeof options == 'string'),
116
args = Array.prototype.slice.call(arguments, 1);
118
// prevent calls to internal methods
119
if (isMethodCall && options.substring(0, 1) == '_') {
123
// handle getter methods
124
if (isMethodCall && getter(namespace, name, options, args)) {
125
var instance = $.data(this[0], name);
126
return (instance ? instance[options].apply(instance, args)
130
// handle initialization and non-getter methods
131
return this.each(function() {
132
var instance = $.data(this, name);
135
(!instance && !isMethodCall &&
136
$.data(this, name, new $[namespace][name](this, options)));
139
(instance && isMethodCall && $.isFunction(instance[options]) &&
140
instance[options].apply(instance, args));
144
// create widget constructor
145
$[namespace][name] = function(element, options) {
148
this.widgetName = name;
149
this.widgetEventPrefix = $[namespace][name].eventPrefix || name;
150
this.widgetBaseClass = namespace + '-' + name;
152
this.options = $.extend({},
154
$[namespace][name].defaults,
155
$.metadata && $.metadata.get(element)[name],
158
this.element = $(element)
159
.bind('setData.' + name, function(e, key, value) {
160
return self._setData(key, value);
162
.bind('getData.' + name, function(e, key) {
163
return self._getData(key);
165
.bind('remove', function() {
166
return self.destroy();
172
// add widget prototype
173
$[namespace][name].prototype = $.extend({}, $.widget.prototype, prototype);
175
// TODO: merge getter and getterSetter properties from widget prototype
176
// and plugin prototype
177
$[namespace][name].getterSetter = 'option';
180
$.widget.prototype = {
181
_init: function() {},
182
destroy: function() {
183
this.element.removeData(this.widgetName);
186
option: function(key, value) {
190
if (typeof key == "string") {
191
if (value === undefined) {
192
return this._getData(key);
195
options[key] = value;
198
$.each(options, function(key, value) {
199
self._setData(key, value);
202
_getData: function(key) {
203
return this.options[key];
205
_setData: function(key, value) {
206
this.options[key] = value;
208
if (key == 'disabled') {
209
this.element[value ? 'addClass' : 'removeClass'](
210
this.widgetBaseClass + '-disabled');
215
this._setData('disabled', false);
217
disable: function() {
218
this._setData('disabled', true);
221
_trigger: function(type, e, data) {
222
var eventName = (type == this.widgetEventPrefix
223
? type : this.widgetEventPrefix + type);
224
e = e || $.event.fix({ type: eventName, target: this.element[0] });
225
return this.element.triggerHandler(eventName, [e, data], this.options[type]);
229
$.widget.defaults = {
234
/** jQuery UI core **/
238
add: function(module, option, set) {
239
var proto = $.ui[module].prototype;
241
proto.plugins[i] = proto.plugins[i] || [];
242
proto.plugins[i].push([option, set[i]]);
245
call: function(instance, name, args) {
246
var set = instance.plugins[name];
249
for (var i = 0; i < set.length; i++) {
250
if (instance.options[set[i][0]]) {
251
set[i][1].apply(instance.element, args);
257
css: function(name) {
258
if ($.ui.cssCache[name]) { return $.ui.cssCache[name]; }
259
var tmp = $('<div class="ui-gen">').addClass(name).css({position:'absolute', top:'-5000px', left:'-5000px', display:'block'}).appendTo('body');
261
//if (!$.browser.safari)
262
//tmp.appendTo('body');
264
//Opera and Safari set width and height to 0px instead of auto
265
//Safari returns rgba(0,0,0,0) when bgcolor is not set
266
$.ui.cssCache[name] = !!(
267
(!(/auto|default/).test(tmp.css('cursor')) || (/^[1-9]/).test(tmp.css('height')) || (/^[1-9]/).test(tmp.css('width')) ||
268
!(/none/).test(tmp.css('backgroundImage')) || !(/transparent|rgba\(0, 0, 0, 0\)/).test(tmp.css('backgroundColor')))
270
try { $('body').get(0).removeChild(tmp.get(0)); } catch(e){}
271
return $.ui.cssCache[name];
273
disableSelection: function(el) {
275
.attr('unselectable', 'on')
276
.css('MozUserSelect', 'none')
277
.bind('selectstart.ui', function() { return false; });
279
enableSelection: function(el) {
281
.attr('unselectable', 'off')
282
.css('MozUserSelect', '')
283
.unbind('selectstart.ui');
285
hasScroll: function(e, a) {
287
//If overflow is hidden, the element might have extra content, but the user wants to hide it
288
if ($(e).css('overflow') == 'hidden') { return false; }
290
var scroll = (a && a == 'left') ? 'scrollLeft' : 'scrollTop',
293
if (e[scroll] > 0) { return true; }
295
// TODO: determine which cases actually cause this to happen
296
// if the element doesn't have the scroll set, see if it's possible to
299
has = (e[scroll] > 0);
306
/** Mouse Interaction Plugin **/
309
_mouseInit: function() {
312
this.element.bind('mousedown.'+this.widgetName, function(e) {
313
return self._mouseDown(e);
316
// Prevent text selection in IE
317
if ($.browser.msie) {
318
this._mouseUnselectable = this.element.attr('unselectable');
319
this.element.attr('unselectable', 'on');
322
this.started = false;
325
// TODO: make sure destroying one instance of mouse doesn't mess with
326
// other instances of mouse
327
_mouseDestroy: function() {
328
this.element.unbind('.'+this.widgetName);
330
// Restore text selection in IE
332
&& this.element.attr('unselectable', this._mouseUnselectable));
335
_mouseDown: function(e) {
336
// we may have missed mouseup (out of window)
337
(this._mouseStarted && this._mouseUp(e));
339
this._mouseDownEvent = e;
342
btnIsLeft = (e.which == 1),
343
elIsCancel = (typeof this.options.cancel == "string" ? $(e.target).parents().add(e.target).filter(this.options.cancel).length : false);
344
if (!btnIsLeft || elIsCancel || !this._mouseCapture(e)) {
348
this.mouseDelayMet = !this.options.delay;
349
if (!this.mouseDelayMet) {
350
this._mouseDelayTimer = setTimeout(function() {
351
self.mouseDelayMet = true;
352
}, this.options.delay);
355
if (this._mouseDistanceMet(e) && this._mouseDelayMet(e)) {
356
this._mouseStarted = (this._mouseStart(e) !== false);
357
if (!this._mouseStarted) {
363
// these delegates are required to keep context
364
this._mouseMoveDelegate = function(e) {
365
return self._mouseMove(e);
367
this._mouseUpDelegate = function(e) {
368
return self._mouseUp(e);
371
.bind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
372
.bind('mouseup.'+this.widgetName, this._mouseUpDelegate);
377
_mouseMove: function(e) {
378
// IE mouseup check - mouseup happened when mouse was out of window
379
if ($.browser.msie && !e.button) {
380
return this._mouseUp(e);
383
if (this._mouseStarted) {
388
if (this._mouseDistanceMet(e) && this._mouseDelayMet(e)) {
390
(this._mouseStart(this._mouseDownEvent, e) !== false);
391
(this._mouseStarted ? this._mouseDrag(e) : this._mouseUp(e));
394
return !this._mouseStarted;
397
_mouseUp: function(e) {
399
.unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
400
.unbind('mouseup.'+this.widgetName, this._mouseUpDelegate);
402
if (this._mouseStarted) {
403
this._mouseStarted = false;
410
_mouseDistanceMet: function(e) {
412
Math.abs(this._mouseDownEvent.pageX - e.pageX),
413
Math.abs(this._mouseDownEvent.pageY - e.pageY)
414
) >= this.options.distance
418
_mouseDelayMet: function(e) {
419
return this.mouseDelayMet;
422
// These are placeholder methods, to be overriden by extending plugin
423
_mouseStart: function(e) {},
424
_mouseDrag: function(e) {},
425
_mouseStop: function(e) {},
426
_mouseCapture: function(e) { return true; }
429
$.ui.mouse.defaults = {
437
* jQuery UI Draggable @VERSION
439
* Copyright (c) 2008 Paul Bakaus
440
* Dual licensed under the MIT (MIT-LICENSE.txt)
441
* and GPL (GPL-LICENSE.txt) licenses.
443
* http://docs.jquery.com/UI/Draggables
450
$.widget("ui.draggable", $.extend({}, $.ui.mouse, {
452
getHandle: function(e) {
454
var handle = !this.options.handle || !$(this.options.handle, this.element).length ? true : false;
455
$(this.options.handle, this.element)
459
if(this == e.target) handle = true;
466
createHelper: function() {
468
var o = this.options;
469
var helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [e])) : (o.helper == 'clone' ? this.element.clone() : this.element);
471
if(!helper.parents('body').length)
472
helper.appendTo((o.appendTo == 'parent' ? this.element[0].parentNode : o.appendTo));
474
if(helper[0] != this.element[0] && !(/(fixed|absolute)/).test(helper.css("position")))
475
helper.css("position", "absolute");
484
if (this.options.helper == 'original' && !(/^(?:r|a|f)/).test(this.element.css("position")))
485
this.element[0].style.position = 'relative';
487
(this.options.cssNamespace && this.element.addClass(this.options.cssNamespace+"-draggable"));
488
(this.options.disabled && this.element.addClass('ui-draggable-disabled'));
494
_mouseCapture: function(e) {
496
var o = this.options;
498
if (this.helper || o.disabled || $(e.target).is('.ui-resizable-handle'))
501
//Quit if we're not on a valid handle
502
this.handle = this.getHandle(e);
510
_mouseStart: function(e) {
512
var o = this.options;
514
//Create and append the visible helper
515
this.helper = this.createHelper();
517
//If ddmanager is used for droppables, set the global draggable
519
$.ui.ddmanager.current = this;
522
* - Position generation -
523
* This block generates everything position related - it's the core of draggables.
526
this.margins = { //Cache the margins
527
left: (parseInt(this.element.css("marginLeft"),10) || 0),
528
top: (parseInt(this.element.css("marginTop"),10) || 0)
531
this.cssPosition = this.helper.css("position"); //Store the helper's css position
532
this.offset = this.element.offset(); //The element's absolute position on the page
533
this.offset = { //Substract the margins from the element's absolute offset
534
top: this.offset.top - this.margins.top,
535
left: this.offset.left - this.margins.left
538
this.offset.click = { //Where the click happened, relative to the element
539
left: e.pageX - this.offset.left,
540
top: e.pageY - this.offset.top
543
//Calling this method cached the next parents that have scrollTop / scrollLeft attached
544
this.cacheScrollParents();
547
this.offsetParent = this.helper.offsetParent(); var po = this.offsetParent.offset(); //Get the offsetParent and cache its position
548
if(this.offsetParent[0] == document.body && $.browser.mozilla) po = { top: 0, left: 0 }; //Ugly FF3 fix
549
this.offset.parent = { //Store its position plus border
550
top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
551
left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
554
//This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
555
if(this.cssPosition == "relative") {
556
var p = this.element.position();
557
this.offset.relative = {
558
top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollTopParent.scrollTop(),
559
left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollLeftParent.scrollLeft()
562
this.offset.relative = { top: 0, left: 0 };
565
//Generate the original position
566
this.originalPosition = this._generatePosition(e);
568
//Cache the helper size
569
this.cacheHelperProportions();
571
//Adjust the mouse offset relative to the helper if 'cursorAt' is supplied
573
this.adjustOffsetFromHelper(o.cursorAt);
575
//Cache later used stuff
577
PAGEY_INCLUDES_SCROLL: (this.cssPosition == "absolute" && (!this.scrollTopParent[0].tagName || (/(html|body)/i).test(this.scrollTopParent[0].tagName))),
578
PAGEX_INCLUDES_SCROLL: (this.cssPosition == "absolute" && (!this.scrollLeftParent[0].tagName || (/(html|body)/i).test(this.scrollLeftParent[0].tagName))),
579
OFFSET_PARENT_NOT_SCROLL_PARENT_Y: this.scrollTopParent[0] != this.offsetParent[0] && !(this.scrollTopParent[0] == document && (/(body|html)/i).test(this.offsetParent[0].tagName)),
580
OFFSET_PARENT_NOT_SCROLL_PARENT_X: this.scrollLeftParent[0] != this.offsetParent[0] && !(this.scrollLeftParent[0] == document && (/(body|html)/i).test(this.offsetParent[0].tagName))
584
this.setContainment();
587
//Call plugins and callbacks
588
this._propagate("start", e);
590
//Recache the helper size
591
this.cacheHelperProportions();
593
//Prepare the droppable offsets
594
if ($.ui.ddmanager && !o.dropBehaviour)
595
$.ui.ddmanager.prepareOffsets(this, e);
597
this.helper.addClass("ui-draggable-dragging");
598
this._mouseDrag(e); //Execute the drag once - this causes the helper not to be visible before getting its correct position
602
cacheScrollParents: function() {
604
this.scrollTopParent = function(el) {
605
do { if(/auto|scroll/.test(el.css('overflow')) || (/auto|scroll/).test(el.css('overflow-y'))) return el; el = el.parent(); } while (el[0].parentNode);
608
this.scrollLeftParent = function(el) {
609
do { if(/auto|scroll/.test(el.css('overflow')) || (/auto|scroll/).test(el.css('overflow-x'))) return el; el = el.parent(); } while (el[0].parentNode);
615
adjustOffsetFromHelper: function(obj) {
616
if(obj.left != undefined) this.offset.click.left = obj.left + this.margins.left;
617
if(obj.right != undefined) this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
618
if(obj.top != undefined) this.offset.click.top = obj.top + this.margins.top;
619
if(obj.bottom != undefined) this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
622
cacheHelperProportions: function() {
623
this.helperProportions = {
624
width: this.helper.outerWidth(),
625
height: this.helper.outerHeight()
629
setContainment: function() {
631
var o = this.options;
632
if(o.containment == 'parent') o.containment = this.helper[0].parentNode;
633
if(o.containment == 'document' || o.containment == 'window') this.containment = [
634
0 - this.offset.relative.left - this.offset.parent.left,
635
0 - this.offset.relative.top - this.offset.parent.top,
636
$(o.containment == 'document' ? document : window).width() - this.offset.relative.left - this.offset.parent.left - this.helperProportions.width - this.margins.left - (parseInt(this.element.css("marginRight"),10) || 0),
637
($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.offset.relative.top - this.offset.parent.top - this.helperProportions.height - this.margins.top - (parseInt(this.element.css("marginBottom"),10) || 0)
640
if(!(/^(document|window|parent)$/).test(o.containment)) {
641
var ce = $(o.containment)[0];
642
var co = $(o.containment).offset();
643
var over = ($(ce).css("overflow") != 'hidden');
646
co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) - this.offset.relative.left - this.offset.parent.left,
647
co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) - this.offset.relative.top - this.offset.parent.top,
648
co.left+(over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - this.offset.relative.left - this.offset.parent.left - this.helperProportions.width - this.margins.left - (parseInt(this.element.css("marginRight"),10) || 0),
649
co.top+(over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - this.offset.relative.top - this.offset.parent.top - this.helperProportions.height - this.margins.top - (parseInt(this.element.css("marginBottom"),10) || 0)
656
_convertPositionTo: function(d, pos) {
658
if(!pos) pos = this.position;
659
var mod = d == "absolute" ? 1 : -1;
663
pos.top // the calculated relative position
664
+ this.offset.relative.top * mod // Only for relative positioned nodes: Relative offset from element to offset parent
665
+ this.offset.parent.top * mod // The offsetParent's offset without borders (offset + border)
666
- (this.cssPosition == "fixed" || this.PAGEY_INCLUDES_SCROLL || this.OFFSET_PARENT_NOT_SCROLL_PARENT_Y ? 0 : this.scrollTopParent.scrollTop()) * mod // The offsetParent's scroll position, not if the element is fixed
667
+ (this.cssPosition == "fixed" ? $(document).scrollTop() : 0) * mod
668
+ this.margins.top * mod //Add the margin (you don't want the margin counting in intersection methods)
671
pos.left // the calculated relative position
672
+ this.offset.relative.left * mod // Only for relative positioned nodes: Relative offset from element to offset parent
673
+ this.offset.parent.left * mod // The offsetParent's offset without borders (offset + border)
674
- (this.cssPosition == "fixed" || this.PAGEX_INCLUDES_SCROLL || this.OFFSET_PARENT_NOT_SCROLL_PARENT_X ? 0 : this.scrollLeftParent.scrollLeft()) * mod // The offsetParent's scroll position, not if the element is fixed
675
+ (this.cssPosition == "fixed" ? $(document).scrollLeft() : 0) * mod
676
+ this.margins.left * mod //Add the margin (you don't want the margin counting in intersection methods)
680
_generatePosition: function(e) {
682
var o = this.options;
685
e.pageY // The absolute mouse position
686
- this.offset.click.top // Click offset (relative to the element)
687
- this.offset.relative.top // Only for relative positioned nodes: Relative offset from element to offset parent
688
- this.offset.parent.top // The offsetParent's offset without borders (offset + border)
689
+ (this.cssPosition == "fixed" || this.PAGEY_INCLUDES_SCROLL || this.OFFSET_PARENT_NOT_SCROLL_PARENT_Y ? 0 : this.scrollTopParent.scrollTop()) // The offsetParent's scroll position, not if the element is fixed
690
- (this.cssPosition == "fixed" ? $(document).scrollTop() : 0)
693
e.pageX // The absolute mouse position
694
- this.offset.click.left // Click offset (relative to the element)
695
- this.offset.relative.left // Only for relative positioned nodes: Relative offset from element to offset parent
696
- this.offset.parent.left // The offsetParent's offset without borders (offset + border)
697
+ (this.cssPosition == "fixed" || this.PAGEX_INCLUDES_SCROLL || this.OFFSET_PARENT_NOT_SCROLL_PARENT_X ? 0 : this.scrollLeftParent.scrollLeft()) // The offsetParent's scroll position, not if the element is fixed
698
- (this.cssPosition == "fixed" ? $(document).scrollLeft() : 0)
702
if(!this.originalPosition) return position; //If we are not dragging yet, we won't check for options
705
* - Position constraining -
706
* Constrain the position to a mix of grid, containment.
708
if(this.containment) {
709
if(position.left < this.containment[0]) position.left = this.containment[0];
710
if(position.top < this.containment[1]) position.top = this.containment[1];
711
if(position.left > this.containment[2]) position.left = this.containment[2];
712
if(position.top > this.containment[3]) position.top = this.containment[3];
716
var top = this.originalPosition.top + Math.round((position.top - this.originalPosition.top) / o.grid[1]) * o.grid[1];
717
position.top = this.containment ? (!(top < this.containment[1] || top > this.containment[3]) ? top : (!(top < this.containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
719
var left = this.originalPosition.left + Math.round((position.left - this.originalPosition.left) / o.grid[0]) * o.grid[0];
720
position.left = this.containment ? (!(left < this.containment[0] || left > this.containment[2]) ? left : (!(left < this.containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
725
_mouseDrag: function(e) {
727
//Compute the helpers position
728
this.position = this._generatePosition(e);
729
this.positionAbs = this._convertPositionTo("absolute");
731
//Call plugins and callbacks and use the resulting position if something is returned
732
this.position = this._propagate("drag", e) || this.position;
734
if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px';
735
if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px';
736
if($.ui.ddmanager) $.ui.ddmanager.drag(this, e);
740
_mouseStop: function(e) {
742
//If we are using droppables, inform the manager about the drop
744
if ($.ui.ddmanager && !this.options.dropBehaviour)
745
var dropped = $.ui.ddmanager.drop(this, e);
747
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))) {
749
$(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10) || 500, function() {
750
self._propagate("stop", e);
754
this._propagate("stop", e);
761
this.helper.removeClass("ui-draggable-dragging");
762
if(this.options.helper != 'original' && !this.cancelHelperRemoval) this.helper.remove();
763
//if($.ui.ddmanager) $.ui.ddmanager.current = null;
765
this.cancelHelperRemoval = false;
768
// From now on bulk stuff - mainly helpers
770
uiHash: function(e) {
773
position: this.position,
774
absolutePosition: this.positionAbs,
775
options: this.options
778
_propagate: function(n,e) {
779
$.ui.plugin.call(this, n, [e, this.uiHash()]);
780
if(n == "drag") this.positionAbs = this._convertPositionTo("absolute"); //The absolute position has to be recalculated after plugins
781
return this.element.triggerHandler(n == "drag" ? n : "drag"+n, [e, this.uiHash()], this.options[n]);
783
destroy: function() {
784
if(!this.element.data('draggable')) return;
785
this.element.removeData("draggable").unbind(".draggable").removeClass('ui-draggable ui-draggable-dragging ui-draggable-disabled');
786
this._mouseDestroy();
790
$.extend($.ui.draggable, {
803
$.ui.plugin.add("draggable", "cursor", {
804
start: function(e, ui) {
806
if (t.css("cursor")) ui.options._cursor = t.css("cursor");
807
t.css("cursor", ui.options.cursor);
809
stop: function(e, ui) {
810
if (ui.options._cursor) $('body').css("cursor", ui.options._cursor);
814
$.ui.plugin.add("draggable", "zIndex", {
815
start: function(e, ui) {
816
var t = $(ui.helper);
817
if(t.css("zIndex")) ui.options._zIndex = t.css("zIndex");
818
t.css('zIndex', ui.options.zIndex);
820
stop: function(e, ui) {
821
if(ui.options._zIndex) $(ui.helper).css('zIndex', ui.options._zIndex);
825
$.ui.plugin.add("draggable", "opacity", {
826
start: function(e, ui) {
827
var t = $(ui.helper);
828
if(t.css("opacity")) ui.options._opacity = t.css("opacity");
829
t.css('opacity', ui.options.opacity);
831
stop: function(e, ui) {
832
if(ui.options._opacity) $(ui.helper).css('opacity', ui.options._opacity);
836
$.ui.plugin.add("draggable", "iframeFix", {
837
start: function(e, ui) {
838
$(ui.options.iframeFix === true ? "iframe" : ui.options.iframeFix).each(function() {
839
$('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>')
841
width: this.offsetWidth+"px", height: this.offsetHeight+"px",
842
position: "absolute", opacity: "0.001", zIndex: 1000
844
.css($(this).offset())
848
stop: function(e, ui) {
849
$("div.ui-draggable-iframeFix").each(function() { this.parentNode.removeChild(this); }); //Remove frame helpers
855
$.ui.plugin.add("draggable", "scroll", {
856
start: function(e, ui) {
858
var i = $(this).data("draggable");
859
o.scrollSensitivity = o.scrollSensitivity || 20;
860
o.scrollSpeed = o.scrollSpeed || 20;
862
i.overflowY = function(el) {
863
do { if(/auto|scroll/.test(el.css('overflow')) || (/auto|scroll/).test(el.css('overflow-y'))) return el; el = el.parent(); } while (el[0].parentNode);
866
i.overflowX = function(el) {
867
do { if(/auto|scroll/.test(el.css('overflow')) || (/auto|scroll/).test(el.css('overflow-x'))) return el; el = el.parent(); } while (el[0].parentNode);
871
if(i.overflowY[0] != document && i.overflowY[0].tagName != 'HTML') i.overflowYOffset = i.overflowY.offset();
872
if(i.overflowX[0] != document && i.overflowX[0].tagName != 'HTML') i.overflowXOffset = i.overflowX.offset();
875
drag: function(e, ui) {
877
var o = ui.options, scrolled = false;
878
var i = $(this).data("draggable");
880
if(i.overflowY[0] != document && i.overflowY[0].tagName != 'HTML') {
881
if((i.overflowYOffset.top + i.overflowY[0].offsetHeight) - e.pageY < o.scrollSensitivity)
882
i.overflowY[0].scrollTop = scrolled = i.overflowY[0].scrollTop + o.scrollSpeed;
883
if(e.pageY - i.overflowYOffset.top < o.scrollSensitivity)
884
i.overflowY[0].scrollTop = scrolled = i.overflowY[0].scrollTop - o.scrollSpeed;
887
if(e.pageY - $(document).scrollTop() < o.scrollSensitivity)
888
scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
889
if($(window).height() - (e.pageY - $(document).scrollTop()) < o.scrollSensitivity)
890
scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
893
if(i.overflowX[0] != document && i.overflowX[0].tagName != 'HTML') {
894
if((i.overflowXOffset.left + i.overflowX[0].offsetWidth) - e.pageX < o.scrollSensitivity)
895
i.overflowX[0].scrollLeft = scrolled = i.overflowX[0].scrollLeft + o.scrollSpeed;
896
if(e.pageX - i.overflowXOffset.left < o.scrollSensitivity)
897
i.overflowX[0].scrollLeft = scrolled = i.overflowX[0].scrollLeft - o.scrollSpeed;
899
if(e.pageX - $(document).scrollLeft() < o.scrollSensitivity)
900
scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
901
if($(window).width() - (e.pageX - $(document).scrollLeft()) < o.scrollSensitivity)
902
scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
905
if(scrolled !== false)
906
$.ui.ddmanager.prepareOffsets(i, e);
912
$.ui.plugin.add("draggable", "snap", {
913
start: function(e, ui) {
915
var inst = $(this).data("draggable");
916
inst.snapElements = [];
918
$(ui.options.snap.constructor != String ? ( ui.options.snap.items || ':data(draggable)' ) : ui.options.snap).each(function() {
919
var $t = $(this); var $o = $t.offset();
920
if(this != inst.element[0]) inst.snapElements.push({
922
width: $t.outerWidth(), height: $t.outerHeight(),
923
top: $o.top, left: $o.left
928
drag: function(e, ui) {
930
var inst = $(this).data("draggable");
931
var d = ui.options.snapTolerance || 20;
933
var x1 = ui.absolutePosition.left, x2 = x1 + inst.helperProportions.width,
934
y1 = ui.absolutePosition.top, y2 = y1 + inst.helperProportions.height;
936
for (var i = inst.snapElements.length - 1; i >= 0; i--){
938
var l = inst.snapElements[i].left, r = l + inst.snapElements[i].width,
939
t = inst.snapElements[i].top, b = t + inst.snapElements[i].height;
941
//Yes, I know, this is insane ;)
942
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))) {
943
if(inst.snapElements[i].snapping) (inst.options.snap.release && inst.options.snap.release.call(inst.element, null, $.extend(inst.uiHash(), { snapItem: inst.snapElements[i].item })));
944
inst.snapElements[i].snapping = false;
948
if(ui.options.snapMode != 'inner') {
949
var ts = Math.abs(t - y2) <= d;
950
var bs = Math.abs(b - y1) <= d;
951
var ls = Math.abs(l - x2) <= d;
952
var rs = Math.abs(r - x1) <= d;
953
if(ts) ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top;
954
if(bs) ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top;
955
if(ls) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left;
956
if(rs) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left;
959
var first = (ts || bs || ls || rs);
961
if(ui.options.snapMode != 'outer') {
962
var ts = Math.abs(t - y1) <= d;
963
var bs = Math.abs(b - y2) <= d;
964
var ls = Math.abs(l - x1) <= d;
965
var rs = Math.abs(r - x2) <= d;
966
if(ts) ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top;
967
if(bs) ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top;
968
if(ls) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left;
969
if(rs) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left;
972
if(!inst.snapElements[i].snapping && (ts || bs || ls || rs || first))
973
(inst.options.snap.snap && inst.options.snap.snap.call(inst.element, null, $.extend(inst.uiHash(), { snapItem: inst.snapElements[i].item })));
974
inst.snapElements[i].snapping = (ts || bs || ls || rs || first);
981
$.ui.plugin.add("draggable", "connectToSortable", {
982
start: function(e,ui) {
984
var inst = $(this).data("draggable");
986
$(ui.options.connectToSortable).each(function() {
987
if($.data(this, 'sortable')) {
988
var sortable = $.data(this, 'sortable');
989
inst.sortables.push({
991
shouldRevert: sortable.options.revert
993
sortable._refreshItems(); //Do a one-time refresh at start to refresh the containerCache
994
sortable._propagate("activate", e, inst);
999
stop: function(e,ui) {
1001
//If we are still over the sortable, we fake the stop event of the sortable, but also remove helper
1002
var inst = $(this).data("draggable");
1004
$.each(inst.sortables, function() {
1005
if(this.instance.isOver) {
1006
this.instance.isOver = 0;
1007
inst.cancelHelperRemoval = true; //Don't remove the helper in the draggable instance
1008
this.instance.cancelHelperRemoval = false; //Remove it in the sortable instance (so sortable plugins like revert still work)
1009
if(this.shouldRevert) this.instance.options.revert = true; //revert here
1010
this.instance._mouseStop(e);
1012
//Also propagate receive event, since the sortable is actually receiving a element
1013
this.instance.element.triggerHandler("sortreceive", [e, $.extend(this.instance.ui(), { sender: inst.element })], this.instance.options["receive"]);
1015
this.instance.options.helper = this.instance.options._helper;
1017
this.instance._propagate("deactivate", e, inst);
1023
drag: function(e,ui) {
1025
var inst = $(this).data("draggable"), self = this;
1027
var checkPos = function(o) {
1029
var l = o.left, r = l + o.width,
1030
t = o.top, b = t + o.height;
1032
return (l < (this.positionAbs.left + this.offset.click.left) && (this.positionAbs.left + this.offset.click.left) < r
1033
&& t < (this.positionAbs.top + this.offset.click.top) && (this.positionAbs.top + this.offset.click.top) < b);
1036
$.each(inst.sortables, function(i) {
1038
if(checkPos.call(inst, this.instance.containerCache)) {
1040
//If it intersects, we use a little isOver variable and set it once, so our move-in stuff gets fired only once
1041
if(!this.instance.isOver) {
1042
this.instance.isOver = 1;
1044
//Now we fake the start of dragging for the sortable instance,
1045
//by cloning the list group item, appending it to the sortable and using it as inst.currentItem
1046
//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)
1047
this.instance.currentItem = $(self).clone().appendTo(this.instance.element).data("sortable-item", true);
1048
this.instance.options._helper = this.instance.options.helper; //Store helper option to later restore it
1049
this.instance.options.helper = function() { return ui.helper[0]; };
1051
e.target = this.instance.currentItem[0];
1052
this.instance._mouseCapture(e, true);
1053
this.instance._mouseStart(e, true, true);
1055
//Because the browser event is way off the new appended portlet, we modify a couple of variables to reflect the changes
1056
this.instance.offset.click.top = inst.offset.click.top;
1057
this.instance.offset.click.left = inst.offset.click.left;
1058
this.instance.offset.parent.left -= inst.offset.parent.left - this.instance.offset.parent.left;
1059
this.instance.offset.parent.top -= inst.offset.parent.top - this.instance.offset.parent.top;
1061
inst._propagate("toSortable", e);
1065
//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
1066
if(this.instance.currentItem) this.instance._mouseDrag(e);
1070
//If it doesn't intersect with the sortable, and it intersected before,
1071
//we fake the drag stop of the sortable, but make sure it doesn't remove the helper by using cancelHelperRemoval
1072
if(this.instance.isOver) {
1073
this.instance.isOver = 0;
1074
this.instance.cancelHelperRemoval = true;
1075
this.instance.options.revert = false; //No revert here
1076
this.instance._mouseStop(e, true);
1077
this.instance.options.helper = this.instance.options._helper;
1079
//Now we remove our currentItem, the list group clone again, and the placeholder, and animate the helper back to it's original size
1080
this.instance.currentItem.remove();
1081
if(this.instance.placeholder) this.instance.placeholder.remove();
1083
inst._propagate("fromSortable", e);
1093
$.ui.plugin.add("draggable", "stack", {
1094
start: function(e,ui) {
1095
var group = $.makeArray($(ui.options.stack.group)).sort(function(a,b) {
1096
return (parseInt($(a).css("zIndex"),10) || ui.options.stack.min) - (parseInt($(b).css("zIndex"),10) || ui.options.stack.min);
1099
$(group).each(function(i) {
1100
this.style.zIndex = ui.options.stack.min + i;
1103
this[0].style.zIndex = ui.options.stack.min + group.length;
1109
* jQuery UI Droppable @VERSION
1111
* Copyright (c) 2008 Paul Bakaus
1112
* Dual licensed under the MIT (MIT-LICENSE.txt)
1113
* and GPL (GPL-LICENSE.txt) licenses.
1115
* http://docs.jquery.com/UI/Droppables
1123
$.widget("ui.droppable", {
1125
_setData: function(key, value) {
1127
if(key == 'accept') {
1128
this.options.accept = value && $.isFunction(value) ? value : function(d) {
1129
return d.is(accept);
1132
$.widget.prototype._setData.apply(this, arguments);
1139
var o = this.options, accept = o.accept;
1140
this.isover = 0; this.isout = 1;
1142
this.options.accept = this.options.accept && $.isFunction(this.options.accept) ? this.options.accept : function(d) {
1143
return d.is(accept);
1146
//Store the droppable's proportions
1147
this.proportions = { width: this.element[0].offsetWidth, height: this.element[0].offsetHeight };
1149
// Add the reference and positions to the manager
1150
$.ui.ddmanager.droppables[this.options.scope] = $.ui.ddmanager.droppables[this.options.scope] || [];
1151
$.ui.ddmanager.droppables[this.options.scope].push(this);
1153
(this.options.cssNamespace && this.element.addClass(this.options.cssNamespace+"-droppable"));
1159
draggable: (c.currentItem || c.element),
1161
position: c.position,
1162
absolutePosition: c.positionAbs,
1163
options: this.options,
1164
element: this.element
1167
destroy: function() {
1168
var drop = $.ui.ddmanager.droppables[this.options.scope];
1169
for ( var i = 0; i < drop.length; i++ )
1170
if ( drop[i] == this )
1174
.removeClass("ui-droppable-disabled")
1175
.removeData("droppable")
1176
.unbind(".droppable");
1178
_over: function(e) {
1180
var draggable = $.ui.ddmanager.current;
1181
if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return; // Bail if draggable and droppable are same element
1183
if (this.options.accept.call(this.element,(draggable.currentItem || draggable.element))) {
1184
$.ui.plugin.call(this, 'over', [e, this.ui(draggable)]);
1185
this.element.triggerHandler("dropover", [e, this.ui(draggable)], this.options.over);
1191
var draggable = $.ui.ddmanager.current;
1192
if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return; // Bail if draggable and droppable are same element
1194
if (this.options.accept.call(this.element,(draggable.currentItem || draggable.element))) {
1195
$.ui.plugin.call(this, 'out', [e, this.ui(draggable)]);
1196
this.element.triggerHandler("dropout", [e, this.ui(draggable)], this.options.out);
1200
_drop: function(e,custom) {
1202
var draggable = custom || $.ui.ddmanager.current;
1203
if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return false; // Bail if draggable and droppable are same element
1205
var childrenIntersection = false;
1206
this.element.find(":data(droppable)").not(".ui-draggable-dragging").each(function() {
1207
var inst = $.data(this, 'droppable');
1208
if(inst.options.greedy && $.ui.intersect(draggable, $.extend(inst, { offset: inst.element.offset() }), inst.options.tolerance)) {
1209
childrenIntersection = true; return false;
1212
if(childrenIntersection) return false;
1214
if(this.options.accept.call(this.element,(draggable.currentItem || draggable.element))) {
1215
$.ui.plugin.call(this, 'drop', [e, this.ui(draggable)]);
1216
this.element.triggerHandler("drop", [e, this.ui(draggable)], this.options.drop);
1217
return this.element;
1223
_activate: function(e) {
1225
var draggable = $.ui.ddmanager.current;
1226
$.ui.plugin.call(this, 'activate', [e, this.ui(draggable)]);
1227
if(draggable) this.element.triggerHandler("dropactivate", [e, this.ui(draggable)], this.options.activate);
1230
_deactivate: function(e) {
1232
var draggable = $.ui.ddmanager.current;
1233
$.ui.plugin.call(this, 'deactivate', [e, this.ui(draggable)]);
1234
if(draggable) this.element.triggerHandler("dropdeactivate", [e, this.ui(draggable)], this.options.deactivate);
1239
$.extend($.ui.droppable, {
1242
tolerance: 'intersect',
1248
$.ui.intersect = function(draggable, droppable, toleranceMode) {
1250
if (!droppable.offset) return false;
1252
var x1 = (draggable.positionAbs || draggable.position.absolute).left, x2 = x1 + draggable.helperProportions.width,
1253
y1 = (draggable.positionAbs || draggable.position.absolute).top, y2 = y1 + draggable.helperProportions.height;
1254
var l = droppable.offset.left, r = l + droppable.proportions.width,
1255
t = droppable.offset.top, b = t + droppable.proportions.height;
1257
switch (toleranceMode) {
1259
return (l < x1 && x2 < r
1260
&& t < y1 && y2 < b);
1263
return (l < x1 + (draggable.helperProportions.width / 2) // Right Half
1264
&& x2 - (draggable.helperProportions.width / 2) < r // Left Half
1265
&& t < y1 + (draggable.helperProportions.height / 2) // Bottom Half
1266
&& y2 - (draggable.helperProportions.height / 2) < b ); // Top Half
1269
return (l < ((draggable.positionAbs || draggable.position.absolute).left + (draggable.clickOffset || draggable.offset.click).left) && ((draggable.positionAbs || draggable.position.absolute).left + (draggable.clickOffset || draggable.offset.click).left) < r
1270
&& t < ((draggable.positionAbs || draggable.position.absolute).top + (draggable.clickOffset || draggable.offset.click).top) && ((draggable.positionAbs || draggable.position.absolute).top + (draggable.clickOffset || draggable.offset.click).top) < b);
1274
(y1 >= t && y1 <= b) || // Top edge touching
1275
(y2 >= t && y2 <= b) || // Bottom edge touching
1276
(y1 < t && y2 > b) // Surrounded vertically
1278
(x1 >= l && x1 <= r) || // Left edge touching
1279
(x2 >= l && x2 <= r) || // Right edge touching
1280
(x1 < l && x2 > r) // Surrounded horizontally
1291
This manager tracks offsets of draggables and droppables
1295
droppables: { 'default': [] },
1296
prepareOffsets: function(t, e) {
1298
var m = $.ui.ddmanager.droppables[t.options.scope];
1299
var type = e ? e.type : null; // workaround for #2317
1300
var list = (t.currentItem || t.element).find(":data(droppable)").andSelf();
1302
droppablesLoop: for (var i = 0; i < m.length; i++) {
1304
if(m[i].options.disabled || (t && !m[i].options.accept.call(m[i].element,(t.currentItem || t.element)))) continue; //No disabled and non-accepted
1305
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
1306
m[i].visible = m[i].element.css("display") != "none"; if(!m[i].visible) continue; //If the element is not visible, continue
1308
m[i].offset = m[i].element.offset();
1309
m[i].proportions = { width: m[i].element[0].offsetWidth, height: m[i].element[0].offsetHeight };
1311
if(type == "dragstart" || type == "sortactivate") m[i]._activate.call(m[i], e); //Activate the droppable if used directly from draggables
1316
drop: function(draggable, e) {
1318
var dropped = false;
1319
$.each($.ui.ddmanager.droppables[draggable.options.scope], function() {
1321
if(!this.options) return;
1322
if (!this.options.disabled && this.visible && $.ui.intersect(draggable, this, this.options.tolerance))
1323
dropped = this._drop.call(this, e);
1325
if (!this.options.disabled && this.visible && this.options.accept.call(this.element,(draggable.currentItem || draggable.element))) {
1326
this.isout = 1; this.isover = 0;
1327
this._deactivate.call(this, e);
1334
drag: function(draggable, e) {
1336
//If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse.
1337
if(draggable.options.refreshPositions) $.ui.ddmanager.prepareOffsets(draggable, e);
1339
//Run through all droppables and check their positions based on specific tolerance options
1341
$.each($.ui.ddmanager.droppables[draggable.options.scope], function() {
1343
if(this.options.disabled || this.greedyChild || !this.visible) return;
1344
var intersects = $.ui.intersect(draggable, this, this.options.tolerance);
1346
var c = !intersects && this.isover == 1 ? 'isout' : (intersects && this.isover == 0 ? 'isover' : null);
1350
if (this.options.greedy) {
1351
var parent = this.element.parents(':data(droppable):eq(0)');
1352
if (parent.length) {
1353
parentInstance = $.data(parent[0], 'droppable');
1354
parentInstance.greedyChild = (c == 'isover' ? 1 : 0);
1358
// we just moved into a greedy child
1359
if (parentInstance && c == 'isover') {
1360
parentInstance['isover'] = 0;
1361
parentInstance['isout'] = 1;
1362
parentInstance._out.call(parentInstance, e);
1365
this[c] = 1; this[c == 'isout' ? 'isover' : 'isout'] = 0;
1366
this[c == "isover" ? "_over" : "_out"].call(this, e);
1368
// we just moved out of a greedy child
1369
if (parentInstance && c == 'isout') {
1370
parentInstance['isout'] = 0;
1371
parentInstance['isover'] = 1;
1372
parentInstance._over.call(parentInstance, e);
1380
* Droppable Extensions
1383
$.ui.plugin.add("droppable", "activeClass", {
1384
activate: function(e, ui) {
1385
$(this).addClass(ui.options.activeClass);
1387
deactivate: function(e, ui) {
1388
$(this).removeClass(ui.options.activeClass);
1390
drop: function(e, ui) {
1391
$(this).removeClass(ui.options.activeClass);
1395
$.ui.plugin.add("droppable", "hoverClass", {
1396
over: function(e, ui) {
1397
$(this).addClass(ui.options.hoverClass);
1399
out: function(e, ui) {
1400
$(this).removeClass(ui.options.hoverClass);
1402
drop: function(e, ui) {
1403
$(this).removeClass(ui.options.hoverClass);
1409
* jQuery UI Resizable @VERSION
1411
* Copyright (c) 2008 Paul Bakaus
1412
* Dual licensed under the MIT (MIT-LICENSE.txt)
1413
* and GPL (GPL-LICENSE.txt) licenses.
1415
* http://docs.jquery.com/UI/Resizables
1422
$.widget("ui.resizable", $.extend({}, $.ui.mouse, {
1425
var self = this, o = this.options;
1427
var elpos = this.element.css('position');
1429
this.originalElement = this.element;
1431
// simulate .ui-resizable { position: relative; }
1432
this.element.addClass("ui-resizable").css({ position: /static/.test(elpos) ? 'relative' : elpos });
1435
_aspectRatio: !!(o.aspectRatio),
1436
helper: o.helper || o.ghost || o.animate ? o.helper || 'proxy' : null,
1437
knobHandles: o.knobHandles === true ? 'ui-resizable-knob-handle' : o.knobHandles
1441
var aBorder = '1px solid #DEDEDE';
1444
'ui-resizable': { display: 'block' },
1445
'ui-resizable-handle': { position: 'absolute', background: '#F2F2F2', fontSize: '0.1px' },
1446
'ui-resizable-n': { cursor: 'n-resize', height: '4px', left: '0px', right: '0px', borderTop: aBorder },
1447
'ui-resizable-s': { cursor: 's-resize', height: '4px', left: '0px', right: '0px', borderBottom: aBorder },
1448
'ui-resizable-e': { cursor: 'e-resize', width: '4px', top: '0px', bottom: '0px', borderRight: aBorder },
1449
'ui-resizable-w': { cursor: 'w-resize', width: '4px', top: '0px', bottom: '0px', borderLeft: aBorder },
1450
'ui-resizable-se': { cursor: 'se-resize', width: '4px', height: '4px', borderRight: aBorder, borderBottom: aBorder },
1451
'ui-resizable-sw': { cursor: 'sw-resize', width: '4px', height: '4px', borderBottom: aBorder, borderLeft: aBorder },
1452
'ui-resizable-ne': { cursor: 'ne-resize', width: '4px', height: '4px', borderRight: aBorder, borderTop: aBorder },
1453
'ui-resizable-nw': { cursor: 'nw-resize', width: '4px', height: '4px', borderLeft: aBorder, borderTop: aBorder }
1457
'ui-resizable-handle': { background: '#F2F2F2', border: '1px solid #808080', height: '8px', width: '8px' },
1458
'ui-resizable-n': { cursor: 'n-resize', top: '0px', left: '45%' },
1459
'ui-resizable-s': { cursor: 's-resize', bottom: '0px', left: '45%' },
1460
'ui-resizable-e': { cursor: 'e-resize', right: '0px', top: '45%' },
1461
'ui-resizable-w': { cursor: 'w-resize', left: '0px', top: '45%' },
1462
'ui-resizable-se': { cursor: 'se-resize', right: '0px', bottom: '0px' },
1463
'ui-resizable-sw': { cursor: 'sw-resize', left: '0px', bottom: '0px' },
1464
'ui-resizable-nw': { cursor: 'nw-resize', left: '0px', top: '0px' },
1465
'ui-resizable-ne': { cursor: 'ne-resize', right: '0px', top: '0px' }
1468
o._nodeName = this.element[0].nodeName;
1470
//Wrap the element if it cannot hold child nodes
1471
if(o._nodeName.match(/canvas|textarea|input|select|button|img/i)) {
1472
var el = this.element;
1474
//Opera fixing relative position
1475
if (/relative/.test(el.css('position')) && $.browser.opera)
1476
el.css({ position: 'relative', top: 'auto', left: 'auto' });
1478
//Create a wrapper element and set the wrapper to the new current internal element
1480
$('<div class="ui-wrapper" style="overflow: hidden;"></div>').css( {
1481
position: el.css('position'),
1482
width: el.outerWidth(),
1483
height: el.outerHeight(),
1485
left: el.css('left')
1489
var oel = this.element; this.element = this.element.parent();
1491
// store instance on wrapper
1492
this.element.data('resizable', this);
1494
//Move margins to the wrapper
1495
this.element.css({ marginLeft: oel.css("marginLeft"), marginTop: oel.css("marginTop"),
1496
marginRight: oel.css("marginRight"), marginBottom: oel.css("marginBottom")
1499
oel.css({ marginLeft: 0, marginTop: 0, marginRight: 0, marginBottom: 0});
1501
//Prevent Safari textarea resize
1502
if ($.browser.safari && o.preventDefault) oel.css('resize', 'none');
1504
o.proportionallyResize = oel.css({ position: 'static', zoom: 1, display: 'block' });
1507
this.element.css({ margin: oel.css('margin') });
1509
// fix handlers offset
1510
this._proportionallyResize();
1513
if(!o.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' };
1514
if(o.handles.constructor == String) {
1516
o.zIndex = o.zIndex || 1000;
1518
if(o.handles == 'all') o.handles = 'n,e,s,w,se,sw,ne,nw';
1520
var n = o.handles.split(","); o.handles = {};
1522
// insertions are applied when don't have theme loaded
1523
var insertionsDefault = {
1524
handle: 'position: absolute; display: none; overflow:hidden;',
1525
n: 'top: 0pt; width:100%;',
1526
e: 'right: 0pt; height:100%;',
1527
s: 'bottom: 0pt; width:100%;',
1528
w: 'left: 0pt; height:100%;',
1529
se: 'bottom: 0pt; right: 0px;',
1530
sw: 'bottom: 0pt; left: 0px;',
1531
ne: 'top: 0pt; right: 0px;',
1532
nw: 'top: 0pt; left: 0px;'
1535
for(var i = 0; i < n.length; i++) {
1536
var handle = $.trim(n[i]), dt = o.defaultTheme, hname = 'ui-resizable-'+handle, loadDefault = !$.ui.css(hname) && !o.knobHandles, userKnobClass = $.ui.css('ui-resizable-knob-handle'),
1537
allDefTheme = $.extend(dt[hname], dt['ui-resizable-handle']), allKnobTheme = $.extend(o.knobTheme[hname], !userKnobClass ? o.knobTheme['ui-resizable-handle'] : {});
1539
// increase zIndex of sw, se, ne, nw axis
1540
var applyZIndex = /sw|se|ne|nw/.test(handle) ? { zIndex: ++o.zIndex } : {};
1542
var defCss = (loadDefault ? insertionsDefault[handle] : ''),
1543
axis = $(['<div class="ui-resizable-handle ', hname, '" style="', defCss, insertionsDefault.handle, '"></div>'].join('')).css( applyZIndex );
1544
o.handles[handle] = '.ui-resizable-'+handle;
1546
this.element.append(
1547
//Theme detection, if not loaded, load o.defaultTheme
1548
axis.css( loadDefault ? allDefTheme : {} )
1549
// Load the knobHandle css, fix width, height, top, left...
1550
.css( o.knobHandles ? allKnobTheme : {} ).addClass(o.knobHandles ? 'ui-resizable-knob-handle' : '').addClass(o.knobHandles)
1554
if (o.knobHandles) this.element.addClass('ui-resizable-knob').css( !$.ui.css('ui-resizable-knob') ? { /*border: '1px #fff dashed'*/ } : {} );
1557
this._renderAxis = function(target) {
1558
target = target || this.element;
1560
for(var i in o.handles) {
1561
if(o.handles[i].constructor == String)
1562
o.handles[i] = $(o.handles[i], this.element).show();
1565
o.handles[i].css({opacity:0});
1567
//Apply pad to wrapper element, needed to fix axis position (textarea, inputs, scrolls)
1568
if (this.element.is('.ui-wrapper') &&
1569
o._nodeName.match(/textarea|input|select|button/i)) {
1571
var axis = $(o.handles[i], this.element), padWrapper = 0;
1573
//Checking the correct pad and border
1574
padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth();
1576
//The padding type i have to apply...
1577
var padPos = [ 'padding',
1578
/ne|nw|n/.test(i) ? 'Top' :
1579
/se|sw|s/.test(i) ? 'Bottom' :
1580
/^e$/.test(i) ? 'Right' : 'Left' ].join("");
1583
target.css(padPos, padWrapper);
1585
this._proportionallyResize();
1587
if(!$(o.handles[i]).length) continue;
1591
this._renderAxis(this.element);
1592
o._handles = $('.ui-resizable-handle', self.element);
1594
if (o.disableSelection)
1595
o._handles.each(function(i, e) { $.ui.disableSelection(e); });
1597
//Matching axis name
1598
o._handles.mouseover(function() {
1601
var axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);
1602
//Axis, default = se
1603
self.axis = o.axis = axis && axis[1] ? axis[1] : 'se';
1607
//If we want to auto hide the elements
1610
$(self.element).addClass("ui-resizable-autohide").hover(function() {
1611
$(this).removeClass("ui-resizable-autohide");
1616
$(this).addClass("ui-resizable-autohide");
1627
originalElement: this.originalElement,
1628
element: this.element,
1629
helper: this.helper,
1630
position: this.position,
1632
options: this.options,
1633
originalSize: this.originalSize,
1634
originalPosition: this.originalPosition
1637
_propagate: function(n,e) {
1638
$.ui.plugin.call(this, n, [e, this.ui()]);
1639
if (n != "resize") this.element.triggerHandler(["resize", n].join(""), [e, this.ui()], this.options[n]);
1641
destroy: function() {
1642
var el = this.element, wrapped = el.children(".ui-resizable").get(0);
1644
this._mouseDestroy();
1646
var _destroy = function(exp) {
1647
$(exp).removeClass("ui-resizable ui-resizable-disabled")
1648
.removeData("resizable").unbind(".resizable").find('.ui-resizable-handle').remove();
1653
if (el.is('.ui-wrapper') && wrapped) {
1656
position: el.css('position'),
1657
width: el.outerWidth(),
1658
height: el.outerHeight(),
1660
left: el.css('left')
1668
_mouseCapture: function(e) {
1670
if(this.options.disabled) return false;
1673
for(var i in this.options.handles) {
1674
if($(this.options.handles[i])[0] == e.target) handle = true;
1676
if (!handle) return false;
1682
_mouseStart: function(e) {
1684
var o = this.options, iniPos = this.element.position(), el = this.element,
1685
num = function(v) { return parseInt(v, 10) || 0; }, ie6 = $.browser.msie && $.browser.version < 7;
1687
o.documentScroll = { top: $(document).scrollTop(), left: $(document).scrollLeft() };
1690
if (el.is('.ui-draggable') || (/absolute/).test(el.css('position'))) {
1692
// sOffset decides if document scrollOffset will be added to the top/left of the resizable element
1693
var sOffset = $.browser.msie && !o.containment && (/absolute/).test(el.css('position')) && !(/relative/).test(el.parent().css('position'));
1694
var dscrollt = sOffset ? o.documentScroll.top : 0, dscrolll = sOffset ? o.documentScroll.left : 0;
1696
el.css({ position: 'absolute', top: (iniPos.top + dscrollt), left: (iniPos.left + dscrolll) });
1699
//Opera fixing relative position
1700
if ($.browser.opera && /relative/.test(el.css('position')))
1701
el.css({ position: 'relative', top: 'auto', left: 'auto' });
1703
this._renderProxy();
1705
var curleft = num(this.helper.css('left')), curtop = num(this.helper.css('top'));
1707
if (o.containment) {
1708
curleft += $(o.containment).scrollLeft()||0;
1709
curtop += $(o.containment).scrollTop()||0;
1712
//Store needed variables
1713
this.offset = this.helper.offset();
1714
this.position = { left: curleft, top: curtop };
1715
this.size = o.helper || ie6 ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
1716
this.originalSize = o.helper || ie6 ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
1717
this.originalPosition = { left: curleft, top: curtop };
1718
this.sizeDiff = { width: el.outerWidth() - el.width(), height: el.outerHeight() - el.height() };
1719
this.originalMousePosition = { left: e.pageX, top: e.pageY };
1722
o.aspectRatio = (typeof o.aspectRatio == 'number') ? o.aspectRatio : ((this.originalSize.width / this.originalSize.height)||1);
1724
if (o.preserveCursor)
1725
$('body').css('cursor', this.axis + '-resize');
1727
this._propagate("start", e);
1730
_mouseDrag: function(e) {
1732
//Increase performance, avoid regex
1733
var el = this.helper, o = this.options, props = {},
1734
self = this, smp = this.originalMousePosition, a = this.axis;
1736
var dx = (e.pageX-smp.left)||0, dy = (e.pageY-smp.top)||0;
1737
var trigger = this._change[a];
1738
if (!trigger) return false;
1740
// Calculate the attrs that will be change
1741
var data = trigger.apply(this, [e, dx, dy]), ie6 = $.browser.msie && $.browser.version < 7, csdif = this.sizeDiff;
1743
if (o._aspectRatio || e.shiftKey)
1744
data = this._updateRatio(data, e);
1746
data = this._respectSize(data, e);
1748
// plugins callbacks need to be called first
1749
this._propagate("resize", e);
1752
top: this.position.top + "px", left: this.position.left + "px",
1753
width: this.size.width + "px", height: this.size.height + "px"
1756
if (!o.helper && o.proportionallyResize)
1757
this._proportionallyResize();
1759
this._updateCache(data);
1761
// calling the user callback at the end
1762
this.element.triggerHandler("resize", [e, this.ui()], this.options["resize"]);
1766
_mouseStop: function(e) {
1768
this.options.resizing = false;
1769
var o = this.options, num = function(v) { return parseInt(v, 10) || 0; }, self = this;
1772
var pr = o.proportionallyResize, ista = pr && (/textarea/i).test(pr.get(0).nodeName),
1773
soffseth = ista && $.ui.hasScroll(pr.get(0), 'left') /* TODO - jump height */ ? 0 : self.sizeDiff.height,
1774
soffsetw = ista ? 0 : self.sizeDiff.width;
1776
var s = { width: (self.size.width - soffsetw), height: (self.size.height - soffseth) },
1777
left = (parseInt(self.element.css('left'), 10) + (self.position.left - self.originalPosition.left)) || null,
1778
top = (parseInt(self.element.css('top'), 10) + (self.position.top - self.originalPosition.top)) || null;
1781
this.element.css($.extend(s, { top: top, left: left }));
1783
if (o.helper && !o.animate) this._proportionallyResize();
1786
if (o.preserveCursor)
1787
$('body').css('cursor', 'auto');
1789
this._propagate("stop", e);
1791
if (o.helper) this.helper.remove();
1795
_updateCache: function(data) {
1796
var o = this.options;
1797
this.offset = this.helper.offset();
1798
if (data.left) this.position.left = data.left;
1799
if (data.top) this.position.top = data.top;
1800
if (data.height) this.size.height = data.height;
1801
if (data.width) this.size.width = data.width;
1803
_updateRatio: function(data, e) {
1805
var o = this.options, cpos = this.position, csize = this.size, a = this.axis;
1807
if (data.height) data.width = (csize.height * o.aspectRatio);
1808
else if (data.width) data.height = (csize.width / o.aspectRatio);
1811
data.left = cpos.left + (csize.width - data.width);
1815
data.top = cpos.top + (csize.height - data.height);
1816
data.left = cpos.left + (csize.width - data.width);
1821
_respectSize: function(data, e) {
1823
var el = this.helper, o = this.options, pRatio = o._aspectRatio || e.shiftKey, a = this.axis,
1824
ismaxw = data.width && o.maxWidth && o.maxWidth < data.width, ismaxh = data.height && o.maxHeight && o.maxHeight < data.height,
1825
isminw = data.width && o.minWidth && o.minWidth > data.width, isminh = data.height && o.minHeight && o.minHeight > data.height;
1827
if (isminw) data.width = o.minWidth;
1828
if (isminh) data.height = o.minHeight;
1829
if (ismaxw) data.width = o.maxWidth;
1830
if (ismaxh) data.height = o.maxHeight;
1832
var dw = this.originalPosition.left + this.originalSize.width, dh = this.position.top + this.size.height;
1833
var cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a);
1835
if (isminw && cw) data.left = dw - o.minWidth;
1836
if (ismaxw && cw) data.left = dw - o.maxWidth;
1837
if (isminh && ch) data.top = dh - o.minHeight;
1838
if (ismaxh && ch) data.top = dh - o.maxHeight;
1840
// fixing jump error on top/left - bug #2330
1841
var isNotwh = !data.width && !data.height;
1842
if (isNotwh && !data.left && data.top) data.top = null;
1843
else if (isNotwh && !data.top && data.left) data.left = null;
1847
_proportionallyResize: function() {
1848
var o = this.options;
1849
if (!o.proportionallyResize) return;
1850
var prel = o.proportionallyResize, el = this.helper || this.element;
1853
var b = [prel.css('borderTopWidth'), prel.css('borderRightWidth'), prel.css('borderBottomWidth'), prel.css('borderLeftWidth')],
1854
p = [prel.css('paddingTop'), prel.css('paddingRight'), prel.css('paddingBottom'), prel.css('paddingLeft')];
1856
o.borderDif = $.map(b, function(v, i) {
1857
var border = parseInt(v,10)||0, padding = parseInt(p[i],10)||0;
1858
return border + padding;
1862
height: (el.height() - o.borderDif[0] - o.borderDif[2]) + "px",
1863
width: (el.width() - o.borderDif[1] - o.borderDif[3]) + "px"
1866
_renderProxy: function() {
1867
var el = this.element, o = this.options;
1868
this.elementOffset = el.offset();
1871
this.helper = this.helper || $('<div style="overflow:hidden;"></div>');
1874
var ie6 = $.browser.msie && $.browser.version < 7, ie6offset = (ie6 ? 1 : 0),
1875
pxyoffset = ( ie6 ? 2 : -1 );
1877
this.helper.addClass(o.helper).css({
1878
width: el.outerWidth() + pxyoffset,
1879
height: el.outerHeight() + pxyoffset,
1880
position: 'absolute',
1881
left: this.elementOffset.left - ie6offset +'px',
1882
top: this.elementOffset.top - ie6offset +'px',
1886
this.helper.appendTo("body");
1888
if (o.disableSelection)
1889
$.ui.disableSelection(this.helper.get(0));
1896
e: function(e, dx, dy) {
1897
return { width: this.originalSize.width + dx };
1899
w: function(e, dx, dy) {
1900
var o = this.options, cs = this.originalSize, sp = this.originalPosition;
1901
return { left: sp.left + dx, width: cs.width - dx };
1903
n: function(e, dx, dy) {
1904
var o = this.options, cs = this.originalSize, sp = this.originalPosition;
1905
return { top: sp.top + dy, height: cs.height - dy };
1907
s: function(e, dx, dy) {
1908
return { height: this.originalSize.height + dy };
1910
se: function(e, dx, dy) {
1911
return $.extend(this._change.s.apply(this, arguments), this._change.e.apply(this, [e, dx, dy]));
1913
sw: function(e, dx, dy) {
1914
return $.extend(this._change.s.apply(this, arguments), this._change.w.apply(this, [e, dx, dy]));
1916
ne: function(e, dx, dy) {
1917
return $.extend(this._change.n.apply(this, arguments), this._change.e.apply(this, [e, dx, dy]));
1919
nw: function(e, dx, dy) {
1920
return $.extend(this._change.n.apply(this, arguments), this._change.w.apply(this, [e, dx, dy]));
1925
$.extend($.ui.resizable, {
1930
preventDefault: true,
1935
disableSelection: true,
1936
preserveCursor: true,
1943
* Resizable Extensions
1946
$.ui.plugin.add("resizable", "containment", {
1948
start: function(e, ui) {
1949
var o = ui.options, self = $(this).data("resizable"), el = self.element;
1950
var oc = o.containment, ce = (oc instanceof $) ? oc.get(0) : (/parent/.test(oc)) ? el.parent().get(0) : oc;
1953
self.containerElement = $(ce);
1955
if (/document/.test(oc) || oc == document) {
1956
self.containerOffset = { left: 0, top: 0 };
1957
self.containerPosition = { left: 0, top: 0 };
1960
element: $(document), left: 0, top: 0,
1961
width: $(document).width(), height: $(document).height() || document.body.parentNode.scrollHeight
1966
// i'm a node, so compute top, left, right, bottom
1968
self.containerOffset = $(ce).offset();
1969
self.containerPosition = $(ce).position();
1970
self.containerSize = { height: $(ce).innerHeight(), width: $(ce).innerWidth() };
1972
var co = self.containerOffset, ch = self.containerSize.height, cw = self.containerSize.width,
1973
width = ($.ui.hasScroll(ce, "left") ? ce.scrollWidth : cw ), height = ($.ui.hasScroll(ce) ? ce.scrollHeight : ch);
1976
element: ce, left: co.left, top: co.top, width: width, height: height
1981
resize: function(e, ui) {
1982
var o = ui.options, self = $(this).data("resizable"),
1983
ps = self.containerSize, co = self.containerOffset, cs = self.size, cp = self.position,
1984
pRatio = o._aspectRatio || e.shiftKey, cop = { top:0, left:0 }, ce = self.containerElement;
1986
if (ce[0] != document && /static/.test(ce.css('position')))
1987
cop = self.containerPosition;
1989
if (cp.left < (o.helper ? co.left : cop.left)) {
1990
self.size.width = self.size.width + (o.helper ? (self.position.left - co.left) : (self.position.left - cop.left));
1991
if (pRatio) self.size.height = self.size.width / o.aspectRatio;
1992
self.position.left = o.helper ? co.left : cop.left;
1995
if (cp.top < (o.helper ? co.top : 0)) {
1996
self.size.height = self.size.height + (o.helper ? (self.position.top - co.top) : self.position.top);
1997
if (pRatio) self.size.width = self.size.height * o.aspectRatio;
1998
self.position.top = o.helper ? co.top : 0;
2001
var woset = (o.helper ? self.offset.left - co.left : (self.position.left - cop.left)) + self.sizeDiff.width,
2002
hoset = (o.helper ? self.offset.top - co.top : self.position.top) + self.sizeDiff.height;
2004
if (woset + self.size.width >= self.parentData.width) {
2005
self.size.width = self.parentData.width - woset;
2006
if (pRatio) self.size.height = self.size.width / o.aspectRatio;
2009
if (hoset + self.size.height >= self.parentData.height) {
2010
self.size.height = self.parentData.height - hoset;
2011
if (pRatio) self.size.width = self.size.height * o.aspectRatio;
2015
stop: function(e, ui){
2016
var o = ui.options, self = $(this).data("resizable"), cp = self.position,
2017
co = self.containerOffset, cop = self.containerPosition, ce = self.containerElement;
2019
var helper = $(self.helper), ho = helper.offset(), w = helper.innerWidth(), h = helper.innerHeight();
2022
if (o.helper && !o.animate && /relative/.test(ce.css('position')))
2023
$(this).css({ left: (ho.left - co.left), top: (ho.top - co.top), width: w, height: h });
2025
if (o.helper && !o.animate && /static/.test(ce.css('position')))
2026
$(this).css({ left: cop.left + (ho.left - co.left), top: cop.top + (ho.top - co.top), width: w, height: h });
2031
$.ui.plugin.add("resizable", "grid", {
2033
resize: function(e, ui) {
2034
var o = ui.options, self = $(this).data("resizable"), cs = self.size, os = self.originalSize, op = self.originalPosition, a = self.axis, ratio = o._aspectRatio || e.shiftKey;
2035
o.grid = typeof o.grid == "number" ? [o.grid, o.grid] : o.grid;
2036
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);
2038
if (/^(se|s|e)$/.test(a)) {
2039
self.size.width = os.width + ox;
2040
self.size.height = os.height + oy;
2042
else if (/^(ne)$/.test(a)) {
2043
self.size.width = os.width + ox;
2044
self.size.height = os.height + oy;
2045
self.position.top = op.top - oy;
2047
else if (/^(sw)$/.test(a)) {
2048
self.size.width = os.width + ox;
2049
self.size.height = os.height + oy;
2050
self.position.left = op.left - ox;
2053
self.size.width = os.width + ox;
2054
self.size.height = os.height + oy;
2055
self.position.top = op.top - oy;
2056
self.position.left = op.left - ox;
2062
$.ui.plugin.add("resizable", "animate", {
2064
stop: function(e, ui) {
2065
var o = ui.options, self = $(this).data("resizable");
2067
var pr = o.proportionallyResize, ista = pr && (/textarea/i).test(pr.get(0).nodeName),
2068
soffseth = ista && $.ui.hasScroll(pr.get(0), 'left') /* TODO - jump height */ ? 0 : self.sizeDiff.height,
2069
soffsetw = ista ? 0 : self.sizeDiff.width;
2071
var style = { width: (self.size.width - soffsetw), height: (self.size.height - soffseth) },
2072
left = (parseInt(self.element.css('left'), 10) + (self.position.left - self.originalPosition.left)) || null,
2073
top = (parseInt(self.element.css('top'), 10) + (self.position.top - self.originalPosition.top)) || null;
2075
self.element.animate(
2076
$.extend(style, top && left ? { top: top, left: left } : {}), {
2077
duration: o.animateDuration || "slow", easing: o.animateEasing || "swing",
2081
width: parseInt(self.element.css('width'), 10),
2082
height: parseInt(self.element.css('height'), 10),
2083
top: parseInt(self.element.css('top'), 10),
2084
left: parseInt(self.element.css('left'), 10)
2087
if (pr) pr.css({ width: data.width, height: data.height });
2089
// propagating resize, and updating values for each animation step
2090
self._updateCache(data);
2091
self._propagate("animate", e);
2100
$.ui.plugin.add("resizable", "ghost", {
2102
start: function(e, ui) {
2103
var o = ui.options, self = $(this).data("resizable"), pr = o.proportionallyResize, cs = self.size;
2105
if (!pr) self.ghost = self.element.clone();
2106
else self.ghost = pr.clone();
2109
{ opacity: .25, display: 'block', position: 'relative', height: cs.height, width: cs.width, margin: 0, left: 0, top: 0 }
2111
.addClass('ui-resizable-ghost').addClass(typeof o.ghost == 'string' ? o.ghost : '');
2113
self.ghost.appendTo(self.helper);
2117
resize: function(e, ui){
2118
var o = ui.options, self = $(this).data("resizable"), pr = o.proportionallyResize;
2120
if (self.ghost) self.ghost.css({ position: 'relative', height: self.size.height, width: self.size.width });
2124
stop: function(e, ui){
2125
var o = ui.options, self = $(this).data("resizable"), pr = o.proportionallyResize;
2126
if (self.ghost && self.helper) self.helper.get(0).removeChild(self.ghost.get(0));
2131
$.ui.plugin.add("resizable", "alsoResize", {
2133
start: function(e, ui) {
2134
var o = ui.options, self = $(this).data("resizable"),
2136
_store = function(exp) {
2137
$(exp).each(function() {
2138
$(this).data("resizable-alsoresize", {
2139
width: parseInt($(this).width(), 10), height: parseInt($(this).height(), 10),
2140
left: parseInt($(this).css('left'), 10), top: parseInt($(this).css('top'), 10)
2145
if (typeof(o.alsoResize) == 'object') {
2146
if (o.alsoResize.length) { o.alsoResize = o.alsoResize[0]; _store(o.alsoResize); }
2147
else { $.each(o.alsoResize, function(exp, c) { _store(exp); }); }
2149
_store(o.alsoResize);
2153
resize: function(e, ui){
2154
var o = ui.options, self = $(this).data("resizable"), os = self.originalSize, op = self.originalPosition;
2157
height: (self.size.height - os.height) || 0, width: (self.size.width - os.width) || 0,
2158
top: (self.position.top - op.top) || 0, left: (self.position.left - op.left) || 0
2161
_alsoResize = function(exp, c) {
2162
$(exp).each(function() {
2163
var start = $(this).data("resizable-alsoresize"), style = {}, css = c && c.length ? c : ['width', 'height', 'top', 'left'];
2165
$.each(css || ['width', 'height', 'top', 'left'], function(i, prop) {
2166
var sum = (start[prop]||0) + (delta[prop]||0);
2167
if (sum && sum >= 0)
2168
style[prop] = sum || null;
2174
if (typeof(o.alsoResize) == 'object') {
2175
$.each(o.alsoResize, function(exp, c) { _alsoResize(exp, c); });
2177
_alsoResize(o.alsoResize);
2181
stop: function(e, ui){
2182
$(this).removeData("resizable-alsoresize-start");
2188
* jQuery UI Selectable @VERSION
2190
* Copyright (c) 2008 Richard D. Worth (rdworth.org)
2191
* Dual licensed under the MIT (MIT-LICENSE.txt)
2192
* and GPL (GPL-LICENSE.txt) licenses.
2194
* http://docs.jquery.com/UI/Selectables
2201
$.widget("ui.selectable", $.extend({}, $.ui.mouse, {
2205
this.element.addClass("ui-selectable");
2207
this.dragged = false;
2209
// cache selectee children based on filter
2211
this.refresh = function() {
2212
selectees = $(self.options.filter, self.element[0]);
2213
selectees.each(function() {
2214
var $this = $(this);
2215
var pos = $this.offset();
2216
$.data(this, "selectable-item", {
2221
right: pos.left + $this.width(),
2222
bottom: pos.top + $this.height(),
2223
startselected: false,
2224
selected: $this.hasClass('ui-selected'),
2225
selecting: $this.hasClass('ui-selecting'),
2226
unselecting: $this.hasClass('ui-unselecting')
2232
this.selectees = selectees.addClass("ui-selectee");
2236
this.helper = $(document.createElement('div'))
2237
.css({border:'1px dotted black'})
2238
.addClass("ui-selectable-helper");
2240
toggle: function() {
2241
if(this.options.disabled){
2247
destroy: function() {
2249
.removeClass("ui-selectable ui-selectable-disabled")
2250
.removeData("selectable")
2251
.unbind(".selectable");
2252
this._mouseDestroy();
2254
_mouseStart: function(e) {
2257
this.opos = [e.pageX, e.pageY];
2259
if (this.options.disabled)
2262
var options = this.options;
2264
this.selectees = $(options.filter, this.element[0]);
2266
// selectable START callback
2267
this.element.triggerHandler("selectablestart", [e, {
2268
"selectable": this.element[0],
2272
$('body').append(this.helper);
2273
// position helper (lasso)
2276
"position": "absolute",
2283
if (options.autoRefresh) {
2287
this.selectees.filter('.ui-selected').each(function() {
2288
var selectee = $.data(this, "selectable-item");
2289
selectee.startselected = true;
2291
selectee.$element.removeClass('ui-selected');
2292
selectee.selected = false;
2293
selectee.$element.addClass('ui-unselecting');
2294
selectee.unselecting = true;
2295
// selectable UNSELECTING callback
2296
self.element.triggerHandler("selectableunselecting", [e, {
2297
selectable: self.element[0],
2298
unselecting: selectee.element,
2300
}], options.unselecting);
2304
var isSelectee = false;
2305
$(e.target).parents().andSelf().each(function() {
2306
if($.data(this, "selectable-item")) isSelectee = true;
2308
return this.options.keyboard ? !isSelectee : true;
2310
_mouseDrag: function(e) {
2312
this.dragged = true;
2314
if (this.options.disabled)
2317
var options = this.options;
2319
var x1 = this.opos[0], y1 = this.opos[1], x2 = e.pageX, y2 = e.pageY;
2320
if (x1 > x2) { var tmp = x2; x2 = x1; x1 = tmp; }
2321
if (y1 > y2) { var tmp = y2; y2 = y1; y1 = tmp; }
2322
this.helper.css({left: x1, top: y1, width: x2-x1, height: y2-y1});
2324
this.selectees.each(function() {
2325
var selectee = $.data(this, "selectable-item");
2326
//prevent helper from being selected if appendTo: selectable
2327
if (!selectee || selectee.element == self.element[0])
2330
if (options.tolerance == 'touch') {
2331
hit = ( !(selectee.left > x2 || selectee.right < x1 || selectee.top > y2 || selectee.bottom < y1) );
2332
} else if (options.tolerance == 'fit') {
2333
hit = (selectee.left > x1 && selectee.right < x2 && selectee.top > y1 && selectee.bottom < y2);
2338
if (selectee.selected) {
2339
selectee.$element.removeClass('ui-selected');
2340
selectee.selected = false;
2342
if (selectee.unselecting) {
2343
selectee.$element.removeClass('ui-unselecting');
2344
selectee.unselecting = false;
2346
if (!selectee.selecting) {
2347
selectee.$element.addClass('ui-selecting');
2348
selectee.selecting = true;
2349
// selectable SELECTING callback
2350
self.element.triggerHandler("selectableselecting", [e, {
2351
selectable: self.element[0],
2352
selecting: selectee.element,
2354
}], options.selecting);
2358
if (selectee.selecting) {
2359
if (e.metaKey && selectee.startselected) {
2360
selectee.$element.removeClass('ui-selecting');
2361
selectee.selecting = false;
2362
selectee.$element.addClass('ui-selected');
2363
selectee.selected = true;
2365
selectee.$element.removeClass('ui-selecting');
2366
selectee.selecting = false;
2367
if (selectee.startselected) {
2368
selectee.$element.addClass('ui-unselecting');
2369
selectee.unselecting = true;
2371
// selectable UNSELECTING callback
2372
self.element.triggerHandler("selectableunselecting", [e, {
2373
selectable: self.element[0],
2374
unselecting: selectee.element,
2376
}], options.unselecting);
2379
if (selectee.selected) {
2380
if (!e.metaKey && !selectee.startselected) {
2381
selectee.$element.removeClass('ui-selected');
2382
selectee.selected = false;
2384
selectee.$element.addClass('ui-unselecting');
2385
selectee.unselecting = true;
2386
// selectable UNSELECTING callback
2387
self.element.triggerHandler("selectableunselecting", [e, {
2388
selectable: self.element[0],
2389
unselecting: selectee.element,
2391
}], options.unselecting);
2399
_mouseStop: function(e) {
2402
this.dragged = false;
2404
var options = this.options;
2406
$('.ui-unselecting', this.element[0]).each(function() {
2407
var selectee = $.data(this, "selectable-item");
2408
selectee.$element.removeClass('ui-unselecting');
2409
selectee.unselecting = false;
2410
selectee.startselected = false;
2411
self.element.triggerHandler("selectableunselected", [e, {
2412
selectable: self.element[0],
2413
unselected: selectee.element,
2415
}], options.unselected);
2417
$('.ui-selecting', this.element[0]).each(function() {
2418
var selectee = $.data(this, "selectable-item");
2419
selectee.$element.removeClass('ui-selecting').addClass('ui-selected');
2420
selectee.selecting = false;
2421
selectee.selected = true;
2422
selectee.startselected = true;
2423
self.element.triggerHandler("selectableselected", [e, {
2424
selectable: self.element[0],
2425
selected: selectee.element,
2427
}], options.selected);
2429
this.element.triggerHandler("selectablestop", [e, {
2430
selectable: self.element[0],
2431
options: this.options
2432
}], this.options.stop);
2434
this.helper.remove();
2440
$.extend($.ui.selectable, {
2454
* jQuery UI Sortable @VERSION
2456
* Copyright (c) 2008 Paul Bakaus
2457
* Dual licensed under the MIT (MIT-LICENSE.txt)
2458
* and GPL (GPL-LICENSE.txt) licenses.
2460
* http://docs.jquery.com/UI/Sortables
2467
function contains(a, b) {
2468
var safari2 = $.browser.safari && $.browser.version < 522;
2469
if (a.contains && !safari2) {
2470
return a.contains(b);
2472
if (a.compareDocumentPosition)
2473
return !!(a.compareDocumentPosition(b) & 16);
2474
while (b = b.parentNode)
2475
if (b == a) return true;
2479
$.widget("ui.sortable", $.extend({}, $.ui.mouse, {
2482
var o = this.options;
2483
this.containerCache = {};
2484
this.element.addClass("ui-sortable");
2489
//Let's determine if the items are floating
2490
this.floating = this.items.length ? (/left|right/).test(this.items[0].item.css('float')) : false;
2492
//Let's determine the parent's offset
2493
this.offset = this.element.offset();
2495
//Initialize mouse events for interaction
2500
ui: function(inst) {
2502
helper: (inst || this)["helper"],
2503
placeholder: (inst || this)["placeholder"] || $([]),
2504
position: (inst || this)["position"],
2505
absolutePosition: (inst || this)["positionAbs"],
2506
options: this.options,
2507
element: this.element,
2508
item: (inst || this)["currentItem"],
2509
sender: inst ? inst.element : null
2513
_propagate: function(n,e,inst, noPropagation) {
2514
$.ui.plugin.call(this, n, [e, this.ui(inst)]);
2515
if(!noPropagation) this.element.triggerHandler(n == "sort" ? n : "sort"+n, [e, this.ui(inst)], this.options[n]);
2518
serialize: function(o) {
2520
var items = this._getItemsAsjQuery(o && o.connected);
2521
var str = []; o = o || {};
2523
$(items).each(function() {
2524
var res = ($(this.item || this).attr(o.attribute || 'id') || '').match(o.expression || (/(.+)[-=_](.+)/));
2525
if(res) str.push((o.key || res[1]+'[]')+'='+(o.key && o.expression ? res[1] : res[2]));
2528
return str.join('&');
2532
toArray: function(o) {
2534
var items = this._getItemsAsjQuery(o && o.connected);
2537
items.each(function() { ret.push($(this).attr(o.attr || 'id')); });
2542
/* Be careful with the following core functions */
2543
_intersectsWith: function(item) {
2544
var x1 = this.positionAbs.left, x2 = x1 + this.helperProportions.width,
2545
y1 = this.positionAbs.top, y2 = y1 + this.helperProportions.height;
2546
var l = item.left, r = l + item.width,
2547
t = item.top, b = t + item.height;
2549
var dyClick = this.offset.click.top, dxClick = this.offset.click.left;
2550
var isOverElement = (y1 + dyClick) > t && (y1 + dyClick) < b && (x1 + dxClick) > l && (x1 + dxClick) < r;
2552
if(this.options.tolerance == "pointer" || this.options.forcePointerForContainers || (this.options.tolerance == "guess" && this.helperProportions[this.floating ? 'width' : 'height'] > item[this.floating ? 'width' : 'height'])) {
2553
return isOverElement;
2556
return (l < x1 + (this.helperProportions.width / 2) // Right Half
2557
&& x2 - (this.helperProportions.width / 2) < r // Left Half
2558
&& t < y1 + (this.helperProportions.height / 2) // Bottom Half
2559
&& y2 - (this.helperProportions.height / 2) < b ); // Top Half
2564
_intersectsWithEdge: function(item) {
2565
var x1 = this.positionAbs.left, x2 = x1 + this.helperProportions.width,
2566
y1 = this.positionAbs.top, y2 = y1 + this.helperProportions.height;
2568
var l = item.left, r = l + item.width,
2569
t = item.top, b = t + item.height;
2571
var dyClick = this.offset.click.top, dxClick = this.offset.click.left;
2572
var isOverElement = (y1 + dyClick) > t && (y1 + dyClick) < b && (x1 + dxClick) > l && (x1 + dxClick) < r;
2574
if(this.options.tolerance == "pointer" || (this.options.tolerance == "guess" && this.helperProportions[this.floating ? 'width' : 'height'] > item[this.floating ? 'width' : 'height'])) {
2575
if(!isOverElement) return false;
2578
if ((x1 + dxClick) > l && (x1 + dxClick) < l + item.width/2) return 2;
2579
if ((x1 + dxClick) > l + item.width/2 && (x1 + dxClick) < r) return 1;
2581
var height = item.height;
2582
var direction = y1 - this.updateOriginalPosition.top < 0 ? 2 : 1; // 2 = up
2584
if (direction == 1 && (y1 + dyClick) < t + height/2) { return 2; } // up
2585
else if (direction == 2 && (y1 + dyClick) > t + height/2) { return 1; } // down
2589
if (!(l < x1 + (this.helperProportions.width / 2) // Right Half
2590
&& x2 - (this.helperProportions.width / 2) < r // Left Half
2591
&& t < y1 + (this.helperProportions.height / 2) // Bottom Half
2592
&& y2 - (this.helperProportions.height / 2) < b )) return false; // Top Half
2595
if(x2 > l && x1 < l) return 2; //Crosses left edge
2596
if(x1 < r && x2 > r) return 1; //Crosses right edge
2598
if(y2 > t && y1 < t) return 1; //Crosses top edge
2599
if(y1 < b && y2 > b) return 2; //Crosses bottom edge
2607
refresh: function() {
2608
this._refreshItems();
2609
this.refreshPositions();
2612
_getItemsAsjQuery: function(connected) {
2618
if(this.options.connectWith && connected) {
2619
for (var i = this.options.connectWith.length - 1; i >= 0; i--){
2620
var cur = $(this.options.connectWith[i]);
2621
for (var j = cur.length - 1; j >= 0; j--){
2622
var inst = $.data(cur[j], 'sortable');
2623
if(inst && inst != this && !inst.options.disabled) {
2624
queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element) : $(inst.options.items, inst.element).not(".ui-sortable-helper"), inst]);
2630
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(".ui-sortable-helper"), this]);
2632
for (var i = queries.length - 1; i >= 0; i--){
2633
queries[i][0].each(function() {
2642
_removeCurrentsFromItems: function() {
2644
var list = this.currentItem.find(":data(sortable-item)");
2646
for (var i=0; i < this.items.length; i++) {
2648
for (var j=0; j < list.length; j++) {
2649
if(list[j] == this.items[i].item[0])
2650
this.items.splice(i,1);
2657
_refreshItems: function() {
2660
this.containers = [this];
2661
var items = this.items;
2663
var queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element, null, { options: this.options, item: this.currentItem }) : $(this.options.items, this.element), this]];
2665
if(this.options.connectWith) {
2666
for (var i = this.options.connectWith.length - 1; i >= 0; i--){
2667
var cur = $(this.options.connectWith[i]);
2668
for (var j = cur.length - 1; j >= 0; j--){
2669
var inst = $.data(cur[j], 'sortable');
2670
if(inst && inst != this && !inst.options.disabled) {
2671
queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element) : $(inst.options.items, inst.element), inst]);
2672
this.containers.push(inst);
2678
for (var i = queries.length - 1; i >= 0; i--){
2679
queries[i][0].each(function() {
2680
$.data(this, 'sortable-item', queries[i][1]); // Data for target checking (mouse manager)
2683
instance: queries[i][1],
2684
width: 0, height: 0,
2692
refreshPositions: function(fast) {
2694
//This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change
2695
if(this.offsetParent) {
2696
var po = this.offsetParent.offset();
2697
this.offset.parent = { top: po.top + this.offsetParentBorders.top, left: po.left + this.offsetParentBorders.left };
2700
for (var i = this.items.length - 1; i >= 0; i--){
2702
//We ignore calculating positions of all connected containers when we're not over them
2703
if(this.items[i].instance != this.currentContainer && this.currentContainer && this.items[i].item[0] != this.currentItem[0])
2706
var t = this.options.toleranceElement ? $(this.options.toleranceElement, this.items[i].item) : this.items[i].item;
2709
this.items[i].width = t[0].offsetWidth;
2710
this.items[i].height = t[0].offsetHeight;
2714
this.items[i].left = p.left;
2715
this.items[i].top = p.top;
2719
if(this.options.custom && this.options.custom.refreshContainers) {
2720
this.options.custom.refreshContainers.call(this);
2722
for (var i = this.containers.length - 1; i >= 0; i--){
2723
var p =this.containers[i].element.offset();
2724
this.containers[i].containerCache.left = p.left;
2725
this.containers[i].containerCache.top = p.top;
2726
this.containers[i].containerCache.width = this.containers[i].element.outerWidth();
2727
this.containers[i].containerCache.height = this.containers[i].element.outerHeight();
2733
destroy: function() {
2735
.removeClass("ui-sortable ui-sortable-disabled")
2736
.removeData("sortable")
2737
.unbind(".sortable");
2738
this._mouseDestroy();
2740
for ( var i = this.items.length - 1; i >= 0; i-- )
2741
this.items[i].item.removeData("sortable-item");
2744
_createPlaceholder: function(that) {
2746
var self = that || this, o = self.options;
2748
if(!o.placeholder || o.placeholder.constructor == String) {
2749
var className = o.placeholder;
2751
element: function() {
2752
var el = $(document.createElement(self.currentItem[0].nodeName)).addClass(className || "ui-sortable-placeholder")[0];
2755
el.style.visibility = "hidden";
2756
document.body.appendChild(el);
2757
el.innerHTML = self.currentItem[0].innerHTML;
2758
document.body.removeChild(el);
2763
update: function(container, p) {
2764
if(className && !o.forcePlaceholderSize) return;
2765
if(!p.height()) { p.height(self.currentItem.innerHeight() - parseInt(self.currentItem.css('paddingTop')||0, 10) - parseInt(self.currentItem.css('paddingBottom')||0, 10)); };
2766
if(!p.width()) { p.width(self.currentItem.innerWidth() - parseInt(self.currentItem.css('paddingLeft')||0, 10) - parseInt(self.currentItem.css('paddingRight')||0, 10)); };
2771
self.placeholder = $(o.placeholder.element.call(self.element, self.currentItem))
2772
self.currentItem.parent()[0].appendChild(self.placeholder[0]);
2773
self.placeholder[0].parentNode.insertBefore(self.placeholder[0], self.currentItem[0]);
2774
o.placeholder.update(self, self.placeholder);
2777
_contactContainers: function(e) {
2778
for (var i = this.containers.length - 1; i >= 0; i--){
2780
if(this._intersectsWith(this.containers[i].containerCache)) {
2781
if(!this.containers[i].containerCache.over) {
2784
if(this.currentContainer != this.containers[i]) {
2786
//When entering a new container, we will find the item with the least distance and append our item near it
2787
var dist = 10000; var itemWithLeastDistance = null; var base = this.positionAbs[this.containers[i].floating ? 'left' : 'top'];
2788
for (var j = this.items.length - 1; j >= 0; j--) {
2789
if(!contains(this.containers[i].element[0], this.items[j].item[0])) continue;
2790
var cur = this.items[j][this.containers[i].floating ? 'left' : 'top'];
2791
if(Math.abs(cur - base) < dist) {
2792
dist = Math.abs(cur - base); itemWithLeastDistance = this.items[j];
2796
if(!itemWithLeastDistance && !this.options.dropOnEmpty) //Check if dropOnEmpty is enabled
2799
this.currentContainer = this.containers[i];
2800
itemWithLeastDistance ? this.options.sortIndicator.call(this, e, itemWithLeastDistance, null, true) : this.options.sortIndicator.call(this, e, null, this.containers[i].element, true);
2801
this._propagate("change", e); //Call plugins and callbacks
2802
this.containers[i]._propagate("change", e, this); //Call plugins and callbacks
2804
//Update the placeholder
2805
this.options.placeholder.update(this.currentContainer, this.placeholder);
2809
this.containers[i]._propagate("over", e, this);
2810
this.containers[i].containerCache.over = 1;
2813
if(this.containers[i].containerCache.over) {
2814
this.containers[i]._propagate("out", e, this);
2815
this.containers[i].containerCache.over = 0;
2822
_mouseCapture: function(e, overrideHandle) {
2824
if(this.options.disabled || this.options.type == 'static') return false;
2826
//We have to refresh the items data once first
2827
this._refreshItems();
2829
//Find out if the clicked node (or one of its parents) is a actual item in this.items
2830
var currentItem = null, self = this, nodes = $(e.target).parents().each(function() {
2831
if($.data(this, 'sortable-item') == self) {
2832
currentItem = $(this);
2836
if($.data(e.target, 'sortable-item') == self) currentItem = $(e.target);
2838
if(!currentItem) return false;
2839
if(this.options.handle && !overrideHandle) {
2840
var validHandle = false;
2842
$(this.options.handle, currentItem).find("*").andSelf().each(function() { if(this == e.target) validHandle = true; });
2843
if(!validHandle) return false;
2846
this.currentItem = currentItem;
2847
this._removeCurrentsFromItems();
2852
createHelper: function(e) {
2854
var o = this.options;
2855
var helper = typeof o.helper == 'function' ? $(o.helper.apply(this.element[0], [e, this.currentItem])) : (o.helper == "original" ? this.currentItem : this.currentItem.clone());
2857
if (!helper.parents('body').length)
2858
$(o.appendTo != 'parent' ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]); //Add the helper to the DOM if that didn't happen already
2864
_mouseStart: function(e, overrideHandle, noActivation) {
2866
var o = this.options;
2867
this.currentContainer = this;
2869
//We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture
2870
this.refreshPositions();
2872
//Create and append the visible helper
2873
this.helper = this.createHelper(e);
2876
* - Position generation -
2877
* This block generates everything position related - it's the core of draggables.
2880
this.margins = { //Cache the margins
2881
left: (parseInt(this.currentItem.css("marginLeft"),10) || 0),
2882
top: (parseInt(this.currentItem.css("marginTop"),10) || 0)
2885
this.offset = this.currentItem.offset(); //The element's absolute position on the page
2886
this.offset = { //Substract the margins from the element's absolute offset
2887
top: this.offset.top - this.margins.top,
2888
left: this.offset.left - this.margins.left
2891
this.offset.click = { //Where the click happened, relative to the element
2892
left: e.pageX - this.offset.left,
2893
top: e.pageY - this.offset.top
2896
this.offsetParent = this.helper.offsetParent(); //Get the offsetParent and cache its position
2897
var po = this.offsetParent.offset();
2899
this.offsetParentBorders = {
2900
top: (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
2901
left: (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
2904
this.offset.parent = { //Store its position plus border
2905
top: po.top + this.offsetParentBorders.top,
2906
left: po.left + this.offsetParentBorders.left
2909
this.updateOriginalPosition = this.originalPosition = this._generatePosition(e); //Generate the original position
2910
this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] }; //Cache the former DOM position
2912
//If o.placeholder is used, create a new element at the given position with the class
2913
this.helperProportions = { width: this.helper.outerWidth(), height: this.helper.outerHeight() };//Cache the helper size
2916
if(o.helper == "original") {
2917
this._storedCSS = { position: this.currentItem.css("position"), top: this.currentItem.css("top"), left: this.currentItem.css("left"), clear: this.currentItem.css("clear") };
2919
this.currentItem.hide(); //Hide the original, won't cause anything bad this way
2922
//Position it absolutely and add a helper class
2924
.css({ position: 'absolute', clear: 'both' })
2925
.addClass('ui-sortable-helper');
2927
//Create the placeholder
2928
this._createPlaceholder();
2930
//Call plugins and callbacks
2931
this._propagate("start", e);
2933
//Recache the helper size
2934
if(!this._preserveHelperProportions)
2935
this.helperProportions = { width: this.helper.outerWidth(), height: this.helper.outerHeight() };
2938
if(o.cursorAt.left != undefined) this.offset.click.left = o.cursorAt.left;
2939
if(o.cursorAt.right != undefined) this.offset.click.left = this.helperProportions.width - o.cursorAt.right;
2940
if(o.cursorAt.top != undefined) this.offset.click.top = o.cursorAt.top;
2941
if(o.cursorAt.bottom != undefined) this.offset.click.top = this.helperProportions.height - o.cursorAt.bottom;
2945
* - Position constraining -
2946
* Here we prepare position constraining like grid and containment.
2950
if(o.containment == 'parent') o.containment = this.helper[0].parentNode;
2951
if(o.containment == 'document' || o.containment == 'window') this.containment = [
2952
0 - this.offset.parent.left,
2953
0 - this.offset.parent.top,
2954
$(o.containment == 'document' ? document : window).width() - this.offset.parent.left - this.helperProportions.width - this.margins.left - (parseInt(this.element.css("marginRight"),10) || 0),
2955
($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.offset.parent.top - this.helperProportions.height - this.margins.top - (parseInt(this.element.css("marginBottom"),10) || 0)
2958
if(!(/^(document|window|parent)$/).test(o.containment)) {
2959
var ce = $(o.containment)[0];
2960
var co = $(o.containment).offset();
2961
var over = ($(ce).css("overflow") != 'hidden');
2963
this.containment = [
2964
co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) - this.offset.parent.left,
2965
co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) - this.offset.parent.top,
2966
co.left+(over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - this.offset.parent.left - this.helperProportions.width - this.margins.left - (parseInt(this.currentItem.css("marginRight"),10) || 0),
2967
co.top+(over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - this.offset.parent.top - this.helperProportions.height - this.margins.top - (parseInt(this.currentItem.css("marginBottom"),10) || 0)
2972
//Post 'activate' events to possible containers
2974
for (var i = this.containers.length - 1; i >= 0; i--) { this.containers[i]._propagate("activate", e, this); }
2977
//Prepare possible droppables
2979
$.ui.ddmanager.current = this;
2981
if ($.ui.ddmanager && !o.dropBehaviour)
2982
$.ui.ddmanager.prepareOffsets(this, e);
2984
this.dragging = true;
2986
this._mouseDrag(e); //Execute the drag once - this causes the helper not to be visible before getting its correct position
2992
_convertPositionTo: function(d, pos) {
2993
if(!pos) pos = this.position;
2994
var mod = d == "absolute" ? 1 : -1;
2997
pos.top // the calculated relative position
2998
+ this.offset.parent.top * mod // The offsetParent's offset without borders (offset + border)
2999
- (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollTop) * mod // The offsetParent's scroll position
3000
+ this.margins.top * mod //Add the margin (you don't want the margin counting in intersection methods)
3003
pos.left // the calculated relative position
3004
+ this.offset.parent.left * mod // The offsetParent's offset without borders (offset + border)
3005
- (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollLeft) * mod // The offsetParent's scroll position
3006
+ this.margins.left * mod //Add the margin (you don't want the margin counting in intersection methods)
3011
_generatePosition: function(e) {
3013
var o = this.options;
3016
e.pageY // The absolute mouse position
3017
- this.offset.click.top // Click offset (relative to the element)
3018
- this.offset.parent.top // The offsetParent's offset without borders (offset + border)
3019
+ (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollTop) // The offsetParent's scroll position, not if the element is fixed
3022
e.pageX // The absolute mouse position
3023
- this.offset.click.left // Click offset (relative to the element)
3024
- this.offset.parent.left // The offsetParent's offset without borders (offset + border)
3025
+ (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollLeft) // The offsetParent's scroll position, not if the element is fixed
3029
if(!this.originalPosition) return position; //If we are not dragging yet, we won't check for options
3032
* - Position constraining -
3033
* Constrain the position to a mix of grid, containment.
3035
if(this.containment) {
3036
if(position.left < this.containment[0]) position.left = this.containment[0];
3037
if(position.top < this.containment[1]) position.top = this.containment[1];
3038
if(position.left > this.containment[2]) position.left = this.containment[2];
3039
if(position.top > this.containment[3]) position.top = this.containment[3];
3043
var top = this.originalPosition.top + Math.round((position.top - this.originalPosition.top) / o.grid[1]) * o.grid[1];
3044
position.top = this.containment ? (!(top < this.containment[1] || top > this.containment[3]) ? top : (!(top < this.containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
3046
var left = this.originalPosition.left + Math.round((position.left - this.originalPosition.left) / o.grid[0]) * o.grid[0];
3047
position.left = this.containment ? (!(left < this.containment[0] || left > this.containment[2]) ? left : (!(left < this.containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
3053
_mouseDrag: function(e) {
3055
//Compute the helpers position
3056
this.position = this._generatePosition(e);
3057
this.positionAbs = this._convertPositionTo("absolute");
3059
//Call the internal plugins
3060
$.ui.plugin.call(this, "sort", [e, this.ui()]);
3062
//Regenerate the absolute position used for position checks
3063
this.positionAbs = this._convertPositionTo("absolute");
3065
//Set the helper's position
3066
this.helper[0].style.left = this.position.left+'px';
3067
this.helper[0].style.top = this.position.top+'px';
3070
for (var i = this.items.length - 1; i >= 0; i--) {
3071
var intersection = this._intersectsWithEdge(this.items[i]);
3072
if(!intersection) continue;
3074
if(this.items[i].item[0] != this.currentItem[0] //cannot intersect with itself
3075
&& this.placeholder[intersection == 1 ? "next" : "prev"]()[0] != this.items[i].item[0] //no useless actions that have been done before
3076
&& !contains(this.placeholder[0], this.items[i].item[0]) //no action if the item moved is the parent of the item checked
3077
&& (this.options.type == 'semi-dynamic' ? !contains(this.element[0], this.items[i].item[0]) : true)
3080
this.updateOriginalPosition = this._generatePosition(e);
3082
this.direction = intersection == 1 ? "down" : "up";
3083
this.options.sortIndicator.call(this, e, this.items[i]);
3084
this._propagate("change", e); //Call plugins and callbacks
3089
//Post events to containers
3090
this._contactContainers(e);
3092
//Interconnect with droppables
3093
if($.ui.ddmanager) $.ui.ddmanager.drag(this, e);
3096
this.element.triggerHandler("sort", [e, this.ui()], this.options["sort"]);
3102
_rearrange: function(e, i, a, hardRefresh) {
3104
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));
3106
//Various things done here to improve the performance:
3107
// 1. we create a setTimeout, that calls refreshPositions
3108
// 2. on the instance, we have a counter variable, that get's higher after every append
3109
// 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same
3110
// 4. this lets only the last addition to the timeout stack through
3111
this.counter = this.counter ? ++this.counter : 1;
3112
var self = this, counter = this.counter;
3114
window.setTimeout(function() {
3115
if(counter == self.counter) self.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove
3120
_mouseStop: function(e, noPropagation) {
3122
//If we are using droppables, inform the manager about the drop
3123
if ($.ui.ddmanager && !this.options.dropBehaviour)
3124
$.ui.ddmanager.drop(this, e);
3126
if(this.options.revert) {
3128
var cur = self.placeholder.offset();
3130
$(this.helper).animate({
3131
left: cur.left - this.offset.parent.left - self.margins.left + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollLeft),
3132
top: cur.top - this.offset.parent.top - self.margins.top + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollTop)
3133
}, parseInt(this.options.revert, 10) || 500, function() {
3137
this._clear(e, noPropagation);
3144
_clear: function(e, noPropagation) {
3146
//We first have to update the dom position of the actual currentItem
3147
if(!this._noFinalSort) this.placeholder.before(this.currentItem);
3148
this._noFinalSort = null;
3150
if(this.options.helper == "original")
3151
this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
3153
this.currentItem.show();
3155
if(this.domPosition.prev != this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent != this.currentItem.parent()[0]) this._propagate("update", e, null, noPropagation); //Trigger update callback if the DOM position has changed
3156
if(!contains(this.element[0], this.currentItem[0])) { //Node was moved out of the current element
3157
this._propagate("remove", e, null, noPropagation);
3158
for (var i = this.containers.length - 1; i >= 0; i--){
3159
if(contains(this.containers[i].element[0], this.currentItem[0])) {
3160
this.containers[i]._propagate("update", e, this, noPropagation);
3161
this.containers[i]._propagate("receive", e, this, noPropagation);
3166
//Post events to containers
3167
for (var i = this.containers.length - 1; i >= 0; i--){
3168
this.containers[i]._propagate("deactivate", e, this, noPropagation);
3169
if(this.containers[i].containerCache.over) {
3170
this.containers[i]._propagate("out", e, this);
3171
this.containers[i].containerCache.over = 0;
3175
this.dragging = false;
3176
if(this.cancelHelperRemoval) {
3177
this._propagate("beforeStop", e, null, noPropagation);
3178
this._propagate("stop", e, null, noPropagation);
3182
this._propagate("beforeStop", e, null, noPropagation);
3184
this.placeholder.remove();
3185
if(this.options.helper != "original") this.helper.remove(); this.helper = null;
3186
this._propagate("stop", e, null, noPropagation);
3193
$.extend($.ui.sortable, {
3194
getter: "serialize toArray",
3201
scrollSensitivity: 20,
3208
sortIndicator: $.ui.sortable.prototype._rearrange,
3210
forcePlaceholderSize: false
3215
* Sortable Extensions
3218
$.ui.plugin.add("sortable", "cursor", {
3219
start: function(e, ui) {
3221
if (t.css("cursor")) ui.options._cursor = t.css("cursor");
3222
t.css("cursor", ui.options.cursor);
3224
beforeStop: function(e, ui) {
3225
if (ui.options._cursor) $('body').css("cursor", ui.options._cursor);
3229
$.ui.plugin.add("sortable", "zIndex", {
3230
start: function(e, ui) {
3232
if(t.css("zIndex")) ui.options._zIndex = t.css("zIndex");
3233
t.css('zIndex', ui.options.zIndex);
3235
beforeStop: function(e, ui) {
3236
if(ui.options._zIndex) $(ui.helper).css('zIndex', ui.options._zIndex);
3240
$.ui.plugin.add("sortable", "opacity", {
3241
start: function(e, ui) {
3243
if(t.css("opacity")) ui.options._opacity = t.css("opacity");
3244
t.css('opacity', ui.options.opacity);
3246
beforeStop: function(e, ui) {
3247
if(ui.options._opacity) $(ui.helper).css('opacity', ui.options._opacity);
3251
$.ui.plugin.add("sortable", "scroll", {
3252
start: function(e, ui) {
3254
var i = $(this).data("sortable");
3256
i.overflowY = function(el) {
3257
do { if(/auto|scroll/.test(el.css('overflow')) || (/auto|scroll/).test(el.css('overflow-y'))) return el; el = el.parent(); } while (el[0].parentNode);
3260
i.overflowX = function(el) {
3261
do { if(/auto|scroll/.test(el.css('overflow')) || (/auto|scroll/).test(el.css('overflow-x'))) return el; el = el.parent(); } while (el[0].parentNode);
3265
if(i.overflowY[0] != document && i.overflowY[0].tagName != 'HTML') i.overflowYOffset = i.overflowY.offset();
3266
if(i.overflowX[0] != document && i.overflowX[0].tagName != 'HTML') i.overflowXOffset = i.overflowX.offset();
3269
sort: function(e, ui) {
3272
var i = $(this).data("sortable");
3274
if(i.overflowY[0] != document && i.overflowY[0].tagName != 'HTML') {
3275
if((i.overflowYOffset.top + i.overflowY[0].offsetHeight) - e.pageY < o.scrollSensitivity)
3276
i.overflowY[0].scrollTop = i.overflowY[0].scrollTop + o.scrollSpeed;
3277
if(e.pageY - i.overflowYOffset.top < o.scrollSensitivity)
3278
i.overflowY[0].scrollTop = i.overflowY[0].scrollTop - o.scrollSpeed;
3280
if(e.pageY - $(document).scrollTop() < o.scrollSensitivity)
3281
$(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
3282
if($(window).height() - (e.pageY - $(document).scrollTop()) < o.scrollSensitivity)
3283
$(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
3286
if(i.overflowX[0] != document && i.overflowX[0].tagName != 'HTML') {
3287
if((i.overflowXOffset.left + i.overflowX[0].offsetWidth) - e.pageX < o.scrollSensitivity)
3288
i.overflowX[0].scrollLeft = i.overflowX[0].scrollLeft + o.scrollSpeed;
3289
if(e.pageX - i.overflowXOffset.left < o.scrollSensitivity)
3290
i.overflowX[0].scrollLeft = i.overflowX[0].scrollLeft - o.scrollSpeed;
3292
if(e.pageX - $(document).scrollLeft() < o.scrollSensitivity)
3293
$(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
3294
if($(window).width() - (e.pageX - $(document).scrollLeft()) < o.scrollSensitivity)
3295
$(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
3301
$.ui.plugin.add("sortable", "axis", {
3302
sort: function(e, ui) {
3304
var i = $(this).data("sortable");
3306
if(ui.options.axis == "y") i.position.left = i.originalPosition.left;
3307
if(ui.options.axis == "x") i.position.top = i.originalPosition.top;
3314
* jQuery UI Effects @VERSION
3316
* Copyright (c) 2008 Aaron Eisenberger (aaronchi@gmail.com)
3317
* Dual licensed under the MIT (MIT-LICENSE.txt)
3318
* and GPL (GPL-LICENSE.txt) licenses.
3320
* http://docs.jquery.com/UI/Effects/
3324
$.effects = $.effects || {}; //Add the 'effects' scope
3326
$.extend($.effects, {
3327
save: function(el, set) {
3328
for(var i=0;i<set.length;i++) {
3329
if(set[i] !== null) $.data(el[0], "ec.storage."+set[i], el[0].style[set[i]]);
3332
restore: function(el, set) {
3333
for(var i=0;i<set.length;i++) {
3334
if(set[i] !== null) el.css(set[i], $.data(el[0], "ec.storage."+set[i]));
3337
setMode: function(el, mode) {
3338
if (mode == 'toggle') mode = el.is(':hidden') ? 'show' : 'hide'; // Set for toggle
3341
getBaseline: function(origin, original) { // Translates a [top,left] array into a baseline value
3342
// this should be a little more flexible in the future to handle a string & hash
3344
switch (origin[0]) {
3345
case 'top': y = 0; break;
3346
case 'middle': y = 0.5; break;
3347
case 'bottom': y = 1; break;
3348
default: y = origin[0] / original.height;
3350
switch (origin[1]) {
3351
case 'left': x = 0; break;
3352
case 'center': x = 0.5; break;
3353
case 'right': x = 1; break;
3354
default: x = origin[1] / original.width;
3356
return {x: x, y: y};
3358
createWrapper: function(el) {
3359
if (el.parent().attr('id') == 'fxWrapper')
3361
var props = {width: el.outerWidth({margin:true}), height: el.outerHeight({margin:true}), 'float': el.css('float')};
3362
el.wrap('<div id="fxWrapper" style="font-size:100%;background:transparent;border:none;margin:0;padding:0"></div>');
3363
var wrapper = el.parent();
3364
if (el.css('position') == 'static'){
3365
wrapper.css({position: 'relative'});
3366
el.css({position: 'relative'});
3368
var top = el.css('top'); if(isNaN(parseInt(top))) top = 'auto';
3369
var left = el.css('left'); if(isNaN(parseInt(left))) left = 'auto';
3370
wrapper.css({ position: el.css('position'), top: top, left: left, zIndex: el.css('z-index') }).show();
3371
el.css({position: 'relative', top:0, left:0});
3376
removeWrapper: function(el) {
3377
if (el.parent().attr('id') == 'fxWrapper')
3378
return el.parent().replaceWith(el);
3381
setTransition: function(el, list, factor, val) {
3383
$.each(list,function(i, x){
3384
unit = el.cssUnit(x);
3385
if (unit[0] > 0) val[x] = unit[0] * factor + unit[1];
3389
animateClass: function(value, duration, easing, callback) {
3391
var cb = (typeof easing == "function" ? easing : (callback ? callback : null));
3392
var ea = (typeof easing == "object" ? easing : null);
3394
return this.each(function() {
3396
var offset = {}; var that = $(this); var oldStyleAttr = that.attr("style") || '';
3397
if(typeof oldStyleAttr == 'object') oldStyleAttr = oldStyleAttr["cssText"]; /* Stupidly in IE, style is a object.. */
3398
if(value.toggle) { that.hasClass(value.toggle) ? value.remove = value.toggle : value.add = value.toggle; }
3400
//Let's get a style offset
3401
var oldStyle = $.extend({}, (document.defaultView ? document.defaultView.getComputedStyle(this,null) : this.currentStyle));
3402
if(value.add) that.addClass(value.add); if(value.remove) that.removeClass(value.remove);
3403
var newStyle = $.extend({}, (document.defaultView ? document.defaultView.getComputedStyle(this,null) : this.currentStyle));
3404
if(value.add) that.removeClass(value.add); if(value.remove) that.addClass(value.remove);
3406
// The main function to form the object for animation
3407
for(var n in newStyle) {
3408
if( typeof newStyle[n] != "function" && newStyle[n] /* No functions and null properties */
3409
&& n.indexOf("Moz") == -1 && n.indexOf("length") == -1 /* No mozilla spezific render properties. */
3410
&& newStyle[n] != oldStyle[n] /* Only values that have changed are used for the animation */
3411
&& (n.match(/color/i) || (!n.match(/color/i) && !isNaN(parseInt(newStyle[n],10)))) /* Only things that can be parsed to integers or colors */
3412
&& (oldStyle.position != "static" || (oldStyle.position == "static" && !n.match(/left|top|bottom|right/))) /* No need for positions when dealing with static positions */
3413
) offset[n] = newStyle[n];
3416
that.animate(offset, duration, ea, function() { // Animate the newly constructed offset object
3417
// Change style attribute back to original. For stupid IE, we need to clear the damn object.
3418
if(typeof $(this).attr("style") == 'object') { $(this).attr("style")["cssText"] = ""; $(this).attr("style")["cssText"] = oldStyleAttr; } else $(this).attr("style", oldStyleAttr);
3419
if(value.add) $(this).addClass(value.add); if(value.remove) $(this).removeClass(value.remove);
3420
if(cb) cb.apply(this, arguments);
3427
//Extend the methods of jQuery
3432
__toggle: $.fn.toggle,
3433
_addClass: $.fn.addClass,
3434
_removeClass: $.fn.removeClass,
3435
_toggleClass: $.fn.toggleClass,
3437
effect: function(fx,o,speed,callback) {
3438
return $.effects[fx] ? $.effects[fx].call(this, {method: fx, options: o || {}, duration: speed, callback: callback }) : null;
3441
if(!arguments[0] || (arguments[0].constructor == Number || /(slow|normal|fast)/.test(arguments[0])))
3442
return this._show.apply(this, arguments);
3444
var o = arguments[1] || {}; o['mode'] = 'show';
3445
return this.effect.apply(this, [arguments[0], o, arguments[2] || o.duration, arguments[3] || o.callback]);
3449
if(!arguments[0] || (arguments[0].constructor == Number || /(slow|normal|fast)/.test(arguments[0])))
3450
return this._hide.apply(this, arguments);
3452
var o = arguments[1] || {}; o['mode'] = 'hide';
3453
return this.effect.apply(this, [arguments[0], o, arguments[2] || o.duration, arguments[3] || o.callback]);
3457
if(!arguments[0] || (arguments[0].constructor == Number || /(slow|normal|fast)/.test(arguments[0])) || (arguments[0].constructor == Function))
3458
return this.__toggle.apply(this, arguments);
3460
var o = arguments[1] || {}; o['mode'] = 'toggle';
3461
return this.effect.apply(this, [arguments[0], o, arguments[2] || o.duration, arguments[3] || o.callback]);
3464
addClass: function(classNames,speed,easing,callback) {
3465
return speed ? $.effects.animateClass.apply(this, [{ add: classNames },speed,easing,callback]) : this._addClass(classNames);
3467
removeClass: function(classNames,speed,easing,callback) {
3468
return speed ? $.effects.animateClass.apply(this, [{ remove: classNames },speed,easing,callback]) : this._removeClass(classNames);
3470
toggleClass: function(classNames,speed,easing,callback) {
3471
return speed ? $.effects.animateClass.apply(this, [{ toggle: classNames },speed,easing,callback]) : this._toggleClass(classNames);
3473
morph: function(remove,add,speed,easing,callback) {
3474
return $.effects.animateClass.apply(this, [{ add: add, remove: remove },speed,easing,callback]);
3476
switchClass: function() {
3477
return this.morph.apply(this, arguments);
3480
cssUnit: function(key) {
3481
var style = this.css(key), val = [];
3482
$.each( ['em','px','%','pt'], function(i, unit){
3483
if(style.indexOf(unit) > 0)
3484
val = [parseFloat(style), unit];
3491
* jQuery Color Animations
3492
* Copyright 2007 John Resig
3493
* Released under the MIT and GPL licenses.
3496
// We override the animation for all of these color styles
3497
jQuery.each(['backgroundColor', 'borderBottomColor', 'borderLeftColor', 'borderRightColor', 'borderTopColor', 'color', 'outlineColor'], function(i,attr){
3498
jQuery.fx.step[attr] = function(fx){
3499
if ( fx.state == 0 ) {
3500
fx.start = getColor( fx.elem, attr );
3501
fx.end = getRGB( fx.end );
3504
fx.elem.style[attr] = "rgb(" + [
3505
Math.max(Math.min( parseInt((fx.pos * (fx.end[0] - fx.start[0])) + fx.start[0]), 255), 0),
3506
Math.max(Math.min( parseInt((fx.pos * (fx.end[1] - fx.start[1])) + fx.start[1]), 255), 0),
3507
Math.max(Math.min( parseInt((fx.pos * (fx.end[2] - fx.start[2])) + fx.start[2]), 255), 0)
3512
// Color Conversion functions from highlightFade
3513
// By Blair Mitchelmore
3514
// http://jquery.offput.ca/highlightFade/
3516
// Parse strings looking for color tuples [255,255,255]
3517
function getRGB(color) {
3520
// Check if we're already dealing with an array of colors
3521
if ( color && color.constructor == Array && color.length == 3 )
3524
// Look for rgb(num,num,num)
3525
if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color))
3526
return [parseInt(result[1]), parseInt(result[2]), parseInt(result[3])];
3528
// Look for rgb(num%,num%,num%)
3529
if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color))
3530
return [parseFloat(result[1])*2.55, parseFloat(result[2])*2.55, parseFloat(result[3])*2.55];
3533
if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color))
3534
return [parseInt(result[1],16), parseInt(result[2],16), parseInt(result[3],16)];
3537
if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color))
3538
return [parseInt(result[1]+result[1],16), parseInt(result[2]+result[2],16), parseInt(result[3]+result[3],16)];
3540
// Look for rgba(0, 0, 0, 0) == transparent in Safari 3
3541
if (result = /rgba\(0, 0, 0, 0\)/.exec(color))
3542
return colors['transparent']
3544
// Otherwise, we're most likely dealing with a named color
3545
return colors[jQuery.trim(color).toLowerCase()];
3548
function getColor(elem, attr) {
3552
color = jQuery.curCSS(elem, attr);
3554
// Keep going until we find an element that has color, or we hit the body
3555
if ( color != '' && color != 'transparent' || jQuery.nodeName(elem, "body") )
3558
attr = "backgroundColor";
3559
} while ( elem = elem.parentNode );
3561
return getRGB(color);
3564
// Some named colors to work with
3565
// From Interface by Stefan Petre
3566
// http://interface.eyecon.ro/
3570
azure:[240,255,255],
3571
beige:[245,245,220],
3577
darkcyan:[0,139,139],
3578
darkgrey:[169,169,169],
3579
darkgreen:[0,100,0],
3580
darkkhaki:[189,183,107],
3581
darkmagenta:[139,0,139],
3582
darkolivegreen:[85,107,47],
3583
darkorange:[255,140,0],
3584
darkorchid:[153,50,204],
3586
darksalmon:[233,150,122],
3587
darkviolet:[148,0,211],
3588
fuchsia:[255,0,255],
3592
khaki:[240,230,140],
3593
lightblue:[173,216,230],
3594
lightcyan:[224,255,255],
3595
lightgreen:[144,238,144],
3596
lightgrey:[211,211,211],
3597
lightpink:[255,182,193],
3598
lightyellow:[255,255,224],
3600
magenta:[255,0,255],
3609
silver:[192,192,192],
3610
white:[255,255,255],
3612
transparent: [255,255,255]
3616
* jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
3618
* Uses the built in easing capabilities added In jQuery 1.1
3619
* to offer multiple easing options
3621
* TERMS OF USE - jQuery Easing
3623
* Open source under the BSD License.
3625
* Copyright © 2008 George McGinley Smith
3626
* All rights reserved.
3628
* Redistribution and use in source and binary forms, with or without modification,
3629
* are permitted provided that the following conditions are met:
3631
* Redistributions of source code must retain the above copyright notice, this list of
3632
* conditions and the following disclaimer.
3633
* Redistributions in binary form must reproduce the above copyright notice, this list
3634
* of conditions and the following disclaimer in the documentation and/or other materials
3635
* provided with the distribution.
3637
* Neither the name of the author nor the names of contributors may be used to endorse
3638
* or promote products derived from this software without specific prior written permission.
3640
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
3641
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
3642
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
3643
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
3644
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
3645
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
3646
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
3647
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
3648
* OF THE POSSIBILITY OF SUCH DAMAGE.
3652
// t: current time, b: begInnIng value, c: change In value, d: duration
3653
jQuery.easing['jswing'] = jQuery.easing['swing'];
3655
jQuery.extend( jQuery.easing,
3658
swing: function (x, t, b, c, d) {
3659
//alert(jQuery.easing.default);
3660
return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
3662
easeInQuad: function (x, t, b, c, d) {
3663
return c*(t/=d)*t + b;
3665
easeOutQuad: function (x, t, b, c, d) {
3666
return -c *(t/=d)*(t-2) + b;
3668
easeInOutQuad: function (x, t, b, c, d) {
3669
if ((t/=d/2) < 1) return c/2*t*t + b;
3670
return -c/2 * ((--t)*(t-2) - 1) + b;
3672
easeInCubic: function (x, t, b, c, d) {
3673
return c*(t/=d)*t*t + b;
3675
easeOutCubic: function (x, t, b, c, d) {
3676
return c*((t=t/d-1)*t*t + 1) + b;
3678
easeInOutCubic: function (x, t, b, c, d) {
3679
if ((t/=d/2) < 1) return c/2*t*t*t + b;
3680
return c/2*((t-=2)*t*t + 2) + b;
3682
easeInQuart: function (x, t, b, c, d) {
3683
return c*(t/=d)*t*t*t + b;
3685
easeOutQuart: function (x, t, b, c, d) {
3686
return -c * ((t=t/d-1)*t*t*t - 1) + b;
3688
easeInOutQuart: function (x, t, b, c, d) {
3689
if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
3690
return -c/2 * ((t-=2)*t*t*t - 2) + b;
3692
easeInQuint: function (x, t, b, c, d) {
3693
return c*(t/=d)*t*t*t*t + b;
3695
easeOutQuint: function (x, t, b, c, d) {
3696
return c*((t=t/d-1)*t*t*t*t + 1) + b;
3698
easeInOutQuint: function (x, t, b, c, d) {
3699
if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
3700
return c/2*((t-=2)*t*t*t*t + 2) + b;
3702
easeInSine: function (x, t, b, c, d) {
3703
return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
3705
easeOutSine: function (x, t, b, c, d) {
3706
return c * Math.sin(t/d * (Math.PI/2)) + b;
3708
easeInOutSine: function (x, t, b, c, d) {
3709
return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
3711
easeInExpo: function (x, t, b, c, d) {
3712
return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
3714
easeOutExpo: function (x, t, b, c, d) {
3715
return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
3717
easeInOutExpo: function (x, t, b, c, d) {
3719
if (t==d) return b+c;
3720
if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
3721
return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
3723
easeInCirc: function (x, t, b, c, d) {
3724
return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
3726
easeOutCirc: function (x, t, b, c, d) {
3727
return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
3729
easeInOutCirc: function (x, t, b, c, d) {
3730
if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
3731
return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
3733
easeInElastic: function (x, t, b, c, d) {
3734
var s=1.70158;var p=0;var a=c;
3735
if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
3736
if (a < Math.abs(c)) { a=c; var s=p/4; }
3737
else var s = p/(2*Math.PI) * Math.asin (c/a);
3738
return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
3740
easeOutElastic: function (x, t, b, c, d) {
3741
var s=1.70158;var p=0;var a=c;
3742
if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
3743
if (a < Math.abs(c)) { a=c; var s=p/4; }
3744
else var s = p/(2*Math.PI) * Math.asin (c/a);
3745
return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
3747
easeInOutElastic: function (x, t, b, c, d) {
3748
var s=1.70158;var p=0;var a=c;
3749
if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5);
3750
if (a < Math.abs(c)) { a=c; var s=p/4; }
3751
else var s = p/(2*Math.PI) * Math.asin (c/a);
3752
if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
3753
return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
3755
easeInBack: function (x, t, b, c, d, s) {
3756
if (s == undefined) s = 1.70158;
3757
return c*(t/=d)*t*((s+1)*t - s) + b;
3759
easeOutBack: function (x, t, b, c, d, s) {
3760
if (s == undefined) s = 1.70158;
3761
return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
3763
easeInOutBack: function (x, t, b, c, d, s) {
3764
if (s == undefined) s = 1.70158;
3765
if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
3766
return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
3768
easeInBounce: function (x, t, b, c, d) {
3769
return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
3771
easeOutBounce: function (x, t, b, c, d) {
3772
if ((t/=d) < (1/2.75)) {
3773
return c*(7.5625*t*t) + b;
3774
} else if (t < (2/2.75)) {
3775
return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
3776
} else if (t < (2.5/2.75)) {
3777
return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
3779
return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
3782
easeInOutBounce: function (x, t, b, c, d) {
3783
if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
3784
return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
3790
* TERMS OF USE - EASING EQUATIONS
3792
* Open source under the BSD License.
3794
* Copyright © 2001 Robert Penner
3795
* All rights reserved.
3797
* Redistribution and use in source and binary forms, with or without modification,
3798
* are permitted provided that the following conditions are met:
3800
* Redistributions of source code must retain the above copyright notice, this list of
3801
* conditions and the following disclaimer.
3802
* Redistributions in binary form must reproduce the above copyright notice, this list
3803
* of conditions and the following disclaimer in the documentation and/or other materials
3804
* provided with the distribution.
3806
* Neither the name of the author nor the names of contributors may be used to endorse
3807
* or promote products derived from this software without specific prior written permission.
3809
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
3810
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
3811
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
3812
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
3813
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
3814
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
3815
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
3816
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
3817
* OF THE POSSIBILITY OF SUCH DAMAGE.
3823
* jQuery UI Effects Blind @VERSION
3825
* Copyright (c) 2008 Aaron Eisenberger (aaronchi@gmail.com)
3826
* Dual licensed under the MIT (MIT-LICENSE.txt)
3827
* and GPL (GPL-LICENSE.txt) licenses.
3829
* http://docs.jquery.com/UI/Effects/Blind
3836
$.effects.blind = function(o) {
3838
return this.queue(function() {
3841
var el = $(this), props = ['position','top','left'];
3844
var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode
3845
var direction = o.options.direction || 'vertical'; // Default direction
3848
$.effects.save(el, props); el.show(); // Save & Show
3849
var wrapper = $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper
3850
var ref = (direction == 'vertical') ? 'height' : 'width';
3851
var distance = (direction == 'vertical') ? wrapper.height() : wrapper.width();
3852
if(mode == 'show') wrapper.css(ref, 0); // Shift
3856
animation[ref] = mode == 'show' ? distance : 0;
3859
wrapper.animate(animation, o.duration, o.options.easing, function() {
3860
if(mode == 'hide') el.hide(); // Hide
3861
$.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
3862
if(o.callback) o.callback.apply(el[0], arguments); // Callback
3872
* jQuery UI Effects Bounce @VERSION
3874
* Copyright (c) 2008 Aaron Eisenberger (aaronchi@gmail.com)
3875
* Dual licensed under the MIT (MIT-LICENSE.txt)
3876
* and GPL (GPL-LICENSE.txt) licenses.
3878
* http://docs.jquery.com/UI/Effects/Bounce
3885
$.effects.bounce = function(o) {
3887
return this.queue(function() {
3890
var el = $(this), props = ['position','top','left'];
3893
var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode
3894
var direction = o.options.direction || 'up'; // Default direction
3895
var distance = o.options.distance || 20; // Default distance
3896
var times = o.options.times || 5; // Default # of times
3897
var speed = o.duration || 250; // Default speed per bounce
3898
if (/show|hide/.test(mode)) props.push('opacity'); // Avoid touching opacity to prevent clearType and PNG issues in IE
3901
$.effects.save(el, props); el.show(); // Save & Show
3902
$.effects.createWrapper(el); // Create Wrapper
3903
var ref = (direction == 'up' || direction == 'down') ? 'top' : 'left';
3904
var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg';
3905
var distance = o.options.distance || (ref == 'top' ? el.outerHeight({margin:true}) / 3 : el.outerWidth({margin:true}) / 3);
3906
if (mode == 'show') el.css('opacity', 0).css(ref, motion == 'pos' ? -distance : distance); // Shift
3907
if (mode == 'hide') distance = distance / (times * 2);
3908
if (mode != 'hide') times--;
3911
if (mode == 'show') { // Show Bounce
3912
var animation = {opacity: 1};
3913
animation[ref] = (motion == 'pos' ? '+=' : '-=') + distance;
3914
el.animate(animation, speed / 2, o.options.easing);
3915
distance = distance / 2;
3918
for (var i = 0; i < times; i++) { // Bounces
3919
var animation1 = {}, animation2 = {};
3920
animation1[ref] = (motion == 'pos' ? '-=' : '+=') + distance;
3921
animation2[ref] = (motion == 'pos' ? '+=' : '-=') + distance;
3922
el.animate(animation1, speed / 2, o.options.easing).animate(animation2, speed / 2, o.options.easing);
3923
distance = (mode == 'hide') ? distance * 2 : distance / 2;
3925
if (mode == 'hide') { // Last Bounce
3926
var animation = {opacity: 0};
3927
animation[ref] = (motion == 'pos' ? '-=' : '+=') + distance;
3928
el.animate(animation, speed / 2, o.options.easing, function(){
3930
$.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
3931
if(o.callback) o.callback.apply(this, arguments); // Callback
3934
var animation1 = {}, animation2 = {};
3935
animation1[ref] = (motion == 'pos' ? '-=' : '+=') + distance;
3936
animation2[ref] = (motion == 'pos' ? '+=' : '-=') + distance;
3937
el.animate(animation1, speed / 2, o.options.easing).animate(animation2, speed / 2, o.options.easing, function(){
3938
$.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
3939
if(o.callback) o.callback.apply(this, arguments); // Callback
3942
el.queue('fx', function() { el.dequeue(); });
3950
* jQuery UI Effects Clip @VERSION
3952
* Copyright (c) 2008 Aaron Eisenberger (aaronchi@gmail.com)
3953
* Dual licensed under the MIT (MIT-LICENSE.txt)
3954
* and GPL (GPL-LICENSE.txt) licenses.
3956
* http://docs.jquery.com/UI/Effects/Clip
3963
$.effects.clip = function(o) {
3965
return this.queue(function() {
3968
var el = $(this), props = ['position','top','left','height','width'];
3971
var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode
3972
var direction = o.options.direction || 'vertical'; // Default direction
3975
$.effects.save(el, props); el.show(); // Save & Show
3976
var wrapper = $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper
3977
var animate = el[0].tagName == 'IMG' ? wrapper : el;
3979
size: (direction == 'vertical') ? 'height' : 'width',
3980
position: (direction == 'vertical') ? 'top' : 'left'
3982
var distance = (direction == 'vertical') ? animate.height() : animate.width();
3983
if(mode == 'show') { animate.css(ref.size, 0); animate.css(ref.position, distance / 2); } // Shift
3987
animation[ref.size] = mode == 'show' ? distance : 0;
3988
animation[ref.position] = mode == 'show' ? 0 : distance / 2;
3991
animate.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() {
3992
if(mode == 'hide') el.hide(); // Hide
3993
$.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
3994
if(o.callback) o.callback.apply(el[0], arguments); // Callback
4004
* jQuery UI Effects Drop @VERSION
4006
* Copyright (c) 2008 Aaron Eisenberger (aaronchi@gmail.com)
4007
* Dual licensed under the MIT (MIT-LICENSE.txt)
4008
* and GPL (GPL-LICENSE.txt) licenses.
4010
* http://docs.jquery.com/UI/Effects/Drop
4017
$.effects.drop = function(o) {
4019
return this.queue(function() {
4022
var el = $(this), props = ['position','top','left','opacity'];
4025
var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode
4026
var direction = o.options.direction || 'left'; // Default Direction
4029
$.effects.save(el, props); el.show(); // Save & Show
4030
$.effects.createWrapper(el); // Create Wrapper
4031
var ref = (direction == 'up' || direction == 'down') ? 'top' : 'left';
4032
var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg';
4033
var distance = o.options.distance || (ref == 'top' ? el.outerHeight({margin:true}) / 2 : el.outerWidth({margin:true}) / 2);
4034
if (mode == 'show') el.css('opacity', 0).css(ref, motion == 'pos' ? -distance : distance); // Shift
4037
var animation = {opacity: mode == 'show' ? 1 : 0};
4038
animation[ref] = (mode == 'show' ? (motion == 'pos' ? '+=' : '-=') : (motion == 'pos' ? '-=' : '+=')) + distance;
4041
el.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() {
4042
if(mode == 'hide') el.hide(); // Hide
4043
$.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
4044
if(o.callback) o.callback.apply(this, arguments); // Callback
4054
* jQuery UI Effects Explode @VERSION
4056
* Copyright (c) 2008 Paul Bakaus (ui.jquery.com)
4057
* Dual licensed under the MIT (MIT-LICENSE.txt)
4058
* and GPL (GPL-LICENSE.txt) licenses.
4060
* http://docs.jquery.com/UI/Effects/Explode
4067
$.effects.explode = function(o) {
4069
return this.queue(function() {
4071
var rows = o.options.pieces ? Math.round(Math.sqrt(o.options.pieces)) : 3;
4072
var cells = o.options.pieces ? Math.round(Math.sqrt(o.options.pieces)) : 3;
4074
o.options.mode = o.options.mode == 'toggle' ? ($(this).is(':visible') ? 'hide' : 'show') : o.options.mode;
4075
var el = $(this).show().css('visibility', 'hidden');
4076
var offset = el.offset();
4078
//Substract the margins - not fixing the problem yet.
4079
offset.top -= parseInt(el.css("marginTop")) || 0;
4080
offset.left -= parseInt(el.css("marginLeft")) || 0;
4082
var width = el.outerWidth(true);
4083
var height = el.outerHeight(true);
4085
for(var i=0;i<rows;i++) { // =
4086
for(var j=0;j<cells;j++) { // ||
4090
.wrap('<div></div>')
4092
position: 'absolute',
4093
visibility: 'visible',
4094
left: -j*(width/cells),
4095
top: -i*(height/rows)
4098
.addClass('effects-explode')
4100
position: 'absolute',
4103
height: height/rows,
4104
left: offset.left + j*(width/cells) + (o.options.mode == 'show' ? (j-Math.floor(cells/2))*(width/cells) : 0),
4105
top: offset.top + i*(height/rows) + (o.options.mode == 'show' ? (i-Math.floor(rows/2))*(height/rows) : 0),
4106
opacity: o.options.mode == 'show' ? 0 : 1
4108
left: offset.left + j*(width/cells) + (o.options.mode == 'show' ? 0 : (j-Math.floor(cells/2))*(width/cells)),
4109
top: offset.top + i*(height/rows) + (o.options.mode == 'show' ? 0 : (i-Math.floor(rows/2))*(height/rows)),
4110
opacity: o.options.mode == 'show' ? 1 : 0
4111
}, o.duration || 500);
4115
// Set a timeout, to call the callback approx. when the other animations have finished
4116
setTimeout(function() {
4118
o.options.mode == 'show' ? el.css({ visibility: 'visible' }) : el.css({ visibility: 'visible' }).hide();
4119
if(o.callback) o.callback.apply(el[0]); // Callback
4122
$('.effects-explode').remove();
4124
}, o.duration || 500);
4133
* jQuery UI Effects Fold @VERSION
4135
* Copyright (c) 2008 Aaron Eisenberger (aaronchi@gmail.com)
4136
* Dual licensed under the MIT (MIT-LICENSE.txt)
4137
* and GPL (GPL-LICENSE.txt) licenses.
4139
* http://docs.jquery.com/UI/Effects/Fold
4146
$.effects.fold = function(o) {
4148
return this.queue(function() {
4151
var el = $(this), props = ['position','top','left'];
4154
var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode
4155
var size = o.options.size || 15; // Default fold size
4156
var horizFirst = !(!o.options.horizFirst); // Ensure a boolean value
4159
$.effects.save(el, props); el.show(); // Save & Show
4160
var wrapper = $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper
4161
var widthFirst = ((mode == 'show') != horizFirst);
4162
var ref = widthFirst ? ['width', 'height'] : ['height', 'width'];
4163
var distance = widthFirst ? [wrapper.width(), wrapper.height()] : [wrapper.height(), wrapper.width()];
4164
var percent = /([0-9]+)%/.exec(size);
4165
if(percent) size = parseInt(percent[1]) / 100 * distance[mode == 'hide' ? 0 : 1];
4166
if(mode == 'show') wrapper.css(horizFirst ? {height: 0, width: size} : {height: size, width: 0}); // Shift
4169
var animation1 = {}, animation2 = {};
4170
animation1[ref[0]] = mode == 'show' ? distance[0] : size;
4171
animation2[ref[1]] = mode == 'show' ? distance[1] : 0;
4174
wrapper.animate(animation1, o.duration / 2, o.options.easing)
4175
.animate(animation2, o.duration / 2, o.options.easing, function() {
4176
if(mode == 'hide') el.hide(); // Hide
4177
$.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
4178
if(o.callback) o.callback.apply(el[0], arguments); // Callback
4188
* jQuery UI Effects Highlight @VERSION
4190
* Copyright (c) 2008 Aaron Eisenberger (aaronchi@gmail.com)
4191
* Dual licensed under the MIT (MIT-LICENSE.txt)
4192
* and GPL (GPL-LICENSE.txt) licenses.
4194
* http://docs.jquery.com/UI/Effects/Highlight
4201
$.effects.highlight = function(o) {
4203
return this.queue(function() {
4206
var el = $(this), props = ['backgroundImage','backgroundColor','opacity'];
4209
var mode = $.effects.setMode(el, o.options.mode || 'show'); // Set Mode
4210
var color = o.options.color || "#ffff99"; // Default highlight color
4211
var oldColor = el.css("backgroundColor");
4214
$.effects.save(el, props); el.show(); // Save & Show
4215
el.css({backgroundImage: 'none', backgroundColor: color}); // Shift
4218
var animation = {backgroundColor: oldColor };
4219
if (mode == "hide") animation['opacity'] = 0;
4222
el.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() {
4223
if(mode == "hide") el.hide();
4224
$.effects.restore(el, props);
4225
if (mode == "show" && jQuery.browser.msie) this.style.removeAttribute('filter');
4226
if(o.callback) o.callback.apply(this, arguments);
4236
* jQuery UI Effects Pulsate @VERSION
4238
* Copyright (c) 2008 Aaron Eisenberger (aaronchi@gmail.com)
4239
* Dual licensed under the MIT (MIT-LICENSE.txt)
4240
* and GPL (GPL-LICENSE.txt) licenses.
4242
* http://docs.jquery.com/UI/Effects/Pulsate
4249
$.effects.pulsate = function(o) {
4251
return this.queue(function() {
4257
var mode = $.effects.setMode(el, o.options.mode || 'show'); // Set Mode
4258
var times = o.options.times || 5; // Default # of times
4261
if (mode == 'hide') times--;
4262
if (el.is(':hidden')) { // Show fadeIn
4263
el.css('opacity', 0);
4265
el.animate({opacity: 1}, o.duration / 2, o.options.easing);
4270
for (var i = 0; i < times; i++) { // Pulsate
4271
el.animate({opacity: 0}, o.duration / 2, o.options.easing).animate({opacity: 1}, o.duration / 2, o.options.easing);
4273
if (mode == 'hide') { // Last Pulse
4274
el.animate({opacity: 0}, o.duration / 2, o.options.easing, function(){
4276
if(o.callback) o.callback.apply(this, arguments); // Callback
4279
el.animate({opacity: 0}, o.duration / 2, o.options.easing).animate({opacity: 1}, o.duration / 2, o.options.easing, function(){
4280
if(o.callback) o.callback.apply(this, arguments); // Callback
4283
el.queue('fx', function() { el.dequeue(); });
4291
* jQuery UI Effects Scale @VERSION
4293
* Copyright (c) 2008 Aaron Eisenberger (aaronchi@gmail.com)
4294
* Dual licensed under the MIT (MIT-LICENSE.txt)
4295
* and GPL (GPL-LICENSE.txt) licenses.
4297
* http://docs.jquery.com/UI/Effects/Scale
4304
$.effects.puff = function(o) {
4306
return this.queue(function() {
4312
var options = $.extend(true, {}, o.options);
4313
var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode
4314
var percent = parseInt(o.options.percent) || 150; // Set default puff percent
4315
options.fade = true; // It's not a puff if it doesn't fade! :)
4316
var original = {height: el.height(), width: el.width()}; // Save original
4319
var factor = percent / 100;
4320
el.from = (mode == 'hide') ? original : {height: original.height * factor, width: original.width * factor};
4323
options.from = el.from;
4324
options.percent = (mode == 'hide') ? percent : 100;
4325
options.mode = mode;
4328
el.effect('scale', options, o.duration, o.callback);
4334
$.effects.scale = function(o) {
4336
return this.queue(function() {
4342
var options = $.extend(true, {}, o.options);
4343
var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode
4344
var percent = parseInt(o.options.percent) || (parseInt(o.options.percent) == 0 ? 0 : (mode == 'hide' ? 0 : 100)); // Set default scaling percent
4345
var direction = o.options.direction || 'both'; // Set default axis
4346
var origin = o.options.origin; // The origin of the scaling
4347
if (mode != 'effect') { // Set default origin and restore for show/hide
4348
options.origin = origin || ['middle','center'];
4349
options.restore = true;
4351
var original = {height: el.height(), width: el.width()}; // Save original
4352
el.from = o.options.from || (mode == 'show' ? {height: 0, width: 0} : original); // Default from state
4355
var factor = { // Set scaling factor
4356
y: direction != 'horizontal' ? (percent / 100) : 1,
4357
x: direction != 'vertical' ? (percent / 100) : 1
4359
el.to = {height: original.height * factor.y, width: original.width * factor.x}; // Set to state
4361
if (o.options.fade) { // Fade option to support puff
4362
if (mode == 'show') {el.from.opacity = 0; el.to.opacity = 1;};
4363
if (mode == 'hide') {el.from.opacity = 1; el.to.opacity = 0;};
4367
options.from = el.from; options.to = el.to; options.mode = mode;
4370
el.effect('size', options, o.duration, o.callback);
4376
$.effects.size = function(o) {
4378
return this.queue(function() {
4381
var el = $(this), props = ['position','top','left','width','height','overflow','opacity'];
4382
var props1 = ['position','top','left','overflow','opacity']; // Always restore
4383
var props2 = ['width','height','overflow']; // Copy for children
4384
var cProps = ['fontSize'];
4385
var vProps = ['borderTopWidth', 'borderBottomWidth', 'paddingTop', 'paddingBottom'];
4386
var hProps = ['borderLeftWidth', 'borderRightWidth', 'paddingLeft', 'paddingRight'];
4389
var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode
4390
var restore = o.options.restore || false; // Default restore
4391
var scale = o.options.scale || 'both'; // Default scale mode
4392
var origin = o.options.origin; // The origin of the sizing
4393
var original = {height: el.height(), width: el.width()}; // Save original
4394
el.from = o.options.from || original; // Default from state
4395
el.to = o.options.to || original; // Default to state
4397
if (origin) { // Calculate baseline shifts
4398
var baseline = $.effects.getBaseline(origin, original);
4399
el.from.top = (original.height - el.from.height) * baseline.y;
4400
el.from.left = (original.width - el.from.width) * baseline.x;
4401
el.to.top = (original.height - el.to.height) * baseline.y;
4402
el.to.left = (original.width - el.to.width) * baseline.x;
4404
var factor = { // Set scaling factor
4405
from: {y: el.from.height / original.height, x: el.from.width / original.width},
4406
to: {y: el.to.height / original.height, x: el.to.width / original.width}
4408
if (scale == 'box' || scale == 'both') { // Scale the css box
4409
if (factor.from.y != factor.to.y) { // Vertical props scaling
4410
props = props.concat(vProps);
4411
el.from = $.effects.setTransition(el, vProps, factor.from.y, el.from);
4412
el.to = $.effects.setTransition(el, vProps, factor.to.y, el.to);
4414
if (factor.from.x != factor.to.x) { // Horizontal props scaling
4415
props = props.concat(hProps);
4416
el.from = $.effects.setTransition(el, hProps, factor.from.x, el.from);
4417
el.to = $.effects.setTransition(el, hProps, factor.to.x, el.to);
4420
if (scale == 'content' || scale == 'both') { // Scale the content
4421
if (factor.from.y != factor.to.y) { // Vertical props scaling
4422
props = props.concat(cProps);
4423
el.from = $.effects.setTransition(el, cProps, factor.from.y, el.from);
4424
el.to = $.effects.setTransition(el, cProps, factor.to.y, el.to);
4427
$.effects.save(el, restore ? props : props1); el.show(); // Save & Show
4428
$.effects.createWrapper(el); // Create Wrapper
4429
el.css('overflow','hidden').css(el.from); // Shift
4432
if (scale == 'content' || scale == 'both') { // Scale the children
4433
vProps = vProps.concat(['marginTop','marginBottom']).concat(cProps); // Add margins/font-size
4434
hProps = hProps.concat(['marginLeft','marginRight']); // Add margins
4435
props2 = props.concat(vProps).concat(hProps); // Concat
4436
el.find("*[width]").each(function(){
4438
if (restore) $.effects.save(child, props2);
4439
var c_original = {height: child.height(), width: child.width()}; // Save original
4440
child.from = {height: c_original.height * factor.from.y, width: c_original.width * factor.from.x};
4441
child.to = {height: c_original.height * factor.to.y, width: c_original.width * factor.to.x};
4442
if (factor.from.y != factor.to.y) { // Vertical props scaling
4443
child.from = $.effects.setTransition(child, vProps, factor.from.y, child.from);
4444
child.to = $.effects.setTransition(child, vProps, factor.to.y, child.to);
4446
if (factor.from.x != factor.to.x) { // Horizontal props scaling
4447
child.from = $.effects.setTransition(child, hProps, factor.from.x, child.from);
4448
child.to = $.effects.setTransition(child, hProps, factor.to.x, child.to);
4450
child.css(child.from); // Shift children
4451
child.animate(child.to, o.duration, o.options.easing, function(){
4452
if (restore) $.effects.restore(child, props2); // Restore children
4453
}); // Animate children
4458
el.animate(el.to, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() {
4459
if(mode == 'hide') el.hide(); // Hide
4460
$.effects.restore(el, restore ? props : props1); $.effects.removeWrapper(el); // Restore
4461
if(o.callback) o.callback.apply(this, arguments); // Callback
4471
* jQuery UI Effects Shake @VERSION
4473
* Copyright (c) 2008 Aaron Eisenberger (aaronchi@gmail.com)
4474
* Dual licensed under the MIT (MIT-LICENSE.txt)
4475
* and GPL (GPL-LICENSE.txt) licenses.
4477
* http://docs.jquery.com/UI/Effects/Shake
4484
$.effects.shake = function(o) {
4486
return this.queue(function() {
4489
var el = $(this), props = ['position','top','left'];
4492
var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode
4493
var direction = o.options.direction || 'left'; // Default direction
4494
var distance = o.options.distance || 20; // Default distance
4495
var times = o.options.times || 3; // Default # of times
4496
var speed = o.duration || o.options.duration || 140; // Default speed per shake
4499
$.effects.save(el, props); el.show(); // Save & Show
4500
$.effects.createWrapper(el); // Create Wrapper
4501
var ref = (direction == 'up' || direction == 'down') ? 'top' : 'left';
4502
var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg';
4505
var animation = {}, animation1 = {}, animation2 = {};
4506
animation[ref] = (motion == 'pos' ? '-=' : '+=') + distance;
4507
animation1[ref] = (motion == 'pos' ? '+=' : '-=') + distance * 2;
4508
animation2[ref] = (motion == 'pos' ? '-=' : '+=') + distance * 2;
4511
el.animate(animation, speed, o.options.easing);
4512
for (var i = 1; i < times; i++) { // Shakes
4513
el.animate(animation1, speed, o.options.easing).animate(animation2, speed, o.options.easing);
4515
el.animate(animation1, speed, o.options.easing).
4516
animate(animation, speed / 2, o.options.easing, function(){ // Last shake
4517
$.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
4518
if(o.callback) o.callback.apply(this, arguments); // Callback
4520
el.queue('fx', function() { el.dequeue(); });
4528
* jQuery UI Effects Slide @VERSION
4530
* Copyright (c) 2008 Aaron Eisenberger (aaronchi@gmail.com)
4531
* Dual licensed under the MIT (MIT-LICENSE.txt)
4532
* and GPL (GPL-LICENSE.txt) licenses.
4534
* http://docs.jquery.com/UI/Effects/Slide
4541
$.effects.slide = function(o) {
4543
return this.queue(function() {
4546
var el = $(this), props = ['position','top','left'];
4549
var mode = $.effects.setMode(el, o.options.mode || 'show'); // Set Mode
4550
var direction = o.options.direction || 'left'; // Default Direction
4553
$.effects.save(el, props); el.show(); // Save & Show
4554
$.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper
4555
var ref = (direction == 'up' || direction == 'down') ? 'top' : 'left';
4556
var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg';
4557
var distance = o.options.distance || (ref == 'top' ? el.outerHeight({margin:true}) : el.outerWidth({margin:true}));
4558
if (mode == 'show') el.css(ref, motion == 'pos' ? -distance : distance); // Shift
4562
animation[ref] = (mode == 'show' ? (motion == 'pos' ? '+=' : '-=') : (motion == 'pos' ? '-=' : '+=')) + distance;
4565
el.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() {
4566
if(mode == 'hide') el.hide(); // Hide
4567
$.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
4568
if(o.callback) o.callback.apply(this, arguments); // Callback
4578
* jQuery UI Effects Transfer @VERSION
4580
* Copyright (c) 2008 Aaron Eisenberger (aaronchi@gmail.com)
4581
* Dual licensed under the MIT (MIT-LICENSE.txt)
4582
* and GPL (GPL-LICENSE.txt) licenses.
4584
* http://docs.jquery.com/UI/Effects/Transfer
4591
$.effects.transfer = function(o) {
4593
return this.queue(function() {
4599
var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode
4600
var target = $(o.options.to); // Find Target
4601
var position = el.offset();
4602
var transfer = $('<div class="ui-effects-transfer"></div>').appendTo(document.body);
4603
if(o.options.className) transfer.addClass(o.options.className);
4606
transfer.addClass(o.options.className);
4609
left: position.left,
4610
height: el.outerHeight() - parseInt(transfer.css('borderTopWidth')) - parseInt(transfer.css('borderBottomWidth')),
4611
width: el.outerWidth() - parseInt(transfer.css('borderLeftWidth')) - parseInt(transfer.css('borderRightWidth')),
4612
position: 'absolute'
4616
position = target.offset();
4619
left: position.left,
4620
height: target.outerHeight() - parseInt(transfer.css('borderTopWidth')) - parseInt(transfer.css('borderBottomWidth')),
4621
width: target.outerWidth() - parseInt(transfer.css('borderLeftWidth')) - parseInt(transfer.css('borderRightWidth'))
4625
transfer.animate(animation, o.duration, o.options.easing, function() {
4626
transfer.remove(); // Remove div
4627
if(o.callback) o.callback.apply(el[0], arguments); // Callback
4637
* jQuery UI Accordion @VERSION
4639
* Copyright (c) 2007, 2008 Jörn Zaefferer
4640
* Dual licensed under the MIT (MIT-LICENSE.txt)
4641
* and GPL (GPL-LICENSE.txt) licenses.
4643
* http://docs.jquery.com/UI/Accordion
4650
$.widget("ui.accordion", {
4652
var options = this.options;
4654
if ( options.navigation ) {
4655
var current = this.element.find("a").filter(options.navigationFilter);
4656
if ( current.length ) {
4657
if ( current.filter(options.header).length ) {
4658
options.active = current;
4660
options.active = current.parent().parent().prev();
4661
current.addClass("current");
4666
// calculate active if not specified, using the first header
4667
options.headers = this.element.find(options.header);
4668
options.active = findActive(options.headers, options.active);
4670
// IE7-/Win - Extra vertical space in Lists fixed
4671
if ($.browser.msie) {
4672
this.element.find('a').css('zoom', '1');
4675
if (!this.element.hasClass("ui-accordion")) {
4676
this.element.addClass("ui-accordion");
4677
$('<span class="ui-accordion-left"/>').insertBefore(options.headers);
4678
$('<span class="ui-accordion-right"/>').appendTo(options.headers);
4679
options.headers.addClass("ui-accordion-header").attr("tabindex", "0");
4683
if ( options.fillSpace ) {
4684
maxHeight = this.element.parent().height();
4685
options.headers.each(function() {
4686
maxHeight -= $(this).outerHeight();
4689
options.headers.next().each(function() {
4690
maxPadding = Math.max(maxPadding, $(this).innerHeight() - $(this).height());
4691
}).height(maxHeight - maxPadding);
4692
} else if ( options.autoHeight ) {
4694
options.headers.next().each(function() {
4695
maxHeight = Math.max(maxHeight, $(this).outerHeight());
4696
}).height(maxHeight);
4700
.not(options.active || "")
4703
options.active.parent().andSelf().addClass(options.selectedClass);
4705
if (options.event) {
4706
this.element.bind((options.event) + ".accordion", clickHandler);
4709
activate: function(index) {
4710
// call clickHandler with custom event
4711
clickHandler.call(this.element[0], {
4712
target: findActive( this.options.headers, index )[0]
4715
destroy: function() {
4716
this.options.headers.next().css("display", "");
4717
if ( this.options.fillSpace || this.options.autoHeight ) {
4718
this.options.headers.next().css("height", "");
4720
$.removeData(this.element[0], "accordion");
4721
this.element.removeClass("ui-accordion").unbind(".accordion");
4725
function scopeCallback(callback, scope) {
4727
return callback.apply(scope, arguments);
4731
function completed(cancel) {
4732
// if removed while animated data can be empty
4733
if (!$.data(this, "accordion")) {
4737
var instance = $.data(this, "accordion");
4738
var options = instance.options;
4739
options.running = cancel ? 0 : --options.running;
4740
if ( options.running ) {
4743
if ( options.clearStyle ) {
4744
options.toShow.add(options.toHide).css({
4749
instance._trigger('change', null, options.data);
4752
function toggle(toShow, toHide, data, clickedActive, down) {
4753
var options = $.data(this, "accordion").options;
4754
options.toShow = toShow;
4755
options.toHide = toHide;
4756
options.data = data;
4757
var complete = scopeCallback(completed, this);
4759
$.data(this, "accordion")._trigger("changestart", null, options.data);
4761
// count elements to animate
4762
options.running = toHide.size() === 0 ? toShow.size() : toHide.size();
4764
if ( options.animated ) {
4765
if ( !options.alwaysOpen && clickedActive ) {
4766
$.ui.accordion.animations[options.animated]({
4771
autoHeight: options.autoHeight
4774
$.ui.accordion.animations[options.animated]({
4779
autoHeight: options.autoHeight
4783
if ( !options.alwaysOpen && clickedActive ) {
4793
function clickHandler(event) {
4794
var options = $.data(this, "accordion").options;
4795
if (options.disabled) {
4799
// called only when using activate(false) to close all parts programmatically
4800
if ( !event.target && !options.alwaysOpen ) {
4801
options.active.parent().andSelf().toggleClass(options.selectedClass);
4802
var toHide = options.active.next(),
4805
newHeader: jQuery([]),
4806
oldHeader: options.active,
4807
newContent: jQuery([]),
4810
toShow = (options.active = $([]));
4811
toggle.call(this, toShow, toHide, data );
4814
// get the click target
4815
var clicked = $(event.target);
4817
// due to the event delegation model, we have to check if one
4818
// of the parent elements is our actual header, and find that
4819
// otherwise stick with the initial target
4820
clicked = $( clicked.parents(options.header)[0] || clicked );
4822
var clickedActive = clicked[0] == options.active[0];
4824
// if animations are still active, or the active header is the target, ignore click
4825
if (options.running || (options.alwaysOpen && clickedActive)) {
4828
if (!clicked.is(options.header)) {
4833
options.active.parent().andSelf().toggleClass(options.selectedClass);
4834
if ( !clickedActive ) {
4835
clicked.parent().andSelf().addClass(options.selectedClass);
4838
// find elements to show and hide
4839
var toShow = clicked.next(),
4840
toHide = options.active.next(),
4843
newHeader: clickedActive && !options.alwaysOpen ? $([]) : clicked,
4844
oldHeader: options.active,
4845
newContent: clickedActive && !options.alwaysOpen ? $([]) : toShow,
4848
down = options.headers.index( options.active[0] ) > options.headers.index( clicked[0] );
4850
options.active = clickedActive ? $([]) : clicked;
4851
toggle.call(this, toShow, toHide, data, clickedActive, down );
4856
function findActive(headers, selector) {
4858
? typeof selector == "number"
4859
? headers.filter(":eq(" + selector + ")")
4860
: headers.not(headers.not(selector))
4861
: selector === false
4863
: headers.filter(":eq(0)");
4866
$.extend($.ui.accordion, {
4868
selectedClass: "selected",
4875
navigationFilter: function() {
4876
return this.href.toLowerCase() == location.href.toLowerCase();
4880
slide: function(options, additions) {
4881
options = $.extend({
4884
}, options, additions);
4885
if ( !options.toHide.size() ) {
4886
options.toShow.animate({height: "show"}, options);
4889
var hideHeight = options.toHide.height(),
4890
showHeight = options.toShow.height(),
4891
difference = showHeight / hideHeight;
4892
options.toShow.css({ height: 0, overflow: 'hidden' }).show();
4893
options.toHide.filter(":hidden").each(options.complete).end().filter(":visible").animate({height:"hide"},{
4894
step: function(now) {
4895
var current = (hideHeight - now) * difference;
4896
if ($.browser.msie || $.browser.opera) {
4897
current = Math.ceil(current);
4899
options.toShow.height( current );
4901
duration: options.duration,
4902
easing: options.easing,
4903
complete: function() {
4904
if ( !options.autoHeight ) {
4905
options.toShow.css("height", "auto");
4911
bounceslide: function(options) {
4912
this.slide(options, {
4913
easing: options.down ? "bounceout" : "swing",
4914
duration: options.down ? 1000 : 200
4917
easeslide: function(options) {
4918
this.slide(options, {
4919
easing: "easeinout",
4928
* jQuery UI Autocomplete @VERSION
4930
* Copyright (c) 2007, 2008 Dylan Verheul, Dan G. Switzer, Anjesh Tuladhar, Jörn Zaefferer
4931
* Dual licensed under the MIT (MIT-LICENSE.txt)
4932
* and GPL (GPL-LICENSE.txt) licenses.
4934
* http://docs.jquery.com/UI/Autocomplete
4941
$.widget("ui.autocomplete", {
4945
$.extend(this.options, {
4946
delay: this.options.url ? $.Autocompleter.defaults.delay : 10,
4947
max: !this.options.scroll ? 10 : 150,
4948
highlight: this.options.highlight || function(value) { return value; }, // if highlight is set to false, replace it with a do-nothing function
4949
formatMatch: this.options.formatMatch || this.options.formatItem // if the formatMatch option is not specified, then use formatItem for backwards compatibility
4952
new $.Autocompleter(this.element[0], this.options);
4956
result: function(handler) {
4957
return this.element.bind("result", handler);
4959
search: function(handler) {
4960
return this.element.trigger("search", [handler]);
4962
flushCache: function() {
4963
return this.element.trigger("flushCache");
4965
setData: function(key, value){
4966
return this.element.trigger("setOptions", [{ key: value }]);
4968
destroy: function() {
4969
return this.element.trigger("unautocomplete");
4974
$.Autocompleter = function(input, options) {
4989
// Create $ object for input element
4990
var $input = $(input).attr("autocomplete", "off").addClass(options.inputClass);
4991
if(options.result) $input.bind('result.autocomplete', options.result);
4994
var previousValue = "";
4995
var cache = $.Autocompleter.Cache(options);
4997
var lastKeyPressCode;
4999
mouseDownOnSelect: false
5001
var select = $.Autocompleter.Select(options, input, selectCurrent, config);
5005
// prevent form submit in opera when selecting with return key
5006
$.browser.opera && $(input.form).bind("submit.autocomplete", function() {
5008
blockSubmit = false;
5013
// only opera doesn't trigger keydown multiple times while pressed, others don't work with keypress at all
5014
$input.bind(($.browser.opera ? "keypress" : "keydown") + ".autocomplete", function(event) {
5015
// track last key pressed
5016
lastKeyPressCode = event.keyCode;
5017
switch(event.keyCode) {
5020
event.preventDefault();
5021
if ( select.visible() ) {
5029
event.preventDefault();
5030
if ( select.visible() ) {
5038
event.preventDefault();
5039
if ( select.visible() ) {
5047
event.preventDefault();
5048
if ( select.visible() ) {
5055
// matches also semicolon
5056
case options.multiple && $.trim(options.multipleSeparator) == "," && KEY.COMMA:
5059
if( selectCurrent() ) {
5060
// stop default to prevent a form submit, Opera needs special handling
5061
event.preventDefault();
5072
clearTimeout(timeout);
5073
timeout = setTimeout(onChange, options.delay);
5076
}).focus(function(){
5077
// track whether the field has focus, we shouldn't process any
5078
// results if the field no longer has focus
5080
}).blur(function() {
5082
if (!config.mouseDownOnSelect) {
5085
}).click(function() {
5086
// show select when clicking in a focused field
5087
if ( hasFocus++ > 1 && !select.visible() ) {
5090
}).bind("search", function() {
5091
// TODO why not just specifying both arguments?
5092
var fn = (arguments.length > 1) ? arguments[1] : null;
5093
function findValueCallback(q, data) {
5095
if( data && data.length ) {
5096
for (var i=0; i < data.length; i++) {
5097
if( data[i].result.toLowerCase() == q.toLowerCase() ) {
5103
if( typeof fn == "function" ) fn(result);
5104
else $input.trigger("result", result && [result.data, result.value]);
5106
$.each(trimWords($input.val()), function(i, value) {
5107
request(value, findValueCallback, findValueCallback);
5109
}).bind("flushCache", function() {
5111
}).bind("setOptions", function() {
5112
$.extend(options, arguments[1]);
5113
// if we've updated the data, repopulate
5114
if ( "data" in arguments[1] )
5116
}).bind("unautocomplete", function() {
5119
$(input.form).unbind(".autocomplete");
5123
function selectCurrent() {
5124
var selected = select.selected();
5128
var v = selected.result;
5131
if ( options.multiple ) {
5132
var words = trimWords($input.val());
5133
if ( words.length > 1 ) {
5134
v = words.slice(0, words.length - 1).join( options.multipleSeparator ) + options.multipleSeparator + v;
5136
v += options.multipleSeparator;
5141
$input.trigger("result", [selected.data, selected.value]);
5145
function onChange(crap, skipPrevCheck) {
5146
if( lastKeyPressCode == KEY.DEL ) {
5151
var currentValue = $input.val();
5153
if ( !skipPrevCheck && currentValue == previousValue )
5156
previousValue = currentValue;
5158
currentValue = lastWord(currentValue);
5159
if ( currentValue.length >= options.minChars) {
5160
$input.addClass(options.loadingClass);
5161
if (!options.matchCase)
5162
currentValue = currentValue.toLowerCase();
5163
request(currentValue, receiveData, hideResultsNow);
5170
function trimWords(value) {
5174
var words = value.split( options.multipleSeparator );
5176
$.each(words, function(i, value) {
5177
if ( $.trim(value) )
5178
result[i] = $.trim(value);
5183
function lastWord(value) {
5184
if ( !options.multiple )
5186
var words = trimWords(value);
5187
return words[words.length - 1];
5190
// fills in the input box w/the first match (assumed to be the best match)
5191
// q: the term entered
5192
// sValue: the first matching result
5193
function autoFill(q, sValue){
5194
// autofill in the complete box w/the first match as long as the user hasn't entered in more data
5195
// if the last user key pressed was backspace, don't autofill
5196
if( options.autoFill && (lastWord($input.val()).toLowerCase() == q.toLowerCase()) && lastKeyPressCode != KEY.BACKSPACE ) {
5197
// fill in the value (keep the case the user has typed)
5198
$input.val($input.val() + sValue.substring(lastWord(previousValue).length));
5199
// select the portion of the value not typed by the user (so the next character will erase)
5200
$.Autocompleter.Selection(input, previousValue.length, previousValue.length + sValue.length);
5204
function hideResults() {
5205
clearTimeout(timeout);
5206
timeout = setTimeout(hideResultsNow, 200);
5209
function hideResultsNow() {
5210
var wasVisible = select.visible();
5212
clearTimeout(timeout);
5214
if (options.mustMatch) {
5215
// call search and run callback
5216
$input.autocomplete("search", function (result){
5217
// if no value found, clear the input box
5219
if (options.multiple) {
5220
var words = trimWords($input.val()).slice(0, -1);
5221
$input.val( words.join(options.multipleSeparator) + (words.length ? options.multipleSeparator : "") );
5230
// position cursor at end of input field
5231
$.Autocompleter.Selection(input, input.value.length, input.value.length);
5234
function receiveData(q, data) {
5235
if ( data && data.length && hasFocus ) {
5237
select.display(data, q);
5238
autoFill(q, data[0].value);
5245
function request(term, success, failure) {
5246
if (!options.matchCase)
5247
term = term.toLowerCase();
5248
var data = cache.load(term);
5249
// recieve the cached data
5250
if (data && data.length) {
5251
success(term, data);
5252
// if an AJAX url has been supplied, try loading the data now
5254
} else if( (typeof options.url == "string") && (options.url.length > 0) ){
5257
timestamp: +new Date()
5259
$.each(options.extraParams, function(key, param) {
5260
extraParams[key] = typeof param == "function" ? param() : param;
5264
// try to leverage ajaxQueue plugin to abort previous requests
5266
// limit abortion to this input
5267
port: "autocomplete" + input.name,
5268
dataType: options.dataType,
5274
success: function(data) {
5275
var parsed = options.parse && options.parse(data) || parse(data);
5276
cache.add(term, parsed);
5277
success(term, parsed);
5282
else if (options.source && typeof options.source == 'function') {
5283
var resultData = options.source(term);
5284
var parsed = (options.parse) ? options.parse(resultData) : resultData;
5286
cache.add(term, parsed);
5287
success(term, parsed);
5289
// if we have a failure, we need to empty the list -- this prevents the the [TAB] key from selecting the last successful match
5295
function parse(data) {
5297
var rows = data.split("\n");
5298
for (var i=0; i < rows.length; i++) {
5299
var row = $.trim(rows[i]);
5301
row = row.split("|");
5302
parsed[parsed.length] = {
5305
result: options.formatResult && options.formatResult(row, row[0]) || row[0]
5312
function stopLoading() {
5313
$input.removeClass(options.loadingClass);
5318
$.Autocompleter.defaults = {
5319
inputClass: "ui-autocomplete-input",
5320
resultsClass: "ui-autocomplete-results",
5321
loadingClass: "ui-autocomplete-loading",
5326
matchContains: false,
5332
formatItem: function(row) { return row[0]; },
5337
multipleSeparator: ", ",
5338
highlight: function(value, term) {
5339
return value.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + term.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi, "\\$1") + ")(?![^<>]*>)(?![^&;]+;)", "gi"), "<strong>$1</strong>");
5345
$.extend($.ui.autocomplete, {
5346
defaults: $.Autocompleter.defaults
5349
$.Autocompleter.Cache = function(options) {
5354
function matchSubset(s, sub) {
5355
if (!options.matchCase)
5356
s = s.toLowerCase();
5357
var i = s.indexOf(sub);
5358
if (i == -1) return false;
5359
return i == 0 || options.matchContains;
5362
function add(q, value) {
5363
if (length > options.cacheLength){
5372
function populate(){
5373
if( !options.data ) return false;
5374
// track the matches
5375
var stMatchSets = {},
5378
// no url was specified, we need to adjust the cache length to make sure it fits the local data store
5379
if( !options.url ) options.cacheLength = 1;
5381
// track all options for minChars = 0
5382
stMatchSets[""] = [];
5384
// loop through the array and create a lookup structure
5385
for ( var i = 0, ol = options.data.length; i < ol; i++ ) {
5386
var rawValue = options.data[i];
5387
// if rawValue is a string, make an array otherwise just reference the array
5388
rawValue = (typeof rawValue == "string") ? [rawValue] : rawValue;
5390
var value = options.formatMatch(rawValue, i+1, options.data.length);
5391
if ( value === false )
5394
var firstChar = value.charAt(0).toLowerCase();
5395
// if no lookup array for this character exists, look it up now
5396
if( !stMatchSets[firstChar] )
5397
stMatchSets[firstChar] = [];
5399
// if the match is a string
5403
result: options.formatResult && options.formatResult(rawValue) || value
5406
// push the current match into the set list
5407
stMatchSets[firstChar].push(row);
5409
// keep track of minChars zero items
5410
if ( nullData++ < options.max ) {
5411
stMatchSets[""].push(row);
5415
// add the data items to the cache
5416
$.each(stMatchSets, function(i, value) {
5417
// increase the cache size
5418
options.cacheLength++;
5424
// populate any existing data
5425
setTimeout(populate, 25);
5437
if (!options.cacheLength || !length)
5440
* if dealing w/local data and matchContains than we must make sure
5441
* to loop through all the data collections looking for matches
5443
if( !options.url && options.matchContains ){
5444
// track all matches
5446
// loop through all the data grids for matches
5447
for( var k in data ){
5448
// don't search through the stMatchSets[""] (minChars: 0) cache
5449
// this prevents duplicates
5452
$.each(c, function(i, x) {
5453
// if we've got a match, add it to the array
5454
if (matchSubset(x.value, q)) {
5462
// if the exact item exists, use it
5466
if (options.matchSubset) {
5467
for (var i = q.length - 1; i >= options.minChars; i--) {
5468
var c = data[q.substr(0, i)];
5471
$.each(c, function(i, x) {
5472
if (matchSubset(x.value, q)) {
5473
csub[csub.length] = x;
5485
$.Autocompleter.Select = function (options, input, select, config) {
5487
ACTIVE: "ui-autocomplete-over"
5502
element = $("<div/>")
5504
.addClass(options.resultsClass)
5505
.css("position", "absolute")
5506
.appendTo(document.body);
5508
list = $("<ul/>").appendTo(element).mouseover( function(event) {
5509
if(target(event).nodeName && target(event).nodeName.toUpperCase() == 'LI') {
5510
active = $("li", list).removeClass(CLASSES.ACTIVE).index(target(event));
5511
$(target(event)).addClass(CLASSES.ACTIVE);
5513
}).click(function(event) {
5514
$(target(event)).addClass(CLASSES.ACTIVE);
5516
// TODO provide option to avoid setting focus again after selection? useful for cleanup-on-focus
5519
}).mousedown(function() {
5520
config.mouseDownOnSelect = true;
5521
}).mouseup(function() {
5522
config.mouseDownOnSelect = false;
5525
if( options.width > 0 )
5526
element.css("width", options.width);
5531
function target(event) {
5532
var element = event.target;
5533
while(element && element.tagName != "LI")
5534
element = element.parentNode;
5535
// more fun with IE, sometimes event.target is empty, just ignore it then
5541
function moveSelect(step) {
5542
listItems.slice(active, active + 1).removeClass(CLASSES.ACTIVE);
5544
var activeItem = listItems.slice(active, active + 1).addClass(CLASSES.ACTIVE);
5545
if(options.scroll) {
5547
listItems.slice(0, active).each(function() {
5548
offset += this.offsetHeight;
5550
if((offset + activeItem[0].offsetHeight - list.scrollTop()) > list[0].clientHeight) {
5551
list.scrollTop(offset + activeItem[0].offsetHeight - list.innerHeight());
5552
} else if(offset < list.scrollTop()) {
5553
list.scrollTop(offset);
5558
function movePosition(step) {
5561
active = listItems.size() - 1;
5562
} else if (active >= listItems.size()) {
5567
function limitNumberOfItems(available) {
5568
return options.max && options.max < available
5573
function fillList() {
5575
var max = limitNumberOfItems(data.length);
5576
for (var i=0; i < max; i++) {
5579
var formatted = options.formatItem(data[i].data, i+1, max, data[i].value, term);
5580
if ( formatted === false )
5582
var li = $("<li/>").html( options.highlight(formatted, term) ).addClass(i%2 == 0 ? "ui-autocomplete-even" : "ui-autocomplete-odd").appendTo(list)[0];
5583
$.data(li, "ui-autocomplete-data", data[i]);
5585
listItems = list.find("li");
5586
if ( options.selectFirst ) {
5587
listItems.slice(0, 1).addClass(CLASSES.ACTIVE);
5590
// apply bgiframe if available
5591
if ( $.fn.bgiframe )
5596
display: function(d, q) {
5608
pageUp: function() {
5609
if (active != 0 && active - 8 < 0) {
5610
moveSelect( -active );
5615
pageDown: function() {
5616
if (active != listItems.size() - 1 && active + 8 > listItems.size()) {
5617
moveSelect( listItems.size() - 1 - active );
5623
element && element.hide();
5624
listItems && listItems.removeClass(CLASSES.ACTIVE)
5626
$(input).triggerHandler("autocompletehide", [{}, { options: options }], options["hide"]);
5628
visible : function() {
5629
return element && element.is(":visible");
5631
current: function() {
5632
return this.visible() && (listItems.filter("." + CLASSES.ACTIVE)[0] || options.selectFirst && listItems[0]);
5635
var offset = $(input).offset();
5637
width: typeof options.width == "string" || options.width > 0 ? options.width : $(input).width(),
5638
top: offset.top + input.offsetHeight,
5642
if(options.scroll) {
5645
maxHeight: options.scrollHeight,
5649
if($.browser.msie && typeof document.body.style.maxHeight === "undefined") {
5651
listItems.each(function() {
5652
listHeight += this.offsetHeight;
5654
var scrollbarsVisible = listHeight > options.scrollHeight;
5655
list.css('height', scrollbarsVisible ? options.scrollHeight : listHeight );
5656
if (!scrollbarsVisible) {
5657
// IE doesn't recalculate width when scrollbar disappears
5658
listItems.width( list.width() - parseInt(listItems.css("padding-left")) - parseInt(listItems.css("padding-right")) );
5664
$(input).triggerHandler("autocompleteshow", [{}, { options: options }], options["show"]);
5667
selected: function() {
5668
var selected = listItems && listItems.filter("." + CLASSES.ACTIVE).removeClass(CLASSES.ACTIVE);
5669
return selected && selected.length && $.data(selected[0], "ui-autocomplete-data");
5671
emptyList: function (){
5672
list && list.empty();
5674
unbind: function() {
5675
element && element.remove();
5680
$.Autocompleter.Selection = function(field, start, end) {
5681
if( field.createTextRange ){
5682
var selRange = field.createTextRange();
5683
selRange.collapse(true);
5684
selRange.moveStart("character", start);
5685
selRange.moveEnd("character", end);
5687
} else if( field.setSelectionRange ){
5688
field.setSelectionRange(start, end);
5690
if( field.selectionStart ){
5691
field.selectionStart = start;
5692
field.selectionEnd = end;
5700
* jQuery UI Color Picker @VERSION
5702
* Copyright (c) 2008 Stefan Petre, Paul Bakaus
5703
* Dual licensed under the MIT (MIT-LICENSE.txt)
5704
* and GPL (GPL-LICENSE.txt) licenses.
5706
* http://docs.jquery.com/UI/ColorPicker
5713
$.widget("ui.colorpicker", {
5718
var o = this.options, self = this,
5719
tpl = '<div class="ui-colorpicker clearfix"><div class="ui-colorpicker-color"><div><div></div></div></div><div class="ui-colorpicker-hue"><div></div></div><div class="ui-colorpicker-new-color"></div><div class="ui-colorpicker-current-color"></div><div class="ui-colorpicker-hex"><label for="ui-colorpicker-hex" title="hex"></label><input type="text" maxlength="6" size="6" /></div><div class="ui-colorpicker-rgb-r ui-colorpicker-field"><label for="ui-colorpicker-rgb-r"></label><input type="text" maxlength="3" size="2" /><span></span></div><div class="ui-colorpicker-rgb-g ui-colorpicker-field"><label for="ui-colorpicker-rgb-g"></label><input type="text" maxlength="3" size="2" /><span></span></div><div class="ui-colorpicker-rgb-b ui-colorpicker-field"><label for="ui-colorpicker-rgb-b"</label><input type="text" maxlength="3" size="2" /><span></span></div><div class="ui-colorpicker-hsb-h ui-colorpicker-field"><label for="ui-colorpicker-hsb-h"></label><input type="text" maxlength="3" size="2" /><span></span></div><div class="ui-colorpicker-hsb-s ui-colorpicker-field"><label for="ui-colorpicker-hsb-s"></label><input type="text" maxlength="3" size="2" /><span></span></div><div class="ui-colorpicker-hsb-b ui-colorpicker-field"><label for="ui-colorpicker-hsb-b"></label><input type="text" maxlength="3" size="2" /><span></span></div><button class="ui-colorpicker-submit ui-default-state" name="submit" type="button">Done</button></div>';
5721
if (typeof o.color == 'string') {
5722
this.color = this._HexToHSB(o.color);
5723
} else if (o.color.r != undefined && o.color.g != undefined && o.color.b != undefined) {
5724
this.color = this._RGBToHSB(o.color);
5725
} else if (o.color.h != undefined && o.color.s != undefined && o.color.b != undefined) {
5726
this.color = this._fixHSB(o.color);
5731
this.origColor = this.color;
5732
this.picker = $(tpl);
5735
this.picker.appendTo(this.element).show();
5737
this.picker.appendTo(document.body);
5740
this.fields = this.picker.find('input')
5741
.bind('keydown', function(e) { return self._keyDown.call(self, e); })
5742
.bind('change', function(e) { return self._change.call(self, e); })
5743
.bind('blur', function(e) { return self._blur.call(self, e); })
5744
.bind('focus', function(e) { return self._focus.call(self, e); });
5746
this.picker.find('span').bind('mousedown', function(e) { return self._downIncrement.call(self, e); });
5748
this.selector = this.picker.find('div.ui-colorpicker-color').bind('mousedown', function(e) { return self._downSelector.call(self, e); });
5749
this.selectorIndic = this.selector.find('div div');
5750
this.hue = this.picker.find('div.ui-colorpicker-hue div');
5751
this.picker.find('div.ui-colorpicker-hue').bind('mousedown', function(e) { return self._downHue.call(self, e); });
5753
this.newColor = this.picker.find('div.ui-colorpicker-new-color');
5754
this.currentColor = this.picker.find('div.ui-colorpicker-current-color');
5756
this.picker.find('.ui-colorpicker-submit')
5757
.bind('mouseenter', function(e) { return self._enterSubmit.call(self, e); })
5758
.bind('mouseleave', function(e) { return self._leaveSubmit.call(self, e); })
5759
.bind('click', function(e) { return self._clickSubmit.call(self, e); });
5761
this._fillRGBFields(this.color);
5762
this._fillHSBFields(this.color);
5763
this._fillHexFields(this.color);
5764
this._setHue(this.color);
5765
this._setSelector(this.color);
5766
this._setCurrentColor(this.color);
5767
this._setNewColor(this.color);
5771
position: 'relative',
5775
$(this.element).bind(o.eventName+".colorpicker", function(e) { return self._show.call(self, e); });
5780
destroy: function() {
5782
this.picker.remove();
5783
this.element.removeData("colorpicker").unbind(".colorpicker");
5787
_fillRGBFields: function(hsb) {
5788
var rgb = this._HSBToRGB(hsb);
5790
.eq(1).val(rgb.r).end()
5791
.eq(2).val(rgb.g).end()
5792
.eq(3).val(rgb.b).end();
5794
_fillHSBFields: function(hsb) {
5796
.eq(4).val(hsb.h).end()
5797
.eq(5).val(hsb.s).end()
5798
.eq(6).val(hsb.b).end();
5800
_fillHexFields: function (hsb) {
5802
.eq(0).val(this._HSBToHex(hsb)).end();
5804
_setSelector: function(hsb) {
5805
this.selector.css('backgroundColor', '#' + this._HSBToHex({h: hsb.h, s: 100, b: 100}));
5806
this.selectorIndic.css({
5807
left: parseInt(150 * hsb.s/100, 10),
5808
top: parseInt(150 * (100-hsb.b)/100, 10)
5811
_setHue: function(hsb) {
5812
this.hue.css('top', parseInt(150 - 150 * hsb.h/360, 10));
5814
_setCurrentColor: function(hsb) {
5815
this.currentColor.css('backgroundColor', '#' + this._HSBToHex(hsb));
5817
_setNewColor: function(hsb) {
5818
this.newColor.css('backgroundColor', '#' + this._HSBToHex(hsb));
5820
_keyDown: function(e) {
5821
var pressedKey = e.charCode || e.keyCode || -1;
5822
if ((pressedKey >= this.charMin && pressedKey <= 90) || pressedKey == 32) {
5826
_change: function(e, target) {
5829
target = target || e.target;
5830
if (target.parentNode.className.indexOf('-hex') > 0) {
5831
this.color = col = this._HexToHSB(this.value);
5832
this._fillRGBFields(col.color);
5833
this._fillHSBFields(col);
5834
} else if (target.parentNode.className.indexOf('-hsb') > 0) {
5835
this.color = col = this._fixHSB({
5836
h: parseInt(this.fields.eq(4).val(), 10),
5837
s: parseInt(this.fields.eq(5).val(), 10),
5838
b: parseInt(this.fields.eq(6).val(), 10)
5840
this._fillRGBFields(col);
5841
this._fillHexFields(col);
5843
this.color = col = this._RGBToHSB(this._fixRGB({
5844
r: parseInt(this.fields.eq(1).val(), 10),
5845
g: parseInt(this.fields.eq(2).val(), 10),
5846
b: parseInt(this.fields.eq(3).val(), 10)
5848
this._fillHexFields(col);
5849
this._fillHSBFields(col);
5851
this._setSelector(col);
5853
this._setNewColor(col);
5855
this._trigger('change', e, { options: this.options, hsb: col, hex: this._HSBToHex(col), rgb: this._HSBToRGB(col) });
5857
_blur: function(e) {
5859
var col = this.color;
5860
this._fillRGBFields(col);
5861
this._fillHSBFields(col);
5862
this._fillHexFields(col);
5864
this._setSelector(col);
5865
this._setNewColor(col);
5866
this.fields.parent().removeClass('ui-colorpicker-focus');
5869
_focus: function(e) {
5871
this.charMin = e.target.parentNode.className.indexOf('-hex') > 0 ? 70 : 65;
5872
this.fields.parent().removeClass('ui-colorpicker-focus');
5873
$(e.target.parentNode).addClass('ui-colorpicker-focus');
5876
_downIncrement: function(e) {
5878
var field = $(e.target).parent().find('input').focus(), self = this;
5879
this.currentIncrement = {
5880
el: $(e.target).parent().addClass('ui-colorpicker-slider'),
5881
max: e.target.parentNode.className.indexOf('-hsb-h') > 0 ? 360 : (e.target.parentNode.className.indexOf('-hsb') > 0 ? 100 : 255),
5884
val: parseInt(field.val(), 10)
5886
$(document).bind('mouseup.cpSlider', function(e) { return self._upIncrement.call(self, e); });
5887
$(document).bind('mousemove.cpSlider', function(e) { return self._moveIncrement.call(self, e); });
5891
_moveIncrement: function(e) {
5892
this.currentIncrement.field.val(Math.max(0, Math.min(this.currentIncrement.max, parseInt(this.currentIncrement.val + e.pageY - this.currentIncrement.y, 10))));
5893
this._change.apply(this, [e, this.currentIncrement.field.get(0)]);
5896
_upIncrement: function(e) {
5897
this.currentIncrement.el.removeClass('ui-colorpicker-slider').find('input').focus();
5898
this._change.apply(this, [e, this.currentIncrement.field.get(0)]);
5899
$(document).unbind('mouseup.cpSlider');
5900
$(document).unbind('mousemove.cpSlider');
5903
_downHue: function(e) {
5906
y: this.picker.find('div.ui-colorpicker-hue').offset().top
5909
this._change.apply(this, [e, this
5912
.val(parseInt(360*(150 - Math.max(0,Math.min(150,(e.pageY - this.currentHue.y))))/150, 10))
5916
$(document).bind('mouseup.cpSlider', function(e) { return self._upHue.call(self, e); });
5917
$(document).bind('mousemove.cpSlider', function(e) { return self._moveHue.call(self, e); });
5921
_moveHue: function(e) {
5923
this._change.apply(this, [e, this
5926
.val(parseInt(360*(150 - Math.max(0,Math.min(150,(e.pageY - this.currentHue.y))))/150, 10))
5932
_upHue: function(e) {
5933
$(document).unbind('mouseup.cpSlider');
5934
$(document).unbind('mousemove.cpSlider');
5937
_downSelector: function(e) {
5940
this.currentSelector = {
5941
pos: this.picker.find('div.ui-colorpicker-color').offset()
5944
this._change.apply(this, [e, this
5947
.val(parseInt(100*(150 - Math.max(0,Math.min(150,(e.pageY - this.currentSelector.pos.top))))/150, 10))
5950
.val(parseInt(100*(Math.max(0,Math.min(150,(e.pageX - this.currentSelector.pos.left))))/150, 10))
5953
$(document).bind('mouseup.cpSlider', function(e) { return self._upSelector.call(self, e); });
5954
$(document).bind('mousemove.cpSlider', function(e) { return self._moveSelector.call(self, e); });
5958
_moveSelector: function(e) {
5960
this._change.apply(this, [e, this
5963
.val(parseInt(100*(150 - Math.max(0,Math.min(150,(e.pageY - this.currentSelector.pos.top))))/150, 10))
5966
.val(parseInt(100*(Math.max(0,Math.min(150,(e.pageX - this.currentSelector.pos.left))))/150, 10))
5972
_upSelector: function(e) {
5973
$(document).unbind('mouseup.cpSlider');
5974
$(document).unbind('mousemove.cpSlider');
5977
_enterSubmit: function(e) {
5978
this.picker.find('.ui-colorpicker-submit').addClass('ui-colorpicker-focus');
5980
_leaveSubmit: function(e) {
5981
this.picker.find('.ui-colorpicker-submit').removeClass('ui-colorpicker-focus');
5983
_clickSubmit: function(e) {
5985
var col = this.color;
5986
this.origColor = col;
5987
this._setCurrentColor(col);
5989
this._trigger("submit", e, { options: this.options, hsb: col, hex: this._HSBToHex(col), rgb: this._HSBToRGB(col) });
5993
_show: function(e) {
5995
this._trigger("beforeShow", e, { options: this.options, hsb: this.color, hex: this._HSBToHex(this.color), rgb: this._HSBToRGB(this.color) });
5997
var pos = this.element.offset();
5998
var viewPort = this._getScroll();
5999
var top = pos.top + this.element[0].offsetHeight;
6000
var left = pos.left;
6001
if (top + 176 > viewPort.t + Math.min(viewPort.h,viewPort.ih)) {
6002
top -= this.element[0].offsetHeight + 176;
6004
if (left + 356 > viewPort.l + Math.min(viewPort.w,viewPort.iw)) {
6007
this.picker.css({left: left + 'px', top: top + 'px'});
6008
if (this._trigger("show", e, { options: this.options, hsb: this.color, hex: this._HSBToHex(this.color), rgb: this._HSBToRGB(this.color) }) != false) {
6013
$(document).bind('mousedown.colorpicker', function(e) { return self._hide.call(self, e); });
6017
_hide: function(e) {
6019
if (!this._isChildOf(this.picker[0], e.target, this.picker[0])) {
6020
if (this._trigger("hide", e, { options: this.options, hsb: this.color, hex: this._HSBToHex(this.color), rgb: this._HSBToRGB(this.color) }) != false) {
6023
$(document).unbind('mousedown.colorpicker');
6027
_isChildOf: function(parentEl, el, container) {
6028
if (parentEl == el) {
6031
if (parentEl.contains && !$.browser.safari) {
6032
return parentEl.contains(el);
6034
if ( parentEl.compareDocumentPosition ) {
6035
return !!(parentEl.compareDocumentPosition(el) & 16);
6037
var prEl = el.parentNode;
6038
while(prEl && prEl != container) {
6039
if (prEl == parentEl)
6041
prEl = prEl.parentNode;
6045
_getScroll: function() {
6047
if (document.documentElement) {
6048
t = document.documentElement.scrollTop;
6049
l = document.documentElement.scrollLeft;
6050
w = document.documentElement.scrollWidth;
6051
h = document.documentElement.scrollHeight;
6053
t = document.body.scrollTop;
6054
l = document.body.scrollLeft;
6055
w = document.body.scrollWidth;
6056
h = document.body.scrollHeight;
6058
iw = self.innerWidth||document.documentElement.clientWidth||document.body.clientWidth||0;
6059
ih = self.innerHeight||document.documentElement.clientHeight||document.body.clientHeight||0;
6060
return { t: t, l: l, w: w, h: h, iw: iw, ih: ih };
6062
_fixHSB: function(hsb) {
6064
h: Math.min(360, Math.max(0, hsb.h)),
6065
s: Math.min(100, Math.max(0, hsb.s)),
6066
b: Math.min(100, Math.max(0, hsb.b))
6069
_fixRGB: function(rgb) {
6071
r: Math.min(255, Math.max(0, rgb.r)),
6072
g: Math.min(255, Math.max(0, rgb.g)),
6073
b: Math.min(255, Math.max(0, rgb.b))
6076
_HexToRGB: function (hex) {
6077
var hex = parseInt(((hex.indexOf('#') > -1) ? hex.substring(1) : hex), 16);
6078
return {r: hex >> 16, g: (hex & 0x00FF00) >> 8, b: (hex & 0x0000FF)};
6080
_HexToHSB: function(hex) {
6081
return this._RGBToHSB(this._HexToRGB(hex));
6083
_RGBToHSB: function(rgb) {
6085
hsb.b = Math.max(Math.max(rgb.r,rgb.g),rgb.b);
6086
hsb.s = (hsb.b <= 0) ? 0 : Math.round(100*(hsb.b - Math.min(Math.min(rgb.r,rgb.g),rgb.b))/hsb.b);
6087
hsb.b = Math.round((hsb.b /255)*100);
6088
if((rgb.r==rgb.g) && (rgb.g==rgb.b)) hsb.h = 0;
6089
else if(rgb.r>=rgb.g && rgb.g>=rgb.b) hsb.h = 60*(rgb.g-rgb.b)/(rgb.r-rgb.b);
6090
else if(rgb.g>=rgb.r && rgb.r>=rgb.b) hsb.h = 60 + 60*(rgb.g-rgb.r)/(rgb.g-rgb.b);
6091
else if(rgb.g>=rgb.b && rgb.b>=rgb.r) hsb.h = 120 + 60*(rgb.b-rgb.r)/(rgb.g-rgb.r);
6092
else if(rgb.b>=rgb.g && rgb.g>=rgb.r) hsb.h = 180 + 60*(rgb.b-rgb.g)/(rgb.b-rgb.r);
6093
else if(rgb.b>=rgb.r && rgb.r>=rgb.g) hsb.h = 240 + 60*(rgb.r-rgb.g)/(rgb.b-rgb.g);
6094
else if(rgb.r>=rgb.b && rgb.b>=rgb.g) hsb.h = 300 + 60*(rgb.r-rgb.b)/(rgb.r-rgb.g);
6096
hsb.h = Math.round(hsb.h);
6099
_HSBToRGB: function(hsb) {
6101
var h = Math.round(hsb.h);
6102
var s = Math.round(hsb.s*255/100);
6103
var v = Math.round(hsb.b*255/100);
6105
rgb.r = rgb.g = rgb.b = v;
6108
var t2 = (255-s)*v/255;
6109
var t3 = (t1-t2)*(h%60)/60;
6111
if(h<60) {rgb.r=t1; rgb.b=t2; rgb.g=t2+t3;}
6112
else if(h<120) {rgb.g=t1; rgb.b=t2; rgb.r=t1-t3;}
6113
else if(h<180) {rgb.g=t1; rgb.r=t2; rgb.b=t2+t3;}
6114
else if(h<240) {rgb.b=t1; rgb.r=t2; rgb.g=t1-t3;}
6115
else if(h<300) {rgb.b=t1; rgb.g=t2; rgb.r=t2+t3;}
6116
else if(h<360) {rgb.r=t1; rgb.g=t2; rgb.b=t1-t3;}
6117
else {rgb.r=0; rgb.g=0; rgb.b=0;}
6119
return {r:Math.round(rgb.r), g:Math.round(rgb.g), b:Math.round(rgb.b)};
6121
_RGBToHex: function(rgb) {
6127
$.each(hex, function (nr, val) {
6128
if (val.length == 1) {
6129
hex[nr] = '0' + val;
6132
return hex.join('');
6134
_HSBToHex: function(hsb) {
6135
return this._RGBToHex(this._HSBToRGB(hsb));
6137
setColor: function(col) {
6138
if (typeof col == 'string') {
6139
col = this._HexToHSB(col);
6140
} else if (col.r != undefined && col.g != undefined && col.b != undefined) {
6141
col = this._RGBToHSB(col);
6142
} else if (col.h != undefined && col.s != undefined && col.b != undefined) {
6143
col = this._fixHSB(col);
6149
this.origColor = col;
6150
this._fillRGBFields(col);
6151
this._fillHSBFields(col);
6152
this._fillHexFields(col);
6154
this._setSelector(col);
6155
this._setCurrentColor(col);
6156
this._setNewColor(col);
6162
$.extend($.ui.colorpicker, {
6171
* jQuery UI Datepicker @VERSION
6173
* Copyright (c) 2006, 2007, 2008 Marc Grabanski
6174
* Dual licensed under the MIT (MIT-LICENSE.txt)
6175
* and GPL (GPL-LICENSE.txt) licenses.
6177
* http://docs.jquery.com/UI/Datepicker
6182
* Marc Grabanski (m@marcgrabanski.com) and Keith Wood (kbwood@virginbroadband.com.au).
6185
(function($) { // hide the namespace
6187
var PROP_NAME = 'datepicker';
6189
/* Date picker manager.
6190
Use the singleton instance of this class, $.datepicker, to interact with the date picker.
6191
Settings for (groups of) date pickers are maintained in an instance object,
6192
allowing multiple different settings on the same page. */
6194
function Datepicker() {
6195
this.debug = false; // Change this to true to start debugging
6196
this._curInst = null; // The current instance in use
6197
this._disabledInputs = []; // List of date picker inputs that have been disabled
6198
this._datepickerShowing = false; // True if the popup picker is showing , false if not
6199
this._inDialog = false; // True if showing within a "dialog", false if not
6200
this._mainDivId = 'ui-datepicker-div'; // The ID of the main datepicker division
6201
this._inlineClass = 'ui-datepicker-inline'; // The name of the inline marker class
6202
this._appendClass = 'ui-datepicker-append'; // The name of the append marker class
6203
this._triggerClass = 'ui-datepicker-trigger'; // The name of the trigger marker class
6204
this._dialogClass = 'ui-datepicker-dialog'; // The name of the dialog marker class
6205
this._promptClass = 'ui-datepicker-prompt'; // The name of the dialog prompt marker class
6206
this._disableClass = 'ui-datepicker-disabled'; // The name of the disabled covering marker class
6207
this._unselectableClass = 'ui-datepicker-unselectable'; // The name of the unselectable cell marker class
6208
this._currentClass = 'ui-datepicker-current-day'; // The name of the current day marker class
6209
this.regional = []; // Available regional settings, indexed by language code
6210
this.regional[''] = { // Default regional settings
6211
clearText: 'Clear', // Display text for clear link
6212
clearStatus: 'Erase the current date', // Status text for clear link
6213
closeText: 'Close', // Display text for close link
6214
closeStatus: 'Close without change', // Status text for close link
6215
prevText: '<Prev', // Display text for previous month link
6216
prevStatus: 'Show the previous month', // Status text for previous month link
6217
prevBigText: '<<', // Display text for previous year link
6218
prevBigStatus: 'Show the previous year', // Status text for previous year link
6219
nextText: 'Next>', // Display text for next month link
6220
nextStatus: 'Show the next month', // Status text for next month link
6221
nextBigText: '>>', // Display text for next year link
6222
nextBigStatus: 'Show the next year', // Status text for next year link
6223
currentText: 'Today', // Display text for current month link
6224
currentStatus: 'Show the current month', // Status text for current month link
6225
monthNames: ['January','February','March','April','May','June',
6226
'July','August','September','October','November','December'], // Names of months for drop-down and formatting
6227
monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], // For formatting
6228
monthStatus: 'Show a different month', // Status text for selecting a month
6229
yearStatus: 'Show a different year', // Status text for selecting a year
6230
weekHeader: 'Wk', // Header for the week of the year column
6231
weekStatus: 'Week of the year', // Status text for the week of the year column
6232
dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], // For formatting
6233
dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], // For formatting
6234
dayNamesMin: ['Su','Mo','Tu','We','Th','Fr','Sa'], // Column headings for days starting at Sunday
6235
dayStatus: 'Set DD as first week day', // Status text for the day of the week selection
6236
dateStatus: 'Select DD, M d', // Status text for the date selection
6237
dateFormat: 'mm/dd/yy', // See format options on parseDate
6238
firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
6239
initStatus: 'Select a date', // Initial Status text on opening
6240
isRTL: false // True if right-to-left language, false if left-to-right
6242
this._defaults = { // Global defaults for all the date picker instances
6243
showOn: 'focus', // 'focus' for popup on focus,
6244
// 'button' for trigger button, or 'both' for either
6245
showAnim: 'show', // Name of jQuery animation for popup
6246
showOptions: {}, // Options for enhanced animations
6247
defaultDate: null, // Used when field is blank: actual date,
6248
// +/-number for offset from today, null for today
6249
appendText: '', // Display text following the input box, e.g. showing the format
6250
buttonText: '...', // Text for trigger button
6251
buttonImage: '', // URL for trigger button image
6252
buttonImageOnly: false, // True if the image appears alone, false if it appears on a button
6253
closeAtTop: true, // True to have the clear/close at the top,
6254
// false to have them at the bottom
6255
mandatory: false, // True to hide the Clear link, false to include it
6256
hideIfNoPrevNext: false, // True to hide next/previous month links
6257
// if not applicable, false to just disable them
6258
navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links
6259
showBigPrevNext: false, // True to show big prev/next links
6260
gotoCurrent: false, // True if today link goes back to current selection instead
6261
changeMonth: true, // True if month can be selected directly, false if only prev/next
6262
changeYear: true, // True if year can be selected directly, false if only prev/next
6263
showMonthAfterYear: false, // True if the year select precedes month, false for month then year
6264
yearRange: '-10:+10', // Range of years to display in drop-down,
6265
// either relative to current year (-nn:+nn) or absolute (nnnn:nnnn)
6266
changeFirstDay: true, // True to click on day name to change, false to remain as set
6267
highlightWeek: false, // True to highlight the selected week
6268
showOtherMonths: false, // True to show dates in other months, false to leave blank
6269
showWeeks: false, // True to show week of the year, false to omit
6270
calculateWeek: this.iso8601Week, // How to calculate the week of the year,
6271
// takes a Date and returns the number of the week for it
6272
shortYearCutoff: '+10', // Short year values < this are in the current century,
6273
// > this are in the previous century,
6274
// string value starting with '+' for current year + value
6275
showStatus: false, // True to show status bar at bottom, false to not show it
6276
statusForDate: this.dateStatus, // Function to provide status text for a date -
6277
// takes date and instance as parameters, returns display text
6278
minDate: null, // The earliest selectable date, or null for no limit
6279
maxDate: null, // The latest selectable date, or null for no limit
6280
duration: 'normal', // Duration of display/closure
6281
beforeShowDay: null, // Function that takes a date and returns an array with
6282
// [0] = true if selectable, false if not, [1] = custom CSS class name(s) or '',
6283
// [2] = cell title (optional), e.g. $.datepicker.noWeekends
6284
beforeShow: null, // Function that takes an input field and
6285
// returns a set of custom settings for the date picker
6286
onSelect: null, // Define a callback function when a date is selected
6287
onChangeMonthYear: null, // Define a callback function when the month or year is changed
6288
onClose: null, // Define a callback function when the datepicker is closed
6289
numberOfMonths: 1, // Number of months to show at a time
6290
showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0)
6291
stepMonths: 1, // Number of months to step back/forward
6292
stepBigMonths: 12, // Number of months to step back/forward for the big links
6293
rangeSelect: false, // Allows for selecting a date range on one date picker
6294
rangeSeparator: ' - ', // Text between two dates in a range
6295
altField: '', // Selector for an alternate field to store selected dates into
6296
altFormat: '' // The date format to use for the alternate field
6298
$.extend(this._defaults, this.regional['']);
6299
this.dpDiv = $('<div id="' + this._mainDivId + '" style="display: none;"></div>');
6302
$.extend(Datepicker.prototype, {
6303
/* Class name added to elements to indicate already configured with a date picker. */
6304
markerClassName: 'hasDatepicker',
6306
/* Debug logging (if enabled). */
6309
console.log.apply('', arguments);
6312
/* Override the default settings for all instances of the date picker.
6313
@param settings object - the new settings to use as defaults (anonymous object)
6314
@return the manager object */
6315
setDefaults: function(settings) {
6316
extendRemove(this._defaults, settings || {});
6320
/* Attach the date picker to a jQuery selection.
6321
@param target element - the target input field or division or span
6322
@param settings object - the new settings to use for this date picker instance (anonymous) */
6323
_attachDatepicker: function(target, settings) {
6324
// check for settings on the control itself - in namespace 'date:'
6325
var inlineSettings = null;
6326
for (attrName in this._defaults) {
6327
var attrValue = target.getAttribute('date:' + attrName);
6329
inlineSettings = inlineSettings || {};
6331
inlineSettings[attrName] = eval(attrValue);
6333
inlineSettings[attrName] = attrValue;
6337
var nodeName = target.nodeName.toLowerCase();
6338
var inline = (nodeName == 'div' || nodeName == 'span');
6340
target.id = 'dp' + (++this.uuid);
6341
var inst = this._newInst($(target), inline);
6342
inst.settings = $.extend({}, settings || {}, inlineSettings || {});
6343
if (nodeName == 'input') {
6344
this._connectDatepicker(target, inst);
6345
} else if (inline) {
6346
this._inlineDatepicker(target, inst);
6350
/* Create a new instance object. */
6351
_newInst: function(target, inline) {
6352
var id = target[0].id.replace(/([:\[\]\.])/g, '\\\\$1'); // escape jQuery meta chars
6353
return {id: id, input: target, // associated target
6354
selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection
6355
drawMonth: 0, drawYear: 0, // month being drawn
6356
inline: inline, // is datepicker inline or not
6357
dpDiv: (!inline ? this.dpDiv : // presentation div
6358
$('<div class="' + this._inlineClass + '"></div>'))};
6361
/* Attach the date picker to an input field. */
6362
_connectDatepicker: function(target, inst) {
6363
var input = $(target);
6364
if (input.hasClass(this.markerClassName))
6366
var appendText = this._get(inst, 'appendText');
6367
var isRTL = this._get(inst, 'isRTL');
6369
input[isRTL ? 'before' : 'after']('<span class="' + this._appendClass + '">' + appendText + '</span>');
6370
var showOn = this._get(inst, 'showOn');
6371
if (showOn == 'focus' || showOn == 'both') // pop-up date picker when in the marked field
6372
input.focus(this._showDatepicker);
6373
if (showOn == 'button' || showOn == 'both') { // pop-up date picker when button clicked
6374
var buttonText = this._get(inst, 'buttonText');
6375
var buttonImage = this._get(inst, 'buttonImage');
6376
var trigger = $(this._get(inst, 'buttonImageOnly') ?
6377
$('<img/>').addClass(this._triggerClass).
6378
attr({ src: buttonImage, alt: buttonText, title: buttonText }) :
6379
$('<button type="button"></button>').addClass(this._triggerClass).
6380
html(buttonImage == '' ? buttonText : $('<img/>').attr(
6381
{ src:buttonImage, alt:buttonText, title:buttonText })));
6382
input[isRTL ? 'before' : 'after'](trigger);
6383
trigger.click(function() {
6384
if ($.datepicker._datepickerShowing && $.datepicker._lastInput == target)
6385
$.datepicker._hideDatepicker();
6387
$.datepicker._showDatepicker(target);
6391
input.addClass(this.markerClassName).keydown(this._doKeyDown).keypress(this._doKeyPress).
6392
bind("setData.datepicker", function(event, key, value) {
6393
inst.settings[key] = value;
6394
}).bind("getData.datepicker", function(event, key) {
6395
return this._get(inst, key);
6397
$.data(target, PROP_NAME, inst);
6400
/* Attach an inline date picker to a div. */
6401
_inlineDatepicker: function(target, inst) {
6402
var divSpan = $(target);
6403
if (divSpan.hasClass(this.markerClassName))
6405
divSpan.addClass(this.markerClassName).append(inst.dpDiv).
6406
bind("setData.datepicker", function(event, key, value){
6407
inst.settings[key] = value;
6408
}).bind("getData.datepicker", function(event, key){
6409
return this._get(inst, key);
6411
$.data(target, PROP_NAME, inst);
6412
this._setDate(inst, this._getDefaultDate(inst));
6413
this._updateDatepicker(inst);
6416
/* Tidy up after displaying the date picker. */
6417
_inlineShow: function(inst) {
6418
var numMonths = this._getNumberOfMonths(inst); // fix width for dynamic number of date pickers
6419
inst.dpDiv.width(numMonths[1] * $('.ui-datepicker', inst.dpDiv[0]).width());
6422
/* Pop-up the date picker in a "dialog" box.
6423
@param input element - ignored
6424
@param dateText string - the initial date to display (in the current format)
6425
@param onSelect function - the function(dateText) to call when a date is selected
6426
@param settings object - update the dialog date picker instance's settings (anonymous object)
6427
@param pos int[2] - coordinates for the dialog's position within the screen or
6428
event - with x/y coordinates or
6429
leave empty for default (screen centre)
6430
@return the manager object */
6431
_dialogDatepicker: function(input, dateText, onSelect, settings, pos) {
6432
var inst = this._dialogInst; // internal instance
6434
var id = 'dp' + (++this.uuid);
6435
this._dialogInput = $('<input type="text" id="' + id +
6436
'" size="1" style="position: absolute; top: -100px;"/>');
6437
this._dialogInput.keydown(this._doKeyDown);
6438
$('body').append(this._dialogInput);
6439
inst = this._dialogInst = this._newInst(this._dialogInput, false);
6441
$.data(this._dialogInput[0], PROP_NAME, inst);
6443
extendRemove(inst.settings, settings || {});
6444
this._dialogInput.val(dateText);
6446
this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null);
6448
var browserWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
6449
var browserHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
6450
var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
6451
var scrollY = document.documentElement.scrollTop || document.body.scrollTop;
6452
this._pos = // should use actual width/height below
6453
[(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY];
6456
// move input on screen for focus, but hidden behind dialog
6457
this._dialogInput.css('left', this._pos[0] + 'px').css('top', this._pos[1] + 'px');
6458
inst.settings.onSelect = onSelect;
6459
this._inDialog = true;
6460
this.dpDiv.addClass(this._dialogClass);
6461
this._showDatepicker(this._dialogInput[0]);
6463
$.blockUI(this.dpDiv);
6464
$.data(this._dialogInput[0], PROP_NAME, inst);
6468
/* Detach a datepicker from its control.
6469
@param target element - the target input field or division or span */
6470
_destroyDatepicker: function(target) {
6471
var $target = $(target);
6472
if (!$target.hasClass(this.markerClassName)) {
6475
var nodeName = target.nodeName.toLowerCase();
6476
$.removeData(target, PROP_NAME);
6477
if (nodeName == 'input') {
6478
$target.siblings('.' + this._appendClass).remove().end().
6479
siblings('.' + this._triggerClass).remove().end().
6480
removeClass(this.markerClassName).
6481
unbind('focus', this._showDatepicker).
6482
unbind('keydown', this._doKeyDown).
6483
unbind('keypress', this._doKeyPress);
6484
} else if (nodeName == 'div' || nodeName == 'span')
6485
$target.removeClass(this.markerClassName).empty();
6488
/* Enable the date picker to a jQuery selection.
6489
@param target element - the target input field or division or span */
6490
_enableDatepicker: function(target) {
6491
var $target = $(target);
6492
if (!$target.hasClass(this.markerClassName)) {
6495
var nodeName = target.nodeName.toLowerCase();
6496
if (nodeName == 'input') {
6497
target.disabled = false;
6498
$target.siblings('button.' + this._triggerClass).
6499
each(function() { this.disabled = false; }).end().
6500
siblings('img.' + this._triggerClass).
6501
css({opacity: '1.0', cursor: ''});
6503
else if (nodeName == 'div' || nodeName == 'span') {
6504
$target.children('.' + this._disableClass).remove();
6506
this._disabledInputs = $.map(this._disabledInputs,
6507
function(value) { return (value == target ? null : value); }); // delete entry
6510
/* Disable the date picker to a jQuery selection.
6511
@param target element - the target input field or division or span */
6512
_disableDatepicker: function(target) {
6513
var $target = $(target);
6514
if (!$target.hasClass(this.markerClassName)) {
6517
var nodeName = target.nodeName.toLowerCase();
6518
if (nodeName == 'input') {
6519
target.disabled = true;
6520
$target.siblings('button.' + this._triggerClass).
6521
each(function() { this.disabled = true; }).end().
6522
siblings('img.' + this._triggerClass).
6523
css({opacity: '0.5', cursor: 'default'});
6525
else if (nodeName == 'div' || nodeName == 'span') {
6526
var inline = $target.children('.' + this._inlineClass);
6527
var offset = inline.offset();
6528
var relOffset = {left: 0, top: 0};
6529
inline.parents().each(function() {
6530
if ($(this).css('position') == 'relative') {
6531
relOffset = $(this).offset();
6535
$target.prepend('<div class="' + this._disableClass + '" style="' +
6536
($.browser.msie ? 'background-color: transparent; ' : '') +
6537
'width: ' + inline.width() + 'px; height: ' + inline.height() +
6538
'px; left: ' + (offset.left - relOffset.left) +
6539
'px; top: ' + (offset.top - relOffset.top) + 'px;"></div>');
6541
this._disabledInputs = $.map(this._disabledInputs,
6542
function(value) { return (value == target ? null : value); }); // delete entry
6543
this._disabledInputs[this._disabledInputs.length] = target;
6546
/* Is the first field in a jQuery collection disabled as a datepicker?
6547
@param target element - the target input field or division or span
6548
@return boolean - true if disabled, false if enabled */
6549
_isDisabledDatepicker: function(target) {
6552
for (var i = 0; i < this._disabledInputs.length; i++) {
6553
if (this._disabledInputs[i] == target)
6559
/* Retrieve the instance data for the target control.
6560
@param target element - the target input field or division or span
6561
@return object - the associated instance data
6562
@throws error if a jQuery problem getting data */
6563
_getInst: function(target) {
6565
return $.data(target, PROP_NAME);
6568
throw 'Missing instance data for this datepicker';
6572
/* Update the settings for a date picker attached to an input field or division.
6573
@param target element - the target input field or division or span
6574
@param name object - the new settings to update or
6575
string - the name of the setting to change or
6576
@param value any - the new value for the setting (omit if above is an object) */
6577
_changeDatepicker: function(target, name, value) {
6578
var settings = name || {};
6579
if (typeof name == 'string') {
6581
settings[name] = value;
6583
var inst = this._getInst(target);
6585
if (this._curInst == inst) {
6586
this._hideDatepicker(null);
6588
extendRemove(inst.settings, settings);
6589
var date = new Date();
6590
extendRemove(inst, {rangeStart: null, // start of range
6591
endDay: null, endMonth: null, endYear: null, // end of range
6592
selectedDay: date.getDate(), selectedMonth: date.getMonth(),
6593
selectedYear: date.getFullYear(), // starting point
6594
currentDay: date.getDate(), currentMonth: date.getMonth(),
6595
currentYear: date.getFullYear(), // current selection
6596
drawMonth: date.getMonth(), drawYear: date.getFullYear()}); // month being drawn
6597
this._updateDatepicker(inst);
6601
/* Redraw the date picker attached to an input field or division.
6602
@param target element - the target input field or division or span */
6603
_refreshDatepicker: function(target) {
6604
var inst = this._getInst(target);
6606
this._updateDatepicker(inst);
6610
/* Set the dates for a jQuery selection.
6611
@param target element - the target input field or division or span
6612
@param date Date - the new date
6613
@param endDate Date - the new end date for a range (optional) */
6614
_setDateDatepicker: function(target, date, endDate) {
6615
var inst = this._getInst(target);
6617
this._setDate(inst, date, endDate);
6618
this._updateDatepicker(inst);
6619
this._updateAlternate(inst);
6623
/* Get the date(s) for the first entry in a jQuery selection.
6624
@param target element - the target input field or division or span
6625
@return Date - the current date or
6626
Date[2] - the current dates for a range */
6627
_getDateDatepicker: function(target) {
6628
var inst = this._getInst(target);
6629
if (inst && !inst.inline)
6630
this._setDateFromField(inst);
6631
return (inst ? this._getDate(inst) : null);
6634
/* Handle keystrokes. */
6635
_doKeyDown: function(e) {
6636
var inst = $.datepicker._getInst(e.target);
6638
if ($.datepicker._datepickerShowing)
6639
switch (e.keyCode) {
6640
case 9: $.datepicker._hideDatepicker(null, '');
6641
break; // hide on tab out
6642
case 13: $.datepicker._selectDay(e.target, inst.selectedMonth, inst.selectedYear,
6643
$('td.ui-datepicker-days-cell-over', inst.dpDiv)[0]);
6644
return false; // don't submit the form
6645
break; // select the value on enter
6646
case 27: $.datepicker._hideDatepicker(null, $.datepicker._get(inst, 'duration'));
6647
break; // hide on escape
6648
case 33: $.datepicker._adjustDate(e.target, (e.ctrlKey ?
6649
-$.datepicker._get(inst, 'stepBigMonths') :
6650
-$.datepicker._get(inst, 'stepMonths')), 'M');
6651
break; // previous month/year on page up/+ ctrl
6652
case 34: $.datepicker._adjustDate(e.target, (e.ctrlKey ?
6653
+$.datepicker._get(inst, 'stepBigMonths') :
6654
+$.datepicker._get(inst, 'stepMonths')), 'M');
6655
break; // next month/year on page down/+ ctrl
6656
case 35: if (e.ctrlKey) $.datepicker._clearDate(e.target);
6657
handled = e.ctrlKey;
6658
break; // clear on ctrl+end
6659
case 36: if (e.ctrlKey) $.datepicker._gotoToday(e.target);
6660
handled = e.ctrlKey;
6661
break; // current on ctrl+home
6662
case 37: if (e.ctrlKey) $.datepicker._adjustDate(e.target, -1, 'D');
6663
handled = e.ctrlKey;
6664
break; // -1 day on ctrl+left
6665
case 38: if (e.ctrlKey) $.datepicker._adjustDate(e.target, -7, 'D');
6666
handled = e.ctrlKey;
6667
break; // -1 week on ctrl+up
6668
case 39: if (e.ctrlKey) $.datepicker._adjustDate(e.target, +1, 'D');
6669
handled = e.ctrlKey;
6670
break; // +1 day on ctrl+right
6671
case 40: if (e.ctrlKey) $.datepicker._adjustDate(e.target, +7, 'D');
6672
handled = e.ctrlKey;
6673
break; // +1 week on ctrl+down
6674
default: handled = false;
6676
else if (e.keyCode == 36 && e.ctrlKey) // display the date picker on ctrl+home
6677
$.datepicker._showDatepicker(this);
6682
e.stopPropagation();
6686
/* Filter entered characters - based on date format. */
6687
_doKeyPress: function(e) {
6688
var inst = $.datepicker._getInst(e.target);
6689
var chars = $.datepicker._possibleChars($.datepicker._get(inst, 'dateFormat'));
6690
var chr = String.fromCharCode(e.charCode == undefined ? e.keyCode : e.charCode);
6691
return e.ctrlKey || (chr < ' ' || !chars || chars.indexOf(chr) > -1);
6694
/* Pop-up the date picker for a given input field.
6695
@param input element - the input field attached to the date picker or
6696
event - if triggered by focus */
6697
_showDatepicker: function(input) {
6698
input = input.target || input;
6699
if (input.nodeName.toLowerCase() != 'input') // find from button/image trigger
6700
input = $('input', input.parentNode)[0];
6701
if ($.datepicker._isDisabledDatepicker(input) || $.datepicker._lastInput == input) // already here
6703
var inst = $.datepicker._getInst(input);
6704
var beforeShow = $.datepicker._get(inst, 'beforeShow');
6705
extendRemove(inst.settings, (beforeShow ? beforeShow.apply(input, [input, inst]) : {}));
6706
$.datepicker._hideDatepicker(null, '');
6707
$.datepicker._lastInput = input;
6708
$.datepicker._setDateFromField(inst);
6709
if ($.datepicker._inDialog) // hide cursor
6711
if (!$.datepicker._pos) { // position below input
6712
$.datepicker._pos = $.datepicker._findPos(input);
6713
$.datepicker._pos[1] += input.offsetHeight; // add the height
6715
var isFixed = false;
6716
$(input).parents().each(function() {
6717
isFixed |= $(this).css('position') == 'fixed';
6720
if (isFixed && $.browser.opera) { // correction for Opera when fixed and scrolled
6721
$.datepicker._pos[0] -= document.documentElement.scrollLeft;
6722
$.datepicker._pos[1] -= document.documentElement.scrollTop;
6724
var offset = {left: $.datepicker._pos[0], top: $.datepicker._pos[1]};
6725
$.datepicker._pos = null;
6726
inst.rangeStart = null;
6727
// determine sizing offscreen
6728
inst.dpDiv.css({position: 'absolute', display: 'block', top: '-1000px'});
6729
$.datepicker._updateDatepicker(inst);
6730
// fix width for dynamic number of date pickers
6731
inst.dpDiv.width($.datepicker._getNumberOfMonths(inst)[1] *
6732
$('.ui-datepicker', inst.dpDiv[0])[0].offsetWidth);
6733
// and adjust position before showing
6734
offset = $.datepicker._checkOffset(inst, offset, isFixed);
6735
inst.dpDiv.css({position: ($.datepicker._inDialog && $.blockUI ?
6736
'static' : (isFixed ? 'fixed' : 'absolute')), display: 'none',
6737
left: offset.left + 'px', top: offset.top + 'px'});
6739
var showAnim = $.datepicker._get(inst, 'showAnim') || 'show';
6740
var duration = $.datepicker._get(inst, 'duration');
6741
var postProcess = function() {
6742
$.datepicker._datepickerShowing = true;
6743
if ($.browser.msie && parseInt($.browser.version,10) < 7) // fix IE < 7 select problems
6744
$('iframe.ui-datepicker-cover').css({width: inst.dpDiv.width() + 4,
6745
height: inst.dpDiv.height() + 4});
6747
if ($.effects && $.effects[showAnim])
6748
inst.dpDiv.show(showAnim, $.datepicker._get(inst, 'showOptions'), duration, postProcess);
6750
inst.dpDiv[showAnim](duration, postProcess);
6753
if (inst.input[0].type != 'hidden')
6754
inst.input[0].focus();
6755
$.datepicker._curInst = inst;
6759
/* Generate the date picker content. */
6760
_updateDatepicker: function(inst) {
6761
var dims = {width: inst.dpDiv.width() + 4,
6762
height: inst.dpDiv.height() + 4};
6763
inst.dpDiv.empty().append(this._generateHTML(inst)).
6764
find('iframe.ui-datepicker-cover').
6765
css({width: dims.width, height: dims.height});
6766
var numMonths = this._getNumberOfMonths(inst);
6767
inst.dpDiv[(numMonths[0] != 1 || numMonths[1] != 1 ? 'add' : 'remove') +
6768
'Class']('ui-datepicker-multi');
6769
inst.dpDiv[(this._get(inst, 'isRTL') ? 'add' : 'remove') +
6770
'Class']('ui-datepicker-rtl');
6771
if (inst.input && inst.input[0].type != 'hidden')
6772
$(inst.input[0]).focus();
6775
/* Check positioning to remain on screen. */
6776
_checkOffset: function(inst, offset, isFixed) {
6777
var pos = inst.input ? this._findPos(inst.input[0]) : null;
6778
var browserWidth = window.innerWidth || document.documentElement.clientWidth;
6779
var browserHeight = window.innerHeight || document.documentElement.clientHeight;
6780
var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
6781
var scrollY = document.documentElement.scrollTop || document.body.scrollTop;
6782
// reposition date picker horizontally if outside the browser window
6783
if (this._get(inst, 'isRTL') || (offset.left + inst.dpDiv.width() - scrollX) > browserWidth)
6784
offset.left = Math.max((isFixed ? 0 : scrollX),
6785
pos[0] + (inst.input ? inst.input.width() : 0) - (isFixed ? scrollX : 0) - inst.dpDiv.width() -
6786
(isFixed && $.browser.opera ? document.documentElement.scrollLeft : 0));
6788
offset.left -= (isFixed ? scrollX : 0);
6789
// reposition date picker vertically if outside the browser window
6790
if ((offset.top + inst.dpDiv.height() - scrollY) > browserHeight)
6791
offset.top = Math.max((isFixed ? 0 : scrollY),
6792
pos[1] - (isFixed ? scrollY : 0) - (this._inDialog ? 0 : inst.dpDiv.height()) -
6793
(isFixed && $.browser.opera ? document.documentElement.scrollTop : 0));
6795
offset.top -= (isFixed ? scrollY : 0);
6799
/* Find an object's position on the screen. */
6800
_findPos: function(obj) {
6801
while (obj && (obj.type == 'hidden' || obj.nodeType != 1)) {
6802
obj = obj.nextSibling;
6804
var position = $(obj).offset();
6805
return [position.left, position.top];
6808
/* Hide the date picker from view.
6809
@param input element - the input field attached to the date picker
6810
@param duration string - the duration over which to close the date picker */
6811
_hideDatepicker: function(input, duration) {
6812
var inst = this._curInst;
6813
if (!inst || (input && inst != $.data(input, PROP_NAME)))
6815
var rangeSelect = this._get(inst, 'rangeSelect');
6816
if (rangeSelect && inst.stayOpen)
6817
this._selectDate('#' + inst.id, this._formatDate(inst,
6818
inst.currentDay, inst.currentMonth, inst.currentYear));
6819
inst.stayOpen = false;
6820
if (this._datepickerShowing) {
6821
duration = (duration != null ? duration : this._get(inst, 'duration'));
6822
var showAnim = this._get(inst, 'showAnim');
6823
var postProcess = function() {
6824
$.datepicker._tidyDialog(inst);
6826
if (duration != '' && $.effects && $.effects[showAnim])
6827
inst.dpDiv.hide(showAnim, $.datepicker._get(inst, 'showOptions'),
6828
duration, postProcess);
6830
inst.dpDiv[(duration == '' ? 'hide' : (showAnim == 'slideDown' ? 'slideUp' :
6831
(showAnim == 'fadeIn' ? 'fadeOut' : 'hide')))](duration, postProcess);
6833
this._tidyDialog(inst);
6834
var onClose = this._get(inst, 'onClose');
6836
onClose.apply((inst.input ? inst.input[0] : null),
6837
[(inst.input ? inst.input.val() : ''), inst]); // trigger custom callback
6838
this._datepickerShowing = false;
6839
this._lastInput = null;
6840
inst.settings.prompt = null;
6841
if (this._inDialog) {
6842
this._dialogInput.css({ position: 'absolute', left: '0', top: '-100px' });
6845
$('body').append(this.dpDiv);
6848
this._inDialog = false;
6850
this._curInst = null;
6853
/* Tidy up after a dialog display. */
6854
_tidyDialog: function(inst) {
6855
inst.dpDiv.removeClass(this._dialogClass).unbind('.ui-datepicker');
6856
$('.' + this._promptClass, inst.dpDiv).remove();
6859
/* Close date picker if clicked elsewhere. */
6860
_checkExternalClick: function(event) {
6861
if (!$.datepicker._curInst)
6863
var $target = $(event.target);
6864
if (($target.parents('#' + $.datepicker._mainDivId).length == 0) &&
6865
!$target.hasClass($.datepicker.markerClassName) &&
6866
!$target.hasClass($.datepicker._triggerClass) &&
6867
$.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI))
6868
$.datepicker._hideDatepicker(null, '');
6871
/* Adjust one of the date sub-fields. */
6872
_adjustDate: function(id, offset, period) {
6874
var inst = this._getInst(target[0]);
6875
this._adjustInstDate(inst, offset, period);
6876
this._updateDatepicker(inst);
6879
/* Action for current link. */
6880
_gotoToday: function(id) {
6882
var inst = this._getInst(target[0]);
6883
if (this._get(inst, 'gotoCurrent') && inst.currentDay) {
6884
inst.selectedDay = inst.currentDay;
6885
inst.drawMonth = inst.selectedMonth = inst.currentMonth;
6886
inst.drawYear = inst.selectedYear = inst.currentYear;
6889
var date = new Date();
6890
inst.selectedDay = date.getDate();
6891
inst.drawMonth = inst.selectedMonth = date.getMonth();
6892
inst.drawYear = inst.selectedYear = date.getFullYear();
6894
this._notifyChange(inst);
6895
this._adjustDate(target);
6898
/* Action for selecting a new month/year. */
6899
_selectMonthYear: function(id, select, period) {
6901
var inst = this._getInst(target[0]);
6902
inst._selectingMonthYear = false;
6903
inst['selected' + (period == 'M' ? 'Month' : 'Year')] =
6904
inst['draw' + (period == 'M' ? 'Month' : 'Year')] =
6905
parseInt(select.options[select.selectedIndex].value,10);
6906
this._notifyChange(inst);
6907
this._adjustDate(target);
6910
/* Restore input focus after not changing month/year. */
6911
_clickMonthYear: function(id) {
6913
var inst = this._getInst(target[0]);
6914
if (inst.input && inst._selectingMonthYear && !$.browser.msie)
6915
inst.input[0].focus();
6916
inst._selectingMonthYear = !inst._selectingMonthYear;
6919
/* Action for changing the first week day. */
6920
_changeFirstDay: function(id, day) {
6922
var inst = this._getInst(target[0]);
6923
inst.settings.firstDay = day;
6924
this._updateDatepicker(inst);
6927
/* Action for selecting a day. */
6928
_selectDay: function(id, month, year, td) {
6929
if ($(td).hasClass(this._unselectableClass))
6932
var inst = this._getInst(target[0]);
6933
var rangeSelect = this._get(inst, 'rangeSelect');
6935
inst.stayOpen = !inst.stayOpen;
6936
if (inst.stayOpen) {
6937
$('.ui-datepicker td', inst.dpDiv).removeClass(this._currentClass);
6938
$(td).addClass(this._currentClass);
6941
inst.selectedDay = inst.currentDay = $('a', td).html();
6942
inst.selectedMonth = inst.currentMonth = month;
6943
inst.selectedYear = inst.currentYear = year;
6944
if (inst.stayOpen) {
6945
inst.endDay = inst.endMonth = inst.endYear = null;
6947
else if (rangeSelect) {
6948
inst.endDay = inst.currentDay;
6949
inst.endMonth = inst.currentMonth;
6950
inst.endYear = inst.currentYear;
6952
this._selectDate(id, this._formatDate(inst,
6953
inst.currentDay, inst.currentMonth, inst.currentYear));
6954
if (inst.stayOpen) {
6955
inst.rangeStart = new Date(inst.currentYear, inst.currentMonth, inst.currentDay);
6956
this._updateDatepicker(inst);
6958
else if (rangeSelect) {
6959
inst.selectedDay = inst.currentDay = inst.rangeStart.getDate();
6960
inst.selectedMonth = inst.currentMonth = inst.rangeStart.getMonth();
6961
inst.selectedYear = inst.currentYear = inst.rangeStart.getFullYear();
6962
inst.rangeStart = null;
6964
this._updateDatepicker(inst);
6968
/* Erase the input field and hide the date picker. */
6969
_clearDate: function(id) {
6971
var inst = this._getInst(target[0]);
6972
if (this._get(inst, 'mandatory'))
6974
inst.stayOpen = false;
6975
inst.endDay = inst.endMonth = inst.endYear = inst.rangeStart = null;
6976
this._selectDate(target, '');
6979
/* Update the input field with the selected date. */
6980
_selectDate: function(id, dateStr) {
6982
var inst = this._getInst(target[0]);
6983
dateStr = (dateStr != null ? dateStr : this._formatDate(inst));
6984
if (this._get(inst, 'rangeSelect') && dateStr)
6985
dateStr = (inst.rangeStart ? this._formatDate(inst, inst.rangeStart) :
6986
dateStr) + this._get(inst, 'rangeSeparator') + dateStr;
6988
inst.input.val(dateStr);
6989
this._updateAlternate(inst);
6990
var onSelect = this._get(inst, 'onSelect');
6992
onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]); // trigger custom callback
6993
else if (inst.input)
6994
inst.input.trigger('change'); // fire the change event
6996
this._updateDatepicker(inst);
6997
else if (!inst.stayOpen) {
6998
this._hideDatepicker(null, this._get(inst, 'duration'));
6999
this._lastInput = inst.input[0];
7000
if (typeof(inst.input[0]) != 'object')
7001
inst.input[0].focus(); // restore focus
7002
this._lastInput = null;
7006
/* Update any alternate field to synchronise with the main field. */
7007
_updateAlternate: function(inst) {
7008
var altField = this._get(inst, 'altField');
7009
if (altField) { // update alternate field too
7010
var altFormat = this._get(inst, 'altFormat');
7011
var date = this._getDate(inst);
7012
dateStr = (isArray(date) ? (!date[0] && !date[1] ? '' :
7013
this.formatDate(altFormat, date[0], this._getFormatConfig(inst)) +
7014
this._get(inst, 'rangeSeparator') + this.formatDate(
7015
altFormat, date[1] || date[0], this._getFormatConfig(inst))) :
7016
this.formatDate(altFormat, date, this._getFormatConfig(inst)));
7017
$(altField).each(function() { $(this).val(dateStr); });
7021
/* Set as beforeShowDay function to prevent selection of weekends.
7022
@param date Date - the date to customise
7023
@return [boolean, string] - is this date selectable?, what is its CSS class? */
7024
noWeekends: function(date) {
7025
var day = date.getDay();
7026
return [(day > 0 && day < 6), ''];
7029
/* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
7030
@param date Date - the date to get the week for
7031
@return number - the number of the week within the year that contains this date */
7032
iso8601Week: function(date) {
7033
var checkDate = new Date(date.getFullYear(), date.getMonth(), date.getDate(),
7034
(date.getTimezoneOffset() / -60));
7035
var firstMon = new Date(checkDate.getFullYear(), 1 - 1, 4); // First week always contains 4 Jan
7036
var firstDay = firstMon.getDay() || 7; // Day of week: Mon = 1, ..., Sun = 7
7037
firstMon.setDate(firstMon.getDate() + 1 - firstDay); // Preceding Monday
7038
if (firstDay < 4 && checkDate < firstMon) { // Adjust first three days in year if necessary
7039
checkDate.setDate(checkDate.getDate() - 3); // Generate for previous year
7040
return $.datepicker.iso8601Week(checkDate);
7041
} else if (checkDate > new Date(checkDate.getFullYear(), 12 - 1, 28)) { // Check last three days in year
7042
firstDay = new Date(checkDate.getFullYear() + 1, 1 - 1, 4).getDay() || 7;
7043
if (firstDay > 4 && (checkDate.getDay() || 7) < firstDay - 3) { // Adjust if necessary
7047
return Math.floor(((checkDate - firstMon) / 86400000) / 7) + 1; // Weeks to given date
7050
/* Provide status text for a particular date.
7051
@param date the date to get the status for
7052
@param inst the current datepicker instance
7053
@return the status display text for this date */
7054
dateStatus: function(date, inst) {
7055
return $.datepicker.formatDate($.datepicker._get(inst, 'dateStatus'),
7056
date, $.datepicker._getFormatConfig(inst));
7059
/* Parse a string value into a date object.
7060
See formatDate below for the possible formats.
7062
@param format string - the expected format of the date
7063
@param value string - the date in the above format
7064
@param settings Object - attributes include:
7065
shortYearCutoff number - the cutoff year for determining the century (optional)
7066
dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
7067
dayNames string[7] - names of the days from Sunday (optional)
7068
monthNamesShort string[12] - abbreviated names of the months (optional)
7069
monthNames string[12] - names of the months (optional)
7070
@return Date - the extracted date value or null if value is blank */
7071
parseDate: function (format, value, settings) {
7072
if (format == null || value == null)
7073
throw 'Invalid arguments';
7074
value = (typeof value == 'object' ? value.toString() : value + '');
7077
var shortYearCutoff = (settings ? settings.shortYearCutoff : null) || this._defaults.shortYearCutoff;
7078
var dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort;
7079
var dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames;
7080
var monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort;
7081
var monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames;
7086
var literal = false;
7087
// Check whether a format character is doubled
7088
var lookAhead = function(match) {
7089
var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match);
7094
// Extract a number from the string value
7095
var getNumber = function(match) {
7097
var origSize = (match == '@' ? 14 : (match == 'y' ? 4 : (match == 'o' ? 3 : 2)));
7098
var size = origSize;
7100
while (size > 0 && iValue < value.length &&
7101
value.charAt(iValue) >= '0' && value.charAt(iValue) <= '9') {
7102
num = num * 10 + parseInt(value.charAt(iValue++),10);
7105
if (size == origSize)
7106
throw 'Missing number at position ' + iValue;
7109
// Extract a name from the string value and convert to an index
7110
var getName = function(match, shortNames, longNames) {
7111
var names = (lookAhead(match) ? longNames : shortNames);
7113
for (var j = 0; j < names.length; j++)
7114
size = Math.max(size, names[j].length);
7117
while (size > 0 && iValue < value.length) {
7118
name += value.charAt(iValue++);
7119
for (var i = 0; i < names.length; i++)
7120
if (name == names[i])
7124
throw 'Unknown name at position ' + iInit;
7126
// Confirm that a literal character matches the string value
7127
var checkLiteral = function() {
7128
if (value.charAt(iValue) != format.charAt(iFormat))
7129
throw 'Unexpected literal at position ' + iValue;
7133
for (var iFormat = 0; iFormat < format.length; iFormat++) {
7135
if (format.charAt(iFormat) == "'" && !lookAhead("'"))
7140
switch (format.charAt(iFormat)) {
7142
day = getNumber('d');
7145
getName('D', dayNamesShort, dayNames);
7148
doy = getNumber('o');
7151
month = getNumber('m');
7154
month = getName('M', monthNamesShort, monthNames);
7157
year = getNumber('y');
7160
var date = new Date(getNumber('@'));
7161
year = date.getFullYear();
7162
month = date.getMonth() + 1;
7163
day = date.getDate();
7176
year += new Date().getFullYear() - new Date().getFullYear() % 100 +
7177
(year <= shortYearCutoff ? 0 : -100);
7182
var dim = this._getDaysInMonth(year, month - 1);
7189
var date = new Date(year, month - 1, day);
7190
if (date.getFullYear() != year || date.getMonth() + 1 != month || date.getDate() != day)
7191
throw 'Invalid date'; // E.g. 31/02/*
7195
/* Standard date formats. */
7196
ATOM: 'yy-mm-dd', // RFC 3339 (ISO 8601)
7197
COOKIE: 'D, dd M yy',
7198
ISO_8601: 'yy-mm-dd',
7199
RFC_822: 'D, d M y',
7200
RFC_850: 'DD, dd-M-y',
7201
RFC_1036: 'D, d M y',
7202
RFC_1123: 'D, d M yy',
7203
RFC_2822: 'D, d M yy',
7204
RSS: 'D, d M y', // RFC 822
7206
W3C: 'yy-mm-dd', // ISO 8601
7208
/* Format a date object into a string value.
7209
The format can be combinations of the following:
7210
d - day of month (no leading zero)
7211
dd - day of month (two digit)
7212
o - day of year (no leading zeros)
7213
oo - day of year (three digit)
7216
m - month of year (no leading zero)
7217
mm - month of year (two digit)
7218
M - month name short
7219
MM - month name long
7220
y - year (two digit)
7221
yy - year (four digit)
7222
@ - Unix timestamp (ms since 01/01/1970)
7223
'...' - literal text
7226
@param format string - the desired format of the date
7227
@param date Date - the date value to format
7228
@param settings Object - attributes include:
7229
dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
7230
dayNames string[7] - names of the days from Sunday (optional)
7231
monthNamesShort string[12] - abbreviated names of the months (optional)
7232
monthNames string[12] - names of the months (optional)
7233
@return string - the date in the above format */
7234
formatDate: function (format, date, settings) {
7237
var dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort;
7238
var dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames;
7239
var monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort;
7240
var monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames;
7241
// Check whether a format character is doubled
7242
var lookAhead = function(match) {
7243
var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) == match);
7248
// Format a number, with leading zero if necessary
7249
var formatNumber = function(match, value, len) {
7250
var num = '' + value;
7251
if (lookAhead(match))
7252
while (num.length < len)
7256
// Format a name, short or long as requested
7257
var formatName = function(match, value, shortNames, longNames) {
7258
return (lookAhead(match) ? longNames[value] : shortNames[value]);
7261
var literal = false;
7263
for (var iFormat = 0; iFormat < format.length; iFormat++) {
7265
if (format.charAt(iFormat) == "'" && !lookAhead("'"))
7268
output += format.charAt(iFormat);
7270
switch (format.charAt(iFormat)) {
7272
output += formatNumber('d', date.getDate(), 2);
7275
output += formatName('D', date.getDay(), dayNamesShort, dayNames);
7278
var doy = date.getDate();
7279
for (var m = date.getMonth() - 1; m >= 0; m--)
7280
doy += this._getDaysInMonth(date.getFullYear(), m);
7281
output += formatNumber('o', doy, 3);
7284
output += formatNumber('m', date.getMonth() + 1, 2);
7287
output += formatName('M', date.getMonth(), monthNamesShort, monthNames);
7290
output += (lookAhead('y') ? date.getFullYear() :
7291
(date.getYear() % 100 < 10 ? '0' : '') + date.getYear() % 100);
7294
output += date.getTime();
7303
output += format.charAt(iFormat);
7309
/* Extract all possible characters from the date format. */
7310
_possibleChars: function (format) {
7312
var literal = false;
7313
for (var iFormat = 0; iFormat < format.length; iFormat++)
7315
if (format.charAt(iFormat) == "'" && !lookAhead("'"))
7318
chars += format.charAt(iFormat);
7320
switch (format.charAt(iFormat)) {
7321
case 'd': case 'm': case 'y': case '@':
7322
chars += '0123456789';
7325
return null; // Accept anything
7333
chars += format.charAt(iFormat);
7338
/* Get a setting value, defaulting if necessary. */
7339
_get: function(inst, name) {
7340
return inst.settings[name] !== undefined ?
7341
inst.settings[name] : this._defaults[name];
7344
/* Parse existing date and initialise date picker. */
7345
_setDateFromField: function(inst) {
7346
var dateFormat = this._get(inst, 'dateFormat');
7347
var dates = inst.input ? inst.input.val().split(this._get(inst, 'rangeSeparator')) : null;
7348
inst.endDay = inst.endMonth = inst.endYear = null;
7349
var date = defaultDate = this._getDefaultDate(inst);
7350
if (dates.length > 0) {
7351
var settings = this._getFormatConfig(inst);
7352
if (dates.length > 1) {
7353
date = this.parseDate(dateFormat, dates[1], settings) || defaultDate;
7354
inst.endDay = date.getDate();
7355
inst.endMonth = date.getMonth();
7356
inst.endYear = date.getFullYear();
7359
date = this.parseDate(dateFormat, dates[0], settings) || defaultDate;
7365
inst.selectedDay = date.getDate();
7366
inst.drawMonth = inst.selectedMonth = date.getMonth();
7367
inst.drawYear = inst.selectedYear = date.getFullYear();
7368
inst.currentDay = (dates[0] ? date.getDate() : 0);
7369
inst.currentMonth = (dates[0] ? date.getMonth() : 0);
7370
inst.currentYear = (dates[0] ? date.getFullYear() : 0);
7371
this._adjustInstDate(inst);
7374
/* Retrieve the default date shown on opening. */
7375
_getDefaultDate: function(inst) {
7376
var date = this._determineDate(this._get(inst, 'defaultDate'), new Date());
7377
var minDate = this._getMinMaxDate(inst, 'min', true);
7378
var maxDate = this._getMinMaxDate(inst, 'max');
7379
date = (minDate && date < minDate ? minDate : date);
7380
date = (maxDate && date > maxDate ? maxDate : date);
7384
/* A date may be specified as an exact value or a relative one. */
7385
_determineDate: function(date, defaultDate) {
7386
var offsetNumeric = function(offset) {
7387
var date = new Date();
7388
date.setUTCDate(date.getUTCDate() + offset);
7391
var offsetString = function(offset, getDaysInMonth) {
7392
var date = new Date();
7393
var year = date.getFullYear();
7394
var month = date.getMonth();
7395
var day = date.getDate();
7396
var pattern = /([+-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g;
7397
var matches = pattern.exec(offset);
7399
switch (matches[2] || 'd') {
7400
case 'd' : case 'D' :
7401
day += parseInt(matches[1],10); break;
7402
case 'w' : case 'W' :
7403
day += parseInt(matches[1],10) * 7; break;
7404
case 'm' : case 'M' :
7405
month += parseInt(matches[1],10);
7406
day = Math.min(day, getDaysInMonth(year, month));
7408
case 'y': case 'Y' :
7409
year += parseInt(matches[1],10);
7410
day = Math.min(day, getDaysInMonth(year, month));
7413
matches = pattern.exec(offset);
7415
return new Date(year, month, day);
7417
date = (date == null ? defaultDate :
7418
(typeof date == 'string' ? offsetString(date, this._getDaysInMonth) :
7419
(typeof date == 'number' ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : date)));
7420
return (date && date.toString() == 'Invalid Date' ? defaultDate : date);
7423
/* Set the date(s) directly. */
7424
_setDate: function(inst, date, endDate) {
7425
var clear = !(date);
7426
var origMonth = inst.selectedMonth;
7427
var origYear = inst.selectedYear;
7428
date = this._determineDate(date, new Date());
7429
inst.selectedDay = inst.currentDay = date.getDate();
7430
inst.drawMonth = inst.selectedMonth = inst.currentMonth = date.getMonth();
7431
inst.drawYear = inst.selectedYear = inst.currentYear = date.getFullYear();
7432
if (this._get(inst, 'rangeSelect')) {
7434
endDate = this._determineDate(endDate, null);
7435
inst.endDay = endDate.getDate();
7436
inst.endMonth = endDate.getMonth();
7437
inst.endYear = endDate.getFullYear();
7439
inst.endDay = inst.currentDay;
7440
inst.endMonth = inst.currentMonth;
7441
inst.endYear = inst.currentYear;
7444
if (origMonth != inst.selectedMonth || origYear != inst.selectedYear)
7445
this._notifyChange(inst);
7446
this._adjustInstDate(inst);
7448
inst.input.val(clear ? '' : this._formatDate(inst) +
7449
(!this._get(inst, 'rangeSelect') ? '' : this._get(inst, 'rangeSeparator') +
7450
this._formatDate(inst, inst.endDay, inst.endMonth, inst.endYear)));
7453
/* Retrieve the date(s) directly. */
7454
_getDate: function(inst) {
7455
var startDate = (!inst.currentYear || (inst.input && inst.input.val() == '') ? null :
7456
new Date(inst.currentYear, inst.currentMonth, inst.currentDay));
7457
if (this._get(inst, 'rangeSelect')) {
7458
return [inst.rangeStart || startDate,
7459
(!inst.endYear ? inst.rangeStart || startDate :
7460
new Date(inst.endYear, inst.endMonth, inst.endDay))];
7465
/* Generate the HTML for the current state of the date picker. */
7466
_generateHTML: function(inst) {
7467
var today = new Date();
7468
today = new Date(today.getFullYear(), today.getMonth(), today.getDate()); // clear time
7469
var showStatus = this._get(inst, 'showStatus');
7470
var initStatus = this._get(inst, 'initStatus') || ' ';
7471
var isRTL = this._get(inst, 'isRTL');
7472
// build the date picker HTML
7473
var clear = (this._get(inst, 'mandatory') ? '' :
7474
'<div class="ui-datepicker-clear"><a onclick="jQuery.datepicker._clearDate(\'#' + inst.id + '\');"' +
7475
this._addStatus(showStatus, inst.id, this._get(inst, 'clearStatus'), initStatus) + '>' +
7476
this._get(inst, 'clearText') + '</a></div>');
7477
var controls = '<div class="ui-datepicker-control">' + (isRTL ? '' : clear) +
7478
'<div class="ui-datepicker-close"><a onclick="jQuery.datepicker._hideDatepicker();"' +
7479
this._addStatus(showStatus, inst.id, this._get(inst, 'closeStatus'), initStatus) + '>' +
7480
this._get(inst, 'closeText') + '</a></div>' + (isRTL ? clear : '') + '</div>';
7481
var prompt = this._get(inst, 'prompt');
7482
var closeAtTop = this._get(inst, 'closeAtTop');
7483
var hideIfNoPrevNext = this._get(inst, 'hideIfNoPrevNext');
7484
var navigationAsDateFormat = this._get(inst, 'navigationAsDateFormat');
7485
var showBigPrevNext = this._get(inst, 'showBigPrevNext');
7486
var numMonths = this._getNumberOfMonths(inst);
7487
var showCurrentAtPos = this._get(inst, 'showCurrentAtPos');
7488
var stepMonths = this._get(inst, 'stepMonths');
7489
var stepBigMonths = this._get(inst, 'stepBigMonths');
7490
var isMultiMonth = (numMonths[0] != 1 || numMonths[1] != 1);
7491
var currentDate = (!inst.currentDay ? new Date(9999, 9, 9) :
7492
new Date(inst.currentYear, inst.currentMonth, inst.currentDay));
7493
var minDate = this._getMinMaxDate(inst, 'min', true);
7494
var maxDate = this._getMinMaxDate(inst, 'max');
7495
var drawMonth = inst.drawMonth - showCurrentAtPos;
7496
var drawYear = inst.drawYear;
7497
if (drawMonth < 0) {
7502
var maxDraw = new Date(maxDate.getFullYear(),
7503
maxDate.getMonth() - numMonths[1] + 1, maxDate.getDate());
7504
maxDraw = (minDate && maxDraw < minDate ? minDate : maxDraw);
7505
while (new Date(drawYear, drawMonth, 1) > maxDraw) {
7507
if (drawMonth < 0) {
7513
// controls and links
7514
var prevText = this._get(inst, 'prevText');
7515
prevText = (!navigationAsDateFormat ? prevText : this.formatDate(
7516
prevText, new Date(drawYear, drawMonth - stepMonths, 1), this._getFormatConfig(inst)));
7517
var prevBigText = (showBigPrevNext ? this._get(inst, 'prevBigText') : '');
7518
prevBigText = (!navigationAsDateFormat ? prevBigText : this.formatDate(
7519
prevBigText, new Date(drawYear, drawMonth - stepBigMonths, 1), this._getFormatConfig(inst)));
7520
var prev = '<div class="ui-datepicker-prev">' + (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ?
7521
(showBigPrevNext ? '<a onclick="jQuery.datepicker._adjustDate(\'#' + inst.id + '\', -' + stepBigMonths + ', \'M\');"' +
7522
this._addStatus(showStatus, inst.id, this._get(inst, 'prevBigStatus'), initStatus) + '>' + prevBigText + '</a>' : '') +
7523
'<a onclick="jQuery.datepicker._adjustDate(\'#' + inst.id + '\', -' + stepMonths + ', \'M\');"' +
7524
this._addStatus(showStatus, inst.id, this._get(inst, 'prevStatus'), initStatus) + '>' + prevText + '</a>' :
7525
(hideIfNoPrevNext ? '' : '<label>' + prevBigText + '</label><label>' + prevText + '</label>')) + '</div>';
7526
var nextText = this._get(inst, 'nextText');
7527
nextText = (!navigationAsDateFormat ? nextText : this.formatDate(
7528
nextText, new Date(drawYear, drawMonth + stepMonths, 1), this._getFormatConfig(inst)));
7529
var nextBigText = (showBigPrevNext ? this._get(inst, 'nextBigText') : '');
7530
nextBigText = (!navigationAsDateFormat ? nextBigText : this.formatDate(
7531
nextBigText, new Date(drawYear, drawMonth + stepBigMonths, 1), this._getFormatConfig(inst)));
7532
var next = '<div class="ui-datepicker-next">' + (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ?
7533
'<a onclick="jQuery.datepicker._adjustDate(\'#' + inst.id + '\', +' + stepMonths + ', \'M\');"' +
7534
this._addStatus(showStatus, inst.id, this._get(inst, 'nextStatus'), initStatus) + '>' + nextText + '</a>' +
7535
(showBigPrevNext ? '<a onclick="jQuery.datepicker._adjustDate(\'#' + inst.id + '\', +' + stepBigMonths + ', \'M\');"' +
7536
this._addStatus(showStatus, inst.id, this._get(inst, 'nextBigStatus'), initStatus) + '>' + nextBigText + '</a>' : '') :
7537
(hideIfNoPrevNext ? '' : '<label>' + nextText + '</label><label>' + nextBigText + '</label>')) + '</div>';
7538
var currentText = this._get(inst, 'currentText');
7539
var gotoDate = (this._get(inst, 'gotoCurrent') && inst.currentDay ? currentDate : today);
7540
currentText = (!navigationAsDateFormat ? currentText :
7541
this.formatDate(currentText, gotoDate, this._getFormatConfig(inst)));
7542
var html = (prompt ? '<div class="' + this._promptClass + '">' + prompt + '</div>' : '') +
7543
(closeAtTop && !inst.inline ? controls : '') +
7544
'<div class="ui-datepicker-links">' + (isRTL ? next : prev) +
7545
(this._isInRange(inst, gotoDate) ? '<div class="ui-datepicker-current">' +
7546
'<a onclick="jQuery.datepicker._gotoToday(\'#' + inst.id + '\');"' +
7547
this._addStatus(showStatus, inst.id, this._get(inst, 'currentStatus'), initStatus) + '>' +
7548
currentText + '</a></div>' : '') + (isRTL ? prev : next) + '</div>';
7549
var firstDay = this._get(inst, 'firstDay');
7550
var changeFirstDay = this._get(inst, 'changeFirstDay');
7551
var dayNames = this._get(inst, 'dayNames');
7552
var dayNamesShort = this._get(inst, 'dayNamesShort');
7553
var dayNamesMin = this._get(inst, 'dayNamesMin');
7554
var monthNames = this._get(inst, 'monthNames');
7555
var beforeShowDay = this._get(inst, 'beforeShowDay');
7556
var highlightWeek = this._get(inst, 'highlightWeek');
7557
var showOtherMonths = this._get(inst, 'showOtherMonths');
7558
var showWeeks = this._get(inst, 'showWeeks');
7559
var calculateWeek = this._get(inst, 'calculateWeek') || this.iso8601Week;
7560
var weekStatus = this._get(inst, 'weekStatus');
7561
var status = (showStatus ? this._get(inst, 'dayStatus') || initStatus : '');
7562
var dateStatus = this._get(inst, 'statusForDate') || this.dateStatus;
7563
var endDate = inst.endDay ? new Date(inst.endYear, inst.endMonth, inst.endDay) : currentDate;
7564
for (var row = 0; row < numMonths[0]; row++)
7565
for (var col = 0; col < numMonths[1]; col++) {
7566
var selectedDate = new Date(drawYear, drawMonth, inst.selectedDay);
7567
html += '<div class="ui-datepicker-one-month' + (col == 0 ? ' ui-datepicker-new-row' : '') + '">' +
7568
this._generateMonthYearHeader(inst, drawMonth, drawYear, minDate, maxDate,
7569
selectedDate, row > 0 || col > 0, showStatus, initStatus, monthNames) + // draw month headers
7570
'<table class="ui-datepicker" cellpadding="0" cellspacing="0"><thead>' +
7571
'<tr class="ui-datepicker-title-row">' +
7572
(showWeeks ? '<td' + this._addStatus(showStatus, inst.id, weekStatus, initStatus) + '>' +
7573
this._get(inst, 'weekHeader') + '</td>' : '');
7574
for (var dow = 0; dow < 7; dow++) { // days of the week
7575
var day = (dow + firstDay) % 7;
7576
var dayStatus = (status.indexOf('DD') > -1 ? status.replace(/DD/, dayNames[day]) :
7577
status.replace(/D/, dayNamesShort[day]));
7578
html += '<td' + ((dow + firstDay + 6) % 7 >= 5 ? ' class="ui-datepicker-week-end-cell"' : '') + '>' +
7579
(!changeFirstDay ? '<span' :
7580
'<a onclick="jQuery.datepicker._changeFirstDay(\'#' + inst.id + '\', ' + day + ');"') +
7581
this._addStatus(showStatus, inst.id, dayStatus, initStatus) + ' title="' + dayNames[day] + '">' +
7582
dayNamesMin[day] + (changeFirstDay ? '</a>' : '</span>') + '</td>';
7584
html += '</tr></thead><tbody>';
7585
var daysInMonth = this._getDaysInMonth(drawYear, drawMonth);
7586
if (drawYear == inst.selectedYear && drawMonth == inst.selectedMonth)
7587
inst.selectedDay = Math.min(inst.selectedDay, daysInMonth);
7588
var leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7;
7589
var tzDate = new Date(drawYear, drawMonth, 1 - leadDays);
7590
var utcDate = new Date(drawYear, drawMonth, 1 - leadDays);
7591
var printDate = utcDate;
7592
var numRows = (isMultiMonth ? 6 : Math.ceil((leadDays + daysInMonth) / 7)); // calculate the number of rows to generate
7593
for (var dRow = 0; dRow < numRows; dRow++) { // create date picker rows
7594
html += '<tr class="ui-datepicker-days-row">' +
7595
(showWeeks ? '<td class="ui-datepicker-week-col"' +
7596
this._addStatus(showStatus, inst.id, weekStatus, initStatus) + '>' +
7597
calculateWeek(printDate) + '</td>' : '');
7598
for (var dow = 0; dow < 7; dow++) { // create date picker days
7599
var daySettings = (beforeShowDay ?
7600
beforeShowDay.apply((inst.input ? inst.input[0] : null), [printDate]) : [true, '']);
7601
var otherMonth = (printDate.getMonth() != drawMonth);
7602
var unselectable = otherMonth || !daySettings[0] ||
7603
(minDate && printDate < minDate) || (maxDate && printDate > maxDate);
7604
html += '<td class="ui-datepicker-days-cell' +
7605
((dow + firstDay + 6) % 7 >= 5 ? ' ui-datepicker-week-end-cell' : '') + // highlight weekends
7606
(otherMonth ? ' ui-datepicker-other-month' : '') + // highlight days from other months
7607
(printDate.getTime() == selectedDate.getTime() && drawMonth == inst.selectedMonth ?
7608
' ui-datepicker-days-cell-over' : '') + // highlight selected day
7609
(unselectable ? ' ' + this._unselectableClass : '') + // highlight unselectable days
7610
(otherMonth && !showOtherMonths ? '' : ' ' + daySettings[1] + // highlight custom dates
7611
(printDate.getTime() >= currentDate.getTime() && printDate.getTime() <= endDate.getTime() ? // in current range
7612
' ' + this._currentClass : '') + // highlight selected day
7613
(printDate.getTime() == today.getTime() ? ' ui-datepicker-today' : '')) + '"' + // highlight today (if different)
7614
((!otherMonth || showOtherMonths) && daySettings[2] ? ' title="' + daySettings[2] + '"' : '') + // cell title
7615
(unselectable ? (highlightWeek ? ' onmouseover="jQuery(this).parent().addClass(\'ui-datepicker-week-over\');"' + // highlight selection week
7616
' onmouseout="jQuery(this).parent().removeClass(\'ui-datepicker-week-over\');"' : '') : // unhighlight selection week
7617
' onmouseover="jQuery(this).addClass(\'ui-datepicker-days-cell-over\')' + // highlight selection
7618
(highlightWeek ? '.parent().addClass(\'ui-datepicker-week-over\')' : '') + ';' + // highlight selection week
7619
(!showStatus || (otherMonth && !showOtherMonths) ? '' : 'jQuery(\'#ui-datepicker-status-' +
7620
inst.id + '\').html(\'' + (dateStatus.apply((inst.input ? inst.input[0] : null),
7621
[printDate, inst]) || initStatus) +'\');') + '"' +
7622
' onmouseout="jQuery(this).removeClass(\'ui-datepicker-days-cell-over\')' + // unhighlight selection
7623
(highlightWeek ? '.parent().removeClass(\'ui-datepicker-week-over\')' : '') + ';' + // unhighlight selection week
7624
(!showStatus || (otherMonth && !showOtherMonths) ? '' : 'jQuery(\'#ui-datepicker-status-' +
7625
inst.id + '\').html(\'' + initStatus + '\');') + '" onclick="jQuery.datepicker._selectDay(\'#' +
7626
inst.id + '\',' + drawMonth + ',' + drawYear + ', this);"') + '>' + // actions
7627
(otherMonth ? (showOtherMonths ? printDate.getDate() : ' ') : // display for other months
7628
(unselectable ? printDate.getDate() : '<a>' + printDate.getDate() + '</a>')) + '</td>'; // display for this month
7629
tzDate.setDate(tzDate.getDate() + 1);
7630
utcDate.setUTCDate(utcDate.getUTCDate() + 1);
7631
printDate = (tzDate > utcDate ? tzDate : utcDate);
7636
if (drawMonth > 11) {
7640
html += '</tbody></table></div>';
7642
html += (showStatus ? '<div style="clear: both;"></div><div id="ui-datepicker-status-' + inst.id +
7643
'" class="ui-datepicker-status">' + initStatus + '</div>' : '') +
7644
(!closeAtTop && !inst.inline ? controls : '') +
7645
'<div style="clear: both;"></div>' +
7646
($.browser.msie && parseInt($.browser.version,10) < 7 && !inst.inline ?
7647
'<iframe src="javascript:false;" class="ui-datepicker-cover"></iframe>' : '');
7651
/* Generate the month and year header. */
7652
_generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate,
7653
selectedDate, secondary, showStatus, initStatus, monthNames) {
7654
minDate = (inst.rangeStart && minDate && selectedDate < minDate ? selectedDate : minDate);
7655
var showMonthAfterYear = this._get(inst, 'showMonthAfterYear');
7656
var html = '<div class="ui-datepicker-header">';
7659
if (secondary || !this._get(inst, 'changeMonth'))
7660
monthHtml += monthNames[drawMonth] + ' ';
7662
var inMinYear = (minDate && minDate.getFullYear() == drawYear);
7663
var inMaxYear = (maxDate && maxDate.getFullYear() == drawYear);
7664
monthHtml += '<select class="ui-datepicker-new-month" ' +
7665
'onchange="jQuery.datepicker._selectMonthYear(\'#' + inst.id + '\', this, \'M\');" ' +
7666
'onclick="jQuery.datepicker._clickMonthYear(\'#' + inst.id + '\');"' +
7667
this._addStatus(showStatus, inst.id, this._get(inst, 'monthStatus'), initStatus) + '>';
7668
for (var month = 0; month < 12; month++) {
7669
if ((!inMinYear || month >= minDate.getMonth()) &&
7670
(!inMaxYear || month <= maxDate.getMonth()))
7671
monthHtml += '<option value="' + month + '"' +
7672
(month == drawMonth ? ' selected="selected"' : '') +
7673
'>' + monthNames[month] + '</option>';
7675
monthHtml += '</select>';
7677
if (!showMonthAfterYear)
7680
if (secondary || !this._get(inst, 'changeYear'))
7683
// determine range of years to display
7684
var years = this._get(inst, 'yearRange').split(':');
7687
if (years.length != 2) {
7688
year = drawYear - 10;
7689
endYear = drawYear + 10;
7690
} else if (years[0].charAt(0) == '+' || years[0].charAt(0) == '-') {
7691
year = endYear = new Date().getFullYear();
7692
year += parseInt(years[0], 10);
7693
endYear += parseInt(years[1], 10);
7695
year = parseInt(years[0], 10);
7696
endYear = parseInt(years[1], 10);
7698
year = (minDate ? Math.max(year, minDate.getFullYear()) : year);
7699
endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear);
7700
html += '<select class="ui-datepicker-new-year" ' +
7701
'onchange="jQuery.datepicker._selectMonthYear(\'#' + inst.id + '\', this, \'Y\');" ' +
7702
'onclick="jQuery.datepicker._clickMonthYear(\'#' + inst.id + '\');"' +
7703
this._addStatus(showStatus, inst.id, this._get(inst, 'yearStatus'), initStatus) + '>';
7704
for (; year <= endYear; year++) {
7705
html += '<option value="' + year + '"' +
7706
(year == drawYear ? ' selected="selected"' : '') +
7707
'>' + year + '</option>';
7709
html += '</select>';
7711
if (showMonthAfterYear)
7713
html += '</div>'; // Close datepicker_header
7717
/* Provide code to set and clear the status panel. */
7718
_addStatus: function(showStatus, id, text, initStatus) {
7719
return (showStatus ? ' onmouseover="jQuery(\'#ui-datepicker-status-' + id +
7720
'\').html(\'' + (text || initStatus) + '\');" ' +
7721
'onmouseout="jQuery(\'#ui-datepicker-status-' + id +
7722
'\').html(\'' + initStatus + '\');"' : '');
7725
/* Adjust one of the date sub-fields. */
7726
_adjustInstDate: function(inst, offset, period) {
7727
var year = inst.drawYear + (period == 'Y' ? offset : 0);
7728
var month = inst.drawMonth + (period == 'M' ? offset : 0);
7729
var day = Math.min(inst.selectedDay, this._getDaysInMonth(year, month)) +
7730
(period == 'D' ? offset : 0);
7731
var date = new Date(year, month, day);
7732
// ensure it is within the bounds set
7733
var minDate = this._getMinMaxDate(inst, 'min', true);
7734
var maxDate = this._getMinMaxDate(inst, 'max');
7735
date = (minDate && date < minDate ? minDate : date);
7736
date = (maxDate && date > maxDate ? maxDate : date);
7737
inst.selectedDay = date.getDate();
7738
inst.drawMonth = inst.selectedMonth = date.getMonth();
7739
inst.drawYear = inst.selectedYear = date.getFullYear();
7740
if (period == 'M' || period == 'Y')
7741
this._notifyChange(inst);
7744
/* Notify change of month/year. */
7745
_notifyChange: function(inst) {
7746
var onChange = this._get(inst, 'onChangeMonthYear');
7748
onChange.apply((inst.input ? inst.input[0] : null),
7749
[inst.selectedYear, inst.selectedMonth + 1, inst]);
7752
/* Determine the number of months to show. */
7753
_getNumberOfMonths: function(inst) {
7754
var numMonths = this._get(inst, 'numberOfMonths');
7755
return (numMonths == null ? [1, 1] : (typeof numMonths == 'number' ? [1, numMonths] : numMonths));
7758
/* Determine the current maximum date - ensure no time components are set - may be overridden for a range. */
7759
_getMinMaxDate: function(inst, minMax, checkRange) {
7760
var date = this._determineDate(this._get(inst, minMax + 'Date'), null);
7765
date.setMilliseconds(0);
7767
return (!checkRange || !inst.rangeStart ? date :
7768
(!date || inst.rangeStart > date ? inst.rangeStart : date));
7771
/* Find the number of days in a given month. */
7772
_getDaysInMonth: function(year, month) {
7773
return 32 - new Date(year, month, 32).getDate();
7776
/* Find the day of the week of the first of a month. */
7777
_getFirstDayOfMonth: function(year, month) {
7778
return new Date(year, month, 1).getDay();
7781
/* Determines if we should allow a "next/prev" month display change. */
7782
_canAdjustMonth: function(inst, offset, curYear, curMonth) {
7783
var numMonths = this._getNumberOfMonths(inst);
7784
var date = new Date(curYear, curMonth + (offset < 0 ? offset : numMonths[1]), 1);
7786
date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth()));
7787
return this._isInRange(inst, date);
7790
/* Is the given date in the accepted range? */
7791
_isInRange: function(inst, date) {
7792
// during range selection, use minimum of selected date and range start
7793
var newMinDate = (!inst.rangeStart ? null :
7794
new Date(inst.selectedYear, inst.selectedMonth, inst.selectedDay));
7795
newMinDate = (newMinDate && inst.rangeStart < newMinDate ? inst.rangeStart : newMinDate);
7796
var minDate = newMinDate || this._getMinMaxDate(inst, 'min');
7797
var maxDate = this._getMinMaxDate(inst, 'max');
7798
return ((!minDate || date >= minDate) && (!maxDate || date <= maxDate));
7801
/* Provide the configuration settings for formatting/parsing. */
7802
_getFormatConfig: function(inst) {
7803
var shortYearCutoff = this._get(inst, 'shortYearCutoff');
7804
shortYearCutoff = (typeof shortYearCutoff != 'string' ? shortYearCutoff :
7805
new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
7806
return {shortYearCutoff: shortYearCutoff,
7807
dayNamesShort: this._get(inst, 'dayNamesShort'), dayNames: this._get(inst, 'dayNames'),
7808
monthNamesShort: this._get(inst, 'monthNamesShort'), monthNames: this._get(inst, 'monthNames')};
7811
/* Format the given date for display. */
7812
_formatDate: function(inst, day, month, year) {
7814
inst.currentDay = inst.selectedDay;
7815
inst.currentMonth = inst.selectedMonth;
7816
inst.currentYear = inst.selectedYear;
7818
var date = (day ? (typeof day == 'object' ? day : new Date(year, month, day)) :
7819
new Date(inst.currentYear, inst.currentMonth, inst.currentDay));
7820
return this.formatDate(this._get(inst, 'dateFormat'), date, this._getFormatConfig(inst));
7824
/* jQuery extend now ignores nulls! */
7825
function extendRemove(target, props) {
7826
$.extend(target, props);
7827
for (var name in props)
7828
if (props[name] == null || props[name] == undefined)
7829
target[name] = props[name];
7833
/* Determine whether an object is an array. */
7834
function isArray(a) {
7835
return (a && (($.browser.safari && typeof a == 'object' && a.length) ||
7836
(a.constructor && a.constructor.toString().match(/\Array\(\)/))));
7839
/* Invoke the datepicker functionality.
7840
@param options string - a command, optionally followed by additional parameters or
7841
Object - settings for attaching new datepicker functionality
7842
@return jQuery object */
7843
$.fn.datepicker = function(options){
7845
/* Initialise the date picker. */
7846
if (!$.datepicker.initialized) {
7847
$(document.body).append($.datepicker.dpDiv).
7848
mousedown($.datepicker._checkExternalClick);
7849
$.datepicker.initialized = true;
7852
var otherArgs = Array.prototype.slice.call(arguments, 1);
7853
if (typeof options == 'string' && (options == 'isDisabled' || options == 'getDate'))
7854
return $.datepicker['_' + options + 'Datepicker'].
7855
apply($.datepicker, [this[0]].concat(otherArgs));
7856
return this.each(function() {
7857
typeof options == 'string' ?
7858
$.datepicker['_' + options + 'Datepicker'].
7859
apply($.datepicker, [this].concat(otherArgs)) :
7860
$.datepicker._attachDatepicker(this, options);
7864
$.datepicker = new Datepicker(); // singleton instance
7865
$.datepicker.initialized = false;
7866
$.datepicker.uuid = new Date().getTime();
7870
* jQuery UI Dialog @VERSION
7872
* Copyright (c) 2008 Richard D. Worth (rdworth.org)
7873
* Dual licensed under the MIT (MIT-LICENSE.txt)
7874
* and GPL (GPL-LICENSE.txt) licenses.
7876
* http://docs.jquery.com/UI/Dialog
7885
var setDataSwitch = {
7886
dragStart: "start.draggable",
7887
drag: "drag.draggable",
7888
dragStop: "stop.draggable",
7889
maxHeight: "maxHeight.resizable",
7890
minHeight: "minHeight.resizable",
7891
maxWidth: "maxWidth.resizable",
7892
minWidth: "minWidth.resizable",
7893
resizeStart: "start.resizable",
7894
resize: "drag.resizable",
7895
resizeStop: "stop.resizable"
7898
$.widget("ui.dialog", {
7900
this.originalTitle = this.element.attr('title');
7901
this.options.title = this.options.title || this.originalTitle;
7904
options = this.options,
7906
uiDialogContent = this.element
7907
.removeAttr('title')
7908
.addClass('ui-dialog-content')
7912
uiDialogContainer = (this.uiDialogContainer = uiDialogContent.parent())
7913
.addClass('ui-dialog-container')
7915
position: 'relative',
7920
uiDialogTitlebar = (this.uiDialogTitlebar = $('<div/>'))
7921
.addClass('ui-dialog-titlebar')
7922
.append('<a href="#" class="ui-dialog-titlebar-close"><span>X</span></a>')
7923
.prependTo(uiDialogContainer),
7925
title = options.title || ' ',
7926
titleId = $.ui.dialog.getTitleId(this.element),
7927
uiDialogTitle = $('<span/>')
7928
.addClass('ui-dialog-title')
7929
.attr('id', titleId)
7931
.prependTo(uiDialogTitlebar),
7933
uiDialog = (this.uiDialog = uiDialogContainer.parent())
7934
.appendTo(document.body)
7936
.addClass('ui-dialog')
7937
.addClass(options.dialogClass)
7938
// add content classes to dialog
7939
// to inherit theme at top level of element
7940
.addClass(uiDialogContent.attr('className'))
7941
.removeClass('ui-dialog-content')
7943
position: 'absolute',
7944
width: options.width,
7945
height: options.height,
7947
zIndex: options.zIndex
7949
// setting tabIndex makes the div focusable
7950
// setting outline to 0 prevents a border on focus in Mozilla
7951
.attr('tabIndex', -1).css('outline', 0).keydown(function(ev) {
7952
(options.closeOnEscape && ev.keyCode
7953
&& ev.keyCode == $.keyCode.ESCAPE && self.close());
7955
.mousedown(function() {
7959
uiDialogButtonPane = (this.uiDialogButtonPane = $('<div/>'))
7960
.addClass('ui-dialog-buttonpane')
7962
position: 'absolute',
7965
.appendTo(uiDialog);
7967
this.uiDialogTitlebarClose = $('.ui-dialog-titlebar-close', uiDialogTitlebar)
7970
$(this).addClass('ui-dialog-titlebar-close-hover');
7973
$(this).removeClass('ui-dialog-titlebar-close-hover');
7976
.mousedown(function(ev) {
7977
ev.stopPropagation();
7984
uiDialogTitlebar.find("*").add(uiDialogTitlebar).each(function() {
7985
$.ui.disableSelection(this);
7988
(options.draggable && $.fn.draggable && this._makeDraggable());
7989
(options.resizable && $.fn.resizable && this._makeResizable());
7991
this._createButtons(options.buttons);
7992
this._isOpen = false;
7994
(options.bgiframe && $.fn.bgiframe && uiDialog.bgiframe());
7995
(options.autoOpen && this.open());
7998
destroy: function() {
7999
(this.overlay && this.overlay.destroy());
8000
this.uiDialog.hide();
8003
.removeData('dialog')
8004
.removeClass('ui-dialog-content')
8005
.hide().appendTo('body');
8006
this.uiDialog.remove();
8008
(this.originalTitle && this.element.attr('title', this.originalTitle));
8012
if (false === this._trigger('beforeclose', null, { options: this.options })) {
8016
(this.overlay && this.overlay.destroy());
8018
.hide(this.options.hide)
8019
.unbind('keypress.ui-dialog');
8021
this._trigger('close', null, { options: this.options });
8022
$.ui.dialog.overlay.resize();
8024
this._isOpen = false;
8027
isOpen: function() {
8028
return this._isOpen;
8032
if (this._isOpen) { return; }
8034
this.overlay = this.options.modal ? new $.ui.dialog.overlay(this) : null;
8035
(this.uiDialog.next().length && this.uiDialog.appendTo('body'));
8036
this._position(this.options.position);
8037
this.uiDialog.show(this.options.show);
8038
(this.options.autoResize && this._size());
8039
this._moveToTop(true);
8041
// prevent tabbing out of modal dialogs
8042
(this.options.modal && this.uiDialog.bind('keypress.ui-dialog', function(e) {
8043
if (e.keyCode != $.keyCode.TAB) {
8047
var tabbables = $(':tabbable', this),
8048
first = tabbables.filter(':first')[0],
8049
last = tabbables.filter(':last')[0];
8051
if (e.target == last && !e.shiftKey) {
8052
setTimeout(function() {
8055
} else if (e.target == first && e.shiftKey) {
8056
setTimeout(function() {
8062
this.uiDialog.find(':tabbable:first').focus();
8063
this._trigger('open', null, { options: this.options });
8064
this._isOpen = true;
8067
_createButtons: function(buttons) {
8070
uiDialogButtonPane = this.uiDialogButtonPane;
8072
// remove any existing buttons
8073
uiDialogButtonPane.empty().hide();
8075
$.each(buttons, function() { return !(hasButtons = true); });
8077
uiDialogButtonPane.show();
8078
$.each(buttons, function(name, fn) {
8079
$('<button type="button"></button>')
8081
.click(function() { fn.apply(self.element[0], arguments); })
8082
.appendTo(uiDialogButtonPane);
8087
_makeDraggable: function() {
8089
options = this.options;
8091
this.uiDialog.draggable({
8092
cancel: '.ui-dialog-content',
8093
helper: options.dragHelper,
8094
handle: '.ui-dialog-titlebar',
8097
(options.dragStart && options.dragStart.apply(self.element[0], arguments));
8100
(options.drag && options.drag.apply(self.element[0], arguments));
8103
(options.dragStop && options.dragStop.apply(self.element[0], arguments));
8104
$.ui.dialog.overlay.resize();
8109
_makeResizable: function(handles) {
8110
handles = (handles === undefined ? this.options.resizable : handles);
8112
options = this.options,
8113
resizeHandles = typeof handles == 'string'
8115
: 'n,e,s,w,se,sw,ne,nw';
8117
this.uiDialog.resizable({
8118
cancel: '.ui-dialog-content',
8119
helper: options.resizeHelper,
8120
maxWidth: options.maxWidth,
8121
maxHeight: options.maxHeight,
8122
minWidth: options.minWidth,
8123
minHeight: options.minHeight,
8125
(options.resizeStart && options.resizeStart.apply(self.element[0], arguments));
8127
resize: function() {
8128
(options.autoResize && self._size.apply(self));
8129
(options.resize && options.resize.apply(self.element[0], arguments));
8131
handles: resizeHandles,
8133
(options.autoResize && self._size.apply(self));
8134
(options.resizeStop && options.resizeStop.apply(self.element[0], arguments));
8135
$.ui.dialog.overlay.resize();
8140
// the force parameter allows us to move modal dialogs to their correct
8142
_moveToTop: function(force) {
8144
if ((this.options.modal && !force)
8145
|| (!this.options.stack && !this.options.modal)) {
8146
return this._trigger('focus', null, { options: this.options });
8149
var maxZ = this.options.zIndex, options = this.options;
8150
$('.ui-dialog:visible').each(function() {
8151
maxZ = Math.max(maxZ, parseInt($(this).css('z-index'), 10) || options.zIndex);
8153
(this.overlay && this.overlay.$el.css('z-index', ++maxZ));
8154
this.uiDialog.css('z-index', ++maxZ);
8156
this._trigger('focus', null, { options: this.options });
8159
_position: function(pos) {
8160
var wnd = $(window), doc = $(document),
8161
pTop = doc.scrollTop(), pLeft = doc.scrollLeft(),
8164
if ($.inArray(pos, ['center','top','right','bottom','left']) >= 0) {
8166
pos == 'right' || pos == 'left' ? pos : 'center',
8167
pos == 'top' || pos == 'bottom' ? pos : 'middle'
8170
if (pos.constructor != Array) {
8171
pos = ['center', 'middle'];
8173
if (pos[0].constructor == Number) {
8181
pLeft += wnd.width() - this.uiDialog.width();
8185
pLeft += (wnd.width() - this.uiDialog.width()) / 2;
8188
if (pos[1].constructor == Number) {
8196
pTop += wnd.height() - this.uiDialog.height();
8200
pTop += (wnd.height() - this.uiDialog.height()) / 2;
8204
// prevent the dialog from being too high (make sure the titlebar
8206
pTop = Math.max(pTop, minTop);
8207
this.uiDialog.css({top: pTop, left: pLeft});
8210
_setData: function(key, value){
8211
(setDataSwitch[key] && this.uiDialog.data(setDataSwitch[key], value));
8214
this._createButtons(value);
8218
? this._makeDraggable()
8219
: this.uiDialog.draggable('destroy'));
8222
this.uiDialog.height(value);
8225
this._position(value);
8228
var uiDialog = this.uiDialog,
8229
isResizable = this.uiDialog.is(':data(resizable)');
8231
// currently resizable, becoming non-resizable
8232
(isResizable && !value && uiDialog.resizable('destroy'));
8234
// currently resizable, changing handles
8235
(isResizable && typeof value == 'string' &&
8236
uiDialog.resizable('option', 'handles', value));
8238
// currently non-resizable, becoming resizable
8239
(isResizable || this._makeResizable(value));
8243
$(".ui-dialog-title", this.uiDialogTitlebar).html(value || ' ');
8246
this.uiDialog.width(value);
8250
$.widget.prototype._setData.apply(this, arguments);
8254
var container = this.uiDialogContainer,
8255
titlebar = this.uiDialogTitlebar,
8256
content = this.element,
8257
tbMargin = (parseInt(content.css('margin-top'), 10) || 0)
8258
+ (parseInt(content.css('margin-bottom'), 10) || 0),
8259
lrMargin = (parseInt(content.css('margin-left'), 10) || 0)
8260
+ (parseInt(content.css('margin-right'), 10) || 0);
8261
content.height(container.height() - titlebar.outerHeight() - tbMargin);
8262
content.width(container.width() - lrMargin);
8266
$.extend($.ui.dialog, {
8272
closeOnEscape: true,
8289
getTitleId: function($el) {
8290
return 'ui-dialog-title-' + ($el.attr('id') || ++this.uuid);
8293
overlay: function(dialog) {
8294
this.$el = $.ui.dialog.overlay.create(dialog);
8298
$.extend($.ui.dialog.overlay, {
8300
events: $.map('focus,mousedown,mouseup,keydown,keypress,click'.split(','),
8301
function(e) { return e + '.dialog-overlay'; }).join(' '),
8302
create: function(dialog) {
8303
if (this.instances.length === 0) {
8304
// prevent use of anchors and inputs
8305
// we use a setTimeout in case the overlay is created from an
8306
// event that we're going to be cancelling (see #2804)
8307
setTimeout(function() {
8308
$('a, :input').bind($.ui.dialog.overlay.events, function() {
8309
// allow use of the element if inside a dialog and
8310
// - there are no modal dialogs
8311
// - there are modal dialogs, but we are in front of the topmost modal
8313
var $dialog = $(this).parents('.ui-dialog');
8314
if ($dialog.length) {
8315
var $overlays = $('.ui-dialog-overlay');
8316
if ($overlays.length) {
8317
var maxZ = parseInt($overlays.css('z-index'), 10);
8318
$overlays.each(function() {
8319
maxZ = Math.max(maxZ, parseInt($(this).css('z-index'), 10));
8321
allow = parseInt($dialog.css('z-index'), 10) > maxZ;
8330
// allow closing by pressing the escape key
8331
$(document).bind('keydown.dialog-overlay', function(e) {
8332
(dialog.options.closeOnEscape && e.keyCode
8333
&& e.keyCode == $.keyCode.ESCAPE && dialog.close());
8336
// handle window resize
8337
$(window).bind('resize.dialog-overlay', $.ui.dialog.overlay.resize);
8340
var $el = $('<div/>').appendTo(document.body)
8341
.addClass('ui-dialog-overlay').css($.extend({
8342
borderWidth: 0, margin: 0, padding: 0,
8343
position: 'absolute', top: 0, left: 0,
8344
width: this.width(),
8345
height: this.height()
8346
}, dialog.options.overlay));
8348
(dialog.options.bgiframe && $.fn.bgiframe && $el.bgiframe());
8350
this.instances.push($el);
8354
destroy: function($el) {
8355
this.instances.splice($.inArray(this.instances, $el), 1);
8357
if (this.instances.length === 0) {
8358
$('a, :input').add([document, window]).unbind('.dialog-overlay');
8364
height: function() {
8366
if ($.browser.msie && $.browser.version < 7) {
8367
var scrollHeight = Math.max(
8368
document.documentElement.scrollHeight,
8369
document.body.scrollHeight
8371
var offsetHeight = Math.max(
8372
document.documentElement.offsetHeight,
8373
document.body.offsetHeight
8376
if (scrollHeight < offsetHeight) {
8377
return $(window).height() + 'px';
8379
return scrollHeight + 'px';
8382
} else if ($.browser.opera) {
8385
$(document).height()
8387
// handle "good" browsers
8389
return $(document).height() + 'px';
8395
if ($.browser.msie && $.browser.version < 7) {
8396
var scrollWidth = Math.max(
8397
document.documentElement.scrollWidth,
8398
document.body.scrollWidth
8400
var offsetWidth = Math.max(
8401
document.documentElement.offsetWidth,
8402
document.body.offsetWidth
8405
if (scrollWidth < offsetWidth) {
8406
return $(window).width() + 'px';
8408
return scrollWidth + 'px';
8411
} else if ($.browser.opera) {
8416
// handle "good" browsers
8418
return $(document).width() + 'px';
8422
resize: function() {
8423
/* If the dialog is draggable and the user drags it past the
8424
* right edge of the window, the document becomes wider so we
8425
* need to stretch the overlay. If the user then drags the
8426
* dialog back to the left, the document will become narrower,
8427
* so we need to shrink the overlay to the appropriate size.
8428
* This is handled by shrinking the overlay before setting it
8429
* to the full document size.
8431
var $overlays = $([]);
8432
$.each($.ui.dialog.overlay.instances, function() {
8433
$overlays = $overlays.add(this);
8440
width: $.ui.dialog.overlay.width(),
8441
height: $.ui.dialog.overlay.height()
8446
$.extend($.ui.dialog.overlay.prototype, {
8447
destroy: function() {
8448
$.ui.dialog.overlay.destroy(this.$el);
8454
* jQuery UI Magnifier @VERSION
8456
* Copyright (c) 2008 jQuery
8457
* Dual licensed under the MIT (MIT-LICENSE.txt)
8458
* and GPL (GPL-LICENSE.txt) licenses.
8460
* http://docs.jquery.com/UI/Magnifier
8469
$.widget("ui.magnifier", {
8475
.addClass("ui-magnifier")
8476
.bind('click.magnifier', function(e) {
8477
(!self.disabled && o.click && o.click.apply(this, [e, {
8478
options: self.options,
8479
current: self.current[0],
8480
currentOffset: self.current[1]
8484
// the element must have relative or absolute positioning
8485
if (!(/^(r|a)/).test(this.element.css("position"))) {
8486
this.element.css("position", "relative");
8490
this.element.find(o.items).each(function() {
8491
var $this = $(this);
8492
// TODO: use a hash so references to this data is readable
8496
[$this.width(),$this.height()],
8497
(o.overlap ? $this.position() : null)
8500
(o.opacity && $this.css('opacity', o.opacity.min));
8504
(o.overlap && $.each(this.items, function() {
8506
position: "absolute",
8512
this.identifier = ++counter;
8513
$(document).bind("mousemove.magnifier"+this.identifier, function(e) {
8514
(self.disabled || self._magnify.apply(self, [e]));
8517
this.pp = this.element.offset();
8520
destroy: function() {
8523
.removeClass("ui-magnifier ui-magnifier-disabled")
8524
.unbind(".magnifier");
8525
$(document).unbind("mousemove.magnifier"+this.identifier);
8528
disable: function() {
8530
$.widget.prototype.disable.apply(this, arguments);
8533
reset: function(e) {
8534
var o = this.options;
8536
$.each(this.items, function() {
8541
top: (item[3] ? item[3].top : 0),
8542
left: (item[3] ? item[3].left : 0)
8545
(o.opacity && $(item[0]).css('opacity', o.opacity.min));
8546
(o.zIndex && $(item[0]).css("z-index", ""));
8550
_magnify: function(e) {
8551
var p = [e.pageX,e.pageY], o = this.options, c, distance = 1;
8552
this.current = this.items[0];
8554
// Compute the parent's distance
8555
// we don't need to fire anything if we are not near the parent
8556
var overlap = ((p[0] > this.pp.left-o.distance) &&
8557
(p[0] < this.pp.left + this.element[0].offsetWidth + o.distance) &&
8558
(p[1] > this.pp.top-o.distance) &&
8559
(p[1] < this.pp.top + this.element[0].offsetHeight + o.distance));
8560
if (!overlap) { return false; }
8562
for (var i=0; i<this.items.length; i++) {
8565
var olddistance = distance;
8567
distance = Math.sqrt(
8568
Math.pow(p[0] - ((c[3] ? this.pp.left : c[1].left) + parseInt(c[0].style.left,10)) - (c[0].offsetWidth/2), 2)
8569
+ Math.pow(p[1] - ((c[3] ? this.pp.top : c[1].top ) + parseInt(c[0].style.top,10)) - (c[0].offsetHeight/2), 2)
8573
distance = Math.abs(p[1] - ((c[3] ? this.pp.top : c[1].top ) + parseInt(c[0].style.top,10)) - (c[0].offsetHeight/2));
8575
distance = Math.abs(p[0] - ((c[3] ? this.pp.left : c[1].left) + parseInt(c[0].style.left,10)) - (c[0].offsetWidth/2));
8579
if (distance < o.distance) {
8580
this.current = distance < olddistance ? c : this.current;
8582
if (!o.axis || o.axis != "y") {
8584
width: c[2][0]+ (c[2][0] * (o.magnification-1)) - (((distance/o.distance)*c[2][0]) * (o.magnification-1)),
8585
left: (c[3] ? (c[3].left + o.verticalLine * ((c[2][1] * (o.magnification-1)) - (((distance/o.distance)*c[2][1]) * (o.magnification-1)))) : 0)
8589
if (!o.axis || o.axis != "x") {
8591
height: c[2][1]+ (c[2][1] * (o.magnification-1)) - (((distance/o.distance)*c[2][1]) * (o.magnification-1)),
8592
top: (c[3] ? c[3].top : 0) + (o.baseline-0.5) * ((c[2][0] * (o.magnification-1)) - (((distance/o.distance)*c[2][0]) * (o.magnification-1)))
8597
$(c[0]).css('opacity', o.opacity.max-(distance/o.distance) < o.opacity.min ? o.opacity.min : o.opacity.max-(distance/o.distance));
8603
top: (c[3] ? c[3].top : 0),
8604
left: (c[3] ? c[3].left : 0)
8607
(o.opacity && $(c[0]).css('opacity', o.opacity.min));
8610
(o.zIndex && $(c[0]).css("z-index", ""));
8613
(o.zIndex && $(this.current[0]).css("z-index", o.zIndex));
8617
$.extend($.ui.magnifier, {
8629
* jQuery UI ProgressBar @VERSION
8631
* Copyright (c) 2008 Eduardo Lundgren
8632
* Dual licensed under the MIT (MIT-LICENSE.txt)
8633
* and GPL (GPL-LICENSE.txt) licenses.
8635
* http://docs.jquery.com/UI/ProgressBar
8642
$.widget("ui.progressbar", {
8645
this._interval = this.options.interval;
8648
options = this.options,
8649
id = (new Date()).getTime()+Math.random(),
8650
text = options.text || '0%';
8652
this.element.addClass("ui-progressbar").width(options.width);
8659
bar: $('<div class="ui-progressbar-bar ui-hidden"></div>').css({
8660
width: '0px', overflow: 'hidden', zIndex: 100
8662
textElement: $('<div class="ui-progressbar-text"></div>').html(text).css({
8663
width: '0px', overflow: 'hidden'
8665
textBg: $('<div class="ui-progressbar-text ui-progressbar-text-back"></div>').html(text).css({
8666
width: this.element.width()
8668
wrapper: $('<div class="ui-progressbar-wrap"></div>')
8672
.append(this.bar.append(this.textElement.addClass(options.textClass)), this.textBg)
8673
.appendTo(this.element);
8680
identifier: this.identifier,
8681
options: this.options,
8683
textElement: this.textElement,
8684
pixelState: this.pixelState,
8685
percentState: this.percentState
8689
_propagate: function(n,e) {
8690
$.ui.plugin.call(this, n, [e, this.ui()]);
8691
this.element.triggerHandler(n == "progressbar" ? n : ["progressbar", n].join(""), [e, this.ui()], this.options[n]);
8694
destroy: function() {
8698
.removeClass("ui-progressbar ui-progressbar-disabled")
8699
.removeData("progressbar").unbind(".progressbar")
8700
.find('.ui-progressbar-wrap').remove();
8702
delete jQuery.easing[this.identifier];
8705
enable: function() {
8706
this.element.removeClass("ui-progressbar-disabled");
8707
this.disabled = false;
8710
disable: function() {
8711
this.element.addClass("ui-progressbar-disabled");
8712
this.disabled = true;
8716
var self = this, options = this.options;
8718
if (this.disabled) {
8722
jQuery.easing[this.identifier] = function (x, t, b, c, d) {
8723
var inc = options.increment,
8724
width = options.width,
8725
step = ((inc > width ? width : inc)/width),
8726
state = Math.round(x/step)*step;
8727
return state > 1 ? 1 : state;
8734
self.active = false;
8741
this._propagate('start', this.ui());
8745
_animate: function() {
8747
options = this.options,
8748
interval = options.interval;
8752
width: options.width
8756
easing: this.identifier,
8757
step: function(step, b) {
8758
self.progress((step/options.width)*100);
8759
var timestamp = new Date().getTime(), elapsedTime = (timestamp - b.startTime);
8760
options.interval = interval - elapsedTime;
8762
complete: function() {
8763
delete jQuery.easing[self.identifier];
8775
if (this.disabled) return;
8777
this._propagate('pause', this.ui());
8783
this.textElement.width(0);
8784
this.bar.addClass('ui-hidden');
8785
this.options.interval = this._interval;
8786
this._propagate('stop', this.ui());
8789
text: function(text){
8790
this.textElement.html(text);
8791
this.textBg.html(text);
8794
progress: function(percentState) {
8795
if (this.bar.is('.ui-hidden')) {
8796
this.bar.removeClass('ui-hidden');
8799
this.percentState = percentState > 100 ? 100 : percentState;
8800
this.pixelState = (this.percentState/100)*this.options.width;
8801
this.bar.width(this.pixelState);
8802
this.textElement.width(this.pixelState);
8804
if (this.options.range && !this.options.text) {
8805
this.textElement.html(Math.round(this.percentState) + '%');
8807
this._propagate('progress', this.ui());
8811
$.ui.progressbar.defaults = {
8823
* jQuery UI Slider @VERSION
8825
* Copyright (c) 2008 Paul Bakaus
8826
* Dual licensed under the MIT (MIT-LICENSE.txt)
8827
* and GPL (GPL-LICENSE.txt) licenses.
8829
* http://docs.jquery.com/UI/Slider
8836
$.fn.unwrap = $.fn.unwrap || function(expr) {
8837
return this.each(function(){
8838
$(this).parents(expr).eq(0).after(this).remove();
8842
$.widget("ui.slider", {
8846
options: this.options,
8847
handle: this.currentHandle,
8848
value: this.options.axis != "both" || !this.options.axis ? Math.round(this.value(null,this.options.axis == "vertical" ? "y" : "x")) : {
8849
x: Math.round(this.value(null,"x")),
8850
y: Math.round(this.value(null,"y"))
8852
range: this._getRange()
8855
_propagate: function(n,e) {
8856
$.ui.plugin.call(this, n, [e, this.ui()]);
8857
this.element.triggerHandler(n == "slide" ? n : "slide"+n, [e, this.ui()], this.options[n]);
8859
destroy: function() {
8862
.removeClass("ui-slider ui-slider-disabled")
8863
.removeData("slider")
8866
if(this.handle && this.handle.length) {
8869
this.handle.each(function() {
8870
$(this).data("mouse")._mouseDestroy();
8874
this.generated && this.generated.remove();
8877
_setData: function(key, value) {
8878
$.widget.prototype._setData.apply(this, arguments);
8879
if (/min|max|steps/.test(key)) {
8880
this._initBoundaries();
8883
if(key == "range") {
8884
value ? this.handle.length == 2 && this._createRange() : this._removeRange();
8892
this.element.addClass("ui-slider");
8893
this._initBoundaries();
8895
// Initialize mouse and key events for interaction
8896
this.handle = $(this.options.handle, this.element);
8897
if (!this.handle.length) {
8898
self.handle = self.generated = $(self.options.handles || [0]).map(function() {
8899
var handle = $("<div/>").addClass("ui-slider-handle").appendTo(self.element);
8901
handle.attr("id", this.id);
8907
var handleclass = function(el) {
8908
this.element = $(el);
8909
this.element.data("mouse", this);
8910
this.options = self.options;
8912
this.element.bind("mousedown", function() {
8913
if(self.currentHandle) this.blur(self.currentHandle);
8914
self._focus(this, true);
8920
$.extend(handleclass.prototype, $.ui.mouse, {
8921
_mouseStart: function(e) { return self._start.call(self, e, this.element[0]); },
8922
_mouseStop: function(e) { return self._stop.call(self, e, this.element[0]); },
8923
_mouseDrag: function(e) { return self._drag.call(self, e, this.element[0]); },
8924
_mouseCapture: function() { return true; },
8925
trigger: function(e) { this._mouseDown(e); }
8931
new handleclass(this);
8933
.wrap('<a href="#" style="outline:none;border:none;"></a>')
8935
.bind('click', function() { return false; })
8936
.bind('focus', function(e) { self._focus(this.firstChild); })
8937
.bind('blur', function(e) { self._blur(this.firstChild); })
8938
.bind('keydown', function(e) { if(!self.options.noKeyboard) return self._keydown(e.keyCode, this.firstChild); })
8941
// Bind the click to the slider itself
8942
this.element.bind('mousedown.slider', function(e) {
8943
self._click.apply(self, [e]);
8944
self.currentHandle.data("mouse").trigger(e);
8945
self.firstValue = self.firstValue + 1; //This is for always triggering the change event
8948
// Move the first handle to the startValue
8949
$.each(this.options.handles || [], function(index, handle) {
8950
self.moveTo(handle.start, index, true);
8952
if (!isNaN(this.options.startValue))
8953
this.moveTo(this.options.startValue, 0, true);
8955
this.previousHandle = $(this.handle[0]); //set the previous handle to the first to allow clicking before selecting the handle
8956
if(this.handle.length == 2 && this.options.range) this._createRange();
8958
_initBoundaries: function() {
8960
var element = this.element[0], o = this.options;
8961
this.actualSize = { width: this.element.outerWidth() , height: this.element.outerHeight() };
8964
axis: o.axis || (element.offsetWidth < element.offsetHeight ? 'vertical' : 'horizontal'),
8965
max: !isNaN(parseInt(o.max,10)) ? { x: parseInt(o.max, 10), y: parseInt(o.max, 10) } : ({ x: o.max && o.max.x || 100, y: o.max && o.max.y || 100 }),
8966
min: !isNaN(parseInt(o.min,10)) ? { x: parseInt(o.min, 10), y: parseInt(o.min, 10) } : ({ x: o.min && o.min.x || 0, y: o.min && o.min.y || 0 })
8968
//Prepare the real maxValue
8970
x: o.max.x - o.min.x,
8971
y: o.max.y - o.min.y
8973
//Calculate stepping based on steps
8975
x: o.stepping && o.stepping.x || parseInt(o.stepping, 10) || (o.steps ? o.realMax.x/(o.steps.x || parseInt(o.steps, 10) || o.realMax.x) : 0),
8976
y: o.stepping && o.stepping.y || parseInt(o.stepping, 10) || (o.steps ? o.realMax.y/(o.steps.y || parseInt(o.steps, 10) || o.realMax.y) : 0)
8981
_keydown: function(keyCode, handle) {
8983
if(/(33|34|35|36|37|38|39|40)/.test(k)) {
8984
var o = this.options, xpos, ypos;
8985
if (/(35|36)/.test(k)) {
8986
xpos = (k == 35) ? o.max.x : o.min.x;
8987
ypos = (k == 35) ? o.max.y : o.min.y;
8989
var oper = /(34|37|40)/.test(k) ? "-=" : "+=";
8990
var step = /(37|38|39|40)/.test(k) ? "_oneStep" : "_pageStep";
8991
xpos = oper + this[step]("x");
8992
ypos = oper + this[step]("y");
9002
_focus: function(handle,hard) {
9003
this.currentHandle = $(handle).addClass('ui-slider-handle-active');
9005
this.currentHandle.parent()[0].focus();
9007
_blur: function(handle) {
9008
$(handle).removeClass('ui-slider-handle-active');
9009
if(this.currentHandle && this.currentHandle[0] == handle) { this.previousHandle = this.currentHandle; this.currentHandle = null; };
9011
_click: function(e) {
9012
// This method is only used if:
9013
// - The user didn't click a handle
9014
// - The Slider is not disabled
9015
// - There is a current, or previous selected handle (otherwise we wouldn't know which one to move)
9017
var pointer = [e.pageX,e.pageY];
9019
var clickedHandle = false;
9020
this.handle.each(function() {
9021
if(this == e.target)
9022
clickedHandle = true;
9024
if (clickedHandle || this.options.disabled || !(this.currentHandle || this.previousHandle))
9027
// If a previous handle was focussed, focus it again
9028
if (!this.currentHandle && this.previousHandle)
9029
this._focus(this.previousHandle, true);
9031
// propagate only for distance > 0, otherwise propagation is done my drag
9032
this.offset = this.element.offset();
9035
y: this._convertValue(e.pageY - this.offset.top - this.currentHandle[0].offsetHeight/2, "y"),
9036
x: this._convertValue(e.pageX - this.offset.left - this.currentHandle[0].offsetWidth/2, "x")
9037
}, null, !this.options.distance);
9042
_createRange: function() {
9043
if(this.rangeElement) return;
9044
this.rangeElement = $('<div></div>')
9045
.addClass('ui-slider-range')
9046
.css({ position: 'absolute' })
9047
.appendTo(this.element);
9048
this._updateRange();
9050
_removeRange: function() {
9051
this.rangeElement.remove();
9052
this.rangeElement = null;
9054
_updateRange: function() {
9055
var prop = this.options.axis == "vertical" ? "top" : "left";
9056
var size = this.options.axis == "vertical" ? "height" : "width";
9057
this.rangeElement.css(prop, (parseInt($(this.handle[0]).css(prop),10) || 0) + this._handleSize(0, this.options.axis == "vertical" ? "y" : "x")/2);
9058
this.rangeElement.css(size, (parseInt($(this.handle[1]).css(prop),10) || 0) - (parseInt($(this.handle[0]).css(prop),10) || 0));
9060
_getRange: function() {
9061
return this.rangeElement ? this._convertValue(parseInt(this.rangeElement.css(this.options.axis == "vertical" ? "height" : "width"),10), this.options.axis == "vertical" ? "y" : "x") : null;
9064
_handleIndex: function() {
9065
return this.handle.index(this.currentHandle[0]);
9067
value: function(handle, axis) {
9068
if(this.handle.length == 1) this.currentHandle = this.handle;
9069
if(!axis) axis = this.options.axis == "vertical" ? "y" : "x";
9071
var curHandle = $(handle != undefined && handle !== null ? this.handle[handle] || handle : this.currentHandle);
9073
if(curHandle.data("mouse").sliderValue) {
9074
return parseInt(curHandle.data("mouse").sliderValue[axis],10);
9076
return parseInt(((parseInt(curHandle.css(axis == "x" ? "left" : "top"),10) / (this.actualSize[axis == "x" ? "width" : "height"] - this._handleSize(handle,axis))) * this.options.realMax[axis]) + this.options.min[axis],10);
9080
_convertValue: function(value,axis) {
9081
return this.options.min[axis] + (value / (this.actualSize[axis == "x" ? "width" : "height"] - this._handleSize(null,axis))) * this.options.realMax[axis];
9084
_translateValue: function(value,axis) {
9085
return ((value - this.options.min[axis]) / this.options.realMax[axis]) * (this.actualSize[axis == "x" ? "width" : "height"] - this._handleSize(null,axis));
9087
_translateRange: function(value,axis) {
9088
if (this.rangeElement) {
9089
if (this.currentHandle[0] == this.handle[0] && value >= this._translateValue(this.value(1),axis))
9090
value = this._translateValue(this.value(1,axis) - this._oneStep(axis), axis);
9091
if (this.currentHandle[0] == this.handle[1] && value <= this._translateValue(this.value(0),axis))
9092
value = this._translateValue(this.value(0,axis) + this._oneStep(axis), axis);
9094
if (this.options.handles) {
9095
var handle = this.options.handles[this._handleIndex()];
9096
if (value < this._translateValue(handle.min,axis)) {
9097
value = this._translateValue(handle.min,axis);
9098
} else if (value > this._translateValue(handle.max,axis)) {
9099
value = this._translateValue(handle.max,axis);
9104
_translateLimits: function(value,axis) {
9105
if (value >= this.actualSize[axis == "x" ? "width" : "height"] - this._handleSize(null,axis))
9106
value = this.actualSize[axis == "x" ? "width" : "height"] - this._handleSize(null,axis);
9111
_handleSize: function(handle,axis) {
9112
return $(handle != undefined && handle !== null ? this.handle[handle] : this.currentHandle)[0]["offset"+(axis == "x" ? "Width" : "Height")];
9114
_oneStep: function(axis) {
9115
return this.options.stepping[axis] || 1;
9117
_pageStep: function(axis) {
9118
return /* this.options.paging[axis] ||*/ 10;
9122
_start: function(e, handle) {
9124
var o = this.options;
9125
if(o.disabled) return false;
9127
// Prepare the outer size
9128
this.actualSize = { width: this.element.outerWidth() , height: this.element.outerHeight() };
9130
// This is a especially ugly fix for strange blur events happening on mousemove events
9131
if (!this.currentHandle)
9132
this._focus(this.previousHandle, true);
9134
this.offset = this.element.offset();
9136
this.handleOffset = this.currentHandle.offset();
9137
this.clickOffset = { top: e.pageY - this.handleOffset.top, left: e.pageX - this.handleOffset.left };
9139
this.firstValue = this.value();
9141
this._propagate('start', e);
9142
this._drag(e, handle);
9146
_stop: function(e) {
9147
this._propagate('stop', e);
9148
if (this.firstValue != this.value())
9149
this._propagate('change', e);
9150
// This is a especially ugly fix for strange blur events happening on mousemove events
9151
this._focus(this.currentHandle, true);
9154
_drag: function(e, handle) {
9156
var o = this.options;
9157
var position = { top: e.pageY - this.offset.top - this.clickOffset.top, left: e.pageX - this.offset.left - this.clickOffset.left};
9158
if(!this.currentHandle) this._focus(this.previousHandle, true); //This is a especially ugly fix for strange blur events happening on mousemove events
9160
position.left = this._translateLimits(position.left, "x");
9161
position.top = this._translateLimits(position.top, "y");
9164
var value = this._convertValue(position.left, "x");
9165
value = Math.round(value / o.stepping.x) * o.stepping.x;
9166
position.left = this._translateValue(value, "x");
9169
var value = this._convertValue(position.top, "y");
9170
value = Math.round(value / o.stepping.y) * o.stepping.y;
9171
position.top = this._translateValue(value, "y");
9174
position.left = this._translateRange(position.left, "x");
9175
position.top = this._translateRange(position.top, "y");
9177
if(o.axis != "vertical") this.currentHandle.css({ left: position.left });
9178
if(o.axis != "horizontal") this.currentHandle.css({ top: position.top });
9180
//Store the slider's value
9181
this.currentHandle.data("mouse").sliderValue = {
9182
x: Math.round(this._convertValue(position.left, "x")) || 0,
9183
y: Math.round(this._convertValue(position.top, "y")) || 0
9186
if (this.rangeElement)
9187
this._updateRange();
9188
this._propagate('slide', e);
9192
moveTo: function(value, handle, noPropagation) {
9194
var o = this.options;
9196
// Prepare the outer size
9197
this.actualSize = { width: this.element.outerWidth() , height: this.element.outerHeight() };
9199
//If no handle has been passed, no current handle is available and we have multiple handles, return false
9200
if (handle == undefined && !this.currentHandle && this.handle.length != 1)
9203
//If only one handle is available, use it
9204
if (handle == undefined && !this.currentHandle)
9207
if (handle != undefined)
9208
this.currentHandle = this.previousHandle = $(this.handle[handle] || handle);
9211
if(value.x !== undefined && value.y !== undefined) {
9212
var x = value.x, y = value.y;
9214
var x = value, y = value;
9217
if(x !== undefined && x.constructor != Number) {
9218
var me = /^\-\=/.test(x), pe = /^\+\=/.test(x);
9220
x = this.value(null, "x") + parseInt(x.replace(me ? '=' : '+=', ''), 10);
9222
x = isNaN(parseInt(x, 10)) ? undefined : parseInt(x, 10);
9226
if(y !== undefined && y.constructor != Number) {
9227
var me = /^\-\=/.test(y), pe = /^\+\=/.test(y);
9229
y = this.value(null, "y") + parseInt(y.replace(me ? '=' : '+=', ''), 10);
9231
y = isNaN(parseInt(y, 10)) ? undefined : parseInt(y, 10);
9235
if(o.axis != "vertical" && x !== undefined) {
9236
if(o.stepping.x) x = Math.round(x / o.stepping.x) * o.stepping.x;
9237
x = this._translateValue(x, "x");
9238
x = this._translateLimits(x, "x");
9239
x = this._translateRange(x, "x");
9241
o.animate ? this.currentHandle.stop().animate({ left: x }, (Math.abs(parseInt(this.currentHandle.css("left")) - x)) * (!isNaN(parseInt(o.animate)) ? o.animate : 5)) : this.currentHandle.css({ left: x });
9244
if(o.axis != "horizontal" && y !== undefined) {
9245
if(o.stepping.y) y = Math.round(y / o.stepping.y) * o.stepping.y;
9246
y = this._translateValue(y, "y");
9247
y = this._translateLimits(y, "y");
9248
y = this._translateRange(y, "y");
9249
o.animate ? this.currentHandle.stop().animate({ top: y }, (Math.abs(parseInt(this.currentHandle.css("top")) - y)) * (!isNaN(parseInt(o.animate)) ? o.animate : 5)) : this.currentHandle.css({ top: y });
9252
if (this.rangeElement)
9253
this._updateRange();
9255
//Store the slider's value
9256
this.currentHandle.data("mouse").sliderValue = {
9257
x: Math.round(this._convertValue(x, "x")) || 0,
9258
y: Math.round(this._convertValue(y, "y")) || 0
9261
if (!noPropagation) {
9262
this._propagate('start', null);
9263
this._propagate('stop', null);
9264
this._propagate('change', null);
9265
this._propagate("slide", null);
9270
$.ui.slider.getter = "value";
9272
$.ui.slider.defaults = {
9273
handle: ".ui-slider-handle",
9280
* jQuery UI Spinner @VERSION
9282
* Copyright (c) 2008 jQuery
9283
* Dual licensed under the MIT (MIT-LICENSE.txt)
9284
* and GPL (GPL-LICENSE.txt) licenses.
9286
* http://docs.jquery.com/UI/Spinner
9293
$.widget('ui.spinner', {
9295
// terminate initialization if spinner already applied to current element
9296
if($.data(this.element[0], 'spinner')) return;
9298
// check for onInit callback
9299
if (this.options.init) {
9300
this.options.init(this.ui(null));
9303
// check for decimals in steppinng and set _decimals as internal (needs cleaning up)
9305
if (this.options.stepping.toString().indexOf('.') != -1) {
9306
var s = this.options.stepping.toString();
9307
this._decimals = s.slice(s.indexOf('.')+1, s.length).length;
9310
//Initialize needed constants
9313
.addClass('ui-spinner-box')
9314
.attr('autocomplete', 'off'); // switch off autocomplete in opera
9316
this._setValue( isNaN(this._getValue()) ? this.options.start : this._getValue() );
9321
.addClass('ui-spinner')
9322
.append('<button class="ui-spinner-up" type="button">▲</button>')
9323
.find('.ui-spinner-up')
9324
.bind('mousedown', function(e) {
9325
$(this).addClass('ui-spinner-pressed');
9326
if(!self.counter) self.counter = 1;
9327
self._mousedown(100, '_up', e);
9329
.bind('mouseup', function(e) {
9330
$(this).removeClass('ui-spinner-pressed');
9331
if(self.counter == 1) self._up(e);
9334
.bind('mouseout', function(e) {
9335
$(this).removeClass('ui-spinner-pressed');
9338
// mousedown/mouseup capture first click, now handle second click
9339
.bind('dblclick', function(e) {
9340
$(this).removeClass('ui-spinner-pressed');
9343
.bind('keydown.spinner', function(e) {
9344
var KEYS = $.keyCode;
9345
if (e.keyCode == KEYS.SPACE || e.keyCode == KEYS.ENTER) {
9346
$(this).addClass('ui-spinner-pressed');
9347
if(!self.counter) self.counter = 1;
9348
self._up.call(self, e);
9349
} else if (e.keyCode == KEYS.DOWN || e.keyCode == KEYS.RIGHT) {
9350
self.element.siblings('.ui-spinner-down').focus();
9351
} else if (e.keyCode == KEYS.LEFT) {
9352
self.element.focus();
9355
.bind('keyup.spinner', function(e) {
9356
$(this).removeClass('ui-spinner-pressed');
9358
self._propagate('change', e);
9361
.append('<button class="ui-spinner-down" type="button">▼</button>')
9362
.find('.ui-spinner-down')
9363
.bind('mousedown', function(e) {
9364
$(this).addClass('ui-spinner-pressed');
9365
if(!self.counter) self.counter = 1;
9366
self._mousedown(100, '_down', e);
9368
.bind('mouseup', function(e) {
9369
$(this).removeClass('ui-spinner-pressed');
9370
if(self.counter == 1) self._down();
9373
.bind('mouseout', function(e) {
9374
$(this).removeClass('ui-spinner-pressed');
9377
// mousedown/mouseup capture first click, now handle second click
9378
.bind('dblclick', function(e) {
9379
$(this).removeClass('ui-spinner-pressed');
9382
.bind('keydown.spinner', function(e) {
9383
var KEYS = $.keyCode;
9384
if (e.keyCode == KEYS.SPACE || e.keyCode == KEYS.ENTER) {
9385
$(this).addClass('ui-spinner-pressed');
9386
if(!self.counter) self.counter = 1;
9387
self._down.call(self, e);
9388
} else if (e.keyCode == KEYS.UP || e.keyCode == KEYS.LEFT) {
9389
self.element.siblings('.ui-spinner-up').focus();
9392
.bind('keyup.spinner', function(e) {
9393
$(this).removeClass('ui-spinner-pressed');
9395
self._propagate('change', e);
9400
// DataList: Set contraints for object length and step size.
9401
// Manipulate height of spinner.
9402
this._items = this.element.children().length;
9403
if (this._items > 1) {
9405
.addClass('ui-spinner-list')
9406
.css('height', this.element.outerHeight()/this._items)
9408
.addClass('ui-spinner-listitem')
9411
.css('height', this.element.outerHeight())
9413
this.options.stepping = 1;
9414
this.options.min = 0;
9415
this.options.max = this._items-1;
9419
.bind('keydown.spinner', function(e) {
9420
if(!self.counter) self.counter = 1;
9421
return self._keydown.call(self, e);
9423
.bind('keyup.spinner', function(e) {
9425
self._propagate('change', e);
9427
.bind('blur.spinner', function(e) {
9431
if ($.fn.mousewheel) {
9432
this.element.mousewheel(function(e, delta) {
9433
self._mousewheel(e, delta);
9439
_constrain: function() {
9440
if(this.options.min != undefined && this._getValue() < this.options.min) this._setValue(this.options.min);
9441
if(this.options.max != undefined && this._getValue() > this.options.max) this._setValue(this.options.max);
9443
_cleanUp: function() {
9444
this._setValue(this._getValue());
9447
_spin: function(d, e) {
9448
if (this.disabled) return;
9450
if(isNaN(this._getValue())) this._setValue(this.options.start);
9451
this._setValue(this._getValue() + (d == 'up' ? 1:-1) * (this.options.incremental && this.counter > 100 ? (this.counter > 200 ? 100 : 10) : 1) * this.options.stepping);
9454
if(this.counter) this.counter++;
9455
this._propagate('spin', e);
9457
_down: function(e) {
9458
this._spin('down', e);
9459
this._propagate('down', e);
9462
this._spin('up', e);
9463
this._propagate('up', e);
9465
_mousedown: function(i, d, e) {
9468
if(this.timer) window.clearInterval(this.timer);
9469
this.timer = window.setInterval(function() {
9471
if(self.counter > 20) self._mousedown(20, d, e);
9474
_mouseup: function(e) {
9476
if(this.timer) window.clearInterval(this.timer);
9477
this.element[0].focus();
9478
this._propagate('change', e);
9480
_keydown: function(e) {
9481
var KEYS = $.keyCode;
9483
if(e.keyCode == KEYS.UP) this._up(e);
9484
if(e.keyCode == KEYS.DOWN) this._down(e);
9485
if(e.keyCode == KEYS.HOME) this._setValue(this.options.min || this.options.start); //Home key goes to min, if defined, else to start
9486
if(e.keyCode == KEYS.END && this.options.max != undefined) this._setValue(this.options.max); //End key goes to maximum
9487
return (e.keyCode == KEYS.TAB || e.keyCode == KEYS.BACKSPACE ||
9488
e.keyCode == KEYS.LEFT || e.keyCode == KEYS.RIGHT || e.keyCode == KEYS.PERIOD ||
9489
e.keyCode == KEYS.NUMPAD_DECIMAL || e.keyCode == KEYS.NUMPAD_SUBTRACT ||
9490
(e.keyCode >= 96 && e.keyCode <= 105) || // add support for numeric keypad 0-9
9491
(/[0-9\-\.]/).test(String.fromCharCode(e.keyCode))) ? true : false;
9493
_mousewheel: function(e, delta) {
9494
delta = ($.browser.opera ? -delta / Math.abs(delta) : delta);
9495
delta > 0 ? this._up(e) : this._down(e);
9498
_getValue: function() {
9499
return parseFloat(this.element.val().replace(/[^0-9\-\.]/g, ''));
9501
_setValue: function(newVal) {
9502
if(isNaN(newVal)) newVal = this.options.start;
9504
this.options.currency ?
9505
$.ui.spinner.format.currency(newVal, this.options.currency) :
9506
$.ui.spinner.format.number(newVal, this._decimals)
9509
_animate: function(d) {
9510
if (this.element.hasClass('ui-spinner-list') && ((d == 'up' && this._getValue() <= this.options.max) || (d == 'down' && this._getValue() >= this.options.min)) ) {
9511
this.element.animate({marginTop: '-' + this._getValue() * this.element.outerHeight() }, {
9517
_addItem: function(html) {
9518
if (!this.element.is('input')) {
9519
var wrapper = 'div';
9520
if (this.element.is('ol') || this.element.is('ul')) {
9523
this.element.append('<'+ wrapper +' class="ui-spinner-dyn">'+ html + '</'+ wrapper +'>');
9531
options: this.options,
9532
element: this.element,
9533
value: this._getValue(),
9537
_propagate: function(n,e) {
9538
$.ui.plugin.call(this, n, [e, this.ui()]);
9539
return this.element.triggerHandler(n == 'spin' ? n : 'spin'+n, [e, this.ui()], this.options[n]);
9541
destroy: function() {
9542
if(!$.data(this.element[0], 'spinner')) return;
9543
if ($.fn.mousewheel) {
9544
this.element.unmousewheel();
9547
.removeClass('ui-spinner-box ui-spinner-list')
9548
.removeAttr('disabled')
9549
.removeAttr('autocomplete')
9550
.removeData('spinner')
9556
.removeClass('ui-spinner-listitem')
9557
.remove('.ui-spinner-dyn')
9560
.removeClass('ui-spinner ui-spinner-disabled')
9561
.before(this.element.clone())
9565
enable: function() {
9567
.removeAttr('disabled')
9569
.removeAttr('disabled')
9571
.removeClass('ui-spinner-disabled');
9572
this.disabled = false;
9574
disable: function() {
9576
.attr('disabled', true)
9578
.attr('disabled', true)
9580
.addClass('ui-spinner-disabled');
9581
this.disabled = true;
9585
$.extend($.ui.spinner, {
9593
number: function(num, dec) {
9594
return this.round(num, dec);
9596
currency: function(num, sym) {
9597
return (num !== Math.abs(num) ? '-' : '') + sym + this.round(Math.abs(num), 2);
9599
round: function(num, dec) {
9600
var s = Math.round(parseFloat(num)*Math.pow(10, dec)) / Math.pow(10, dec); // round off weird decimals
9602
s = s + ((s.toString().indexOf('.') == -1) ? '.' : '') + '0000000001';
9603
s = s.substr(0, s.indexOf('.')+1+dec);
9614
* jQuery UI Tabs @VERSION
9616
* Copyright (c) 2007, 2008 Klaus Hartl (stilbuero.de)
9617
* Dual licensed under the MIT (MIT-LICENSE.txt)
9618
* and GPL (GPL-LICENSE.txt) licenses.
9620
* http://docs.jquery.com/UI/Tabs
9627
$.widget("ui.tabs", {
9629
this.options.event += '.tabs'; // namespace event
9634
_setData: function(key, value) {
9635
if ((/^selected/).test(key))
9638
this.options[key] = value;
9642
length: function() {
9643
return this.$tabs.length;
9645
_tabId: function(a) {
9646
return a.title && a.title.replace(/\s/g, '_').replace(/[^A-Za-z0-9\-_:\.]/g, '')
9647
|| this.options.idPrefix + $.data(a);
9649
ui: function(tab, panel) {
9651
options: this.options,
9654
index: this.$tabs.index(tab)
9657
_tabify: function(init) {
9659
this.$lis = $('li:has(a[href])', this.element);
9660
this.$tabs = this.$lis.map(function() { return $('a', this)[0]; });
9661
this.$panels = $([]);
9663
var self = this, o = this.options;
9665
this.$tabs.each(function(i, a) {
9667
if (a.hash && a.hash.replace('#', '')) // Safari 2 reports '#' for an empty hash
9668
self.$panels = self.$panels.add(a.hash);
9670
else if ($(a).attr('href') != '#') { // prevent loading the page itself if href is just "#"
9671
$.data(a, 'href.tabs', a.href); // required for restore on destroy
9672
$.data(a, 'load.tabs', a.href); // mutable
9673
var id = self._tabId(a);
9675
var $panel = $('#' + id);
9676
if (!$panel.length) {
9677
$panel = $(o.panelTemplate).attr('id', id).addClass(o.panelClass)
9678
.insertAfter( self.$panels[i - 1] || self.element );
9679
$panel.data('destroy.tabs', true);
9681
self.$panels = self.$panels.add( $panel );
9685
o.disabled.push(i + 1);
9688
// initialization from scratch
9691
// attach necessary classes for styling if not present
9692
this.element.addClass(o.navClass);
9693
this.$panels.each(function() {
9694
var $this = $(this);
9695
$this.addClass(o.panelClass);
9699
// use "selected" option or try to retrieve:
9700
// 1. from fragment identifier in url
9702
// 3. from selected class attribute on <li>
9703
if (o.selected === undefined) {
9704
if (location.hash) {
9705
this.$tabs.each(function(i, a) {
9706
if (a.hash == location.hash) {
9708
// prevent page scroll to fragment
9709
if ($.browser.msie || $.browser.opera) { // && !o.remote
9710
var $toShow = $(location.hash), toShowId = $toShow.attr('id');
9711
$toShow.attr('id', '');
9712
setTimeout(function() {
9713
$toShow.attr('id', toShowId); // restore id
9717
return false; // break
9721
else if (o.cookie) {
9722
var index = parseInt($.cookie('ui-tabs-' + $.data(self.element[0])), 10);
9723
if (index && self.$tabs[index])
9726
else if (self.$lis.filter('.' + o.selectedClass).length)
9727
o.selected = self.$lis.index( self.$lis.filter('.' + o.selectedClass)[0] );
9729
o.selected = o.selected === null || o.selected !== undefined ? o.selected : 0; // first tab selected by default
9731
// Take disabling tabs via class attribute from HTML
9732
// into account and update option properly.
9733
// A selected tab cannot become disabled.
9734
o.disabled = $.unique(o.disabled.concat(
9735
$.map(this.$lis.filter('.' + o.disabledClass),
9736
function(n, i) { return self.$lis.index(n); } )
9738
if ($.inArray(o.selected, o.disabled) != -1)
9739
o.disabled.splice($.inArray(o.selected, o.disabled), 1);
9741
// highlight selected tab
9742
this.$panels.addClass(o.hideClass);
9743
this.$lis.removeClass(o.selectedClass);
9744
if (o.selected !== null) {
9745
this.$panels.eq(o.selected).show().removeClass(o.hideClass); // use show and remove class to show in any case no matter how it has been hidden before
9746
this.$lis.eq(o.selected).addClass(o.selectedClass);
9748
// seems to be expected behavior that the show callback is fired
9749
var onShow = function() {
9750
self._trigger('show', null,
9751
self.ui(self.$tabs[o.selected], self.$panels[o.selected]));
9754
// load if remote tab
9755
if ($.data(this.$tabs[o.selected], 'load.tabs'))
9756
this.load(o.selected, onShow);
9757
// just trigger show event
9762
// clean up to avoid memory leaks in certain versions of IE 6
9763
$(window).bind('unload', function() {
9764
self.$tabs.unbind('.tabs');
9765
self.$lis = self.$tabs = self.$panels = null;
9769
// update selected after add/remove
9771
o.selected = this.$lis.index( this.$lis.filter('.' + o.selectedClass)[0] );
9773
// set or update cookie after init and add/remove respectively
9775
$.cookie('ui-tabs-' + $.data(self.element[0]), o.selected, o.cookie);
9778
for (var i = 0, li; li = this.$lis[i]; i++)
9779
$(li)[$.inArray(i, o.disabled) != -1 && !$(li).hasClass(o.selectedClass) ? 'addClass' : 'removeClass'](o.disabledClass);
9781
// reset cache if switching from cached to not cached
9782
if (o.cache === false)
9783
this.$tabs.removeData('cache.tabs');
9785
// set up animations
9786
var hideFx, showFx, baseFx = { 'min-width': 0, duration: 1 }, baseDuration = 'normal';
9787
if (o.fx && o.fx.constructor == Array)
9788
hideFx = o.fx[0] || baseFx, showFx = o.fx[1] || baseFx;
9790
hideFx = showFx = o.fx || baseFx;
9792
// reset some styles to maintain print style sheets etc.
9793
var resetCSS = { display: '', overflow: '', height: '' };
9794
if (!$.browser.msie) // not in IE to prevent ClearType font issue
9795
resetCSS.opacity = '';
9797
// Hide a tab, animation prevents browser scrolling to fragment,
9798
// $show is optional.
9799
function hideTab(clicked, $hide, $show) {
9800
$hide.animate(hideFx, hideFx.duration || baseDuration, function() { //
9801
$hide.addClass(o.hideClass).css(resetCSS); // maintain flexible height and accessibility in print etc.
9802
if ($.browser.msie && hideFx.opacity)
9803
$hide[0].style.filter = '';
9805
showTab(clicked, $show, $hide);
9809
// Show a tab, animation prevents browser scrolling to fragment,
9810
// $hide is optional.
9811
function showTab(clicked, $show, $hide) {
9812
if (showFx === baseFx)
9813
$show.css('display', 'block'); // prevent occasionally occuring flicker in Firefox cause by gap between showing and hiding the tab panels
9814
$show.animate(showFx, showFx.duration || baseDuration, function() {
9815
$show.removeClass(o.hideClass).css(resetCSS); // maintain flexible height and accessibility in print etc.
9816
if ($.browser.msie && showFx.opacity)
9817
$show[0].style.filter = '';
9820
self._trigger('show', null, self.ui(clicked, $show[0]));
9825
function switchTab(clicked, $li, $hide, $show) {
9826
/*if (o.bookmarkable && trueClick) { // add to history only if true click occured, not a triggered click
9827
$.ajaxHistory.update(clicked.hash);
9829
$li.addClass(o.selectedClass)
9830
.siblings().removeClass(o.selectedClass);
9831
hideTab(clicked, $hide, $show);
9834
// attach tab event handler, unbind to avoid duplicates from former tabifying...
9835
this.$tabs.unbind('.tabs').bind(o.event, function() {
9837
//var trueClick = e.clientX; // add to history only if true click occured, not a triggered click
9838
var $li = $(this).parents('li:eq(0)'),
9839
$hide = self.$panels.filter(':visible'),
9840
$show = $(this.hash);
9842
// If tab is already selected and not unselectable or tab disabled or
9843
// or is already loading or click callback returns false stop here.
9844
// Check if click handler returns false last so that it is not executed
9845
// for a disabled or loading tab!
9846
if (($li.hasClass(o.selectedClass) && !o.unselect)
9847
|| $li.hasClass(o.disabledClass)
9848
|| $(this).hasClass(o.loadingClass)
9849
|| self._trigger('select', null, self.ui(this, $show[0])) === false
9855
self.options.selected = self.$tabs.index(this);
9857
// if tab may be closed
9859
if ($li.hasClass(o.selectedClass)) {
9860
self.options.selected = null;
9861
$li.removeClass(o.selectedClass);
9862
self.$panels.stop();
9863
hideTab(this, $hide);
9866
} else if (!$hide.length) {
9867
self.$panels.stop();
9869
self.load(self.$tabs.index(this), function() {
9870
$li.addClass(o.selectedClass).addClass(o.unselectClass);
9879
$.cookie('ui-tabs-' + $.data(self.element[0]), self.options.selected, o.cookie);
9881
// stop possibly running animations
9882
self.$panels.stop();
9887
// prevent scrollbar scrolling to 0 and than back in IE7, happens only if bookmarking/history is enabled
9888
/*if ($.browser.msie && o.bookmarkable) {
9889
var showId = this.hash.replace('#', '');
9890
$show.attr('id', '');
9891
setTimeout(function() {
9892
$show.attr('id', showId); // restore id
9897
self.load(self.$tabs.index(this), $hide.length ?
9899
switchTab(a, $li, $hide, $show);
9902
$li.addClass(o.selectedClass);
9907
// Set scrollbar to saved position - need to use timeout with 0 to prevent browser scroll to target of hash
9908
/*var scrollX = window.pageXOffset || document.documentElement && document.documentElement.scrollLeft || document.body.scrollLeft || 0;
9909
var scrollY = window.pageYOffset || document.documentElement && document.documentElement.scrollTop || document.body.scrollTop || 0;
9910
setTimeout(function() {
9911
scrollTo(scrollX, scrollY);
9915
throw 'jQuery UI Tabs: Mismatching fragment identifier.';
9917
// Prevent IE from keeping other link focussed when using the back button
9918
// and remove dotted border from clicked link. This is controlled in modern
9919
// browsers via CSS, also blur removes focus from address bar in Firefox
9920
// which can become a usability and annoying problem with tabsRotate.
9924
//return o.bookmarkable && !!trueClick; // convert trueClick == undefined to Boolean required in IE
9929
// disable click if event is configured to something else
9930
if (!(/^click/).test(o.event))
9931
this.$tabs.bind('click.tabs', function() { return false; });
9934
add: function(url, label, index) {
9935
if (index == undefined)
9936
index = this.$tabs.length; // append by default
9938
var o = this.options;
9939
var $li = $(o.tabTemplate.replace(/#\{href\}/g, url).replace(/#\{label\}/g, label));
9940
$li.data('destroy.tabs', true);
9942
var id = url.indexOf('#') == 0 ? url.replace('#', '') : this._tabId( $('a:first-child', $li)[0] );
9944
// try to find an existing element before creating a new one
9945
var $panel = $('#' + id);
9946
if (!$panel.length) {
9947
$panel = $(o.panelTemplate).attr('id', id)
9948
.addClass(o.hideClass)
9949
.data('destroy.tabs', true);
9951
$panel.addClass(o.panelClass);
9952
if (index >= this.$lis.length) {
9953
$li.appendTo(this.element);
9954
$panel.appendTo(this.element[0].parentNode);
9956
$li.insertBefore(this.$lis[index]);
9957
$panel.insertBefore(this.$panels[index]);
9960
o.disabled = $.map(o.disabled,
9961
function(n, i) { return n >= index ? ++n : n });
9965
if (this.$tabs.length == 1) {
9966
$li.addClass(o.selectedClass);
9967
$panel.removeClass(o.hideClass);
9968
var href = $.data(this.$tabs[0], 'load.tabs');
9970
this.load(index, href);
9974
this._trigger('add', null, this.ui(this.$tabs[index], this.$panels[index]));
9976
remove: function(index) {
9977
var o = this.options, $li = this.$lis.eq(index).remove(),
9978
$panel = this.$panels.eq(index).remove();
9980
// If selected tab was removed focus tab to the right or
9981
// in case the last tab was removed the tab to the left.
9982
if ($li.hasClass(o.selectedClass) && this.$tabs.length > 1)
9983
this.select(index + (index + 1 < this.$tabs.length ? 1 : -1));
9985
o.disabled = $.map($.grep(o.disabled, function(n, i) { return n != index; }),
9986
function(n, i) { return n >= index ? --n : n });
9991
this._trigger('remove', null, this.ui($li.find('a')[0], $panel[0]));
9993
enable: function(index) {
9994
var o = this.options;
9995
if ($.inArray(index, o.disabled) == -1)
9998
var $li = this.$lis.eq(index).removeClass(o.disabledClass);
9999
if ($.browser.safari) { // fix disappearing tab (that used opacity indicating disabling) after enabling in Safari 2...
10000
$li.css('display', 'inline-block');
10001
setTimeout(function() {
10002
$li.css('display', 'block');
10006
o.disabled = $.grep(o.disabled, function(n, i) { return n != index; });
10009
this._trigger('enable', null, this.ui(this.$tabs[index], this.$panels[index]));
10011
disable: function(index) {
10012
var self = this, o = this.options;
10013
if (index != o.selected) { // cannot disable already selected tab
10014
this.$lis.eq(index).addClass(o.disabledClass);
10016
o.disabled.push(index);
10020
this._trigger('disable', null, this.ui(this.$tabs[index], this.$panels[index]));
10023
select: function(index) {
10024
if (typeof index == 'string')
10025
index = this.$tabs.index( this.$tabs.filter('[href$=' + index + ']')[0] );
10026
this.$tabs.eq(index).trigger(this.options.event);
10028
load: function(index, callback) { // callback is for internal usage only
10030
var self = this, o = this.options, $a = this.$tabs.eq(index), a = $a[0],
10031
bypassCache = callback == undefined || callback === false, url = $a.data('load.tabs');
10033
callback = callback || function() {};
10035
// no remote or from cache - just finish with callback
10036
if (!url || !bypassCache && $.data(a, 'cache.tabs')) {
10041
// load remote from here on
10043
var inner = function(parent) {
10044
var $parent = $(parent), $inner = $parent.find('*:last');
10045
return $inner.length && $inner.is(':not(img)') && $inner || $parent;
10047
var cleanup = function() {
10048
self.$tabs.filter('.' + o.loadingClass).removeClass(o.loadingClass)
10051
inner(this).parent().html(inner(this).data('label.tabs'));
10057
var label = inner(a).html();
10058
inner(a).wrapInner('<em></em>')
10059
.find('em').data('label.tabs', label).html(o.spinner);
10062
var ajaxOptions = $.extend({}, o.ajaxOptions, {
10064
success: function(r, s) {
10069
$.data(a, 'cache.tabs', true); // if loaded once do not load them again
10072
self._trigger('load', null, self.ui(self.$tabs[index], self.$panels[index]));
10073
o.ajaxOptions.success && o.ajaxOptions.success(r, s);
10075
// This callback is required because the switch has to take
10076
// place after loading has completed. Call last in order to
10077
// fire load before show callback...
10082
// terminate pending requests from other tabs and restore tab label
10086
$a.addClass(o.loadingClass);
10087
setTimeout(function() { // timeout is again required in IE, "wait" for id being restored
10088
self.xhr = $.ajax(ajaxOptions);
10092
url: function(index, url) {
10093
this.$tabs.eq(index).removeData('cache.tabs').data('load.tabs', url);
10095
destroy: function() {
10096
var o = this.options;
10097
this.element.unbind('.tabs')
10098
.removeClass(o.navClass).removeData('tabs');
10099
this.$tabs.each(function() {
10100
var href = $.data(this, 'href.tabs');
10103
var $this = $(this).unbind('.tabs');
10104
$.each(['href', 'load', 'cache'], function(i, prefix) {
10105
$this.removeData(prefix + '.tabs');
10108
this.$lis.add(this.$panels).each(function() {
10109
if ($.data(this, 'destroy.tabs'))
10112
$(this).removeClass([o.selectedClass, o.unselectClass,
10113
o.disabledClass, o.panelClass, o.hideClass].join(' '));
10118
$.ui.tabs.defaults = {
10123
cookie: null, // e.g. { expires: 7, path: '/', domain: 'jquery.com', secure: true }
10124
// TODO history: false,
10127
spinner: 'Loading…',
10129
idPrefix: 'ui-tabs-',
10133
fx: null, // e.g. { height: 'toggle', opacity: 'toggle', duration: 200 }
10136
tabTemplate: '<li><a href="#{href}"><span>#{label}</span></a></li>',
10137
panelTemplate: '<div></div>',
10140
navClass: 'ui-tabs-nav',
10141
selectedClass: 'ui-tabs-selected',
10142
unselectClass: 'ui-tabs-unselect',
10143
disabledClass: 'ui-tabs-disabled',
10144
panelClass: 'ui-tabs-panel',
10145
hideClass: 'ui-tabs-hide',
10146
loadingClass: 'ui-tabs-loading'
10149
$.ui.tabs.getter = "length";
10158
$.extend($.ui.tabs.prototype, {
10160
rotate: function(ms, continuing) {
10162
continuing = continuing || false;
10164
var self = this, t = this.options.selected;
10167
self.rotation = setInterval(function() {
10168
t = ++t < self.$tabs.length ? t : 0;
10174
if (!e || e.clientX) { // only in case of a true click
10175
clearInterval(self.rotation);
10183
this.$tabs.bind(this.options.event, stop);
10185
this.$tabs.bind(this.options.event, function() {
10187
t = self.options.selected;
10194
this.$tabs.unbind(this.options.event, stop);