| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
ve.ui.MWGalleryItemWidget = function VeUiMWGalleryItemWidget( imageInfo, config ) { |
| 22 |
this.resource = imageInfo.resource; |
| 23 |
this.altText = imageInfo.altText || ''; |
| 24 |
this.altTextSame = imageInfo.altTextSame; |
| 25 |
this.href = imageInfo.href; |
| 26 |
|
| 27 |
this.originalAltText = imageInfo.altText; |
| 28 |
this.src = imageInfo.src; |
| 29 |
this.height = imageInfo.height; |
| 30 |
this.width = imageInfo.width; |
| 31 |
this.thumbUrl = imageInfo.thumbUrl; |
| 32 |
this.captionDocument = imageInfo.captionDocument; |
| 33 |
this.highlighted = false; |
| 34 |
this.tagName = imageInfo.tagName; |
| 35 |
this.isError = imageInfo.isError; |
| 36 |
this.imageClassAttr = imageInfo.imageClassAttr; |
| 37 |
this.imgWrapperClassAttr = imageInfo.imgWrapperClassAttr; |
| 38 |
this.mw = imageInfo.mw; |
| 39 |
this.mediaClass = imageInfo.mediaClass; |
| 40 |
this.mediaTag = imageInfo.mediaTag; |
| 41 |
|
| 42 |
|
| 43 |
config = config || {}; |
| 44 |
|
| 45 |
|
| 46 |
ve.ui.MWGalleryItemWidget.super.call( this, config ); |
| 47 |
|
| 48 |
this.$element |
| 49 |
.addClass( 've-ui-mwGalleryDialog-image-container mw-no-invert' ) |
| 50 |
.addClass( config.isMobile ? |
| 51 |
've-ui-mwGalleryDialog-image-container-mobile' : |
| 52 |
've-ui-mwGalleryDialog-image-container-desktop' |
| 53 |
) |
| 54 |
.css( 'background-image', 'url(' + this.thumbUrl + ')' ); |
| 55 |
|
| 56 |
|
| 57 |
OO.ui.mixin.DraggableElement.call( this, ve.extendObject( { $handle: this.$element }, config ) ); |
| 58 |
OO.ui.mixin.TabIndexedElement.call( this, config ); |
| 59 |
|
| 60 |
this.$element.on( { |
| 61 |
click: this.onItemClick.bind( this ), |
| 62 |
keypress: this.onItemKeyPress.bind( this ) |
| 63 |
} ); |
| 64 |
}; |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
OO.inheritClass( ve.ui.MWGalleryItemWidget, OO.ui.Widget ); |
| 69 |
|
| 70 |
OO.mixinClass( ve.ui.MWGalleryItemWidget, OO.ui.mixin.DraggableElement ); |
| 71 |
OO.mixinClass( ve.ui.MWGalleryItemWidget, OO.ui.mixin.TabIndexedElement ); |
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
ve.ui.MWGalleryItemWidget.prototype.onItemClick = function () { |
| 87 |
this.emit( 'edit', this ); |
| 88 |
}; |
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
ve.ui.MWGalleryItemWidget.prototype.onItemKeyPress = function ( e ) { |
| 98 |
if ( e.which === OO.ui.Keys.ENTER ) { |
| 99 |
this.emit( 'edit', this ); |
| 100 |
return false; |
| 101 |
} |
| 102 |
}; |
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
ve.ui.MWGalleryItemWidget.prototype.setCaptionDocument = function ( captionDocument ) { |
| 110 |
this.captionDocument = captionDocument; |
| 111 |
}; |
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
ve.ui.MWGalleryItemWidget.prototype.setAltText = function ( altText ) { |
| 119 |
this.altText = altText; |
| 120 |
}; |
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
ve.ui.MWGalleryItemWidget.prototype.setAltTextSame = function ( same ) { |
| 128 |
this.altTextSame = same; |
| 129 |
}; |
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
ve.ui.MWGalleryItemWidget.prototype.toggleHighlighted = function ( highlighted ) { |
| 137 |
highlighted = highlighted !== undefined ? highlighted : !this.highlighted; |
| 138 |
this.$element.toggleClass( 've-ui-mwGalleryDialog-image-container-highlighted', !!highlighted ); |
| 139 |
}; |