| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
ve.ui.LanguageInspector = function VeUiLanguageInspector() { |
| 17 |
|
| 18 |
ve.ui.LanguageInspector.super.apply( this, arguments ); |
| 19 |
}; |
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
OO.inheritClass( ve.ui.LanguageInspector, ve.ui.AnnotationInspector ); |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
ve.ui.LanguageInspector.static.name = 'language'; |
| 28 |
|
| 29 |
ve.ui.LanguageInspector.static.title = |
| 30 |
OO.ui.deferMsg( 'visualeditor-languageinspector-title' ); |
| 31 |
|
| 32 |
ve.ui.LanguageInspector.static.modelClasses = [ ve.dm.LanguageAnnotation ]; |
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
ve.ui.LanguageInspector.prototype.getAnnotation = function () { |
| 40 |
const lang = this.languageInput.getLang(), |
| 41 |
dir = this.languageInput.getDir(); |
| 42 |
return ( lang || dir ? |
| 43 |
new ve.dm.LanguageAnnotation( { |
| 44 |
type: 'meta/language', |
| 45 |
attributes: { |
| 46 |
lang: lang, |
| 47 |
dir: dir |
| 48 |
} |
| 49 |
} ) : |
| 50 |
null |
| 51 |
); |
| 52 |
}; |
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
ve.ui.LanguageInspector.prototype.getAnnotationFromFragment = function ( fragment ) { |
| 58 |
return new ve.dm.LanguageAnnotation( { |
| 59 |
type: 'meta/language', |
| 60 |
attributes: { |
| 61 |
lang: fragment.getDocument().getLang(), |
| 62 |
dir: fragment.getDocument().getDir() |
| 63 |
} |
| 64 |
} ); |
| 65 |
}; |
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
ve.ui.LanguageInspector.prototype.initialize = function () { |
| 71 |
|
| 72 |
ve.ui.LanguageInspector.super.prototype.initialize.call( this ); |
| 73 |
|
| 74 |
|
| 75 |
this.languageInput = new ve.ui.LanguageInputWidget( { |
| 76 |
dialogManager: this.manager.getSurface().getDialogs() |
| 77 |
} ); |
| 78 |
|
| 79 |
const languageField = new OO.ui.FieldLayout( this.languageInput, { |
| 80 |
align: 'left', |
| 81 |
classes: [ 've-ui-languageInspector-languageField' ], |
| 82 |
label: ve.msg( 'visualeditor-languageinspector-widget-label-language' ) |
| 83 |
} ); |
| 84 |
|
| 85 |
|
| 86 |
this.form.$element.append( languageField.$element ); |
| 87 |
}; |
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
ve.ui.LanguageInspector.prototype.getSetupProcess = function ( data ) { |
| 93 |
return ve.ui.LanguageInspector.super.prototype.getSetupProcess.call( this, data ) |
| 94 |
.next( () => { |
| 95 |
this.languageInput.setLangAndDir( |
| 96 |
this.initialAnnotation.getAttribute( 'lang' ), |
| 97 |
this.initialAnnotation.getAttribute( 'dir' ) |
| 98 |
).setReadOnly( this.isReadOnly() ); |
| 99 |
} ); |
| 100 |
}; |
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
ve.ui.windowFactory.register( ve.ui.LanguageInspector ); |