aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorFelix Nagel <info@felixnagel.com>2013-03-19 19:59:31 +0100
committerFelix Nagel <info@felixnagel.com>2013-03-19 19:59:31 +0100
commit1ce8d87f8bee3b1ec8698e0e2b8ead726d0d4ca2 (patch)
tree77edf8d66ab74aa11b86c286ba2a528b4d3c36de /ui
parent5a9a80f86cc7844e7357af834c61cc14431110d1 (diff)
parent1c1f7c6184ba6f6a13e93960ea77c293f9d4308e (diff)
downloadjquery-ui-1ce8d87f8bee3b1ec8698e0e2b8ead726d0d4ca2.tar.gz
jquery-ui-1ce8d87f8bee3b1ec8698e0e2b8ead726d0d4ca2.zip
Merge branch 'master' into selectmenu
Diffstat (limited to 'ui')
-rw-r--r--ui/jquery.ui.accordion.js6
-rw-r--r--ui/jquery.ui.autocomplete.js2
-rw-r--r--ui/jquery.ui.button.js10
-rw-r--r--ui/jquery.ui.core.js94
-rw-r--r--ui/jquery.ui.datepicker.js24
-rw-r--r--ui/jquery.ui.dialog.js50
-rw-r--r--ui/jquery.ui.draggable.js84
-rw-r--r--ui/jquery.ui.droppable.js8
-rw-r--r--ui/jquery.ui.effect.js67
-rw-r--r--ui/jquery.ui.menu.js5
-rw-r--r--ui/jquery.ui.progressbar.js6
-rw-r--r--ui/jquery.ui.resizable.js22
-rw-r--r--ui/jquery.ui.slider.js6
-rw-r--r--ui/jquery.ui.sortable.js55
-rw-r--r--ui/jquery.ui.spinner.js10
-rw-r--r--ui/jquery.ui.widget.js7
16 files changed, 219 insertions, 237 deletions
diff --git a/ui/jquery.ui.accordion.js b/ui/jquery.ui.accordion.js
index 1afa95cb4..c210a29a9 100644
--- a/ui/jquery.ui.accordion.js
+++ b/ui/jquery.ui.accordion.js
@@ -65,8 +65,7 @@ $.widget( "ui.accordion", {
_getCreateEventData: function() {
return {
header: this.active,
- panel: !this.active.length ? $() : this.active.next(),
- content: !this.active.length ? $() : this.active.next()
+ panel: !this.active.length ? $() : this.active.next()
};
},
@@ -161,6 +160,9 @@ $.widget( "ui.accordion", {
// #5332 - opacity doesn't cascade to positioned elements in IE
// so we need to add the disabled class to the headers and panels
if ( key === "disabled" ) {
+ this.element
+ .toggleClass( "ui-state-disabled", !!value )
+ .attr( "aria-disabled", value );
this.headers.add( this.headers.next() )
.toggleClass( "ui-state-disabled", !!value );
}
diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js
index b3a05da0b..92ddc3a12 100644
--- a/ui/jquery.ui.autocomplete.js
+++ b/ui/jquery.ui.autocomplete.js
@@ -201,7 +201,7 @@ $.widget( "ui.autocomplete", {
role: null
})
.hide()
- .data( "ui-menu" );
+ .menu( "instance" );
this._on( this.menu.element, {
mousedown: function( event ) {
diff --git a/ui/jquery.ui.button.js b/ui/jquery.ui.button.js
index fcb7b14d1..5e64f5164 100644
--- a/ui/jquery.ui.button.js
+++ b/ui/jquery.ui.button.js
@@ -207,9 +207,6 @@ $.widget( "ui.button", {
}
}
- // TODO: pull out $.Widget's handling for the disabled option into
- // $.Widget.prototype._setOptionDisabled so it's easy to proxy and can
- // be overridden by individual plugins
this._setOption( "disabled", options.disabled );
this._resetButton();
},
@@ -273,11 +270,8 @@ $.widget( "ui.button", {
_setOption: function( key, value ) {
this._super( key, value );
if ( key === "disabled" ) {
- if ( value ) {
- this.element.prop( "disabled", true );
- } else {
- this.element.prop( "disabled", false );
- }
+ this.widget().toggleClass( "ui-state-disabled", !!value );
+ this.element.prop( "disabled", !!value );
return;
}
this._resetButton();
diff --git a/ui/jquery.ui.core.js b/ui/jquery.ui.core.js
index d224f181a..0d263fa5f 100644
--- a/ui/jquery.ui.core.js
+++ b/ui/jquery.ui.core.js
@@ -13,13 +13,8 @@
var uuid = 0,
runiqueId = /^ui-id-\d+$/;
-// prevent duplicate loading
-// this is only a problem because we proxy existing functions
-// and we don't want to double proxy them
+// $.ui might exist from components with no dependencies, e.g., $.ui.position
$.ui = $.ui || {};
-if ( $.ui.version ) {
- return;
-}
$.extend( $.ui, {
version: "@VERSION",
@@ -52,20 +47,21 @@ $.extend( $.ui, {
// plugins
$.fn.extend({
- _focus: $.fn.focus,
- focus: function( delay, fn ) {
- return typeof delay === "number" ?
- this.each(function() {
- var elem = this;
- setTimeout(function() {
- $( elem ).focus();
- if ( fn ) {
- fn.call( elem );
- }
- }, delay );
- }) :
- this._focus.apply( this, arguments );
- },
+ focus: (function( orig ) {
+ return function( delay, fn ) {
+ return typeof delay === "number" ?
+ this.each(function() {
+ var elem = this;
+ setTimeout(function() {
+ $( elem ).focus();
+ if ( fn ) {
+ fn.call( elem );
+ }
+ }, delay );
+ }) :
+ orig.apply( this, arguments );
+ };
+ })( $.fn.focus ),
scrollParent: function() {
var scrollParent;
@@ -82,35 +78,6 @@ $.fn.extend({
return (/fixed/).test(this.css("position")) || !scrollParent.length ? $(document) : scrollParent;
},
- zIndex: function( zIndex ) {
- if ( zIndex !== undefined ) {
- return this.css( "zIndex", zIndex );
- }
-
- if ( this.length ) {
- var elem = $( this[ 0 ] ), position, value;
- while ( elem.length && elem[ 0 ] !== document ) {
- // Ignore z-index if position is set to a value where z-index is ignored by the browser
- // This makes behavior of this function consistent across browsers
- // WebKit always returns auto if the element is positioned
- position = elem.css( "position" );
- if ( position === "absolute" || position === "relative" || position === "fixed" ) {
- // IE returns 0 when zIndex is not specified
- // other browsers return a string
- // we ignore the case of nested elements with an explicit value of 0
- // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
- value = parseInt( elem.css( "zIndex" ), 10 );
- if ( !isNaN( value ) && value !== 0 ) {
- return value;
- }
- }
- elem = elem.parent();
- }
- }
-
- return 0;
- },
-
uniqueId: function() {
return this.each(function() {
if ( !this.id ) {
@@ -267,6 +234,35 @@ $.fn.extend({
enableSelection: function() {
return this.unbind( ".ui-disableSelection" );
+ },
+
+ zIndex: function( zIndex ) {
+ if ( zIndex !== undefined ) {
+ return this.css( "zIndex", zIndex );
+ }
+
+ if ( this.length ) {
+ var elem = $( this[ 0 ] ), position, value;
+ while ( elem.length && elem[ 0 ] !== document ) {
+ // Ignore z-index if position is set to a value where z-index is ignored by the browser
+ // This makes behavior of this function consistent across browsers
+ // WebKit always returns auto if the element is positioned
+ position = elem.css( "position" );
+ if ( position === "absolute" || position === "relative" || position === "fixed" ) {
+ // IE returns 0 when zIndex is not specified
+ // other browsers return a string
+ // we ignore the case of nested elements with an explicit value of 0
+ // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
+ value = parseInt( elem.css( "zIndex" ), 10 );
+ if ( !isNaN( value ) && value !== 0 ) {
+ return value;
+ }
+ }
+ elem = elem.parent();
+ }
+ }
+
+ return 0;
}
});
diff --git a/ui/jquery.ui.datepicker.js b/ui/jquery.ui.datepicker.js
index efee7a819..5892e2ddc 100644
--- a/ui/jquery.ui.datepicker.js
+++ b/ui/jquery.ui.datepicker.js
@@ -19,6 +19,28 @@ var PROP_NAME = "datepicker",
dpuuid = new Date().getTime(),
instActive;
+function getZindex( elem ) {
+ var position, value;
+ while ( elem.length && elem[ 0 ] !== document ) {
+ // Ignore z-index if position is set to a value where z-index is ignored by the browser
+ // This makes behavior of this function consistent across browsers
+ // WebKit always returns auto if the element is positioned
+ position = elem.css( "position" );
+ if ( position === "absolute" || position === "relative" || position === "fixed" ) {
+ // IE returns 0 when zIndex is not specified
+ // other browsers return a string
+ // we ignore the case of nested elements with an explicit value of 0
+ // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
+ value = parseInt( elem.css( "zIndex" ), 10 );
+ if ( !isNaN( value ) && value !== 0 ) {
+ return value;
+ }
+ }
+ elem = elem.parent();
+ }
+
+ return 0;
+}
/* Date picker manager.
Use the singleton instance of this class, $.datepicker, to interact with the date picker.
Settings for (groups of) date pickers are maintained in an instance object,
@@ -744,7 +766,7 @@ $.extend(Datepicker.prototype, {
if (!inst.inline) {
showAnim = $.datepicker._get(inst, "showAnim");
duration = $.datepicker._get(inst, "duration");
- inst.dpDiv.zIndex($(input).zIndex()+1);
+ inst.dpDiv.css( "z-index", getZindex( $( input ) ) + 1 );
$.datepicker._datepickerShowing = true;
if ( $.effects && $.effects.effect[ showAnim ] ) {
diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js
index b35c0ffcf..59a7961ed 100644
--- a/ui/jquery.ui.dialog.js
+++ b/ui/jquery.ui.dialog.js
@@ -755,54 +755,4 @@ $.widget( "ui.dialog", {
$.ui.dialog.overlayInstances = 0;
-// DEPRECATED
-if ( $.uiBackCompat !== false ) {
- // position option with array notation
- // just override with old implementation
- $.widget( "ui.dialog", $.ui.dialog, {
- _position: function() {
- var position = this.options.position,
- myAt = [],
- offset = [ 0, 0 ],
- isVisible;
-
- if ( position ) {
- if ( typeof position === "string" || (typeof position === "object" && "0" in position ) ) {
- myAt = position.split ? position.split(" ") : [ position[0], position[1] ];
- if ( myAt.length === 1 ) {
- myAt[1] = myAt[0];
- }
-
- $.each( [ "left", "top" ], function( i, offsetPosition ) {
- if ( +myAt[ i ] === myAt[ i ] ) {
- offset[ i ] = myAt[ i ];
- myAt[ i ] = offsetPosition;
- }
- });
-
- position = {
- my: myAt[0] + (offset[0] < 0 ? offset[0] : "+" + offset[0]) + " " +
- myAt[1] + (offset[1] < 0 ? offset[1] : "+" + offset[1]),
- at: myAt.join(" ")
- };
- }
-
- position = $.extend( {}, $.ui.dialog.prototype.options.position, position );
- } else {
- position = $.ui.dialog.prototype.options.position;
- }
-
- // need to show the dialog to get the actual offset in the position plugin
- isVisible = this.uiDialog.is(":visible");
- if ( !isVisible ) {
- this.uiDialog.show();
- }
- this.uiDialog.position( position );
- if ( !isVisible ) {
- this.uiDialog.hide();
- }
- }
- });
-}
-
}( jQuery ) );
diff --git a/ui/jquery.ui.draggable.js b/ui/jquery.ui.draggable.js
index 7c1fb3361..e5fc069b9 100644
--- a/ui/jquery.ui.draggable.js
+++ b/ui/jquery.ui.draggable.js
@@ -135,6 +135,9 @@ $.widget("ui.draggable", $.ui.mouse, {
left: this.offset.left - this.margins.left
};
+ //Reset scroll cache
+ this.offset.scroll = false;
+
$.extend(this.offset, {
click: { //Where the click happened, relative to the element
left: event.pageX - this.offset.left,
@@ -214,9 +217,7 @@ $.widget("ui.draggable", $.ui.mouse, {
_mouseStop: function(event) {
//If we are using droppables, inform the manager about the drop
- var element,
- that = this,
- elementInDom = false,
+ var that = this,
dropped = false;
if ($.ui.ddmanager && !this.options.dropBehaviour) {
dropped = $.ui.ddmanager.drop(this, event);
@@ -229,13 +230,7 @@ $.widget("ui.draggable", $.ui.mouse, {
}
//if the original element is no longer in the DOM don't bother to continue (see #8269)
- element = this.element[0];
- while ( element && (element = element.parentNode) ) {
- if (element === document ) {
- elementInDom = true;
- }
- }
- if ( !elementInDom && this.options.helper === "original" ) {
+ if ( this.options.helper === "original" && !$.contains( this.element[ 0 ].ownerDocument, this.element[ 0 ] ) ) {
return false;
}
@@ -281,17 +276,9 @@ $.widget("ui.draggable", $.ui.mouse, {
},
_getHandle: function(event) {
-
- var handle = !this.options.handle || !$(this.options.handle, this.element).length ? true : false;
-
- this.element.find( this.options.handle ).each(function() {
- if(this === event.target) {
- handle = true;
- }
- });
-
- return handle;
-
+ return this.options.handle ?
+ !!$( event.target ).closest( this.element.find( this.options.handle ) ).length :
+ true;
},
_createHelper: function(event) {
@@ -421,8 +408,8 @@ $.widget("ui.draggable", $.ui.mouse, {
this.containment = [
(parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0),
(parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0),
- (over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left - this.margins.right,
- (over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top - this.margins.bottom
+ (over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderRightWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left - this.margins.right,
+ (over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderBottomWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top - this.margins.bottom
];
this.relative_container = c;
@@ -441,18 +428,23 @@ $.widget("ui.draggable", $.ui.mouse, {
var mod = d === "absolute" ? 1 : -1,
scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
+ //Cache the scroll
+ if (!this.offset.scroll) {
+ this.offset.scroll = {top : scroll.scrollTop(), left : scroll.scrollLeft()};
+ }
+
return {
top: (
pos.top + // The absolute mouse position
this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
- ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
+ ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : this.offset.scroll.top ) ) * mod)
),
left: (
pos.left + // The absolute mouse position
this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
- ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
+ ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : this.offset.scroll.left ) * mod)
)
};
@@ -467,6 +459,11 @@ $.widget("ui.draggable", $.ui.mouse, {
pageX = event.pageX,
pageY = event.pageY;
+ //Cache the scroll
+ if (!this.offset.scroll) {
+ this.offset.scroll = {top : scroll.scrollTop(), left : scroll.scrollLeft()};
+ }
+
/*
* - Position constraining -
* Constrain the position to a mix of grid, containment.
@@ -516,14 +513,14 @@ $.widget("ui.draggable", $.ui.mouse, {
this.offset.click.top - // Click offset (relative to the element)
this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
- ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
+ ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : this.offset.scroll.top ) ))
),
left: (
pageX - // The absolute mouse position
this.offset.click.left - // Click offset (relative to the element)
this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
- ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
+ ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : this.offset.scroll.left ))
)
};
@@ -566,11 +563,11 @@ $.widget("ui.draggable", $.ui.mouse, {
$.ui.plugin.add("draggable", "connectToSortable", {
start: function(event, ui) {
- var inst = $(this).data("ui-draggable"), o = inst.options,
+ var inst = $(this).draggable( "instance" ), o = inst.options,
uiSortable = $.extend({}, ui, { item: inst.element });
inst.sortables = [];
$(o.connectToSortable).each(function() {
- var sortable = $.data(this, "ui-sortable");
+ var sortable = $( this ).sortable( "instance" );
if (sortable && !sortable.options.disabled) {
inst.sortables.push({
instance: sortable,
@@ -585,7 +582,7 @@ $.ui.plugin.add("draggable", "connectToSortable", {
stop: function(event, ui) {
//If we are still over the sortable, we fake the stop event of the sortable, but also remove helper
- var inst = $(this).data("ui-draggable"),
+ var inst = $(this).draggable( "instance" ),
uiSortable = $.extend({}, ui, { item: inst.element });
$.each(inst.sortables, function() {
@@ -621,7 +618,7 @@ $.ui.plugin.add("draggable", "connectToSortable", {
},
drag: function(event, ui) {
- var inst = $(this).data("ui-draggable"), that = this;
+ var inst = $(this).draggable( "instance" ), that = this;
$.each(inst.sortables, function() {
@@ -722,14 +719,14 @@ $.ui.plugin.add("draggable", "connectToSortable", {
$.ui.plugin.add("draggable", "cursor", {
start: function() {
- var t = $("body"), o = $(this).data("ui-draggable").options;
+ var t = $("body"), o = $(this).draggable( "instance" ).options;
if (t.css("cursor")) {
o._cursor = t.css("cursor");
}
t.css("cursor", o.cursor);
},
stop: function() {
- var o = $(this).data("ui-draggable").options;
+ var o = $(this).draggable( "instance" ).options;
if (o._cursor) {
$("body").css("cursor", o._cursor);
}
@@ -738,14 +735,14 @@ $.ui.plugin.add("draggable", "cursor", {
$.ui.plugin.add("draggable", "opacity", {
start: function(event, ui) {
- var t = $(ui.helper), o = $(this).data("ui-draggable").options;
+ var t = $(ui.helper), o = $(this).draggable( "instance" ).options;
if(t.css("opacity")) {
o._opacity = t.css("opacity");
}
t.css("opacity", o.opacity);
},
stop: function(event, ui) {
- var o = $(this).data("ui-draggable").options;
+ var o = $(this).draggable( "instance" ).options;
if(o._opacity) {
$(ui.helper).css("opacity", o._opacity);
}
@@ -754,14 +751,14 @@ $.ui.plugin.add("draggable", "opacity", {
$.ui.plugin.add("draggable", "scroll", {
start: function() {
- var i = $(this).data("ui-draggable");
+ var i = $(this).draggable( "instance" );
if(i.scrollParent[0] !== document && i.scrollParent[0].tagName !== "HTML") {
i.overflowOffset = i.scrollParent.offset();
}
},
drag: function( event ) {
- var i = $(this).data("ui-draggable"), o = i.options, scrolled = false;
+ var i = $(this).draggable( "instance" ), o = i.options, scrolled = false;
if(i.scrollParent[0] !== document && i.scrollParent[0].tagName !== "HTML") {
@@ -811,7 +808,7 @@ $.ui.plugin.add("draggable", "scroll", {
$.ui.plugin.add("draggable", "snap", {
start: function() {
- var i = $(this).data("ui-draggable"),
+ var i = $(this).draggable( "instance" ),
o = i.options;
i.snapElements = [];
@@ -832,7 +829,7 @@ $.ui.plugin.add("draggable", "snap", {
drag: function(event, ui) {
var ts, bs, ls, rs, l, r, t, b, i, first,
- inst = $(this).data("ui-draggable"),
+ inst = $(this).draggable( "instance" ),
o = inst.options,
d = o.snapTolerance,
x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
@@ -845,8 +842,7 @@ $.ui.plugin.add("draggable", "snap", {
t = inst.snapElements[i].top;
b = t + inst.snapElements[i].height;
- //Yes, I know, this is insane ;)
- 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))) {
+ if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d || !$.contains( inst.snapElements[ i ].item.ownerDocument, inst.snapElements[ i ].item ) ) {
if(inst.snapElements[i].snapping) {
(inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
}
@@ -907,7 +903,7 @@ $.ui.plugin.add("draggable", "snap", {
$.ui.plugin.add("draggable", "stack", {
start: function() {
var min,
- o = this.data("ui-draggable").options,
+ o = $(this).draggable( "instance" ).options,
group = $.makeArray($(o.stack)).sort(function(a,b) {
return (parseInt($(a).css("zIndex"),10) || 0) - (parseInt($(b).css("zIndex"),10) || 0);
});
@@ -924,14 +920,14 @@ $.ui.plugin.add("draggable", "stack", {
$.ui.plugin.add("draggable", "zIndex", {
start: function(event, ui) {
- var t = $(ui.helper), o = $(this).data("ui-draggable").options;
+ var t = $(ui.helper), o = $(this).draggable( "instance" ).options;
if(t.css("zIndex")) {
o._zIndex = t.css("zIndex");
}
t.css("zIndex", o.zIndex);
},
stop: function(event, ui) {
- var o = $(this).data("ui-draggable").options;
+ var o = $(this).draggable( "instance" ).options;
if(o._zIndex) {
$(ui.helper).css("zIndex", o._zIndex);
}
diff --git a/ui/jquery.ui.droppable.js b/ui/jquery.ui.droppable.js
index 552b24a58..6bc4b594d 100644
--- a/ui/jquery.ui.droppable.js
+++ b/ui/jquery.ui.droppable.js
@@ -82,7 +82,7 @@ $.widget("ui.droppable", {
return d.is(value);
};
}
- $.Widget.prototype._setOption.apply(this, arguments);
+ this._super( key, value );
},
_activate: function(event) {
@@ -152,7 +152,7 @@ $.widget("ui.droppable", {
}
this.element.find(":data(ui-droppable)").not(".ui-draggable-dragging").each(function() {
- var inst = $.data(this, "ui-droppable");
+ var inst = $( this ).droppable( "instance" );
if(
inst.options.greedy &&
!inst.options.disabled &&
@@ -331,11 +331,11 @@ $.ui.ddmanager = {
// find droppable parents with same scope
scope = this.options.scope;
parent = this.element.parents(":data(ui-droppable)").filter(function () {
- return $.data(this, "ui-droppable").options.scope === scope;
+ return $(this).droppable( "instance" ).options.scope === scope;
});
if (parent.length) {
- parentInstance = $.data(parent[0], "ui-droppable");
+ parentInstance = $( parent[ 0 ] ).droppable( "instance" );
parentInstance.greedyChild = (c === "isover");
}
}
diff --git a/ui/jquery.ui.effect.js b/ui/jquery.ui.effect.js
index f3d9929b0..3d65b40c7 100644
--- a/ui/jquery.ui.effect.js
+++ b/ui/jquery.ui.effect.js
@@ -8,7 +8,7 @@
*
* http://api.jqueryui.com/category/effects-core/
*/
-;(jQuery.effects || (function($, undefined) {
+(function($, undefined) {
var dataSpace = "ui-effects-";
@@ -839,39 +839,42 @@ $.effects.animateClass = function( value, duration, easing, callback ) {
};
$.fn.extend({
- _addClass: $.fn.addClass,
- addClass: function( classNames, speed, easing, callback ) {
- return speed ?
- $.effects.animateClass.call( this,
- { add: classNames }, speed, easing, callback ) :
- this._addClass( classNames );
- },
-
- _removeClass: $.fn.removeClass,
- removeClass: function( classNames, speed, easing, callback ) {
- return arguments.length > 1 ?
- $.effects.animateClass.call( this,
- { remove: classNames }, speed, easing, callback ) :
- this._removeClass.apply( this, arguments );
- },
-
- _toggleClass: $.fn.toggleClass,
- toggleClass: function( classNames, force, speed, easing, callback ) {
- if ( typeof force === "boolean" || force === undefined ) {
- if ( !speed ) {
- // without speed parameter
- return this._toggleClass( classNames, force );
+ addClass: (function( orig ) {
+ return function( classNames, speed, easing, callback ) {
+ return speed ?
+ $.effects.animateClass.call( this,
+ { add: classNames }, speed, easing, callback ) :
+ orig.apply( this, arguments );
+ };
+ })( $.fn.addClass ),
+
+ removeClass: (function( orig ) {
+ return function( classNames, speed, easing, callback ) {
+ return arguments.length > 1 ?
+ $.effects.animateClass.call( this,
+ { remove: classNames }, speed, easing, callback ) :
+ orig.apply( this, arguments );
+ };
+ })( $.fn.removeClass ),
+
+ toggleClass: (function( orig ) {
+ return function( classNames, force, speed, easing, callback ) {
+ if ( typeof force === "boolean" || force === undefined ) {
+ if ( !speed ) {
+ // without speed parameter
+ return orig.apply( this, arguments );
+ } else {
+ return $.effects.animateClass.call( this,
+ (force ? { add: classNames } : { remove: classNames }),
+ speed, easing, callback );
+ }
} else {
+ // without force parameter
return $.effects.animateClass.call( this,
- (force ? { add: classNames } : { remove: classNames }),
- speed, easing, callback );
+ { toggle: classNames }, force, speed, easing );
}
- } else {
- // without force parameter
- return $.effects.animateClass.call( this,
- { toggle: classNames }, force, speed, easing );
- }
- },
+ };
+ })( $.fn.toggleClass ),
switchClass: function( remove, add, speed, easing, callback) {
return $.effects.animateClass.call( this, {
@@ -1283,4 +1286,4 @@ $.each( baseEasings, function( name, easeIn ) {
})();
-})(jQuery));
+})(jQuery);
diff --git a/ui/jquery.ui.menu.js b/ui/jquery.ui.menu.js
index 1c633786d..bdef93248 100644
--- a/ui/jquery.ui.menu.js
+++ b/ui/jquery.ui.menu.js
@@ -350,6 +350,11 @@ $.widget( "ui.menu", {
.removeClass( this.options.icons.submenu )
.addClass( value.submenu );
}
+ if ( key === "disabled" ) {
+ this.element
+ .toggleClass( "ui-state-disabled", !!value )
+ .attr( "aria-disabled", value );
+ }
this._super( key, value );
},
diff --git a/ui/jquery.ui.progressbar.js b/ui/jquery.ui.progressbar.js
index 9e959ebc4..0eaa8b41e 100644
--- a/ui/jquery.ui.progressbar.js
+++ b/ui/jquery.ui.progressbar.js
@@ -97,7 +97,11 @@ $.widget( "ui.progressbar", {
// Don't allow a max less than min
value = Math.max( this.min, value );
}
-
+ if ( key === "disabled" ) {
+ this.element
+ .toggleClass( "ui-state-disabled", !!value )
+ .attr( "aria-disabled", value );
+ }
this._super( key, value );
},
diff --git a/ui/jquery.ui.resizable.js b/ui/jquery.ui.resizable.js
index 2468dcaa6..761ea058b 100644
--- a/ui/jquery.ui.resizable.js
+++ b/ui/jquery.ui.resizable.js
@@ -81,7 +81,7 @@ $.widget("ui.resizable", $.ui.mouse, {
//Overwrite the original this.element
this.element = this.element.parent().data(
- "ui-resizable", this.element.data("ui-resizable")
+ "ui-resizable", this.element.resizable( "instance" )
);
this.elementIsWrapper = true;
@@ -651,7 +651,7 @@ $.widget("ui.resizable", $.ui.mouse, {
$.ui.plugin.add("resizable", "animate", {
stop: function( event ) {
- var that = $(this).data("ui-resizable"),
+ var that = $(this).resizable( "instance" ),
o = that.options,
pr = that._proportionallyResizeElements,
ista = pr.length && (/textarea/i).test(pr[0].nodeName),
@@ -693,7 +693,7 @@ $.ui.plugin.add("resizable", "containment", {
start: function() {
var element, p, co, ch, cw, width, height,
- that = $(this).data("ui-resizable"),
+ that = $(this).resizable( "instance" ),
o = that.options,
el = that.element,
oc = o.containment,
@@ -739,7 +739,7 @@ $.ui.plugin.add("resizable", "containment", {
resize: function( event ) {
var woset, hoset, isParent, isOffsetRelative,
- that = $(this).data("ui-resizable"),
+ that = $(this).resizable( "instance" ),
o = that.options,
co = that.containerOffset, cp = that.position,
pRatio = that._aspectRatio || event.shiftKey,
@@ -794,7 +794,7 @@ $.ui.plugin.add("resizable", "containment", {
},
stop: function(){
- var that = $(this).data("ui-resizable"),
+ var that = $(this).resizable( "instance" ),
o = that.options,
co = that.containerOffset,
cop = that.containerPosition,
@@ -818,7 +818,7 @@ $.ui.plugin.add("resizable", "containment", {
$.ui.plugin.add("resizable", "alsoResize", {
start: function () {
- var that = $(this).data("ui-resizable"),
+ var that = $(this).resizable( "instance" ),
o = that.options,
_store = function (exp) {
$(exp).each(function() {
@@ -839,7 +839,7 @@ $.ui.plugin.add("resizable", "alsoResize", {
},
resize: function (event, ui) {
- var that = $(this).data("ui-resizable"),
+ var that = $(this).resizable( "instance" ),
o = that.options,
os = that.originalSize,
op = that.originalPosition,
@@ -880,7 +880,7 @@ $.ui.plugin.add("resizable", "ghost", {
start: function() {
- var that = $(this).data("ui-resizable"), o = that.options, cs = that.size;
+ var that = $(this).resizable( "instance" ), o = that.options, cs = that.size;
that.ghost = that.originalElement.clone();
that.ghost
@@ -893,14 +893,14 @@ $.ui.plugin.add("resizable", "ghost", {
},
resize: function(){
- var that = $(this).data("ui-resizable");
+ var that = $(this).resizable( "instance" );
if (that.ghost) {
that.ghost.css({ position: "relative", height: that.size.height, width: that.size.width });
}
},
stop: function() {
- var that = $(this).data("ui-resizable");
+ var that = $(this).resizable( "instance" );
if (that.ghost && that.helper) {
that.helper.get(0).removeChild(that.ghost.get(0));
}
@@ -911,7 +911,7 @@ $.ui.plugin.add("resizable", "ghost", {
$.ui.plugin.add("resizable", "grid", {
resize: function() {
- var that = $(this).data("ui-resizable"),
+ var that = $(this).resizable( "instance" ),
o = that.options,
cs = that.size,
os = that.originalSize,
diff --git a/ui/jquery.ui.slider.js b/ui/jquery.ui.slider.js
index b3e609aa2..88281240d 100644
--- a/ui/jquery.ui.slider.js
+++ b/ui/jquery.ui.slider.js
@@ -427,7 +427,11 @@ $.widget( "ui.slider", $.ui.mouse, {
valsLength = this.options.values.length;
}
- $.Widget.prototype._setOption.apply( this, arguments );
+ if ( key === "disabled" ) {
+ this.element.toggleClass( "ui-state-disabled", !!value );
+ }
+
+ this._super( key, value );
switch ( key ) {
case "orientation":
diff --git a/ui/jquery.ui.sortable.js b/ui/jquery.ui.sortable.js
index 93c6cccc5..642d5d947 100644
--- a/ui/jquery.ui.sortable.js
+++ b/ui/jquery.ui.sortable.js
@@ -21,6 +21,10 @@ function isOverAxis( x, reference, size ) {
return ( x > reference ) && ( x < ( reference + size ) );
}
+function isFloating(item) {
+ return (/left|right/).test(item.css("float")) || (/inline|table-cell/).test(item.css("display"));
+}
+
$.widget("ui.sortable", $.ui.mouse, {
version: "@VERSION",
widgetEventPrefix: "sort",
@@ -73,7 +77,7 @@ $.widget("ui.sortable", $.ui.mouse, {
this.refresh();
//Let's determine if the items are being displayed horizontally
- this.floating = this.items.length ? o.axis === "x" || (/left|right/).test(this.items[0].item.css("float")) || (/inline|table-cell/).test(this.items[0].item.css("display")) : false;
+ this.floating = this.items.length ? o.axis === "x" || isFloating(this.items[0].item) : false;
//Let's determine the parent's offset
this.offset = this.element.offset();
@@ -98,17 +102,6 @@ $.widget("ui.sortable", $.ui.mouse, {
return this;
},
- _setOption: function(key, value){
- if ( key === "disabled" ) {
- this.options[ key ] = value;
-
- this.widget().toggleClass( "ui-sortable-disabled", !!value );
- } else {
- // Don't call widget base _setOption for disable as it adds ui-state-disabled class
- $.Widget.prototype._setOption.apply(this, arguments);
- }
- },
-
_mouseCapture: function(event, overrideHandle) {
var currentItem = null,
validHandle = false,
@@ -424,14 +417,18 @@ $.widget("ui.sortable", $.ui.mouse, {
if(this.options.revert) {
var that = this,
- cur = this.placeholder.offset();
+ cur = this.placeholder.offset(),
+ axis = this.options.axis,
+ animation = {};
+ if ( !axis || axis === "x" ) {
+ animation.left = cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollLeft);
+ }
+ if ( !axis || axis === "y" ) {
+ animation.top = cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollTop);
+ }
this.reverting = true;
-
- $(this.helper).animate({
- left: cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollLeft),
- top: cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollTop)
- }, parseInt(this.options.revert, 10) || 500, function() {
+ $(this.helper).animate( animation, parseInt(this.options.revert, 10) || 500, function() {
that._clear(event);
});
} else {
@@ -799,7 +796,7 @@ $.widget("ui.sortable", $.ui.mouse, {
},
_contactContainers: function(event) {
- var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, base, cur, nearBottom,
+ var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, base, cur, nearBottom, floating,
innermostContainer = null,
innermostIndex = null;
@@ -838,15 +835,18 @@ $.widget("ui.sortable", $.ui.mouse, {
// move the item into the container if it's not there already
if(this.containers.length === 1) {
- this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
- this.containers[innermostIndex].containerCache.over = 1;
+ if (!this.containers[innermostIndex].containerCache.over) {
+ this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
+ this.containers[innermostIndex].containerCache.over = 1;
+ }
} else {
//When entering a new container, we will find the item with the least distance and append our item near it
dist = 10000;
itemWithLeastDistance = null;
- posProperty = this.containers[innermostIndex].floating ? "left" : "top";
- sizeProperty = this.containers[innermostIndex].floating ? "width" : "height";
+ floating = innermostContainer.floating || isFloating(this.currentItem);
+ posProperty = floating ? "left" : "top";
+ sizeProperty = floating ? "width" : "height";
base = this.positionAbs[posProperty] + this.offset.click[posProperty];
for (j = this.items.length - 1; j >= 0; j--) {
if(!$.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) {
@@ -855,6 +855,9 @@ $.widget("ui.sortable", $.ui.mouse, {
if(this.items[j].item[0] === this.currentItem[0]) {
continue;
}
+ if (floating && !isOverAxis(this.positionAbs.top + this.offset.click.top, this.items[j].top, this.items[j].height)) {
+ continue;
+ }
cur = this.items[j].item.offset()[posProperty];
nearBottom = false;
if(Math.abs(cur - base) > Math.abs(cur + this.items[j][sizeProperty] - base)){
@@ -873,10 +876,14 @@ $.widget("ui.sortable", $.ui.mouse, {
return;
}
- this.currentContainer = this.containers[innermostIndex];
+ if(this.currentContainer === this.containers[innermostIndex]) {
+ return;
+ }
+
itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true);
this._trigger("change", event, this._uiHash());
this.containers[innermostIndex]._trigger("change", event, this._uiHash(this));
+ this.currentContainer = this.containers[innermostIndex];
//Update the placeholder
this.options.placeholder.update(this.currentContainer, this.placeholder);
diff --git a/ui/jquery.ui.spinner.js b/ui/jquery.ui.spinner.js
index 644b65239..c022413dc 100644
--- a/ui/jquery.ui.spinner.js
+++ b/ui/jquery.ui.spinner.js
@@ -381,13 +381,9 @@ $.widget( "ui.spinner", {
this._super( key, value );
if ( key === "disabled" ) {
- if ( value ) {
- this.element.prop( "disabled", true );
- this.buttons.button( "disable" );
- } else {
- this.element.prop( "disabled", false );
- this.buttons.button( "enable" );
- }
+ this.widget().toggleClass( "ui-state-disabled", !!value );
+ this.element.prop( "disabled", !!value );
+ this.buttons.button( value ? "disable" : "enable" );
}
},
diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js
index c581e4b81..741ac74d7 100644
--- a/ui/jquery.ui.widget.js
+++ b/ui/jquery.ui.widget.js
@@ -178,6 +178,10 @@ $.widget.bridge = function( name, object ) {
this.each(function() {
var methodValue,
instance = $.data( this, fullName );
+ if ( options === "instance" ) {
+ returnValue = instance;
+ return false;
+ }
if ( !instance ) {
return $.error( "cannot call methods on " + name + " prior to initialization; " +
"attempted to call method '" + options + "'" );
@@ -345,8 +349,7 @@ $.Widget.prototype = {
if ( key === "disabled" ) {
this.widget()
- .toggleClass( this.widgetFullName + "-disabled ui-state-disabled", !!value )
- .attr( "aria-disabled", value );
+ .toggleClass( this.widgetFullName + "-disabled", !!value );
this.hoverable.removeClass( "ui-state-hover" );
this.focusable.removeClass( "ui-state-focus" );
}