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 cf26384..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,12 +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: 102; } .smartphoto-body { @@ -226,7 +227,7 @@ animation-timing-function: ease-out; } -.smartphoto-arrows[aria-hidden="true"] { +.smartphoto-arrows[aria-hidden='true'] { animation-name: smartphoto-hide; display: none; } @@ -248,7 +249,7 @@ outline: none; } -.smartphoto-arrows [aria-hidden="true"] { +.smartphoto-arrows [aria-hidden='true'] { animation-name: smartphoto-hide; display: none; } @@ -295,7 +296,7 @@ animation-timing-function: ease-out; } -.smartphoto-nav[aria-hidden="true"] { +.smartphoto-nav[aria-hidden='true'] { animation-name: smartphoto-hide; display: none; } @@ -322,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 { @@ -379,7 +380,7 @@ width: 100%; height: 50px; padding: 0 50px; - color: #FFF; + color: #fff; font-size: 12px; text-align: center; line-height: 50px; @@ -409,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 710a190..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}.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/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..5c6f805 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) @@ -15,14 +15,13 @@ * * custom-event-polyfill: * license: MIT (http://opensource.org/licenses/MIT) - * contributors: Frank Panetta, Mikhail Reenko , Joscha Feth - * homepage: https://github.com/krambuhl/custom-event-polyfill#readme + * author: NO AUTHOR! + * contributors: Frank Panetta (http://www.savvi.io), Mikhail Reenko , Joscha Feth (http://www.feth.com) * version: 0.3.0 * * es6-promise-polyfill: * license: MIT (http://opensource.org/licenses/MIT) * author: Roman Dvornov - * homepage: https://github.com/lahmatiy/es6-promise-polyfill#readme * version: 1.2.0 * * ie-array-find-polyfill: @@ -34,3916 +33,4374 @@ * morphdom: * license: MIT (http://opensource.org/licenses/MIT) * author: Patrick Steele-Idem - * homepage: https://github.com/patrick-steele-idem/morphdom#readme * version: 2.5.12 * * process: * license: MIT (http://opensource.org/licenses/MIT) * author: Roman Shtylman - * homepage: https://github.com/shtylman/node-process#readme * version: 0.11.10 * * timers-browserify: * licenses: MIT (http://opensource.org/licenses/MIT) - * author: J. Ryan Stinnett + * author: J. Ryan Stinnett (http://convolv.es/) * contributors: Guy Bedford , Ionut-Cristian Florescu , James Halliday , Jan Schär , Johannes Ewald , Jonathan Prins , Matt Esch * homepage: https://github.com/jryans/timers-browserify * version: 1.4.2 * * 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; - } - } - 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 _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); +(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 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 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 (_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; + return n[i].exports; } - element = element.parentElement; + for (var u = 'function' == typeof require && require, i = 0; i < t.length; i++) o(t[i]); + return o; } - return null; -}; - -var listenerList = []; - -var on = exports.on = function on(element, query, eventNames, fn) { - var capture = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false; - - 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; - } - }); - } 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(){}; - -function isArray(value) { - return Object.prototype.toString.call(value) === '[object Array]'; -} - -// async calls -var asyncSetTimer = typeof setImmediate !== 'undefined' ? setImmediate : setTimeout; -var asyncQueue = []; -var asyncTimer; - -function asyncFlush(){ - // run promise callbacks - for (var i = 0; i < asyncQueue.length; i++) - asyncQueue[i][0](asyncQueue[i][1]); - - // reset async asyncQueue - asyncQueue = []; - asyncTimer = false; -} - -function asyncCall(callback, arg){ - asyncQueue.push([callback, arg]); - - if (!asyncTimer) - { - asyncTimer = true; - asyncSetTimer(asyncFlush, 0); - } -} - - -function invokeResolver(resolver, promise) { - function resolvePromise(value) { - resolve(promise, value); - } - - function rejectPromise(reason) { - reject(promise, reason); - } - - try { - resolver(resolvePromise, rejectPromise); - } catch(e) { - rejectPromise(e); - } -} - -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); - } - } - - if (!handleThenable(promise, value)) - { - if (settled === FULFILLED) - resolve(promise, value); - - 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; - - reject(promise, reason); - } - }); - - return true; - } - } - } catch (e) { - if (!resolved) - reject(promise, e); - - return true; - } - - return false; -} - -function resolve(promise, value){ - if (promise === value || !handleThenable(promise, value)) - fulfill(promise, value); -} - -function fulfill(promise, value){ - if (promise.state_ === PENDING) - { - promise.state_ = SEALED; - promise.data_ = value; - - asyncCall(publishFulfillment, promise); - } -} - -function reject(promise, reason){ - if (promise.state_ === PENDING) - { - promise.state_ = SEALED; - promise.data_ = reason; - - asyncCall(publishRejection, promise); - } -} - -function publish(promise) { - var callbacks = promise.then_; - promise.then_ = undefined; - - for (var i = 0; i < callbacks.length; i++) { - invokeCallback(callbacks[i]); - } -} - -function publishFulfillment(promise){ - promise.state_ = FULFILLED; - publish(promise); -} - -function publishRejection(promise){ - promise.state_ = REJECTED; - 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); - } - - return subscriber.then; - }, - - 'catch': function(onRejection) { - return this.then(null, onRejection); - } -}; - -Promise.all = function(promises){ - var Class = this; - - if (!isArray(promises)) - throw new TypeError('You must pass an array to Promise.all().'); - - return new Class(function(resolve, reject){ - var results = []; - var remaining = 0; - - function resolver(index){ - remaining++; - return function(value){ - results[index] = value; - if (!--remaining) - resolve(results); - }; - } - - for (var i = 0, promise; i < promises.length; i++) - { - promise = promises[i]; - - if (promise && typeof promise.then === 'function') - promise.then(resolver(i), reject); - else - results[i] = promise; - } - - if (!remaining) - resolve(results); - }); -}; - -Promise.race = function(promises){ - var Class = this; - - if (!isArray(promises)) - throw new TypeError('You must pass an array to Promise.race().'); - - return new Class(function(resolve, reject) { - for (var i = 0, promise; i < promises.length; i++) - { - promise = promises[i]; - - 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; - - if (typeof predicate !== 'function') { - throw new TypeError('predicate must be a function'); - } - - var thisArg = arguments[1]; - - var index = 0; - - while (index < len) { - var iValue = obj[index]; - if (predicate.call(thisArg, iValue, index, obj)) { - return iValue; - } - index++; - } - - 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; - } - - // 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 (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); - - 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; - - 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 (!toNode.hasAttributeNS(attrNamespaceURI, attrName)) { - fromNode.removeAttributeNS(attrNamespaceURI, 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 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 createFragmentFromRange(str) { - if (!range) { - range = doc.createRange(); - range.selectNode(doc.body); - } - - var fragment = range.createContextualFragment(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 - //