Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge branch 'master' into selectmenu

  • Loading branch information...
commit bd7bd936d1e437ee1154ab6b7b1cdc70b1018363 2 parents 3025c51 + f0007ec
Kris Borchers kborchers authored
9 tests/unit/dialog/dialog_tickets.js
@@ -140,4 +140,13 @@ test("#6966: Escape key closes all dialogs, not the top one", function(){
140 140 d1.remove();
141 141 });
142 142
  143 +test("#4980: Destroy should place element back in original DOM position", function(){
  144 + container = $('<div id="container"><div id="modal">Content</div></div>');
  145 + modal = container.find('#modal');
  146 + modal.dialog();
  147 + ok(!$.contains(container[0], modal[0]), 'dialog should move modal element to outside container element');
  148 + modal.dialog('destroy');
  149 + ok($.contains(container[0], modal[0]), 'dialog(destroy) should place element back in original DOM position');
  150 +});
  151 +
143 152 })(jQuery);
40 tests/unit/menu/menu_events.js
@@ -93,12 +93,16 @@ asyncTest( "handle submenu auto collapse: mouseleave", function() {
93 93 setTimeout(function() {
94 94 equal( $menu.find( "ul[aria-expanded='true']" ).length, 2, "second submenu expanded" );
95 95 $menu.find( "ul[aria-expanded='true']:first" ).trigger( "mouseleave" );
96   - equal( $menu.find( "ul[aria-expanded='true']" ).length, 1, "second submenu collapsed" );
97   - $menu.trigger( "mouseleave" );
98   - equal( $menu.find( "ul[aria-expanded='true']" ).length, 0, "first submenu collapsed" );
99   - start();
100   - }, 400);
101   - }, 200);
  96 + setTimeout(function() {
  97 + equal( $menu.find( "ul[aria-expanded='true']" ).length, 1, "second submenu collapsed" );
  98 + $menu.trigger( "mouseleave" );
  99 + setTimeout(function() {
  100 + equal( $menu.find( "ul[aria-expanded='true']" ).length, 0, "first submenu collapsed" );
  101 + start();
  102 + }, 1400);
  103 + }, 1050);
  104 + }, 700);
  105 + }, 350);
102 106 });
103 107
104 108 asyncTest( "handle custom menu item submenu auto collapse: mouseleave", function() {
@@ -112,17 +116,19 @@ asyncTest( "handle custom menu item submenu auto collapse: mouseleave", function
112 116 setTimeout(function() {
113 117 equal( $menu.find( "div[aria-expanded='true']" ).length, 2, "second submenu expanded" );
114 118 $menu.find( "div[aria-expanded='true']:first" ).trigger( "mouseleave" );
115   - equal( $menu.find( "div[aria-expanded='true']" ).length, 1, "second submenu collapsed" );
116   -
117   - $menu.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN });
118   - ok( $menu.find( ".ui-state-active" ).is( "#menu5 :nth-child(7) a" ),
119   - "down keypress selected an item from the first submenu" );
120   -
121   - $menu.trigger( "mouseleave" );
122   - equal( $menu.find( "div[aria-expanded='true']" ).length, 0, "first submenu collapsed" );
123   - start();
124   - }, 400);
125   - }, 200);
  119 + setTimeout(function() {
  120 + equal( $menu.find( "div[aria-expanded='true']" ).length, 1, "second submenu collapsed" );
  121 + $menu.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN });
  122 + ok( $menu.find( ".ui-state-active" ).is( "#menu5 :nth-child(7) a" ),
  123 + "down keypress selected an item from the first submenu" );
  124 + $menu.trigger( "mouseleave" );
  125 + setTimeout(function() {
  126 + equal( $menu.find( "div[aria-expanded='true']" ).length, 0, "first submenu collapsed" );
  127 + start();
  128 + }, 1400);
  129 + }, 1050);
  130 + }, 700);
  131 + }, 350);
