$.extend($.effects, {
version: "@VERSION",
-
+
// Saves a set of properties in a data storage
save: function(element, set) {
for(var i=0; i < set.length; i++) {
if(set[i] !== null) element.data("ec.storage."+set[i], element[0].style[set[i]]);
}
},
-
+
// Restores a set of previously saved properties from a data storage
restore: function(element, set) {
for(var i=0; i < set.length; i++) {
if(set[i] !== null) element.css(set[i], element.data("ec.storage."+set[i]));
}
},
-
+
setMode: function(el, mode) {
if (mode == 'toggle') mode = el.is(':hidden') ? 'show' : 'hide'; // Set for toggle
return mode;
},
-
+
getBaseline: function(origin, original) { // Translates a [top,left] array into a baseline value
// this should be a little more flexible in the future to handle a string & hash
var y, x;
};
return {x: x, y: y};
},
-
+
// Wraps the element around a wrapper that copies position properties
createWrapper: function(element) {
//Extend the methods of jQuery
$.fn.extend({
-
+
//Save old methods
_show: $.fn.show,
_hide: $.fn.hide,
_addClass: $.fn.addClass,
_removeClass: $.fn.removeClass,
_toggleClass: $.fn.toggleClass,
-
+
// New effect methods
effect: function(fx, options, speed, callback) {
return $.effects[fx] ? $.effects[fx].call(this, {method: fx, options: options || {}, duration: speed, callback: callback }) : null;
},
-
+
show: function() {
if(!arguments[0] || (arguments[0].constructor == Number || (/(slow|normal|fast)/).test(arguments[0])))
return this._show.apply(this, arguments);
return this.effect.apply(this, [arguments[0], o, arguments[2] || o.duration, arguments[3] || o.callback]);
}
},
-
+
hide: function() {
if(!arguments[0] || (arguments[0].constructor == Number || (/(slow|normal|fast)/).test(arguments[0])))
return this._hide.apply(this, arguments);
return this.effect.apply(this, [arguments[0], o, arguments[2] || o.duration, arguments[3] || o.callback]);
}
},
-
+
toggle: function(){
if(!arguments[0] || (arguments[0].constructor == Number || (/(slow|normal|fast)/).test(arguments[0])) || (arguments[0].constructor == Function))
return this.__toggle.apply(this, arguments);
return this.effect.apply(this, [arguments[0], o, arguments[2] || o.duration, arguments[3] || o.callback]);
}
},
-
+
addClass: function(classNames, speed, easing, callback) {
return speed ? $.effects.animateClass.apply(this, [{ add: classNames },speed,easing,callback]) : this._addClass(classNames);
},
switchClass: function() {
return this.morph.apply(this, arguments);
},
-
+
// helper functions
cssUnit: function(key) {
var style = this.css(key), val = [];
var mode = $.effects.setMode(el, o.options.mode || 'show'); // Set Mode
var times = o.options.times || 5; // Default # of times
var duration = o.duration ? o.duration / 2 : $.fx.speeds._default / 2;
-
+
// Adjust
if (mode == 'hide') times--;
if (el.is(':hidden')) { // Show fadeIn
$.widget("ui.accordion", {
_init: function() {
-
+
var o = this.options, self = this;
this.running = 0;
}
this.element.addClass("ui-accordion ui-widget ui-helper-reset");
-
+
this.groups = this.element.children().addClass("ui-accordion-group");
this.headers = this.groups.find("> :first-child").addClass("ui-accordion-header ui-helper-reset ui-state-default ui-corner-all")
.bind("mouseenter.accordion", function(){ $(this).addClass('ui-state-hover'); })
.bind("mouseleave.accordion", function(){ $(this).removeClass('ui-state-hover'); });
-
+
// wrap content elements in div against animation issues
this.headers
.next()
this.active = this._findActive(this.active || o.active).toggleClass("ui-state-default").toggleClass("ui-state-active").toggleClass("ui-corner-all").toggleClass("ui-corner-top");
this.active.parent().addClass('ui-accordion-selected');
-
+
//Append icon elements
$("<span/>").addClass("ui-icon " + o.icons.header).prependTo(this.headers);
this.active.find(".ui-icon").toggleClass(o.icons.header).toggleClass(o.icons.headerSelected);
if (o.event) {
this.element.bind((o.event) + ".accordion", function(event) { return self._clickHandler.call(self, event); });
}
-
+
},
destroy: function() {
-
+
this.element
.removeClass("ui-accordion ui-widget ui-helper-reset")
.removeAttr("role")
.unbind(".accordion")
.removeClass("ui-accordion-header ui-helper-reset ui-state-default ui-corner-all ui-state-active ui-corner-top")
.removeAttr("role").removeAttr("aria-expanded").removeAttr("tabindex");
-
+
this.headers.find("a").removeAttr("tabindex");
this.headers.children(".ui-icon").remove();
this.headers.next().children().removeClass("ui-accordion-content").each(function() {
$(this).parent().replaceWith(this);
});
-
+
},
_keydown: function(event) {
-
+
var o = this.options, keyCode = $.ui.keyCode;
-
+
if (o.disabled || event.altKey || event.ctrlKey)
return;
},
resize: function() {
-
+
var o = this.options, maxHeight;
if (o.fillSpace) {
-
+
maxHeight = this.element.parent().height();
this.headers.each(function() {
maxHeight -= $(this).outerHeight();
});
-
+
var maxPadding = 0;
this.headers.next().each(function() {
maxPadding = Math.max(maxPadding, $(this).innerHeight() - $(this).height());
}).height(maxHeight - maxPadding)
.css('overflow', 'auto');
-
+
} else if ( o.autoHeight ) {
maxHeight = 0;
this.headers.next().each(function() {
maxHeight = Math.max(maxHeight, $(this).outerHeight());
}).height(maxHeight);
}
-
+
},
activate: function(index) {
// call clickHandler with custom event
this._clickHandler({ target: this._findActive(index)[0] });
},
-
+
_findActive: function(selector) {
return selector
? typeof selector == "number"
? $([])
: this.headers.filter(":eq(0)");
},
-
+
_clickHandler: function(event) {
-
+
var o = this.options;
if (o.disabled) return false;
-
+
// called only when using activate(false) to close all parts programmatically
if (!event.target && !o.alwaysOpen) {
this.active.parent().toggleClass('ui-accordion-selected');
this._toggle(toShow, toHide, data);
return false;
}
-
+
// get the click target
var clicked = $(event.target);
-
+
// due to the event delegation model, we have to check if one
// of the parent elements is our actual header, and find that
// otherwise stick with the initial target
clicked = $( clicked.parents(o.header)[0] || clicked );
var clickedIsActive = clicked[0] == this.active[0];
-
+
// if animations are still active, or the active header is the target, ignore click
if (this.running || (o.alwaysOpen && clickedIsActive)) {
return false;
if (!clicked.is(o.header)) {
return;
}
-
+
// switch classes
this.active.parent().toggleClass('ui-accordion-selected');
this.active.removeClass("ui-state-active ui-corner-top").addClass("ui-state-default ui-corner-all")
clicked.removeClass("ui-state-default ui-corner-all").addClass("ui-state-active ui-corner-top")
.find(".ui-icon").removeClass(o.icons.header).addClass(o.icons.headerSelected);
}
-
+
// find elements to show and hide
var toShow = clicked.next(),
toHide = this.active.next(),
oldContent: toHide
},
down = this.headers.index( this.active[0] ) > this.headers.index( clicked[0] );
-
+
this.active = clickedIsActive ? $([]) : clicked;
this._toggle(toShow, toHide, data, clickedIsActive, down);
-
+
return false;
-
+
},
-
+
_toggle: function(toShow, toHide, data, clickedIsActive, down) {
var o = this.options, self = this;
-
+
this.toShow = toShow;
this.toHide = toHide;
this.data = data;
-
+
var complete = function() { if(!self) return; return self._completed.apply(self, arguments); };
// trigger changestart event
this.running = toHide.size() === 0 ? toShow.size() : toHide.size();
if (o.animated) {
-
+
var animOptions = {};
-
+
if ( !o.alwaysOpen && clickedIsActive ) {
animOptions = {
toShow: $([]),
autoHeight: o.autoHeight || o.fillSpace
};
}
-
+
if (!o.proxied) {
o.proxied = o.animated;
}
-
+
if (!o.proxiedDuration) {
o.proxiedDuration = o.duration;
}
-
+
o.animated = $.isFunction(o.proxied) ?
o.proxied(animOptions) : o.proxied;
-
+
o.duration = $.isFunction(o.proxiedDuration) ?
o.proxiedDuration(animOptions) : o.proxiedDuration;
-
+
var animations = $.ui.accordion.animations,
duration = o.duration,
easing = o.animated;
-
+
if (!animations[easing]) {
animations[easing] = function(options) {
this.slide(options, {
});
};
}
-
+
animations[easing](animOptions);
-
+
} else {
-
+
if (!o.alwaysOpen && clickedIsActive) {
toShow.toggle();
} else {
toHide.hide();
toShow.show();
}
-
+
complete(true);
-
+
}
-
+
toHide.prev().attr('aria-expanded','false').attr("tabIndex", "-1");
toShow.prev().attr('aria-expanded','true').attr("tabIndex", "0").focus();
},
-
+
_completed: function(cancel) {
var o = this.options;
-
+
this.running = cancel ? 0 : --this.running;
if (this.running) return;
-
+
if (o.clearStyle) {
this.toShow.add(this.toHide).css({
height: "",
overflow: ""
});
}
-
+
this._trigger('change', null, this.data);
-
+
}
});
// however, in Safari, this causes select boxes not to be selectable
// anymore, so this fix is needed
($.browser.safari || event.preventDefault());
-
+
return true;
},
if (inst.input && inst.input[0].type != 'hidden' && inst == $.datepicker._curInst)
$(inst.input[0]).focus();
},
-
+
/* Check positioning to remain on screen. */
- _checkOffset: function(inst, offset, isFixed) {
+ _checkOffset: function(inst, offset, isFixed) {
var dpWidth = inst.dpDiv.outerWidth();
var dpHeight = inst.dpDiv.outerHeight();
var inputWidth = inst.input ? inst.input.outerWidth() : 0;
var inputHeight = inst.input ? inst.input.outerHeight() : 0;
var viewWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
var viewHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
-
+
offset.left -= (this._get(inst, 'isRTL') ? (dpWidth - inputWidth) : 0);
offset.left -= (isFixed && offset.left == inst.input.offset().left) ? $(document).scrollLeft() : 0;
offset.top -= (isFixed && offset.top == (inst.input.offset().top + inputHeight)) ? $(document).scrollTop() : 0;
-
+
// now check if datepicker is showing outside window viewpoint - move to a better place if so.
offset.left -= (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ? Math.abs(offset.left + dpWidth - viewWidth) : 0;
offset.top -= (offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ? Math.abs(offset.top + dpHeight + inputHeight*2 - viewHeight) : 0;
-
+
return offset;
- },
+ },
/* Find an object's position on the screen. */
_findPos: function(obj) {
var dropped = false;
if ($.ui.ddmanager && !this.options.dropBehaviour)
dropped = $.ui.ddmanager.drop(this, event);
-
+
//if a drop comes from outside (a sortable)
if(this.dropped) {
dropped = this.dropped;
//Get the offsetParent and cache its position
this.offsetParent = this.helper.offsetParent();
var po = this.offsetParent.offset();
-
+
// This is a special case where we need to modify a offset calculated on start, since the following happened:
// 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
// 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
- ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod
)
};
-
+
},
_generatePosition: function(event) {
if(this.cssPosition == 'relative' && !(this.scrollParent[0] != document && this.scrollParent[0] != this.offsetParent[0])) {
this.offset.relative = this._getRelativeOffset();
}
-
+
var pageX = event.pageX;
var pageY = event.pageY;
* - Position constraining -
* Constrain the position to a mix of grid, containment.
*/
-
+
if(this.originalPosition) { //If we are not dragging yet, we won't check for options
if(this.containment) {
if(event.pageX - this.offset.click.left > this.containment[2]) pageX = this.containment[2] + this.offset.click.left;
if(event.pageY - this.offset.click.top > this.containment[3]) pageY = this.containment[3] + this.offset.click.top;
}
-
+
if(o.grid) {
var top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
pageY = this.containment ? (!(top - this.offset.click.top < this.containment[1] || top - this.offset.click.top > this.containment[3]) ? top : (!(top - this.offset.click.top < this.containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
$.each(inst.sortables, function() {
if(this.instance.isOver) {
-
+
this.instance.isOver = 0;
-
+
inst.cancelHelperRemoval = true; //Don't remove the helper in the draggable instance
this.instance.cancelHelperRemoval = false; //Remove it in the sortable instance (so sortable plugins like revert still work)
-
+
//The sortable revert is supported, and we have to set a temporary dropped variable on the draggable to support revert: 'valid/invalid'
if(this.shouldRevert) this.instance.options.revert = true;
-
+
//Trigger the stop of the sortable
this.instance._mouseStop(event);
-
+
this.instance.options.helper = this.instance.options._helper;
//If the helper has been the original item, restore properties in the sortable
_propagate: function(n, event) {
$.ui.plugin.call(this, n, [event, this.ui()]);
-
+
(n != "resize" && this._trigger(n, event, this.ui()));
},
this.range = $([]);
if (o.range) {
-
+
if (o.range === true) {
this.range = $('<div></div>');
if (!o.values) o.values = [this._valueMin(), this._valueMin()];
(o.range == "max") && (this.orientation == "horizontal") && this.range.css({ right : 0 });
(o.range == "min") && (this.orientation == "vertical") && this.range.css({ bottom : 0 });
(o.range == "max") && (this.orientation == "vertical") && this.range.css({ top : 0 });
-
+
}
if ($(".ui-slider-handle", this.element).length == 0)
},
_mouseDrag: function(event) {
-
+
var position = { x: event.pageX, y: event.pageY };
var normValue = this._normValueFromMouse(position);
this._slide(event, this._handleIndex, normValue);
return false;
-
+
},
_mouseStop: function(event) {
-
+
this.handles.removeClass("ui-state-active");
this._stop(event);
this._change(event);
this._handleIndex = null;
return false;
-
+
},
_normValueFromMouse: function(position) {
normValue += this.options.step;
return normValue;
-
+
},
_start: function(event) {
},
_slide: function(event, index, newVal) {
-
+
var handle = this.handles[index];
if (this.options.values && this.options.values.length) {
if ($('body').css("cursor")) this._storedCursor = $('body').css("cursor");
$('body').css("cursor", o.cursor);
}
-
+
if(o.opacity) { // opacity option
if (this.helper.css("opacity")) this._storedOpacity = this.helper.css("opacity");
this.helper.css("opacity", o.opacity);
}
-
+
if(o.zIndex) { // zIndex option
if (this.helper.css("zIndex")) this._storedZIndex = this.helper.css("zIndex");
this.helper.css("zIndex", o.zIndex);
}
-
+
//Prepare scrolling
if(this.scrollParent[0] != document && this.scrollParent[0].tagName != 'HTML')
this.overflowOffset = this.scrollParent.offset();
if(this.options.scroll) {
var o = this.options, scrolled = false;
if(this.scrollParent[0] != document && this.scrollParent[0].tagName != 'HTML') {
-
+
if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity)
this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity)
this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
-
+
if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity)
this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity)
this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
-
+
} else {
-
+
if(event.pageY - $(document).scrollTop() < o.scrollSensitivity)
scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity)
scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
-
+
if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity)
scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity)
scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
-
+
}
-
+
if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour)
$.ui.ddmanager.prepareOffsets(this, event);
}
cancel: function() {
var self = this;
-
+
if(this.dragging) {
this._mouseUp();
return el;
},
update: function(container, p) {
-
+
// 1. If a className is set as 'placeholder option, we don't force sizes - the class is responsible for that
// 2. The option 'forcePlaceholderSize can be enabled to force it even if a class name is specified
if(className && !o.forcePlaceholderSize) return;
-
+
//If the element doesn't have a actual height by itself (without styles coming from a stylesheet), it receives the inline height from the dragged item
if(!p.height()) { p.height(self.currentItem.innerHeight() - parseInt(self.currentItem.css('paddingTop')||0, 10) - parseInt(self.currentItem.css('paddingBottom')||0, 10)); };
if(!p.width()) { p.width(self.currentItem.innerWidth() - parseInt(self.currentItem.css('paddingLeft')||0, 10) - parseInt(self.currentItem.css('paddingRight')||0, 10)); };
//Get the offsetParent and cache its position
this.offsetParent = this.helper.offsetParent();
var po = this.offsetParent.offset();
-
+
// This is a special case where we need to modify a offset calculated on start, since the following happened:
// 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
// 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
- ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod
)
};
-
+
},
_generatePosition: function(event) {
if(this.cssPosition == 'relative' && !(this.scrollParent[0] != document && this.scrollParent[0] != this.offsetParent[0])) {
this.offset.relative = this._getRelativeOffset();
}
-
+
var pageX = event.pageX;
var pageY = event.pageY;
* - Position constraining -
* Constrain the position to a mix of grid, containment.
*/
-
+
if(this.originalPosition) { //If we are not dragging yet, we won't check for options
if(this.containment) {
if(event.pageX - this.offset.click.left > this.containment[2]) pageX = this.containment[2] + this.offset.click.left;
if(event.pageY - this.offset.click.top > this.containment[3]) pageY = this.containment[3] + this.offset.click.top;
}
-
+
if(o.grid) {
var top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
pageY = this.containment ? (!(top - this.offset.click.top < this.containment[1] || top - this.offset.click.top > this.containment[3]) ? top : (!(top - this.offset.click.top < this.containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
+ ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() )
)
};
-
+
},
_rearrange: function(event, i, a, hardRefresh) {
this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
if(this.helper[0] != this.currentItem[0]) this.helper.remove(); this.helper = null;
-
+
if(!noPropagation) {
for (var i=0; i < delayedTriggers.length; i++) { delayedTriggers[i].call(this, event); }; //Trigger all delayed events
this._trigger("stop", event, this._uiHash());
this.$lis = $('li:has(a[href])', this.list);
this.$tabs = this.$lis.map(function() { return $('a', this)[0]; });
this.$panels = $([]);
-
+
var self = this, o = this.options;
var fragmentId = /^#.+/; // Safari 2 reports '#' for an empty hash
// inline tab
if (fragmentId.test(href))
self.$panels = self.$panels.add(self._sanitizeSelector(href));
-
+
// remote tab
else if (href != '#') { // prevent loading the page itself if href is just "#"
$.data(a, 'href.tabs', href); // required for restore on destroy
-
+
// TODO until #3808 is fixed strip fragment identifier from url
// (IE fails to load from such url)
$.data(a, 'load.tabs', href.replace(/#.*$/, '')); // mutable data
-
+
var id = self._tabId(a);
a.href = '#' + id;
var $panel = $('#' + id);
}
self.$panels = self.$panels.add($panel);
}
-
+
// invalid tab href
else
o.disabled.push(i + 1);