| 1 | /* |
| 2 | * This file is part of the MediaWiki extension MultimediaViewer. |
| 3 | * |
| 4 | * MultimediaViewer is free software: you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published by |
| 6 | * the Free Software Foundation, either version 2 of the License, or |
| 7 | * (at your option) any later version. |
| 8 | * |
| 9 | * MultimediaViewer is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with MultimediaViewer. If not, see <http://www.gnu.org/licenses/>. |
| 16 | */ |
| 17 | |
| 18 | /** |
| 19 | * Represents an image on the page. |
| 20 | */ |
| 21 | class LightboxImage { |
| 22 | /** |
| 23 | * @param {string} fileLink Link to the file - generally a thumb URL |
| 24 | * @param {mw.Title} fileTitle Represents the File: page |
| 25 | * @param {number} index Which number file this is |
| 26 | * @param {number} position The relative position of this image to others with same file |
| 27 | * @param {HTMLImageElement} thumb The thumbnail that represents this image on the page |
| 28 | * @param {string} [caption] The caption, if any. |
| 29 | */ |
| 30 | constructor( fileLink, fileTitle, index, position, thumb, caption ) { |
| 31 | /** @property {string} Link to the file - generally a thumb URL */ |
| 32 | this.src = fileLink; |
| 33 | |
| 34 | /** @property {mw.Title} filePageTitle Title of the image's file page */ |
| 35 | this.filePageTitle = fileTitle; |
| 36 | |
| 37 | /** @property {number} index What number this image is in the array of indexed images */ |
| 38 | this.index = index; |
| 39 | |
| 40 | /** @property {number} position The relative position of this image to others with same file */ |
| 41 | this.position = position; |
| 42 | |
| 43 | /** @property {HTMLImageElement} thumbnail The <img> element that holds the already-loaded thumbnail of the image */ |
| 44 | this.thumbnail = thumb; |
| 45 | |
| 46 | /** @property {string} caption The caption of the image, if any */ |
| 47 | this.caption = caption; |
| 48 | |
| 49 | /** @property {string} The alt text of the image */ |
| 50 | this.alt = $( this.thumbnail ).attr( 'alt' ); |
| 51 | |
| 52 | /** @property {number} originalWidth of the full-sized file (read from HTML data attribute, might be missing) */ |
| 53 | this.originalWidth = parseInt( $( this.thumbnail ).data( 'file-width' ), 10 ); |
| 54 | |
| 55 | /** @property {number} originalHeight Height of the full-sized file (read from HTML data attribute, might be missing) */ |
| 56 | this.originalHeight = parseInt( $( this.thumbnail ).data( 'file-height' ), 10 ); |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | module.exports = LightboxImage; |