From 0a097e192c668d226d20c6532b9411f6420e8881 Mon Sep 17 00:00:00 2001 From: Takayuki Nagatomi Date: Thu, 29 Jun 2023 17:50:41 +0900 Subject: [PATCH 1/6] Fixed focus movement within a modal. --- css/smartphoto.css | 1 + css/smartphoto.min.css | 2 +- examples/jquery.html | 20 ------------ examples/multiple.html | 2 +- js/jquery-smartphoto.js | 31 ++++++++++++++++-- js/jquery-smartphoto.min.js | 6 ++-- js/smartphoto.js | 31 ++++++++++++++++-- js/smartphoto.min.js | 6 ++-- lib/core/index.js | 29 ++++++++++++++++- scss/smartphoto.scss | 1 + src/core/index.js | 32 +++++++++++++++--- src/core/viewer.html | 65 +++++++++++++++++++++++++++++++++++++ src/core/viwer.html | 49 ---------------------------- 13 files changed, 189 insertions(+), 86 deletions(-) create mode 100644 src/core/viewer.html delete mode 100644 src/core/viwer.html diff --git a/css/smartphoto.css b/css/smartphoto.css index cf26384..6eb5e4d 100644 --- a/css/smartphoto.css +++ b/css/smartphoto.css @@ -146,6 +146,7 @@ text-decoration: none; cursor: pointer; line-height: 1; + z-index: 1; } .smartphoto-body { diff --git a/css/smartphoto.min.css b/css/smartphoto.min.css index 710a190..a820662 100644 --- a/css/smartphoto.min.css +++ b/css/smartphoto.min.css @@ -1 +1 @@ -@keyframes smartphoto{from{opacity:0}to{opacity:1}}@keyframes smartphoto-img-wrap{from{opacity:0}to{opacity:1}}@keyframes smartphoto-inner{from{transform:translate(0, 100px)}to{transform:translate(0, 0)}}@keyframes smartphoto-loader{0%{opacity:.4;transform:rotate(0deg)}50%{opacity:1;transform:rotate(180deg)}100%{opacity:.4;transform:rotate(360deg)}}@keyframes smartphoto-appear{0%{display:none;opacity:0}1%{display:block;opacity:0}100%{display:block;opacity:1}}@keyframes smartphoto-hide{0%{display:block;opacity:1}99%{display:block;opacity:0}100%{display:none;opacity:0}}.smartphoto{position:fixed;z-index:100;top:0;left:0;width:100%;height:100%;overflow:hidden;background-color:#000;opacity:1;font-family:sans-serif;cursor:pointer;-webkit-transition:opacity .3s ease-out;-moz-transition:opacity .3s ease-out;-ms-transition:opacity .3s ease-out;-o-transition:opacity .3s ease-out;transition:opacity .3s ease-out;transition:all 0.3s ease-out;animation-name:smartphoto;animation-duration:.3s;animation-timing-function:ease-out}.smartphoto[aria-hidden="true"]{display:none}.smartphoto-close{opacity:0}.smartphoto-count{display:inline-block;color:#FFF;font-size:16px}.smartphoto-header{display:block;box-sizing:border-box;position:fixed;z-index:102;top:0;left:0;width:100%;height:50px;padding:15px;background-color:rgba(0,0,0,0.2)}.smartphoto-content{display:block;position:absolute;top:0;left:0;width:100%;height:100%}.smartphoto-dismiss{display:block;position:absolute;top:15px;right:10px;width:20px;height:20px;padding:0;border:none;background-color:transparent;background-image:url(data:image/svg+xml;base64,PHN2ZyBpZD0i44Os44Kk44Ok44O8XzEiIGRhdGEtbmFtZT0i44Os44Kk44Ok44O8IDEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDI4MzQuNjUgMjgzNC42NSIgZmlsbD0iI0ZGRiI+PHRpdGxlPmljb248L3RpdGxlPjxwYXRoIGQ9Ik0xNTc2LjQyLDE0MDYuNzYsMjc4NCwxOTkuMTlhNTYuODYsNTYuODYsMCwwLDAsMC04MC4xOGwtNzguOTItNzguOTJhNTYuODYsNTYuODYsMCwwLDAtODAuMTgsMEwxNDE3LjMyLDEyNDcuNjYsMjA5Ljc1LDQwLjA5YTU2Ljg2LDU2Ljg2LDAsMCwwLTgwLjE4LDBMNTAuNjUsMTE5YTU2Ljg2LDU2Ljg2LDAsMCwwLDAsODAuMThMMTI1OC4yMywxNDA2Ljc2LDUwLjY1LDI2MTQuMzRhNTYuODYsNTYuODYsMCwwLDAsMCw4MC4xOGw3OC45Miw3OC45MmE1Ni44Niw1Ni44NiwwLDAsMCw4MC4xOCwwTDE0MTcuMzIsMTU2NS44NiwyNjI0LjksMjc3My40NGE1Ni44Niw1Ni44NiwwLDAsMCw4MC4xOCwwbDc4LjkyLTc4LjkyYTU2Ljg2LDU2Ljg2LDAsMCwwLDAtODAuMThaIi8+PC9zdmc+);text-shadow:0 1px 0 #FFF;color:#FFF;font-size:30px;text-decoration:none;cursor:pointer;line-height:1}.smartphoto-body{position:relative;z-index:102;width:100%;height:100%;margin:0 auto}.smartphoto-inner{position:relative;width:100%;height:100%;vertical-align:top}.smartphoto-img{display:none;max-width:none;width:auto;height:auto;cursor:zoom-in;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;transition:transform 0.3s ease-out;-webkit-user-drag:none}.smartphoto-img.active{display:block}.smartphoto-img-onmove{cursor:grab;cursor:-webkit-grab;transition:none}.smartphoto-img-elasticmove{transition:transform 0.3s ease-out}.smartphoto-img-wrap{display:inline-block;opacity:1;-webkit-transition:opacity .3s ease-out;-moz-transition:opacity .3s ease-out;-ms-transition:opacity .3s ease-out;-o-transition:opacity .3s ease-out;transition:opacity .3s ease-out;animation-name:smartphoto-img-wrap;animation-duration:.3s;animation-timing-function:ease-out}.smartphoto-img-left{transform:translateX(150%) !important}.smartphoto-img-right{transform:translateX(-150%) !important}.smartphoto-arrows{list-style-type:none;margin:0;padding:0;position:relative;z-index:1002;top:50%;left:0;opacity:1;animation-name:smartphoto-appear;animation-duration:.3s;animation-timing-function:ease-out}.smartphoto-arrows[aria-hidden="true"]{animation-name:smartphoto-hide;display:none}.smartphoto-arrows li{display:block;position:absolute;top:50%;width:30px;height:30px;margin-top:-20px;box-sizing:content-box;animation-duration:.3s;animation-timing-function:ease-out;animation-name:smartphoto-appear}.smartphoto-arrows li:focus{outline:none}.smartphoto-arrows [aria-hidden="true"]{animation-name:smartphoto-hide;display:none}.smartphoto-arrows a{display:block;width:100%;height:100%;text-decoration:none}.smartphoto-arrow-right{right:0;padding:5px 0;background-color:rgba(0,0,0,0.5)}.smartphoto-arrow-right a{background-image:url(data:image/svg+xml;base64,PHN2ZyBpZD0i44Os44Kk44Ok44O8XzEiIGRhdGEtbmFtZT0i44Os44Kk44Ok44O8IDEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDI4MzQuNjUgMjgzNC42NSIgZmlsbD0iI0ZGRiAiPjx0aXRsZT5pY29uPC90aXRsZT48cGF0aCBkPSJNMTgzNy44OCwxNDE3LjMyLDY0My41OSwyMjNhNzIuMjEsNzIuMjEsMCwwLDEsMC0xMDEuODJMNzQzLjgyLDIxYTcyLjIxLDcyLjIxLDAsMCwxLDEwMS44MiwwTDIwOTAuODMsMTI2Ni4xOWwxMDAuMjMsMTAwLjIzYTcyLjIxLDcyLjIxLDAsMCwxLDAsMTAxLjgyTDg0NS42NCwyODEzLjY1YTcyLjIxLDcyLjIxLDAsMCwxLTEwMS44MiwwTDY0My41OSwyNzEzLjQyYTcyLjIxLDcyLjIxLDAsMCwxLDAtMTAxLjgyWiIvPjwvc3ZnPg==)}.smartphoto-arrow-left{left:0;padding:5px 0;background-color:rgba(0,0,0,0.5)}.smartphoto-arrow-left a{background-image:url(data:image/svg+xml;base64,PHN2ZyBpZD0i44Os44Kk44Ok44O8XzEiIGRhdGEtbmFtZT0i44Os44Kk44Ok44O8IDEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDI4MzQuNjUgMjgzNC42NSIgZmlsbD0iI0ZGRiI+PHRpdGxlPmljb248L3RpdGxlPjxwYXRoIGQ9Ik05OTYuNzcsMTQxNy4zMiwyMTkxLjA2LDIyM2E3Mi4yMSw3Mi4yMSwwLDAsMCwwLTEwMS44MkwyMDkwLjgzLDIxQTcyLjIxLDcyLjIxLDAsMCwwLDE5ODksMjFMNzQzLjgyLDEyNjYuMTksNjQzLjU5LDEzNjYuNDJhNzIuMjEsNzIuMjEsMCwwLDAsMCwxMDEuODJMMTk4OSwyODEzLjY1YTcyLjIxLDcyLjIxLDAsMCwwLDEwMS44MiwwbDEwMC4yMy0xMDAuMjNhNzIuMjEsNzIuMjEsMCwwLDAsMC0xMDEuODJaIi8+PC9zdmc+)}.smartPhotoArrowHideIcon{display:none}.smartphoto-nav{position:absolute;bottom:0;left:0;width:100%;opacity:1;animation-name:smartphoto-appear;animation-duration:.3s;animation-timing-function:ease-out}.smartphoto-nav[aria-hidden="true"]{animation-name:smartphoto-hide;display:none}.smartphoto-nav ul{display:block;overflow-x:auto;list-style:none;margin:0;padding:0;text-align:center;white-space:nowrap;-webkit-overflow-scrolling:touch}.smartphoto-nav li{display:inline-block;overflow:hidden;width:50px;height:50px}.smartphoto-nav a{display:block;width:100%;height:100%;background-color:#FFF;background-position:center center;background-size:cover;opacity:.5}.smartphoto-nav a:focus{opacity:.8}.smartphoto-nav a.current{opacity:1}.smartphoto-nav img{width:auto;height:100%}.smartphoto-list{list-style-type:none;position:absolute;z-index:101;top:0;left:0;margin:0;padding:0;white-space:nowrap}.smartphoto-list li{display:block;position:absolute;top:0;left:0;width:100%;height:100%;transition:all 0.3s ease-out}.smartphoto-list li:focus{outline:none}.smartphoto-list-onmove{transition:all 0.3s ease-out}.smartphoto-caption{overflow:hidden;box-sizing:border-box;position:absolute;top:0;left:0;width:100%;height:50px;padding:0 50px;color:#FFF;font-size:12px;text-align:center;line-height:50px;white-space:nowrap;text-overflow:ellipsis}.smartphoto-caption:focus{outline:none}.smartphoto-loader-wrap{display:block;position:relative;z-index:103;width:0;height:0;transform:translate(50vw, 50vh)}.smartphoto-loader{position:absolute;z-index:101;top:0;left:0;width:30px;height:30px;margin-top:-25px;margin-left:-25px;border:8px solid #17CDDD;border-right-color:transparent;border-radius:50%;animation:smartphoto-loader .5s infinite linear}.smartphoto-img-clone{position:fixed;z-index:100;top:0;left:0;transition:all .3s ease-out}.smartphoto-sr-only{overflow:hidden;position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;clip:rect(0, 0, 0, 0)} +@keyframes smartphoto{from{opacity:0}to{opacity:1}}@keyframes smartphoto-img-wrap{from{opacity:0}to{opacity:1}}@keyframes smartphoto-inner{from{transform:translate(0, 100px)}to{transform:translate(0, 0)}}@keyframes smartphoto-loader{0%{opacity:.4;transform:rotate(0deg)}50%{opacity:1;transform:rotate(180deg)}100%{opacity:.4;transform:rotate(360deg)}}@keyframes smartphoto-appear{0%{display:none;opacity:0}1%{display:block;opacity:0}100%{display:block;opacity:1}}@keyframes smartphoto-hide{0%{display:block;opacity:1}99%{display:block;opacity:0}100%{display:none;opacity:0}}.smartphoto{position:fixed;z-index:100;top:0;left:0;width:100%;height:100%;overflow:hidden;background-color:#000;opacity:1;font-family:sans-serif;cursor:pointer;-webkit-transition:opacity .3s ease-out;-moz-transition:opacity .3s ease-out;-ms-transition:opacity .3s ease-out;-o-transition:opacity .3s ease-out;transition:opacity .3s ease-out;transition:all 0.3s ease-out;animation-name:smartphoto;animation-duration:.3s;animation-timing-function:ease-out}.smartphoto[aria-hidden="true"]{display:none}.smartphoto-close{opacity:0}.smartphoto-count{display:inline-block;color:#FFF;font-size:16px}.smartphoto-header{display:block;box-sizing:border-box;position:fixed;z-index:102;top:0;left:0;width:100%;height:50px;padding:15px;background-color:rgba(0,0,0,0.2)}.smartphoto-content{display:block;position:absolute;top:0;left:0;width:100%;height:100%}.smartphoto-dismiss{display:block;position:absolute;top:15px;right:10px;width:20px;height:20px;padding:0;border:none;background-color:transparent;background-image:url(data:image/svg+xml;base64,PHN2ZyBpZD0i44Os44Kk44Ok44O8XzEiIGRhdGEtbmFtZT0i44Os44Kk44Ok44O8IDEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDI4MzQuNjUgMjgzNC42NSIgZmlsbD0iI0ZGRiI+PHRpdGxlPmljb248L3RpdGxlPjxwYXRoIGQ9Ik0xNTc2LjQyLDE0MDYuNzYsMjc4NCwxOTkuMTlhNTYuODYsNTYuODYsMCwwLDAsMC04MC4xOGwtNzguOTItNzguOTJhNTYuODYsNTYuODYsMCwwLDAtODAuMTgsMEwxNDE3LjMyLDEyNDcuNjYsMjA5Ljc1LDQwLjA5YTU2Ljg2LDU2Ljg2LDAsMCwwLTgwLjE4LDBMNTAuNjUsMTE5YTU2Ljg2LDU2Ljg2LDAsMCwwLDAsODAuMThMMTI1OC4yMywxNDA2Ljc2LDUwLjY1LDI2MTQuMzRhNTYuODYsNTYuODYsMCwwLDAsMCw4MC4xOGw3OC45Miw3OC45MmE1Ni44Niw1Ni44NiwwLDAsMCw4MC4xOCwwTDE0MTcuMzIsMTU2NS44NiwyNjI0LjksMjc3My40NGE1Ni44Niw1Ni44NiwwLDAsMCw4MC4xOCwwbDc4LjkyLTc4LjkyYTU2Ljg2LDU2Ljg2LDAsMCwwLDAtODAuMThaIi8+PC9zdmc+);text-shadow:0 1px 0 #FFF;color:#FFF;font-size:30px;text-decoration:none;cursor:pointer;line-height:1;z-index:1}.smartphoto-body{position:relative;z-index:102;width:100%;height:100%;margin:0 auto}.smartphoto-inner{position:relative;width:100%;height:100%;vertical-align:top}.smartphoto-img{display:none;max-width:none;width:auto;height:auto;cursor:zoom-in;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;transition:transform 0.3s ease-out;-webkit-user-drag:none}.smartphoto-img.active{display:block}.smartphoto-img-onmove{cursor:grab;cursor:-webkit-grab;transition:none}.smartphoto-img-elasticmove{transition:transform 0.3s ease-out}.smartphoto-img-wrap{display:inline-block;opacity:1;-webkit-transition:opacity .3s ease-out;-moz-transition:opacity .3s ease-out;-ms-transition:opacity .3s ease-out;-o-transition:opacity .3s ease-out;transition:opacity .3s ease-out;animation-name:smartphoto-img-wrap;animation-duration:.3s;animation-timing-function:ease-out}.smartphoto-img-left{transform:translateX(150%) !important}.smartphoto-img-right{transform:translateX(-150%) !important}.smartphoto-arrows{list-style-type:none;margin:0;padding:0;position:relative;z-index:1002;top:50%;left:0;opacity:1;animation-name:smartphoto-appear;animation-duration:.3s;animation-timing-function:ease-out}.smartphoto-arrows[aria-hidden="true"]{animation-name:smartphoto-hide;display:none}.smartphoto-arrows li{display:block;position:absolute;top:50%;width:30px;height:30px;margin-top:-20px;box-sizing:content-box;animation-duration:.3s;animation-timing-function:ease-out;animation-name:smartphoto-appear}.smartphoto-arrows li:focus{outline:none}.smartphoto-arrows [aria-hidden="true"]{animation-name:smartphoto-hide;display:none}.smartphoto-arrows a{display:block;width:100%;height:100%;text-decoration:none}.smartphoto-arrow-right{right:0;padding:5px 0;background-color:rgba(0,0,0,0.5)}.smartphoto-arrow-right a{background-image:url(data:image/svg+xml;base64,PHN2ZyBpZD0i44Os44Kk44Ok44O8XzEiIGRhdGEtbmFtZT0i44Os44Kk44Ok44O8IDEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDI4MzQuNjUgMjgzNC42NSIgZmlsbD0iI0ZGRiAiPjx0aXRsZT5pY29uPC90aXRsZT48cGF0aCBkPSJNMTgzNy44OCwxNDE3LjMyLDY0My41OSwyMjNhNzIuMjEsNzIuMjEsMCwwLDEsMC0xMDEuODJMNzQzLjgyLDIxYTcyLjIxLDcyLjIxLDAsMCwxLDEwMS44MiwwTDIwOTAuODMsMTI2Ni4xOWwxMDAuMjMsMTAwLjIzYTcyLjIxLDcyLjIxLDAsMCwxLDAsMTAxLjgyTDg0NS42NCwyODEzLjY1YTcyLjIxLDcyLjIxLDAsMCwxLTEwMS44MiwwTDY0My41OSwyNzEzLjQyYTcyLjIxLDcyLjIxLDAsMCwxLDAtMTAxLjgyWiIvPjwvc3ZnPg==)}.smartphoto-arrow-left{left:0;padding:5px 0;background-color:rgba(0,0,0,0.5)}.smartphoto-arrow-left a{background-image:url(data:image/svg+xml;base64,PHN2ZyBpZD0i44Os44Kk44Ok44O8XzEiIGRhdGEtbmFtZT0i44Os44Kk44Ok44O8IDEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDI4MzQuNjUgMjgzNC42NSIgZmlsbD0iI0ZGRiI+PHRpdGxlPmljb248L3RpdGxlPjxwYXRoIGQ9Ik05OTYuNzcsMTQxNy4zMiwyMTkxLjA2LDIyM2E3Mi4yMSw3Mi4yMSwwLDAsMCwwLTEwMS44MkwyMDkwLjgzLDIxQTcyLjIxLDcyLjIxLDAsMCwwLDE5ODksMjFMNzQzLjgyLDEyNjYuMTksNjQzLjU5LDEzNjYuNDJhNzIuMjEsNzIuMjEsMCwwLDAsMCwxMDEuODJMMTk4OSwyODEzLjY1YTcyLjIxLDcyLjIxLDAsMCwwLDEwMS44MiwwbDEwMC4yMy0xMDAuMjNhNzIuMjEsNzIuMjEsMCwwLDAsMC0xMDEuODJaIi8+PC9zdmc+)}.smartPhotoArrowHideIcon{display:none}.smartphoto-nav{position:absolute;bottom:0;left:0;width:100%;opacity:1;animation-name:smartphoto-appear;animation-duration:.3s;animation-timing-function:ease-out}.smartphoto-nav[aria-hidden="true"]{animation-name:smartphoto-hide;display:none}.smartphoto-nav ul{display:block;overflow-x:auto;list-style:none;margin:0;padding:0;text-align:center;white-space:nowrap;-webkit-overflow-scrolling:touch}.smartphoto-nav li{display:inline-block;overflow:hidden;width:50px;height:50px}.smartphoto-nav a{display:block;width:100%;height:100%;background-color:#FFF;background-position:center center;background-size:cover;opacity:.5}.smartphoto-nav a:focus{opacity:.8}.smartphoto-nav a.current{opacity:1}.smartphoto-nav img{width:auto;height:100%}.smartphoto-list{list-style-type:none;position:absolute;z-index:101;top:0;left:0;margin:0;padding:0;white-space:nowrap}.smartphoto-list li{display:block;position:absolute;top:0;left:0;width:100%;height:100%;transition:all 0.3s ease-out}.smartphoto-list li:focus{outline:none}.smartphoto-list-onmove{transition:all 0.3s ease-out}.smartphoto-caption{overflow:hidden;box-sizing:border-box;position:absolute;top:0;left:0;width:100%;height:50px;padding:0 50px;color:#FFF;font-size:12px;text-align:center;line-height:50px;white-space:nowrap;text-overflow:ellipsis}.smartphoto-caption:focus{outline:none}.smartphoto-loader-wrap{display:block;position:relative;z-index:103;width:0;height:0;transform:translate(50vw, 50vh)}.smartphoto-loader{position:absolute;z-index:101;top:0;left:0;width:30px;height:30px;margin-top:-25px;margin-left:-25px;border:8px solid #17CDDD;border-right-color:transparent;border-radius:50%;animation:smartphoto-loader .5s infinite linear}.smartphoto-img-clone{position:fixed;z-index:100;top:0;left:0;transition:all .3s ease-out}.smartphoto-sr-only{overflow:hidden;position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;clip:rect(0, 0, 0, 0)} diff --git a/examples/jquery.html b/examples/jquery.html index 0d377f6..a7f39e2 100644 --- a/examples/jquery.html +++ b/examples/jquery.html @@ -42,26 +42,6 @@

jquery-smartphoto.js

-
- - - -
-
- - - -
-
- - - -
-
- - - -
diff --git a/examples/multiple.html b/examples/multiple.html index 36a1d76..dc8c136 100644 --- a/examples/multiple.html +++ b/examples/multiple.html @@ -84,7 +84,7 @@

resizeStyle = Fit

diff --git a/js/jquery-smartphoto.js b/js/jquery-smartphoto.js index c6511cb..0385be4 100644 --- a/js/jquery-smartphoto.js +++ b/js/jquery-smartphoto.js @@ -6,7 +6,7 @@ * license: MIT (http://opensource.org/licenses/MIT) * author: appleple * homepage: http://developer.a-blogcms.jp - * version: 1.6.4 + * version: 1.6.5 * * a-template: * license: MIT (http://opensource.org/licenses/MIT) @@ -2213,7 +2213,7 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function" function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } -var template = "
aria-hidden=\"true\" aria-hidden=\"false\" role=\"dialog\">\n\t
\n\t\t
\n\t\t\t
\n\t\t\t\t\t{currentIndex}[increment]/{total}\n\t\t\t\t\t{caption}\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\t
data-action-touchstart=\"beforeDrag\" data-action-touchmove=\"onDrag\" data-action-touchend=\"afterDrag(false)\" data-action-click=\"hidePhoto()\">\n\t\t\t\t
\n\t\t\t\t
    \\{classNames.smartPhotoListOnMove\\}\">\n\t\t\t\t\t\n\t\t\t\t\t
  • current\">\n\t\t\t\t\t\t\n\t\t\t\t\t\t
    data-action-mousemove=\"onDrag\" data-action-mousedown=\"beforeDrag\" data-action-mouseup=\"afterDrag\" data-action-touchstart=\"beforeDrag\" data-action-touchmove=\"onDrag\" data-action-touchend=\"afterDrag\">\n\t\t\t\t\t\t\ttransform:translate(\\{photoPosX\\}[virtualPos]px,\\{photoPosY\\}[virtualPos]px) scale(\\{scaleSize\\});width:{width}px;\" src=\"{src}\" class=\"\\\\{classNames.smartPhotoImg\\\\} \\\\{classNames.smartPhotoImgOnMove\\\\} \\\\{classNames.smartPhotoImgElasticMove\\\\} active\" ondragstart=\"return false;\">\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t
  • \n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t
\n\t\t\n\t\t\n\t\t\n\t
\n
\n"; +var template = "
aria-hidden=\"true\" aria-hidden=\"false\" role=\"dialog\" tabindex=\"-1\">\n\t
\n\t\t
\n\t\t\t
\n\t\t\t\t{currentIndex}[increment]/{total}\n\t\t\t\t{caption}\n\t\t\t
\n\n\t\t\t
data-action-touchstart=\"beforeDrag\" data-action-touchmove=\"onDrag\" data-action-touchend=\"afterDrag(false)\" data-action-click=\"hidePhoto()\">\n\t\t\t
\n\n\t\t\t
    \\{classNames.smartPhotoListOnMove\\}\">\n\t\t\t\t\n\t\t\t\t
  • current\">\n\t\t\t\t\t\n\t\t\t\t\t
    data-action-mousemove=\"onDrag\" data-action-mousedown=\"beforeDrag\" data-action-mouseup=\"afterDrag\" data-action-touchstart=\"beforeDrag\" data-action-touchmove=\"onDrag\" data-action-touchend=\"afterDrag\">\n\t\t\t\t\t\ttransform:translate(\\{photoPosX\\}[virtualPos]px,\\{photoPosY\\}[virtualPos]px) scale(\\{scaleSize\\});width:{width}px;\" src=\"{src}\" class=\"\\\\{classNames.smartPhotoImg\\\\} \\\\{classNames.smartPhotoImgOnMove\\\\} \\\\{classNames.smartPhotoImgElasticMove\\\\} active\" ondragstart=\"return false;\">\n\t\t\t\t\t
    \n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t
    \n\t\t\t\t\t\t\n\t\t\t\t\t
    \n\t\t\t\t\t\n\t\t\t\t
  • \n\t\t\t\t\n\t\t\t
\n\n\t\t\t\n\t\t\t aria-hidden=\"true\"\n\t\t\t\t aria-hidden=\"false\"\n\t\t\t\ttabindex=\"-1\">\n\t\t\t\t
  • \\{classNames.smartPhotoArrowHideIcon\\}\" aria-hidden=\"true\">\\{message.gotoPrevImage\\}
  • \n\t\t\t\t
  • \\{classNames.smartPhotoArrowHideIcon\\}\" aria-hidden=\"true\">\\{message.gotoNextImage\\}
  • \n\t\t\t\n\t\t\t\n\n\t\t\t\n\t\t\taria-hidden=\"true\"\n\t\t\t\t aria-hidden=\"false\">\n\t\t\t\t\n\t\t\t\n\t\t\t\n\n\t\t\t\n\t\t\t\t\\{message.closeDialog\\}\n\t\t\t\n\t\t
    \n\t\t\n\t\t\n\t\t\n\t
    \n
    \n"; var util = require('../lib/util'); @@ -2595,6 +2595,21 @@ function (_ATemplate) { var currentItem = _this3._getSelectedItem(); + var onFocus = function onFocus(e) { + if (e.keyCode === 9) { + var smartPhoto = document.querySelector(".".concat(_this3.data.classNames.smartPhoto)); + var arrows = document.querySelector(".".concat(_this3.data.classNames.smartPhotoArrows)); + var dismiss = document.querySelector(".".concat(_this3.data.classNames.smartPhotoDismiss)); + var curFocus = document.activeElement; + + if (curFocus === smartPhoto) { + arrows.focus(); + } else if (curFocus === dismiss) { + smartPhoto.focus(); + } + } + }; + if (currentItem.loaded) { _this3._initPhoto(); @@ -2607,6 +2622,12 @@ function (_ATemplate) { body.style.overflow = 'hidden'; _this3._fireEvent('open'); + + var smartPhoto = document.querySelector(".".concat(_this3.data.classNames.smartPhoto)); + smartPhoto.focus(); + document.addEventListener('keydown', onFocus); + + _this3._registerRemoveEvent(window, 'keydown', onFocus); } else { _this3._loadItem(currentItem).then(function () { _this3._initPhoto(); @@ -2620,6 +2641,12 @@ function (_ATemplate) { body.style.overflow = 'hidden'; _this3._fireEvent('open'); + + var smartPhoto = document.querySelector(".".concat(_this3.data.classNames.smartPhoto)); + smartPhoto.focus(); + document.addEventListener('keydown', onFocus); + + _this3._registerRemoveEvent(window, 'keydown', onFocus); }); } }; diff --git a/js/jquery-smartphoto.min.js b/js/jquery-smartphoto.min.js index 2677a90..a25a525 100644 --- a/js/jquery-smartphoto.min.js +++ b/js/jquery-smartphoto.min.js @@ -6,7 +6,7 @@ * license: MIT (http://opensource.org/licenses/MIT) * author: appleple * homepage: http://developer.a-blogcms.jp - * version: 1.6.4 + * version: 1.6.5 * * a-template: * license: MIT (http://opensource.org/licenses/MIT) @@ -52,5 +52,5 @@ * * This header is generated by licensify (https://github.com/twada/licensify) */ -!function(){function t(e,a,o){function n(r,s){if(!a[r]){if(!e[r]){var c="function"==typeof require&&require;if(!s&&c)return c(r,!0);if(i)return i(r,!0);var d=new Error("Cannot find module '"+r+"'");throw d.code="MODULE_NOT_FOUND",d}var u=a[r]={exports:{}};e[r][0].call(u.exports,function(t){return n(e[r][1][t]||t)},u,u.exports,t,e,a,o)}return a[r].exports}for(var i="function"==typeof require&&require,r=0;r1;)a=a[o.shift()];a[o.shift()]=e}},{key:"removeDataByString",value:function(t){for(var e=this.data,a=t.split(".");a.length>1;)e=e[a.shift()];var o=a.shift();o.match(/^\d+$/)?e.splice(Number(o),1):delete e[o]}},{key:"resolveBlock",value:function(t,e,a){var o=this,n=t.match(//g),i=t.match(//g),r=t.match(//g),s=t.match(//g);if(n)for(var c=0,d=n.length;c/g;return t=t.replace(e,function(t,e){return(0,c.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,a=this;return t=t.replace(e,function(t,e,o){var n=a.getDataByString(e),i=[];i="function"==typeof n?n.apply(a):n;var r="";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 a=this.atemplate.find(function(e){return e.id===t}),o="";if(a&&a.html&&(o=a.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",a=arguments[1],o=this.templates;this.beforeUpdated&&this.beforeUpdated();for(var n=0,i=o.length;n"+u+"");else(0,c.selector)(d).insertAdjacentHTML("afterend",'
    '),"text"===e?(0,c.selector)("[data-id='"+r+"']").innerText=u:(0,c.selector)("[data-id='"+r+"']").innerHTML=u;var p=t.atemplate.find(function(t){return t.id===r});p.binded||(p.binded=!0,t.addDataBind((0,c.selector)("[data-id='"+r+"']")),t.addActionBind((0,c.selector)("[data-id='"+r+"']")))}(n);return this.updateBindingData(a),this.onUpdated&&this.onUpdated(a),this}},{key:"updateBindingData",value:function(t){for(var e=this,a=this.templates,o=0,n=a.length;o1?a-1:0),n=1;n1;)e=e[a.shift()];var o=a.shift();return o.match(/^\d+$/)?e.splice(Number(o),1):delete e[o],this}}]),t}();a.default=l,e.exports=a.default},{"./util":2,"ie-array-find-polyfill":5,morphdom:6}],2:[function(t,e,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var o=a.matches=function(t,e){for(var a=(t.document||t.ownerDocument).querySelectorAll(e),o=a.length;--o>=0&&a.item(o)!==t;);return o>-1},n=(a.selector=function(t){return document.querySelector(t)},a.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}),i=[];a.on=function(t,e,a,o){var r=arguments.length>4&&void 0!==arguments[4]&&arguments[4];a.split(" ").forEach(function(a){var s=function(t){var a=n(t.target,e);a&&(t.delegateTarget=a,o(t))};i.push({listener:s,element:t,query:e,event:a,capture:r}),t.addEventListener(a,s,r)})},a.off=function(t,e,a){a.split(" ").forEach(function(a){i.forEach(function(o,n){o.element===t&&o.query===e&&o.event===a&&(t.removeEventListener(a,o.listener,o.capture),i.splice(n,1))})})}},{}],3:[function(t,e,a){try{var o=new window.CustomEvent("test");if(o.preventDefault(),!0!==o.defaultPrevented)throw new Error("Could not prevent default")}catch(t){var n=function(t,e){var a,o;return e=e||{bubbles:!1,cancelable:!1,detail:void 0},a=document.createEvent("CustomEvent"),a.initCustomEvent(t,e.bubbles,e.cancelable,e.detail),o=a.preventDefault,a.preventDefault=function(){o.call(this);try{Object.defineProperty(this,"defaultPrevented",{get:function(){return!0}})}catch(t){this.defaultPrevented=!0}},a};n.prototype=window.Event.prototype,window.CustomEvent=n}},{}],4:[function(t,e,a){(function(t,e){!function(t){function o(t){return"[object Array]"===Object.prototype.toString.call(t)}function n(){for(var t=0;t>>0;if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var o=arguments[1],n=0;n=0;s--)a=r[s],o=a.name,n=a.namespaceURI,i=a.value,n?(o=a.localName||o,t.getAttributeNS(n,o)!==i&&("xmlns"===a.prefix&&(o=a.name),t.setAttributeNS(n,o,i))):t.getAttribute(o)!==i&&t.setAttribute(o,i);for(var c=t.attributes,d=c.length-1;d>=0;d--)a=c[d],o=a.name,n=a.namespaceURI,n?(o=a.localName||o,e.hasAttributeNS(n,o)||t.removeAttributeNS(n,o)):e.hasAttribute(o)||t.removeAttribute(o)}}function n(t){var e=g.createElement("template");return e.innerHTML=t,e.content.childNodes[0]}function i(t){return p||(p=g.createRange(),p.selectNode(g.body)),p.createContextualFragment(t).childNodes[0]}function r(t){var e=g.createElement("body");return e.innerHTML=t,e.childNodes[0]}function s(t){return t=t.trim(),y?n(t):x?i(t):r(t)}function c(t,e){var a=t.nodeName,o=e.nodeName;return a===o||!!(e.actualize&&a.charCodeAt(0)<91&&o.charCodeAt(0)>90)&&a===o.toUpperCase()}function d(t,e){return e&&e!==v?g.createElementNS(e,t):g.createElement(t)}function u(t,e){for(var a=t.firstChild;a;){var o=a.nextSibling;e.appendChild(a),a=o}return e}function h(t,e,a){t[a]!==e[a]&&(t[a]=e[a],t[a]?t.setAttribute(a,""):t.removeAttribute(a))}function l(){}function f(t){if(t)return t.getAttribute&&t.getAttribute("id")||t.id}var p,m=11,v="http://www.w3.org/1999/xhtml",g="undefined"==typeof document?void 0:document,y=!!g&&"content"in g.createElement("template"),x=!!g&&g.createRange&&"createContextualFragment"in g.createRange(),w={OPTION:function(t,e){var a=t.parentNode;if(a){var o=a.nodeName.toUpperCase();"OPTGROUP"===o&&(a=a.parentNode,o=a&&a.nodeName.toUpperCase()),"SELECT"!==o||a.hasAttribute("multiple")||(t.hasAttribute("selected")&&!e.selected&&(t.setAttribute("selected","selected"),t.removeAttribute("selected")),a.selectedIndex=-1)}h(t,e,"selected")},INPUT:function(t,e){h(t,e,"checked"),h(t,e,"disabled"),t.value!==e.value&&(t.value=e.value),e.hasAttribute("value")||t.removeAttribute("value")},TEXTAREA:function(t,e){var a=e.value;t.value!==a&&(t.value=a);var o=t.firstChild;if(o){var n=o.nodeValue;if(n==a||!a&&n==t.placeholder)return;o.nodeValue=a}},SELECT:function(t,e){if(!e.hasAttribute("multiple")){for(var a,o,n=-1,i=0,r=t.firstChild;r;)if("OPTGROUP"===(o=r.nodeName&&r.nodeName.toUpperCase()))a=r,r=a.firstChild;else{if("OPTION"===o){if(r.hasAttribute("selected")){n=i;break}i++}r=r.nextSibling,!r&&a&&(r=a.nextSibling,a=null)}t.selectedIndex=n}}},P=1,E=11,b=3,_=8,I=function(t){return function(e,a,o){function n(t){G.push(t)}function i(t,e){if(t.nodeType===P)for(var a=t.firstChild;a;){var o=void 0;e&&(o=I(a))?n(o):(T(a),a.firstChild&&i(a,e)),a=a.nextSibling}}function r(t,e,a){!1!==B(t)&&(e&&e.removeChild(t),T(t),i(t,a))}function h(t){if(t.nodeType===P||t.nodeType===E)for(var e=t.firstChild;e;){var a=I(e);a&&(C[a]=e),h(e),e=e.nextSibling}}function p(t){S(t);for(var e=t.firstChild;e;){var a=e.nextSibling,o=I(e);if(o){var n=C[o];n&&c(e,n)&&(e.parentNode.replaceChild(n,e),v(n,e))}p(e),e=a}}function m(t,e,a){for(;e;){var o=e.nextSibling;(a=I(e))?n(a):r(e,t,!0),e=o}}function v(e,a,o){var n=I(a);if(n&&delete C[n],!o){if(!1===k(e,a))return;if(t(e,a),A(e),!1===D(e,a))return}"TEXTAREA"!==e.nodeName?y(e,a):w.TEXTAREA(e,a)}function y(t,e){var a,o,i,s,d,u=e.firstChild,h=t.firstChild;t:for(;u;){for(s=u.nextSibling,a=I(u);h;){if(i=h.nextSibling,u.isSameNode&&u.isSameNode(h)){u=s,h=i;continue t}o=I(h);var l=h.nodeType,f=void 0;if(l===u.nodeType&&(l===P?(a?a!==o&&((d=C[a])?i===d?f=!1:(t.insertBefore(d,h),o?n(o):r(h,t,!0),h=d):f=!1):o&&(f=!1),(f=!1!==f&&c(h,u))&&v(h,u)):l!==b&&l!=_||(f=!0,h.nodeValue!==u.nodeValue&&(h.nodeValue=u.nodeValue))),f){u=s,h=i;continue t}o?n(o):r(h,t,!0),h=i}if(a&&(d=C[a])&&c(d,u))t.appendChild(d),v(d,u);else{var y=N(u);!1!==y&&(y&&(u=y),u.actualize&&(u=u.actualize(t.ownerDocument||g)),t.appendChild(u),p(u))}u=s,h=i}m(t,h,o);var x=w[t.nodeName];x&&x(t,e)}if(o||(o={}),"string"==typeof a)if("#document"===e.nodeName||"HTML"===e.nodeName){var x=a;a=g.createElement("html"),a.innerHTML=x}else a=s(a);var I=o.getNodeKey||f,N=o.onBeforeNodeAdded||l,S=o.onNodeAdded||l,k=o.onBeforeElUpdated||l,A=o.onElUpdated||l,B=o.onBeforeNodeDiscarded||l,T=o.onNodeDiscarded||l,D=o.onBeforeElChildrenUpdated||l,O=!0===o.childrenOnly,C=Object.create(null),G=[];h(e);var L=e,z=L.nodeType,X=a.nodeType;if(!O)if(z===P)X===P?c(e,a)||(T(e),L=u(e,d(a.nodeName,a.namespaceURI))):L=a;else if(z===b||z===_){if(X===z)return L.nodeValue!==a.nodeValue&&(L.nodeValue=a.nodeValue),L;L=a}if(L===a)T(e);else{if(a.isSameNode&&a.isSameNode(L))return;if(v(L,a,O),G)for(var M=0,Y=G.length;M1)for(var a=1;a=0&&(t._idleTimeoutId=setTimeout(function(){t._onTimeout&&t._onTimeout()},e))},a.setImmediate="function"==typeof e?e:function(t){var e=d++,o=!(arguments.length<2)&&s.call(arguments,1);return c[e]=!0,i(function(){c[e]&&(o?t.apply(null,o):t.call(null),a.clearImmediate(e))}),e},a.clearImmediate="function"==typeof o?o:function(t){delete c[t]}}).call(this,t("timers").setImmediate,t("timers").clearImmediate)},{"process/browser.js":7,timers:8}],9:[function(t,e,a){"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":11}],10:[function(t,e,a){"use strict";function o(t){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){for(var a=0;ago to {caption}\n\t\t\t\t\t\t\x3c!-- END groupItems:loop --\x3e\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t\t\x3c!-- END nav:exist --\x3e\n\t\t\n\t\t\x3c!-- BEGIN appearEffect:exist --\x3e\n\t\t\n\t\t\x3c!-- END appearEffect:exist --\x3e\n\t\n\n',p=t("../lib/util"),m=t("es6-promise-polyfill"),v=m.Promise,g={classNames:{smartPhoto:"smartphoto",smartPhotoClose:"smartphoto-close",smartPhotoBody:"smartphoto-body",smartPhotoInner:"smartphoto-inner",smartPhotoContent:"smartphoto-content",smartPhotoImg:"smartphoto-img",smartPhotoImgOnMove:"smartphoto-img-onmove",smartPhotoImgElasticMove:"smartphoto-img-elasticmove",smartPhotoImgWrap:"smartphoto-img-wrap",smartPhotoArrows:"smartphoto-arrows",smartPhotoNav:"smartphoto-nav",smartPhotoArrowRight:"smartphoto-arrow-right",smartPhotoArrowLeft:"smartphoto-arrow-left",smartPhotoArrowHideIcon:"smartphoto-arrow-hide",smartPhotoImgLeft:"smartphoto-img-left",smartPhotoImgRight:"smartphoto-img-right",smartPhotoList:"smartphoto-list",smartPhotoListOnMove:"smartphoto-list-onmove",smartPhotoHeader:"smartphoto-header",smartPhotoCount:"smartphoto-count",smartPhotoCaption:"smartphoto-caption",smartPhotoDismiss:"smartphoto-dismiss",smartPhotoLoader:"smartphoto-loader",smartPhotoLoaderWrap:"smartphoto-loader-wrap",smartPhotoImgClone:"smartphoto-img-clone"},message:{gotoNextImage:"go to the next image",gotoPrevImage:"go to the previous image",closeDialog:"close the image dialog"},arrows:!0,nav:!0,showAnimation:!0,verticalGravity:!1,useOrientationApi:!1,useHistoryApi:!0,swipeTopToClose:!1,swipeBottomToClose:!0,swipeOffset:100,headerHeight:60,footerHeight:60,forceInterval:10,registance:.5,loadOffset:2,resizeStyle:"fit",lazyAttribute:"data-src"},y=function(t){function e(t,a){var o;n(this,e),o=s(this,d(e).call(this)),o.data=p.extend({},g,a),o.data.currentIndex=0,o.data.oldIndex=0,o.data.hide=!0,o.data.group={},o.data.scaleSize=1,o.data.scale=!1,o.pos={x:0,y:0},o.data.photoPosX=0,o.data.photoPosY=0,o.handlers=[],o.convert={increment:o.increment,virtualPos:o.virtualPos,round:o.round},o.data.groupItems=o.groupItems,o.elements="string"==typeof t?document.querySelectorAll(t):t;var i=new Date;o.tapSecond=i.getTime(),o.onListMove=!1,o.clicked=!1,o.id=o._getUniqId(),o.vx=0,o.vy=0,o.data.appearEffect=null,o.addTemplate(o.id,f),o.data.isSmartPhone=o._isSmartPhone();var r=document.querySelector("body");p.append(r,"
    ")),[].forEach.call(o.elements,function(t){o.addNewItem(t)}),o.update();var c=o._getCurrentItemByHash();if(c&&p.triggerEvent(c.element,"click"), -o.interval=setInterval(function(){o._doAnim()},o.data.forceInterval),!o.data.isSmartPhone){var u=function(){o.groupItems()&&(o._resetTranslate(),o._setPosByCurrentIndex(),o._setSizeByScreen(),o.update())},h=function(t){var e=t.keyCode||t.which;!0!==o.data.hide&&(37===e?o.gotoSlide(o.data.prev):39===e?o.gotoSlide(o.data.next):27===e&&o.hidePhoto())};return window.addEventListener("resize",u),window.addEventListener("keydown",h),o._registerRemoveEvent(window,"resize",u),o._registerRemoveEvent(window,"keydown",h),s(o)}var l=function(){if(o.groupItems()){o._resetTranslate(),o._setPosByCurrentIndex(),o._setHashByCurrentIndex(),o._setSizeByScreen(),o.update();var t=o._getWindowWidth();!function e(a){new v(function(t){setTimeout(function(){t()},25)}).then(function(){t!==o._getWindowWidth()?(o._resetTranslate(),o._setPosByCurrentIndex(),o._setHashByCurrentIndex(),o._setSizeByScreen(),o.update()):a<=500&&e(a+25)})}(0)}};if(window.addEventListener("orientationchange",l),o._registerRemoveEvent(window,"orientationchange",l),!o.data.useOrientationApi)return s(o);var m=function(t){var e=window,a=e.orientation;t&&t.gamma&&!o.data.appearEffect&&(o.isBeingZoomed||o.photoSwipable||o.data.elastic||!o.data.scale||(0===a?o._calcGravity(t.gamma,t.beta):90===a?o._calcGravity(t.beta,t.gamma):-90===a?o._calcGravity(-t.beta,-t.gamma):180===a&&o._calcGravity(-t.gamma,-t.beta)))};return window.addEventListener("deviceorientation",m),o._registerRemoveEvent(window,"deviceorientation",m),o}return u(e,t),r(e,[{key:"on",value:function(t,e){var a=this._getElementByClass(this.data.classNames.smartPhoto),o=function(t){e.call(a,t)};a.addEventListener(t,o),this._registerRemoveEvent(a,t,o)}},{key:"_registerRemoveEvent",value:function(t,e,a){this.handlers.push({target:t,event:e,handler:a})}},{key:"destroy",value:function(){this.handlers.forEach(function(t){t.target.removeEventListener(t.event,t.handler)});var t=document.querySelector('[data-id="'.concat(this.id,'"]'));p.removeElement(t),clearInterval(this.interval),this.removeTemplateEvents()}},{key:"increment",value:function(t){return t+1}},{key:"round",value:function(t){return Math.round(t)}},{key:"virtualPos",value:function(t){return(t=parseInt(t,10))/this._getSelectedItem().scale/this.data.scaleSize}},{key:"groupItems",value:function(){return this.data.group[this.data.currentGroup]}},{key:"_resetTranslate",value:function(){var t=this;this.groupItems().forEach(function(e,a){e.translateX=t._getWindowWidth()*a})}},{key:"addNewItem",value:function(t){var e=this,a=t.getAttribute("data-group")||"nogroup",o=this.data.group;"nogroup"===a&&t.setAttribute("data-group","nogroup"),o[a]||(o[a]=[]);var n=o[a].length,i=document.querySelector("body"),r=t.getAttribute("href"),s=t.querySelector("img"),c=r;s&&(c=s.getAttribute(this.data.lazyAttribute)?s.getAttribute(this.data.lazyAttribute):s.currentSrc?s.currentSrc:s.src);var d={src:r,thumb:c,caption:t.getAttribute("data-caption"),groupId:a,translateX:this._getWindowWidth()*n,index:n,translateY:0,width:50,height:50,id:t.getAttribute("data-id")||n,loaded:!1,processed:!1,element:t};o[a].push(d),this.data.currentGroup=a,t.getAttribute("data-id")||t.setAttribute("data-id",n),t.setAttribute("data-index",n);var u=function(a){a.preventDefault(),e.data.currentGroup=t.getAttribute("data-group"),e.data.currentIndex=parseInt(t.getAttribute("data-index"),10),e._setHashByCurrentIndex();var o=e._getSelectedItem();o.loaded?(e._initPhoto(),e.addAppearEffect(t,o),e.clicked=!0,e.update(),i.style.overflow="hidden",e._fireEvent("open")):e._loadItem(o).then(function(){e._initPhoto(),e.addAppearEffect(t,o),e.clicked=!0,e.update(),i.style.overflow="hidden",e._fireEvent("open")})};t.addEventListener("click",u),this._registerRemoveEvent(t,"click",u)}},{key:"_initPhoto",value:function(){this.data.total=this.groupItems().length,this.data.hide=!1,this.data.photoPosX=0,this.data.photoPosY=0,this._setPosByCurrentIndex(),this._setSizeByScreen(),this.setArrow(),"fill"===this.data.resizeStyle&&this.data.isSmartPhone&&(this.data.scale=!0,this.data.hideUi=!0,this.data.scaleSize=this._getScaleBoarder())}},{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 v(function(e){p.isOldIE()&&e();var a=t.data,o=a.appearEffect,n=a.classNames,i=t._getElementByClass(n.smartPhotoImgClone),r=function t(){i.removeEventListener("transitionend",t,!0),e()};i.addEventListener("transitionend",r,!0),setTimeout(function(){i.style.transform="translate(".concat(o.afterX,"px, ").concat(o.afterY,"px) scale(").concat(o.scale,")")},10)})}},{key:"addAppearEffect",value:function(t,e){if(!1===this.data.showAnimation)return void(this.data.appear=!0);var a=t.querySelector("img"),o=p.getViewPos(a),n={},i=1;n.width=a.offsetWidth,n.height=a.offsetHeight,n.top=o.top,n.left=o.left,n.once=!0,a.getAttribute(this.data.lazyAttribute)?n.img=a.getAttribute(this.data.lazyAttribute):n.img=e.src;var r=this._getWindowWidth(),s=this._getWindowHeight(),c=s-this.data.headerHeight-this.data.footerHeight;"fill"===this.data.resizeStyle&&this.data.isSmartPhone?i=a.offsetWidth>a.offsetHeight?s/a.offsetHeight:r/a.offsetWidth:(n.width>=n.height?i=e.heightn.width&&(i=e.heightr&&(i=r/n.width));var d=(i-1)/2*a.offsetWidth+(r-a.offsetWidth*i)/2,u=(i-1)/2*a.offsetHeight+(s-a.offsetHeight*i)/2;n.afterX=d,n.afterY=u,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 a=void 0!==window.pageXOffset?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft,o=void 0!==window.pageYOffset?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop,n=document.querySelector("body");window.location.hash&&this._setHash(""),window.scroll(a,o),this._doHideEffect(e).then(function(){t.update(),n.style.overflow="",t._fireEvent("close")})}},{key:"_doHideEffect",value:function(t){var e=this;return new v(function(a){p.isOldIE()&&a();var o=e.data.classNames,n=e._getElementByClass(o.smartPhoto),i=e._getElementByQuery(".current .".concat(o.smartPhotoImg)),r=e._getWindowHeight(),s=function t(){n.removeEventListener("transitionend",t,!0),a()};n.style.opacity=0,"bottom"===t?i.style.transform="translateY(".concat(r,"px)"):"top"===t&&(i.style.transform="translateY(-".concat(r,"px)")),n.addEventListener("transitionend",s,!0)})}},{key:"_getElementByClass",value:function(t){return document.querySelector('[data-id="'.concat(this.id,'"] .').concat(t))}},{key:"_getElementByQuery",value:function(t){return document.querySelector('[data-id="'.concat(this.id,'"] ').concat(t))}},{key:"_getTouchPos",value:function(){var t=0,e=0,a="undefined"==typeof event?this.e:event;return this._isTouched(a)?(t=a.touches[0].pageX,e=a.touches[0].pageY):a.pageX&&(t=a.pageX,e=a.pageY),{x:t,y:e}}},{key:"_getGesturePos",value:function(t){var e=t.touches;return[{x:e[0].pageX,y:e[0].pageY},{x:e[1].pageX,y:e[1].pageY}]}},{key:"_setPosByCurrentIndex",value:function(){var t=this,e=this.groupItems(),a=-1*e[this.data.currentIndex].translateX;this.pos.x=a,setTimeout(function(){t.data.translateX=a,t.data.translateY=0,t._listUpdate()},1)}},{key:"_setHashByCurrentIndex",value:function(){var t=void 0!==window.pageXOffset?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft,e=void 0!==window.pageYOffset?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop,a=this.groupItems(),o=a[this.data.currentIndex].id,n=this.data.currentGroup,i="group=".concat(n,"&photo=").concat(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,"".concat(location.pathname).concat(location.search,"#").concat(t)):window.history.replaceState(null,null,"".concat(location.pathname).concat(location.search)))}},{key:"_getCurrentItemByHash",value:function(){var t=this.data.group,e=location.hash.substr(1),a=p.parseQuery(e),o=null,n=function(t){a.group===t.groupId&&a.photo===t.id&&(o=t)};return Object.keys(t).forEach(function(e){t[e].forEach(n)}),o}},{key:"_loadItem",value:function(t){return new v(function(e){var a=new Image;a.onload=function(){t.width=a.width,t.height=a.height,t.loaded=!0,e()},a.onerror=function(){e()},a.src=t.src})}},{key:"_getItemByIndex",value:function(t){var e=this.data;return e.group[e.currentGroup][t]?e.group[e.currentGroup][t]:null}},{key:"_loadNeighborItems",value:function(){for(var t=this,e=this.data.currentIndex,a=this.data.loadOffset,o=e-a,n=e+a,i=[],r=o;rt&&(a.scale=t/a.width,a.x=(a.scale-1)/2*a.width))})}},{key:"_slideList",value:function(){var t=this;this.data.scaleSize=1,this.isBeingZoomed=!1,this.data.hideUi=!1,this.data.scale=!1,this.data.photoPosX=0,this.data.photoPosY=0,this.data.onMoveClass=!0,this._setPosByCurrentIndex(),this._setHashByCurrentIndex(),this._setSizeByScreen(),setTimeout(function(){var e=t._getSelectedItem();t.data.onMoveClass=!1,t.setArrow(),t.update(),t.data.oldIndex!==t.data.currentIndex&&t._fireEvent("change"),t.data.oldIndex=t.data.currentIndex,t._loadNeighborItems(),e.loaded||t._loadItem(e).then(function(){t._initPhoto(),t.update()})},200)}},{key:"gotoSlide",value:function(t){this.e&&this.e.preventDefault&&this.e.preventDefault(),this.data.currentIndex=parseInt(t,10),this.data.currentIndex||(this.data.currentIndex=0),this._slideList()}},{key:"setArrow",value:function(){var t=this.groupItems(),e=t.length,a=this.data.currentIndex+1,o=this.data.currentIndex-1;this.data.showNextArrow=!1,this.data.showPrevArrow=!1,a!==e&&(this.data.next=a,this.data.showNextArrow=!0),-1!==o&&(this.data.prev=o,this.data.showPrevArrow=!0)}},{key:"beforeDrag",value:function(){if(this._isGestured(this.e))return void this.beforeGesture();if(this.isBeingZoomed=!1,this.data.scale)return void this.beforePhotoDrag();var t=this._getTouchPos();this.isSwipable=!0,this.dragStart=!0,this.firstPos=t,this.oldPos=t}},{key:"afterDrag",value:function(){var t=this.groupItems(),e=new Date,a=e.getTime(),o=this.tapSecond-a,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():p.isSmartPhone()||0!==n||0!==i?Math.abs(o)<=500&&0===n&&0===i?(this.e.preventDefault(),void this.zoomPhoto()):(this.tapSecond=a,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,a=t.y-this.firstPos.y;this.dragStart&&(this._fireEvent("swipestart"),this.dragStart=!1,Math.abs(e)>Math.abs(a)?this.moveDir="horizontal":this.moveDir="vertical"),"horizontal"===this.moveDir?(this.pos.x+=e,this.data.translateX=this.pos.x):this.data.translateY=a,this.onListMove=!0,this.oldPos=t,this._listUpdate()}}}},{key:"zoomPhoto",value:function(){var t=this;this.data.hideUi=!0,this.data.scaleSize=this._getScaleBoarder(),this.data.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,a=t.y-this.oldPhotoPos.y,o=this._round(this.data.scaleSize*e,6),n=this._round(this.data.scaleSize*a,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),a=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.photoPosYa&&0!==this.data.currentIndex)return void this.gotoSlide(this.data.prev);if(e.minX-this.data.photoPosX>a&&this.data.currentIndex+1!==this.data.total)return void this.gotoSlide(this.data.next);0===o&&0===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]),a=(e-this.oldDistance)/100,o=this.data.scaleSize,n=this.data.photoPosX,i=this.data.photoPosY;this.isBeingZoomed=!0,this.data.scaleSize+=this._round(a,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(),a=this._getWindowHeight();return p.isSmartPhone()?t.width>t.height?a/(t.height*t.scale):e/(t.width*t.scale):1/t.scale}},{key:"_makeBound",value:function(t){var e,a,o,n,i=t.width*t.scale*this.data.scaleSize,r=t.height*t.scale*this.data.scaleSize,s=this._getWindowWidth(),c=this._getWindowHeight();return s>i?(o=(s-i)/2,e=-1*o):(o=(i-s)/2,e=-1*o),c>r?(n=(c-r)/2,a=-1*n):(n=(r-c)/2,a=-1*n),{minX:this._round(e,6)*this.data.scaleSize,minY:this._round(a,6)*this.data.scaleSize,maxX:this._round(o,6)*this.data.scaleSize,maxY:this._round(n,6)*this.data.scaleSize}}},{key:"_registerElasticForce",value:function(t,e){var a=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(){a.data.elastic=!1,a._photoUpdate()},300)}},{key:"_getSelectedItem",value:function(){var t=this.data,e=t.currentIndex;return t.group[t.currentGroup][e]}},{key:"_getUniqId",value:function(){return(Date.now().toString(36)+Math.random().toString(36).substr(2,5)).toUpperCase()}},{key:"_getDistance",value:function(t,e){var a=t.x-e.x,o=t.y-e.y;return Math.sqrt(a*a+o*o)}},{key:"_round",value:function(t,e){var a=Math.pow(10,e);return t*=a,t=Math.round(t),t/=a}},{key:"_isTouched",value:function(t){return!(!t||!t.touches)}},{key:"_isGestured",value:function(t){return!!(t&&t.touches&&t.touches.length>1)}},{key:"_isSmartPhone",value:function(){var t=navigator.userAgent;return t.indexOf("iPhone")>0||t.indexOf("iPad")>0||t.indexOf("ipod")>0||t.indexOf("Android")>0}},{key:"_calcGravity",value:function(t,e){(t>5||t<-5)&&(this.vx+=.05*t),!1!==this.data.verticalGravity&&(e>5||e<-5)&&(this.vy+=.05*e)}},{key:"_photoUpdate",value:function(){var t=this.data.classNames,e=this._getElementByQuery(".current"),a=e.querySelector(".".concat(t.smartPhotoImg)),o=this._getElementByQuery(".".concat(t.smartPhotoNav)),n=this._getElementByQuery(".".concat(t.smartPhotoArrows)),i=this.virtualPos(this.data.photoPosX),r=this.virtualPos(this.data.photoPosY),s=this.data.scaleSize,c="translate(".concat(i,"px,").concat(r,"px) scale(").concat(s,")");a.style.transform=c,this.data.scale?p.addClass(a,t.smartPhotoImgOnMove):p.removeClass(a,t.smartPhotoImgOnMove),this.data.elastic?p.addClass(a,t.smartPhotoImgElasticMove):p.removeClass(a,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(".".concat(t.smartPhotoList)),a="translate(".concat(this.data.translateX,"px,").concat(this.data.translateY,"px)");e.style.transform=a,this.data.onMoveClass?p.addClass(e,t.smartPhotoListOnMove):p.removeClass(e,t.smartPhotoListOnMove)}},{key:"_fireEvent",value:function(t){var e=this._getElementByClass(this.data.classNames.smartPhoto);p.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 a=this._getForceAndTheta(this.vx,this.vy),o=a.force,n=a.theta;o-=this.data.registance,Math.abs(o)<.5||(this.vx=Math.cos(n)*o,this.vy=Math.sin(n)*o,this._photoUpdate())}}}]),e}(l.default);a.default=y,e.exports=a.default},{"../lib/util":12,"a-template":1,"custom-event-polyfill":3,"es6-promise-polyfill":4}],11:[function(t,e,a){"use strict";e.exports=t("./core/")},{"./core/":10}],12:[function(t,e,a){"use strict";function o(t){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function n(t){t=t||{};for(var e=1;e0||t.indexOf("iPad")>0||t.indexOf("ipod")>0||t.indexOf("Android")>0};a.isSmartPhone=i;var r=n;a.extend=r;var s=function(t,e,a){var o;window.CustomEvent?o=new CustomEvent(e,{cancelable:!0}):(o=document.createEvent("CustomEvent"),o.initCustomEvent(e,!1,!1,a)),t.dispatchEvent(o)};a.triggerEvent=s;var c=function(t){for(var e,a,o,n=t.split("&"),i={},r=0,s=n.length;r0;)t.appendChild(a.children[0])};a.append=h;var l=function(t,e){t.classList?t.classList.add(e):t.className+=" ".concat(e)};a.addClass=l;var f=function(t,e){t.classList?t.classList.remove(e):t.className=t.className.replace(new RegExp("(^|\\b)"+e.split(" ").join("|")+"(\\b|$)","gi")," ")};a.removeClass=f;var p=function(){var t=window.navigator.userAgent.toLowerCase(),e=window.navigator.appVersion.toLowerCase(),a="unknown";return-1!=t.indexOf("msie")?a=-1!=e.indexOf("msie 6.")?"ie6":-1!=e.indexOf("msie 7.")?"ie7":-1!=e.indexOf("msie 8.")?"ie8":-1!=e.indexOf("msie 9.")?"ie9":-1!=e.indexOf("msie 10.")?"ie10":"ie":-1!=t.indexOf("trident/7")?a="ie11":-1!=t.indexOf("chrome")?a="chrome":-1!=t.indexOf("safari")?a="safari":-1!=t.indexOf("opera")?a="opera":-1!=t.indexOf("firefox")&&(a="firefox"),a};a.getBrowser=p;var m=function(){var t=p();return-1!==t.indexOf("ie")&&parseInt(t.replace(/[^0-9]/g,""))<=10};a.isOldIE=m},{}]},{},[9]); \ No newline at end of file +!function(){function t(e,a,o){function n(r,s){if(!a[r]){if(!e[r]){var c="function"==typeof require&&require;if(!s&&c)return c(r,!0);if(i)return i(r,!0);var d=new Error("Cannot find module '"+r+"'");throw d.code="MODULE_NOT_FOUND",d}var u=a[r]={exports:{}};e[r][0].call(u.exports,function(t){return n(e[r][1][t]||t)},u,u.exports,t,e,a,o)}return a[r].exports}for(var i="function"==typeof require&&require,r=0;r1;)a=a[o.shift()];a[o.shift()]=e}},{key:"removeDataByString",value:function(t){for(var e=this.data,a=t.split(".");a.length>1;)e=e[a.shift()];var o=a.shift();o.match(/^\d+$/)?e.splice(Number(o),1):delete e[o]}},{key:"resolveBlock",value:function(t,e,a){var o=this,n=t.match(//g),i=t.match(//g),r=t.match(//g),s=t.match(//g);if(n)for(var c=0,d=n.length;c/g;return t=t.replace(e,function(t,e){return(0,c.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,a=this;return t=t.replace(e,function(t,e,o){var n=a.getDataByString(e),i=[];i="function"==typeof n?n.apply(a):n;var r="";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 a=this.atemplate.find(function(e){return e.id===t}),o="";if(a&&a.html&&(o=a.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",a=arguments[1],o=this.templates;this.beforeUpdated&&this.beforeUpdated();for(var n=0,i=o.length;n"+u+"");else(0,c.selector)(d).insertAdjacentHTML("afterend",'
    '),"text"===e?(0,c.selector)("[data-id='"+r+"']").innerText=u:(0,c.selector)("[data-id='"+r+"']").innerHTML=u;var p=t.atemplate.find(function(t){return t.id===r});p.binded||(p.binded=!0,t.addDataBind((0,c.selector)("[data-id='"+r+"']")),t.addActionBind((0,c.selector)("[data-id='"+r+"']")))}(n);return this.updateBindingData(a),this.onUpdated&&this.onUpdated(a),this}},{key:"updateBindingData",value:function(t){for(var e=this,a=this.templates,o=0,n=a.length;o1?a-1:0),n=1;n1;)e=e[a.shift()];var o=a.shift();return o.match(/^\d+$/)?e.splice(Number(o),1):delete e[o],this}}]),t}();a.default=h,e.exports=a.default},{"./util":2,"ie-array-find-polyfill":5,morphdom:6}],2:[function(t,e,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var o=a.matches=function(t,e){for(var a=(t.document||t.ownerDocument).querySelectorAll(e),o=a.length;--o>=0&&a.item(o)!==t;);return o>-1},n=(a.selector=function(t){return document.querySelector(t)},a.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}),i=[];a.on=function(t,e,a,o){var r=arguments.length>4&&void 0!==arguments[4]&&arguments[4];a.split(" ").forEach(function(a){var s=function(t){var a=n(t.target,e);a&&(t.delegateTarget=a,o(t))};i.push({listener:s,element:t,query:e,event:a,capture:r}),t.addEventListener(a,s,r)})},a.off=function(t,e,a){a.split(" ").forEach(function(a){i.forEach(function(o,n){o.element===t&&o.query===e&&o.event===a&&(t.removeEventListener(a,o.listener,o.capture),i.splice(n,1))})})}},{}],3:[function(t,e,a){try{var o=new window.CustomEvent("test");if(o.preventDefault(),!0!==o.defaultPrevented)throw new Error("Could not prevent default")}catch(t){var n=function(t,e){var a,o;return e=e||{bubbles:!1,cancelable:!1,detail:void 0},a=document.createEvent("CustomEvent"),a.initCustomEvent(t,e.bubbles,e.cancelable,e.detail),o=a.preventDefault,a.preventDefault=function(){o.call(this);try{Object.defineProperty(this,"defaultPrevented",{get:function(){return!0}})}catch(t){this.defaultPrevented=!0}},a};n.prototype=window.Event.prototype,window.CustomEvent=n}},{}],4:[function(t,e,a){(function(t,e){!function(t){function o(t){return"[object Array]"===Object.prototype.toString.call(t)}function n(){for(var t=0;t>>0;if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var o=arguments[1],n=0;n=0;s--)a=r[s],o=a.name,n=a.namespaceURI,i=a.value,n?(o=a.localName||o,t.getAttributeNS(n,o)!==i&&("xmlns"===a.prefix&&(o=a.name),t.setAttributeNS(n,o,i))):t.getAttribute(o)!==i&&t.setAttribute(o,i);for(var c=t.attributes,d=c.length-1;d>=0;d--)a=c[d],o=a.name,n=a.namespaceURI,n?(o=a.localName||o,e.hasAttributeNS(n,o)||t.removeAttributeNS(n,o)):e.hasAttribute(o)||t.removeAttribute(o)}}function n(t){var e=g.createElement("template");return e.innerHTML=t,e.content.childNodes[0]}function i(t){return p||(p=g.createRange(),p.selectNode(g.body)),p.createContextualFragment(t).childNodes[0]}function r(t){var e=g.createElement("body");return e.innerHTML=t,e.childNodes[0]}function s(t){return t=t.trim(),y?n(t):x?i(t):r(t)}function c(t,e){var a=t.nodeName,o=e.nodeName;return a===o||!!(e.actualize&&a.charCodeAt(0)<91&&o.charCodeAt(0)>90)&&a===o.toUpperCase()}function d(t,e){return e&&e!==v?g.createElementNS(e,t):g.createElement(t)}function u(t,e){for(var a=t.firstChild;a;){var o=a.nextSibling;e.appendChild(a),a=o}return e}function l(t,e,a){t[a]!==e[a]&&(t[a]=e[a],t[a]?t.setAttribute(a,""):t.removeAttribute(a))}function h(){}function f(t){if(t)return t.getAttribute&&t.getAttribute("id")||t.id}var p,m=11,v="http://www.w3.org/1999/xhtml",g="undefined"==typeof document?void 0:document,y=!!g&&"content"in g.createElement("template"),x=!!g&&g.createRange&&"createContextualFragment"in g.createRange(),w={OPTION:function(t,e){var a=t.parentNode;if(a){var o=a.nodeName.toUpperCase();"OPTGROUP"===o&&(a=a.parentNode,o=a&&a.nodeName.toUpperCase()),"SELECT"!==o||a.hasAttribute("multiple")||(t.hasAttribute("selected")&&!e.selected&&(t.setAttribute("selected","selected"),t.removeAttribute("selected")),a.selectedIndex=-1)}l(t,e,"selected")},INPUT:function(t,e){l(t,e,"checked"),l(t,e,"disabled"),t.value!==e.value&&(t.value=e.value),e.hasAttribute("value")||t.removeAttribute("value")},TEXTAREA:function(t,e){var a=e.value;t.value!==a&&(t.value=a);var o=t.firstChild;if(o){var n=o.nodeValue;if(n==a||!a&&n==t.placeholder)return;o.nodeValue=a}},SELECT:function(t,e){if(!e.hasAttribute("multiple")){for(var a,o,n=-1,i=0,r=t.firstChild;r;)if("OPTGROUP"===(o=r.nodeName&&r.nodeName.toUpperCase()))a=r,r=a.firstChild;else{if("OPTION"===o){if(r.hasAttribute("selected")){n=i;break}i++}r=r.nextSibling,!r&&a&&(r=a.nextSibling,a=null)}t.selectedIndex=n}}},P=1,E=11,b=3,_=8,I=function(t){return function(e,a,o){function n(t){G.push(t)}function i(t,e){if(t.nodeType===P)for(var a=t.firstChild;a;){var o=void 0;e&&(o=I(a))?n(o):(T(a),a.firstChild&&i(a,e)),a=a.nextSibling}}function r(t,e,a){!1!==B(t)&&(e&&e.removeChild(t),T(t),i(t,a))}function l(t){if(t.nodeType===P||t.nodeType===E)for(var e=t.firstChild;e;){var a=I(e);a&&(C[a]=e),l(e),e=e.nextSibling}}function p(t){S(t);for(var e=t.firstChild;e;){var a=e.nextSibling,o=I(e);if(o){var n=C[o];n&&c(e,n)&&(e.parentNode.replaceChild(n,e),v(n,e))}p(e),e=a}}function m(t,e,a){for(;e;){var o=e.nextSibling;(a=I(e))?n(a):r(e,t,!0),e=o}}function v(e,a,o){var n=I(a);if(n&&delete C[n],!o){if(!1===k(e,a))return;if(t(e,a),A(e),!1===D(e,a))return}"TEXTAREA"!==e.nodeName?y(e,a):w.TEXTAREA(e,a)}function y(t,e){var a,o,i,s,d,u=e.firstChild,l=t.firstChild;t:for(;u;){for(s=u.nextSibling,a=I(u);l;){if(i=l.nextSibling,u.isSameNode&&u.isSameNode(l)){u=s,l=i;continue t}o=I(l);var h=l.nodeType,f=void 0;if(h===u.nodeType&&(h===P?(a?a!==o&&((d=C[a])?i===d?f=!1:(t.insertBefore(d,l),o?n(o):r(l,t,!0),l=d):f=!1):o&&(f=!1),(f=!1!==f&&c(l,u))&&v(l,u)):h!==b&&h!=_||(f=!0,l.nodeValue!==u.nodeValue&&(l.nodeValue=u.nodeValue))),f){u=s,l=i;continue t}o?n(o):r(l,t,!0),l=i}if(a&&(d=C[a])&&c(d,u))t.appendChild(d),v(d,u);else{var y=N(u);!1!==y&&(y&&(u=y),u.actualize&&(u=u.actualize(t.ownerDocument||g)),t.appendChild(u),p(u))}u=s,l=i}m(t,l,o);var x=w[t.nodeName];x&&x(t,e)}if(o||(o={}),"string"==typeof a)if("#document"===e.nodeName||"HTML"===e.nodeName){var x=a;a=g.createElement("html"),a.innerHTML=x}else a=s(a);var I=o.getNodeKey||f,N=o.onBeforeNodeAdded||h,S=o.onNodeAdded||h,k=o.onBeforeElUpdated||h,A=o.onElUpdated||h,B=o.onBeforeNodeDiscarded||h,T=o.onNodeDiscarded||h,D=o.onBeforeElChildrenUpdated||h,O=!0===o.childrenOnly,C=Object.create(null),G=[];l(e);var L=e,z=L.nodeType,X=a.nodeType;if(!O)if(z===P)X===P?c(e,a)||(T(e),L=u(e,d(a.nodeName,a.namespaceURI))):L=a;else if(z===b||z===_){if(X===z)return L.nodeValue!==a.nodeValue&&(L.nodeValue=a.nodeValue),L;L=a}if(L===a)T(e);else{if(a.isSameNode&&a.isSameNode(L))return;if(v(L,a,O),G)for(var M=0,Y=G.length;M1)for(var a=1;a=0&&(t._idleTimeoutId=setTimeout(function(){t._onTimeout&&t._onTimeout()},e))},a.setImmediate="function"==typeof e?e:function(t){var e=d++,o=!(arguments.length<2)&&s.call(arguments,1);return c[e]=!0,i(function(){c[e]&&(o?t.apply(null,o):t.call(null),a.clearImmediate(e))}),e},a.clearImmediate="function"==typeof o?o:function(t){delete c[t]}}).call(this,t("timers").setImmediate,t("timers").clearImmediate)},{"process/browser.js":7,timers:8}],9:[function(t,e,a){"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":11}],10:[function(t,e,a){"use strict";function o(t){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){for(var a=0;ago to {caption}\n\t\t\t\t\t\x3c!-- END groupItems:loop --\x3e\n\t\t\t\t\n\t\t\t\n\t\t\t\x3c!-- END nav:exist --\x3e\n\n\t\t\t\n\t\t\t\t\\{message.closeDialog\\}\n\t\t\t\n\t\t\n\t\t\x3c!-- BEGIN appearEffect:exist --\x3e\n\t\t\n\t\t\x3c!-- END appearEffect:exist --\x3e\n\t\n\n',p=t("../lib/util"),m=t("es6-promise-polyfill"),v=m.Promise,g={classNames:{smartPhoto:"smartphoto",smartPhotoClose:"smartphoto-close",smartPhotoBody:"smartphoto-body",smartPhotoInner:"smartphoto-inner",smartPhotoContent:"smartphoto-content",smartPhotoImg:"smartphoto-img",smartPhotoImgOnMove:"smartphoto-img-onmove",smartPhotoImgElasticMove:"smartphoto-img-elasticmove",smartPhotoImgWrap:"smartphoto-img-wrap",smartPhotoArrows:"smartphoto-arrows",smartPhotoNav:"smartphoto-nav",smartPhotoArrowRight:"smartphoto-arrow-right",smartPhotoArrowLeft:"smartphoto-arrow-left",smartPhotoArrowHideIcon:"smartphoto-arrow-hide",smartPhotoImgLeft:"smartphoto-img-left",smartPhotoImgRight:"smartphoto-img-right",smartPhotoList:"smartphoto-list",smartPhotoListOnMove:"smartphoto-list-onmove",smartPhotoHeader:"smartphoto-header",smartPhotoCount:"smartphoto-count",smartPhotoCaption:"smartphoto-caption",smartPhotoDismiss:"smartphoto-dismiss",smartPhotoLoader:"smartphoto-loader",smartPhotoLoaderWrap:"smartphoto-loader-wrap",smartPhotoImgClone:"smartphoto-img-clone"},message:{gotoNextImage:"go to the next image",gotoPrevImage:"go to the previous image",closeDialog:"close the image dialog"},arrows:!0,nav:!0,showAnimation:!0,verticalGravity:!1,useOrientationApi:!1,useHistoryApi:!0,swipeTopToClose:!1,swipeBottomToClose:!0,swipeOffset:100,headerHeight:60,footerHeight:60,forceInterval:10,registance:.5,loadOffset:2,resizeStyle:"fit",lazyAttribute:"data-src"},y=function(t){function e(t,a){var o;n(this,e),o=s(this,d(e).call(this)),o.data=p.extend({},g,a),o.data.currentIndex=0,o.data.oldIndex=0,o.data.hide=!0,o.data.group={},o.data.scaleSize=1,o.data.scale=!1,o.pos={x:0,y:0},o.data.photoPosX=0,o.data.photoPosY=0,o.handlers=[],o.convert={increment:o.increment,virtualPos:o.virtualPos,round:o.round},o.data.groupItems=o.groupItems,o.elements="string"==typeof t?document.querySelectorAll(t):t;var i=new Date;o.tapSecond=i.getTime(),o.onListMove=!1,o.clicked=!1,o.id=o._getUniqId(),o.vx=0,o.vy=0,o.data.appearEffect=null,o.addTemplate(o.id,f),o.data.isSmartPhone=o._isSmartPhone();var r=document.querySelector("body");p.append(r,"
    ")),[].forEach.call(o.elements,function(t){o.addNewItem(t)}),o.update() +;var c=o._getCurrentItemByHash();if(c&&p.triggerEvent(c.element,"click"),o.interval=setInterval(function(){o._doAnim()},o.data.forceInterval),!o.data.isSmartPhone){var u=function(){o.groupItems()&&(o._resetTranslate(),o._setPosByCurrentIndex(),o._setSizeByScreen(),o.update())},l=function(t){var e=t.keyCode||t.which;!0!==o.data.hide&&(37===e?o.gotoSlide(o.data.prev):39===e?o.gotoSlide(o.data.next):27===e&&o.hidePhoto())};return window.addEventListener("resize",u),window.addEventListener("keydown",l),o._registerRemoveEvent(window,"resize",u),o._registerRemoveEvent(window,"keydown",l),s(o)}var h=function(){if(o.groupItems()){o._resetTranslate(),o._setPosByCurrentIndex(),o._setHashByCurrentIndex(),o._setSizeByScreen(),o.update();var t=o._getWindowWidth();!function e(a){new v(function(t){setTimeout(function(){t()},25)}).then(function(){t!==o._getWindowWidth()?(o._resetTranslate(),o._setPosByCurrentIndex(),o._setHashByCurrentIndex(),o._setSizeByScreen(),o.update()):a<=500&&e(a+25)})}(0)}};if(window.addEventListener("orientationchange",h),o._registerRemoveEvent(window,"orientationchange",h),!o.data.useOrientationApi)return s(o);var m=function(t){var e=window,a=e.orientation;t&&t.gamma&&!o.data.appearEffect&&(o.isBeingZoomed||o.photoSwipable||o.data.elastic||!o.data.scale||(0===a?o._calcGravity(t.gamma,t.beta):90===a?o._calcGravity(t.beta,t.gamma):-90===a?o._calcGravity(-t.beta,-t.gamma):180===a&&o._calcGravity(-t.gamma,-t.beta)))};return window.addEventListener("deviceorientation",m),o._registerRemoveEvent(window,"deviceorientation",m),o}return u(e,t),r(e,[{key:"on",value:function(t,e){var a=this._getElementByClass(this.data.classNames.smartPhoto),o=function(t){e.call(a,t)};a.addEventListener(t,o),this._registerRemoveEvent(a,t,o)}},{key:"_registerRemoveEvent",value:function(t,e,a){this.handlers.push({target:t,event:e,handler:a})}},{key:"destroy",value:function(){this.handlers.forEach(function(t){t.target.removeEventListener(t.event,t.handler)});var t=document.querySelector('[data-id="'.concat(this.id,'"]'));p.removeElement(t),clearInterval(this.interval),this.removeTemplateEvents()}},{key:"increment",value:function(t){return t+1}},{key:"round",value:function(t){return Math.round(t)}},{key:"virtualPos",value:function(t){return(t=parseInt(t,10))/this._getSelectedItem().scale/this.data.scaleSize}},{key:"groupItems",value:function(){return this.data.group[this.data.currentGroup]}},{key:"_resetTranslate",value:function(){var t=this;this.groupItems().forEach(function(e,a){e.translateX=t._getWindowWidth()*a})}},{key:"addNewItem",value:function(t){var e=this,a=t.getAttribute("data-group")||"nogroup",o=this.data.group;"nogroup"===a&&t.setAttribute("data-group","nogroup"),o[a]||(o[a]=[]);var n=o[a].length,i=document.querySelector("body"),r=t.getAttribute("href"),s=t.querySelector("img"),c=r;s&&(c=s.getAttribute(this.data.lazyAttribute)?s.getAttribute(this.data.lazyAttribute):s.currentSrc?s.currentSrc:s.src);var d={src:r,thumb:c,caption:t.getAttribute("data-caption"),groupId:a,translateX:this._getWindowWidth()*n,index:n,translateY:0,width:50,height:50,id:t.getAttribute("data-id")||n,loaded:!1,processed:!1,element:t};o[a].push(d),this.data.currentGroup=a,t.getAttribute("data-id")||t.setAttribute("data-id",n),t.setAttribute("data-index",n);var u=function(a){a.preventDefault(),e.data.currentGroup=t.getAttribute("data-group"),e.data.currentIndex=parseInt(t.getAttribute("data-index"),10),e._setHashByCurrentIndex();var o=e._getSelectedItem(),n=function(t){if(9===t.keyCode){var a=document.querySelector(".".concat(e.data.classNames.smartPhoto)),o=document.querySelector(".".concat(e.data.classNames.smartPhotoArrows)),n=document.querySelector(".".concat(e.data.classNames.smartPhotoDismiss)),i=document.activeElement;i===a?o.focus():i===n&&a.focus()}};if(o.loaded){e._initPhoto(),e.addAppearEffect(t,o),e.clicked=!0,e.update(),i.style.overflow="hidden",e._fireEvent("open");document.querySelector(".".concat(e.data.classNames.smartPhoto)).focus(),document.addEventListener("keydown",n),e._registerRemoveEvent(window,"keydown",n)}else e._loadItem(o).then(function(){e._initPhoto(),e.addAppearEffect(t,o),e.clicked=!0,e.update(),i.style.overflow="hidden",e._fireEvent("open"),document.querySelector(".".concat(e.data.classNames.smartPhoto)).focus(),document.addEventListener("keydown",n),e._registerRemoveEvent(window,"keydown",n)})};t.addEventListener("click",u),this._registerRemoveEvent(t,"click",u)}},{key:"_initPhoto",value:function(){this.data.total=this.groupItems().length,this.data.hide=!1,this.data.photoPosX=0,this.data.photoPosY=0,this._setPosByCurrentIndex(),this._setSizeByScreen(),this.setArrow(),"fill"===this.data.resizeStyle&&this.data.isSmartPhone&&(this.data.scale=!0,this.data.hideUi=!0,this.data.scaleSize=this._getScaleBoarder())}},{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 v(function(e){p.isOldIE()&&e();var a=t.data,o=a.appearEffect,n=a.classNames,i=t._getElementByClass(n.smartPhotoImgClone),r=function t(){i.removeEventListener("transitionend",t,!0),e()};i.addEventListener("transitionend",r,!0),setTimeout(function(){i.style.transform="translate(".concat(o.afterX,"px, ").concat(o.afterY,"px) scale(").concat(o.scale,")")},10)})}},{key:"addAppearEffect",value:function(t,e){if(!1===this.data.showAnimation)return void(this.data.appear=!0);var a=t.querySelector("img"),o=p.getViewPos(a),n={},i=1;n.width=a.offsetWidth,n.height=a.offsetHeight,n.top=o.top,n.left=o.left,n.once=!0,a.getAttribute(this.data.lazyAttribute)?n.img=a.getAttribute(this.data.lazyAttribute):n.img=e.src;var r=this._getWindowWidth(),s=this._getWindowHeight(),c=s-this.data.headerHeight-this.data.footerHeight;"fill"===this.data.resizeStyle&&this.data.isSmartPhone?i=a.offsetWidth>a.offsetHeight?s/a.offsetHeight:r/a.offsetWidth:(n.width>=n.height?i=e.heightn.width&&(i=e.heightr&&(i=r/n.width));var d=(i-1)/2*a.offsetWidth+(r-a.offsetWidth*i)/2,u=(i-1)/2*a.offsetHeight+(s-a.offsetHeight*i)/2;n.afterX=d,n.afterY=u,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 a=void 0!==window.pageXOffset?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft,o=void 0!==window.pageYOffset?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop,n=document.querySelector("body");window.location.hash&&this._setHash(""),window.scroll(a,o),this._doHideEffect(e).then(function(){t.update(),n.style.overflow="",t._fireEvent("close")})}},{key:"_doHideEffect",value:function(t){var e=this;return new v(function(a){p.isOldIE()&&a();var o=e.data.classNames,n=e._getElementByClass(o.smartPhoto),i=e._getElementByQuery(".current .".concat(o.smartPhotoImg)),r=e._getWindowHeight(),s=function t(){n.removeEventListener("transitionend",t,!0),a()};n.style.opacity=0,"bottom"===t?i.style.transform="translateY(".concat(r,"px)"):"top"===t&&(i.style.transform="translateY(-".concat(r,"px)")),n.addEventListener("transitionend",s,!0)})}},{key:"_getElementByClass",value:function(t){return document.querySelector('[data-id="'.concat(this.id,'"] .').concat(t))}},{key:"_getElementByQuery",value:function(t){return document.querySelector('[data-id="'.concat(this.id,'"] ').concat(t))}},{key:"_getTouchPos",value:function(){var t=0,e=0,a="undefined"==typeof event?this.e:event;return this._isTouched(a)?(t=a.touches[0].pageX,e=a.touches[0].pageY):a.pageX&&(t=a.pageX,e=a.pageY),{x:t,y:e}}},{key:"_getGesturePos",value:function(t){var e=t.touches;return[{x:e[0].pageX,y:e[0].pageY},{x:e[1].pageX,y:e[1].pageY}]}},{key:"_setPosByCurrentIndex",value:function(){var t=this,e=this.groupItems(),a=-1*e[this.data.currentIndex].translateX;this.pos.x=a,setTimeout(function(){t.data.translateX=a,t.data.translateY=0,t._listUpdate()},1)}},{key:"_setHashByCurrentIndex",value:function(){var t=void 0!==window.pageXOffset?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft,e=void 0!==window.pageYOffset?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop,a=this.groupItems(),o=a[this.data.currentIndex].id,n=this.data.currentGroup,i="group=".concat(n,"&photo=").concat(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,"".concat(location.pathname).concat(location.search,"#").concat(t)):window.history.replaceState(null,null,"".concat(location.pathname).concat(location.search)))}},{key:"_getCurrentItemByHash",value:function(){var t=this.data.group,e=location.hash.substr(1),a=p.parseQuery(e),o=null,n=function(t){a.group===t.groupId&&a.photo===t.id&&(o=t)};return Object.keys(t).forEach(function(e){t[e].forEach(n)}),o}},{key:"_loadItem",value:function(t){return new v(function(e){var a=new Image;a.onload=function(){t.width=a.width,t.height=a.height,t.loaded=!0,e()},a.onerror=function(){e()},a.src=t.src})}},{key:"_getItemByIndex",value:function(t){var e=this.data;return e.group[e.currentGroup][t]?e.group[e.currentGroup][t]:null}},{key:"_loadNeighborItems",value:function(){for(var t=this,e=this.data.currentIndex,a=this.data.loadOffset,o=e-a,n=e+a,i=[],r=o;rt&&(a.scale=t/a.width,a.x=(a.scale-1)/2*a.width))})}},{key:"_slideList",value:function(){var t=this;this.data.scaleSize=1,this.isBeingZoomed=!1,this.data.hideUi=!1,this.data.scale=!1,this.data.photoPosX=0,this.data.photoPosY=0,this.data.onMoveClass=!0,this._setPosByCurrentIndex(),this._setHashByCurrentIndex(),this._setSizeByScreen(),setTimeout(function(){var e=t._getSelectedItem();t.data.onMoveClass=!1,t.setArrow(),t.update(),t.data.oldIndex!==t.data.currentIndex&&t._fireEvent("change"),t.data.oldIndex=t.data.currentIndex,t._loadNeighborItems(),e.loaded||t._loadItem(e).then(function(){t._initPhoto(),t.update()})},200)}},{key:"gotoSlide",value:function(t){this.e&&this.e.preventDefault&&this.e.preventDefault(),this.data.currentIndex=parseInt(t,10),this.data.currentIndex||(this.data.currentIndex=0),this._slideList()}},{key:"setArrow",value:function(){var t=this.groupItems(),e=t.length,a=this.data.currentIndex+1,o=this.data.currentIndex-1;this.data.showNextArrow=!1,this.data.showPrevArrow=!1,a!==e&&(this.data.next=a,this.data.showNextArrow=!0),-1!==o&&(this.data.prev=o,this.data.showPrevArrow=!0)}},{key:"beforeDrag",value:function(){if(this._isGestured(this.e))return void this.beforeGesture();if(this.isBeingZoomed=!1,this.data.scale)return void this.beforePhotoDrag();var t=this._getTouchPos();this.isSwipable=!0,this.dragStart=!0,this.firstPos=t,this.oldPos=t}},{key:"afterDrag",value:function(){var t=this.groupItems(),e=new Date,a=e.getTime(),o=this.tapSecond-a,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():p.isSmartPhone()||0!==n||0!==i?Math.abs(o)<=500&&0===n&&0===i?(this.e.preventDefault(),void this.zoomPhoto()):(this.tapSecond=a,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,a=t.y-this.firstPos.y;this.dragStart&&(this._fireEvent("swipestart"),this.dragStart=!1,Math.abs(e)>Math.abs(a)?this.moveDir="horizontal":this.moveDir="vertical"),"horizontal"===this.moveDir?(this.pos.x+=e,this.data.translateX=this.pos.x):this.data.translateY=a,this.onListMove=!0,this.oldPos=t,this._listUpdate()}}}},{key:"zoomPhoto",value:function(){var t=this;this.data.hideUi=!0,this.data.scaleSize=this._getScaleBoarder(),this.data.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,a=t.y-this.oldPhotoPos.y,o=this._round(this.data.scaleSize*e,6),n=this._round(this.data.scaleSize*a,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),a=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.photoPosYa&&0!==this.data.currentIndex)return void this.gotoSlide(this.data.prev);if(e.minX-this.data.photoPosX>a&&this.data.currentIndex+1!==this.data.total)return void this.gotoSlide(this.data.next);0===o&&0===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]),a=(e-this.oldDistance)/100,o=this.data.scaleSize,n=this.data.photoPosX,i=this.data.photoPosY;this.isBeingZoomed=!0,this.data.scaleSize+=this._round(a,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(),a=this._getWindowHeight();return p.isSmartPhone()?t.width>t.height?a/(t.height*t.scale):e/(t.width*t.scale):1/t.scale}},{key:"_makeBound",value:function(t){var e,a,o,n,i=t.width*t.scale*this.data.scaleSize,r=t.height*t.scale*this.data.scaleSize,s=this._getWindowWidth(),c=this._getWindowHeight();return s>i?(o=(s-i)/2,e=-1*o):(o=(i-s)/2,e=-1*o),c>r?(n=(c-r)/2,a=-1*n):(n=(r-c)/2,a=-1*n),{minX:this._round(e,6)*this.data.scaleSize,minY:this._round(a,6)*this.data.scaleSize,maxX:this._round(o,6)*this.data.scaleSize,maxY:this._round(n,6)*this.data.scaleSize}}},{key:"_registerElasticForce",value:function(t,e){var a=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(){a.data.elastic=!1,a._photoUpdate()},300)}},{key:"_getSelectedItem",value:function(){var t=this.data,e=t.currentIndex;return t.group[t.currentGroup][e]}},{key:"_getUniqId",value:function(){return(Date.now().toString(36)+Math.random().toString(36).substr(2,5)).toUpperCase()}},{key:"_getDistance",value:function(t,e){var a=t.x-e.x,o=t.y-e.y;return Math.sqrt(a*a+o*o)}},{key:"_round",value:function(t,e){var a=Math.pow(10,e);return t*=a,t=Math.round(t),t/=a}},{key:"_isTouched",value:function(t){return!(!t||!t.touches)}},{key:"_isGestured",value:function(t){return!!(t&&t.touches&&t.touches.length>1)}},{key:"_isSmartPhone",value:function(){var t=navigator.userAgent;return t.indexOf("iPhone")>0||t.indexOf("iPad")>0||t.indexOf("ipod")>0||t.indexOf("Android")>0}},{key:"_calcGravity",value:function(t,e){(t>5||t<-5)&&(this.vx+=.05*t),!1!==this.data.verticalGravity&&(e>5||e<-5)&&(this.vy+=.05*e)}},{key:"_photoUpdate",value:function(){var t=this.data.classNames,e=this._getElementByQuery(".current"),a=e.querySelector(".".concat(t.smartPhotoImg)),o=this._getElementByQuery(".".concat(t.smartPhotoNav)),n=this._getElementByQuery(".".concat(t.smartPhotoArrows)),i=this.virtualPos(this.data.photoPosX),r=this.virtualPos(this.data.photoPosY),s=this.data.scaleSize,c="translate(".concat(i,"px,").concat(r,"px) scale(").concat(s,")");a.style.transform=c,this.data.scale?p.addClass(a,t.smartPhotoImgOnMove):p.removeClass(a,t.smartPhotoImgOnMove),this.data.elastic?p.addClass(a,t.smartPhotoImgElasticMove):p.removeClass(a,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(".".concat(t.smartPhotoList)),a="translate(".concat(this.data.translateX,"px,").concat(this.data.translateY,"px)");e.style.transform=a,this.data.onMoveClass?p.addClass(e,t.smartPhotoListOnMove):p.removeClass(e,t.smartPhotoListOnMove)}},{key:"_fireEvent",value:function(t){var e=this._getElementByClass(this.data.classNames.smartPhoto);p.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 a=this._getForceAndTheta(this.vx,this.vy),o=a.force,n=a.theta;o-=this.data.registance,Math.abs(o)<.5||(this.vx=Math.cos(n)*o,this.vy=Math.sin(n)*o,this._photoUpdate())}}}]),e}(h.default);a.default=y,e.exports=a.default},{"../lib/util":12,"a-template":1,"custom-event-polyfill":3,"es6-promise-polyfill":4}],11:[function(t,e,a){"use strict";e.exports=t("./core/")},{"./core/":10}],12:[function(t,e,a){"use strict";function o(t){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function n(t){t=t||{};for(var e=1;e0||t.indexOf("iPad")>0||t.indexOf("ipod")>0||t.indexOf("Android")>0};a.isSmartPhone=i;var r=n;a.extend=r;var s=function(t,e,a){var o;window.CustomEvent?o=new CustomEvent(e,{cancelable:!0}):(o=document.createEvent("CustomEvent"),o.initCustomEvent(e,!1,!1,a)),t.dispatchEvent(o)};a.triggerEvent=s;var c=function(t){for(var e,a,o,n=t.split("&"),i={},r=0,s=n.length;r0;)t.appendChild(a.children[0])};a.append=l;var h=function(t,e){t.classList?t.classList.add(e):t.className+=" ".concat(e)};a.addClass=h;var f=function(t,e){t.classList?t.classList.remove(e):t.className=t.className.replace(new RegExp("(^|\\b)"+e.split(" ").join("|")+"(\\b|$)","gi")," ")};a.removeClass=f;var p=function(){var t=window.navigator.userAgent.toLowerCase(),e=window.navigator.appVersion.toLowerCase(),a="unknown";return-1!=t.indexOf("msie")?a=-1!=e.indexOf("msie 6.")?"ie6":-1!=e.indexOf("msie 7.")?"ie7":-1!=e.indexOf("msie 8.")?"ie8":-1!=e.indexOf("msie 9.")?"ie9":-1!=e.indexOf("msie 10.")?"ie10":"ie":-1!=t.indexOf("trident/7")?a="ie11":-1!=t.indexOf("chrome")?a="chrome":-1!=t.indexOf("safari")?a="safari":-1!=t.indexOf("opera")?a="opera":-1!=t.indexOf("firefox")&&(a="firefox"),a};a.getBrowser=p;var m=function(){var t=p();return-1!==t.indexOf("ie")&&parseInt(t.replace(/[^0-9]/g,""))<=10};a.isOldIE=m},{}]},{},[9]); \ No newline at end of file diff --git a/js/smartphoto.js b/js/smartphoto.js index e76147f..e3416af 100644 --- a/js/smartphoto.js +++ b/js/smartphoto.js @@ -6,7 +6,7 @@ * license: MIT (http://opensource.org/licenses/MIT) * author: appleple * homepage: http://developer.a-blogcms.jp - * version: 1.6.4 + * version: 1.6.5 * * a-template: * license: MIT (http://opensource.org/licenses/MIT) @@ -2186,7 +2186,7 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function" function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } -var template = "
    aria-hidden=\"true\" aria-hidden=\"false\" role=\"dialog\">\n\t
    \n\t\t
    \n\t\t\t
    \n\t\t\t\t\t{currentIndex}[increment]/{total}\n\t\t\t\t\t{caption}\n\t\t\t\t\t\n\t\t\t\t
    \n\t\t\t\t
    data-action-touchstart=\"beforeDrag\" data-action-touchmove=\"onDrag\" data-action-touchend=\"afterDrag(false)\" data-action-click=\"hidePhoto()\">\n\t\t\t\t
    \n\t\t\t\t
      \\{classNames.smartPhotoListOnMove\\}\">\n\t\t\t\t\t\n\t\t\t\t\t
    • current\">\n\t\t\t\t\t\t\n\t\t\t\t\t\t
      data-action-mousemove=\"onDrag\" data-action-mousedown=\"beforeDrag\" data-action-mouseup=\"afterDrag\" data-action-touchstart=\"beforeDrag\" data-action-touchmove=\"onDrag\" data-action-touchend=\"afterDrag\">\n\t\t\t\t\t\t\ttransform:translate(\\{photoPosX\\}[virtualPos]px,\\{photoPosY\\}[virtualPos]px) scale(\\{scaleSize\\});width:{width}px;\" src=\"{src}\" class=\"\\\\{classNames.smartPhotoImg\\\\} \\\\{classNames.smartPhotoImgOnMove\\\\} \\\\{classNames.smartPhotoImgElasticMove\\\\} active\" ondragstart=\"return false;\">\n\t\t\t\t\t\t
      \n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t
      \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
      \n\t\t\t\t\t\t\n\t\t\t\t\t
    • \n\t\t\t\t\t\n\t\t\t\t
    \n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t
    \n\t\t\n\t\t\n\t\t\n\t
    \n
    \n"; +var template = "
    aria-hidden=\"true\" aria-hidden=\"false\" role=\"dialog\" tabindex=\"-1\">\n\t
    \n\t\t
    \n\t\t\t
    \n\t\t\t\t{currentIndex}[increment]/{total}\n\t\t\t\t{caption}\n\t\t\t
    \n\n\t\t\t
    data-action-touchstart=\"beforeDrag\" data-action-touchmove=\"onDrag\" data-action-touchend=\"afterDrag(false)\" data-action-click=\"hidePhoto()\">\n\t\t\t
    \n\n\t\t\t
      \\{classNames.smartPhotoListOnMove\\}\">\n\t\t\t\t\n\t\t\t\t
    • current\">\n\t\t\t\t\t\n\t\t\t\t\t
      data-action-mousemove=\"onDrag\" data-action-mousedown=\"beforeDrag\" data-action-mouseup=\"afterDrag\" data-action-touchstart=\"beforeDrag\" data-action-touchmove=\"onDrag\" data-action-touchend=\"afterDrag\">\n\t\t\t\t\t\ttransform:translate(\\{photoPosX\\}[virtualPos]px,\\{photoPosY\\}[virtualPos]px) scale(\\{scaleSize\\});width:{width}px;\" src=\"{src}\" class=\"\\\\{classNames.smartPhotoImg\\\\} \\\\{classNames.smartPhotoImgOnMove\\\\} \\\\{classNames.smartPhotoImgElasticMove\\\\} active\" ondragstart=\"return false;\">\n\t\t\t\t\t
      \n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t
      \n\t\t\t\t\t\t\n\t\t\t\t\t
      \n\t\t\t\t\t\n\t\t\t\t
    • \n\t\t\t\t\n\t\t\t
    \n\n\t\t\t\n\t\t\t aria-hidden=\"true\"\n\t\t\t\t aria-hidden=\"false\"\n\t\t\t\ttabindex=\"-1\">\n\t\t\t\t
  • \\{classNames.smartPhotoArrowHideIcon\\}\" aria-hidden=\"true\">\\{message.gotoPrevImage\\}
  • \n\t\t\t\t
  • \\{classNames.smartPhotoArrowHideIcon\\}\" aria-hidden=\"true\">\\{message.gotoNextImage\\}
  • \n\t\t\t\n\t\t\t\n\n\t\t\t\n\t\t\taria-hidden=\"true\"\n\t\t\t\t aria-hidden=\"false\">\n\t\t\t\t\n\t\t\t\n\t\t\t\n\n\t\t\t\n\t\t\t\t\\{message.closeDialog\\}\n\t\t\t\n\t\t
    \n\t\t\n\t\t\n\t\t\n\t
    \n
    \n"; var util = require('../lib/util'); @@ -2568,6 +2568,21 @@ function (_ATemplate) { var currentItem = _this3._getSelectedItem(); + var onFocus = function onFocus(e) { + if (e.keyCode === 9) { + var smartPhoto = document.querySelector(".".concat(_this3.data.classNames.smartPhoto)); + var arrows = document.querySelector(".".concat(_this3.data.classNames.smartPhotoArrows)); + var dismiss = document.querySelector(".".concat(_this3.data.classNames.smartPhotoDismiss)); + var curFocus = document.activeElement; + + if (curFocus === smartPhoto) { + arrows.focus(); + } else if (curFocus === dismiss) { + smartPhoto.focus(); + } + } + }; + if (currentItem.loaded) { _this3._initPhoto(); @@ -2580,6 +2595,12 @@ function (_ATemplate) { body.style.overflow = 'hidden'; _this3._fireEvent('open'); + + var smartPhoto = document.querySelector(".".concat(_this3.data.classNames.smartPhoto)); + smartPhoto.focus(); + document.addEventListener('keydown', onFocus); + + _this3._registerRemoveEvent(window, 'keydown', onFocus); } else { _this3._loadItem(currentItem).then(function () { _this3._initPhoto(); @@ -2593,6 +2614,12 @@ function (_ATemplate) { body.style.overflow = 'hidden'; _this3._fireEvent('open'); + + var smartPhoto = document.querySelector(".".concat(_this3.data.classNames.smartPhoto)); + smartPhoto.focus(); + document.addEventListener('keydown', onFocus); + + _this3._registerRemoveEvent(window, 'keydown', onFocus); }); } }; diff --git a/js/smartphoto.min.js b/js/smartphoto.min.js index 12a45ef..e7fc3aa 100644 --- a/js/smartphoto.min.js +++ b/js/smartphoto.min.js @@ -6,7 +6,7 @@ * license: MIT (http://opensource.org/licenses/MIT) * author: appleple * homepage: http://developer.a-blogcms.jp - * version: 1.6.4 + * version: 1.6.5 * * a-template: * license: MIT (http://opensource.org/licenses/MIT) @@ -52,5 +52,5 @@ * * 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,a,o){function n(r,s){if(!a[r]){if(!e[r]){var c="function"==typeof require&&require;if(!s&&c)return c(r,!0);if(i)return i(r,!0);var d=new Error("Cannot find module '"+r+"'");throw d.code="MODULE_NOT_FOUND",d}var u=a[r]={exports:{}};e[r][0].call(u.exports,function(t){return n(e[r][1][t]||t)},u,u.exports,t,e,a,o)}return a[r].exports}for(var i="function"==typeof require&&require,r=0;r1;)a=a[o.shift()];a[o.shift()]=e}},{key:"removeDataByString",value:function(t){for(var e=this.data,a=t.split(".");a.length>1;)e=e[a.shift()];var o=a.shift();o.match(/^\d+$/)?e.splice(Number(o),1):delete e[o]}},{key:"resolveBlock",value:function(t,e,a){var o=this,n=t.match(//g),i=t.match(//g),r=t.match(//g),s=t.match(//g);if(n)for(var c=0,d=n.length;c/g;return t=t.replace(e,function(t,e){return(0,c.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,a=this;return t=t.replace(e,function(t,e,o){var n=a.getDataByString(e),i=[];i="function"==typeof n?n.apply(a):n;var r="";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 a=this.atemplate.find(function(e){return e.id===t}),o="";if(a&&a.html&&(o=a.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",a=arguments[1],o=this.templates;this.beforeUpdated&&this.beforeUpdated();for(var n=0,i=o.length;n"+u+"");else(0,c.selector)(d).insertAdjacentHTML("afterend",'
    '),"text"===e?(0,c.selector)("[data-id='"+r+"']").innerText=u:(0,c.selector)("[data-id='"+r+"']").innerHTML=u;var p=t.atemplate.find(function(t){return t.id===r});p.binded||(p.binded=!0,t.addDataBind((0,c.selector)("[data-id='"+r+"']")),t.addActionBind((0,c.selector)("[data-id='"+r+"']")))}(n);return this.updateBindingData(a),this.onUpdated&&this.onUpdated(a),this}},{key:"updateBindingData",value:function(t){for(var e=this,a=this.templates,o=0,n=a.length;o1?a-1:0),n=1;n1;)e=e[a.shift()];var o=a.shift();return o.match(/^\d+$/)?e.splice(Number(o),1):delete e[o],this}}]),t}();a.default=h,e.exports=a.default},{"./util":2,"ie-array-find-polyfill":5,morphdom:6}],2:[function(t,e,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var o=a.matches=function(t,e){for(var a=(t.document||t.ownerDocument).querySelectorAll(e),o=a.length;--o>=0&&a.item(o)!==t;);return o>-1},n=(a.selector=function(t){return document.querySelector(t)},a.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}),i=[];a.on=function(t,e,a,o){var r=arguments.length>4&&void 0!==arguments[4]&&arguments[4];a.split(" ").forEach(function(a){var s=function(t){var a=n(t.target,e);a&&(t.delegateTarget=a,o(t))};i.push({listener:s,element:t,query:e,event:a,capture:r}),t.addEventListener(a,s,r)})},a.off=function(t,e,a){a.split(" ").forEach(function(a){i.forEach(function(o,n){o.element===t&&o.query===e&&o.event===a&&(t.removeEventListener(a,o.listener,o.capture),i.splice(n,1))})})}},{}],3:[function(t,e,a){try{var o=new window.CustomEvent("test");if(o.preventDefault(),!0!==o.defaultPrevented)throw new Error("Could not prevent default")}catch(t){var n=function(t,e){var a,o;return e=e||{bubbles:!1,cancelable:!1,detail:void 0},a=document.createEvent("CustomEvent"),a.initCustomEvent(t,e.bubbles,e.cancelable,e.detail),o=a.preventDefault,a.preventDefault=function(){o.call(this);try{Object.defineProperty(this,"defaultPrevented",{get:function(){return!0}})}catch(t){this.defaultPrevented=!0}},a};n.prototype=window.Event.prototype,window.CustomEvent=n}},{}],4:[function(e,a,o){(function(e,a){!function(e){function n(t){return"[object Array]"===Object.prototype.toString.call(t)}function i(){for(var t=0;t>>0;if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var o=arguments[1],n=0;n=0;s--)a=r[s],o=a.name,n=a.namespaceURI,i=a.value,n?(o=a.localName||o,t.getAttributeNS(n,o)!==i&&("xmlns"===a.prefix&&(o=a.name),t.setAttributeNS(n,o,i))):t.getAttribute(o)!==i&&t.setAttribute(o,i);for(var c=t.attributes,d=c.length-1;d>=0;d--)a=c[d],o=a.name,n=a.namespaceURI,n?(o=a.localName||o,e.hasAttributeNS(n,o)||t.removeAttributeNS(n,o)):e.hasAttribute(o)||t.removeAttribute(o)}}function n(t){var e=g.createElement("template");return e.innerHTML=t,e.content.childNodes[0]}function i(t){return p||(p=g.createRange(),p.selectNode(g.body)),p.createContextualFragment(t).childNodes[0]}function r(t){var e=g.createElement("body");return e.innerHTML=t,e.childNodes[0]}function s(t){return t=t.trim(),y?n(t):x?i(t):r(t)}function c(t,e){var a=t.nodeName,o=e.nodeName;return a===o||!!(e.actualize&&a.charCodeAt(0)<91&&o.charCodeAt(0)>90)&&a===o.toUpperCase()}function d(t,e){return e&&e!==v?g.createElementNS(e,t):g.createElement(t)}function u(t,e){for(var a=t.firstChild;a;){var o=a.nextSibling;e.appendChild(a),a=o}return e}function l(t,e,a){t[a]!==e[a]&&(t[a]=e[a],t[a]?t.setAttribute(a,""):t.removeAttribute(a))}function h(){}function f(t){if(t)return t.getAttribute&&t.getAttribute("id")||t.id}var p,m=11,v="http://www.w3.org/1999/xhtml",g="undefined"==typeof document?void 0:document,y=!!g&&"content"in g.createElement("template"),x=!!g&&g.createRange&&"createContextualFragment"in g.createRange(),w={OPTION:function(t,e){var a=t.parentNode;if(a){var o=a.nodeName.toUpperCase();"OPTGROUP"===o&&(a=a.parentNode,o=a&&a.nodeName.toUpperCase()),"SELECT"!==o||a.hasAttribute("multiple")||(t.hasAttribute("selected")&&!e.selected&&(t.setAttribute("selected","selected"),t.removeAttribute("selected")),a.selectedIndex=-1)}l(t,e,"selected")},INPUT:function(t,e){l(t,e,"checked"),l(t,e,"disabled"),t.value!==e.value&&(t.value=e.value),e.hasAttribute("value")||t.removeAttribute("value")},TEXTAREA:function(t,e){var a=e.value;t.value!==a&&(t.value=a);var o=t.firstChild;if(o){var n=o.nodeValue;if(n==a||!a&&n==t.placeholder)return;o.nodeValue=a}},SELECT:function(t,e){if(!e.hasAttribute("multiple")){for(var a,o,n=-1,i=0,r=t.firstChild;r;)if("OPTGROUP"===(o=r.nodeName&&r.nodeName.toUpperCase()))a=r,r=a.firstChild;else{if("OPTION"===o){if(r.hasAttribute("selected")){n=i;break}i++}r=r.nextSibling,!r&&a&&(r=a.nextSibling,a=null)}t.selectedIndex=n}}},P=1,E=11,b=3,_=8,I=function(t){return function(e,a,o){function n(t){G.push(t)}function i(t,e){if(t.nodeType===P)for(var a=t.firstChild;a;){var o=void 0;e&&(o=I(a))?n(o):(T(a),a.firstChild&&i(a,e)),a=a.nextSibling}}function r(t,e,a){!1!==B(t)&&(e&&e.removeChild(t),T(t),i(t,a))}function l(t){if(t.nodeType===P||t.nodeType===E)for(var e=t.firstChild;e;){var a=I(e);a&&(C[a]=e),l(e),e=e.nextSibling}}function p(t){S(t);for(var e=t.firstChild;e;){var a=e.nextSibling,o=I(e);if(o){var n=C[o];n&&c(e,n)&&(e.parentNode.replaceChild(n,e),v(n,e))}p(e),e=a}}function m(t,e,a){for(;e;){var o=e.nextSibling;(a=I(e))?n(a):r(e,t,!0),e=o}}function v(e,a,o){var n=I(a);if(n&&delete C[n],!o){if(!1===k(e,a))return;if(t(e,a),A(e),!1===D(e,a))return}"TEXTAREA"!==e.nodeName?y(e,a):w.TEXTAREA(e,a)}function y(t,e){var a,o,i,s,d,u=e.firstChild,l=t.firstChild;t:for(;u;){for(s=u.nextSibling,a=I(u);l;){if(i=l.nextSibling,u.isSameNode&&u.isSameNode(l)){u=s,l=i;continue t}o=I(l);var h=l.nodeType,f=void 0;if(h===u.nodeType&&(h===P?(a?a!==o&&((d=C[a])?i===d?f=!1:(t.insertBefore(d,l),o?n(o):r(l,t,!0),l=d):f=!1):o&&(f=!1),(f=!1!==f&&c(l,u))&&v(l,u)):h!==b&&h!=_||(f=!0,l.nodeValue!==u.nodeValue&&(l.nodeValue=u.nodeValue))),f){u=s,l=i;continue t}o?n(o):r(l,t,!0),l=i}if(a&&(d=C[a])&&c(d,u))t.appendChild(d),v(d,u);else{var y=N(u);!1!==y&&(y&&(u=y),u.actualize&&(u=u.actualize(t.ownerDocument||g)),t.appendChild(u),p(u))}u=s,l=i}m(t,l,o);var x=w[t.nodeName];x&&x(t,e)}if(o||(o={}),"string"==typeof a)if("#document"===e.nodeName||"HTML"===e.nodeName){var x=a;a=g.createElement("html"),a.innerHTML=x}else a=s(a);var I=o.getNodeKey||f,N=o.onBeforeNodeAdded||h,S=o.onNodeAdded||h,k=o.onBeforeElUpdated||h,A=o.onElUpdated||h,B=o.onBeforeNodeDiscarded||h,T=o.onNodeDiscarded||h,D=o.onBeforeElChildrenUpdated||h,O=!0===o.childrenOnly,C=Object.create(null),G=[];l(e);var L=e,z=L.nodeType,X=a.nodeType;if(!O)if(z===P)X===P?c(e,a)||(T(e),L=u(e,d(a.nodeName,a.namespaceURI))):L=a;else if(z===b||z===_){if(X===z)return L.nodeValue!==a.nodeValue&&(L.nodeValue=a.nodeValue),L;L=a}if(L===a)T(e);else{if(a.isSameNode&&a.isSameNode(L))return;if(v(L,a,O),G)for(var M=0,Y=G.length;M1)for(var a=1;a=0&&(t._idleTimeoutId=setTimeout(function(){t._onTimeout&&t._onTimeout()},e))},a.setImmediate="function"==typeof e?e:function(t){var e=d++,o=!(arguments.length<2)&&s.call(arguments,1);return c[e]=!0,i(function(){c[e]&&(o?t.apply(null,o):t.call(null),a.clearImmediate(e))}),e},a.clearImmediate="function"==typeof o?o:function(t){delete c[t]}}).call(this,t("timers").setImmediate,t("timers").clearImmediate)},{"process/browser.js":7,timers:8}],9:[function(t,e,a){"use strict";function o(t){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){for(var a=0;ago to {caption}\n\t\t\t\t\t\t\x3c!-- END groupItems:loop --\x3e\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t\t\x3c!-- END nav:exist --\x3e\n\t\t\n\t\t\x3c!-- BEGIN appearEffect:exist --\x3e\n\t\t\n\t\t\x3c!-- END appearEffect:exist --\x3e\n\t\n\n',p=t("../lib/util"),m=t("es6-promise-polyfill"),v=m.Promise,g={classNames:{smartPhoto:"smartphoto",smartPhotoClose:"smartphoto-close",smartPhotoBody:"smartphoto-body",smartPhotoInner:"smartphoto-inner",smartPhotoContent:"smartphoto-content",smartPhotoImg:"smartphoto-img",smartPhotoImgOnMove:"smartphoto-img-onmove",smartPhotoImgElasticMove:"smartphoto-img-elasticmove",smartPhotoImgWrap:"smartphoto-img-wrap",smartPhotoArrows:"smartphoto-arrows",smartPhotoNav:"smartphoto-nav",smartPhotoArrowRight:"smartphoto-arrow-right",smartPhotoArrowLeft:"smartphoto-arrow-left",smartPhotoArrowHideIcon:"smartphoto-arrow-hide",smartPhotoImgLeft:"smartphoto-img-left",smartPhotoImgRight:"smartphoto-img-right",smartPhotoList:"smartphoto-list",smartPhotoListOnMove:"smartphoto-list-onmove",smartPhotoHeader:"smartphoto-header",smartPhotoCount:"smartphoto-count",smartPhotoCaption:"smartphoto-caption",smartPhotoDismiss:"smartphoto-dismiss",smartPhotoLoader:"smartphoto-loader",smartPhotoLoaderWrap:"smartphoto-loader-wrap",smartPhotoImgClone:"smartphoto-img-clone"},message:{gotoNextImage:"go to the next image",gotoPrevImage:"go to the previous image",closeDialog:"close the image dialog"},arrows:!0,nav:!0,showAnimation:!0,verticalGravity:!1,useOrientationApi:!1,useHistoryApi:!0,swipeTopToClose:!1,swipeBottomToClose:!0,swipeOffset:100,headerHeight:60,footerHeight:60,forceInterval:10,registance:.5,loadOffset:2,resizeStyle:"fit",lazyAttribute:"data-src"},y=function(t){function e(t,a){var o;n(this,e),o=s(this,d(e).call(this)),o.data=p.extend({},g,a),o.data.currentIndex=0,o.data.oldIndex=0,o.data.hide=!0,o.data.group={},o.data.scaleSize=1,o.data.scale=!1,o.pos={x:0,y:0},o.data.photoPosX=0,o.data.photoPosY=0,o.handlers=[],o.convert={increment:o.increment,virtualPos:o.virtualPos,round:o.round},o.data.groupItems=o.groupItems,o.elements="string"==typeof t?document.querySelectorAll(t):t;var i=new Date;o.tapSecond=i.getTime(),o.onListMove=!1,o.clicked=!1,o.id=o._getUniqId(),o.vx=0,o.vy=0,o.data.appearEffect=null,o.addTemplate(o.id,f),o.data.isSmartPhone=o._isSmartPhone();var r=document.querySelector("body");p.append(r,"
    ")),[].forEach.call(o.elements,function(t){o.addNewItem(t)}),o.update();var c=o._getCurrentItemByHash();if(c&&p.triggerEvent(c.element,"click"), -o.interval=setInterval(function(){o._doAnim()},o.data.forceInterval),!o.data.isSmartPhone){var u=function(){o.groupItems()&&(o._resetTranslate(),o._setPosByCurrentIndex(),o._setSizeByScreen(),o.update())},l=function(t){var e=t.keyCode||t.which;!0!==o.data.hide&&(37===e?o.gotoSlide(o.data.prev):39===e?o.gotoSlide(o.data.next):27===e&&o.hidePhoto())};return window.addEventListener("resize",u),window.addEventListener("keydown",l),o._registerRemoveEvent(window,"resize",u),o._registerRemoveEvent(window,"keydown",l),s(o)}var h=function(){if(o.groupItems()){o._resetTranslate(),o._setPosByCurrentIndex(),o._setHashByCurrentIndex(),o._setSizeByScreen(),o.update();var t=o._getWindowWidth();!function e(a){new v(function(t){setTimeout(function(){t()},25)}).then(function(){t!==o._getWindowWidth()?(o._resetTranslate(),o._setPosByCurrentIndex(),o._setHashByCurrentIndex(),o._setSizeByScreen(),o.update()):a<=500&&e(a+25)})}(0)}};if(window.addEventListener("orientationchange",h),o._registerRemoveEvent(window,"orientationchange",h),!o.data.useOrientationApi)return s(o);var m=function(t){var e=window,a=e.orientation;t&&t.gamma&&!o.data.appearEffect&&(o.isBeingZoomed||o.photoSwipable||o.data.elastic||!o.data.scale||(0===a?o._calcGravity(t.gamma,t.beta):90===a?o._calcGravity(t.beta,t.gamma):-90===a?o._calcGravity(-t.beta,-t.gamma):180===a&&o._calcGravity(-t.gamma,-t.beta)))};return window.addEventListener("deviceorientation",m),o._registerRemoveEvent(window,"deviceorientation",m),o}return u(e,t),r(e,[{key:"on",value:function(t,e){var a=this._getElementByClass(this.data.classNames.smartPhoto),o=function(t){e.call(a,t)};a.addEventListener(t,o),this._registerRemoveEvent(a,t,o)}},{key:"_registerRemoveEvent",value:function(t,e,a){this.handlers.push({target:t,event:e,handler:a})}},{key:"destroy",value:function(){this.handlers.forEach(function(t){t.target.removeEventListener(t.event,t.handler)});var t=document.querySelector('[data-id="'.concat(this.id,'"]'));p.removeElement(t),clearInterval(this.interval),this.removeTemplateEvents()}},{key:"increment",value:function(t){return t+1}},{key:"round",value:function(t){return Math.round(t)}},{key:"virtualPos",value:function(t){return(t=parseInt(t,10))/this._getSelectedItem().scale/this.data.scaleSize}},{key:"groupItems",value:function(){return this.data.group[this.data.currentGroup]}},{key:"_resetTranslate",value:function(){var t=this;this.groupItems().forEach(function(e,a){e.translateX=t._getWindowWidth()*a})}},{key:"addNewItem",value:function(t){var e=this,a=t.getAttribute("data-group")||"nogroup",o=this.data.group;"nogroup"===a&&t.setAttribute("data-group","nogroup"),o[a]||(o[a]=[]);var n=o[a].length,i=document.querySelector("body"),r=t.getAttribute("href"),s=t.querySelector("img"),c=r;s&&(c=s.getAttribute(this.data.lazyAttribute)?s.getAttribute(this.data.lazyAttribute):s.currentSrc?s.currentSrc:s.src);var d={src:r,thumb:c,caption:t.getAttribute("data-caption"),groupId:a,translateX:this._getWindowWidth()*n,index:n,translateY:0,width:50,height:50,id:t.getAttribute("data-id")||n,loaded:!1,processed:!1,element:t};o[a].push(d),this.data.currentGroup=a,t.getAttribute("data-id")||t.setAttribute("data-id",n),t.setAttribute("data-index",n);var u=function(a){a.preventDefault(),e.data.currentGroup=t.getAttribute("data-group"),e.data.currentIndex=parseInt(t.getAttribute("data-index"),10),e._setHashByCurrentIndex();var o=e._getSelectedItem();o.loaded?(e._initPhoto(),e.addAppearEffect(t,o),e.clicked=!0,e.update(),i.style.overflow="hidden",e._fireEvent("open")):e._loadItem(o).then(function(){e._initPhoto(),e.addAppearEffect(t,o),e.clicked=!0,e.update(),i.style.overflow="hidden",e._fireEvent("open")})};t.addEventListener("click",u),this._registerRemoveEvent(t,"click",u)}},{key:"_initPhoto",value:function(){this.data.total=this.groupItems().length,this.data.hide=!1,this.data.photoPosX=0,this.data.photoPosY=0,this._setPosByCurrentIndex(),this._setSizeByScreen(),this.setArrow(),"fill"===this.data.resizeStyle&&this.data.isSmartPhone&&(this.data.scale=!0,this.data.hideUi=!0,this.data.scaleSize=this._getScaleBoarder())}},{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 v(function(e){p.isOldIE()&&e();var a=t.data,o=a.appearEffect,n=a.classNames,i=t._getElementByClass(n.smartPhotoImgClone),r=function t(){i.removeEventListener("transitionend",t,!0),e()};i.addEventListener("transitionend",r,!0),setTimeout(function(){i.style.transform="translate(".concat(o.afterX,"px, ").concat(o.afterY,"px) scale(").concat(o.scale,")")},10)})}},{key:"addAppearEffect",value:function(t,e){if(!1===this.data.showAnimation)return void(this.data.appear=!0);var a=t.querySelector("img"),o=p.getViewPos(a),n={},i=1;n.width=a.offsetWidth,n.height=a.offsetHeight,n.top=o.top,n.left=o.left,n.once=!0,a.getAttribute(this.data.lazyAttribute)?n.img=a.getAttribute(this.data.lazyAttribute):n.img=e.src;var r=this._getWindowWidth(),s=this._getWindowHeight(),c=s-this.data.headerHeight-this.data.footerHeight;"fill"===this.data.resizeStyle&&this.data.isSmartPhone?i=a.offsetWidth>a.offsetHeight?s/a.offsetHeight:r/a.offsetWidth:(n.width>=n.height?i=e.heightn.width&&(i=e.heightr&&(i=r/n.width));var d=(i-1)/2*a.offsetWidth+(r-a.offsetWidth*i)/2,u=(i-1)/2*a.offsetHeight+(s-a.offsetHeight*i)/2;n.afterX=d,n.afterY=u,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 a=void 0!==window.pageXOffset?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft,o=void 0!==window.pageYOffset?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop,n=document.querySelector("body");window.location.hash&&this._setHash(""),window.scroll(a,o),this._doHideEffect(e).then(function(){t.update(),n.style.overflow="",t._fireEvent("close")})}},{key:"_doHideEffect",value:function(t){var e=this;return new v(function(a){p.isOldIE()&&a();var o=e.data.classNames,n=e._getElementByClass(o.smartPhoto),i=e._getElementByQuery(".current .".concat(o.smartPhotoImg)),r=e._getWindowHeight(),s=function t(){n.removeEventListener("transitionend",t,!0),a()};n.style.opacity=0,"bottom"===t?i.style.transform="translateY(".concat(r,"px)"):"top"===t&&(i.style.transform="translateY(-".concat(r,"px)")),n.addEventListener("transitionend",s,!0)})}},{key:"_getElementByClass",value:function(t){return document.querySelector('[data-id="'.concat(this.id,'"] .').concat(t))}},{key:"_getElementByQuery",value:function(t){return document.querySelector('[data-id="'.concat(this.id,'"] ').concat(t))}},{key:"_getTouchPos",value:function(){var t=0,e=0,a="undefined"==typeof event?this.e:event;return this._isTouched(a)?(t=a.touches[0].pageX,e=a.touches[0].pageY):a.pageX&&(t=a.pageX,e=a.pageY),{x:t,y:e}}},{key:"_getGesturePos",value:function(t){var e=t.touches;return[{x:e[0].pageX,y:e[0].pageY},{x:e[1].pageX,y:e[1].pageY}]}},{key:"_setPosByCurrentIndex",value:function(){var t=this,e=this.groupItems(),a=-1*e[this.data.currentIndex].translateX;this.pos.x=a,setTimeout(function(){t.data.translateX=a,t.data.translateY=0,t._listUpdate()},1)}},{key:"_setHashByCurrentIndex",value:function(){var t=void 0!==window.pageXOffset?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft,e=void 0!==window.pageYOffset?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop,a=this.groupItems(),o=a[this.data.currentIndex].id,n=this.data.currentGroup,i="group=".concat(n,"&photo=").concat(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,"".concat(location.pathname).concat(location.search,"#").concat(t)):window.history.replaceState(null,null,"".concat(location.pathname).concat(location.search)))}},{key:"_getCurrentItemByHash",value:function(){var t=this.data.group,e=location.hash.substr(1),a=p.parseQuery(e),o=null,n=function(t){a.group===t.groupId&&a.photo===t.id&&(o=t)};return Object.keys(t).forEach(function(e){t[e].forEach(n)}),o}},{key:"_loadItem",value:function(t){return new v(function(e){var a=new Image;a.onload=function(){t.width=a.width,t.height=a.height,t.loaded=!0,e()},a.onerror=function(){e()},a.src=t.src})}},{key:"_getItemByIndex",value:function(t){var e=this.data;return e.group[e.currentGroup][t]?e.group[e.currentGroup][t]:null}},{key:"_loadNeighborItems",value:function(){for(var t=this,e=this.data.currentIndex,a=this.data.loadOffset,o=e-a,n=e+a,i=[],r=o;rt&&(a.scale=t/a.width,a.x=(a.scale-1)/2*a.width))})}},{key:"_slideList",value:function(){var t=this;this.data.scaleSize=1,this.isBeingZoomed=!1,this.data.hideUi=!1,this.data.scale=!1,this.data.photoPosX=0,this.data.photoPosY=0,this.data.onMoveClass=!0,this._setPosByCurrentIndex(),this._setHashByCurrentIndex(),this._setSizeByScreen(),setTimeout(function(){var e=t._getSelectedItem();t.data.onMoveClass=!1,t.setArrow(),t.update(),t.data.oldIndex!==t.data.currentIndex&&t._fireEvent("change"),t.data.oldIndex=t.data.currentIndex,t._loadNeighborItems(),e.loaded||t._loadItem(e).then(function(){t._initPhoto(),t.update()})},200)}},{key:"gotoSlide",value:function(t){this.e&&this.e.preventDefault&&this.e.preventDefault(),this.data.currentIndex=parseInt(t,10),this.data.currentIndex||(this.data.currentIndex=0),this._slideList()}},{key:"setArrow",value:function(){var t=this.groupItems(),e=t.length,a=this.data.currentIndex+1,o=this.data.currentIndex-1;this.data.showNextArrow=!1,this.data.showPrevArrow=!1,a!==e&&(this.data.next=a,this.data.showNextArrow=!0),-1!==o&&(this.data.prev=o,this.data.showPrevArrow=!0)}},{key:"beforeDrag",value:function(){if(this._isGestured(this.e))return void this.beforeGesture();if(this.isBeingZoomed=!1,this.data.scale)return void this.beforePhotoDrag();var t=this._getTouchPos();this.isSwipable=!0,this.dragStart=!0,this.firstPos=t,this.oldPos=t}},{key:"afterDrag",value:function(){var t=this.groupItems(),e=new Date,a=e.getTime(),o=this.tapSecond-a,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():p.isSmartPhone()||0!==n||0!==i?Math.abs(o)<=500&&0===n&&0===i?(this.e.preventDefault(),void this.zoomPhoto()):(this.tapSecond=a,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,a=t.y-this.firstPos.y;this.dragStart&&(this._fireEvent("swipestart"),this.dragStart=!1,Math.abs(e)>Math.abs(a)?this.moveDir="horizontal":this.moveDir="vertical"),"horizontal"===this.moveDir?(this.pos.x+=e,this.data.translateX=this.pos.x):this.data.translateY=a,this.onListMove=!0,this.oldPos=t,this._listUpdate()}}}},{key:"zoomPhoto",value:function(){var t=this;this.data.hideUi=!0,this.data.scaleSize=this._getScaleBoarder(),this.data.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,a=t.y-this.oldPhotoPos.y,o=this._round(this.data.scaleSize*e,6),n=this._round(this.data.scaleSize*a,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),a=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.photoPosYa&&0!==this.data.currentIndex)return void this.gotoSlide(this.data.prev);if(e.minX-this.data.photoPosX>a&&this.data.currentIndex+1!==this.data.total)return void this.gotoSlide(this.data.next);0===o&&0===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]),a=(e-this.oldDistance)/100,o=this.data.scaleSize,n=this.data.photoPosX,i=this.data.photoPosY;this.isBeingZoomed=!0,this.data.scaleSize+=this._round(a,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(),a=this._getWindowHeight();return p.isSmartPhone()?t.width>t.height?a/(t.height*t.scale):e/(t.width*t.scale):1/t.scale}},{key:"_makeBound",value:function(t){var e,a,o,n,i=t.width*t.scale*this.data.scaleSize,r=t.height*t.scale*this.data.scaleSize,s=this._getWindowWidth(),c=this._getWindowHeight();return s>i?(o=(s-i)/2,e=-1*o):(o=(i-s)/2,e=-1*o),c>r?(n=(c-r)/2,a=-1*n):(n=(r-c)/2,a=-1*n),{minX:this._round(e,6)*this.data.scaleSize,minY:this._round(a,6)*this.data.scaleSize,maxX:this._round(o,6)*this.data.scaleSize,maxY:this._round(n,6)*this.data.scaleSize}}},{key:"_registerElasticForce",value:function(t,e){var a=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(){a.data.elastic=!1,a._photoUpdate()},300)}},{key:"_getSelectedItem",value:function(){var t=this.data,e=t.currentIndex;return t.group[t.currentGroup][e]}},{key:"_getUniqId",value:function(){return(Date.now().toString(36)+Math.random().toString(36).substr(2,5)).toUpperCase()}},{key:"_getDistance",value:function(t,e){var a=t.x-e.x,o=t.y-e.y;return Math.sqrt(a*a+o*o)}},{key:"_round",value:function(t,e){var a=Math.pow(10,e);return t*=a,t=Math.round(t),t/=a}},{key:"_isTouched",value:function(t){return!(!t||!t.touches)}},{key:"_isGestured",value:function(t){return!!(t&&t.touches&&t.touches.length>1)}},{key:"_isSmartPhone",value:function(){var t=navigator.userAgent;return t.indexOf("iPhone")>0||t.indexOf("iPad")>0||t.indexOf("ipod")>0||t.indexOf("Android")>0}},{key:"_calcGravity",value:function(t,e){(t>5||t<-5)&&(this.vx+=.05*t),!1!==this.data.verticalGravity&&(e>5||e<-5)&&(this.vy+=.05*e)}},{key:"_photoUpdate",value:function(){var t=this.data.classNames,e=this._getElementByQuery(".current"),a=e.querySelector(".".concat(t.smartPhotoImg)),o=this._getElementByQuery(".".concat(t.smartPhotoNav)),n=this._getElementByQuery(".".concat(t.smartPhotoArrows)),i=this.virtualPos(this.data.photoPosX),r=this.virtualPos(this.data.photoPosY),s=this.data.scaleSize,c="translate(".concat(i,"px,").concat(r,"px) scale(").concat(s,")");a.style.transform=c,this.data.scale?p.addClass(a,t.smartPhotoImgOnMove):p.removeClass(a,t.smartPhotoImgOnMove),this.data.elastic?p.addClass(a,t.smartPhotoImgElasticMove):p.removeClass(a,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(".".concat(t.smartPhotoList)),a="translate(".concat(this.data.translateX,"px,").concat(this.data.translateY,"px)");e.style.transform=a,this.data.onMoveClass?p.addClass(e,t.smartPhotoListOnMove):p.removeClass(e,t.smartPhotoListOnMove)}},{key:"_fireEvent",value:function(t){var e=this._getElementByClass(this.data.classNames.smartPhoto);p.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 a=this._getForceAndTheta(this.vx,this.vy),o=a.force,n=a.theta;o-=this.data.registance,Math.abs(o)<.5||(this.vx=Math.cos(n)*o,this.vy=Math.sin(n)*o,this._photoUpdate())}}}]),e}(h.default);a.default=y,e.exports=a.default},{"../lib/util":11,"a-template":1,"custom-event-polyfill":3,"es6-promise-polyfill":4}],10:[function(t,e,a){"use strict";e.exports=t("./core/")},{"./core/":9}],11:[function(t,e,a){"use strict";function o(t){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function n(t){t=t||{};for(var e=1;e0||t.indexOf("iPad")>0||t.indexOf("ipod")>0||t.indexOf("Android")>0};a.isSmartPhone=i;var r=n;a.extend=r;var s=function(t,e,a){var o;window.CustomEvent?o=new CustomEvent(e,{cancelable:!0}):(o=document.createEvent("CustomEvent"),o.initCustomEvent(e,!1,!1,a)),t.dispatchEvent(o)};a.triggerEvent=s;var c=function(t){for(var e,a,o,n=t.split("&"),i={},r=0,s=n.length;r0;)t.appendChild(a.children[0])};a.append=l;var h=function(t,e){t.classList?t.classList.add(e):t.className+=" ".concat(e)};a.addClass=h;var f=function(t,e){t.classList?t.classList.remove(e):t.className=t.className.replace(new RegExp("(^|\\b)"+e.split(" ").join("|")+"(\\b|$)","gi")," ")};a.removeClass=f;var p=function(){var t=window.navigator.userAgent.toLowerCase(),e=window.navigator.appVersion.toLowerCase(),a="unknown";return-1!=t.indexOf("msie")?a=-1!=e.indexOf("msie 6.")?"ie6":-1!=e.indexOf("msie 7.")?"ie7":-1!=e.indexOf("msie 8.")?"ie8":-1!=e.indexOf("msie 9.")?"ie9":-1!=e.indexOf("msie 10.")?"ie10":"ie":-1!=t.indexOf("trident/7")?a="ie11":-1!=t.indexOf("chrome")?a="chrome":-1!=t.indexOf("safari")?a="safari":-1!=t.indexOf("opera")?a="opera":-1!=t.indexOf("firefox")&&(a="firefox"),a};a.getBrowser=p;var m=function(){var t=p();return-1!==t.indexOf("ie")&&parseInt(t.replace(/[^0-9]/g,""))<=10};a.isOldIE=m},{}]},{},[10])(10)}); \ No newline at end of file +!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,a,o){function n(r,s){if(!a[r]){if(!e[r]){var c="function"==typeof require&&require;if(!s&&c)return c(r,!0);if(i)return i(r,!0);var d=new Error("Cannot find module '"+r+"'");throw d.code="MODULE_NOT_FOUND",d}var u=a[r]={exports:{}};e[r][0].call(u.exports,function(t){return n(e[r][1][t]||t)},u,u.exports,t,e,a,o)}return a[r].exports}for(var i="function"==typeof require&&require,r=0;r1;)a=a[o.shift()];a[o.shift()]=e}},{key:"removeDataByString",value:function(t){for(var e=this.data,a=t.split(".");a.length>1;)e=e[a.shift()];var o=a.shift();o.match(/^\d+$/)?e.splice(Number(o),1):delete e[o]}},{key:"resolveBlock",value:function(t,e,a){var o=this,n=t.match(//g),i=t.match(//g),r=t.match(//g),s=t.match(//g);if(n)for(var c=0,d=n.length;c/g;return t=t.replace(e,function(t,e){return(0,c.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,a=this;return t=t.replace(e,function(t,e,o){var n=a.getDataByString(e),i=[];i="function"==typeof n?n.apply(a):n;var r="";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 a=this.atemplate.find(function(e){return e.id===t}),o="";if(a&&a.html&&(o=a.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",a=arguments[1],o=this.templates;this.beforeUpdated&&this.beforeUpdated();for(var n=0,i=o.length;n"+u+"");else(0,c.selector)(d).insertAdjacentHTML("afterend",'
    '),"text"===e?(0,c.selector)("[data-id='"+r+"']").innerText=u:(0,c.selector)("[data-id='"+r+"']").innerHTML=u;var p=t.atemplate.find(function(t){return t.id===r});p.binded||(p.binded=!0,t.addDataBind((0,c.selector)("[data-id='"+r+"']")),t.addActionBind((0,c.selector)("[data-id='"+r+"']")))}(n);return this.updateBindingData(a),this.onUpdated&&this.onUpdated(a),this}},{key:"updateBindingData",value:function(t){for(var e=this,a=this.templates,o=0,n=a.length;o1?a-1:0),n=1;n1;)e=e[a.shift()];var o=a.shift();return o.match(/^\d+$/)?e.splice(Number(o),1):delete e[o],this}}]),t}();a.default=h,e.exports=a.default},{"./util":2,"ie-array-find-polyfill":5,morphdom:6}],2:[function(t,e,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var o=a.matches=function(t,e){for(var a=(t.document||t.ownerDocument).querySelectorAll(e),o=a.length;--o>=0&&a.item(o)!==t;);return o>-1},n=(a.selector=function(t){return document.querySelector(t)},a.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}),i=[];a.on=function(t,e,a,o){var r=arguments.length>4&&void 0!==arguments[4]&&arguments[4];a.split(" ").forEach(function(a){var s=function(t){var a=n(t.target,e);a&&(t.delegateTarget=a,o(t))};i.push({listener:s,element:t,query:e,event:a,capture:r}),t.addEventListener(a,s,r)})},a.off=function(t,e,a){a.split(" ").forEach(function(a){i.forEach(function(o,n){o.element===t&&o.query===e&&o.event===a&&(t.removeEventListener(a,o.listener,o.capture),i.splice(n,1))})})}},{}],3:[function(t,e,a){try{var o=new window.CustomEvent("test");if(o.preventDefault(),!0!==o.defaultPrevented)throw new Error("Could not prevent default")}catch(t){var n=function(t,e){var a,o;return e=e||{bubbles:!1,cancelable:!1,detail:void 0},a=document.createEvent("CustomEvent"),a.initCustomEvent(t,e.bubbles,e.cancelable,e.detail),o=a.preventDefault,a.preventDefault=function(){o.call(this);try{Object.defineProperty(this,"defaultPrevented",{get:function(){return!0}})}catch(t){this.defaultPrevented=!0}},a};n.prototype=window.Event.prototype,window.CustomEvent=n}},{}],4:[function(e,a,o){(function(e,a){!function(e){function n(t){return"[object Array]"===Object.prototype.toString.call(t)}function i(){for(var t=0;t>>0;if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var o=arguments[1],n=0;n=0;s--)a=r[s],o=a.name,n=a.namespaceURI,i=a.value,n?(o=a.localName||o,t.getAttributeNS(n,o)!==i&&("xmlns"===a.prefix&&(o=a.name),t.setAttributeNS(n,o,i))):t.getAttribute(o)!==i&&t.setAttribute(o,i);for(var c=t.attributes,d=c.length-1;d>=0;d--)a=c[d],o=a.name,n=a.namespaceURI,n?(o=a.localName||o,e.hasAttributeNS(n,o)||t.removeAttributeNS(n,o)):e.hasAttribute(o)||t.removeAttribute(o)}}function n(t){var e=g.createElement("template");return e.innerHTML=t,e.content.childNodes[0]}function i(t){return p||(p=g.createRange(),p.selectNode(g.body)),p.createContextualFragment(t).childNodes[0]}function r(t){var e=g.createElement("body");return e.innerHTML=t,e.childNodes[0]}function s(t){return t=t.trim(),y?n(t):x?i(t):r(t)}function c(t,e){var a=t.nodeName,o=e.nodeName;return a===o||!!(e.actualize&&a.charCodeAt(0)<91&&o.charCodeAt(0)>90)&&a===o.toUpperCase()}function d(t,e){return e&&e!==v?g.createElementNS(e,t):g.createElement(t)}function u(t,e){for(var a=t.firstChild;a;){var o=a.nextSibling;e.appendChild(a),a=o}return e}function l(t,e,a){t[a]!==e[a]&&(t[a]=e[a],t[a]?t.setAttribute(a,""):t.removeAttribute(a))}function h(){}function f(t){if(t)return t.getAttribute&&t.getAttribute("id")||t.id}var p,m=11,v="http://www.w3.org/1999/xhtml",g="undefined"==typeof document?void 0:document,y=!!g&&"content"in g.createElement("template"),x=!!g&&g.createRange&&"createContextualFragment"in g.createRange(),w={OPTION:function(t,e){var a=t.parentNode;if(a){var o=a.nodeName.toUpperCase();"OPTGROUP"===o&&(a=a.parentNode,o=a&&a.nodeName.toUpperCase()),"SELECT"!==o||a.hasAttribute("multiple")||(t.hasAttribute("selected")&&!e.selected&&(t.setAttribute("selected","selected"),t.removeAttribute("selected")),a.selectedIndex=-1)}l(t,e,"selected")},INPUT:function(t,e){l(t,e,"checked"),l(t,e,"disabled"),t.value!==e.value&&(t.value=e.value),e.hasAttribute("value")||t.removeAttribute("value")},TEXTAREA:function(t,e){var a=e.value;t.value!==a&&(t.value=a);var o=t.firstChild;if(o){var n=o.nodeValue;if(n==a||!a&&n==t.placeholder)return;o.nodeValue=a}},SELECT:function(t,e){if(!e.hasAttribute("multiple")){for(var a,o,n=-1,i=0,r=t.firstChild;r;)if("OPTGROUP"===(o=r.nodeName&&r.nodeName.toUpperCase()))a=r,r=a.firstChild;else{if("OPTION"===o){if(r.hasAttribute("selected")){n=i;break}i++}r=r.nextSibling,!r&&a&&(r=a.nextSibling,a=null)}t.selectedIndex=n}}},P=1,E=11,b=3,_=8,I=function(t){return function(e,a,o){function n(t){G.push(t)}function i(t,e){if(t.nodeType===P)for(var a=t.firstChild;a;){var o=void 0;e&&(o=I(a))?n(o):(T(a),a.firstChild&&i(a,e)),a=a.nextSibling}}function r(t,e,a){!1!==B(t)&&(e&&e.removeChild(t),T(t),i(t,a))}function l(t){if(t.nodeType===P||t.nodeType===E)for(var e=t.firstChild;e;){var a=I(e);a&&(C[a]=e),l(e),e=e.nextSibling}}function p(t){S(t);for(var e=t.firstChild;e;){var a=e.nextSibling,o=I(e);if(o){var n=C[o];n&&c(e,n)&&(e.parentNode.replaceChild(n,e),v(n,e))}p(e),e=a}}function m(t,e,a){for(;e;){var o=e.nextSibling;(a=I(e))?n(a):r(e,t,!0),e=o}}function v(e,a,o){var n=I(a);if(n&&delete C[n],!o){if(!1===k(e,a))return;if(t(e,a),A(e),!1===D(e,a))return}"TEXTAREA"!==e.nodeName?y(e,a):w.TEXTAREA(e,a)}function y(t,e){var a,o,i,s,d,u=e.firstChild,l=t.firstChild;t:for(;u;){for(s=u.nextSibling,a=I(u);l;){if(i=l.nextSibling,u.isSameNode&&u.isSameNode(l)){u=s,l=i;continue t}o=I(l);var h=l.nodeType,f=void 0;if(h===u.nodeType&&(h===P?(a?a!==o&&((d=C[a])?i===d?f=!1:(t.insertBefore(d,l),o?n(o):r(l,t,!0),l=d):f=!1):o&&(f=!1),(f=!1!==f&&c(l,u))&&v(l,u)):h!==b&&h!=_||(f=!0,l.nodeValue!==u.nodeValue&&(l.nodeValue=u.nodeValue))),f){u=s,l=i;continue t}o?n(o):r(l,t,!0),l=i}if(a&&(d=C[a])&&c(d,u))t.appendChild(d),v(d,u);else{var y=N(u);!1!==y&&(y&&(u=y),u.actualize&&(u=u.actualize(t.ownerDocument||g)),t.appendChild(u),p(u))}u=s,l=i}m(t,l,o);var x=w[t.nodeName];x&&x(t,e)}if(o||(o={}),"string"==typeof a)if("#document"===e.nodeName||"HTML"===e.nodeName){var x=a;a=g.createElement("html"),a.innerHTML=x}else a=s(a);var I=o.getNodeKey||f,N=o.onBeforeNodeAdded||h,S=o.onNodeAdded||h,k=o.onBeforeElUpdated||h,A=o.onElUpdated||h,B=o.onBeforeNodeDiscarded||h,T=o.onNodeDiscarded||h,D=o.onBeforeElChildrenUpdated||h,O=!0===o.childrenOnly,C=Object.create(null),G=[];l(e);var L=e,z=L.nodeType,X=a.nodeType;if(!O)if(z===P)X===P?c(e,a)||(T(e),L=u(e,d(a.nodeName,a.namespaceURI))):L=a;else if(z===b||z===_){if(X===z)return L.nodeValue!==a.nodeValue&&(L.nodeValue=a.nodeValue),L;L=a}if(L===a)T(e);else{if(a.isSameNode&&a.isSameNode(L))return;if(v(L,a,O),G)for(var M=0,Y=G.length;M1)for(var a=1;a=0&&(t._idleTimeoutId=setTimeout(function(){t._onTimeout&&t._onTimeout()},e))},a.setImmediate="function"==typeof e?e:function(t){var e=d++,o=!(arguments.length<2)&&s.call(arguments,1);return c[e]=!0,i(function(){c[e]&&(o?t.apply(null,o):t.call(null),a.clearImmediate(e))}),e},a.clearImmediate="function"==typeof o?o:function(t){delete c[t]}}).call(this,t("timers").setImmediate,t("timers").clearImmediate)},{"process/browser.js":7,timers:8}],9:[function(t,e,a){"use strict";function o(t){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){for(var a=0;ago to {caption}\n\t\t\t\t\t\x3c!-- END groupItems:loop --\x3e\n\t\t\t\t\n\t\t\t\n\t\t\t\x3c!-- END nav:exist --\x3e\n\n\t\t\t\n\t\t\t\t\\{message.closeDialog\\}\n\t\t\t\n\t\t\n\t\t\x3c!-- BEGIN appearEffect:exist --\x3e\n\t\t\n\t\t\x3c!-- END appearEffect:exist --\x3e\n\t\n\n',p=t("../lib/util"),m=t("es6-promise-polyfill"),v=m.Promise,g={classNames:{smartPhoto:"smartphoto",smartPhotoClose:"smartphoto-close",smartPhotoBody:"smartphoto-body",smartPhotoInner:"smartphoto-inner",smartPhotoContent:"smartphoto-content",smartPhotoImg:"smartphoto-img",smartPhotoImgOnMove:"smartphoto-img-onmove",smartPhotoImgElasticMove:"smartphoto-img-elasticmove",smartPhotoImgWrap:"smartphoto-img-wrap",smartPhotoArrows:"smartphoto-arrows",smartPhotoNav:"smartphoto-nav",smartPhotoArrowRight:"smartphoto-arrow-right",smartPhotoArrowLeft:"smartphoto-arrow-left",smartPhotoArrowHideIcon:"smartphoto-arrow-hide",smartPhotoImgLeft:"smartphoto-img-left",smartPhotoImgRight:"smartphoto-img-right",smartPhotoList:"smartphoto-list",smartPhotoListOnMove:"smartphoto-list-onmove",smartPhotoHeader:"smartphoto-header",smartPhotoCount:"smartphoto-count",smartPhotoCaption:"smartphoto-caption",smartPhotoDismiss:"smartphoto-dismiss",smartPhotoLoader:"smartphoto-loader",smartPhotoLoaderWrap:"smartphoto-loader-wrap",smartPhotoImgClone:"smartphoto-img-clone"},message:{gotoNextImage:"go to the next image",gotoPrevImage:"go to the previous image",closeDialog:"close the image dialog"},arrows:!0,nav:!0,showAnimation:!0,verticalGravity:!1,useOrientationApi:!1,useHistoryApi:!0,swipeTopToClose:!1,swipeBottomToClose:!0,swipeOffset:100,headerHeight:60,footerHeight:60,forceInterval:10,registance:.5,loadOffset:2,resizeStyle:"fit",lazyAttribute:"data-src"},y=function(t){function e(t,a){var o;n(this,e),o=s(this,d(e).call(this)),o.data=p.extend({},g,a),o.data.currentIndex=0,o.data.oldIndex=0,o.data.hide=!0,o.data.group={},o.data.scaleSize=1,o.data.scale=!1,o.pos={x:0,y:0},o.data.photoPosX=0,o.data.photoPosY=0,o.handlers=[],o.convert={increment:o.increment,virtualPos:o.virtualPos,round:o.round},o.data.groupItems=o.groupItems,o.elements="string"==typeof t?document.querySelectorAll(t):t;var i=new Date;o.tapSecond=i.getTime(),o.onListMove=!1,o.clicked=!1,o.id=o._getUniqId(),o.vx=0,o.vy=0,o.data.appearEffect=null,o.addTemplate(o.id,f),o.data.isSmartPhone=o._isSmartPhone();var r=document.querySelector("body");p.append(r,"
    ")),[].forEach.call(o.elements,function(t){o.addNewItem(t)}),o.update();var c=o._getCurrentItemByHash() +;if(c&&p.triggerEvent(c.element,"click"),o.interval=setInterval(function(){o._doAnim()},o.data.forceInterval),!o.data.isSmartPhone){var u=function(){o.groupItems()&&(o._resetTranslate(),o._setPosByCurrentIndex(),o._setSizeByScreen(),o.update())},l=function(t){var e=t.keyCode||t.which;!0!==o.data.hide&&(37===e?o.gotoSlide(o.data.prev):39===e?o.gotoSlide(o.data.next):27===e&&o.hidePhoto())};return window.addEventListener("resize",u),window.addEventListener("keydown",l),o._registerRemoveEvent(window,"resize",u),o._registerRemoveEvent(window,"keydown",l),s(o)}var h=function(){if(o.groupItems()){o._resetTranslate(),o._setPosByCurrentIndex(),o._setHashByCurrentIndex(),o._setSizeByScreen(),o.update();var t=o._getWindowWidth();!function e(a){new v(function(t){setTimeout(function(){t()},25)}).then(function(){t!==o._getWindowWidth()?(o._resetTranslate(),o._setPosByCurrentIndex(),o._setHashByCurrentIndex(),o._setSizeByScreen(),o.update()):a<=500&&e(a+25)})}(0)}};if(window.addEventListener("orientationchange",h),o._registerRemoveEvent(window,"orientationchange",h),!o.data.useOrientationApi)return s(o);var m=function(t){var e=window,a=e.orientation;t&&t.gamma&&!o.data.appearEffect&&(o.isBeingZoomed||o.photoSwipable||o.data.elastic||!o.data.scale||(0===a?o._calcGravity(t.gamma,t.beta):90===a?o._calcGravity(t.beta,t.gamma):-90===a?o._calcGravity(-t.beta,-t.gamma):180===a&&o._calcGravity(-t.gamma,-t.beta)))};return window.addEventListener("deviceorientation",m),o._registerRemoveEvent(window,"deviceorientation",m),o}return u(e,t),r(e,[{key:"on",value:function(t,e){var a=this._getElementByClass(this.data.classNames.smartPhoto),o=function(t){e.call(a,t)};a.addEventListener(t,o),this._registerRemoveEvent(a,t,o)}},{key:"_registerRemoveEvent",value:function(t,e,a){this.handlers.push({target:t,event:e,handler:a})}},{key:"destroy",value:function(){this.handlers.forEach(function(t){t.target.removeEventListener(t.event,t.handler)});var t=document.querySelector('[data-id="'.concat(this.id,'"]'));p.removeElement(t),clearInterval(this.interval),this.removeTemplateEvents()}},{key:"increment",value:function(t){return t+1}},{key:"round",value:function(t){return Math.round(t)}},{key:"virtualPos",value:function(t){return(t=parseInt(t,10))/this._getSelectedItem().scale/this.data.scaleSize}},{key:"groupItems",value:function(){return this.data.group[this.data.currentGroup]}},{key:"_resetTranslate",value:function(){var t=this;this.groupItems().forEach(function(e,a){e.translateX=t._getWindowWidth()*a})}},{key:"addNewItem",value:function(t){var e=this,a=t.getAttribute("data-group")||"nogroup",o=this.data.group;"nogroup"===a&&t.setAttribute("data-group","nogroup"),o[a]||(o[a]=[]);var n=o[a].length,i=document.querySelector("body"),r=t.getAttribute("href"),s=t.querySelector("img"),c=r;s&&(c=s.getAttribute(this.data.lazyAttribute)?s.getAttribute(this.data.lazyAttribute):s.currentSrc?s.currentSrc:s.src);var d={src:r,thumb:c,caption:t.getAttribute("data-caption"),groupId:a,translateX:this._getWindowWidth()*n,index:n,translateY:0,width:50,height:50,id:t.getAttribute("data-id")||n,loaded:!1,processed:!1,element:t};o[a].push(d),this.data.currentGroup=a,t.getAttribute("data-id")||t.setAttribute("data-id",n),t.setAttribute("data-index",n);var u=function(a){a.preventDefault(),e.data.currentGroup=t.getAttribute("data-group"),e.data.currentIndex=parseInt(t.getAttribute("data-index"),10),e._setHashByCurrentIndex();var o=e._getSelectedItem(),n=function(t){if(9===t.keyCode){var a=document.querySelector(".".concat(e.data.classNames.smartPhoto)),o=document.querySelector(".".concat(e.data.classNames.smartPhotoArrows)),n=document.querySelector(".".concat(e.data.classNames.smartPhotoDismiss)),i=document.activeElement;i===a?o.focus():i===n&&a.focus()}};if(o.loaded){e._initPhoto(),e.addAppearEffect(t,o),e.clicked=!0,e.update(),i.style.overflow="hidden",e._fireEvent("open");document.querySelector(".".concat(e.data.classNames.smartPhoto)).focus(),document.addEventListener("keydown",n),e._registerRemoveEvent(window,"keydown",n)}else e._loadItem(o).then(function(){e._initPhoto(),e.addAppearEffect(t,o),e.clicked=!0,e.update(),i.style.overflow="hidden",e._fireEvent("open"),document.querySelector(".".concat(e.data.classNames.smartPhoto)).focus(),document.addEventListener("keydown",n),e._registerRemoveEvent(window,"keydown",n)})};t.addEventListener("click",u),this._registerRemoveEvent(t,"click",u)}},{key:"_initPhoto",value:function(){this.data.total=this.groupItems().length,this.data.hide=!1,this.data.photoPosX=0,this.data.photoPosY=0,this._setPosByCurrentIndex(),this._setSizeByScreen(),this.setArrow(),"fill"===this.data.resizeStyle&&this.data.isSmartPhone&&(this.data.scale=!0,this.data.hideUi=!0,this.data.scaleSize=this._getScaleBoarder())}},{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 v(function(e){p.isOldIE()&&e();var a=t.data,o=a.appearEffect,n=a.classNames,i=t._getElementByClass(n.smartPhotoImgClone),r=function t(){i.removeEventListener("transitionend",t,!0),e()};i.addEventListener("transitionend",r,!0),setTimeout(function(){i.style.transform="translate(".concat(o.afterX,"px, ").concat(o.afterY,"px) scale(").concat(o.scale,")")},10)})}},{key:"addAppearEffect",value:function(t,e){if(!1===this.data.showAnimation)return void(this.data.appear=!0);var a=t.querySelector("img"),o=p.getViewPos(a),n={},i=1;n.width=a.offsetWidth,n.height=a.offsetHeight,n.top=o.top,n.left=o.left,n.once=!0,a.getAttribute(this.data.lazyAttribute)?n.img=a.getAttribute(this.data.lazyAttribute):n.img=e.src;var r=this._getWindowWidth(),s=this._getWindowHeight(),c=s-this.data.headerHeight-this.data.footerHeight;"fill"===this.data.resizeStyle&&this.data.isSmartPhone?i=a.offsetWidth>a.offsetHeight?s/a.offsetHeight:r/a.offsetWidth:(n.width>=n.height?i=e.heightn.width&&(i=e.heightr&&(i=r/n.width));var d=(i-1)/2*a.offsetWidth+(r-a.offsetWidth*i)/2,u=(i-1)/2*a.offsetHeight+(s-a.offsetHeight*i)/2;n.afterX=d,n.afterY=u,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 a=void 0!==window.pageXOffset?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft,o=void 0!==window.pageYOffset?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop,n=document.querySelector("body");window.location.hash&&this._setHash(""),window.scroll(a,o),this._doHideEffect(e).then(function(){t.update(),n.style.overflow="",t._fireEvent("close")})}},{key:"_doHideEffect",value:function(t){var e=this;return new v(function(a){p.isOldIE()&&a();var o=e.data.classNames,n=e._getElementByClass(o.smartPhoto),i=e._getElementByQuery(".current .".concat(o.smartPhotoImg)),r=e._getWindowHeight(),s=function t(){n.removeEventListener("transitionend",t,!0),a()};n.style.opacity=0,"bottom"===t?i.style.transform="translateY(".concat(r,"px)"):"top"===t&&(i.style.transform="translateY(-".concat(r,"px)")),n.addEventListener("transitionend",s,!0)})}},{key:"_getElementByClass",value:function(t){return document.querySelector('[data-id="'.concat(this.id,'"] .').concat(t))}},{key:"_getElementByQuery",value:function(t){return document.querySelector('[data-id="'.concat(this.id,'"] ').concat(t))}},{key:"_getTouchPos",value:function(){var t=0,e=0,a="undefined"==typeof event?this.e:event;return this._isTouched(a)?(t=a.touches[0].pageX,e=a.touches[0].pageY):a.pageX&&(t=a.pageX,e=a.pageY),{x:t,y:e}}},{key:"_getGesturePos",value:function(t){var e=t.touches;return[{x:e[0].pageX,y:e[0].pageY},{x:e[1].pageX,y:e[1].pageY}]}},{key:"_setPosByCurrentIndex",value:function(){var t=this,e=this.groupItems(),a=-1*e[this.data.currentIndex].translateX;this.pos.x=a,setTimeout(function(){t.data.translateX=a,t.data.translateY=0,t._listUpdate()},1)}},{key:"_setHashByCurrentIndex",value:function(){var t=void 0!==window.pageXOffset?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft,e=void 0!==window.pageYOffset?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop,a=this.groupItems(),o=a[this.data.currentIndex].id,n=this.data.currentGroup,i="group=".concat(n,"&photo=").concat(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,"".concat(location.pathname).concat(location.search,"#").concat(t)):window.history.replaceState(null,null,"".concat(location.pathname).concat(location.search)))}},{key:"_getCurrentItemByHash",value:function(){var t=this.data.group,e=location.hash.substr(1),a=p.parseQuery(e),o=null,n=function(t){a.group===t.groupId&&a.photo===t.id&&(o=t)};return Object.keys(t).forEach(function(e){t[e].forEach(n)}),o}},{key:"_loadItem",value:function(t){return new v(function(e){var a=new Image;a.onload=function(){t.width=a.width,t.height=a.height,t.loaded=!0,e()},a.onerror=function(){e()},a.src=t.src})}},{key:"_getItemByIndex",value:function(t){var e=this.data;return e.group[e.currentGroup][t]?e.group[e.currentGroup][t]:null}},{key:"_loadNeighborItems",value:function(){for(var t=this,e=this.data.currentIndex,a=this.data.loadOffset,o=e-a,n=e+a,i=[],r=o;rt&&(a.scale=t/a.width,a.x=(a.scale-1)/2*a.width))})}},{key:"_slideList",value:function(){var t=this;this.data.scaleSize=1,this.isBeingZoomed=!1,this.data.hideUi=!1,this.data.scale=!1,this.data.photoPosX=0,this.data.photoPosY=0,this.data.onMoveClass=!0,this._setPosByCurrentIndex(),this._setHashByCurrentIndex(),this._setSizeByScreen(),setTimeout(function(){var e=t._getSelectedItem();t.data.onMoveClass=!1,t.setArrow(),t.update(),t.data.oldIndex!==t.data.currentIndex&&t._fireEvent("change"),t.data.oldIndex=t.data.currentIndex,t._loadNeighborItems(),e.loaded||t._loadItem(e).then(function(){t._initPhoto(),t.update()})},200)}},{key:"gotoSlide",value:function(t){this.e&&this.e.preventDefault&&this.e.preventDefault(),this.data.currentIndex=parseInt(t,10),this.data.currentIndex||(this.data.currentIndex=0),this._slideList()}},{key:"setArrow",value:function(){var t=this.groupItems(),e=t.length,a=this.data.currentIndex+1,o=this.data.currentIndex-1;this.data.showNextArrow=!1,this.data.showPrevArrow=!1,a!==e&&(this.data.next=a,this.data.showNextArrow=!0),-1!==o&&(this.data.prev=o,this.data.showPrevArrow=!0)}},{key:"beforeDrag",value:function(){if(this._isGestured(this.e))return void this.beforeGesture();if(this.isBeingZoomed=!1,this.data.scale)return void this.beforePhotoDrag();var t=this._getTouchPos();this.isSwipable=!0,this.dragStart=!0,this.firstPos=t,this.oldPos=t}},{key:"afterDrag",value:function(){var t=this.groupItems(),e=new Date,a=e.getTime(),o=this.tapSecond-a,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():p.isSmartPhone()||0!==n||0!==i?Math.abs(o)<=500&&0===n&&0===i?(this.e.preventDefault(),void this.zoomPhoto()):(this.tapSecond=a,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,a=t.y-this.firstPos.y;this.dragStart&&(this._fireEvent("swipestart"),this.dragStart=!1,Math.abs(e)>Math.abs(a)?this.moveDir="horizontal":this.moveDir="vertical"),"horizontal"===this.moveDir?(this.pos.x+=e,this.data.translateX=this.pos.x):this.data.translateY=a,this.onListMove=!0,this.oldPos=t,this._listUpdate()}}}},{key:"zoomPhoto",value:function(){var t=this;this.data.hideUi=!0,this.data.scaleSize=this._getScaleBoarder(),this.data.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,a=t.y-this.oldPhotoPos.y,o=this._round(this.data.scaleSize*e,6),n=this._round(this.data.scaleSize*a,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),a=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.photoPosYa&&0!==this.data.currentIndex)return void this.gotoSlide(this.data.prev);if(e.minX-this.data.photoPosX>a&&this.data.currentIndex+1!==this.data.total)return void this.gotoSlide(this.data.next);0===o&&0===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]),a=(e-this.oldDistance)/100,o=this.data.scaleSize,n=this.data.photoPosX,i=this.data.photoPosY;this.isBeingZoomed=!0,this.data.scaleSize+=this._round(a,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(),a=this._getWindowHeight();return p.isSmartPhone()?t.width>t.height?a/(t.height*t.scale):e/(t.width*t.scale):1/t.scale}},{key:"_makeBound",value:function(t){var e,a,o,n,i=t.width*t.scale*this.data.scaleSize,r=t.height*t.scale*this.data.scaleSize,s=this._getWindowWidth(),c=this._getWindowHeight();return s>i?(o=(s-i)/2,e=-1*o):(o=(i-s)/2,e=-1*o),c>r?(n=(c-r)/2,a=-1*n):(n=(r-c)/2,a=-1*n),{minX:this._round(e,6)*this.data.scaleSize,minY:this._round(a,6)*this.data.scaleSize,maxX:this._round(o,6)*this.data.scaleSize,maxY:this._round(n,6)*this.data.scaleSize}}},{key:"_registerElasticForce",value:function(t,e){var a=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(){a.data.elastic=!1,a._photoUpdate()},300)}},{key:"_getSelectedItem",value:function(){var t=this.data,e=t.currentIndex;return t.group[t.currentGroup][e]}},{key:"_getUniqId",value:function(){return(Date.now().toString(36)+Math.random().toString(36).substr(2,5)).toUpperCase()}},{key:"_getDistance",value:function(t,e){var a=t.x-e.x,o=t.y-e.y;return Math.sqrt(a*a+o*o)}},{key:"_round",value:function(t,e){var a=Math.pow(10,e);return t*=a,t=Math.round(t),t/=a}},{key:"_isTouched",value:function(t){return!(!t||!t.touches)}},{key:"_isGestured",value:function(t){return!!(t&&t.touches&&t.touches.length>1)}},{key:"_isSmartPhone",value:function(){var t=navigator.userAgent;return t.indexOf("iPhone")>0||t.indexOf("iPad")>0||t.indexOf("ipod")>0||t.indexOf("Android")>0}},{key:"_calcGravity",value:function(t,e){(t>5||t<-5)&&(this.vx+=.05*t),!1!==this.data.verticalGravity&&(e>5||e<-5)&&(this.vy+=.05*e)}},{key:"_photoUpdate",value:function(){var t=this.data.classNames,e=this._getElementByQuery(".current"),a=e.querySelector(".".concat(t.smartPhotoImg)),o=this._getElementByQuery(".".concat(t.smartPhotoNav)),n=this._getElementByQuery(".".concat(t.smartPhotoArrows)),i=this.virtualPos(this.data.photoPosX),r=this.virtualPos(this.data.photoPosY),s=this.data.scaleSize,c="translate(".concat(i,"px,").concat(r,"px) scale(").concat(s,")");a.style.transform=c,this.data.scale?p.addClass(a,t.smartPhotoImgOnMove):p.removeClass(a,t.smartPhotoImgOnMove),this.data.elastic?p.addClass(a,t.smartPhotoImgElasticMove):p.removeClass(a,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(".".concat(t.smartPhotoList)),a="translate(".concat(this.data.translateX,"px,").concat(this.data.translateY,"px)");e.style.transform=a,this.data.onMoveClass?p.addClass(e,t.smartPhotoListOnMove):p.removeClass(e,t.smartPhotoListOnMove)}},{key:"_fireEvent",value:function(t){var e=this._getElementByClass(this.data.classNames.smartPhoto);p.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 a=this._getForceAndTheta(this.vx,this.vy),o=a.force,n=a.theta;o-=this.data.registance,Math.abs(o)<.5||(this.vx=Math.cos(n)*o,this.vy=Math.sin(n)*o,this._photoUpdate())}}}]),e}(h.default);a.default=y,e.exports=a.default},{"../lib/util":11,"a-template":1,"custom-event-polyfill":3,"es6-promise-polyfill":4}],10:[function(t,e,a){"use strict";e.exports=t("./core/")},{"./core/":9}],11:[function(t,e,a){"use strict";function o(t){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function n(t){t=t||{};for(var e=1;e0||t.indexOf("iPad")>0||t.indexOf("ipod")>0||t.indexOf("Android")>0};a.isSmartPhone=i;var r=n;a.extend=r;var s=function(t,e,a){var o;window.CustomEvent?o=new CustomEvent(e,{cancelable:!0}):(o=document.createEvent("CustomEvent"),o.initCustomEvent(e,!1,!1,a)),t.dispatchEvent(o)};a.triggerEvent=s;var c=function(t){for(var e,a,o,n=t.split("&"),i={},r=0,s=n.length;r0;)t.appendChild(a.children[0])};a.append=l;var h=function(t,e){t.classList?t.classList.add(e):t.className+=" ".concat(e)};a.addClass=h;var f=function(t,e){t.classList?t.classList.remove(e):t.className=t.className.replace(new RegExp("(^|\\b)"+e.split(" ").join("|")+"(\\b|$)","gi")," ")};a.removeClass=f;var p=function(){var t=window.navigator.userAgent.toLowerCase(),e=window.navigator.appVersion.toLowerCase(),a="unknown";return-1!=t.indexOf("msie")?a=-1!=e.indexOf("msie 6.")?"ie6":-1!=e.indexOf("msie 7.")?"ie7":-1!=e.indexOf("msie 8.")?"ie8":-1!=e.indexOf("msie 9.")?"ie9":-1!=e.indexOf("msie 10.")?"ie10":"ie":-1!=t.indexOf("trident/7")?a="ie11":-1!=t.indexOf("chrome")?a="chrome":-1!=t.indexOf("safari")?a="safari":-1!=t.indexOf("opera")?a="opera":-1!=t.indexOf("firefox")&&(a="firefox"),a};a.getBrowser=p;var m=function(){var t=p();return-1!==t.indexOf("ie")&&parseInt(t.replace(/[^0-9]/g,""))<=10};a.isOldIE=m},{}]},{},[10])(10)}); \ No newline at end of file diff --git a/lib/core/index.js b/lib/core/index.js index da23a89..07602cf 100644 --- a/lib/core/index.js +++ b/lib/core/index.js @@ -29,7 +29,7 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function" function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } -var template = "
    aria-hidden=\"true\" aria-hidden=\"false\" role=\"dialog\">\n\t
    \n\t\t
    \n\t\t\t
    \n\t\t\t\t\t{currentIndex}[increment]/{total}\n\t\t\t\t\t{caption}\n\t\t\t\t\t\n\t\t\t\t
    \n\t\t\t\t
    data-action-touchstart=\"beforeDrag\" data-action-touchmove=\"onDrag\" data-action-touchend=\"afterDrag(false)\" data-action-click=\"hidePhoto()\">\n\t\t\t\t
    \n\t\t\t\t
      \\{classNames.smartPhotoListOnMove\\}\">\n\t\t\t\t\t\n\t\t\t\t\t
    • current\">\n\t\t\t\t\t\t\n\t\t\t\t\t\t
      data-action-mousemove=\"onDrag\" data-action-mousedown=\"beforeDrag\" data-action-mouseup=\"afterDrag\" data-action-touchstart=\"beforeDrag\" data-action-touchmove=\"onDrag\" data-action-touchend=\"afterDrag\">\n\t\t\t\t\t\t\ttransform:translate(\\{photoPosX\\}[virtualPos]px,\\{photoPosY\\}[virtualPos]px) scale(\\{scaleSize\\});width:{width}px;\" src=\"{src}\" class=\"\\\\{classNames.smartPhotoImg\\\\} \\\\{classNames.smartPhotoImgOnMove\\\\} \\\\{classNames.smartPhotoImgElasticMove\\\\} active\" ondragstart=\"return false;\">\n\t\t\t\t\t\t
      \n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t
      \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
      \n\t\t\t\t\t\t\n\t\t\t\t\t
    • \n\t\t\t\t\t\n\t\t\t\t
    \n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t
    \n\t\t\n\t\t\n\t\t\n\t
    \n
    \n"; +var template = "
    aria-hidden=\"true\" aria-hidden=\"false\" role=\"dialog\" tabindex=\"-1\">\n\t
    \n\t\t
    \n\t\t\t
    \n\t\t\t\t{currentIndex}[increment]/{total}\n\t\t\t\t{caption}\n\t\t\t
    \n\n\t\t\t
    data-action-touchstart=\"beforeDrag\" data-action-touchmove=\"onDrag\" data-action-touchend=\"afterDrag(false)\" data-action-click=\"hidePhoto()\">\n\t\t\t
    \n\n\t\t\t
      \\{classNames.smartPhotoListOnMove\\}\">\n\t\t\t\t\n\t\t\t\t
    • current\">\n\t\t\t\t\t\n\t\t\t\t\t
      data-action-mousemove=\"onDrag\" data-action-mousedown=\"beforeDrag\" data-action-mouseup=\"afterDrag\" data-action-touchstart=\"beforeDrag\" data-action-touchmove=\"onDrag\" data-action-touchend=\"afterDrag\">\n\t\t\t\t\t\ttransform:translate(\\{photoPosX\\}[virtualPos]px,\\{photoPosY\\}[virtualPos]px) scale(\\{scaleSize\\});width:{width}px;\" src=\"{src}\" class=\"\\\\{classNames.smartPhotoImg\\\\} \\\\{classNames.smartPhotoImgOnMove\\\\} \\\\{classNames.smartPhotoImgElasticMove\\\\} active\" ondragstart=\"return false;\">\n\t\t\t\t\t
      \n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t
      \n\t\t\t\t\t\t\n\t\t\t\t\t
      \n\t\t\t\t\t\n\t\t\t\t
    • \n\t\t\t\t\n\t\t\t
    \n\n\t\t\t\n\t\t\t aria-hidden=\"true\"\n\t\t\t\t aria-hidden=\"false\"\n\t\t\t\ttabindex=\"-1\">\n\t\t\t\t
  • \\{classNames.smartPhotoArrowHideIcon\\}\" aria-hidden=\"true\">\\{message.gotoPrevImage\\}
  • \n\t\t\t\t
  • \\{classNames.smartPhotoArrowHideIcon\\}\" aria-hidden=\"true\">\\{message.gotoNextImage\\}
  • \n\t\t\t\n\t\t\t\n\n\t\t\t\n\t\t\taria-hidden=\"true\"\n\t\t\t\t aria-hidden=\"false\">\n\t\t\t\t\n\t\t\t\n\t\t\t\n\n\t\t\t\n\t\t\t\t\\{message.closeDialog\\}\n\t\t\t\n\t\t
    \n\t\t\n\t\t\n\t\t\n\t
    \n
    \n"; var util = require('../lib/util'); @@ -411,6 +411,21 @@ function (_ATemplate) { var currentItem = _this3._getSelectedItem(); + var onFocus = function onFocus(e) { + if (e.keyCode === 9) { + var smartPhoto = document.querySelector(".".concat(_this3.data.classNames.smartPhoto)); + var arrows = document.querySelector(".".concat(_this3.data.classNames.smartPhotoArrows)); + var dismiss = document.querySelector(".".concat(_this3.data.classNames.smartPhotoDismiss)); + var curFocus = document.activeElement; + + if (curFocus === smartPhoto) { + arrows.focus(); + } else if (curFocus === dismiss) { + smartPhoto.focus(); + } + } + }; + if (currentItem.loaded) { _this3._initPhoto(); @@ -423,6 +438,12 @@ function (_ATemplate) { body.style.overflow = 'hidden'; _this3._fireEvent('open'); + + var smartPhoto = document.querySelector(".".concat(_this3.data.classNames.smartPhoto)); + smartPhoto.focus(); + document.addEventListener('keydown', onFocus); + + _this3._registerRemoveEvent(window, 'keydown', onFocus); } else { _this3._loadItem(currentItem).then(function () { _this3._initPhoto(); @@ -436,6 +457,12 @@ function (_ATemplate) { body.style.overflow = 'hidden'; _this3._fireEvent('open'); + + var smartPhoto = document.querySelector(".".concat(_this3.data.classNames.smartPhoto)); + smartPhoto.focus(); + document.addEventListener('keydown', onFocus); + + _this3._registerRemoveEvent(window, 'keydown', onFocus); }); } }; diff --git a/scss/smartphoto.scss b/scss/smartphoto.scss index 7d76a0f..8550bb7 100644 --- a/scss/smartphoto.scss +++ b/scss/smartphoto.scss @@ -156,6 +156,7 @@ $header-color: rgba(0, 0, 0, .2) !default; text-decoration: none; cursor: pointer; line-height: 1; + z-index: 1; } diff --git a/src/core/index.js b/src/core/index.js index e79594a..eef45f0 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -1,7 +1,7 @@ import ATemplate from 'a-template'; import 'custom-event-polyfill'; -import template from './viwer.html'; +import template from './viewer.html'; const util = require('../lib/util'); const { Promise } = require('es6-promise-polyfill'); @@ -32,7 +32,7 @@ const defaults = { smartPhotoDismiss: 'smartphoto-dismiss', smartPhotoLoader: 'smartphoto-loader', smartPhotoLoaderWrap: 'smartphoto-loader-wrap', - smartPhotoImgClone: 'smartphoto-img-clone' + smartPhotoImgClone: 'smartphoto-img-clone', }, message: { gotoNextImage: 'go to the next image', @@ -103,7 +103,6 @@ export default class SmartPhoto extends ATemplate { this.interval = setInterval(() => { this._doAnim(); }, this.data.forceInterval); - if (!this.data.isSmartPhone) { const resizeHandler = () => { if (!this.groupItems()) { @@ -306,6 +305,21 @@ export default class SmartPhoto extends ATemplate { this.data.currentIndex = parseInt(element.getAttribute('data-index'), 10); this._setHashByCurrentIndex(); const currentItem = this._getSelectedItem(); + + const onFocus = (e) => { + if(e.keyCode === 9) { + const smartPhoto = document.querySelector(`.${this.data.classNames.smartPhoto}`); + const arrows = document.querySelector(`.${this.data.classNames.smartPhotoArrows}`); + const dismiss = document.querySelector(`.${this.data.classNames.smartPhotoDismiss}`); + const curFocus = document.activeElement; + if (curFocus === smartPhoto) { + arrows.focus() + } else if (curFocus === dismiss) { + smartPhoto.focus() + } + } + } + if (currentItem.loaded) { this._initPhoto(); this.addAppearEffect(element, currentItem); @@ -313,6 +327,11 @@ export default class SmartPhoto extends ATemplate { this.update(); body.style.overflow = 'hidden'; this._fireEvent('open'); + + const smartPhoto = document.querySelector(`.${this.data.classNames.smartPhoto}`); + smartPhoto.focus(); + document.addEventListener('keydown', onFocus); + this._registerRemoveEvent(window, 'keydown', onFocus); } else { this._loadItem(currentItem).then(() => { this._initPhoto(); @@ -321,7 +340,12 @@ export default class SmartPhoto extends ATemplate { this.update(); body.style.overflow = 'hidden'; this._fireEvent('open'); - }); + + const smartPhoto = document.querySelector(`.${this.data.classNames.smartPhoto}`); + smartPhoto.focus(); + document.addEventListener('keydown', onFocus); + this._registerRemoveEvent(window, 'keydown', onFocus); + }); } }; element.addEventListener('click', clickHandler); diff --git a/src/core/viewer.html b/src/core/viewer.html new file mode 100644 index 0000000..8268209 --- /dev/null +++ b/src/core/viewer.html @@ -0,0 +1,65 @@ +
    aria-hidden="true" aria-hidden="false" role="dialog" tabindex="-1"> +
    +
    +
    + {currentIndex}[increment]/{total} + {caption} +
    + +
    data-action-touchstart="beforeDrag" data-action-touchmove="onDrag" data-action-touchend="afterDrag(false)" data-action-click="hidePhoto()"> +
    + +
      + +
    • + +
      data-action-mousemove="onDrag" data-action-mousedown="beforeDrag" data-action-mouseup="afterDrag" data-action-touchstart="beforeDrag" data-action-touchmove="onDrag" data-action-touchend="afterDrag"> + +
      + + +
      + +
      + +
    • + +
    + + + + + + + + + + +
    + + + +
    +
    diff --git a/src/core/viwer.html b/src/core/viwer.html deleted file mode 100644 index 8e8fb34..0000000 --- a/src/core/viwer.html +++ /dev/null @@ -1,49 +0,0 @@ -
    aria-hidden="true" aria-hidden="false" role="dialog"> -
    -
    -
    - {currentIndex}[increment]/{total} - {caption} - -
    -
    data-action-touchstart="beforeDrag" data-action-touchmove="onDrag" data-action-touchend="afterDrag(false)" data-action-click="hidePhoto()"> -
    -
      - -
    • - -
      data-action-mousemove="onDrag" data-action-mousedown="beforeDrag" data-action-mouseup="afterDrag" data-action-touchstart="beforeDrag" data-action-touchmove="onDrag" data-action-touchend="afterDrag"> - -
      - - -
      - -
      - -
    • - -
    - - - - - - -
    - - - -
    -
    From 9230c3631e262a029f3e2ff068eaf9243fbc2829 Mon Sep 17 00:00:00 2001 From: Takayuki Nagatomi Date: Mon, 3 Jul 2023 14:59:51 +0900 Subject: [PATCH 2/6] Added husky and lint-staged --- .husky/.gitignore | 1 + .husky/pre-commit | 4 + .node-version | 2 +- .prettierrc | 7 + css/smartphoto.css | 32 +- css/smartphoto.min.css | 387 +- js/jquery-smartphoto.js | 7326 +++++----- js/jquery-smartphoto.min.js | 2668 +++- js/smartphoto.js | 7339 +++++----- js/smartphoto.min.js | 2708 +++- lib/core/index.js | 2814 ++-- package-lock.json | 26298 ++++++++++++++++++++-------------- package.json | 17 +- scss/smartphoto.scss | 2 +- src/core/index.js | 106 +- 15 files changed, 30386 insertions(+), 19325 deletions(-) create mode 100644 .husky/.gitignore create mode 100755 .husky/pre-commit create mode 100644 .prettierrc diff --git a/.husky/.gitignore b/.husky/.gitignore new file mode 100644 index 0000000..31354ec --- /dev/null +++ b/.husky/.gitignore @@ -0,0 +1 @@ +_ diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 0000000..36af219 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,4 @@ +#!/bin/sh +. "$(dirname "$0")/_/husky.sh" + +npx lint-staged diff --git a/.node-version b/.node-version index 641c7df..8ddbc0c 100644 --- a/.node-version +++ b/.node-version @@ -1 +1 @@ -v8.9.4 +v18.16.0 diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..4c4f65b --- /dev/null +++ b/.prettierrc @@ -0,0 +1,7 @@ +{ + "bracketSameLine": true, + "printWidth": 100, + "semi": true, + "singleQuote": true, + "tabWidth": 2 +} diff --git a/css/smartphoto.css b/css/smartphoto.css index 6eb5e4d..f9d3623 100644 --- a/css/smartphoto.css +++ b/css/smartphoto.css @@ -27,7 +27,7 @@ @keyframes smartphoto-loader { 0% { - opacity: .4; + opacity: 0.4; transform: rotate(0deg); } 50% { @@ -35,7 +35,7 @@ transform: rotate(180deg); } 100% { - opacity: .4; + opacity: 0.4; transform: rotate(360deg); } } @@ -93,7 +93,7 @@ animation-timing-function: ease-out; } -.smartphoto[aria-hidden="true"] { +.smartphoto[aria-hidden='true'] { display: none; } @@ -103,7 +103,7 @@ .smartphoto-count { display: inline-block; - color: #FFF; + color: #fff; font-size: 16px; } @@ -140,13 +140,13 @@ border: none; background-color: transparent; background-image: url(data:image/svg+xml;base64,PHN2ZyBpZD0i44Os44Kk44Ok44O8XzEiIGRhdGEtbmFtZT0i44Os44Kk44Ok44O8IDEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDI4MzQuNjUgMjgzNC42NSIgZmlsbD0iI0ZGRiI+PHRpdGxlPmljb248L3RpdGxlPjxwYXRoIGQ9Ik0xNTc2LjQyLDE0MDYuNzYsMjc4NCwxOTkuMTlhNTYuODYsNTYuODYsMCwwLDAsMC04MC4xOGwtNzguOTItNzguOTJhNTYuODYsNTYuODYsMCwwLDAtODAuMTgsMEwxNDE3LjMyLDEyNDcuNjYsMjA5Ljc1LDQwLjA5YTU2Ljg2LDU2Ljg2LDAsMCwwLTgwLjE4LDBMNTAuNjUsMTE5YTU2Ljg2LDU2Ljg2LDAsMCwwLDAsODAuMThMMTI1OC4yMywxNDA2Ljc2LDUwLjY1LDI2MTQuMzRhNTYuODYsNTYuODYsMCwwLDAsMCw4MC4xOGw3OC45Miw3OC45MmE1Ni44Niw1Ni44NiwwLDAsMCw4MC4xOCwwTDE0MTcuMzIsMTU2NS44NiwyNjI0LjksMjc3My40NGE1Ni44Niw1Ni44NiwwLDAsMCw4MC4xOCwwbDc4LjkyLTc4LjkyYTU2Ljg2LDU2Ljg2LDAsMCwwLDAtODAuMThaIi8+PC9zdmc+); - text-shadow: 0 1px 0 #FFF; - color: #FFF; + text-shadow: 0 1px 0 #fff; + color: #fff; font-size: 30px; text-decoration: none; cursor: pointer; line-height: 1; - z-index: 1; + z-index: 102; } .smartphoto-body { @@ -227,7 +227,7 @@ animation-timing-function: ease-out; } -.smartphoto-arrows[aria-hidden="true"] { +.smartphoto-arrows[aria-hidden='true'] { animation-name: smartphoto-hide; display: none; } @@ -249,7 +249,7 @@ outline: none; } -.smartphoto-arrows [aria-hidden="true"] { +.smartphoto-arrows [aria-hidden='true'] { animation-name: smartphoto-hide; display: none; } @@ -296,7 +296,7 @@ animation-timing-function: ease-out; } -.smartphoto-nav[aria-hidden="true"] { +.smartphoto-nav[aria-hidden='true'] { animation-name: smartphoto-hide; display: none; } @@ -323,14 +323,14 @@ display: block; width: 100%; height: 100%; - background-color: #FFF; + background-color: #fff; background-position: center center; background-size: cover; - opacity: .5; + opacity: 0.5; } .smartphoto-nav a:focus { - opacity: .8; + opacity: 0.8; } .smartphoto-nav a.current { @@ -380,7 +380,7 @@ width: 100%; height: 50px; padding: 0 50px; - color: #FFF; + color: #fff; font-size: 12px; text-align: center; line-height: 50px; @@ -410,10 +410,10 @@ height: 30px; margin-top: -25px; margin-left: -25px; - border: 8px solid #17CDDD; + border: 8px solid #17cddd; border-right-color: transparent; border-radius: 50%; - animation: smartphoto-loader .5s infinite linear; + animation: smartphoto-loader 0.5s infinite linear; } .smartphoto-img-clone { diff --git a/css/smartphoto.min.css b/css/smartphoto.min.css index a820662..4099939 100644 --- a/css/smartphoto.min.css +++ b/css/smartphoto.min.css @@ -1 +1,386 @@ -@keyframes smartphoto{from{opacity:0}to{opacity:1}}@keyframes smartphoto-img-wrap{from{opacity:0}to{opacity:1}}@keyframes smartphoto-inner{from{transform:translate(0, 100px)}to{transform:translate(0, 0)}}@keyframes smartphoto-loader{0%{opacity:.4;transform:rotate(0deg)}50%{opacity:1;transform:rotate(180deg)}100%{opacity:.4;transform:rotate(360deg)}}@keyframes smartphoto-appear{0%{display:none;opacity:0}1%{display:block;opacity:0}100%{display:block;opacity:1}}@keyframes smartphoto-hide{0%{display:block;opacity:1}99%{display:block;opacity:0}100%{display:none;opacity:0}}.smartphoto{position:fixed;z-index:100;top:0;left:0;width:100%;height:100%;overflow:hidden;background-color:#000;opacity:1;font-family:sans-serif;cursor:pointer;-webkit-transition:opacity .3s ease-out;-moz-transition:opacity .3s ease-out;-ms-transition:opacity .3s ease-out;-o-transition:opacity .3s ease-out;transition:opacity .3s ease-out;transition:all 0.3s ease-out;animation-name:smartphoto;animation-duration:.3s;animation-timing-function:ease-out}.smartphoto[aria-hidden="true"]{display:none}.smartphoto-close{opacity:0}.smartphoto-count{display:inline-block;color:#FFF;font-size:16px}.smartphoto-header{display:block;box-sizing:border-box;position:fixed;z-index:102;top:0;left:0;width:100%;height:50px;padding:15px;background-color:rgba(0,0,0,0.2)}.smartphoto-content{display:block;position:absolute;top:0;left:0;width:100%;height:100%}.smartphoto-dismiss{display:block;position:absolute;top:15px;right:10px;width:20px;height:20px;padding:0;border:none;background-color:transparent;background-image:url(data:image/svg+xml;base64,PHN2ZyBpZD0i44Os44Kk44Ok44O8XzEiIGRhdGEtbmFtZT0i44Os44Kk44Ok44O8IDEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDI4MzQuNjUgMjgzNC42NSIgZmlsbD0iI0ZGRiI+PHRpdGxlPmljb248L3RpdGxlPjxwYXRoIGQ9Ik0xNTc2LjQyLDE0MDYuNzYsMjc4NCwxOTkuMTlhNTYuODYsNTYuODYsMCwwLDAsMC04MC4xOGwtNzguOTItNzguOTJhNTYuODYsNTYuODYsMCwwLDAtODAuMTgsMEwxNDE3LjMyLDEyNDcuNjYsMjA5Ljc1LDQwLjA5YTU2Ljg2LDU2Ljg2LDAsMCwwLTgwLjE4LDBMNTAuNjUsMTE5YTU2Ljg2LDU2Ljg2LDAsMCwwLDAsODAuMThMMTI1OC4yMywxNDA2Ljc2LDUwLjY1LDI2MTQuMzRhNTYuODYsNTYuODYsMCwwLDAsMCw4MC4xOGw3OC45Miw3OC45MmE1Ni44Niw1Ni44NiwwLDAsMCw4MC4xOCwwTDE0MTcuMzIsMTU2NS44NiwyNjI0LjksMjc3My40NGE1Ni44Niw1Ni44NiwwLDAsMCw4MC4xOCwwbDc4LjkyLTc4LjkyYTU2Ljg2LDU2Ljg2LDAsMCwwLDAtODAuMThaIi8+PC9zdmc+);text-shadow:0 1px 0 #FFF;color:#FFF;font-size:30px;text-decoration:none;cursor:pointer;line-height:1;z-index:1}.smartphoto-body{position:relative;z-index:102;width:100%;height:100%;margin:0 auto}.smartphoto-inner{position:relative;width:100%;height:100%;vertical-align:top}.smartphoto-img{display:none;max-width:none;width:auto;height:auto;cursor:zoom-in;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;transition:transform 0.3s ease-out;-webkit-user-drag:none}.smartphoto-img.active{display:block}.smartphoto-img-onmove{cursor:grab;cursor:-webkit-grab;transition:none}.smartphoto-img-elasticmove{transition:transform 0.3s ease-out}.smartphoto-img-wrap{display:inline-block;opacity:1;-webkit-transition:opacity .3s ease-out;-moz-transition:opacity .3s ease-out;-ms-transition:opacity .3s ease-out;-o-transition:opacity .3s ease-out;transition:opacity .3s ease-out;animation-name:smartphoto-img-wrap;animation-duration:.3s;animation-timing-function:ease-out}.smartphoto-img-left{transform:translateX(150%) !important}.smartphoto-img-right{transform:translateX(-150%) !important}.smartphoto-arrows{list-style-type:none;margin:0;padding:0;position:relative;z-index:1002;top:50%;left:0;opacity:1;animation-name:smartphoto-appear;animation-duration:.3s;animation-timing-function:ease-out}.smartphoto-arrows[aria-hidden="true"]{animation-name:smartphoto-hide;display:none}.smartphoto-arrows li{display:block;position:absolute;top:50%;width:30px;height:30px;margin-top:-20px;box-sizing:content-box;animation-duration:.3s;animation-timing-function:ease-out;animation-name:smartphoto-appear}.smartphoto-arrows li:focus{outline:none}.smartphoto-arrows [aria-hidden="true"]{animation-name:smartphoto-hide;display:none}.smartphoto-arrows a{display:block;width:100%;height:100%;text-decoration:none}.smartphoto-arrow-right{right:0;padding:5px 0;background-color:rgba(0,0,0,0.5)}.smartphoto-arrow-right a{background-image:url(data:image/svg+xml;base64,PHN2ZyBpZD0i44Os44Kk44Ok44O8XzEiIGRhdGEtbmFtZT0i44Os44Kk44Ok44O8IDEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDI4MzQuNjUgMjgzNC42NSIgZmlsbD0iI0ZGRiAiPjx0aXRsZT5pY29uPC90aXRsZT48cGF0aCBkPSJNMTgzNy44OCwxNDE3LjMyLDY0My41OSwyMjNhNzIuMjEsNzIuMjEsMCwwLDEsMC0xMDEuODJMNzQzLjgyLDIxYTcyLjIxLDcyLjIxLDAsMCwxLDEwMS44MiwwTDIwOTAuODMsMTI2Ni4xOWwxMDAuMjMsMTAwLjIzYTcyLjIxLDcyLjIxLDAsMCwxLDAsMTAxLjgyTDg0NS42NCwyODEzLjY1YTcyLjIxLDcyLjIxLDAsMCwxLTEwMS44MiwwTDY0My41OSwyNzEzLjQyYTcyLjIxLDcyLjIxLDAsMCwxLDAtMTAxLjgyWiIvPjwvc3ZnPg==)}.smartphoto-arrow-left{left:0;padding:5px 0;background-color:rgba(0,0,0,0.5)}.smartphoto-arrow-left a{background-image:url(data:image/svg+xml;base64,PHN2ZyBpZD0i44Os44Kk44Ok44O8XzEiIGRhdGEtbmFtZT0i44Os44Kk44Ok44O8IDEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDI4MzQuNjUgMjgzNC42NSIgZmlsbD0iI0ZGRiI+PHRpdGxlPmljb248L3RpdGxlPjxwYXRoIGQ9Ik05OTYuNzcsMTQxNy4zMiwyMTkxLjA2LDIyM2E3Mi4yMSw3Mi4yMSwwLDAsMCwwLTEwMS44MkwyMDkwLjgzLDIxQTcyLjIxLDcyLjIxLDAsMCwwLDE5ODksMjFMNzQzLjgyLDEyNjYuMTksNjQzLjU5LDEzNjYuNDJhNzIuMjEsNzIuMjEsMCwwLDAsMCwxMDEuODJMMTk4OSwyODEzLjY1YTcyLjIxLDcyLjIxLDAsMCwwLDEwMS44MiwwbDEwMC4yMy0xMDAuMjNhNzIuMjEsNzIuMjEsMCwwLDAsMC0xMDEuODJaIi8+PC9zdmc+)}.smartPhotoArrowHideIcon{display:none}.smartphoto-nav{position:absolute;bottom:0;left:0;width:100%;opacity:1;animation-name:smartphoto-appear;animation-duration:.3s;animation-timing-function:ease-out}.smartphoto-nav[aria-hidden="true"]{animation-name:smartphoto-hide;display:none}.smartphoto-nav ul{display:block;overflow-x:auto;list-style:none;margin:0;padding:0;text-align:center;white-space:nowrap;-webkit-overflow-scrolling:touch}.smartphoto-nav li{display:inline-block;overflow:hidden;width:50px;height:50px}.smartphoto-nav a{display:block;width:100%;height:100%;background-color:#FFF;background-position:center center;background-size:cover;opacity:.5}.smartphoto-nav a:focus{opacity:.8}.smartphoto-nav a.current{opacity:1}.smartphoto-nav img{width:auto;height:100%}.smartphoto-list{list-style-type:none;position:absolute;z-index:101;top:0;left:0;margin:0;padding:0;white-space:nowrap}.smartphoto-list li{display:block;position:absolute;top:0;left:0;width:100%;height:100%;transition:all 0.3s ease-out}.smartphoto-list li:focus{outline:none}.smartphoto-list-onmove{transition:all 0.3s ease-out}.smartphoto-caption{overflow:hidden;box-sizing:border-box;position:absolute;top:0;left:0;width:100%;height:50px;padding:0 50px;color:#FFF;font-size:12px;text-align:center;line-height:50px;white-space:nowrap;text-overflow:ellipsis}.smartphoto-caption:focus{outline:none}.smartphoto-loader-wrap{display:block;position:relative;z-index:103;width:0;height:0;transform:translate(50vw, 50vh)}.smartphoto-loader{position:absolute;z-index:101;top:0;left:0;width:30px;height:30px;margin-top:-25px;margin-left:-25px;border:8px solid #17CDDD;border-right-color:transparent;border-radius:50%;animation:smartphoto-loader .5s infinite linear}.smartphoto-img-clone{position:fixed;z-index:100;top:0;left:0;transition:all .3s ease-out}.smartphoto-sr-only{overflow:hidden;position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;clip:rect(0, 0, 0, 0)} +@keyframes smartphoto { + from { + opacity: 0; + } + to { + opacity: 1; + } +} +@keyframes smartphoto-img-wrap { + from { + opacity: 0; + } + to { + opacity: 1; + } +} +@keyframes smartphoto-inner { + from { + transform: translate(0, 100px); + } + to { + transform: translate(0, 0); + } +} +@keyframes smartphoto-loader { + 0% { + opacity: 0.4; + transform: rotate(0deg); + } + 50% { + opacity: 1; + transform: rotate(180deg); + } + 100% { + opacity: 0.4; + transform: rotate(360deg); + } +} +@keyframes smartphoto-appear { + 0% { + display: none; + opacity: 0; + } + 1% { + display: block; + opacity: 0; + } + 100% { + display: block; + opacity: 1; + } +} +@keyframes smartphoto-hide { + 0% { + display: block; + opacity: 1; + } + 99% { + display: block; + opacity: 0; + } + 100% { + display: none; + opacity: 0; + } +} +.smartphoto { + position: fixed; + z-index: 100; + top: 0; + left: 0; + width: 100%; + height: 100%; + overflow: hidden; + background-color: #000; + opacity: 1; + font-family: sans-serif; + cursor: pointer; + -webkit-transition: opacity 0.3s ease-out; + -moz-transition: opacity 0.3s ease-out; + -ms-transition: opacity 0.3s ease-out; + -o-transition: opacity 0.3s ease-out; + transition: opacity 0.3s ease-out; + transition: all 0.3s ease-out; + animation-name: smartphoto; + animation-duration: 0.3s; + animation-timing-function: ease-out; +} +.smartphoto[aria-hidden='true'] { + display: none; +} +.smartphoto-close { + opacity: 0; +} +.smartphoto-count { + display: inline-block; + color: #fff; + font-size: 16px; +} +.smartphoto-header { + display: block; + box-sizing: border-box; + position: fixed; + z-index: 102; + top: 0; + left: 0; + width: 100%; + height: 50px; + padding: 15px; + background-color: rgba(0, 0, 0, 0.2); +} +.smartphoto-content { + display: block; + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; +} +.smartphoto-dismiss { + display: block; + position: absolute; + top: 15px; + right: 10px; + width: 20px; + height: 20px; + padding: 0; + border: none; + background-color: transparent; + background-image: url(data:image/svg+xml;base64,PHN2ZyBpZD0i44Os44Kk44Ok44O8XzEiIGRhdGEtbmFtZT0i44Os44Kk44Ok44O8IDEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDI4MzQuNjUgMjgzNC42NSIgZmlsbD0iI0ZGRiI+PHRpdGxlPmljb248L3RpdGxlPjxwYXRoIGQ9Ik0xNTc2LjQyLDE0MDYuNzYsMjc4NCwxOTkuMTlhNTYuODYsNTYuODYsMCwwLDAsMC04MC4xOGwtNzguOTItNzguOTJhNTYuODYsNTYuODYsMCwwLDAtODAuMTgsMEwxNDE3LjMyLDEyNDcuNjYsMjA5Ljc1LDQwLjA5YTU2Ljg2LDU2Ljg2LDAsMCwwLTgwLjE4LDBMNTAuNjUsMTE5YTU2Ljg2LDU2Ljg2LDAsMCwwLDAsODAuMThMMTI1OC4yMywxNDA2Ljc2LDUwLjY1LDI2MTQuMzRhNTYuODYsNTYuODYsMCwwLDAsMCw4MC4xOGw3OC45Miw3OC45MmE1Ni44Niw1Ni44NiwwLDAsMCw4MC4xOCwwTDE0MTcuMzIsMTU2NS44NiwyNjI0LjksMjc3My40NGE1Ni44Niw1Ni44NiwwLDAsMCw4MC4xOCwwbDc4LjkyLTc4LjkyYTU2Ljg2LDU2Ljg2LDAsMCwwLDAtODAuMThaIi8+PC9zdmc+); + text-shadow: 0 1px 0 #fff; + color: #fff; + font-size: 30px; + text-decoration: none; + cursor: pointer; + line-height: 1; + z-index: 102; +} +.smartphoto-body { + position: relative; + z-index: 102; + width: 100%; + height: 100%; + margin: 0 auto; +} +.smartphoto-inner { + position: relative; + width: 100%; + height: 100%; + vertical-align: top; +} +.smartphoto-img { + display: none; + max-width: none; + width: auto; + height: auto; + cursor: zoom-in; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + transition: transform 0.3s ease-out; + -webkit-user-drag: none; +} +.smartphoto-img.active { + display: block; +} +.smartphoto-img-onmove { + cursor: grab; + cursor: -webkit-grab; + transition: none; +} +.smartphoto-img-elasticmove { + transition: transform 0.3s ease-out; +} +.smartphoto-img-wrap { + display: inline-block; + opacity: 1; + -webkit-transition: opacity 0.3s ease-out; + -moz-transition: opacity 0.3s ease-out; + -ms-transition: opacity 0.3s ease-out; + -o-transition: opacity 0.3s ease-out; + transition: opacity 0.3s ease-out; + animation-name: smartphoto-img-wrap; + animation-duration: 0.3s; + animation-timing-function: ease-out; +} +.smartphoto-img-left { + transform: translateX(150%) !important; +} +.smartphoto-img-right { + transform: translateX(-150%) !important; +} +.smartphoto-arrows { + list-style-type: none; + margin: 0; + padding: 0; + position: relative; + z-index: 1002; + top: 50%; + left: 0; + opacity: 1; + animation-name: smartphoto-appear; + animation-duration: 0.3s; + animation-timing-function: ease-out; +} +.smartphoto-arrows[aria-hidden='true'] { + animation-name: smartphoto-hide; + display: none; +} +.smartphoto-arrows li { + display: block; + position: absolute; + top: 50%; + width: 30px; + height: 30px; + margin-top: -20px; + box-sizing: content-box; + animation-duration: 0.3s; + animation-timing-function: ease-out; + animation-name: smartphoto-appear; +} +.smartphoto-arrows li:focus { + outline: none; +} +.smartphoto-arrows [aria-hidden='true'] { + animation-name: smartphoto-hide; + display: none; +} +.smartphoto-arrows a { + display: block; + width: 100%; + height: 100%; + text-decoration: none; +} +.smartphoto-arrow-right { + right: 0; + padding: 5px 0; + background-color: rgba(0, 0, 0, 0.5); +} +.smartphoto-arrow-right a { + background-image: url(data:image/svg+xml;base64,PHN2ZyBpZD0i44Os44Kk44Ok44O8XzEiIGRhdGEtbmFtZT0i44Os44Kk44Ok44O8IDEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDI4MzQuNjUgMjgzNC42NSIgZmlsbD0iI0ZGRiAiPjx0aXRsZT5pY29uPC90aXRsZT48cGF0aCBkPSJNMTgzNy44OCwxNDE3LjMyLDY0My41OSwyMjNhNzIuMjEsNzIuMjEsMCwwLDEsMC0xMDEuODJMNzQzLjgyLDIxYTcyLjIxLDcyLjIxLDAsMCwxLDEwMS44MiwwTDIwOTAuODMsMTI2Ni4xOWwxMDAuMjMsMTAwLjIzYTcyLjIxLDcyLjIxLDAsMCwxLDAsMTAxLjgyTDg0NS42NCwyODEzLjY1YTcyLjIxLDcyLjIxLDAsMCwxLTEwMS44MiwwTDY0My41OSwyNzEzLjQyYTcyLjIxLDcyLjIxLDAsMCwxLDAtMTAxLjgyWiIvPjwvc3ZnPg==); +} +.smartphoto-arrow-left { + left: 0; + padding: 5px 0; + background-color: rgba(0, 0, 0, 0.5); +} +.smartphoto-arrow-left a { + background-image: url(data:image/svg+xml;base64,PHN2ZyBpZD0i44Os44Kk44Ok44O8XzEiIGRhdGEtbmFtZT0i44Os44Kk44Ok44O8IDEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDI4MzQuNjUgMjgzNC42NSIgZmlsbD0iI0ZGRiI+PHRpdGxlPmljb248L3RpdGxlPjxwYXRoIGQ9Ik05OTYuNzcsMTQxNy4zMiwyMTkxLjA2LDIyM2E3Mi4yMSw3Mi4yMSwwLDAsMCwwLTEwMS44MkwyMDkwLjgzLDIxQTcyLjIxLDcyLjIxLDAsMCwwLDE5ODksMjFMNzQzLjgyLDEyNjYuMTksNjQzLjU5LDEzNjYuNDJhNzIuMjEsNzIuMjEsMCwwLDAsMCwxMDEuODJMMTk4OSwyODEzLjY1YTcyLjIxLDcyLjIxLDAsMCwwLDEwMS44MiwwbDEwMC4yMy0xMDAuMjNhNzIuMjEsNzIuMjEsMCwwLDAsMC0xMDEuODJaIi8+PC9zdmc+); +} +.smartPhotoArrowHideIcon { + display: none; +} +.smartphoto-nav { + position: absolute; + bottom: 0; + left: 0; + width: 100%; + opacity: 1; + animation-name: smartphoto-appear; + animation-duration: 0.3s; + animation-timing-function: ease-out; +} +.smartphoto-nav[aria-hidden='true'] { + animation-name: smartphoto-hide; + display: none; +} +.smartphoto-nav ul { + display: block; + overflow-x: auto; + list-style: none; + margin: 0; + padding: 0; + text-align: center; + white-space: nowrap; + -webkit-overflow-scrolling: touch; +} +.smartphoto-nav li { + display: inline-block; + overflow: hidden; + width: 50px; + height: 50px; +} +.smartphoto-nav a { + display: block; + width: 100%; + height: 100%; + background-color: #fff; + background-position: center center; + background-size: cover; + opacity: 0.5; +} +.smartphoto-nav a:focus { + opacity: 0.8; +} +.smartphoto-nav a.current { + opacity: 1; +} +.smartphoto-nav img { + width: auto; + height: 100%; +} +.smartphoto-list { + list-style-type: none; + position: absolute; + z-index: 101; + top: 0; + left: 0; + margin: 0; + padding: 0; + white-space: nowrap; +} +.smartphoto-list li { + display: block; + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + transition: all 0.3s ease-out; +} +.smartphoto-list li:focus { + outline: none; +} +.smartphoto-list-onmove { + transition: all 0.3s ease-out; +} +.smartphoto-caption { + overflow: hidden; + box-sizing: border-box; + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 50px; + padding: 0 50px; + color: #fff; + font-size: 12px; + text-align: center; + line-height: 50px; + white-space: nowrap; + text-overflow: ellipsis; +} +.smartphoto-caption:focus { + outline: none; +} +.smartphoto-loader-wrap { + display: block; + position: relative; + z-index: 103; + width: 0; + height: 0; + transform: translate(50vw, 50vh); +} +.smartphoto-loader { + position: absolute; + z-index: 101; + top: 0; + left: 0; + width: 30px; + height: 30px; + margin-top: -25px; + margin-left: -25px; + border: 8px solid #17cddd; + border-right-color: transparent; + border-radius: 50%; + animation: smartphoto-loader 0.5s infinite linear; +} +.smartphoto-img-clone { + position: fixed; + z-index: 100; + top: 0; + left: 0; + transition: all 0.3s ease-out; +} +.smartphoto-sr-only { + overflow: hidden; + position: absolute; + width: 1px; + height: 1px; + margin: -1px; + padding: 0; + border: 0; + clip: rect(0, 0, 0, 0); +} diff --git a/js/jquery-smartphoto.js b/js/jquery-smartphoto.js index 0385be4..a9f63f3 100644 --- a/js/jquery-smartphoto.js +++ b/js/jquery-smartphoto.js @@ -52,1578 +52,1729 @@ * * This header is generated by licensify (https://github.com/twada/licensify) */ -(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i { - // const d = new $.Deferred(); - // promises.push(d); - // const src = selector(`#${template}`).getAttribute('src'); - // $.ajax({ - // url: src, - // type: 'GET', - // dataType: 'text' - // }).success((data) => { - // selector(`#${template}`).innerHTML = data; - // d.resolve(); - // }); - // }); - // return $.when(...promises); - // } - - }, { - key: 'getData', - value: function getData() { - return JSON.parse(JSON.stringify(this.data)); - } - }, { - key: 'saveData', - value: function saveData(key) { - var data = JSON.stringify(this.data); - localStorage.setItem(key, data); - } - }, { - key: 'setData', - value: function setData(opt) { - var _this4 = this; - - Object.keys(opt).forEach(function (key) { - if (typeof opt[key] !== 'function') { - _this4.data[key] = opt[key]; - } - }); - } - }, { - key: 'loadData', - value: function loadData(key) { - var data = JSON.parse(localStorage.getItem(key)); - if (data) { - this.setData(data); - } - } - }, { - key: 'getRand', - value: function getRand(a, b) { - return ~~(Math.random() * (b - a + 1)) + a; - } - }, { - key: 'getRandText', - value: function getRandText(limit) { - var ret = ''; - var strings = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; - var length = strings.length; - for (var i = 0; i < limit; i += 1) { - ret += strings.charAt(Math.floor(this.getRand(0, length))); - } - return ret; - } - }, { - key: 'getDataFromObj', - value: function getDataFromObj(s, o) { - s = s.replace(/\[([\w\-\.ぁ-んァ-ヶ亜-熙]+)\]/g, '.$1'); // convert indexes to properties - s = s.replace(/^\./, ''); // strip leading dot - var a = s.split('.'); - while (a.length) { - var n = a.shift(); - if (n in o) { - o = o[n]; - } else { - return null; + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError('Cannot call a class as a function'); + } } - } - return o; - } - }, { - key: 'getDataByString', - value: function getDataByString(s) { - var o = this.data; - return this.getDataFromObj(s, o); - } - }, { - key: 'updateDataByString', - value: function updateDataByString(path, newValue) { - var object = this.data; - var stack = path.split('.'); - while (stack.length > 1) { - object = object[stack.shift()]; - } - object[stack.shift()] = newValue; - } - }, { - key: 'removeDataByString', - value: function removeDataByString(path) { - var object = this.data; - var stack = path.split('.'); - while (stack.length > 1) { - object = object[stack.shift()]; - } - var shift = stack.shift(); - if (shift.match(/^\d+$/)) { - object.splice(Number(shift), 1); - } else { - delete object[shift]; - } - } - }, { - key: 'resolveBlock', - value: function resolveBlock(html, item, i) { - var that = this; - var touchs = html.match(//g); - var touchnots = html.match(//g); - var exists = html.match(//g); - var empties = html.match(//g); - /* タッチブロック解決*/ - if (touchs) { - for (var k = 0, n = touchs.length; k < n; k += 1) { - var start = touchs[k]; - start = start.replace(/([\w\-\.ぁ-んァ-ヶ亜-熙]+):touch#([\w\-\.ぁ-んァ-ヶ亜-熙]+)/, '($1):touch#($2)'); - var end = start.replace(/BEGIN/, 'END'); - var reg = new RegExp(start + '(([\\n\\r\\t]|.)*?)' + end, 'g'); - html = html.replace(reg, function (m, key2, val, next) { - var itemkey = typeof item[key2] === 'function' ? item[key2].apply(that) : that.getDataFromObj(key2, item); - if ('' + itemkey === val) { - return next; + + var eventType = + 'input paste copy click change keydown keyup keypress contextmenu mouseup mousedown mousemove touchstart touchend touchmove compositionstart compositionend focus'; + var bindType = 'input change click'; + var dataAction = eventType.replace(/([a-z]+)/g, '[data-action-$1],') + '[data-action]'; + + var aTemplate = (function () { + function aTemplate(opt) { + var _this = this; + + _classCallCheck(this, aTemplate); + + this.atemplate = []; + this.events = []; + if (opt) { + Object.keys(opt).forEach(function (key) { + _this[key] = opt[key]; + }); } - return ''; - }); - } - } - /* タッチノットブロック解決*/ - if (touchnots) { - for (var _k = 0, _n = touchnots.length; _k < _n; _k += 1) { - var _start = touchnots[_k]; - _start = _start.replace(/([\w\-\.ぁ-んァ-ヶ亜-熙]+):touchnot#([\w\-\.ぁ-んァ-ヶ亜-熙]+)/, '($1):touchnot#($2)'); - var _end = _start.replace(/BEGIN/, 'END'); - var _reg = new RegExp(_start + '(([\\n\\r\\t]|.)*?)' + _end, 'g'); - html = html.replace(_reg, function (m, key2, val, next) { - var itemkey = typeof item[key2] === 'function' ? item[key2].apply(that) : that.getDataFromObj(key2, item); - if ('' + itemkey !== val) { - return next; + if (!this.data) { + this.data = {}; } - return ''; - }); - } - } - /* existブロックを解決*/ - if (exists) { - for (var _k2 = 0, _n2 = exists.length; _k2 < _n2; _k2 += 1) { - var _start2 = exists[_k2]; - _start2 = _start2.replace(/([\w\-\.ぁ-んァ-ヶ亜-熙]+):exist/, '($1):exist'); - var _end2 = _start2.replace(/BEGIN/, 'END'); - var _reg2 = new RegExp(_start2 + '(([\\n\\r\\t]|.)*?)' + _end2, 'g'); - html = html.replace(_reg2, function (m, key2, next) { - var itemkey = typeof item[key2] === 'function' ? item[key2].apply(that) : that.getDataFromObj(key2, item); - if (itemkey || itemkey === 0) { - return next; + if (!this.templates) { + this.templates = []; } - return ''; - }); - } - } - /* emptyブロックを解決*/ - if (empties) { - for (var _k3 = 0, _n3 = empties.length; _k3 < _n3; _k3 += 1) { - var _start3 = empties[_k3]; - _start3 = _start3.replace(/([\w\-\.ぁ-んァ-ヶ亜-熙]+):empty/, '($1):empty'); - var _end3 = _start3.replace(/BEGIN/, 'END'); - var empty = new RegExp(_start3 + '(([\\n\\r\\t]|.)*?)' + _end3, 'g'); - html = html.replace(empty, function (m, key2, next) { - var itemkey = typeof item[key2] === 'function' ? item[key2].apply(that) : that.getDataFromObj(key2, item); - if (!itemkey && itemkey !== 0) { - return next; + var templates = this.templates; + var length = templates.length; + for (var i = 0, n = length; i < n; i += 1) { + var template = this.templates[i]; + var html = (0, _util.selector)('#' + template).innerHTML; + this.atemplate.push({ id: template, html: html, binded: false }); } - return ''; - }); - } - } - /* 変数解決*/ - html = html.replace(/{([\w\-\.ぁ-んァ-ヶ亜-熙]+)}(\[([\w\-\.ぁ-んァ-ヶ亜-熙]+)\])*/g, function (n, key3, key4, converter) { - var data = void 0; - if ('' + key3 === 'i') { - data = i; - } else if (item[key3] || item[key3] === 0) { - if (typeof item[key3] === 'function') { - data = item[key3].apply(that); - } else { - data = item[key3]; - } - } else { - if (converter && that.convert && that.convert[converter]) { - return that.convert[converter].call(that, ''); - } - return ''; - } - if (converter && that.convert && that.convert[converter]) { - return that.convert[converter].call(that, data); - } - return data; - }); - return html; - } - /* 絶対パス形式の変数を解決*/ - - }, { - key: 'resolveAbsBlock', - value: function resolveAbsBlock(html) { - var that = this; - html = html.replace(/{(.*?)}/g, function (n, key3) { - var data = that.getDataByString(key3); - if (typeof data !== 'undefined') { - if (typeof data === 'function') { - return data.apply(that); - } - return data; - } - return n; - }); - return html; - } - }, { - key: 'resolveInclude', - value: function resolveInclude(html) { - var include = //g; - html = html.replace(include, function (m, key) { - return (0, _util.selector)('#' + key).innerHTML; - }); - return html; - } - }, { - key: 'resolveWith', - value: function resolveWith(html) { - var width = /(([\n\r\t]|.)*?)/g; - html = html.replace(width, function (m, key) { - m = m.replace(/data\-bind=['"](.*?)['"]/g, 'data-bind=\'' + key + '.$1\''); - return m; - }); - return html; - } - }, { - key: 'resolveLoop', - value: function resolveLoop(html) { - var loop = /(([\n\r\t]|.)*?)/g; - var that = this; - /* ループ文解決*/ - html = html.replace(loop, function (m, key, val) { - var keyItem = that.getDataByString(key); - var keys = []; - if (typeof keyItem === 'function') { - keys = keyItem.apply(that); - } else { - keys = keyItem; - } - var ret = ''; - if (keys instanceof Array) { - for (var i = 0, n = keys.length; i < n; i += 1) { - ret += that.resolveBlock(val, keys[i], i); - } - } - /* エスケープ削除*/ - ret = ret.replace(/\\([^\\])/g, '$1'); - return ret; - }); - return html; - } - }, { - key: 'removeData', - value: function removeData(arr) { - var data = this.data; - Object.keys(data).forEach(function (i) { - for (var t = 0, n = arr.length; t < n; t += 1) { - if (i === arr[t]) { - delete data[i]; } - } - }); - return this; - } - }, { - key: 'hasLoop', - value: function hasLoop(txt) { - var loop = /(([\n\r\t]|.)*?)/g; - if (txt.match(loop)) { - return true; - } - return false; - } - }, { - key: 'getHtml', - value: function getHtml(query, row) { - var template = this.atemplate.find(function (item) { - return item.id === query; - }); - var html = ''; - if (template && template.html) { - html = template.html; - } - if (row) { - html = query; - } - if (!html) { - return ''; - } - var data = this.data; - /* インクルード解決*/ - html = this.resolveInclude(html); - /* with解決*/ - html = this.resolveWith(html); - /* ループ解決*/ - while (this.hasLoop(html)) { - html = this.resolveLoop(html); - } - /* 変数解決*/ - html = this.resolveBlock(html, data); - /* エスケープ削除*/ - html = html.replace(/\\([^\\])/g, '$1'); - /* 絶対パスで指定された変数を解決*/ - html = this.resolveAbsBlock(html); - /* 空行削除*/ - return html.replace(/^([\t ])*\n/gm, ''); - } - }, { - key: 'update', - value: function update() { - var _this5 = this; - var renderWay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'html'; - var part = arguments[1]; + _createClass(aTemplate, [ + { + key: 'addDataBind', + value: function addDataBind(ele) { + var _this2 = this; + + (0, _util.on)(ele, '[data-bind]', bindType, function (e) { + var target = e.delegateTarget; + var data = target.getAttribute('data-bind'); + var attr = target.getAttribute('href'); + var value = target.value; + if (attr) { + value = value.replace('#', ''); + } + if (target.getAttribute('type') === 'checkbox') { + (function () { + var arr = []; + var items = document.querySelectorAll('[data-bind="' + data + '"]'); + [].forEach.call(items, function (item) { + if (item.checked) { + arr.push(item.value); + } + }); + })(); + } else if (target.getAttribute('type') !== 'radio') { + _this2.updateDataByString(data, value); + } + }); + this.events.push({ + element: ele, + selector: '[data-bind]', + event: bindType, + }); + }, + }, + { + key: 'addActionBind', + value: function addActionBind(ele) { + var _this3 = this; + + (0, _util.on)(ele, dataAction, eventType, function (e) { + var target = e.delegateTarget; + var events = eventType.split(' '); + var action = 'action'; + events.forEach(function (event) { + if (target.getAttribute('data-action-' + event)) { + if (e.type === event) { + action += '-' + event; + } + } + }); + var string = target.getAttribute('data-' + action); + if (!string) { + return; + } + var method = string.replace(/\(.*?\);?/, ''); + var parameter = string.replace(/(.*?)\((.*?)\);?/, '$2'); + var pts = parameter.split(','); // 引き数 + _this3.e = e; + if (_this3.method && _this3.method[method]) { + var _method; + + (_method = _this3.method)[method].apply(_method, _toConsumableArray(pts)); + } else if (_this3[method]) { + _this3[method].apply(_this3, _toConsumableArray(pts)); + } + }); + this.events.push({ + element: ele, + selector: dataAction, + event: bindType, + }); + }, + }, + { + key: 'removeTemplateEvents', + value: function removeTemplateEvents() { + this.events.forEach(function (event) { + (0, _util.off)(event.element, event.selector, event.event); + }); + }, + }, + { + key: 'addTemplate', + value: function addTemplate(id, html) { + this.atemplate.push({ id: id, html: html, binded: false }); + this.templates.push(id); + }, + + // loadHtml() { + // const templates = this.templates; + // const promises = []; + // templates.forEach((template) => { + // const d = new $.Deferred(); + // promises.push(d); + // const src = selector(`#${template}`).getAttribute('src'); + // $.ajax({ + // url: src, + // type: 'GET', + // dataType: 'text' + // }).success((data) => { + // selector(`#${template}`).innerHTML = data; + // d.resolve(); + // }); + // }); + // return $.when(...promises); + // } + }, + { + key: 'getData', + value: function getData() { + return JSON.parse(JSON.stringify(this.data)); + }, + }, + { + key: 'saveData', + value: function saveData(key) { + var data = JSON.stringify(this.data); + localStorage.setItem(key, data); + }, + }, + { + key: 'setData', + value: function setData(opt) { + var _this4 = this; + + Object.keys(opt).forEach(function (key) { + if (typeof opt[key] !== 'function') { + _this4.data[key] = opt[key]; + } + }); + }, + }, + { + key: 'loadData', + value: function loadData(key) { + var data = JSON.parse(localStorage.getItem(key)); + if (data) { + this.setData(data); + } + }, + }, + { + key: 'getRand', + value: function getRand(a, b) { + return ~~(Math.random() * (b - a + 1)) + a; + }, + }, + { + key: 'getRandText', + value: function getRandText(limit) { + var ret = ''; + var strings = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; + var length = strings.length; + for (var i = 0; i < limit; i += 1) { + ret += strings.charAt(Math.floor(this.getRand(0, length))); + } + return ret; + }, + }, + { + key: 'getDataFromObj', + value: function getDataFromObj(s, o) { + s = s.replace(/\[([\w\-\.ぁ-んァ-ヶ亜-熙]+)\]/g, '.$1'); // convert indexes to properties + s = s.replace(/^\./, ''); // strip leading dot + var a = s.split('.'); + while (a.length) { + var n = a.shift(); + if (n in o) { + o = o[n]; + } else { + return null; + } + } + return o; + }, + }, + { + key: 'getDataByString', + value: function getDataByString(s) { + var o = this.data; + return this.getDataFromObj(s, o); + }, + }, + { + key: 'updateDataByString', + value: function updateDataByString(path, newValue) { + var object = this.data; + var stack = path.split('.'); + while (stack.length > 1) { + object = object[stack.shift()]; + } + object[stack.shift()] = newValue; + }, + }, + { + key: 'removeDataByString', + value: function removeDataByString(path) { + var object = this.data; + var stack = path.split('.'); + while (stack.length > 1) { + object = object[stack.shift()]; + } + var shift = stack.shift(); + if (shift.match(/^\d+$/)) { + object.splice(Number(shift), 1); + } else { + delete object[shift]; + } + }, + }, + { + key: 'resolveBlock', + value: function resolveBlock(html, item, i) { + var that = this; + var touchs = html.match( + //g + ); + var touchnots = html.match( + //g + ); + var exists = html.match(//g); + var empties = html.match(//g); + /* タッチブロック解決*/ + if (touchs) { + for (var k = 0, n = touchs.length; k < n; k += 1) { + var start = touchs[k]; + start = start.replace( + /([\w\-\.ぁ-んァ-ヶ亜-熙]+):touch#([\w\-\.ぁ-んァ-ヶ亜-熙]+)/, + '($1):touch#($2)' + ); + var end = start.replace(/BEGIN/, 'END'); + var reg = new RegExp(start + '(([\\n\\r\\t]|.)*?)' + end, 'g'); + html = html.replace(reg, function (m, key2, val, next) { + var itemkey = + typeof item[key2] === 'function' + ? item[key2].apply(that) + : that.getDataFromObj(key2, item); + if ('' + itemkey === val) { + return next; + } + return ''; + }); + } + } + /* タッチノットブロック解決*/ + if (touchnots) { + for (var _k = 0, _n = touchnots.length; _k < _n; _k += 1) { + var _start = touchnots[_k]; + _start = _start.replace( + /([\w\-\.ぁ-んァ-ヶ亜-熙]+):touchnot#([\w\-\.ぁ-んァ-ヶ亜-熙]+)/, + '($1):touchnot#($2)' + ); + var _end = _start.replace(/BEGIN/, 'END'); + var _reg = new RegExp(_start + '(([\\n\\r\\t]|.)*?)' + _end, 'g'); + html = html.replace(_reg, function (m, key2, val, next) { + var itemkey = + typeof item[key2] === 'function' + ? item[key2].apply(that) + : that.getDataFromObj(key2, item); + if ('' + itemkey !== val) { + return next; + } + return ''; + }); + } + } + /* existブロックを解決*/ + if (exists) { + for (var _k2 = 0, _n2 = exists.length; _k2 < _n2; _k2 += 1) { + var _start2 = exists[_k2]; + _start2 = _start2.replace(/([\w\-\.ぁ-んァ-ヶ亜-熙]+):exist/, '($1):exist'); + var _end2 = _start2.replace(/BEGIN/, 'END'); + var _reg2 = new RegExp(_start2 + '(([\\n\\r\\t]|.)*?)' + _end2, 'g'); + html = html.replace(_reg2, function (m, key2, next) { + var itemkey = + typeof item[key2] === 'function' + ? item[key2].apply(that) + : that.getDataFromObj(key2, item); + if (itemkey || itemkey === 0) { + return next; + } + return ''; + }); + } + } + /* emptyブロックを解決*/ + if (empties) { + for (var _k3 = 0, _n3 = empties.length; _k3 < _n3; _k3 += 1) { + var _start3 = empties[_k3]; + _start3 = _start3.replace(/([\w\-\.ぁ-んァ-ヶ亜-熙]+):empty/, '($1):empty'); + var _end3 = _start3.replace(/BEGIN/, 'END'); + var empty = new RegExp(_start3 + '(([\\n\\r\\t]|.)*?)' + _end3, 'g'); + html = html.replace(empty, function (m, key2, next) { + var itemkey = + typeof item[key2] === 'function' + ? item[key2].apply(that) + : that.getDataFromObj(key2, item); + if (!itemkey && itemkey !== 0) { + return next; + } + return ''; + }); + } + } + /* 変数解決*/ + html = html.replace( + /{([\w\-\.ぁ-んァ-ヶ亜-熙]+)}(\[([\w\-\.ぁ-んァ-ヶ亜-熙]+)\])*/g, + function (n, key3, key4, converter) { + var data = void 0; + if ('' + key3 === 'i') { + data = i; + } else if (item[key3] || item[key3] === 0) { + if (typeof item[key3] === 'function') { + data = item[key3].apply(that); + } else { + data = item[key3]; + } + } else { + if (converter && that.convert && that.convert[converter]) { + return that.convert[converter].call(that, ''); + } + return ''; + } + if (converter && that.convert && that.convert[converter]) { + return that.convert[converter].call(that, data); + } + return data; + } + ); + return html; + }, + /* 絶対パス形式の変数を解決*/ + }, + { + key: 'resolveAbsBlock', + value: function resolveAbsBlock(html) { + var that = this; + html = html.replace(/{(.*?)}/g, function (n, key3) { + var data = that.getDataByString(key3); + if (typeof data !== 'undefined') { + if (typeof data === 'function') { + return data.apply(that); + } + return data; + } + return n; + }); + return html; + }, + }, + { + key: 'resolveInclude', + value: function resolveInclude(html) { + var include = //g; + html = html.replace(include, function (m, key) { + return (0, _util.selector)('#' + key).innerHTML; + }); + return html; + }, + }, + { + key: 'resolveWith', + value: function resolveWith(html) { + var width = + /(([\n\r\t]|.)*?)/g; + html = html.replace(width, function (m, key) { + m = m.replace(/data\-bind=['"](.*?)['"]/g, "data-bind='" + key + ".$1'"); + return m; + }); + return html; + }, + }, + { + key: 'resolveLoop', + value: function resolveLoop(html) { + var loop = + /(([\n\r\t]|.)*?)/g; + var that = this; + /* ループ文解決*/ + html = html.replace(loop, function (m, key, val) { + var keyItem = that.getDataByString(key); + var keys = []; + if (typeof keyItem === 'function') { + keys = keyItem.apply(that); + } else { + keys = keyItem; + } + var ret = ''; + if (keys instanceof Array) { + for (var i = 0, n = keys.length; i < n; i += 1) { + ret += that.resolveBlock(val, keys[i], i); + } + } + /* エスケープ削除*/ + ret = ret.replace(/\\([^\\])/g, '$1'); + return ret; + }); + return html; + }, + }, + { + key: 'removeData', + value: function removeData(arr) { + var data = this.data; + Object.keys(data).forEach(function (i) { + for (var t = 0, n = arr.length; t < n; t += 1) { + if (i === arr[t]) { + delete data[i]; + } + } + }); + return this; + }, + }, + { + key: 'hasLoop', + value: function hasLoop(txt) { + var loop = + /(([\n\r\t]|.)*?)/g; + if (txt.match(loop)) { + return true; + } + return false; + }, + }, + { + key: 'getHtml', + value: function getHtml(query, row) { + var template = this.atemplate.find(function (item) { + return item.id === query; + }); + var html = ''; + if (template && template.html) { + html = template.html; + } + if (row) { + html = query; + } + if (!html) { + return ''; + } + var data = this.data; + /* インクルード解決*/ + html = this.resolveInclude(html); + /* with解決*/ + html = this.resolveWith(html); + /* ループ解決*/ + while (this.hasLoop(html)) { + html = this.resolveLoop(html); + } + /* 変数解決*/ + html = this.resolveBlock(html, data); + /* エスケープ削除*/ + html = html.replace(/\\([^\\])/g, '$1'); + /* 絶対パスで指定された変数を解決*/ + html = this.resolveAbsBlock(html); + /* 空行削除*/ + return html.replace(/^([\t ])*\n/gm, ''); + }, + }, + { + key: 'update', + value: function update() { + var _this5 = this; + + var renderWay = + arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'html'; + var part = arguments[1]; + + var templates = this.templates; + if (this.beforeUpdated) { + this.beforeUpdated(); + } - var templates = this.templates; - if (this.beforeUpdated) { - this.beforeUpdated(); - } + var _loop = function _loop(i, n) { + var tem = templates[i]; + var query = '#' + tem; + var html = _this5.getHtml(tem); + var target = (0, _util.selector)("[data-id='" + tem + "']"); + if (!target) { + (0, _util.selector)(query).insertAdjacentHTML( + 'afterend', + '
    ' + ); + if (renderWay === 'text') { + (0, _util.selector)("[data-id='" + tem + "']").innerText = html; + } else { + (0, _util.selector)("[data-id='" + tem + "']").innerHTML = html; + } + } else if (renderWay === 'text') { + target.innerText = html; + } else if (part) { + var doc = document.createElement('div'); + doc.innerHTML = html; + var partHtml = doc.querySelector(part).outerHTML; + (0, _morphdom2.default)(target.querySelector(part), partHtml); + } else { + (0, _morphdom2.default)( + target, + "
    " + html + '
    ' + ); + } + var template = _this5.atemplate.find(function (item) { + return item.id === tem; + }); + if (!template.binded) { + template.binded = true; + _this5.addDataBind((0, _util.selector)("[data-id='" + tem + "']")); + _this5.addActionBind((0, _util.selector)("[data-id='" + tem + "']")); + } + }; + + for (var i = 0, n = templates.length; i < n; i += 1) { + _loop(i, n); + } + this.updateBindingData(part); + if (this.onUpdated) { + this.onUpdated(part); + } + return this; + }, + }, + { + key: 'updateBindingData', + value: function updateBindingData(part) { + var _this6 = this; + + var templates = this.templates; + for (var i = 0, n = templates.length; i < n; i += 1) { + var temp = templates[i]; + var _template = (0, _util.selector)("[data-id='" + temp + "']"); + if (part) { + _template = _template.querySelector(part); + } + var binds = _template.querySelectorAll('[data-bind]'); + [].forEach.call(binds, function (item) { + var data = _this6.getDataByString(item.getAttribute('data-bind')); + if ( + item.getAttribute('type') === 'checkbox' || + item.getAttribute('type') === 'radio' + ) { + if (data === item.value) { + item.checked = true; + } + } else { + // if(item !== document.activeElement) { + item.value = data; + // } + } + }); + var onewaybinds = _template.querySelectorAll('[data-bind-oneway]'); + [].forEach.call(onewaybinds, function (item) { + var data = _this6.getDataByString(item.getAttribute('data-bind-oneway')); + if ( + item.getAttribute('type') === 'checkbox' || + item.getAttribute('type') === 'radio' + ) { + if (data === item.value) { + item.checked = true; + } + } else { + // if(item !== document.activeElement) { + item.value = data; + // } + } + }); + } + return this; + }, + }, + { + key: 'applyMethod', + value: function applyMethod(method) { + var _method2; + + for ( + var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; + _key < _len; + _key++ + ) { + args[_key - 1] = arguments[_key]; + } - var _loop = function _loop(i, n) { - var tem = templates[i]; - var query = '#' + tem; - var html = _this5.getHtml(tem); - var target = (0, _util.selector)('[data-id=\'' + tem + '\']'); - if (!target) { - (0, _util.selector)(query).insertAdjacentHTML('afterend', '
    '); - if (renderWay === 'text') { - (0, _util.selector)('[data-id=\'' + tem + '\']').innerText = html; - } else { - (0, _util.selector)('[data-id=\'' + tem + '\']').innerHTML = html; - } - } else if (renderWay === 'text') { - target.innerText = html; - } else if (part) { - var doc = document.createElement('div'); - doc.innerHTML = html; - var partHtml = doc.querySelector(part).outerHTML; - (0, _morphdom2.default)(target.querySelector(part), partHtml); - } else { - (0, _morphdom2.default)(target, '
    ' + html + '
    '); - } - var template = _this5.atemplate.find(function (item) { - return item.id === tem; + return (_method2 = this.method)[method].apply(_method2, args); + }, + }, + { + key: 'getComputedProp', + value: function getComputedProp(prop) { + return this.data[prop].apply(this); + }, + }, + { + key: 'remove', + value: function remove(path) { + var object = this.data; + var stack = path.split('.'); + while (stack.length > 1) { + object = object[stack.shift()]; + } + var shift = stack.shift(); + if (shift.match(/^\d+$/)) { + object.splice(Number(shift), 1); + } else { + delete object[shift]; + } + return this; + }, + }, + ]); + + return aTemplate; + })(); + + exports.default = aTemplate; + module.exports = exports['default']; + }, + { './util': 2, 'ie-array-find-polyfill': 5, morphdom: 6 }, + ], + 2: [ + function (require, module, exports) { + 'use strict'; + + Object.defineProperty(exports, '__esModule', { + value: true, + }); + var matches = (exports.matches = function matches(element, query) { + var matches = (element.document || element.ownerDocument).querySelectorAll(query); + var i = matches.length; + while (--i >= 0 && matches.item(i) !== element) {} + return i > -1; }); - if (!template.binded) { - template.binded = true; - _this5.addDataBind((0, _util.selector)('[data-id=\'' + tem + '\']')); - _this5.addActionBind((0, _util.selector)('[data-id=\'' + tem + '\']')); - } - }; - for (var i = 0, n = templates.length; i < n; i += 1) { - _loop(i, n); - } - this.updateBindingData(part); - if (this.onUpdated) { - this.onUpdated(part); - } - return this; - } - }, { - key: 'updateBindingData', - value: function updateBindingData(part) { - var _this6 = this; - - var templates = this.templates; - for (var i = 0, n = templates.length; i < n; i += 1) { - var temp = templates[i]; - var _template = (0, _util.selector)('[data-id=\'' + temp + '\']'); - if (part) { - _template = _template.querySelector(part); - } - var binds = _template.querySelectorAll('[data-bind]'); - [].forEach.call(binds, function (item) { - var data = _this6.getDataByString(item.getAttribute('data-bind')); - if (item.getAttribute('type') === 'checkbox' || item.getAttribute('type') === 'radio') { - if (data === item.value) { - item.checked = true; - } - } else { - // if(item !== document.activeElement) { - item.value = data; - // } - } + var selector = (exports.selector = function selector(_selector) { + return document.querySelector(_selector); }); - var onewaybinds = _template.querySelectorAll('[data-bind-oneway]'); - [].forEach.call(onewaybinds, function (item) { - var data = _this6.getDataByString(item.getAttribute('data-bind-oneway')); - if (item.getAttribute('type') === 'checkbox' || item.getAttribute('type') === 'radio') { - if (data === item.value) { - item.checked = true; + + var findAncestor = (exports.findAncestor = function findAncestor(element, selector) { + if (typeof element.closest === 'function') { + return element.closest(selector) || null; + } + while (element && element !== document) { + if (matches(element, selector)) { + return element; } - } else { - // if(item !== document.activeElement) { - item.value = data; - // } + element = element.parentElement; } + return null; }); - } - return this; - } - }, { - key: 'applyMethod', - value: function applyMethod(method) { - var _method2; - for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - args[_key - 1] = arguments[_key]; - } + var listenerList = []; - return (_method2 = this.method)[method].apply(_method2, args); - } - }, { - key: 'getComputedProp', - value: function getComputedProp(prop) { - return this.data[prop].apply(this); - } - }, { - key: 'remove', - value: function remove(path) { - var object = this.data; - var stack = path.split('.'); - while (stack.length > 1) { - object = object[stack.shift()]; - } - var shift = stack.shift(); - if (shift.match(/^\d+$/)) { - object.splice(Number(shift), 1); - } else { - delete object[shift]; - } - return this; - } - }]); - - return aTemplate; -}(); - -exports.default = aTemplate; -module.exports = exports['default']; -},{"./util":2,"ie-array-find-polyfill":5,"morphdom":6}],2:[function(require,module,exports){ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -var matches = exports.matches = function matches(element, query) { - var matches = (element.document || element.ownerDocument).querySelectorAll(query); - var i = matches.length; - while (--i >= 0 && matches.item(i) !== element) {} - return i > -1; -}; - -var selector = exports.selector = function selector(_selector) { - return document.querySelector(_selector); -}; - -var findAncestor = exports.findAncestor = function findAncestor(element, selector) { - if (typeof element.closest === 'function') { - return element.closest(selector) || null; - } - while (element && element !== document) { - if (matches(element, selector)) { - return element; - } - element = element.parentElement; - } - return null; -}; + var on = (exports.on = function on(element, query, eventNames, fn) { + var capture = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false; -var listenerList = []; + var events = eventNames.split(' '); + events.forEach(function (event) { + var listener = function listener(e) { + var delegateTarget = findAncestor(e.target, query); + if (delegateTarget) { + e.delegateTarget = delegateTarget; + fn(e); + } + }; + listenerList.push({ + listener: listener, + element: element, + query: query, + event: event, + capture: capture, + }); + element.addEventListener(event, listener, capture); + }); + }); -var on = exports.on = function on(element, query, eventNames, fn) { - var capture = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false; + var off = (exports.off = function off(element, query, eventNames) { + var events = eventNames.split(' '); + events.forEach(function (event) { + listenerList.forEach(function (item, index) { + if (item.element === element && item.query === query && item.event === event) { + element.removeEventListener(event, item.listener, item.capture); + listenerList.splice(index, 1); + } + }); + }); + }); + }, + {}, + ], + 3: [ + function (require, module, exports) { + // Polyfill for creating CustomEvents on IE9/10/11 - var events = eventNames.split(' '); - events.forEach(function (event) { - var listener = function listener(e) { - var delegateTarget = findAncestor(e.target, query); - if (delegateTarget) { - e.delegateTarget = delegateTarget; - fn(e); - } - }; - listenerList.push({ listener: listener, element: element, query: query, event: event, capture: capture }); - element.addEventListener(event, listener, capture); - }); -}; - -var off = exports.off = function off(element, query, eventNames) { - var events = eventNames.split(' '); - events.forEach(function (event) { - listenerList.forEach(function (item, index) { - if (item.element === element && item.query === query && item.event === event) { - element.removeEventListener(event, item.listener, item.capture); - listenerList.splice(index, 1); - } - }); - }); -}; -},{}],3:[function(require,module,exports){ -// Polyfill for creating CustomEvents on IE9/10/11 - -// code pulled from: -// https://github.com/d4tocchini/customevent-polyfill -// https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent#Polyfill - -try { - var ce = new window.CustomEvent('test'); - ce.preventDefault(); - if (ce.defaultPrevented !== true) { - // IE has problems with .preventDefault() on custom events - // http://stackoverflow.com/questions/23349191 - throw new Error('Could not prevent default'); - } -} catch(e) { - var CustomEvent = function(event, params) { - var evt, origPrevent; - params = params || { - bubbles: false, - cancelable: false, - detail: undefined - }; - - evt = document.createEvent("CustomEvent"); - evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail); - origPrevent = evt.preventDefault; - evt.preventDefault = function () { - origPrevent.call(this); - try { - Object.defineProperty(this, 'defaultPrevented', { - get: function () { - return true; + // code pulled from: + // https://github.com/d4tocchini/customevent-polyfill + // https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent#Polyfill + + try { + var ce = new window.CustomEvent('test'); + ce.preventDefault(); + if (ce.defaultPrevented !== true) { + // IE has problems with .preventDefault() on custom events + // http://stackoverflow.com/questions/23349191 + throw new Error('Could not prevent default'); } - }); - } catch(e) { - this.defaultPrevented = true; - } - }; - return evt; - }; - - CustomEvent.prototype = window.Event.prototype; - window.CustomEvent = CustomEvent; // expose definition to window -} - -},{}],4:[function(require,module,exports){ -(function (global,setImmediate){ -(function(global){ - -// -// Check for native Promise and it has correct interface -// - -var NativePromise = global['Promise']; -var nativePromiseSupported = - NativePromise && - // Some of these methods are missing from - // Firefox/Chrome experimental implementations - 'resolve' in NativePromise && - 'reject' in NativePromise && - 'all' in NativePromise && - 'race' in NativePromise && - // Older version of the spec had a resolver object - // as the arg rather than a function - (function(){ - var resolve; - new NativePromise(function(r){ resolve = r; }); - return typeof resolve === 'function'; - })(); - - -// -// export if necessary -// - -if (typeof exports !== 'undefined' && exports) -{ - // node.js - exports.Promise = nativePromiseSupported ? NativePromise : Promise; - exports.Polyfill = Promise; -} -else -{ - // AMD - if (typeof define == 'function' && define.amd) - { - define(function(){ - return nativePromiseSupported ? NativePromise : Promise; - }); - } - else - { - // in browser add to global - if (!nativePromiseSupported) - global['Promise'] = Promise; - } -} + } catch (e) { + var CustomEvent = function (event, params) { + var evt, origPrevent; + params = params || { + bubbles: false, + cancelable: false, + detail: undefined, + }; + + evt = document.createEvent('CustomEvent'); + evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail); + origPrevent = evt.preventDefault; + evt.preventDefault = function () { + origPrevent.call(this); + try { + Object.defineProperty(this, 'defaultPrevented', { + get: function () { + return true; + }, + }); + } catch (e) { + this.defaultPrevented = true; + } + }; + return evt; + }; + + CustomEvent.prototype = window.Event.prototype; + window.CustomEvent = CustomEvent; // expose definition to window + } + }, + {}, + ], + 4: [ + function (require, module, exports) { + (function (global, setImmediate) { + (function (global) { + // + // Check for native Promise and it has correct interface + // + + var NativePromise = global['Promise']; + var nativePromiseSupported = + NativePromise && + // Some of these methods are missing from + // Firefox/Chrome experimental implementations + 'resolve' in NativePromise && + 'reject' in NativePromise && + 'all' in NativePromise && + 'race' in NativePromise && + // Older version of the spec had a resolver object + // as the arg rather than a function + (function () { + var resolve; + new NativePromise(function (r) { + resolve = r; + }); + return typeof resolve === 'function'; + })(); + + // + // export if necessary + // + + if (typeof exports !== 'undefined' && exports) { + // node.js + exports.Promise = nativePromiseSupported ? NativePromise : Promise; + exports.Polyfill = Promise; + } else { + // AMD + if (typeof define == 'function' && define.amd) { + define(function () { + return nativePromiseSupported ? NativePromise : Promise; + }); + } else { + // in browser add to global + if (!nativePromiseSupported) global['Promise'] = Promise; + } + } + + // + // Polyfill + // + var PENDING = 'pending'; + var SEALED = 'sealed'; + var FULFILLED = 'fulfilled'; + var REJECTED = 'rejected'; + var NOOP = function () {}; -// -// Polyfill -// + function isArray(value) { + return Object.prototype.toString.call(value) === '[object Array]'; + } -var PENDING = 'pending'; -var SEALED = 'sealed'; -var FULFILLED = 'fulfilled'; -var REJECTED = 'rejected'; -var NOOP = function(){}; + // async calls + var asyncSetTimer = typeof setImmediate !== 'undefined' ? setImmediate : setTimeout; + var asyncQueue = []; + var asyncTimer; -function isArray(value) { - return Object.prototype.toString.call(value) === '[object Array]'; -} + function asyncFlush() { + // run promise callbacks + for (var i = 0; i < asyncQueue.length; i++) asyncQueue[i][0](asyncQueue[i][1]); -// async calls -var asyncSetTimer = typeof setImmediate !== 'undefined' ? setImmediate : setTimeout; -var asyncQueue = []; -var asyncTimer; + // reset async asyncQueue + asyncQueue = []; + asyncTimer = false; + } -function asyncFlush(){ - // run promise callbacks - for (var i = 0; i < asyncQueue.length; i++) - asyncQueue[i][0](asyncQueue[i][1]); + function asyncCall(callback, arg) { + asyncQueue.push([callback, arg]); - // reset async asyncQueue - asyncQueue = []; - asyncTimer = false; -} + if (!asyncTimer) { + asyncTimer = true; + asyncSetTimer(asyncFlush, 0); + } + } -function asyncCall(callback, arg){ - asyncQueue.push([callback, arg]); + function invokeResolver(resolver, promise) { + function resolvePromise(value) { + resolve(promise, value); + } - if (!asyncTimer) - { - asyncTimer = true; - asyncSetTimer(asyncFlush, 0); - } -} + function rejectPromise(reason) { + reject(promise, reason); + } + try { + resolver(resolvePromise, rejectPromise); + } catch (e) { + rejectPromise(e); + } + } -function invokeResolver(resolver, promise) { - function resolvePromise(value) { - resolve(promise, value); - } + function invokeCallback(subscriber) { + var owner = subscriber.owner; + var settled = owner.state_; + var value = owner.data_; + var callback = subscriber[settled]; + var promise = subscriber.then; + + if (typeof callback === 'function') { + settled = FULFILLED; + try { + value = callback(value); + } catch (e) { + reject(promise, e); + } + } - function rejectPromise(reason) { - reject(promise, reason); - } + if (!handleThenable(promise, value)) { + if (settled === FULFILLED) resolve(promise, value); - try { - resolver(resolvePromise, rejectPromise); - } catch(e) { - rejectPromise(e); - } -} + if (settled === REJECTED) reject(promise, value); + } + } -function invokeCallback(subscriber){ - var owner = subscriber.owner; - var settled = owner.state_; - var value = owner.data_; - var callback = subscriber[settled]; - var promise = subscriber.then; + function handleThenable(promise, value) { + var resolved; - if (typeof callback === 'function') - { - settled = FULFILLED; - try { - value = callback(value); - } catch(e) { - reject(promise, e); - } - } + try { + if (promise === value) + throw new TypeError('A promises callback cannot return that same promise.'); - if (!handleThenable(promise, value)) - { - if (settled === FULFILLED) - resolve(promise, value); + if (value && (typeof value === 'function' || typeof value === 'object')) { + var then = value.then; // then should be retrived only once - if (settled === REJECTED) - reject(promise, value); - } -} - -function handleThenable(promise, value) { - var resolved; - - try { - if (promise === value) - throw new TypeError('A promises callback cannot return that same promise.'); - - if (value && (typeof value === 'function' || typeof value === 'object')) - { - var then = value.then; // then should be retrived only once - - if (typeof then === 'function') - { - then.call(value, function(val){ - if (!resolved) - { - resolved = true; - - if (value !== val) - resolve(promise, val); - else - fulfill(promise, val); - } - }, function(reason){ - if (!resolved) - { - resolved = true; + if (typeof then === 'function') { + then.call( + value, + function (val) { + if (!resolved) { + resolved = true; - reject(promise, reason); - } - }); + if (value !== val) resolve(promise, val); + else fulfill(promise, val); + } + }, + function (reason) { + if (!resolved) { + resolved = true; - return true; - } - } - } catch (e) { - if (!resolved) - reject(promise, e); + reject(promise, reason); + } + } + ); - return true; - } + return true; + } + } + } catch (e) { + if (!resolved) reject(promise, e); - return false; -} + return true; + } -function resolve(promise, value){ - if (promise === value || !handleThenable(promise, value)) - fulfill(promise, value); -} + return false; + } -function fulfill(promise, value){ - if (promise.state_ === PENDING) - { - promise.state_ = SEALED; - promise.data_ = value; + function resolve(promise, value) { + if (promise === value || !handleThenable(promise, value)) fulfill(promise, value); + } - asyncCall(publishFulfillment, promise); - } -} + function fulfill(promise, value) { + if (promise.state_ === PENDING) { + promise.state_ = SEALED; + promise.data_ = value; -function reject(promise, reason){ - if (promise.state_ === PENDING) - { - promise.state_ = SEALED; - promise.data_ = reason; + asyncCall(publishFulfillment, promise); + } + } - asyncCall(publishRejection, promise); - } -} + function reject(promise, reason) { + if (promise.state_ === PENDING) { + promise.state_ = SEALED; + promise.data_ = reason; -function publish(promise) { - var callbacks = promise.then_; - promise.then_ = undefined; + asyncCall(publishRejection, promise); + } + } - for (var i = 0; i < callbacks.length; i++) { - invokeCallback(callbacks[i]); - } -} + function publish(promise) { + var callbacks = promise.then_; + promise.then_ = undefined; -function publishFulfillment(promise){ - promise.state_ = FULFILLED; - publish(promise); -} + for (var i = 0; i < callbacks.length; i++) { + invokeCallback(callbacks[i]); + } + } -function publishRejection(promise){ - promise.state_ = REJECTED; - publish(promise); -} + function publishFulfillment(promise) { + promise.state_ = FULFILLED; + publish(promise); + } -/** -* @class -*/ -function Promise(resolver){ - if (typeof resolver !== 'function') - throw new TypeError('Promise constructor takes a function argument'); - - if (this instanceof Promise === false) - throw new TypeError('Failed to construct \'Promise\': Please use the \'new\' operator, this object constructor cannot be called as a function.'); - - this.then_ = []; - - invokeResolver(resolver, this); -} - -Promise.prototype = { - constructor: Promise, - - state_: PENDING, - then_: null, - data_: undefined, - - then: function(onFulfillment, onRejection){ - var subscriber = { - owner: this, - then: new this.constructor(NOOP), - fulfilled: onFulfillment, - rejected: onRejection - }; - - if (this.state_ === FULFILLED || this.state_ === REJECTED) - { - // already resolved, call callback async - asyncCall(invokeCallback, subscriber); - } - else - { - // subscribe - this.then_.push(subscriber); - } + function publishRejection(promise) { + promise.state_ = REJECTED; + publish(promise); + } - return subscriber.then; - }, + /** + * @class + */ + function Promise(resolver) { + if (typeof resolver !== 'function') + throw new TypeError('Promise constructor takes a function argument'); - 'catch': function(onRejection) { - return this.then(null, onRejection); - } -}; + if (this instanceof Promise === false) + throw new TypeError( + "Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function." + ); -Promise.all = function(promises){ - var Class = this; + this.then_ = []; - if (!isArray(promises)) - throw new TypeError('You must pass an array to Promise.all().'); + invokeResolver(resolver, this); + } - return new Class(function(resolve, reject){ - var results = []; - var remaining = 0; + Promise.prototype = { + constructor: Promise, - function resolver(index){ - remaining++; - return function(value){ - results[index] = value; - if (!--remaining) - resolve(results); - }; - } + state_: PENDING, + then_: null, + data_: undefined, - for (var i = 0, promise; i < promises.length; i++) - { - promise = promises[i]; + then: function (onFulfillment, onRejection) { + var subscriber = { + owner: this, + then: new this.constructor(NOOP), + fulfilled: onFulfillment, + rejected: onRejection, + }; - if (promise && typeof promise.then === 'function') - promise.then(resolver(i), reject); - else - results[i] = promise; - } + if (this.state_ === FULFILLED || this.state_ === REJECTED) { + // already resolved, call callback async + asyncCall(invokeCallback, subscriber); + } else { + // subscribe + this.then_.push(subscriber); + } - if (!remaining) - resolve(results); - }); -}; + return subscriber.then; + }, -Promise.race = function(promises){ - var Class = this; + catch: function (onRejection) { + return this.then(null, onRejection); + }, + }; - if (!isArray(promises)) - throw new TypeError('You must pass an array to Promise.race().'); + Promise.all = function (promises) { + var Class = this; - return new Class(function(resolve, reject) { - for (var i = 0, promise; i < promises.length; i++) - { - promise = promises[i]; + if (!isArray(promises)) + throw new TypeError('You must pass an array to Promise.all().'); - if (promise && typeof promise.then === 'function') - promise.then(resolve, reject); - else - resolve(promise); - } - }); -}; + return new Class(function (resolve, reject) { + var results = []; + var remaining = 0; -Promise.resolve = function(value){ - var Class = this; + function resolver(index) { + remaining++; + return function (value) { + results[index] = value; + if (!--remaining) resolve(results); + }; + } - if (value && typeof value === 'object' && value.constructor === Class) - return value; + for (var i = 0, promise; i < promises.length; i++) { + promise = promises[i]; - return new Class(function(resolve){ - resolve(value); - }); -}; + if (promise && typeof promise.then === 'function') + promise.then(resolver(i), reject); + else results[i] = promise; + } -Promise.reject = function(reason){ - var Class = this; + if (!remaining) resolve(results); + }); + }; - return new Class(function(resolve, reject){ - reject(reason); - }); -}; + Promise.race = function (promises) { + var Class = this; -})(typeof window != 'undefined' ? window : typeof global != 'undefined' ? global : typeof self != 'undefined' ? self : this); + if (!isArray(promises)) + throw new TypeError('You must pass an array to Promise.race().'); -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("timers").setImmediate) -},{"timers":8}],5:[function(require,module,exports){ -'use strict'; -if (!Array.prototype.find) { - Object.defineProperty(Array.prototype, 'find', { - value: function (predicate) { + return new Class(function (resolve, reject) { + for (var i = 0, promise; i < promises.length; i++) { + promise = promises[i]; - if (this == null) { + if (promise && typeof promise.then === 'function') promise.then(resolve, reject); + else resolve(promise); + } + }); + }; + + Promise.resolve = function (value) { + var Class = this; + + if (value && typeof value === 'object' && value.constructor === Class) return value; + + return new Class(function (resolve) { + resolve(value); + }); + }; + + Promise.reject = function (reason) { + var Class = this; + + return new Class(function (resolve, reject) { + reject(reason); + }); + }; + })( + typeof window != 'undefined' + ? window + : typeof global != 'undefined' + ? global + : typeof self != 'undefined' + ? self + : this + ); + }).call( + this, + typeof global !== 'undefined' + ? global + : typeof self !== 'undefined' + ? self + : typeof window !== 'undefined' + ? window + : {}, + require('timers').setImmediate + ); + }, + { timers: 8 }, + ], + 5: [ + function (require, module, exports) { + 'use strict'; + if (!Array.prototype.find) { + Object.defineProperty(Array.prototype, 'find', { + value: function (predicate) { + if (this == null) { throw new TypeError('this is null or not defined'); - } + } - var obj = Object(this); - var len = obj.length >>> 0; + var obj = Object(this); + var len = obj.length >>> 0; - if (typeof predicate !== 'function') { + if (typeof predicate !== 'function') { throw new TypeError('predicate must be a function'); - } + } - var thisArg = arguments[1]; + var thisArg = arguments[1]; - var index = 0; + var index = 0; - while (index < len) { + while (index < len) { var iValue = obj[index]; if (predicate.call(thisArg, iValue, index, obj)) { - return iValue; + return iValue; } index++; - } + } - return undefined; + return undefined; + }, + }); } - }); -} -},{}],6:[function(require,module,exports){ -'use strict'; - -var DOCUMENT_FRAGMENT_NODE = 11; - -function morphAttrs(fromNode, toNode) { - var toNodeAttrs = toNode.attributes; - var attr; - var attrName; - var attrNamespaceURI; - var attrValue; - var fromValue; - - // document-fragments dont have attributes so lets not do anything - if (toNode.nodeType === DOCUMENT_FRAGMENT_NODE || fromNode.nodeType === DOCUMENT_FRAGMENT_NODE) { - return; - } + }, + {}, + ], + 6: [ + function (require, module, exports) { + 'use strict'; + + var DOCUMENT_FRAGMENT_NODE = 11; + + function morphAttrs(fromNode, toNode) { + var toNodeAttrs = toNode.attributes; + var attr; + var attrName; + var attrNamespaceURI; + var attrValue; + var fromValue; + + // document-fragments dont have attributes so lets not do anything + if ( + toNode.nodeType === DOCUMENT_FRAGMENT_NODE || + fromNode.nodeType === DOCUMENT_FRAGMENT_NODE + ) { + return; + } - // update attributes on original DOM element - for (var i = toNodeAttrs.length - 1; i >= 0; i--) { - attr = toNodeAttrs[i]; - attrName = attr.name; - attrNamespaceURI = attr.namespaceURI; - attrValue = attr.value; + // update attributes on original DOM element + for (var i = toNodeAttrs.length - 1; i >= 0; i--) { + attr = toNodeAttrs[i]; + attrName = attr.name; + attrNamespaceURI = attr.namespaceURI; + attrValue = attr.value; - if (attrNamespaceURI) { - attrName = attr.localName || attrName; - fromValue = fromNode.getAttributeNS(attrNamespaceURI, attrName); + if (attrNamespaceURI) { + attrName = attr.localName || attrName; + fromValue = fromNode.getAttributeNS(attrNamespaceURI, attrName); - if (fromValue !== attrValue) { - if (attr.prefix === 'xmlns'){ - attrName = attr.name; // It's not allowed to set an attribute with the XMLNS namespace without specifying the `xmlns` prefix + if (fromValue !== attrValue) { + if (attr.prefix === 'xmlns') { + attrName = attr.name; // It's not allowed to set an attribute with the XMLNS namespace without specifying the `xmlns` prefix } fromNode.setAttributeNS(attrNamespaceURI, attrName, attrValue); - } - } else { - fromValue = fromNode.getAttribute(attrName); + } + } else { + fromValue = fromNode.getAttribute(attrName); - if (fromValue !== attrValue) { + if (fromValue !== attrValue) { fromNode.setAttribute(attrName, attrValue); + } } - } - } + } - // Remove any extra attributes found on the original DOM element that - // weren't found on the target element. - var fromNodeAttrs = fromNode.attributes; + // Remove any extra attributes found on the original DOM element that + // weren't found on the target element. + var fromNodeAttrs = fromNode.attributes; - for (var d = fromNodeAttrs.length - 1; d >= 0; d--) { - attr = fromNodeAttrs[d]; - attrName = attr.name; - attrNamespaceURI = attr.namespaceURI; + for (var d = fromNodeAttrs.length - 1; d >= 0; d--) { + attr = fromNodeAttrs[d]; + attrName = attr.name; + attrNamespaceURI = attr.namespaceURI; - if (attrNamespaceURI) { - attrName = attr.localName || attrName; + if (attrNamespaceURI) { + attrName = attr.localName || attrName; - if (!toNode.hasAttributeNS(attrNamespaceURI, attrName)) { + if (!toNode.hasAttributeNS(attrNamespaceURI, attrName)) { fromNode.removeAttributeNS(attrNamespaceURI, attrName); - } - } else { - if (!toNode.hasAttribute(attrName)) { + } + } else { + if (!toNode.hasAttribute(attrName)) { fromNode.removeAttribute(attrName); + } } + } } - } -} -var range; // Create a range object for efficently rendering strings to elements. -var NS_XHTML = 'http://www.w3.org/1999/xhtml'; + var range; // Create a range object for efficently rendering strings to elements. + var NS_XHTML = 'http://www.w3.org/1999/xhtml'; -var doc = typeof document === 'undefined' ? undefined : document; -var HAS_TEMPLATE_SUPPORT = !!doc && 'content' in doc.createElement('template'); -var HAS_RANGE_SUPPORT = !!doc && doc.createRange && 'createContextualFragment' in doc.createRange(); + var doc = typeof document === 'undefined' ? undefined : document; + var HAS_TEMPLATE_SUPPORT = !!doc && 'content' in doc.createElement('template'); + var HAS_RANGE_SUPPORT = + !!doc && doc.createRange && 'createContextualFragment' in doc.createRange(); -function createFragmentFromTemplate(str) { - var template = doc.createElement('template'); - template.innerHTML = str; - return template.content.childNodes[0]; -} + function createFragmentFromTemplate(str) { + var template = doc.createElement('template'); + template.innerHTML = str; + return template.content.childNodes[0]; + } -function createFragmentFromRange(str) { - if (!range) { - range = doc.createRange(); - range.selectNode(doc.body); - } + function createFragmentFromRange(str) { + if (!range) { + range = doc.createRange(); + range.selectNode(doc.body); + } - var fragment = range.createContextualFragment(str); - return fragment.childNodes[0]; -} + var fragment = range.createContextualFragment(str); + return fragment.childNodes[0]; + } -function createFragmentFromWrap(str) { - var fragment = doc.createElement('body'); - fragment.innerHTML = str; - return fragment.childNodes[0]; -} + function createFragmentFromWrap(str) { + var fragment = doc.createElement('body'); + fragment.innerHTML = str; + return fragment.childNodes[0]; + } -/** - * This is about the same - * var html = new DOMParser().parseFromString(str, 'text/html'); - * return html.body.firstChild; - * - * @method toElement - * @param {String} str - */ -function toElement(str) { - str = str.trim(); - if (HAS_TEMPLATE_SUPPORT) { - // avoid restrictions on content for things like `Hi` which - // createContextualFragment doesn't support - //