mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/MultimediaViewer
synced 2024-11-24 08:13:38 +00:00
Fix some OOJS-UI issues
* intializeSelection was removed * selectItem is replaced by chooseItem, sort of (selectItem does not always update the UI, I think?) * remove old workaround, bug was fixed upstream This fixes the download button and unbreaks lots of unittests. It does not fix the "Loading" text in the embed tab. Change-Id: Iec7bf9ad5b516001231c7ba46fda962671aaddd8
This commit is contained in:
parent
3df526b919
commit
660553c58e
|
@ -44,7 +44,7 @@
|
|||
* Default item for the size menu.
|
||||
* @property {OO.ui.MenuItemWidget}
|
||||
*/
|
||||
this.defaultItem = this.downloadSizeMenu.getMenu().getSelectedItem();
|
||||
this.defaultItem = this.downloadSizeMenu.getMenu().getFirstSelectableItem();
|
||||
}
|
||||
oo.inheritClass( Download, mw.mmv.ui.reuse.Tab );
|
||||
DP = Download.prototype;
|
||||
|
@ -120,7 +120,7 @@
|
|||
var download = this;
|
||||
|
||||
// Register handlers for switching between file sizes
|
||||
this.downloadSizeMenu.getMenu().on( 'select', $.proxy( download.handleSizeSwitch, download ) );
|
||||
this.downloadSizeMenu.getMenu().on( 'choose', $.proxy( download.handleSizeSwitch, download ) );
|
||||
this.$selectionArrow.on( 'click', function () {
|
||||
download.downloadSizeMenu.$element.click();
|
||||
} );
|
||||
|
@ -132,14 +132,14 @@
|
|||
DP.unattach = function () {
|
||||
this.constructor.super.prototype.unattach.call( this );
|
||||
|
||||
this.downloadSizeMenu.getMenu().off( 'select' );
|
||||
this.downloadSizeMenu.getMenu().off( 'choose' );
|
||||
this.$selectionArrow.off( 'click' );
|
||||
};
|
||||
|
||||
/**
|
||||
* Handles size menu change events.
|
||||
*
|
||||
* @param {OO.ui.MenuItemWidget}
|
||||
* @param {OO.ui.MenuItemWidget} item
|
||||
*/
|
||||
DP.handleSizeSwitch = function ( item ) {
|
||||
var download = this,
|
||||
|
@ -188,8 +188,7 @@
|
|||
this.imageExtension = image.title.getExtension().toLowerCase();
|
||||
|
||||
// Reset size menu to default item and update download button label now that we have the info
|
||||
this.downloadSizeMenu.getMenu().intializeSelection( this.defaultItem );
|
||||
this.downloadSizeMenu.getMenu().selectItem( this.defaultItem );
|
||||
this.downloadSizeMenu.getMenu().chooseItem( this.defaultItem );
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -70,13 +70,13 @@
|
|||
* Default item for the html size menu.
|
||||
* @property {OO.ui.MenuItemWidget}
|
||||
*/
|
||||
this.defaultHtmlItem = this.embedSizeSwitchHtml.getMenu().getSelectedItem();
|
||||
this.defaultHtmlItem = this.embedSizeSwitchHtml.getMenu().getFirstSelectableItem();
|
||||
|
||||
/**
|
||||
* Default item for the wikitext size menu.
|
||||
* @property {OO.ui.MenuItemWidget}
|
||||
*/
|
||||
this.defaultWikitextItem = this.embedSizeSwitchWikitext.getMenu().getSelectedItem();
|
||||
this.defaultWikitextItem = this.embedSizeSwitchWikitext.getMenu().getFirstSelectableItem();
|
||||
|
||||
/**
|
||||
* Currently selected size menu.
|
||||
|
@ -161,7 +161,6 @@
|
|||
.append( this.embedSwitch.$element )
|
||||
.appendTo( $container );
|
||||
|
||||
// Default to 'wikitext'
|
||||
this.embedSwitch.selectItem( wikitextButtonOption );
|
||||
};
|
||||
|
||||
|
@ -211,12 +210,9 @@
|
|||
// Register handler for switching between wikitext/html snippets
|
||||
this.embedSwitch.on( 'select', $.proxy( embed.handleTypeSwitch, embed ) );
|
||||
|
||||
// workaround for bug 63094
|
||||
this.proxiedHandleSizeSwitch = this.proxiedHandleSizeSwitch || $.proxy( this.handleSizeSwitch, this );
|
||||
|
||||
// Register handlers for switching between file sizes
|
||||
this.embedSizeSwitchHtml.getMenu().on( 'select', this.proxiedHandleSizeSwitch );
|
||||
this.embedSizeSwitchWikitext.getMenu().on( 'select', this.proxiedHandleSizeSwitch );
|
||||
this.embedSizeSwitchHtml.getMenu().on( 'select', $.proxy( this.handleSizeSwitch, this ) );
|
||||
this.embedSizeSwitchWikitext.getMenu().on( 'select', $.proxy( this.handleSizeSwitch, this ) );
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -228,15 +224,14 @@
|
|||
this.embedTextHtml.offDOMEvent( 'focus mousedown click' );
|
||||
this.embedTextWikitext.offDOMEvent( 'focus mousedown click' );
|
||||
this.embedSwitch.off( 'select' );
|
||||
// the noop is needed for some tests which call unattach before calling attach.
|
||||
this.embedSizeSwitchHtml.getMenu().off( 'select', this.proxiedHandleSizeSwitch || $.noop );
|
||||
this.embedSizeSwitchWikitext.getMenu().off( 'select', this.proxiedHandleSizeSwitch || $.noop );
|
||||
this.embedSizeSwitchHtml.getMenu().off( 'select' );
|
||||
this.embedSizeSwitchWikitext.getMenu().off( 'select' );
|
||||
};
|
||||
|
||||
/**
|
||||
* Handles size menu change events.
|
||||
*
|
||||
* @param {OO.ui.MenuItemWidget}
|
||||
* @param {OO.ui.MenuItemWidget} item
|
||||
*/
|
||||
EP.handleSizeSwitch = function ( item ) {
|
||||
var value = item.getData();
|
||||
|
@ -247,7 +242,7 @@
|
|||
/**
|
||||
* Handles snippet type switch.
|
||||
*
|
||||
* @param {OO.ui.MenuItemWidget}
|
||||
* @param {OO.ui.MenuItemWidget} item
|
||||
*/
|
||||
EP.handleTypeSwitch = function ( item ) {
|
||||
var value = item.getData();
|
||||
|
@ -287,7 +282,6 @@
|
|||
* Reset current menu selection to default item.
|
||||
*/
|
||||
EP.resetCurrentSizeMenuToDefault = function () {
|
||||
this.currentSizeMenu.intializeSelection( this.currentDefaultItem );
|
||||
this.currentSizeMenu.selectItem( this.currentDefaultItem );
|
||||
};
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@
|
|||
|
||||
// Triggering action events before attaching should do nothing
|
||||
download.downloadSizeMenu.getMenu().emit(
|
||||
'select', download.downloadSizeMenu.getMenu().getSelectedItem() );
|
||||
'choose', download.downloadSizeMenu.getMenu().getSelectedItem() );
|
||||
download.$selectionArrow.click();
|
||||
|
||||
download.handleSizeSwitch = function() {
|
||||
|
@ -91,7 +91,7 @@
|
|||
|
||||
// Action events should be handled now
|
||||
download.downloadSizeMenu.getMenu().emit(
|
||||
'select', download.downloadSizeMenu.getMenu().getSelectedItem() );
|
||||
'choose', download.downloadSizeMenu.getMenu().getSelectedItem() );
|
||||
download.$selectionArrow.click();
|
||||
|
||||
// Test the unattach part
|
||||
|
@ -106,7 +106,7 @@
|
|||
|
||||
// Triggering action events now that we are unattached should do nothing
|
||||
download.downloadSizeMenu.getMenu().emit(
|
||||
'select', download.downloadSizeMenu.getMenu().getSelectedItem() );
|
||||
'choose', download.downloadSizeMenu.getMenu().getSelectedItem() );
|
||||
download.$selectionArrow.click();
|
||||
} );
|
||||
|
||||
|
|
Loading…
Reference in a new issue