126 132 });
127 133
128 134
4 ui/jquery.ui.autocomplete.js
@@ -473,8 +473,8 @@ $.widget( "ui.autocomplete", {
473 473 this.search( null, event );
474 474 return;
475 475 }
476   - if ( this.menu.first() && /^previous/.test(direction) ||
477   - this.menu.last() && /^next/.test(direction) ) {
  476 + if ( this.menu.isFirstItem() && /^previous/.test(direction) ||
  477 + this.menu.isLastItem() && /^next/.test(direction) ) {
478 478 this._value( this.term );
479 479 this.menu.blur();
480 480 return;
17 ui/jquery.ui.dialog.js
@@ -77,8 +77,11 @@ $.widget("ui.dialog", {
77 77 // #5742 - .attr() might return a DOMElement
78 78 if ( typeof this.originalTitle !== "string" ) {
79 79 this.originalTitle = "";
80   - }
81   -
  80 + }
  81 + this.oldPosition = {
  82 + parent: this.element.parent(),
  83 + index: this.element.parent().children().index( this.element )
  84 + };
82 85 this.options.title = this.options.title || this.originalTitle;
83 86 var self = this,
84 87 options = self.options,
@@ -168,7 +171,8 @@ $.widget("ui.dialog", {
168 171 },
169 172
170 173 _destroy: function() {
171   - var self = this;
  174 + var self = this, next,
  175 + oldPosition = this.oldPosition;
172 176
173 177 if ( self.overlay ) {
174 178 self.overlay.destroy();
@@ -183,6 +187,13 @@ $.widget("ui.dialog", {
183 187 if ( self.originalTitle ) {
184 188 self.element.attr( "title", self.originalTitle );
185 189 }
  190 +
  191 + next = oldPosition.parent.children().eq( oldPosition.index );
  192 + if ( next.length ) {
  193 + next.before( self.element );
  194 + } else {
  195 + oldPosition.parent.append( self.element );
  196 + }
186 197 },
187 198
188 199 widget: function() {
38 ui/jquery.ui.menu.js
@@ -18,7 +18,7 @@ var idIncrement = 0;
18 18 $.widget( "ui.menu", {
19 19 version: "@VERSION",
20 20 defaultElement: "<ul>",
21   - delay: 150,
  21 + delay: 300,
22 22 options: {
23 23 menus: "ul",
24 24 position: {
@@ -332,12 +332,12 @@ $.widget( "ui.menu", {
332 332 },
333 333
334 334 blur: function( event ) {
  335 + clearTimeout( this.timer );
  336 +
335 337 if ( !this.active ) {
336 338 return;
337 339 }
338 340
339   - clearTimeout( this.timer );
340   -
341 341 this.active.children( "a" ).removeClass( "ui-state-focus" );
342 342 this.active = null;
343 343
@@ -381,20 +381,22 @@ $.widget( "ui.menu", {
381 381 },
382 382
383 383 collapseAll: function( event, all ) {
  384 + clearTimeout( this.timer );
  385 + this.timer = this._delay( function() {
  386 + // if we were passed an event, look for the submenu that contains the event
  387 + var currentMenu = all ? this.element :
  388 + $( event && event.target ).closest( this.element.find( ".ui-menu" ) );
384 389
385   - // if we were passed an event, look for the submenu that contains the event
386   - var currentMenu = all ? this.element :
387   - $( event && event.target ).closest( this.element.find( ".ui-menu" ) );
388   -
389   - // if we found no valid submenu ancestor, use the main menu to close all sub menus anyway
390   - if ( !currentMenu.length ) {
391   - currentMenu = this.element;
392   - }
  390 + // if we found no valid submenu ancestor, use the main menu to close all sub menus anyway
  391 + if ( !currentMenu.length ) {
  392 + currentMenu = this.element;
  393 + }
393 394
394   - this._close( currentMenu );
  395 + this._close( currentMenu );
395 396
396   - this.blur( event );
397   - this.activeMenu = currentMenu;
  397 + this.blur( event );
  398 + this.activeMenu = currentMenu;
  399 + }, this.delay);
398 400 },
399 401
400 402 // With no arguments, closes the currently active menu - if nothing is active
@@ -445,11 +447,11 @@ $.widget( "ui.menu", {
445 447 this._move( "prev", "last", event );
446 448 },
447 449
448   - first: function() {
  450 + isFirstItem: function() {
449 451 return this.active && !this.active.prevAll( ".ui-menu-item" ).length;
450 452 },
451 453
452   - last: function() {
  454 + isLastItem: function() {
453 455 return this.active && !this.active.nextAll( ".ui-menu-item" ).length;
454 456 },
455 457
@@ -478,7 +480,7 @@ $.widget( "ui.menu", {
478 480 this.focus( event, this.activeMenu.children( ".ui-menu-item" ).first() );
479 481 return;
480 482 }
481   - if ( this.last() ) {
  483 + if ( this.isLastItem() ) {
482 484 return;
483 485 }
484 486 if ( this._hasScroll() ) {
@@ -502,7 +504,7 @@ $.widget( "ui.menu", {
502 504 this.focus( event, this.activeMenu.children( ".ui-menu-item" ).first() );
503 505 return;
504 506 }
505   - if ( this.first() ) {
  507 + if ( this.isFirstItem() ) {
506 508 return;
507 509 }
508 510 if ( this._hasScroll() ) {

0 comments on commit bd7bd93

Please sign in to comment.
Something went wrong with that request. Please try again.