vendor: 2,928 bytes, lines 1-101
1/*! lg-hash - v1.0.4 - 2017-12-20 2* http://sachinchoolur.github.io/lightGallery 3* Copyright (c) 2017 Sachin N; Licensed GPLv3 */ 4 5(function (root, factory) { 6 if (typeof define === 'function' && define.amd) { 7 // AMD. Register as an anonymous module unless amdModuleId is set 8 define(['jquery'], function (a0) { 9 return (factory(a0)); 10 }); 11 } else if (typeof exports === 'object') { 12 // Node. Does not work with strict CommonJS, but 13 // only CommonJS-like environments that support module.exports, 14 // like Node. 15 module.exports = factory(require('jquery')); 16 } else { 17 factory(jQuery); 18 } 19}(this, function ($) { 20 21(function() { 22 23 'use strict'; 24 25 var defaults = { 26 hash: true 27 }; 28 29 var Hash = function(element) { 30 31 this.core = $(element).data('lightGallery'); 32 33 this.core.s = $.extend({}, defaults, this.core.s); 34 35 if (this.core.s.hash) { 36 this.oldHash = window.location.hash; 37 this.init(); 38 } 39 40 return this; 41 }; 42 43 Hash.prototype.init = function() { 44 var _this = this; 45 var _hash; 46 47 // Change hash value on after each slide transition 48 _this.core.$el.on('onAfterSlide.lg.tm', function(event, prevIndex, index) { 49 if (history.replaceState) { 50 history.replaceState(null, null, window.location.pathname + window.location.search + '#lg=' + _this.core.s.galleryId + '&slide=' + index); 51 } else { 52 window.location.hash = 'lg=' + _this.core.s.galleryId + '&slide=' + index; 53 } 54 }); 55 56 // Listen hash change and change the slide according to slide value 57 $(window).on('hashchange.lg.hash', function() { 58 _hash = window.location.hash; 59 var _idx = parseInt(_hash.split('&slide=')[1], 10); 60 61 // it galleryId doesn't exist in the url close the gallery 62 if ((_hash.indexOf('lg=' + _this.core.s.galleryId) > -1)) { 63 _this.core.slide(_idx, false, false); 64 } else if (_this.core.lGalleryOn) { 65 _this.core.destroy(); 66 } 67 68 }); 69 }; 70 71 Hash.prototype.destroy = function() { 72 73 if (!this.core.s.hash) { 74 return; 75 } 76 77 // Reset to old hash value 78 if (this.oldHash && this.oldHash.indexOf('lg=' + this.core.s.galleryId) < 0) { 79 if (history.replaceState) { 80 history.replaceState(null, null, this.oldHash); 81 } else { 82 window.location.hash = this.oldHash; 83 } 84 } else { 85 if (history.replaceState) { 86 history.replaceState(null, document.title, window.location.pathname + window.location.search); 87 } else { 88 window.location.hash = ''; 89 } 90 } 91 92 this.core.$el.off('.lg.hash'); 93 94 }; 95 96 $.fn.lightGallery.modules.hash = Hash; 97 98})(); 99 100 101}));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.