From fb789c7ff70af3685693fde4bb85c6da34aa4d61 Mon Sep 17 00:00:00 2001 From: Trevor Parscal Date: Tue, 25 Jun 2013 15:11:41 -0700 Subject: [PATCH] Automatically focus on the query input on insert media dialog open Change-Id: I03d44d09e3abfffb67adeba5ebe3a52451cc5be5 --- .../ve/ui/dialogs/ve.ui.MWMediaInsertDialog.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/modules/ve/ui/dialogs/ve.ui.MWMediaInsertDialog.js b/modules/ve/ui/dialogs/ve.ui.MWMediaInsertDialog.js index a143ae165f..b974b3933f 100644 --- a/modules/ve/ui/dialogs/ve.ui.MWMediaInsertDialog.js +++ b/modules/ve/ui/dialogs/ve.ui.MWMediaInsertDialog.js @@ -41,6 +41,14 @@ ve.ui.MWMediaInsertDialog.prototype.onSelect = function ( item ) { this.applyButton.setDisabled( item === null ); }; +ve.ui.MWMediaInsertDialog.prototype.onOpen = function () { + // Parent method + ve.ui.Dialog.prototype.onOpen.call( this ); + + // Initialization + this.search.getQuery().$input.focus().select(); +}; + ve.ui.MWMediaInsertDialog.prototype.onClose = function ( action ) { var info; @@ -75,17 +83,17 @@ ve.ui.MWMediaInsertDialog.prototype.initialize = function () { ve.ui.Dialog.prototype.initialize.call( this ); // Properties - this.media = new ve.ui.MWMediaSearchWidget( { '$$': this.frame.$$ } ); + this.search = new ve.ui.MWMediaSearchWidget( { '$$': this.frame.$$ } ); // Events - this.media.connect( this, { 'select': 'onSelect' } ); + this.search.connect( this, { 'select': 'onSelect' } ); // Initialization this.applyButton.setDisabled( true ).setLabel( mw.msg( 'visualeditor-dialog-media-insert-button' ) ); - this.media.$.addClass( 've-ui-mwMediaInsertDialog-select' ); - this.$body.append( this.media.$ ); + this.search.$.addClass( 've-ui-mwMediaInsertDialog-select' ); + this.$body.append( this.search.$ ); }; /* Registration */