Personal blog written from scratch using Node.js, Bootstrap, and MySQL. https://jrtechs.net
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3364 lines
110 KiB

  1. /*! lightgallery - v1.6.12 - 2019-02-19
  2. * http://sachinchoolur.github.io/lightGallery/
  3. * Copyright (c) 2019 Sachin N; Licensed GPLv3 */
  4. /*! lightgallery - v1.6.12 - 2019-02-19
  5. * http://sachinchoolur.github.io/lightGallery/
  6. * Copyright (c) 2019 Sachin N; Licensed GPLv3 */
  7. (function (root, factory) {
  8. if (typeof define === 'function' && define.amd) {
  9. // AMD. Register as an anonymous module unless amdModuleId is set
  10. define(['jquery'], function (a0) {
  11. return (factory(a0));
  12. });
  13. } else if (typeof module === 'object' && module.exports) {
  14. // Node. Does not work with strict CommonJS, but
  15. // only CommonJS-like environments that support module.exports,
  16. // like Node.
  17. module.exports = factory(require('jquery'));
  18. } else {
  19. factory(root["jQuery"]);
  20. }
  21. }(this, function ($) {
  22. (function() {
  23. 'use strict';
  24. var defaults = {
  25. mode: 'lg-slide',
  26. // Ex : 'ease'
  27. cssEasing: 'ease',
  28. //'for jquery animation'
  29. easing: 'linear',
  30. speed: 600,
  31. height: '100%',
  32. width: '100%',
  33. addClass: '',
  34. startClass: 'lg-start-zoom',
  35. backdropDuration: 150,
  36. hideBarsDelay: 6000,
  37. useLeft: false,
  38. closable: true,
  39. loop: true,
  40. escKey: true,
  41. keyPress: true,
  42. controls: true,
  43. slideEndAnimatoin: true,
  44. hideControlOnEnd: false,
  45. mousewheel: true,
  46. getCaptionFromTitleOrAlt: true,
  47. // .lg-item || '.lg-sub-html'
  48. appendSubHtmlTo: '.lg-sub-html',
  49. subHtmlSelectorRelative: false,
  50. /**
  51. * @desc number of preload slides
  52. * will exicute only after the current slide is fully loaded.
  53. *
  54. * @ex you clicked on 4th image and if preload = 1 then 3rd slide and 5th
  55. * slide will be loaded in the background after the 4th slide is fully loaded..
  56. * if preload is 2 then 2nd 3rd 5th 6th slides will be preloaded.. ... ...
  57. *
  58. */
  59. preload: 1,
  60. showAfterLoad: true,
  61. selector: '',
  62. selectWithin: '',
  63. nextHtml: '',
  64. prevHtml: '',
  65. // 0, 1
  66. index: false,
  67. iframeMaxWidth: '100%',
  68. download: true,
  69. counter: true,
  70. appendCounterTo: '.lg-toolbar',
  71. swipeThreshold: 50,
  72. enableSwipe: true,
  73. enableDrag: true,
  74. dynamic: false,
  75. dynamicEl: [],
  76. galleryId: 1
  77. };
  78. function Plugin(element, options) {
  79. // Current lightGallery element
  80. this.el = element;
  81. // Current jquery element
  82. this.$el = $(element);
  83. // lightGallery settings
  84. this.s = $.extend({}, defaults, options);
  85. // When using dynamic mode, ensure dynamicEl is an array
  86. if (this.s.dynamic && this.s.dynamicEl !== 'undefined' && this.s.dynamicEl.constructor === Array && !this.s.dynamicEl.length) {
  87. throw ('When using dynamic mode, you must also define dynamicEl as an Array.');
  88. }
  89. // lightGallery modules
  90. this.modules = {};
  91. // false when lightgallery complete first slide;
  92. this.lGalleryOn = false;
  93. this.lgBusy = false;
  94. // Timeout function for hiding controls;
  95. this.hideBartimeout = false;
  96. // To determine browser supports for touch events;
  97. this.isTouch = ('ontouchstart' in document.documentElement);
  98. // Disable hideControlOnEnd if sildeEndAnimation is true
  99. if (this.s.slideEndAnimatoin) {
  100. this.s.hideControlOnEnd = false;
  101. }
  102. // Gallery items
  103. if (this.s.dynamic) {
  104. this.$items = this.s.dynamicEl;
  105. } else {
  106. if (this.s.selector === 'this') {
  107. this.$items = this.$el;
  108. } else if (this.s.selector !== '') {
  109. if (this.s.selectWithin) {
  110. this.$items = $(this.s.selectWithin).find(this.s.selector);
  111. } else {
  112. this.$items = this.$el.find($(this.s.selector));
  113. }
  114. } else {
  115. this.$items = this.$el.children();
  116. }
  117. }
  118. // .lg-item
  119. this.$slide = '';
  120. // .lg-outer
  121. this.$outer = '';
  122. this.init();
  123. return this;
  124. }
  125. Plugin.prototype.init = function() {
  126. var _this = this;
  127. // s.preload should not be more than $item.length
  128. if (_this.s.preload > _this.$items.length) {
  129. _this.s.preload = _this.$items.length;
  130. }
  131. // if dynamic option is enabled execute immediately
  132. var _hash = window.location.hash;
  133. if (_hash.indexOf('lg=' + this.s.galleryId) > 0) {
  134. _this.index = parseInt(_hash.split('&slide=')[1], 10);
  135. $('body').addClass('lg-from-hash');
  136. if (!$('body').hasClass('lg-on')) {
  137. setTimeout(function() {
  138. _this.build(_this.index);
  139. });
  140. $('body').addClass('lg-on');
  141. }
  142. }
  143. if (_this.s.dynamic) {
  144. _this.$el.trigger('onBeforeOpen.lg');
  145. _this.index = _this.s.index || 0;
  146. // prevent accidental double execution
  147. if (!$('body').hasClass('lg-on')) {
  148. setTimeout(function() {
  149. _this.build(_this.index);
  150. $('body').addClass('lg-on');
  151. });
  152. }
  153. } else {
  154. // Using different namespace for click because click event should not unbind if selector is same object('this')
  155. _this.$items.on('click.lgcustom', function(event) {
  156. // For IE8
  157. try {
  158. event.preventDefault();
  159. event.preventDefault();
  160. } catch (er) {
  161. event.returnValue = false;
  162. }
  163. _this.$el.trigger('onBeforeOpen.lg');
  164. _this.index = _this.s.index || _this.$items.index(this);
  165. // prevent accidental double execution
  166. if (!$('body').hasClass('lg-on')) {
  167. _this.build(_this.index);
  168. $('body').addClass('lg-on');
  169. }
  170. });
  171. }
  172. };
  173. Plugin.prototype.build = function(index) {
  174. var _this = this;
  175. _this.structure();
  176. // module constructor
  177. $.each($.fn.lightGallery.modules, function(key) {
  178. _this.modules[key] = new $.fn.lightGallery.modules[key](_this.el);
  179. });
  180. // initiate slide function
  181. _this.slide(index, false, false, false);
  182. if (_this.s.keyPress) {
  183. _this.keyPress();
  184. }
  185. if (_this.$items.length > 1) {
  186. _this.arrow();
  187. setTimeout(function() {
  188. _this.enableDrag();
  189. _this.enableSwipe();
  190. }, 50);
  191. if (_this.s.mousewheel) {
  192. _this.mousewheel();
  193. }
  194. } else {
  195. _this.$slide.on('click.lg', function() {
  196. _this.$el.trigger('onSlideClick.lg');
  197. });
  198. }
  199. _this.counter();
  200. _this.closeGallery();
  201. _this.$el.trigger('onAfterOpen.lg');
  202. // Hide controllers if mouse doesn't move for some period
  203. _this.$outer.on('mousemove.lg click.lg touchstart.lg', function() {
  204. _this.$outer.removeClass('lg-hide-items');
  205. clearTimeout(_this.hideBartimeout);
  206. // Timeout will be cleared on each slide movement also
  207. _this.hideBartimeout = setTimeout(function() {
  208. _this.$outer.addClass('lg-hide-items');
  209. }, _this.s.hideBarsDelay);
  210. });
  211. _this.$outer.trigger('mousemove.lg');
  212. };
  213. Plugin.prototype.structure = function() {
  214. var list = '';
  215. var controls = '';
  216. var i = 0;
  217. var subHtmlCont = '';
  218. var template;
  219. var _this = this;
  220. $('body').append('<div class="lg-backdrop"></div>');
  221. $('.lg-backdrop').css('transition-duration', this.s.backdropDuration + 'ms');
  222. // Create gallery items
  223. for (i = 0; i < this.$items.length; i++) {
  224. list += '<div class="lg-item"></div>';
  225. }
  226. // Create controlls
  227. if (this.s.controls && this.$items.length > 1) {
  228. controls = '<div class="lg-actions">' +
  229. '<button class="lg-prev lg-icon">' + this.s.prevHtml + '</button>' +
  230. '<button class="lg-next lg-icon">' + this.s.nextHtml + '</button>' +
  231. '</div>';
  232. }
  233. if (this.s.appendSubHtmlTo === '.lg-sub-html') {
  234. subHtmlCont = '<div class="lg-sub-html"></div>';
  235. }
  236. template = '<div class="lg-outer ' + this.s.addClass + ' ' + this.s.startClass + '">' +
  237. '<div class="lg" style="width:' + this.s.width + '; height:' + this.s.height + '">' +
  238. '<div class="lg-inner">' + list + '</div>' +
  239. '<div class="lg-toolbar lg-group">' +
  240. '<span class="lg-close lg-icon"></span>' +
  241. '</div>' +
  242. controls +
  243. subHtmlCont +
  244. '</div>' +
  245. '</div>';
  246. $('body').append(template);
  247. this.$outer = $('.lg-outer');
  248. this.$slide = this.$outer.find('.lg-item');
  249. if (this.s.useLeft) {
  250. this.$outer.addClass('lg-use-left');
  251. // Set mode lg-slide if use left is true;
  252. this.s.mode = 'lg-slide';
  253. } else {
  254. this.$outer.addClass('lg-use-css3');
  255. }
  256. // For fixed height gallery
  257. _this.setTop();
  258. $(window).on('resize.lg orientationchange.lg', function() {
  259. setTimeout(function() {
  260. _this.setTop();
  261. }, 100);
  262. });
  263. // add class lg-current to remove initial transition
  264. this.$slide.eq(this.index).addClass('lg-current');
  265. // add Class for css support and transition mode
  266. if (this.doCss()) {
  267. this.$outer.addClass('lg-css3');
  268. } else {
  269. this.$outer.addClass('lg-css');
  270. // Set speed 0 because no animation will happen if browser doesn't support css3
  271. this.s.speed = 0;
  272. }
  273. this.$outer.addClass(this.s.mode);
  274. if (this.s.enableDrag && this.$items.length > 1) {
  275. this.$outer.addClass('lg-grab');
  276. }
  277. if (this.s.showAfterLoad) {
  278. this.$outer.addClass('lg-show-after-load');
  279. }
  280. if (this.doCss()) {
  281. var $inner = this.$outer.find('.lg-inner');
  282. $inner.css('transition-timing-function', this.s.cssEasing);
  283. $inner.css('transition-duration', this.s.speed + 'ms');
  284. }
  285. setTimeout(function() {
  286. $('.lg-backdrop').addClass('in');
  287. });
  288. setTimeout(function() {
  289. _this.$outer.addClass('lg-visible');
  290. }, this.s.backdropDuration);
  291. if (this.s.download) {
  292. this.$outer.find('.lg-toolbar').append('<a id="lg-download" target="_blank" download class="lg-download lg-icon"></a>');
  293. }
  294. // Store the current scroll top value to scroll back after closing the gallery..
  295. this.prevScrollTop = $(window).scrollTop();
  296. };
  297. // For fixed height gallery
  298. Plugin.prototype.setTop = function() {
  299. if (this.s.height !== '100%') {
  300. var wH = $(window).height();
  301. var top = (wH - parseInt(this.s.height, 10)) / 2;
  302. var $lGallery = this.$outer.find('.lg');
  303. if (wH >= parseInt(this.s.height, 10)) {
  304. $lGallery.css('top', top + 'px');
  305. } else {
  306. $lGallery.css('top', '0px');
  307. }
  308. }
  309. };
  310. // Find css3 support
  311. Plugin.prototype.doCss = function() {
  312. // check for css animation support
  313. var support = function() {
  314. var transition = ['transition', 'MozTransition', 'WebkitTransition', 'OTransition', 'msTransition', 'KhtmlTransition'];
  315. var root = document.documentElement;
  316. var i = 0;
  317. for (i = 0; i < transition.length; i++) {
  318. if (transition[i] in root.style) {
  319. return true;
  320. }
  321. }
  322. };
  323. if (support()) {
  324. return true;
  325. }
  326. return false;
  327. };
  328. /**
  329. * @desc Check the given src is video
  330. * @param {String} src
  331. * @return {Object} video type
  332. * Ex:{ youtube : ["//www.youtube.com/watch?v=c0asJgSyxcY", "c0asJgSyxcY"] }
  333. */
  334. Plugin.prototype.isVideo = function(src, index) {
  335. var html;
  336. if (this.s.dynamic) {
  337. html = this.s.dynamicEl[index].html;
  338. } else {
  339. html = this.$items.eq(index).attr('data-html');
  340. }
  341. if (!src) {
  342. if(html) {
  343. return {
  344. html5: true
  345. };
  346. } else {
  347. console.error('lightGallery :- data-src is not pvovided on slide item ' + (index + 1) + '. Please make sure the selector property is properly configured. More info - http://sachinchoolur.github.io/lightGallery/demos/html-markup.html');
  348. return false;
  349. }
  350. }
  351. var youtube = src.match(/\/\/(?:www\.)?youtu(?:\.be|be\.com|be-nocookie\.com)\/(?:watch\?v=|embed\/)?([a-z0-9\-\_\%]+)/i);
  352. var vimeo = src.match(/\/\/(?:www\.)?vimeo.com\/([0-9a-z\-_]+)/i);
  353. var dailymotion = src.match(/\/\/(?:www\.)?dai.ly\/([0-9a-z\-_]+)/i);
  354. var vk = src.match(/\/\/(?:www\.)?(?:vk\.com|vkontakte\.ru)\/(?:video_ext\.php\?)(.*)/i);
  355. if (youtube) {
  356. return {
  357. youtube: youtube
  358. };
  359. } else if (vimeo) {
  360. return {
  361. vimeo: vimeo
  362. };
  363. } else if (dailymotion) {
  364. return {
  365. dailymotion: dailymotion
  366. };
  367. } else if (vk) {
  368. return {
  369. vk: vk
  370. };
  371. }
  372. };
  373. /**
  374. * @desc Create image counter
  375. * Ex: 1/10
  376. */
  377. Plugin.prototype.counter = function() {
  378. if (this.s.counter) {
  379. $(this.s.appendCounterTo).append('<div id="lg-counter"><span id="lg-counter-current">' + (parseInt(this.index, 10) + 1) + '</span> / <span id="lg-counter-all">' + this.$items.length + '</span></div>');
  380. }
  381. };
  382. /**
  383. * @desc add sub-html into the slide
  384. * @param {Number} index - index of the slide
  385. */
  386. Plugin.prototype.addHtml = function(index) {
  387. var subHtml = null;
  388. var subHtmlUrl;
  389. var $currentEle;
  390. if (this.s.dynamic) {
  391. if (this.s.dynamicEl[index].subHtmlUrl) {
  392. subHtmlUrl = this.s.dynamicEl[index].subHtmlUrl;
  393. } else {
  394. subHtml = this.s.dynamicEl[index].subHtml;
  395. }
  396. } else {
  397. $currentEle = this.$items.eq(index);
  398. if ($currentEle.attr('data-sub-html-url')) {
  399. subHtmlUrl = $currentEle.attr('data-sub-html-url');
  400. } else {
  401. subHtml = $currentEle.attr('data-sub-html');
  402. if (this.s.getCaptionFromTitleOrAlt && !subHtml) {
  403. subHtml = $currentEle.attr('title') || $currentEle.find('img').first().attr('alt');
  404. }
  405. }
  406. }
  407. if (!subHtmlUrl) {
  408. if (typeof subHtml !== 'undefined' && subHtml !== null) {
  409. // get first letter of subhtml
  410. // if first letter starts with . or # get the html form the jQuery object
  411. var fL = subHtml.substring(0, 1);
  412. if (fL === '.' || fL === '#') {
  413. if (this.s.subHtmlSelectorRelative && !this.s.dynamic) {
  414. subHtml = $currentEle.find(subHtml).html();
  415. } else {
  416. subHtml = $(subHtml).html();
  417. }
  418. }
  419. } else {
  420. subHtml = '';
  421. }
  422. }
  423. if (this.s.appendSubHtmlTo === '.lg-sub-html') {
  424. if (subHtmlUrl) {
  425. this.$outer.find(this.s.appendSubHtmlTo).load(subHtmlUrl);
  426. } else {
  427. this.$outer.find(this.s.appendSubHtmlTo).html(subHtml);
  428. }
  429. } else {
  430. if (subHtmlUrl) {
  431. this.$slide.eq(index).load(subHtmlUrl);
  432. } else {
  433. this.$slide.eq(index).append(subHtml);
  434. }
  435. }
  436. // Add lg-empty-html class if title doesn't exist
  437. if (typeof subHtml !== 'undefined' && subHtml !== null) {
  438. if (subHtml === '') {
  439. this.$outer.find(this.s.appendSubHtmlTo).addClass('lg-empty-html');
  440. } else {
  441. this.$outer.find(this.s.appendSubHtmlTo).removeClass('lg-empty-html');
  442. }
  443. }
  444. this.$el.trigger('onAfterAppendSubHtml.lg', [index]);
  445. };
  446. /**
  447. * @desc Preload slides
  448. * @param {Number} index - index of the slide
  449. */
  450. Plugin.prototype.preload = function(index) {
  451. var i = 1;
  452. var j = 1;
  453. for (i = 1; i <= this.s.preload; i++) {
  454. if (i >= this.$items.length - index) {
  455. break;
  456. }
  457. this.loadContent(index + i, false, 0);
  458. }
  459. for (j = 1; j <= this.s.preload; j++) {
  460. if (index - j < 0) {
  461. break;
  462. }
  463. this.loadContent(index - j, false, 0);
  464. }
  465. };
  466. /**
  467. * @desc Load slide content into slide.
  468. * @param {Number} index - index of the slide.
  469. * @param {Boolean} rec - if true call loadcontent() function again.
  470. * @param {Boolean} delay - delay for adding complete class. it is 0 except first time.
  471. */
  472. Plugin.prototype.loadContent = function(index, rec, delay) {
  473. var _this = this;
  474. var _hasPoster = false;
  475. var _$img;
  476. var _src;
  477. var _poster;
  478. var _srcset;
  479. var _sizes;
  480. var _html;
  481. var getResponsiveSrc = function(srcItms) {
  482. var rsWidth = [];
  483. var rsSrc = [];
  484. for (var i = 0; i < srcItms.length; i++) {
  485. var __src = srcItms[i].split(' ');
  486. // Manage empty space
  487. if (__src[0] === '') {
  488. __src.splice(0, 1);
  489. }
  490. rsSrc.push(__src[0]);
  491. rsWidth.push(__src[1]);
  492. }
  493. var wWidth = $(window).width();
  494. for (var j = 0; j < rsWidth.length; j++) {
  495. if (parseInt(rsWidth[j], 10) > wWidth) {
  496. _src = rsSrc[j];
  497. break;
  498. }
  499. }
  500. };
  501. if (_this.s.dynamic) {
  502. if (_this.s.dynamicEl[index].poster) {
  503. _hasPoster = true;
  504. _poster = _this.s.dynamicEl[index].poster;
  505. }
  506. _html = _this.s.dynamicEl[index].html;
  507. _src = _this.s.dynamicEl[index].src;
  508. if (_this.s.dynamicEl[index].responsive) {
  509. var srcDyItms = _this.s.dynamicEl[index].responsive.split(',');
  510. getResponsiveSrc(srcDyItms);
  511. }
  512. _srcset = _this.s.dynamicEl[index].srcset;
  513. _sizes = _this.s.dynamicEl[index].sizes;
  514. } else {
  515. if (_this.$items.eq(index).attr('data-poster')) {
  516. _hasPoster = true;
  517. _poster = _this.$items.eq(index).attr('data-poster');
  518. }
  519. _html = _this.$items.eq(index).attr('data-html');
  520. _src = _this.$items.eq(index).attr('href') || _this.$items.eq(index).attr('data-src');
  521. if (_this.$items.eq(index).attr('data-responsive')) {
  522. var srcItms = _this.$items.eq(index).attr('data-responsive').split(',');
  523. getResponsiveSrc(srcItms);
  524. }
  525. _srcset = _this.$items.eq(index).attr('data-srcset');
  526. _sizes = _this.$items.eq(index).attr('data-sizes');
  527. }
  528. //if (_src || _srcset || _sizes || _poster) {
  529. var iframe = false;
  530. if (_this.s.dynamic) {
  531. if (_this.s.dynamicEl[index].iframe) {
  532. iframe = true;
  533. }
  534. } else {
  535. if (_this.$items.eq(index).attr('data-iframe') === 'true') {
  536. iframe = true;
  537. }
  538. }
  539. var _isVideo = _this.isVideo(_src, index);
  540. if (!_this.$slide.eq(index).hasClass('lg-loaded')) {
  541. if (iframe) {
  542. _this.$slide.eq(index).prepend('<div class="lg-video-cont lg-has-iframe" style="max-width:' + _this.s.iframeMaxWidth + '"><div class="lg-video"><iframe class="lg-object" frameborder="0" src="' + _src + '" allowfullscreen="true"></iframe></div></div>');
  543. } else if (_hasPoster) {
  544. var videoClass = '';
  545. if (_isVideo && _isVideo.youtube) {
  546. videoClass = 'lg-has-youtube';
  547. } else if (_isVideo && _isVideo.vimeo) {
  548. videoClass = 'lg-has-vimeo';
  549. } else {
  550. videoClass = 'lg-has-html5';
  551. }
  552. _this.$slide.eq(index).prepend('<div class="lg-video-cont ' + videoClass + ' "><div class="lg-video"><span class="lg-video-play"></span><img class="lg-object lg-has-poster" src="' + _poster + '" /></div></div>');
  553. } else if (_isVideo) {
  554. _this.$slide.eq(index).prepend('<div class="lg-video-cont "><div class="lg-video"></div></div>');
  555. _this.$el.trigger('hasVideo.lg', [index, _src, _html]);
  556. } else {
  557. _this.$slide.eq(index).prepend('<div class="lg-img-wrap"><img class="lg-object lg-image" src="' + _src + '" /></div>');
  558. }
  559. _this.$el.trigger('onAferAppendSlide.lg', [index]);
  560. _$img = _this.$slide.eq(index).find('.lg-object');
  561. if (_sizes) {
  562. _$img.attr('sizes', _sizes);
  563. }
  564. if (_srcset) {
  565. _$img.attr('srcset', _srcset);
  566. try {
  567. picturefill({
  568. elements: [_$img[0]]
  569. });
  570. } catch (e) {
  571. console.warn('lightGallery :- If you want srcset to be supported for older browser please include picturefil version 2 javascript library in your document.');
  572. }
  573. }
  574. if (this.s.appendSubHtmlTo !== '.lg-sub-html') {
  575. _this.addHtml(index);
  576. }
  577. _this.$slide.eq(index).addClass('lg-loaded');
  578. }
  579. _this.$slide.eq(index).find('.lg-object').on('load.lg error.lg', function() {
  580. // For first time add some delay for displaying the start animation.
  581. var _speed = 0;
  582. // Do not change the delay value because it is required for zoom plugin.
  583. // If gallery opened from direct url (hash) speed value should be 0
  584. if (delay && !$('body').hasClass('lg-from-hash')) {
  585. _speed = delay;
  586. }
  587. setTimeout(function() {
  588. _this.$slide.eq(index).addClass('lg-complete');
  589. _this.$el.trigger('onSlideItemLoad.lg', [index, delay || 0]);
  590. }, _speed);
  591. });
  592. // @todo check load state for html5 videos
  593. if (_isVideo && _isVideo.html5 && !_hasPoster) {
  594. _this.$slide.eq(index).addClass('lg-complete');
  595. }
  596. if (rec === true) {
  597. if (!_this.$slide.eq(index).hasClass('lg-complete')) {
  598. _this.$slide.eq(index).find('.lg-object').on('load.lg error.lg', function() {
  599. _this.preload(index);
  600. });
  601. } else {
  602. _this.preload(index);
  603. }
  604. }
  605. //}
  606. };
  607. /**
  608. * @desc slide function for lightgallery
  609. ** Slide() gets call on start
  610. ** ** Set lg.on true once slide() function gets called.
  611. ** Call loadContent() on slide() function inside setTimeout
  612. ** ** On first slide we do not want any animation like slide of fade
  613. ** ** So on first slide( if lg.on if false that is first slide) loadContent() should start loading immediately
  614. ** ** Else loadContent() should wait for the transition to complete.
  615. ** ** So set timeout s.speed + 50
  616. <=> ** loadContent() will load slide content in to the particular slide
  617. ** ** It has recursion (rec) parameter. if rec === true loadContent() will call preload() function.
  618. ** ** preload will execute only when the previous slide is fully loaded (images iframe)
  619. ** ** avoid simultaneous image load
  620. <=> ** Preload() will check for s.preload value and call loadContent() again accoring to preload value
  621. ** loadContent() <====> Preload();
  622. * @param {Number} index - index of the slide
  623. * @param {Boolean} fromTouch - true if slide function called via touch event or mouse drag
  624. * @param {Boolean} fromThumb - true if slide function called via thumbnail click
  625. * @param {String} direction - Direction of the slide(next/prev)
  626. */
  627. Plugin.prototype.slide = function(index, fromTouch, fromThumb, direction) {
  628. var _prevIndex = this.$outer.find('.lg-current').index();
  629. var _this = this;
  630. // Prevent if multiple call
  631. // Required for hsh plugin
  632. if (_this.lGalleryOn && (_prevIndex === index)) {
  633. return;
  634. }
  635. var _length = this.$slide.length;
  636. var _time = _this.lGalleryOn ? this.s.speed : 0;
  637. if (!_this.lgBusy) {
  638. if (this.s.download) {
  639. var _src;
  640. if (_this.s.dynamic) {
  641. _src = _this.s.dynamicEl[index].downloadUrl !== false && (_this.s.dynamicEl[index].downloadUrl || _this.s.dynamicEl[index].src);
  642. } else {
  643. _src = _this.$items.eq(index).attr('data-download-url') !== 'false' && (_this.$items.eq(index).attr('data-download-url') || _this.$items.eq(index).attr('href') || _this.$items.eq(index).attr('data-src'));
  644. }
  645. if (_src) {
  646. $('#lg-download').attr('href', _src);
  647. _this.$outer.removeClass('lg-hide-download');
  648. } else {
  649. _this.$outer.addClass('lg-hide-download');
  650. }
  651. }
  652. this.$el.trigger('onBeforeSlide.lg', [_prevIndex, index, fromTouch, fromThumb]);
  653. _this.lgBusy = true;
  654. clearTimeout(_this.hideBartimeout);
  655. // Add title if this.s.appendSubHtmlTo === lg-sub-html
  656. if (this.s.appendSubHtmlTo === '.lg-sub-html') {
  657. // wait for slide animation to complete
  658. setTimeout(function() {
  659. _this.addHtml(index);
  660. }, _time);
  661. }
  662. this.arrowDisable(index);
  663. if (!direction) {
  664. if (index < _prevIndex) {
  665. direction = 'prev';
  666. } else if (index > _prevIndex) {
  667. direction = 'next';
  668. }
  669. }
  670. if (!fromTouch) {
  671. // remove all transitions
  672. _this.$outer.addClass('lg-no-trans');
  673. this.$slide.removeClass('lg-prev-slide lg-next-slide');
  674. if (direction === 'prev') {
  675. //prevslide
  676. this.$slide.eq(index).addClass('lg-prev-slide');
  677. this.$slide.eq(_prevIndex).addClass('lg-next-slide');
  678. } else {
  679. // next slide
  680. this.$slide.eq(index).addClass('lg-next-slide');
  681. this.$slide.eq(_prevIndex).addClass('lg-prev-slide');
  682. }
  683. // give 50 ms for browser to add/remove class
  684. setTimeout(function() {
  685. _this.$slide.removeClass('lg-current');
  686. //_this.$slide.eq(_prevIndex).removeClass('lg-current');
  687. _this.$slide.eq(index).addClass('lg-current');
  688. // reset all transitions
  689. _this.$outer.removeClass('lg-no-trans');
  690. }, 50);
  691. } else {
  692. this.$slide.removeClass('lg-prev-slide lg-current lg-next-slide');
  693. var touchPrev;
  694. var touchNext;
  695. if (_length > 2) {
  696. touchPrev = index - 1;
  697. touchNext = index + 1;
  698. if ((index === 0) && (_prevIndex === _length - 1)) {
  699. // next slide
  700. touchNext = 0;
  701. touchPrev = _length - 1;
  702. } else if ((index === _length - 1) && (_prevIndex === 0)) {
  703. // prev slide
  704. touchNext = 0;
  705. touchPrev = _length - 1;
  706. }
  707. } else {
  708. touchPrev = 0;
  709. touchNext = 1;
  710. }
  711. if (direction === 'prev') {
  712. _this.$slide.eq(touchNext).addClass('lg-next-slide');
  713. } else {
  714. _this.$slide.eq(touchPrev).addClass('lg-prev-slide');
  715. }
  716. _this.$slide.eq(index).addClass('lg-current');
  717. }
  718. if (_this.lGalleryOn) {
  719. setTimeout(function() {
  720. _this.loadContent(index, true, 0);
  721. }, this.s.speed + 50);
  722. setTimeout(function() {
  723. _this.lgBusy = false;
  724. _this.$el.trigger('onAfterSlide.lg', [_prevIndex, index, fromTouch, fromThumb]);
  725. }, this.s.speed);
  726. } else {
  727. _this.loadContent(index, true, _this.s.backdropDuration);
  728. _this.lgBusy = false;
  729. _this.$el.trigger('onAfterSlide.lg', [_prevIndex, index, fromTouch, fromThumb]);
  730. }
  731. _this.lGalleryOn = true;
  732. if (this.s.counter) {
  733. $('#lg-counter-current').text(index + 1);
  734. }
  735. }
  736. _this.index = index;
  737. };
  738. /**
  739. * @desc Go to next slide
  740. * @param {Boolean} fromTouch - true if slide function called via touch event
  741. */
  742. Plugin.prototype.goToNextSlide = function(fromTouch) {
  743. var _this = this;
  744. var _loop = _this.s.loop;
  745. if (fromTouch && _this.$slide.length < 3) {
  746. _loop = false;
  747. }
  748. if (!_this.lgBusy) {
  749. if ((_this.index + 1) < _this.$slide.length) {
  750. _this.index++;
  751. _this.$el.trigger('onBeforeNextSlide.lg', [_this.index]);
  752. _this.slide(_this.index, fromTouch, false, 'next');
  753. } else {
  754. if (_loop) {
  755. _this.index = 0;
  756. _this.$el.trigger('onBeforeNextSlide.lg', [_this.index]);
  757. _this.slide(_this.index, fromTouch, false, 'next');
  758. } else if (_this.s.slideEndAnimatoin && !fromTouch) {
  759. _this.$outer.addClass('lg-right-end');
  760. setTimeout(function() {
  761. _this.$outer.removeClass('lg-right-end');
  762. }, 400);
  763. }
  764. }
  765. }
  766. };
  767. /**
  768. * @desc Go to previous slide
  769. * @param {Boolean} fromTouch - true if slide function called via touch event
  770. */
  771. Plugin.prototype.goToPrevSlide = function(fromTouch) {
  772. var _this = this;
  773. var _loop = _this.s.loop;
  774. if (fromTouch && _this.$slide.length < 3) {
  775. _loop = false;
  776. }
  777. if (!_this.lgBusy) {
  778. if (_this.index > 0) {
  779. _this.index--;
  780. _this.$el.trigger('onBeforePrevSlide.lg', [_this.index, fromTouch]);
  781. _this.slide(_this.index, fromTouch, false, 'prev');
  782. } else {
  783. if (_loop) {
  784. _this.index = _this.$items.length - 1;
  785. _this.$el.trigger('onBeforePrevSlide.lg', [_this.index, fromTouch]);
  786. _this.slide(_this.index, fromTouch, false, 'prev');
  787. } else if (_this.s.slideEndAnimatoin && !fromTouch) {
  788. _this.$outer.addClass('lg-left-end');
  789. setTimeout(function() {
  790. _this.$outer.removeClass('lg-left-end');
  791. }, 400);
  792. }
  793. }
  794. }
  795. };
  796. Plugin.prototype.keyPress = function() {
  797. var _this = this;
  798. if (this.$items.length > 1) {
  799. $(window).on('keyup.lg', function(e) {
  800. if (_this.$items.length > 1) {
  801. if (e.keyCode === 37) {
  802. e.preventDefault();
  803. _this.goToPrevSlide();
  804. }
  805. if (e.keyCode === 39) {
  806. e.preventDefault();
  807. _this.goToNextSlide();
  808. }
  809. }
  810. });
  811. }
  812. $(window).on('keydown.lg', function(e) {
  813. if (_this.s.escKey === true && e.keyCode === 27) {
  814. e.preventDefault();
  815. if (!_this.$outer.hasClass('lg-thumb-open')) {
  816. _this.destroy();
  817. } else {
  818. _this.$outer.removeClass('lg-thumb-open');
  819. }
  820. }
  821. });
  822. };
  823. Plugin.prototype.arrow = function() {
  824. var _this = this;
  825. this.$outer.find('.lg-prev').on('click.lg', function() {
  826. _this.goToPrevSlide();
  827. });
  828. this.$outer.find('.lg-next').on('click.lg', function() {
  829. _this.goToNextSlide();
  830. });
  831. };
  832. Plugin.prototype.arrowDisable = function(index) {
  833. // Disable arrows if s.hideControlOnEnd is true
  834. if (!this.s.loop && this.s.hideControlOnEnd) {
  835. if ((index + 1) < this.$slide.length) {
  836. this.$outer.find('.lg-next').removeAttr('disabled').removeClass('disabled');
  837. } else {
  838. this.$outer.find('.lg-next').attr('disabled', 'disabled').addClass('disabled');
  839. }
  840. if (index > 0) {
  841. this.$outer.find('.lg-prev').removeAttr('disabled').removeClass('disabled');
  842. } else {
  843. this.$outer.find('.lg-prev').attr('disabled', 'disabled').addClass('disabled');
  844. }
  845. }
  846. };
  847. Plugin.prototype.setTranslate = function($el, xValue, yValue) {
  848. // jQuery supports Automatic CSS prefixing since jQuery 1.8.0
  849. if (this.s.useLeft) {
  850. $el.css('left', xValue);
  851. } else {
  852. $el.css({
  853. transform: 'translate3d(' + (xValue) + 'px, ' + yValue + 'px, 0px)'
  854. });
  855. }
  856. };
  857. Plugin.prototype.touchMove = function(startCoords, endCoords) {
  858. var distance = endCoords - startCoords;
  859. if (Math.abs(distance) > 15) {
  860. // reset opacity and transition duration
  861. this.$outer.addClass('lg-dragging');
  862. // move current slide
  863. this.setTranslate(this.$slide.eq(this.index), distance, 0);
  864. // move next and prev slide with current slide
  865. this.setTranslate($('.lg-prev-slide'), -this.$slide.eq(this.index).width() + distance, 0);
  866. this.setTranslate($('.lg-next-slide'), this.$slide.eq(this.index).width() + distance, 0);
  867. }
  868. };
  869. Plugin.prototype.touchEnd = function(distance) {
  870. var _this = this;
  871. // keep slide animation for any mode while dragg/swipe
  872. if (_this.s.mode !== 'lg-slide') {
  873. _this.$outer.addClass('lg-slide');
  874. }
  875. this.$slide.not('.lg-current, .lg-prev-slide, .lg-next-slide').css('opacity', '0');
  876. // set transition duration
  877. setTimeout(function() {
  878. _this.$outer.removeClass('lg-dragging');
  879. if ((distance < 0) && (Math.abs(distance) > _this.s.swipeThreshold)) {
  880. _this.goToNextSlide(true);
  881. } else if ((distance > 0) && (Math.abs(distance) > _this.s.swipeThreshold)) {
  882. _this.goToPrevSlide(true);
  883. } else if (Math.abs(distance) < 5) {
  884. // Trigger click if distance is less than 5 pix
  885. _this.$el.trigger('onSlideClick.lg');
  886. }
  887. _this.$slide.removeAttr('style');
  888. });
  889. // remove slide class once drag/swipe is completed if mode is not slide
  890. setTimeout(function() {
  891. if (!_this.$outer.hasClass('lg-dragging') && _this.s.mode !== 'lg-slide') {
  892. _this.$outer.removeClass('lg-slide');
  893. }
  894. }, _this.s.speed + 100);
  895. };
  896. Plugin.prototype.enableSwipe = function() {
  897. var _this = this;
  898. var startCoords = 0;
  899. var endCoords = 0;
  900. var isMoved = false;
  901. if (_this.s.enableSwipe && _this.doCss()) {
  902. _this.$slide.on('touchstart.lg', function(e) {
  903. if (!_this.$outer.hasClass('lg-zoomed') && !_this.lgBusy) {
  904. e.preventDefault();
  905. _this.manageSwipeClass();
  906. startCoords = e.originalEvent.targetTouches[0].pageX;
  907. }
  908. });
  909. _this.$slide.on('touchmove.lg', function(e) {
  910. if (!_this.$outer.hasClass('lg-zoomed')) {
  911. e.preventDefault();
  912. endCoords = e.originalEvent.targetTouches[0].pageX;
  913. _this.touchMove(startCoords, endCoords);
  914. isMoved = true;
  915. }
  916. });
  917. _this.$slide.on('touchend.lg', function() {
  918. if (!_this.$outer.hasClass('lg-zoomed')) {
  919. if (isMoved) {
  920. isMoved = false;
  921. _this.touchEnd(endCoords - startCoords);
  922. } else {
  923. _this.$el.trigger('onSlideClick.lg');
  924. }
  925. }
  926. });
  927. }
  928. };
  929. Plugin.prototype.enableDrag = function() {
  930. var _this = this;
  931. var startCoords = 0;
  932. var endCoords = 0;
  933. var isDraging = false;
  934. var isMoved = false;
  935. if (_this.s.enableDrag && _this.doCss()) {
  936. _this.$slide.on('mousedown.lg', function(e) {
  937. if (!_this.$outer.hasClass('lg-zoomed') && !_this.lgBusy && !$(e.target).text().trim()) {
  938. e.preventDefault();
  939. _this.manageSwipeClass();
  940. startCoords = e.pageX;
  941. isDraging = true;
  942. // ** Fix for webkit cursor issue https://code.google.com/p/chromium/issues/detail?id=26723
  943. _this.$outer.scrollLeft += 1;
  944. _this.$outer.scrollLeft -= 1;
  945. // *
  946. _this.$outer.removeClass('lg-grab').addClass('lg-grabbing');
  947. _this.$el.trigger('onDragstart.lg');
  948. }
  949. });
  950. $(window).on('mousemove.lg', function(e) {
  951. if (isDraging) {
  952. isMoved = true;
  953. endCoords = e.pageX;
  954. _this.touchMove(startCoords, endCoords);
  955. _this.$el.trigger('onDragmove.lg');
  956. }
  957. });
  958. $(window).on('mouseup.lg', function(e) {
  959. if (isMoved) {
  960. isMoved = false;
  961. _this.touchEnd(endCoords - startCoords);
  962. _this.$el.trigger('onDragend.lg');
  963. } else if ($(e.target).hasClass('lg-object') || $(e.target).hasClass('lg-video-play')) {
  964. _this.$el.trigger('onSlideClick.lg');
  965. }
  966. // Prevent execution on click
  967. if (isDraging) {
  968. isDraging = false;
  969. _this.$outer.removeClass('lg-grabbing').addClass('lg-grab');
  970. }
  971. });
  972. }
  973. };
  974. Plugin.prototype.manageSwipeClass = function() {
  975. var _touchNext = this.index + 1;
  976. var _touchPrev = this.index - 1;
  977. if (this.s.loop && this.$slide.length > 2) {
  978. if (this.index === 0) {
  979. _touchPrev = this.$slide.length - 1;
  980. } else if (this.index === this.$slide.length - 1) {
  981. _touchNext = 0;
  982. }
  983. }
  984. this.$slide.removeClass('lg-next-slide lg-prev-slide');
  985. if (_touchPrev > -1) {
  986. this.$slide.eq(_touchPrev).addClass('lg-prev-slide');
  987. }
  988. this.$slide.eq(_touchNext).addClass('lg-next-slide');
  989. };
  990. Plugin.prototype.mousewheel = function() {
  991. var _this = this;
  992. _this.$outer.on('mousewheel.lg', function(e) {
  993. if (!e.deltaY) {
  994. return;
  995. }
  996. if (e.deltaY > 0) {
  997. _this.goToPrevSlide();
  998. } else {
  999. _this.goToNextSlide();
  1000. }
  1001. e.preventDefault();
  1002. });
  1003. };
  1004. Plugin.prototype.closeGallery = function() {
  1005. var _this = this;
  1006. var mousedown = false;
  1007. this.$outer.find('.lg-close').on('click.lg', function() {
  1008. _this.destroy();
  1009. });
  1010. if (_this.s.closable) {
  1011. // If you drag the slide and release outside gallery gets close on chrome
  1012. // for preventing this check mousedown and mouseup happened on .lg-item or lg-outer
  1013. _this.$outer.on('mousedown.lg', function(e) {
  1014. if ($(e.target).is('.lg-outer') || $(e.target).is('.lg-item ') || $(e.target).is('.lg-img-wrap')) {
  1015. mousedown = true;
  1016. } else {
  1017. mousedown = false;
  1018. }
  1019. });
  1020. _this.$outer.on('mousemove.lg', function() {
  1021. mousedown = false;
  1022. });
  1023. _this.$outer.on('mouseup.lg', function(e) {
  1024. if ($(e.target).is('.lg-outer') || $(e.target).is('.lg-item ') || $(e.target).is('.lg-img-wrap') && mousedown) {
  1025. if (!_this.$outer.hasClass('lg-dragging')) {
  1026. _this.destroy();
  1027. }
  1028. }
  1029. });
  1030. }
  1031. };
  1032. Plugin.prototype.destroy = function(d) {
  1033. var _this = this;
  1034. if (!d) {
  1035. _this.$el.trigger('onBeforeClose.lg');
  1036. $(window).scrollTop(_this.prevScrollTop);
  1037. }
  1038. /**
  1039. * if d is false or undefined destroy will only close the gallery
  1040. * plugins instance remains with the element
  1041. *
  1042. * if d is true destroy will completely remove the plugin
  1043. */
  1044. if (d) {
  1045. if (!_this.s.dynamic) {
  1046. // only when not using dynamic mode is $items a jquery collection
  1047. this.$items.off('click.lg click.lgcustom');
  1048. }
  1049. $.removeData(_this.el, 'lightGallery');
  1050. }
  1051. // Unbind all events added by lightGallery
  1052. this.$el.off('.lg.tm');
  1053. // Distroy all lightGallery modules
  1054. $.each($.fn.lightGallery.modules, function(key) {
  1055. if (_this.modules[key]) {
  1056. _this.modules[key].destroy();
  1057. }
  1058. });
  1059. this.lGalleryOn = false;
  1060. clearTimeout(_this.hideBartimeout);
  1061. this.hideBartimeout = false;
  1062. $(window).off('.lg');
  1063. $('body').removeClass('lg-on lg-from-hash');
  1064. if (_this.$outer) {
  1065. _this.$outer.removeClass('lg-visible');
  1066. }
  1067. $('.lg-backdrop').removeClass('in');
  1068. setTimeout(function() {
  1069. if (_this.$outer) {
  1070. _this.$outer.remove();
  1071. }
  1072. $('.lg-backdrop').remove();
  1073. if (!d) {
  1074. _this.$el.trigger('onCloseAfter.lg');
  1075. }
  1076. }, _this.s.backdropDuration + 50);
  1077. };
  1078. $.fn.lightGallery = function(options) {
  1079. return this.each(function() {
  1080. if (!$.data(this, 'lightGallery')) {
  1081. $.data(this, 'lightGallery', new Plugin(this, options));
  1082. } else {
  1083. try {
  1084. $(this).data('lightGallery').init();
  1085. } catch (err) {
  1086. console.error('lightGallery has not initiated properly');
  1087. }
  1088. }
  1089. });
  1090. };
  1091. $.fn.lightGallery.modules = {};
  1092. })();
  1093. }));
  1094. /*! lg-autoplay - v1.0.4 - 2017-03-28
  1095. * http://sachinchoolur.github.io/lightGallery
  1096. * Copyright (c) 2017 Sachin N; Licensed GPLv3 */
  1097. (function (root, factory) {
  1098. if (typeof define === 'function' && define.amd) {
  1099. // AMD. Register as an anonymous module unless amdModuleId is set
  1100. define(['jquery'], function (a0) {
  1101. return (factory(a0));
  1102. });
  1103. } else if (typeof exports === 'object') {
  1104. // Node. Does not work with strict CommonJS, but
  1105. // only CommonJS-like environments that support module.exports,
  1106. // like Node.
  1107. module.exports = factory(require('jquery'));
  1108. } else {
  1109. factory(jQuery);
  1110. }
  1111. }(this, function ($) {
  1112. (function() {
  1113. 'use strict';
  1114. var defaults = {
  1115. autoplay: false,
  1116. pause: 5000,
  1117. progressBar: true,
  1118. fourceAutoplay: false,
  1119. autoplayControls: true,
  1120. appendAutoplayControlsTo: '.lg-toolbar'
  1121. };
  1122. /**
  1123. * Creates the autoplay plugin.
  1124. * @param {object} element - lightGallery element
  1125. */
  1126. var Autoplay = function(element) {
  1127. this.core = $(element).data('lightGallery');
  1128. this.$el = $(element);
  1129. // Execute only if items are above 1
  1130. if (this.core.$items.length < 2) {
  1131. return false;
  1132. }
  1133. this.core.s = $.extend({}, defaults, this.core.s);
  1134. this.interval = false;
  1135. // Identify if slide happened from autoplay
  1136. this.fromAuto = true;
  1137. // Identify if autoplay canceled from touch/drag
  1138. this.canceledOnTouch = false;
  1139. // save fourceautoplay value
  1140. this.fourceAutoplayTemp = this.core.s.fourceAutoplay;
  1141. // do not allow progress bar if browser does not support css3 transitions
  1142. if (!this.core.doCss()) {
  1143. this.core.s.progressBar = false;
  1144. }
  1145. this.init();
  1146. return this;
  1147. };
  1148. Autoplay.prototype.init = function() {
  1149. var _this = this;
  1150. // append autoplay controls
  1151. if (_this.core.s.autoplayControls) {
  1152. _this.controls();
  1153. }
  1154. // Create progress bar
  1155. if (_this.core.s.progressBar) {
  1156. _this.core.$outer.find('.lg').append('<div class="lg-progress-bar"><div class="lg-progress"></div></div>');
  1157. }
  1158. // set progress
  1159. _this.progress();
  1160. // Start autoplay
  1161. if (_this.core.s.autoplay) {
  1162. _this.$el.one('onSlideItemLoad.lg.tm', function() {
  1163. _this.startlAuto();
  1164. });
  1165. }
  1166. // cancel interval on touchstart and dragstart
  1167. _this.$el.on('onDragstart.lg.tm touchstart.lg.tm', function() {
  1168. if (_this.interval) {
  1169. _this.cancelAuto();
  1170. _this.canceledOnTouch = true;
  1171. }
  1172. });
  1173. // restore autoplay if autoplay canceled from touchstart / dragstart
  1174. _this.$el.on('onDragend.lg.tm touchend.lg.tm onSlideClick.lg.tm', function() {
  1175. if (!_this.interval && _this.canceledOnTouch) {
  1176. _this.startlAuto();
  1177. _this.canceledOnTouch = false;
  1178. }
  1179. });
  1180. };
  1181. Autoplay.prototype.progress = function() {
  1182. var _this = this;
  1183. var _$progressBar;
  1184. var _$progress;
  1185. _this.$el.on('onBeforeSlide.lg.tm', function() {
  1186. // start progress bar animation
  1187. if (_this.core.s.progressBar && _this.fromAuto) {
  1188. _$progressBar = _this.core.$outer.find('.lg-progress-bar');
  1189. _$progress = _this.core.$outer.find('.lg-progress');
  1190. if (_this.interval) {
  1191. _$progress.removeAttr('style');
  1192. _$progressBar.removeClass('lg-start');
  1193. setTimeout(function() {
  1194. _$progress.css('transition', 'width ' + (_this.core.s.speed + _this.core.s.pause) + 'ms ease 0s');
  1195. _$progressBar.addClass('lg-start');
  1196. }, 20);
  1197. }
  1198. }
  1199. // Remove setinterval if slide is triggered manually and fourceautoplay is false
  1200. if (!_this.fromAuto && !_this.core.s.fourceAutoplay) {
  1201. _this.cancelAuto();
  1202. }
  1203. _this.fromAuto = false;
  1204. });
  1205. };
  1206. // Manage autoplay via play/stop buttons
  1207. Autoplay.prototype.controls = function() {
  1208. var _this = this;
  1209. var _html = '<span class="lg-autoplay-button lg-icon"></span>';
  1210. // Append autoplay controls
  1211. $(this.core.s.appendAutoplayControlsTo).append(_html);
  1212. _this.core.$outer.find('.lg-autoplay-button').on('click.lg', function() {
  1213. if ($(_this.core.$outer).hasClass('lg-show-autoplay')) {
  1214. _this.cancelAuto();
  1215. _this.core.s.fourceAutoplay = false;
  1216. } else {
  1217. if (!_this.interval) {
  1218. _this.startlAuto();
  1219. _this.core.s.fourceAutoplay = _this.fourceAutoplayTemp;
  1220. }
  1221. }
  1222. });
  1223. };
  1224. // Autostart gallery
  1225. Autoplay.prototype.startlAuto = function() {
  1226. var _this = this;
  1227. _this.core.$outer.find('.lg-progress').css('transition', 'width ' + (_this.core.s.speed + _this.core.s.pause) + 'ms ease 0s');
  1228. _this.core.$outer.addClass('lg-show-autoplay');
  1229. _this.core.$outer.find('.lg-progress-bar').addClass('lg-start');
  1230. _this.interval = setInterval(function() {
  1231. if (_this.core.index + 1 < _this.core.$items.length) {
  1232. _this.core.index++;
  1233. } else {
  1234. _this.core.index = 0;
  1235. }
  1236. _this.fromAuto = true;
  1237. _this.core.slide(_this.core.index, false, false, 'next');
  1238. }, _this.core.s.speed + _this.core.s.pause);
  1239. };
  1240. // cancel Autostart
  1241. Autoplay.prototype.cancelAuto = function() {
  1242. clearInterval(this.interval);
  1243. this.interval = false;
  1244. this.core.$outer.find('.lg-progress').removeAttr('style');
  1245. this.core.$outer.removeClass('lg-show-autoplay');
  1246. this.core.$outer.find('.lg-progress-bar').removeClass('lg-start');
  1247. };
  1248. Autoplay.prototype.destroy = function() {
  1249. this.cancelAuto();
  1250. this.core.$outer.find('.lg-progress-bar').remove();
  1251. };
  1252. $.fn.lightGallery.modules.autoplay = Autoplay;
  1253. })();
  1254. }));
  1255. /*! lg-fullscreen - v1.1.0 - 2019-02-19
  1256. * http://sachinchoolur.github.io/lightGallery
  1257. * Copyright (c) 2019 Sachin N; Licensed GPLv3 */
  1258. (function (root, factory) {
  1259. if (typeof define === 'function' && define.amd) {
  1260. // AMD. Register as an anonymous module unless amdModuleId is set
  1261. define(['jquery'], function (a0) {
  1262. return (factory(a0));
  1263. });
  1264. } else if (typeof module === 'object' && module.exports) {
  1265. // Node. Does not work with strict CommonJS, but
  1266. // only CommonJS-like environments that support module.exports,
  1267. // like Node.
  1268. module.exports = factory(require('jquery'));
  1269. } else {
  1270. factory(root["jQuery"]);
  1271. }
  1272. }(this, function ($) {
  1273. (function() {
  1274. 'use strict';
  1275. var defaults = {
  1276. fullScreen: true
  1277. };
  1278. function isFullScreen() {
  1279. return (
  1280. document.fullscreenElement ||
  1281. document.mozFullScreenElement ||
  1282. document.webkitFullscreenElement ||
  1283. document.msFullscreenElement
  1284. );
  1285. }
  1286. var Fullscreen = function(element) {
  1287. // get lightGallery core plugin data
  1288. this.core = $(element).data('lightGallery');
  1289. this.$el = $(element);
  1290. // extend module defalut settings with lightGallery core settings
  1291. this.core.s = $.extend({}, defaults, this.core.s);
  1292. this.init();
  1293. return this;
  1294. };
  1295. Fullscreen.prototype.init = function() {
  1296. var fullScreen = '';
  1297. if (this.core.s.fullScreen) {
  1298. // check for fullscreen browser support
  1299. if (!document.fullscreenEnabled && !document.webkitFullscreenEnabled &&
  1300. !document.mozFullScreenEnabled && !document.msFullscreenEnabled) {
  1301. return;
  1302. } else {
  1303. fullScreen = '<span class="lg-fullscreen lg-icon"></span>';
  1304. this.core.$outer.find('.lg-toolbar').append(fullScreen);
  1305. this.fullScreen();
  1306. }
  1307. }
  1308. };
  1309. Fullscreen.prototype.requestFullscreen = function() {
  1310. var el = document.documentElement;
  1311. if (el.requestFullscreen) {
  1312. el.requestFullscreen();
  1313. } else if (el.msRequestFullscreen) {
  1314. el.msRequestFullscreen();
  1315. } else if (el.mozRequestFullScreen) {
  1316. el.mozRequestFullScreen();
  1317. } else if (el.webkitRequestFullscreen) {
  1318. el.webkitRequestFullscreen();
  1319. }
  1320. };
  1321. Fullscreen.prototype.exitFullscreen = function() {
  1322. if (document.exitFullscreen) {
  1323. document.exitFullscreen();
  1324. } else if (document.msExitFullscreen) {
  1325. document.msExitFullscreen();
  1326. } else if (document.mozCancelFullScreen) {
  1327. document.mozCancelFullScreen();
  1328. } else if (document.webkitExitFullscreen) {
  1329. document.webkitExitFullscreen();
  1330. }
  1331. };
  1332. // https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Using_full_screen_mode
  1333. Fullscreen.prototype.fullScreen = function() {
  1334. var _this = this;
  1335. $(document).on('fullscreenchange.lg webkitfullscreenchange.lg mozfullscreenchange.lg MSFullscreenChange.lg', function() {
  1336. _this.core.$outer.toggleClass('lg-fullscreen-on');
  1337. });
  1338. this.core.$outer.find('.lg-fullscreen').on('click.lg', function() {
  1339. if (isFullScreen()) {
  1340. _this.exitFullscreen();
  1341. } else {
  1342. _this.requestFullscreen();
  1343. }
  1344. });
  1345. };
  1346. Fullscreen.prototype.destroy = function() {
  1347. // exit from fullscreen if activated
  1348. if(isFullScreen()) {
  1349. this.exitFullscreen();
  1350. }
  1351. $(document).off('fullscreenchange.lg webkitfullscreenchange.lg mozfullscreenchange.lg MSFullscreenChange.lg');
  1352. };
  1353. $.fn.lightGallery.modules.fullscreen = Fullscreen;
  1354. })();
  1355. }));
  1356. /*! lg-pager - v1.0.2 - 2017-01-22
  1357. * http://sachinchoolur.github.io/lightGallery
  1358. * Copyright (c) 2017 Sachin N; Licensed GPLv3 */
  1359. (function (root, factory) {
  1360. if (typeof define === 'function' && define.amd) {
  1361. // AMD. Register as an anonymous module unless amdModuleId is set
  1362. define(['jquery'], function (a0) {
  1363. return (factory(a0));
  1364. });
  1365. } else if (typeof exports === 'object') {
  1366. // Node. Does not work with strict CommonJS, but
  1367. // only CommonJS-like environments that support module.exports,
  1368. // like Node.
  1369. module.exports = factory(require('jquery'));
  1370. } else {
  1371. factory(jQuery);
  1372. }
  1373. }(this, function ($) {
  1374. (function() {
  1375. 'use strict';
  1376. var defaults = {
  1377. pager: false
  1378. };
  1379. var Pager = function(element) {
  1380. this.core = $(element).data('lightGallery');
  1381. this.$el = $(element);
  1382. this.core.s = $.extend({}, defaults, this.core.s);
  1383. if (this.core.s.pager && this.core.$items.length > 1) {
  1384. this.init();
  1385. }
  1386. return this;
  1387. };
  1388. Pager.prototype.init = function() {
  1389. var _this = this;
  1390. var pagerList = '';
  1391. var $pagerCont;
  1392. var $pagerOuter;
  1393. var timeout;
  1394. _this.core.$outer.find('.lg').append('<div class="lg-pager-outer"></div>');
  1395. if (_this.core.s.dynamic) {
  1396. for (var i = 0; i < _this.core.s.dynamicEl.length; i++) {
  1397. pagerList += '<span class="lg-pager-cont"> <span class="lg-pager"></span><div class="lg-pager-thumb-cont"><span class="lg-caret"></span> <img src="' + _this.core.s.dynamicEl[i].thumb + '" /></div></span>';
  1398. }
  1399. } else {
  1400. _this.core.$items.each(function() {
  1401. if (!_this.core.s.exThumbImage) {
  1402. pagerList += '<span class="lg-pager-cont"> <span class="lg-pager"></span><div class="lg-pager-thumb-cont"><span class="lg-caret"></span> <img src="' + $(this).find('img').attr('src') + '" /></div></span>';
  1403. } else {
  1404. pagerList += '<span class="lg-pager-cont"> <span class="lg-pager"></span><div class="lg-pager-thumb-cont"><span class="lg-caret"></span> <img src="' + $(this).attr(_this.core.s.exThumbImage) + '" /></div></span>';
  1405. }
  1406. });
  1407. }
  1408. $pagerOuter = _this.core.$outer.find('.lg-pager-outer');
  1409. $pagerOuter.html(pagerList);
  1410. $pagerCont = _this.core.$outer.find('.lg-pager-cont');
  1411. $pagerCont.on('click.lg touchend.lg', function() {
  1412. var _$this = $(this);
  1413. _this.core.index = _$this.index();
  1414. _this.core.slide(_this.core.index, false, true, false);
  1415. });
  1416. $pagerOuter.on('mouseover.lg', function() {
  1417. clearTimeout(timeout);
  1418. $pagerOuter.addClass('lg-pager-hover');
  1419. });
  1420. $pagerOuter.on('mouseout.lg', function() {
  1421. timeout = setTimeout(function() {
  1422. $pagerOuter.removeClass('lg-pager-hover');
  1423. });
  1424. });
  1425. _this.core.$el.on('onBeforeSlide.lg.tm', function(e, prevIndex, index) {
  1426. $pagerCont.removeClass('lg-pager-active');
  1427. $pagerCont.eq(index).addClass('lg-pager-active');
  1428. });
  1429. };
  1430. Pager.prototype.destroy = function() {
  1431. };
  1432. $.fn.lightGallery.modules.pager = Pager;
  1433. })();
  1434. }));
  1435. /*! lg-thumbnail - v1.1.0 - 2017-08-08
  1436. * http://sachinchoolur.github.io/lightGallery
  1437. * Copyright (c) 2017 Sachin N; Licensed GPLv3 */
  1438. (function (root, factory) {
  1439. if (typeof define === 'function' && define.amd) {
  1440. // AMD. Register as an anonymous module unless amdModuleId is set
  1441. define(['jquery'], function (a0) {
  1442. return (factory(a0));
  1443. });
  1444. } else if (typeof exports === 'object') {
  1445. // Node. Does not work with strict CommonJS, but
  1446. // only CommonJS-like environments that support module.exports,
  1447. // like Node.
  1448. module.exports = factory(require('jquery'));
  1449. } else {
  1450. factory(jQuery);
  1451. }
  1452. }(this, function ($) {
  1453. (function() {
  1454. 'use strict';
  1455. var defaults = {
  1456. thumbnail: true,
  1457. animateThumb: true,
  1458. currentPagerPosition: 'middle',
  1459. thumbWidth: 100,
  1460. thumbHeight: '80px',
  1461. thumbContHeight: 100,
  1462. thumbMargin: 5,
  1463. exThumbImage: false,
  1464. showThumbByDefault: true,
  1465. toogleThumb: true,
  1466. pullCaptionUp: true,
  1467. enableThumbDrag: true,
  1468. enableThumbSwipe: true,
  1469. swipeThreshold: 50,
  1470. loadYoutubeThumbnail: true,
  1471. youtubeThumbSize: 1,
  1472. loadVimeoThumbnail: true,
  1473. vimeoThumbSize: 'thumbnail_small',
  1474. loadDailymotionThumbnail: true
  1475. };
  1476. var Thumbnail = function(element) {
  1477. // get lightGallery core plugin data
  1478. this.core = $(element).data('lightGallery');
  1479. // extend module default settings with lightGallery core settings
  1480. this.core.s = $.extend({}, defaults, this.core.s);
  1481. this.$el = $(element);
  1482. this.$thumbOuter = null;
  1483. this.thumbOuterWidth = 0;
  1484. this.thumbTotalWidth = (this.core.$items.length * (this.core.s.thumbWidth + this.core.s.thumbMargin));
  1485. this.thumbIndex = this.core.index;
  1486. if (this.core.s.animateThumb) {
  1487. this.core.s.thumbHeight = '100%';
  1488. }
  1489. // Thumbnail animation value
  1490. this.left = 0;
  1491. this.init();
  1492. return this;
  1493. };
  1494. Thumbnail.prototype.init = function() {
  1495. var _this = this;
  1496. if (this.core.s.thumbnail && this.core.$items.length > 1) {
  1497. if (this.core.s.showThumbByDefault) {
  1498. setTimeout(function(){
  1499. _this.core.$outer.addClass('lg-thumb-open');
  1500. }, 700);
  1501. }
  1502. if (this.core.s.pullCaptionUp) {
  1503. this.core.$outer.addClass('lg-pull-caption-up');
  1504. }
  1505. this.build();
  1506. if (this.core.s.animateThumb && this.core.doCss()) {
  1507. if (this.core.s.enableThumbDrag) {
  1508. this.enableThumbDrag();
  1509. }
  1510. if (this.core.s.enableThumbSwipe) {
  1511. this.enableThumbSwipe();
  1512. }
  1513. this.thumbClickable = false;
  1514. } else {
  1515. this.thumbClickable = true;
  1516. }
  1517. this.toogle();
  1518. this.thumbkeyPress();
  1519. }
  1520. };
  1521. Thumbnail.prototype.build = function() {
  1522. var _this = this;
  1523. var thumbList = '';
  1524. var vimeoErrorThumbSize = '';
  1525. var $thumb;
  1526. var html = '<div class="lg-thumb-outer">' +
  1527. '<div class="lg-thumb lg-group">' +
  1528. '</div>' +
  1529. '</div>';
  1530. switch (this.core.s.vimeoThumbSize) {
  1531. case 'thumbnail_large':
  1532. vimeoErrorThumbSize = '640';
  1533. break;
  1534. case 'thumbnail_medium':
  1535. vimeoErrorThumbSize = '200x150';
  1536. break;
  1537. case 'thumbnail_small':
  1538. vimeoErrorThumbSize = '100x75';
  1539. }
  1540. _this.core.$outer.addClass('lg-has-thumb');
  1541. _this.core.$outer.find('.lg').append(html);
  1542. _this.$thumbOuter = _this.core.$outer.find('.lg-thumb-outer');
  1543. _this.thumbOuterWidth = _this.$thumbOuter.width();
  1544. if (_this.core.s.animateThumb) {
  1545. _this.core.$outer.find('.lg-thumb').css({
  1546. width: _this.thumbTotalWidth + 'px',
  1547. position: 'relative'
  1548. });
  1549. }
  1550. if (this.core.s.animateThumb) {
  1551. _this.$thumbOuter.css('height', _this.core.s.thumbContHeight + 'px');
  1552. }
  1553. function getThumb(src, thumb, index) {
  1554. var isVideo = _this.core.isVideo(src, index) || {};
  1555. var thumbImg;
  1556. var vimeoId = '';
  1557. if (isVideo.youtube || isVideo.vimeo || isVideo.dailymotion) {
  1558. if (isVideo.youtube) {
  1559. if (_this.core.s.loadYoutubeThumbnail) {
  1560. thumbImg = '//img.youtube.com/vi/' + isVideo.youtube[1] + '/' + _this.core.s.youtubeThumbSize + '.jpg';
  1561. } else {
  1562. thumbImg = thumb;
  1563. }
  1564. } else if (isVideo.vimeo) {
  1565. if (_this.core.s.loadVimeoThumbnail) {
  1566. thumbImg = '//i.vimeocdn.com/video/error_' + vimeoErrorThumbSize + '.jpg';
  1567. vimeoId = isVideo.vimeo[1];
  1568. } else {
  1569. thumbImg = thumb;
  1570. }
  1571. } else if (isVideo.dailymotion) {
  1572. if (_this.core.s.loadDailymotionThumbnail) {
  1573. thumbImg = '//www.dailymotion.com/thumbnail/video/' + isVideo.dailymotion[1];
  1574. } else {
  1575. thumbImg = thumb;
  1576. }
  1577. }
  1578. } else {
  1579. thumbImg = thumb;
  1580. }
  1581. thumbList += '<div data-vimeo-id="' + vimeoId + '" class="lg-thumb-item" style="width:' + _this.core.s.thumbWidth + 'px; height: ' + _this.core.s.thumbHeight + '; margin-right: ' + _this.core.s.thumbMargin + 'px"><img src="' + thumbImg + '" /></div>';
  1582. vimeoId = '';
  1583. }
  1584. if (_this.core.s.dynamic) {
  1585. for (var i = 0; i < _this.core.s.dynamicEl.length; i++) {
  1586. getThumb(_this.core.s.dynamicEl[i].src, _this.core.s.dynamicEl[i].thumb, i);
  1587. }
  1588. } else {
  1589. _this.core.$items.each(function(i) {
  1590. if (!_this.core.s.exThumbImage) {
  1591. getThumb($(this).attr('href') || $(this).attr('data-src'), $(this).find('img').attr('src'), i);
  1592. } else {
  1593. getThumb($(this).attr('href') || $(this).attr('data-src'), $(this).attr(_this.core.s.exThumbImage), i);
  1594. }
  1595. });
  1596. }
  1597. _this.core.$outer.find('.lg-thumb').html(thumbList);
  1598. $thumb = _this.core.$outer.find('.lg-thumb-item');
  1599. // Load vimeo thumbnails
  1600. $thumb.each(function() {
  1601. var $this = $(this);
  1602. var vimeoVideoId = $this.attr('data-vimeo-id');
  1603. if (vimeoVideoId) {
  1604. $.getJSON('//www.vimeo.com/api/v2/video/' + vimeoVideoId + '.json?callback=?', {
  1605. format: 'json'
  1606. }, function(data) {
  1607. $this.find('img').attr('src', data[0][_this.core.s.vimeoThumbSize]);
  1608. });
  1609. }
  1610. });
  1611. // manage active class for thumbnail
  1612. $thumb.eq(_this.core.index).addClass('active');
  1613. _this.core.$el.on('onBeforeSlide.lg.tm', function() {
  1614. $thumb.removeClass('active');
  1615. $thumb.eq(_this.core.index).addClass('active');
  1616. });
  1617. $thumb.on('click.lg touchend.lg', function() {
  1618. var _$this = $(this);
  1619. setTimeout(function() {
  1620. // In IE9 and bellow touch does not support
  1621. // Go to slide if browser does not support css transitions
  1622. if ((_this.thumbClickable && !_this.core.lgBusy) || !_this.core.doCss()) {
  1623. _this.core.index = _$this.index();
  1624. _this.core.slide(_this.core.index, false, true, false);
  1625. }
  1626. }, 50);
  1627. });
  1628. _this.core.$el.on('onBeforeSlide.lg.tm', function() {
  1629. _this.animateThumb(_this.core.index);
  1630. });
  1631. $(window).on('resize.lg.thumb orientationchange.lg.thumb', function() {
  1632. setTimeout(function() {
  1633. _this.animateThumb(_this.core.index);
  1634. _this.thumbOuterWidth = _this.$thumbOuter.width();
  1635. }, 200);
  1636. });
  1637. };
  1638. Thumbnail.prototype.setTranslate = function(value) {
  1639. // jQuery supports Automatic CSS prefixing since jQuery 1.8.0
  1640. this.core.$outer.find('.lg-thumb').css({
  1641. transform: 'translate3d(-' + (value) + 'px, 0px, 0px)'
  1642. });
  1643. };
  1644. Thumbnail.prototype.animateThumb = function(index) {
  1645. var $thumb = this.core.$outer.find('.lg-thumb');
  1646. if (this.core.s.animateThumb) {
  1647. var position;
  1648. switch (this.core.s.currentPagerPosition) {
  1649. case 'left':
  1650. position = 0;
  1651. break;
  1652. case 'middle':
  1653. position = (this.thumbOuterWidth / 2) - (this.core.s.thumbWidth / 2);
  1654. break;
  1655. case 'right':
  1656. position = this.thumbOuterWidth - this.core.s.thumbWidth;
  1657. }
  1658. this.left = ((this.core.s.thumbWidth + this.core.s.thumbMargin) * index - 1) - position;
  1659. if (this.left > (this.thumbTotalWidth - this.thumbOuterWidth)) {
  1660. this.left = this.thumbTotalWidth - this.thumbOuterWidth;
  1661. }
  1662. if (this.left < 0) {
  1663. this.left = 0;
  1664. }
  1665. if (this.core.lGalleryOn) {
  1666. if (!$thumb.hasClass('on')) {
  1667. this.core.$outer.find('.lg-thumb').css('transition-duration', this.core.s.speed + 'ms');
  1668. }
  1669. if (!this.core.doCss()) {
  1670. $thumb.animate({
  1671. left: -this.left + 'px'
  1672. }, this.core.s.speed);
  1673. }
  1674. } else {
  1675. if (!this.core.doCss()) {
  1676. $thumb.css('left', -this.left + 'px');
  1677. }
  1678. }
  1679. this.setTranslate(this.left);
  1680. }
  1681. };
  1682. // Enable thumbnail dragging and swiping
  1683. Thumbnail.prototype.enableThumbDrag = function() {
  1684. var _this = this;
  1685. var startCoords = 0;
  1686. var endCoords = 0;
  1687. var isDraging = false;
  1688. var isMoved = false;
  1689. var tempLeft = 0;
  1690. _this.$thumbOuter.addClass('lg-grab');
  1691. _this.core.$outer.find('.lg-thumb').on('mousedown.lg.thumb', function(e) {
  1692. if (_this.thumbTotalWidth > _this.thumbOuterWidth) {
  1693. // execute only on .lg-object
  1694. e.preventDefault();
  1695. startCoords = e.pageX;
  1696. isDraging = true;
  1697. // ** Fix for webkit cursor issue https://code.google.com/p/chromium/issues/detail?id=26723
  1698. _this.core.$outer.scrollLeft += 1;
  1699. _this.core.$outer.scrollLeft -= 1;
  1700. // *
  1701. _this.thumbClickable = false;
  1702. _this.$thumbOuter.removeClass('lg-grab').addClass('lg-grabbing');
  1703. }
  1704. });
  1705. $(window).on('mousemove.lg.thumb', function(e) {
  1706. if (isDraging) {
  1707. tempLeft = _this.left;
  1708. isMoved = true;
  1709. endCoords = e.pageX;
  1710. _this.$thumbOuter.addClass('lg-dragging');
  1711. tempLeft = tempLeft - (endCoords - startCoords);
  1712. if (tempLeft > (_this.thumbTotalWidth - _this.thumbOuterWidth)) {
  1713. tempLeft = _this.thumbTotalWidth - _this.thumbOuterWidth;
  1714. }
  1715. if (tempLeft < 0) {
  1716. tempLeft = 0;
  1717. }
  1718. // move current slide
  1719. _this.setTranslate(tempLeft);
  1720. }
  1721. });
  1722. $(window).on('mouseup.lg.thumb', function() {
  1723. if (isMoved) {
  1724. isMoved = false;
  1725. _this.$thumbOuter.removeClass('lg-dragging');
  1726. _this.left = tempLeft;
  1727. if (Math.abs(endCoords - startCoords) < _this.core.s.swipeThreshold) {
  1728. _this.thumbClickable = true;
  1729. }
  1730. } else {
  1731. _this.thumbClickable = true;
  1732. }
  1733. if (isDraging) {
  1734. isDraging = false;
  1735. _this.$thumbOuter.removeClass('lg-grabbing').addClass('lg-grab');
  1736. }
  1737. });
  1738. };
  1739. Thumbnail.prototype.enableThumbSwipe = function() {
  1740. var _this = this;
  1741. var startCoords = 0;
  1742. var endCoords = 0;
  1743. var isMoved = false;
  1744. var tempLeft = 0;
  1745. _this.core.$outer.find('.lg-thumb').on('touchstart.lg', function(e) {
  1746. if (_this.thumbTotalWidth > _this.thumbOuterWidth) {
  1747. e.preventDefault();
  1748. startCoords = e.originalEvent.targetTouches[0].pageX;
  1749. _this.thumbClickable = false;
  1750. }
  1751. });
  1752. _this.core.$outer.find('.lg-thumb').on('touchmove.lg', function(e) {
  1753. if (_this.thumbTotalWidth > _this.thumbOuterWidth) {
  1754. e.preventDefault();
  1755. endCoords = e.originalEvent.targetTouches[0].pageX;
  1756. isMoved = true;
  1757. _this.$thumbOuter.addClass('lg-dragging');
  1758. tempLeft = _this.left;
  1759. tempLeft = tempLeft - (endCoords - startCoords);
  1760. if (tempLeft > (_this.thumbTotalWidth - _this.thumbOuterWidth)) {
  1761. tempLeft = _this.thumbTotalWidth - _this.thumbOuterWidth;
  1762. }
  1763. if (tempLeft < 0) {
  1764. tempLeft = 0;
  1765. }
  1766. // move current slide
  1767. _this.setTranslate(tempLeft);
  1768. }
  1769. });
  1770. _this.core.$outer.find('.lg-thumb').on('touchend.lg', function() {
  1771. if (_this.thumbTotalWidth > _this.thumbOuterWidth) {
  1772. if (isMoved) {
  1773. isMoved = false;
  1774. _this.$thumbOuter.removeClass('lg-dragging');
  1775. if (Math.abs(endCoords - startCoords) < _this.core.s.swipeThreshold) {
  1776. _this.thumbClickable = true;
  1777. }
  1778. _this.left = tempLeft;
  1779. } else {
  1780. _this.thumbClickable = true;
  1781. }
  1782. } else {
  1783. _this.thumbClickable = true;
  1784. }
  1785. });
  1786. };
  1787. Thumbnail.prototype.toogle = function() {
  1788. var _this = this;
  1789. if (_this.core.s.toogleThumb) {
  1790. _this.core.$outer.addClass('lg-can-toggle');
  1791. _this.$thumbOuter.append('<span class="lg-toogle-thumb lg-icon"></span>');
  1792. _this.core.$outer.find('.lg-toogle-thumb').on('click.lg', function() {
  1793. _this.core.$outer.toggleClass('lg-thumb-open');
  1794. });
  1795. }
  1796. };
  1797. Thumbnail.prototype.thumbkeyPress = function() {
  1798. var _this = this;
  1799. $(window).on('keydown.lg.thumb', function(e) {
  1800. if (e.keyCode === 38) {
  1801. e.preventDefault();
  1802. _this.core.$outer.addClass('lg-thumb-open');
  1803. } else if (e.keyCode === 40) {
  1804. e.preventDefault();
  1805. _this.core.$outer.removeClass('lg-thumb-open');
  1806. }
  1807. });
  1808. };
  1809. Thumbnail.prototype.destroy = function() {
  1810. if (this.core.s.thumbnail && this.core.$items.length > 1) {
  1811. $(window).off('resize.lg.thumb orientationchange.lg.thumb keydown.lg.thumb');
  1812. this.$thumbOuter.remove();
  1813. this.core.$outer.removeClass('lg-has-thumb');
  1814. }
  1815. };
  1816. $.fn.lightGallery.modules.Thumbnail = Thumbnail;
  1817. })();
  1818. }));
  1819. /*! lg-video - v1.2.2 - 2018-05-01
  1820. * http://sachinchoolur.github.io/lightGallery
  1821. * Copyright (c) 2018 Sachin N; Licensed GPLv3 */
  1822. (function (root, factory) {
  1823. if (typeof define === 'function' && define.amd) {
  1824. // AMD. Register as an anonymous module unless amdModuleId is set
  1825. define(['jquery'], function (a0) {
  1826. return (factory(a0));
  1827. });
  1828. } else if (typeof module === 'object' && module.exports) {
  1829. // Node. Does not work with strict CommonJS, but
  1830. // only CommonJS-like environments that support module.exports,
  1831. // like Node.
  1832. module.exports = factory(require('jquery'));
  1833. } else {
  1834. factory(root["jQuery"]);
  1835. }
  1836. }(this, function ($) {
  1837. (function() {
  1838. 'use strict';
  1839. var defaults = {
  1840. videoMaxWidth: '855px',
  1841. autoplayFirstVideo: true,
  1842. youtubePlayerParams: false,
  1843. vimeoPlayerParams: false,
  1844. dailymotionPlayerParams: false,
  1845. vkPlayerParams: false,
  1846. videojs: false,
  1847. videojsOptions: {}
  1848. };
  1849. var Video = function(element) {
  1850. this.core = $(element).data('lightGallery');
  1851. this.$el = $(element);
  1852. this.core.s = $.extend({}, defaults, this.core.s);
  1853. this.videoLoaded = false;
  1854. this.init();
  1855. return this;
  1856. };
  1857. Video.prototype.init = function() {
  1858. var _this = this;
  1859. // Event triggered when video url found without poster
  1860. _this.core.$el.on('hasVideo.lg.tm', onHasVideo.bind(this));
  1861. // Set max width for video
  1862. _this.core.$el.on('onAferAppendSlide.lg.tm', onAferAppendSlide.bind(this));
  1863. if (_this.core.doCss() && (_this.core.$items.length > 1) && (_this.core.s.enableSwipe || _this.core.s.enableDrag)) {
  1864. _this.core.$el.on('onSlideClick.lg.tm', function() {
  1865. var $el = _this.core.$slide.eq(_this.core.index);
  1866. _this.loadVideoOnclick($el);
  1867. });
  1868. } else {
  1869. // For IE 9 and bellow
  1870. _this.core.$slide.on('click.lg', function() {
  1871. _this.loadVideoOnclick($(this));
  1872. });
  1873. }
  1874. _this.core.$el.on('onBeforeSlide.lg.tm', onBeforeSlide.bind(this));
  1875. _this.core.$el.on('onAfterSlide.lg.tm', function(event, prevIndex) {
  1876. _this.core.$slide.eq(prevIndex).removeClass('lg-video-playing');
  1877. });
  1878. if (_this.core.s.autoplayFirstVideo) {
  1879. _this.core.$el.on('onAferAppendSlide.lg.tm', function (e, index) {
  1880. if (!_this.core.lGalleryOn) {
  1881. var $el = _this.core.$slide.eq(index);
  1882. setTimeout(function () {
  1883. _this.loadVideoOnclick($el);
  1884. }, 100);
  1885. }
  1886. });
  1887. }
  1888. };
  1889. Video.prototype.loadVideo = function(src, addClass, noPoster, index, html) {
  1890. var video = '';
  1891. var autoplay = 1;
  1892. var a = '';
  1893. var isVideo = this.core.isVideo(src, index) || {};
  1894. // Enable autoplay based on setting for first video if poster doesn't exist
  1895. if (noPoster) {
  1896. if (this.videoLoaded) {
  1897. autoplay = 0;
  1898. } else {
  1899. autoplay = this.core.s.autoplayFirstVideo ? 1 : 0;
  1900. }
  1901. }
  1902. if (isVideo.youtube) {
  1903. a = '?wmode=opaque&autoplay=' + autoplay + '&enablejsapi=1';
  1904. if (this.core.s.youtubePlayerParams) {
  1905. a = a + '&' + $.param(this.core.s.youtubePlayerParams);
  1906. }
  1907. video = '<iframe class="lg-video-object lg-youtube ' + addClass + '" width="560" height="315" src="//www.youtube.com/embed/' + isVideo.youtube[1] + a + '" frameborder="0" allowfullscreen></iframe>';
  1908. } else if (isVideo.vimeo) {
  1909. a = '?autoplay=' + autoplay + '&api=1';
  1910. if (this.core.s.vimeoPlayerParams) {
  1911. a = a + '&' + $.param(this.core.s.vimeoPlayerParams);
  1912. }
  1913. video = '<iframe class="lg-video-object lg-vimeo ' + addClass + '" width="560" height="315" src="//player.vimeo.com/video/' + isVideo.vimeo[1] + a + '" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>';
  1914. } else if (isVideo.dailymotion) {
  1915. a = '?wmode=opaque&autoplay=' + autoplay + '&api=postMessage';
  1916. if (this.core.s.dailymotionPlayerParams) {
  1917. a = a + '&' + $.param(this.core.s.dailymotionPlayerParams);
  1918. }
  1919. video = '<iframe class="lg-video-object lg-dailymotion ' + addClass + '" width="560" height="315" src="//www.dailymotion.com/embed/video/' + isVideo.dailymotion[1] + a + '" frameborder="0" allowfullscreen></iframe>';
  1920. } else if (isVideo.html5) {
  1921. var fL = html.substring(0, 1);
  1922. if (fL === '.' || fL === '#') {
  1923. html = $(html).html();
  1924. }
  1925. video = html;
  1926. } else if (isVideo.vk) {
  1927. a = '&autoplay=' + autoplay;
  1928. if (this.core.s.vkPlayerParams) {
  1929. a = a + '&' + $.param(this.core.s.vkPlayerParams);
  1930. }
  1931. video = '<iframe class="lg-video-object lg-vk ' + addClass + '" width="560" height="315" src="//vk.com/video_ext.php?' + isVideo.vk[1] + a + '" frameborder="0" allowfullscreen></iframe>';
  1932. }
  1933. return video;
  1934. };
  1935. Video.prototype.loadVideoOnclick = function($el){
  1936. var _this = this;
  1937. // check slide has poster
  1938. if ($el.find('.lg-object').hasClass('lg-has-poster') && $el.find('.lg-object').is(':visible')) {
  1939. // check already video element present
  1940. if (!$el.hasClass('lg-has-video')) {
  1941. $el.addClass('lg-video-playing lg-has-video');
  1942. var _src;
  1943. var _html;
  1944. var _loadVideo = function(_src, _html) {
  1945. $el.find('.lg-video').append(_this.loadVideo(_src, '', false, _this.core.index, _html));
  1946. if (_html) {
  1947. if (_this.core.s.videojs) {
  1948. try {
  1949. videojs(_this.core.$slide.eq(_this.core.index).find('.lg-html5').get(0), _this.core.s.videojsOptions, function() {
  1950. this.play();
  1951. });
  1952. } catch (e) {
  1953. console.error('Make sure you have included videojs');
  1954. }
  1955. } else {
  1956. _this.core.$slide.eq(_this.core.index).find('.lg-html5').get(0).play();
  1957. }
  1958. }
  1959. };
  1960. if (_this.core.s.dynamic) {
  1961. _src = _this.core.s.dynamicEl[_this.core.index].src;
  1962. _html = _this.core.s.dynamicEl[_this.core.index].html;
  1963. _loadVideo(_src, _html);
  1964. } else {
  1965. _src = _this.core.$items.eq(_this.core.index).attr('href') || _this.core.$items.eq(_this.core.index).attr('data-src');
  1966. _html = _this.core.$items.eq(_this.core.index).attr('data-html');
  1967. _loadVideo(_src, _html);
  1968. }
  1969. var $tempImg = $el.find('.lg-object');
  1970. $el.find('.lg-video').append($tempImg);
  1971. // @todo loading icon for html5 videos also
  1972. // for showing the loading indicator while loading video
  1973. if (!$el.find('.lg-video-object').hasClass('lg-html5')) {
  1974. $el.removeClass('lg-complete');
  1975. $el.find('.lg-video-object').on('load.lg error.lg', function() {
  1976. $el.addClass('lg-complete');
  1977. });
  1978. }
  1979. } else {
  1980. var youtubePlayer = $el.find('.lg-youtube').get(0);
  1981. var vimeoPlayer = $el.find('.lg-vimeo').get(0);
  1982. var dailymotionPlayer = $el.find('.lg-dailymotion').get(0);
  1983. var html5Player = $el.find('.lg-html5').get(0);
  1984. if (youtubePlayer) {
  1985. youtubePlayer.contentWindow.postMessage('{"event":"command","func":"playVideo","args":""}', '*');
  1986. } else if (vimeoPlayer) {
  1987. try {
  1988. $f(vimeoPlayer).api('play');
  1989. } catch (e) {
  1990. console.error('Make sure you have included froogaloop2 js');
  1991. }
  1992. } else if (dailymotionPlayer) {
  1993. dailymotionPlayer.contentWindow.postMessage('play', '*');
  1994. } else if (html5Player) {
  1995. if (_this.core.s.videojs) {
  1996. try {
  1997. videojs(html5Player).play();
  1998. } catch (e) {
  1999. console.error('Make sure you have included videojs');
  2000. }
  2001. } else {
  2002. html5Player.play();
  2003. }
  2004. }
  2005. $el.addClass('lg-video-playing');
  2006. }
  2007. }
  2008. };
  2009. Video.prototype.destroy = function() {
  2010. this.videoLoaded = false;
  2011. };
  2012. function onHasVideo(event, index, src, html) {
  2013. /*jshint validthis:true */
  2014. var _this = this;
  2015. _this.core.$slide.eq(index).find('.lg-video').append(_this.loadVideo(src, 'lg-object', true, index, html));
  2016. if (html) {
  2017. if (_this.core.s.videojs) {
  2018. try {
  2019. videojs(_this.core.$slide.eq(index).find('.lg-html5').get(0), _this.core.s.videojsOptions, function() {
  2020. if (!_this.videoLoaded && _this.core.s.autoplayFirstVideo) {
  2021. this.play();
  2022. }
  2023. });
  2024. } catch (e) {
  2025. console.error('Make sure you have included videojs');
  2026. }
  2027. } else {
  2028. if(!_this.videoLoaded && _this.core.s.autoplayFirstVideo) {
  2029. _this.core.$slide.eq(index).find('.lg-html5').get(0).play();
  2030. }
  2031. }
  2032. }
  2033. }
  2034. function onAferAppendSlide(event, index) {
  2035. /*jshint validthis:true */
  2036. var $videoCont = this.core.$slide.eq(index).find('.lg-video-cont');
  2037. if (!$videoCont.hasClass('lg-has-iframe')) {
  2038. $videoCont.css('max-width', this.core.s.videoMaxWidth);
  2039. this.videoLoaded = true;
  2040. }
  2041. }
  2042. function onBeforeSlide(event, prevIndex, index) {
  2043. /*jshint validthis:true */
  2044. var _this = this;
  2045. var $videoSlide = _this.core.$slide.eq(prevIndex);
  2046. var youtubePlayer = $videoSlide.find('.lg-youtube').get(0);
  2047. var vimeoPlayer = $videoSlide.find('.lg-vimeo').get(0);
  2048. var dailymotionPlayer = $videoSlide.find('.lg-dailymotion').get(0);
  2049. var vkPlayer = $videoSlide.find('.lg-vk').get(0);
  2050. var html5Player = $videoSlide.find('.lg-html5').get(0);
  2051. if (youtubePlayer) {
  2052. youtubePlayer.contentWindow.postMessage('{"event":"command","func":"pauseVideo","args":""}', '*');
  2053. } else if (vimeoPlayer) {
  2054. try {
  2055. $f(vimeoPlayer).api('pause');
  2056. } catch (e) {
  2057. console.error('Make sure you have included froogaloop2 js');
  2058. }
  2059. } else if (dailymotionPlayer) {
  2060. dailymotionPlayer.contentWindow.postMessage('pause', '*');
  2061. } else if (html5Player) {
  2062. if (_this.core.s.videojs) {
  2063. try {
  2064. videojs(html5Player).pause();
  2065. } catch (e) {
  2066. console.error('Make sure you have included videojs');
  2067. }
  2068. } else {
  2069. html5Player.pause();
  2070. }
  2071. } if (vkPlayer) {
  2072. $(vkPlayer).attr('src', $(vkPlayer).attr('src').replace('&autoplay', '&noplay'));
  2073. }
  2074. var _src;
  2075. if (_this.core.s.dynamic) {
  2076. _src = _this.core.s.dynamicEl[index].src;
  2077. } else {
  2078. _src = _this.core.$items.eq(index).attr('href') || _this.core.$items.eq(index).attr('data-src');
  2079. }
  2080. var _isVideo = _this.core.isVideo(_src, index) || {};
  2081. if (_isVideo.youtube || _isVideo.vimeo || _isVideo.dailymotion || _isVideo.vk) {
  2082. _this.core.$outer.addClass('lg-hide-download');
  2083. }
  2084. }
  2085. $.fn.lightGallery.modules.video = Video;
  2086. })();
  2087. }));
  2088. /*! lg-zoom - v1.1.0 - 2017-08-08
  2089. * http://sachinchoolur.github.io/lightGallery
  2090. * Copyright (c) 2017 Sachin N; Licensed GPLv3 */
  2091. (function (root, factory) {
  2092. if (typeof define === 'function' && define.amd) {
  2093. // AMD. Register as an anonymous module unless amdModuleId is set
  2094. define(['jquery'], function (a0) {
  2095. return (factory(a0));
  2096. });
  2097. } else if (typeof exports === 'object') {
  2098. // Node. Does not work with strict CommonJS, but
  2099. // only CommonJS-like environments that support module.exports,
  2100. // like Node.
  2101. module.exports = factory(require('jquery'));
  2102. } else {
  2103. factory(jQuery);
  2104. }
  2105. }(this, function ($) {
  2106. (function() {
  2107. 'use strict';
  2108. var getUseLeft = function() {
  2109. var useLeft = false;
  2110. var isChrome = navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);
  2111. if (isChrome && parseInt(isChrome[2], 10) < 54) {
  2112. useLeft = true;
  2113. }
  2114. return useLeft;
  2115. };
  2116. var defaults = {
  2117. scale: 1,
  2118. zoom: true,
  2119. actualSize: true,
  2120. enableZoomAfter: 300,
  2121. useLeftForZoom: getUseLeft()
  2122. };
  2123. var Zoom = function(element) {
  2124. this.core = $(element).data('lightGallery');
  2125. this.core.s = $.extend({}, defaults, this.core.s);
  2126. if (this.core.s.zoom && this.core.doCss()) {
  2127. this.init();
  2128. // Store the zoomable timeout value just to clear it while closing
  2129. this.zoomabletimeout = false;
  2130. // Set the initial value center
  2131. this.pageX = $(window).width() / 2;
  2132. this.pageY = ($(window).height() / 2) + $(window).scrollTop();
  2133. }
  2134. return this;
  2135. };
  2136. Zoom.prototype.init = function() {
  2137. var _this = this;
  2138. var zoomIcons = '<span id="lg-zoom-in" class="lg-icon"></span><span id="lg-zoom-out" class="lg-icon"></span>';
  2139. if (_this.core.s.actualSize) {
  2140. zoomIcons += '<span id="lg-actual-size" class="lg-icon"></span>';
  2141. }
  2142. if (_this.core.s.useLeftForZoom) {
  2143. _this.core.$outer.addClass('lg-use-left-for-zoom');
  2144. } else {
  2145. _this.core.$outer.addClass('lg-use-transition-for-zoom');
  2146. }
  2147. this.core.$outer.find('.lg-toolbar').append(zoomIcons);
  2148. // Add zoomable class
  2149. _this.core.$el.on('onSlideItemLoad.lg.tm.zoom', function(event, index, delay) {
  2150. // delay will be 0 except first time
  2151. var _speed = _this.core.s.enableZoomAfter + delay;
  2152. // set _speed value 0 if gallery opened from direct url and if it is first slide
  2153. if ($('body').hasClass('lg-from-hash') && delay) {
  2154. // will execute only once
  2155. _speed = 0;
  2156. } else {
  2157. // Remove lg-from-hash to enable starting animation.
  2158. $('body').removeClass('lg-from-hash');
  2159. }
  2160. _this.zoomabletimeout = setTimeout(function() {
  2161. _this.core.$slide.eq(index).addClass('lg-zoomable');
  2162. }, _speed + 30);
  2163. });
  2164. var scale = 1;
  2165. /**
  2166. * @desc Image zoom
  2167. * Translate the wrap and scale the image to get better user experience
  2168. *
  2169. * @param {String} scaleVal - Zoom decrement/increment value
  2170. */
  2171. var zoom = function(scaleVal) {
  2172. var $image = _this.core.$outer.find('.lg-current .lg-image');
  2173. var _x;
  2174. var _y;
  2175. // Find offset manually to avoid issue after zoom
  2176. var offsetX = ($(window).width() - $image.prop('offsetWidth')) / 2;
  2177. var offsetY = (($(window).height() - $image.prop('offsetHeight')) / 2) + $(window).scrollTop();
  2178. _x = _this.pageX - offsetX;
  2179. _y = _this.pageY - offsetY;
  2180. var x = (scaleVal - 1) * (_x);
  2181. var y = (scaleVal - 1) * (_y);
  2182. $image.css('transform', 'scale3d(' + scaleVal + ', ' + scaleVal + ', 1)').attr('data-scale', scaleVal);
  2183. if (_this.core.s.useLeftForZoom) {
  2184. $image.parent().css({
  2185. left: -x + 'px',
  2186. top: -y + 'px'
  2187. }).attr('data-x', x).attr('data-y', y);
  2188. } else {
  2189. $image.parent().css('transform', 'translate3d(-' + x + 'px, -' + y + 'px, 0)').attr('data-x', x).attr('data-y', y);
  2190. }
  2191. };
  2192. var callScale = function() {
  2193. if (scale > 1) {
  2194. _this.core.$outer.addClass('lg-zoomed');
  2195. } else {
  2196. _this.resetZoom();
  2197. }
  2198. if (scale < 1) {
  2199. scale = 1;
  2200. }
  2201. zoom(scale);
  2202. };
  2203. var actualSize = function(event, $image, index, fromIcon) {
  2204. var w = $image.prop('offsetWidth');
  2205. var nw;
  2206. if (_this.core.s.dynamic) {
  2207. nw = _this.core.s.dynamicEl[index].width || $image[0].naturalWidth || w;
  2208. } else {
  2209. nw = _this.core.$items.eq(index).attr('data-width') || $image[0].naturalWidth || w;
  2210. }
  2211. var _scale;
  2212. if (_this.core.$outer.hasClass('lg-zoomed')) {
  2213. scale = 1;
  2214. } else {
  2215. if (nw > w) {
  2216. _scale = nw / w;
  2217. scale = _scale || 2;
  2218. }
  2219. }
  2220. if (fromIcon) {
  2221. _this.pageX = $(window).width() / 2;
  2222. _this.pageY = ($(window).height() / 2) + $(window).scrollTop();
  2223. } else {
  2224. _this.pageX = event.pageX || event.originalEvent.targetTouches[0].pageX;
  2225. _this.pageY = event.pageY || event.originalEvent.targetTouches[0].pageY;
  2226. }
  2227. callScale();
  2228. setTimeout(function() {
  2229. _this.core.$outer.removeClass('lg-grabbing').addClass('lg-grab');
  2230. }, 10);
  2231. };
  2232. var tapped = false;
  2233. // event triggered after appending slide content
  2234. _this.core.$el.on('onAferAppendSlide.lg.tm.zoom', function(event, index) {
  2235. // Get the current element
  2236. var $image = _this.core.$slide.eq(index).find('.lg-image');
  2237. $image.on('dblclick', function(event) {
  2238. actualSize(event, $image, index);
  2239. });
  2240. $image.on('touchstart', function(event) {
  2241. if (!tapped) {
  2242. tapped = setTimeout(function() {
  2243. tapped = null;
  2244. }, 300);
  2245. } else {
  2246. clearTimeout(tapped);
  2247. tapped = null;
  2248. actualSize(event, $image, index);
  2249. }
  2250. event.preventDefault();
  2251. });
  2252. });
  2253. // Update zoom on resize and orientationchange
  2254. $(window).on('resize.lg.zoom scroll.lg.zoom orientationchange.lg.zoom', function() {
  2255. _this.pageX = $(window).width() / 2;
  2256. _this.pageY = ($(window).height() / 2) + $(window).scrollTop();
  2257. zoom(scale);
  2258. });
  2259. $('#lg-zoom-out').on('click.lg', function() {
  2260. if (_this.core.$outer.find('.lg-current .lg-image').length) {
  2261. scale -= _this.core.s.scale;
  2262. callScale();
  2263. }
  2264. });
  2265. $('#lg-zoom-in').on('click.lg', function() {
  2266. if (_this.core.$outer.find('.lg-current .lg-image').length) {
  2267. scale += _this.core.s.scale;
  2268. callScale();
  2269. }
  2270. });
  2271. $('#lg-actual-size').on('click.lg', function(event) {
  2272. actualSize(event, _this.core.$slide.eq(_this.core.index).find('.lg-image'), _this.core.index, true);
  2273. });
  2274. // Reset zoom on slide change
  2275. _this.core.$el.on('onBeforeSlide.lg.tm', function() {
  2276. scale = 1;
  2277. _this.resetZoom();
  2278. });
  2279. // Drag option after zoom
  2280. _this.zoomDrag();
  2281. _this.zoomSwipe();
  2282. };
  2283. // Reset zoom effect
  2284. Zoom.prototype.resetZoom = function() {
  2285. this.core.$outer.removeClass('lg-zoomed');
  2286. this.core.$slide.find('.lg-img-wrap').removeAttr('style data-x data-y');
  2287. this.core.$slide.find('.lg-image').removeAttr('style data-scale');
  2288. // Reset pagx pagy values to center
  2289. this.pageX = $(window).width() / 2;
  2290. this.pageY = ($(window).height() / 2) + $(window).scrollTop();
  2291. };
  2292. Zoom.prototype.zoomSwipe = function() {
  2293. var _this = this;
  2294. var startCoords = {};
  2295. var endCoords = {};
  2296. var isMoved = false;
  2297. // Allow x direction drag
  2298. var allowX = false;
  2299. // Allow Y direction drag
  2300. var allowY = false;
  2301. _this.core.$slide.on('touchstart.lg', function(e) {
  2302. if (_this.core.$outer.hasClass('lg-zoomed')) {
  2303. var $image = _this.core.$slide.eq(_this.core.index).find('.lg-object');
  2304. allowY = $image.prop('offsetHeight') * $image.attr('data-scale') > _this.core.$outer.find('.lg').height();
  2305. allowX = $image.prop('offsetWidth') * $image.attr('data-scale') > _this.core.$outer.find('.lg').width();
  2306. if ((allowX || allowY)) {
  2307. e.preventDefault();
  2308. startCoords = {
  2309. x: e.originalEvent.targetTouches[0].pageX,
  2310. y: e.originalEvent.targetTouches[0].pageY
  2311. };
  2312. }
  2313. }
  2314. });
  2315. _this.core.$slide.on('touchmove.lg', function(e) {
  2316. if (_this.core.$outer.hasClass('lg-zoomed')) {
  2317. var _$el = _this.core.$slide.eq(_this.core.index).find('.lg-img-wrap');
  2318. var distanceX;
  2319. var distanceY;
  2320. e.preventDefault();
  2321. isMoved = true;
  2322. endCoords = {
  2323. x: e.originalEvent.targetTouches[0].pageX,
  2324. y: e.originalEvent.targetTouches[0].pageY
  2325. };
  2326. // reset opacity and transition duration
  2327. _this.core.$outer.addClass('lg-zoom-dragging');
  2328. if (allowY) {
  2329. distanceY = (-Math.abs(_$el.attr('data-y'))) + (endCoords.y - startCoords.y);
  2330. } else {
  2331. distanceY = -Math.abs(_$el.attr('data-y'));
  2332. }
  2333. if (allowX) {
  2334. distanceX = (-Math.abs(_$el.attr('data-x'))) + (endCoords.x - startCoords.x);
  2335. } else {
  2336. distanceX = -Math.abs(_$el.attr('data-x'));
  2337. }
  2338. if ((Math.abs(endCoords.x - startCoords.x) > 15) || (Math.abs(endCoords.y - startCoords.y) > 15)) {
  2339. if (_this.core.s.useLeftForZoom) {
  2340. _$el.css({
  2341. left: distanceX + 'px',
  2342. top: distanceY + 'px'
  2343. });
  2344. } else {
  2345. _$el.css('transform', 'translate3d(' + distanceX + 'px, ' + distanceY + 'px, 0)');
  2346. }
  2347. }
  2348. }
  2349. });
  2350. _this.core.$slide.on('touchend.lg', function() {
  2351. if (_this.core.$outer.hasClass('lg-zoomed')) {
  2352. if (isMoved) {
  2353. isMoved = false;
  2354. _this.core.$outer.removeClass('lg-zoom-dragging');
  2355. _this.touchendZoom(startCoords, endCoords, allowX, allowY);
  2356. }
  2357. }
  2358. });
  2359. };
  2360. Zoom.prototype.zoomDrag = function() {
  2361. var _this = this;
  2362. var startCoords = {};
  2363. var endCoords = {};
  2364. var isDraging = false;
  2365. var isMoved = false;
  2366. // Allow x direction drag
  2367. var allowX = false;
  2368. // Allow Y direction drag
  2369. var allowY = false;
  2370. _this.core.$slide.on('mousedown.lg.zoom', function(e) {
  2371. // execute only on .lg-object
  2372. var $image = _this.core.$slide.eq(_this.core.index).find('.lg-object');
  2373. allowY = $image.prop('offsetHeight') * $image.attr('data-scale') > _this.core.$outer.find('.lg').height();
  2374. allowX = $image.prop('offsetWidth') * $image.attr('data-scale') > _this.core.$outer.find('.lg').width();
  2375. if (_this.core.$outer.hasClass('lg-zoomed')) {
  2376. if ($(e.target).hasClass('lg-object') && (allowX || allowY)) {
  2377. e.preventDefault();
  2378. startCoords = {
  2379. x: e.pageX,
  2380. y: e.pageY
  2381. };
  2382. isDraging = true;
  2383. // ** Fix for webkit cursor issue https://code.google.com/p/chromium/issues/detail?id=26723
  2384. _this.core.$outer.scrollLeft += 1;
  2385. _this.core.$outer.scrollLeft -= 1;
  2386. _this.core.$outer.removeClass('lg-grab').addClass('lg-grabbing');
  2387. }
  2388. }
  2389. });
  2390. $(window).on('mousemove.lg.zoom', function(e) {
  2391. if (isDraging) {
  2392. var _$el = _this.core.$slide.eq(_this.core.index).find('.lg-img-wrap');
  2393. var distanceX;
  2394. var distanceY;
  2395. isMoved = true;
  2396. endCoords = {
  2397. x: e.pageX,
  2398. y: e.pageY
  2399. };
  2400. // reset opacity and transition duration
  2401. _this.core.$outer.addClass('lg-zoom-dragging');
  2402. if (allowY) {
  2403. distanceY = (-Math.abs(_$el.attr('data-y'))) + (endCoords.y - startCoords.y);
  2404. } else {
  2405. distanceY = -Math.abs(_$el.attr('data-y'));
  2406. }
  2407. if (allowX) {
  2408. distanceX = (-Math.abs(_$el.attr('data-x'))) + (endCoords.x - startCoords.x);
  2409. } else {
  2410. distanceX = -Math.abs(_$el.attr('data-x'));
  2411. }
  2412. if (_this.core.s.useLeftForZoom) {
  2413. _$el.css({
  2414. left: distanceX + 'px',
  2415. top: distanceY + 'px'
  2416. });
  2417. } else {
  2418. _$el.css('transform', 'translate3d(' + distanceX + 'px, ' + distanceY + 'px, 0)');
  2419. }
  2420. }
  2421. });
  2422. $(window).on('mouseup.lg.zoom', function(e) {
  2423. if (isDraging) {
  2424. isDraging = false;
  2425. _this.core.$outer.removeClass('lg-zoom-dragging');
  2426. // Fix for chrome mouse move on click
  2427. if (isMoved && ((startCoords.x !== endCoords.x) || (startCoords.y !== endCoords.y))) {
  2428. endCoords = {
  2429. x: e.pageX,
  2430. y: e.pageY
  2431. };
  2432. _this.touchendZoom(startCoords, endCoords, allowX, allowY);
  2433. }
  2434. isMoved = false;
  2435. }
  2436. _this.core.$outer.removeClass('lg-grabbing').addClass('lg-grab');
  2437. });
  2438. };
  2439. Zoom.prototype.touchendZoom = function(startCoords, endCoords, allowX, allowY) {
  2440. var _this = this;
  2441. var _$el = _this.core.$slide.eq(_this.core.index).find('.lg-img-wrap');
  2442. var $image = _this.core.$slide.eq(_this.core.index).find('.lg-object');
  2443. var distanceX = (-Math.abs(_$el.attr('data-x'))) + (endCoords.x - startCoords.x);
  2444. var distanceY = (-Math.abs(_$el.attr('data-y'))) + (endCoords.y - startCoords.y);
  2445. var minY = (_this.core.$outer.find('.lg').height() - $image.prop('offsetHeight')) / 2;
  2446. var maxY = Math.abs(($image.prop('offsetHeight') * Math.abs($image.attr('data-scale'))) - _this.core.$outer.find('.lg').height() + minY);
  2447. var minX = (_this.core.$outer.find('.lg').width() - $image.prop('offsetWidth')) / 2;
  2448. var maxX = Math.abs(($image.prop('offsetWidth') * Math.abs($image.attr('data-scale'))) - _this.core.$outer.find('.lg').width() + minX);
  2449. if ((Math.abs(endCoords.x - startCoords.x) > 15) || (Math.abs(endCoords.y - startCoords.y) > 15)) {
  2450. if (allowY) {
  2451. if (distanceY <= -maxY) {
  2452. distanceY = -maxY;
  2453. } else if (distanceY >= -minY) {
  2454. distanceY = -minY;
  2455. }
  2456. }
  2457. if (allowX) {
  2458. if (distanceX <= -maxX) {
  2459. distanceX = -maxX;
  2460. } else if (distanceX >= -minX) {
  2461. distanceX = -minX;
  2462. }
  2463. }
  2464. if (allowY) {
  2465. _$el.attr('data-y', Math.abs(distanceY));
  2466. } else {
  2467. distanceY = -Math.abs(_$el.attr('data-y'));
  2468. }
  2469. if (allowX) {
  2470. _$el.attr('data-x', Math.abs(distanceX));
  2471. } else {
  2472. distanceX = -Math.abs(_$el.attr('data-x'));
  2473. }
  2474. if (_this.core.s.useLeftForZoom) {
  2475. _$el.css({
  2476. left: distanceX + 'px',
  2477. top: distanceY + 'px'
  2478. });
  2479. } else {
  2480. _$el.css('transform', 'translate3d(' + distanceX + 'px, ' + distanceY + 'px, 0)');
  2481. }
  2482. }
  2483. };
  2484. Zoom.prototype.destroy = function() {
  2485. var _this = this;
  2486. // Unbind all events added by lightGallery zoom plugin
  2487. _this.core.$el.off('.lg.zoom');
  2488. $(window).off('.lg.zoom');
  2489. _this.core.$slide.off('.lg.zoom');
  2490. _this.core.$el.off('.lg.tm.zoom');
  2491. _this.resetZoom();
  2492. clearTimeout(_this.zoomabletimeout);
  2493. _this.zoomabletimeout = false;
  2494. };
  2495. $.fn.lightGallery.modules.zoom = Zoom;
  2496. })();
  2497. }));
  2498. /*! lg-hash - v1.0.4 - 2017-12-20
  2499. * http://sachinchoolur.github.io/lightGallery
  2500. * Copyright (c) 2017 Sachin N; Licensed GPLv3 */
  2501. (function (root, factory) {
  2502. if (typeof define === 'function' && define.amd) {
  2503. // AMD. Register as an anonymous module unless amdModuleId is set
  2504. define(['jquery'], function (a0) {
  2505. return (factory(a0));
  2506. });
  2507. } else if (typeof exports === 'object') {
  2508. // Node. Does not work with strict CommonJS, but
  2509. // only CommonJS-like environments that support module.exports,
  2510. // like Node.
  2511. module.exports = factory(require('jquery'));
  2512. } else {
  2513. factory(jQuery);
  2514. }
  2515. }(this, function ($) {
  2516. (function() {
  2517. 'use strict';
  2518. var defaults = {
  2519. hash: true
  2520. };
  2521. var Hash = function(element) {
  2522. this.core = $(element).data('lightGallery');
  2523. this.core.s = $.extend({}, defaults, this.core.s);
  2524. if (this.core.s.hash) {
  2525. this.oldHash = window.location.hash;
  2526. this.init();
  2527. }
  2528. return this;
  2529. };
  2530. Hash.prototype.init = function() {
  2531. var _this = this;
  2532. var _hash;
  2533. // Change hash value on after each slide transition
  2534. _this.core.$el.on('onAfterSlide.lg.tm', function(event, prevIndex, index) {
  2535. if (history.replaceState) {
  2536. history.replaceState(null, null, window.location.pathname + window.location.search + '#lg=' + _this.core.s.galleryId + '&slide=' + index);
  2537. } else {
  2538. window.location.hash = 'lg=' + _this.core.s.galleryId + '&slide=' + index;
  2539. }
  2540. });
  2541. // Listen hash change and change the slide according to slide value
  2542. $(window).on('hashchange.lg.hash', function() {
  2543. _hash = window.location.hash;
  2544. var _idx = parseInt(_hash.split('&slide=')[1], 10);
  2545. // it galleryId doesn't exist in the url close the gallery
  2546. if ((_hash.indexOf('lg=' + _this.core.s.galleryId) > -1)) {
  2547. _this.core.slide(_idx, false, false);
  2548. } else if (_this.core.lGalleryOn) {
  2549. _this.core.destroy();
  2550. }
  2551. });
  2552. };
  2553. Hash.prototype.destroy = function() {
  2554. if (!this.core.s.hash) {
  2555. return;
  2556. }
  2557. // Reset to old hash value
  2558. if (this.oldHash && this.oldHash.indexOf('lg=' + this.core.s.galleryId) < 0) {
  2559. if (history.replaceState) {
  2560. history.replaceState(null, null, this.oldHash);
  2561. } else {
  2562. window.location.hash = this.oldHash;
  2563. }
  2564. } else {
  2565. if (history.replaceState) {
  2566. history.replaceState(null, document.title, window.location.pathname + window.location.search);
  2567. } else {
  2568. window.location.hash = '';
  2569. }
  2570. }
  2571. this.core.$el.off('.lg.hash');
  2572. };
  2573. $.fn.lightGallery.modules.hash = Hash;
  2574. })();
  2575. }));
  2576. /*! lg-share - v1.1.0 - 2017-10-03
  2577. * http://sachinchoolur.github.io/lightGallery
  2578. * Copyright (c) 2017 Sachin N; Licensed GPLv3 */
  2579. (function (root, factory) {
  2580. if (typeof define === 'function' && define.amd) {
  2581. // AMD. Register as an anonymous module unless amdModuleId is set
  2582. define(['jquery'], function (a0) {
  2583. return (factory(a0));
  2584. });
  2585. } else if (typeof exports === 'object') {
  2586. // Node. Does not work with strict CommonJS, but
  2587. // only CommonJS-like environments that support module.exports,
  2588. // like Node.
  2589. module.exports = factory(require('jquery'));
  2590. } else {
  2591. factory(jQuery);
  2592. }
  2593. }(this, function ($) {
  2594. (function() {
  2595. 'use strict';
  2596. var defaults = {
  2597. share: true,
  2598. facebook: true,
  2599. facebookDropdownText: 'Facebook',
  2600. twitter: true,
  2601. twitterDropdownText: 'Twitter',
  2602. googlePlus: true,
  2603. googlePlusDropdownText: 'GooglePlus',
  2604. pinterest: true,
  2605. pinterestDropdownText: 'Pinterest'
  2606. };
  2607. var Share = function(element) {
  2608. this.core = $(element).data('lightGallery');
  2609. this.core.s = $.extend({}, defaults, this.core.s);
  2610. if (this.core.s.share) {
  2611. this.init();
  2612. }
  2613. return this;
  2614. };
  2615. Share.prototype.init = function() {
  2616. var _this = this;
  2617. var shareHtml = '<span id="lg-share" class="lg-icon">' +
  2618. '<ul class="lg-dropdown" style="position: absolute;">';
  2619. shareHtml += _this.core.s.facebook ? '<li><a id="lg-share-facebook" target="_blank"><span class="lg-icon"></span><span class="lg-dropdown-text">' + this.core.s.facebookDropdownText + '</span></a></li>' : '';
  2620. shareHtml += _this.core.s.twitter ? '<li><a id="lg-share-twitter" target="_blank"><span class="lg-icon"></span><span class="lg-dropdown-text">' + this.core.s.twitterDropdownText + '</span></a></li>' : '';
  2621. shareHtml += _this.core.s.googlePlus ? '<li><a id="lg-share-googleplus" target="_blank"><span class="lg-icon"></span><span class="lg-dropdown-text">' + this.core.s.googlePlusDropdownText + '</span></a></li>' : '';
  2622. shareHtml += _this.core.s.pinterest ? '<li><a id="lg-share-pinterest" target="_blank"><span class="lg-icon"></span><span class="lg-dropdown-text">' + this.core.s.pinterestDropdownText + '</span></a></li>' : '';
  2623. shareHtml += '</ul></span>';
  2624. this.core.$outer.find('.lg-toolbar').append(shareHtml);
  2625. this.core.$outer.find('.lg').append('<div id="lg-dropdown-overlay"></div>');
  2626. $('#lg-share').on('click.lg', function(){
  2627. _this.core.$outer.toggleClass('lg-dropdown-active');
  2628. });
  2629. $('#lg-dropdown-overlay').on('click.lg', function(){
  2630. _this.core.$outer.removeClass('lg-dropdown-active');
  2631. });
  2632. _this.core.$el.on('onAfterSlide.lg.tm', function(event, prevIndex, index) {
  2633. setTimeout(function() {
  2634. $('#lg-share-facebook').attr('href', 'https://www.facebook.com/sharer/sharer.php?u=' + (encodeURIComponent(_this.getSahreProps(index, 'facebookShareUrl') || window.location.href)));
  2635. $('#lg-share-twitter').attr('href', 'https://twitter.com/intent/tweet?text=' + _this.getSahreProps(index, 'tweetText') + '&url=' + (encodeURIComponent(_this.getSahreProps(index, 'twitterShareUrl') || window.location.href)));
  2636. $('#lg-share-googleplus').attr('href', 'https://plus.google.com/share?url=' + (encodeURIComponent(_this.getSahreProps(index, 'googleplusShareUrl') || window.location.href)));
  2637. $('#lg-share-pinterest').attr('href', 'http://www.pinterest.com/pin/create/button/?url=' + (encodeURIComponent(_this.getSahreProps(index, 'pinterestShareUrl') || window.location.href)) + '&media=' + encodeURIComponent(_this.getSahreProps(index, 'src')) + '&description=' + _this.getSahreProps(index, 'pinterestText'));
  2638. }, 100);
  2639. });
  2640. };
  2641. Share.prototype.getSahreProps = function(index, prop){
  2642. var shareProp = '';
  2643. if(this.core.s.dynamic) {
  2644. shareProp = this.core.s.dynamicEl[index][prop];
  2645. } else {
  2646. var _href = this.core.$items.eq(index).attr('href');
  2647. var _prop = this.core.$items.eq(index).data(prop);
  2648. shareProp = prop === 'src' ? _href || _prop : _prop;
  2649. }
  2650. return shareProp;
  2651. };
  2652. Share.prototype.destroy = function() {
  2653. };
  2654. $.fn.lightGallery.modules.share = Share;
  2655. })();
  2656. }));