Merge "Fix issues with size menus after oojs-ui update"

This commit is contained in:
jenkins-bot 2014-04-09 18:54:15 +00:00 committed by Gerrit Code Review
commit 4c08160eb3
4 changed files with 20 additions and 15 deletions

View file

@ -44,7 +44,7 @@
* Default item for the size menu.
* @property {OO.ui.MenuItemWidget}
*/
this.defaultItem = this.downloadSizeMenu.getMenu().getFirstSelectableItem();
this.defaultItem = this.downloadSizeMenu.getMenu().getSelectedItem();
}
oo.inheritClass( Download, mw.mmv.ui.reuse.Tab );
DP = Download.prototype;

View file

@ -70,13 +70,13 @@
* Default item for the html size menu.
* @property {OO.ui.MenuItemWidget}
*/
this.defaultHtmlItem = this.embedSizeSwitchHtml.getMenu().getFirstSelectableItem();
this.defaultHtmlItem = this.embedSizeSwitchHtml.getMenu().getSelectedItem();
/**
* Default item for the wikitext size menu.
* @property {OO.ui.MenuItemWidget}
*/
this.defaultWikitextItem = this.embedSizeSwitchWikitext.getMenu().getFirstSelectableItem();
this.defaultWikitextItem = this.embedSizeSwitchWikitext.getMenu().getSelectedItem();
/**
* Currently selected size menu.
@ -211,8 +211,8 @@
this.embedSwitch.on( 'select', $.proxy( embed.handleTypeSwitch, embed ) );
// Register handlers for switching between file sizes
this.embedSizeSwitchHtml.getMenu().on( 'select', $.proxy( this.handleSizeSwitch, this ) );
this.embedSizeSwitchWikitext.getMenu().on( 'select', $.proxy( this.handleSizeSwitch, this ) );
this.embedSizeSwitchHtml.getMenu().on( 'choose', $.proxy( this.handleSizeSwitch, this ) );
this.embedSizeSwitchWikitext.getMenu().on( 'choose', $.proxy( this.handleSizeSwitch, this ) );
};
/**
@ -224,8 +224,9 @@
this.embedTextHtml.offDOMEvent( 'focus mousedown click' );
this.embedTextWikitext.offDOMEvent( 'focus mousedown click' );
this.embedSwitch.off( 'select' );
this.embedSizeSwitchHtml.getMenu().off( 'select' );
this.embedSizeSwitchWikitext.getMenu().off( 'select' );
// the noop is needed for some tests which call unattach before calling attach.
this.embedSizeSwitchHtml.getMenu().off( 'choose' );
this.embedSizeSwitchWikitext.getMenu().off( 'choose' );
};
/**
@ -282,7 +283,11 @@
* Reset current menu selection to default item.
*/
EP.resetCurrentSizeMenuToDefault = function () {
this.currentSizeMenu.selectItem( this.currentDefaultItem );
this.currentSizeMenu.chooseItem( this.currentDefaultItem );
// Force select logic to update the selected item bar, otherwise we end up
// with the wrong label. This is implementation dependent and maybe it should
// be done via a to flag to OO.ui.SelectWidget.prototype.chooseItem()?
this.currentSizeMenu.emit( 'select', this.currentDefaultItem );
};
/**

View file

@ -66,7 +66,7 @@
}
menu.getMenu().addItems( items );
menu.getMenu().selectItem( choices[ def ] );
menu.getMenu().chooseItem( choices[ def ] );
return menu;
};

View file

@ -299,9 +299,9 @@
embed.embedTextWikitext.$element.focus();
embed.embedSwitch.emit( 'select' );
embed.embedSizeSwitchHtml.getMenu().emit(
'select', embed.embedSizeSwitchHtml.getMenu().getSelectedItem() );
'choose', embed.embedSizeSwitchHtml.getMenu().getSelectedItem() );
embed.embedSizeSwitchWikitext.getMenu().emit(
'select', embed.embedSizeSwitchWikitext.getMenu().getSelectedItem() );
'choose', embed.embedSizeSwitchWikitext.getMenu().getSelectedItem() );
embed.selectAllOnEvent = function() {
assert.ok( true, 'selectAllOnEvent was called.' );
@ -320,9 +320,9 @@
embed.embedTextWikitext.$element.focus();
embed.embedSwitch.emit( 'select' );
embed.embedSizeSwitchHtml.getMenu().emit(
'select', embed.embedSizeSwitchHtml.getMenu().getSelectedItem() );
'choose', embed.embedSizeSwitchHtml.getMenu().getSelectedItem() );
embed.embedSizeSwitchWikitext.getMenu().emit(
'select', embed.embedSizeSwitchWikitext.getMenu().getSelectedItem() );
'choose', embed.embedSizeSwitchWikitext.getMenu().getSelectedItem() );
// Test the unattach part
embed.selectAllOnEvent = function() {
@ -342,9 +342,9 @@
embed.embedTextWikitext.$element.focus();
embed.embedSwitch.emit( 'select' );
embed.embedSizeSwitchHtml.getMenu().emit(
'select', embed.embedSizeSwitchHtml.getMenu().getSelectedItem() );
'choose', embed.embedSizeSwitchHtml.getMenu().getSelectedItem() );
embed.embedSizeSwitchWikitext.getMenu().emit(
'select', embed.embedSizeSwitchWikitext.getMenu().getSelectedItem() );
'choose', embed.embedSizeSwitchWikitext.getMenu().getSelectedItem() );
} );
QUnit.test( 'handleTypeSwitch():', 6, function ( assert ) {