diff --git a/user/config/plugins/featherlight.yaml b/user/config/plugins/featherlight.yaml new file mode 100644 index 0000000..0ac810a --- /dev/null +++ b/user/config/plugins/featherlight.yaml @@ -0,0 +1,10 @@ +enabled: true # global enable/disable the entire plugin +active: true # if the plugin is active and JS/CSS should be loaded +gallery: true # enable/disable the gallery extension +requirejs: false # output to an AMD module +openSpeed: 250 # open speed in ms +closeSpeed: 250 # close speed in ms +closeOnClick: background # background|anywhere|false +closeOnEsc: true # true|false on hitting Esc key +root: body # where to append featherlights +initTemplate: plugin://featherlight/js/featherlight.init.js diff --git a/user/config/system.yaml b/user/config/system.yaml index e1fffd6..77bc633 100644 --- a/user/config/system.yaml +++ b/user/config/system.yaml @@ -35,7 +35,7 @@ errors: log: true debugger: - enabled: false + enabled: true twig: true shutdown: close_connection: true diff --git a/user/plugins/featherlight/.gitignore b/user/plugins/featherlight/.gitignore new file mode 100644 index 0000000..9bea433 --- /dev/null +++ b/user/plugins/featherlight/.gitignore @@ -0,0 +1,2 @@ + +.DS_Store diff --git a/user/plugins/featherlight/CHANGELOG.md b/user/plugins/featherlight/CHANGELOG.md new file mode 100644 index 0000000..ce797f6 --- /dev/null +++ b/user/plugins/featherlight/CHANGELOG.md @@ -0,0 +1,55 @@ +# v1.5.0 +## 07/26/2017 + +1. [](#new) + * Update to Featherlight 1.7.7 + +# v1.4.0 +## 07/14/2016 + +1. [](#new) + * Allow to have a custom initialization javascript file + * Allow AMD module output for RequireJS +1. [](#improved) + * Moved initialization to its own javascript file instead of inlined in the PHP code + * Fixed closeOnEsc + +# v1.3.1 +## 05/23/2016 + +1. [](#improved) + * Use common language strings + * Set active by default + +# v1.3.0 +## 08/25/2015 + +1. [](#improved) + * Added blueprints for Grav Admin plugin + +# v1.2.0 +## 06/16/2015 + +1. [](#improved) + * Updated to featherlight 1.3.2 + * Added Gallery support + +# v1.1.0 +## 03/24/2015 + +1. [](#improved) + * Updated to featherlight 1.2.3 + * Added 'root' option to configure where featherlight is added + * Added reference for to load jQuery if needed + +# v1.0.3 +## 02/19/2015 + +1. [](#improved) + * README improvements + +# v1.0.2 +## 11/30/2014 + +1. [](#new) + * ChangeLog started... diff --git a/user/plugins/featherlight/LICENSE b/user/plugins/featherlight/LICENSE new file mode 100644 index 0000000..484793a --- /dev/null +++ b/user/plugins/featherlight/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014 Grav + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/user/plugins/featherlight/README.md b/user/plugins/featherlight/README.md new file mode 100644 index 0000000..ff66e37 --- /dev/null +++ b/user/plugins/featherlight/README.md @@ -0,0 +1,160 @@ +# Grav Featherlight Plugin + +![Featherlight](assets/featherlight.png) + +`featherlight` is a simple [Grav](http://github.com/getgrav/grav) plugin that adds **lightbox** functionality via the jQuery plugin [Featherlight.js](http://noelboss.github.io/featherlight/). + +# Installation + +Installing the Featherlight plugin can be done in one of two ways. Our GPM (Grav Package Manager) installation method enables you to quickly and easily install the plugin with a simple terminal command, while the manual method enables you to do so via a zip file. + +## GPM Installation (Preferred) + +The simplest way to install this plugin is via the [Grav Package Manager (GPM)](http://learn.getgrav.org/advanced/grav-gpm) through your system's Terminal (also called the command line). From the root of your Grav install type: + + bin/gpm install featherlight + +This will install the Featherlight plugin into your `/user/plugins` directory within Grav. Its files can be found under `/your/site/grav/user/plugins/featherlight`. + +## Manual Installation + +To install this plugin, just download the zip version of this repository and unzip it under `/your/site/grav/user/plugins`. Then, rename the folder to `featherlight`. You can find these files either on [GitHub](https://github.com/getgrav/grav-plugin-featherlight) or via [GetGrav.org](http://getgrav.org/downloads/plugins#extras). + +You should now have all the plugin files under + + /your/site/grav/user/plugins/featherlight + +>> NOTE: This plugin is a modular component for Grav which requires [Grav](http://github.com/getgrav/grav) to function + +# Usage + +To best understand how Featherlight works, you should read through the original project [documentation](https://github.com/noelboss/featherlight/#installation). + +## Configuration + +Featherlight is **enabled** but **not active** by default. You can change this behavior by setting `active: true` in the plugin's configuration. Simply copy the `user/plugins/featherlight/featherlight.yaml` into `user/config/plugins/featherlight.yaml` and make your modifications. + +``` +enabled: true # global enable/disable the entire plugin +active: false # if the plugin is active and JS/CSS should be loaded +openSpeed: 250 # open speed in ms +closeSpeed: 250 # close speed in ms +closeOnClick: background # background|anywhere|false +closeOnEsc: true # true|false on hitting Esc key +root: body # where to append featherlights +initTemplate: plugin://featherlight/js/featherlight.init.js +``` + +You can also override any default setings from the page headers: + +eg: + + --- + title: Sample Code With Custom Settings + featherlight: + active: true + openSpeed: 100 + closeSpeed: 100 + --- + + +You can also enable globally in the `yaml`, but disable featherlighting for a particular page: + + --- + title: Sample Code with Featherlight disabled + featherlight: + active: false + --- + +## Implementing a lightbox with Featherlight + +To implement a lightbox using Featherlight in Grav, you must output the proper HTML output. Luckily Grav already takes care of this for you if you are using Grav media files. + +In markdown this could look something like: + +``` +![Sample Image](sample-image.jpg?lightbox=1024&cropResize=200,200) +``` + +In Twig this could look like: + +``` +{{ page.media['sample-image.jpg'].lightbox(1024,768).cropResize(200,200).html('Sample Image') }} +``` + +More details can be found in the [Grav documentation for Media functionality](http://learn.getgrav.org/content/media). + +## Adding captions to the lightbox + +Image captions within the lightbox do not come out of the box with featherlight. But as the author described in his [wiki](https://github.com/noelboss/featherlight/wiki/Gallery:-showing-a-caption) it's quite easy to add. + +Per default we use a this script when initializing the plugin: [js/featherlight.init.js](js/featherlight.init.js). You can copy it to the "user" folder, change the initTemplate setting to `user://js/featherlight.init.js` and add a afterContent callback like this: + + $(document).ready(function(){ + $('a[rel="lightbox"]').{pluginName}({ + openSpeed: {openSpeed}, + closeSpeed: {closeSpeed}, + closeOnClick: '{closeOnClick}', + closeOnEsc: '{closeOnEsc}', + root: '{root}', + afterContent: function() { + var caption = this.$currentTarget.find('img').attr('alt'); + this.$instance.find('.caption').remove(); + $('
').text(caption).appendTo(this.$instance.find('.featherlight-content')); + } + }); + }); + +The placeholders `{pluginName}`, `{openSpeed}`, `{closeSpeed}` and `{root}` will be replaced when processing this file. + +## Using AMD modules with RequireJS + +Must update to `v1.4.1`. When you select `RequireJS` from the config, this plugin will inlineJS an AMD module called `featherlight` that you can use with RequireJS. If you call this module directly, it will work, however if you decide to disable this plugin RequireJS will fail. As such, if you include the module below it will see if `featherlight` exists and include it if it does. + +``` +define(['jquery'], function($){ + var Lightbox = { + Init : function() { + if (require.specified('featherlight')) { + require( [ 'featherlight' ], function (Featherlight) { + Featherlight.Init(); + }); + } + } + }; + return Lightbox; +}); +``` + +Also set your main.js file to include this line: + +``` +paths: { + ... + plugin: '/user/plugins', + ... +}, +``` + +# Updating + +As development for the Featherlight plugin continues, new versions may become available that add additional features and functionality, improve compatibility with newer Grav releases, and generally provide a better user experience. Updating Featherlight is easy, and can be done through Grav's GPM system, as well as manually. + +## GPM Update (Preferred) + +The simplest way to update this plugin is via the [Grav Package Manager (GPM)](http://learn.getgrav.org/advanced/grav-gpm). You can do this with this by navigating to the root directory of your Grav install using your system's Terminal (also called command line) and typing the following: + + bin/gpm update featherlight + +This command will check your Grav install to see if your Featherlight plugin is due for an update. If a newer release is found, you will be asked whether or not you wish to update. To continue, type `y` and hit enter. The plugin will automatically update and clear Grav's cache. + +## Manual Update + +Manually updating Featherlight is pretty simple. Here is what you will need to do to get this done: + +* Delete the `your/site/user/plugins/featherlight` directory. +* Download the new version of the Featherlight plugin from either [GitHub](https://github.com/getgrav/grav-plugin-featherlight) or [GetGrav.org](http://getgrav.org/downloads/plugins#extras). +* Unzip the zip file in `your/site/user/plugins` and rename the resulting folder to `featherlight`. +* Clear the Grav cache. The simplest way to do this is by going to the root Grav directory in terminal and typing `bin/grav clear-cache`. + +> Note: Any changes you have made to any of the files listed under this directory will also be removed and replaced by the new set. Any files located elsewhere (for example a YAML settings file placed in `user/config/plugins`) will remain intact. diff --git a/user/plugins/featherlight/assets/featherlight.png b/user/plugins/featherlight/assets/featherlight.png new file mode 100644 index 0000000..a2396c6 Binary files /dev/null and b/user/plugins/featherlight/assets/featherlight.png differ diff --git a/user/plugins/featherlight/blueprints.yaml b/user/plugins/featherlight/blueprints.yaml new file mode 100644 index 0000000..608401e --- /dev/null +++ b/user/plugins/featherlight/blueprints.yaml @@ -0,0 +1,113 @@ +name: Featherlight +version: 1.5.0 +description: "Featherlight is a simple [Grav](http://github.com/getgrav/grav) plugin that adds **lightbox** functionality via the jQuery plugin [Featherlight.js](http://noelboss.github.io/featherlight/)." +icon: file-photo-o +author: + name: Team Grav + email: devs@getgrav.org + url: http://getgrav.org +homepage: https://github.com/getgrav/grav-plugin-featherlight +keywords: featherlight, plugin, code, lightbox +bugs: https://github.com/getgrav/grav-plugin-featherlight/issues +license: MIT + +form: + validation: strict + fields: + enabled: + type: toggle + label: PLUGIN_ADMIN.PLUGIN_STATUS + hightlight: 1 + default: 1 + options: + 1: PLUGIN_ADMIN.ENABLED + 0: PLUGIN_ADMIN.DISABLED + validate: + type: bool + + active: + type: toggle + label: Active + hightlight: 1 + default: 1 + options: + 1: PLUGIN_ADMIN.ENABLED + 0: PLUGIN_ADMIN.DISABLED + validate: + type: bool + help: Activate on all pages. You can override this setting on a page basis + + requirejs: + type: toggle + label: RequireJS + hightlight: 1 + default: 0 + options: + 1: PLUGIN_ADMIN.ENABLED + 0: PLUGIN_ADMIN.DISABLED + validate: + type: bool + help: Outputs a AMD module to use with RequireJS + + gallery: + type: toggle + label: Gallery + hightlight: 1 + default: 0 + options: + 1: PLUGIN_ADMIN.ENABLED + 0: PLUGIN_ADMIN.DISABLED + validate: + type: bool + help: Enable/disable the lightbox gallery extension + + openSpeed: + type: text + size: medium + label: Open Speed + default: '250' + help: Open Speed in ms + + closeSpeed: + type: text + size: medium + label: Close Speed + default: '250' + help: Close Speed in ms + + closeOnClick: + type: select + size: medium + classes: fancy + label: Close on Click + options: + background: background + anywhere: anywhere + 'false': 'false' + + closeOnEsc: + type: toggle + label: Close on Esc + hightlight: 1 + default: 0 + options: + 1: PLUGIN_ADMIN.ENABLED + 0: PLUGIN_ADMIN.DISABLED + validate: + type: bool + help: Close the lightbox on hitting the Esc key + + root: + type: text + size: medium + label: Root + default: 'body' + help: Where to append featherlights + + initTemplate: + type: text + size: medium + label: Init script + default: 'plugin://featherlight/js/featherlight.init.js' + placeholder: 'plugin://featherlight/js/featherlight.init.js' + help: Path to template file for JS init script diff --git a/user/plugins/featherlight/css/featherlight.gallery.min.css b/user/plugins/featherlight/css/featherlight.gallery.min.css new file mode 100644 index 0000000..211ba2e --- /dev/null +++ b/user/plugins/featherlight/css/featherlight.gallery.min.css @@ -0,0 +1,8 @@ +/** + * Featherlight Gallery – an extension for the ultra slim jQuery lightbox + * Version 1.7.7 - http://noelboss.github.io/featherlight/ + * + * Copyright 2017, Noël Raoul Bossart (http://www.noelboss.com) + * MIT Licensed. +**/ +@media all{.featherlight-next,.featherlight-previous{display:block;position:absolute;top:25px;right:25px;bottom:0;left:80%;cursor:pointer;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;background:rgba(0,0,0,0)}.featherlight-previous{left:25px;right:80%}.featherlight-next:hover,.featherlight-previous:hover{background:rgba(255,255,255,.25)}.featherlight-next span,.featherlight-previous span{display:none;position:absolute;top:50%;left:5%;width:82%;text-align:center;font-size:80px;line-height:80px;margin-top:-40px;text-shadow:0 0 5px #fff;color:#fff;font-style:normal;font-weight:400}.featherlight-next span{right:5%;left:auto}.featherlight-next:hover span,.featherlight-previous:hover span{display:inline-block}.featherlight-first-slide.featherlight-last-slide .featherlight-next,.featherlight-first-slide.featherlight-last-slide .featherlight-previous,.featherlight-loading .featherlight-next,.featherlight-loading .featherlight-previous,.featherlight-swipe-aware .featherlight-next,.featherlight-swipe-aware .featherlight-previous{display:none}}@media only screen and (max-device-width:1024px){.featherlight-next:hover,.featherlight-previous:hover{background:0 0}.featherlight-next span,.featherlight-previous span{display:block}}@media only screen and (max-width:1024px){.featherlight-next,.featherlight-previous{top:10px;right:10px;left:85%}.featherlight-previous{left:10px;right:85%}.featherlight-next span,.featherlight-previous span{margin-top:-30px;font-size:40px}} \ No newline at end of file diff --git a/user/plugins/featherlight/css/featherlight.min.css b/user/plugins/featherlight/css/featherlight.min.css new file mode 100644 index 0000000..e7d681f --- /dev/null +++ b/user/plugins/featherlight/css/featherlight.min.css @@ -0,0 +1,8 @@ +/** + * Featherlight - ultra slim jQuery lightbox + * Version 1.7.7 - http://noelboss.github.io/featherlight/ + * + * Copyright 2017, Noël Raoul Bossart (http://www.noelboss.com) + * MIT Licensed. +**/ +@media all{.featherlight{display:none;position:fixed;top:0;right:0;bottom:0;left:0;z-index:2147483647;text-align:center;white-space:nowrap;cursor:pointer;background:#333;background:rgba(0,0,0,0)}.featherlight:last-of-type{background:rgba(0,0,0,.8)}.featherlight:before{content:'';display:inline-block;height:100%;vertical-align:middle}.featherlight .featherlight-content{position:relative;text-align:left;vertical-align:middle;display:inline-block;overflow:auto;padding:25px 25px 0;border-bottom:25px solid transparent;margin-left:5%;margin-right:5%;max-height:95%;background:#fff;cursor:auto;white-space:normal}.featherlight .featherlight-inner{display:block}.featherlight link.featherlight-inner,.featherlight script.featherlight-inner,.featherlight style.featherlight-inner{display:none}.featherlight .featherlight-close-icon{position:absolute;z-index:9999;top:0;right:0;line-height:25px;width:25px;cursor:pointer;text-align:center;font-family:Arial,sans-serif;background:#fff;background:rgba(255,255,255,.3);color:#000;border:0;padding:0}.featherlight .featherlight-close-icon::-moz-focus-inner{border:0;padding:0}.featherlight .featherlight-image{width:100%}.featherlight-iframe .featherlight-content{border-bottom:0;padding:0;-webkit-overflow-scrolling:touch;overflow-y:scroll}.featherlight iframe{border:0}.featherlight *{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}}@media only screen and (max-width:1024px){.featherlight .featherlight-content{margin-left:0;margin-right:0;max-height:98%;padding:10px 10px 0;border-bottom:10px solid transparent}} \ No newline at end of file diff --git a/user/plugins/featherlight/featherlight.php b/user/plugins/featherlight/featherlight.php new file mode 100644 index 0000000..e7bbc83 --- /dev/null +++ b/user/plugins/featherlight/featherlight.php @@ -0,0 +1,130 @@ + ['onPluginsInitialized', 0] + ]; + } + + /** + * Initialize configuration + */ + public function onPluginsInitialized() + { + if ($this->isAdmin()) { + $this->active = false; + return; + } + + $this->enable([ + 'onPageInitialized' => ['onPageInitialized', 0] + ]); + } + + /** + * Initialize configuration + */ + public function onPageInitialized() + { + $defaults = (array) $this->config->get('plugins.featherlight'); + + /** @var Page $page */ + $page = $this->grav['page']; + if (isset($page->header()->featherlight)) { + $this->config->set('plugins.featherlight', array_merge($defaults, $page->header()->featherlight)); + } + + // take the old legacy `lightbox: true` setting into account + if (isset($page->header()->lightbox) && $page->header()->lightbox == true) { + $legacy = true; + } else { + $legacy = false; + } + + $this->active = $this->config->get('plugins.featherlight.active') || $legacy; + + if ($this->active) { + $this->enable([ + 'onTwigSiteVariables' => ['onTwigSiteVariables', 0] + ]); + } + } + + /** + * if enabled on this page, load the JS + CSS theme. + */ + public function onTwigSiteVariables() + { + $config = $this->config->get('plugins.featherlight'); + + if ($config['requirejs']) { + $init = "define(\"featherlight\",['jquery', 'plugin/featherlight/js/featherlight.min' ], function($){ + var Lightbox = { + Init : function() { + $('a[rel=\"lightbox\"]').featherlight({ + openSpeed: {$config['openSpeed']}, + closeSpeed: {$config['closeSpeed']}, + closeOnClick: '{$config['closeOnClick']}', + closeOnEsc: '{$config['closeOnEsc']}', + root: '{$config['root']}' + }); + } + }; + return Lightbox; + });"; + $this->grav['assets'] + ->addCss('plugin://featherlight/css/featherlight.min.css') + ->addInlineJs($init); + } elseif ($config['gallery']) { + $init = $this->getInitJs($config); + $this->grav['assets'] + ->addCss('plugin://featherlight/css/featherlight.min.css') + ->addCss('plugin://featherlight/css/featherlight.gallery.min.css') + ->add('jquery', 101) + ->addJs('plugin://featherlight/js/featherlight.min.js') + ->addJs('plugin://featherlight/js/featherlight.gallery.min.js') + ->addInlineJs($init); + } else { + $init = $this->getInitJs($config); + $this->grav['assets'] + ->addCss('plugin://featherlight/css/featherlight.min.css') + ->add('jquery', 101) + ->addJs('plugin://featherlight/js/featherlight.min.js') + ->addInlineJs($init); + } + } + + protected function getInitJs($config) { + $asset = $this->grav['locator']->findResource($config['initTemplate'], false); + + $init = file_get_contents(ROOT_DIR . $asset); + + $init = str_replace( + array('{pluginName}', '{openSpeed}', '{closeSpeed}', '{closeOnClick}', '{closeOnEsc}', '{root}'), + array( + $config['gallery'] ? 'featherlightGallery' : 'featherlight', + $config['openSpeed'], + $config['closeSpeed'], + $config['closeOnClick'], + $config['closeOnEsc'], + $config['root'] + ), + $init + ); + + return $init; + } +} diff --git a/user/plugins/featherlight/featherlight.yaml b/user/plugins/featherlight/featherlight.yaml new file mode 100644 index 0000000..e1826f0 --- /dev/null +++ b/user/plugins/featherlight/featherlight.yaml @@ -0,0 +1,10 @@ +enabled: true # global enable/disable the entire plugin +active: true # if the plugin is active and JS/CSS should be loaded +gallery: false # enable/disable the gallery extension +requirejs: false # output to an AMD module +openSpeed: 250 # open speed in ms +closeSpeed: 250 # close speed in ms +closeOnClick: background # background|anywhere|false +closeOnEsc: true # true|false on hitting Esc key +root: body # where to append featherlights +initTemplate: plugin://featherlight/js/featherlight.init.js diff --git a/user/plugins/featherlight/hebe.json b/user/plugins/featherlight/hebe.json new file mode 100644 index 0000000..6ccf6c3 --- /dev/null +++ b/user/plugins/featherlight/hebe.json @@ -0,0 +1,15 @@ +{ + "project":"grav-plugin-featherlight", + "platforms":{ + "grav":{ + "nodes":{ + "plugin":[ + { + "source":"/", + "destination":"/user/plugins/featherlight" + } + ] + } + } + } +} diff --git a/user/plugins/featherlight/js/featherlight.gallery.min.js b/user/plugins/featherlight/js/featherlight.gallery.min.js new file mode 100644 index 0000000..bfd8eea --- /dev/null +++ b/user/plugins/featherlight/js/featherlight.gallery.min.js @@ -0,0 +1,7 @@ +/** + * Featherlight Gallery – an extension for the ultra slim jQuery lightbox + * Version 1.7.7 - http://noelboss.github.io/featherlight/ + * + * Copyright 2017, Noël Raoul Bossart (http://www.noelboss.com) + * MIT Licensed. +**/!function(a){"use strict";function b(c,d){if(!(this instanceof b)){var e=new b(a.extend({$source:c,$currentTarget:c.first()},d));return e.open(),e}a.featherlight.apply(this,arguments),this.chainCallbacks(h)}var c=function(a){window.console&&window.console.warn&&window.console.warn("FeatherlightGallery: "+a)};if("undefined"==typeof a)return c("Too much lightness, Featherlight needs jQuery.");if(!a.featherlight)return c("Load the featherlight plugin before the gallery plugin");var d="ontouchstart"in window||window.DocumentTouch&&document instanceof DocumentTouch,e=a.event&&a.event.special.swipeleft&&a,f=window.Hammer&&function(a){var b=new window.Hammer.Manager(a[0]);return b.add(new window.Hammer.Swipe),b},g=d&&(e||f);d&&!g&&c("No compatible swipe library detected; one must be included before featherlightGallery for swipe motions to navigate the galleries.");var h={afterClose:function(a,b){var c=this;return c.$instance.off("next."+c.namespace+" previous."+c.namespace),c._swiper&&(c._swiper.off("swipeleft",c._swipeleft).off("swiperight",c._swiperight),c._swiper=null),a(b)},beforeOpen:function(a,b){var c=this;return c.$instance.on("next."+c.namespace+" previous."+c.namespace,function(a){var b="next"===a.type?1:-1;c.navigateTo(c.currentNavigation()+b)}),g&&(c._swiper=g(c.$instance).on("swipeleft",c._swipeleft=function(){c.$instance.trigger("next")}).on("swiperight",c._swiperight=function(){c.$instance.trigger("previous")}),c.$instance.addClass(this.namespace+"-swipe-aware",g)),c.$instance.find("."+c.namespace+"-content").append(c.createNavigation("previous")).append(c.createNavigation("next")),a(b)},beforeContent:function(a,b){var c=this.currentNavigation(),d=this.slides().length;return this.$instance.toggleClass(this.namespace+"-first-slide",0===c).toggleClass(this.namespace+"-last-slide",c===d-1),a(b)},onKeyUp:function(a,b){var c={37:"previous",39:"next"}[b.keyCode];return c?(this.$instance.trigger(c),!1):a(b)}};a.featherlight.extend(b,{autoBind:"[data-featherlight-gallery]"}),a.extend(b.prototype,{previousIcon:"◀",nextIcon:"▶",galleryFadeIn:100,galleryFadeOut:300,slides:function(){return this.filter?this.$source.find(this.filter):this.$source},images:function(){return c("images is deprecated, please use slides instead"),this.slides()},currentNavigation:function(){return this.slides().index(this.$currentTarget)},navigateTo:function(b){var c=this,d=c.slides(),e=d.length,f=c.$instance.find("."+c.namespace+"-inner");return b=(b%e+e)%e,c.$currentTarget=d.eq(b),c.beforeContent(),a.when(c.getContent(),f.fadeTo(c.galleryFadeOut,.2)).always(function(a){c.setContent(a),c.afterContent(),a.fadeTo(c.galleryFadeIn,1)})},createNavigation:function(b){var c=this;return a(''+this[b+"Icon"]+"").click(function(){a(this).trigger(b+"."+c.namespace)})}}),a.featherlightGallery=b,a.fn.featherlightGallery=function(a){return b.attach(this,a),this},a(document).ready(function(){b._onReady()})}(jQuery); \ No newline at end of file diff --git a/user/plugins/featherlight/js/featherlight.init.js b/user/plugins/featherlight/js/featherlight.init.js new file mode 100644 index 0000000..311d721 --- /dev/null +++ b/user/plugins/featherlight/js/featherlight.init.js @@ -0,0 +1,9 @@ +$(document).ready(function(){ + $('a[rel="lightbox"]').{pluginName}({ + openSpeed: {openSpeed}, + closeSpeed: {closeSpeed}, + closeOnClick: '{closeOnClick}', + closeOnEsc: '{closeOnEsc}', + root: '{root}' + }); +}); diff --git a/user/plugins/featherlight/js/featherlight.min.js b/user/plugins/featherlight/js/featherlight.min.js new file mode 100644 index 0000000..510a57c --- /dev/null +++ b/user/plugins/featherlight/js/featherlight.min.js @@ -0,0 +1,8 @@ +/** + * Featherlight - ultra slim jQuery lightbox + * Version 1.7.7 - http://noelboss.github.io/featherlight/ + * + * Copyright 2017, Noël Raoul Bossart (http://www.noelboss.com) + * MIT Licensed. +**/ +!function(a){"use strict";function b(a,c){if(!(this instanceof b)){var d=new b(a,c);return d.open(),d}this.id=b.id++,this.setup(a,c),this.chainCallbacks(b._callbackChain)}function c(a,b){var c={};for(var d in a)d in b&&(c[d]=a[d],delete a[d]);return c}function d(a,b){var c={},d=new RegExp("^"+b+"([A-Z])(.*)");for(var e in a){var f=e.match(d);if(f){var g=(f[1]+f[2].replace(/([A-Z])/g,"-$1")).toLowerCase();c[g]=a[e]}}return c}if("undefined"==typeof a)return void("console"in window&&window.console.info("Too much lightness, Featherlight needs jQuery."));var e=[],f=function(b){return e=a.grep(e,function(a){return a!==b&&a.$instance.closest("body").length>0})},g={allowfullscreen:1,frameborder:1,height:1,longdesc:1,marginheight:1,marginwidth:1,name:1,referrerpolicy:1,scrolling:1,sandbox:1,src:1,srcdoc:1,width:1},h={keyup:"onKeyUp",resize:"onResize"},i=function(c){a.each(b.opened().reverse(),function(){return c.isDefaultPrevented()||!1!==this[h[c.type]](c)?void 0:(c.preventDefault(),c.stopPropagation(),!1)})},j=function(c){if(c!==b._globalHandlerInstalled){b._globalHandlerInstalled=c;var d=a.map(h,function(a,c){return c+"."+b.prototype.namespace}).join(" ");a(window)[c?"on":"off"](d,i)}};b.prototype={constructor:b,namespace:"featherlight",targetAttr:"data-featherlight",variant:null,resetCss:!1,background:null,openTrigger:"click",closeTrigger:"click",filter:null,root:"body",openSpeed:250,closeSpeed:250,closeOnClick:"background",closeOnEsc:!0,closeIcon:"✕",loading:"",persist:!1,otherClose:null,beforeOpen:a.noop,beforeContent:a.noop,beforeClose:a.noop,afterOpen:a.noop,afterContent:a.noop,afterClose:a.noop,onKeyUp:a.noop,onResize:a.noop,type:null,contentFilters:["jquery","image","html","ajax","iframe","text"],setup:function(b,c){"object"!=typeof b||b instanceof a!=!1||c||(c=b,b=void 0);var d=a.extend(this,c,{target:b}),e=d.resetCss?d.namespace+"-reset":d.namespace,f=a(d.background||['
','
','",'
'+d.loading+"
","
","
"].join("")),g="."+d.namespace+"-close"+(d.otherClose?","+d.otherClose:"");return d.$instance=f.clone().addClass(d.variant),d.$instance.on(d.closeTrigger+"."+d.namespace,function(b){var c=a(b.target);("background"===d.closeOnClick&&c.is("."+d.namespace)||"anywhere"===d.closeOnClick||c.closest(g).length)&&(d.close(b),b.preventDefault())}),this},getContent:function(){if(this.persist!==!1&&this.$content)return this.$content;var b=this,c=this.constructor.contentFilters,d=function(a){return b.$currentTarget&&b.$currentTarget.attr(a)},e=d(b.targetAttr),f=b.target||e||"",g=c[b.type];if(!g&&f in c&&(g=c[f],f=b.target&&e),f=f||d("href")||"",!g)for(var h in c)b[h]&&(g=c[h],f=b[h]);if(!g){var i=f;if(f=null,a.each(b.contentFilters,function(){return g=c[this],g.test&&(f=g.test(i)),!f&&g.regex&&i.match&&i.match(g.regex)&&(f=i),!f}),!f)return"console"in window&&window.console.error("Featherlight: no content filter found "+(i?' for "'+i+'"':" (no target specified)")),!1}return g.process.call(b,f)},setContent:function(b){var c=this;return b.is("iframe")&&c.$instance.addClass(c.namespace+"-iframe"),c.$instance.removeClass(c.namespace+"-loading"),c.$instance.find("."+c.namespace+"-inner").not(b).slice(1).remove().end().replaceWith(a.contains(c.$instance[0],b[0])?"":b),c.$content=b.addClass(c.namespace+"-inner"),c},open:function(b){var c=this;if(c.$instance.hide().appendTo(c.root),!(b&&b.isDefaultPrevented()||c.beforeOpen(b)===!1)){b&&b.preventDefault();var d=c.getContent();if(d)return e.push(c),j(!0),c.$instance.fadeIn(c.openSpeed),c.beforeContent(b),a.when(d).always(function(a){c.setContent(a),c.afterContent(b)}).then(c.$instance.promise()).done(function(){c.afterOpen(b)})}return c.$instance.detach(),a.Deferred().reject().promise()},close:function(b){var c=this,d=a.Deferred();return c.beforeClose(b)===!1?d.reject():(0===f(c).length&&j(!1),c.$instance.fadeOut(c.closeSpeed,function(){c.$instance.detach(),c.afterClose(b),d.resolve()})),d.promise()},resize:function(a,b){if(a&&b){this.$content.css("width","").css("height","");var c=Math.max(a/(this.$content.parent().width()-1),b/(this.$content.parent().height()-1));c>1&&(c=b/Math.floor(b/c),this.$content.css("width",""+a/c+"px").css("height",""+b/c+"px"))}},chainCallbacks:function(b){for(var c in b)this[c]=a.proxy(b[c],this,a.proxy(this[c],this))}},a.extend(b,{id:0,autoBind:"[data-featherlight]",defaults:b.prototype,contentFilters:{jquery:{regex:/^[#.]\w/,test:function(b){return b instanceof a&&b},process:function(b){return this.persist!==!1?a(b):a(b).clone(!0)}},image:{regex:/\.(png|jpg|jpeg|gif|tiff|bmp|svg)(\?\S*)?$/i,process:function(b){var c=this,d=a.Deferred(),e=new Image,f=a('');return e.onload=function(){f.naturalWidth=e.width,f.naturalHeight=e.height,d.resolve(f)},e.onerror=function(){d.reject(f)},e.src=b,d.promise()}},html:{regex:/^\s*<[\w!][^<]*>/,process:function(b){return a(b)}},ajax:{regex:/./,process:function(b){var c=a.Deferred(),d=a("
").load(b,function(a,b){"error"!==b&&c.resolve(d.contents()),c.fail()});return c.promise()}},iframe:{process:function(b){var e=new a.Deferred,f=a("