diff --git a/examples/history-push-state.html b/examples/history-push-state.html new file mode 100644 index 0000000..0f39eb4 --- /dev/null +++ b/examples/history-push-state.html @@ -0,0 +1,58 @@ + + + + + + + + SmartPhoto.js + + + +
+

SmartPhoto.js

+
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+
+ + + + diff --git a/js/jquery-smartphoto.js b/js/jquery-smartphoto.js index 1d5f587..cd0ec51 100644 --- a/js/jquery-smartphoto.js +++ b/js/jquery-smartphoto.js @@ -11,20 +11,17 @@ * a-template: * license: MIT (http://opensource.org/licenses/MIT) * author: steelydylan - * maintainers: appleple , steelydylan * version: 0.5.1 * * array.prototype.find: * license: MIT (http://opensource.org/licenses/MIT) * author: Paul Miller - * maintainers: ljharb , paulmillr * contributors: Duncan Hall * homepage: https://github.com/paulmillr/Array.prototype.find#readme * version: 2.0.4 * * custom-event-polyfill: * license: MIT (http://opensource.org/licenses/MIT) - * maintainers: krambuhl * contributors: Frank Panetta, Mikhail Reenko , Joscha Feth * homepage: https://github.com/krambuhl/custom-event-polyfill#readme * version: 0.3.0 @@ -32,14 +29,12 @@ * define-properties: * license: MIT (http://opensource.org/licenses/MIT) * author: Jordan Harband - * maintainers: ljharb * homepage: https://github.com/ljharb/define-properties#readme * version: 1.1.2 * * es-abstract: * license: MIT (http://opensource.org/licenses/MIT) * author: Jordan Harband - * maintainers: ljharb * contributors: Jordan Harband * homepage: https://github.com/ljharb/es-abstract#readme * version: 1.10.0 @@ -47,29 +42,25 @@ * es-to-primitive: * license: MIT (http://opensource.org/licenses/MIT) * author: Jordan Harband - * maintainers: ljharb * homepage: https://github.com/ljharb/es-to-primitive#readme * version: 1.1.1 * * es6-promise-polyfill: * license: MIT (http://opensource.org/licenses/MIT) * author: Roman Dvornov - * maintainers: lahmatiy * homepage: https://github.com/lahmatiy/es6-promise-polyfill#readme * version: 1.2.0 * * foreach: * license: MIT (http://opensource.org/licenses/MIT) * author: Manuel Stofer - * maintainers: manuelstofer * contributors: Manuel Stofer, Jordan Harband - * homepage: https://github.com/manuelstofer/foreach + * homepage: https://github.com/manuelstofer/foreach#readme * version: 2.0.5 * * function-bind: * license: MIT (http://opensource.org/licenses/MIT) * author: Raynos - * maintainers: raynos , ljharb * contributors: Raynos, Jordan Harband * homepage: https://github.com/Raynos/function-bind * version: 1.1.1 @@ -77,14 +68,12 @@ * has: * licenses: MIT (http://opensource.org/licenses/MIT) * author: Thiago de Arruda - * maintainers: tarruda * homepage: https://github.com/tarruda/has * version: 1.0.1 * * is-callable: * license: MIT (http://opensource.org/licenses/MIT) * author: Jordan Harband - * maintainers: ljharb * contributors: Jordan Harband * homepage: https://github.com/ljharb/is-callable#readme * version: 1.1.3 @@ -92,35 +81,30 @@ * is-date-object: * license: MIT (http://opensource.org/licenses/MIT) * author: Jordan Harband - * maintainers: ljharb * homepage: https://github.com/ljharb/is-date-object#readme * version: 1.0.1 * * is-regex: * license: MIT (http://opensource.org/licenses/MIT) * author: Jordan Harband - * maintainers: ljharb * homepage: https://github.com/ljharb/is-regex * version: 1.0.4 * * is-symbol: * license: MIT (http://opensource.org/licenses/MIT) * author: Jordan Harband - * maintainers: ljharb - * homepage: https://github.com/ljharb/is-symbol + * homepage: https://github.com/ljharb/is-symbol#readme * version: 1.0.1 * * morphdom: * license: MIT (http://opensource.org/licenses/MIT) * author: Patrick Steele-Idem - * maintainers: mlrawlings , pnidem * homepage: https://github.com/patrick-steele-idem/morphdom#readme * version: 2.3.3 * * object-keys: * license: MIT (http://opensource.org/licenses/MIT) * author: Jordan Harband - * maintainers: ljharb * contributors: Jordan Harband , Raynos , Nathan Rajlich , Ivan Starkov , Gary Katsevman * homepage: https://github.com/ljharb/object-keys#readme * version: 1.0.11 @@ -3414,6 +3398,7 @@ var defaults = { verticalGravity: false, useOrientationApi: false, useHistoryApi: true, + historyApiMethod: 'replace', swipeTopToClose: false, swipeBottomToClose: true, swipeOffset: 100, @@ -3477,6 +3462,45 @@ var SmartPhoto = function (_ATemplate) { _this._doAnim(); }, _this.data.forceInterval); + // IF history API is enabled + // > setup history event listener + if (_this.data.useHistoryApi && _this.data.historyApiMethod === 'push') { + + window.onpopstate = function (event) { + + // if state is not set - the gallery was hidden in this history state + if (!event || !event.state || event.state.group === void 0 || event.state.index === void 0) { + _this.hidePhoto(); + return; + } + + // geting photo info from state object + _this.data.currentGroup = event.state.group; + _this.data.currentIndex = event.state.index; + var currentItem = _this._getSelectedItem(); + + if (currentItem.loaded) { + _this._initPhoto(); + _this.data.appear = true; + _this.clicked = true; + _this.update(); + body.style.overflow = 'hidden'; + _this._fireEvent('open'); + } else { + _this._loadItem(currentItem).then(function () { + _this._initPhoto(); + _this.data.appear = true; + _this.clicked = true; + _this.update(); + body.style.overflow = 'hidden'; + _this._fireEvent('open'); + }); + } + + _this.gotoSlide(event.state.index, true); // <- don't update history + }; + } + if (!_this.data.isSmartPhone) { window.addEventListener('resize', function () { if (!_this.groupItems()) { @@ -3788,7 +3812,7 @@ var SmartPhoto = function (_ATemplate) { var scrollY = window.scrollY; var body = document.querySelector('body'); if (location.hash) { - this._setHash(''); + this._setHash(); } window.scroll(scrollX, scrollY); this._doHideEffect(dir).then(function () { @@ -3873,20 +3897,40 @@ var SmartPhoto = function (_ATemplate) { var items = this.groupItems(); var id = items[this.data.currentIndex].id; var group = this.data.currentGroup; - var hash = 'group=' + group + '&photo=' + id; - this._setHash(hash); + this._setHash(group, id, this.data.currentIndex); window.scroll(scrollX, scrollY); } }, { key: '_setHash', - value: function _setHash(hash) { + value: function _setHash(group, id, index) { + if (!(window.history && window.history.pushState) || !this.data.useHistoryApi) { return; } - if (hash) { - window.history.replaceState(null, null, '' + location.pathname + location.search + '#' + hash); - } else { - window.history.replaceState(null, null, '' + location.pathname + location.search); + + // if the displayed image has not changed + // > don't change history + if (this.data.oldIndex === index) { + return; + } + + var newUrl = '' + location.pathname + location.search, + newState = void 0; + + // if `group` od `id` are not set + // > don't construct new state + if (group !== void 0 && id !== void 0) { + newUrl += '#group=' + group + '&photo=' + id; + newState = { group: group, id: id, index: index }; + } + + switch (this.data.historyApiMethod) { + case 'push': + window.history.pushState(newState, null, newUrl); + break; + case 'replace': + default: + window.history.replaceState(newState, null, newUrl); } } }, { @@ -3951,7 +3995,7 @@ var SmartPhoto = function (_ATemplate) { } }, { key: '_slideList', - value: function _slideList() { + value: function _slideList(skipHistory) { var _this10 = this; this.data.scaleSize = 1; @@ -3962,7 +4006,11 @@ var SmartPhoto = function (_ATemplate) { this.data.photoPosY = 0; this.data.onMoveClass = true; this._setPosByCurrentIndex(); - this._setHashByCurrentIndex(); + + if (!skipHistory) { + this._setHashByCurrentIndex(); + } + this._setSizeByScreen(); setTimeout(function () { _this10.data.onMoveClass = false; @@ -3976,7 +4024,7 @@ var SmartPhoto = function (_ATemplate) { } }, { key: 'gotoSlide', - value: function gotoSlide(index) { + value: function gotoSlide(index, skipHistory) { if (this.e && this.e.preventDefault) { this.e.preventDefault(); } @@ -3984,7 +4032,7 @@ var SmartPhoto = function (_ATemplate) { if (!this.data.currentIndex) { this.data.currentIndex = 0; } - this._slideList(); + this._slideList(skipHistory); } }, { key: 'setArrow', diff --git a/js/jquery-smartphoto.min.js b/js/jquery-smartphoto.min.js index 94574f4..09c246b 100644 --- a/js/jquery-smartphoto.min.js +++ b/js/jquery-smartphoto.min.js @@ -11,20 +11,17 @@ * a-template: * license: MIT (http://opensource.org/licenses/MIT) * author: steelydylan - * maintainers: appleple , steelydylan * version: 0.5.1 * * array.prototype.find: * license: MIT (http://opensource.org/licenses/MIT) * author: Paul Miller - * maintainers: ljharb , paulmillr * contributors: Duncan Hall * homepage: https://github.com/paulmillr/Array.prototype.find#readme * version: 2.0.4 * * custom-event-polyfill: * license: MIT (http://opensource.org/licenses/MIT) - * maintainers: krambuhl * contributors: Frank Panetta, Mikhail Reenko , Joscha Feth * homepage: https://github.com/krambuhl/custom-event-polyfill#readme * version: 0.3.0 @@ -32,14 +29,12 @@ * define-properties: * license: MIT (http://opensource.org/licenses/MIT) * author: Jordan Harband - * maintainers: ljharb * homepage: https://github.com/ljharb/define-properties#readme * version: 1.1.2 * * es-abstract: * license: MIT (http://opensource.org/licenses/MIT) * author: Jordan Harband - * maintainers: ljharb * contributors: Jordan Harband * homepage: https://github.com/ljharb/es-abstract#readme * version: 1.10.0 @@ -47,29 +42,25 @@ * es-to-primitive: * license: MIT (http://opensource.org/licenses/MIT) * author: Jordan Harband - * maintainers: ljharb * homepage: https://github.com/ljharb/es-to-primitive#readme * version: 1.1.1 * * es6-promise-polyfill: * license: MIT (http://opensource.org/licenses/MIT) * author: Roman Dvornov - * maintainers: lahmatiy * homepage: https://github.com/lahmatiy/es6-promise-polyfill#readme * version: 1.2.0 * * foreach: * license: MIT (http://opensource.org/licenses/MIT) * author: Manuel Stofer - * maintainers: manuelstofer * contributors: Manuel Stofer, Jordan Harband - * homepage: https://github.com/manuelstofer/foreach + * homepage: https://github.com/manuelstofer/foreach#readme * version: 2.0.5 * * function-bind: * license: MIT (http://opensource.org/licenses/MIT) * author: Raynos - * maintainers: raynos , ljharb * contributors: Raynos, Jordan Harband * homepage: https://github.com/Raynos/function-bind * version: 1.1.1 @@ -77,14 +68,12 @@ * has: * licenses: MIT (http://opensource.org/licenses/MIT) * author: Thiago de Arruda - * maintainers: tarruda * homepage: https://github.com/tarruda/has * version: 1.0.1 * * is-callable: * license: MIT (http://opensource.org/licenses/MIT) * author: Jordan Harband - * maintainers: ljharb * contributors: Jordan Harband * homepage: https://github.com/ljharb/is-callable#readme * version: 1.1.3 @@ -92,41 +81,36 @@ * is-date-object: * license: MIT (http://opensource.org/licenses/MIT) * author: Jordan Harband - * maintainers: ljharb * homepage: https://github.com/ljharb/is-date-object#readme * version: 1.0.1 * * is-regex: * license: MIT (http://opensource.org/licenses/MIT) * author: Jordan Harband - * maintainers: ljharb * homepage: https://github.com/ljharb/is-regex * version: 1.0.4 * * is-symbol: * license: MIT (http://opensource.org/licenses/MIT) * author: Jordan Harband - * maintainers: ljharb - * homepage: https://github.com/ljharb/is-symbol + * homepage: https://github.com/ljharb/is-symbol#readme * version: 1.0.1 * * morphdom: * license: MIT (http://opensource.org/licenses/MIT) * author: Patrick Steele-Idem - * maintainers: mlrawlings , pnidem * homepage: https://github.com/patrick-steele-idem/morphdom#readme * version: 2.3.3 * * object-keys: * license: MIT (http://opensource.org/licenses/MIT) * author: Jordan Harband - * maintainers: ljharb * contributors: Jordan Harband , Raynos , Nathan Rajlich , Ivan Starkov , Gary Katsevman * homepage: https://github.com/ljharb/object-keys#readme * version: 1.0.11 * * This header is generated by licensify (https://github.com/twada/licensify) */ -!function(){function t(e,r,o){function n(a,s){if(!r[a]){if(!e[a]){var c="function"==typeof require&&require;if(!s&&c)return c(a,!0);if(i)return i(a,!0);var u=new Error("Cannot find module '"+a+"'");throw u.code="MODULE_NOT_FOUND",u}var l=r[a]={exports:{}};e[a][0].call(l.exports,function(t){var r=e[a][1][t];return n(r||t)},l,l.exports,t,e,r,o)}return r[a].exports}for(var i="function"==typeof require&&require,a=0;a1;)r=r[o.shift()];r[o.shift()]=e}},{key:"removeDataByString",value:function(t){for(var e=this.data,r=t.split(".");r.length>1;)e=e[r.shift()];var o=r.shift();o.match(/^\d+$/)?e.splice(Number(o),1):delete e[o]}},{key:"resolveBlock",value:function(t,e,r){var o=this,n=t.match(//g),i=t.match(//g),a=t.match(//g),s=t.match(//g);if(n)for(var c=0,u=n.length;c/g;return t=t.replace(e,function(t,e){return(0,a.selector)("#"+e).innerHTML})}},{key:"resolveWith",value:function(t){var e=/(([\n\r\t]|.)*?)/g;return t=t.replace(e,function(t,e){return t=t.replace(/data\-bind=['"](.*?)['"]/g,"data-bind='"+e+".$1'")})}},{key:"resolveLoop",value:function(t){var e=/(([\n\r\t]|.)*?)/g,r=this;return t=t.replace(e,function(t,e,o){var n=r.getDataByString(e),i=[];i="function"==typeof n?n.apply(r):n;var a="";if(i instanceof Array)for(var s=0,c=i.length;s(([\n\r\t]|.)*?)/g;return!!t.match(e)}},{key:"getHtml",value:function(t,e){var r=c(this.atemplate,function(e){return e.id===t}),o="";if(r&&r.html&&(o=r.html),e&&(o=t),!o)return"";var n=this.data;for(o=this.resolveInclude(o),o=this.resolveWith(o);this.hasLoop(o);)o=this.resolveLoop(o);return o=this.resolveBlock(o,n),o=o.replace(/\\([^\\])/g,"$1"),o=this.resolveAbsBlock(o),o.replace(/^([\t ])*\n/gm,"")}},{key:"update",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"html",r=arguments[1],o=this.templates;this.beforeUpdated&&this.beforeUpdated();for(var n=0,i=o.length;n"+h+"");else(0,a.selector)(l).insertAdjacentHTML("afterend",'
'),"text"===e?(0,a.selector)("[data-id='"+u+"']").innerText=h:(0,a.selector)("[data-id='"+u+"']").innerHTML=h;var m=c(t.atemplate,function(t){return t.id===u});m.binded||(m.binded=!0,t.addDataBind((0,a.selector)("[data-id='"+u+"']")),t.addActionBind((0,a.selector)("[data-id='"+u+"']")))}(n);return this.updateBindingData(r),this.onUpdated&&this.onUpdated(r),this}},{key:"updateBindingData",value:function(t){for(var e=this,r=this.templates,o=0,n=r.length;o1?r-1:0),n=1;n1;)e=e[r.shift()];var o=r.shift();return o.match(/^\d+$/)?e.splice(Number(o),1):delete e[o],this}}]),t}();r.default=h,e.exports=r.default},{"./util":2,"array.prototype.find":4,morphdom:30}],2:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=r.matches=function(t,e){for(var r=(t.document||t.ownerDocument).querySelectorAll(e),o=r.length;--o>=0&&r.item(o)!==t;);return o>-1},n=(r.selector=function(t){return document.querySelector(t)},r.findAncestor=function(t,e){if("function"==typeof t.closest)return t.closest(e)||null;for(;t&&t!==document;){if(o(t,e))return t;t=t.parentElement}return null});r.on=function(t,e,r,o){r.split(" ").forEach(function(r){t.addEventListener(r,function(t){var r=(t.target,n(t.target,e));r&&(t.delegateTarget=r,o(t))})})}},{}],3:[function(t,e,r){"use strict";var o=t("es-abstract/es6");e.exports=function(t){var e=o.ToObject(this),r=o.ToInteger(o.ToLength(e.length));if(!o.IsCallable(t))throw new TypeError("Array#find: predicate must be a function");if(0!==r)for(var n,i=arguments[1],a=0;a2?arguments[2]:{},a=o(e);i&&(a=a.concat(Object.getOwnPropertySymbols(e))),n(a,function(o){u(t,o,e[o],r[o])})};l.supportsDescriptors=!!c,e.exports=l},{foreach:22,"object-keys":31}],9:[function(t,e,r){"use strict";var o=t("has"),n=t("es-to-primitive/es6"),i=Object.prototype.toString,a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator,s=t("./helpers/isNaN"),c=t("./helpers/isFinite"),u=Number.MAX_SAFE_INTEGER||Math.pow(2,53)-1,l=t("./helpers/assign"),h=t("./helpers/sign"),d=t("./helpers/mod"),f=t("./helpers/isPrimitive"),p=parseInt,y=t("function-bind"),m=y.call(Function.call,Array.prototype.slice),v=y.call(Function.call,String.prototype.slice),g=y.call(Function.call,RegExp.prototype.test,/^0b[01]+$/i),b=y.call(Function.call,RegExp.prototype.test,/^0o[0-7]+$/i),w=y.call(Function.call,RegExp.prototype.exec),x=["…","​","￾"].join(""),P=new RegExp("["+x+"]","g"),E=y.call(Function.call,RegExp.prototype.test,P),S=/^[-+]0x[0-9a-f]+$/i,I=y.call(Function.call,RegExp.prototype.test,S),N=["\t\n\v\f\r   ᠎    ","          \u2028","\u2029\ufeff"].join(""),T=new RegExp("(^["+N+"]+)|(["+N+"]+$)","g"),_=y.call(Function.call,String.prototype.replace),O=function(t){return _(t,T,"")},D=t("./es5"),j=t("is-regex"),A=l(l({},D),{Call:function(t,e){var r=arguments.length>2?arguments[2]:[];if(!this.IsCallable(t))throw new TypeError(t+" is not a function");return t.apply(e,r)},ToPrimitive:n,ToNumber:function(t){var e=f(t)?t:n(t,Number);if("symbol"==typeof e)throw new TypeError("Cannot convert a Symbol value to a number");if("string"==typeof e){if(g(e))return this.ToNumber(p(v(e,2),2));if(b(e))return this.ToNumber(p(v(e,2),8));if(E(e)||I(e))return NaN;var r=O(e);if(r!==e)return this.ToNumber(r)}return Number(e)},ToInt16:function(t){var e=this.ToUint16(t);return e>=32768?e-65536:e},ToInt8:function(t){var e=this.ToUint8(t);return e>=128?e-256:e},ToUint8:function(t){var e=this.ToNumber(t);if(s(e)||0===e||!c(e))return 0;var r=h(e)*Math.floor(Math.abs(e));return d(r,256)},ToUint8Clamp:function(t){var e=this.ToNumber(t);if(s(e)||e<=0)return 0;if(e>=255)return 255;var r=Math.floor(t);return r+.5u?u:e},CanonicalNumericIndexString:function(t){if("[object String]"!==i.call(t))throw new TypeError("must be a string");if("-0"===t)return-0;var e=this.ToNumber(t);return this.SameValue(this.ToString(e),t)?e:void 0},RequireObjectCoercible:D.CheckObjectCoercible,IsArray:Array.isArray||function(t){return"[object Array]"===i.call(t)},IsConstructor:function(t){return"function"==typeof t&&!!t.prototype},IsExtensible:function(t){return!Object.preventExtensions||!f(t)&&Object.isExtensible(t)},IsInteger:function(t){if("number"!=typeof t||s(t)||!c(t))return!1;var e=Math.abs(t);return Math.floor(e)===e},IsPropertyKey:function(t){return"string"==typeof t||"symbol"==typeof t},IsRegExp:function(t){if(!t||"object"!=typeof t)return!1;if(a){var e=t[Symbol.match];if(void 0!==e)return D.ToBoolean(e)}return j(t)},SameValueZero:function(t,e){return t===e||s(t)&&s(e)},GetV:function(t,e){if(!this.IsPropertyKey(e))throw new TypeError("Assertion failed: IsPropertyKey(P) is not true");return this.ToObject(t)[e]},GetMethod:function(t,e){if(!this.IsPropertyKey(e))throw new TypeError("Assertion failed: IsPropertyKey(P) is not true");var r=this.GetV(t,e);if(null!=r){if(!this.IsCallable(r))throw new TypeError(e+"is not a function");return r}},Get:function(t,e){if("Object"!==this.Type(t))throw new TypeError("Assertion failed: Type(O) is not Object");if(!this.IsPropertyKey(e))throw new TypeError("Assertion failed: IsPropertyKey(P) is not true");return t[e]},Type:function(t){return"symbol"==typeof t?"Symbol":D.Type(t)},SpeciesConstructor:function(t,e){if("Object"!==this.Type(t))throw new TypeError("Assertion failed: Type(O) is not Object");var r=t.constructor;if(void 0===r)return e;if("Object"!==this.Type(r))throw new TypeError("O.constructor is not an Object");var o=a&&Symbol.species?r[Symbol.species]:void 0;if(null==o)return e;if(this.IsConstructor(o))return o;throw new TypeError("no constructor found")},CompletePropertyDescriptor:function(t){if(!this.IsPropertyDescriptor(t))throw new TypeError("Desc must be a Property Descriptor");return this.IsGenericDescriptor(t)||this.IsDataDescriptor(t)?(o(t,"[[Value]]")||(t["[[Value]]"]=void 0),o(t,"[[Writable]]")||(t["[[Writable]]"]=!1)):(o(t,"[[Get]]")||(t["[[Get]]"]=void 0),o(t,"[[Set]]")||(t["[[Set]]"]=void 0)),o(t,"[[Enumerable]]")||(t["[[Enumerable]]"]=!1),o(t,"[[Configurable]]")||(t["[[Configurable]]"]=!1),t},Set:function(t,e,r,o){if("Object"!==this.Type(t))throw new TypeError("O must be an Object");if(!this.IsPropertyKey(e))throw new TypeError("P must be a Property Key");if("Boolean"!==this.Type(o))throw new TypeError("Throw must be a Boolean");if(o)return t[e]=r,!0;try{t[e]=r}catch(t){return!1}},HasOwnProperty:function(t,e){if("Object"!==this.Type(t))throw new TypeError("O must be an Object");if(!this.IsPropertyKey(e))throw new TypeError("P must be a Property Key");return o(t,e)},HasProperty:function(t,e){if("Object"!==this.Type(t))throw new TypeError("O must be an Object");if(!this.IsPropertyKey(e))throw new TypeError("P must be a Property Key");return e in t},IsConcatSpreadable:function(t){if("Object"!==this.Type(t))return!1;if(a&&"symbol"==typeof Symbol.isConcatSpreadable){var e=this.Get(t,Symbol.isConcatSpreadable);if(void 0!==e)return this.ToBoolean(e)}return this.IsArray(t)},Invoke:function(t,e){if(!this.IsPropertyKey(e))throw new TypeError("P must be a Property Key");var r=m(arguments,2),o=this.GetV(t,e);return this.Call(o,t,r)},CreateIterResultObject:function(t,e){if("Boolean"!==this.Type(e))throw new TypeError("Assertion failed: Type(done) is not Boolean");return{value:t,done:e}},RegExpExec:function(t,e){if("Object"!==this.Type(t))throw new TypeError("R must be an Object");if("String"!==this.Type(e))throw new TypeError("S must be a String");var r=this.Get(t,"exec");if(this.IsCallable(r)){var o=this.Call(r,t,[e]);if(null===o||"Object"===this.Type(o))return o;throw new TypeError('"exec" method must return `null` or an Object')}return w(t,e)},ArraySpeciesCreate:function(t,e){if(!this.IsInteger(e)||e<0)throw new TypeError("Assertion failed: length must be an integer >= 0");var r,o=0===e?0:e;if(this.IsArray(t)&&(r=this.Get(t,"constructor"),"Object"===this.Type(r)&&a&&Symbol.species&&null===(r=this.Get(r,Symbol.species))&&(r=void 0)),void 0===r)return Array(o);if(!this.IsConstructor(r))throw new TypeError("C must be a constructor");return new r(o)},CreateDataProperty:function(t,e,r){if("Object"!==this.Type(t))throw new TypeError("Assertion failed: Type(O) is not Object");if(!this.IsPropertyKey(e))throw new TypeError("Assertion failed: IsPropertyKey(P) is not true");var o=Object.getOwnPropertyDescriptor(t,e),n=o||"function"!=typeof Object.isExtensible||Object.isExtensible(t);if(o&&(!o.writable||!o.configurable)||!n)return!1;var i={configurable:!0,enumerable:!0,value:r,writable:!0};return Object.defineProperty(t,e,i),!0},CreateDataPropertyOrThrow:function(t,e,r){if("Object"!==this.Type(t))throw new TypeError("Assertion failed: Type(O) is not Object");if(!this.IsPropertyKey(e))throw new TypeError("Assertion failed: IsPropertyKey(P) is not true");var o=this.CreateDataProperty(t,e,r);if(!o)throw new TypeError("unable to create data property");return o},AdvanceStringIndex:function(t,e,r){if("String"!==this.Type(t))throw new TypeError("Assertion failed: Type(S) is not String");if(!this.IsInteger(e))throw new TypeError("Assertion failed: length must be an integer >= 0 and <= (2**53 - 1)");if(e<0||e>u)throw new RangeError("Assertion failed: length must be an integer >= 0 and <= (2**53 - 1)");if("Boolean"!==this.Type(r))throw new TypeError("Assertion failed: Type(unicode) is not Boolean");if(!r)return e+1;if(e+1>=t.length)return e+1;var o=t.charCodeAt(e);if(o<55296||o>56319)return e+1;var n=t.charCodeAt(e+1);return n<56320||n>57343?e+1:e+2}});delete A.CheckObjectCoercible,e.exports=A},{"./es5":10,"./helpers/assign":12,"./helpers/isFinite":13,"./helpers/isNaN":14,"./helpers/isPrimitive":15,"./helpers/mod":16,"./helpers/sign":17,"es-to-primitive/es6":19,"function-bind":24,has:25,"is-regex":28}],10:[function(t,e,r){"use strict";var o=t("./helpers/isNaN"),n=t("./helpers/isFinite"),i=t("./helpers/sign"),a=t("./helpers/mod"),s=t("is-callable"),c=t("es-to-primitive/es5"),u=t("has"),l={ToPrimitive:c,ToBoolean:function(t){return!!t},ToNumber:function(t){return Number(t)},ToInteger:function(t){var e=this.ToNumber(t);return o(e)?0:0!==e&&n(e)?i(e)*Math.floor(Math.abs(e)):e},ToInt32:function(t){return this.ToNumber(t)>>0},ToUint32:function(t){return this.ToNumber(t)>>>0},ToUint16:function(t){var e=this.ToNumber(t);if(o(e)||0===e||!n(e))return 0;var r=i(e)*Math.floor(Math.abs(e));return a(r,65536)},ToString:function(t){return String(t)},ToObject:function(t){return this.CheckObjectCoercible(t),Object(t)},CheckObjectCoercible:function(t,e){if(null==t)throw new TypeError(e||"Cannot call method on "+t);return t},IsCallable:s,SameValue:function(t,e){return t===e?0!==t||1/t==1/e:o(t)&&o(e)},Type:function(t){return null===t?"Null":void 0===t?"Undefined":"function"==typeof t||"object"==typeof t?"Object":"number"==typeof t?"Number":"boolean"==typeof t?"Boolean":"string"==typeof t?"String":void 0},IsPropertyDescriptor:function(t){if("Object"!==this.Type(t))return!1;var e={"[[Configurable]]":!0,"[[Enumerable]]":!0,"[[Get]]":!0,"[[Set]]":!0,"[[Value]]":!0,"[[Writable]]":!0};for(var r in t)if(u(t,r)&&!e[r])return!1;var o=u(t,"[[Value]]"),n=u(t,"[[Get]]")||u(t,"[[Set]]");if(o&&n)throw new TypeError("Property Descriptors may not be both accessor and data descriptors");return!0},IsAccessorDescriptor:function(t){if(void 0===t)return!1;if(!this.IsPropertyDescriptor(t))throw new TypeError("Desc must be a Property Descriptor");return!(!u(t,"[[Get]]")&&!u(t,"[[Set]]"))},IsDataDescriptor:function(t){if(void 0===t)return!1;if(!this.IsPropertyDescriptor(t))throw new TypeError("Desc must be a Property Descriptor");return!(!u(t,"[[Value]]")&&!u(t,"[[Writable]]"))},IsGenericDescriptor:function(t){if(void 0===t)return!1;if(!this.IsPropertyDescriptor(t))throw new TypeError("Desc must be a Property Descriptor");return!this.IsAccessorDescriptor(t)&&!this.IsDataDescriptor(t)},FromPropertyDescriptor:function(t){if(void 0===t)return t;if(!this.IsPropertyDescriptor(t))throw new TypeError("Desc must be a Property Descriptor");if(this.IsDataDescriptor(t))return{value:t["[[Value]]"],writable:!!t["[[Writable]]"],enumerable:!!t["[[Enumerable]]"],configurable:!!t["[[Configurable]]"]};if(this.IsAccessorDescriptor(t))return{get:t["[[Get]]"],set:t["[[Set]]"],enumerable:!!t["[[Enumerable]]"],configurable:!!t["[[Configurable]]"]};throw new TypeError("FromPropertyDescriptor must be called with a fully populated Property Descriptor")},ToPropertyDescriptor:function(t){if("Object"!==this.Type(t))throw new TypeError("ToPropertyDescriptor requires an object");var e={};if(u(t,"enumerable")&&(e["[[Enumerable]]"]=this.ToBoolean(t.enumerable)),u(t,"configurable")&&(e["[[Configurable]]"]=this.ToBoolean(t.configurable)),u(t,"value")&&(e["[[Value]]"]=t.value),u(t,"writable")&&(e["[[Writable]]"]=this.ToBoolean(t.writable)),u(t,"get")){var r=t.get;if(void 0!==r&&!this.IsCallable(r))throw new TypeError("getter must be a function");e["[[Get]]"]=r}if(u(t,"set")){var o=t.set;if(void 0!==o&&!this.IsCallable(o))throw new TypeError("setter must be a function");e["[[Set]]"]=o}if((u(e,"[[Get]]")||u(e,"[[Set]]"))&&(u(e,"[[Value]]")||u(e,"[[Writable]]")))throw new TypeError("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return e}};e.exports=l},{"./helpers/isFinite":13,"./helpers/isNaN":14,"./helpers/mod":16,"./helpers/sign":17,"es-to-primitive/es5":18,has:25,"is-callable":26}],11:[function(t,e,r){"use strict";e.exports=t("./es2015")},{"./es2015":9}],12:[function(t,e,r){var o=Object.prototype.hasOwnProperty;e.exports=function(t,e){if(Object.assign)return Object.assign(t,e);for(var r in e)o.call(e,r)&&(t[r]=e[r]);return t}},{}],13:[function(t,e,r){var o=Number.isNaN||function(t){return t!==t};e.exports=Number.isFinite||function(t){return"number"==typeof t&&!o(t)&&t!==1/0&&t!==-1/0}},{}],14:[function(t,e,r){e.exports=Number.isNaN||function(t){return t!==t}},{}],15:[function(t,e,r){e.exports=function(t){return null===t||"function"!=typeof t&&"object"!=typeof t}},{}],16:[function(t,e,r){e.exports=function(t,e){var r=t%e;return Math.floor(r>=0?r:r+e)}},{}],17:[function(t,e,r){e.exports=function(t){return t>=0?1:-1}},{}],18:[function(t,e,r){"use strict";var o=Object.prototype.toString,n=t("./helpers/isPrimitive"),i=t("is-callable"),a={"[[DefaultValue]]":function(t,e){var r=e||("[object Date]"===o.call(t)?String:Number);if(r===String||r===Number){var a,s,c=r===String?["toString","valueOf"]:["valueOf","toString"];for(s=0;s1&&(e===String?r="string":e===Number&&(r="number"));var i;if(o&&(Symbol.toPrimitive?i=u(t,Symbol.toPrimitive):s(t)&&(i=Symbol.prototype.valueOf)),void 0!==i){var l=i.call(t,r);if(n(l))return l;throw new TypeError("unable to convert exotic object to primitive")}return"default"===r&&(a(t)||s(t))&&(r="string"),c(t,"default"===r?"number":r)}},{"./helpers/isPrimitive":20,"is-callable":26,"is-date-object":27,"is-symbol":29}],20:[function(t,e,r){arguments[4][15][0].apply(r,arguments)},{dup:15}],21:[function(t,e,r){(function(t){!function(t){function e(t){return"[object Array]"===Object.prototype.toString.call(t)}function o(){for(var t=0;t90)&&r===o.toUpperCase()}function i(t,e){return e&&e!==f?p.createElementNS(e,t):p.createElement(t)}function a(t,e){for(var r=t.firstChild;r;){var o=r.nextSibling;e.appendChild(r),r=o}return e}function s(t,e){var r,o,n,i,a,s=e.attributes;for(r=s.length-1;r>=0;--r)o=s[r],n=o.name,i=o.namespaceURI,a=o.value,i?(n=o.localName||n,t.getAttributeNS(i,n)!==a&&t.setAttributeNS(i,n,a)):t.getAttribute(n)!==a&&t.setAttribute(n,a);for(s=t.attributes,r=s.length-1;r>=0;--r)o=s[r],!1!==o.specified&&(n=o.name,i=o.namespaceURI,i?(n=o.localName||n,m(e,i,n)||t.removeAttributeNS(i,n)):m(e,null,n)||t.removeAttribute(n))}function c(t,e,r){t[r]!==e[r]&&(t[r]=e[r],t[r]?t.setAttribute(r,""):t.removeAttribute(r,""))}function u(){}function l(t){return t.id}var h,d,f="http://www.w3.org/1999/xhtml",p="undefined"==typeof document?void 0:document,y=p?p.body||p.createElement("div"):{};d=y.hasAttributeNS?function(t,e,r){return t.hasAttributeNS(e,r)}:y.hasAttribute?function(t,e,r){return t.hasAttribute(r)}:function(t,e,r){return null!=t.getAttributeNode(e,r)};var m=d,v={OPTION:function(t,e){c(t,e,"selected")},INPUT:function(t,e){c(t,e,"checked"),c(t,e,"disabled"),t.value!==e.value&&(t.value=e.value),m(e,null,"value")||t.removeAttribute("value")},TEXTAREA:function(t,e){var r=e.value;t.value!==r&&(t.value=r);var o=t.firstChild;if(o){var n=o.nodeValue;if(n==r||!r&&n==t.placeholder)return;o.nodeValue=r}},SELECT:function(t,e){if(!m(e,null,"multiple")){for(var r=0,o=e.firstChild;o;){var n=o.nodeName;if(n&&"OPTION"===n.toUpperCase()){if(m(o,null,"selected")){r;break}r++}o=o.nextSibling}t.selectedIndex=r}}},g=1,b=3,w=8,x=function(t){return function(e,r,s){function c(t){P?P.push(t):P=[t]}function h(t,e){if(t.nodeType===g)for(var r=t.firstChild;r;){var o=void 0;e&&(o=E(r))?c(o):(O(r),r.firstChild&&h(r,e)),r=r.nextSibling}}function d(t,e,r){!1!==_(t)&&(e&&e.removeChild(t),O(t),h(t,r))}function f(t){if(t.nodeType===g)for(var e=t.firstChild;e;){var r=E(e);r&&(A[r]=e),f(e),e=e.nextSibling}}function y(t){I(t);for(var e=t.firstChild;e;){var r=e.nextSibling,o=E(e);if(o){var i=A[o];i&&n(e,i)&&(e.parentNode.replaceChild(i,e),m(i,e))}y(e),e=r}}function m(o,i,a){var s,u=E(i);if(u&&delete A[u],!r.isSameNode||!r.isSameNode(e)){if(!a){if(!1===N(o,i))return;if(t(o,i),T(o),!1===D(o,i))return}if("TEXTAREA"!==o.nodeName){var l,h,f,x,P=i.firstChild,I=o.firstChild;t:for(;P;){for(f=P.nextSibling,l=E(P);I;){if(h=I.nextSibling,P.isSameNode&&P.isSameNode(I)){P=f,I=h;continue t}s=E(I);var _=I.nodeType,O=void 0;if(_===P.nodeType&&(_===g?(l?l!==s&&((x=A[l])?I.nextSibling===x?O=!1:(o.insertBefore(x,I),h=I.nextSibling,s?c(s):d(I,o,!0),I=x):O=!1):s&&(O=!1),(O=!1!==O&&n(I,P))&&m(I,P)):_!==b&&_!=w||(O=!0,I.nodeValue!==P.nodeValue&&(I.nodeValue=P.nodeValue))),O){P=f,I=h;continue t}s?c(s):d(I,o,!0),I=h}if(l&&(x=A[l])&&n(x,P))o.appendChild(x),m(x,P);else{var j=S(P);!1!==j&&(j&&(P=j),P.actualize&&(P=P.actualize(o.ownerDocument||p)),o.appendChild(P),y(P))}P=f,I=h}for(;I;)h=I.nextSibling,(s=E(I))?c(s):d(I,o,!0),I=h}var k=v[o.nodeName];k&&k(o,i)}}if(s||(s={}),"string"==typeof r)if("#document"===e.nodeName||"HTML"===e.nodeName){var x=r;r=p.createElement("html"),r.innerHTML=x}else r=o(r);var P,E=s.getNodeKey||l,S=s.onBeforeNodeAdded||u,I=s.onNodeAdded||u,N=s.onBeforeElUpdated||u,T=s.onElUpdated||u,_=s.onBeforeNodeDiscarded||u,O=s.onNodeDiscarded||u,D=s.onBeforeElChildrenUpdated||u,j=!0===s.childrenOnly,A={};f(e);var k=e,C=k.nodeType,B=r.nodeType;if(!j)if(C===g)B===g?n(e,r)||(O(e),k=a(e,i(r.nodeName,r.namespaceURI))):k=r;else if(C===b||C===w){if(B===C)return k.nodeValue!==r.nodeValue&&(k.nodeValue=r.nodeValue),k;k=r}if(k===r)O(e);else if(m(k,r,j),P)for(var G=0,M=P.length;G0&&!o.call(t,0))for(var f=0;f0)for(var y=0;y=0&&"[object Function]"===o.call(t.callee)),r}},{}],33:[function(t,e,r){"use strict";var o=t("../index"),n=function(t){t.fn.SmartPhoto=function(t){return"strings"==typeof t||new o(this,t),this}};if("function"==typeof define&&define.amd)define(["jquery"],n);else{var i=window.jQuery?window.jQuery:window.$;void 0!==i&&n(i)}e.exports=n},{"../index":35}],34:[function(t,e,r){"use strict";function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(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 i(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)}Object.defineProperty(r,"__esModule",{value:!0});var a=function(){function t(t,e){for(var r=0;r"),[].forEach.call(i.elements,function(t){i.addNewItem(t)}),i.update(),i._getEachImageSize().then(function(){i._fireEvent("loadall");var t=i._getCurrentItemByHash();t&&l.triggerEvent(t.element,"click")}),setInterval(function(){i._doAnim()},i.data.forceInterval),i.data.isSmartPhone?(window.addEventListener("orientationchange",function(){i.groupItems()&&(i._resetTranslate(),i._setPosByCurrentIndex(),i._setHashByCurrentIndex(),i._setSizeByScreen(),i.update())}),i.data.useOrientationApi?(window.addEventListener("deviceorientation",function(t){var e=window.orientation;t&&t.gamma&&!i.data.appearEffect&&(i.isBeingZoomed||i.photoSwipable||i.data.elastic||!i.data.scale||(0===e?i._calcGravity(t.gamma,t.beta):90===e?i._calcGravity(t.beta,t.gamma):-90===e?i._calcGravity(-t.beta,-t.gamma):180===e&&i._calcGravity(-t.gamma,-t.beta)))}),i):n(i)):(window.addEventListener("resize",function(){i.groupItems()&&(i._resetTranslate(),i._setPosByCurrentIndex(),i._setSizeByScreen(),i.update())}),window.addEventListener("keydown",function(t){var e=t.keyCode||t.which;!0!==i.data.hide&&(37===e?i.gotoSlide(i.data.prev):39===e?i.gotoSlide(i.data.next):27===e&&i.hidePhoto())}),n(i))}return i(e,t),a(e,[{key:"on",value:function(t,e){var r=this;this._getElementByClass(this.data.classNames.smartPhoto).addEventListener(t,function(t){e.call(r,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,r=function(e){var r=new h(function(t,r){var o=new Image;o.onload=function(){e.width=o.width,e.height=o.height,e.loaded=!0,t()},o.onerror=function(){r()},o.src=e.src});t.push(r)};return Object.keys(e).forEach(function(t){e[t].forEach(r)}),h.all(t)}},{key:"_resetTranslate",value:function(){var t=this;this.groupItems().forEach(function(e,r){e.translateX=t._getWindowWidth()*r})}},{key:"addNewItem",value:function(t){var e=this,r=t.getAttribute("data-group")||"nogroup",o=this.data.group;"nogroup"===r&&t.setAttribute("data-group","nogroup"),o[r]||(o[r]=[]);var n=o[r].length,i=document.querySelector("body"),a={src:t.getAttribute("href"),caption:t.getAttribute("data-caption"),groupId:r,translateX:this._getWindowWidth()*n,index:n,translateY:0,width:50,height:50,id:t.getAttribute("data-id")||n,loaded:!1,processed:!1,element:t};o[r].push(a),this.data.currentGroup=r,t.getAttribute("data-id")||t.setAttribute("data-id",n),t.setAttribute("data-index",n),t.addEventListener("click",function(r){r.preventDefault(),e.data.currentGroup=t.getAttribute("data-group"),e.data.currentIndex=parseInt(t.getAttribute("data-index"),10),e._setHashByCurrentIndex();var o=e._getSelectedItem();o.loaded?(e._initPhoto(),e.addAppearEffect(t,o),e.clicked=!0,e.update(),i.style.overflow="hidden",e._fireEvent("open")):e._loadItem(o).then(function(){e._initPhoto(),e.addAppearEffect(t,o),e.clicked=!0,e.update(),i.style.overflow="hidden",e._fireEvent("open")})})}},{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 h(function(e){var r=t.data.appearEffect,o=t.data.classNames,n=t._getElementByClass(o.smartPhotoImgClone),i=function t(){n.removeEventListener("transitionend",t,!0),e()};n.addEventListener("transitionend",i,!0),setTimeout(function(){n.style.transform="translate("+r.afterX+"px, "+r.afterY+"px) scale("+r.scale+")"},10)})}},{key:"addAppearEffect",value:function(t,e){if(!1===this.data.showAnimation)return void(this.data.appear=!0);var r=t.querySelector("img"),o=l.getViewPos(r),n={},i=1;n.width=r.offsetWidth,n.height=r.offsetHeight,n.top=o.top,n.left=o.left,n.once=!0,n.img=r.getAttribute("src");var a=this._getWindowWidth(),s=this._getWindowHeight(),c=s-this.data.headerHeight-this.data.footerHeight;"fill"===this.data.resizeStyle&&this.data.isSmartPhone?i=r.offsetWidth>r.offsetHeight?s/r.offsetHeight:a/r.offsetWidth:(n.width>n.height?i=e.heightn.width&&(i=e.heighta&&(i=a/n.width));var u=(i-1)/2*r.offsetWidth+(a-r.offsetWidth*i)/2,h=(i-1)/2*r.offsetHeight+(s-r.offsetHeight*i)/2;n.afterX=u,n.afterY=h,n.scale=i,this.data.appearEffect=n}},{key:"hidePhoto",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"bottom";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 r=window.scrollX,o=window.scrollY,n=document.querySelector("body");location.hash&&this._setHash(""),window.scroll(r,o),this._doHideEffect(e).then(function(){t.update(),n.style.overflow="",t._fireEvent("close")})}},{key:"_doHideEffect",value:function(t){var e=this;return new h(function(r){var o=e.data.classNames,n=e._getElementByClass(o.smartPhoto),i=e._getElementByQuery(".current ."+o.smartPhotoImg),a=e._getWindowHeight(),s=function t(){n.removeEventListener("transitionend",t,!0),r()};n.style.opacity=0,"bottom"===t?i.style.transform="translateY("+a+"px)":"top"===t&&(i.style.transform="translateY(-"+a+"px)"),n.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,r="undefined"==typeof event?this.e:event;return this._isTouched(r)?(t=r.touches[0].pageX,e=r.touches[0].pageY):r.pageX&&(t=r.pageX,e=r.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(),r=-1*e[this.data.currentIndex].translateX;this.pos.x=r,setTimeout(function(){t.data.translateX=r,t.data.translateY=0,t._listUpdate()},1)}},{key:"_setHashByCurrentIndex",value:function(){var t=window.scrollX,e=window.scrollY,r=this.groupItems(),o=r[this.data.currentIndex].id,n=this.data.currentGroup,i="group="+n+"&photo="+o;this._setHash(i),window.scroll(t,e)}},{key:"_setHash",value:function(t){window.history&&window.history.pushState&&this.data.useHistoryApi&&(t?window.history.replaceState(null,null,""+location.pathname+location.search+"#"+t):window.history.replaceState(null,null,""+location.pathname+location.search))}},{key:"_getCurrentItemByHash",value:function(){var t=this.data.group,e=location.hash.substr(1),r=l.parseQuery(e),o=null,n=function(t){r.group===t.groupId&&r.photo===t.id&&(o=t)};return Object.keys(t).forEach(function(e){t[e].forEach(n)}),o}},{key:"_loadItem",value:function(t){return new h(function(e){var r=new Image;r.onload=function(){t.width=r.width,t.height=r.height,t.loaded=!0,e()},r.onerror=function(){e()},r.src=t.src})}},{key:"_setSizeByScreen",value:function(){var t=this._getWindowWidth(),e=this._getWindowHeight(),r=this.data.headerHeight,o=this.data.footerHeight,n=e-(r+o);this.groupItems().forEach(function(r){r.loaded&&(r.processed=!0,r.scale=n/r.height,r.heightt&&(r.scale=t/r.width,r.x=(r.scale-1)/2*r.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,r=this.data.currentIndex+1,o=this.data.currentIndex-1;this.data.showNextArrow=!1,this.data.showPrevArrow=!1,r!==e&&(this.data.next=r,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,r=e.getTime(),o=this.tapSecond-r,n=0,i=0;return this.isSwipable=!1,this.onListMove=!1,this.oldPos&&(n=this.oldPos.x-this.firstPos.x,i=this.oldPos.y-this.firstPos.y),this.isBeingZoomed?void this.afterGesture():this.data.scale?void this.afterPhotoDrag():l.isSmartPhone()||0!==n||0!==i?Math.abs(o)<=500&&0===n&&0===i?(this.e.preventDefault(),void this.zoomPhoto()):(this.tapSecond=r,this._fireEvent("swipeend"),"horizontal"===this.moveDir&&(n>=this.data.swipeOffset&&0!==this.data.currentIndex?this.data.currentIndex-=1:n<=-this.data.swipeOffset&&this.data.currentIndex!==t.length-1&&(this.data.currentIndex+=1),this._slideList()),void("vertical"===this.moveDir&&(this.data.swipeBottomToClose&&i>=this.data.swipeOffset?this.hidePhoto("bottom"):this.data.swipeTopToClose&&i<=-this.data.swipeOffset?this.hidePhoto("top"):(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,r=t.y-this.firstPos.y;this.dragStart&&(this._fireEvent("swipestart"),this.dragStart=!1,Math.abs(e)>Math.abs(r)?this.moveDir="horizontal":this.moveDir="vertical"),"horizontal"===this.moveDir?(this.pos.x+=e,this.data.translateX=this.pos.x):this.data.translateY=r,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.scaleSize<=1||(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,r=t.y-this.oldPhotoPos.y,o=this._round(this.data.scaleSize*e,6),n=this._round(this.data.scaleSize*r,6);"number"==typeof o&&(this.data.photoPosX+=o,this.photoVX=o),"number"==typeof n&&(this.data.photoPosY+=n,this.photoVY=n),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),r=this.data.swipeOffset*this.data.scaleSize,o=0,n=0;if(this.data.photoPosX>e.maxX?o=-1:this.data.photoPosXe.maxY?n=-1:this.data.photoPosYr&&0!==this.data.currentIndex)return void this.gotoSlide(this.data.prev);if(e.minX-this.data.photoPosX>r&&this.data.currentIndex+1!==this.data.total)return void this.gotoSlide(this.data.next);0===o&&0===n?(this.vx=this.photoVX/5,this.vy=this.photoVY/5):this._registerElasticForce(o,n)}}},{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]),r=(e-this.oldDistance)/100,o=this.data.scaleSize,n=this.data.photoPosX,i=this.data.photoPosY;this.isBeingZoomed=!0,this.data.scaleSize+=this._round(r,6),this.data.scaleSize<.2&&(this.data.scaleSize=.2),this.data.scaleSizethis._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(),r=this._getWindowHeight();return l.isSmartPhone()?t.width>t.height?r/(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,r=t.height*t.scale*this.data.scaleSize,o=void 0,n=void 0,i=void 0,a=void 0,s=this._getWindowWidth(),c=this._getWindowHeight();return s>e?(i=(s-e)/2,o=-1*i):(i=(e-s)/2,o=-1*i),c>r?(a=(c-r)/2,n=-1*a):(a=(r-c)/2,n=-1*a),{minX:this._round(o,6)*this.data.scaleSize,minY:this._round(n,6)*this.data.scaleSize,maxX:this._round(i,6)*this.data.scaleSize,maxY:this._round(a,6)*this.data.scaleSize}}},{key:"_registerElasticForce",value:function(t,e){var r=this,o=this._getSelectedItem(),n=this._makeBound(o);this.data.elastic=!0,1===t?this.data.photoPosX=n.minX:-1===t&&(this.data.photoPosX=n.maxX),1===e?this.data.photoPosY=n.minY:-1===e&&(this.data.photoPosY=n.maxY),this._photoUpdate(),setTimeout(function(){r.data.elastic=!1,r._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 r=t.x-e.x,o=t.y-e.y;return Math.sqrt(r*r+o*o)}},{key:"_round",value:function(t,e){var r=Math.pow(10,e);return t*=r,t=Math.round(t),t/=r}},{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"),r=e.querySelector("."+t.smartPhotoImg),o=this._getElementByQuery("."+t.smartPhotoNav),n=this._getElementByQuery("."+t.smartPhotoArrows),i=this.virtualPos(this.data.photoPosX),a=this.virtualPos(this.data.photoPosY),s=this.data.scaleSize,c="translate("+i+"px,"+a+"px) scale("+s+")";r.style.transform=c,this.data.scale?l.addClass(r,t.smartPhotoImgOnMove):l.removeClass(r,t.smartPhotoImgOnMove),this.data.elastic?l.addClass(r,t.smartPhotoImgElasticMove):l.removeClass(r,t.smartPhotoImgElasticMove),this.data.hideUi?(o&&o.setAttribute("aria-hidden","true"),n&&n.setAttribute("aria-hidden","true")):(o&&o.setAttribute("aria-hidden","false"),n&&n.setAttribute("aria-hidden","false"))}},{key:"_getWindowWidth",value:function(){return document&&document.documentElement?document.documentElement.clientWidth:window&&window.innerWidth?window.innerWidth:0}},{key:"_getWindowHeight",value:function(){return document&&document.documentElement?document.documentElement.clientHeight:window&&window.innerHeight?window.innerHeight:0}},{key:"_listUpdate",value:function(){var t=this.data.classNames,e=this._getElementByQuery("."+t.smartPhotoList),r="translate("+this.data.translateX+"px,"+this.data.translateY+"px)";e.style.transform=r,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.photoPosXe.maxX&&(this.data.photoPosX=e.maxX,this.vx*=-.2),this.data.photoPosYe.maxY&&(this.data.photoPosY=e.maxY,this.vy*=-.2);var r=this._getForceAndTheta(this.vx,this.vy),o=r.force,n=r.theta;o-=this.data.registance,Math.abs(o)<.5||(this.vx=Math.cos(n)*o,this.vy=Math.sin(n)*o,this._photoUpdate())}}}]),e}(c.default);r.default=f,e.exports=r.default},{"../lib/util":36,"a-template":1,"custom-event-polyfill":7,"es6-promise-polyfill":21}],35:[function(t,e,r){"use strict";e.exports=t("./core/")},{"./core/":34}],36:[function(t,e,r){"use strict";function o(t){t=t||{};for(var e=1;e0||t.indexOf("iPad")>0||t.indexOf("ipod")>0||t.indexOf("Android")>0},e.exports.extend=o,e.exports.triggerEvent=function(t,e,r){var o=void 0;window.CustomEvent?o=new CustomEvent(e,{cancelable:!0}):(o=document.createEvent("CustomEvent"),o.initCustomEvent(e,!1,!1,r)),t.dispatchEvent(o)},e.exports.parseQuery=function(t){for(var e,r,o,n=t.split("&"),i={},a=0,s=n.length;a1;)r=r[o.shift()];r[o.shift()]=e}},{key:"removeDataByString",value:function(t){for(var e=this.data,r=t.split(".");r.length>1;)e=e[r.shift()];var o=r.shift();o.match(/^\d+$/)?e.splice(Number(o),1):delete e[o]}},{key:"resolveBlock",value:function(t,e,r){var o=this,n=t.match(//g),i=t.match(//g),a=t.match(//g),s=t.match(//g);if(n)for(var c=0,u=n.length;c/g;return t=t.replace(e,function(t,e){return(0,a.selector)("#"+e).innerHTML})}},{key:"resolveWith",value:function(t){var e=/(([\n\r\t]|.)*?)/g;return t=t.replace(e,function(t,e){return t=t.replace(/data\-bind=['"](.*?)['"]/g,"data-bind='"+e+".$1'")})}},{key:"resolveLoop",value:function(t){var e=/(([\n\r\t]|.)*?)/g,r=this;return t=t.replace(e,function(t,e,o){var n=r.getDataByString(e),i=[];i="function"==typeof n?n.apply(r):n;var a="";if(i instanceof Array)for(var s=0,c=i.length;s(([\n\r\t]|.)*?)/g;return!!t.match(e)}},{key:"getHtml",value:function(t,e){var r=c(this.atemplate,function(e){return e.id===t}),o="";if(r&&r.html&&(o=r.html),e&&(o=t),!o)return"";var n=this.data;for(o=this.resolveInclude(o),o=this.resolveWith(o);this.hasLoop(o);)o=this.resolveLoop(o);return o=this.resolveBlock(o,n),o=o.replace(/\\([^\\])/g,"$1"),o=this.resolveAbsBlock(o),o.replace(/^([\t ])*\n/gm,"")}},{key:"update",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"html",r=arguments[1],o=this.templates;this.beforeUpdated&&this.beforeUpdated();for(var n=0,i=o.length;n"+h+"");else(0,a.selector)(l).insertAdjacentHTML("afterend",'
'),"text"===e?(0,a.selector)("[data-id='"+u+"']").innerText=h:(0,a.selector)("[data-id='"+u+"']").innerHTML=h;var m=c(t.atemplate,function(t){return t.id===u});m.binded||(m.binded=!0,t.addDataBind((0,a.selector)("[data-id='"+u+"']")),t.addActionBind((0,a.selector)("[data-id='"+u+"']")))}(n);return this.updateBindingData(r),this.onUpdated&&this.onUpdated(r),this}},{key:"updateBindingData",value:function(t){for(var e=this,r=this.templates,o=0,n=r.length;o1?r-1:0),n=1;n1;)e=e[r.shift()];var o=r.shift();return o.match(/^\d+$/)?e.splice(Number(o),1):delete e[o],this}}]),t}();r.default=h,e.exports=r.default},{"./util":2,"array.prototype.find":4,morphdom:30}],2:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=r.matches=function(t,e){for(var r=(t.document||t.ownerDocument).querySelectorAll(e),o=r.length;--o>=0&&r.item(o)!==t;);return o>-1},n=(r.selector=function(t){return document.querySelector(t)},r.findAncestor=function(t,e){if("function"==typeof t.closest)return t.closest(e)||null;for(;t&&t!==document;){if(o(t,e))return t;t=t.parentElement}return null});r.on=function(t,e,r,o){r.split(" ").forEach(function(r){t.addEventListener(r,function(t){var r=(t.target,n(t.target,e));r&&(t.delegateTarget=r,o(t))})})}},{}],3:[function(t,e,r){"use strict";var o=t("es-abstract/es6");e.exports=function(t){var e=o.ToObject(this),r=o.ToInteger(o.ToLength(e.length));if(!o.IsCallable(t))throw new TypeError("Array#find: predicate must be a function");if(0!==r)for(var n,i=arguments[1],a=0;a2?arguments[2]:{},a=o(e);i&&(a=a.concat(Object.getOwnPropertySymbols(e))),n(a,function(o){u(t,o,e[o],r[o])})};l.supportsDescriptors=!!c,e.exports=l},{foreach:22,"object-keys":31}],9:[function(t,e,r){"use strict";var o=t("has"),n=t("es-to-primitive/es6"),i=Object.prototype.toString,a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator,s=t("./helpers/isNaN"),c=t("./helpers/isFinite"),u=Number.MAX_SAFE_INTEGER||Math.pow(2,53)-1,l=t("./helpers/assign"),h=t("./helpers/sign"),d=t("./helpers/mod"),f=t("./helpers/isPrimitive"),p=parseInt,y=t("function-bind"),m=y.call(Function.call,Array.prototype.slice),v=y.call(Function.call,String.prototype.slice),g=y.call(Function.call,RegExp.prototype.test,/^0b[01]+$/i),b=y.call(Function.call,RegExp.prototype.test,/^0o[0-7]+$/i),w=y.call(Function.call,RegExp.prototype.exec),x=["…","​","￾"].join(""),P=new RegExp("["+x+"]","g"),E=y.call(Function.call,RegExp.prototype.test,P),S=/^[-+]0x[0-9a-f]+$/i,I=y.call(Function.call,RegExp.prototype.test,S),N=["\t\n\v\f\r   ᠎    ","          \u2028","\u2029\ufeff"].join(""),T=new RegExp("(^["+N+"]+)|(["+N+"]+$)","g"),_=y.call(Function.call,String.prototype.replace),O=function(t){return _(t,T,"")},D=t("./es5"),A=t("is-regex"),j=l(l({},D),{Call:function(t,e){var r=arguments.length>2?arguments[2]:[];if(!this.IsCallable(t))throw new TypeError(t+" is not a function");return t.apply(e,r)},ToPrimitive:n,ToNumber:function(t){var e=f(t)?t:n(t,Number);if("symbol"==typeof e)throw new TypeError("Cannot convert a Symbol value to a number");if("string"==typeof e){if(g(e))return this.ToNumber(p(v(e,2),2));if(b(e))return this.ToNumber(p(v(e,2),8));if(E(e)||I(e))return NaN;var r=O(e);if(r!==e)return this.ToNumber(r)}return Number(e)},ToInt16:function(t){var e=this.ToUint16(t);return e>=32768?e-65536:e},ToInt8:function(t){var e=this.ToUint8(t);return e>=128?e-256:e},ToUint8:function(t){var e=this.ToNumber(t);if(s(e)||0===e||!c(e))return 0;var r=h(e)*Math.floor(Math.abs(e));return d(r,256)},ToUint8Clamp:function(t){var e=this.ToNumber(t);if(s(e)||e<=0)return 0;if(e>=255)return 255;var r=Math.floor(t);return r+.5u?u:e},CanonicalNumericIndexString:function(t){if("[object String]"!==i.call(t))throw new TypeError("must be a string");if("-0"===t)return-0;var e=this.ToNumber(t);return this.SameValue(this.ToString(e),t)?e:void 0},RequireObjectCoercible:D.CheckObjectCoercible,IsArray:Array.isArray||function(t){return"[object Array]"===i.call(t)},IsConstructor:function(t){return"function"==typeof t&&!!t.prototype},IsExtensible:function(t){return!Object.preventExtensions||!f(t)&&Object.isExtensible(t)},IsInteger:function(t){if("number"!=typeof t||s(t)||!c(t))return!1;var e=Math.abs(t);return Math.floor(e)===e},IsPropertyKey:function(t){return"string"==typeof t||"symbol"==typeof t},IsRegExp:function(t){if(!t||"object"!=typeof t)return!1;if(a){var e=t[Symbol.match];if(void 0!==e)return D.ToBoolean(e)}return A(t)},SameValueZero:function(t,e){return t===e||s(t)&&s(e)},GetV:function(t,e){if(!this.IsPropertyKey(e))throw new TypeError("Assertion failed: IsPropertyKey(P) is not true");return this.ToObject(t)[e]},GetMethod:function(t,e){if(!this.IsPropertyKey(e))throw new TypeError("Assertion failed: IsPropertyKey(P) is not true");var r=this.GetV(t,e);if(null!=r){if(!this.IsCallable(r))throw new TypeError(e+"is not a function");return r}},Get:function(t,e){if("Object"!==this.Type(t))throw new TypeError("Assertion failed: Type(O) is not Object");if(!this.IsPropertyKey(e))throw new TypeError("Assertion failed: IsPropertyKey(P) is not true");return t[e]},Type:function(t){return"symbol"==typeof t?"Symbol":D.Type(t)},SpeciesConstructor:function(t,e){if("Object"!==this.Type(t))throw new TypeError("Assertion failed: Type(O) is not Object");var r=t.constructor;if(void 0===r)return e;if("Object"!==this.Type(r))throw new TypeError("O.constructor is not an Object");var o=a&&Symbol.species?r[Symbol.species]:void 0;if(null==o)return e;if(this.IsConstructor(o))return o;throw new TypeError("no constructor found")},CompletePropertyDescriptor:function(t){if(!this.IsPropertyDescriptor(t))throw new TypeError("Desc must be a Property Descriptor");return this.IsGenericDescriptor(t)||this.IsDataDescriptor(t)?(o(t,"[[Value]]")||(t["[[Value]]"]=void 0),o(t,"[[Writable]]")||(t["[[Writable]]"]=!1)):(o(t,"[[Get]]")||(t["[[Get]]"]=void 0),o(t,"[[Set]]")||(t["[[Set]]"]=void 0)),o(t,"[[Enumerable]]")||(t["[[Enumerable]]"]=!1),o(t,"[[Configurable]]")||(t["[[Configurable]]"]=!1),t},Set:function(t,e,r,o){if("Object"!==this.Type(t))throw new TypeError("O must be an Object");if(!this.IsPropertyKey(e))throw new TypeError("P must be a Property Key");if("Boolean"!==this.Type(o))throw new TypeError("Throw must be a Boolean");if(o)return t[e]=r,!0;try{t[e]=r}catch(t){return!1}},HasOwnProperty:function(t,e){if("Object"!==this.Type(t))throw new TypeError("O must be an Object");if(!this.IsPropertyKey(e))throw new TypeError("P must be a Property Key");return o(t,e)},HasProperty:function(t,e){if("Object"!==this.Type(t))throw new TypeError("O must be an Object");if(!this.IsPropertyKey(e))throw new TypeError("P must be a Property Key");return e in t},IsConcatSpreadable:function(t){if("Object"!==this.Type(t))return!1;if(a&&"symbol"==typeof Symbol.isConcatSpreadable){var e=this.Get(t,Symbol.isConcatSpreadable);if(void 0!==e)return this.ToBoolean(e)}return this.IsArray(t)},Invoke:function(t,e){if(!this.IsPropertyKey(e))throw new TypeError("P must be a Property Key");var r=m(arguments,2),o=this.GetV(t,e);return this.Call(o,t,r)},CreateIterResultObject:function(t,e){if("Boolean"!==this.Type(e))throw new TypeError("Assertion failed: Type(done) is not Boolean");return{value:t,done:e}},RegExpExec:function(t,e){if("Object"!==this.Type(t))throw new TypeError("R must be an Object");if("String"!==this.Type(e))throw new TypeError("S must be a String");var r=this.Get(t,"exec");if(this.IsCallable(r)){var o=this.Call(r,t,[e]);if(null===o||"Object"===this.Type(o))return o;throw new TypeError('"exec" method must return `null` or an Object')}return w(t,e)},ArraySpeciesCreate:function(t,e){if(!this.IsInteger(e)||e<0)throw new TypeError("Assertion failed: length must be an integer >= 0");var r,o=0===e?0:e;if(this.IsArray(t)&&(r=this.Get(t,"constructor"),"Object"===this.Type(r)&&a&&Symbol.species&&null===(r=this.Get(r,Symbol.species))&&(r=void 0)),void 0===r)return Array(o);if(!this.IsConstructor(r))throw new TypeError("C must be a constructor");return new r(o)},CreateDataProperty:function(t,e,r){if("Object"!==this.Type(t))throw new TypeError("Assertion failed: Type(O) is not Object");if(!this.IsPropertyKey(e))throw new TypeError("Assertion failed: IsPropertyKey(P) is not true");var o=Object.getOwnPropertyDescriptor(t,e),n=o||"function"!=typeof Object.isExtensible||Object.isExtensible(t);if(o&&(!o.writable||!o.configurable)||!n)return!1;var i={configurable:!0,enumerable:!0,value:r,writable:!0};return Object.defineProperty(t,e,i),!0},CreateDataPropertyOrThrow:function(t,e,r){if("Object"!==this.Type(t))throw new TypeError("Assertion failed: Type(O) is not Object");if(!this.IsPropertyKey(e))throw new TypeError("Assertion failed: IsPropertyKey(P) is not true");var o=this.CreateDataProperty(t,e,r);if(!o)throw new TypeError("unable to create data property");return o},AdvanceStringIndex:function(t,e,r){if("String"!==this.Type(t))throw new TypeError("Assertion failed: Type(S) is not String");if(!this.IsInteger(e))throw new TypeError("Assertion failed: length must be an integer >= 0 and <= (2**53 - 1)");if(e<0||e>u)throw new RangeError("Assertion failed: length must be an integer >= 0 and <= (2**53 - 1)");if("Boolean"!==this.Type(r))throw new TypeError("Assertion failed: Type(unicode) is not Boolean");if(!r)return e+1;if(e+1>=t.length)return e+1;var o=t.charCodeAt(e);if(o<55296||o>56319)return e+1;var n=t.charCodeAt(e+1);return n<56320||n>57343?e+1:e+2}});delete j.CheckObjectCoercible,e.exports=j},{"./es5":10,"./helpers/assign":12,"./helpers/isFinite":13,"./helpers/isNaN":14,"./helpers/isPrimitive":15,"./helpers/mod":16,"./helpers/sign":17,"es-to-primitive/es6":19,"function-bind":24,has:25,"is-regex":28}],10:[function(t,e,r){"use strict";var o=t("./helpers/isNaN"),n=t("./helpers/isFinite"),i=t("./helpers/sign"),a=t("./helpers/mod"),s=t("is-callable"),c=t("es-to-primitive/es5"),u=t("has"),l={ToPrimitive:c,ToBoolean:function(t){return!!t},ToNumber:function(t){return Number(t)},ToInteger:function(t){var e=this.ToNumber(t);return o(e)?0:0!==e&&n(e)?i(e)*Math.floor(Math.abs(e)):e},ToInt32:function(t){return this.ToNumber(t)>>0},ToUint32:function(t){return this.ToNumber(t)>>>0},ToUint16:function(t){var e=this.ToNumber(t);if(o(e)||0===e||!n(e))return 0;var r=i(e)*Math.floor(Math.abs(e));return a(r,65536)},ToString:function(t){return String(t)},ToObject:function(t){return this.CheckObjectCoercible(t),Object(t)},CheckObjectCoercible:function(t,e){if(null==t)throw new TypeError(e||"Cannot call method on "+t);return t},IsCallable:s,SameValue:function(t,e){return t===e?0!==t||1/t==1/e:o(t)&&o(e)},Type:function(t){return null===t?"Null":void 0===t?"Undefined":"function"==typeof t||"object"==typeof t?"Object":"number"==typeof t?"Number":"boolean"==typeof t?"Boolean":"string"==typeof t?"String":void 0},IsPropertyDescriptor:function(t){if("Object"!==this.Type(t))return!1;var e={"[[Configurable]]":!0,"[[Enumerable]]":!0,"[[Get]]":!0,"[[Set]]":!0,"[[Value]]":!0,"[[Writable]]":!0};for(var r in t)if(u(t,r)&&!e[r])return!1;var o=u(t,"[[Value]]"),n=u(t,"[[Get]]")||u(t,"[[Set]]");if(o&&n)throw new TypeError("Property Descriptors may not be both accessor and data descriptors");return!0},IsAccessorDescriptor:function(t){if(void 0===t)return!1;if(!this.IsPropertyDescriptor(t))throw new TypeError("Desc must be a Property Descriptor");return!(!u(t,"[[Get]]")&&!u(t,"[[Set]]"))},IsDataDescriptor:function(t){if(void 0===t)return!1;if(!this.IsPropertyDescriptor(t))throw new TypeError("Desc must be a Property Descriptor");return!(!u(t,"[[Value]]")&&!u(t,"[[Writable]]"))},IsGenericDescriptor:function(t){if(void 0===t)return!1;if(!this.IsPropertyDescriptor(t))throw new TypeError("Desc must be a Property Descriptor");return!this.IsAccessorDescriptor(t)&&!this.IsDataDescriptor(t)},FromPropertyDescriptor:function(t){if(void 0===t)return t;if(!this.IsPropertyDescriptor(t))throw new TypeError("Desc must be a Property Descriptor");if(this.IsDataDescriptor(t))return{value:t["[[Value]]"],writable:!!t["[[Writable]]"],enumerable:!!t["[[Enumerable]]"],configurable:!!t["[[Configurable]]"]};if(this.IsAccessorDescriptor(t))return{get:t["[[Get]]"],set:t["[[Set]]"],enumerable:!!t["[[Enumerable]]"],configurable:!!t["[[Configurable]]"]};throw new TypeError("FromPropertyDescriptor must be called with a fully populated Property Descriptor")},ToPropertyDescriptor:function(t){if("Object"!==this.Type(t))throw new TypeError("ToPropertyDescriptor requires an object");var e={};if(u(t,"enumerable")&&(e["[[Enumerable]]"]=this.ToBoolean(t.enumerable)),u(t,"configurable")&&(e["[[Configurable]]"]=this.ToBoolean(t.configurable)),u(t,"value")&&(e["[[Value]]"]=t.value),u(t,"writable")&&(e["[[Writable]]"]=this.ToBoolean(t.writable)),u(t,"get")){var r=t.get;if(void 0!==r&&!this.IsCallable(r))throw new TypeError("getter must be a function");e["[[Get]]"]=r}if(u(t,"set")){var o=t.set;if(void 0!==o&&!this.IsCallable(o))throw new TypeError("setter must be a function");e["[[Set]]"]=o}if((u(e,"[[Get]]")||u(e,"[[Set]]"))&&(u(e,"[[Value]]")||u(e,"[[Writable]]")))throw new TypeError("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return e}};e.exports=l},{"./helpers/isFinite":13,"./helpers/isNaN":14,"./helpers/mod":16,"./helpers/sign":17,"es-to-primitive/es5":18,has:25,"is-callable":26}],11:[function(t,e,r){"use strict";e.exports=t("./es2015")},{"./es2015":9}],12:[function(t,e,r){var o=Object.prototype.hasOwnProperty;e.exports=function(t,e){if(Object.assign)return Object.assign(t,e);for(var r in e)o.call(e,r)&&(t[r]=e[r]);return t}},{}],13:[function(t,e,r){var o=Number.isNaN||function(t){return t!==t};e.exports=Number.isFinite||function(t){return"number"==typeof t&&!o(t)&&t!==1/0&&t!==-1/0}},{}],14:[function(t,e,r){e.exports=Number.isNaN||function(t){return t!==t}},{}],15:[function(t,e,r){e.exports=function(t){return null===t||"function"!=typeof t&&"object"!=typeof t}},{}],16:[function(t,e,r){e.exports=function(t,e){var r=t%e;return Math.floor(r>=0?r:r+e)}},{}],17:[function(t,e,r){e.exports=function(t){return t>=0?1:-1}},{}],18:[function(t,e,r){"use strict";var o=Object.prototype.toString,n=t("./helpers/isPrimitive"),i=t("is-callable"),a={"[[DefaultValue]]":function(t,e){var r=e||("[object Date]"===o.call(t)?String:Number);if(r===String||r===Number){var a,s,c=r===String?["toString","valueOf"]:["valueOf","toString"];for(s=0;s1&&(e===String?r="string":e===Number&&(r="number"));var i;if(o&&(Symbol.toPrimitive?i=u(t,Symbol.toPrimitive):s(t)&&(i=Symbol.prototype.valueOf)),void 0!==i){var l=i.call(t,r);if(n(l))return l;throw new TypeError("unable to convert exotic object to primitive")}return"default"===r&&(a(t)||s(t))&&(r="string"),c(t,"default"===r?"number":r)}},{"./helpers/isPrimitive":20,"is-callable":26,"is-date-object":27,"is-symbol":29}],20:[function(t,e,r){arguments[4][15][0].apply(r,arguments)},{dup:15}],21:[function(t,e,r){(function(t){!function(t){function e(t){return"[object Array]"===Object.prototype.toString.call(t)}function o(){for(var t=0;t90)&&r===o.toUpperCase()}function i(t,e){return e&&e!==f?p.createElementNS(e,t):p.createElement(t)}function a(t,e){for(var r=t.firstChild;r;){var o=r.nextSibling;e.appendChild(r),r=o}return e}function s(t,e){var r,o,n,i,a,s=e.attributes;for(r=s.length-1;r>=0;--r)o=s[r],n=o.name,i=o.namespaceURI,a=o.value,i?(n=o.localName||n,t.getAttributeNS(i,n)!==a&&t.setAttributeNS(i,n,a)):t.getAttribute(n)!==a&&t.setAttribute(n,a);for(s=t.attributes,r=s.length-1;r>=0;--r)o=s[r],!1!==o.specified&&(n=o.name,i=o.namespaceURI,i?(n=o.localName||n,m(e,i,n)||t.removeAttributeNS(i,n)):m(e,null,n)||t.removeAttribute(n))}function c(t,e,r){t[r]!==e[r]&&(t[r]=e[r],t[r]?t.setAttribute(r,""):t.removeAttribute(r,""))}function u(){}function l(t){return t.id}var h,d,f="http://www.w3.org/1999/xhtml",p="undefined"==typeof document?void 0:document,y=p?p.body||p.createElement("div"):{};d=y.hasAttributeNS?function(t,e,r){return t.hasAttributeNS(e,r)}:y.hasAttribute?function(t,e,r){return t.hasAttribute(r)}:function(t,e,r){return null!=t.getAttributeNode(e,r)};var m=d,v={OPTION:function(t,e){c(t,e,"selected")},INPUT:function(t,e){c(t,e,"checked"),c(t,e,"disabled"),t.value!==e.value&&(t.value=e.value),m(e,null,"value")||t.removeAttribute("value")},TEXTAREA:function(t,e){var r=e.value;t.value!==r&&(t.value=r);var o=t.firstChild;if(o){var n=o.nodeValue;if(n==r||!r&&n==t.placeholder)return;o.nodeValue=r}},SELECT:function(t,e){if(!m(e,null,"multiple")){for(var r=0,o=e.firstChild;o;){var n=o.nodeName;if(n&&"OPTION"===n.toUpperCase()){if(m(o,null,"selected")){r;break}r++}o=o.nextSibling}t.selectedIndex=r}}},g=1,b=3,w=8,x=function(t){return function(e,r,s){function c(t){P?P.push(t):P=[t]}function h(t,e){if(t.nodeType===g)for(var r=t.firstChild;r;){var o=void 0;e&&(o=E(r))?c(o):(O(r),r.firstChild&&h(r,e)),r=r.nextSibling}}function d(t,e,r){!1!==_(t)&&(e&&e.removeChild(t),O(t),h(t,r))}function f(t){if(t.nodeType===g)for(var e=t.firstChild;e;){var r=E(e);r&&(j[r]=e),f(e),e=e.nextSibling}}function y(t){I(t);for(var e=t.firstChild;e;){var r=e.nextSibling,o=E(e);if(o){var i=j[o];i&&n(e,i)&&(e.parentNode.replaceChild(i,e),m(i,e))}y(e),e=r}}function m(o,i,a){var s,u=E(i);if(u&&delete j[u],!r.isSameNode||!r.isSameNode(e)){if(!a){if(!1===N(o,i))return;if(t(o,i),T(o),!1===D(o,i))return}if("TEXTAREA"!==o.nodeName){var l,h,f,x,P=i.firstChild,I=o.firstChild;t:for(;P;){for(f=P.nextSibling,l=E(P);I;){if(h=I.nextSibling,P.isSameNode&&P.isSameNode(I)){P=f,I=h;continue t}s=E(I);var _=I.nodeType,O=void 0;if(_===P.nodeType&&(_===g?(l?l!==s&&((x=j[l])?I.nextSibling===x?O=!1:(o.insertBefore(x,I),h=I.nextSibling,s?c(s):d(I,o,!0),I=x):O=!1):s&&(O=!1),(O=!1!==O&&n(I,P))&&m(I,P)):_!==b&&_!=w||(O=!0,I.nodeValue!==P.nodeValue&&(I.nodeValue=P.nodeValue))),O){P=f,I=h;continue t}s?c(s):d(I,o,!0),I=h}if(l&&(x=j[l])&&n(x,P))o.appendChild(x),m(x,P);else{var A=S(P);!1!==A&&(A&&(P=A),P.actualize&&(P=P.actualize(o.ownerDocument||p)),o.appendChild(P),y(P))}P=f,I=h}for(;I;)h=I.nextSibling,(s=E(I))?c(s):d(I,o,!0),I=h}var k=v[o.nodeName];k&&k(o,i)}}if(s||(s={}),"string"==typeof r)if("#document"===e.nodeName||"HTML"===e.nodeName){var x=r;r=p.createElement("html"),r.innerHTML=x}else r=o(r);var P,E=s.getNodeKey||l,S=s.onBeforeNodeAdded||u,I=s.onNodeAdded||u,N=s.onBeforeElUpdated||u,T=s.onElUpdated||u,_=s.onBeforeNodeDiscarded||u,O=s.onNodeDiscarded||u,D=s.onBeforeElChildrenUpdated||u,A=!0===s.childrenOnly,j={};f(e);var k=e,C=k.nodeType,B=r.nodeType;if(!A)if(C===g)B===g?n(e,r)||(O(e),k=a(e,i(r.nodeName,r.namespaceURI))):k=r;else if(C===b||C===w){if(B===C)return k.nodeValue!==r.nodeValue&&(k.nodeValue=r.nodeValue),k;k=r}if(k===r)O(e);else if(m(k,r,A),P)for(var G=0,M=P.length;G0&&!o.call(t,0))for(var f=0;f0)for(var y=0;y=0&&"[object Function]"===o.call(t.callee)),r}},{}],33:[function(t,e,r){"use strict";var o=t("../index"),n=function(t){t.fn.SmartPhoto=function(t){return"strings"==typeof t||new o(this,t),this}};if("function"==typeof define&&define.amd)define(["jquery"],n);else{var i=window.jQuery?window.jQuery:window.$;void 0!==i&&n(i)}e.exports=n},{"../index":35}],34:[function(t,e,r){"use strict";function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(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 i(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)}Object.defineProperty(r,"__esModule",{value:!0});var a=function(){function t(t,e){for(var r=0;r"),[].forEach.call(i.elements,function(t){i.addNewItem(t)}),i.update(),i._getEachImageSize().then(function(){i._fireEvent("loadall");var t=i._getCurrentItemByHash();t&&l.triggerEvent(t.element,"click")}),setInterval(function(){i._doAnim()},i.data.forceInterval),i.data.useHistoryApi&&"push"===i.data.historyApiMethod&&(window.onpopstate=function(t){if(!t||!t.state||void 0===t.state.group||void 0===t.state.index)return void i.hidePhoto();i.data.currentGroup=t.state.group,i.data.currentIndex=t.state.index;var e=i._getSelectedItem();e.loaded?(i._initPhoto(),i.data.appear=!0,i.clicked=!0,i.update(),s.style.overflow="hidden",i._fireEvent("open")):i._loadItem(e).then(function(){i._initPhoto(),i.data.appear=!0,i.clicked=!0,i.update(),s.style.overflow="hidden",i._fireEvent("open")}),i.gotoSlide(t.state.index,!0)}),i.data.isSmartPhone?(window.addEventListener("orientationchange",function(){i.groupItems()&&(i._resetTranslate(),i._setPosByCurrentIndex(),i._setHashByCurrentIndex(),i._setSizeByScreen(),i.update())}),i.data.useOrientationApi?(window.addEventListener("deviceorientation",function(t){var e=window.orientation;t&&t.gamma&&!i.data.appearEffect&&(i.isBeingZoomed||i.photoSwipable||i.data.elastic||!i.data.scale||(0===e?i._calcGravity(t.gamma,t.beta):90===e?i._calcGravity(t.beta,t.gamma):-90===e?i._calcGravity(-t.beta,-t.gamma):180===e&&i._calcGravity(-t.gamma,-t.beta)))}),i):n(i)):(window.addEventListener("resize",function(){i.groupItems()&&(i._resetTranslate(),i._setPosByCurrentIndex(),i._setSizeByScreen(),i.update())}),window.addEventListener("keydown",function(t){var e=t.keyCode||t.which;!0!==i.data.hide&&(37===e?i.gotoSlide(i.data.prev):39===e?i.gotoSlide(i.data.next):27===e&&i.hidePhoto())}),n(i))}return i(e,t),a(e,[{key:"on",value:function(t,e){var r=this;this._getElementByClass(this.data.classNames.smartPhoto).addEventListener(t,function(t){e.call(r,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,r=function(e){var r=new h(function(t,r){var o=new Image;o.onload=function(){e.width=o.width,e.height=o.height,e.loaded=!0,t()},o.onerror=function(){r()},o.src=e.src});t.push(r)};return Object.keys(e).forEach(function(t){e[t].forEach(r)}),h.all(t)}},{key:"_resetTranslate",value:function(){var t=this;this.groupItems().forEach(function(e,r){e.translateX=t._getWindowWidth()*r})}},{key:"addNewItem",value:function(t){var e=this,r=t.getAttribute("data-group")||"nogroup",o=this.data.group;"nogroup"===r&&t.setAttribute("data-group","nogroup"),o[r]||(o[r]=[]);var n=o[r].length,i=document.querySelector("body"),a={src:t.getAttribute("href"),caption:t.getAttribute("data-caption"),groupId:r,translateX:this._getWindowWidth()*n,index:n,translateY:0,width:50,height:50,id:t.getAttribute("data-id")||n,loaded:!1,processed:!1,element:t};o[r].push(a),this.data.currentGroup=r,t.getAttribute("data-id")||t.setAttribute("data-id",n),t.setAttribute("data-index",n),t.addEventListener("click",function(r){r.preventDefault(),e.data.currentGroup=t.getAttribute("data-group"),e.data.currentIndex=parseInt(t.getAttribute("data-index"),10),e._setHashByCurrentIndex();var o=e._getSelectedItem();o.loaded?(e._initPhoto(),e.addAppearEffect(t,o),e.clicked=!0,e.update(),i.style.overflow="hidden",e._fireEvent("open")):e._loadItem(o).then(function(){e._initPhoto(),e.addAppearEffect(t,o),e.clicked=!0,e.update(),i.style.overflow="hidden",e._fireEvent("open")})})}},{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 h(function(e){var r=t.data.appearEffect,o=t.data.classNames,n=t._getElementByClass(o.smartPhotoImgClone),i=function t(){n.removeEventListener("transitionend",t,!0),e()};n.addEventListener("transitionend",i,!0),setTimeout(function(){n.style.transform="translate("+r.afterX+"px, "+r.afterY+"px) scale("+r.scale+")"},10)})}},{key:"addAppearEffect",value:function(t,e){if(!1===this.data.showAnimation)return void(this.data.appear=!0);var r=t.querySelector("img"),o=l.getViewPos(r),n={},i=1;n.width=r.offsetWidth,n.height=r.offsetHeight,n.top=o.top,n.left=o.left,n.once=!0,n.img=r.getAttribute("src");var a=this._getWindowWidth(),s=this._getWindowHeight(),c=s-this.data.headerHeight-this.data.footerHeight;"fill"===this.data.resizeStyle&&this.data.isSmartPhone?i=r.offsetWidth>r.offsetHeight?s/r.offsetHeight:a/r.offsetWidth:(n.width>n.height?i=e.heightn.width&&(i=e.heighta&&(i=a/n.width));var u=(i-1)/2*r.offsetWidth+(a-r.offsetWidth*i)/2,h=(i-1)/2*r.offsetHeight+(s-r.offsetHeight*i)/2;n.afterX=u,n.afterY=h,n.scale=i,this.data.appearEffect=n}},{key:"hidePhoto",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"bottom";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 r=window.scrollX,o=window.scrollY,n=document.querySelector("body");location.hash&&this._setHash(),window.scroll(r,o),this._doHideEffect(e).then(function(){t.update(),n.style.overflow="",t._fireEvent("close")})}},{key:"_doHideEffect",value:function(t){var e=this;return new h(function(r){var o=e.data.classNames,n=e._getElementByClass(o.smartPhoto),i=e._getElementByQuery(".current ."+o.smartPhotoImg),a=e._getWindowHeight(),s=function t(){n.removeEventListener("transitionend",t,!0),r()};n.style.opacity=0,"bottom"===t?i.style.transform="translateY("+a+"px)":"top"===t&&(i.style.transform="translateY(-"+a+"px)"),n.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,r="undefined"==typeof event?this.e:event;return this._isTouched(r)?(t=r.touches[0].pageX,e=r.touches[0].pageY):r.pageX&&(t=r.pageX,e=r.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(),r=-1*e[this.data.currentIndex].translateX;this.pos.x=r,setTimeout(function(){t.data.translateX=r,t.data.translateY=0,t._listUpdate()},1)}},{key:"_setHashByCurrentIndex",value:function(){var t=window.scrollX,e=window.scrollY,r=this.groupItems(),o=r[this.data.currentIndex].id,n=this.data.currentGroup;this._setHash(n,o,this.data.currentIndex),window.scroll(t,e)}},{key:"_setHash",value:function(t,e,r){if(window.history&&window.history.pushState&&this.data.useHistoryApi&&this.data.oldIndex!==r){var o=""+location.pathname+location.search,n=void 0;switch(void 0!==t&&void 0!==e&&(o+="#group="+t+"&photo="+e,n={group:t,id:e,index:r}),this.data.historyApiMethod){case"push":window.history.pushState(n,null,o);break;case"replace":default:window.history.replaceState(n,null,o)}}}},{key:"_getCurrentItemByHash",value:function(){var t=this.data.group,e=location.hash.substr(1),r=l.parseQuery(e),o=null,n=function(t){r.group===t.groupId&&r.photo===t.id&&(o=t)};return Object.keys(t).forEach(function(e){t[e].forEach(n)}),o}},{key:"_loadItem",value:function(t){return new h(function(e){var r=new Image;r.onload=function(){t.width=r.width,t.height=r.height,t.loaded=!0,e()},r.onerror=function(){e()},r.src=t.src})}},{key:"_setSizeByScreen",value:function(){var t=this._getWindowWidth(),e=this._getWindowHeight(),r=this.data.headerHeight,o=this.data.footerHeight,n=e-(r+o);this.groupItems().forEach(function(r){r.loaded&&(r.processed=!0,r.scale=n/r.height,r.heightt&&(r.scale=t/r.width,r.x=(r.scale-1)/2*r.width))})}},{key:"_slideList",value:function(t){var e=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(),t||this._setHashByCurrentIndex(),this._setSizeByScreen(),setTimeout(function(){e.data.onMoveClass=!1,e.setArrow(),e.update(),e.data.oldIndex!==e.data.currentIndex&&e._fireEvent("change"),e.data.oldIndex=e.data.currentIndex},200)}},{key:"gotoSlide",value:function(t,e){this.e&&this.e.preventDefault&&this.e.preventDefault(),this.data.currentIndex=parseInt(t,10),this.data.currentIndex||(this.data.currentIndex=0),this._slideList(e)}},{key:"setArrow",value:function(){var t=this.groupItems(),e=t.length,r=this.data.currentIndex+1,o=this.data.currentIndex-1;this.data.showNextArrow=!1,this.data.showPrevArrow=!1,r!==e&&(this.data.next=r,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,r=e.getTime(),o=this.tapSecond-r,n=0,i=0;return this.isSwipable=!1,this.onListMove=!1,this.oldPos&&(n=this.oldPos.x-this.firstPos.x,i=this.oldPos.y-this.firstPos.y),this.isBeingZoomed?void this.afterGesture():this.data.scale?void this.afterPhotoDrag():l.isSmartPhone()||0!==n||0!==i?Math.abs(o)<=500&&0===n&&0===i?(this.e.preventDefault(),void this.zoomPhoto()):(this.tapSecond=r,this._fireEvent("swipeend"),"horizontal"===this.moveDir&&(n>=this.data.swipeOffset&&0!==this.data.currentIndex?this.data.currentIndex-=1:n<=-this.data.swipeOffset&&this.data.currentIndex!==t.length-1&&(this.data.currentIndex+=1),this._slideList()),void("vertical"===this.moveDir&&(this.data.swipeBottomToClose&&i>=this.data.swipeOffset?this.hidePhoto("bottom"):this.data.swipeTopToClose&&i<=-this.data.swipeOffset?this.hidePhoto("top"):(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,r=t.y-this.firstPos.y;this.dragStart&&(this._fireEvent("swipestart"),this.dragStart=!1,Math.abs(e)>Math.abs(r)?this.moveDir="horizontal":this.moveDir="vertical"),"horizontal"===this.moveDir?(this.pos.x+=e,this.data.translateX=this.pos.x):this.data.translateY=r,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.scaleSize<=1||(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,r=t.y-this.oldPhotoPos.y,o=this._round(this.data.scaleSize*e,6),n=this._round(this.data.scaleSize*r,6);"number"==typeof o&&(this.data.photoPosX+=o,this.photoVX=o),"number"==typeof n&&(this.data.photoPosY+=n,this.photoVY=n),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),r=this.data.swipeOffset*this.data.scaleSize,o=0,n=0;if(this.data.photoPosX>e.maxX?o=-1:this.data.photoPosXe.maxY?n=-1:this.data.photoPosYr&&0!==this.data.currentIndex)return void this.gotoSlide(this.data.prev);if(e.minX-this.data.photoPosX>r&&this.data.currentIndex+1!==this.data.total)return void this.gotoSlide(this.data.next);0===o&&0===n?(this.vx=this.photoVX/5,this.vy=this.photoVY/5):this._registerElasticForce(o,n)}}},{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]),r=(e-this.oldDistance)/100,o=this.data.scaleSize,n=this.data.photoPosX,i=this.data.photoPosY;this.isBeingZoomed=!0,this.data.scaleSize+=this._round(r,6),this.data.scaleSize<.2&&(this.data.scaleSize=.2),this.data.scaleSizethis._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(),r=this._getWindowHeight();return l.isSmartPhone()?t.width>t.height?r/(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,r=t.height*t.scale*this.data.scaleSize,o=void 0,n=void 0,i=void 0,a=void 0,s=this._getWindowWidth(),c=this._getWindowHeight();return s>e?(i=(s-e)/2,o=-1*i):(i=(e-s)/2,o=-1*i),c>r?(a=(c-r)/2,n=-1*a):(a=(r-c)/2,n=-1*a),{minX:this._round(o,6)*this.data.scaleSize,minY:this._round(n,6)*this.data.scaleSize,maxX:this._round(i,6)*this.data.scaleSize,maxY:this._round(a,6)*this.data.scaleSize}}},{key:"_registerElasticForce",value:function(t,e){var r=this,o=this._getSelectedItem(),n=this._makeBound(o);this.data.elastic=!0,1===t?this.data.photoPosX=n.minX:-1===t&&(this.data.photoPosX=n.maxX),1===e?this.data.photoPosY=n.minY:-1===e&&(this.data.photoPosY=n.maxY),this._photoUpdate(),setTimeout(function(){r.data.elastic=!1,r._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 r=t.x-e.x,o=t.y-e.y;return Math.sqrt(r*r+o*o)}},{key:"_round",value:function(t,e){var r=Math.pow(10,e);return t*=r,t=Math.round(t),t/=r}},{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"),r=e.querySelector("."+t.smartPhotoImg),o=this._getElementByQuery("."+t.smartPhotoNav),n=this._getElementByQuery("."+t.smartPhotoArrows),i=this.virtualPos(this.data.photoPosX),a=this.virtualPos(this.data.photoPosY),s=this.data.scaleSize,c="translate("+i+"px,"+a+"px) scale("+s+")";r.style.transform=c,this.data.scale?l.addClass(r,t.smartPhotoImgOnMove):l.removeClass(r,t.smartPhotoImgOnMove),this.data.elastic?l.addClass(r,t.smartPhotoImgElasticMove):l.removeClass(r,t.smartPhotoImgElasticMove),this.data.hideUi?(o&&o.setAttribute("aria-hidden","true"),n&&n.setAttribute("aria-hidden","true")):(o&&o.setAttribute("aria-hidden","false"),n&&n.setAttribute("aria-hidden","false"))}},{key:"_getWindowWidth",value:function(){return document&&document.documentElement?document.documentElement.clientWidth:window&&window.innerWidth?window.innerWidth:0}},{key:"_getWindowHeight",value:function(){return document&&document.documentElement?document.documentElement.clientHeight:window&&window.innerHeight?window.innerHeight:0}},{key:"_listUpdate",value:function(){var t=this.data.classNames,e=this._getElementByQuery("."+t.smartPhotoList),r="translate("+this.data.translateX+"px,"+this.data.translateY+"px)";e.style.transform=r,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.photoPosXe.maxX&&(this.data.photoPosX=e.maxX,this.vx*=-.2),this.data.photoPosYe.maxY&&(this.data.photoPosY=e.maxY,this.vy*=-.2);var r=this._getForceAndTheta(this.vx,this.vy),o=r.force,n=r.theta;o-=this.data.registance,Math.abs(o)<.5||(this.vx=Math.cos(n)*o,this.vy=Math.sin(n)*o,this._photoUpdate())}}}]),e}(c.default);r.default=f,e.exports=r.default},{"../lib/util":36,"a-template":1,"custom-event-polyfill":7,"es6-promise-polyfill":21}],35:[function(t,e,r){"use strict";e.exports=t("./core/")},{"./core/":34}],36:[function(t,e,r){"use strict";function o(t){t=t||{};for(var e=1;e0||t.indexOf("iPad")>0||t.indexOf("ipod")>0||t.indexOf("Android")>0},e.exports.extend=o,e.exports.triggerEvent=function(t,e,r){var o=void 0;window.CustomEvent?o=new CustomEvent(e,{cancelable:!0}):(o=document.createEvent("CustomEvent"),o.initCustomEvent(e,!1,!1,r)),t.dispatchEvent(o)},e.exports.parseQuery=function(t){for(var e,r,o,n=t.split("&"),i={},a=0,s=n.length;a, steelydylan * version: 0.5.1 * * array.prototype.find: * license: MIT (http://opensource.org/licenses/MIT) * author: Paul Miller - * maintainers: ljharb , paulmillr * contributors: Duncan Hall * homepage: https://github.com/paulmillr/Array.prototype.find#readme * version: 2.0.4 * * custom-event-polyfill: * license: MIT (http://opensource.org/licenses/MIT) - * maintainers: krambuhl * contributors: Frank Panetta, Mikhail Reenko , Joscha Feth * homepage: https://github.com/krambuhl/custom-event-polyfill#readme * version: 0.3.0 @@ -32,14 +29,12 @@ * define-properties: * license: MIT (http://opensource.org/licenses/MIT) * author: Jordan Harband - * maintainers: ljharb * homepage: https://github.com/ljharb/define-properties#readme * version: 1.1.2 * * es-abstract: * license: MIT (http://opensource.org/licenses/MIT) * author: Jordan Harband - * maintainers: ljharb * contributors: Jordan Harband * homepage: https://github.com/ljharb/es-abstract#readme * version: 1.10.0 @@ -47,29 +42,25 @@ * es-to-primitive: * license: MIT (http://opensource.org/licenses/MIT) * author: Jordan Harband - * maintainers: ljharb * homepage: https://github.com/ljharb/es-to-primitive#readme * version: 1.1.1 * * es6-promise-polyfill: * license: MIT (http://opensource.org/licenses/MIT) * author: Roman Dvornov - * maintainers: lahmatiy * homepage: https://github.com/lahmatiy/es6-promise-polyfill#readme * version: 1.2.0 * * foreach: * license: MIT (http://opensource.org/licenses/MIT) * author: Manuel Stofer - * maintainers: manuelstofer * contributors: Manuel Stofer, Jordan Harband - * homepage: https://github.com/manuelstofer/foreach + * homepage: https://github.com/manuelstofer/foreach#readme * version: 2.0.5 * * function-bind: * license: MIT (http://opensource.org/licenses/MIT) * author: Raynos - * maintainers: raynos , ljharb * contributors: Raynos, Jordan Harband * homepage: https://github.com/Raynos/function-bind * version: 1.1.1 @@ -77,14 +68,12 @@ * has: * licenses: MIT (http://opensource.org/licenses/MIT) * author: Thiago de Arruda - * maintainers: tarruda * homepage: https://github.com/tarruda/has * version: 1.0.1 * * is-callable: * license: MIT (http://opensource.org/licenses/MIT) * author: Jordan Harband - * maintainers: ljharb * contributors: Jordan Harband * homepage: https://github.com/ljharb/is-callable#readme * version: 1.1.3 @@ -92,35 +81,30 @@ * is-date-object: * license: MIT (http://opensource.org/licenses/MIT) * author: Jordan Harband - * maintainers: ljharb * homepage: https://github.com/ljharb/is-date-object#readme * version: 1.0.1 * * is-regex: * license: MIT (http://opensource.org/licenses/MIT) * author: Jordan Harband - * maintainers: ljharb * homepage: https://github.com/ljharb/is-regex * version: 1.0.4 * * is-symbol: * license: MIT (http://opensource.org/licenses/MIT) * author: Jordan Harband - * maintainers: ljharb - * homepage: https://github.com/ljharb/is-symbol + * homepage: https://github.com/ljharb/is-symbol#readme * version: 1.0.1 * * morphdom: * license: MIT (http://opensource.org/licenses/MIT) * author: Patrick Steele-Idem - * maintainers: mlrawlings , pnidem * homepage: https://github.com/patrick-steele-idem/morphdom#readme * version: 2.3.3 * * object-keys: * license: MIT (http://opensource.org/licenses/MIT) * author: Jordan Harband - * maintainers: ljharb * contributors: Jordan Harband , Raynos , Nathan Rajlich , Ivan Starkov , Gary Katsevman * homepage: https://github.com/ljharb/object-keys#readme * version: 1.0.11 @@ -3389,6 +3373,7 @@ var defaults = { verticalGravity: false, useOrientationApi: false, useHistoryApi: true, + historyApiMethod: 'replace', swipeTopToClose: false, swipeBottomToClose: true, swipeOffset: 100, @@ -3452,6 +3437,45 @@ var SmartPhoto = function (_ATemplate) { _this._doAnim(); }, _this.data.forceInterval); + // IF history API is enabled + // > setup history event listener + if (_this.data.useHistoryApi && _this.data.historyApiMethod === 'push') { + + window.onpopstate = function (event) { + + // if state is not set - the gallery was hidden in this history state + if (!event || !event.state || event.state.group === void 0 || event.state.index === void 0) { + _this.hidePhoto(); + return; + } + + // geting photo info from state object + _this.data.currentGroup = event.state.group; + _this.data.currentIndex = event.state.index; + var currentItem = _this._getSelectedItem(); + + if (currentItem.loaded) { + _this._initPhoto(); + _this.data.appear = true; + _this.clicked = true; + _this.update(); + body.style.overflow = 'hidden'; + _this._fireEvent('open'); + } else { + _this._loadItem(currentItem).then(function () { + _this._initPhoto(); + _this.data.appear = true; + _this.clicked = true; + _this.update(); + body.style.overflow = 'hidden'; + _this._fireEvent('open'); + }); + } + + _this.gotoSlide(event.state.index, true); // <- don't update history + }; + } + if (!_this.data.isSmartPhone) { window.addEventListener('resize', function () { if (!_this.groupItems()) { @@ -3763,7 +3787,7 @@ var SmartPhoto = function (_ATemplate) { var scrollY = window.scrollY; var body = document.querySelector('body'); if (location.hash) { - this._setHash(''); + this._setHash(); } window.scroll(scrollX, scrollY); this._doHideEffect(dir).then(function () { @@ -3848,20 +3872,40 @@ var SmartPhoto = function (_ATemplate) { var items = this.groupItems(); var id = items[this.data.currentIndex].id; var group = this.data.currentGroup; - var hash = 'group=' + group + '&photo=' + id; - this._setHash(hash); + this._setHash(group, id, this.data.currentIndex); window.scroll(scrollX, scrollY); } }, { key: '_setHash', - value: function _setHash(hash) { + value: function _setHash(group, id, index) { + if (!(window.history && window.history.pushState) || !this.data.useHistoryApi) { return; } - if (hash) { - window.history.replaceState(null, null, '' + location.pathname + location.search + '#' + hash); - } else { - window.history.replaceState(null, null, '' + location.pathname + location.search); + + // if the displayed image has not changed + // > don't change history + if (this.data.oldIndex === index) { + return; + } + + var newUrl = '' + location.pathname + location.search, + newState = void 0; + + // if `group` od `id` are not set + // > don't construct new state + if (group !== void 0 && id !== void 0) { + newUrl += '#group=' + group + '&photo=' + id; + newState = { group: group, id: id, index: index }; + } + + switch (this.data.historyApiMethod) { + case 'push': + window.history.pushState(newState, null, newUrl); + break; + case 'replace': + default: + window.history.replaceState(newState, null, newUrl); } } }, { @@ -3926,7 +3970,7 @@ var SmartPhoto = function (_ATemplate) { } }, { key: '_slideList', - value: function _slideList() { + value: function _slideList(skipHistory) { var _this10 = this; this.data.scaleSize = 1; @@ -3937,7 +3981,11 @@ var SmartPhoto = function (_ATemplate) { this.data.photoPosY = 0; this.data.onMoveClass = true; this._setPosByCurrentIndex(); - this._setHashByCurrentIndex(); + + if (!skipHistory) { + this._setHashByCurrentIndex(); + } + this._setSizeByScreen(); setTimeout(function () { _this10.data.onMoveClass = false; @@ -3951,7 +3999,7 @@ var SmartPhoto = function (_ATemplate) { } }, { key: 'gotoSlide', - value: function gotoSlide(index) { + value: function gotoSlide(index, skipHistory) { if (this.e && this.e.preventDefault) { this.e.preventDefault(); } @@ -3959,7 +4007,7 @@ var SmartPhoto = function (_ATemplate) { if (!this.data.currentIndex) { this.data.currentIndex = 0; } - this._slideList(); + this._slideList(skipHistory); } }, { key: 'setArrow', diff --git a/js/smartphoto.min.js b/js/smartphoto.min.js index aa06f69..1503b87 100644 --- a/js/smartphoto.min.js +++ b/js/smartphoto.min.js @@ -11,20 +11,17 @@ * a-template: * license: MIT (http://opensource.org/licenses/MIT) * author: steelydylan - * maintainers: appleple , steelydylan * version: 0.5.1 * * array.prototype.find: * license: MIT (http://opensource.org/licenses/MIT) * author: Paul Miller - * maintainers: ljharb , paulmillr * contributors: Duncan Hall * homepage: https://github.com/paulmillr/Array.prototype.find#readme * version: 2.0.4 * * custom-event-polyfill: * license: MIT (http://opensource.org/licenses/MIT) - * maintainers: krambuhl * contributors: Frank Panetta, Mikhail Reenko , Joscha Feth * homepage: https://github.com/krambuhl/custom-event-polyfill#readme * version: 0.3.0 @@ -32,14 +29,12 @@ * define-properties: * license: MIT (http://opensource.org/licenses/MIT) * author: Jordan Harband - * maintainers: ljharb * homepage: https://github.com/ljharb/define-properties#readme * version: 1.1.2 * * es-abstract: * license: MIT (http://opensource.org/licenses/MIT) * author: Jordan Harband - * maintainers: ljharb * contributors: Jordan Harband * homepage: https://github.com/ljharb/es-abstract#readme * version: 1.10.0 @@ -47,29 +42,25 @@ * es-to-primitive: * license: MIT (http://opensource.org/licenses/MIT) * author: Jordan Harband - * maintainers: ljharb * homepage: https://github.com/ljharb/es-to-primitive#readme * version: 1.1.1 * * es6-promise-polyfill: * license: MIT (http://opensource.org/licenses/MIT) * author: Roman Dvornov - * maintainers: lahmatiy * homepage: https://github.com/lahmatiy/es6-promise-polyfill#readme * version: 1.2.0 * * foreach: * license: MIT (http://opensource.org/licenses/MIT) * author: Manuel Stofer - * maintainers: manuelstofer * contributors: Manuel Stofer, Jordan Harband - * homepage: https://github.com/manuelstofer/foreach + * homepage: https://github.com/manuelstofer/foreach#readme * version: 2.0.5 * * function-bind: * license: MIT (http://opensource.org/licenses/MIT) * author: Raynos - * maintainers: raynos , ljharb * contributors: Raynos, Jordan Harband * homepage: https://github.com/Raynos/function-bind * version: 1.1.1 @@ -77,14 +68,12 @@ * has: * licenses: MIT (http://opensource.org/licenses/MIT) * author: Thiago de Arruda - * maintainers: tarruda * homepage: https://github.com/tarruda/has * version: 1.0.1 * * is-callable: * license: MIT (http://opensource.org/licenses/MIT) * author: Jordan Harband - * maintainers: ljharb * contributors: Jordan Harband * homepage: https://github.com/ljharb/is-callable#readme * version: 1.1.3 @@ -92,41 +81,36 @@ * is-date-object: * license: MIT (http://opensource.org/licenses/MIT) * author: Jordan Harband - * maintainers: ljharb * homepage: https://github.com/ljharb/is-date-object#readme * version: 1.0.1 * * is-regex: * license: MIT (http://opensource.org/licenses/MIT) * author: Jordan Harband - * maintainers: ljharb * homepage: https://github.com/ljharb/is-regex * version: 1.0.4 * * is-symbol: * license: MIT (http://opensource.org/licenses/MIT) * author: Jordan Harband - * maintainers: ljharb - * homepage: https://github.com/ljharb/is-symbol + * homepage: https://github.com/ljharb/is-symbol#readme * version: 1.0.1 * * morphdom: * license: MIT (http://opensource.org/licenses/MIT) * author: Patrick Steele-Idem - * maintainers: mlrawlings , pnidem * homepage: https://github.com/patrick-steele-idem/morphdom#readme * version: 2.3.3 * * object-keys: * license: MIT (http://opensource.org/licenses/MIT) * author: Jordan Harband - * maintainers: ljharb * contributors: Jordan Harband , Raynos , Nathan Rajlich , Ivan Starkov , Gary Katsevman * homepage: https://github.com/ljharb/object-keys#readme * version: 1.0.11 * * This header is generated by licensify (https://github.com/twada/licensify) */ -!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(){var t;return function(){function t(e,r,o){function n(a,s){if(!r[a]){if(!e[a]){var c="function"==typeof require&&require;if(!s&&c)return c(a,!0);if(i)return i(a,!0);var u=new Error("Cannot find module '"+a+"'");throw u.code="MODULE_NOT_FOUND",u}var l=r[a]={exports:{}};e[a][0].call(l.exports,function(t){var r=e[a][1][t];return n(r||t)},l,l.exports,t,e,r,o)}return r[a].exports}for(var i="function"==typeof require&&require,a=0;a1;)r=r[o.shift()];r[o.shift()]=e}},{key:"removeDataByString",value:function(t){for(var e=this.data,r=t.split(".");r.length>1;)e=e[r.shift()];var o=r.shift();o.match(/^\d+$/)?e.splice(Number(o),1):delete e[o]}},{key:"resolveBlock",value:function(t,e,r){var o=this,n=t.match(//g),i=t.match(//g),a=t.match(//g),s=t.match(//g);if(n)for(var c=0,u=n.length;c/g;return t=t.replace(e,function(t,e){return(0,a.selector)("#"+e).innerHTML})}},{key:"resolveWith",value:function(t){var e=/(([\n\r\t]|.)*?)/g;return t=t.replace(e,function(t,e){return t=t.replace(/data\-bind=['"](.*?)['"]/g,"data-bind='"+e+".$1'")})}},{key:"resolveLoop",value:function(t){var e=/(([\n\r\t]|.)*?)/g,r=this;return t=t.replace(e,function(t,e,o){var n=r.getDataByString(e),i=[];i="function"==typeof n?n.apply(r):n;var a="";if(i instanceof Array)for(var s=0,c=i.length;s(([\n\r\t]|.)*?)/g;return!!t.match(e)}},{key:"getHtml",value:function(t,e){var r=c(this.atemplate,function(e){return e.id===t}),o="";if(r&&r.html&&(o=r.html),e&&(o=t),!o)return"";var n=this.data;for(o=this.resolveInclude(o),o=this.resolveWith(o);this.hasLoop(o);)o=this.resolveLoop(o);return o=this.resolveBlock(o,n),o=o.replace(/\\([^\\])/g,"$1"),o=this.resolveAbsBlock(o),o.replace(/^([\t ])*\n/gm,"")}},{key:"update",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"html",r=arguments[1],o=this.templates;this.beforeUpdated&&this.beforeUpdated();for(var n=0,i=o.length;n"+h+"");else(0,a.selector)(l).insertAdjacentHTML("afterend",'
'),"text"===e?(0,a.selector)("[data-id='"+u+"']").innerText=h:(0,a.selector)("[data-id='"+u+"']").innerHTML=h;var m=c(t.atemplate,function(t){return t.id===u});m.binded||(m.binded=!0,t.addDataBind((0,a.selector)("[data-id='"+u+"']")),t.addActionBind((0,a.selector)("[data-id='"+u+"']")))}(n);return this.updateBindingData(r),this.onUpdated&&this.onUpdated(r),this}},{key:"updateBindingData",value:function(t){for(var e=this,r=this.templates,o=0,n=r.length;o1?r-1:0),n=1;n1;)e=e[r.shift()];var o=r.shift();return o.match(/^\d+$/)?e.splice(Number(o),1):delete e[o],this}}]),t}();r.default=h,e.exports=r.default},{"./util":2,"array.prototype.find":4,morphdom:30}],2:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=r.matches=function(t,e){for(var r=(t.document||t.ownerDocument).querySelectorAll(e),o=r.length;--o>=0&&r.item(o)!==t;);return o>-1},n=(r.selector=function(t){return document.querySelector(t)},r.findAncestor=function(t,e){if("function"==typeof t.closest)return t.closest(e)||null;for(;t&&t!==document;){if(o(t,e))return t;t=t.parentElement}return null});r.on=function(t,e,r,o){r.split(" ").forEach(function(r){t.addEventListener(r,function(t){var r=(t.target,n(t.target,e));r&&(t.delegateTarget=r,o(t))})})}},{}],3:[function(t,e,r){"use strict";var o=t("es-abstract/es6");e.exports=function(t){var e=o.ToObject(this),r=o.ToInteger(o.ToLength(e.length));if(!o.IsCallable(t))throw new TypeError("Array#find: predicate must be a function");if(0!==r)for(var n,i=arguments[1],a=0;a2?arguments[2]:{},a=o(e);i&&(a=a.concat(Object.getOwnPropertySymbols(e))),n(a,function(o){u(t,o,e[o],r[o])})};l.supportsDescriptors=!!c,e.exports=l},{foreach:22,"object-keys":31}],9:[function(t,e,r){"use strict";var o=t("has"),n=t("es-to-primitive/es6"),i=Object.prototype.toString,a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator,s=t("./helpers/isNaN"),c=t("./helpers/isFinite"),u=Number.MAX_SAFE_INTEGER||Math.pow(2,53)-1,l=t("./helpers/assign"),h=t("./helpers/sign"),d=t("./helpers/mod"),f=t("./helpers/isPrimitive"),p=parseInt,y=t("function-bind"),m=y.call(Function.call,Array.prototype.slice),v=y.call(Function.call,String.prototype.slice),g=y.call(Function.call,RegExp.prototype.test,/^0b[01]+$/i),b=y.call(Function.call,RegExp.prototype.test,/^0o[0-7]+$/i),w=y.call(Function.call,RegExp.prototype.exec),x=["…","​","￾"].join(""),P=new RegExp("["+x+"]","g"),E=y.call(Function.call,RegExp.prototype.test,P),S=/^[-+]0x[0-9a-f]+$/i,I=y.call(Function.call,RegExp.prototype.test,S),N=["\t\n\v\f\r   ᠎    ","          \u2028","\u2029\ufeff"].join(""),T=new RegExp("(^["+N+"]+)|(["+N+"]+$)","g"),_=y.call(Function.call,String.prototype.replace),O=function(t){return _(t,T,"")},D=t("./es5"),j=t("is-regex"),A=l(l({},D),{Call:function(t,e){var r=arguments.length>2?arguments[2]:[];if(!this.IsCallable(t))throw new TypeError(t+" is not a function");return t.apply(e,r)},ToPrimitive:n,ToNumber:function(t){var e=f(t)?t:n(t,Number);if("symbol"==typeof e)throw new TypeError("Cannot convert a Symbol value to a number");if("string"==typeof e){if(g(e))return this.ToNumber(p(v(e,2),2));if(b(e))return this.ToNumber(p(v(e,2),8));if(E(e)||I(e))return NaN;var r=O(e);if(r!==e)return this.ToNumber(r)}return Number(e)},ToInt16:function(t){var e=this.ToUint16(t);return e>=32768?e-65536:e},ToInt8:function(t){var e=this.ToUint8(t);return e>=128?e-256:e},ToUint8:function(t){var e=this.ToNumber(t);if(s(e)||0===e||!c(e))return 0;var r=h(e)*Math.floor(Math.abs(e));return d(r,256)},ToUint8Clamp:function(t){var e=this.ToNumber(t);if(s(e)||e<=0)return 0;if(e>=255)return 255;var r=Math.floor(t);return r+.5u?u:e},CanonicalNumericIndexString:function(t){if("[object String]"!==i.call(t))throw new TypeError("must be a string");if("-0"===t)return-0;var e=this.ToNumber(t);return this.SameValue(this.ToString(e),t)?e:void 0},RequireObjectCoercible:D.CheckObjectCoercible,IsArray:Array.isArray||function(t){return"[object Array]"===i.call(t)},IsConstructor:function(t){return"function"==typeof t&&!!t.prototype},IsExtensible:function(t){return!Object.preventExtensions||!f(t)&&Object.isExtensible(t)},IsInteger:function(t){if("number"!=typeof t||s(t)||!c(t))return!1;var e=Math.abs(t);return Math.floor(e)===e},IsPropertyKey:function(t){return"string"==typeof t||"symbol"==typeof t},IsRegExp:function(t){if(!t||"object"!=typeof t)return!1;if(a){var e=t[Symbol.match];if(void 0!==e)return D.ToBoolean(e)}return j(t)},SameValueZero:function(t,e){return t===e||s(t)&&s(e)},GetV:function(t,e){if(!this.IsPropertyKey(e))throw new TypeError("Assertion failed: IsPropertyKey(P) is not true");return this.ToObject(t)[e]},GetMethod:function(t,e){if(!this.IsPropertyKey(e))throw new TypeError("Assertion failed: IsPropertyKey(P) is not true");var r=this.GetV(t,e);if(null!=r){if(!this.IsCallable(r))throw new TypeError(e+"is not a function");return r}},Get:function(t,e){if("Object"!==this.Type(t))throw new TypeError("Assertion failed: Type(O) is not Object");if(!this.IsPropertyKey(e))throw new TypeError("Assertion failed: IsPropertyKey(P) is not true");return t[e]},Type:function(t){return"symbol"==typeof t?"Symbol":D.Type(t)},SpeciesConstructor:function(t,e){if("Object"!==this.Type(t))throw new TypeError("Assertion failed: Type(O) is not Object");var r=t.constructor;if(void 0===r)return e;if("Object"!==this.Type(r))throw new TypeError("O.constructor is not an Object");var o=a&&Symbol.species?r[Symbol.species]:void 0;if(null==o)return e;if(this.IsConstructor(o))return o;throw new TypeError("no constructor found")},CompletePropertyDescriptor:function(t){if(!this.IsPropertyDescriptor(t))throw new TypeError("Desc must be a Property Descriptor");return this.IsGenericDescriptor(t)||this.IsDataDescriptor(t)?(o(t,"[[Value]]")||(t["[[Value]]"]=void 0),o(t,"[[Writable]]")||(t["[[Writable]]"]=!1)):(o(t,"[[Get]]")||(t["[[Get]]"]=void 0),o(t,"[[Set]]")||(t["[[Set]]"]=void 0)),o(t,"[[Enumerable]]")||(t["[[Enumerable]]"]=!1),o(t,"[[Configurable]]")||(t["[[Configurable]]"]=!1),t},Set:function(t,e,r,o){if("Object"!==this.Type(t))throw new TypeError("O must be an Object");if(!this.IsPropertyKey(e))throw new TypeError("P must be a Property Key");if("Boolean"!==this.Type(o))throw new TypeError("Throw must be a Boolean");if(o)return t[e]=r,!0;try{t[e]=r}catch(t){return!1}},HasOwnProperty:function(t,e){if("Object"!==this.Type(t))throw new TypeError("O must be an Object");if(!this.IsPropertyKey(e))throw new TypeError("P must be a Property Key");return o(t,e)},HasProperty:function(t,e){if("Object"!==this.Type(t))throw new TypeError("O must be an Object");if(!this.IsPropertyKey(e))throw new TypeError("P must be a Property Key");return e in t},IsConcatSpreadable:function(t){if("Object"!==this.Type(t))return!1;if(a&&"symbol"==typeof Symbol.isConcatSpreadable){var e=this.Get(t,Symbol.isConcatSpreadable);if(void 0!==e)return this.ToBoolean(e)}return this.IsArray(t)},Invoke:function(t,e){if(!this.IsPropertyKey(e))throw new TypeError("P must be a Property Key");var r=m(arguments,2),o=this.GetV(t,e);return this.Call(o,t,r)},CreateIterResultObject:function(t,e){if("Boolean"!==this.Type(e))throw new TypeError("Assertion failed: Type(done) is not Boolean");return{value:t,done:e}},RegExpExec:function(t,e){if("Object"!==this.Type(t))throw new TypeError("R must be an Object");if("String"!==this.Type(e))throw new TypeError("S must be a String");var r=this.Get(t,"exec");if(this.IsCallable(r)){var o=this.Call(r,t,[e]);if(null===o||"Object"===this.Type(o))return o;throw new TypeError('"exec" method must return `null` or an Object')}return w(t,e)},ArraySpeciesCreate:function(t,e){if(!this.IsInteger(e)||e<0)throw new TypeError("Assertion failed: length must be an integer >= 0");var r,o=0===e?0:e;if(this.IsArray(t)&&(r=this.Get(t,"constructor"),"Object"===this.Type(r)&&a&&Symbol.species&&null===(r=this.Get(r,Symbol.species))&&(r=void 0)),void 0===r)return Array(o);if(!this.IsConstructor(r))throw new TypeError("C must be a constructor");return new r(o)},CreateDataProperty:function(t,e,r){if("Object"!==this.Type(t))throw new TypeError("Assertion failed: Type(O) is not Object");if(!this.IsPropertyKey(e))throw new TypeError("Assertion failed: IsPropertyKey(P) is not true");var o=Object.getOwnPropertyDescriptor(t,e),n=o||"function"!=typeof Object.isExtensible||Object.isExtensible(t);if(o&&(!o.writable||!o.configurable)||!n)return!1;var i={configurable:!0,enumerable:!0,value:r,writable:!0};return Object.defineProperty(t,e,i),!0},CreateDataPropertyOrThrow:function(t,e,r){if("Object"!==this.Type(t))throw new TypeError("Assertion failed: Type(O) is not Object");if(!this.IsPropertyKey(e))throw new TypeError("Assertion failed: IsPropertyKey(P) is not true");var o=this.CreateDataProperty(t,e,r);if(!o)throw new TypeError("unable to create data property");return o},AdvanceStringIndex:function(t,e,r){if("String"!==this.Type(t))throw new TypeError("Assertion failed: Type(S) is not String");if(!this.IsInteger(e))throw new TypeError("Assertion failed: length must be an integer >= 0 and <= (2**53 - 1)");if(e<0||e>u)throw new RangeError("Assertion failed: length must be an integer >= 0 and <= (2**53 - 1)");if("Boolean"!==this.Type(r))throw new TypeError("Assertion failed: Type(unicode) is not Boolean");if(!r)return e+1;if(e+1>=t.length)return e+1;var o=t.charCodeAt(e);if(o<55296||o>56319)return e+1;var n=t.charCodeAt(e+1);return n<56320||n>57343?e+1:e+2}});delete A.CheckObjectCoercible,e.exports=A},{"./es5":10,"./helpers/assign":12,"./helpers/isFinite":13,"./helpers/isNaN":14,"./helpers/isPrimitive":15,"./helpers/mod":16,"./helpers/sign":17,"es-to-primitive/es6":19,"function-bind":24,has:25,"is-regex":28}],10:[function(t,e,r){"use strict";var o=t("./helpers/isNaN"),n=t("./helpers/isFinite"),i=t("./helpers/sign"),a=t("./helpers/mod"),s=t("is-callable"),c=t("es-to-primitive/es5"),u=t("has"),l={ToPrimitive:c,ToBoolean:function(t){return!!t},ToNumber:function(t){return Number(t)},ToInteger:function(t){var e=this.ToNumber(t);return o(e)?0:0!==e&&n(e)?i(e)*Math.floor(Math.abs(e)):e},ToInt32:function(t){return this.ToNumber(t)>>0},ToUint32:function(t){return this.ToNumber(t)>>>0},ToUint16:function(t){var e=this.ToNumber(t);if(o(e)||0===e||!n(e))return 0;var r=i(e)*Math.floor(Math.abs(e));return a(r,65536)},ToString:function(t){return String(t)},ToObject:function(t){return this.CheckObjectCoercible(t),Object(t)},CheckObjectCoercible:function(t,e){if(null==t)throw new TypeError(e||"Cannot call method on "+t);return t},IsCallable:s,SameValue:function(t,e){return t===e?0!==t||1/t==1/e:o(t)&&o(e)},Type:function(t){return null===t?"Null":void 0===t?"Undefined":"function"==typeof t||"object"==typeof t?"Object":"number"==typeof t?"Number":"boolean"==typeof t?"Boolean":"string"==typeof t?"String":void 0},IsPropertyDescriptor:function(t){if("Object"!==this.Type(t))return!1;var e={"[[Configurable]]":!0,"[[Enumerable]]":!0,"[[Get]]":!0,"[[Set]]":!0,"[[Value]]":!0,"[[Writable]]":!0};for(var r in t)if(u(t,r)&&!e[r])return!1;var o=u(t,"[[Value]]"),n=u(t,"[[Get]]")||u(t,"[[Set]]");if(o&&n)throw new TypeError("Property Descriptors may not be both accessor and data descriptors");return!0},IsAccessorDescriptor:function(t){if(void 0===t)return!1;if(!this.IsPropertyDescriptor(t))throw new TypeError("Desc must be a Property Descriptor");return!(!u(t,"[[Get]]")&&!u(t,"[[Set]]"))},IsDataDescriptor:function(t){if(void 0===t)return!1;if(!this.IsPropertyDescriptor(t))throw new TypeError("Desc must be a Property Descriptor");return!(!u(t,"[[Value]]")&&!u(t,"[[Writable]]"))},IsGenericDescriptor:function(t){if(void 0===t)return!1;if(!this.IsPropertyDescriptor(t))throw new TypeError("Desc must be a Property Descriptor");return!this.IsAccessorDescriptor(t)&&!this.IsDataDescriptor(t)},FromPropertyDescriptor:function(t){if(void 0===t)return t;if(!this.IsPropertyDescriptor(t))throw new TypeError("Desc must be a Property Descriptor");if(this.IsDataDescriptor(t))return{value:t["[[Value]]"],writable:!!t["[[Writable]]"],enumerable:!!t["[[Enumerable]]"],configurable:!!t["[[Configurable]]"]};if(this.IsAccessorDescriptor(t))return{get:t["[[Get]]"],set:t["[[Set]]"],enumerable:!!t["[[Enumerable]]"],configurable:!!t["[[Configurable]]"]};throw new TypeError("FromPropertyDescriptor must be called with a fully populated Property Descriptor")},ToPropertyDescriptor:function(t){if("Object"!==this.Type(t))throw new TypeError("ToPropertyDescriptor requires an object");var e={};if(u(t,"enumerable")&&(e["[[Enumerable]]"]=this.ToBoolean(t.enumerable)),u(t,"configurable")&&(e["[[Configurable]]"]=this.ToBoolean(t.configurable)),u(t,"value")&&(e["[[Value]]"]=t.value),u(t,"writable")&&(e["[[Writable]]"]=this.ToBoolean(t.writable)),u(t,"get")){var r=t.get;if(void 0!==r&&!this.IsCallable(r))throw new TypeError("getter must be a function");e["[[Get]]"]=r}if(u(t,"set")){var o=t.set;if(void 0!==o&&!this.IsCallable(o))throw new TypeError("setter must be a function");e["[[Set]]"]=o}if((u(e,"[[Get]]")||u(e,"[[Set]]"))&&(u(e,"[[Value]]")||u(e,"[[Writable]]")))throw new TypeError("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return e}};e.exports=l},{"./helpers/isFinite":13,"./helpers/isNaN":14,"./helpers/mod":16,"./helpers/sign":17,"es-to-primitive/es5":18,has:25,"is-callable":26}],11:[function(t,e,r){"use strict";e.exports=t("./es2015")},{"./es2015":9}],12:[function(t,e,r){var o=Object.prototype.hasOwnProperty;e.exports=function(t,e){if(Object.assign)return Object.assign(t,e);for(var r in e)o.call(e,r)&&(t[r]=e[r]);return t}},{}],13:[function(t,e,r){var o=Number.isNaN||function(t){return t!==t};e.exports=Number.isFinite||function(t){return"number"==typeof t&&!o(t)&&t!==1/0&&t!==-1/0}},{}],14:[function(t,e,r){e.exports=Number.isNaN||function(t){return t!==t}},{}],15:[function(t,e,r){e.exports=function(t){return null===t||"function"!=typeof t&&"object"!=typeof t}},{}],16:[function(t,e,r){e.exports=function(t,e){var r=t%e;return Math.floor(r>=0?r:r+e)}},{}],17:[function(t,e,r){e.exports=function(t){return t>=0?1:-1}},{}],18:[function(t,e,r){"use strict";var o=Object.prototype.toString,n=t("./helpers/isPrimitive"),i=t("is-callable"),a={"[[DefaultValue]]":function(t,e){var r=e||("[object Date]"===o.call(t)?String:Number);if(r===String||r===Number){var a,s,c=r===String?["toString","valueOf"]:["valueOf","toString"];for(s=0;s1&&(e===String?r="string":e===Number&&(r="number"));var i;if(o&&(Symbol.toPrimitive?i=u(t,Symbol.toPrimitive):s(t)&&(i=Symbol.prototype.valueOf)),void 0!==i){var l=i.call(t,r);if(n(l))return l;throw new TypeError("unable to convert exotic object to primitive")}return"default"===r&&(a(t)||s(t))&&(r="string"),c(t,"default"===r?"number":r)}},{"./helpers/isPrimitive":20,"is-callable":26,"is-date-object":27,"is-symbol":29}],20:[function(t,e,r){arguments[4][15][0].apply(r,arguments)},{dup:15}],21:[function(e,r,o){(function(e){!function(e){function r(t){return"[object Array]"===Object.prototype.toString.call(t)}function n(){for(var t=0;t90)&&r===o.toUpperCase()}function i(t,e){return e&&e!==f?p.createElementNS(e,t):p.createElement(t)}function a(t,e){for(var r=t.firstChild;r;){var o=r.nextSibling;e.appendChild(r),r=o}return e}function s(t,e){var r,o,n,i,a,s=e.attributes;for(r=s.length-1;r>=0;--r)o=s[r],n=o.name,i=o.namespaceURI,a=o.value,i?(n=o.localName||n,t.getAttributeNS(i,n)!==a&&t.setAttributeNS(i,n,a)):t.getAttribute(n)!==a&&t.setAttribute(n,a);for(s=t.attributes,r=s.length-1;r>=0;--r)o=s[r],!1!==o.specified&&(n=o.name,i=o.namespaceURI,i?(n=o.localName||n,m(e,i,n)||t.removeAttributeNS(i,n)):m(e,null,n)||t.removeAttribute(n))}function c(t,e,r){t[r]!==e[r]&&(t[r]=e[r],t[r]?t.setAttribute(r,""):t.removeAttribute(r,""))}function u(){}function l(t){return t.id}var h,d,f="http://www.w3.org/1999/xhtml",p="undefined"==typeof document?void 0:document,y=p?p.body||p.createElement("div"):{};d=y.hasAttributeNS?function(t,e,r){return t.hasAttributeNS(e,r)}:y.hasAttribute?function(t,e,r){return t.hasAttribute(r)}:function(t,e,r){return null!=t.getAttributeNode(e,r)};var m=d,v={OPTION:function(t,e){c(t,e,"selected")},INPUT:function(t,e){c(t,e,"checked"),c(t,e,"disabled"),t.value!==e.value&&(t.value=e.value),m(e,null,"value")||t.removeAttribute("value")},TEXTAREA:function(t,e){var r=e.value;t.value!==r&&(t.value=r);var o=t.firstChild;if(o){var n=o.nodeValue;if(n==r||!r&&n==t.placeholder)return;o.nodeValue=r}},SELECT:function(t,e){if(!m(e,null,"multiple")){for(var r=0,o=e.firstChild;o;){var n=o.nodeName;if(n&&"OPTION"===n.toUpperCase()){if(m(o,null,"selected")){r;break}r++}o=o.nextSibling}t.selectedIndex=r}}},g=1,b=3,w=8,x=function(t){return function(e,r,s){function c(t){P?P.push(t):P=[t]}function h(t,e){if(t.nodeType===g)for(var r=t.firstChild;r;){var o=void 0;e&&(o=E(r))?c(o):(O(r),r.firstChild&&h(r,e)),r=r.nextSibling}}function d(t,e,r){!1!==_(t)&&(e&&e.removeChild(t),O(t),h(t,r))}function f(t){if(t.nodeType===g)for(var e=t.firstChild;e;){var r=E(e);r&&(A[r]=e),f(e),e=e.nextSibling}}function y(t){I(t);for(var e=t.firstChild;e;){var r=e.nextSibling,o=E(e);if(o){var i=A[o];i&&n(e,i)&&(e.parentNode.replaceChild(i,e),m(i,e))}y(e),e=r}}function m(o,i,a){var s,u=E(i);if(u&&delete A[u],!r.isSameNode||!r.isSameNode(e)){if(!a){if(!1===N(o,i))return;if(t(o,i),T(o),!1===D(o,i))return}if("TEXTAREA"!==o.nodeName){var l,h,f,x,P=i.firstChild,I=o.firstChild;t:for(;P;){for(f=P.nextSibling,l=E(P);I;){if(h=I.nextSibling,P.isSameNode&&P.isSameNode(I)){P=f,I=h;continue t}s=E(I);var _=I.nodeType,O=void 0;if(_===P.nodeType&&(_===g?(l?l!==s&&((x=A[l])?I.nextSibling===x?O=!1:(o.insertBefore(x,I),h=I.nextSibling,s?c(s):d(I,o,!0),I=x):O=!1):s&&(O=!1),(O=!1!==O&&n(I,P))&&m(I,P)):_!==b&&_!=w||(O=!0,I.nodeValue!==P.nodeValue&&(I.nodeValue=P.nodeValue))),O){P=f,I=h;continue t}s?c(s):d(I,o,!0),I=h}if(l&&(x=A[l])&&n(x,P))o.appendChild(x),m(x,P);else{var j=S(P);!1!==j&&(j&&(P=j),P.actualize&&(P=P.actualize(o.ownerDocument||p)),o.appendChild(P),y(P))}P=f,I=h}for(;I;)h=I.nextSibling,(s=E(I))?c(s):d(I,o,!0),I=h}var k=v[o.nodeName];k&&k(o,i)}}if(s||(s={}),"string"==typeof r)if("#document"===e.nodeName||"HTML"===e.nodeName){var x=r;r=p.createElement("html"),r.innerHTML=x}else r=o(r);var P,E=s.getNodeKey||l,S=s.onBeforeNodeAdded||u,I=s.onNodeAdded||u,N=s.onBeforeElUpdated||u,T=s.onElUpdated||u,_=s.onBeforeNodeDiscarded||u,O=s.onNodeDiscarded||u,D=s.onBeforeElChildrenUpdated||u,j=!0===s.childrenOnly,A={};f(e);var k=e,C=k.nodeType,B=r.nodeType;if(!j)if(C===g)B===g?n(e,r)||(O(e),k=a(e,i(r.nodeName,r.namespaceURI))):k=r;else if(C===b||C===w){if(B===C)return k.nodeValue!==r.nodeValue&&(k.nodeValue=r.nodeValue),k;k=r}if(k===r)O(e);else if(m(k,r,j),P)for(var G=0,M=P.length;G0&&!o.call(t,0))for(var f=0;f0)for(var y=0;y=0&&"[object Function]"===o.call(t.callee)),r}},{}],33:[function(t,e,r){"use strict";function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(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 i(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)}Object.defineProperty(r,"__esModule",{value:!0});var a=function(){function t(t,e){for(var r=0;r"),[].forEach.call(i.elements,function(t){i.addNewItem(t)}),i.update(),i._getEachImageSize().then(function(){i._fireEvent("loadall");var t=i._getCurrentItemByHash();t&&l.triggerEvent(t.element,"click")}),setInterval(function(){i._doAnim()},i.data.forceInterval),i.data.isSmartPhone?(window.addEventListener("orientationchange",function(){i.groupItems()&&(i._resetTranslate(),i._setPosByCurrentIndex(),i._setHashByCurrentIndex(),i._setSizeByScreen(),i.update())}),i.data.useOrientationApi?(window.addEventListener("deviceorientation",function(t){var e=window.orientation;t&&t.gamma&&!i.data.appearEffect&&(i.isBeingZoomed||i.photoSwipable||i.data.elastic||!i.data.scale||(0===e?i._calcGravity(t.gamma,t.beta):90===e?i._calcGravity(t.beta,t.gamma):-90===e?i._calcGravity(-t.beta,-t.gamma):180===e&&i._calcGravity(-t.gamma,-t.beta)))}),i):n(i)):(window.addEventListener("resize",function(){i.groupItems()&&(i._resetTranslate(),i._setPosByCurrentIndex(),i._setSizeByScreen(),i.update())}),window.addEventListener("keydown",function(t){var e=t.keyCode||t.which;!0!==i.data.hide&&(37===e?i.gotoSlide(i.data.prev):39===e?i.gotoSlide(i.data.next):27===e&&i.hidePhoto())}),n(i))}return i(e,t),a(e,[{key:"on",value:function(t,e){var r=this;this._getElementByClass(this.data.classNames.smartPhoto).addEventListener(t,function(t){e.call(r,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,r=function(e){var r=new h(function(t,r){var o=new Image;o.onload=function(){e.width=o.width,e.height=o.height,e.loaded=!0,t()},o.onerror=function(){r()},o.src=e.src});t.push(r)};return Object.keys(e).forEach(function(t){e[t].forEach(r)}),h.all(t)}},{key:"_resetTranslate",value:function(){var t=this;this.groupItems().forEach(function(e,r){e.translateX=t._getWindowWidth()*r})}},{key:"addNewItem",value:function(t){var e=this,r=t.getAttribute("data-group")||"nogroup",o=this.data.group;"nogroup"===r&&t.setAttribute("data-group","nogroup"),o[r]||(o[r]=[]);var n=o[r].length,i=document.querySelector("body"),a={src:t.getAttribute("href"),caption:t.getAttribute("data-caption"),groupId:r,translateX:this._getWindowWidth()*n,index:n,translateY:0,width:50,height:50,id:t.getAttribute("data-id")||n,loaded:!1,processed:!1,element:t};o[r].push(a),this.data.currentGroup=r,t.getAttribute("data-id")||t.setAttribute("data-id",n),t.setAttribute("data-index",n),t.addEventListener("click",function(r){r.preventDefault(),e.data.currentGroup=t.getAttribute("data-group"),e.data.currentIndex=parseInt(t.getAttribute("data-index"),10),e._setHashByCurrentIndex();var o=e._getSelectedItem();o.loaded?(e._initPhoto(),e.addAppearEffect(t,o),e.clicked=!0,e.update(),i.style.overflow="hidden",e._fireEvent("open")):e._loadItem(o).then(function(){e._initPhoto(),e.addAppearEffect(t,o),e.clicked=!0,e.update(),i.style.overflow="hidden",e._fireEvent("open")})})}},{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 h(function(e){var r=t.data.appearEffect,o=t.data.classNames,n=t._getElementByClass(o.smartPhotoImgClone),i=function t(){n.removeEventListener("transitionend",t,!0),e()};n.addEventListener("transitionend",i,!0),setTimeout(function(){n.style.transform="translate("+r.afterX+"px, "+r.afterY+"px) scale("+r.scale+")"},10)})}},{key:"addAppearEffect",value:function(t,e){if(!1===this.data.showAnimation)return void(this.data.appear=!0);var r=t.querySelector("img"),o=l.getViewPos(r),n={},i=1;n.width=r.offsetWidth,n.height=r.offsetHeight,n.top=o.top,n.left=o.left,n.once=!0,n.img=r.getAttribute("src");var a=this._getWindowWidth(),s=this._getWindowHeight(),c=s-this.data.headerHeight-this.data.footerHeight;"fill"===this.data.resizeStyle&&this.data.isSmartPhone?i=r.offsetWidth>r.offsetHeight?s/r.offsetHeight:a/r.offsetWidth:(n.width>n.height?i=e.heightn.width&&(i=e.heighta&&(i=a/n.width));var u=(i-1)/2*r.offsetWidth+(a-r.offsetWidth*i)/2,h=(i-1)/2*r.offsetHeight+(s-r.offsetHeight*i)/2;n.afterX=u,n.afterY=h,n.scale=i,this.data.appearEffect=n}},{key:"hidePhoto",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"bottom";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 r=window.scrollX,o=window.scrollY,n=document.querySelector("body");location.hash&&this._setHash(""),window.scroll(r,o),this._doHideEffect(e).then(function(){t.update(),n.style.overflow="",t._fireEvent("close")})}},{key:"_doHideEffect",value:function(t){var e=this;return new h(function(r){var o=e.data.classNames,n=e._getElementByClass(o.smartPhoto),i=e._getElementByQuery(".current ."+o.smartPhotoImg),a=e._getWindowHeight(),s=function t(){n.removeEventListener("transitionend",t,!0),r()};n.style.opacity=0,"bottom"===t?i.style.transform="translateY("+a+"px)":"top"===t&&(i.style.transform="translateY(-"+a+"px)"),n.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,r="undefined"==typeof event?this.e:event;return this._isTouched(r)?(t=r.touches[0].pageX,e=r.touches[0].pageY):r.pageX&&(t=r.pageX,e=r.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(),r=-1*e[this.data.currentIndex].translateX;this.pos.x=r,setTimeout(function(){t.data.translateX=r,t.data.translateY=0,t._listUpdate()},1)}},{key:"_setHashByCurrentIndex",value:function(){var t=window.scrollX,e=window.scrollY,r=this.groupItems(),o=r[this.data.currentIndex].id,n=this.data.currentGroup,i="group="+n+"&photo="+o;this._setHash(i),window.scroll(t,e)}},{key:"_setHash",value:function(t){window.history&&window.history.pushState&&this.data.useHistoryApi&&(t?window.history.replaceState(null,null,""+location.pathname+location.search+"#"+t):window.history.replaceState(null,null,""+location.pathname+location.search))}},{key:"_getCurrentItemByHash",value:function(){var t=this.data.group,e=location.hash.substr(1),r=l.parseQuery(e),o=null,n=function(t){r.group===t.groupId&&r.photo===t.id&&(o=t)};return Object.keys(t).forEach(function(e){t[e].forEach(n)}),o}},{key:"_loadItem",value:function(t){return new h(function(e){var r=new Image;r.onload=function(){t.width=r.width,t.height=r.height,t.loaded=!0,e()},r.onerror=function(){e()},r.src=t.src})}},{key:"_setSizeByScreen",value:function(){var t=this._getWindowWidth(),e=this._getWindowHeight(),r=this.data.headerHeight,o=this.data.footerHeight,n=e-(r+o);this.groupItems().forEach(function(r){r.loaded&&(r.processed=!0,r.scale=n/r.height,r.heightt&&(r.scale=t/r.width,r.x=(r.scale-1)/2*r.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,r=this.data.currentIndex+1,o=this.data.currentIndex-1;this.data.showNextArrow=!1,this.data.showPrevArrow=!1,r!==e&&(this.data.next=r,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,r=e.getTime(),o=this.tapSecond-r,n=0,i=0;return this.isSwipable=!1,this.onListMove=!1,this.oldPos&&(n=this.oldPos.x-this.firstPos.x,i=this.oldPos.y-this.firstPos.y),this.isBeingZoomed?void this.afterGesture():this.data.scale?void this.afterPhotoDrag():l.isSmartPhone()||0!==n||0!==i?Math.abs(o)<=500&&0===n&&0===i?(this.e.preventDefault(),void this.zoomPhoto()):(this.tapSecond=r,this._fireEvent("swipeend"),"horizontal"===this.moveDir&&(n>=this.data.swipeOffset&&0!==this.data.currentIndex?this.data.currentIndex-=1:n<=-this.data.swipeOffset&&this.data.currentIndex!==t.length-1&&(this.data.currentIndex+=1),this._slideList()),void("vertical"===this.moveDir&&(this.data.swipeBottomToClose&&i>=this.data.swipeOffset?this.hidePhoto("bottom"):this.data.swipeTopToClose&&i<=-this.data.swipeOffset?this.hidePhoto("top"):(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,r=t.y-this.firstPos.y;this.dragStart&&(this._fireEvent("swipestart"),this.dragStart=!1,Math.abs(e)>Math.abs(r)?this.moveDir="horizontal":this.moveDir="vertical"),"horizontal"===this.moveDir?(this.pos.x+=e,this.data.translateX=this.pos.x):this.data.translateY=r,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.scaleSize<=1||(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,r=t.y-this.oldPhotoPos.y,o=this._round(this.data.scaleSize*e,6),n=this._round(this.data.scaleSize*r,6);"number"==typeof o&&(this.data.photoPosX+=o,this.photoVX=o),"number"==typeof n&&(this.data.photoPosY+=n,this.photoVY=n),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),r=this.data.swipeOffset*this.data.scaleSize,o=0,n=0;if(this.data.photoPosX>e.maxX?o=-1:this.data.photoPosXe.maxY?n=-1:this.data.photoPosYr&&0!==this.data.currentIndex)return void this.gotoSlide(this.data.prev);if(e.minX-this.data.photoPosX>r&&this.data.currentIndex+1!==this.data.total)return void this.gotoSlide(this.data.next);0===o&&0===n?(this.vx=this.photoVX/5,this.vy=this.photoVY/5):this._registerElasticForce(o,n)}}},{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]),r=(e-this.oldDistance)/100,o=this.data.scaleSize,n=this.data.photoPosX,i=this.data.photoPosY;this.isBeingZoomed=!0,this.data.scaleSize+=this._round(r,6),this.data.scaleSize<.2&&(this.data.scaleSize=.2),this.data.scaleSizethis._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(),r=this._getWindowHeight();return l.isSmartPhone()?t.width>t.height?r/(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,r=t.height*t.scale*this.data.scaleSize,o=void 0,n=void 0,i=void 0,a=void 0,s=this._getWindowWidth(),c=this._getWindowHeight();return s>e?(i=(s-e)/2,o=-1*i):(i=(e-s)/2,o=-1*i),c>r?(a=(c-r)/2,n=-1*a):(a=(r-c)/2,n=-1*a),{minX:this._round(o,6)*this.data.scaleSize,minY:this._round(n,6)*this.data.scaleSize,maxX:this._round(i,6)*this.data.scaleSize,maxY:this._round(a,6)*this.data.scaleSize}}},{key:"_registerElasticForce",value:function(t,e){var r=this,o=this._getSelectedItem(),n=this._makeBound(o);this.data.elastic=!0,1===t?this.data.photoPosX=n.minX:-1===t&&(this.data.photoPosX=n.maxX),1===e?this.data.photoPosY=n.minY:-1===e&&(this.data.photoPosY=n.maxY),this._photoUpdate(),setTimeout(function(){r.data.elastic=!1,r._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 r=t.x-e.x,o=t.y-e.y;return Math.sqrt(r*r+o*o)}},{key:"_round",value:function(t,e){var r=Math.pow(10,e);return t*=r,t=Math.round(t),t/=r}},{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"),r=e.querySelector("."+t.smartPhotoImg),o=this._getElementByQuery("."+t.smartPhotoNav),n=this._getElementByQuery("."+t.smartPhotoArrows),i=this.virtualPos(this.data.photoPosX),a=this.virtualPos(this.data.photoPosY),s=this.data.scaleSize,c="translate("+i+"px,"+a+"px) scale("+s+")";r.style.transform=c,this.data.scale?l.addClass(r,t.smartPhotoImgOnMove):l.removeClass(r,t.smartPhotoImgOnMove),this.data.elastic?l.addClass(r,t.smartPhotoImgElasticMove):l.removeClass(r,t.smartPhotoImgElasticMove),this.data.hideUi?(o&&o.setAttribute("aria-hidden","true"),n&&n.setAttribute("aria-hidden","true")):(o&&o.setAttribute("aria-hidden","false"),n&&n.setAttribute("aria-hidden","false"))}},{key:"_getWindowWidth",value:function(){return document&&document.documentElement?document.documentElement.clientWidth:window&&window.innerWidth?window.innerWidth:0}},{key:"_getWindowHeight",value:function(){return document&&document.documentElement?document.documentElement.clientHeight:window&&window.innerHeight?window.innerHeight:0}},{key:"_listUpdate",value:function(){var t=this.data.classNames,e=this._getElementByQuery("."+t.smartPhotoList),r="translate("+this.data.translateX+"px,"+this.data.translateY+"px)";e.style.transform=r,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.photoPosXe.maxX&&(this.data.photoPosX=e.maxX,this.vx*=-.2),this.data.photoPosYe.maxY&&(this.data.photoPosY=e.maxY,this.vy*=-.2);var r=this._getForceAndTheta(this.vx,this.vy),o=r.force,n=r.theta;o-=this.data.registance,Math.abs(o)<.5||(this.vx=Math.cos(n)*o,this.vy=Math.sin(n)*o,this._photoUpdate())}}}]),e}(c.default);r.default=f,e.exports=r.default},{"../lib/util":35,"a-template":1,"custom-event-polyfill":7,"es6-promise-polyfill":21}],34:[function(t,e,r){"use strict";e.exports=t("./core/")},{"./core/":33}],35:[function(t,e,r){"use strict";function o(t){t=t||{};for(var e=1;e0||t.indexOf("iPad")>0||t.indexOf("ipod")>0||t.indexOf("Android")>0},e.exports.extend=o,e.exports.triggerEvent=function(t,e,r){var o=void 0;window.CustomEvent?o=new CustomEvent(e,{cancelable:!0}):(o=document.createEvent("CustomEvent"),o.initCustomEvent(e,!1,!1,r)),t.dispatchEvent(o)},e.exports.parseQuery=function(t){for(var e,r,o,n=t.split("&"),i={},a=0,s=n.length;a1;)r=r[o.shift()];r[o.shift()]=e}},{key:"removeDataByString",value:function(t){for(var e=this.data,r=t.split(".");r.length>1;)e=e[r.shift()];var o=r.shift();o.match(/^\d+$/)?e.splice(Number(o),1):delete e[o]}},{key:"resolveBlock",value:function(t,e,r){var o=this,n=t.match(//g),i=t.match(//g),a=t.match(//g),s=t.match(//g);if(n)for(var c=0,u=n.length;c/g;return t=t.replace(e,function(t,e){return(0,a.selector)("#"+e).innerHTML})}},{key:"resolveWith",value:function(t){var e=/(([\n\r\t]|.)*?)/g;return t=t.replace(e,function(t,e){return t=t.replace(/data\-bind=['"](.*?)['"]/g,"data-bind='"+e+".$1'")})}},{key:"resolveLoop",value:function(t){var e=/(([\n\r\t]|.)*?)/g,r=this;return t=t.replace(e,function(t,e,o){var n=r.getDataByString(e),i=[];i="function"==typeof n?n.apply(r):n;var a="";if(i instanceof Array)for(var s=0,c=i.length;s(([\n\r\t]|.)*?)/g;return!!t.match(e)}},{key:"getHtml",value:function(t,e){var r=c(this.atemplate,function(e){return e.id===t}),o="";if(r&&r.html&&(o=r.html),e&&(o=t),!o)return"";var n=this.data;for(o=this.resolveInclude(o),o=this.resolveWith(o);this.hasLoop(o);)o=this.resolveLoop(o);return o=this.resolveBlock(o,n),o=o.replace(/\\([^\\])/g,"$1"),o=this.resolveAbsBlock(o),o.replace(/^([\t ])*\n/gm,"")}},{key:"update",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"html",r=arguments[1],o=this.templates;this.beforeUpdated&&this.beforeUpdated();for(var n=0,i=o.length;n"+h+"");else(0,a.selector)(l).insertAdjacentHTML("afterend",'
'),"text"===e?(0,a.selector)("[data-id='"+u+"']").innerText=h:(0,a.selector)("[data-id='"+u+"']").innerHTML=h;var m=c(t.atemplate,function(t){return t.id===u});m.binded||(m.binded=!0,t.addDataBind((0,a.selector)("[data-id='"+u+"']")),t.addActionBind((0,a.selector)("[data-id='"+u+"']")))}(n);return this.updateBindingData(r),this.onUpdated&&this.onUpdated(r),this}},{key:"updateBindingData",value:function(t){for(var e=this,r=this.templates,o=0,n=r.length;o1?r-1:0),n=1;n1;)e=e[r.shift()];var o=r.shift();return o.match(/^\d+$/)?e.splice(Number(o),1):delete e[o],this}}]),t}();r.default=h,e.exports=r.default},{"./util":2,"array.prototype.find":4,morphdom:30}],2:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=r.matches=function(t,e){for(var r=(t.document||t.ownerDocument).querySelectorAll(e),o=r.length;--o>=0&&r.item(o)!==t;);return o>-1},n=(r.selector=function(t){return document.querySelector(t)},r.findAncestor=function(t,e){if("function"==typeof t.closest)return t.closest(e)||null;for(;t&&t!==document;){if(o(t,e))return t;t=t.parentElement}return null});r.on=function(t,e,r,o){r.split(" ").forEach(function(r){t.addEventListener(r,function(t){var r=(t.target,n(t.target,e));r&&(t.delegateTarget=r,o(t))})})}},{}],3:[function(t,e,r){"use strict";var o=t("es-abstract/es6");e.exports=function(t){var e=o.ToObject(this),r=o.ToInteger(o.ToLength(e.length));if(!o.IsCallable(t))throw new TypeError("Array#find: predicate must be a function");if(0!==r)for(var n,i=arguments[1],a=0;a2?arguments[2]:{},a=o(e);i&&(a=a.concat(Object.getOwnPropertySymbols(e))),n(a,function(o){u(t,o,e[o],r[o])})};l.supportsDescriptors=!!c,e.exports=l},{foreach:22,"object-keys":31}],9:[function(t,e,r){"use strict";var o=t("has"),n=t("es-to-primitive/es6"),i=Object.prototype.toString,a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator,s=t("./helpers/isNaN"),c=t("./helpers/isFinite"),u=Number.MAX_SAFE_INTEGER||Math.pow(2,53)-1,l=t("./helpers/assign"),h=t("./helpers/sign"),d=t("./helpers/mod"),f=t("./helpers/isPrimitive"),p=parseInt,y=t("function-bind"),m=y.call(Function.call,Array.prototype.slice),v=y.call(Function.call,String.prototype.slice),g=y.call(Function.call,RegExp.prototype.test,/^0b[01]+$/i),b=y.call(Function.call,RegExp.prototype.test,/^0o[0-7]+$/i),w=y.call(Function.call,RegExp.prototype.exec),x=["…","​","￾"].join(""),P=new RegExp("["+x+"]","g"),E=y.call(Function.call,RegExp.prototype.test,P),S=/^[-+]0x[0-9a-f]+$/i,I=y.call(Function.call,RegExp.prototype.test,S),N=["\t\n\v\f\r   ᠎    ","          \u2028","\u2029\ufeff"].join(""),T=new RegExp("(^["+N+"]+)|(["+N+"]+$)","g"),_=y.call(Function.call,String.prototype.replace),O=function(t){return _(t,T,"")},D=t("./es5"),A=t("is-regex"),j=l(l({},D),{Call:function(t,e){var r=arguments.length>2?arguments[2]:[];if(!this.IsCallable(t))throw new TypeError(t+" is not a function");return t.apply(e,r)},ToPrimitive:n,ToNumber:function(t){var e=f(t)?t:n(t,Number);if("symbol"==typeof e)throw new TypeError("Cannot convert a Symbol value to a number");if("string"==typeof e){if(g(e))return this.ToNumber(p(v(e,2),2));if(b(e))return this.ToNumber(p(v(e,2),8));if(E(e)||I(e))return NaN;var r=O(e);if(r!==e)return this.ToNumber(r)}return Number(e)},ToInt16:function(t){var e=this.ToUint16(t);return e>=32768?e-65536:e},ToInt8:function(t){var e=this.ToUint8(t);return e>=128?e-256:e},ToUint8:function(t){var e=this.ToNumber(t);if(s(e)||0===e||!c(e))return 0;var r=h(e)*Math.floor(Math.abs(e));return d(r,256)},ToUint8Clamp:function(t){var e=this.ToNumber(t);if(s(e)||e<=0)return 0;if(e>=255)return 255;var r=Math.floor(t);return r+.5u?u:e},CanonicalNumericIndexString:function(t){if("[object String]"!==i.call(t))throw new TypeError("must be a string");if("-0"===t)return-0;var e=this.ToNumber(t);return this.SameValue(this.ToString(e),t)?e:void 0},RequireObjectCoercible:D.CheckObjectCoercible,IsArray:Array.isArray||function(t){return"[object Array]"===i.call(t)},IsConstructor:function(t){return"function"==typeof t&&!!t.prototype},IsExtensible:function(t){return!Object.preventExtensions||!f(t)&&Object.isExtensible(t)},IsInteger:function(t){if("number"!=typeof t||s(t)||!c(t))return!1;var e=Math.abs(t);return Math.floor(e)===e},IsPropertyKey:function(t){return"string"==typeof t||"symbol"==typeof t},IsRegExp:function(t){if(!t||"object"!=typeof t)return!1;if(a){var e=t[Symbol.match];if(void 0!==e)return D.ToBoolean(e)}return A(t)},SameValueZero:function(t,e){return t===e||s(t)&&s(e)},GetV:function(t,e){if(!this.IsPropertyKey(e))throw new TypeError("Assertion failed: IsPropertyKey(P) is not true");return this.ToObject(t)[e]},GetMethod:function(t,e){if(!this.IsPropertyKey(e))throw new TypeError("Assertion failed: IsPropertyKey(P) is not true");var r=this.GetV(t,e);if(null!=r){if(!this.IsCallable(r))throw new TypeError(e+"is not a function");return r}},Get:function(t,e){if("Object"!==this.Type(t))throw new TypeError("Assertion failed: Type(O) is not Object");if(!this.IsPropertyKey(e))throw new TypeError("Assertion failed: IsPropertyKey(P) is not true");return t[e]},Type:function(t){return"symbol"==typeof t?"Symbol":D.Type(t)},SpeciesConstructor:function(t,e){if("Object"!==this.Type(t))throw new TypeError("Assertion failed: Type(O) is not Object");var r=t.constructor;if(void 0===r)return e;if("Object"!==this.Type(r))throw new TypeError("O.constructor is not an Object");var o=a&&Symbol.species?r[Symbol.species]:void 0;if(null==o)return e;if(this.IsConstructor(o))return o;throw new TypeError("no constructor found")},CompletePropertyDescriptor:function(t){if(!this.IsPropertyDescriptor(t))throw new TypeError("Desc must be a Property Descriptor");return this.IsGenericDescriptor(t)||this.IsDataDescriptor(t)?(o(t,"[[Value]]")||(t["[[Value]]"]=void 0),o(t,"[[Writable]]")||(t["[[Writable]]"]=!1)):(o(t,"[[Get]]")||(t["[[Get]]"]=void 0),o(t,"[[Set]]")||(t["[[Set]]"]=void 0)),o(t,"[[Enumerable]]")||(t["[[Enumerable]]"]=!1),o(t,"[[Configurable]]")||(t["[[Configurable]]"]=!1),t},Set:function(t,e,r,o){if("Object"!==this.Type(t))throw new TypeError("O must be an Object");if(!this.IsPropertyKey(e))throw new TypeError("P must be a Property Key");if("Boolean"!==this.Type(o))throw new TypeError("Throw must be a Boolean");if(o)return t[e]=r,!0;try{t[e]=r}catch(t){return!1}},HasOwnProperty:function(t,e){if("Object"!==this.Type(t))throw new TypeError("O must be an Object");if(!this.IsPropertyKey(e))throw new TypeError("P must be a Property Key");return o(t,e)},HasProperty:function(t,e){if("Object"!==this.Type(t))throw new TypeError("O must be an Object");if(!this.IsPropertyKey(e))throw new TypeError("P must be a Property Key");return e in t},IsConcatSpreadable:function(t){if("Object"!==this.Type(t))return!1;if(a&&"symbol"==typeof Symbol.isConcatSpreadable){var e=this.Get(t,Symbol.isConcatSpreadable);if(void 0!==e)return this.ToBoolean(e)}return this.IsArray(t)},Invoke:function(t,e){if(!this.IsPropertyKey(e))throw new TypeError("P must be a Property Key");var r=m(arguments,2),o=this.GetV(t,e);return this.Call(o,t,r)},CreateIterResultObject:function(t,e){if("Boolean"!==this.Type(e))throw new TypeError("Assertion failed: Type(done) is not Boolean");return{value:t,done:e}},RegExpExec:function(t,e){if("Object"!==this.Type(t))throw new TypeError("R must be an Object");if("String"!==this.Type(e))throw new TypeError("S must be a String");var r=this.Get(t,"exec");if(this.IsCallable(r)){var o=this.Call(r,t,[e]);if(null===o||"Object"===this.Type(o))return o;throw new TypeError('"exec" method must return `null` or an Object')}return w(t,e)},ArraySpeciesCreate:function(t,e){if(!this.IsInteger(e)||e<0)throw new TypeError("Assertion failed: length must be an integer >= 0");var r,o=0===e?0:e;if(this.IsArray(t)&&(r=this.Get(t,"constructor"),"Object"===this.Type(r)&&a&&Symbol.species&&null===(r=this.Get(r,Symbol.species))&&(r=void 0)),void 0===r)return Array(o);if(!this.IsConstructor(r))throw new TypeError("C must be a constructor");return new r(o)},CreateDataProperty:function(t,e,r){if("Object"!==this.Type(t))throw new TypeError("Assertion failed: Type(O) is not Object");if(!this.IsPropertyKey(e))throw new TypeError("Assertion failed: IsPropertyKey(P) is not true");var o=Object.getOwnPropertyDescriptor(t,e),n=o||"function"!=typeof Object.isExtensible||Object.isExtensible(t);if(o&&(!o.writable||!o.configurable)||!n)return!1;var i={configurable:!0,enumerable:!0,value:r,writable:!0};return Object.defineProperty(t,e,i),!0},CreateDataPropertyOrThrow:function(t,e,r){if("Object"!==this.Type(t))throw new TypeError("Assertion failed: Type(O) is not Object");if(!this.IsPropertyKey(e))throw new TypeError("Assertion failed: IsPropertyKey(P) is not true");var o=this.CreateDataProperty(t,e,r);if(!o)throw new TypeError("unable to create data property");return o},AdvanceStringIndex:function(t,e,r){if("String"!==this.Type(t))throw new TypeError("Assertion failed: Type(S) is not String");if(!this.IsInteger(e))throw new TypeError("Assertion failed: length must be an integer >= 0 and <= (2**53 - 1)");if(e<0||e>u)throw new RangeError("Assertion failed: length must be an integer >= 0 and <= (2**53 - 1)");if("Boolean"!==this.Type(r))throw new TypeError("Assertion failed: Type(unicode) is not Boolean");if(!r)return e+1;if(e+1>=t.length)return e+1;var o=t.charCodeAt(e);if(o<55296||o>56319)return e+1;var n=t.charCodeAt(e+1);return n<56320||n>57343?e+1:e+2}});delete j.CheckObjectCoercible,e.exports=j},{"./es5":10,"./helpers/assign":12,"./helpers/isFinite":13,"./helpers/isNaN":14,"./helpers/isPrimitive":15,"./helpers/mod":16,"./helpers/sign":17,"es-to-primitive/es6":19,"function-bind":24,has:25,"is-regex":28}],10:[function(t,e,r){"use strict";var o=t("./helpers/isNaN"),n=t("./helpers/isFinite"),i=t("./helpers/sign"),a=t("./helpers/mod"),s=t("is-callable"),c=t("es-to-primitive/es5"),u=t("has"),l={ToPrimitive:c,ToBoolean:function(t){return!!t},ToNumber:function(t){return Number(t)},ToInteger:function(t){var e=this.ToNumber(t);return o(e)?0:0!==e&&n(e)?i(e)*Math.floor(Math.abs(e)):e},ToInt32:function(t){return this.ToNumber(t)>>0},ToUint32:function(t){return this.ToNumber(t)>>>0},ToUint16:function(t){var e=this.ToNumber(t);if(o(e)||0===e||!n(e))return 0;var r=i(e)*Math.floor(Math.abs(e));return a(r,65536)},ToString:function(t){return String(t)},ToObject:function(t){return this.CheckObjectCoercible(t),Object(t)},CheckObjectCoercible:function(t,e){if(null==t)throw new TypeError(e||"Cannot call method on "+t);return t},IsCallable:s,SameValue:function(t,e){return t===e?0!==t||1/t==1/e:o(t)&&o(e)},Type:function(t){return null===t?"Null":void 0===t?"Undefined":"function"==typeof t||"object"==typeof t?"Object":"number"==typeof t?"Number":"boolean"==typeof t?"Boolean":"string"==typeof t?"String":void 0},IsPropertyDescriptor:function(t){if("Object"!==this.Type(t))return!1;var e={"[[Configurable]]":!0,"[[Enumerable]]":!0,"[[Get]]":!0,"[[Set]]":!0,"[[Value]]":!0,"[[Writable]]":!0};for(var r in t)if(u(t,r)&&!e[r])return!1;var o=u(t,"[[Value]]"),n=u(t,"[[Get]]")||u(t,"[[Set]]");if(o&&n)throw new TypeError("Property Descriptors may not be both accessor and data descriptors");return!0},IsAccessorDescriptor:function(t){if(void 0===t)return!1;if(!this.IsPropertyDescriptor(t))throw new TypeError("Desc must be a Property Descriptor");return!(!u(t,"[[Get]]")&&!u(t,"[[Set]]"))},IsDataDescriptor:function(t){if(void 0===t)return!1;if(!this.IsPropertyDescriptor(t))throw new TypeError("Desc must be a Property Descriptor");return!(!u(t,"[[Value]]")&&!u(t,"[[Writable]]"))},IsGenericDescriptor:function(t){if(void 0===t)return!1;if(!this.IsPropertyDescriptor(t))throw new TypeError("Desc must be a Property Descriptor");return!this.IsAccessorDescriptor(t)&&!this.IsDataDescriptor(t)},FromPropertyDescriptor:function(t){if(void 0===t)return t;if(!this.IsPropertyDescriptor(t))throw new TypeError("Desc must be a Property Descriptor");if(this.IsDataDescriptor(t))return{value:t["[[Value]]"],writable:!!t["[[Writable]]"],enumerable:!!t["[[Enumerable]]"],configurable:!!t["[[Configurable]]"]};if(this.IsAccessorDescriptor(t))return{get:t["[[Get]]"],set:t["[[Set]]"],enumerable:!!t["[[Enumerable]]"],configurable:!!t["[[Configurable]]"]};throw new TypeError("FromPropertyDescriptor must be called with a fully populated Property Descriptor")},ToPropertyDescriptor:function(t){if("Object"!==this.Type(t))throw new TypeError("ToPropertyDescriptor requires an object");var e={};if(u(t,"enumerable")&&(e["[[Enumerable]]"]=this.ToBoolean(t.enumerable)),u(t,"configurable")&&(e["[[Configurable]]"]=this.ToBoolean(t.configurable)),u(t,"value")&&(e["[[Value]]"]=t.value),u(t,"writable")&&(e["[[Writable]]"]=this.ToBoolean(t.writable)),u(t,"get")){var r=t.get;if(void 0!==r&&!this.IsCallable(r))throw new TypeError("getter must be a function");e["[[Get]]"]=r}if(u(t,"set")){var o=t.set;if(void 0!==o&&!this.IsCallable(o))throw new TypeError("setter must be a function");e["[[Set]]"]=o}if((u(e,"[[Get]]")||u(e,"[[Set]]"))&&(u(e,"[[Value]]")||u(e,"[[Writable]]")))throw new TypeError("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");return e}};e.exports=l},{"./helpers/isFinite":13,"./helpers/isNaN":14,"./helpers/mod":16,"./helpers/sign":17,"es-to-primitive/es5":18,has:25,"is-callable":26}],11:[function(t,e,r){"use strict";e.exports=t("./es2015")},{"./es2015":9}],12:[function(t,e,r){var o=Object.prototype.hasOwnProperty;e.exports=function(t,e){if(Object.assign)return Object.assign(t,e);for(var r in e)o.call(e,r)&&(t[r]=e[r]);return t}},{}],13:[function(t,e,r){var o=Number.isNaN||function(t){return t!==t};e.exports=Number.isFinite||function(t){return"number"==typeof t&&!o(t)&&t!==1/0&&t!==-1/0}},{}],14:[function(t,e,r){e.exports=Number.isNaN||function(t){return t!==t}},{}],15:[function(t,e,r){e.exports=function(t){return null===t||"function"!=typeof t&&"object"!=typeof t}},{}],16:[function(t,e,r){e.exports=function(t,e){var r=t%e;return Math.floor(r>=0?r:r+e)}},{}],17:[function(t,e,r){e.exports=function(t){return t>=0?1:-1}},{}],18:[function(t,e,r){"use strict";var o=Object.prototype.toString,n=t("./helpers/isPrimitive"),i=t("is-callable"),a={"[[DefaultValue]]":function(t,e){var r=e||("[object Date]"===o.call(t)?String:Number);if(r===String||r===Number){var a,s,c=r===String?["toString","valueOf"]:["valueOf","toString"];for(s=0;s1&&(e===String?r="string":e===Number&&(r="number"));var i;if(o&&(Symbol.toPrimitive?i=u(t,Symbol.toPrimitive):s(t)&&(i=Symbol.prototype.valueOf)),void 0!==i){var l=i.call(t,r);if(n(l))return l;throw new TypeError("unable to convert exotic object to primitive")}return"default"===r&&(a(t)||s(t))&&(r="string"),c(t,"default"===r?"number":r)}},{"./helpers/isPrimitive":20,"is-callable":26,"is-date-object":27,"is-symbol":29}],20:[function(t,e,r){arguments[4][15][0].apply(r,arguments)},{dup:15}],21:[function(e,r,o){(function(e){!function(e){function r(t){return"[object Array]"===Object.prototype.toString.call(t)}function n(){for(var t=0;t90)&&r===o.toUpperCase()}function i(t,e){return e&&e!==f?p.createElementNS(e,t):p.createElement(t)}function a(t,e){for(var r=t.firstChild;r;){var o=r.nextSibling;e.appendChild(r),r=o}return e}function s(t,e){var r,o,n,i,a,s=e.attributes;for(r=s.length-1;r>=0;--r)o=s[r],n=o.name,i=o.namespaceURI,a=o.value,i?(n=o.localName||n,t.getAttributeNS(i,n)!==a&&t.setAttributeNS(i,n,a)):t.getAttribute(n)!==a&&t.setAttribute(n,a);for(s=t.attributes,r=s.length-1;r>=0;--r)o=s[r],!1!==o.specified&&(n=o.name,i=o.namespaceURI,i?(n=o.localName||n,m(e,i,n)||t.removeAttributeNS(i,n)):m(e,null,n)||t.removeAttribute(n))}function c(t,e,r){t[r]!==e[r]&&(t[r]=e[r],t[r]?t.setAttribute(r,""):t.removeAttribute(r,""))}function u(){}function l(t){return t.id}var h,d,f="http://www.w3.org/1999/xhtml",p="undefined"==typeof document?void 0:document,y=p?p.body||p.createElement("div"):{};d=y.hasAttributeNS?function(t,e,r){return t.hasAttributeNS(e,r)}:y.hasAttribute?function(t,e,r){return t.hasAttribute(r)}:function(t,e,r){return null!=t.getAttributeNode(e,r)};var m=d,v={OPTION:function(t,e){c(t,e,"selected")},INPUT:function(t,e){c(t,e,"checked"),c(t,e,"disabled"),t.value!==e.value&&(t.value=e.value),m(e,null,"value")||t.removeAttribute("value")},TEXTAREA:function(t,e){var r=e.value;t.value!==r&&(t.value=r);var o=t.firstChild;if(o){var n=o.nodeValue;if(n==r||!r&&n==t.placeholder)return;o.nodeValue=r}},SELECT:function(t,e){if(!m(e,null,"multiple")){for(var r=0,o=e.firstChild;o;){var n=o.nodeName;if(n&&"OPTION"===n.toUpperCase()){if(m(o,null,"selected")){r;break}r++}o=o.nextSibling}t.selectedIndex=r}}},g=1,b=3,w=8,x=function(t){return function(e,r,s){function c(t){P?P.push(t):P=[t]}function h(t,e){if(t.nodeType===g)for(var r=t.firstChild;r;){var o=void 0;e&&(o=E(r))?c(o):(O(r),r.firstChild&&h(r,e)),r=r.nextSibling}}function d(t,e,r){!1!==_(t)&&(e&&e.removeChild(t),O(t),h(t,r))}function f(t){if(t.nodeType===g)for(var e=t.firstChild;e;){var r=E(e);r&&(j[r]=e),f(e),e=e.nextSibling}}function y(t){I(t);for(var e=t.firstChild;e;){var r=e.nextSibling,o=E(e);if(o){var i=j[o];i&&n(e,i)&&(e.parentNode.replaceChild(i,e),m(i,e))}y(e),e=r}}function m(o,i,a){var s,u=E(i);if(u&&delete j[u],!r.isSameNode||!r.isSameNode(e)){if(!a){if(!1===N(o,i))return;if(t(o,i),T(o),!1===D(o,i))return}if("TEXTAREA"!==o.nodeName){var l,h,f,x,P=i.firstChild,I=o.firstChild;t:for(;P;){for(f=P.nextSibling,l=E(P);I;){if(h=I.nextSibling,P.isSameNode&&P.isSameNode(I)){P=f,I=h;continue t}s=E(I);var _=I.nodeType,O=void 0;if(_===P.nodeType&&(_===g?(l?l!==s&&((x=j[l])?I.nextSibling===x?O=!1:(o.insertBefore(x,I),h=I.nextSibling,s?c(s):d(I,o,!0),I=x):O=!1):s&&(O=!1),(O=!1!==O&&n(I,P))&&m(I,P)):_!==b&&_!=w||(O=!0,I.nodeValue!==P.nodeValue&&(I.nodeValue=P.nodeValue))),O){P=f,I=h;continue t}s?c(s):d(I,o,!0),I=h}if(l&&(x=j[l])&&n(x,P))o.appendChild(x),m(x,P);else{var A=S(P);!1!==A&&(A&&(P=A),P.actualize&&(P=P.actualize(o.ownerDocument||p)),o.appendChild(P),y(P))}P=f,I=h}for(;I;)h=I.nextSibling,(s=E(I))?c(s):d(I,o,!0),I=h}var k=v[o.nodeName];k&&k(o,i)}}if(s||(s={}),"string"==typeof r)if("#document"===e.nodeName||"HTML"===e.nodeName){var x=r;r=p.createElement("html"),r.innerHTML=x}else r=o(r);var P,E=s.getNodeKey||l,S=s.onBeforeNodeAdded||u,I=s.onNodeAdded||u,N=s.onBeforeElUpdated||u,T=s.onElUpdated||u,_=s.onBeforeNodeDiscarded||u,O=s.onNodeDiscarded||u,D=s.onBeforeElChildrenUpdated||u,A=!0===s.childrenOnly,j={};f(e);var k=e,C=k.nodeType,B=r.nodeType;if(!A)if(C===g)B===g?n(e,r)||(O(e),k=a(e,i(r.nodeName,r.namespaceURI))):k=r;else if(C===b||C===w){if(B===C)return k.nodeValue!==r.nodeValue&&(k.nodeValue=r.nodeValue),k;k=r}if(k===r)O(e);else if(m(k,r,A),P)for(var G=0,M=P.length;G0&&!o.call(t,0))for(var f=0;f0)for(var y=0;y=0&&"[object Function]"===o.call(t.callee)),r}},{}],33:[function(t,e,r){"use strict";function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(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 i(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)}Object.defineProperty(r,"__esModule",{value:!0});var a=function(){function t(t,e){for(var r=0;r"),[].forEach.call(i.elements,function(t){i.addNewItem(t)}),i.update(),i._getEachImageSize().then(function(){i._fireEvent("loadall");var t=i._getCurrentItemByHash();t&&l.triggerEvent(t.element,"click")}),setInterval(function(){i._doAnim()},i.data.forceInterval),i.data.useHistoryApi&&"push"===i.data.historyApiMethod&&(window.onpopstate=function(t){if(!t||!t.state||void 0===t.state.group||void 0===t.state.index)return void i.hidePhoto();i.data.currentGroup=t.state.group,i.data.currentIndex=t.state.index;var e=i._getSelectedItem();e.loaded?(i._initPhoto(),i.data.appear=!0,i.clicked=!0,i.update(),s.style.overflow="hidden",i._fireEvent("open")):i._loadItem(e).then(function(){i._initPhoto(),i.data.appear=!0,i.clicked=!0,i.update(),s.style.overflow="hidden",i._fireEvent("open")}),i.gotoSlide(t.state.index,!0)}),i.data.isSmartPhone?(window.addEventListener("orientationchange",function(){i.groupItems()&&(i._resetTranslate(),i._setPosByCurrentIndex(),i._setHashByCurrentIndex(),i._setSizeByScreen(),i.update())}),i.data.useOrientationApi?(window.addEventListener("deviceorientation",function(t){var e=window.orientation;t&&t.gamma&&!i.data.appearEffect&&(i.isBeingZoomed||i.photoSwipable||i.data.elastic||!i.data.scale||(0===e?i._calcGravity(t.gamma,t.beta):90===e?i._calcGravity(t.beta,t.gamma):-90===e?i._calcGravity(-t.beta,-t.gamma):180===e&&i._calcGravity(-t.gamma,-t.beta)))}),i):n(i)):(window.addEventListener("resize",function(){i.groupItems()&&(i._resetTranslate(),i._setPosByCurrentIndex(),i._setSizeByScreen(),i.update())}),window.addEventListener("keydown",function(t){var e=t.keyCode||t.which;!0!==i.data.hide&&(37===e?i.gotoSlide(i.data.prev):39===e?i.gotoSlide(i.data.next):27===e&&i.hidePhoto())}),n(i))}return i(e,t),a(e,[{key:"on",value:function(t,e){var r=this;this._getElementByClass(this.data.classNames.smartPhoto).addEventListener(t,function(t){e.call(r,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,r=function(e){var r=new h(function(t,r){var o=new Image;o.onload=function(){e.width=o.width,e.height=o.height,e.loaded=!0,t()},o.onerror=function(){r()},o.src=e.src});t.push(r)};return Object.keys(e).forEach(function(t){e[t].forEach(r)}),h.all(t)}},{key:"_resetTranslate",value:function(){var t=this;this.groupItems().forEach(function(e,r){e.translateX=t._getWindowWidth()*r})}},{key:"addNewItem",value:function(t){var e=this,r=t.getAttribute("data-group")||"nogroup",o=this.data.group;"nogroup"===r&&t.setAttribute("data-group","nogroup"),o[r]||(o[r]=[]);var n=o[r].length,i=document.querySelector("body"),a={src:t.getAttribute("href"),caption:t.getAttribute("data-caption"),groupId:r,translateX:this._getWindowWidth()*n,index:n,translateY:0,width:50,height:50,id:t.getAttribute("data-id")||n,loaded:!1,processed:!1,element:t};o[r].push(a),this.data.currentGroup=r,t.getAttribute("data-id")||t.setAttribute("data-id",n),t.setAttribute("data-index",n),t.addEventListener("click",function(r){r.preventDefault(),e.data.currentGroup=t.getAttribute("data-group"),e.data.currentIndex=parseInt(t.getAttribute("data-index"),10),e._setHashByCurrentIndex();var o=e._getSelectedItem();o.loaded?(e._initPhoto(),e.addAppearEffect(t,o),e.clicked=!0,e.update(),i.style.overflow="hidden",e._fireEvent("open")):e._loadItem(o).then(function(){e._initPhoto(),e.addAppearEffect(t,o),e.clicked=!0,e.update(),i.style.overflow="hidden",e._fireEvent("open")})})}},{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 h(function(e){var r=t.data.appearEffect,o=t.data.classNames,n=t._getElementByClass(o.smartPhotoImgClone),i=function t(){n.removeEventListener("transitionend",t,!0),e()};n.addEventListener("transitionend",i,!0),setTimeout(function(){n.style.transform="translate("+r.afterX+"px, "+r.afterY+"px) scale("+r.scale+")"},10)})}},{key:"addAppearEffect",value:function(t,e){if(!1===this.data.showAnimation)return void(this.data.appear=!0);var r=t.querySelector("img"),o=l.getViewPos(r),n={},i=1;n.width=r.offsetWidth,n.height=r.offsetHeight,n.top=o.top,n.left=o.left,n.once=!0,n.img=r.getAttribute("src");var a=this._getWindowWidth(),s=this._getWindowHeight(),c=s-this.data.headerHeight-this.data.footerHeight;"fill"===this.data.resizeStyle&&this.data.isSmartPhone?i=r.offsetWidth>r.offsetHeight?s/r.offsetHeight:a/r.offsetWidth:(n.width>n.height?i=e.heightn.width&&(i=e.heighta&&(i=a/n.width));var u=(i-1)/2*r.offsetWidth+(a-r.offsetWidth*i)/2,h=(i-1)/2*r.offsetHeight+(s-r.offsetHeight*i)/2;n.afterX=u,n.afterY=h,n.scale=i,this.data.appearEffect=n}},{key:"hidePhoto",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"bottom";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 r=window.scrollX,o=window.scrollY,n=document.querySelector("body");location.hash&&this._setHash(),window.scroll(r,o),this._doHideEffect(e).then(function(){t.update(),n.style.overflow="",t._fireEvent("close")})}},{key:"_doHideEffect",value:function(t){var e=this;return new h(function(r){var o=e.data.classNames,n=e._getElementByClass(o.smartPhoto),i=e._getElementByQuery(".current ."+o.smartPhotoImg),a=e._getWindowHeight(),s=function t(){n.removeEventListener("transitionend",t,!0),r()};n.style.opacity=0,"bottom"===t?i.style.transform="translateY("+a+"px)":"top"===t&&(i.style.transform="translateY(-"+a+"px)"),n.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,r="undefined"==typeof event?this.e:event;return this._isTouched(r)?(t=r.touches[0].pageX,e=r.touches[0].pageY):r.pageX&&(t=r.pageX,e=r.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(),r=-1*e[this.data.currentIndex].translateX;this.pos.x=r,setTimeout(function(){t.data.translateX=r,t.data.translateY=0,t._listUpdate()},1)}},{key:"_setHashByCurrentIndex",value:function(){var t=window.scrollX,e=window.scrollY,r=this.groupItems(),o=r[this.data.currentIndex].id,n=this.data.currentGroup;this._setHash(n,o,this.data.currentIndex),window.scroll(t,e)}},{key:"_setHash",value:function(t,e,r){if(window.history&&window.history.pushState&&this.data.useHistoryApi&&this.data.oldIndex!==r){var o=""+location.pathname+location.search,n=void 0;switch(void 0!==t&&void 0!==e&&(o+="#group="+t+"&photo="+e,n={group:t,id:e,index:r}),this.data.historyApiMethod){case"push":window.history.pushState(n,null,o);break;case"replace":default:window.history.replaceState(n,null,o)}}}},{key:"_getCurrentItemByHash",value:function(){var t=this.data.group,e=location.hash.substr(1),r=l.parseQuery(e),o=null,n=function(t){r.group===t.groupId&&r.photo===t.id&&(o=t)};return Object.keys(t).forEach(function(e){t[e].forEach(n)}),o}},{key:"_loadItem",value:function(t){return new h(function(e){var r=new Image;r.onload=function(){t.width=r.width,t.height=r.height,t.loaded=!0,e()},r.onerror=function(){e()},r.src=t.src})}},{key:"_setSizeByScreen",value:function(){var t=this._getWindowWidth(),e=this._getWindowHeight(),r=this.data.headerHeight,o=this.data.footerHeight,n=e-(r+o);this.groupItems().forEach(function(r){r.loaded&&(r.processed=!0,r.scale=n/r.height,r.heightt&&(r.scale=t/r.width,r.x=(r.scale-1)/2*r.width))})}},{key:"_slideList",value:function(t){var e=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(),t||this._setHashByCurrentIndex(),this._setSizeByScreen(),setTimeout(function(){e.data.onMoveClass=!1,e.setArrow(),e.update(),e.data.oldIndex!==e.data.currentIndex&&e._fireEvent("change"),e.data.oldIndex=e.data.currentIndex},200)}},{key:"gotoSlide",value:function(t,e){this.e&&this.e.preventDefault&&this.e.preventDefault(),this.data.currentIndex=parseInt(t,10),this.data.currentIndex||(this.data.currentIndex=0),this._slideList(e)}},{key:"setArrow",value:function(){var t=this.groupItems(),e=t.length,r=this.data.currentIndex+1,o=this.data.currentIndex-1;this.data.showNextArrow=!1,this.data.showPrevArrow=!1,r!==e&&(this.data.next=r,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,r=e.getTime(),o=this.tapSecond-r,n=0,i=0;return this.isSwipable=!1,this.onListMove=!1,this.oldPos&&(n=this.oldPos.x-this.firstPos.x,i=this.oldPos.y-this.firstPos.y),this.isBeingZoomed?void this.afterGesture():this.data.scale?void this.afterPhotoDrag():l.isSmartPhone()||0!==n||0!==i?Math.abs(o)<=500&&0===n&&0===i?(this.e.preventDefault(),void this.zoomPhoto()):(this.tapSecond=r,this._fireEvent("swipeend"),"horizontal"===this.moveDir&&(n>=this.data.swipeOffset&&0!==this.data.currentIndex?this.data.currentIndex-=1:n<=-this.data.swipeOffset&&this.data.currentIndex!==t.length-1&&(this.data.currentIndex+=1),this._slideList()),void("vertical"===this.moveDir&&(this.data.swipeBottomToClose&&i>=this.data.swipeOffset?this.hidePhoto("bottom"):this.data.swipeTopToClose&&i<=-this.data.swipeOffset?this.hidePhoto("top"):(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,r=t.y-this.firstPos.y;this.dragStart&&(this._fireEvent("swipestart"),this.dragStart=!1,Math.abs(e)>Math.abs(r)?this.moveDir="horizontal":this.moveDir="vertical"),"horizontal"===this.moveDir?(this.pos.x+=e,this.data.translateX=this.pos.x):this.data.translateY=r,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.scaleSize<=1||(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,r=t.y-this.oldPhotoPos.y,o=this._round(this.data.scaleSize*e,6),n=this._round(this.data.scaleSize*r,6);"number"==typeof o&&(this.data.photoPosX+=o,this.photoVX=o),"number"==typeof n&&(this.data.photoPosY+=n,this.photoVY=n),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),r=this.data.swipeOffset*this.data.scaleSize,o=0,n=0;if(this.data.photoPosX>e.maxX?o=-1:this.data.photoPosXe.maxY?n=-1:this.data.photoPosYr&&0!==this.data.currentIndex)return void this.gotoSlide(this.data.prev);if(e.minX-this.data.photoPosX>r&&this.data.currentIndex+1!==this.data.total)return void this.gotoSlide(this.data.next);0===o&&0===n?(this.vx=this.photoVX/5,this.vy=this.photoVY/5):this._registerElasticForce(o,n)}}},{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]),r=(e-this.oldDistance)/100,o=this.data.scaleSize,n=this.data.photoPosX,i=this.data.photoPosY;this.isBeingZoomed=!0,this.data.scaleSize+=this._round(r,6),this.data.scaleSize<.2&&(this.data.scaleSize=.2),this.data.scaleSizethis._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(),r=this._getWindowHeight();return l.isSmartPhone()?t.width>t.height?r/(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,r=t.height*t.scale*this.data.scaleSize,o=void 0,n=void 0,i=void 0,a=void 0,s=this._getWindowWidth(),c=this._getWindowHeight();return s>e?(i=(s-e)/2,o=-1*i):(i=(e-s)/2,o=-1*i),c>r?(a=(c-r)/2,n=-1*a):(a=(r-c)/2,n=-1*a),{minX:this._round(o,6)*this.data.scaleSize,minY:this._round(n,6)*this.data.scaleSize,maxX:this._round(i,6)*this.data.scaleSize,maxY:this._round(a,6)*this.data.scaleSize}}},{key:"_registerElasticForce",value:function(t,e){var r=this,o=this._getSelectedItem(),n=this._makeBound(o);this.data.elastic=!0,1===t?this.data.photoPosX=n.minX:-1===t&&(this.data.photoPosX=n.maxX),1===e?this.data.photoPosY=n.minY:-1===e&&(this.data.photoPosY=n.maxY),this._photoUpdate(),setTimeout(function(){r.data.elastic=!1,r._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 r=t.x-e.x,o=t.y-e.y;return Math.sqrt(r*r+o*o)}},{key:"_round",value:function(t,e){var r=Math.pow(10,e);return t*=r,t=Math.round(t),t/=r}},{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"),r=e.querySelector("."+t.smartPhotoImg),o=this._getElementByQuery("."+t.smartPhotoNav),n=this._getElementByQuery("."+t.smartPhotoArrows),i=this.virtualPos(this.data.photoPosX),a=this.virtualPos(this.data.photoPosY),s=this.data.scaleSize,c="translate("+i+"px,"+a+"px) scale("+s+")";r.style.transform=c,this.data.scale?l.addClass(r,t.smartPhotoImgOnMove):l.removeClass(r,t.smartPhotoImgOnMove),this.data.elastic?l.addClass(r,t.smartPhotoImgElasticMove):l.removeClass(r,t.smartPhotoImgElasticMove),this.data.hideUi?(o&&o.setAttribute("aria-hidden","true"),n&&n.setAttribute("aria-hidden","true")):(o&&o.setAttribute("aria-hidden","false"),n&&n.setAttribute("aria-hidden","false"))}},{key:"_getWindowWidth",value:function(){return document&&document.documentElement?document.documentElement.clientWidth:window&&window.innerWidth?window.innerWidth:0}},{key:"_getWindowHeight",value:function(){return document&&document.documentElement?document.documentElement.clientHeight:window&&window.innerHeight?window.innerHeight:0}},{key:"_listUpdate",value:function(){var t=this.data.classNames,e=this._getElementByQuery("."+t.smartPhotoList),r="translate("+this.data.translateX+"px,"+this.data.translateY+"px)";e.style.transform=r,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.photoPosXe.maxX&&(this.data.photoPosX=e.maxX,this.vx*=-.2),this.data.photoPosYe.maxY&&(this.data.photoPosY=e.maxY,this.vy*=-.2);var r=this._getForceAndTheta(this.vx,this.vy),o=r.force,n=r.theta;o-=this.data.registance,Math.abs(o)<.5||(this.vx=Math.cos(n)*o,this.vy=Math.sin(n)*o,this._photoUpdate())}}}]),e}(c.default);r.default=f,e.exports=r.default},{"../lib/util":35,"a-template":1,"custom-event-polyfill":7,"es6-promise-polyfill":21}],34:[function(t,e,r){"use strict";e.exports=t("./core/")},{"./core/":33}],35:[function(t,e,r){"use strict";function o(t){t=t||{};for(var e=1;e0||t.indexOf("iPad")>0||t.indexOf("ipod")>0||t.indexOf("Android")>0},e.exports.extend=o,e.exports.triggerEvent=function(t,e,r){var o=void 0;window.CustomEvent?o=new CustomEvent(e,{cancelable:!0}):(o=document.createEvent("CustomEvent"),o.initCustomEvent(e,!1,!1,r)),t.dispatchEvent(o)},e.exports.parseQuery=function(t){for(var e,r,o,n=t.split("&"),i={},a=0,s=n.length;a setup history event listener + if (_this.data.useHistoryApi && _this.data.historyApiMethod === 'push') { + + window.onpopstate = function (event) { + + // if state is not set - the gallery was hidden in this history state + if (!event || !event.state || event.state.group === void 0 || event.state.index === void 0) { + _this.hidePhoto(); + return; + } + + // geting photo info from state object + _this.data.currentGroup = event.state.group; + _this.data.currentIndex = event.state.index; + var currentItem = _this._getSelectedItem(); + + if (currentItem.loaded) { + _this._initPhoto(); + _this.data.appear = true; + _this.clicked = true; + _this.update(); + body.style.overflow = 'hidden'; + _this._fireEvent('open'); + } else { + _this._loadItem(currentItem).then(function () { + _this._initPhoto(); + _this.data.appear = true; + _this.clicked = true; + _this.update(); + body.style.overflow = 'hidden'; + _this._fireEvent('open'); + }); + } + + _this.gotoSlide(event.state.index, true); // <- don't update history + }; + } + if (!_this.data.isSmartPhone) { window.addEventListener('resize', function () { if (!_this.groupItems()) { @@ -438,7 +478,7 @@ var SmartPhoto = function (_ATemplate) { var scrollY = window.scrollY; var body = document.querySelector('body'); if (location.hash) { - this._setHash(''); + this._setHash(); } window.scroll(scrollX, scrollY); this._doHideEffect(dir).then(function () { @@ -523,20 +563,40 @@ var SmartPhoto = function (_ATemplate) { var items = this.groupItems(); var id = items[this.data.currentIndex].id; var group = this.data.currentGroup; - var hash = 'group=' + group + '&photo=' + id; - this._setHash(hash); + this._setHash(group, id, this.data.currentIndex); window.scroll(scrollX, scrollY); } }, { key: '_setHash', - value: function _setHash(hash) { + value: function _setHash(group, id, index) { + if (!(window.history && window.history.pushState) || !this.data.useHistoryApi) { return; } - if (hash) { - window.history.replaceState(null, null, '' + location.pathname + location.search + '#' + hash); - } else { - window.history.replaceState(null, null, '' + location.pathname + location.search); + + // if the displayed image has not changed + // > don't change history + if (this.data.oldIndex === index) { + return; + } + + var newUrl = '' + location.pathname + location.search, + newState = void 0; + + // if `group` od `id` are not set + // > don't construct new state + if (group !== void 0 && id !== void 0) { + newUrl += '#group=' + group + '&photo=' + id; + newState = { group: group, id: id, index: index }; + } + + switch (this.data.historyApiMethod) { + case 'push': + window.history.pushState(newState, null, newUrl); + break; + case 'replace': + default: + window.history.replaceState(newState, null, newUrl); } } }, { @@ -601,7 +661,7 @@ var SmartPhoto = function (_ATemplate) { } }, { key: '_slideList', - value: function _slideList() { + value: function _slideList(skipHistory) { var _this10 = this; this.data.scaleSize = 1; @@ -612,7 +672,11 @@ var SmartPhoto = function (_ATemplate) { this.data.photoPosY = 0; this.data.onMoveClass = true; this._setPosByCurrentIndex(); - this._setHashByCurrentIndex(); + + if (!skipHistory) { + this._setHashByCurrentIndex(); + } + this._setSizeByScreen(); setTimeout(function () { _this10.data.onMoveClass = false; @@ -626,7 +690,7 @@ var SmartPhoto = function (_ATemplate) { } }, { key: 'gotoSlide', - value: function gotoSlide(index) { + value: function gotoSlide(index, skipHistory) { if (this.e && this.e.preventDefault) { this.e.preventDefault(); } @@ -634,7 +698,7 @@ var SmartPhoto = function (_ATemplate) { if (!this.data.currentIndex) { this.data.currentIndex = 0; } - this._slideList(); + this._slideList(skipHistory); } }, { key: 'setArrow', diff --git a/readme.md b/readme.md index 0205d8d..a4fd1e7 100644 --- a/readme.md +++ b/readme.md @@ -110,6 +110,16 @@ document.addEventListener('DOMContentLoaded',function(){ frequency to apply force to images 10 + + useHistoryApi + update page URL to reflect currently viewed image + true + + + historyApiMethod + which method to use for HistoryAPI ('replace'=replaces the URL with new one, without affecting history; 'push'=pushing new URL to history + 'replace' + #### Hide parts diff --git a/src/core/index.js b/src/core/index.js index ec1eca7..2b7d17c 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -44,6 +44,7 @@ const defaults = { verticalGravity: false, useOrientationApi: false, useHistoryApi: true, + historyApiMethod: 'replace', swipeTopToClose: false, swipeBottomToClose: true, swipeOffset: 100, @@ -104,6 +105,45 @@ export default class SmartPhoto extends ATemplate { this._doAnim(); }, this.data.forceInterval); + // IF history API is enabled + // > setup history event listener + if(this.data.useHistoryApi && this.data.historyApiMethod === 'push') { + + window.onpopstate = event => { + + // if state is not set - the gallery was hidden in this history state + if(!event || !event.state || event.state.group===void 0 || event.state.index === void 0) { + this.hidePhoto(); + return; + } + + // geting photo info from state object + this.data.currentGroup = event.state.group; + this.data.currentIndex = event.state.index; + const currentItem = this._getSelectedItem(); + + if (currentItem.loaded) { + this._initPhoto(); + this.data.appear = true; + this.clicked = true; + this.update(); + body.style.overflow = 'hidden'; + this._fireEvent('open'); + } else { + this._loadItem(currentItem).then(() => { + this._initPhoto(); + this.data.appear = true; + this.clicked = true; + this.update(); + body.style.overflow = 'hidden'; + this._fireEvent('open'); + }); + } + + this.gotoSlide(event.state.index, true); // <- don't update history + }; + } + if (!this.data.isSmartPhone) { window.addEventListener('resize', () => { if (!this.groupItems()) { @@ -387,7 +427,7 @@ export default class SmartPhoto extends ATemplate { const scrollY = window.scrollY; const body = document.querySelector('body'); if (location.hash) { - this._setHash(''); + this._setHash(); } window.scroll(scrollX, scrollY); this._doHideEffect(dir).then(() => { @@ -464,19 +504,39 @@ export default class SmartPhoto extends ATemplate { const items = this.groupItems(); const id = items[this.data.currentIndex].id; const group = this.data.currentGroup; - const hash = `group=${group}&photo=${id}`; - this._setHash(hash); + this._setHash(group, id, this.data.currentIndex); window.scroll(scrollX, scrollY); } - _setHash(hash) { + _setHash(group, id, index) { + if (!(window.history && window.history.pushState) || !this.data.useHistoryApi) { return; } - if (hash) { - window.history.replaceState(null, null, `${location.pathname}${location.search}#${hash}`); - } else { - window.history.replaceState(null, null, `${location.pathname}${location.search}`); + + // if the displayed image has not changed + // > don't change history + if(this.data.oldIndex === index) { + return; + } + + var newUrl = `${location.pathname}${location.search}`, + newState = void 0; + + // if `group` od `id` are not set + // > don't construct new state + if(group !== void 0 && id !== void 0) { + newUrl+=`#group=${group}&photo=${id}`; + newState = { group:group, id:id, index:index }; + } + + switch(this.data.historyApiMethod) { + case 'push': + window.history.pushState(newState, null, newUrl); + break; + case 'replace': + default: + window.history.replaceState(newState, null, newUrl); } } @@ -537,7 +597,7 @@ export default class SmartPhoto extends ATemplate { }); } - _slideList() { + _slideList(skipHistory) { this.data.scaleSize = 1; this.isBeingZoomed = false; this.data.hideUi = false; @@ -546,7 +606,11 @@ export default class SmartPhoto extends ATemplate { this.data.photoPosY = 0; this.data.onMoveClass = true; this._setPosByCurrentIndex(); - this._setHashByCurrentIndex(); + + if(!skipHistory) { + this._setHashByCurrentIndex(); + } + this._setSizeByScreen(); setTimeout(() => { this.data.onMoveClass = false; @@ -559,7 +623,7 @@ export default class SmartPhoto extends ATemplate { }, 200); } - gotoSlide(index) { + gotoSlide(index, skipHistory) { if (this.e && this.e.preventDefault) { this.e.preventDefault(); } @@ -567,7 +631,7 @@ export default class SmartPhoto extends ATemplate { if (!this.data.currentIndex) { this.data.currentIndex = 0; } - this._slideList(); + this._slideList(skipHistory); } setArrow() {