--- regenerate: false --- {% capture cache %} {% comment %} # ----------------------------------------------------------------------------- # ~/assets/themes/j1/extentions/justified_gallery/js/j1_adapter_justified_gallery.js # Liquid template to create the J1 Adapter for Justified Gallery # # Product/Info: # https://jekyll-one.com # # Copyright (C) 2019 Juergen Adams # # J1 Template is licensed under the MIT License. # See: https://github.com/jekyll-one/j1_template_mde/blob/master/LICENSE # # ----------------------------------------------------------------------------- {% endcomment %} /* # ----------------------------------------------------------------------------- # ~/assets/themes/j1/extentions/justified_gallery/js/j1_adapter_justified_gallery.js # JS Adapter for JustifiedGallery # # Product/Info: # https://jekyll-one.com # https://github.com/miromannino/Justified-Gallery # # Copyright (C) 2019 Juergen Adams # Copyright (C) 2016 Miro Mannino # # J1 Template is licensed under the MIT License. # See: https://github.com/jekyll-one/j1_template_mde/blob/master/LICENSE # Justified Gallery is licensed under the MIT license # See: https://github.com/miromannino/Justified-Gallery # # ----------------------------------------------------------------------------- # Adapter generated: {{site.time}} # ----------------------------------------------------------------------------- */ 'use strict'; {% comment %} Liquid procedures --------------------------------------------------------------- {% endcomment %} {% comment %} Variables --------------------------------------------------------------- {% endcomment %} {% assign environment = site.environment %} {% assign config = site.data.apps.j1_justified_gallery %} {% comment %} Main --------------------------------------------------------------- {% endcomment %} j1.JustifiedGallery = (function (j1, window) { var environment = '{{environment}}'; // Set environment var state = 'unknown'; var logger; var logText; return { // J1 J1JustifiedGallery init: function ( options ) { // Setup logger logger = log4javascript.getLogger("j1.JustifiedGallery.init"); if ( options != null ) { var lb_settings = $.extend({}, options); } {% if environment == 'development' %} logText = 'start gallery initialization'; logger.info(logText); state = 'started'; logger.info('state: ' + state); // Set|Log status {% endif %} this.load( lb_settings ); }, // --------------------------------------------------------------------- // Load AJAX data and initialize the jg gallery // --------------------------------------------------------------------- load: function ( options ) { // Setup logger logger = log4javascript.getLogger("j1.JustifiedGallery.load"); {% if environment == 'development' %} state = 'running'; logger.info('state: ' + state); // Set|Log status {% endif %} {% for item in config.galleries %} {% if item.gallery.enabled %} {% assign lb_options = item.gallery.lightbox_options %} {% assign jg_options = item.gallery.gallery_options %} {% assign gallery_title = item.gallery.title %} {% assign gallery_type = item.gallery.type %} {% assign lightbox = item.gallery.lightbox_options.lightbox %} {% assign css_classes = item.gallery.css_classes %} {% assign show_delay = 250 %} {% if lightbox == "lg" %} {% assign lb_mode = "lg-fade" %} {% assign lb_cssEasing = "cubic-bezier(0.25, 0, 0.25, 1)" %} {% assign lb_thumbnails = true %} {% assign lb_autoplay = false %} {% assign lb_fullscreen = true %} {% assign lb_pager = true %} {% assign lb_zoomer = true %} {% assign lb_hash = true %} {% assign lb_video = false %} {% assign lb_video_html5 = false %} {% assign lb_video_online = false %} {% assign lb_share = false %} {% assign lb_share_facebook = false %} {% assign lb_share_twitter = false %} {% assign lb_share_googleplus = false %} {% assign lb_share_pinterest = false %} {% endif %} {% assign container_id = item.gallery.id %} {% capture gallery_id %}{{item.gallery.id}}_div{% endcapture %} {% if item.gallery.show_delay %} {% assign show_delay = item.gallery.show_delay %} {% endif %} {% if lb_options.mode %} {% assign lb_mode = lb_options.mode %} {% endif %} {% if lb_options.cssEasing %} {% assign lb_cssEasing = lb_options.cssEasing %} {% endif %} {% if lb_options.thumbnails %} {% assign lb_thumbnails = lb_options.thumbnails %} {% endif %} {% if lb_options.autoplay %} {% assign lb_autoplay = lb_options.autoplay %} {% endif %} {% if lb_options.fullscreen %} {% assign lb_fullscreen = lb_options.fullscreen %} {% endif %} {% if lb_options.pager %} {% assign lb_pager = lb_options.pager %} {% endif %} {% if lb_options.zoomer %} {% assign lb_zoomer = lb_options.zoomer %} {% endif %} {% if lb_options.video.enabled %} {% assign lb_video = lb_options.video.enabled %} {% endif %} {% if lb_options.video.enabled %} logText = 'Video not supported'; logger.error(logText); {% endif %} // Create an gallery instance if id: {{ container_id }} exists if ( $('#{{ container_id }}').length ) { {% if environment == 'development' %} logText = 'Gallery on ID #{{ container_id }} is being initialized'; logger.info(logText); {% endif %} // Place HTML markup for the title {% if gallery_title %} var gallery_title = ''; $('#{{ container_id }}').before( gallery_title ); {% endif %} $('#{{ container_id }}').addClass("justifiedgallery "); {% if gallery_type == "image" %} // Collect image gallery data from data file (jsonPath) $.getJSON( '{{config.jsonPath}}', function (data) { var content = ''; var gallery_class = 'justified-gallery' {% if lightbox == "lg" %} gallery_class += ' light-gallery '; {% endif %} content += ''; {% endif %} // Hide gallery container (until lightGallery is NOT initialized) // and place HTML markup $("#{{ container_id }}").hide().html(content); // Initialize and run the gallery using individual gallery|lightbox options {% if lightbox == "lg" %} var gallery_selector = $("#{{ gallery_id }}"); if ( options !== undefined ) { // lightbox initialized on COMPLETE event of justifiedGallery gallery_selector.justifiedGallery().on('jg.complete', function () { gallery_selector.lightGallery({ {% for option in item.gallery.lightbox_options %} {{ option[0] | json }}: {{ option[1] | json }}, {% endfor %} }); // Initialize instance variable of lightGallery (for later access) j1["{{gallery_id}}"] = gallery_selector.data('lightGallery'); // Show gallery DIV element if jg has completed *and* the // lightbox is initialized (delayed) setTimeout(function() { $("#{{ container_id }}").show(); }, {{ show_delay }}); {% if environment == 'development' %} logText = 'Gallery on ID #{{ container_id }} initializing completed'; logger.info(logText); {% endif %} }); } else { gallery_selector.justifiedGallery({ {% for option in item.gallery.gallery_options %} {{ option[0] | json }}: {{ option[1] | json }}, {% endfor %} }).on('jg.complete', function () { // lightbox initialized on COMPLETE event of justifiedGallery gallery_selector.lightGallery({ {% for option in item.gallery.lightbox_options %} {{ option[0] | json }}: {{ option[1] | json }}, {% endfor %} }); // Initialize instance variable of lightGallery (for later access) j1["{{gallery_id}}"] = gallery_selector.data('lightGallery'); // Show gallery DIV element if jg has completed *and* the // lightbox is initialized (delayed) setTimeout(function() { $("#{{ container_id }}").show(); }, {{ show_delay }}); {% if environment == 'development' %} logText = 'Gallery on ID #{{ container_id }} initializing completed'; logger.info(logText); {% endif %} }); } {% endif %} // endif lightbox "lg" {% if lightbox == "cb" %} // $(this).find('a').colorbox(); {% endif %} // endif lightbox "cb" }); // end getJSON } //end gallery {% endif %} // endif gallery enabled {% endfor %} }, // end function load // ------------------------------------------------------------------------- // returns the current (processing) state of the module // ------------------------------------------------------------------------- state: function () { return state; } }; // end return })(j1, window); {% endcapture %} {{ cache | strip_empty_lines }}