diff --git a/classes/RateItArticle.php b/classes/RateItArticle.php index 044abb0..b353b8e 100644 --- a/classes/RateItArticle.php +++ b/classes/RateItArticle.php @@ -198,7 +198,7 @@ class RateItArticle extends RateItFrontend { continue; } - $this->addRatingForImage($arrRating, $arrGallery['id'], $objFile->id, $objFile->path); + $this->addRatingForImage($arrRating, $arrGallery['id'], $objFiles->id, $objFile->path); } // Folders else { @@ -224,7 +224,7 @@ class RateItArticle extends RateItFrontend { continue; } - $this->addRatingForImage($arrRating, $arrGallery['id'], $objSubfiles->id, $objSubfiles->path); + $this->addRatingForImage($arrRating, $arrGallery['id'], $objSubfiles->id, $objSubfiles->path); } } } diff --git a/dca/tl_content.php b/dca/tl_content.php index 76321bf..8d2361d 100644 --- a/dca/tl_content.php +++ b/dca/tl_content.php @@ -92,7 +92,7 @@ class tl_content_rateit extends rateit\DcaHelper { continue; } - $this->insertOrUpdateRatingItemGallery($dc, $type, $objFile->name, $objFile->id, ($dc->activeRecord->rateit_active ? '1' : '')); + $this->insertOrUpdateRatingItemGallery($dc, $type, $objFile->name, $objFiles->id, ($dc->activeRecord->rateit_active ? '1' : '')); } // Folders else { @@ -131,7 +131,11 @@ class tl_content_rateit extends rateit\DcaHelper { public function delete(\DC_Table $dc) { if ($dc->activeRecord->type == "gallery") { - $objFiles = \FilesModel::findMultipleByUuids(deserialize($dc->activeRecord->multiSRC)); + if (version_compare(VERSION, '3.2', '>=')) { + $objFiles = \FilesModel::findMultipleByUuids(deserialize($dc->activeRecord->multiSRC)); + } else { + $objFiles = \FilesModel::findMultipleByIds(deserialize($dc->activeRecord->multiSRC)); + } // Get all images while ($objFiles->next()) { @@ -143,13 +147,17 @@ class tl_content_rateit extends rateit\DcaHelper { continue; } - $rkey = $dc->activeRecord->id.'_'.$objFile->id; + $rkey = $dc->activeRecord->id.'_'.$objFiles->id; $this->Database->prepare("DELETE FROM tl_rateit_items WHERE rkey=? and typ=?") ->execute($rkey, 'galpic'); } // Folders else { - $objSubfiles = \FilesModel::findByPid($objFiles->uuid); + if (version_compare(VERSION, '3.2', '>=')) { + $objSubfiles = \FilesModel::findByPid($objFiles->uuid); + } else { + $objSubfiles = \FilesModel::findByPid($objFiles->id); + } if ($objSubfiles === null) { continue; @@ -167,7 +175,7 @@ class tl_content_rateit extends rateit\DcaHelper { continue; } - $rkey = $dc->activeRecord->id.'_'.$objFile->id; + $rkey = $dc->activeRecord->id.'_'.$objSubfiles->id; $this->Database->prepare("DELETE FROM tl_rateit_items WHERE rkey=? and typ=?") ->execute($rkey, 'galpic'); } diff --git a/public/js/jquery/colorbox/colorbox-rateit.js b/public/js/jquery/colorbox/colorbox-rateit.js index 1f5d3c2..fd5dc4e 100644 --- a/public/js/jquery/colorbox/colorbox-rateit.js +++ b/public/js/jquery/colorbox/colorbox-rateit.js @@ -1,7 +1,7 @@ /*! - Colorbox v1.4.31 - 2013-09-25 + Colorbox v1.5.8 - 2014-04-15 jQuery lightbox and modal window plugin - (c) 2013 Jack Moore - http://www.jacklmoore.com/colorbox + (c) 2014 Jack Moore - http://www.jacklmoore.com/colorbox license: http://www.opensource.org/licenses/mit-license.php */ (function ($, document, window) { @@ -29,9 +29,6 @@ maxHeight: false, scalePhotos: true, scrolling: true, - href: false, - title: false, - rel: false, opacity: 0.9, preloading: true, className: false, @@ -54,7 +51,7 @@ slideshowSpeed: 2500, slideshowStart: "start slideshow", slideshowStop: "stop slideshow", - photoRegex: /\.(gif|png|jp(e|g|eg)|bmp|ico|webp)((#|\?).*)?$/i, + photoRegex: /\.(gif|png|jp(e|g|eg)|bmp|ico|webp|jxr|svg)((#|\?).*)?$/i, // alternate image paths for high-res displays retinaImage: false, @@ -78,9 +75,21 @@ onLoad: false, onComplete: false, onCleanup: false, - onClosed: false + onClosed: false, + + rel: function() { + return this.rel; + }, + href: function() { + // using this.href would give the absolute url, when the href may have been inteded as a selector (e.g. '#container') + return $(this).attr('href'); + }, + title: function() { + return this.title; + } }, - + + // Abstracting the HTML and event identifiers for easy rebranding colorbox = 'colorbox', prefix = 'cbox', @@ -120,7 +129,7 @@ $ratingHover, $ratingDescription, $groupControls, - $events = $(''), + $events = $(''), // $({}) would be prefered, but there is an issue with jQuery 1.4.2 // Variables for cached values or use across multiple functions settings, @@ -128,7 +137,6 @@ interfaceWidth, loadedHeight, loadedWidth, - element, index, photo, open, @@ -137,7 +145,6 @@ loadingTimer, publicMethod, div = "div", - className, requests = 0, previousCSS = {}, init; @@ -167,6 +174,38 @@ return window.innerHeight ? window.innerHeight : $(window).height(); } + function Settings(element, options) { + if (options !== Object(options)) { + options = {}; + } + + this.cache = {}; + this.el = element; + + this.value = function(key) { + var dataAttr; + + if (this.cache[key] === undefined) { + dataAttr = $(this.el).attr('data-cbox-'+key); + + if (dataAttr !== undefined) { + this.cache[key] = dataAttr; + } else if (options[key] !== undefined) { + this.cache[key] = options[key]; + } else if (defaults[key] !== undefined) { + this.cache[key] = defaults[key]; + } + } + + return this.cache[key]; + }; + + this.get = function(key) { + var value = this.value(key); + return $.isFunction(value) ? value.call(this.el, this) : value; + }; + } + // Determine the next and previous members in a group. function getIndex(increment) { var @@ -184,62 +223,55 @@ // Checks an href to see if it is a photo. // There is a force photo option (photo: true) for hrefs that cannot be matched by the regex. function isImage(settings, url) { - return settings.photo || settings.photoRegex.test(url); + return settings.get('photo') || settings.get('photoRegex').test(url); } function retinaUrl(settings, url) { - return settings.retinaUrl && window.devicePixelRatio > 1 ? url.replace(settings.photoRegex, settings.retinaSuffix) : url; + return settings.get('retinaUrl') && window.devicePixelRatio > 1 ? url.replace(settings.get('photoRegex'), settings.get('retinaSuffix')) : url; } function trapFocus(e) { - if ('contains' in $box[0] && !$box[0].contains(e.target)) { + if ('contains' in $box[0] && !$box[0].contains(e.target) && e.target !== $overlay[0]) { e.stopPropagation(); $box.focus(); } } - // Assigns function results to their respective properties - function makeSettings() { - var i, - data = $.data(element, colorbox); + function setClass(str) { + if (setClass.str !== str) { + $box.add($overlay).removeClass(setClass.str).addClass(str); + setClass.str = str; + } + } + + function getRelated(rel) { + index = 0; - if (data == null) { - settings = $.extend({}, defaults); - if (console && console.log) { - console.log('Error: cboxElement missing settings object'); + if (rel && rel !== false) { + $related = $('.' + boxElement).filter(function () { + var options = $.data(this, colorbox); + var settings = new Settings(this, options); + return (settings.get('rel') === rel); + }); + index = $related.index(settings.el); + + // Check direct calls to Colorbox. + if (index === -1) { + $related = $related.add(settings.el); + index = $related.length - 1; } } else { - settings = $.extend({}, data); - } - - for (i in settings) { - if ($.isFunction(settings[i]) && i.slice(0, 2) !== 'on') { // checks to make sure the function isn't one of the callbacks, they will be handled at the appropriate time. - settings[i] = settings[i].call(element); - } - } - - settings.rel = settings.rel || element.rel || $(element).data('rel') || 'nofollow'; - settings.href = settings.href || $(element).attr('href'); - settings.title = settings.title || element.title; - - if (typeof settings.href === "string") { - settings.href = $.trim(settings.href); + $related = $(settings.el); } } - function trigger(event, callback) { + function trigger(event) { // for external use $(document).trigger(event); - // for internal use - $events.trigger(event); - - if ($.isFunction(callback)) { - callback.call(element); - } + $events.triggerHandler(event); } - var slideshow = (function(){ var active, className = prefix + "Slideshow_", @@ -251,15 +283,15 @@ } function set() { - if (settings.loop || $related[index + 1]) { + if (settings.get('loop') || $related[index + 1]) { clear(); - timeOut = setTimeout(publicMethod.next, settings.slideshowSpeed); + timeOut = setTimeout(publicMethod.next, settings.get('slideshowSpeed')); } } function start() { $slideshow - .html(settings.slideshowStop) + .html(settings.get('slideshowStop')) .unbind(click) .one(click, stop); @@ -278,7 +310,7 @@ .unbind(event_load, clear); $slideshow - .html(settings.slideshowStart) + .html(settings.get('slideshowStart')) .unbind(click) .one(click, function () { publicMethod.next(); @@ -300,15 +332,15 @@ return function(){ if (active) { - if (!settings.slideshow) { + if (!settings.get('slideshow')) { $events.unbind(event_cleanup, reset); reset(); } } else { - if (settings.slideshow && $related[1]) { + if (settings.get('slideshow') && $related[1]) { active = true; $events.one(event_cleanup, reset); - if (settings.slideshowAuto) { + if (settings.get('slideshowAuto')) { start(); } else { stop(); @@ -321,65 +353,26 @@ }()); - function launch(target) { + function launch(element) { + var options; + if (!closing) { - - element = target; - - makeSettings(); - - $related = $(element); - - index = 0; - - if (settings.rel !== 'nofollow') { - $related = $('.' + boxElement).filter(function () { - var data = $.data(this, colorbox), - relRelated; - if (data) { - relRelated = $(this).data('rel') || data.rel || this.rel; - } - - return (relRelated === settings.rel); - }); - index = $related.index(element); - - // Check direct calls to Colorbox. - if (index === -1) { - $related = $related.add(element); - index = $related.length - 1; - } - } - - $overlay.css({ - opacity: parseFloat(settings.opacity), - cursor: settings.overlayClose ? "pointer" : "auto", - visibility: 'visible' - }).show(); - + options = $(element).data('colorbox'); - if (className) { - $box.add($overlay).removeClass(className); - } - if (settings.className) { - $box.add($overlay).addClass(settings.className); - } - className = settings.className; - - if (settings.closeButton) { - $close.html(settings.close).appendTo($content); - } else { - $close.appendTo('
'); - } + settings = new Settings(element, options); + + getRelated(settings.get('rel')); if (!open) { open = active = true; // Prevents the page-change action from queuing up if the visitor holds down the left or right keys. + + setClass(settings.get('className')); // Show colorbox so the sizes can be calculated in older versions of jQuery - $box.css({visibility:'hidden', display:'block'}); + $box.css({visibility:'hidden', display:'block', opacity:''}); - $loaded = $tag(div, 'LoadedContent', 'width:0; height:0; overflow:hidden'); + $loaded = $tag(div, 'LoadedContent', 'width:0; height:0; overflow:hidden; visibility:hidden'); $content.css({width:'', height:''}).append($loaded); // Cache values needed for size calculations @@ -389,18 +382,25 @@ loadedWidth = $loaded.outerWidth(true); // Opens inital empty Colorbox prior to content being loaded. - settings.w = setSize(settings.initialWidth, 'x'); - settings.h = setSize(settings.initialHeight, 'y'); + var initialWidth = setSize(settings.get('initialWidth'), 'x'); + var initialHeight = setSize(settings.get('initialHeight'), 'y'); + var maxWidth = settings.get('maxWidth'); + var maxHeight = settings.get('maxHeight'); + + settings.w = (maxWidth !== false ? Math.min(initialWidth, setSize(maxWidth, 'x')) : initialWidth) - loadedWidth - interfaceWidth; + settings.h = (maxHeight !== false ? Math.min(initialHeight, setSize(maxHeight, 'y')) : initialHeight) - loadedHeight - interfaceHeight; + $loaded.css({width:'', height:settings.h}); publicMethod.position(); - trigger(event_open, settings.onOpen); - + trigger(event_open); + settings.get('onOpen'); + $groupControls.add($title).hide(); $box.focus(); - if (settings.trapFocus) { + if (settings.get('trapFocus')) { // Confine focus to the modal // Uses event capturing that is not supported in IE8- if (document.addEventListener) { @@ -414,12 +414,25 @@ } // Return focus on closing - if (settings.returnFocus) { + if (settings.get('returnFocus')) { $events.one(event_closed, function () { - $(element).focus(); + $(settings.el).focus(); }); } } + + $overlay.css({ + opacity: parseFloat(settings.get('opacity')) || '', + cursor: settings.get('overlayClose') ? 'pointer' : '', + visibility: 'visible' + }).show(); + + if (settings.get('closeButton')) { + $close.html(settings.get('close')).appendTo($content); + } else { + $close.appendTo('
'); // replace with .detach() when dropping jQuery < 1.4 + } + load(); } } @@ -457,7 +470,7 @@ $next = $('