7 lines
2.1 KiB
JavaScript
7 lines
2.1 KiB
JavaScript
/**!
|
|
* lg-hash.js | 0.0.1 | August 1st 2016
|
|
* http://sachinchoolur.github.io/lg-hash.js
|
|
* Copyright (c) 2016 Sachin N;
|
|
* @license Apache 2.0
|
|
*/
|
|
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.LgHash=e()}}(function(){var e,t,o;return function e(t,o,i){function n(s,l){if(!o[s]){if(!t[s]){var a="function"==typeof require&&require;if(!l&&a)return a(s,!0);if(r)return r(s,!0);var h=new Error("Cannot find module '"+s+"'");throw h.code="MODULE_NOT_FOUND",h}var f=o[s]={exports:{}};t[s][0].call(f.exports,function(e){var o=t[s][1][e];return n(o?o:e)},f,f.exports,e,t,o,i)}return o[s].exports}for(var r="function"==typeof require&&require,s=0;s<i.length;s++)n(i[s]);return n}({1:[function(t,o,i){!function(t,o){if("function"==typeof e&&e.amd)e([],o);else if("undefined"!=typeof i)o();else{var n={exports:{}};o(),t.lgHash=n.exports}}(this,function(){"use strict";var e=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var i in o)Object.prototype.hasOwnProperty.call(o,i)&&(e[i]=o[i])}return e},t={hash:!0},o=function o(i){return this.el=i,this.core=window.lgData[this.el.getAttribute("lg-uid")],this.core.s=e({},t,this.core.s),this.core.s.hash&&(this.oldHash=window.location.hash,this.init()),this};o.prototype.init=function(){var e=this,t;utils.on(e.core.el,"onAfterSlide.lgtm",function(t){window.location.hash="lg="+e.core.s.galleryId+"&slide="+t.detail.index}),utils.on(window,"hashchange.lghash",function(){t=window.location.hash;var o=parseInt(t.split("&slide=")[1],10);t.indexOf("lg="+e.core.s.galleryId)>-1?e.core.slide(o,!1,!1):e.core.lGalleryOn&&e.core.destroy()})},o.prototype.destroy=function(){this.core.s.hash&&(this.oldHash&&this.oldHash.indexOf("lg="+this.core.s.galleryId)<0?window.location.hash=this.oldHash:history.pushState?history.pushState("",document.title,window.location.pathname+window.location.search):window.location.hash="",utils.off(this.core.el,".lghash"))},window.lgModules.hash=o})},{}]},{},[1])(1)}); |