From: Stephen Cameron Date: Fri, 30 Mar 2018 18:54:45 +0000 (+0200) Subject: WIP #1945 @4 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=ad1f872daa53e2ca02f6d7bda436e18990a7b989;p=fluidbook-html5.git WIP #1945 @4 --- diff --git a/images/slick/ajax-loader.gif b/images/slick/ajax-loader.gif new file mode 100755 index 00000000..e0e6e976 Binary files /dev/null and b/images/slick/ajax-loader.gif differ diff --git a/js/libs/fluidbook/fluidbook.js b/js/libs/fluidbook/fluidbook.js index 686daa37..6d52f0e0 100644 --- a/js/libs/fluidbook/fluidbook.js +++ b/js/libs/fluidbook/fluidbook.js @@ -54,6 +54,7 @@ Fluidbook.prototype = { this.tooltip = new FluidbookTooltip(this); this.audiodescription = new FluidbookAudioDescription(this); this.sound = new FluidbookSound(this); + this.slideshow = new FluidbookSlideshow(this); if (this.datas.form == 'bulle') { this.form = new FluidbookBulleForm(this); diff --git a/js/libs/fluidbook/fluidbook.menu.js b/js/libs/fluidbook/fluidbook.menu.js index c48741c5..c86c7a45 100644 --- a/js/libs/fluidbook/fluidbook.menu.js +++ b/js/libs/fluidbook/fluidbook.menu.js @@ -96,6 +96,8 @@ FluidbookMenu.prototype = { this.openArchives($("#nav #archives").data('tooltip'), cb); } else if (view == 'text') { this.openText(param1, cb); + } else if (view == 'slideshow') { + this.openSlideshow(param1, cb); } else { this['open' + camelView](param1, param2, cb); } @@ -168,8 +170,37 @@ FluidbookMenu.prototype = { callback(); } this.fluidbook.hideLoader(5); - } - , + }, + + openSlideshow: function (slideshow, callback) { + var a = $('a[href="#/slideshow/' + slideshow + '"]'); + var markup = decodeURIComponent($(a).attr('data-slideshow')); + var view = '
' + this.closeButton() + '
'; + view += '
'; + view += markup; + view += '
'; + $("#view").append('
' + view + '
'); + + // TODO: check which type should be passed to fluidbook.stats.track() ??? + // this.fluidbook.stats.track(11); + + //this.fluidbook.initSlideshow(); + + var $this = this; + var times = [250, 500, 750, 1000, 1250]; + $.each(times, function (k, v) { + setTimeout(function () { + $this.resize(); + }, v); + }); + + if (callback != undefined) { + callback(); + } + + this.fluidbook.hideLoader(5); + }, + closeButton: function (c) { if (c == undefined) { c = ''; @@ -557,6 +588,11 @@ FluidbookMenu.prototype = { m.find('.multimediaScale').css({width: nw, height: nh, overflow: 'hidden'}).transform({scale: [s, s], origin: [0, 0]}).css('text-align', 'left'); break; + case 'slideshow': + // ToDo: resize slideshow to fit inside view, accounting for image, caption and thumbnail grid + // w contains max width of popup + // h contains max height of popup + break; default: break; } @@ -633,4 +669,4 @@ FluidbookMenu.prototype = { $("#viewOverlay").css('opacity', 1); }, 10); } -}; \ No newline at end of file +}; diff --git a/js/libs/fluidbook/fluidbook.slideshow.js b/js/libs/fluidbook/fluidbook.slideshow.js new file mode 100644 index 00000000..80adc799 --- /dev/null +++ b/js/libs/fluidbook/fluidbook.slideshow.js @@ -0,0 +1,44 @@ +function FluidbookSlideshow(fluidbook) { + this.fluidbook = fluidbook; +} + +FluidbookSlideshow.prototype = { + initSlideshow: function(id) { + var $slideshow = $('#' + id), + thumbnailsID = id +'_thumbnails', + $thumbnails; + + if ($slideshow.length == 0) return false; + + // Dynamically add thumbnails from full sized images + // Images have to load anyway so we can reuse full images for thumbnails + $('
').appendTo($slideshow.parent()); + $thumbnails = $('#' + thumbnailsID); + + $slideshow.find('img').each(function() { + var img = $(this).clone(); + $thumbnails.append(img); + }); + + // Main image slider + $slideshow.slick({ + variableWidth: false, + asNavFor: '#'+ thumbnailsID, // Synced with thumbnails slider + infinite: false, + draggable: true + }); + + // Thumbnails slider + $thumbnails.slick({ + slidesToShow: 6, + asNavFor: '#'+ id, // Synced with main slider + focusOnSelect: true, + variableWidth: true, + arrows: false, + draggable: true, + swipeToSlide: true, + infinite: false, + centerMode: false + }); + } +} diff --git a/js/libs/fluidbook/fluidbook.utils.js b/js/libs/fluidbook/fluidbook.utils.js index 9ff2ff9e..27e7659b 100644 --- a/js/libs/fluidbook/fluidbook.utils.js +++ b/js/libs/fluidbook/fluidbook.utils.js @@ -100,4 +100,4 @@ function array_diff(a, b) { return a.filter(function (i) { return b.indexOf(i) < 0; }); -} \ No newline at end of file +} diff --git a/js/libs/slick/slick.js b/js/libs/slick/slick.js new file mode 100644 index 00000000..d0937bdc --- /dev/null +++ b/js/libs/slick/slick.js @@ -0,0 +1,3025 @@ +/* + _ _ _ _ + ___| (_) ___| | __ (_)___ + / __| | |/ __| |/ / | / __| + \__ \ | | (__| < _ | \__ \ + |___/_|_|\___|_|\_(_)/ |___/ + |__/ + + Version: 1.8.1 + Author: Ken Wheeler + Website: http://kenwheeler.github.io + Docs: http://kenwheeler.github.io/slick + Repo: http://github.com/kenwheeler/slick + Issues: http://github.com/kenwheeler/slick/issues + + */ +/* global window, document, define, jQuery, setInterval, clearInterval */ +;(function(factory) { + 'use strict'; + if (typeof define === 'function' && define.amd) { + define(['jquery'], factory); + } else if (typeof exports !== 'undefined') { + module.exports = factory(require('jquery')); + } else { + factory(jQuery); + } + +}(function($) { + 'use strict'; + var Slick = window.Slick || {}; + + Slick = (function() { + + var instanceUid = 0; + + function Slick(element, settings) { + + var _ = this, dataSettings; + + _.defaults = { + accessibility: true, + adaptiveHeight: false, + appendArrows: $(element), + appendDots: $(element), + arrows: true, + asNavFor: null, + prevArrow: '', + nextArrow: '', + autoplay: false, + autoplaySpeed: 3000, + centerMode: false, + centerPadding: '50px', + cssEase: 'ease', + customPaging: function(slider, i) { + return $('