smartphoto
Advanced tools
Comparing version 0.5.7 to 0.5.8
@@ -9,3 +9,3 @@ /** | ||
* homepage: http://developer.a-blogcms.jp | ||
* version: 0.5.7 | ||
* version: 0.5.8 | ||
* | ||
@@ -33,3 +33,3 @@ * a-template: | ||
*/ | ||
!function t(e,a,o){function i(s,n){if(!a[s]){if(!e[s]){var h="function"==typeof require&&require;if(!n&&h)return h(s,!0);if(r)return r(s,!0);var d=new Error("Cannot find module '"+s+"'");throw d.code="MODULE_NOT_FOUND",d}var c=a[s]={exports:{}};e[s][0].call(c.exports,function(t){var a=e[s][1][t];return i(a||t)},c,c.exports,t,e,a,o)}return a[s].exports}for(var r="function"==typeof require&&require,s=0;s<o.length;s++)i(o[s]);return i}({1:[function(t,e,a){"use strict";function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}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}}(),r=t("morphdom"),s=t("delegate"),n=[],h="input paste copy click change keydown keyup contextmenu mouseup mousedown mousemove touchstart touchend touchmove compositionstart compositionend",d=h.replace(/([a-z]+)/g,"[data-action-$1],")+"[data-action]";Array.prototype.find||(Array.prototype.find=function(t){if(null===this)throw new TypeError("Array.prototype.find called on null or undefined");if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var e=Object(this),a=e.length>>>0,o=arguments[1],i=void 0,r=0;r<a;r++)if(i=e[r],t.call(o,i,r,e))return i}),Element.prototype.matches||(Element.prototype.matches=Element.prototype.matchesSelector||Element.prototype.mozMatchesSelector||Element.prototype.msMatchesSelector||Element.prototype.oMatchesSelector||Element.prototype.webkitMatchesSelector||function(t){for(var e=(this.document||this.ownerDocument).querySelectorAll(t),a=e.length;--a>=0&&e.item(a)!==this;);return a>-1});var c=function(t){return document.querySelector(t)},l=function(t){for(var e=0,a=n.length;e<a;e++)for(var o=n[e],i=o.templates,r=0,s=i.length;r<s;r++)if(i[r]==t)return o;return null},u=function(t,e){if("function"==typeof t.closest)return t.closest(e)||null;for(;t;){if(t.matches(e))return t;t=t.parentElement}return null},p=function(t,e,a,o){a.split(" ").forEach(function(a){s(t,e,a,o)})};"undefined"!=typeof document&&(p(document,"[data-bind]","input change click",function(t){var e=t.delegateTarget,a=e.getAttribute("data-bind"),o=e.getAttribute("href"),i=u(e,"[data-id]").getAttribute("data-id"),r=e.value;if(o&&(r=r.replace("#","")),i){var s=l(i);"radio"===e.getAttribute("type")||("checkbox"===e.getAttribute("type")?function(){var t=[],e=document.querySelectorAll('[data-bind="'+a+'"]');[].forEach.call(e,function(e){e.checked&&t.push(e.value)})}():s.updateDataByString(a,r))}}),p(document,d,h,function(t){var e=t.delegateTarget;if(!("click"===t.type&&"select"===e.tagName||"input"===t.type&&"button"===e.getAttribute("type"))){var a=h.split(" "),o="action";a.forEach(function(a){e.getAttribute("data-action-"+a)&&t.type===a&&(o+="-"+a)});var i=e.getAttribute("data-"+o);if(i){var r=i.replace(/\(.*?\);?/,""),s=i.replace(/(.*?)\((.*?)\);?/,"$2"),n=s.split(","),d=u(e,"[data-id]").getAttribute("data-id");if(d){var c=l(d);c.e=t,c.method&&c.method[r]?c.method[r].apply(c,n):c[r]&&c[r].apply(c,n)}}}}));var f=function(){function t(e){o(this,t),this.atemplate=[],n.push(this);for(var a in e)this[a]=e[a];this.data||(this.data={}),this.templates||(this.templates=[]);for(var i=this.templates,r=i.length,s=0,h=r;s<h;s++){var d=this.templates[s],l=c("#"+d).innerHTML;this.atemplate.push({id:d,html:l})}this.setId()}return i(t,[{key:"addTemplate",value:function(t,e){this.atemplate.push({id:t,html:e}),this.templates.push(t)}},{key:"loadHtml",value:function(){var t=this.templates,e=[];return t.forEach(function(t){var a=new $.Deferred;e.push(a);var o=c("#"+t).getAttribute("src");$.ajax({url:o,type:"GET",dataType:"text"}).success(function(e){c("#"+t).innerHTML=e,a.resolve()})}),$.when.apply($,e)}},{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){for(var e in t)"function"!=typeof t[e]&&(this.data[e]=t[e])}},{key:"loadData",value:function(t){var e=JSON.parse(localStorage.getItem(t));if(e)for(var a in e)"function"!=typeof e[a]&&(this.data[a]=e[a])}},{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,i=0;i<t;i++)e+=a.charAt(Math.floor(this.getRand(0,o)));return e}},{key:"setId",value:function(){for(var e=void 0,a=(t.ids,!1);;){e=this.getRandText(10);for(var o=0,i=t.ids;o<i;o++)t.ids[o]===e&&(a=!0);if(!1===a)break}this.data.aTemplate_id=e}},{key:"getDataFromObj",value:function(t,e){t=t.replace(/\[([a-zA-Z0-9._-]+)\]/g,".$1"),t=t.replace(/^\./,"");for(var a=t.split(".");a.length;){var o=a.shift();if(!(o in e))return;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.split(".");a.length>1;)e=e[a.shift()];var o=a.shift();o.match(/^\d+$/)?e.splice(Number(o),1):delete e[o]}},{key:"resolveBlock",value:function(t,e,a){var o=this,i=t.match(/<!-- BEGIN ([a-zA-Z0-9._-]+):touch#([a-zA-Z0-9._-]+) -->/g),r=t.match(/<!-- BEGIN ([a-zA-Z0-9._-]+):touchnot#([a-zA-Z0-9._-]+) -->/g),s=t.match(/<!-- BEGIN ([a-zA-Z0-9._-]+):exist -->/g),n=t.match(/<!-- BEGIN ([a-zA-Z0-9._-]+):empty -->/g);if(i)for(var h=0,d=i.length;h<d;h++){var c=i[h];c=c.replace(/([a-zA-Z0-9._-]+):touch#([a-zA-Z0-9._-]+)/,"($1):touch#($2)");var l=c.replace(/BEGIN/,"END"),u=new RegExp(c+"(([\\n\\r\\t]|.)*?)"+l,"g");t=t.replace(u,function(t,a,i,r){return("function"==typeof e[a]?e[a].apply(o):o.getDataFromObj(a,e))==i?r:""})}if(r)for(var p=0,f=r.length;p<f;p++){var m=r[p];m=m.replace(/([a-zA-Z0-9._-]+):touchnot#([a-zA-Z0-9._-]+)/,"($1):touchnot#($2)");var v=m.replace(/BEGIN/,"END"),g=new RegExp(m+"(([\\n\\r\\t]|.)*?)"+v,"g");t=t.replace(g,function(t,a,i,r){return("function"==typeof e[a]?e[a].apply(o):o.getDataFromObj(a,e))!=i?r:""})}if(s)for(var x=0,y=s.length;x<y;x++){var P=s[x];P=P.replace(/([a-zA-Z0-9._-]+):exist/,"($1):exist");var E=P.replace(/BEGIN/,"END"),w=new RegExp(P+"(([\\n\\r\\t]|.)*?)"+E,"g");t=t.replace(w,function(t,a,i){var r="function"==typeof e[a]?e[a].apply(o):o.getDataFromObj(a,e);return r||0===r?i:""})}if(n)for(var _=0,b=n.length;_<b;_++){var S=n[_];S=S.replace(/([a-zA-Z0-9._-]+):empty/,"($1):empty");var N=S.replace(/BEGIN/,"END"),I=new RegExp(S+"(([\\n\\r\\t]|.)*?)"+N,"g");t=t.replace(I,function(t,a,i){var r="function"==typeof e[a]?e[a].apply(o):o.getDataFromObj(a,e);return r||0===r?"":i})}return t=t.replace(/{([a-zA-Z0-9._-]+)}(\[([a-zA-Z0-9._-]+)\])*/g,function(t,i,r,s){var n=void 0;if("i"==i)n=a;else{if(!e[i]&&0!==e[i])return s&&o.convert&&o.convert[s]?o.convert[s].call(o,""):"";n="function"==typeof e[i]?e[i].apply(o):e[i]}return s&&o.convert&&o.convert[s]?o.convert[s].call(o,n):n})}},{key:"resolveAbsBlock",value:function(t){var e=this;return t=t.replace(/{(.*?)}/g,function(t,a){var o=e.getDataByString(a);return void 0!==o?"function"==typeof o?o.apply(e):o:t})}},{key:"resolveInclude",value:function(t){return t=t.replace(/<!-- #include id="(.*?)" -->/g,function(t,e){return c("#"+e).innerHTML})}},{key:"resolveWith",value:function(t){return t=t.replace(/<!-- BEGIN ([a-zA-Z0-9._-]+):with -->(([\n\r\t]|.)*?)<!-- END ([a-zA-Z0-9._-]+):with -->/g,function(t,e,a){return t=t.replace(/data\-bind=['"](.*?)['"]/g,"data-bind='"+e+".$1'")})}},{key:"resolveLoop",value:function(t){var e=this;return t=t.replace(/<!-- BEGIN (.+?):loop -->(([\n\r\t]|.)*?)<!-- END (.+?):loop -->/g,function(t,a,o){var i=e.getDataByString(a),r=[];r="function"==typeof i?i.apply(e):i;var s="";if(r instanceof Array)for(var n=0,h=r.length;n<h;n++)s+=e.resolveBlock(o,r[n],n);return s=s.replace(/\\([^\\])/g,"$1")})}},{key:"removeData",value:function(t){var e=this.data;for(var a in e)for(var o=0,i=t.length;o<i;o++)a===t[o]&&delete e[a];return this}},{key:"hasLoop",value:function(t){return!!t.match(/<!-- BEGIN (.+?):loop -->(([\n\r\t]|.)*?)<!-- END (.+?):loop -->/g)}},{key:"getHtml",value:function(t,e){var a=this.atemplate.find(function(e){return e.id===t}),o="";if(a&&a.html&&(o=a.html),e&&(o=t),!o)return"";var i=this.data;for(o=this.resolveInclude(o),o=this.resolveWith(o);this.hasLoop(o);)o=this.resolveLoop(o);return o=this.resolveBlock(o,i),o=o.replace(/\\([^\\])/g,"$1"),o=this.resolveAbsBlock(o),o.replace(/^([\t ])*\n/gm,"")}},{key:"update",value:function(t,e){var a=(this.getHtml(),this.templates),o=t||"html";this.beforeUpdated&&this.beforeUpdated();for(var i=0,s=a.length;i<s;i++){var n=a[i],h="#"+n,d=this.getHtml(n),l=c("[data-id='"+n+"']");if((!e||e==n)&&(l?"text"===o?l.innerText=d:r(l,"<div data-id='"+n+"'>"+d+"</div>"):(c(h).insertAdjacentHTML("afterend",'<div data-id="'+n+'"></div>'),"text"===o?c("[data-id='"+n+"']").innerText=d:c("[data-id='"+n+"']").innerHTML=d),e))break}return this.updateBindingData(e),this.onUpdated&&this.onUpdated(e),this}},{key:"updateBindingData",value:function(t){for(var e=this,a=this.templates,o=0,i=a.length;o<i;o++){var r=a[o];if(!t||t==r){var s=c("[data-id='"+r+"']"),n=s.querySelectorAll("[data-bind]");if([].forEach.call(n,function(t){var a=e.getDataByString(t.getAttribute("data-bind"));"checkbox"===t.getAttribute("type")||"radio"===t.getAttribute("type")?a==t.value&&(t.checked=!0):t.value=a}),t)break}}return this}},{key:"applyMethod",value:function(t){var e=[].splice.call(arguments,0);return e.shift(),this.method[t].apply(this,e)}},{key:"getComputedProp",value:function(t){return this.data[t].apply(this)}},{key:"remove",value:function(t){for(var e=this.data,a=t.split(".");a.length>1;)e=e[a.shift()];var o=a.shift();return o.match(/^\d+$/)?e.splice(Number(o),1):delete e[o],this}}]),t}();e.exports=f},{delegate:3,morphdom:4}],2:[function(t,e,a){function o(t,e){for(;t&&t.nodeType!==i;){if(t.matches(e))return t;t=t.parentNode}}var i=9;if("undefined"!=typeof Element&&!Element.prototype.matches){var r=Element.prototype;r.matches=r.matchesSelector||r.mozMatchesSelector||r.msMatchesSelector||r.oMatchesSelector||r.webkitMatchesSelector}e.exports=o},{}],3:[function(t,e,a){function o(t,e,a,o,r){var s=i.apply(this,arguments);return t.addEventListener(a,s,r),{destroy:function(){t.removeEventListener(a,s,r)}}}function i(t,e,a,o){return function(a){a.delegateTarget=r(a.target,e),a.delegateTarget&&o.call(t,a)}}var r=t("./closest");e.exports=o},{"./closest":2}],4:[function(t,e,a){"use strict";function o(t){!l&&f.createRange&&(l=f.createRange(),l.selectNode(f.body));var e;return l&&l.createContextualFragment?e=l.createContextualFragment(t):(e=f.createElement("body"),e.innerHTML=t),e.childNodes[0]}function i(t,e){var a=t.nodeName,o=e.nodeName;return a===o||!!(e.actualize&&a.charCodeAt(0)<91&&o.charCodeAt(0)>90)&&a===o.toUpperCase()}function r(t,e){return e&&e!==p?f.createElementNS(e,t):f.createElement(t)}function s(t,e){for(var a=t.firstChild;a;){var o=a.nextSibling;e.appendChild(a),a=o}return e}function n(t,e){var a,o,i,r,s,n=e.attributes;for(a=n.length-1;a>=0;--a)o=n[a],i=o.name,r=o.namespaceURI,s=o.value,r?(i=o.localName||i,t.getAttributeNS(r,i)!==s&&t.setAttributeNS(r,i,s)):t.getAttribute(i)!==s&&t.setAttribute(i,s);for(n=t.attributes,a=n.length-1;a>=0;--a)o=n[a],!1!==o.specified&&(i=o.name,r=o.namespaceURI,r?(i=o.localName||i,v(e,r,i)||t.removeAttributeNS(r,i)):v(e,null,i)||t.removeAttribute(i))}function h(t,e,a){t[a]!==e[a]&&(t[a]=e[a],t[a]?t.setAttribute(a,""):t.removeAttribute(a,""))}function d(){}function c(t){return t.id}var l,u,p="http://www.w3.org/1999/xhtml",f="undefined"==typeof document?void 0:document,m=f?f.body||f.createElement("div"):{};u=m.hasAttributeNS?function(t,e,a){return t.hasAttributeNS(e,a)}:m.hasAttribute?function(t,e,a){return t.hasAttribute(a)}:function(t,e,a){return null!=t.getAttributeNode(e,a)};var v=u,g={OPTION:function(t,e){h(t,e,"selected")},INPUT:function(t,e){h(t,e,"checked"),h(t,e,"disabled"),t.value!==e.value&&(t.value=e.value),v(e,null,"value")||t.removeAttribute("value")},TEXTAREA:function(t,e){var a=e.value;t.value!==a&&(t.value=a);var o=t.firstChild;if(o){var i=o.nodeValue;if(i==a||!a&&i==t.placeholder)return;o.nodeValue=a}},SELECT:function(t,e){if(!v(e,null,"multiple")){for(var a=0,o=e.firstChild;o;){var i=o.nodeName;if(i&&"OPTION"===i.toUpperCase()){if(v(o,null,"selected")){a;break}a++}o=o.nextSibling}t.selectedIndex=a}}},x=1,y=3,P=8,E=function(t){return function(e,a,n){function h(t){w?w.push(t):w=[t]}function l(t,e){if(t.nodeType===x)for(var a=t.firstChild;a;){var o=void 0;e&&(o=_(a))?h(o):(A(a),a.firstChild&&l(a,e)),a=a.nextSibling}}function u(t,e,a){!1!==k(t)&&(e&&e.removeChild(t),A(t),l(t,a))}function p(t){if(t.nodeType===x)for(var e=t.firstChild;e;){var a=_(e);a&&(C[a]=e),p(e),e=e.nextSibling}}function m(t){S(t);for(var e=t.firstChild;e;){var a=e.nextSibling,o=_(e);if(o){var r=C[o];r&&i(e,r)&&(e.parentNode.replaceChild(r,e),v(r,e))}m(e),e=a}}function v(o,r,s){var n,d=_(r);if(d&&delete C[d],!a.isSameNode||!a.isSameNode(e)){if(!s){if(!1===N(o,r))return;if(t(o,r),I(o),!1===D(o,r))return}if("TEXTAREA"!==o.nodeName){var c,l,p,E,w=r.firstChild,S=o.firstChild;t:for(;w;){for(p=w.nextSibling,c=_(w);S;){if(l=S.nextSibling,w.isSameNode&&w.isSameNode(S)){w=p,S=l;continue t}n=_(S);var k=S.nodeType,A=void 0;if(k===w.nodeType&&(k===x?(c?c!==n&&((E=C[c])?S.nextSibling===E?A=!1:(o.insertBefore(E,S),l=S.nextSibling,n?h(n):u(S,o,!0),S=E):A=!1):n&&(A=!1),(A=!1!==A&&i(S,w))&&v(S,w)):k!==y&&k!=P||(A=!0,S.nodeValue=w.nodeValue)),A){w=p,S=l;continue t}n?h(n):u(S,o,!0),S=l}if(c&&(E=C[c])&&i(E,w))o.appendChild(E),v(E,w);else{var B=b(w);!1!==B&&(B&&(w=B),w.actualize&&(w=w.actualize(o.ownerDocument||f)),o.appendChild(w),m(w))}w=p,S=l}for(;S;)l=S.nextSibling,(n=_(S))?h(n):u(S,o,!0),S=l}var z=g[o.nodeName];z&&z(o,r)}}if(n||(n={}),"string"==typeof a)if("#document"===e.nodeName||"HTML"===e.nodeName){var E=a;a=f.createElement("html"),a.innerHTML=E}else a=o(a);var w,_=n.getNodeKey||c,b=n.onBeforeNodeAdded||d,S=n.onNodeAdded||d,N=n.onBeforeElUpdated||d,I=n.onElUpdated||d,k=n.onBeforeNodeDiscarded||d,A=n.onNodeDiscarded||d,D=n.onBeforeElChildrenUpdated||d,B=!0===n.childrenOnly,C={};p(e);var z=e,G=z.nodeType,T=a.nodeType;if(!B)if(G===x)T===x?i(e,a)||(A(e),z=s(e,r(a.nodeName,a.namespaceURI))):z=a;else if(G===y||G===P){if(T===G)return z.nodeValue=a.nodeValue,z;z=a}if(z===a)A(e);else if(v(z,a,B),w)for(var O=0,X=w.length;O<X;O++){var M=C[w[O]];M&&u(M,M.parentNode,!1)}return!B&&z!==e&&e.parentNode&&(z.actualize&&(z=z.actualize(e.ownerDocument||f)),e.parentNode.replaceChild(z,e)),z}}(n);e.exports=E},{}],5:[function(t,e,a){"use strict";var o=t("../index"),i=function(t){t.fn.smartPhoto=function(t){return"strings"==typeof t||new o(this.selector,t),this}};if("function"==typeof define&&define.amd)define(["jquery"],i);else{var r=window.jQuery?window.jQuery:window.$;void 0!==r&&i(r)}e.exports=i},{"../index":7}],6:[function(t,e,a){"use strict";function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function r(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}var s=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}}(),n=t("a-template"),h=function(t){return t&&t.__esModule?t:{default:t}}(n),d='<div class="\\{classNames.smartPhoto\\}"\x3c!-- BEGIN hide:exist --\x3e aria-hidden="true"\x3c!-- END hide:exist --\x3e\x3c!-- BEGIN hide:empty --\x3e aria-hidden="false"\x3c!-- END hide:empty --\x3e role="dialog">\n\t<div class="\\{classNames.smartPhotoBody\\}">\n\t\t<div class="\\{classNames.smartPhotoInner\\}">\n\t\t\t <div class="\\{classNames.smartPhotoHeader\\}">\n\t\t\t\t\t<span class="\\{classNames.smartPhotoCount\\}">{currentIndex}[increment]/{total}</span>\n\t\t\t\t\t<span class="\\{classNames.smartPhotoCaption\\}" aria-live="polite" tabindex="-1">\x3c!-- BEGIN groupItems:loop --\x3e\x3c!-- \\BEGIN currentIndex:touch#{index} --\x3e{caption}\x3c!-- \\END currentIndex:touch#{index} --\x3e\x3c!-- END groupItems:loop --\x3e</span>\n\t\t\t\t\t<button class="\\{classNames.smartPhotoDismiss\\}" data-action-click="hidePhoto()"><span class="smartphoto-sr-only">\\{message.closeDialog\\}</span></button>\n\t\t\t\t</div>\n\t\t\t\t<div class="\\{classNames.smartPhotoContent\\}"\x3c!-- BEGIN isSmartPhone:exist --\x3e data-action-touchstart="beforeDrag" data-action-touchmove="onDrag" data-action-touchend="afterDrag(false)"\x3c!-- END isSmartPhone:exist --\x3e>\n\t\t\t\t</div>\n\t\t\t\t<ul style="transform:translate({translateX}px,{translateY}px);" class="\\{classNames.smartPhotoList\\}\x3c!-- BEGIN onMoveClass:exist --\x3e \\{classNames.smartPhotoListOnMove\\}\x3c!-- END onMoveClass:exist --\x3e">\n\t\t\t\t\t\x3c!-- BEGIN groupItems:loop --\x3e\n\t\t\t\t\t<li style="transform:translate({translateX}px,{translateY}px);" class="\x3c!-- \\BEGIN currentIndex:touch#{index} --\x3ecurrent\x3c!-- \\END currentIndex:touch#{index} --\x3e">\n\t\t\t\t\t\t\x3c!-- BEGIN loaded:exist --\x3e\n\t\t\t\t\t\t<div style="transform:translate({x}px,{y}px) scale({scale});" class="\\\\{classNames.smartPhotoImgWrap\\\\}"\x3c!-- \\BEGIN isSmartPhone:empty --\x3e data-action-mousemove="onDrag" data-action-mousedown="beforeDrag" data-action-mouseup="afterDrag"\x3c!-- \\END isSmartPhone:empty --\x3e\x3c!-- \\BEGIN isSmartPhone:exist --\x3e data-action-touchstart="beforeDrag" data-action-touchmove="onDrag" data-action-touchend="afterDrag"\x3c!-- \\END isSmartPhone:exist --\x3e>\n\t\t\t\t\t\t\t<img style="\x3c!-- \\BEGIN currentIndex:touch#{index} --\x3etransform:translate(\\{photoPosX\\}[virtualPos]px,\\{photoPosY\\}[virtualPos]px) scale(\\{scaleSize\\});\x3c!-- \\END currentIndex:touch#{index} --\x3e" src="{src}" class="\\\\{classNames.smartPhotoImg\\\\}\x3c!-- \\BEGIN scale:exist --\x3e \\\\{classNames.smartPhotoImgOnMove\\\\}\x3c!-- \\END scale:exist --\x3e\x3c!-- \\BEGIN elastic:exist --\x3e \\\\{classNames.smartPhotoImgElasticMove\\\\}\x3c!-- \\END elastic:exist --\x3e\x3c!-- \\BEGIN appear:exist --\x3e active\x3c!-- \\END appear:exist --\x3e" ondragstart="return false;">\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\x3c!-- END loaded:exist --\x3e\n\t\t\t\t\t\t\x3c!-- BEGIN loaded:empty --\x3e\n\t\t\t\t\t\t<div class="\\\\{classNames.smartPhotoLoaderWrap\\\\}">\n\t\t\t\t\t\t\t<span class="\\\\{classNames.smartPhotoLoader\\\\}"></span>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\x3c!-- END loaded:empty --\x3e\n\t\t\t\t\t</li>\n\t\t\t\t\t\x3c!-- END groupItems:loop --\x3e\n\t\t\t\t</ul>\n\t\t\t\t\x3c!-- BEGIN arrows:exist --\x3e\n\t\t\t\t<ul class="\\{classNames.smartPhotoArrows\\}"\x3c!-- BEGIN hideUi:exist --\x3e aria-hidden="true"\x3c!-- END hideUi:exist --\x3e\x3c!-- BEGIN hideUi:exist --\x3e aria-hidden="false"\x3c!-- END hideUi:exist --\x3e>\n\t\t\t\t\t<li class="\\{classNames.smartPhotoArrowLeft\\}"\x3c!-- BEGIN showPrevArrow:empty --\x3e aria-hidden="true"\x3c!-- END showPrevArrow:empty --\x3e><a href="#" data-action-click="gotoSlide({prev})" role="button"><span class="smartphoto-sr-only">\\{message.gotoPrevImage\\}</span></a></li>\n\t\t\t\t\t<li class="\\{classNames.smartPhotoArrowRight\\}"\x3c!-- BEGIN showNextArrow:empty --\x3e aria-hidden="true"\x3c!-- END showNextArrow:empty --\x3e><a href="#" data-action-click="gotoSlide({next})" role="button"><span class="smartphoto-sr-only">\\{message.gotoNextImage\\}</span></a></li>\n\t\t\t\t</ul>\n\t\t\t\t\x3c!-- END arrows:exist --\x3e\n\t\t\t\t\x3c!-- BEGIN nav:exist --\x3e\n\t\t\t\t<nav class="\\{classNames.smartPhotoNav\\}"\x3c!-- BEGIN hideUi:exist --\x3e aria-hidden="true"\x3c!-- END hideUi:exist --\x3e\x3c!-- BEGIN hideUi:exist --\x3e aria-hidden="false"\x3c!-- END hideUi:exist --\x3e>\n\t\t\t\t\t<ul>\n\t\t\t\t\t\t\x3c!-- BEGIN groupItems:loop --\x3e\n\t\t\t\t\t\t<li><a href="#" data-action-click="gotoSlide({index})" class="\x3c!-- \\BEGIN currentIndex:touch#{index} --\x3ecurrent\x3c!-- \\END currentIndex:touch#{index} --\x3e" style="background-image:url({src});" role="button"><span class="smartphoto-sr-only">go to {caption}</span></a></li>\n\t\t\t\t\t\t\x3c!-- END groupItems:loop --\x3e\n\t\t\t\t\t</ul>\n\t\t\t\t</nav>\n\t\t\t\t\x3c!-- END nav:exist --\x3e\n\t\t</div>\n\t\t\x3c!-- BEGIN appearEffect:exist --\x3e\n\t\t<img src=\\{appearEffect.img\\}\n\t\tclass="\\{classNames.smartPhotoImgClone\\}"\n\t\tstyle="width:\\{appearEffect.width\\}px;height:\\{appearEffect.height\\}px;transform:translate(\\{appearEffect.left\\}px,\\{appearEffect.top\\}px) scale(1)" />\n\t\t\x3c!-- END appearEffect:exist --\x3e\n\t</div>\n</div>\n',c=t("../lib/util"),l={classNames:{smartPhoto:"smartphoto",smartPhotoClose:"smartphoto-close",smartPhotoBody:"smartphoto-body",smartPhotoInner:"smartphoto-inner",smartPhotoContent:"smartphoto-content",smartPhotoImg:"smartphoto-img",smartPhotoImgOnMove:"smartphoto-img-onmove",smartPhotoImgElasticMove:"smartphoto-img-elasticmove",smartPhotoImgWrap:"smartphoto-img-wrap",smartPhotoArrows:"smartphoto-arrows",smartPhotoNav:"smartphoto-nav",smartPhotoArrowRight:"smartphoto-arrow-right",smartPhotoArrowLeft:"smartphoto-arrow-left",smartPhotoImgLeft:"smartphoto-img-left",smartPhotoImgRight:"smartphoto-img-right",smartPhotoList:"smartphoto-list",smartPhotoListOnMove:"smartphoto-list-onmove",smartPhotoHeader:"smartphoto-header",smartPhotoCount:"smartphoto-count",smartPhotoCaption:"smartphoto-caption",smartPhotoDismiss:"smartphoto-dismiss",smartPhotoLoader:"smartphoto-loader",smartPhotoLoaderWrap:"smartphoto-loader-wrap",smartPhotoImgClone:"smartphoto-img-clone"},message:{gotoNextImage:"go to the next image",gotoPrevImage:"go to the previous image",closeDialog:"close the image dialog"},arrows:!0,nav:!0,animationSpeed:300,swipeOffset:100,headerHeight:60,footerHeight:60,forceInterval:10,registance:.5,resizeStyle:"fill",verticalGravity:!1,useOrientationApi:!0},u=function(t){function e(t,a){o(this,e);var r=i(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));r.data=c.extend({},l,a),r.data.currentIndex=0,r.data.oldIndex=0,r.data.hide=!0,r.data.group={},r.data.scaleSize=1,r.data.scale=!1,r.pos={x:0,y:0},r.data.photoPosX=0,r.data.photoPosY=0,r.convert={increment:r.increment,virtualPos:r.virtualPos},r.data.groupItems=r.groupItems,r.elements=document.querySelectorAll(t);var s=new Date;r.tapSecond=s.getTime(),r.onListMove=!1,r.clicked=!1,r.id=r._getUniqId(),r.vx=0,r.vy=0,r.data.appearEffect=null,r.addTemplate(r.id,d),r.data.isSmartPhone=r._isSmartPhone();var n=document.querySelector("body");c.append(n,"<div data-id='"+r.id+"'></div>"),[].forEach.call(r.elements,function(t){r.addNewItem(t)});var h=r._getCurrentItemByHash();return h&&c.triggerEvent(h.element,"click"),r.update(),r._getEachImageSize().then(function(){r._fireEvent("loadall")}),setInterval(function(){r._doAnim()},r.data.forceInterval),r.data.isSmartPhone?(window.addEventListener("orientationchange",function(){r._resetTranslate(),r._setPosByCurrentIndex(),r._setHashByCurrentIndex(),r._setSizeByScreen(),r.update()}),r.data.useOrientationApi?(window.addEventListener("deviceorientation",function(t){var e=window.orientation;t&&t.gamma&&!r.data.appearEffect&&(r.isBeingZoomed||r.photoSwipable||r.data.elastic||!r.data.scale||(0===e?r._calcGravity(t.gamma,t.beta):90===e?r._calcGravity(t.beta,t.gamma):-90===e?r._calcGravity(-t.beta,-t.gamma):180===e&&r._calcGravity(-t.gamma,-t.beta)))}),r):i(r)):(window.addEventListener("resize",function(){r._resetTranslate(),r._setPosByCurrentIndex(),r._setSizeByScreen(),r.update()}),window.addEventListener("keydown",function(t){var e=t.keyCode||t.which;!0!==r.data.hide&&(37===e?r.gotoSlide(r.data.prev):39===e?r.gotoSlide(r.data.next):27===e&&r.hidePhoto())}),i(r))}return r(e,t),s(e,[{key:"on",value:function(t,e){var a=this;this._getElementByClass(this.data.classNames.smartPhoto).addEventListener(t,function(t){e.call(a,t)})}},{key:"increment",value:function(t){return t+1}},{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:"_getEachImageSize",value:function(){var t=[],e=this.data.group,a=function(e){var a=new Promise(function(t,a){var o=new Image;o.onload=function(){e.width=o.width,e.height=o.height,e.loaded=!0,t()},o.onerror=function(){a()},o.src=e.src});t.push(a)};return Object.keys(e).forEach(function(t){e[t].forEach(a)}),Promise.all(t)}},{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 i=o[a].length,r={src:t.getAttribute("href"),caption:t.getAttribute("data-caption"),groupId:a,translateX:this._getWindowWidth()*i,index:i,translateY:0,width:50,height:50,id:t.getAttribute("data-id")||i,loaded:!1,element:t};o[a].push(r),this.data.currentGroup=a,t.getAttribute("data-id")||t.setAttribute("data-id",i),t.setAttribute("data-index",i),t.addEventListener("click",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),e.clicked=!0,e.update(),e._fireEvent("open")):e._loadItem(o).then(function(){e.data.appear=!0,e.clicked=!0,e._initPhoto(),e.update(),e._fireEvent("open")})})}},{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())}},{key:"onUpdated",value:function(){var t=this;if(this.data.appearEffect&&this.data.appearEffect.once&&(this.data.appearEffect.once=!1,this.execEffect().then(function(){t.replaceEffectWithImg()})),this.clicked){this.clicked=!1;var e=this.data.classNames;this._getElementByClass(e.smartPhotoCaption).focus()}}},{key:"execEffect",value:function(){var t=this.data.appearEffect,e=this.data.classNames,a=document.querySelector('[data-id="'+this.id+'"] .'+e.smartPhotoImgClone);return new Promise(function(e){setTimeout(function(){a.style.transition="all .3s ease-out",a.style.transform="translate("+t.afterX+"px, "+t.afterY+"px) scale("+t.scale+")",e()},30)})}},{key:"replaceEffectWithImg",value:function(){var t=this;setTimeout(function(){t.data.appearEffect=null,t.data.appear=!0,t.update()},300)}},{key:"addAppearEffect",value:function(t){var e=t.querySelector("img"),a=c.getViewPos(e),o={},i=1;o.width=e.offsetWidth,o.height=e.offsetHeight,o.top=a.top,o.left=a.left,o.once=!0,o.img=e.getAttribute("src");var r=this._getWindowWidth(),s=this._getWindowHeight(),n=s-this.data.headerHeight-this.data.footerHeight;"fill"===this.data.resizeStyle&&this.data.isSmartPhone?i=e.offsetWidth>e.offsetHeight?s/e.offsetHeight:r/e.offsetWidth:(i=n/e.offsetHeight)*e.offsetWidth>r&&(i=r/e.offsetWidth);var h=(i-1)/2*e.offsetWidth+(r-e.offsetWidth*i)/2,d=(i-1)/2*e.offsetHeight+(s-e.offsetHeight*i)/2;o.afterX=h,o.afterY=d,o.scale=i,this.data.appearEffect=o}},{key:"hidePhoto",value:function(){var t=this;this.data.hide=!0,this.data.appear=!1,this.data.appearEffect=null,this.data.hideUi=!1,this.data.scale=!1,this.data.scaleSize=1;var e=window.scrollX,a=window.scrollY;location.hash&&this._setHash(""),window.scroll(e,a),this._doHideEffect().then(function(){t.update(),t._fireEvent("close")})}},{key:"_doHideEffect",value:function(){var t=this;return new Promise(function(e){var a=t.data.classNames,o=t._getElementByClass(a.smartPhoto),i=t._getElementByQuery(".current ."+a.smartPhotoImg),r=t._getWindowHeight(),s=function t(){o.removeEventListener("transitionend",t,!0),e()};o.style.opacity=0,i.style.transform="translateY("+r+"px)",o.addEventListener("transitionend",s,!0)})}},{key:"_getElementByClass",value:function(t){return document.querySelector('[data-id="'+this.id+'"] .'+t)}},{key:"_getElementByQuery",value:function(t){return document.querySelector('[data-id="'+this.id+'"] '+t)}},{key:"_getTouchPos",value:function(){var t=0,e=0,a="undefined"==typeof event?this.e:event;return this._isTouched(a)?(t=a.touches[0].pageX,e=a.touches[0].pageY):a.pageX&&(t=a.pageX,e=a.pageY),{x:t,y:e}}},{key:"_getGesturePos",value:function(t){var e=t.touches;return[{x:e[0].pageX,y:e[0].pageY},{x:e[1].pageX,y:e[1].pageY}]}},{key:"_setPosByCurrentIndex",value:function(){var t=this,e=this.groupItems(),a=-1*e[this.data.currentIndex].translateX;this.pos.x=a,setTimeout(function(){t.data.translateX=a,t.data.translateY=0,t._listUpdate()},1)}},{key:"_setHashByCurrentIndex",value:function(){var t=window.scrollX,e=window.scrollY,a=this.groupItems(),o=a[this.data.currentIndex].id,i=this.data.currentGroup,r="group="+i+"&photo="+o;this._setHash(r),window.scroll(t,e)}},{key:"_setHash",value:function(t){window.history&&window.history.pushState&&(t?window.history.replaceState(null,null,location.pathname+"#"+t):window.history.replaceState(null,null,""+location.pathname))}},{key:"_getCurrentItemByHash",value:function(){var t=this.data.group,e=location.hash.substr(1),a=c.parseQuery(e),o=null,i=function(t){a.group===t.groupId&&a.photo===t.id&&(o=t)};return Object.keys(t).forEach(function(e){t[e].forEach(i)}),o}},{key:"_loadItem",value:function(t){return new Promise(function(e){var a=new Image;a.onload=function(){t.width=a.width,t.height=a.height,t.loaded=!0,e()},a.onerror=function(){e()},a.src=t.src})}},{key:"_setSizeByScreen",value:function(){var t=this._getWindowWidth(),e=this._getWindowHeight(),a=this.data.headerHeight,o=this.data.footerHeight,i=e-(a+o);this.groupItems().forEach(function(a){a.scale=i/a.height,a.x=(a.scale-1)/2*a.width+(t-a.width*a.scale)/2,a.y=(a.scale-1)/2*a.height+(e-a.height*a.scale)/2,a.width*a.scale>t&&(a.scale=t/a.width,a.x=(a.scale-1)/2*a.width)})}},{key:"_slideList",value:function(){var t=this;this.data.scaleSize=1,this.isBeingZoomed=!1,this.data.hideUi=!1,this.data.scale=!1,this.data.photoPosX=0,this.data.photoPosY=0,this.data.onMoveClass=!0,this._setPosByCurrentIndex(),this._setHashByCurrentIndex(),this._setSizeByScreen(),setTimeout(function(){t.data.onMoveClass=!1,t.setArrow(),t.update(),t.data.oldIndex!==t.data.currentIndex&&t._fireEvent("change"),t.data.oldIndex=t.data.currentIndex},200)}},{key:"gotoSlide",value:function(t){this.e&&this.e.preventDefault&&this.e.preventDefault(),this.data.currentIndex=parseInt(t,10),this.data.currentIndex||(this.data.currentIndex=0),this._slideList()}},{key:"setArrow",value:function(){var t=this.groupItems(),e=t.length,a=this.data.currentIndex+1,o=this.data.currentIndex-1;this.data.showNextArrow=!1,this.data.showPrevArrow=!1,a!==e&&(this.data.next=a,this.data.showNextArrow=!0),-1!==o&&(this.data.prev=o,this.data.showPrevArrow=!0)}},{key:"beforeDrag",value:function(){if(this._isGestured(this.e))return void this.beforeGesture();if(this.isBeingZoomed=!1,this.data.scale)return void this.beforePhotoDrag();var t=this._getTouchPos();this.isSwipable=!0,this.dragStart=!0,this.firstPos=t,this.oldPos=t}},{key:"afterDrag",value:function(){var t=this.groupItems(),e=new Date,a=e.getTime(),o=this.tapSecond-a,i=0,r=0;return this.isSwipable=!1, | ||
this.onListMove=!1,this.oldPos&&(i=this.oldPos.x-this.firstPos.x,r=this.oldPos.y-this.firstPos.y),this.isBeingZoomed?void this.afterGesture():this.data.scale?void this.afterPhotoDrag():c.isSmartPhone()||0!==i||0!==r?Math.abs(o)<=500&&0===i&&0===r?(this.e.preventDefault(),void this.zoomPhoto()):(this.tapSecond=a,this._fireEvent("swipeend"),"horizontal"===this.moveDir&&(i>=this.data.swipeOffset&&0!==this.data.currentIndex?this.data.currentIndex-=1:i<=-this.data.swipeOffset&&this.data.currentIndex!==t.length-1&&(this.data.currentIndex+=1),this._slideList()),void("vertical"===this.moveDir&&(r>=this.data.swipeOffset?this.hidePhoto():(this.data.translateY=0,this._slideList())))):void this.zoomPhoto()}},{key:"onDrag",value:function(){if(this.e.preventDefault(),this._isGestured(this.e)&&!1===this.onListMove)return void this.onGesture();if(!this.isBeingZoomed){if(this.data.scale)return void this.onPhotoDrag();if(this.isSwipable){var t=this._getTouchPos(),e=t.x-this.oldPos.x,a=t.y-this.firstPos.y;this.dragStart&&(this._fireEvent("swipestart"),this.dragStart=!1,Math.abs(e)>Math.abs(a)?this.moveDir="horizontal":this.moveDir="vertical"),"horizontal"===this.moveDir?(this.pos.x+=e,this.data.translateX=this.pos.x):this.data.translateY=a,this.onListMove=!0,this.oldPos=t,this._listUpdate()}}}},{key:"zoomPhoto",value:function(){var t=this;this.data.hideUi=!0,this.data.scaleSize=this._getScaleBoarder(),this.data.photoPosX=0,this.data.photoPosY=0,this._photoUpdate(),setTimeout(function(){t.data.scale=!0,t._photoUpdate(),t._fireEvent("zoomin")},300)}},{key:"zoomOutPhoto",value:function(){this.data.scaleSize=1,this.isBeingZoomed=!1,this.data.hideUi=!1,this.data.scale=!1,this.data.photoPosX=0,this.data.photoPosY=0,this._photoUpdate(),this._fireEvent("zoomout")}},{key:"beforePhotoDrag",value:function(){var t=this._getTouchPos();this.photoSwipable=!0,this.data.photoPosX||(this.data.photoPosX=0),this.data.photoPosY||(this.data.photoPosY=0),this.oldPhotoPos=t,this.firstPhotoPos=t}},{key:"onPhotoDrag",value:function(){if(this.photoSwipable){this.e.preventDefault();var t=this._getTouchPos(),e=t.x-this.oldPhotoPos.x,a=t.y-this.oldPhotoPos.y,o=this._round(this.data.scaleSize*e,6),i=this._round(this.data.scaleSize*a,6);"number"==typeof o&&(this.data.photoPosX+=o,this.photoVX=o),"number"==typeof i&&(this.data.photoPosY+=i,this.photoVY=i),this.oldPhotoPos=t,this._photoUpdate()}}},{key:"afterPhotoDrag",value:function(){if(this.oldPhotoPos.x===this.firstPhotoPos.x&&this.photoSwipable)this.photoSwipable=!1,this.zoomOutPhoto();else{this.photoSwipable=!1;var t=this._getSelectedItem(),e=this._makeBound(t),a=this.data.swipeOffset*this.data.scaleSize,o=0,i=0;if(this.data.photoPosX>e.maxX?o=-1:this.data.photoPosX<e.minX&&(o=1),this.data.photoPosY>e.maxY?i=-1:this.data.photoPosY<e.minY&&(i=1),this.data.photoPosX-e.maxX>a&&0!==this.data.currentIndex)return void this.gotoSlide(this.data.prev);if(e.minX-this.data.photoPosX>a&&this.data.currentIndex+1!==this.data.total)return void this.gotoSlide(this.data.next);0===o&&0===i?(this.vx=this.photoVX/5,this.vy=this.photoVY/5):this._registerElasticForce(o,i)}}},{key:"beforeGesture",value:function(){this._fireEvent("gesturestart");var t=this._getGesturePos(this.e),e=this._getDistance(t[0],t[1]);this.isBeingZoomed=!0,this.oldDistance=e,this.data.scale=!0,this.e.preventDefault()}},{key:"onGesture",value:function(){var t=this._getGesturePos(this.e),e=this._getDistance(t[0],t[1]),a=(e-this.oldDistance)/100,o=this.data.scaleSize,i=this.data.photoPosX,r=this.data.photoPosY;this.isBeingZoomed=!0,this.data.scaleSize+=this._round(a,6),this.data.scaleSize<.2&&(this.data.scaleSize=.2),this.data.scaleSize<o&&(this.data.photoPosX=(1+this.data.scaleSize-o)*i,this.data.photoPosY=(1+this.data.scaleSize-o)*r),this.data.scaleSize<1||this.data.scaleSize>this._getScaleBoarder()?this.data.hideUi=!0:this.data.hideUi=!1,this.oldDistance=e,this.e.preventDefault(),this._photoUpdate()}},{key:"afterGesture",value:function(){this.data.scaleSize>this._getScaleBoarder()||(this.data.photoPosX=0,this.data.photoPosY=0,this.data.scale=!1,this.data.scaleSize=1,this.data.hideUi=!1,this._fireEvent("gestureend"),this._photoUpdate())}},{key:"_getForceAndTheta",value:function(t,e){return{force:Math.sqrt(t*t+e*e),theta:Math.atan2(e,t)}}},{key:"_getScaleBoarder",value:function(){var t=this._getSelectedItem(),e=this._getWindowWidth(),a=this._getWindowHeight();return c.isSmartPhone()?t.width>t.height?a/(t.height*t.scale):e/(t.width*t.scale):1/t.scale}},{key:"_makeBound",value:function(t){var e=t.width*t.scale*this.data.scaleSize,a=t.height*t.scale*this.data.scaleSize,o=void 0,i=void 0,r=void 0,s=void 0,n=this._getWindowWidth(),h=this._getWindowHeight();return n>e?(r=(n-e)/2,o=-1*r):(r=(e-n)/2,o=-1*r),h>a?(s=(h-a)/2,i=-1*s):(s=(a-h)/2,i=-1*s),{minX:this._round(o,6)*this.data.scaleSize,minY:this._round(i,6)*this.data.scaleSize,maxX:this._round(r,6)*this.data.scaleSize,maxY:this._round(s,6)*this.data.scaleSize}}},{key:"_registerElasticForce",value:function(t,e){var a=this,o=this._getSelectedItem(),i=this._makeBound(o);this.data.elastic=!0,1===t?this.data.photoPosX=i.minX:-1===t&&(this.data.photoPosX=i.maxX),1===e?this.data.photoPosY=i.minY:-1===e&&(this.data.photoPosY=i.maxY),this._photoUpdate(),setTimeout(function(){a.data.elastic=!1,a._photoUpdate()},300)}},{key:"_getSelectedItem",value:function(){var t=this.data,e=t.currentIndex;return t.group[t.currentGroup][e]}},{key:"_getUniqId",value:function(){return(Date.now().toString(36)+Math.random().toString(36).substr(2,5)).toUpperCase()}},{key:"_getDistance",value:function(t,e){var a=t.x-e.x,o=t.y-e.y;return Math.sqrt(a*a+o*o)}},{key:"_round",value:function(t,e){var a=Math.pow(10,e);return t*=a,t=Math.round(t),t/=a}},{key:"_isTouched",value:function(t){return!(!t||!t.touches)}},{key:"_isGestured",value:function(t){return!!(t&&t.touches&&t.touches.length>1)}},{key:"_isSmartPhone",value:function(){var t=navigator.userAgent;return t.indexOf("iPhone")>0||t.indexOf("iPad")>0||t.indexOf("ipod")>0||t.indexOf("Android")>0}},{key:"_calcGravity",value:function(t,e){(t>5||t<-5)&&(this.vx+=.05*t),!1!==this.data.verticalGravity&&(e>5||e<-5)&&(this.vy+=.05*e)}},{key:"_photoUpdate",value:function(){var t=this.data.classNames,e=this._getElementByQuery(".current"),a=e.querySelector("."+t.smartPhotoImg),o=this._getElementByQuery("."+t.smartPhotoNav),i=this._getElementByQuery("."+t.smartPhotoArrows),r=this.virtualPos(this.data.photoPosX),s=this.virtualPos(this.data.photoPosY),n=this.data.scaleSize,h="translate("+r+"px,"+s+"px) scale("+n+")";a.style.transform=h,this.data.scale?c.addClass(a,t.smartPhotoImgOnMove):c.removeClass(a,t.smartPhotoImgOnMove),this.data.elastic?c.addClass(a,t.smartPhotoImgElasticMove):c.removeClass(a,t.smartPhotoImgElasticMove),this.data.hideUi?(o&&o.setAttribute("aria-hidden","true"),i&&i.setAttribute("aria-hidden","true")):(o&&o.setAttribute("aria-hidden","false"),i&&i.setAttribute("aria-hidden","false"))}},{key:"_getWindowWidth",value:function(){return document.documentElement.clientWidth}},{key:"_getWindowHeight",value:function(){return window.innerHeight}},{key:"_listUpdate",value:function(){var t=this.data.classNames,e=this._getElementByQuery("."+t.smartPhotoList),a="translate("+this.data.translateX+"px,"+this.data.translateY+"px)";e.style.transform=a,this.data.onMoveClass?c.addClass(e,t.smartPhotoListOnMove):c.removeClass(e,t.smartPhotoListOnMove)}},{key:"_fireEvent",value:function(t){var e=this._getElementByClass(this.data.classNames.smartPhoto);c.triggerEvent(e,t)}},{key:"_doAnim",value:function(){if(!(this.isBeingZoomed||this.isSwipable||this.photoSwipable||this.data.elastic)&&this.data.scale){this.data.photoPosX+=this.vx,this.data.photoPosY+=this.vy;var t=this._getSelectedItem(),e=this._makeBound(t);this.data.photoPosX<e.minX?(this.data.photoPosX=e.minX,this.vx*=-.2):this.data.photoPosX>e.maxX&&(this.data.photoPosX=e.maxX,this.vx*=-.2),this.data.photoPosY<e.minY?(this.data.photoPosY=e.minY,this.vy*=-.2):this.data.photoPosY>e.maxY&&(this.data.photoPosY=e.maxY,this.vy*=-.2);var a=this._getForceAndTheta(this.vx,this.vy),o=a.force,i=a.theta;o-=this.data.registance,Math.abs(o)<.5||(this.vx=Math.cos(i)*o,this.vy=Math.sin(i)*o,this._photoUpdate())}}}]),e}(h.default);e.exports=u},{"../lib/util":8,"a-template":1}],7:[function(t,e,a){"use strict";e.exports=t("./core/")},{"./core/":6}],8:[function(t,e,a){"use strict";function o(t){t=t||{};for(var e=1;e<arguments.length;e++){var a=arguments[e];if(a)for(var r in a)a.hasOwnProperty(r)&&("object"===i(a[r])?t[r]=o(t[r],a[r]):t[r]=a[r])}return t}var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};e.exports.isSmartPhone=function(){var t=navigator.userAgent;return t.indexOf("iPhone")>0||t.indexOf("iPad")>0||t.indexOf("ipod")>0||t.indexOf("Android")>0},e.exports.extend=o,e.exports.triggerEvent=function(t,e,a){var o=void 0;window.CustomEvent?o=new CustomEvent(e,{cancelable:!0}):(o=document.createEvent("CustomEvent"),o.initCustomEvent(e,!1,!1,a)),t.dispatchEvent(o)},e.exports.parseQuery=function(t){for(var e,a,o,i=t.split("&"),r={},s=0,n=i.length;s<n;s++)e=i[s].split("="),void 0!==e[0]&&(a=e[0],o=void 0!==e[1]?e.slice(1).join("="):a,r[a]=decodeURIComponent(o));return r},e.exports.getViewPos=function(t){return{left:t.getBoundingClientRect().left,top:t.getBoundingClientRect().top}},e.exports.removeElement=function(t){t&&t.parentNode&&t.parentNode.removeChild(t)},e.exports.append=function(t,e){var a=new DOMParser,o=a.parseFromString(e,"text/html");t.appendChild(o.querySelector("body").childNodes[0])},e.exports.addClass=function(t,e){t.classList?t.classList.add(e):t.className+=" "+e},e.exports.removeClass=function(t,e){t.classList?t.classList.remove(e):t.className=t.className.replace(new RegExp("(^|\\b)"+e.split(" ").join("|")+"(\\b|$)","gi")," ")}},{}]},{},[5]); | ||
!function t(e,a,o){function i(s,n){if(!a[s]){if(!e[s]){var h="function"==typeof require&&require;if(!n&&h)return h(s,!0);if(r)return r(s,!0);var d=new Error("Cannot find module '"+s+"'");throw d.code="MODULE_NOT_FOUND",d}var c=a[s]={exports:{}};e[s][0].call(c.exports,function(t){var a=e[s][1][t];return i(a||t)},c,c.exports,t,e,a,o)}return a[s].exports}for(var r="function"==typeof require&&require,s=0;s<o.length;s++)i(o[s]);return i}({1:[function(t,e,a){"use strict";function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}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}}(),r=t("morphdom"),s=t("delegate"),n=[],h="input paste copy click change keydown keyup contextmenu mouseup mousedown mousemove touchstart touchend touchmove compositionstart compositionend",d=h.replace(/([a-z]+)/g,"[data-action-$1],")+"[data-action]";Array.prototype.find||(Array.prototype.find=function(t){if(null===this)throw new TypeError("Array.prototype.find called on null or undefined");if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var e=Object(this),a=e.length>>>0,o=arguments[1],i=void 0,r=0;r<a;r++)if(i=e[r],t.call(o,i,r,e))return i}),Element.prototype.matches||(Element.prototype.matches=Element.prototype.matchesSelector||Element.prototype.mozMatchesSelector||Element.prototype.msMatchesSelector||Element.prototype.oMatchesSelector||Element.prototype.webkitMatchesSelector||function(t){for(var e=(this.document||this.ownerDocument).querySelectorAll(t),a=e.length;--a>=0&&e.item(a)!==this;);return a>-1});var c=function(t){return document.querySelector(t)},l=function(t){for(var e=0,a=n.length;e<a;e++)for(var o=n[e],i=o.templates,r=0,s=i.length;r<s;r++)if(i[r]==t)return o;return null},u=function(t,e){if("function"==typeof t.closest)return t.closest(e)||null;for(;t;){if(t.matches(e))return t;t=t.parentElement}return null},p=function(t,e,a,o){a.split(" ").forEach(function(a){s(t,e,a,o)})};"undefined"!=typeof document&&(p(document,"[data-bind]","input change click",function(t){var e=t.delegateTarget,a=e.getAttribute("data-bind"),o=e.getAttribute("href"),i=u(e,"[data-id]").getAttribute("data-id"),r=e.value;if(o&&(r=r.replace("#","")),i){var s=l(i);"radio"===e.getAttribute("type")||("checkbox"===e.getAttribute("type")?function(){var t=[],e=document.querySelectorAll('[data-bind="'+a+'"]');[].forEach.call(e,function(e){e.checked&&t.push(e.value)})}():s.updateDataByString(a,r))}}),p(document,d,h,function(t){var e=t.delegateTarget;if(!("click"===t.type&&"select"===e.tagName||"input"===t.type&&"button"===e.getAttribute("type"))){var a=h.split(" "),o="action";a.forEach(function(a){e.getAttribute("data-action-"+a)&&t.type===a&&(o+="-"+a)});var i=e.getAttribute("data-"+o);if(i){var r=i.replace(/\(.*?\);?/,""),s=i.replace(/(.*?)\((.*?)\);?/,"$2"),n=s.split(","),d=u(e,"[data-id]").getAttribute("data-id");if(d){var c=l(d);c.e=t,c.method&&c.method[r]?c.method[r].apply(c,n):c[r]&&c[r].apply(c,n)}}}}));var f=function(){function t(e){o(this,t),this.atemplate=[],n.push(this);for(var a in e)this[a]=e[a];this.data||(this.data={}),this.templates||(this.templates=[]);for(var i=this.templates,r=i.length,s=0,h=r;s<h;s++){var d=this.templates[s],l=c("#"+d).innerHTML;this.atemplate.push({id:d,html:l})}this.setId()}return i(t,[{key:"addTemplate",value:function(t,e){this.atemplate.push({id:t,html:e}),this.templates.push(t)}},{key:"loadHtml",value:function(){var t=this.templates,e=[];return t.forEach(function(t){var a=new $.Deferred;e.push(a);var o=c("#"+t).getAttribute("src");$.ajax({url:o,type:"GET",dataType:"text"}).success(function(e){c("#"+t).innerHTML=e,a.resolve()})}),$.when.apply($,e)}},{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){for(var e in t)"function"!=typeof t[e]&&(this.data[e]=t[e])}},{key:"loadData",value:function(t){var e=JSON.parse(localStorage.getItem(t));if(e)for(var a in e)"function"!=typeof e[a]&&(this.data[a]=e[a])}},{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,i=0;i<t;i++)e+=a.charAt(Math.floor(this.getRand(0,o)));return e}},{key:"setId",value:function(){for(var e=void 0,a=(t.ids,!1);;){e=this.getRandText(10);for(var o=0,i=t.ids;o<i;o++)t.ids[o]===e&&(a=!0);if(!1===a)break}this.data.aTemplate_id=e}},{key:"getDataFromObj",value:function(t,e){t=t.replace(/\[([a-zA-Z0-9._-]+)\]/g,".$1"),t=t.replace(/^\./,"");for(var a=t.split(".");a.length;){var o=a.shift();if(!(o in e))return;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.split(".");a.length>1;)e=e[a.shift()];var o=a.shift();o.match(/^\d+$/)?e.splice(Number(o),1):delete e[o]}},{key:"resolveBlock",value:function(t,e,a){var o=this,i=t.match(/<!-- BEGIN ([a-zA-Z0-9._-]+):touch#([a-zA-Z0-9._-]+) -->/g),r=t.match(/<!-- BEGIN ([a-zA-Z0-9._-]+):touchnot#([a-zA-Z0-9._-]+) -->/g),s=t.match(/<!-- BEGIN ([a-zA-Z0-9._-]+):exist -->/g),n=t.match(/<!-- BEGIN ([a-zA-Z0-9._-]+):empty -->/g);if(i)for(var h=0,d=i.length;h<d;h++){var c=i[h];c=c.replace(/([a-zA-Z0-9._-]+):touch#([a-zA-Z0-9._-]+)/,"($1):touch#($2)");var l=c.replace(/BEGIN/,"END"),u=new RegExp(c+"(([\\n\\r\\t]|.)*?)"+l,"g");t=t.replace(u,function(t,a,i,r){return("function"==typeof e[a]?e[a].apply(o):o.getDataFromObj(a,e))==i?r:""})}if(r)for(var p=0,f=r.length;p<f;p++){var m=r[p];m=m.replace(/([a-zA-Z0-9._-]+):touchnot#([a-zA-Z0-9._-]+)/,"($1):touchnot#($2)");var v=m.replace(/BEGIN/,"END"),g=new RegExp(m+"(([\\n\\r\\t]|.)*?)"+v,"g");t=t.replace(g,function(t,a,i,r){return("function"==typeof e[a]?e[a].apply(o):o.getDataFromObj(a,e))!=i?r:""})}if(s)for(var x=0,y=s.length;x<y;x++){var P=s[x];P=P.replace(/([a-zA-Z0-9._-]+):exist/,"($1):exist");var E=P.replace(/BEGIN/,"END"),w=new RegExp(P+"(([\\n\\r\\t]|.)*?)"+E,"g");t=t.replace(w,function(t,a,i){var r="function"==typeof e[a]?e[a].apply(o):o.getDataFromObj(a,e);return r||0===r?i:""})}if(n)for(var _=0,b=n.length;_<b;_++){var S=n[_];S=S.replace(/([a-zA-Z0-9._-]+):empty/,"($1):empty");var N=S.replace(/BEGIN/,"END"),I=new RegExp(S+"(([\\n\\r\\t]|.)*?)"+N,"g");t=t.replace(I,function(t,a,i){var r="function"==typeof e[a]?e[a].apply(o):o.getDataFromObj(a,e);return r||0===r?"":i})}return t=t.replace(/{([a-zA-Z0-9._-]+)}(\[([a-zA-Z0-9._-]+)\])*/g,function(t,i,r,s){var n=void 0;if("i"==i)n=a;else{if(!e[i]&&0!==e[i])return s&&o.convert&&o.convert[s]?o.convert[s].call(o,""):"";n="function"==typeof e[i]?e[i].apply(o):e[i]}return s&&o.convert&&o.convert[s]?o.convert[s].call(o,n):n})}},{key:"resolveAbsBlock",value:function(t){var e=this;return t=t.replace(/{(.*?)}/g,function(t,a){var o=e.getDataByString(a);return void 0!==o?"function"==typeof o?o.apply(e):o:t})}},{key:"resolveInclude",value:function(t){return t=t.replace(/<!-- #include id="(.*?)" -->/g,function(t,e){return c("#"+e).innerHTML})}},{key:"resolveWith",value:function(t){return t=t.replace(/<!-- BEGIN ([a-zA-Z0-9._-]+):with -->(([\n\r\t]|.)*?)<!-- END ([a-zA-Z0-9._-]+):with -->/g,function(t,e,a){return t=t.replace(/data\-bind=['"](.*?)['"]/g,"data-bind='"+e+".$1'")})}},{key:"resolveLoop",value:function(t){var e=this;return t=t.replace(/<!-- BEGIN (.+?):loop -->(([\n\r\t]|.)*?)<!-- END (.+?):loop -->/g,function(t,a,o){var i=e.getDataByString(a),r=[];r="function"==typeof i?i.apply(e):i;var s="";if(r instanceof Array)for(var n=0,h=r.length;n<h;n++)s+=e.resolveBlock(o,r[n],n);return s=s.replace(/\\([^\\])/g,"$1")})}},{key:"removeData",value:function(t){var e=this.data;for(var a in e)for(var o=0,i=t.length;o<i;o++)a===t[o]&&delete e[a];return this}},{key:"hasLoop",value:function(t){return!!t.match(/<!-- BEGIN (.+?):loop -->(([\n\r\t]|.)*?)<!-- END (.+?):loop -->/g)}},{key:"getHtml",value:function(t,e){var a=this.atemplate.find(function(e){return e.id===t}),o="";if(a&&a.html&&(o=a.html),e&&(o=t),!o)return"";var i=this.data;for(o=this.resolveInclude(o),o=this.resolveWith(o);this.hasLoop(o);)o=this.resolveLoop(o);return o=this.resolveBlock(o,i),o=o.replace(/\\([^\\])/g,"$1"),o=this.resolveAbsBlock(o),o.replace(/^([\t ])*\n/gm,"")}},{key:"update",value:function(t,e){var a=(this.getHtml(),this.templates),o=t||"html";this.beforeUpdated&&this.beforeUpdated();for(var i=0,s=a.length;i<s;i++){var n=a[i],h="#"+n,d=this.getHtml(n),l=c("[data-id='"+n+"']");if((!e||e==n)&&(l?"text"===o?l.innerText=d:r(l,"<div data-id='"+n+"'>"+d+"</div>"):(c(h).insertAdjacentHTML("afterend",'<div data-id="'+n+'"></div>'),"text"===o?c("[data-id='"+n+"']").innerText=d:c("[data-id='"+n+"']").innerHTML=d),e))break}return this.updateBindingData(e),this.onUpdated&&this.onUpdated(e),this}},{key:"updateBindingData",value:function(t){for(var e=this,a=this.templates,o=0,i=a.length;o<i;o++){var r=a[o];if(!t||t==r){var s=c("[data-id='"+r+"']"),n=s.querySelectorAll("[data-bind]");if([].forEach.call(n,function(t){var a=e.getDataByString(t.getAttribute("data-bind"));"checkbox"===t.getAttribute("type")||"radio"===t.getAttribute("type")?a==t.value&&(t.checked=!0):t.value=a}),t)break}}return this}},{key:"applyMethod",value:function(t){var e=[].splice.call(arguments,0);return e.shift(),this.method[t].apply(this,e)}},{key:"getComputedProp",value:function(t){return this.data[t].apply(this)}},{key:"remove",value:function(t){for(var e=this.data,a=t.split(".");a.length>1;)e=e[a.shift()];var o=a.shift();return o.match(/^\d+$/)?e.splice(Number(o),1):delete e[o],this}}]),t}();e.exports=f},{delegate:3,morphdom:4}],2:[function(t,e,a){function o(t,e){for(;t&&t.nodeType!==i;){if(t.matches(e))return t;t=t.parentNode}}var i=9;if("undefined"!=typeof Element&&!Element.prototype.matches){var r=Element.prototype;r.matches=r.matchesSelector||r.mozMatchesSelector||r.msMatchesSelector||r.oMatchesSelector||r.webkitMatchesSelector}e.exports=o},{}],3:[function(t,e,a){function o(t,e,a,o,r){var s=i.apply(this,arguments);return t.addEventListener(a,s,r),{destroy:function(){t.removeEventListener(a,s,r)}}}function i(t,e,a,o){return function(a){a.delegateTarget=r(a.target,e),a.delegateTarget&&o.call(t,a)}}var r=t("./closest");e.exports=o},{"./closest":2}],4:[function(t,e,a){"use strict";function o(t){!l&&f.createRange&&(l=f.createRange(),l.selectNode(f.body));var e;return l&&l.createContextualFragment?e=l.createContextualFragment(t):(e=f.createElement("body"),e.innerHTML=t),e.childNodes[0]}function i(t,e){var a=t.nodeName,o=e.nodeName;return a===o||!!(e.actualize&&a.charCodeAt(0)<91&&o.charCodeAt(0)>90)&&a===o.toUpperCase()}function r(t,e){return e&&e!==p?f.createElementNS(e,t):f.createElement(t)}function s(t,e){for(var a=t.firstChild;a;){var o=a.nextSibling;e.appendChild(a),a=o}return e}function n(t,e){var a,o,i,r,s,n=e.attributes;for(a=n.length-1;a>=0;--a)o=n[a],i=o.name,r=o.namespaceURI,s=o.value,r?(i=o.localName||i,t.getAttributeNS(r,i)!==s&&t.setAttributeNS(r,i,s)):t.getAttribute(i)!==s&&t.setAttribute(i,s);for(n=t.attributes,a=n.length-1;a>=0;--a)o=n[a],!1!==o.specified&&(i=o.name,r=o.namespaceURI,r?(i=o.localName||i,v(e,r,i)||t.removeAttributeNS(r,i)):v(e,null,i)||t.removeAttribute(i))}function h(t,e,a){t[a]!==e[a]&&(t[a]=e[a],t[a]?t.setAttribute(a,""):t.removeAttribute(a,""))}function d(){}function c(t){return t.id}var l,u,p="http://www.w3.org/1999/xhtml",f="undefined"==typeof document?void 0:document,m=f?f.body||f.createElement("div"):{};u=m.hasAttributeNS?function(t,e,a){return t.hasAttributeNS(e,a)}:m.hasAttribute?function(t,e,a){return t.hasAttribute(a)}:function(t,e,a){return null!=t.getAttributeNode(e,a)};var v=u,g={OPTION:function(t,e){h(t,e,"selected")},INPUT:function(t,e){h(t,e,"checked"),h(t,e,"disabled"),t.value!==e.value&&(t.value=e.value),v(e,null,"value")||t.removeAttribute("value")},TEXTAREA:function(t,e){var a=e.value;t.value!==a&&(t.value=a);var o=t.firstChild;if(o){var i=o.nodeValue;if(i==a||!a&&i==t.placeholder)return;o.nodeValue=a}},SELECT:function(t,e){if(!v(e,null,"multiple")){for(var a=0,o=e.firstChild;o;){var i=o.nodeName;if(i&&"OPTION"===i.toUpperCase()){if(v(o,null,"selected")){a;break}a++}o=o.nextSibling}t.selectedIndex=a}}},x=1,y=3,P=8,E=function(t){return function(e,a,n){function h(t){w?w.push(t):w=[t]}function l(t,e){if(t.nodeType===x)for(var a=t.firstChild;a;){var o=void 0;e&&(o=_(a))?h(o):(A(a),a.firstChild&&l(a,e)),a=a.nextSibling}}function u(t,e,a){!1!==k(t)&&(e&&e.removeChild(t),A(t),l(t,a))}function p(t){if(t.nodeType===x)for(var e=t.firstChild;e;){var a=_(e);a&&(C[a]=e),p(e),e=e.nextSibling}}function m(t){S(t);for(var e=t.firstChild;e;){var a=e.nextSibling,o=_(e);if(o){var r=C[o];r&&i(e,r)&&(e.parentNode.replaceChild(r,e),v(r,e))}m(e),e=a}}function v(o,r,s){var n,d=_(r);if(d&&delete C[d],!a.isSameNode||!a.isSameNode(e)){if(!s){if(!1===N(o,r))return;if(t(o,r),I(o),!1===B(o,r))return}if("TEXTAREA"!==o.nodeName){var c,l,p,E,w=r.firstChild,S=o.firstChild;t:for(;w;){for(p=w.nextSibling,c=_(w);S;){if(l=S.nextSibling,w.isSameNode&&w.isSameNode(S)){w=p,S=l;continue t}n=_(S);var k=S.nodeType,A=void 0;if(k===w.nodeType&&(k===x?(c?c!==n&&((E=C[c])?S.nextSibling===E?A=!1:(o.insertBefore(E,S),l=S.nextSibling,n?h(n):u(S,o,!0),S=E):A=!1):n&&(A=!1),(A=!1!==A&&i(S,w))&&v(S,w)):k!==y&&k!=P||(A=!0,S.nodeValue=w.nodeValue)),A){w=p,S=l;continue t}n?h(n):u(S,o,!0),S=l}if(c&&(E=C[c])&&i(E,w))o.appendChild(E),v(E,w);else{var D=b(w);!1!==D&&(D&&(w=D),w.actualize&&(w=w.actualize(o.ownerDocument||f)),o.appendChild(w),m(w))}w=p,S=l}for(;S;)l=S.nextSibling,(n=_(S))?h(n):u(S,o,!0),S=l}var z=g[o.nodeName];z&&z(o,r)}}if(n||(n={}),"string"==typeof a)if("#document"===e.nodeName||"HTML"===e.nodeName){var E=a;a=f.createElement("html"),a.innerHTML=E}else a=o(a);var w,_=n.getNodeKey||c,b=n.onBeforeNodeAdded||d,S=n.onNodeAdded||d,N=n.onBeforeElUpdated||d,I=n.onElUpdated||d,k=n.onBeforeNodeDiscarded||d,A=n.onNodeDiscarded||d,B=n.onBeforeElChildrenUpdated||d,D=!0===n.childrenOnly,C={};p(e);var z=e,G=z.nodeType,T=a.nodeType;if(!D)if(G===x)T===x?i(e,a)||(A(e),z=s(e,r(a.nodeName,a.namespaceURI))):z=a;else if(G===y||G===P){if(T===G)return z.nodeValue=a.nodeValue,z;z=a}if(z===a)A(e);else if(v(z,a,D),w)for(var O=0,X=w.length;O<X;O++){var M=C[w[O]];M&&u(M,M.parentNode,!1)}return!D&&z!==e&&e.parentNode&&(z.actualize&&(z=z.actualize(e.ownerDocument||f)),e.parentNode.replaceChild(z,e)),z}}(n);e.exports=E},{}],5:[function(t,e,a){"use strict";var o=t("../index"),i=function(t){t.fn.smartPhoto=function(t){return"strings"==typeof t||new o(this.selector,t),this}};if("function"==typeof define&&define.amd)define(["jquery"],i);else{var r=window.jQuery?window.jQuery:window.$;void 0!==r&&i(r)}e.exports=i},{"../index":7}],6:[function(t,e,a){"use strict";function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function r(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}var s=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}}(),n=t("a-template"),h=function(t){return t&&t.__esModule?t:{default:t}}(n),d='<div class="\\{classNames.smartPhoto\\}"\x3c!-- BEGIN hide:exist --\x3e aria-hidden="true"\x3c!-- END hide:exist --\x3e\x3c!-- BEGIN hide:empty --\x3e aria-hidden="false"\x3c!-- END hide:empty --\x3e role="dialog">\n\t<div class="\\{classNames.smartPhotoBody\\}">\n\t\t<div class="\\{classNames.smartPhotoInner\\}">\n\t\t\t <div class="\\{classNames.smartPhotoHeader\\}">\n\t\t\t\t\t<span class="\\{classNames.smartPhotoCount\\}">{currentIndex}[increment]/{total}</span>\n\t\t\t\t\t<span class="\\{classNames.smartPhotoCaption\\}" aria-live="polite" tabindex="-1">\x3c!-- BEGIN groupItems:loop --\x3e\x3c!-- \\BEGIN currentIndex:touch#{index} --\x3e{caption}\x3c!-- \\END currentIndex:touch#{index} --\x3e\x3c!-- END groupItems:loop --\x3e</span>\n\t\t\t\t\t<button class="\\{classNames.smartPhotoDismiss\\}" data-action-click="hidePhoto()"><span class="smartphoto-sr-only">\\{message.closeDialog\\}</span></button>\n\t\t\t\t</div>\n\t\t\t\t<div class="\\{classNames.smartPhotoContent\\}"\x3c!-- BEGIN isSmartPhone:exist --\x3e data-action-touchstart="beforeDrag" data-action-touchmove="onDrag" data-action-touchend="afterDrag(false)"\x3c!-- END isSmartPhone:exist --\x3e>\n\t\t\t\t</div>\n\t\t\t\t<ul style="transform:translate({translateX}px,{translateY}px);" class="\\{classNames.smartPhotoList\\}\x3c!-- BEGIN onMoveClass:exist --\x3e \\{classNames.smartPhotoListOnMove\\}\x3c!-- END onMoveClass:exist --\x3e">\n\t\t\t\t\t\x3c!-- BEGIN groupItems:loop --\x3e\n\t\t\t\t\t<li style="transform:translate({translateX}px,{translateY}px);" class="\x3c!-- \\BEGIN currentIndex:touch#{index} --\x3ecurrent\x3c!-- \\END currentIndex:touch#{index} --\x3e">\n\t\t\t\t\t\t\x3c!-- BEGIN processed:exist --\x3e\n\t\t\t\t\t\t<div style="transform:translate({x}px,{y}px) scale({scale});" class="\\\\{classNames.smartPhotoImgWrap\\\\}"\x3c!-- \\BEGIN isSmartPhone:empty --\x3e data-action-mousemove="onDrag" data-action-mousedown="beforeDrag" data-action-mouseup="afterDrag"\x3c!-- \\END isSmartPhone:empty --\x3e\x3c!-- \\BEGIN isSmartPhone:exist --\x3e data-action-touchstart="beforeDrag" data-action-touchmove="onDrag" data-action-touchend="afterDrag"\x3c!-- \\END isSmartPhone:exist --\x3e>\n\t\t\t\t\t\t\t<img style="\x3c!-- \\BEGIN currentIndex:touch#{index} --\x3etransform:translate(\\{photoPosX\\}[virtualPos]px,\\{photoPosY\\}[virtualPos]px) scale(\\{scaleSize\\});\x3c!-- \\END currentIndex:touch#{index} --\x3e" src="{src}" class="\\\\{classNames.smartPhotoImg\\\\}\x3c!-- \\BEGIN scale:exist --\x3e \\\\{classNames.smartPhotoImgOnMove\\\\}\x3c!-- \\END scale:exist --\x3e\x3c!-- \\BEGIN elastic:exist --\x3e \\\\{classNames.smartPhotoImgElasticMove\\\\}\x3c!-- \\END elastic:exist --\x3e\x3c!-- \\BEGIN appear:exist --\x3e active\x3c!-- \\END appear:exist --\x3e" ondragstart="return false;">\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\x3c!-- END processed:exist --\x3e\n\t\t\t\t\t\t\x3c!-- BEGIN processed:empty --\x3e\n\t\t\t\t\t\t<div class="\\\\{classNames.smartPhotoLoaderWrap\\\\}">\n\t\t\t\t\t\t\t<span class="\\\\{classNames.smartPhotoLoader\\\\}"></span>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\x3c!-- END processed:empty --\x3e\n\t\t\t\t\t</li>\n\t\t\t\t\t\x3c!-- END groupItems:loop --\x3e\n\t\t\t\t</ul>\n\t\t\t\t\x3c!-- BEGIN arrows:exist --\x3e\n\t\t\t\t<ul class="\\{classNames.smartPhotoArrows\\}"\x3c!-- BEGIN hideUi:exist --\x3e aria-hidden="true"\x3c!-- END hideUi:exist --\x3e\x3c!-- BEGIN hideUi:exist --\x3e aria-hidden="false"\x3c!-- END hideUi:exist --\x3e>\n\t\t\t\t\t<li class="\\{classNames.smartPhotoArrowLeft\\}"\x3c!-- BEGIN showPrevArrow:empty --\x3e aria-hidden="true"\x3c!-- END showPrevArrow:empty --\x3e><a href="#" data-action-click="gotoSlide({prev})" role="button"><span class="smartphoto-sr-only">\\{message.gotoPrevImage\\}</span></a></li>\n\t\t\t\t\t<li class="\\{classNames.smartPhotoArrowRight\\}"\x3c!-- BEGIN showNextArrow:empty --\x3e aria-hidden="true"\x3c!-- END showNextArrow:empty --\x3e><a href="#" data-action-click="gotoSlide({next})" role="button"><span class="smartphoto-sr-only">\\{message.gotoNextImage\\}</span></a></li>\n\t\t\t\t</ul>\n\t\t\t\t\x3c!-- END arrows:exist --\x3e\n\t\t\t\t\x3c!-- BEGIN nav:exist --\x3e\n\t\t\t\t<nav class="\\{classNames.smartPhotoNav\\}"\x3c!-- BEGIN hideUi:exist --\x3e aria-hidden="true"\x3c!-- END hideUi:exist --\x3e\x3c!-- BEGIN hideUi:exist --\x3e aria-hidden="false"\x3c!-- END hideUi:exist --\x3e>\n\t\t\t\t\t<ul>\n\t\t\t\t\t\t\x3c!-- BEGIN groupItems:loop --\x3e\n\t\t\t\t\t\t<li><a href="#" data-action-click="gotoSlide({index})" class="\x3c!-- \\BEGIN currentIndex:touch#{index} --\x3ecurrent\x3c!-- \\END currentIndex:touch#{index} --\x3e" style="background-image:url({src});" role="button"><span class="smartphoto-sr-only">go to {caption}</span></a></li>\n\t\t\t\t\t\t\x3c!-- END groupItems:loop --\x3e\n\t\t\t\t\t</ul>\n\t\t\t\t</nav>\n\t\t\t\t\x3c!-- END nav:exist --\x3e\n\t\t</div>\n\t\t\x3c!-- BEGIN appearEffect:exist --\x3e\n\t\t<img src=\\{appearEffect.img\\}\n\t\tclass="\\{classNames.smartPhotoImgClone\\}"\n\t\tstyle="width:\\{appearEffect.width\\}px;height:\\{appearEffect.height\\}px;transform:translate(\\{appearEffect.left\\}px,\\{appearEffect.top\\}px) scale(1)" />\n\t\t\x3c!-- END appearEffect:exist --\x3e\n\t</div>\n</div>\n',c=t("../lib/util"),l={classNames:{smartPhoto:"smartphoto",smartPhotoClose:"smartphoto-close",smartPhotoBody:"smartphoto-body",smartPhotoInner:"smartphoto-inner",smartPhotoContent:"smartphoto-content",smartPhotoImg:"smartphoto-img",smartPhotoImgOnMove:"smartphoto-img-onmove",smartPhotoImgElasticMove:"smartphoto-img-elasticmove",smartPhotoImgWrap:"smartphoto-img-wrap",smartPhotoArrows:"smartphoto-arrows",smartPhotoNav:"smartphoto-nav",smartPhotoArrowRight:"smartphoto-arrow-right",smartPhotoArrowLeft:"smartphoto-arrow-left",smartPhotoImgLeft:"smartphoto-img-left",smartPhotoImgRight:"smartphoto-img-right",smartPhotoList:"smartphoto-list",smartPhotoListOnMove:"smartphoto-list-onmove",smartPhotoHeader:"smartphoto-header",smartPhotoCount:"smartphoto-count",smartPhotoCaption:"smartphoto-caption",smartPhotoDismiss:"smartphoto-dismiss",smartPhotoLoader:"smartphoto-loader",smartPhotoLoaderWrap:"smartphoto-loader-wrap",smartPhotoImgClone:"smartphoto-img-clone"},message:{gotoNextImage:"go to the next image",gotoPrevImage:"go to the previous image",closeDialog:"close the image dialog"},arrows:!0,nav:!0,animationSpeed:300,swipeOffset:100,headerHeight:60,footerHeight:60,forceInterval:10,registance:.5,resizeStyle:"fill",verticalGravity:!1,useOrientationApi:!0},u=function(t){function e(t,a){o(this,e);var r=i(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));r.data=c.extend({},l,a),r.data.currentIndex=0,r.data.oldIndex=0,r.data.hide=!0,r.data.group={},r.data.scaleSize=1,r.data.scale=!1,r.pos={x:0,y:0},r.data.photoPosX=0,r.data.photoPosY=0,r.convert={increment:r.increment,virtualPos:r.virtualPos},r.data.groupItems=r.groupItems,r.elements=document.querySelectorAll(t);var s=new Date;r.tapSecond=s.getTime(),r.onListMove=!1,r.clicked=!1,r.id=r._getUniqId(),r.vx=0,r.vy=0,r.data.appearEffect=null,r.addTemplate(r.id,d),r.data.isSmartPhone=r._isSmartPhone();var n=document.querySelector("body");c.append(n,"<div data-id='"+r.id+"'></div>"),[].forEach.call(r.elements,function(t){r.addNewItem(t)});var h=r._getCurrentItemByHash();return h&&c.triggerEvent(h.element,"click"),r.update(),r._getEachImageSize().then(function(){r._fireEvent("loadall")}),setInterval(function(){r._doAnim()},r.data.forceInterval),r.data.isSmartPhone?(window.addEventListener("orientationchange",function(){r._resetTranslate(),r._setPosByCurrentIndex(),r._setHashByCurrentIndex(),r._setSizeByScreen(),r.update()}),r.data.useOrientationApi?(window.addEventListener("deviceorientation",function(t){var e=window.orientation;t&&t.gamma&&!r.data.appearEffect&&(r.isBeingZoomed||r.photoSwipable||r.data.elastic||!r.data.scale||(0===e?r._calcGravity(t.gamma,t.beta):90===e?r._calcGravity(t.beta,t.gamma):-90===e?r._calcGravity(-t.beta,-t.gamma):180===e&&r._calcGravity(-t.gamma,-t.beta)))}),r):i(r)):(window.addEventListener("resize",function(){r._resetTranslate(),r._setPosByCurrentIndex(),r._setSizeByScreen(),r.update()}),window.addEventListener("keydown",function(t){var e=t.keyCode||t.which;!0!==r.data.hide&&(37===e?r.gotoSlide(r.data.prev):39===e?r.gotoSlide(r.data.next):27===e&&r.hidePhoto())}),i(r))}return r(e,t),s(e,[{key:"on",value:function(t,e){var a=this;this._getElementByClass(this.data.classNames.smartPhoto).addEventListener(t,function(t){e.call(a,t)})}},{key:"increment",value:function(t){return t+1}},{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:"_getEachImageSize",value:function(){var t=[],e=this.data.group,a=function(e){var a=new Promise(function(t,a){var o=new Image;o.onload=function(){e.width=o.width,e.height=o.height,e.loaded=!0,t()},o.onerror=function(){a()},o.src=e.src});t.push(a)};return Object.keys(e).forEach(function(t){e[t].forEach(a)}),Promise.all(t)}},{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 i=o[a].length,r={src:t.getAttribute("href"),caption:t.getAttribute("data-caption"),groupId:a,translateX:this._getWindowWidth()*i,index:i,translateY:0,width:50,height:50,id:t.getAttribute("data-id")||i,loaded:!1,processed:!1,element:t};o[a].push(r),this.data.currentGroup=a,t.getAttribute("data-id")||t.setAttribute("data-id",i),t.setAttribute("data-index",i),t.addEventListener("click",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),e.clicked=!0,e.update(),e._fireEvent("open")):e._loadItem(o).then(function(){e._initPhoto(),e.addAppearEffect(t),e.clicked=!0,e.update(),e._fireEvent("open")})})}},{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())}},{key:"onUpdated",value:function(){var t=this;if(this.data.appearEffect&&this.data.appearEffect.once&&(this.data.appearEffect.once=!1,this.execEffect().then(function(){t.data.appearEffect=null,t.data.appear=!0,t.update()})),this.clicked){this.clicked=!1;var e=this.data.classNames;this._getElementByClass(e.smartPhotoCaption).focus()}}},{key:"execEffect",value:function(){var t=this;return new Promise(function(e){var a=t.data.appearEffect,o=t.data.classNames,i=t._getElementByClass(o.smartPhotoImgClone),r=function t(){i.removeEventListener("transitionend",t,!0),e()};i.addEventListener("transitionend",r,!0),setTimeout(function(){i.style.transform="translate("+a.afterX+"px, "+a.afterY+"px) scale("+a.scale+")"},10)})}},{key:"addAppearEffect",value:function(t){var e=t.querySelector("img"),a=c.getViewPos(e),o={},i=1;o.width=e.offsetWidth,o.height=e.offsetHeight,o.top=a.top,o.left=a.left,o.once=!0,o.img=e.getAttribute("src");var r=this._getWindowWidth(),s=this._getWindowHeight(),n=s-this.data.headerHeight-this.data.footerHeight;"fill"===this.data.resizeStyle&&this.data.isSmartPhone?i=e.offsetWidth>e.offsetHeight?s/e.offsetHeight:r/e.offsetWidth:(i=n/e.offsetHeight)*e.offsetWidth>r&&(i=r/e.offsetWidth);var h=(i-1)/2*e.offsetWidth+(r-e.offsetWidth*i)/2,d=(i-1)/2*e.offsetHeight+(s-e.offsetHeight*i)/2;o.afterX=h,o.afterY=d,o.scale=i,this.data.appearEffect=o}},{key:"hidePhoto",value:function(){var t=this;this.data.hide=!0,this.data.appear=!1,this.data.appearEffect=null,this.data.hideUi=!1,this.data.scale=!1,this.data.scaleSize=1;var e=window.scrollX,a=window.scrollY;location.hash&&this._setHash(""),window.scroll(e,a),this._doHideEffect().then(function(){t.update(),t._fireEvent("close")})}},{key:"_doHideEffect",value:function(){var t=this;return new Promise(function(e){var a=t.data.classNames,o=t._getElementByClass(a.smartPhoto),i=t._getElementByQuery(".current ."+a.smartPhotoImg),r=t._getWindowHeight(),s=function t(){o.removeEventListener("transitionend",t,!0),e()};o.style.opacity=0,i.style.transform="translateY("+r+"px)",o.addEventListener("transitionend",s,!0)})}},{key:"_getElementByClass",value:function(t){return document.querySelector('[data-id="'+this.id+'"] .'+t)}},{key:"_getElementByQuery",value:function(t){return document.querySelector('[data-id="'+this.id+'"] '+t)}},{key:"_getTouchPos",value:function(){var t=0,e=0,a="undefined"==typeof event?this.e:event;return this._isTouched(a)?(t=a.touches[0].pageX,e=a.touches[0].pageY):a.pageX&&(t=a.pageX,e=a.pageY),{x:t,y:e}}},{key:"_getGesturePos",value:function(t){var e=t.touches;return[{x:e[0].pageX,y:e[0].pageY},{x:e[1].pageX,y:e[1].pageY}]}},{key:"_setPosByCurrentIndex",value:function(){var t=this,e=this.groupItems(),a=-1*e[this.data.currentIndex].translateX;this.pos.x=a,setTimeout(function(){t.data.translateX=a,t.data.translateY=0,t._listUpdate()},1)}},{key:"_setHashByCurrentIndex",value:function(){var t=window.scrollX,e=window.scrollY,a=this.groupItems(),o=a[this.data.currentIndex].id,i=this.data.currentGroup,r="group="+i+"&photo="+o;this._setHash(r),window.scroll(t,e)}},{key:"_setHash",value:function(t){window.history&&window.history.pushState&&(t?window.history.replaceState(null,null,location.pathname+"#"+t):window.history.replaceState(null,null,""+location.pathname))}},{key:"_getCurrentItemByHash",value:function(){var t=this.data.group,e=location.hash.substr(1),a=c.parseQuery(e),o=null,i=function(t){a.group===t.groupId&&a.photo===t.id&&(o=t)};return Object.keys(t).forEach(function(e){t[e].forEach(i)}),o}},{key:"_loadItem",value:function(t){return new Promise(function(e){var a=new Image;a.onload=function(){t.width=a.width,t.height=a.height,t.loaded=!0,e()},a.onerror=function(){e()},a.src=t.src})}},{key:"_setSizeByScreen",value:function(){var t=this._getWindowWidth(),e=this._getWindowHeight(),a=this.data.headerHeight,o=this.data.footerHeight,i=e-(a+o);this.groupItems().forEach(function(a){a.loaded&&(a.processed=!0,a.scale=i/a.height,a.x=(a.scale-1)/2*a.width+(t-a.width*a.scale)/2,a.y=(a.scale-1)/2*a.height+(e-a.height*a.scale)/2,a.width*a.scale>t&&(a.scale=t/a.width,a.x=(a.scale-1)/2*a.width))})}},{key:"_slideList",value:function(){var t=this;this.data.scaleSize=1,this.isBeingZoomed=!1,this.data.hideUi=!1,this.data.scale=!1,this.data.photoPosX=0,this.data.photoPosY=0,this.data.onMoveClass=!0,this._setPosByCurrentIndex(),this._setHashByCurrentIndex(),this._setSizeByScreen(),setTimeout(function(){t.data.onMoveClass=!1,t.setArrow(),t.update(),t.data.oldIndex!==t.data.currentIndex&&t._fireEvent("change"),t.data.oldIndex=t.data.currentIndex},200)}},{key:"gotoSlide",value:function(t){this.e&&this.e.preventDefault&&this.e.preventDefault(),this.data.currentIndex=parseInt(t,10),this.data.currentIndex||(this.data.currentIndex=0),this._slideList()}},{key:"setArrow",value:function(){var t=this.groupItems(),e=t.length,a=this.data.currentIndex+1,o=this.data.currentIndex-1;this.data.showNextArrow=!1,this.data.showPrevArrow=!1,a!==e&&(this.data.next=a,this.data.showNextArrow=!0),-1!==o&&(this.data.prev=o,this.data.showPrevArrow=!0)}},{key:"beforeDrag",value:function(){if(this._isGestured(this.e))return void this.beforeGesture();if(this.isBeingZoomed=!1,this.data.scale)return void this.beforePhotoDrag();var t=this._getTouchPos();this.isSwipable=!0,this.dragStart=!0,this.firstPos=t,this.oldPos=t}},{key:"afterDrag",value:function(){var t=this.groupItems(),e=new Date,a=e.getTime(),o=this.tapSecond-a,i=0,r=0;return this.isSwipable=!1,this.onListMove=!1, | ||
this.oldPos&&(i=this.oldPos.x-this.firstPos.x,r=this.oldPos.y-this.firstPos.y),this.isBeingZoomed?void this.afterGesture():this.data.scale?void this.afterPhotoDrag():c.isSmartPhone()||0!==i||0!==r?Math.abs(o)<=500&&0===i&&0===r?(this.e.preventDefault(),void this.zoomPhoto()):(this.tapSecond=a,this._fireEvent("swipeend"),"horizontal"===this.moveDir&&(i>=this.data.swipeOffset&&0!==this.data.currentIndex?this.data.currentIndex-=1:i<=-this.data.swipeOffset&&this.data.currentIndex!==t.length-1&&(this.data.currentIndex+=1),this._slideList()),void("vertical"===this.moveDir&&(r>=this.data.swipeOffset?this.hidePhoto():(this.data.translateY=0,this._slideList())))):void this.zoomPhoto()}},{key:"onDrag",value:function(){if(this.e.preventDefault(),this._isGestured(this.e)&&!1===this.onListMove)return void this.onGesture();if(!this.isBeingZoomed){if(this.data.scale)return void this.onPhotoDrag();if(this.isSwipable){var t=this._getTouchPos(),e=t.x-this.oldPos.x,a=t.y-this.firstPos.y;this.dragStart&&(this._fireEvent("swipestart"),this.dragStart=!1,Math.abs(e)>Math.abs(a)?this.moveDir="horizontal":this.moveDir="vertical"),"horizontal"===this.moveDir?(this.pos.x+=e,this.data.translateX=this.pos.x):this.data.translateY=a,this.onListMove=!0,this.oldPos=t,this._listUpdate()}}}},{key:"zoomPhoto",value:function(){var t=this;this.data.hideUi=!0,this.data.scaleSize=this._getScaleBoarder(),this.data.photoPosX=0,this.data.photoPosY=0,this._photoUpdate(),setTimeout(function(){t.data.scale=!0,t._photoUpdate(),t._fireEvent("zoomin")},300)}},{key:"zoomOutPhoto",value:function(){this.data.scaleSize=1,this.isBeingZoomed=!1,this.data.hideUi=!1,this.data.scale=!1,this.data.photoPosX=0,this.data.photoPosY=0,this._photoUpdate(),this._fireEvent("zoomout")}},{key:"beforePhotoDrag",value:function(){var t=this._getTouchPos();this.photoSwipable=!0,this.data.photoPosX||(this.data.photoPosX=0),this.data.photoPosY||(this.data.photoPosY=0),this.oldPhotoPos=t,this.firstPhotoPos=t}},{key:"onPhotoDrag",value:function(){if(this.photoSwipable){this.e.preventDefault();var t=this._getTouchPos(),e=t.x-this.oldPhotoPos.x,a=t.y-this.oldPhotoPos.y,o=this._round(this.data.scaleSize*e,6),i=this._round(this.data.scaleSize*a,6);"number"==typeof o&&(this.data.photoPosX+=o,this.photoVX=o),"number"==typeof i&&(this.data.photoPosY+=i,this.photoVY=i),this.oldPhotoPos=t,this._photoUpdate()}}},{key:"afterPhotoDrag",value:function(){if(this.oldPhotoPos.x===this.firstPhotoPos.x&&this.photoSwipable)this.photoSwipable=!1,this.zoomOutPhoto();else{this.photoSwipable=!1;var t=this._getSelectedItem(),e=this._makeBound(t),a=this.data.swipeOffset*this.data.scaleSize,o=0,i=0;if(this.data.photoPosX>e.maxX?o=-1:this.data.photoPosX<e.minX&&(o=1),this.data.photoPosY>e.maxY?i=-1:this.data.photoPosY<e.minY&&(i=1),this.data.photoPosX-e.maxX>a&&0!==this.data.currentIndex)return void this.gotoSlide(this.data.prev);if(e.minX-this.data.photoPosX>a&&this.data.currentIndex+1!==this.data.total)return void this.gotoSlide(this.data.next);0===o&&0===i?(this.vx=this.photoVX/5,this.vy=this.photoVY/5):this._registerElasticForce(o,i)}}},{key:"beforeGesture",value:function(){this._fireEvent("gesturestart");var t=this._getGesturePos(this.e),e=this._getDistance(t[0],t[1]);this.isBeingZoomed=!0,this.oldDistance=e,this.data.scale=!0,this.e.preventDefault()}},{key:"onGesture",value:function(){var t=this._getGesturePos(this.e),e=this._getDistance(t[0],t[1]),a=(e-this.oldDistance)/100,o=this.data.scaleSize,i=this.data.photoPosX,r=this.data.photoPosY;this.isBeingZoomed=!0,this.data.scaleSize+=this._round(a,6),this.data.scaleSize<.2&&(this.data.scaleSize=.2),this.data.scaleSize<o&&(this.data.photoPosX=(1+this.data.scaleSize-o)*i,this.data.photoPosY=(1+this.data.scaleSize-o)*r),this.data.scaleSize<1||this.data.scaleSize>this._getScaleBoarder()?this.data.hideUi=!0:this.data.hideUi=!1,this.oldDistance=e,this.e.preventDefault(),this._photoUpdate()}},{key:"afterGesture",value:function(){this.data.scaleSize>this._getScaleBoarder()||(this.data.photoPosX=0,this.data.photoPosY=0,this.data.scale=!1,this.data.scaleSize=1,this.data.hideUi=!1,this._fireEvent("gestureend"),this._photoUpdate())}},{key:"_getForceAndTheta",value:function(t,e){return{force:Math.sqrt(t*t+e*e),theta:Math.atan2(e,t)}}},{key:"_getScaleBoarder",value:function(){var t=this._getSelectedItem(),e=this._getWindowWidth(),a=this._getWindowHeight();return c.isSmartPhone()?t.width>t.height?a/(t.height*t.scale):e/(t.width*t.scale):1/t.scale}},{key:"_makeBound",value:function(t){var e=t.width*t.scale*this.data.scaleSize,a=t.height*t.scale*this.data.scaleSize,o=void 0,i=void 0,r=void 0,s=void 0,n=this._getWindowWidth(),h=this._getWindowHeight();return n>e?(r=(n-e)/2,o=-1*r):(r=(e-n)/2,o=-1*r),h>a?(s=(h-a)/2,i=-1*s):(s=(a-h)/2,i=-1*s),{minX:this._round(o,6)*this.data.scaleSize,minY:this._round(i,6)*this.data.scaleSize,maxX:this._round(r,6)*this.data.scaleSize,maxY:this._round(s,6)*this.data.scaleSize}}},{key:"_registerElasticForce",value:function(t,e){var a=this,o=this._getSelectedItem(),i=this._makeBound(o);this.data.elastic=!0,1===t?this.data.photoPosX=i.minX:-1===t&&(this.data.photoPosX=i.maxX),1===e?this.data.photoPosY=i.minY:-1===e&&(this.data.photoPosY=i.maxY),this._photoUpdate(),setTimeout(function(){a.data.elastic=!1,a._photoUpdate()},300)}},{key:"_getSelectedItem",value:function(){var t=this.data,e=t.currentIndex;return t.group[t.currentGroup][e]}},{key:"_getUniqId",value:function(){return(Date.now().toString(36)+Math.random().toString(36).substr(2,5)).toUpperCase()}},{key:"_getDistance",value:function(t,e){var a=t.x-e.x,o=t.y-e.y;return Math.sqrt(a*a+o*o)}},{key:"_round",value:function(t,e){var a=Math.pow(10,e);return t*=a,t=Math.round(t),t/=a}},{key:"_isTouched",value:function(t){return!(!t||!t.touches)}},{key:"_isGestured",value:function(t){return!!(t&&t.touches&&t.touches.length>1)}},{key:"_isSmartPhone",value:function(){var t=navigator.userAgent;return t.indexOf("iPhone")>0||t.indexOf("iPad")>0||t.indexOf("ipod")>0||t.indexOf("Android")>0}},{key:"_calcGravity",value:function(t,e){(t>5||t<-5)&&(this.vx+=.05*t),!1!==this.data.verticalGravity&&(e>5||e<-5)&&(this.vy+=.05*e)}},{key:"_photoUpdate",value:function(){var t=this.data.classNames,e=this._getElementByQuery(".current"),a=e.querySelector("."+t.smartPhotoImg),o=this._getElementByQuery("."+t.smartPhotoNav),i=this._getElementByQuery("."+t.smartPhotoArrows),r=this.virtualPos(this.data.photoPosX),s=this.virtualPos(this.data.photoPosY),n=this.data.scaleSize,h="translate("+r+"px,"+s+"px) scale("+n+")";a.style.transform=h,this.data.scale?c.addClass(a,t.smartPhotoImgOnMove):c.removeClass(a,t.smartPhotoImgOnMove),this.data.elastic?c.addClass(a,t.smartPhotoImgElasticMove):c.removeClass(a,t.smartPhotoImgElasticMove),this.data.hideUi?(o&&o.setAttribute("aria-hidden","true"),i&&i.setAttribute("aria-hidden","true")):(o&&o.setAttribute("aria-hidden","false"),i&&i.setAttribute("aria-hidden","false"))}},{key:"_getWindowWidth",value:function(){return document.documentElement.clientWidth}},{key:"_getWindowHeight",value:function(){return window.innerHeight}},{key:"_listUpdate",value:function(){var t=this.data.classNames,e=this._getElementByQuery("."+t.smartPhotoList),a="translate("+this.data.translateX+"px,"+this.data.translateY+"px)";e.style.transform=a,this.data.onMoveClass?c.addClass(e,t.smartPhotoListOnMove):c.removeClass(e,t.smartPhotoListOnMove)}},{key:"_fireEvent",value:function(t){var e=this._getElementByClass(this.data.classNames.smartPhoto);c.triggerEvent(e,t)}},{key:"_doAnim",value:function(){if(!(this.isBeingZoomed||this.isSwipable||this.photoSwipable||this.data.elastic)&&this.data.scale){this.data.photoPosX+=this.vx,this.data.photoPosY+=this.vy;var t=this._getSelectedItem(),e=this._makeBound(t);this.data.photoPosX<e.minX?(this.data.photoPosX=e.minX,this.vx*=-.2):this.data.photoPosX>e.maxX&&(this.data.photoPosX=e.maxX,this.vx*=-.2),this.data.photoPosY<e.minY?(this.data.photoPosY=e.minY,this.vy*=-.2):this.data.photoPosY>e.maxY&&(this.data.photoPosY=e.maxY,this.vy*=-.2);var a=this._getForceAndTheta(this.vx,this.vy),o=a.force,i=a.theta;o-=this.data.registance,Math.abs(o)<.5||(this.vx=Math.cos(i)*o,this.vy=Math.sin(i)*o,this._photoUpdate())}}}]),e}(h.default);e.exports=u},{"../lib/util":8,"a-template":1}],7:[function(t,e,a){"use strict";e.exports=t("./core/")},{"./core/":6}],8:[function(t,e,a){"use strict";function o(t){t=t||{};for(var e=1;e<arguments.length;e++){var a=arguments[e];if(a)for(var r in a)a.hasOwnProperty(r)&&("object"===i(a[r])?t[r]=o(t[r],a[r]):t[r]=a[r])}return t}var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};e.exports.isSmartPhone=function(){var t=navigator.userAgent;return t.indexOf("iPhone")>0||t.indexOf("iPad")>0||t.indexOf("ipod")>0||t.indexOf("Android")>0},e.exports.extend=o,e.exports.triggerEvent=function(t,e,a){var o=void 0;window.CustomEvent?o=new CustomEvent(e,{cancelable:!0}):(o=document.createEvent("CustomEvent"),o.initCustomEvent(e,!1,!1,a)),t.dispatchEvent(o)},e.exports.parseQuery=function(t){for(var e,a,o,i=t.split("&"),r={},s=0,n=i.length;s<n;s++)e=i[s].split("="),void 0!==e[0]&&(a=e[0],o=void 0!==e[1]?e.slice(1).join("="):a,r[a]=decodeURIComponent(o));return r},e.exports.getViewPos=function(t){return{left:t.getBoundingClientRect().left,top:t.getBoundingClientRect().top}},e.exports.removeElement=function(t){t&&t.parentNode&&t.parentNode.removeChild(t)},e.exports.append=function(t,e){var a=new DOMParser,o=a.parseFromString(e,"text/html");t.appendChild(o.querySelector("body").childNodes[0])},e.exports.addClass=function(t,e){t.classList?t.classList.add(e):t.className+=" "+e},e.exports.removeClass=function(t,e){t.classList?t.classList.remove(e):t.className=t.className.replace(new RegExp("(^|\\b)"+e.split(" ").join("|")+"(\\b|$)","gi")," ")}},{}]},{},[5]); |
@@ -9,3 +9,3 @@ /** | ||
* homepage: http://developer.a-blogcms.jp | ||
* version: 0.5.7 | ||
* version: 0.5.8 | ||
* | ||
@@ -33,3 +33,3 @@ * a-template: | ||
*/ | ||
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.smartPhoto=t()}}(function(){return function t(e,a,o){function i(n,s){if(!a[n]){if(!e[n]){var h="function"==typeof require&&require;if(!s&&h)return h(n,!0);if(r)return r(n,!0);var d=new Error("Cannot find module '"+n+"'");throw d.code="MODULE_NOT_FOUND",d}var l=a[n]={exports:{}};e[n][0].call(l.exports,function(t){var a=e[n][1][t];return i(a||t)},l,l.exports,t,e,a,o)}return a[n].exports}for(var r="function"==typeof require&&require,n=0;n<o.length;n++)i(o[n]);return i}({1:[function(t,e,a){"use strict";function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}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}}(),r=t("morphdom"),n=t("delegate"),s=[],h="input paste copy click change keydown keyup contextmenu mouseup mousedown mousemove touchstart touchend touchmove compositionstart compositionend",d=h.replace(/([a-z]+)/g,"[data-action-$1],")+"[data-action]";Array.prototype.find||(Array.prototype.find=function(t){if(null===this)throw new TypeError("Array.prototype.find called on null or undefined");if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var e=Object(this),a=e.length>>>0,o=arguments[1],i=void 0,r=0;r<a;r++)if(i=e[r],t.call(o,i,r,e))return i}),Element.prototype.matches||(Element.prototype.matches=Element.prototype.matchesSelector||Element.prototype.mozMatchesSelector||Element.prototype.msMatchesSelector||Element.prototype.oMatchesSelector||Element.prototype.webkitMatchesSelector||function(t){for(var e=(this.document||this.ownerDocument).querySelectorAll(t),a=e.length;--a>=0&&e.item(a)!==this;);return a>-1});var l=function(t){return document.querySelector(t)},c=function(t){for(var e=0,a=s.length;e<a;e++)for(var o=s[e],i=o.templates,r=0,n=i.length;r<n;r++)if(i[r]==t)return o;return null},u=function(t,e){if("function"==typeof t.closest)return t.closest(e)||null;for(;t;){if(t.matches(e))return t;t=t.parentElement}return null},p=function(t,e,a,o){a.split(" ").forEach(function(a){n(t,e,a,o)})};"undefined"!=typeof document&&(p(document,"[data-bind]","input change click",function(t){var e=t.delegateTarget,a=e.getAttribute("data-bind"),o=e.getAttribute("href"),i=u(e,"[data-id]").getAttribute("data-id"),r=e.value;if(o&&(r=r.replace("#","")),i){var n=c(i);"radio"===e.getAttribute("type")||("checkbox"===e.getAttribute("type")?function(){var t=[],e=document.querySelectorAll('[data-bind="'+a+'"]');[].forEach.call(e,function(e){e.checked&&t.push(e.value)})}():n.updateDataByString(a,r))}}),p(document,d,h,function(t){var e=t.delegateTarget;if(!("click"===t.type&&"select"===e.tagName||"input"===t.type&&"button"===e.getAttribute("type"))){var a=h.split(" "),o="action";a.forEach(function(a){e.getAttribute("data-action-"+a)&&t.type===a&&(o+="-"+a)});var i=e.getAttribute("data-"+o);if(i){var r=i.replace(/\(.*?\);?/,""),n=i.replace(/(.*?)\((.*?)\);?/,"$2"),s=n.split(","),d=u(e,"[data-id]").getAttribute("data-id");if(d){var l=c(d);l.e=t,l.method&&l.method[r]?l.method[r].apply(l,s):l[r]&&l[r].apply(l,s)}}}}));var f=function(){function t(e){o(this,t),this.atemplate=[],s.push(this);for(var a in e)this[a]=e[a];this.data||(this.data={}),this.templates||(this.templates=[]);for(var i=this.templates,r=i.length,n=0,h=r;n<h;n++){var d=this.templates[n],c=l("#"+d).innerHTML;this.atemplate.push({id:d,html:c})}this.setId()}return i(t,[{key:"addTemplate",value:function(t,e){this.atemplate.push({id:t,html:e}),this.templates.push(t)}},{key:"loadHtml",value:function(){var t=this.templates,e=[];return t.forEach(function(t){var a=new $.Deferred;e.push(a);var o=l("#"+t).getAttribute("src");$.ajax({url:o,type:"GET",dataType:"text"}).success(function(e){l("#"+t).innerHTML=e,a.resolve()})}),$.when.apply($,e)}},{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){for(var e in t)"function"!=typeof t[e]&&(this.data[e]=t[e])}},{key:"loadData",value:function(t){var e=JSON.parse(localStorage.getItem(t));if(e)for(var a in e)"function"!=typeof e[a]&&(this.data[a]=e[a])}},{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,i=0;i<t;i++)e+=a.charAt(Math.floor(this.getRand(0,o)));return e}},{key:"setId",value:function(){for(var e=void 0,a=(t.ids,!1);;){e=this.getRandText(10);for(var o=0,i=t.ids;o<i;o++)t.ids[o]===e&&(a=!0);if(!1===a)break}this.data.aTemplate_id=e}},{key:"getDataFromObj",value:function(t,e){t=t.replace(/\[([a-zA-Z0-9._-]+)\]/g,".$1"),t=t.replace(/^\./,"");for(var a=t.split(".");a.length;){var o=a.shift();if(!(o in e))return;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.split(".");a.length>1;)e=e[a.shift()];var o=a.shift();o.match(/^\d+$/)?e.splice(Number(o),1):delete e[o]}},{key:"resolveBlock",value:function(t,e,a){var o=this,i=t.match(/<!-- BEGIN ([a-zA-Z0-9._-]+):touch#([a-zA-Z0-9._-]+) -->/g),r=t.match(/<!-- BEGIN ([a-zA-Z0-9._-]+):touchnot#([a-zA-Z0-9._-]+) -->/g),n=t.match(/<!-- BEGIN ([a-zA-Z0-9._-]+):exist -->/g),s=t.match(/<!-- BEGIN ([a-zA-Z0-9._-]+):empty -->/g);if(i)for(var h=0,d=i.length;h<d;h++){var l=i[h];l=l.replace(/([a-zA-Z0-9._-]+):touch#([a-zA-Z0-9._-]+)/,"($1):touch#($2)");var c=l.replace(/BEGIN/,"END"),u=new RegExp(l+"(([\\n\\r\\t]|.)*?)"+c,"g");t=t.replace(u,function(t,a,i,r){return("function"==typeof e[a]?e[a].apply(o):o.getDataFromObj(a,e))==i?r:""})}if(r)for(var p=0,f=r.length;p<f;p++){var m=r[p];m=m.replace(/([a-zA-Z0-9._-]+):touchnot#([a-zA-Z0-9._-]+)/,"($1):touchnot#($2)");var v=m.replace(/BEGIN/,"END"),g=new RegExp(m+"(([\\n\\r\\t]|.)*?)"+v,"g");t=t.replace(g,function(t,a,i,r){return("function"==typeof e[a]?e[a].apply(o):o.getDataFromObj(a,e))!=i?r:""})}if(n)for(var y=0,x=n.length;y<x;y++){var P=n[y];P=P.replace(/([a-zA-Z0-9._-]+):exist/,"($1):exist");var E=P.replace(/BEGIN/,"END"),w=new RegExp(P+"(([\\n\\r\\t]|.)*?)"+E,"g");t=t.replace(w,function(t,a,i){var r="function"==typeof e[a]?e[a].apply(o):o.getDataFromObj(a,e);return r||0===r?i:""})}if(s)for(var b=0,_=s.length;b<_;b++){var S=s[b];S=S.replace(/([a-zA-Z0-9._-]+):empty/,"($1):empty");var N=S.replace(/BEGIN/,"END"),I=new RegExp(S+"(([\\n\\r\\t]|.)*?)"+N,"g");t=t.replace(I,function(t,a,i){var r="function"==typeof e[a]?e[a].apply(o):o.getDataFromObj(a,e);return r||0===r?"":i})}return t=t.replace(/{([a-zA-Z0-9._-]+)}(\[([a-zA-Z0-9._-]+)\])*/g,function(t,i,r,n){var s=void 0;if("i"==i)s=a;else{if(!e[i]&&0!==e[i])return n&&o.convert&&o.convert[n]?o.convert[n].call(o,""):"";s="function"==typeof e[i]?e[i].apply(o):e[i]}return n&&o.convert&&o.convert[n]?o.convert[n].call(o,s):s})}},{key:"resolveAbsBlock",value:function(t){var e=this;return t=t.replace(/{(.*?)}/g,function(t,a){var o=e.getDataByString(a);return void 0!==o?"function"==typeof o?o.apply(e):o:t})}},{key:"resolveInclude",value:function(t){return t=t.replace(/<!-- #include id="(.*?)" -->/g,function(t,e){return l("#"+e).innerHTML})}},{key:"resolveWith",value:function(t){return t=t.replace(/<!-- BEGIN ([a-zA-Z0-9._-]+):with -->(([\n\r\t]|.)*?)<!-- END ([a-zA-Z0-9._-]+):with -->/g,function(t,e,a){return t=t.replace(/data\-bind=['"](.*?)['"]/g,"data-bind='"+e+".$1'")})}},{key:"resolveLoop",value:function(t){var e=this;return t=t.replace(/<!-- BEGIN (.+?):loop -->(([\n\r\t]|.)*?)<!-- END (.+?):loop -->/g,function(t,a,o){var i=e.getDataByString(a),r=[];r="function"==typeof i?i.apply(e):i;var n="";if(r instanceof Array)for(var s=0,h=r.length;s<h;s++)n+=e.resolveBlock(o,r[s],s);return n=n.replace(/\\([^\\])/g,"$1")})}},{key:"removeData",value:function(t){var e=this.data;for(var a in e)for(var o=0,i=t.length;o<i;o++)a===t[o]&&delete e[a];return this}},{key:"hasLoop",value:function(t){return!!t.match(/<!-- BEGIN (.+?):loop -->(([\n\r\t]|.)*?)<!-- END (.+?):loop -->/g)}},{key:"getHtml",value:function(t,e){var a=this.atemplate.find(function(e){return e.id===t}),o="";if(a&&a.html&&(o=a.html),e&&(o=t),!o)return"";var i=this.data;for(o=this.resolveInclude(o),o=this.resolveWith(o);this.hasLoop(o);)o=this.resolveLoop(o);return o=this.resolveBlock(o,i),o=o.replace(/\\([^\\])/g,"$1"),o=this.resolveAbsBlock(o),o.replace(/^([\t ])*\n/gm,"")}},{key:"update",value:function(t,e){var a=(this.getHtml(),this.templates),o=t||"html";this.beforeUpdated&&this.beforeUpdated();for(var i=0,n=a.length;i<n;i++){var s=a[i],h="#"+s,d=this.getHtml(s),c=l("[data-id='"+s+"']");if((!e||e==s)&&(c?"text"===o?c.innerText=d:r(c,"<div data-id='"+s+"'>"+d+"</div>"):(l(h).insertAdjacentHTML("afterend",'<div data-id="'+s+'"></div>'),"text"===o?l("[data-id='"+s+"']").innerText=d:l("[data-id='"+s+"']").innerHTML=d),e))break}return this.updateBindingData(e),this.onUpdated&&this.onUpdated(e),this}},{key:"updateBindingData",value:function(t){for(var e=this,a=this.templates,o=0,i=a.length;o<i;o++){var r=a[o];if(!t||t==r){var n=l("[data-id='"+r+"']"),s=n.querySelectorAll("[data-bind]");if([].forEach.call(s,function(t){var a=e.getDataByString(t.getAttribute("data-bind"));"checkbox"===t.getAttribute("type")||"radio"===t.getAttribute("type")?a==t.value&&(t.checked=!0):t.value=a}),t)break}}return this}},{key:"applyMethod",value:function(t){var e=[].splice.call(arguments,0);return e.shift(),this.method[t].apply(this,e)}},{key:"getComputedProp",value:function(t){return this.data[t].apply(this)}},{key:"remove",value:function(t){for(var e=this.data,a=t.split(".");a.length>1;)e=e[a.shift()];var o=a.shift();return o.match(/^\d+$/)?e.splice(Number(o),1):delete e[o],this}}]),t}();e.exports=f},{delegate:3,morphdom:4}],2:[function(t,e,a){function o(t,e){for(;t&&t.nodeType!==i;){if(t.matches(e))return t;t=t.parentNode}}var i=9;if("undefined"!=typeof Element&&!Element.prototype.matches){var r=Element.prototype;r.matches=r.matchesSelector||r.mozMatchesSelector||r.msMatchesSelector||r.oMatchesSelector||r.webkitMatchesSelector}e.exports=o},{}],3:[function(t,e,a){function o(t,e,a,o,r){var n=i.apply(this,arguments);return t.addEventListener(a,n,r),{destroy:function(){t.removeEventListener(a,n,r)}}}function i(t,e,a,o){return function(a){a.delegateTarget=r(a.target,e),a.delegateTarget&&o.call(t,a)}}var r=t("./closest");e.exports=o},{"./closest":2}],4:[function(t,e,a){"use strict";function o(t){!c&&f.createRange&&(c=f.createRange(),c.selectNode(f.body));var e;return c&&c.createContextualFragment?e=c.createContextualFragment(t):(e=f.createElement("body"),e.innerHTML=t),e.childNodes[0]}function i(t,e){var a=t.nodeName,o=e.nodeName;return a===o||!!(e.actualize&&a.charCodeAt(0)<91&&o.charCodeAt(0)>90)&&a===o.toUpperCase()}function r(t,e){return e&&e!==p?f.createElementNS(e,t):f.createElement(t)}function n(t,e){for(var a=t.firstChild;a;){var o=a.nextSibling;e.appendChild(a),a=o}return e}function s(t,e){var a,o,i,r,n,s=e.attributes;for(a=s.length-1;a>=0;--a)o=s[a],i=o.name,r=o.namespaceURI,n=o.value,r?(i=o.localName||i,t.getAttributeNS(r,i)!==n&&t.setAttributeNS(r,i,n)):t.getAttribute(i)!==n&&t.setAttribute(i,n);for(s=t.attributes,a=s.length-1;a>=0;--a)o=s[a],!1!==o.specified&&(i=o.name,r=o.namespaceURI,r?(i=o.localName||i,v(e,r,i)||t.removeAttributeNS(r,i)):v(e,null,i)||t.removeAttribute(i))}function h(t,e,a){t[a]!==e[a]&&(t[a]=e[a],t[a]?t.setAttribute(a,""):t.removeAttribute(a,""))}function d(){}function l(t){return t.id}var c,u,p="http://www.w3.org/1999/xhtml",f="undefined"==typeof document?void 0:document,m=f?f.body||f.createElement("div"):{};u=m.hasAttributeNS?function(t,e,a){return t.hasAttributeNS(e,a)}:m.hasAttribute?function(t,e,a){return t.hasAttribute(a)}:function(t,e,a){return null!=t.getAttributeNode(e,a)};var v=u,g={OPTION:function(t,e){h(t,e,"selected")},INPUT:function(t,e){h(t,e,"checked"),h(t,e,"disabled"),t.value!==e.value&&(t.value=e.value),v(e,null,"value")||t.removeAttribute("value")},TEXTAREA:function(t,e){var a=e.value;t.value!==a&&(t.value=a);var o=t.firstChild;if(o){var i=o.nodeValue;if(i==a||!a&&i==t.placeholder)return;o.nodeValue=a}},SELECT:function(t,e){if(!v(e,null,"multiple")){for(var a=0,o=e.firstChild;o;){var i=o.nodeName;if(i&&"OPTION"===i.toUpperCase()){if(v(o,null,"selected")){a;break}a++}o=o.nextSibling}t.selectedIndex=a}}},y=1,x=3,P=8,E=function(t){return function(e,a,s){function h(t){w?w.push(t):w=[t]}function c(t,e){if(t.nodeType===y)for(var a=t.firstChild;a;){var o=void 0;e&&(o=b(a))?h(o):(A(a),a.firstChild&&c(a,e)),a=a.nextSibling}}function u(t,e,a){!1!==k(t)&&(e&&e.removeChild(t),A(t),c(t,a))}function p(t){if(t.nodeType===y)for(var e=t.firstChild;e;){var a=b(e);a&&(C[a]=e),p(e),e=e.nextSibling}}function m(t){S(t);for(var e=t.firstChild;e;){var a=e.nextSibling,o=b(e);if(o){var r=C[o];r&&i(e,r)&&(e.parentNode.replaceChild(r,e),v(r,e))}m(e),e=a}}function v(o,r,n){var s,d=b(r);if(d&&delete C[d],!a.isSameNode||!a.isSameNode(e)){if(!n){if(!1===N(o,r))return;if(t(o,r),I(o),!1===D(o,r))return}if("TEXTAREA"!==o.nodeName){var l,c,p,E,w=r.firstChild,S=o.firstChild;t:for(;w;){for(p=w.nextSibling,l=b(w);S;){if(c=S.nextSibling,w.isSameNode&&w.isSameNode(S)){w=p,S=c;continue t}s=b(S);var k=S.nodeType,A=void 0;if(k===w.nodeType&&(k===y?(l?l!==s&&((E=C[l])?S.nextSibling===E?A=!1:(o.insertBefore(E,S),c=S.nextSibling,s?h(s):u(S,o,!0),S=E):A=!1):s&&(A=!1),(A=!1!==A&&i(S,w))&&v(S,w)):k!==x&&k!=P||(A=!0,S.nodeValue=w.nodeValue)),A){w=p,S=c;continue t}s?h(s):u(S,o,!0),S=c}if(l&&(E=C[l])&&i(E,w))o.appendChild(E),v(E,w);else{var B=_(w);!1!==B&&(B&&(w=B),w.actualize&&(w=w.actualize(o.ownerDocument||f)),o.appendChild(w),m(w))}w=p,S=c}for(;S;)c=S.nextSibling,(s=b(S))?h(s):u(S,o,!0),S=c}var z=g[o.nodeName];z&&z(o,r)}}if(s||(s={}),"string"==typeof a)if("#document"===e.nodeName||"HTML"===e.nodeName){var E=a;a=f.createElement("html"),a.innerHTML=E}else a=o(a);var w,b=s.getNodeKey||l,_=s.onBeforeNodeAdded||d,S=s.onNodeAdded||d,N=s.onBeforeElUpdated||d,I=s.onElUpdated||d,k=s.onBeforeNodeDiscarded||d,A=s.onNodeDiscarded||d,D=s.onBeforeElChildrenUpdated||d,B=!0===s.childrenOnly,C={};p(e);var z=e,G=z.nodeType,T=a.nodeType;if(!B)if(G===y)T===y?i(e,a)||(A(e),z=n(e,r(a.nodeName,a.namespaceURI))):z=a;else if(G===x||G===P){if(T===G)return z.nodeValue=a.nodeValue,z;z=a}if(z===a)A(e);else if(v(z,a,B),w)for(var O=0,X=w.length;O<X;O++){var M=C[w[O]];M&&u(M,M.parentNode,!1)}return!B&&z!==e&&e.parentNode&&(z.actualize&&(z=z.actualize(e.ownerDocument||f)),e.parentNode.replaceChild(z,e)),z}}(s);e.exports=E},{}],5:[function(t,e,a){"use strict";function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function r(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}var n=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}}(),s=t("a-template"),h=function(t){return t&&t.__esModule?t:{default:t}}(s),d='<div class="\\{classNames.smartPhoto\\}"\x3c!-- BEGIN hide:exist --\x3e aria-hidden="true"\x3c!-- END hide:exist --\x3e\x3c!-- BEGIN hide:empty --\x3e aria-hidden="false"\x3c!-- END hide:empty --\x3e role="dialog">\n\t<div class="\\{classNames.smartPhotoBody\\}">\n\t\t<div class="\\{classNames.smartPhotoInner\\}">\n\t\t\t <div class="\\{classNames.smartPhotoHeader\\}">\n\t\t\t\t\t<span class="\\{classNames.smartPhotoCount\\}">{currentIndex}[increment]/{total}</span>\n\t\t\t\t\t<span class="\\{classNames.smartPhotoCaption\\}" aria-live="polite" tabindex="-1">\x3c!-- BEGIN groupItems:loop --\x3e\x3c!-- \\BEGIN currentIndex:touch#{index} --\x3e{caption}\x3c!-- \\END currentIndex:touch#{index} --\x3e\x3c!-- END groupItems:loop --\x3e</span>\n\t\t\t\t\t<button class="\\{classNames.smartPhotoDismiss\\}" data-action-click="hidePhoto()"><span class="smartphoto-sr-only">\\{message.closeDialog\\}</span></button>\n\t\t\t\t</div>\n\t\t\t\t<div class="\\{classNames.smartPhotoContent\\}"\x3c!-- BEGIN isSmartPhone:exist --\x3e data-action-touchstart="beforeDrag" data-action-touchmove="onDrag" data-action-touchend="afterDrag(false)"\x3c!-- END isSmartPhone:exist --\x3e>\n\t\t\t\t</div>\n\t\t\t\t<ul style="transform:translate({translateX}px,{translateY}px);" class="\\{classNames.smartPhotoList\\}\x3c!-- BEGIN onMoveClass:exist --\x3e \\{classNames.smartPhotoListOnMove\\}\x3c!-- END onMoveClass:exist --\x3e">\n\t\t\t\t\t\x3c!-- BEGIN groupItems:loop --\x3e\n\t\t\t\t\t<li style="transform:translate({translateX}px,{translateY}px);" class="\x3c!-- \\BEGIN currentIndex:touch#{index} --\x3ecurrent\x3c!-- \\END currentIndex:touch#{index} --\x3e">\n\t\t\t\t\t\t\x3c!-- BEGIN loaded:exist --\x3e\n\t\t\t\t\t\t<div style="transform:translate({x}px,{y}px) scale({scale});" class="\\\\{classNames.smartPhotoImgWrap\\\\}"\x3c!-- \\BEGIN isSmartPhone:empty --\x3e data-action-mousemove="onDrag" data-action-mousedown="beforeDrag" data-action-mouseup="afterDrag"\x3c!-- \\END isSmartPhone:empty --\x3e\x3c!-- \\BEGIN isSmartPhone:exist --\x3e data-action-touchstart="beforeDrag" data-action-touchmove="onDrag" data-action-touchend="afterDrag"\x3c!-- \\END isSmartPhone:exist --\x3e>\n\t\t\t\t\t\t\t<img style="\x3c!-- \\BEGIN currentIndex:touch#{index} --\x3etransform:translate(\\{photoPosX\\}[virtualPos]px,\\{photoPosY\\}[virtualPos]px) scale(\\{scaleSize\\});\x3c!-- \\END currentIndex:touch#{index} --\x3e" src="{src}" class="\\\\{classNames.smartPhotoImg\\\\}\x3c!-- \\BEGIN scale:exist --\x3e \\\\{classNames.smartPhotoImgOnMove\\\\}\x3c!-- \\END scale:exist --\x3e\x3c!-- \\BEGIN elastic:exist --\x3e \\\\{classNames.smartPhotoImgElasticMove\\\\}\x3c!-- \\END elastic:exist --\x3e\x3c!-- \\BEGIN appear:exist --\x3e active\x3c!-- \\END appear:exist --\x3e" ondragstart="return false;">\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\x3c!-- END loaded:exist --\x3e\n\t\t\t\t\t\t\x3c!-- BEGIN loaded:empty --\x3e\n\t\t\t\t\t\t<div class="\\\\{classNames.smartPhotoLoaderWrap\\\\}">\n\t\t\t\t\t\t\t<span class="\\\\{classNames.smartPhotoLoader\\\\}"></span>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\x3c!-- END loaded:empty --\x3e\n\t\t\t\t\t</li>\n\t\t\t\t\t\x3c!-- END groupItems:loop --\x3e\n\t\t\t\t</ul>\n\t\t\t\t\x3c!-- BEGIN arrows:exist --\x3e\n\t\t\t\t<ul class="\\{classNames.smartPhotoArrows\\}"\x3c!-- BEGIN hideUi:exist --\x3e aria-hidden="true"\x3c!-- END hideUi:exist --\x3e\x3c!-- BEGIN hideUi:exist --\x3e aria-hidden="false"\x3c!-- END hideUi:exist --\x3e>\n\t\t\t\t\t<li class="\\{classNames.smartPhotoArrowLeft\\}"\x3c!-- BEGIN showPrevArrow:empty --\x3e aria-hidden="true"\x3c!-- END showPrevArrow:empty --\x3e><a href="#" data-action-click="gotoSlide({prev})" role="button"><span class="smartphoto-sr-only">\\{message.gotoPrevImage\\}</span></a></li>\n\t\t\t\t\t<li class="\\{classNames.smartPhotoArrowRight\\}"\x3c!-- BEGIN showNextArrow:empty --\x3e aria-hidden="true"\x3c!-- END showNextArrow:empty --\x3e><a href="#" data-action-click="gotoSlide({next})" role="button"><span class="smartphoto-sr-only">\\{message.gotoNextImage\\}</span></a></li>\n\t\t\t\t</ul>\n\t\t\t\t\x3c!-- END arrows:exist --\x3e\n\t\t\t\t\x3c!-- BEGIN nav:exist --\x3e\n\t\t\t\t<nav class="\\{classNames.smartPhotoNav\\}"\x3c!-- BEGIN hideUi:exist --\x3e aria-hidden="true"\x3c!-- END hideUi:exist --\x3e\x3c!-- BEGIN hideUi:exist --\x3e aria-hidden="false"\x3c!-- END hideUi:exist --\x3e>\n\t\t\t\t\t<ul>\n\t\t\t\t\t\t\x3c!-- BEGIN groupItems:loop --\x3e\n\t\t\t\t\t\t<li><a href="#" data-action-click="gotoSlide({index})" class="\x3c!-- \\BEGIN currentIndex:touch#{index} --\x3ecurrent\x3c!-- \\END currentIndex:touch#{index} --\x3e" style="background-image:url({src});" role="button"><span class="smartphoto-sr-only">go to {caption}</span></a></li>\n\t\t\t\t\t\t\x3c!-- END groupItems:loop --\x3e\n\t\t\t\t\t</ul>\n\t\t\t\t</nav>\n\t\t\t\t\x3c!-- END nav:exist --\x3e\n\t\t</div>\n\t\t\x3c!-- BEGIN appearEffect:exist --\x3e\n\t\t<img src=\\{appearEffect.img\\}\n\t\tclass="\\{classNames.smartPhotoImgClone\\}"\n\t\tstyle="width:\\{appearEffect.width\\}px;height:\\{appearEffect.height\\}px;transform:translate(\\{appearEffect.left\\}px,\\{appearEffect.top\\}px) scale(1)" />\n\t\t\x3c!-- END appearEffect:exist --\x3e\n\t</div>\n</div>\n',l=t("../lib/util"),c={classNames:{smartPhoto:"smartphoto",smartPhotoClose:"smartphoto-close",smartPhotoBody:"smartphoto-body",smartPhotoInner:"smartphoto-inner",smartPhotoContent:"smartphoto-content",smartPhotoImg:"smartphoto-img",smartPhotoImgOnMove:"smartphoto-img-onmove",smartPhotoImgElasticMove:"smartphoto-img-elasticmove",smartPhotoImgWrap:"smartphoto-img-wrap",smartPhotoArrows:"smartphoto-arrows",smartPhotoNav:"smartphoto-nav",smartPhotoArrowRight:"smartphoto-arrow-right",smartPhotoArrowLeft:"smartphoto-arrow-left",smartPhotoImgLeft:"smartphoto-img-left",smartPhotoImgRight:"smartphoto-img-right",smartPhotoList:"smartphoto-list",smartPhotoListOnMove:"smartphoto-list-onmove",smartPhotoHeader:"smartphoto-header",smartPhotoCount:"smartphoto-count",smartPhotoCaption:"smartphoto-caption",smartPhotoDismiss:"smartphoto-dismiss",smartPhotoLoader:"smartphoto-loader",smartPhotoLoaderWrap:"smartphoto-loader-wrap",smartPhotoImgClone:"smartphoto-img-clone"},message:{gotoNextImage:"go to the next image",gotoPrevImage:"go to the previous image",closeDialog:"close the image dialog"},arrows:!0,nav:!0,animationSpeed:300,swipeOffset:100,headerHeight:60,footerHeight:60,forceInterval:10,registance:.5,resizeStyle:"fill",verticalGravity:!1,useOrientationApi:!0},u=function(t){function e(t,a){o(this,e);var r=i(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));r.data=l.extend({},c,a),r.data.currentIndex=0,r.data.oldIndex=0,r.data.hide=!0,r.data.group={},r.data.scaleSize=1,r.data.scale=!1,r.pos={x:0,y:0},r.data.photoPosX=0,r.data.photoPosY=0,r.convert={increment:r.increment,virtualPos:r.virtualPos},r.data.groupItems=r.groupItems,r.elements=document.querySelectorAll(t);var n=new Date;r.tapSecond=n.getTime(),r.onListMove=!1,r.clicked=!1,r.id=r._getUniqId(),r.vx=0,r.vy=0,r.data.appearEffect=null,r.addTemplate(r.id,d),r.data.isSmartPhone=r._isSmartPhone();var s=document.querySelector("body");l.append(s,"<div data-id='"+r.id+"'></div>"),[].forEach.call(r.elements,function(t){r.addNewItem(t)});var h=r._getCurrentItemByHash();return h&&l.triggerEvent(h.element,"click"),r.update(),r._getEachImageSize().then(function(){r._fireEvent("loadall")}),setInterval(function(){r._doAnim()},r.data.forceInterval),r.data.isSmartPhone?(window.addEventListener("orientationchange",function(){r._resetTranslate(),r._setPosByCurrentIndex(),r._setHashByCurrentIndex(),r._setSizeByScreen(),r.update()}),r.data.useOrientationApi?(window.addEventListener("deviceorientation",function(t){var e=window.orientation;t&&t.gamma&&!r.data.appearEffect&&(r.isBeingZoomed||r.photoSwipable||r.data.elastic||!r.data.scale||(0===e?r._calcGravity(t.gamma,t.beta):90===e?r._calcGravity(t.beta,t.gamma):-90===e?r._calcGravity(-t.beta,-t.gamma):180===e&&r._calcGravity(-t.gamma,-t.beta)))}),r):i(r)):(window.addEventListener("resize",function(){r._resetTranslate(),r._setPosByCurrentIndex(),r._setSizeByScreen(),r.update()}),window.addEventListener("keydown",function(t){var e=t.keyCode||t.which;!0!==r.data.hide&&(37===e?r.gotoSlide(r.data.prev):39===e?r.gotoSlide(r.data.next):27===e&&r.hidePhoto())}),i(r))}return r(e,t),n(e,[{key:"on",value:function(t,e){var a=this;this._getElementByClass(this.data.classNames.smartPhoto).addEventListener(t,function(t){e.call(a,t)})}},{key:"increment",value:function(t){return t+1}},{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:"_getEachImageSize",value:function(){var t=[],e=this.data.group,a=function(e){var a=new Promise(function(t,a){var o=new Image;o.onload=function(){e.width=o.width,e.height=o.height,e.loaded=!0,t()},o.onerror=function(){a()},o.src=e.src});t.push(a)};return Object.keys(e).forEach(function(t){e[t].forEach(a)}),Promise.all(t)}},{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 i=o[a].length,r={src:t.getAttribute("href"),caption:t.getAttribute("data-caption"),groupId:a,translateX:this._getWindowWidth()*i,index:i,translateY:0,width:50,height:50,id:t.getAttribute("data-id")||i,loaded:!1,element:t};o[a].push(r),this.data.currentGroup=a,t.getAttribute("data-id")||t.setAttribute("data-id",i),t.setAttribute("data-index",i),t.addEventListener("click",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),e.clicked=!0,e.update(),e._fireEvent("open")):e._loadItem(o).then(function(){e.data.appear=!0,e.clicked=!0,e._initPhoto(),e.update(),e._fireEvent("open")})})}},{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())}},{key:"onUpdated",value:function(){var t=this;if(this.data.appearEffect&&this.data.appearEffect.once&&(this.data.appearEffect.once=!1,this.execEffect().then(function(){t.replaceEffectWithImg()})),this.clicked){this.clicked=!1;var e=this.data.classNames;this._getElementByClass(e.smartPhotoCaption).focus()}}},{key:"execEffect",value:function(){var t=this.data.appearEffect,e=this.data.classNames,a=document.querySelector('[data-id="'+this.id+'"] .'+e.smartPhotoImgClone);return new Promise(function(e){setTimeout(function(){a.style.transition="all .3s ease-out",a.style.transform="translate("+t.afterX+"px, "+t.afterY+"px) scale("+t.scale+")",e()},30)})}},{key:"replaceEffectWithImg",value:function(){var t=this;setTimeout(function(){t.data.appearEffect=null,t.data.appear=!0,t.update()},300)}},{key:"addAppearEffect",value:function(t){var e=t.querySelector("img"),a=l.getViewPos(e),o={},i=1;o.width=e.offsetWidth,o.height=e.offsetHeight,o.top=a.top,o.left=a.left,o.once=!0,o.img=e.getAttribute("src");var r=this._getWindowWidth(),n=this._getWindowHeight(),s=n-this.data.headerHeight-this.data.footerHeight;"fill"===this.data.resizeStyle&&this.data.isSmartPhone?i=e.offsetWidth>e.offsetHeight?n/e.offsetHeight:r/e.offsetWidth:(i=s/e.offsetHeight)*e.offsetWidth>r&&(i=r/e.offsetWidth);var h=(i-1)/2*e.offsetWidth+(r-e.offsetWidth*i)/2,d=(i-1)/2*e.offsetHeight+(n-e.offsetHeight*i)/2;o.afterX=h,o.afterY=d,o.scale=i,this.data.appearEffect=o}},{key:"hidePhoto",value:function(){var t=this;this.data.hide=!0,this.data.appear=!1,this.data.appearEffect=null,this.data.hideUi=!1,this.data.scale=!1,this.data.scaleSize=1;var e=window.scrollX,a=window.scrollY;location.hash&&this._setHash(""),window.scroll(e,a),this._doHideEffect().then(function(){t.update(),t._fireEvent("close")})}},{key:"_doHideEffect",value:function(){var t=this;return new Promise(function(e){var a=t.data.classNames,o=t._getElementByClass(a.smartPhoto),i=t._getElementByQuery(".current ."+a.smartPhotoImg),r=t._getWindowHeight(),n=function t(){o.removeEventListener("transitionend",t,!0),e()};o.style.opacity=0,i.style.transform="translateY("+r+"px)",o.addEventListener("transitionend",n,!0)})}},{key:"_getElementByClass",value:function(t){return document.querySelector('[data-id="'+this.id+'"] .'+t)}},{key:"_getElementByQuery",value:function(t){return document.querySelector('[data-id="'+this.id+'"] '+t)}},{key:"_getTouchPos",value:function(){var t=0,e=0,a="undefined"==typeof event?this.e:event;return this._isTouched(a)?(t=a.touches[0].pageX,e=a.touches[0].pageY):a.pageX&&(t=a.pageX,e=a.pageY),{x:t,y:e}}},{key:"_getGesturePos",value:function(t){var e=t.touches;return[{x:e[0].pageX,y:e[0].pageY},{x:e[1].pageX,y:e[1].pageY}]}},{key:"_setPosByCurrentIndex",value:function(){var t=this,e=this.groupItems(),a=-1*e[this.data.currentIndex].translateX;this.pos.x=a,setTimeout(function(){t.data.translateX=a,t.data.translateY=0,t._listUpdate()},1)}},{key:"_setHashByCurrentIndex",value:function(){var t=window.scrollX,e=window.scrollY,a=this.groupItems(),o=a[this.data.currentIndex].id,i=this.data.currentGroup,r="group="+i+"&photo="+o;this._setHash(r),window.scroll(t,e)}},{key:"_setHash",value:function(t){window.history&&window.history.pushState&&(t?window.history.replaceState(null,null,location.pathname+"#"+t):window.history.replaceState(null,null,""+location.pathname))}},{key:"_getCurrentItemByHash",value:function(){var t=this.data.group,e=location.hash.substr(1),a=l.parseQuery(e),o=null,i=function(t){a.group===t.groupId&&a.photo===t.id&&(o=t)};return Object.keys(t).forEach(function(e){t[e].forEach(i)}),o}},{key:"_loadItem",value:function(t){return new Promise(function(e){var a=new Image;a.onload=function(){t.width=a.width,t.height=a.height,t.loaded=!0,e()},a.onerror=function(){e()},a.src=t.src})}},{key:"_setSizeByScreen",value:function(){var t=this._getWindowWidth(),e=this._getWindowHeight(),a=this.data.headerHeight,o=this.data.footerHeight,i=e-(a+o);this.groupItems().forEach(function(a){a.scale=i/a.height,a.x=(a.scale-1)/2*a.width+(t-a.width*a.scale)/2,a.y=(a.scale-1)/2*a.height+(e-a.height*a.scale)/2,a.width*a.scale>t&&(a.scale=t/a.width,a.x=(a.scale-1)/2*a.width)})}},{key:"_slideList",value:function(){var t=this;this.data.scaleSize=1,this.isBeingZoomed=!1,this.data.hideUi=!1,this.data.scale=!1,this.data.photoPosX=0,this.data.photoPosY=0,this.data.onMoveClass=!0,this._setPosByCurrentIndex(),this._setHashByCurrentIndex(),this._setSizeByScreen(),setTimeout(function(){t.data.onMoveClass=!1,t.setArrow(),t.update(),t.data.oldIndex!==t.data.currentIndex&&t._fireEvent("change"),t.data.oldIndex=t.data.currentIndex},200)}},{key:"gotoSlide",value:function(t){this.e&&this.e.preventDefault&&this.e.preventDefault(),this.data.currentIndex=parseInt(t,10),this.data.currentIndex||(this.data.currentIndex=0),this._slideList()}},{key:"setArrow",value:function(){var t=this.groupItems(),e=t.length,a=this.data.currentIndex+1,o=this.data.currentIndex-1;this.data.showNextArrow=!1,this.data.showPrevArrow=!1,a!==e&&(this.data.next=a,this.data.showNextArrow=!0),-1!==o&&(this.data.prev=o,this.data.showPrevArrow=!0)}},{key:"beforeDrag",value:function(){if(this._isGestured(this.e))return void this.beforeGesture();if(this.isBeingZoomed=!1,this.data.scale)return void this.beforePhotoDrag();var t=this._getTouchPos();this.isSwipable=!0,this.dragStart=!0,this.firstPos=t,this.oldPos=t}},{key:"afterDrag",value:function(){var t=this.groupItems(),e=new Date,a=e.getTime(),o=this.tapSecond-a,i=0,r=0;return this.isSwipable=!1, | ||
this.onListMove=!1,this.oldPos&&(i=this.oldPos.x-this.firstPos.x,r=this.oldPos.y-this.firstPos.y),this.isBeingZoomed?void this.afterGesture():this.data.scale?void this.afterPhotoDrag():l.isSmartPhone()||0!==i||0!==r?Math.abs(o)<=500&&0===i&&0===r?(this.e.preventDefault(),void this.zoomPhoto()):(this.tapSecond=a,this._fireEvent("swipeend"),"horizontal"===this.moveDir&&(i>=this.data.swipeOffset&&0!==this.data.currentIndex?this.data.currentIndex-=1:i<=-this.data.swipeOffset&&this.data.currentIndex!==t.length-1&&(this.data.currentIndex+=1),this._slideList()),void("vertical"===this.moveDir&&(r>=this.data.swipeOffset?this.hidePhoto():(this.data.translateY=0,this._slideList())))):void this.zoomPhoto()}},{key:"onDrag",value:function(){if(this.e.preventDefault(),this._isGestured(this.e)&&!1===this.onListMove)return void this.onGesture();if(!this.isBeingZoomed){if(this.data.scale)return void this.onPhotoDrag();if(this.isSwipable){var t=this._getTouchPos(),e=t.x-this.oldPos.x,a=t.y-this.firstPos.y;this.dragStart&&(this._fireEvent("swipestart"),this.dragStart=!1,Math.abs(e)>Math.abs(a)?this.moveDir="horizontal":this.moveDir="vertical"),"horizontal"===this.moveDir?(this.pos.x+=e,this.data.translateX=this.pos.x):this.data.translateY=a,this.onListMove=!0,this.oldPos=t,this._listUpdate()}}}},{key:"zoomPhoto",value:function(){var t=this;this.data.hideUi=!0,this.data.scaleSize=this._getScaleBoarder(),this.data.photoPosX=0,this.data.photoPosY=0,this._photoUpdate(),setTimeout(function(){t.data.scale=!0,t._photoUpdate(),t._fireEvent("zoomin")},300)}},{key:"zoomOutPhoto",value:function(){this.data.scaleSize=1,this.isBeingZoomed=!1,this.data.hideUi=!1,this.data.scale=!1,this.data.photoPosX=0,this.data.photoPosY=0,this._photoUpdate(),this._fireEvent("zoomout")}},{key:"beforePhotoDrag",value:function(){var t=this._getTouchPos();this.photoSwipable=!0,this.data.photoPosX||(this.data.photoPosX=0),this.data.photoPosY||(this.data.photoPosY=0),this.oldPhotoPos=t,this.firstPhotoPos=t}},{key:"onPhotoDrag",value:function(){if(this.photoSwipable){this.e.preventDefault();var t=this._getTouchPos(),e=t.x-this.oldPhotoPos.x,a=t.y-this.oldPhotoPos.y,o=this._round(this.data.scaleSize*e,6),i=this._round(this.data.scaleSize*a,6);"number"==typeof o&&(this.data.photoPosX+=o,this.photoVX=o),"number"==typeof i&&(this.data.photoPosY+=i,this.photoVY=i),this.oldPhotoPos=t,this._photoUpdate()}}},{key:"afterPhotoDrag",value:function(){if(this.oldPhotoPos.x===this.firstPhotoPos.x&&this.photoSwipable)this.photoSwipable=!1,this.zoomOutPhoto();else{this.photoSwipable=!1;var t=this._getSelectedItem(),e=this._makeBound(t),a=this.data.swipeOffset*this.data.scaleSize,o=0,i=0;if(this.data.photoPosX>e.maxX?o=-1:this.data.photoPosX<e.minX&&(o=1),this.data.photoPosY>e.maxY?i=-1:this.data.photoPosY<e.minY&&(i=1),this.data.photoPosX-e.maxX>a&&0!==this.data.currentIndex)return void this.gotoSlide(this.data.prev);if(e.minX-this.data.photoPosX>a&&this.data.currentIndex+1!==this.data.total)return void this.gotoSlide(this.data.next);0===o&&0===i?(this.vx=this.photoVX/5,this.vy=this.photoVY/5):this._registerElasticForce(o,i)}}},{key:"beforeGesture",value:function(){this._fireEvent("gesturestart");var t=this._getGesturePos(this.e),e=this._getDistance(t[0],t[1]);this.isBeingZoomed=!0,this.oldDistance=e,this.data.scale=!0,this.e.preventDefault()}},{key:"onGesture",value:function(){var t=this._getGesturePos(this.e),e=this._getDistance(t[0],t[1]),a=(e-this.oldDistance)/100,o=this.data.scaleSize,i=this.data.photoPosX,r=this.data.photoPosY;this.isBeingZoomed=!0,this.data.scaleSize+=this._round(a,6),this.data.scaleSize<.2&&(this.data.scaleSize=.2),this.data.scaleSize<o&&(this.data.photoPosX=(1+this.data.scaleSize-o)*i,this.data.photoPosY=(1+this.data.scaleSize-o)*r),this.data.scaleSize<1||this.data.scaleSize>this._getScaleBoarder()?this.data.hideUi=!0:this.data.hideUi=!1,this.oldDistance=e,this.e.preventDefault(),this._photoUpdate()}},{key:"afterGesture",value:function(){this.data.scaleSize>this._getScaleBoarder()||(this.data.photoPosX=0,this.data.photoPosY=0,this.data.scale=!1,this.data.scaleSize=1,this.data.hideUi=!1,this._fireEvent("gestureend"),this._photoUpdate())}},{key:"_getForceAndTheta",value:function(t,e){return{force:Math.sqrt(t*t+e*e),theta:Math.atan2(e,t)}}},{key:"_getScaleBoarder",value:function(){var t=this._getSelectedItem(),e=this._getWindowWidth(),a=this._getWindowHeight();return l.isSmartPhone()?t.width>t.height?a/(t.height*t.scale):e/(t.width*t.scale):1/t.scale}},{key:"_makeBound",value:function(t){var e=t.width*t.scale*this.data.scaleSize,a=t.height*t.scale*this.data.scaleSize,o=void 0,i=void 0,r=void 0,n=void 0,s=this._getWindowWidth(),h=this._getWindowHeight();return s>e?(r=(s-e)/2,o=-1*r):(r=(e-s)/2,o=-1*r),h>a?(n=(h-a)/2,i=-1*n):(n=(a-h)/2,i=-1*n),{minX:this._round(o,6)*this.data.scaleSize,minY:this._round(i,6)*this.data.scaleSize,maxX:this._round(r,6)*this.data.scaleSize,maxY:this._round(n,6)*this.data.scaleSize}}},{key:"_registerElasticForce",value:function(t,e){var a=this,o=this._getSelectedItem(),i=this._makeBound(o);this.data.elastic=!0,1===t?this.data.photoPosX=i.minX:-1===t&&(this.data.photoPosX=i.maxX),1===e?this.data.photoPosY=i.minY:-1===e&&(this.data.photoPosY=i.maxY),this._photoUpdate(),setTimeout(function(){a.data.elastic=!1,a._photoUpdate()},300)}},{key:"_getSelectedItem",value:function(){var t=this.data,e=t.currentIndex;return t.group[t.currentGroup][e]}},{key:"_getUniqId",value:function(){return(Date.now().toString(36)+Math.random().toString(36).substr(2,5)).toUpperCase()}},{key:"_getDistance",value:function(t,e){var a=t.x-e.x,o=t.y-e.y;return Math.sqrt(a*a+o*o)}},{key:"_round",value:function(t,e){var a=Math.pow(10,e);return t*=a,t=Math.round(t),t/=a}},{key:"_isTouched",value:function(t){return!(!t||!t.touches)}},{key:"_isGestured",value:function(t){return!!(t&&t.touches&&t.touches.length>1)}},{key:"_isSmartPhone",value:function(){var t=navigator.userAgent;return t.indexOf("iPhone")>0||t.indexOf("iPad")>0||t.indexOf("ipod")>0||t.indexOf("Android")>0}},{key:"_calcGravity",value:function(t,e){(t>5||t<-5)&&(this.vx+=.05*t),!1!==this.data.verticalGravity&&(e>5||e<-5)&&(this.vy+=.05*e)}},{key:"_photoUpdate",value:function(){var t=this.data.classNames,e=this._getElementByQuery(".current"),a=e.querySelector("."+t.smartPhotoImg),o=this._getElementByQuery("."+t.smartPhotoNav),i=this._getElementByQuery("."+t.smartPhotoArrows),r=this.virtualPos(this.data.photoPosX),n=this.virtualPos(this.data.photoPosY),s=this.data.scaleSize,h="translate("+r+"px,"+n+"px) scale("+s+")";a.style.transform=h,this.data.scale?l.addClass(a,t.smartPhotoImgOnMove):l.removeClass(a,t.smartPhotoImgOnMove),this.data.elastic?l.addClass(a,t.smartPhotoImgElasticMove):l.removeClass(a,t.smartPhotoImgElasticMove),this.data.hideUi?(o&&o.setAttribute("aria-hidden","true"),i&&i.setAttribute("aria-hidden","true")):(o&&o.setAttribute("aria-hidden","false"),i&&i.setAttribute("aria-hidden","false"))}},{key:"_getWindowWidth",value:function(){return document.documentElement.clientWidth}},{key:"_getWindowHeight",value:function(){return window.innerHeight}},{key:"_listUpdate",value:function(){var t=this.data.classNames,e=this._getElementByQuery("."+t.smartPhotoList),a="translate("+this.data.translateX+"px,"+this.data.translateY+"px)";e.style.transform=a,this.data.onMoveClass?l.addClass(e,t.smartPhotoListOnMove):l.removeClass(e,t.smartPhotoListOnMove)}},{key:"_fireEvent",value:function(t){var e=this._getElementByClass(this.data.classNames.smartPhoto);l.triggerEvent(e,t)}},{key:"_doAnim",value:function(){if(!(this.isBeingZoomed||this.isSwipable||this.photoSwipable||this.data.elastic)&&this.data.scale){this.data.photoPosX+=this.vx,this.data.photoPosY+=this.vy;var t=this._getSelectedItem(),e=this._makeBound(t);this.data.photoPosX<e.minX?(this.data.photoPosX=e.minX,this.vx*=-.2):this.data.photoPosX>e.maxX&&(this.data.photoPosX=e.maxX,this.vx*=-.2),this.data.photoPosY<e.minY?(this.data.photoPosY=e.minY,this.vy*=-.2):this.data.photoPosY>e.maxY&&(this.data.photoPosY=e.maxY,this.vy*=-.2);var a=this._getForceAndTheta(this.vx,this.vy),o=a.force,i=a.theta;o-=this.data.registance,Math.abs(o)<.5||(this.vx=Math.cos(i)*o,this.vy=Math.sin(i)*o,this._photoUpdate())}}}]),e}(h.default);e.exports=u},{"../lib/util":7,"a-template":1}],6:[function(t,e,a){"use strict";e.exports=t("./core/")},{"./core/":5}],7:[function(t,e,a){"use strict";function o(t){t=t||{};for(var e=1;e<arguments.length;e++){var a=arguments[e];if(a)for(var r in a)a.hasOwnProperty(r)&&("object"===i(a[r])?t[r]=o(t[r],a[r]):t[r]=a[r])}return t}var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};e.exports.isSmartPhone=function(){var t=navigator.userAgent;return t.indexOf("iPhone")>0||t.indexOf("iPad")>0||t.indexOf("ipod")>0||t.indexOf("Android")>0},e.exports.extend=o,e.exports.triggerEvent=function(t,e,a){var o=void 0;window.CustomEvent?o=new CustomEvent(e,{cancelable:!0}):(o=document.createEvent("CustomEvent"),o.initCustomEvent(e,!1,!1,a)),t.dispatchEvent(o)},e.exports.parseQuery=function(t){for(var e,a,o,i=t.split("&"),r={},n=0,s=i.length;n<s;n++)e=i[n].split("="),void 0!==e[0]&&(a=e[0],o=void 0!==e[1]?e.slice(1).join("="):a,r[a]=decodeURIComponent(o));return r},e.exports.getViewPos=function(t){return{left:t.getBoundingClientRect().left,top:t.getBoundingClientRect().top}},e.exports.removeElement=function(t){t&&t.parentNode&&t.parentNode.removeChild(t)},e.exports.append=function(t,e){var a=new DOMParser,o=a.parseFromString(e,"text/html");t.appendChild(o.querySelector("body").childNodes[0])},e.exports.addClass=function(t,e){t.classList?t.classList.add(e):t.className+=" "+e},e.exports.removeClass=function(t,e){t.classList?t.classList.remove(e):t.className=t.className.replace(new RegExp("(^|\\b)"+e.split(" ").join("|")+"(\\b|$)","gi")," ")}},{}]},{},[6])(6)}); | ||
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.smartPhoto=t()}}(function(){return function t(e,a,o){function i(s,n){if(!a[s]){if(!e[s]){var h="function"==typeof require&&require;if(!n&&h)return h(s,!0);if(r)return r(s,!0);var d=new Error("Cannot find module '"+s+"'");throw d.code="MODULE_NOT_FOUND",d}var c=a[s]={exports:{}};e[s][0].call(c.exports,function(t){var a=e[s][1][t];return i(a||t)},c,c.exports,t,e,a,o)}return a[s].exports}for(var r="function"==typeof require&&require,s=0;s<o.length;s++)i(o[s]);return i}({1:[function(t,e,a){"use strict";function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}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}}(),r=t("morphdom"),s=t("delegate"),n=[],h="input paste copy click change keydown keyup contextmenu mouseup mousedown mousemove touchstart touchend touchmove compositionstart compositionend",d=h.replace(/([a-z]+)/g,"[data-action-$1],")+"[data-action]";Array.prototype.find||(Array.prototype.find=function(t){if(null===this)throw new TypeError("Array.prototype.find called on null or undefined");if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var e=Object(this),a=e.length>>>0,o=arguments[1],i=void 0,r=0;r<a;r++)if(i=e[r],t.call(o,i,r,e))return i}),Element.prototype.matches||(Element.prototype.matches=Element.prototype.matchesSelector||Element.prototype.mozMatchesSelector||Element.prototype.msMatchesSelector||Element.prototype.oMatchesSelector||Element.prototype.webkitMatchesSelector||function(t){for(var e=(this.document||this.ownerDocument).querySelectorAll(t),a=e.length;--a>=0&&e.item(a)!==this;);return a>-1});var c=function(t){return document.querySelector(t)},l=function(t){for(var e=0,a=n.length;e<a;e++)for(var o=n[e],i=o.templates,r=0,s=i.length;r<s;r++)if(i[r]==t)return o;return null},u=function(t,e){if("function"==typeof t.closest)return t.closest(e)||null;for(;t;){if(t.matches(e))return t;t=t.parentElement}return null},p=function(t,e,a,o){a.split(" ").forEach(function(a){s(t,e,a,o)})};"undefined"!=typeof document&&(p(document,"[data-bind]","input change click",function(t){var e=t.delegateTarget,a=e.getAttribute("data-bind"),o=e.getAttribute("href"),i=u(e,"[data-id]").getAttribute("data-id"),r=e.value;if(o&&(r=r.replace("#","")),i){var s=l(i);"radio"===e.getAttribute("type")||("checkbox"===e.getAttribute("type")?function(){var t=[],e=document.querySelectorAll('[data-bind="'+a+'"]');[].forEach.call(e,function(e){e.checked&&t.push(e.value)})}():s.updateDataByString(a,r))}}),p(document,d,h,function(t){var e=t.delegateTarget;if(!("click"===t.type&&"select"===e.tagName||"input"===t.type&&"button"===e.getAttribute("type"))){var a=h.split(" "),o="action";a.forEach(function(a){e.getAttribute("data-action-"+a)&&t.type===a&&(o+="-"+a)});var i=e.getAttribute("data-"+o);if(i){var r=i.replace(/\(.*?\);?/,""),s=i.replace(/(.*?)\((.*?)\);?/,"$2"),n=s.split(","),d=u(e,"[data-id]").getAttribute("data-id");if(d){var c=l(d);c.e=t,c.method&&c.method[r]?c.method[r].apply(c,n):c[r]&&c[r].apply(c,n)}}}}));var f=function(){function t(e){o(this,t),this.atemplate=[],n.push(this);for(var a in e)this[a]=e[a];this.data||(this.data={}),this.templates||(this.templates=[]);for(var i=this.templates,r=i.length,s=0,h=r;s<h;s++){var d=this.templates[s],l=c("#"+d).innerHTML;this.atemplate.push({id:d,html:l})}this.setId()}return i(t,[{key:"addTemplate",value:function(t,e){this.atemplate.push({id:t,html:e}),this.templates.push(t)}},{key:"loadHtml",value:function(){var t=this.templates,e=[];return t.forEach(function(t){var a=new $.Deferred;e.push(a);var o=c("#"+t).getAttribute("src");$.ajax({url:o,type:"GET",dataType:"text"}).success(function(e){c("#"+t).innerHTML=e,a.resolve()})}),$.when.apply($,e)}},{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){for(var e in t)"function"!=typeof t[e]&&(this.data[e]=t[e])}},{key:"loadData",value:function(t){var e=JSON.parse(localStorage.getItem(t));if(e)for(var a in e)"function"!=typeof e[a]&&(this.data[a]=e[a])}},{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,i=0;i<t;i++)e+=a.charAt(Math.floor(this.getRand(0,o)));return e}},{key:"setId",value:function(){for(var e=void 0,a=(t.ids,!1);;){e=this.getRandText(10);for(var o=0,i=t.ids;o<i;o++)t.ids[o]===e&&(a=!0);if(!1===a)break}this.data.aTemplate_id=e}},{key:"getDataFromObj",value:function(t,e){t=t.replace(/\[([a-zA-Z0-9._-]+)\]/g,".$1"),t=t.replace(/^\./,"");for(var a=t.split(".");a.length;){var o=a.shift();if(!(o in e))return;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.split(".");a.length>1;)e=e[a.shift()];var o=a.shift();o.match(/^\d+$/)?e.splice(Number(o),1):delete e[o]}},{key:"resolveBlock",value:function(t,e,a){var o=this,i=t.match(/<!-- BEGIN ([a-zA-Z0-9._-]+):touch#([a-zA-Z0-9._-]+) -->/g),r=t.match(/<!-- BEGIN ([a-zA-Z0-9._-]+):touchnot#([a-zA-Z0-9._-]+) -->/g),s=t.match(/<!-- BEGIN ([a-zA-Z0-9._-]+):exist -->/g),n=t.match(/<!-- BEGIN ([a-zA-Z0-9._-]+):empty -->/g);if(i)for(var h=0,d=i.length;h<d;h++){var c=i[h];c=c.replace(/([a-zA-Z0-9._-]+):touch#([a-zA-Z0-9._-]+)/,"($1):touch#($2)");var l=c.replace(/BEGIN/,"END"),u=new RegExp(c+"(([\\n\\r\\t]|.)*?)"+l,"g");t=t.replace(u,function(t,a,i,r){return("function"==typeof e[a]?e[a].apply(o):o.getDataFromObj(a,e))==i?r:""})}if(r)for(var p=0,f=r.length;p<f;p++){var m=r[p];m=m.replace(/([a-zA-Z0-9._-]+):touchnot#([a-zA-Z0-9._-]+)/,"($1):touchnot#($2)");var v=m.replace(/BEGIN/,"END"),g=new RegExp(m+"(([\\n\\r\\t]|.)*?)"+v,"g");t=t.replace(g,function(t,a,i,r){return("function"==typeof e[a]?e[a].apply(o):o.getDataFromObj(a,e))!=i?r:""})}if(s)for(var x=0,y=s.length;x<y;x++){var P=s[x];P=P.replace(/([a-zA-Z0-9._-]+):exist/,"($1):exist");var E=P.replace(/BEGIN/,"END"),w=new RegExp(P+"(([\\n\\r\\t]|.)*?)"+E,"g");t=t.replace(w,function(t,a,i){var r="function"==typeof e[a]?e[a].apply(o):o.getDataFromObj(a,e);return r||0===r?i:""})}if(n)for(var _=0,b=n.length;_<b;_++){var S=n[_];S=S.replace(/([a-zA-Z0-9._-]+):empty/,"($1):empty");var N=S.replace(/BEGIN/,"END"),I=new RegExp(S+"(([\\n\\r\\t]|.)*?)"+N,"g");t=t.replace(I,function(t,a,i){var r="function"==typeof e[a]?e[a].apply(o):o.getDataFromObj(a,e);return r||0===r?"":i})}return t=t.replace(/{([a-zA-Z0-9._-]+)}(\[([a-zA-Z0-9._-]+)\])*/g,function(t,i,r,s){var n=void 0;if("i"==i)n=a;else{if(!e[i]&&0!==e[i])return s&&o.convert&&o.convert[s]?o.convert[s].call(o,""):"";n="function"==typeof e[i]?e[i].apply(o):e[i]}return s&&o.convert&&o.convert[s]?o.convert[s].call(o,n):n})}},{key:"resolveAbsBlock",value:function(t){var e=this;return t=t.replace(/{(.*?)}/g,function(t,a){var o=e.getDataByString(a);return void 0!==o?"function"==typeof o?o.apply(e):o:t})}},{key:"resolveInclude",value:function(t){return t=t.replace(/<!-- #include id="(.*?)" -->/g,function(t,e){return c("#"+e).innerHTML})}},{key:"resolveWith",value:function(t){return t=t.replace(/<!-- BEGIN ([a-zA-Z0-9._-]+):with -->(([\n\r\t]|.)*?)<!-- END ([a-zA-Z0-9._-]+):with -->/g,function(t,e,a){return t=t.replace(/data\-bind=['"](.*?)['"]/g,"data-bind='"+e+".$1'")})}},{key:"resolveLoop",value:function(t){var e=this;return t=t.replace(/<!-- BEGIN (.+?):loop -->(([\n\r\t]|.)*?)<!-- END (.+?):loop -->/g,function(t,a,o){var i=e.getDataByString(a),r=[];r="function"==typeof i?i.apply(e):i;var s="";if(r instanceof Array)for(var n=0,h=r.length;n<h;n++)s+=e.resolveBlock(o,r[n],n);return s=s.replace(/\\([^\\])/g,"$1")})}},{key:"removeData",value:function(t){var e=this.data;for(var a in e)for(var o=0,i=t.length;o<i;o++)a===t[o]&&delete e[a];return this}},{key:"hasLoop",value:function(t){return!!t.match(/<!-- BEGIN (.+?):loop -->(([\n\r\t]|.)*?)<!-- END (.+?):loop -->/g)}},{key:"getHtml",value:function(t,e){var a=this.atemplate.find(function(e){return e.id===t}),o="";if(a&&a.html&&(o=a.html),e&&(o=t),!o)return"";var i=this.data;for(o=this.resolveInclude(o),o=this.resolveWith(o);this.hasLoop(o);)o=this.resolveLoop(o);return o=this.resolveBlock(o,i),o=o.replace(/\\([^\\])/g,"$1"),o=this.resolveAbsBlock(o),o.replace(/^([\t ])*\n/gm,"")}},{key:"update",value:function(t,e){var a=(this.getHtml(),this.templates),o=t||"html";this.beforeUpdated&&this.beforeUpdated();for(var i=0,s=a.length;i<s;i++){var n=a[i],h="#"+n,d=this.getHtml(n),l=c("[data-id='"+n+"']");if((!e||e==n)&&(l?"text"===o?l.innerText=d:r(l,"<div data-id='"+n+"'>"+d+"</div>"):(c(h).insertAdjacentHTML("afterend",'<div data-id="'+n+'"></div>'),"text"===o?c("[data-id='"+n+"']").innerText=d:c("[data-id='"+n+"']").innerHTML=d),e))break}return this.updateBindingData(e),this.onUpdated&&this.onUpdated(e),this}},{key:"updateBindingData",value:function(t){for(var e=this,a=this.templates,o=0,i=a.length;o<i;o++){var r=a[o];if(!t||t==r){var s=c("[data-id='"+r+"']"),n=s.querySelectorAll("[data-bind]");if([].forEach.call(n,function(t){var a=e.getDataByString(t.getAttribute("data-bind"));"checkbox"===t.getAttribute("type")||"radio"===t.getAttribute("type")?a==t.value&&(t.checked=!0):t.value=a}),t)break}}return this}},{key:"applyMethod",value:function(t){var e=[].splice.call(arguments,0);return e.shift(),this.method[t].apply(this,e)}},{key:"getComputedProp",value:function(t){return this.data[t].apply(this)}},{key:"remove",value:function(t){for(var e=this.data,a=t.split(".");a.length>1;)e=e[a.shift()];var o=a.shift();return o.match(/^\d+$/)?e.splice(Number(o),1):delete e[o],this}}]),t}();e.exports=f},{delegate:3,morphdom:4}],2:[function(t,e,a){function o(t,e){for(;t&&t.nodeType!==i;){if(t.matches(e))return t;t=t.parentNode}}var i=9;if("undefined"!=typeof Element&&!Element.prototype.matches){var r=Element.prototype;r.matches=r.matchesSelector||r.mozMatchesSelector||r.msMatchesSelector||r.oMatchesSelector||r.webkitMatchesSelector}e.exports=o},{}],3:[function(t,e,a){function o(t,e,a,o,r){var s=i.apply(this,arguments);return t.addEventListener(a,s,r),{destroy:function(){t.removeEventListener(a,s,r)}}}function i(t,e,a,o){return function(a){a.delegateTarget=r(a.target,e),a.delegateTarget&&o.call(t,a)}}var r=t("./closest");e.exports=o},{"./closest":2}],4:[function(t,e,a){"use strict";function o(t){!l&&f.createRange&&(l=f.createRange(),l.selectNode(f.body));var e;return l&&l.createContextualFragment?e=l.createContextualFragment(t):(e=f.createElement("body"),e.innerHTML=t),e.childNodes[0]}function i(t,e){var a=t.nodeName,o=e.nodeName;return a===o||!!(e.actualize&&a.charCodeAt(0)<91&&o.charCodeAt(0)>90)&&a===o.toUpperCase()}function r(t,e){return e&&e!==p?f.createElementNS(e,t):f.createElement(t)}function s(t,e){for(var a=t.firstChild;a;){var o=a.nextSibling;e.appendChild(a),a=o}return e}function n(t,e){var a,o,i,r,s,n=e.attributes;for(a=n.length-1;a>=0;--a)o=n[a],i=o.name,r=o.namespaceURI,s=o.value,r?(i=o.localName||i,t.getAttributeNS(r,i)!==s&&t.setAttributeNS(r,i,s)):t.getAttribute(i)!==s&&t.setAttribute(i,s);for(n=t.attributes,a=n.length-1;a>=0;--a)o=n[a],!1!==o.specified&&(i=o.name,r=o.namespaceURI,r?(i=o.localName||i,v(e,r,i)||t.removeAttributeNS(r,i)):v(e,null,i)||t.removeAttribute(i))}function h(t,e,a){t[a]!==e[a]&&(t[a]=e[a],t[a]?t.setAttribute(a,""):t.removeAttribute(a,""))}function d(){}function c(t){return t.id}var l,u,p="http://www.w3.org/1999/xhtml",f="undefined"==typeof document?void 0:document,m=f?f.body||f.createElement("div"):{};u=m.hasAttributeNS?function(t,e,a){return t.hasAttributeNS(e,a)}:m.hasAttribute?function(t,e,a){return t.hasAttribute(a)}:function(t,e,a){return null!=t.getAttributeNode(e,a)};var v=u,g={OPTION:function(t,e){h(t,e,"selected")},INPUT:function(t,e){h(t,e,"checked"),h(t,e,"disabled"),t.value!==e.value&&(t.value=e.value),v(e,null,"value")||t.removeAttribute("value")},TEXTAREA:function(t,e){var a=e.value;t.value!==a&&(t.value=a);var o=t.firstChild;if(o){var i=o.nodeValue;if(i==a||!a&&i==t.placeholder)return;o.nodeValue=a}},SELECT:function(t,e){if(!v(e,null,"multiple")){for(var a=0,o=e.firstChild;o;){var i=o.nodeName;if(i&&"OPTION"===i.toUpperCase()){if(v(o,null,"selected")){a;break}a++}o=o.nextSibling}t.selectedIndex=a}}},x=1,y=3,P=8,E=function(t){return function(e,a,n){function h(t){w?w.push(t):w=[t]}function l(t,e){if(t.nodeType===x)for(var a=t.firstChild;a;){var o=void 0;e&&(o=_(a))?h(o):(A(a),a.firstChild&&l(a,e)),a=a.nextSibling}}function u(t,e,a){!1!==k(t)&&(e&&e.removeChild(t),A(t),l(t,a))}function p(t){if(t.nodeType===x)for(var e=t.firstChild;e;){var a=_(e);a&&(C[a]=e),p(e),e=e.nextSibling}}function m(t){S(t);for(var e=t.firstChild;e;){var a=e.nextSibling,o=_(e);if(o){var r=C[o];r&&i(e,r)&&(e.parentNode.replaceChild(r,e),v(r,e))}m(e),e=a}}function v(o,r,s){var n,d=_(r);if(d&&delete C[d],!a.isSameNode||!a.isSameNode(e)){if(!s){if(!1===N(o,r))return;if(t(o,r),I(o),!1===B(o,r))return}if("TEXTAREA"!==o.nodeName){var c,l,p,E,w=r.firstChild,S=o.firstChild;t:for(;w;){for(p=w.nextSibling,c=_(w);S;){if(l=S.nextSibling,w.isSameNode&&w.isSameNode(S)){w=p,S=l;continue t}n=_(S);var k=S.nodeType,A=void 0;if(k===w.nodeType&&(k===x?(c?c!==n&&((E=C[c])?S.nextSibling===E?A=!1:(o.insertBefore(E,S),l=S.nextSibling,n?h(n):u(S,o,!0),S=E):A=!1):n&&(A=!1),(A=!1!==A&&i(S,w))&&v(S,w)):k!==y&&k!=P||(A=!0,S.nodeValue=w.nodeValue)),A){w=p,S=l;continue t}n?h(n):u(S,o,!0),S=l}if(c&&(E=C[c])&&i(E,w))o.appendChild(E),v(E,w);else{var D=b(w);!1!==D&&(D&&(w=D),w.actualize&&(w=w.actualize(o.ownerDocument||f)),o.appendChild(w),m(w))}w=p,S=l}for(;S;)l=S.nextSibling,(n=_(S))?h(n):u(S,o,!0),S=l}var z=g[o.nodeName];z&&z(o,r)}}if(n||(n={}),"string"==typeof a)if("#document"===e.nodeName||"HTML"===e.nodeName){var E=a;a=f.createElement("html"),a.innerHTML=E}else a=o(a);var w,_=n.getNodeKey||c,b=n.onBeforeNodeAdded||d,S=n.onNodeAdded||d,N=n.onBeforeElUpdated||d,I=n.onElUpdated||d,k=n.onBeforeNodeDiscarded||d,A=n.onNodeDiscarded||d,B=n.onBeforeElChildrenUpdated||d,D=!0===n.childrenOnly,C={};p(e);var z=e,G=z.nodeType,T=a.nodeType;if(!D)if(G===x)T===x?i(e,a)||(A(e),z=s(e,r(a.nodeName,a.namespaceURI))):z=a;else if(G===y||G===P){if(T===G)return z.nodeValue=a.nodeValue,z;z=a}if(z===a)A(e);else if(v(z,a,D),w)for(var O=0,X=w.length;O<X;O++){var M=C[w[O]];M&&u(M,M.parentNode,!1)}return!D&&z!==e&&e.parentNode&&(z.actualize&&(z=z.actualize(e.ownerDocument||f)),e.parentNode.replaceChild(z,e)),z}}(n);e.exports=E},{}],5:[function(t,e,a){"use strict";function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function r(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}var s=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}}(),n=t("a-template"),h=function(t){return t&&t.__esModule?t:{default:t}}(n),d='<div class="\\{classNames.smartPhoto\\}"\x3c!-- BEGIN hide:exist --\x3e aria-hidden="true"\x3c!-- END hide:exist --\x3e\x3c!-- BEGIN hide:empty --\x3e aria-hidden="false"\x3c!-- END hide:empty --\x3e role="dialog">\n\t<div class="\\{classNames.smartPhotoBody\\}">\n\t\t<div class="\\{classNames.smartPhotoInner\\}">\n\t\t\t <div class="\\{classNames.smartPhotoHeader\\}">\n\t\t\t\t\t<span class="\\{classNames.smartPhotoCount\\}">{currentIndex}[increment]/{total}</span>\n\t\t\t\t\t<span class="\\{classNames.smartPhotoCaption\\}" aria-live="polite" tabindex="-1">\x3c!-- BEGIN groupItems:loop --\x3e\x3c!-- \\BEGIN currentIndex:touch#{index} --\x3e{caption}\x3c!-- \\END currentIndex:touch#{index} --\x3e\x3c!-- END groupItems:loop --\x3e</span>\n\t\t\t\t\t<button class="\\{classNames.smartPhotoDismiss\\}" data-action-click="hidePhoto()"><span class="smartphoto-sr-only">\\{message.closeDialog\\}</span></button>\n\t\t\t\t</div>\n\t\t\t\t<div class="\\{classNames.smartPhotoContent\\}"\x3c!-- BEGIN isSmartPhone:exist --\x3e data-action-touchstart="beforeDrag" data-action-touchmove="onDrag" data-action-touchend="afterDrag(false)"\x3c!-- END isSmartPhone:exist --\x3e>\n\t\t\t\t</div>\n\t\t\t\t<ul style="transform:translate({translateX}px,{translateY}px);" class="\\{classNames.smartPhotoList\\}\x3c!-- BEGIN onMoveClass:exist --\x3e \\{classNames.smartPhotoListOnMove\\}\x3c!-- END onMoveClass:exist --\x3e">\n\t\t\t\t\t\x3c!-- BEGIN groupItems:loop --\x3e\n\t\t\t\t\t<li style="transform:translate({translateX}px,{translateY}px);" class="\x3c!-- \\BEGIN currentIndex:touch#{index} --\x3ecurrent\x3c!-- \\END currentIndex:touch#{index} --\x3e">\n\t\t\t\t\t\t\x3c!-- BEGIN processed:exist --\x3e\n\t\t\t\t\t\t<div style="transform:translate({x}px,{y}px) scale({scale});" class="\\\\{classNames.smartPhotoImgWrap\\\\}"\x3c!-- \\BEGIN isSmartPhone:empty --\x3e data-action-mousemove="onDrag" data-action-mousedown="beforeDrag" data-action-mouseup="afterDrag"\x3c!-- \\END isSmartPhone:empty --\x3e\x3c!-- \\BEGIN isSmartPhone:exist --\x3e data-action-touchstart="beforeDrag" data-action-touchmove="onDrag" data-action-touchend="afterDrag"\x3c!-- \\END isSmartPhone:exist --\x3e>\n\t\t\t\t\t\t\t<img style="\x3c!-- \\BEGIN currentIndex:touch#{index} --\x3etransform:translate(\\{photoPosX\\}[virtualPos]px,\\{photoPosY\\}[virtualPos]px) scale(\\{scaleSize\\});\x3c!-- \\END currentIndex:touch#{index} --\x3e" src="{src}" class="\\\\{classNames.smartPhotoImg\\\\}\x3c!-- \\BEGIN scale:exist --\x3e \\\\{classNames.smartPhotoImgOnMove\\\\}\x3c!-- \\END scale:exist --\x3e\x3c!-- \\BEGIN elastic:exist --\x3e \\\\{classNames.smartPhotoImgElasticMove\\\\}\x3c!-- \\END elastic:exist --\x3e\x3c!-- \\BEGIN appear:exist --\x3e active\x3c!-- \\END appear:exist --\x3e" ondragstart="return false;">\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\x3c!-- END processed:exist --\x3e\n\t\t\t\t\t\t\x3c!-- BEGIN processed:empty --\x3e\n\t\t\t\t\t\t<div class="\\\\{classNames.smartPhotoLoaderWrap\\\\}">\n\t\t\t\t\t\t\t<span class="\\\\{classNames.smartPhotoLoader\\\\}"></span>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\x3c!-- END processed:empty --\x3e\n\t\t\t\t\t</li>\n\t\t\t\t\t\x3c!-- END groupItems:loop --\x3e\n\t\t\t\t</ul>\n\t\t\t\t\x3c!-- BEGIN arrows:exist --\x3e\n\t\t\t\t<ul class="\\{classNames.smartPhotoArrows\\}"\x3c!-- BEGIN hideUi:exist --\x3e aria-hidden="true"\x3c!-- END hideUi:exist --\x3e\x3c!-- BEGIN hideUi:exist --\x3e aria-hidden="false"\x3c!-- END hideUi:exist --\x3e>\n\t\t\t\t\t<li class="\\{classNames.smartPhotoArrowLeft\\}"\x3c!-- BEGIN showPrevArrow:empty --\x3e aria-hidden="true"\x3c!-- END showPrevArrow:empty --\x3e><a href="#" data-action-click="gotoSlide({prev})" role="button"><span class="smartphoto-sr-only">\\{message.gotoPrevImage\\}</span></a></li>\n\t\t\t\t\t<li class="\\{classNames.smartPhotoArrowRight\\}"\x3c!-- BEGIN showNextArrow:empty --\x3e aria-hidden="true"\x3c!-- END showNextArrow:empty --\x3e><a href="#" data-action-click="gotoSlide({next})" role="button"><span class="smartphoto-sr-only">\\{message.gotoNextImage\\}</span></a></li>\n\t\t\t\t</ul>\n\t\t\t\t\x3c!-- END arrows:exist --\x3e\n\t\t\t\t\x3c!-- BEGIN nav:exist --\x3e\n\t\t\t\t<nav class="\\{classNames.smartPhotoNav\\}"\x3c!-- BEGIN hideUi:exist --\x3e aria-hidden="true"\x3c!-- END hideUi:exist --\x3e\x3c!-- BEGIN hideUi:exist --\x3e aria-hidden="false"\x3c!-- END hideUi:exist --\x3e>\n\t\t\t\t\t<ul>\n\t\t\t\t\t\t\x3c!-- BEGIN groupItems:loop --\x3e\n\t\t\t\t\t\t<li><a href="#" data-action-click="gotoSlide({index})" class="\x3c!-- \\BEGIN currentIndex:touch#{index} --\x3ecurrent\x3c!-- \\END currentIndex:touch#{index} --\x3e" style="background-image:url({src});" role="button"><span class="smartphoto-sr-only">go to {caption}</span></a></li>\n\t\t\t\t\t\t\x3c!-- END groupItems:loop --\x3e\n\t\t\t\t\t</ul>\n\t\t\t\t</nav>\n\t\t\t\t\x3c!-- END nav:exist --\x3e\n\t\t</div>\n\t\t\x3c!-- BEGIN appearEffect:exist --\x3e\n\t\t<img src=\\{appearEffect.img\\}\n\t\tclass="\\{classNames.smartPhotoImgClone\\}"\n\t\tstyle="width:\\{appearEffect.width\\}px;height:\\{appearEffect.height\\}px;transform:translate(\\{appearEffect.left\\}px,\\{appearEffect.top\\}px) scale(1)" />\n\t\t\x3c!-- END appearEffect:exist --\x3e\n\t</div>\n</div>\n',c=t("../lib/util"),l={classNames:{smartPhoto:"smartphoto",smartPhotoClose:"smartphoto-close",smartPhotoBody:"smartphoto-body",smartPhotoInner:"smartphoto-inner",smartPhotoContent:"smartphoto-content",smartPhotoImg:"smartphoto-img",smartPhotoImgOnMove:"smartphoto-img-onmove",smartPhotoImgElasticMove:"smartphoto-img-elasticmove",smartPhotoImgWrap:"smartphoto-img-wrap",smartPhotoArrows:"smartphoto-arrows",smartPhotoNav:"smartphoto-nav",smartPhotoArrowRight:"smartphoto-arrow-right",smartPhotoArrowLeft:"smartphoto-arrow-left",smartPhotoImgLeft:"smartphoto-img-left",smartPhotoImgRight:"smartphoto-img-right",smartPhotoList:"smartphoto-list",smartPhotoListOnMove:"smartphoto-list-onmove",smartPhotoHeader:"smartphoto-header",smartPhotoCount:"smartphoto-count",smartPhotoCaption:"smartphoto-caption",smartPhotoDismiss:"smartphoto-dismiss",smartPhotoLoader:"smartphoto-loader",smartPhotoLoaderWrap:"smartphoto-loader-wrap",smartPhotoImgClone:"smartphoto-img-clone"},message:{gotoNextImage:"go to the next image",gotoPrevImage:"go to the previous image",closeDialog:"close the image dialog"},arrows:!0,nav:!0,animationSpeed:300,swipeOffset:100,headerHeight:60,footerHeight:60,forceInterval:10,registance:.5,resizeStyle:"fill",verticalGravity:!1,useOrientationApi:!0},u=function(t){function e(t,a){o(this,e);var r=i(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));r.data=c.extend({},l,a),r.data.currentIndex=0,r.data.oldIndex=0,r.data.hide=!0,r.data.group={},r.data.scaleSize=1,r.data.scale=!1,r.pos={x:0,y:0},r.data.photoPosX=0,r.data.photoPosY=0,r.convert={increment:r.increment,virtualPos:r.virtualPos},r.data.groupItems=r.groupItems,r.elements=document.querySelectorAll(t);var s=new Date;r.tapSecond=s.getTime(),r.onListMove=!1,r.clicked=!1,r.id=r._getUniqId(),r.vx=0,r.vy=0,r.data.appearEffect=null,r.addTemplate(r.id,d),r.data.isSmartPhone=r._isSmartPhone();var n=document.querySelector("body");c.append(n,"<div data-id='"+r.id+"'></div>"),[].forEach.call(r.elements,function(t){r.addNewItem(t)});var h=r._getCurrentItemByHash();return h&&c.triggerEvent(h.element,"click"),r.update(),r._getEachImageSize().then(function(){r._fireEvent("loadall")}),setInterval(function(){r._doAnim()},r.data.forceInterval),r.data.isSmartPhone?(window.addEventListener("orientationchange",function(){r._resetTranslate(),r._setPosByCurrentIndex(),r._setHashByCurrentIndex(),r._setSizeByScreen(),r.update()}),r.data.useOrientationApi?(window.addEventListener("deviceorientation",function(t){var e=window.orientation;t&&t.gamma&&!r.data.appearEffect&&(r.isBeingZoomed||r.photoSwipable||r.data.elastic||!r.data.scale||(0===e?r._calcGravity(t.gamma,t.beta):90===e?r._calcGravity(t.beta,t.gamma):-90===e?r._calcGravity(-t.beta,-t.gamma):180===e&&r._calcGravity(-t.gamma,-t.beta)))}),r):i(r)):(window.addEventListener("resize",function(){r._resetTranslate(),r._setPosByCurrentIndex(),r._setSizeByScreen(),r.update()}),window.addEventListener("keydown",function(t){var e=t.keyCode||t.which;!0!==r.data.hide&&(37===e?r.gotoSlide(r.data.prev):39===e?r.gotoSlide(r.data.next):27===e&&r.hidePhoto())}),i(r))}return r(e,t),s(e,[{key:"on",value:function(t,e){var a=this;this._getElementByClass(this.data.classNames.smartPhoto).addEventListener(t,function(t){e.call(a,t)})}},{key:"increment",value:function(t){return t+1}},{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:"_getEachImageSize",value:function(){var t=[],e=this.data.group,a=function(e){var a=new Promise(function(t,a){var o=new Image;o.onload=function(){e.width=o.width,e.height=o.height,e.loaded=!0,t()},o.onerror=function(){a()},o.src=e.src});t.push(a)};return Object.keys(e).forEach(function(t){e[t].forEach(a)}),Promise.all(t)}},{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 i=o[a].length,r={src:t.getAttribute("href"),caption:t.getAttribute("data-caption"),groupId:a,translateX:this._getWindowWidth()*i,index:i,translateY:0,width:50,height:50,id:t.getAttribute("data-id")||i,loaded:!1,processed:!1,element:t};o[a].push(r),this.data.currentGroup=a,t.getAttribute("data-id")||t.setAttribute("data-id",i),t.setAttribute("data-index",i),t.addEventListener("click",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),e.clicked=!0,e.update(),e._fireEvent("open")):e._loadItem(o).then(function(){e._initPhoto(),e.addAppearEffect(t),e.clicked=!0,e.update(),e._fireEvent("open")})})}},{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())}},{key:"onUpdated",value:function(){var t=this;if(this.data.appearEffect&&this.data.appearEffect.once&&(this.data.appearEffect.once=!1,this.execEffect().then(function(){t.data.appearEffect=null,t.data.appear=!0,t.update()})),this.clicked){this.clicked=!1;var e=this.data.classNames;this._getElementByClass(e.smartPhotoCaption).focus()}}},{key:"execEffect",value:function(){var t=this;return new Promise(function(e){var a=t.data.appearEffect,o=t.data.classNames,i=t._getElementByClass(o.smartPhotoImgClone),r=function t(){i.removeEventListener("transitionend",t,!0),e()};i.addEventListener("transitionend",r,!0),setTimeout(function(){i.style.transform="translate("+a.afterX+"px, "+a.afterY+"px) scale("+a.scale+")"},10)})}},{key:"addAppearEffect",value:function(t){var e=t.querySelector("img"),a=c.getViewPos(e),o={},i=1;o.width=e.offsetWidth,o.height=e.offsetHeight,o.top=a.top,o.left=a.left,o.once=!0,o.img=e.getAttribute("src");var r=this._getWindowWidth(),s=this._getWindowHeight(),n=s-this.data.headerHeight-this.data.footerHeight;"fill"===this.data.resizeStyle&&this.data.isSmartPhone?i=e.offsetWidth>e.offsetHeight?s/e.offsetHeight:r/e.offsetWidth:(i=n/e.offsetHeight)*e.offsetWidth>r&&(i=r/e.offsetWidth);var h=(i-1)/2*e.offsetWidth+(r-e.offsetWidth*i)/2,d=(i-1)/2*e.offsetHeight+(s-e.offsetHeight*i)/2;o.afterX=h,o.afterY=d,o.scale=i,this.data.appearEffect=o}},{key:"hidePhoto",value:function(){var t=this;this.data.hide=!0,this.data.appear=!1,this.data.appearEffect=null,this.data.hideUi=!1,this.data.scale=!1,this.data.scaleSize=1;var e=window.scrollX,a=window.scrollY;location.hash&&this._setHash(""),window.scroll(e,a),this._doHideEffect().then(function(){t.update(),t._fireEvent("close")})}},{key:"_doHideEffect",value:function(){var t=this;return new Promise(function(e){var a=t.data.classNames,o=t._getElementByClass(a.smartPhoto),i=t._getElementByQuery(".current ."+a.smartPhotoImg),r=t._getWindowHeight(),s=function t(){o.removeEventListener("transitionend",t,!0),e()};o.style.opacity=0,i.style.transform="translateY("+r+"px)",o.addEventListener("transitionend",s,!0)})}},{key:"_getElementByClass",value:function(t){return document.querySelector('[data-id="'+this.id+'"] .'+t)}},{key:"_getElementByQuery",value:function(t){return document.querySelector('[data-id="'+this.id+'"] '+t)}},{key:"_getTouchPos",value:function(){var t=0,e=0,a="undefined"==typeof event?this.e:event;return this._isTouched(a)?(t=a.touches[0].pageX,e=a.touches[0].pageY):a.pageX&&(t=a.pageX,e=a.pageY),{x:t,y:e}}},{key:"_getGesturePos",value:function(t){var e=t.touches;return[{x:e[0].pageX,y:e[0].pageY},{x:e[1].pageX,y:e[1].pageY}]}},{key:"_setPosByCurrentIndex",value:function(){var t=this,e=this.groupItems(),a=-1*e[this.data.currentIndex].translateX;this.pos.x=a,setTimeout(function(){t.data.translateX=a,t.data.translateY=0,t._listUpdate()},1)}},{key:"_setHashByCurrentIndex",value:function(){var t=window.scrollX,e=window.scrollY,a=this.groupItems(),o=a[this.data.currentIndex].id,i=this.data.currentGroup,r="group="+i+"&photo="+o;this._setHash(r),window.scroll(t,e)}},{key:"_setHash",value:function(t){window.history&&window.history.pushState&&(t?window.history.replaceState(null,null,location.pathname+"#"+t):window.history.replaceState(null,null,""+location.pathname))}},{key:"_getCurrentItemByHash",value:function(){var t=this.data.group,e=location.hash.substr(1),a=c.parseQuery(e),o=null,i=function(t){a.group===t.groupId&&a.photo===t.id&&(o=t)};return Object.keys(t).forEach(function(e){t[e].forEach(i)}),o}},{key:"_loadItem",value:function(t){return new Promise(function(e){var a=new Image;a.onload=function(){t.width=a.width,t.height=a.height,t.loaded=!0,e()},a.onerror=function(){e()},a.src=t.src})}},{key:"_setSizeByScreen",value:function(){var t=this._getWindowWidth(),e=this._getWindowHeight(),a=this.data.headerHeight,o=this.data.footerHeight,i=e-(a+o);this.groupItems().forEach(function(a){a.loaded&&(a.processed=!0,a.scale=i/a.height,a.x=(a.scale-1)/2*a.width+(t-a.width*a.scale)/2,a.y=(a.scale-1)/2*a.height+(e-a.height*a.scale)/2,a.width*a.scale>t&&(a.scale=t/a.width,a.x=(a.scale-1)/2*a.width))})}},{key:"_slideList",value:function(){var t=this;this.data.scaleSize=1,this.isBeingZoomed=!1,this.data.hideUi=!1,this.data.scale=!1,this.data.photoPosX=0,this.data.photoPosY=0,this.data.onMoveClass=!0,this._setPosByCurrentIndex(),this._setHashByCurrentIndex(),this._setSizeByScreen(),setTimeout(function(){t.data.onMoveClass=!1,t.setArrow(),t.update(),t.data.oldIndex!==t.data.currentIndex&&t._fireEvent("change"),t.data.oldIndex=t.data.currentIndex},200)}},{key:"gotoSlide",value:function(t){this.e&&this.e.preventDefault&&this.e.preventDefault(),this.data.currentIndex=parseInt(t,10),this.data.currentIndex||(this.data.currentIndex=0),this._slideList()}},{key:"setArrow",value:function(){var t=this.groupItems(),e=t.length,a=this.data.currentIndex+1,o=this.data.currentIndex-1;this.data.showNextArrow=!1,this.data.showPrevArrow=!1,a!==e&&(this.data.next=a,this.data.showNextArrow=!0),-1!==o&&(this.data.prev=o,this.data.showPrevArrow=!0)}},{key:"beforeDrag",value:function(){if(this._isGestured(this.e))return void this.beforeGesture();if(this.isBeingZoomed=!1,this.data.scale)return void this.beforePhotoDrag();var t=this._getTouchPos();this.isSwipable=!0,this.dragStart=!0,this.firstPos=t,this.oldPos=t}},{key:"afterDrag",value:function(){var t=this.groupItems(),e=new Date,a=e.getTime(),o=this.tapSecond-a,i=0,r=0;return this.isSwipable=!1,this.onListMove=!1, | ||
this.oldPos&&(i=this.oldPos.x-this.firstPos.x,r=this.oldPos.y-this.firstPos.y),this.isBeingZoomed?void this.afterGesture():this.data.scale?void this.afterPhotoDrag():c.isSmartPhone()||0!==i||0!==r?Math.abs(o)<=500&&0===i&&0===r?(this.e.preventDefault(),void this.zoomPhoto()):(this.tapSecond=a,this._fireEvent("swipeend"),"horizontal"===this.moveDir&&(i>=this.data.swipeOffset&&0!==this.data.currentIndex?this.data.currentIndex-=1:i<=-this.data.swipeOffset&&this.data.currentIndex!==t.length-1&&(this.data.currentIndex+=1),this._slideList()),void("vertical"===this.moveDir&&(r>=this.data.swipeOffset?this.hidePhoto():(this.data.translateY=0,this._slideList())))):void this.zoomPhoto()}},{key:"onDrag",value:function(){if(this.e.preventDefault(),this._isGestured(this.e)&&!1===this.onListMove)return void this.onGesture();if(!this.isBeingZoomed){if(this.data.scale)return void this.onPhotoDrag();if(this.isSwipable){var t=this._getTouchPos(),e=t.x-this.oldPos.x,a=t.y-this.firstPos.y;this.dragStart&&(this._fireEvent("swipestart"),this.dragStart=!1,Math.abs(e)>Math.abs(a)?this.moveDir="horizontal":this.moveDir="vertical"),"horizontal"===this.moveDir?(this.pos.x+=e,this.data.translateX=this.pos.x):this.data.translateY=a,this.onListMove=!0,this.oldPos=t,this._listUpdate()}}}},{key:"zoomPhoto",value:function(){var t=this;this.data.hideUi=!0,this.data.scaleSize=this._getScaleBoarder(),this.data.photoPosX=0,this.data.photoPosY=0,this._photoUpdate(),setTimeout(function(){t.data.scale=!0,t._photoUpdate(),t._fireEvent("zoomin")},300)}},{key:"zoomOutPhoto",value:function(){this.data.scaleSize=1,this.isBeingZoomed=!1,this.data.hideUi=!1,this.data.scale=!1,this.data.photoPosX=0,this.data.photoPosY=0,this._photoUpdate(),this._fireEvent("zoomout")}},{key:"beforePhotoDrag",value:function(){var t=this._getTouchPos();this.photoSwipable=!0,this.data.photoPosX||(this.data.photoPosX=0),this.data.photoPosY||(this.data.photoPosY=0),this.oldPhotoPos=t,this.firstPhotoPos=t}},{key:"onPhotoDrag",value:function(){if(this.photoSwipable){this.e.preventDefault();var t=this._getTouchPos(),e=t.x-this.oldPhotoPos.x,a=t.y-this.oldPhotoPos.y,o=this._round(this.data.scaleSize*e,6),i=this._round(this.data.scaleSize*a,6);"number"==typeof o&&(this.data.photoPosX+=o,this.photoVX=o),"number"==typeof i&&(this.data.photoPosY+=i,this.photoVY=i),this.oldPhotoPos=t,this._photoUpdate()}}},{key:"afterPhotoDrag",value:function(){if(this.oldPhotoPos.x===this.firstPhotoPos.x&&this.photoSwipable)this.photoSwipable=!1,this.zoomOutPhoto();else{this.photoSwipable=!1;var t=this._getSelectedItem(),e=this._makeBound(t),a=this.data.swipeOffset*this.data.scaleSize,o=0,i=0;if(this.data.photoPosX>e.maxX?o=-1:this.data.photoPosX<e.minX&&(o=1),this.data.photoPosY>e.maxY?i=-1:this.data.photoPosY<e.minY&&(i=1),this.data.photoPosX-e.maxX>a&&0!==this.data.currentIndex)return void this.gotoSlide(this.data.prev);if(e.minX-this.data.photoPosX>a&&this.data.currentIndex+1!==this.data.total)return void this.gotoSlide(this.data.next);0===o&&0===i?(this.vx=this.photoVX/5,this.vy=this.photoVY/5):this._registerElasticForce(o,i)}}},{key:"beforeGesture",value:function(){this._fireEvent("gesturestart");var t=this._getGesturePos(this.e),e=this._getDistance(t[0],t[1]);this.isBeingZoomed=!0,this.oldDistance=e,this.data.scale=!0,this.e.preventDefault()}},{key:"onGesture",value:function(){var t=this._getGesturePos(this.e),e=this._getDistance(t[0],t[1]),a=(e-this.oldDistance)/100,o=this.data.scaleSize,i=this.data.photoPosX,r=this.data.photoPosY;this.isBeingZoomed=!0,this.data.scaleSize+=this._round(a,6),this.data.scaleSize<.2&&(this.data.scaleSize=.2),this.data.scaleSize<o&&(this.data.photoPosX=(1+this.data.scaleSize-o)*i,this.data.photoPosY=(1+this.data.scaleSize-o)*r),this.data.scaleSize<1||this.data.scaleSize>this._getScaleBoarder()?this.data.hideUi=!0:this.data.hideUi=!1,this.oldDistance=e,this.e.preventDefault(),this._photoUpdate()}},{key:"afterGesture",value:function(){this.data.scaleSize>this._getScaleBoarder()||(this.data.photoPosX=0,this.data.photoPosY=0,this.data.scale=!1,this.data.scaleSize=1,this.data.hideUi=!1,this._fireEvent("gestureend"),this._photoUpdate())}},{key:"_getForceAndTheta",value:function(t,e){return{force:Math.sqrt(t*t+e*e),theta:Math.atan2(e,t)}}},{key:"_getScaleBoarder",value:function(){var t=this._getSelectedItem(),e=this._getWindowWidth(),a=this._getWindowHeight();return c.isSmartPhone()?t.width>t.height?a/(t.height*t.scale):e/(t.width*t.scale):1/t.scale}},{key:"_makeBound",value:function(t){var e=t.width*t.scale*this.data.scaleSize,a=t.height*t.scale*this.data.scaleSize,o=void 0,i=void 0,r=void 0,s=void 0,n=this._getWindowWidth(),h=this._getWindowHeight();return n>e?(r=(n-e)/2,o=-1*r):(r=(e-n)/2,o=-1*r),h>a?(s=(h-a)/2,i=-1*s):(s=(a-h)/2,i=-1*s),{minX:this._round(o,6)*this.data.scaleSize,minY:this._round(i,6)*this.data.scaleSize,maxX:this._round(r,6)*this.data.scaleSize,maxY:this._round(s,6)*this.data.scaleSize}}},{key:"_registerElasticForce",value:function(t,e){var a=this,o=this._getSelectedItem(),i=this._makeBound(o);this.data.elastic=!0,1===t?this.data.photoPosX=i.minX:-1===t&&(this.data.photoPosX=i.maxX),1===e?this.data.photoPosY=i.minY:-1===e&&(this.data.photoPosY=i.maxY),this._photoUpdate(),setTimeout(function(){a.data.elastic=!1,a._photoUpdate()},300)}},{key:"_getSelectedItem",value:function(){var t=this.data,e=t.currentIndex;return t.group[t.currentGroup][e]}},{key:"_getUniqId",value:function(){return(Date.now().toString(36)+Math.random().toString(36).substr(2,5)).toUpperCase()}},{key:"_getDistance",value:function(t,e){var a=t.x-e.x,o=t.y-e.y;return Math.sqrt(a*a+o*o)}},{key:"_round",value:function(t,e){var a=Math.pow(10,e);return t*=a,t=Math.round(t),t/=a}},{key:"_isTouched",value:function(t){return!(!t||!t.touches)}},{key:"_isGestured",value:function(t){return!!(t&&t.touches&&t.touches.length>1)}},{key:"_isSmartPhone",value:function(){var t=navigator.userAgent;return t.indexOf("iPhone")>0||t.indexOf("iPad")>0||t.indexOf("ipod")>0||t.indexOf("Android")>0}},{key:"_calcGravity",value:function(t,e){(t>5||t<-5)&&(this.vx+=.05*t),!1!==this.data.verticalGravity&&(e>5||e<-5)&&(this.vy+=.05*e)}},{key:"_photoUpdate",value:function(){var t=this.data.classNames,e=this._getElementByQuery(".current"),a=e.querySelector("."+t.smartPhotoImg),o=this._getElementByQuery("."+t.smartPhotoNav),i=this._getElementByQuery("."+t.smartPhotoArrows),r=this.virtualPos(this.data.photoPosX),s=this.virtualPos(this.data.photoPosY),n=this.data.scaleSize,h="translate("+r+"px,"+s+"px) scale("+n+")";a.style.transform=h,this.data.scale?c.addClass(a,t.smartPhotoImgOnMove):c.removeClass(a,t.smartPhotoImgOnMove),this.data.elastic?c.addClass(a,t.smartPhotoImgElasticMove):c.removeClass(a,t.smartPhotoImgElasticMove),this.data.hideUi?(o&&o.setAttribute("aria-hidden","true"),i&&i.setAttribute("aria-hidden","true")):(o&&o.setAttribute("aria-hidden","false"),i&&i.setAttribute("aria-hidden","false"))}},{key:"_getWindowWidth",value:function(){return document.documentElement.clientWidth}},{key:"_getWindowHeight",value:function(){return window.innerHeight}},{key:"_listUpdate",value:function(){var t=this.data.classNames,e=this._getElementByQuery("."+t.smartPhotoList),a="translate("+this.data.translateX+"px,"+this.data.translateY+"px)";e.style.transform=a,this.data.onMoveClass?c.addClass(e,t.smartPhotoListOnMove):c.removeClass(e,t.smartPhotoListOnMove)}},{key:"_fireEvent",value:function(t){var e=this._getElementByClass(this.data.classNames.smartPhoto);c.triggerEvent(e,t)}},{key:"_doAnim",value:function(){if(!(this.isBeingZoomed||this.isSwipable||this.photoSwipable||this.data.elastic)&&this.data.scale){this.data.photoPosX+=this.vx,this.data.photoPosY+=this.vy;var t=this._getSelectedItem(),e=this._makeBound(t);this.data.photoPosX<e.minX?(this.data.photoPosX=e.minX,this.vx*=-.2):this.data.photoPosX>e.maxX&&(this.data.photoPosX=e.maxX,this.vx*=-.2),this.data.photoPosY<e.minY?(this.data.photoPosY=e.minY,this.vy*=-.2):this.data.photoPosY>e.maxY&&(this.data.photoPosY=e.maxY,this.vy*=-.2);var a=this._getForceAndTheta(this.vx,this.vy),o=a.force,i=a.theta;o-=this.data.registance,Math.abs(o)<.5||(this.vx=Math.cos(i)*o,this.vy=Math.sin(i)*o,this._photoUpdate())}}}]),e}(h.default);e.exports=u},{"../lib/util":7,"a-template":1}],6:[function(t,e,a){"use strict";e.exports=t("./core/")},{"./core/":5}],7:[function(t,e,a){"use strict";function o(t){t=t||{};for(var e=1;e<arguments.length;e++){var a=arguments[e];if(a)for(var r in a)a.hasOwnProperty(r)&&("object"===i(a[r])?t[r]=o(t[r],a[r]):t[r]=a[r])}return t}var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};e.exports.isSmartPhone=function(){var t=navigator.userAgent;return t.indexOf("iPhone")>0||t.indexOf("iPad")>0||t.indexOf("ipod")>0||t.indexOf("Android")>0},e.exports.extend=o,e.exports.triggerEvent=function(t,e,a){var o=void 0;window.CustomEvent?o=new CustomEvent(e,{cancelable:!0}):(o=document.createEvent("CustomEvent"),o.initCustomEvent(e,!1,!1,a)),t.dispatchEvent(o)},e.exports.parseQuery=function(t){for(var e,a,o,i=t.split("&"),r={},s=0,n=i.length;s<n;s++)e=i[s].split("="),void 0!==e[0]&&(a=e[0],o=void 0!==e[1]?e.slice(1).join("="):a,r[a]=decodeURIComponent(o));return r},e.exports.getViewPos=function(t){return{left:t.getBoundingClientRect().left,top:t.getBoundingClientRect().top}},e.exports.removeElement=function(t){t&&t.parentNode&&t.parentNode.removeChild(t)},e.exports.append=function(t,e){var a=new DOMParser,o=a.parseFromString(e,"text/html");t.appendChild(o.querySelector("body").childNodes[0])},e.exports.addClass=function(t,e){t.classList?t.classList.add(e):t.className+=" "+e},e.exports.removeClass=function(t,e){t.classList?t.classList.remove(e):t.className=t.className.replace(new RegExp("(^|\\b)"+e.split(" ").join("|")+"(\\b|$)","gi")," ")}},{}]},{},[6])(6)}); |
@@ -17,3 +17,3 @@ 'use strict'; | ||
var template = '<div class="\\{classNames.smartPhoto\\}"<!-- BEGIN hide:exist --> aria-hidden="true"<!-- END hide:exist --><!-- BEGIN hide:empty --> aria-hidden="false"<!-- END hide:empty --> role="dialog">\n\t<div class="\\{classNames.smartPhotoBody\\}">\n\t\t<div class="\\{classNames.smartPhotoInner\\}">\n\t\t\t <div class="\\{classNames.smartPhotoHeader\\}">\n\t\t\t\t\t<span class="\\{classNames.smartPhotoCount\\}">{currentIndex}[increment]/{total}</span>\n\t\t\t\t\t<span class="\\{classNames.smartPhotoCaption\\}" aria-live="polite" tabindex="-1"><!-- BEGIN groupItems:loop --><!-- \\BEGIN currentIndex:touch#{index} -->{caption}<!-- \\END currentIndex:touch#{index} --><!-- END groupItems:loop --></span>\n\t\t\t\t\t<button class="\\{classNames.smartPhotoDismiss\\}" data-action-click="hidePhoto()"><span class="smartphoto-sr-only">\\{message.closeDialog\\}</span></button>\n\t\t\t\t</div>\n\t\t\t\t<div class="\\{classNames.smartPhotoContent\\}"<!-- BEGIN isSmartPhone:exist --> data-action-touchstart="beforeDrag" data-action-touchmove="onDrag" data-action-touchend="afterDrag(false)"<!-- END isSmartPhone:exist -->>\n\t\t\t\t</div>\n\t\t\t\t<ul style="transform:translate({translateX}px,{translateY}px);" class="\\{classNames.smartPhotoList\\}<!-- BEGIN onMoveClass:exist --> \\{classNames.smartPhotoListOnMove\\}<!-- END onMoveClass:exist -->">\n\t\t\t\t\t<!-- BEGIN groupItems:loop -->\n\t\t\t\t\t<li style="transform:translate({translateX}px,{translateY}px);" class="<!-- \\BEGIN currentIndex:touch#{index} -->current<!-- \\END currentIndex:touch#{index} -->">\n\t\t\t\t\t\t<!-- BEGIN loaded:exist -->\n\t\t\t\t\t\t<div style="transform:translate({x}px,{y}px) scale({scale});" class="\\\\{classNames.smartPhotoImgWrap\\\\}"<!-- \\BEGIN isSmartPhone:empty --> data-action-mousemove="onDrag" data-action-mousedown="beforeDrag" data-action-mouseup="afterDrag"<!-- \\END isSmartPhone:empty --><!-- \\BEGIN isSmartPhone:exist --> data-action-touchstart="beforeDrag" data-action-touchmove="onDrag" data-action-touchend="afterDrag"<!-- \\END isSmartPhone:exist -->>\n\t\t\t\t\t\t\t<img style="<!-- \\BEGIN currentIndex:touch#{index} -->transform:translate(\\{photoPosX\\}[virtualPos]px,\\{photoPosY\\}[virtualPos]px) scale(\\{scaleSize\\});<!-- \\END currentIndex:touch#{index} -->" src="{src}" class="\\\\{classNames.smartPhotoImg\\\\}<!-- \\BEGIN scale:exist --> \\\\{classNames.smartPhotoImgOnMove\\\\}<!-- \\END scale:exist --><!-- \\BEGIN elastic:exist --> \\\\{classNames.smartPhotoImgElasticMove\\\\}<!-- \\END elastic:exist --><!-- \\BEGIN appear:exist --> active<!-- \\END appear:exist -->" ondragstart="return false;">\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<!-- END loaded:exist -->\n\t\t\t\t\t\t<!-- BEGIN loaded:empty -->\n\t\t\t\t\t\t<div class="\\\\{classNames.smartPhotoLoaderWrap\\\\}">\n\t\t\t\t\t\t\t<span class="\\\\{classNames.smartPhotoLoader\\\\}"></span>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<!-- END loaded:empty -->\n\t\t\t\t\t</li>\n\t\t\t\t\t<!-- END groupItems:loop -->\n\t\t\t\t</ul>\n\t\t\t\t<!-- BEGIN arrows:exist -->\n\t\t\t\t<ul class="\\{classNames.smartPhotoArrows\\}"<!-- BEGIN hideUi:exist --> aria-hidden="true"<!-- END hideUi:exist --><!-- BEGIN hideUi:exist --> aria-hidden="false"<!-- END hideUi:exist -->>\n\t\t\t\t\t<li class="\\{classNames.smartPhotoArrowLeft\\}"<!-- BEGIN showPrevArrow:empty --> aria-hidden="true"<!-- END showPrevArrow:empty -->><a href="#" data-action-click="gotoSlide({prev})" role="button"><span class="smartphoto-sr-only">\\{message.gotoPrevImage\\}</span></a></li>\n\t\t\t\t\t<li class="\\{classNames.smartPhotoArrowRight\\}"<!-- BEGIN showNextArrow:empty --> aria-hidden="true"<!-- END showNextArrow:empty -->><a href="#" data-action-click="gotoSlide({next})" role="button"><span class="smartphoto-sr-only">\\{message.gotoNextImage\\}</span></a></li>\n\t\t\t\t</ul>\n\t\t\t\t<!-- END arrows:exist -->\n\t\t\t\t<!-- BEGIN nav:exist -->\n\t\t\t\t<nav class="\\{classNames.smartPhotoNav\\}"<!-- BEGIN hideUi:exist --> aria-hidden="true"<!-- END hideUi:exist --><!-- BEGIN hideUi:exist --> aria-hidden="false"<!-- END hideUi:exist -->>\n\t\t\t\t\t<ul>\n\t\t\t\t\t\t<!-- BEGIN groupItems:loop -->\n\t\t\t\t\t\t<li><a href="#" data-action-click="gotoSlide({index})" class="<!-- \\BEGIN currentIndex:touch#{index} -->current<!-- \\END currentIndex:touch#{index} -->" style="background-image:url({src});" role="button"><span class="smartphoto-sr-only">go to {caption}</span></a></li>\n\t\t\t\t\t\t<!-- END groupItems:loop -->\n\t\t\t\t\t</ul>\n\t\t\t\t</nav>\n\t\t\t\t<!-- END nav:exist -->\n\t\t</div>\n\t\t<!-- BEGIN appearEffect:exist -->\n\t\t<img src=\\{appearEffect.img\\}\n\t\tclass="\\{classNames.smartPhotoImgClone\\}"\n\t\tstyle="width:\\{appearEffect.width\\}px;height:\\{appearEffect.height\\}px;transform:translate(\\{appearEffect.left\\}px,\\{appearEffect.top\\}px) scale(1)" />\n\t\t<!-- END appearEffect:exist -->\n\t</div>\n</div>\n'; | ||
var template = '<div class="\\{classNames.smartPhoto\\}"<!-- BEGIN hide:exist --> aria-hidden="true"<!-- END hide:exist --><!-- BEGIN hide:empty --> aria-hidden="false"<!-- END hide:empty --> role="dialog">\n\t<div class="\\{classNames.smartPhotoBody\\}">\n\t\t<div class="\\{classNames.smartPhotoInner\\}">\n\t\t\t <div class="\\{classNames.smartPhotoHeader\\}">\n\t\t\t\t\t<span class="\\{classNames.smartPhotoCount\\}">{currentIndex}[increment]/{total}</span>\n\t\t\t\t\t<span class="\\{classNames.smartPhotoCaption\\}" aria-live="polite" tabindex="-1"><!-- BEGIN groupItems:loop --><!-- \\BEGIN currentIndex:touch#{index} -->{caption}<!-- \\END currentIndex:touch#{index} --><!-- END groupItems:loop --></span>\n\t\t\t\t\t<button class="\\{classNames.smartPhotoDismiss\\}" data-action-click="hidePhoto()"><span class="smartphoto-sr-only">\\{message.closeDialog\\}</span></button>\n\t\t\t\t</div>\n\t\t\t\t<div class="\\{classNames.smartPhotoContent\\}"<!-- BEGIN isSmartPhone:exist --> data-action-touchstart="beforeDrag" data-action-touchmove="onDrag" data-action-touchend="afterDrag(false)"<!-- END isSmartPhone:exist -->>\n\t\t\t\t</div>\n\t\t\t\t<ul style="transform:translate({translateX}px,{translateY}px);" class="\\{classNames.smartPhotoList\\}<!-- BEGIN onMoveClass:exist --> \\{classNames.smartPhotoListOnMove\\}<!-- END onMoveClass:exist -->">\n\t\t\t\t\t<!-- BEGIN groupItems:loop -->\n\t\t\t\t\t<li style="transform:translate({translateX}px,{translateY}px);" class="<!-- \\BEGIN currentIndex:touch#{index} -->current<!-- \\END currentIndex:touch#{index} -->">\n\t\t\t\t\t\t<!-- BEGIN processed:exist -->\n\t\t\t\t\t\t<div style="transform:translate({x}px,{y}px) scale({scale});" class="\\\\{classNames.smartPhotoImgWrap\\\\}"<!-- \\BEGIN isSmartPhone:empty --> data-action-mousemove="onDrag" data-action-mousedown="beforeDrag" data-action-mouseup="afterDrag"<!-- \\END isSmartPhone:empty --><!-- \\BEGIN isSmartPhone:exist --> data-action-touchstart="beforeDrag" data-action-touchmove="onDrag" data-action-touchend="afterDrag"<!-- \\END isSmartPhone:exist -->>\n\t\t\t\t\t\t\t<img style="<!-- \\BEGIN currentIndex:touch#{index} -->transform:translate(\\{photoPosX\\}[virtualPos]px,\\{photoPosY\\}[virtualPos]px) scale(\\{scaleSize\\});<!-- \\END currentIndex:touch#{index} -->" src="{src}" class="\\\\{classNames.smartPhotoImg\\\\}<!-- \\BEGIN scale:exist --> \\\\{classNames.smartPhotoImgOnMove\\\\}<!-- \\END scale:exist --><!-- \\BEGIN elastic:exist --> \\\\{classNames.smartPhotoImgElasticMove\\\\}<!-- \\END elastic:exist --><!-- \\BEGIN appear:exist --> active<!-- \\END appear:exist -->" ondragstart="return false;">\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<!-- END processed:exist -->\n\t\t\t\t\t\t<!-- BEGIN processed:empty -->\n\t\t\t\t\t\t<div class="\\\\{classNames.smartPhotoLoaderWrap\\\\}">\n\t\t\t\t\t\t\t<span class="\\\\{classNames.smartPhotoLoader\\\\}"></span>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<!-- END processed:empty -->\n\t\t\t\t\t</li>\n\t\t\t\t\t<!-- END groupItems:loop -->\n\t\t\t\t</ul>\n\t\t\t\t<!-- BEGIN arrows:exist -->\n\t\t\t\t<ul class="\\{classNames.smartPhotoArrows\\}"<!-- BEGIN hideUi:exist --> aria-hidden="true"<!-- END hideUi:exist --><!-- BEGIN hideUi:exist --> aria-hidden="false"<!-- END hideUi:exist -->>\n\t\t\t\t\t<li class="\\{classNames.smartPhotoArrowLeft\\}"<!-- BEGIN showPrevArrow:empty --> aria-hidden="true"<!-- END showPrevArrow:empty -->><a href="#" data-action-click="gotoSlide({prev})" role="button"><span class="smartphoto-sr-only">\\{message.gotoPrevImage\\}</span></a></li>\n\t\t\t\t\t<li class="\\{classNames.smartPhotoArrowRight\\}"<!-- BEGIN showNextArrow:empty --> aria-hidden="true"<!-- END showNextArrow:empty -->><a href="#" data-action-click="gotoSlide({next})" role="button"><span class="smartphoto-sr-only">\\{message.gotoNextImage\\}</span></a></li>\n\t\t\t\t</ul>\n\t\t\t\t<!-- END arrows:exist -->\n\t\t\t\t<!-- BEGIN nav:exist -->\n\t\t\t\t<nav class="\\{classNames.smartPhotoNav\\}"<!-- BEGIN hideUi:exist --> aria-hidden="true"<!-- END hideUi:exist --><!-- BEGIN hideUi:exist --> aria-hidden="false"<!-- END hideUi:exist -->>\n\t\t\t\t\t<ul>\n\t\t\t\t\t\t<!-- BEGIN groupItems:loop -->\n\t\t\t\t\t\t<li><a href="#" data-action-click="gotoSlide({index})" class="<!-- \\BEGIN currentIndex:touch#{index} -->current<!-- \\END currentIndex:touch#{index} -->" style="background-image:url({src});" role="button"><span class="smartphoto-sr-only">go to {caption}</span></a></li>\n\t\t\t\t\t\t<!-- END groupItems:loop -->\n\t\t\t\t\t</ul>\n\t\t\t\t</nav>\n\t\t\t\t<!-- END nav:exist -->\n\t\t</div>\n\t\t<!-- BEGIN appearEffect:exist -->\n\t\t<img src=\\{appearEffect.img\\}\n\t\tclass="\\{classNames.smartPhotoImgClone\\}"\n\t\tstyle="width:\\{appearEffect.width\\}px;height:\\{appearEffect.height\\}px;transform:translate(\\{appearEffect.left\\}px,\\{appearEffect.top\\}px) scale(1)" />\n\t\t<!-- END appearEffect:exist -->\n\t</div>\n</div>\n'; | ||
@@ -266,2 +266,3 @@ | ||
loaded: false, | ||
processed: false, | ||
element: element | ||
@@ -290,5 +291,5 @@ }; | ||
_this4._loadItem(currentItem).then(function () { | ||
_this4.data.appear = true; | ||
_this4._initPhoto(); | ||
_this4.addAppearEffect(element); | ||
_this4.clicked = true; | ||
_this4._initPhoto(); | ||
_this4.update(); | ||
@@ -324,3 +325,5 @@ _this4._fireEvent('open'); | ||
this.execEffect().then(function () { | ||
_this5.replaceEffectWithImg(); | ||
_this5.data.appearEffect = null; | ||
_this5.data.appear = true; | ||
_this5.update(); | ||
}); | ||
@@ -338,25 +341,19 @@ } | ||
value: function execEffect() { | ||
var appearEffect = this.data.appearEffect; | ||
var classNames = this.data.classNames; | ||
var effect = document.querySelector('[data-id="' + this.id + '"] .' + classNames.smartPhotoImgClone); | ||
var _this6 = this; | ||
return new Promise(function (resolve) { | ||
var appearEffect = _this6.data.appearEffect; | ||
var classNames = _this6.data.classNames; | ||
var effect = _this6._getElementByClass(classNames.smartPhotoImgClone); | ||
var handler = function handler() { | ||
effect.removeEventListener('transitionend', handler, true); | ||
resolve(); | ||
}; | ||
effect.addEventListener('transitionend', handler, true); | ||
setTimeout(function () { | ||
effect.style.transition = 'all .3s ease-out'; | ||
effect.style.transform = 'translate(' + appearEffect.afterX + 'px, ' + appearEffect.afterY + 'px) scale(' + appearEffect.scale + ')'; | ||
resolve(); | ||
}, 30); | ||
}, 10); | ||
}); | ||
} | ||
}, { | ||
key: 'replaceEffectWithImg', | ||
value: function replaceEffectWithImg() { | ||
var _this6 = this; | ||
setTimeout(function () { | ||
_this6.data.appearEffect = null; | ||
_this6.data.appear = true; | ||
_this6.update(); | ||
}, 300); | ||
} | ||
}, { | ||
key: 'addAppearEffect', | ||
@@ -550,2 +547,6 @@ value: function addAppearEffect(element) { | ||
items.forEach(function (item) { | ||
if (!item.loaded) { | ||
return; | ||
} | ||
item.processed = true; | ||
item.scale = screenY / item.height; | ||
@@ -552,0 +553,0 @@ item.x = (item.scale - 1) / 2 * item.width + (windowX - item.width * item.scale) / 2; |
{ | ||
"name": "smartphoto", | ||
"version": "0.5.7", | ||
"version": "0.5.8", | ||
"description": "smartphoto", | ||
@@ -5,0 +5,0 @@ "homepage": "http://developer.a-blogcms.jp", |
# SmartPhoto | ||
[![npm version](https://badge.fury.io/js/smartphoto.svg)](https://badge.fury.io/js/smartphoto) | ||
[![CircleCI](https://circleci.com/gh/appleple/SmartPhoto/tree/master.svg?style=shield)](https://circleci.com/gh/appleple/SmartPhoto/tree/master) | ||
[![npm download](http://img.shields.io/npm/dm/smartphoto.svg)](https://www.npmjs.com/package/smartphoto) | ||
[![GitHub license](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://raw.githubusercontent.com/appleple/SmartPhoto/master/LICENSE) | ||
@@ -139,2 +140,14 @@ | ||
```js | ||
// when the modal opened | ||
photo.on('open',function(){ | ||
console.log('open'); | ||
}); | ||
// when the modal closed | ||
photo.on('close',function(){ | ||
console.log('close'); | ||
}); | ||
// when all images are loaded | ||
photo.on('loadall',function(){ | ||
console.log('loadall'); | ||
}); | ||
// when photo is changed | ||
@@ -144,18 +157,18 @@ photo.on('change',function(){ | ||
}); | ||
// when the modal is closed | ||
photo.on('close',function(){ | ||
console.log('close'); | ||
}); | ||
// when swipe start | ||
// when swipe started | ||
photo.on('swipestart',function(){ | ||
console.log('swipestart'); | ||
}); | ||
// when swipe end | ||
// when swipe ended | ||
photo.on('swipeend',function(){ | ||
console.log('swipeend'); | ||
}); | ||
// when all images are loaded | ||
photo.on('loadall',function(){ | ||
console.log('loadall'); | ||
// when zoomed in | ||
photo.on('zoomin',function(){ | ||
console.log('zoomin'); | ||
}); | ||
// when zoomed out | ||
photo.on('zoomout',function(){ | ||
console.log('zoomout'); | ||
}); | ||
``` | ||
@@ -162,0 +175,0 @@ |
@@ -231,2 +231,3 @@ import aTemplate from 'a-template'; | ||
loaded: false, | ||
processed: false, | ||
element | ||
@@ -255,5 +256,5 @@ }; | ||
this._loadItem(currentItem).then(() => { | ||
this.data.appear = true; | ||
this._initPhoto(); | ||
this.addAppearEffect(element); | ||
this.clicked = true; | ||
this._initPhoto(); | ||
this.update(); | ||
@@ -285,3 +286,5 @@ this._fireEvent('open'); | ||
this.execEffect().then(() => { | ||
this.replaceEffectWithImg(); | ||
this.data.appearEffect = null; | ||
this.data.appear = true; | ||
this.update(); | ||
}); | ||
@@ -298,22 +301,17 @@ } | ||
execEffect() { | ||
const appearEffect = this.data.appearEffect; | ||
const classNames = this.data.classNames; | ||
const effect = document.querySelector(`[data-id="${this.id}"] .${classNames.smartPhotoImgClone}`); | ||
return new Promise((resolve) => { | ||
const appearEffect = this.data.appearEffect; | ||
const classNames = this.data.classNames; | ||
const effect = this._getElementByClass(classNames.smartPhotoImgClone); | ||
const handler = () => { | ||
effect.removeEventListener('transitionend', handler, true); | ||
resolve(); | ||
}; | ||
effect.addEventListener('transitionend', handler, true); | ||
setTimeout(() => { | ||
effect.style.transition = 'all .3s ease-out'; | ||
effect.style.transform = `translate(${appearEffect.afterX}px, ${appearEffect.afterY}px) scale(${appearEffect.scale})`; | ||
resolve(); | ||
}, 30); | ||
}, 10); | ||
}); | ||
} | ||
replaceEffectWithImg() { | ||
setTimeout(() => { | ||
this.data.appearEffect = null; | ||
this.data.appear = true; | ||
this.update(); | ||
}, 300); | ||
} | ||
addAppearEffect(element) { | ||
@@ -491,2 +489,6 @@ const img = element.querySelector('img'); | ||
items.forEach((item) => { | ||
if (!item.loaded) { | ||
return; | ||
} | ||
item.processed = true; | ||
item.scale = screenY / item.height; | ||
@@ -493,0 +495,0 @@ item.x = (item.scale - 1) / 2 * item.width + (windowX - (item.width * item.scale)) / 2; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
7311254
8574
211