From 9a2a5bfc1af5cd0a5f781072c4b6b116f9749486 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Fri, 18 Jul 2014 12:11:28 +0200 Subject: [PATCH] Fixed image viewer JS (old code still existed) --- wcfsetup/install/files/js/WCF.ImageViewer.js | 114 +++++-------------- 1 file changed, 26 insertions(+), 88 deletions(-) diff --git a/wcfsetup/install/files/js/WCF.ImageViewer.js b/wcfsetup/install/files/js/WCF.ImageViewer.js index 06afcd1c31..323aef24de 100644 --- a/wcfsetup/install/files/js/WCF.ImageViewer.js +++ b/wcfsetup/install/files/js/WCF.ImageViewer.js @@ -1,6 +1,5 @@ /** - * ImageViewer for WCF. - * Based upon "Slimbox 2" by Christophe Beyls 2007-2012, http://www.digitalia.be/software/slimbox2, MIT-style license. + * Enhanced image viewer for WCF. * * @author Alexander Ebert * @copyright 2001-2014 WoltLab GmbH @@ -8,21 +7,21 @@ */ WCF.ImageViewer = Class.extend({ /** - * Initializes the ImageViewer for every a-tag with the attribute rel = imageviewer. + * trigger element to mimic a slideshow button + * @var jQuery + */ + _triggerElement: null, + + /** + * Initializes the WCF.ImageViewer class. */ init: function() { - // navigation buttons - $('').appendTo($('#lbPrevLink')); - $('').appendTo($('#lbNextLink')); - - // close and enlarge icons - $('').appendTo($('#lbCloseLink')); - var $buttonEnlarge = $('').insertAfter($('#lbCloseLink')); - - // handle enlarge button - $buttonEnlarge.click($.proxy(this._enlarge, this)); - - this._initImageViewer(); + this._triggerElement = $('').data('disableSlideshow', true).hide().appendTo(document.body); + this._triggerElement.wcfImageViewer({ + enableSlideshow: 0, + imageSelector: '.jsImageViewerEnabled', + staticViewer: true + }); WCF.DOMNodeInsertedHandler.addCallback('WCF.ImageViewer', $.proxy(this._domNodeInserted, this)); WCF.DOMNodeInsertedHandler.execute(); @@ -33,39 +32,29 @@ WCF.ImageViewer = Class.extend({ */ _domNodeInserted: function() { this._initImageSizeCheck(); - this._initImageViewer(); + this._rebuildImageViewer(); }, /** - * Initializes the image viewer for all links with class ".jsImageViewer" + * Rebuilds the image viewer. */ - _initImageViewer: function() { - // disable ImageViewer on touch devices identifying themselves as 'mobile' - if ($.browser.touch && /[Mm]obile/.test(navigator.userAgent)) { - // Apple always appends mobile regardless if it is an iPad or iP(hone|od) - if (!/iPad/.test(navigator.userAgent)) { - return; - } - } - + _rebuildImageViewer: function() { var $links = $('a.jsImageViewer'); if ($links.length) { - $links.removeClass('jsImageViewer').slimbox({ - counterText: WCF.Language.get('wcf.imageViewer.counter'), - loop: true - }); + $links.removeClass('jsImageViewer').addClass('jsImageViewerEnabled').click($.proxy(this._click, this)); } }, /** - * Redirects to image for full view. + * Handles click on an image with image viewer support. + * + * @param object event */ - _enlarge: function() { - var $url = $('#lbImage').css('backgroundImage'); - if ($url) { - $url = $url.replace(/^url\((["']?)(.*)\1\)$/, '$2'); - window.location = $url; - } + _click: function(event) { + event.preventDefault(); + event.stopPropagation(); + + this._triggerElement.wcfImageViewer('open', null, $(event.currentTarget).wcfIdentify()); }, /** @@ -108,57 +97,6 @@ WCF.ImageViewer = Class.extend({ } }); -/** - * Enhanced image viewer for WCF. - * - * @author Alexander Ebert - * @copyright 2001-2014 WoltLab GmbH - * @license GNU Lesser General Public License - */ -WCF.ImageViewer = Class.extend({ - /** - * trigger element to mimic a slideshow button - * @var jQuery - */ - _triggerElement: null, - - /** - * Initializes the WCF.ImageViewer class. - */ - init: function() { - this._triggerElement = $('').data('disableSlideshow', true).hide().appendTo(document.body); - this._triggerElement.wcfImageViewer({ - enableSlideshow: 0, - imageSelector: '.jsImageViewerEnabled', - staticViewer: true - }); - - this._rebuildImageViewer(); - }, - - /** - * Rebuilds the image viewer. - */ - _rebuildImageViewer: function() { - var $links = $('a.jsImageViewer'); - if ($links.length) { - $links.removeClass('jsImageViewer').addClass('jsImageViewerEnabled').click($.proxy(this._click, this)); - } - }, - - /** - * Handles click on an image with image viewer support. - * - * @param object event - */ - _click: function(event) { - event.preventDefault(); - event.stopPropagation(); - - this._triggerElement.wcfImageViewer('open', null, $(event.currentTarget).wcfIdentify()); - } -}); - /** * Provides a focused image viewer for WCF. * -- 2.20.1