diff options
author | Mario Vavti <mario@mariovavti.com> | 2018-06-25 14:29:07 +0200 |
---|---|---|
committer | Mario Vavti <mario@mariovavti.com> | 2018-06-25 14:29:07 +0200 |
commit | 259417815820d85deadaf90f6c0ed003880f373f (patch) | |
tree | 26448b64c79841e99b16df92b1610d0ed014128c /library/justifiedGallery | |
parent | 28043726e64f750e646b42aa6f649e277fc3767e (diff) | |
download | volse-hubzilla-259417815820d85deadaf90f6c0ed003880f373f.tar.gz volse-hubzilla-259417815820d85deadaf90f6c0ed003880f373f.tar.bz2 volse-hubzilla-259417815820d85deadaf90f6c0ed003880f373f.zip |
updates justified gallery lib to version 3.7 and minor fixes for full template
Diffstat (limited to 'library/justifiedGallery')
-rw-r--r-- | library/justifiedGallery/jquery.justifiedGallery.js | 433 | ||||
-rw-r--r-- | library/justifiedGallery/jquery.justifiedGallery.min.js | 5 | ||||
-rw-r--r-- | library/justifiedGallery/justifiedGallery.css | 2 | ||||
-rw-r--r-- | library/justifiedGallery/justifiedGallery.min.css | 99 |
4 files changed, 333 insertions, 206 deletions
diff --git a/library/justifiedGallery/jquery.justifiedGallery.js b/library/justifiedGallery/jquery.justifiedGallery.js index 85a4168bd..e1495d870 100644 --- a/library/justifiedGallery/jquery.justifiedGallery.js +++ b/library/justifiedGallery/jquery.justifiedGallery.js @@ -1,26 +1,49 @@ /*! - * Justified Gallery - v3.6.5 + * justifiedGallery - v3.7.0 * http://miromannino.github.io/Justified-Gallery/ * Copyright (c) 2018 Miro Mannino * Licensed under the MIT license. */ -(function($) { - - function hasScrollBar() { - return $("body").height() > $(window).height(); +(function (factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(['jquery'], factory); + } else if (typeof module === 'object' && module.exports) { + // Node/CommonJS + module.exports = function( root, jQuery ) { + if ( jQuery === undefined ) { + // require('jQuery') returns a factory that requires window to + // build a jQuery instance, we normalize how we use modules + // that require this pattern but the window provided is a noop + // if it's defined (how jquery works) + if ( typeof window !== 'undefined' ) { + jQuery = require('jquery'); + } + else { + jQuery = require('jquery')(root); + } + } + factory(jQuery); + return jQuery; + }; + } else { + // Browser globals + factory(jQuery); } +}(function ($) { + /** * Justified Gallery controller constructor * * @param $gallery the gallery to build - * @param settings the settings (the defaults are in $.fn.justifiedGallery.defaults) + * @param settings the settings (the defaults are in JustifiedGallery.defaults) * @constructor */ var JustifiedGallery = function ($gallery, settings) { - + this.settings = settings; this.checkSettings(); - + this.imgAnalyzerTimeout = null; this.entries = null; this.buildingRow = { @@ -46,12 +69,13 @@ $el : $('<div class="spinner"><span></span><span></span><span></span></div>'), intervalId : null }; + this.scrollBarOn = false; this.checkWidthIntervalId = null; this.galleryWidth = $gallery.width(); this.$gallery = $gallery; - + }; - + /** @returns {String} the best suffix given the width and the height */ JustifiedGallery.prototype.getSuffix = function (width, height) { var longestSide, i; @@ -63,7 +87,7 @@ } return this.settings.sizeRangeSuffixes[this.suffixRanges[i - 1]]; }; - + /** * Remove the suffix from the string * @@ -72,14 +96,14 @@ JustifiedGallery.prototype.removeSuffix = function (str, suffix) { return str.substring(0, str.length - suffix.length); }; - + /** * @returns {boolean} a boolean to say if the suffix is contained in the str or not */ JustifiedGallery.prototype.endsWith = function (str, suffix) { return str.indexOf(suffix, str.length - suffix.length) !== -1; }; - + /** * Get the used suffix of a particular url * @@ -95,7 +119,7 @@ } return ''; }; - + /** * Given an image src, with the width and the height, returns the new image src with the * best suffix to show the best quality thumbnail. @@ -104,7 +128,7 @@ */ JustifiedGallery.prototype.newSrc = function (imageSrc, imgWidth, imgHeight, image) { var newImageSrc; - + if (this.settings.thumbnailPath) { newImageSrc = this.settings.thumbnailPath(imageSrc, imgWidth, imgHeight, image); } else { @@ -114,10 +138,10 @@ newImageSrc = this.removeSuffix(newImageSrc, this.getUsedSuffix(newImageSrc)); newImageSrc += this.getSuffix(imgWidth, imgHeight) + ext; } - + return newImageSrc; }; - + /** * Shows the images that is in the given entry * @@ -133,7 +157,7 @@ $entry.find(this.settings.imgSelector).stop().fadeTo(this.settings.imagesAnimationDuration, 1.0, callback); } }; - + /** * Extract the image src form the image, looking from the 'safe-src', and if it can't be found, from the * 'src' attribute. It saves in the image data the 'jg.originalSrc' field, with the extracted src. @@ -146,19 +170,19 @@ $image.data('jg.originalSrc', imageSrc); return imageSrc; }; - + /** @returns {jQuery} the image in the given entry */ JustifiedGallery.prototype.imgFromEntry = function ($entry) { var $img = $entry.find(this.settings.imgSelector); return $img.length === 0 ? null : $img; }; - + /** @returns {jQuery} the caption in the given entry */ JustifiedGallery.prototype.captionFromEntry = function ($entry) { var $caption = $entry.find('> .caption'); return $caption.length === 0 ? null : $caption; }; - + /** * Display the entry * @@ -174,28 +198,28 @@ $entry.height(rowHeight); $entry.css('top', y); $entry.css('left', x); - + var $image = this.imgFromEntry($entry); if ($image !== null) { $image.css('width', imgWidth); $image.css('height', imgHeight); $image.css('margin-left', - imgWidth / 2); $image.css('margin-top', - imgHeight / 2); - + // Image reloading for an high quality of thumbnails var imageSrc = $image.attr('src'); var newImageSrc = this.newSrc(imageSrc, imgWidth, imgHeight, $image[0]); - + $image.one('error', function () { $image.attr('src', $image.data('jg.originalSrc')); //revert to the original thumbnail, we got it. }); - + var loadNewImage = function () { if (imageSrc !== newImageSrc) { //load the new image after the fadeIn $image.attr('src', newImageSrc); } }; - + if ($entry.data('jg.loaded') === 'skipped') { this.onImageEvent(imageSrc, $.proxy(function() { this.showImg($entry, loadNewImage); @@ -204,14 +228,14 @@ } else { this.showImg($entry, loadNewImage); } - + } else { this.showImg($entry); } - + this.displayEntryCaption($entry); }; - + /** * Display the entry caption. If the caption element doesn't exists, it creates the caption using the 'alt' * or the 'title' attributes. @@ -222,7 +246,7 @@ var $image = this.imgFromEntry($entry); if ($image !== null && this.settings.captions) { var $imgCaption = this.captionFromEntry($entry); - + // Create it if it doesn't exists if ($imgCaption === null) { var caption = $image.attr('alt'); @@ -233,7 +257,7 @@ $entry.data('jg.createdCaption', true); } } - + // Create events (we check again the $imgCaption because it can be still inexistent) if ($imgCaption !== null) { if (!this.settings.cssAnimation) $imgCaption.stop().fadeTo(0, this.settings.captionSettings.nonVisibleOpacity); @@ -243,7 +267,7 @@ this.removeCaptionEventsHandlers($entry); } }; - + /** * Validates the caption * @@ -253,7 +277,7 @@ JustifiedGallery.prototype.isValidCaption = function (caption) { return (typeof caption !== 'undefined' && caption.length > 0); }; - + /** * The callback for the event 'mouseenter'. It assumes that the event currentTarget is an entry. * It shows the caption using jQuery (or using CSS if it is configured so) @@ -269,7 +293,7 @@ this.settings.captionSettings.visibleOpacity); } }; - + /** * The callback for the event 'mouseleave'. It assumes that the event currentTarget is an entry. * It hides the caption using jQuery (or using CSS if it is configured so) @@ -285,7 +309,7 @@ this.settings.captionSettings.nonVisibleOpacity); } }; - + /** * Add the handlers of the entry for the caption * @@ -303,7 +327,7 @@ $entry.data('jg.captionMouseEvents', captionMouseEvents); } }; - + /** * Remove the handlers of the entry for the caption * @@ -317,7 +341,7 @@ $entry.removeData('jg.captionMouseEvents'); } }; - + /** * Clear the building row data to be used for a new row */ @@ -326,7 +350,7 @@ this.buildingRow.aspectRatio = 0; this.buildingRow.width = 0; }; - + /** * Justify the building row, preparing it to * @@ -341,7 +365,7 @@ var rowHeight = availableWidth / this.buildingRow.aspectRatio; var defaultRowHeight = this.settings.rowHeight; var justifiable = this.buildingRow.width / availableWidth > this.settings.justifyThreshold; - + //Skip the last row if we can't justify it and the lastRow == 'hide' if (isLastRow && this.settings.lastRow === 'hide' && !justifiable) { for (i = 0; i < this.buildingRow.entriesBuff.length; i++) { @@ -355,21 +379,21 @@ } return -1; } - + // With lastRow = nojustify, justify if is justificable (the images will not become too big) if (isLastRow && !justifiable && this.settings.lastRow !== 'justify' && this.settings.lastRow !== 'hide') { justify = false; - + if (this.rows > 0) { defaultRowHeight = (this.offY - this.border - this.settings.margins * this.rows) / this.rows; justify = defaultRowHeight * this.buildingRow.aspectRatio / availableWidth > this.settings.justifyThreshold; } } - + for (i = 0; i < this.buildingRow.entriesBuff.length; i++) { $entry = this.buildingRow.entriesBuff[i]; imgAspectRatio = $entry.data('jg.width') / $entry.data('jg.height'); - + if (justify) { newImgW = (i === this.buildingRow.entriesBuff.length - 1) ? availableWidth : rowHeight * imgAspectRatio; newImgH = rowHeight; @@ -377,17 +401,17 @@ newImgW = defaultRowHeight * imgAspectRatio; newImgH = defaultRowHeight; } - + availableWidth -= Math.round(newImgW); $entry.data('jg.jwidth', Math.round(newImgW)); $entry.data('jg.jheight', Math.ceil(newImgH)); if (i === 0 || minHeight > newImgH) minHeight = newImgH; } - + this.buildingRow.height = minHeight; return justify; }; - + /** * Flush a row: justify it, modify the gallery height accordingly to the row height * @@ -396,115 +420,120 @@ JustifiedGallery.prototype.flushRow = function (isLastRow) { var settings = this.settings; var $entry, buildingRowRes, offX = this.border, i; - + buildingRowRes = this.prepareBuildingRow(isLastRow); if (isLastRow && settings.lastRow === 'hide' && buildingRowRes === -1) { this.clearBuildingRow(); return; } - + if(this.maxRowHeight) { if(this.maxRowHeight < this.buildingRow.height) this.buildingRow.height = this.maxRowHeight; } - + //Align last (unjustified) row if (isLastRow && (settings.lastRow === 'center' || settings.lastRow === 'right')) { var availableWidth = this.galleryWidth - 2 * this.border - (this.buildingRow.entriesBuff.length - 1) * settings.margins; - + for (i = 0; i < this.buildingRow.entriesBuff.length; i++) { $entry = this.buildingRow.entriesBuff[i]; availableWidth -= $entry.data('jg.jwidth'); } - + if (settings.lastRow === 'center') offX += availableWidth / 2; else if (settings.lastRow === 'right') offX += availableWidth; } - + var lastEntryIdx = this.buildingRow.entriesBuff.length - 1; for (i = 0; i <= lastEntryIdx; i++) { $entry = this.buildingRow.entriesBuff[ this.settings.rtl ? lastEntryIdx - i : i ]; this.displayEntry($entry, offX, this.offY, $entry.data('jg.jwidth'), $entry.data('jg.jheight'), this.buildingRow.height); offX += $entry.data('jg.jwidth') + settings.margins; } - + //Gallery Height this.galleryHeightToSet = this.offY + this.buildingRow.height + this.border; this.setGalleryTempHeight(this.galleryHeightToSet + this.getSpinnerHeight()); - + if (!isLastRow || (this.buildingRow.height <= settings.rowHeight && buildingRowRes)) { //Ready for a new row this.offY += this.buildingRow.height + settings.margins; this.rows += 1; this.clearBuildingRow(); - this.$gallery.trigger('jg.rowflush'); + this.settings.triggerEvent.call(this, 'jg.rowflush'); } }; - - - // Scroll position not restoring: https://github.com/miromannino/Justified-Gallery/issues/221 + + + // Scroll position not restoring: https://github.com/miromannino/Justified-Gallery/issues/221 var galleryPrevStaticHeight = 0; - + JustifiedGallery.prototype.rememberGalleryHeight = function () { galleryPrevStaticHeight = this.$gallery.height(); this.$gallery.height(galleryPrevStaticHeight); }; - + // grow only JustifiedGallery.prototype.setGalleryTempHeight = function (height) { galleryPrevStaticHeight = Math.max(height, galleryPrevStaticHeight); this.$gallery.height(galleryPrevStaticHeight); }; - + JustifiedGallery.prototype.setGalleryFinalHeight = function (height) { galleryPrevStaticHeight = height; this.$gallery.height(height); }; - - + + /** + * @returns {boolean} a boolean saying if the scrollbar is active or not + */ + function hasScrollBar() { + return $("body").height() > $(window).height(); + } + /** * Checks the width of the gallery container, to know if a new justification is needed */ - var scrollBarOn = false; JustifiedGallery.prototype.checkWidth = function () { this.checkWidthIntervalId = setInterval($.proxy(function () { - + // if the gallery is not currently visible, abort. if (!this.$gallery.is(":visible")) return; - + var galleryWidth = parseFloat(this.$gallery.width()); - if (hasScrollBar() === scrollBarOn) { + if (hasScrollBar() === this.scrollBarOn) { if (Math.abs(galleryWidth - this.galleryWidth) > this.settings.refreshSensitivity) { this.galleryWidth = galleryWidth; this.rewind(); - + this.rememberGalleryHeight(); - + // Restart to analyze this.startImgAnalyzer(true); } } else { - scrollBarOn = hasScrollBar(); + this.scrollBarOn = hasScrollBar(); this.galleryWidth = galleryWidth; } }, this), this.settings.refreshTime); }; - + /** * @returns {boolean} a boolean saying if the spinner is active or not */ JustifiedGallery.prototype.isSpinnerActive = function () { return this.spinner.intervalId !== null; }; - + /** * @returns {int} the spinner height */ JustifiedGallery.prototype.getSpinnerHeight = function () { return this.spinner.$el.innerHeight(); }; - + /** * Stops the spinner animation and modify the gallery height to exclude the spinner */ @@ -514,7 +543,7 @@ this.setGalleryTempHeight(this.$gallery.height() - this.getSpinnerHeight()); this.spinner.$el.detach(); }; - + /** * Starts the spinner animation */ @@ -533,7 +562,7 @@ spinnerContext.phase = (spinnerContext.phase + 1) % ($spinnerPoints.length * 2); }, spinnerContext.timeSlot); }; - + /** * Rewind the image analysis to start from the first entry. */ @@ -544,7 +573,7 @@ this.rows = 0; this.clearBuildingRow(); }; - + /** * Update the entries searching it from the justified gallery HTML element * @@ -553,16 +582,16 @@ */ JustifiedGallery.prototype.updateEntries = function (norewind) { var newEntries; - + if (norewind && this.lastFetchedEntry != null) { newEntries = $(this.lastFetchedEntry).nextAll(this.settings.selector).toArray(); } else { this.entries = []; newEntries = this.$gallery.children(this.settings.selector).toArray(); } - + if (newEntries.length > 0) { - + // Sort or randomize if ($.isFunction(this.settings.sort)) { newEntries = this.sortArray(newEntries); @@ -570,20 +599,20 @@ newEntries = this.shuffleArray(newEntries); } this.lastFetchedEntry = newEntries[newEntries.length - 1]; - + // Filter if (this.settings.filter) { newEntries = this.filterArray(newEntries); } else { this.resetFilters(newEntries); } - + } - + this.entries = this.entries.concat(newEntries); return true; }; - + /** * Apply the entries order to the DOM, iterating the entries and appending the images * @@ -595,7 +624,7 @@ $(this).appendTo(that.$gallery); }); }; - + /** * Shuffle the array using the Fisher-Yates shuffle algorithm * @@ -613,7 +642,7 @@ this.insertToGallery(a); return a; }; - + /** * Sort the array using settings.comparator as comparator * @@ -625,7 +654,7 @@ this.insertToGallery(a); return a; }; - + /** * Reset the filters removing the 'jg-filtered' class from all the entries * @@ -634,7 +663,7 @@ JustifiedGallery.prototype.resetFilters = function (a) { for (var i = 0; i < a.length; i++) $(a[i]).removeClass('jg-filtered'); }; - + /** * Filter the entries considering theirs classes (if a string has been passed) or using a function for filtering. * @@ -668,7 +697,7 @@ return filteredArr; } }; - + /** * Destroy the Justified Gallery instance. * @@ -680,10 +709,10 @@ */ JustifiedGallery.prototype.destroy = function () { clearInterval(this.checkWidthIntervalId); - + $.each(this.entries, $.proxy(function(_, entry) { var $entry = $(entry); - + // Reset entry style $entry.css('width', ''); $entry.css('height', ''); @@ -691,7 +720,7 @@ $entry.css('left', ''); $entry.data('jg.loaded', undefined); $entry.removeClass('jg-entry'); - + // Reset image style var $img = this.imgFromEntry($entry); $img.css('width', ''); @@ -700,7 +729,7 @@ $img.css('margin-top', ''); $img.attr('src', $img.data('jg.originalSrc')); $img.data('jg.originalSrc', undefined); - + // Remove caption this.removeCaptionEventsHandlers($entry); var $caption = this.captionFromEntry($entry); @@ -711,14 +740,14 @@ } else { if ($caption !== null) $caption.fadeTo(0, 1); } - + }, this)); - + this.$gallery.css('height', ''); this.$gallery.removeClass('justified-gallery'); this.$gallery.data('jg.controller', undefined); }; - + /** * Analyze the images and builds the rows. It returns if it found an image that is not loaded. * @@ -733,41 +762,41 @@ var imgAspectRatio = $entry.data('jg.width') / $entry.data('jg.height'); if (availableWidth / (this.buildingRow.aspectRatio + imgAspectRatio) < this.settings.rowHeight) { this.flushRow(false); - + if(++this.yield.flushed >= this.yield.every) { this.startImgAnalyzer(isForResize); return; } } - + this.buildingRow.entriesBuff.push($entry); this.buildingRow.aspectRatio += imgAspectRatio; this.buildingRow.width += imgAspectRatio * this.settings.rowHeight; this.lastAnalyzedIndex = i; - + } else if ($entry.data('jg.loaded') !== 'error') { return; } } - + // Last row flush (the row is not full) if (this.buildingRow.entriesBuff.length > 0) this.flushRow(true); - + if (this.isSpinnerActive()) { this.stopLoadingSpinnerAnimation(); } - + /* Stop, if there is, the timeout to start the analyzeImages. This is because an image can be set loaded, and the timeout can be set, but this image can be analyzed yet. */ this.stopImgAnalyzerStarter(); - + //On complete callback - this.$gallery.trigger(isForResize ? 'jg.resize' : 'jg.complete'); + this.settings.triggerEvent.call(this, isForResize ? 'jg.resize' : 'jg.complete'); this.setGalleryFinalHeight(this.galleryHeightToSet); }; - + /** * Stops any ImgAnalyzer starter (that has an assigned timeout) */ @@ -778,7 +807,7 @@ this.imgAnalyzerTimeout = null; } }; - + /** * Starts the image analyzer. It is not immediately called to let the browser to update the view * @@ -791,7 +820,7 @@ that.analyzeImages(isForResize); }, 0.001); // we can't start it immediately due to a IE different behaviour }; - + /** * Checks if the image is loaded or not using another image object. We cannot use the 'complete' image property, * because some browsers, with a 404 set complete = true. @@ -802,7 +831,7 @@ */ JustifiedGallery.prototype.onImageEvent = function (imageSrc, onLoad, onError) { if (!onLoad && !onError) return; - + var memImage = new Image(); var $memImage = $(memImage); if (onLoad) { @@ -819,7 +848,7 @@ } memImage.src = imageSrc; }; - + /** * Init of Justified Gallery controlled * It analyzes all the entries starting theirs loading and calling the image analyzer (that works with loaded images) @@ -829,23 +858,23 @@ $.each(this.entries, function (index, entry) { var $entry = $(entry); var $image = that.imgFromEntry($entry); - + $entry.addClass('jg-entry'); - + if ($entry.data('jg.loaded') !== true && $entry.data('jg.loaded') !== 'skipped') { - + // Link Rel global overwrite if (that.settings.rel !== null) $entry.attr('rel', that.settings.rel); - + // Link Target global overwrite if (that.settings.target !== null) $entry.attr('target', that.settings.target); - + if ($image !== null) { - + // Image src var imageSrc = that.extractImgSrcFromImage($image); $image.attr('src', imageSrc); - + /* If we have the height and the width, we don't wait that the image is loaded, but we start directly * with the justification */ if (that.settings.waitThumbnailsLoad === false) { @@ -860,13 +889,13 @@ return true; // continue } } - + $entry.data('jg.loaded', false); imagesToLoad = true; - + // Spinner start if (!that.isSpinnerActive()) that.startLoadingSpinnerAnimation(); - + that.onImageEvent(imageSrc, function (loadImg) { // image loaded $entry.data('jg.width', loadImg.width); $entry.data('jg.height', loadImg.height); @@ -876,21 +905,21 @@ $entry.data('jg.loaded', 'error'); that.startImgAnalyzer(false); }); - + } else { $entry.data('jg.loaded', true); $entry.data('jg.width', $entry.width() | parseFloat($entry.css('width')) | 1); $entry.data('jg.height', $entry.height() | parseFloat($entry.css('height')) | 1); } - + } - + }); - + if (!imagesToLoad && !skippedImages) this.startImgAnalyzer(false); this.checkWidth(); }; - + /** * Checks that it is a valid number. If a string is passed it is converted to a number * @@ -901,14 +930,14 @@ if ($.type(settingContainer[settingName]) === 'string') { settingContainer[settingName] = parseFloat(settingContainer[settingName]); } - + if ($.type(settingContainer[settingName]) === 'number') { if (isNaN(settingContainer[settingName])) throw 'invalid number for ' + settingName; } else { throw settingName + ' must be a number'; } }; - + /** * Checks the sizeRangeSuffixes and, if necessary, converts * its keys from string (e.g. old settings with 'lt100') to int. @@ -917,12 +946,12 @@ if ($.type(this.settings.sizeRangeSuffixes) !== 'object') { throw 'sizeRangeSuffixes must be defined and must be an object'; } - + var suffixRanges = []; for (var rangeIdx in this.settings.sizeRangeSuffixes) { if (this.settings.sizeRangeSuffixes.hasOwnProperty(rangeIdx)) suffixRanges.push(rangeIdx); } - + var newSizeRngSuffixes = {0: ''}; for (var i = 0; i < suffixRanges.length; i++) { if ($.type(suffixRanges[i]) === 'string') { @@ -936,10 +965,10 @@ newSizeRngSuffixes[suffixRanges[i]] = this.settings.sizeRangeSuffixes[suffixRanges[i]]; } } - + this.settings.sizeRangeSuffixes = newSizeRngSuffixes; }; - + /** * check and convert the maxRowHeight setting * requires rowHeight to be already set @@ -949,7 +978,7 @@ JustifiedGallery.prototype.retrieveMaxRowHeight = function () { var newMaxRowHeight = null; var rowHeight = this.settings.rowHeight; - + if ($.type(this.settings.maxRowHeight) === 'string') { if (this.settings.maxRowHeight.match(/^[0-9]+%$/)) { newMaxRowHeight = rowHeight * parseFloat(this.settings.maxRowHeight.match(/^([0-9]+)%$/)[1]) / 100; @@ -963,26 +992,26 @@ } else { throw 'maxRowHeight must be a number or a percentage'; } - + // check if the converted value is not a number if (isNaN(newMaxRowHeight)) throw 'invalid number for maxRowHeight'; - + // check values, maxRowHeight must be >= rowHeight if (newMaxRowHeight < rowHeight) newMaxRowHeight = rowHeight; - + return newMaxRowHeight; }; - + /** * Checks the settings */ JustifiedGallery.prototype.checkSettings = function () { this.checkSizeRangesSuffixes(); - + this.checkOrConvertNumber(this.settings, 'rowHeight'); this.checkOrConvertNumber(this.settings, 'margins'); this.checkOrConvertNumber(this.settings, 'border'); - + var lastRowModes = [ 'justify', 'nojustify', @@ -994,7 +1023,7 @@ if (lastRowModes.indexOf(this.settings.lastRow) === -1) { throw 'lastRow must be one of: ' + lastRowModes.join(', '); } - + this.checkOrConvertNumber(this.settings, 'justifyThreshold'); if (this.settings.justifyThreshold < 0 || this.settings.justifyThreshold > 1) { throw 'justifyThreshold must be in the interval [0,1]'; @@ -1002,38 +1031,38 @@ if ($.type(this.settings.cssAnimation) !== 'boolean') { throw 'cssAnimation must be a boolean'; } - + if ($.type(this.settings.captions) !== 'boolean') throw 'captions must be a boolean'; this.checkOrConvertNumber(this.settings.captionSettings, 'animationDuration'); - + this.checkOrConvertNumber(this.settings.captionSettings, 'visibleOpacity'); if (this.settings.captionSettings.visibleOpacity < 0 || this.settings.captionSettings.visibleOpacity > 1) { throw 'captionSettings.visibleOpacity must be in the interval [0, 1]'; } - + this.checkOrConvertNumber(this.settings.captionSettings, 'nonVisibleOpacity'); if (this.settings.captionSettings.nonVisibleOpacity < 0 || this.settings.captionSettings.nonVisibleOpacity > 1) { throw 'captionSettings.nonVisibleOpacity must be in the interval [0, 1]'; } - + this.checkOrConvertNumber(this.settings, 'imagesAnimationDuration'); this.checkOrConvertNumber(this.settings, 'refreshTime'); this.checkOrConvertNumber(this.settings, 'refreshSensitivity'); if ($.type(this.settings.randomize) !== 'boolean') throw 'randomize must be a boolean'; if ($.type(this.settings.selector) !== 'string') throw 'selector must be a string'; - + if (this.settings.sort !== false && !$.isFunction(this.settings.sort)) { throw 'sort must be false or a comparison function'; } - + if (this.settings.filter !== false && !$.isFunction(this.settings.filter) && $.type(this.settings.filter) !== 'string') { throw 'filter must be false, a string or a filter function'; } }; - + /** * It brings all the indexes from the sizeRangeSuffixes and it orders them. They are then sorted and returned. * @returns {Array} sorted suffix ranges @@ -1046,7 +1075,7 @@ suffixRanges.sort(function (a, b) { return a > b ? 1 : a < b ? -1 : 0; }); return suffixRanges; }; - + /** * Update the existing settings only changing some of them * @@ -1056,63 +1085,15 @@ // In this case Justified Gallery has been called again changing only some options this.settings = $.extend({}, this.settings, newSettings); this.checkSettings(); - + // As reported in the settings: negative value = same as margins, 0 = disabled this.border = this.settings.border >= 0 ? this.settings.border : this.settings.margins; - + this.maxRowHeight = this.retrieveMaxRowHeight(); this.suffixRanges = this.retrieveSuffixRanges(); }; - - /** - * Justified Gallery plugin for jQuery - * - * Events - * - jg.complete : called when all the gallery has been created - * - jg.resize : called when the gallery has been resized - * - jg.rowflush : when a new row appears - * - * @param arg the action (or the settings) passed when the plugin is called - * @returns {*} the object itself - */ - $.fn.justifiedGallery = function (arg) { - return this.each(function (index, gallery) { - - var $gallery = $(gallery); - $gallery.addClass('justified-gallery'); - - var controller = $gallery.data('jg.controller'); - if (typeof controller === 'undefined') { - // Create controller and assign it to the object data - if (typeof arg !== 'undefined' && arg !== null && $.type(arg) !== 'object') { - if (arg === 'destroy') return; // Just a call to an unexisting object - throw 'The argument must be an object'; - } - controller = new JustifiedGallery($gallery, $.extend({}, $.fn.justifiedGallery.defaults, arg)); - $gallery.data('jg.controller', controller); - } else if (arg === 'norewind') { - // In this case we don't rewind: we analyze only the latest images (e.g. to complete the last unfinished row - // ... left to be more readable - } else if (arg === 'destroy') { - controller.destroy(); - return; - } else { - // In this case Justified Gallery has been called again changing only some options - controller.updateSettings(arg); - controller.rewind(); - } - - // Update the entries list - if (!controller.updateEntries(arg === 'norewind')) return; - - // Init justified gallery - controller.init(); - - }); - }; - - // Default options - $.fn.justifiedGallery.defaults = { + + JustifiedGallery.prototype.defaults = { sizeRangeSuffixes: { }, /* e.g. Flickr configuration { 100: '_t', // used when longest is less than 100px @@ -1132,9 +1113,9 @@ // can't exceed 3 * rowHeight) margins: 1, border: -1, // negative value = same as margins, 0 = disabled, any other value to set the border - + lastRow: 'nojustify', // … which is the same as 'left', or can be 'justify', 'center', 'right' or 'hide' - + justifyThreshold: 0.90, /* if row width / available space > 0.90 it will be always justified * (i.e. lastRow setting is not considered) */ waitThumbnailsLoad: true, @@ -1165,7 +1146,57 @@ It follows the specifications of the Array.prototype.filter() function of JavaScript. */ selector: 'a, div:not(.spinner)', // The selector that is used to know what are the entries of the gallery - imgSelector: '> img, > a > img' // The selector that is used to know what are the images of each entry + imgSelector: '> img, > a > img', // The selector that is used to know what are the images of each entry + triggerEvent: function (event) { // This is called to trigger events, the default behavior is to call $.trigger + this.$gallery.trigger(event); // Consider that 'this' is this set to the JustifiedGallery object, so it can + } // access to fields such as $gallery, useful to trigger events with jQuery. + }; + + /** + * Justified Gallery plugin for jQuery + * + * Events + * - jg.complete : called when all the gallery has been created + * - jg.resize : called when the gallery has been resized + * - jg.rowflush : when a new row appears + * + * @param arg the action (or the settings) passed when the plugin is called + * @returns {*} the object itself + */ + $.fn.justifiedGallery = function (arg) { + return this.each(function (index, gallery) { + + var $gallery = $(gallery); + $gallery.addClass('justified-gallery'); + + var controller = $gallery.data('jg.controller'); + if (typeof controller === 'undefined') { + // Create controller and assign it to the object data + if (typeof arg !== 'undefined' && arg !== null && $.type(arg) !== 'object') { + if (arg === 'destroy') return; // Just a call to an unexisting object + throw 'The argument must be an object'; + } + controller = new JustifiedGallery($gallery, $.extend({}, JustifiedGallery.prototype.defaults, arg)); + $gallery.data('jg.controller', controller); + } else if (arg === 'norewind') { + // In this case we don't rewind: we analyze only the latest images (e.g. to complete the last unfinished row + // ... left to be more readable + } else if (arg === 'destroy') { + controller.destroy(); + return; + } else { + // In this case Justified Gallery has been called again changing only some options + controller.updateSettings(arg); + controller.rewind(); + } + + // Update the entries list + if (!controller.updateEntries(arg === 'norewind')) return; + + // Init justified gallery + controller.init(); + + }); }; -}(jQuery)); +}));
\ No newline at end of file diff --git a/library/justifiedGallery/jquery.justifiedGallery.min.js b/library/justifiedGallery/jquery.justifiedGallery.min.js index 87519987b..bda51a188 100644 --- a/library/justifiedGallery/jquery.justifiedGallery.min.js +++ b/library/justifiedGallery/jquery.justifiedGallery.min.js @@ -1,7 +1,8 @@ /*! - * Justified Gallery - v3.6.5 + * justifiedGallery - v3.7.0 * http://miromannino.github.io/Justified-Gallery/ * Copyright (c) 2018 Miro Mannino * Licensed under the MIT license. */ -!function(a){function b(){return a("body").height()>a(window).height()}var c=function(b,c){this.settings=c,this.checkSettings(),this.imgAnalyzerTimeout=null,this.entries=null,this.buildingRow={entriesBuff:[],width:0,height:0,aspectRatio:0},this.lastFetchedEntry=null,this.lastAnalyzedIndex=-1,this.yield={every:2,flushed:0},this.border=c.border>=0?c.border:c.margins,this.maxRowHeight=this.retrieveMaxRowHeight(),this.suffixRanges=this.retrieveSuffixRanges(),this.offY=this.border,this.rows=0,this.spinner={phase:0,timeSlot:150,$el:a('<div class="spinner"><span></span><span></span><span></span></div>'),intervalId:null},this.checkWidthIntervalId=null,this.galleryWidth=b.width(),this.$gallery=b};c.prototype.getSuffix=function(a,b){var c,d;for(c=a>b?a:b,d=0;d<this.suffixRanges.length;d++)if(c<=this.suffixRanges[d])return this.settings.sizeRangeSuffixes[this.suffixRanges[d]];return this.settings.sizeRangeSuffixes[this.suffixRanges[d-1]]},c.prototype.removeSuffix=function(a,b){return a.substring(0,a.length-b.length)},c.prototype.endsWith=function(a,b){return-1!==a.indexOf(b,a.length-b.length)},c.prototype.getUsedSuffix=function(a){for(var b in this.settings.sizeRangeSuffixes)if(this.settings.sizeRangeSuffixes.hasOwnProperty(b)){if(0===this.settings.sizeRangeSuffixes[b].length)continue;if(this.endsWith(a,this.settings.sizeRangeSuffixes[b]))return this.settings.sizeRangeSuffixes[b]}return""},c.prototype.newSrc=function(a,b,c,d){var e;if(this.settings.thumbnailPath)e=this.settings.thumbnailPath(a,b,c,d);else{var f=a.match(this.settings.extension),g=null!==f?f[0]:"";e=a.replace(this.settings.extension,""),e=this.removeSuffix(e,this.getUsedSuffix(e)),e+=this.getSuffix(b,c)+g}return e},c.prototype.showImg=function(a,b){this.settings.cssAnimation?(a.addClass("entry-visible"),b&&b()):(a.stop().fadeTo(this.settings.imagesAnimationDuration,1,b),a.find(this.settings.imgSelector).stop().fadeTo(this.settings.imagesAnimationDuration,1,b))},c.prototype.extractImgSrcFromImage=function(a){var b="undefined"!=typeof a.data("safe-src")?a.data("safe-src"):a.attr("src");return a.data("jg.originalSrc",b),b},c.prototype.imgFromEntry=function(a){var b=a.find(this.settings.imgSelector);return 0===b.length?null:b},c.prototype.captionFromEntry=function(a){var b=a.find("> .caption");return 0===b.length?null:b},c.prototype.displayEntry=function(b,c,d,e,f,g){b.width(e),b.height(g),b.css("top",d),b.css("left",c);var h=this.imgFromEntry(b);if(null!==h){h.css("width",e),h.css("height",f),h.css("margin-left",-e/2),h.css("margin-top",-f/2);var i=h.attr("src"),j=this.newSrc(i,e,f,h[0]);h.one("error",function(){h.attr("src",h.data("jg.originalSrc"))});var k=function(){i!==j&&h.attr("src",j)};"skipped"===b.data("jg.loaded")?this.onImageEvent(i,a.proxy(function(){this.showImg(b,k),b.data("jg.loaded",!0)},this)):this.showImg(b,k)}else this.showImg(b);this.displayEntryCaption(b)},c.prototype.displayEntryCaption=function(b){var c=this.imgFromEntry(b);if(null!==c&&this.settings.captions){var d=this.captionFromEntry(b);if(null===d){var e=c.attr("alt");this.isValidCaption(e)||(e=b.attr("title")),this.isValidCaption(e)&&(d=a('<div class="caption">'+e+"</div>"),b.append(d),b.data("jg.createdCaption",!0))}null!==d&&(this.settings.cssAnimation||d.stop().fadeTo(0,this.settings.captionSettings.nonVisibleOpacity),this.addCaptionEventsHandlers(b))}else this.removeCaptionEventsHandlers(b)},c.prototype.isValidCaption=function(a){return"undefined"!=typeof a&&a.length>0},c.prototype.onEntryMouseEnterForCaption=function(b){var c=this.captionFromEntry(a(b.currentTarget));this.settings.cssAnimation?c.addClass("caption-visible").removeClass("caption-hidden"):c.stop().fadeTo(this.settings.captionSettings.animationDuration,this.settings.captionSettings.visibleOpacity)},c.prototype.onEntryMouseLeaveForCaption=function(b){var c=this.captionFromEntry(a(b.currentTarget));this.settings.cssAnimation?c.removeClass("caption-visible").removeClass("caption-hidden"):c.stop().fadeTo(this.settings.captionSettings.animationDuration,this.settings.captionSettings.nonVisibleOpacity)},c.prototype.addCaptionEventsHandlers=function(b){var c=b.data("jg.captionMouseEvents");"undefined"==typeof c&&(c={mouseenter:a.proxy(this.onEntryMouseEnterForCaption,this),mouseleave:a.proxy(this.onEntryMouseLeaveForCaption,this)},b.on("mouseenter",void 0,void 0,c.mouseenter),b.on("mouseleave",void 0,void 0,c.mouseleave),b.data("jg.captionMouseEvents",c))},c.prototype.removeCaptionEventsHandlers=function(a){var b=a.data("jg.captionMouseEvents");"undefined"!=typeof b&&(a.off("mouseenter",void 0,b.mouseenter),a.off("mouseleave",void 0,b.mouseleave),a.removeData("jg.captionMouseEvents"))},c.prototype.clearBuildingRow=function(){this.buildingRow.entriesBuff=[],this.buildingRow.aspectRatio=0,this.buildingRow.width=0},c.prototype.prepareBuildingRow=function(a){var b,c,d,e,f,g=!0,h=0,i=this.galleryWidth-2*this.border-(this.buildingRow.entriesBuff.length-1)*this.settings.margins,j=i/this.buildingRow.aspectRatio,k=this.settings.rowHeight,l=this.buildingRow.width/i>this.settings.justifyThreshold;if(a&&"hide"===this.settings.lastRow&&!l){for(b=0;b<this.buildingRow.entriesBuff.length;b++)c=this.buildingRow.entriesBuff[b],this.settings.cssAnimation?c.removeClass("entry-visible"):(c.stop().fadeTo(0,.1),c.find("> img, > a > img").fadeTo(0,0));return-1}for(a&&!l&&"justify"!==this.settings.lastRow&&"hide"!==this.settings.lastRow&&(g=!1,this.rows>0&&(k=(this.offY-this.border-this.settings.margins*this.rows)/this.rows,g=k*this.buildingRow.aspectRatio/i>this.settings.justifyThreshold)),b=0;b<this.buildingRow.entriesBuff.length;b++)c=this.buildingRow.entriesBuff[b],d=c.data("jg.width")/c.data("jg.height"),g?(e=b===this.buildingRow.entriesBuff.length-1?i:j*d,f=j):(e=k*d,f=k),i-=Math.round(e),c.data("jg.jwidth",Math.round(e)),c.data("jg.jheight",Math.ceil(f)),(0===b||h>f)&&(h=f);return this.buildingRow.height=h,g},c.prototype.flushRow=function(a){var b,c,d,e=this.settings,f=this.border;if(c=this.prepareBuildingRow(a),a&&"hide"===e.lastRow&&-1===c)return void this.clearBuildingRow();if(this.maxRowHeight&&this.maxRowHeight<this.buildingRow.height&&(this.buildingRow.height=this.maxRowHeight),a&&("center"===e.lastRow||"right"===e.lastRow)){var g=this.galleryWidth-2*this.border-(this.buildingRow.entriesBuff.length-1)*e.margins;for(d=0;d<this.buildingRow.entriesBuff.length;d++)b=this.buildingRow.entriesBuff[d],g-=b.data("jg.jwidth");"center"===e.lastRow?f+=g/2:"right"===e.lastRow&&(f+=g)}var h=this.buildingRow.entriesBuff.length-1;for(d=0;h>=d;d++)b=this.buildingRow.entriesBuff[this.settings.rtl?h-d:d],this.displayEntry(b,f,this.offY,b.data("jg.jwidth"),b.data("jg.jheight"),this.buildingRow.height),f+=b.data("jg.jwidth")+e.margins;this.galleryHeightToSet=this.offY+this.buildingRow.height+this.border,this.setGalleryTempHeight(this.galleryHeightToSet+this.getSpinnerHeight()),(!a||this.buildingRow.height<=e.rowHeight&&c)&&(this.offY+=this.buildingRow.height+e.margins,this.rows+=1,this.clearBuildingRow(),this.$gallery.trigger("jg.rowflush"))};var d=0;c.prototype.rememberGalleryHeight=function(){d=this.$gallery.height(),this.$gallery.height(d)},c.prototype.setGalleryTempHeight=function(a){d=Math.max(a,d),this.$gallery.height(d)},c.prototype.setGalleryFinalHeight=function(a){d=a,this.$gallery.height(a)};var e=!1;c.prototype.checkWidth=function(){this.checkWidthIntervalId=setInterval(a.proxy(function(){if(this.$gallery.is(":visible")){var a=parseFloat(this.$gallery.width());b()===e?Math.abs(a-this.galleryWidth)>this.settings.refreshSensitivity&&(this.galleryWidth=a,this.rewind(),this.rememberGalleryHeight(),this.startImgAnalyzer(!0)):(e=b(),this.galleryWidth=a)}},this),this.settings.refreshTime)},c.prototype.isSpinnerActive=function(){return null!==this.spinner.intervalId},c.prototype.getSpinnerHeight=function(){return this.spinner.$el.innerHeight()},c.prototype.stopLoadingSpinnerAnimation=function(){clearInterval(this.spinner.intervalId),this.spinner.intervalId=null,this.setGalleryTempHeight(this.$gallery.height()-this.getSpinnerHeight()),this.spinner.$el.detach()},c.prototype.startLoadingSpinnerAnimation=function(){var a=this.spinner,b=a.$el.find("span");clearInterval(a.intervalId),this.$gallery.append(a.$el),this.setGalleryTempHeight(this.offY+this.buildingRow.height+this.getSpinnerHeight()),a.intervalId=setInterval(function(){a.phase<b.length?b.eq(a.phase).fadeTo(a.timeSlot,1):b.eq(a.phase-b.length).fadeTo(a.timeSlot,0),a.phase=(a.phase+1)%(2*b.length)},a.timeSlot)},c.prototype.rewind=function(){this.lastFetchedEntry=null,this.lastAnalyzedIndex=-1,this.offY=this.border,this.rows=0,this.clearBuildingRow()},c.prototype.updateEntries=function(b){var c;return b&&null!=this.lastFetchedEntry?c=a(this.lastFetchedEntry).nextAll(this.settings.selector).toArray():(this.entries=[],c=this.$gallery.children(this.settings.selector).toArray()),c.length>0&&(a.isFunction(this.settings.sort)?c=this.sortArray(c):this.settings.randomize&&(c=this.shuffleArray(c)),this.lastFetchedEntry=c[c.length-1],this.settings.filter?c=this.filterArray(c):this.resetFilters(c)),this.entries=this.entries.concat(c),!0},c.prototype.insertToGallery=function(b){var c=this;a.each(b,function(){a(this).appendTo(c.$gallery)})},c.prototype.shuffleArray=function(a){var b,c,d;for(b=a.length-1;b>0;b--)c=Math.floor(Math.random()*(b+1)),d=a[b],a[b]=a[c],a[c]=d;return this.insertToGallery(a),a},c.prototype.sortArray=function(a){return a.sort(this.settings.sort),this.insertToGallery(a),a},c.prototype.resetFilters=function(b){for(var c=0;c<b.length;c++)a(b[c]).removeClass("jg-filtered")},c.prototype.filterArray=function(b){var c=this.settings;if("string"===a.type(c.filter))return b.filter(function(b){var d=a(b);return d.is(c.filter)?(d.removeClass("jg-filtered"),!0):(d.addClass("jg-filtered").removeClass("jg-visible"),!1)});if(a.isFunction(c.filter)){for(var d=b.filter(c.filter),e=0;e<b.length;e++)-1===d.indexOf(b[e])?a(b[e]).addClass("jg-filtered").removeClass("jg-visible"):a(b[e]).removeClass("jg-filtered");return d}},c.prototype.destroy=function(){clearInterval(this.checkWidthIntervalId),a.each(this.entries,a.proxy(function(b,c){var d=a(c);d.css("width",""),d.css("height",""),d.css("top",""),d.css("left",""),d.data("jg.loaded",void 0),d.removeClass("jg-entry");var e=this.imgFromEntry(d);e.css("width",""),e.css("height",""),e.css("margin-left",""),e.css("margin-top",""),e.attr("src",e.data("jg.originalSrc")),e.data("jg.originalSrc",void 0),this.removeCaptionEventsHandlers(d);var f=this.captionFromEntry(d);d.data("jg.createdCaption")?(d.data("jg.createdCaption",void 0),null!==f&&f.remove()):null!==f&&f.fadeTo(0,1)},this)),this.$gallery.css("height",""),this.$gallery.removeClass("justified-gallery"),this.$gallery.data("jg.controller",void 0)},c.prototype.analyzeImages=function(b){for(var c=this.lastAnalyzedIndex+1;c<this.entries.length;c++){var d=a(this.entries[c]);if(d.data("jg.loaded")===!0||"skipped"===d.data("jg.loaded")){var e=this.galleryWidth-2*this.border-(this.buildingRow.entriesBuff.length-1)*this.settings.margins,f=d.data("jg.width")/d.data("jg.height");if(e/(this.buildingRow.aspectRatio+f)<this.settings.rowHeight&&(this.flushRow(!1),++this.yield.flushed>=this.yield.every))return void this.startImgAnalyzer(b);this.buildingRow.entriesBuff.push(d),this.buildingRow.aspectRatio+=f,this.buildingRow.width+=f*this.settings.rowHeight,this.lastAnalyzedIndex=c}else if("error"!==d.data("jg.loaded"))return}this.buildingRow.entriesBuff.length>0&&this.flushRow(!0),this.isSpinnerActive()&&this.stopLoadingSpinnerAnimation(),this.stopImgAnalyzerStarter(),this.$gallery.trigger(b?"jg.resize":"jg.complete"),this.setGalleryFinalHeight(this.galleryHeightToSet)},c.prototype.stopImgAnalyzerStarter=function(){this.yield.flushed=0,null!==this.imgAnalyzerTimeout&&(clearTimeout(this.imgAnalyzerTimeout),this.imgAnalyzerTimeout=null)},c.prototype.startImgAnalyzer=function(a){var b=this;this.stopImgAnalyzerStarter(),this.imgAnalyzerTimeout=setTimeout(function(){b.analyzeImages(a)},.001)},c.prototype.onImageEvent=function(b,c,d){if(c||d){var e=new Image,f=a(e);c&&f.one("load",function(){f.off("load error"),c(e)}),d&&f.one("error",function(){f.off("load error"),d(e)}),e.src=b}},c.prototype.init=function(){var b=!1,c=!1,d=this;a.each(this.entries,function(e,f){var g=a(f),h=d.imgFromEntry(g);if(g.addClass("jg-entry"),g.data("jg.loaded")!==!0&&"skipped"!==g.data("jg.loaded"))if(null!==d.settings.rel&&g.attr("rel",d.settings.rel),null!==d.settings.target&&g.attr("target",d.settings.target),null!==h){var i=d.extractImgSrcFromImage(h);if(h.attr("src",i),d.settings.waitThumbnailsLoad===!1){var j=parseFloat(h.prop("width")),k=parseFloat(h.prop("height"));if(!isNaN(j)&&!isNaN(k))return g.data("jg.width",j),g.data("jg.height",k),g.data("jg.loaded","skipped"),c=!0,d.startImgAnalyzer(!1),!0}g.data("jg.loaded",!1),b=!0,d.isSpinnerActive()||d.startLoadingSpinnerAnimation(),d.onImageEvent(i,function(a){g.data("jg.width",a.width),g.data("jg.height",a.height),g.data("jg.loaded",!0),d.startImgAnalyzer(!1)},function(){g.data("jg.loaded","error"),d.startImgAnalyzer(!1)})}else g.data("jg.loaded",!0),g.data("jg.width",g.width()|parseFloat(g.css("width"))|1),g.data("jg.height",g.height()|parseFloat(g.css("height"))|1)}),b||c||this.startImgAnalyzer(!1),this.checkWidth()},c.prototype.checkOrConvertNumber=function(b,c){if("string"===a.type(b[c])&&(b[c]=parseFloat(b[c])),"number"!==a.type(b[c]))throw c+" must be a number";if(isNaN(b[c]))throw"invalid number for "+c},c.prototype.checkSizeRangesSuffixes=function(){if("object"!==a.type(this.settings.sizeRangeSuffixes))throw"sizeRangeSuffixes must be defined and must be an object";var b=[];for(var c in this.settings.sizeRangeSuffixes)this.settings.sizeRangeSuffixes.hasOwnProperty(c)&&b.push(c);for(var d={0:""},e=0;e<b.length;e++)if("string"===a.type(b[e]))try{var f=parseInt(b[e].replace(/^[a-z]+/,""),10);d[f]=this.settings.sizeRangeSuffixes[b[e]]}catch(g){throw"sizeRangeSuffixes keys must contains correct numbers ("+g+")"}else d[b[e]]=this.settings.sizeRangeSuffixes[b[e]];this.settings.sizeRangeSuffixes=d},c.prototype.retrieveMaxRowHeight=function(){var b=null,c=this.settings.rowHeight;if("string"===a.type(this.settings.maxRowHeight))b=this.settings.maxRowHeight.match(/^[0-9]+%$/)?c*parseFloat(this.settings.maxRowHeight.match(/^([0-9]+)%$/)[1])/100:parseFloat(this.settings.maxRowHeight);else{if("number"!==a.type(this.settings.maxRowHeight)){if(this.settings.maxRowHeight===!1||null==this.settings.maxRowHeight)return null;throw"maxRowHeight must be a number or a percentage"}b=this.settings.maxRowHeight}if(isNaN(b))throw"invalid number for maxRowHeight";return c>b&&(b=c),b},c.prototype.checkSettings=function(){this.checkSizeRangesSuffixes(),this.checkOrConvertNumber(this.settings,"rowHeight"),this.checkOrConvertNumber(this.settings,"margins"),this.checkOrConvertNumber(this.settings,"border");var b=["justify","nojustify","left","center","right","hide"];if(-1===b.indexOf(this.settings.lastRow))throw"lastRow must be one of: "+b.join(", ");if(this.checkOrConvertNumber(this.settings,"justifyThreshold"),this.settings.justifyThreshold<0||this.settings.justifyThreshold>1)throw"justifyThreshold must be in the interval [0,1]";if("boolean"!==a.type(this.settings.cssAnimation))throw"cssAnimation must be a boolean";if("boolean"!==a.type(this.settings.captions))throw"captions must be a boolean";if(this.checkOrConvertNumber(this.settings.captionSettings,"animationDuration"),this.checkOrConvertNumber(this.settings.captionSettings,"visibleOpacity"),this.settings.captionSettings.visibleOpacity<0||this.settings.captionSettings.visibleOpacity>1)throw"captionSettings.visibleOpacity must be in the interval [0, 1]";if(this.checkOrConvertNumber(this.settings.captionSettings,"nonVisibleOpacity"),this.settings.captionSettings.nonVisibleOpacity<0||this.settings.captionSettings.nonVisibleOpacity>1)throw"captionSettings.nonVisibleOpacity must be in the interval [0, 1]";if(this.checkOrConvertNumber(this.settings,"imagesAnimationDuration"),this.checkOrConvertNumber(this.settings,"refreshTime"),this.checkOrConvertNumber(this.settings,"refreshSensitivity"),"boolean"!==a.type(this.settings.randomize))throw"randomize must be a boolean";if("string"!==a.type(this.settings.selector))throw"selector must be a string";if(this.settings.sort!==!1&&!a.isFunction(this.settings.sort))throw"sort must be false or a comparison function";if(this.settings.filter!==!1&&!a.isFunction(this.settings.filter)&&"string"!==a.type(this.settings.filter))throw"filter must be false, a string or a filter function"},c.prototype.retrieveSuffixRanges=function(){var a=[];for(var b in this.settings.sizeRangeSuffixes)this.settings.sizeRangeSuffixes.hasOwnProperty(b)&&a.push(parseInt(b,10));return a.sort(function(a,b){return a>b?1:b>a?-1:0}),a},c.prototype.updateSettings=function(b){this.settings=a.extend({},this.settings,b),this.checkSettings(),this.border=this.settings.border>=0?this.settings.border:this.settings.margins,this.maxRowHeight=this.retrieveMaxRowHeight(),this.suffixRanges=this.retrieveSuffixRanges()},a.fn.justifiedGallery=function(b){return this.each(function(d,e){var f=a(e);f.addClass("justified-gallery");var g=f.data("jg.controller");if("undefined"==typeof g){if("undefined"!=typeof b&&null!==b&&"object"!==a.type(b)){if("destroy"===b)return;throw"The argument must be an object"}g=new c(f,a.extend({},a.fn.justifiedGallery.defaults,b)),f.data("jg.controller",g)}else if("norewind"===b);else{if("destroy"===b)return void g.destroy();g.updateSettings(b),g.rewind()}g.updateEntries("norewind"===b)&&g.init()})},a.fn.justifiedGallery.defaults={sizeRangeSuffixes:{},thumbnailPath:void 0,rowHeight:120,maxRowHeight:!1,margins:1,border:-1,lastRow:"nojustify",justifyThreshold:.9,waitThumbnailsLoad:!0,captions:!0,cssAnimation:!0,imagesAnimationDuration:500,captionSettings:{animationDuration:500,visibleOpacity:.7,nonVisibleOpacity:0},rel:null,target:null,extension:/\.[^.\\/]+$/,refreshTime:200,refreshSensitivity:0,randomize:!1,rtl:!1,sort:!1,filter:!1,selector:"a, div:not(.spinner)",imgSelector:"> img, > a > img"}}(jQuery);
\ No newline at end of file + +!function(e){"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof module&&module.exports?module.exports=function(t,i){return void 0===i&&(i="undefined"!=typeof window?require("jquery"):require("jquery")(t)),e(i),i}:e(jQuery)}(function(g){var r=function(t,i){this.settings=i,this.checkSettings(),this.imgAnalyzerTimeout=null,this.entries=null,this.buildingRow={entriesBuff:[],width:0,height:0,aspectRatio:0},this.lastFetchedEntry=null,this.lastAnalyzedIndex=-1,this.yield={every:2,flushed:0},this.border=0<=i.border?i.border:i.margins,this.maxRowHeight=this.retrieveMaxRowHeight(),this.suffixRanges=this.retrieveSuffixRanges(),this.offY=this.border,this.rows=0,this.spinner={phase:0,timeSlot:150,$el:g('<div class="spinner"><span></span><span></span><span></span></div>'),intervalId:null},this.scrollBarOn=!1,this.checkWidthIntervalId=null,this.galleryWidth=t.width(),this.$gallery=t};r.prototype.getSuffix=function(t,i){var e,s;for(e=i<t?t:i,s=0;s<this.suffixRanges.length;s++)if(e<=this.suffixRanges[s])return this.settings.sizeRangeSuffixes[this.suffixRanges[s]];return this.settings.sizeRangeSuffixes[this.suffixRanges[s-1]]},r.prototype.removeSuffix=function(t,i){return t.substring(0,t.length-i.length)},r.prototype.endsWith=function(t,i){return-1!==t.indexOf(i,t.length-i.length)},r.prototype.getUsedSuffix=function(t){for(var i in this.settings.sizeRangeSuffixes)if(this.settings.sizeRangeSuffixes.hasOwnProperty(i)){if(0===this.settings.sizeRangeSuffixes[i].length)continue;if(this.endsWith(t,this.settings.sizeRangeSuffixes[i]))return this.settings.sizeRangeSuffixes[i]}return""},r.prototype.newSrc=function(t,i,e,s){var n;if(this.settings.thumbnailPath)n=this.settings.thumbnailPath(t,i,e,s);else{var r=t.match(this.settings.extension),o=null!==r?r[0]:"";n=t.replace(this.settings.extension,""),n=this.removeSuffix(n,this.getUsedSuffix(n)),n+=this.getSuffix(i,e)+o}return n},r.prototype.showImg=function(t,i){this.settings.cssAnimation?(t.addClass("entry-visible"),i&&i()):(t.stop().fadeTo(this.settings.imagesAnimationDuration,1,i),t.find(this.settings.imgSelector).stop().fadeTo(this.settings.imagesAnimationDuration,1,i))},r.prototype.extractImgSrcFromImage=function(t){var i=void 0!==t.data("safe-src")?t.data("safe-src"):t.attr("src");return t.data("jg.originalSrc",i),i},r.prototype.imgFromEntry=function(t){var i=t.find(this.settings.imgSelector);return 0===i.length?null:i},r.prototype.captionFromEntry=function(t){var i=t.find("> .caption");return 0===i.length?null:i},r.prototype.displayEntry=function(t,i,e,s,n,r){t.width(s),t.height(r),t.css("top",e),t.css("left",i);var o=this.imgFromEntry(t);if(null!==o){o.css("width",s),o.css("height",n),o.css("margin-left",-s/2),o.css("margin-top",-n/2);var a=o.attr("src"),h=this.newSrc(a,s,n,o[0]);o.one("error",function(){o.attr("src",o.data("jg.originalSrc"))});var l=function(){a!==h&&o.attr("src",h)};"skipped"===t.data("jg.loaded")?this.onImageEvent(a,g.proxy(function(){this.showImg(t,l),t.data("jg.loaded",!0)},this)):this.showImg(t,l)}else this.showImg(t);this.displayEntryCaption(t)},r.prototype.displayEntryCaption=function(t){var i=this.imgFromEntry(t);if(null!==i&&this.settings.captions){var e=this.captionFromEntry(t);if(null===e){var s=i.attr("alt");this.isValidCaption(s)||(s=t.attr("title")),this.isValidCaption(s)&&(e=g('<div class="caption">'+s+"</div>"),t.append(e),t.data("jg.createdCaption",!0))}null!==e&&(this.settings.cssAnimation||e.stop().fadeTo(0,this.settings.captionSettings.nonVisibleOpacity),this.addCaptionEventsHandlers(t))}else this.removeCaptionEventsHandlers(t)},r.prototype.isValidCaption=function(t){return void 0!==t&&0<t.length},r.prototype.onEntryMouseEnterForCaption=function(t){var i=this.captionFromEntry(g(t.currentTarget));this.settings.cssAnimation?i.addClass("caption-visible").removeClass("caption-hidden"):i.stop().fadeTo(this.settings.captionSettings.animationDuration,this.settings.captionSettings.visibleOpacity)},r.prototype.onEntryMouseLeaveForCaption=function(t){var i=this.captionFromEntry(g(t.currentTarget));this.settings.cssAnimation?i.removeClass("caption-visible").removeClass("caption-hidden"):i.stop().fadeTo(this.settings.captionSettings.animationDuration,this.settings.captionSettings.nonVisibleOpacity)},r.prototype.addCaptionEventsHandlers=function(t){var i=t.data("jg.captionMouseEvents");void 0===i&&(i={mouseenter:g.proxy(this.onEntryMouseEnterForCaption,this),mouseleave:g.proxy(this.onEntryMouseLeaveForCaption,this)},t.on("mouseenter",void 0,void 0,i.mouseenter),t.on("mouseleave",void 0,void 0,i.mouseleave),t.data("jg.captionMouseEvents",i))},r.prototype.removeCaptionEventsHandlers=function(t){var i=t.data("jg.captionMouseEvents");void 0!==i&&(t.off("mouseenter",void 0,i.mouseenter),t.off("mouseleave",void 0,i.mouseleave),t.removeData("jg.captionMouseEvents"))},r.prototype.clearBuildingRow=function(){this.buildingRow.entriesBuff=[],this.buildingRow.aspectRatio=0,this.buildingRow.width=0},r.prototype.prepareBuildingRow=function(t){var i,e,s,n,r,o=!0,a=0,h=this.galleryWidth-2*this.border-(this.buildingRow.entriesBuff.length-1)*this.settings.margins,l=h/this.buildingRow.aspectRatio,g=this.settings.rowHeight,u=this.buildingRow.width/h>this.settings.justifyThreshold;if(t&&"hide"===this.settings.lastRow&&!u){for(i=0;i<this.buildingRow.entriesBuff.length;i++)e=this.buildingRow.entriesBuff[i],this.settings.cssAnimation?e.removeClass("entry-visible"):(e.stop().fadeTo(0,.1),e.find("> img, > a > img").fadeTo(0,0));return-1}for(t&&!u&&"justify"!==this.settings.lastRow&&"hide"!==this.settings.lastRow&&(o=!1,0<this.rows&&(o=(g=(this.offY-this.border-this.settings.margins*this.rows)/this.rows)*this.buildingRow.aspectRatio/h>this.settings.justifyThreshold)),i=0;i<this.buildingRow.entriesBuff.length;i++)s=(e=this.buildingRow.entriesBuff[i]).data("jg.width")/e.data("jg.height"),o?(n=i===this.buildingRow.entriesBuff.length-1?h:l*s,r=l):(n=g*s,r=g),h-=Math.round(n),e.data("jg.jwidth",Math.round(n)),e.data("jg.jheight",Math.ceil(r)),(0===i||r<a)&&(a=r);return this.buildingRow.height=a,o},r.prototype.flushRow=function(t){var i,e,s,n=this.settings,r=this.border;if(e=this.prepareBuildingRow(t),t&&"hide"===n.lastRow&&-1===e)this.clearBuildingRow();else{if(this.maxRowHeight&&this.maxRowHeight<this.buildingRow.height&&(this.buildingRow.height=this.maxRowHeight),t&&("center"===n.lastRow||"right"===n.lastRow)){var o=this.galleryWidth-2*this.border-(this.buildingRow.entriesBuff.length-1)*n.margins;for(s=0;s<this.buildingRow.entriesBuff.length;s++)o-=(i=this.buildingRow.entriesBuff[s]).data("jg.jwidth");"center"===n.lastRow?r+=o/2:"right"===n.lastRow&&(r+=o)}var a=this.buildingRow.entriesBuff.length-1;for(s=0;s<=a;s++)i=this.buildingRow.entriesBuff[this.settings.rtl?a-s:s],this.displayEntry(i,r,this.offY,i.data("jg.jwidth"),i.data("jg.jheight"),this.buildingRow.height),r+=i.data("jg.jwidth")+n.margins;this.galleryHeightToSet=this.offY+this.buildingRow.height+this.border,this.setGalleryTempHeight(this.galleryHeightToSet+this.getSpinnerHeight()),(!t||this.buildingRow.height<=n.rowHeight&&e)&&(this.offY+=this.buildingRow.height+n.margins,this.rows+=1,this.clearBuildingRow(),this.settings.triggerEvent.call(this,"jg.rowflush"))}};var i=0;function e(){return g("body").height()>g(window).height()}r.prototype.rememberGalleryHeight=function(){i=this.$gallery.height(),this.$gallery.height(i)},r.prototype.setGalleryTempHeight=function(t){i=Math.max(t,i),this.$gallery.height(i)},r.prototype.setGalleryFinalHeight=function(t){i=t,this.$gallery.height(t)},r.prototype.checkWidth=function(){this.checkWidthIntervalId=setInterval(g.proxy(function(){if(this.$gallery.is(":visible")){var t=parseFloat(this.$gallery.width());e()===this.scrollBarOn?Math.abs(t-this.galleryWidth)>this.settings.refreshSensitivity&&(this.galleryWidth=t,this.rewind(),this.rememberGalleryHeight(),this.startImgAnalyzer(!0)):(this.scrollBarOn=e(),this.galleryWidth=t)}},this),this.settings.refreshTime)},r.prototype.isSpinnerActive=function(){return null!==this.spinner.intervalId},r.prototype.getSpinnerHeight=function(){return this.spinner.$el.innerHeight()},r.prototype.stopLoadingSpinnerAnimation=function(){clearInterval(this.spinner.intervalId),this.spinner.intervalId=null,this.setGalleryTempHeight(this.$gallery.height()-this.getSpinnerHeight()),this.spinner.$el.detach()},r.prototype.startLoadingSpinnerAnimation=function(){var t=this.spinner,i=t.$el.find("span");clearInterval(t.intervalId),this.$gallery.append(t.$el),this.setGalleryTempHeight(this.offY+this.buildingRow.height+this.getSpinnerHeight()),t.intervalId=setInterval(function(){t.phase<i.length?i.eq(t.phase).fadeTo(t.timeSlot,1):i.eq(t.phase-i.length).fadeTo(t.timeSlot,0),t.phase=(t.phase+1)%(2*i.length)},t.timeSlot)},r.prototype.rewind=function(){this.lastFetchedEntry=null,this.lastAnalyzedIndex=-1,this.offY=this.border,this.rows=0,this.clearBuildingRow()},r.prototype.updateEntries=function(t){var i;return t&&null!=this.lastFetchedEntry?i=g(this.lastFetchedEntry).nextAll(this.settings.selector).toArray():(this.entries=[],i=this.$gallery.children(this.settings.selector).toArray()),0<i.length&&(g.isFunction(this.settings.sort)?i=this.sortArray(i):this.settings.randomize&&(i=this.shuffleArray(i)),this.lastFetchedEntry=i[i.length-1],this.settings.filter?i=this.filterArray(i):this.resetFilters(i)),this.entries=this.entries.concat(i),!0},r.prototype.insertToGallery=function(t){var i=this;g.each(t,function(){g(this).appendTo(i.$gallery)})},r.prototype.shuffleArray=function(t){var i,e,s;for(i=t.length-1;0<i;i--)e=Math.floor(Math.random()*(i+1)),s=t[i],t[i]=t[e],t[e]=s;return this.insertToGallery(t),t},r.prototype.sortArray=function(t){return t.sort(this.settings.sort),this.insertToGallery(t),t},r.prototype.resetFilters=function(t){for(var i=0;i<t.length;i++)g(t[i]).removeClass("jg-filtered")},r.prototype.filterArray=function(t){var e=this.settings;if("string"===g.type(e.filter))return t.filter(function(t){var i=g(t);return i.is(e.filter)?(i.removeClass("jg-filtered"),!0):(i.addClass("jg-filtered").removeClass("jg-visible"),!1)});if(g.isFunction(e.filter)){for(var i=t.filter(e.filter),s=0;s<t.length;s++)-1===i.indexOf(t[s])?g(t[s]).addClass("jg-filtered").removeClass("jg-visible"):g(t[s]).removeClass("jg-filtered");return i}},r.prototype.destroy=function(){clearInterval(this.checkWidthIntervalId),g.each(this.entries,g.proxy(function(t,i){var e=g(i);e.css("width",""),e.css("height",""),e.css("top",""),e.css("left",""),e.data("jg.loaded",void 0),e.removeClass("jg-entry");var s=this.imgFromEntry(e);s.css("width",""),s.css("height",""),s.css("margin-left",""),s.css("margin-top",""),s.attr("src",s.data("jg.originalSrc")),s.data("jg.originalSrc",void 0),this.removeCaptionEventsHandlers(e);var n=this.captionFromEntry(e);e.data("jg.createdCaption")?(e.data("jg.createdCaption",void 0),null!==n&&n.remove()):null!==n&&n.fadeTo(0,1)},this)),this.$gallery.css("height",""),this.$gallery.removeClass("justified-gallery"),this.$gallery.data("jg.controller",void 0)},r.prototype.analyzeImages=function(t){for(var i=this.lastAnalyzedIndex+1;i<this.entries.length;i++){var e=g(this.entries[i]);if(!0===e.data("jg.loaded")||"skipped"===e.data("jg.loaded")){var s=this.galleryWidth-2*this.border-(this.buildingRow.entriesBuff.length-1)*this.settings.margins,n=e.data("jg.width")/e.data("jg.height");if(s/(this.buildingRow.aspectRatio+n)<this.settings.rowHeight&&(this.flushRow(!1),++this.yield.flushed>=this.yield.every))return void this.startImgAnalyzer(t);this.buildingRow.entriesBuff.push(e),this.buildingRow.aspectRatio+=n,this.buildingRow.width+=n*this.settings.rowHeight,this.lastAnalyzedIndex=i}else if("error"!==e.data("jg.loaded"))return}0<this.buildingRow.entriesBuff.length&&this.flushRow(!0),this.isSpinnerActive()&&this.stopLoadingSpinnerAnimation(),this.stopImgAnalyzerStarter(),this.settings.triggerEvent.call(this,t?"jg.resize":"jg.complete"),this.setGalleryFinalHeight(this.galleryHeightToSet)},r.prototype.stopImgAnalyzerStarter=function(){this.yield.flushed=0,null!==this.imgAnalyzerTimeout&&(clearTimeout(this.imgAnalyzerTimeout),this.imgAnalyzerTimeout=null)},r.prototype.startImgAnalyzer=function(t){var i=this;this.stopImgAnalyzerStarter(),this.imgAnalyzerTimeout=setTimeout(function(){i.analyzeImages(t)},.001)},r.prototype.onImageEvent=function(t,i,e){if(i||e){var s=new Image,n=g(s);i&&n.one("load",function(){n.off("load error"),i(s)}),e&&n.one("error",function(){n.off("load error"),e(s)}),s.src=t}},r.prototype.init=function(){var a=!1,h=!1,l=this;g.each(this.entries,function(t,i){var e=g(i),s=l.imgFromEntry(e);if(e.addClass("jg-entry"),!0!==e.data("jg.loaded")&&"skipped"!==e.data("jg.loaded"))if(null!==l.settings.rel&&e.attr("rel",l.settings.rel),null!==l.settings.target&&e.attr("target",l.settings.target),null!==s){var n=l.extractImgSrcFromImage(s);if(s.attr("src",n),!1===l.settings.waitThumbnailsLoad){var r=parseFloat(s.prop("width")),o=parseFloat(s.prop("height"));if(!isNaN(r)&&!isNaN(o))return e.data("jg.width",r),e.data("jg.height",o),e.data("jg.loaded","skipped"),h=!0,l.startImgAnalyzer(!1),!0}e.data("jg.loaded",!1),a=!0,l.isSpinnerActive()||l.startLoadingSpinnerAnimation(),l.onImageEvent(n,function(t){e.data("jg.width",t.width),e.data("jg.height",t.height),e.data("jg.loaded",!0),l.startImgAnalyzer(!1)},function(){e.data("jg.loaded","error"),l.startImgAnalyzer(!1)})}else e.data("jg.loaded",!0),e.data("jg.width",e.width()|parseFloat(e.css("width"))|1),e.data("jg.height",e.height()|parseFloat(e.css("height"))|1)}),a||h||this.startImgAnalyzer(!1),this.checkWidth()},r.prototype.checkOrConvertNumber=function(t,i){if("string"===g.type(t[i])&&(t[i]=parseFloat(t[i])),"number"!==g.type(t[i]))throw i+" must be a number";if(isNaN(t[i]))throw"invalid number for "+i},r.prototype.checkSizeRangesSuffixes=function(){if("object"!==g.type(this.settings.sizeRangeSuffixes))throw"sizeRangeSuffixes must be defined and must be an object";var t=[];for(var i in this.settings.sizeRangeSuffixes)this.settings.sizeRangeSuffixes.hasOwnProperty(i)&&t.push(i);for(var e={0:""},s=0;s<t.length;s++)if("string"===g.type(t[s]))try{e[parseInt(t[s].replace(/^[a-z]+/,""),10)]=this.settings.sizeRangeSuffixes[t[s]]}catch(t){throw"sizeRangeSuffixes keys must contains correct numbers ("+t+")"}else e[t[s]]=this.settings.sizeRangeSuffixes[t[s]];this.settings.sizeRangeSuffixes=e},r.prototype.retrieveMaxRowHeight=function(){var t=null,i=this.settings.rowHeight;if("string"===g.type(this.settings.maxRowHeight))t=this.settings.maxRowHeight.match(/^[0-9]+%$/)?i*parseFloat(this.settings.maxRowHeight.match(/^([0-9]+)%$/)[1])/100:parseFloat(this.settings.maxRowHeight);else{if("number"!==g.type(this.settings.maxRowHeight)){if(!1===this.settings.maxRowHeight||null==this.settings.maxRowHeight)return null;throw"maxRowHeight must be a number or a percentage"}t=this.settings.maxRowHeight}if(isNaN(t))throw"invalid number for maxRowHeight";return t<i&&(t=i),t},r.prototype.checkSettings=function(){this.checkSizeRangesSuffixes(),this.checkOrConvertNumber(this.settings,"rowHeight"),this.checkOrConvertNumber(this.settings,"margins"),this.checkOrConvertNumber(this.settings,"border");var t=["justify","nojustify","left","center","right","hide"];if(-1===t.indexOf(this.settings.lastRow))throw"lastRow must be one of: "+t.join(", ");if(this.checkOrConvertNumber(this.settings,"justifyThreshold"),this.settings.justifyThreshold<0||1<this.settings.justifyThreshold)throw"justifyThreshold must be in the interval [0,1]";if("boolean"!==g.type(this.settings.cssAnimation))throw"cssAnimation must be a boolean";if("boolean"!==g.type(this.settings.captions))throw"captions must be a boolean";if(this.checkOrConvertNumber(this.settings.captionSettings,"animationDuration"),this.checkOrConvertNumber(this.settings.captionSettings,"visibleOpacity"),this.settings.captionSettings.visibleOpacity<0||1<this.settings.captionSettings.visibleOpacity)throw"captionSettings.visibleOpacity must be in the interval [0, 1]";if(this.checkOrConvertNumber(this.settings.captionSettings,"nonVisibleOpacity"),this.settings.captionSettings.nonVisibleOpacity<0||1<this.settings.captionSettings.nonVisibleOpacity)throw"captionSettings.nonVisibleOpacity must be in the interval [0, 1]";if(this.checkOrConvertNumber(this.settings,"imagesAnimationDuration"),this.checkOrConvertNumber(this.settings,"refreshTime"),this.checkOrConvertNumber(this.settings,"refreshSensitivity"),"boolean"!==g.type(this.settings.randomize))throw"randomize must be a boolean";if("string"!==g.type(this.settings.selector))throw"selector must be a string";if(!1!==this.settings.sort&&!g.isFunction(this.settings.sort))throw"sort must be false or a comparison function";if(!1!==this.settings.filter&&!g.isFunction(this.settings.filter)&&"string"!==g.type(this.settings.filter))throw"filter must be false, a string or a filter function"},r.prototype.retrieveSuffixRanges=function(){var t=[];for(var i in this.settings.sizeRangeSuffixes)this.settings.sizeRangeSuffixes.hasOwnProperty(i)&&t.push(parseInt(i,10));return t.sort(function(t,i){return i<t?1:t<i?-1:0}),t},r.prototype.updateSettings=function(t){this.settings=g.extend({},this.settings,t),this.checkSettings(),this.border=0<=this.settings.border?this.settings.border:this.settings.margins,this.maxRowHeight=this.retrieveMaxRowHeight(),this.suffixRanges=this.retrieveSuffixRanges()},r.prototype.defaults={sizeRangeSuffixes:{},thumbnailPath:void 0,rowHeight:120,maxRowHeight:!1,margins:1,border:-1,lastRow:"nojustify",justifyThreshold:.9,waitThumbnailsLoad:!0,captions:!0,cssAnimation:!0,imagesAnimationDuration:500,captionSettings:{animationDuration:500,visibleOpacity:.7,nonVisibleOpacity:0},rel:null,target:null,extension:/\.[^.\\/]+$/,refreshTime:200,refreshSensitivity:0,randomize:!1,rtl:!1,sort:!1,filter:!1,selector:"a, div:not(.spinner)",imgSelector:"> img, > a > img",triggerEvent:function(t){this.$gallery.trigger(t)}},g.fn.justifiedGallery=function(n){return this.each(function(t,i){var e=g(i);e.addClass("justified-gallery");var s=e.data("jg.controller");if(void 0===s){if(null!=n&&"object"!==g.type(n)){if("destroy"===n)return;throw"The argument must be an object"}s=new r(e,g.extend({},r.prototype.defaults,n)),e.data("jg.controller",s)}else if("norewind"===n);else{if("destroy"===n)return void s.destroy();s.updateSettings(n),s.rewind()}s.updateEntries("norewind"===n)&&s.init()})}});
\ No newline at end of file diff --git a/library/justifiedGallery/justifiedGallery.css b/library/justifiedGallery/justifiedGallery.css index 3b1da6850..8b753dc38 100644 --- a/library/justifiedGallery/justifiedGallery.css +++ b/library/justifiedGallery/justifiedGallery.css @@ -1,5 +1,5 @@ /*! - * Justified Gallery - v3.6.5 + * justifiedGallery - v3.7.0 * http://miromannino.github.io/Justified-Gallery/ * Copyright (c) 2018 Miro Mannino * Licensed under the MIT license. diff --git a/library/justifiedGallery/justifiedGallery.min.css b/library/justifiedGallery/justifiedGallery.min.css index ba8b177d7..8b753dc38 100644 --- a/library/justifiedGallery/justifiedGallery.min.css +++ b/library/justifiedGallery/justifiedGallery.min.css @@ -1,7 +1,102 @@ /*! - * Justified Gallery - v3.6.5 + * justifiedGallery - v3.7.0 * http://miromannino.github.io/Justified-Gallery/ * Copyright (c) 2018 Miro Mannino * Licensed under the MIT license. */ -.justified-gallery{width:100%;position:relative;overflow:hidden}.justified-gallery>a,.justified-gallery>div,.justified-gallery>figure{position:absolute;display:inline-block;overflow:hidden;filter:"alpha(opacity=10)";opacity:.1;margin:0;padding:0}.justified-gallery>a>img,.justified-gallery>div>img,.justified-gallery>figure>img,.justified-gallery>a>a>img,.justified-gallery>div>a>img,.justified-gallery>figure>a>img{position:absolute;top:50%;left:50%;margin:0;padding:0;border:0;filter:"alpha(opacity=0)";opacity:0}.justified-gallery>a>.caption,.justified-gallery>div>.caption,.justified-gallery>figure>.caption{display:none;position:absolute;bottom:0;padding:5px;background-color:#000;left:0;right:0;margin:0;color:#fff;font-size:12px;font-weight:300;font-family:sans-serif}.justified-gallery>a>.caption.caption-visible,.justified-gallery>div>.caption.caption-visible,.justified-gallery>figure>.caption.caption-visible{display:initial;filter:"alpha(opacity=70)";opacity:.7;-webkit-transition:opacity 500ms ease-in;-moz-transition:opacity 500ms ease-in;-o-transition:opacity 500ms ease-in;transition:opacity 500ms ease-in}.justified-gallery>.entry-visible{filter:"alpha(opacity=100)";opacity:1;background:0 0}.justified-gallery>.entry-visible>img,.justified-gallery>.entry-visible>a>img{filter:"alpha(opacity=100)";opacity:1;-webkit-transition:opacity 500ms ease-in;-moz-transition:opacity 500ms ease-in;-o-transition:opacity 500ms ease-in;transition:opacity 500ms ease-in}.justified-gallery>.jg-filtered{display:none}.justified-gallery>.spinner{position:absolute;bottom:0;margin-left:-24px;padding:10px 0;left:50%;filter:"alpha(opacity=100)";opacity:1;overflow:initial}.justified-gallery>.spinner>span{display:inline-block;filter:"alpha(opacity=0)";opacity:0;width:8px;height:8px;margin:0 4px;background-color:#000;border-radius:6px}
\ No newline at end of file +.justified-gallery { + width: 100%; + position: relative; + overflow: hidden; +} +.justified-gallery > a, +.justified-gallery > div, +.justified-gallery > figure { + position: absolute; + display: inline-block; + overflow: hidden; + /* background: #888888; To have gray placeholders while the gallery is loading with waitThumbnailsLoad = false */ + filter: "alpha(opacity=10)"; + opacity: 0.1; + margin: 0; + padding: 0; +} +.justified-gallery > a > img, +.justified-gallery > div > img, +.justified-gallery > figure > img, +.justified-gallery > a > a > img, +.justified-gallery > div > a > img, +.justified-gallery > figure > a > img { + position: absolute; + top: 50%; + left: 50%; + margin: 0; + padding: 0; + border: none; + filter: "alpha(opacity=0)"; + opacity: 0; +} +.justified-gallery > a > .caption, +.justified-gallery > div > .caption, +.justified-gallery > figure > .caption { + display: none; + position: absolute; + bottom: 0; + padding: 5px; + background-color: #000000; + left: 0; + right: 0; + margin: 0; + color: white; + font-size: 12px; + font-weight: 300; + font-family: sans-serif; +} +.justified-gallery > a > .caption.caption-visible, +.justified-gallery > div > .caption.caption-visible, +.justified-gallery > figure > .caption.caption-visible { + display: initial; + filter: "alpha(opacity=70)"; + opacity: 0.7; + -webkit-transition: opacity 500ms ease-in; + -moz-transition: opacity 500ms ease-in; + -o-transition: opacity 500ms ease-in; + transition: opacity 500ms ease-in; +} +.justified-gallery > .entry-visible { + filter: "alpha(opacity=100)"; + opacity: 1; + background: none; +} +.justified-gallery > .entry-visible > img, +.justified-gallery > .entry-visible > a > img { + filter: "alpha(opacity=100)"; + opacity: 1; + -webkit-transition: opacity 500ms ease-in; + -moz-transition: opacity 500ms ease-in; + -o-transition: opacity 500ms ease-in; + transition: opacity 500ms ease-in; +} +.justified-gallery > .jg-filtered { + display: none; +} +.justified-gallery > .spinner { + position: absolute; + bottom: 0; + margin-left: -24px; + padding: 10px 0 10px 0; + left: 50%; + filter: "alpha(opacity=100)"; + opacity: 1; + overflow: initial; +} +.justified-gallery > .spinner > span { + display: inline-block; + filter: "alpha(opacity=0)"; + opacity: 0; + width: 8px; + height: 8px; + margin: 0 4px 0 4px; + background-color: #000; + border-radius: 6px; +} |