2013-11-13 23:01:16 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the MediaWiki extension MultimediaViewer.
|
|
|
|
*
|
|
|
|
* MultimediaViewer is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* MultimediaViewer is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with MultimediaViewer. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2018-11-12 16:33:24 +00:00
|
|
|
( function () {
|
2014-02-25 01:54:05 +00:00
|
|
|
|
2013-12-10 19:54:07 +00:00
|
|
|
/**
|
2014-02-19 02:27:30 +00:00
|
|
|
* Represents an image on the page.
|
2013-12-10 19:54:07 +00:00
|
|
|
*/
|
2023-05-20 12:38:59 +00:00
|
|
|
class LightboxImage {
|
|
|
|
/**
|
|
|
|
* @param {string} fileLink Link to the file - generally a thumb URL
|
|
|
|
* @param {string} filePageLink Link to the File: page
|
|
|
|
* @param {mw.Title} fileTitle Represents the File: page
|
|
|
|
* @param {number} index Which number file this is
|
2024-05-21 18:24:39 +00:00
|
|
|
* @param {number} position The relative position of this image to others with same file
|
2023-05-20 12:38:59 +00:00
|
|
|
* @param {HTMLImageElement} thumb The thumbnail that represents this image on the page
|
|
|
|
* @param {string} [caption] The caption, if any.
|
|
|
|
*/
|
2024-05-21 18:24:39 +00:00
|
|
|
constructor( fileLink, filePageLink, fileTitle, index, position, thumb, caption ) {
|
2023-05-20 12:38:59 +00:00
|
|
|
/** @property {string} Link to the file - generally a thumb URL */
|
|
|
|
this.src = fileLink;
|
2013-12-10 19:54:07 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
/** @property {string} filePageLink URL to the image's file page */
|
|
|
|
this.filePageLink = filePageLink;
|
2013-12-10 19:54:07 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
/** @property {mw.Title} filePageTitle Title of the image's file page */
|
|
|
|
this.filePageTitle = fileTitle;
|
2013-12-10 19:54:07 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
/** @property {number} index What number this image is in the array of indexed images */
|
|
|
|
this.index = index;
|
2013-12-10 19:54:07 +00:00
|
|
|
|
2024-05-21 18:24:39 +00:00
|
|
|
/** @property {number} position The relative position of this image to others with same file */
|
|
|
|
this.position = position;
|
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
/** @property {HTMLImageElement} thumbnail The <img> element that holds the already-loaded thumbnail of the image */
|
|
|
|
this.thumbnail = thumb;
|
2013-12-10 19:54:07 +00:00
|
|
|
|
2023-05-20 12:38:59 +00:00
|
|
|
/** @property {string} caption The caption of the image, if any */
|
|
|
|
this.caption = caption;
|
2024-05-21 18:24:39 +00:00
|
|
|
}
|
2014-04-09 23:59:49 +00:00
|
|
|
|
2024-05-21 18:24:39 +00:00
|
|
|
/** @return {string} The alt text of the image */
|
|
|
|
get alt() {
|
|
|
|
return $( this.thumbnail ).attr( 'alt' );
|
|
|
|
}
|
2014-12-30 05:10:27 +00:00
|
|
|
|
2024-05-21 18:24:39 +00:00
|
|
|
/** @return {number} Width of the full-sized file (read from HTML data attribute, might be missing) */
|
|
|
|
get originalWidth() {
|
|
|
|
return parseInt( $( this.thumbnail ).data( 'file-width' ), 10 );
|
|
|
|
}
|
2014-04-09 23:59:49 +00:00
|
|
|
|
2024-05-21 18:24:39 +00:00
|
|
|
/** @return {number} originalHeight Height of the full-sized file (read from HTML data attribute, might be missing) */
|
|
|
|
get originalHeight() {
|
|
|
|
return parseInt( $( this.thumbnail ).data( 'file-height' ), 10 );
|
2023-05-20 12:38:59 +00:00
|
|
|
}
|
2013-11-13 23:01:16 +00:00
|
|
|
}
|
|
|
|
|
2023-05-19 20:26:45 +00:00
|
|
|
module.exports = LightboxImage;
|
2018-11-12 16:33:24 +00:00
|
|
|
}() );
|