SmartGallery-omeka-module/asset/js/jquery-smartphoto.min.js

56 lines
55 KiB
JavaScript
Raw Normal View History

2021-09-07 11:01:22 +02:00
/**
* Modules in this bundle
* @license
*
* smartphoto:
* license: MIT (http://opensource.org/licenses/MIT)
* author: appleple
* homepage: http://developer.a-blogcms.jp
* version: 1.6.3
*
* a-template:
* license: MIT (http://opensource.org/licenses/MIT)
* author: steelydylan
* version: 0.6.1
*
* custom-event-polyfill:
* license: MIT (http://opensource.org/licenses/MIT)
* contributors: Frank Panetta, Mikhail Reenko <reenko@yandex.ru>, Joscha Feth <joscha@feth.com>
* homepage: https://github.com/krambuhl/custom-event-polyfill#readme
* version: 0.3.0
*
* es6-promise-polyfill:
* license: MIT (http://opensource.org/licenses/MIT)
* author: Roman Dvornov <rdvornov@gmail.com>
* homepage: https://github.com/lahmatiy/es6-promise-polyfill#readme
* version: 1.2.0
*
* ie-array-find-polyfill:
* license: MIT (http://opensource.org/licenses/MIT)
* author: Carlos Abdalla
* homepage: https://github.com/abdalla/ie-array-find-polyfill#readme
* version: 1.1.0
*
* morphdom:
* license: MIT (http://opensource.org/licenses/MIT)
* author: Patrick Steele-Idem <pnidem@gmail.com>
* homepage: https://github.com/patrick-steele-idem/morphdom#readme
* version: 2.5.12
*
* process:
* license: MIT (http://opensource.org/licenses/MIT)
* author: Roman Shtylman <shtylman@gmail.com>
* homepage: https://github.com/shtylman/node-process#readme
* version: 0.11.10
*
* timers-browserify:
* licenses: MIT (http://opensource.org/licenses/MIT)
* author: J. Ryan Stinnett <jryans@gmail.com>
* contributors: Guy Bedford <guybedford@gmail.com>, Ionut-Cristian Florescu <ionut.florescu@gmail.com>, James Halliday <mail@substack.net>, Jan Schär <jscissr@gmail.com>, Johannes Ewald <johannes.ewald@peerigon.com>, Jonathan Prins <jon@blip.tv>, Matt Esch <matt@mattesch.info>
* homepage: https://github.com/jryans/timers-browserify
* version: 1.4.2
*
* This header is generated by licensify (https://github.com/twada/licensify)
*/
!function(){function t(e,a,o){function n(r,s){if(!a[r]){if(!e[r]){var c="function"==typeof require&&require;if(!s&&c)return c(r,!0);if(i)return i(r,!0);var d=new Error("Cannot find module '"+r+"'");throw d.code="MODULE_NOT_FOUND",d}var u=a[r]={exports:{}};e[r][0].call(u.exports,function(t){return n(e[r][1][t]||t)},u,u.exports,t,e,a,o)}return a[r].exports}for(var i="function"==typeof require&&require,r=0;r<o.length;r++)n(o[r]);return n}return t}()({1:[function(t,e,a){"use strict";function o(t){if(Array.isArray(t)){for(var e=0,a=Array(t.length);e<t.length;e++)a[e]=t[e];return a}return Array.from(t)}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(a,"__esModule",{value:!0});var i=function(){function t(t,e){for(var a=0;a<e.length;a++){var o=e[a];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,a,o){return a&&t(e.prototype,a),o&&t(e,o),e}}();t("ie-array-find-polyfill");var r=t("morphdom"),s=function(t){return t&&t.__esModule?t:{default:t}}(r),c=t("./util"),d="input paste copy click change keydown keyup keypress contextmenu mouseup mousedown mousemove touchstart touchend touchmove compositionstart compositionend focus",u="input change click",h=d.replace(/([a-z]+)/g,"[data-action-$1],")+"[data-action]",l=function(){function t(e){var a=this;n(this,t),this.atemplate=[],this.events=[],e&&Object.keys(e).forEach(function(t){a[t]=e[t]}),this.data||(this.data={}),this.templates||(this.templates=[]);for(var o=this.templates,i=o.length,r=0,s=i;r<s;r+=1){var d=this.templates[r],u=(0,c.selector)("#"+d).innerHTML;this.atemplate.push({id:d,html:u,binded:!1})}}return i(t,[{key:"addDataBind",value:function(t){var e=this;(0,c.on)(t,"[data-bind]",u,function(t){var a=t.delegateTarget,o=a.getAttribute("data-bind"),n=a.getAttribute("href"),i=a.value;n&&(i=i.replace("#","")),"checkbox"===a.getAttribute("type")?function(){var t=[],e=document.querySelectorAll('[data-bind="'+o+'"]');[].forEach.call(e,function(e){e.checked&&t.push(e.value)})}():"radio"!==a.getAttribute("type")&&e.updateDataByString(o,i)}),this.events.push({element:t,selector:"[data-bind]",event:u})}},{key:"addActionBind",value:function(t){var e=this;(0,c.on)(t,h,d,function(t){var a=t.delegateTarget,n=d.split(" "),i="action";n.forEach(function(e){a.getAttribute("data-action-"+e)&&t.type===e&&(i+="-"+e)});var r=a.getAttribute("data-"+i);if(r){var s=r.replace(/\(.*?\);?/,""),c=r.replace(/(.*?)\((.*?)\);?/,"$2"),u=c.split(",");if(e.e=t,e.method&&e.method[s]){var h;(h=e.method)[s].apply(h,o(u))}else e[s]&&e[s].apply(e,o(u))}}),this.events.push({element:t,selector:h,event:u})}},{key:"removeTemplateEvents",value:function(){this.events.forEach(function(t){(0,c.off)(t.element,t.selector,t.event)})}},{key:"addTemplate",value:function(t,e){this.atemplate.push({id:t,html:e,binded:!1}),this.templates.push(t)}},{key:"getData",value:function(){return JSON.parse(JSON.stringify(this.data))}},{key:"saveData",value:function(t){var e=JSON.stringify(this.data);localStorage.setItem(t,e)}},{key:"setData",value:function(t){var e=this;Object.keys(t).forEach(function(a){"function"!=typeof t[a]&&(e.data[a]=t[a])})}},{key:"loadData",value:function(t){var e=JSON.parse(localStorage.getItem(t));e&&this.setData(e)}},{key:"getRand",value:function(t,e){return~~(Math.random()*(e-t+1))+t}},{key:"getRandText",value:function(t){for(var e="",a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",o=a.length,n=0;n<t;n+=1)e+=a.charAt(Math.floor(this.getRand(0,o)));return e}},{key:"getDataFromObj",value:function(t,e){t=t.replace(/\[([\w\-\.ぁ-んァ-ヶ亜-熙]+)\]/g,".$1"),t=t.replace(/^\./,"");for(var a=t.split(".");a.length;){var o=a.shift();if(!(o in e))return null;e=e[o]}return e}},{key:"getDataByString",value:function(t){var e=this.data;return this.getDataFromObj(t,e)}},{key:"updateDataByString",value:function(t,e){for(var a=this.data,o=t.split(".");o.length>1;)a=a[o.shift()];a[o.shift()]=e}},{key:"removeDataByString",value:function(t){for(var e=this.data,a=t.spli
o.interval=setInterval(function(){o._doAnim()},o.data.forceInterval),!o.data.isSmartPhone){var u=function(){o.groupItems()&&(o._resetTranslate(),o._setPosByCurrentIndex(),o._setSizeByScreen(),o.update())},h=function(t){var e=t.keyCode||t.which;!0!==o.data.hide&&(37===e?o.gotoSlide(o.data.prev):39===e?o.gotoSlide(o.data.next):27===e&&o.hidePhoto())};return window.addEventListener("resize",u),window.addEventListener("keydown",h),o._registerRemoveEvent(window,"resize",u),o._registerRemoveEvent(window,"keydown",h),s(o)}var l=function(){if(o.groupItems()){o._resetTranslate(),o._setPosByCurrentIndex(),o._setHashByCurrentIndex(),o._setSizeByScreen(),o.update();var t=o._getWindowWidth();!function e(a){new v(function(t){setTimeout(function(){t()},25)}).then(function(){t!==o._getWindowWidth()?(o._resetTranslate(),o._setPosByCurrentIndex(),o._setHashByCurrentIndex(),o._setSizeByScreen(),o.update()):a<=500&&e(a+25)})}(0)}};if(window.addEventListener("orientationchange",l),o._registerRemoveEvent(window,"orientationchange",l),!o.data.useOrientationApi)return s(o);var m=function(t){var e=window,a=e.orientation;t&&t.gamma&&!o.data.appearEffect&&(o.isBeingZoomed||o.photoSwipable||o.data.elastic||!o.data.scale||(0===a?o._calcGravity(t.gamma,t.beta):90===a?o._calcGravity(t.beta,t.gamma):-90===a?o._calcGravity(-t.beta,-t.gamma):180===a&&o._calcGravity(-t.gamma,-t.beta)))};return window.addEventListener("deviceorientation",m),o._registerRemoveEvent(window,"deviceorientation",m),o}return u(e,t),r(e,[{key:"on",value:function(t,e){var a=this._getElementByClass(this.data.classNames.smartPhoto),o=function(t){e.call(a,t)};a.addEventListener(t,o),this._registerRemoveEvent(a,t,o)}},{key:"_registerRemoveEvent",value:function(t,e,a){this.handlers.push({target:t,event:e,handler:a})}},{key:"destroy",value:function(){this.handlers.forEach(function(t){t.target.removeEventListener(t.event,t.handler)});var t=document.querySelector('[data-id="'.concat(this.id,'"]'));p.removeElement(t),clearInterval(this.interval),this.removeTemplateEvents()}},{key:"increment",value:function(t){return t+1}},{key:"round",value:function(t){return Math.round(t)}},{key:"virtualPos",value:function(t){return(t=parseInt(t,10))/this._getSelectedItem().scale/this.data.scaleSize}},{key:"groupItems",value:function(){return this.data.group[this.data.currentGroup]}},{key:"_resetTranslate",value:function(){var t=this;this.groupItems().forEach(function(e,a){e.translateX=t._getWindowWidth()*a})}},{key:"addNewItem",value:function(t){var e=this,a=t.getAttribute("data-group")||"nogroup",o=this.data.group;"nogroup"===a&&t.setAttribute("data-group","nogroup"),o[a]||(o[a]=[]);var n=o[a].length,i=document.querySelector("body"),r=t.getAttribute("href"),s=t.querySelector("img"),c=r;s&&(c=s.getAttribute(this.data.lazyAttribute)?s.getAttribute(this.data.lazyAttribute):s.currentSrc?s.currentSrc:s.src);var d={src:r,thumb:c,caption:t.getAttribute("data-caption"),groupId:a,translateX:this._getWindowWidth()*n,index:n,translateY:0,width:50,height:50,id:t.getAttribute("data-id")||n,loaded:!1,processed:!1,element:t};o[a].push(d),this.data.currentGroup=a,t.getAttribute("data-id")||t.setAttribute("data-id",n),t.setAttribute("data-index",n);var u=function(a){a.preventDefault(),e.data.currentGroup=t.getAttribute("data-group"),e.data.currentIndex=parseInt(t.getAttribute("data-index"),10),e._setHashByCurrentIndex();var o=e._getSelectedItem();o.loaded?(e._initPhoto(),e.addAppearEffect(t,o),e.clicked=!0,e.update(),i.style.overflow="hidden",e._fireEvent("open")):e._loadItem(o).then(function(){e._initPhoto(),e.addAppearEffect(t,o),e.clicked=!0,e.update(),i.style.overflow="hidden",e._fireEvent("open")})};t.addEventListener("click",u),this._registerRemoveEvent(t,"click",u)}},{key:"_initPhoto",value:function(){this.data.total=this.groupItems().length,this.data.hide=!1,this.data.photoPosX=0,this.data.photoPosY=0,this._setPosByCurrentIndex(),this._setSizeByScreen(),this.setArrow(),"fill"===this.data.resizeStyle&&this.data.isSmartPhone&&(this.data.scale=!0,this.data.hideUi=!0,this.data.scaleSize=this._getScaleBoarder())}},{k