| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
ve.ui.CommentAnnotationContextItem = function VeUiCommentAnnotationContextItem( context, model, config ) { |
| 18 |
|
| 19 |
ve.ui.CommentAnnotationContextItem.super.call( this, context, model, config ); |
| 20 |
|
| 21 |
|
| 22 |
this.$element.addClass( 've-ui-commentAnnotationContextItem' ); |
| 23 |
|
| 24 |
this.editButton.setLabel( ve.msg( 'visualeditor-commentannotationcontextitem-comment' ) ); |
| 25 |
}; |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
OO.inheritClass( ve.ui.CommentAnnotationContextItem, ve.ui.AnnotationContextItem ); |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
ve.ui.CommentAnnotationContextItem.static.name = 'commentAnnotation'; |
| 34 |
|
| 35 |
ve.ui.CommentAnnotationContextItem.static.icon = 'speechBubble'; |
| 36 |
|
| 37 |
ve.ui.CommentAnnotationContextItem.static.label = OO.ui.deferMsg( 'visualeditor-commentinspector-title' ); |
| 38 |
|
| 39 |
ve.ui.CommentAnnotationContextItem.static.modelClasses = [ ve.dm.CommentAnnotation ]; |
| 40 |
|
| 41 |
ve.ui.CommentAnnotationContextItem.static.embeddable = false; |
| 42 |
|
| 43 |
ve.ui.CommentAnnotationContextItem.static.commandName = 'commentAnnotation'; |
| 44 |
|
| 45 |
ve.ui.CommentAnnotationContextItem.static.clearable = true; |
| 46 |
|
| 47 |
ve.ui.CommentAnnotationContextItem.static.clearIcon = 'trash'; |
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
ve.ui.CommentAnnotationContextItem.static.renderThread = function ( model ) { |
| 56 |
let $thread = $( [] ); |
| 57 |
|
| 58 |
model.getAttribute( 'comments' ).forEach( ( comment ) => { |
| 59 |
const $lineDivs = comment.text.split( '\n' ).map( ( line ) => $( '<div>' ).text( line ) ); |
| 60 |
$thread = $thread.add( |
| 61 |
$( '<div>' ).addClass( 've-ui-commentAnnotationContextItem-comment' ).append( |
| 62 |
$( '<strong>' ).text( comment.author ), |
| 63 |
$lineDivs |
| 64 |
) |
| 65 |
); |
| 66 |
} ); |
| 67 |
|
| 68 |
return $thread; |
| 69 |
}; |
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
ve.ui.CommentAnnotationContextItem.prototype.renderBody = function () { |
| 77 |
const $thread = this.constructor.static.renderThread( this.model ); |
| 78 |
this.$body.append( $thread ); |
| 79 |
}; |
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
ve.ui.contextItemFactory.register( ve.ui.CommentAnnotationContextItem ); |