| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
ve.ui.LanguageSearchDialog = function VeUiLanguageSearchDialog( config ) { |
| 17 |
|
| 18 |
ve.ui.LanguageSearchDialog.super.call( this, config ); |
| 19 |
}; |
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
OO.inheritClass( ve.ui.LanguageSearchDialog, OO.ui.ProcessDialog ); |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
ve.ui.LanguageSearchDialog.static.name = 'languageSearch'; |
| 28 |
|
| 29 |
ve.ui.LanguageSearchDialog.static.size = 'medium'; |
| 30 |
|
| 31 |
ve.ui.LanguageSearchDialog.static.title = |
| 32 |
OO.ui.deferMsg( 'visualeditor-dialog-language-search-title' ); |
| 33 |
|
| 34 |
ve.ui.LanguageSearchDialog.static.actions = [ |
| 35 |
{ |
| 36 |
label: OO.ui.deferMsg( 'visualeditor-dialog-action-cancel' ), |
| 37 |
flags: [ 'safe', 'close' ] |
| 38 |
} |
| 39 |
]; |
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
ve.ui.LanguageSearchDialog.static.languageSearchWidget = ve.ui.LanguageSearchWidget; |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
ve.ui.LanguageSearchDialog.prototype.initialize = function () { |
| 56 |
ve.ui.LanguageSearchDialog.super.prototype.initialize.apply( this, arguments ); |
| 57 |
|
| 58 |
|
| 59 |
this.searchWidget = new this.constructor.static.languageSearchWidget(); |
| 60 |
this.searchWidget.getResults().connect( this, { choose: 'onSearchResultsChoose' } ); |
| 61 |
this.$body.append( this.searchWidget.$element ); |
| 62 |
}; |
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
ve.ui.LanguageSearchDialog.prototype.onSearchResultsChoose = function ( item ) { |
| 70 |
const data = item.getData(); |
| 71 |
this.close( { |
| 72 |
action: 'done', |
| 73 |
lang: data.code, |
| 74 |
dir: ve.init.platform.getLanguageDirection( data.code ) |
| 75 |
} ); |
| 76 |
}; |
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
ve.ui.LanguageSearchDialog.prototype.getSetupProcess = function ( data ) { |
| 82 |
return ve.ui.LanguageSearchDialog.super.prototype.getSetupProcess.call( this, data ) |
| 83 |
.next( () => { |
| 84 |
this.searchWidget.setAvailableLanguages( data.availableLanguages ); |
| 85 |
this.searchWidget.addResults(); |
| 86 |
} ); |
| 87 |
}; |
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
ve.ui.LanguageSearchDialog.prototype.getReadyProcess = function ( data ) { |
| 93 |
return ve.ui.LanguageSearchDialog.super.prototype.getReadyProcess.call( this, data ) |
| 94 |
.next( () => { |
| 95 |
this.searchWidget.getQuery().focus(); |
| 96 |
} ); |
| 97 |
}; |
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
ve.ui.LanguageSearchDialog.prototype.getTeardownProcess = function ( data ) { |
| 103 |
return ve.ui.LanguageSearchDialog.super.prototype.getTeardownProcess.call( this, data ) |
| 104 |
.first( () => { |
| 105 |
this.searchWidget.getQuery().setValue( '' ); |
| 106 |
} ); |
| 107 |
}; |
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
ve.ui.LanguageSearchDialog.prototype.getBodyHeight = function () { |
| 113 |
return 300; |
| 114 |
}; |
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
ve.ui.windowFactory.register( ve.ui.LanguageSearchDialog ); |