mirror of
https://github.com/jquery/jquery-ui.git
synced 2025-01-07 20:34:24 +00:00
Merge branch 'master' into selectmenu
This commit is contained in:
commit
bd7bd936d1
@ -140,4 +140,13 @@ test("#6966: Escape key closes all dialogs, not the top one", function(){
|
|||||||
d1.remove();
|
d1.remove();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("#4980: Destroy should place element back in original DOM position", function(){
|
||||||
|
container = $('<div id="container"><div id="modal">Content</div></div>');
|
||||||
|
modal = container.find('#modal');
|
||||||
|
modal.dialog();
|
||||||
|
ok(!$.contains(container[0], modal[0]), 'dialog should move modal element to outside container element');
|
||||||
|
modal.dialog('destroy');
|
||||||
|
ok($.contains(container[0], modal[0]), 'dialog(destroy) should place element back in original DOM position');
|
||||||
|
});
|
||||||
|
|
||||||
})(jQuery);
|
})(jQuery);
|
||||||
|
@ -93,12 +93,16 @@ asyncTest( "handle submenu auto collapse: mouseleave", function() {
|
|||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
equal( $menu.find( "ul[aria-expanded='true']" ).length, 2, "second submenu expanded" );
|
equal( $menu.find( "ul[aria-expanded='true']" ).length, 2, "second submenu expanded" );
|
||||||
$menu.find( "ul[aria-expanded='true']:first" ).trigger( "mouseleave" );
|
$menu.find( "ul[aria-expanded='true']:first" ).trigger( "mouseleave" );
|
||||||
|
setTimeout(function() {
|
||||||
equal( $menu.find( "ul[aria-expanded='true']" ).length, 1, "second submenu collapsed" );
|
equal( $menu.find( "ul[aria-expanded='true']" ).length, 1, "second submenu collapsed" );
|
||||||
$menu.trigger( "mouseleave" );
|
$menu.trigger( "mouseleave" );
|
||||||
|
setTimeout(function() {
|
||||||
equal( $menu.find( "ul[aria-expanded='true']" ).length, 0, "first submenu collapsed" );
|
equal( $menu.find( "ul[aria-expanded='true']" ).length, 0, "first submenu collapsed" );
|
||||||
start();
|
start();
|
||||||
}, 400);
|
}, 1400);
|
||||||
}, 200);
|
}, 1050);
|
||||||
|
}, 700);
|
||||||
|
}, 350);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest( "handle custom menu item submenu auto collapse: mouseleave", function() {
|
asyncTest( "handle custom menu item submenu auto collapse: mouseleave", function() {
|
||||||
@ -112,17 +116,19 @@ asyncTest( "handle custom menu item submenu auto collapse: mouseleave", function
|
|||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
equal( $menu.find( "div[aria-expanded='true']" ).length, 2, "second submenu expanded" );
|
equal( $menu.find( "div[aria-expanded='true']" ).length, 2, "second submenu expanded" );
|
||||||
$menu.find( "div[aria-expanded='true']:first" ).trigger( "mouseleave" );
|
$menu.find( "div[aria-expanded='true']:first" ).trigger( "mouseleave" );
|
||||||
|
setTimeout(function() {
|
||||||
equal( $menu.find( "div[aria-expanded='true']" ).length, 1, "second submenu collapsed" );
|
equal( $menu.find( "div[aria-expanded='true']" ).length, 1, "second submenu collapsed" );
|
||||||
|
|
||||||
$menu.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN });
|
$menu.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN });
|
||||||
ok( $menu.find( ".ui-state-active" ).is( "#menu5 :nth-child(7) a" ),
|
ok( $menu.find( ".ui-state-active" ).is( "#menu5 :nth-child(7) a" ),
|
||||||
"down keypress selected an item from the first submenu" );
|
"down keypress selected an item from the first submenu" );
|
||||||
|
|
||||||
$menu.trigger( "mouseleave" );
|
$menu.trigger( "mouseleave" );
|
||||||
|
setTimeout(function() {
|
||||||
equal( $menu.find( "div[aria-expanded='true']" ).length, 0, "first submenu collapsed" );
|
equal( $menu.find( "div[aria-expanded='true']" ).length, 0, "first submenu collapsed" );
|
||||||
start();
|
start();
|
||||||
}, 400);
|
}, 1400);
|
||||||
}, 200);
|
}, 1050);
|
||||||
|
}, 700);
|
||||||
|
}, 350);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
4
ui/jquery.ui.autocomplete.js
vendored
4
ui/jquery.ui.autocomplete.js
vendored
@ -473,8 +473,8 @@ $.widget( "ui.autocomplete", {
|
|||||||
this.search( null, event );
|
this.search( null, event );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ( this.menu.first() && /^previous/.test(direction) ||
|
if ( this.menu.isFirstItem() && /^previous/.test(direction) ||
|
||||||
this.menu.last() && /^next/.test(direction) ) {
|
this.menu.isLastItem() && /^next/.test(direction) ) {
|
||||||
this._value( this.term );
|
this._value( this.term );
|
||||||
this.menu.blur();
|
this.menu.blur();
|
||||||
return;
|
return;
|
||||||
|
15
ui/jquery.ui.dialog.js
vendored
15
ui/jquery.ui.dialog.js
vendored
@ -78,7 +78,10 @@ $.widget("ui.dialog", {
|
|||||||
if ( typeof this.originalTitle !== "string" ) {
|
if ( typeof this.originalTitle !== "string" ) {
|
||||||
this.originalTitle = "";
|
this.originalTitle = "";
|
||||||
}
|
}
|
||||||
|
this.oldPosition = {
|
||||||
|
parent: this.element.parent(),
|
||||||
|
index: this.element.parent().children().index( this.element )
|
||||||
|
};
|
||||||
this.options.title = this.options.title || this.originalTitle;
|
this.options.title = this.options.title || this.originalTitle;
|
||||||
var self = this,
|
var self = this,
|
||||||
options = self.options,
|
options = self.options,
|
||||||
@ -168,7 +171,8 @@ $.widget("ui.dialog", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
_destroy: function() {
|
_destroy: function() {
|
||||||
var self = this;
|
var self = this, next,
|
||||||
|
oldPosition = this.oldPosition;
|
||||||
|
|
||||||
if ( self.overlay ) {
|
if ( self.overlay ) {
|
||||||
self.overlay.destroy();
|
self.overlay.destroy();
|
||||||
@ -183,6 +187,13 @@ $.widget("ui.dialog", {
|
|||||||
if ( self.originalTitle ) {
|
if ( self.originalTitle ) {
|
||||||
self.element.attr( "title", self.originalTitle );
|
self.element.attr( "title", self.originalTitle );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
next = oldPosition.parent.children().eq( oldPosition.index );
|
||||||
|
if ( next.length ) {
|
||||||
|
next.before( self.element );
|
||||||
|
} else {
|
||||||
|
oldPosition.parent.append( self.element );
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
widget: function() {
|
widget: function() {
|
||||||
|
18
ui/jquery.ui.menu.js
vendored
18
ui/jquery.ui.menu.js
vendored
@ -18,7 +18,7 @@ var idIncrement = 0;
|
|||||||
$.widget( "ui.menu", {
|
$.widget( "ui.menu", {
|
||||||
version: "@VERSION",
|
version: "@VERSION",
|
||||||
defaultElement: "<ul>",
|
defaultElement: "<ul>",
|
||||||
delay: 150,
|
delay: 300,
|
||||||
options: {
|
options: {
|
||||||
menus: "ul",
|
menus: "ul",
|
||||||
position: {
|
position: {
|
||||||
@ -332,12 +332,12 @@ $.widget( "ui.menu", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
blur: function( event ) {
|
blur: function( event ) {
|
||||||
|
clearTimeout( this.timer );
|
||||||
|
|
||||||
if ( !this.active ) {
|
if ( !this.active ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
clearTimeout( this.timer );
|
|
||||||
|
|
||||||
this.active.children( "a" ).removeClass( "ui-state-focus" );
|
this.active.children( "a" ).removeClass( "ui-state-focus" );
|
||||||
this.active = null;
|
this.active = null;
|
||||||
|
|
||||||
@ -381,7 +381,8 @@ $.widget( "ui.menu", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
collapseAll: function( event, all ) {
|
collapseAll: function( event, all ) {
|
||||||
|
clearTimeout( this.timer );
|
||||||
|
this.timer = this._delay( function() {
|
||||||
// if we were passed an event, look for the submenu that contains the event
|
// if we were passed an event, look for the submenu that contains the event
|
||||||
var currentMenu = all ? this.element :
|
var currentMenu = all ? this.element :
|
||||||
$( event && event.target ).closest( this.element.find( ".ui-menu" ) );
|
$( event && event.target ).closest( this.element.find( ".ui-menu" ) );
|
||||||
@ -395,6 +396,7 @@ $.widget( "ui.menu", {
|
|||||||
|
|
||||||
this.blur( event );
|
this.blur( event );
|
||||||
this.activeMenu = currentMenu;
|
this.activeMenu = currentMenu;
|
||||||
|
}, this.delay);
|
||||||
},
|
},
|
||||||
|
|
||||||
// With no arguments, closes the currently active menu - if nothing is active
|
// With no arguments, closes the currently active menu - if nothing is active
|
||||||
@ -445,11 +447,11 @@ $.widget( "ui.menu", {
|
|||||||
this._move( "prev", "last", event );
|
this._move( "prev", "last", event );
|
||||||
},
|
},
|
||||||
|
|
||||||
first: function() {
|
isFirstItem: function() {
|
||||||
return this.active && !this.active.prevAll( ".ui-menu-item" ).length;
|
return this.active && !this.active.prevAll( ".ui-menu-item" ).length;
|
||||||
},
|
},
|
||||||
|
|
||||||
last: function() {
|
isLastItem: function() {
|
||||||
return this.active && !this.active.nextAll( ".ui-menu-item" ).length;
|
return this.active && !this.active.nextAll( ".ui-menu-item" ).length;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -478,7 +480,7 @@ $.widget( "ui.menu", {
|
|||||||
this.focus( event, this.activeMenu.children( ".ui-menu-item" ).first() );
|
this.focus( event, this.activeMenu.children( ".ui-menu-item" ).first() );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ( this.last() ) {
|
if ( this.isLastItem() ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ( this._hasScroll() ) {
|
if ( this._hasScroll() ) {
|
||||||
@ -502,7 +504,7 @@ $.widget( "ui.menu", {
|
|||||||
this.focus( event, this.activeMenu.children( ".ui-menu-item" ).first() );
|
this.focus( event, this.activeMenu.children( ".ui-menu-item" ).first() );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ( this.first() ) {
|
if ( this.isFirstItem() ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ( this._hasScroll() ) {
|
if ( this._hasScroll() ) {
|
||||||
|
Loading…
Reference in New Issue
Block a user