| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
ve.ce.LanguageAnnotation = function VeCeLanguageAnnotation() { |
| 18 |
|
| 19 |
ve.ce.LanguageAnnotation.super.apply( this, arguments ); |
| 20 |
|
| 21 |
|
| 22 |
this.$element |
| 23 |
.addClass( 've-ce-languageAnnotation' ) |
| 24 |
.addClass( 've-ce-bidi-isolate' ) |
| 25 |
.prop( { |
| 26 |
lang: this.model.getAttribute( 'lang' ) || undefined, |
| 27 |
dir: this.model.getAttribute( 'dir' ) || undefined, |
| 28 |
title: this.constructor.static.getDescription( this.model ) |
| 29 |
} ); |
| 30 |
}; |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
OO.inheritClass( ve.ce.LanguageAnnotation, ve.ce.TextStyleAnnotation ); |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
ve.ce.LanguageAnnotation.static.name = 'meta/language'; |
| 39 |
|
| 40 |
ve.ce.LanguageAnnotation.static.tagName = 'span'; |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
ve.ce.LanguageAnnotation.static.getDescription = function ( model ) { |
| 48 |
const lang = ( model.getAttribute( 'lang' ) || '' ).toLowerCase(), |
| 49 |
name = ve.init.platform.getLanguageName( lang ), |
| 50 |
dir = ( model.getAttribute( 'dir' ) || '' ).toUpperCase(); |
| 51 |
|
| 52 |
if ( !dir || dir === ve.init.platform.getLanguageDirection( lang ).toUpperCase() ) { |
| 53 |
return ve.msg( 'visualeditor-languageannotation-description', name ); |
| 54 |
} |
| 55 |
|
| 56 |
return ve.msg( 'visualeditor-languageannotation-description-with-dir', name, dir ); |
| 57 |
}; |
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
ve.ce.annotationFactory.register( ve.ce.LanguageAnnotation ); |