@@ -144,7 +144,7 @@ $.widget( "ui.selectmenu", {
// set ARIA role
role: "listbox"
})
.data( "ui-menu" );
.menu( "instance" );

// adjust border radius
this.menu.addClass( "ui-corner-bottom" ).removeClass( "ui-corner-all" );
@@ -393,6 +393,10 @@ $.widget( "ui.selectmenu", {
}
if ( key === "disabled" ) {
this.menu.menu( "option", "disabled", value );
this.button
.toggleClass( "ui-state-disabled", !!value )
.attr( "aria-disabled", value );

if ( value ) {
this.element.attr( "disabled", "disabled" );
this.button.attr( "tabindex", -1 );
@@ -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":
@@ -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);
@@ -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" );
}
},

@@ -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" );
}