summaryrefslogtreecommitdiff
path: root/StoneIsland/platforms
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2015-11-24 20:57:41 -0500
committerJules Laplace <jules@okfoc.us>2015-11-24 20:57:41 -0500
commit612561818f907f0f9988247c82ec158ba4494986 (patch)
tree8bbc773dad7a6364cbdb8aed2ef4cab04854f49a /StoneIsland/platforms
parentd548a7d02ce6349ca9a820b6824e4374b759812b (diff)
build
Diffstat (limited to 'StoneIsland/platforms')
-rw-r--r--StoneIsland/platforms/ios/StoneIsland.xcodeproj/project.xcworkspace/xcuserdata/jules.xcuserdatad/UserInterfaceState.xcuserstatebin13429 -> 13567 bytes
-rw-r--r--StoneIsland/platforms/ios/www/css/account.css396
-rw-r--r--StoneIsland/platforms/ios/www/css/blogs.css191
-rw-r--r--StoneIsland/platforms/ios/www/css/cart.css164
-rw-r--r--StoneIsland/platforms/ios/www/css/index.css19
-rw-r--r--StoneIsland/platforms/ios/www/css/nav.css199
-rw-r--r--StoneIsland/platforms/ios/www/css/products.css198
-rw-r--r--StoneIsland/platforms/ios/www/css/vendor/flickity.css141
-rw-r--r--StoneIsland/platforms/ios/www/index.html852
-rw-r--r--StoneIsland/platforms/ios/www/js/index.js29
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/_router.js106
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/account/AccountView.js70
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/account/OrdersView.js29
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/account/PaymentView.js25
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/account/ProfileView.js100
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/account/SettingsView.js23
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/account/ShippingView.js24
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/account/orders/OrderList.js17
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/account/orders/SingleOrder.js18
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/auth/LoginView.js53
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/auth/LogoutView.js15
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/auth/SignupView.js103
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/blogs/ArchiveView.js12
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/blogs/BlogView.js20
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/blogs/HubView.js67
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/blogs/PageView.js24
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/blogs/StoryView.js45
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/cart/CartBilling.js11
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/cart/CartConfirm.js29
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/cart/CartPayment.js40
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/cart/CartShipping.js28
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/cart/CartSummary.js179
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/cart/CartThanks.js23
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/cart/CartView.js38
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/nav/AddressView.js39
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/nav/CreditCardView.js27
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/nav/CurtainView.js18
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/nav/FooterView.js36
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/nav/HeaderView.js31
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/nav/IntroView.js1
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/nav/LoginView.js57
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/nav/NavView.js103
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/nav/SearchView.js16
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/products/ClosedStoreView.js47
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/products/CollectionView.js91
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/products/GalleryView.js46
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/products/ProductView.js264
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/products/Selector.js16
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/products/filters/CategoryFilter.js40
-rw-r--r--StoneIsland/platforms/ios/www/js/sdk/_sdk.js10
-rw-r--r--StoneIsland/platforms/ios/www/js/sdk/account.js66
-rw-r--r--StoneIsland/platforms/ios/www/js/sdk/address.js6
-rw-r--r--StoneIsland/platforms/ios/www/js/sdk/auth.js104
-rw-r--r--StoneIsland/platforms/ios/www/js/sdk/cart.js80
-rw-r--r--StoneIsland/platforms/ios/www/js/sdk/payment.js30
-rw-r--r--StoneIsland/platforms/ios/www/js/sdk/product.js18
-rw-r--r--StoneIsland/platforms/ios/www/js/sdk/shipping.js54
-rw-r--r--StoneIsland/platforms/ios/www/js/vendor/flickity.pkgd.js5090
-rw-r--r--StoneIsland/platforms/ios/www/js/vendor/moment.js3195
-rw-r--r--StoneIsland/platforms/ios/www/js/vendor/prefixfree.js497
-rw-r--r--StoneIsland/platforms/ios/www/js/vendor/promise.js34
-rw-r--r--StoneIsland/platforms/ios/www/js/vendor/util.js12
-rw-r--r--StoneIsland/platforms/ios/www/js/vendor/view/formview.js146
-rw-r--r--StoneIsland/platforms/ios/www/js/vendor/view/router.js8
-rw-r--r--StoneIsland/platforms/ios/www/js/vendor/view/scrollable.js20
-rw-r--r--StoneIsland/platforms/ios/www/js/vendor/view/serializable.js129
-rw-r--r--StoneIsland/platforms/ios/www/js/vendor/view/view.js11
67 files changed, 12880 insertions, 750 deletions
diff --git a/StoneIsland/platforms/ios/StoneIsland.xcodeproj/project.xcworkspace/xcuserdata/jules.xcuserdatad/UserInterfaceState.xcuserstate b/StoneIsland/platforms/ios/StoneIsland.xcodeproj/project.xcworkspace/xcuserdata/jules.xcuserdatad/UserInterfaceState.xcuserstate
index bcf4bbca..a8bb4a28 100644
--- a/StoneIsland/platforms/ios/StoneIsland.xcodeproj/project.xcworkspace/xcuserdata/jules.xcuserdatad/UserInterfaceState.xcuserstate
+++ b/StoneIsland/platforms/ios/StoneIsland.xcodeproj/project.xcworkspace/xcuserdata/jules.xcuserdatad/UserInterfaceState.xcuserstate
Binary files differ
diff --git a/StoneIsland/platforms/ios/www/css/account.css b/StoneIsland/platforms/ios/www/css/account.css
new file mode 100644
index 00000000..b709cbdb
--- /dev/null
+++ b/StoneIsland/platforms/ios/www/css/account.css
@@ -0,0 +1,396 @@
+.login #login { display: block }
+#login {
+ display: none;
+}
+
+
+.logout #logout { display: block }
+#logout {
+ display: none;
+}
+
+
+.signup #signup { display: block }
+#signup {
+ display: none;
+}
+
+
+.profile #profile { display: block }
+#profile {
+ display: none;
+}
+
+
+.payment #payment { display: block }
+#payment {
+ display: none;
+}
+
+
+.shipping #shipping { display: block }
+#shipping {
+ display: none;
+}
+
+
+.orders #orders { display: block }
+#orders {
+ display: none;
+}
+
+#orders.list {
+}
+#orders.single {
+}
+
+#order_list {
+}
+#single_order {
+}
+
+.settings #settings { display: block }
+#settings {
+ display: none;
+}
+
+
+
+form h2 {
+ text-align: center;
+ margin: 0;
+ padding: 20px 10px 8px 10px;
+ font-size: 14px;
+ color: #000;
+ letter-spacing: 1px;
+ font-weight: bold;
+}
+
+input[type=text], input[type=password], input[type=number], input[type=date], input[type=email] {
+ font-family:pfd, sans-serif;
+ font-size:14px;
+ outline:none!important;
+ color:#000;
+ letter-spacing:1px;
+ text-transform:uppercase;
+ height:35px;
+ text-align:center;
+ margin: 0px auto;
+ display:block;
+ margin-top:4px;
+ width: calc(100vw - 10px);
+ border:1px solid #a9a9a9;
+ padding: 0;
+ border-radius: 0;
+}
+
+.half-input {
+ margin: 0px auto;
+ display: block;
+ margin-top: 4px;
+ width: calc(100vw - 10px);
+ border: 1px solid #a9a9a9;
+ overflow: auto;
+}
+
+.half-input input, .half-input select {
+ position: relative;
+ margin: 0;
+ border:none;
+ box-sizing: border-box;
+ float: left;
+ width: 50%;
+}
+
+.half-input > input:first-child {
+ border-right: 1px solid #a9a9a9;
+}
+
+.toggle-container {
+ margin: 0px auto;
+ display: table;
+ margin-top: 10px;
+ width: calc(100vw - 10px);
+ box-sizing: border-box;
+ padding:10px 18px 2px;
+ font-size:14px;
+}
+
+.toggle-row {
+ display:block;
+ padding-bottom:16px;
+}
+
+.toggle-container .caption {
+ display:table-cell;
+ vertical-align:middle;
+ width:100%;
+}
+
+.toggle-container .toggle {
+ display: table-cell;
+ vertical-align: middle;
+ text-align: right;
+ position: relative;
+ right: 12px;
+}
+
+.toggle-container h3 {
+ margin:0;
+}
+
+input.switch {
+ max-height: 0;
+ max-width: 0;
+ opacity: 0;
+}
+
+input.switch + label {
+ display: inline-block;
+ box-shadow: inset 0 0 0px 1px rgba(0,0,0,.7);
+ text-indent: -5000px;
+ height: 30px;
+ width: 50px;
+ border-radius: 15px;
+ position: absolute;
+ top: 50%;
+ left: 0;
+ transform: translateX(-50%) translateY(-50%);
+}
+
+input.switch + label:before {
+ content: "";
+ position: absolute;
+ display: block;
+ height: 30px;
+ width: 30px;
+ top: 0;
+ left: 0;
+ border-radius: 15px;
+ background: rgba(19, 191, 17, 0);
+ -moz-transition: .25s ease-in-out;
+ -webkit-transition: .25s ease-in-out;
+ transition: .25s ease-in-out;
+}
+
+input.switch + label:after {
+ content: "";
+ position: absolute;
+ display: block;
+ height: 30px;
+ width: 30px;
+ top: 0;
+ left: 0px;
+ border-radius: 15px;
+ background: white;
+ box-shadow: inset 0 0 0 1px rgba(0,0,0,.7);
+ -moz-transition: .25s ease-in-out;
+ -webkit-transition: .25s ease-in-out;
+ transition: .25s ease-in-out;
+}
+
+input.switch:checked + label:before {
+ width: 50px;
+ background: #136f11;
+}
+
+input.switch:checked + label:after {
+ left: 20px;
+ box-shadow: inset 0 0 0 1px rgba(0,0,0,.7);
+}
+
+.container {
+ position:relative;
+ min-height:calc(100vh - 154px);
+ width:100vw;
+ box-sizing:border-box;
+ display: flex;
+ flex-direction: column;
+ margin:0;
+ left:0;
+ right:0;
+ top: 0;
+}
+
+
+.container-row {
+ box-sizing:border-box;
+}
+
+.container-fill {
+ min-height:40px;
+ flex: 1;
+ align-items: center;
+ justify-content: center;
+ position:relative;
+}
+
+.container-row .container-message {
+ color:#000;
+ text-align:center;
+ width:calc(100vw - 10px);
+ box-sizing:border-box;
+ margin:12px auto;
+ position:relative
+
+}
+
+.container-fill .container-message {
+ font-size:12px;
+ letter-spacing:0.5px;
+ text-align:center;
+ position:absolute;
+ top:50%;
+ left:50%;
+ width:100%;
+ -webkit-transform: translateX(-50%) translateY(-50%);
+ transform: translateX(-50%) translateY(-50%);
+ color:#000;
+}
+
+
+
+.premessage {
+ top:calc(50% - 20px)!important;
+}
+
+.submessage {
+ top:75%!important;
+}
+
+.alert-notice {
+ color:red!important
+}
+
+.checkbox-container {
+ font-size:11px;
+ width:calc(100vw - 10px);
+ display:table;
+ box-sizing:border-box;
+ margin:0 auto 5px;
+}
+
+.checkbox-toggle {
+ display:table-cell;
+ box-sizing:border-box;
+ padding-right:15px;
+ position:relative;
+}
+
+.checkbox-toggle input {
+ width:25px; height:35px;
+ opacity:0;
+}
+
+.checkbox-caption {
+ vertical-align:middle;
+ display:table-cell;
+ box-sizing:border-box;
+}
+
+.checkbox-row {
+ margin:12px 0;
+ box-sizing:border-box;
+}
+
+.checkbox-row:first-child {
+ margin:0;
+}
+
+
+.checkbox-toggle label {
+ position:absolute;
+ top:50%;
+ transform:translateY(-50%);
+ cursor: pointer;
+ width: 36px;
+ height: 36px;
+ left: 0;
+ background: #fff;
+ border:1px solid #000;
+ box-sizing:border-box;
+}
+
+.checkbox-toggle label:after {
+ opacity: 0;
+ content: "";
+ top:50%;
+ position:absolute;
+ left:50%;
+ transform:translateX(-50%) translateY(-50%) rotate(45deg);
+ width:2px;
+ height:36px;
+ background:black;
+ transition: opacity .2s;
+}
+
+.checkbox-toggle label:before {
+ opacity: 0;
+ content: "";
+ top:50%;
+ position:absolute;
+ left:50%;
+ transform:translateX(-50%) translateY(-50%) rotate(-45deg);
+ width:2px;
+ height:36px;
+ background:black;
+ transition: opacity .2s;
+}
+
+.checkbox-toggle input[type=checkbox]:checked + label:after, .checkbox-toggle input[type=checkbox]:checked + label:before,
+.checkbox-toggle input[type=radio]:checked + label:after, .checkbox-toggle input[type=radio]:checked + label:before {
+ opacity: 1;
+}
+
+.privacy-msg {
+ text-align: center;
+}
+
+.select-wrapper {
+ position: relative;
+ text-align: center;
+
+ overflow: hidden;
+ font-size: 14px;
+ outline: none !important;
+ color: #000;
+ letter-spacing: 1px;
+ text-transform: uppercase;
+ height: 35px;
+ text-align: center;
+ margin: 0px auto;
+ display: block;
+ margin-top: 4px;
+ width: calc(100vw - 10px);
+ border: 1px solid #a9a9a9;
+}
+.half-input .select-wrapper {
+ width: 50%;
+ border: 0;
+ margin-top: -1px;
+ float: left;
+}
+.half-input .select-wrapper span {
+ top: 9px;
+ color: #aaa;
+}
+.select-wrapper select {
+ opacity: 0;
+ width: 100%;
+ height: 35px;
+ line-height: 35px;
+ position: absolute;
+ top: 0; left: 0;
+ box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ -webkit-box-sizing: border-box;
+ border: 10px solid;
+}
+.select-wrapper span {
+ position: relative;
+ top: 8px;
+ color: #888;
+}
+.select-wrapper.picked span {
+ color: #000;
+} \ No newline at end of file
diff --git a/StoneIsland/platforms/ios/www/css/blogs.css b/StoneIsland/platforms/ios/www/css/blogs.css
index ec945f65..239e99bf 100644
--- a/StoneIsland/platforms/ios/www/css/blogs.css
+++ b/StoneIsland/platforms/ios/www/css/blogs.css
@@ -1,17 +1,202 @@
.story #story { display: block }
-#content.story { overflow: scroll }
#story {
display: none;
}
+#story .links {
+ margin: 15px 0 0;
+ text-align: center;
+ text-transform:uppercase;
+}
+#story .links li {
+ padding: 10px;
+ list-style-type: none;
+ display: inline-block;
+}
+#story .links li:before {
+ content: ' | ',
+}
+#story .links li:first-child:before {
+ content: '',
+}
+#story .links li.active {
+ font-weight: bold;
+ text-decoration: underline;
+}
+#story .content > div {
+ display: none;
+}
+#story .content div.active {
+ display: block;
+}
.hub #hub { display: block }
-#content.hub { overflow: scroll }
#hub {
display: none;
}
.archive #archive { display: block }
-#content.archive { overflow: scroll }
#archive {
display: none;
+}
+
+.privacy #privacy { display: block }
+.terms #terms { display: block }
+.returns #returns { display: block }
+.care #care { display: block }
+.page {
+ display: none;
+}
+
+.page .content {
+ padding: 10px;
+}
+
+#content .content .body {
+ letter-spacing:0.35px;
+ font-size:12px;
+ width:calc(100vw - 40px);
+ box-sizing:border-box;
+ margin:10px auto 20px;
+}
+
+#content .content .body:last-child {
+ margin:10px auto 100px;
+}
+
+.content-header {
+ width:calc(100vw - 40px);
+ box-sizing:border-box;
+ margin:20px auto 0px;
+}
+
+.content-header .title, .content-header .subtitle {
+ display:block;
+ font-weight:bold;
+ font-size:14px;
+ text-transform:uppercase
+}
+
+.content-header .title {
+ margin:0;
+ padding:0;
+ line-height:13px;
+}
+
+.content-header .subtitle {
+ padding-bottom:10px
+}
+
+.content-share {
+ border:1px solid black;
+ padding:4px 8px;
+ float:right
+}
+
+.content-header span.date, .content-header span.store {
+ font-size:10px;
+}
+
+/* NOTE: optional arrows */
+
+.gallery-multiple-images::before {
+ border:1px solid black;
+ top:50%;
+ transform:scale(.5,1) translateY(-50%);
+ transform-origin:top left;
+ left:20px;
+ content:'\25C0';
+ font-size:18px;
+ padding:3px 14px 3px 11px;
+ z-index:999;
+ position:absolute;
+ display:block;
+ background:rgba(255,255,255,1);
+}
+
+.gallery-multiple-images::after {
+ border:1px solid black;
+ top:50%;
+ transform:scale(.5,1) translateY(-50%);
+ transform-origin:top right;
+ right:20px;
+ content:'\25B6';
+ font-size:18px;
+ padding:3px 11px 3px 14px;
+ z-index:999;
+ position:absolute;
+ display:block;
+ background:rgba(255,255,255,1);
+}
+
+/* NOTE: not sure if this down arrow is necessary.. the fade
+ might do..? what do you think? it can be removed
+ with javascript when the body hits the bottom of
+ the page */
+
+.fade-cover {
+ background: linear-gradient(rgba(255,255,255,0), rgba(255,255,255,1));
+ position:fixed;
+ bottom:0;
+ width:100vw;
+ height:100px;
+ box-sizing:border-box
+}
+
+.fade-cover::before {
+ border:1px solid black;
+ top:50%;
+ left:50%;
+ margin-left:-24px;
+ transform:scale(1,.5) translateY(-50%);
+ transform-origin:bottom right;
+ content:'\25BC';
+ font-size:17px;
+ padding:9px 11px;
+ z-index:999;
+ position:absolute;
+ display:block;
+ background:rgba(255,255,255,1);
+}
+
+#story img {
+ box-sizing:border-box;
+ width:calc(100vw + 150px);
+ position:relative;
+ left:-75px;
+}
+
+ul.links {
+ -webkit-padding-start: 0px!important
+}
+
+.archive h1 {
+ font-size:26px;
+ border-bottom:0;
+ margin-top:8px;
+ padding-bottom:0;
+ line-height:24px;
+}
+
+.archive .subtitle {
+ box-sizing:border-box;
+ width:calc(100vw - 10px);
+ position:relative;
+ text-align:center;
+ margin:0 0 12px;
+ padding:0;
+ font-weight:bold;
+ font-size:14px;
+}
+
+/* NOTE: not really sure how this is going to work on the archive page
+ based on the pdf mockup */
+
+.archive .above {
+ width:calc(100vw - 80px);
+ box-sizing:border-box;
+ margin:0 auto;
+}
+
+.archive h2 {
+font-size:32px
} \ No newline at end of file
diff --git a/StoneIsland/platforms/ios/www/css/cart.css b/StoneIsland/platforms/ios/www/css/cart.css
index 5a5efcd6..bc5088d5 100644
--- a/StoneIsland/platforms/ios/www/css/cart.css
+++ b/StoneIsland/platforms/ios/www/css/cart.css
@@ -19,22 +19,174 @@
display: inline-block;
font-size: 13px;
text-align: center;
- padding: 5px 0;
+ padding: 11px 0 10px;
color: #bbb;
width: 33%;
+ position:relative;
}
-#cart .steps span.active {
- color: #888;
+.summary_step, .shipping_step {
+border-right: 1px solid #bbb
}
-#summary {
+#cart.summary .summary_step,
+#cart.payment .payment_step,
+#cart.shipping .shipping_step {
+ color: #000;
+}
+
+#cart_summary,
+#cart_shipping,
+#cart_payment,
+#cart_confirm,
+#cart_thanks {
+ height: calc(100vh - 195px);
+ overflow: hidden;
+ position: relative;
+}
+
+#cart.summary #cart_summary { display: block }
+#cart_summary {
+ display: none;
+}
+
+.full .cart_body { display: block; }
+.empty .cart_empty { display: block; }
+.cart_body {
display: none;
}
+.cart_empty {
+ display: none;
+ text-align: center;
+ margin: 0;
+}
-#shipping {
+#cart.payment #cart_payment { display: block }
+#cart_payment {
display: none;
}
-#billing {
+#cart.shipping #cart_shipping { display: block }
+#cart_shipping {
display: none;
}
+
+#cart.confirm #cart_confirm { display: block }
+#cart_confirm {
+ display: none;
+}
+
+#cart.thanks #cart_thanks { display: block }
+#cart_thanks {
+ display: none;
+}
+
+.summary-container {
+ top:0px;
+}
+
+.billing-container {
+ min-height:calc(100vh - 210px);
+ top:16px;
+}
+
+.cart_item_row {
+display:table;
+position:relative;
+width:calc(100vw - 30px);
+margin:0 auto;
+box-sizing:border-box;
+padding-top:20px;
+}
+
+.cart_item_info, .cart_item_price {
+display:table-cell;
+vertical-align:bottom;
+box-sizing:border-box
+}
+
+.cart_item_image {
+display:table-cell;
+vertical-align:middle;
+box-sizing:border-box
+}
+
+.cart_item_image img {
+max-width:calc(33vw - 25px);
+}
+
+.cart_item_info {
+padding-left:30px;
+padding-bottom:5px;
+position:relative;
+width:100%
+}
+
+.cart_item_price {
+text-align:right;
+position:relative;
+padding-bottom:5px;
+padding-left:5px;
+}
+
+.cart_item_price .price {
+font-size:11px;
+font-weight:bold;
+display:block
+}
+
+.cart_item_info .sku {
+font-size:10px;
+font-weight:bold;
+display:block
+}
+
+.cart_item_info .title {
+font-size:10px;
+font-weight:bold;
+display:block;
+line-height:12px;
+text-transform:uppercase;
+}
+
+.cart_item_info .type {
+font-size:10px;
+font-weight:bold;
+display:block;
+text-transform:capitalize;
+}
+
+.cart_item_info .meta {
+padding-top:5px;
+letter-spacing:.75px;
+font-size:8px;
+}
+
+.cart-summary {
+width:calc(100vw - 30px);
+margin:0 auto;
+display:table;
+color:#bbb;
+font-size:11px;
+}
+
+.cart-summary-row {
+display:table-row;
+}
+
+.cart-summary span {
+display:table-cell;
+padding-top:20px;
+vertical-align:bottom;
+}
+
+.cart-summary-row span:not(.label) {
+text-align:right
+}
+
+.cart-summary-row .label {
+font-weight:bold
+}
+
+.cart-summary-row:last-child {
+color:#000;
+} \ No newline at end of file
diff --git a/StoneIsland/platforms/ios/www/css/index.css b/StoneIsland/platforms/ios/www/css/index.css
index db803fa9..0d855aeb 100644
--- a/StoneIsland/platforms/ios/www/css/index.css
+++ b/StoneIsland/platforms/ios/www/css/index.css
@@ -12,7 +12,7 @@ body {
-webkit-touch-callout: none; /* prevent callout to copy image, etc when tap to hold */
-webkit-text-size-adjust: none; /* prevent webkit from resizing text to fit */
-webkit-user-select: none; /* prevent copy paste, to allow, change 'none' to 'text' */
- background: #eeeeee;
+ background: #fff;
font-family: pfd, sans-serif;
font-size: 12px;
}
@@ -22,16 +22,16 @@ body {
width: 80px;
height: 80px;
position: absolute;
- top: 50%;
+ top: 50vh;
left: 50%;
- margin-top: -40px;
+ margin-top: -60px;
margin-left: -40px;
display: none;
}
.loader:before {
content: '';
border-radius: 50%;
- border-top: 3px solid #fff;
+ border-top: 3px solid #999;
border-right: 3px solid transparent;
animation: loading .5s linear infinite;
-webkit-animation: loading .5s linear infinite;
@@ -39,9 +39,20 @@ body {
height: 80px;
display: block;
}
+.loading .loader { display: block; }
@keyframes loading {
to {transform: rotate(360deg)}
}
@-webkit-keyframes loading {
to {-webkit-transform: rotate(360deg)}
}
+
+.scroll {
+ position: absolute;
+ width: 100%;
+}
+
+.error_hilite {
+ color: red !important;
+ border-color: red !important;
+}
diff --git a/StoneIsland/platforms/ios/www/css/nav.css b/StoneIsland/platforms/ios/www/css/nav.css
index 2463d123..3d2278d4 100644
--- a/StoneIsland/platforms/ios/www/css/nav.css
+++ b/StoneIsland/platforms/ios/www/css/nav.css
@@ -6,8 +6,8 @@
top: 0; left: 0;
width: 249px;
-webkit-transform: translateZ(0) translateX(-249px);
- -webkit-transition: -webkit-transform 0.3s;
- background: #eeeeee;
+ -webkit-transition: -webkit-transform 0.1s;
+ background: #fff;
}
#content {
position: absolute;
@@ -15,7 +15,7 @@
width: 100%; height: 100%;
overflow: hidden;
-webkit-transform: translateZ(0) translateX(0px);
- -webkit-transition: -webkit-transform 0.3s;
+ -webkit-transition: -webkit-transform 0.1s;
}
.ios #nav,
.ios #content {
@@ -28,7 +28,7 @@
.nav #content {
-webkit-transform: translateZ(0) translateX(249px);
}
-.nav .logo {
+#nav .logo {
background-image: url(../img/wide-logo.png);
background-repeat: no-repeat;
background-position: center center;
@@ -36,26 +36,52 @@
width: 120px;
height: 80px;
margin-left: 20px;
+ display: block !important;
}
#nav .menu span {
display: block;
font-size: 14px;
+ letter-spacing:1.25px;
+ text-shadow:0px 0px 1px rgba(0,0,0,.2);
color: #000;
- padding: 15px 0 15px 20px;
}
+
+#nav .main_menu span {
+ padding: 30px 0 10px 20px;
+}
+
+#nav .account_menu span, #nav .faq_menu span {
+ padding: 28px 0 0px 20px;
+}
+
+#nav .faq_menu span:last-child {
+ padding-bottom:45px!important;
+}
+
+#nav .main_menu { display: block; }
+#nav .account_menu { display: none; }
+#nav .faq_menu { display: none; }
+#nav.faq .main_menu,
+#nav.account .main_menu { display: none; }
+#nav.account .account_menu { display: block; }
+#nav.faq .faq_menu { display: block; }
+
#nav .submenu {
position: absolute;
width: 100%;
padding: 20px 0;
- bottom: 33px;
+ top:0;
border-top: 1px solid #ddd;
}
+
#nav .submenu span {
display: block;
font-size: 14px;
+ letter-spacing:1.25px;
color: #bbb;
- padding: 4px 0 5px 20px
+ padding: 4px 0 7px 20px
}
+
#nav .social {
position: absolute;
bottom: 0;
@@ -73,6 +99,29 @@
text-align: center;
}
+#nav-container {
+ display:flex;
+ height:calc(100% - 40px);
+ width:100%;
+ position:absolute;
+ flex-direction: column;
+}
+
+#nav-row {
+ box-sizing:border-box;
+ padding-bottom:30px;
+}
+
+#nav-fill {
+ flex: 1;
+ position:relative;
+}
+
+.menu-emphasis {
+font-weight:bold;
+padding-bottom:0px;
+}
+
/* INTRO PAGE WITH SPINNING COMPASS */
#intro {
@@ -131,7 +180,7 @@
position: absolute;
top: 0; left: 0; width: 100%;
height: 42px;
- background: white;
+ border-bottom: 1px solid black;
}
#header .logo {
background-image: url(../img/wide-logo.png);
@@ -139,46 +188,72 @@
background-position: center center;
position: absolute;
background-size: contain;
- width: 80px; height: 38px;
- left: 50%; top: 2px;
- margin-left: -40px;
+ width: 120px; height: 40px;
+ left: 50%; top: -4px;
+ margin-left: -60px;
}
#header .burger {
display: inline-block;
font-size: 24px;
padding: 6px 10px;
}
+
#header .cart {
display: inline-block;
- padding: 6px 10px;
float: right;
+ width: 18px;
+ top: 15px;
+ height: 18px;
+ margin-right:18px;
+ border: 1px solid #a9a9a9;
+ position: relative;
+ background: #fff;
}
+.cart .cart_count {
+ position: absolute;
+ top: 50%;
+ left: 50%;
+ transform: translateY(-50%) translateX(-50%);
+ color: #a9a9a9;
+ font-size:13px
+}
+
+.cart::before {
+ position: absolute;
+ content: '\25E0';
+ left:50%;
+ transform:translateX(-50%);
+ color:#a9a9a9;
+ font-size:20px;
+ top:calc(-100%);
+}
#footer {
display: block;
position: absolute;
bottom: 0; left: 0; width: 100%;
- background: #eee;
+ background: #fff;
border-top: 1px solid #ddd;
+ z-index: 1;
}
-#footer span {
- display: none;
- padding: 10px 0;
- color: #bbb;
-}
-#footer .filter {
- float: right;
- padding: 10px;
-}
-#footer .buynow,
-#footer .addtocart,
-#footer .cancel,
-#footer .checkout,
-#footer .checkout_proceed {
+#footer div {
width: 50%;
text-align: center;
+ padding: 10px 0;
+ color: #000;
float: left;
+ font-size:14px;
+ font-weight:bold;
+}
+#footer .ok {
+ color: #000;
+}
+#footer .ok.wide {
+ width: 100%;
+}
+#footer .ok.disabled {
+ color: #bbb;
}
@@ -189,25 +264,24 @@
position: absolute;
top: 0; left: 0;
width: 100%; height: 100%;
- background: rgba(72,72,72,0.8);
+ background: rgba(255,255,255,0.8);
opacity: 0;
- -webkit-transition: opacity 0.4s;
- transition: opacity 0.4s;
+ -webkit-transition: opacity 0.2s;
+ transition: opacity 0.2s;
}
#curtain.visible {
pointer-events: auto;
opacity: 1;
+ z-index: 2;
}
-
-
-/* LOGIN / SIGNUP SCREEN */
-
-#login {
- display: none;
- position: absolute;
- top: 50%; left: 50%;
- -webkit-transform: translateX(-50%) translateY(-50%);
- background: #fff;
+#curtain.white {
+ background: rgba(255,255,255,0.8);
+}
+#curtain.dark {
+ background: rgba(72,72,72,0.8);
+}
+#curtain.loading .loader {
+ display: block;
}
@@ -215,27 +289,46 @@
#selector {
display: none;
- height: 100%; width: 100%;
- position: absolute; top: 0; left: 0;
- background: #eeeeee;
+ width: 100%;
+ position: absolute; bottom: 0; left: 0;
+ background: #fff;
+ z-index: 2;
+}
+#selector .options div {
+ width: 100%;
+ background: white;
+ text-align: center;
+ padding: 5px;
+ font-size: 14px;
}
/* CONTENT */
-#story, #hub, #archive, #collection, #product, #cart {
+#story, #hub, #archive, .page,
+#collection, #product, #search, #closed,
+#login, #logout, #signup,
+#cart,
+#profile, #shipping, #payment, #settings, #orders {
position: absolute;
- top: 40px;
- height: -webkit-calc(100% - 40px);
- height: calc(100% - 40px);
+ top: 43px;
+ height: -webkit-calc(100% - 43px - 39px);
+ height: calc(100% - 43px - 39px);
width: 100%;
+ overflow: hidden;
+}
+#story, #hub, #archive, .page, #closed {
+ /* these things do not have a footer */
+ height: -webkit-calc(100% - 43px);
+ height: calc(100% - 43px);
}
+
h1 {
text-align: center;
margin: 0;
- padding: 15px 10px 10px 10px;
- border-bottom: 1px solid #ccc;
- font-size: 18px;
- color: #ccc;
- letter-spacing: 2px;
- font-weight: 100;
+ padding: 16px 10px 12px 10px;
+ border-bottom: 1px solid #000;
+ font-size: 14px;
+ color: #000;
+ letter-spacing: 1px;
+ font-weight: bold;
}
diff --git a/StoneIsland/platforms/ios/www/css/products.css b/StoneIsland/platforms/ios/www/css/products.css
index bac0d116..6ab9d0bd 100644
--- a/StoneIsland/platforms/ios/www/css/products.css
+++ b/StoneIsland/platforms/ios/www/css/products.css
@@ -1,14 +1,202 @@
.collection #collection { display: block }
-.collection #footer .filter { display: block }
-#content.collection { overflow: scroll }
#collection {
display: none;
+ text-align: center;
+}
+#collection .item {
+ text-align: center;
+ display: inline-block;
+ max-width: 49vw;
+}
+#collection .item img {
+ width: 49vw;
+ height: 63vw;
}
.product #product { display: block }
-.product #footer .buynow { display: block }
-.product #footer .addtocart { display: block }
-#content.product { overflow: scroll }
#product {
display: none;
}
+#product .style {
+ text-transform: uppercase;
+}
+
+#product.loading #gallery,
+#product.loading .content {
+ display: none;
+}
+#product.loading .loader {
+ display: block;
+}
+
+.gallery {
+ width: 100vw;
+ height: 52vh;
+}
+
+.gallery .item {
+ width: 100vw;
+ height: 52vh;
+ background-size: contain;
+ background-position: center center;
+ background-repeat: no-repeat;
+}
+
+.search #search { display: block }
+#search {
+ display: none;
+}
+
+.closed #closed { display: block }
+#closed {
+ display: none;
+ background-size: cover;
+ background-position: center;
+ background-repeat: no-repeat;
+ transition: background 0.5s ease-in;
+}
+#closed .closed_store_msg {
+ position: absolute;
+ bottom: 20vh;
+ background: rgba(255,255,255,0.9);
+ padding-top: 20px;
+ padding-bottom: 10px;
+ text-align: center;
+ width: 100%;
+}
+
+.product .content {
+ box-sizing:border-box;
+ width:calc(100vw - 50px);
+ position:relative;
+ margin:0 auto 40px;
+ padding:0;
+}
+
+.product .product-header {
+ font-size:14px;
+ margin:18px 0 0;
+ max-width:60%;
+ position:relative;
+ font-weight:bold;
+}
+
+#product::before {
+ content:'';
+ width:100%;
+ background: linear-gradient(rgba(255,255,255,0), rgba(255,255,255,1));
+ height:40px;
+ z-index:2;
+ position:absolute;
+ bottom:0px;
+ left:0
+}
+
+.product .style {
+ padding:4px 9px;
+ border:1px solid black;
+ float:left
+}
+
+.product .share {
+ float:right;
+ padding:4px 9px;
+ border:1px solid black;
+}
+
+.product .type {
+ display:table-cell;
+ font-size:14px;
+}
+
+.product .size {
+ padding-right:16px;
+ position:relative
+}
+
+.product .price {
+ display:table-cell;
+ font-size:14px;
+ text-align:right;
+ vertical-align:bottom
+}
+
+.product .price, .product .type {
+ font-weight:bold;
+ margin:0;
+ padding: 0 0 7px;
+}
+
+.type-price {
+ display:table;
+ position:relative;
+ width:100%
+}
+
+.style-share {
+ letter-spacing:0.5px;
+}
+
+.size-color {
+ position:relative
+}
+
+.type-price, .style-share {
+ clear:both;
+ position:relative;
+ box-sizing:border-box
+}
+
+
+.size::after {
+ content: '';
+ display: inline-block;
+ width: 1px;
+ height: calc(100% + 4px);
+ transform: translateY(-2px);
+ position: absolute;
+ top: 0;
+ right:5px;
+ background: #999;
+}
+
+
+.product .fit {
+ clear:both;
+ font-size:9px;
+ letter-spacing:0.5px;
+ text-decoration:underline;
+ text-transform:uppercase;
+ padding:12px 0 2px;
+}
+
+#product #gallery::before {
+ border:1px solid black;
+ top:50%;
+ transform:scale(.5,1) translateY(-50%);
+ transform-origin:top left;
+ left:20px;
+ content:'\25C0';
+ font-size:18px;
+ padding:3px 14px 3px 11px;
+ z-index:999;
+ position:absolute;
+ display:block;
+ background:rgba(255,255,255,1);
+}
+
+#product #gallery::after {
+ border:1px solid black;
+ top:50%;
+ transform:scale(.5,1) translateY(-50%);
+ transform-origin:top right;
+ right:20px;
+ content:'\25B6';
+ font-size:18px;
+ padding:3px 11px 3px 14px;
+ z-index:999;
+ position:absolute;
+ display:block;
+ background:rgba(255,255,255,1);
+}
+
diff --git a/StoneIsland/platforms/ios/www/css/vendor/flickity.css b/StoneIsland/platforms/ios/www/css/vendor/flickity.css
new file mode 100644
index 00000000..b8eca4e4
--- /dev/null
+++ b/StoneIsland/platforms/ios/www/css/vendor/flickity.css
@@ -0,0 +1,141 @@
+/*! Flickity v1.0.2
+http://flickity.metafizzy.co
+---------------------------------------------- */
+
+.flickity-enabled {
+ position: relative;
+}
+
+.flickity-enabled:focus { outline: none; }
+
+.flickity-viewport {
+ overflow: hidden;
+ position: relative;
+ height: 100%;
+}
+
+.flickity-slider {
+ position: absolute;
+ width: 100%;
+ height: 100%;
+}
+
+/* draggable */
+
+.flickity-enabled.is-draggable {
+ -webkit-tap-highlight-color: transparent;
+ tap-highlight-color: transparent;
+ -webkit-user-select: none;
+ -moz-user-select: none;
+ -ms-user-select: none;
+ user-select: none;
+}
+
+.flickity-enabled.is-draggable .flickity-viewport {
+ cursor: move;
+ cursor: -webkit-grab;
+ cursor: grab;
+}
+
+.flickity-enabled.is-draggable .flickity-viewport.is-pointer-down {
+ cursor: -webkit-grabbing;
+ cursor: grabbing;
+}
+
+/* ---- previous/next buttons ---- */
+
+.flickity-prev-next-button {
+ position: absolute;
+ top: 50%;
+ width: 44px;
+ height: 44px;
+ border: none;
+ border-radius: 50%;
+ background: white;
+ background: hsla(0, 0%, 100%, 0.75);
+ cursor: pointer;
+ /* vertically center */
+ -webkit-transform: translateY(-50%);
+ -ms-transform: translateY(-50%);
+ transform: translateY(-50%);
+}
+
+.flickity-prev-next-button:hover { background: white; }
+
+.flickity-prev-next-button:focus {
+ outline: none;
+ box-shadow: 0 0 0 5px #09F;
+}
+
+.flickity-prev-next-button:active {
+ filter: alpha(opacity=60); /* IE8 */
+ opacity: 0.6;
+}
+
+.flickity-prev-next-button.previous { left: 10px; }
+.flickity-prev-next-button.next { right: 10px; }
+/* right to left */
+.flickity-rtl .flickity-prev-next-button.previous {
+ left: auto;
+ right: 10px;
+}
+.flickity-rtl .flickity-prev-next-button.next {
+ right: auto;
+ left: 10px;
+}
+
+.flickity-prev-next-button:disabled {
+ filter: alpha(opacity=30); /* IE8 */
+ opacity: 0.3;
+ cursor: auto;
+}
+
+.flickity-prev-next-button svg {
+ position: absolute;
+ left: 20%;
+ top: 20%;
+ width: 60%;
+ height: 60%;
+}
+
+.flickity-prev-next-button .arrow {
+ fill: #333;
+}
+
+/* color & size if no SVG - IE8 and Android 2.3 */
+.flickity-prev-next-button.no-svg {
+ color: #333;
+ font-size: 26px;
+}
+
+/* ---- page dots ---- */
+
+.flickity-page-dots {
+ position: absolute;
+ width: 100%;
+ bottom: -25px;
+ padding: 0;
+ margin: 0;
+ list-style: none;
+ text-align: center;
+ line-height: 1;
+}
+
+.flickity-rtl .flickity-page-dots { direction: rtl; }
+
+.flickity-page-dots .dot {
+ display: inline-block;
+ width: 10px;
+ height: 10px;
+ margin: 0 8px;
+ background: #333;
+ border-radius: 50%;
+ filter: alpha(opacity=25); /* IE8 */
+ opacity: 0.25;
+ cursor: pointer;
+}
+
+.flickity-page-dots .dot.is-selected {
+ filter: alpha(opacity=100); /* IE8 */
+ opacity: 1;
+}
diff --git a/StoneIsland/platforms/ios/www/index.html b/StoneIsland/platforms/ios/www/index.html
index b2f89a28..aeb1eb61 100644
--- a/StoneIsland/platforms/ios/www/index.html
+++ b/StoneIsland/platforms/ios/www/index.html
@@ -18,8 +18,10 @@
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
<link rel="stylesheet" type="text/css" href="css/fonts/fonts.css">
<link rel="stylesheet" type="text/css" href="css/fonts/ionicons.css">
+ <link rel="stylesheet" type="text/css" href="css/vendor/flickity.css">
<link rel="stylesheet" type="text/css" href="css/index.css">
<link rel="stylesheet" type="text/css" href="css/nav.css">
+ <link rel="stylesheet" type="text/css" href="css/account.css">
<link rel="stylesheet" type="text/css" href="css/products.css">
<link rel="stylesheet" type="text/css" href="css/cart.css">
<link rel="stylesheet" type="text/css" href="css/blogs.css">
@@ -28,19 +30,60 @@
<body>
<div id="nav">
+ <div id="nav-container">
+ <div id="nav-row">
+ <!-- flex -->
+
<span class="menu">
<div class="logo"></div>
- <span class="store">STORE</span>
- <span class="hub">HUB</span>
- <span class="story">STORY</span>
- <span class="archive">ARCHIVE</span>
+ <div class="main_menu">
+ <span class="store">STORE</span>
+ <span class="hub">HUB</span>
+ <span class="story">STORY</span>
+ <span class="archive">ARCHIVE</span>
+ </div>
+ <div class="account_menu">
+ <span class="account_back menu-emphasis">&lt; ACCOUNT</span>
+ <span class="profile">PROFILE</span>
+ <span class="payment">PAYMENT</span>
+ <span class="shipping">SHIPPING</span>
+ <span class="orders">ORDERS</span>
+ <span class="return_link">RETURN</span>
+ <span class="settings">NOTIFICATIONS</span>
+ </div>
+ <div class="faq_menu">
+ <span class="faq_back menu-emphasis">&lt; FAQ</span>
+ <span class="privacy">PRIVACY POLICY</span>
+ <span class="terms">TERMS AND CONDITIONS</span>
+ <span class="returns">RETURN POLICY</span>
+ <span class="care">CUSTOMER CARE</span>
+ </div>
</span>
+ </div>
+ <div id="nav-fill">
+ <!-- flex fill -->
<span class="submenu">
- <span class="login">ACCOUNT / LOGIN</span>
- <span class="faq">FAQ</span>
- <span class="search">SEARCH</span>
+ <div class="main_menu">
+ <span class="account">ACCOUNT</span>
+ <span class="login">LOGIN</span>
+ <span class="faq">FAQ</span>
+ </div>
+ <div class="account_menu">
+ <span class="logout">LOGOUT</span>
+ <span class="faq">FAQ</span>
+ <span class="main">MAIN MENU</span>
+ </div>
+ <div class="faq_menu">
+ <span class="account">ACCOUNT</span>
+ <span class="login">LOGIN</span>
+ <span class="logout">LOGOUT</span>
+ <span class="main">MAIN MENU</span>
+ </div>
</span>
+ </div>
+ <!-- end flex -->
+ </div>
<span class="social">
<span class="fb ion-social-facebook"></span>
@@ -57,34 +100,33 @@
<div class="hub">HUB</div>
<div class="story">STORY</div>
<div class="archive">ARCHIVE</div>
- <span class="latlng">+40.589060 -74.044636</span>
+ <span class="latlng">+40&deg; 58' 90" -74&deg; 04' 46"</span>
</div>
<div id="header">
<span class="burger ion-android-menu"></span>
<span class="logo"></span>
- <span class="cart"><span class="cart_count">2</span></span>
+ <span class="cart"><span class="cart_count">0</span></span>
</div>
<div id="footer">
- <span class="filter">FILTER</span>
- <span class="buynow">BUY NOW</span>
- <span class="addtocart">ADD TO CART</span>
- <span class="cancel">CANCEL</span>
- <span class="checkout">CHECKOUT</span>
- <span class="checkout_proceed">PROCEED WITH CHECKOUT</span>
+ <!-- 'Cancel' i think needs to go BACK in the navigation.. rather than jumping to the home screen -->
+ <div class="cancel">CANCEL</div>
+ <div class="ok">OK</div>
</div>
-
+
+
+ <!-- BLOGS ================================================ -->
+
<div id="story">
<div class="scroll">
<h1>STORY</h1>
+ <img>
+ <ul class="links"></ul>
<div class="content">
<script type="text/html" class="template">
- <div>
- <img src="{{image}}">
- <span class="date">{{date}}</span>
- <span class="title">{{title}}</span>
- <div class="body">{{body}}</div>
+ <div data-id="{{id}}">
+ <div class="body">{{body}}</div>
</div>
</script>
</div>
@@ -97,19 +139,32 @@
<div class="content">
<script type="text/html" class="template">
<div>
- <img src="{{image}}">
- <span class="title"><b>{{code}}</b> {{title}}</span>
+ <div class="gallery gallery-{{id}}"></div>
+ <div class="content-header">
+ <div class="content-share">
+ SHARE +
+ </div>
+ <span class="title">{{title}}</span>
<span class="subtitle">{{subtitle}}</span>
+ <span class="date">
+ {{date}}
+ <span class="store">
+ | <b><u>STORE</u></b>
+ </span>
+ </span>
+ </div>
<div class="body">{{body}}</div>
</div>
</script>
</div>
</div>
+ <div class="fade-cover"></div>
</div>
<div id="archive">
<div class="scroll">
<h1>ARCHIVE</h1>
+ <div class="subtitle">'982-'015</div>
<div class="content">
<script type="text/html" class="template">
<img src="{{image}}">
@@ -127,6 +182,34 @@
</div>
</div>
+ <div id="privacy" class="page">
+ <div class="scroll">
+ <h1>PRIVACY POLICY</h1>
+ <div class="content"></div>
+ </div>
+ </div>
+ <div id="terms" class="page">
+ <div class="scroll">
+ <h1>TERMS AND CONDITIONS</h1>
+ <div class="content"></div>
+ </div>
+ </div>
+ <div id="returns" class="page">
+ <div class="scroll">
+ <h1>RETURN POLICY</h1>
+ <div class="content"></div>
+ </div>
+ </div>
+ <div id="care" class="page">
+ <div class="scroll">
+ <h1>CUSTOMER CARE</h1>
+ <div class="content"></div>
+ </div>
+ </div>
+
+
+ <!-- STORE ================================================ -->
+
<div id="collection">
<div class="scroll">
<h1>COLLECTION NAME</h1>
@@ -140,204 +223,570 @@
</div>
</div>
</div>
-
+
+ <div id="search">
+ <div class="scroll">
+ <h1>SEARCH</h1>
+ <form>
+ <input type="text" class="q" placeholder="ENTER YOUR SEARCH">
+ </form>
+ </div>
+ </div>
+
<div id="product">
<div class="scroll">
- <div id="gallery">
- <span class="left"></span>
- <span class="right"></span>
- <div class="slider">
- <script type="text/html" class="template">
- <div class="item">
- <img src="{{image}}">
- </div>
- </script>
- </div>
+ <div class="loader"></div>
+ <div id="gallery" class="gallery">
+ <script type="text/html" class="template">
+ <div class="item" style="background-image:url({{image}})"></div>
+ </script>
</div>
<div class="content">
- <h2><b class="num"></b><span class="title"></h2>
- <span class="type"></span>
- <span class="price"></span>
+ <div class="product-header">
+ <span class="num"></span>
+ <span class="title"></span>
+ </div>
+ <div class="type-price">
+ <span class="type"></span>
+ <span class="price"></span>
+ </div>
+ <div class="style-share">
<span class="style">
- <span class="size"></span>
- <span class="color"></span>
+ <div class="size-color">
+ <span class="size"></span>
+ <span class="color"></span>
+ </div>
</span>
<span class="share">SHARE +</span>
+ </div>
+ <div class="fit">Fits Large</div>
<div class="body">
</div>
+ <div class="sizing">
+ <b>Sizing:</b> The products of this collaboration fit slightly larger than the classic Stone Island garments.
+ <br><br>
+ We suggest you choose a smaller size than yours.
+ </div>
</div>
</div>
</div>
-
- <div id="selector">
- <span class="close"></span>
- <div class="options">
- <script type="text/html" class="template">
- <span data-id="{{id}}">{{value}}</span>
- </script>
+ <div id="closed">
+ <div class="closed_store_msg">
+ <h3>THIS STORE IS CURRENTLY CLOSED</h3>
+ <div class="website_link">
+ visit<br>
+ <b>www.stoneisland.com</b>
+ </div>
</div>
</div>
- <div id="curtain"></div>
+
+ <!-- ACCOUNT ================================================ -->
+
<div id="login">
- <span class="close">
- <div class="login_ask">LOGIN</div>
- <div class="signup_ask">SIGNUP</div>
- <form>
- <input type="email" name="email" placeholder="EMAIL" required>
- <input type="password" name="password" placeholder="PASSWORD" required>
- <span class="submit">SIGN IN</span>
- </form>
+ <div class="scroll">
+ <h1>LOGIN</h1>
+ <form>
+ <div class="container">
+ <div class="container-row">
+ <input style="margin-bottom:10px" type="email" name="Email" placeholder="EMAIL ADDRESS" required>
+ <input type="password" name="Password" placeholder="PASSWORD" required>
+ </div>
+ <div class="container-fill">
+ <div class="container-message premessage">
+ <span class="newuser">New User?</span>
+ </div>
+ <div class="container-message submessage">
+ <span class="msg"></span>
+ </div>
+ </div>
+ </div>
+ </form>
+ </div>
</div>
- <div id="cart">
- <h1>YOUR CART / <span class="itemcount">2 ITEMS</h1>
+ <div id="logout">
+ <div class="scroll">
+ <h1>LOGOUT</h1>
+ <div class="container">
+ <div class="container-fill">
+ <span class="container-message msg">
+ You are now logged out.
+ </span>
+ </div>
+ </div>
+ </div>
+ </div>
- <div class="steps">
- <span class="summary">SUMMARY</span>
- <span class="shipping">SHIPPING</span>
- <span class="billing">BILLING</span>
+ <div id="signup">
+ <div class="scroll">
+ <h1>NEW USER</h1>
+ <form>
+ <div class="container">
+ <div class="container-row">
+ <input type="text" name="Name" placeholder="FIRST NAME" required>
+ <input type="text" name="Surname" placeholder="LAST NAME" required>
+ <input type="email" name="Email" placeholder="EMAIL ADDRESS" required>
+ <input type="email" name="ConfirmEmail" placeholder="CONFIRM EMAIL ADDRESS" required>
+ <input type="date" name="BirthDay" placeholder="BIRTHDAY (MM/DD/YYYY)" required>
+
+ <div class="select-wrapper">
+ <span>GENDER</span>
+ <select name="Gender">
+ <option value="NONE">Gender</option>
+ <option value="U">Male</option>
+ <option value="D">Female</option>
+ </select>
+ </div>
+ <h2>PASSWORD</h2>
+ <input type="password" name="Password" placeholder="PASSWORD (7 CHARACTERS OR MORE)" required>
+ <input type="password" name="Password2" placeholder="CONFIRM PASSWORD" required>
+ </div>
+ <div class="container-row">
+ <div class="container-message">
+ <span class="msg">
+ * Your personal and payment<br>
+ information will always remain private
+ </span>
+ </div>
+ </div>
+ <div class="container-row">
+ <div class="checkbox-container">
+ <div class="checkbox-row">
+ <div class="checkbox-toggle">
+ <input id="checkbox-data-profiling" type="checkbox" name="DataProfiling" value="true" required>
+ <label for="checkbox-data-profiling"></label>
+ </div>
+ <label class="checkbox-caption" for="checkbox-data-profiling">
+ I agree that YOOX and SPORTSWEAR COMPANY may collect my personal information for marketing purposes (newsletters, news and promotions).
+ </label>
+ </div>
+ <div class="checkbox-row">
+ <div class="checkbox-toggle">
+ <input type="checkbox" id="checkbox-shopping-data-profiling" name="DataProfiling2" value="true" required>
+ <label for="checkbox-shopping-data-profiling"></label>
+ </div>
+ <label class="checkbox-caption" for="checkbox-shopping-data-profiling">
+ I agree that YOOX NET-A-PORTER GROUP and SPORTSWEAR COMPANY may collect my personal information for creating a profile of my shopping habits.
+ </label>
+ </div>
+ <div class="privacy-msg">
+ Consult our <u>PRIVACY POLICY</u> for further information.
+ </div>
+ </div>
+ </div>
+ </div>
+ </form>
</div>
+ </div>
+
+ <div id="profile">
+ <div class="scroll">
+ <h1>PROFILE</h1>
+ <form>
+ <div class="container">
+ <div class="container-row">
+ <input type="text" name="Name" placeholder="FIRST NAME" required>
+ <input type="text" name="Surname" placeholder="LAST NAME" required>
+ <input type="email" name="Email" placeholder="EMAIL ADDRESS" required>
+ <input type="date" name="BirthDay" placeholder="BIRTHDAY (MM/DD/YYYY)" required>
- <div id="summary">
- <div class="rows">
+ <div class="select-wrapper">
+ <span>GENDER</span>
+ <select name="Gender">
+ <option value="NONE">Gender</option>
+ <option value="U">Male</option>
+ <option value="D">Female</option>
+ </select>
+ </div>
+
+ <h2>CHANGE PASSWORD</h2>
+ <input type="password" name="CurrentPassword" placeholder="CURRENT PASSWORD" required>
+ <input type="password" name="NewPassword" placeholder="NEW PASSWORD (7 CHARACTERS OR MORE)" required>
+ <div class="toggle-container">
+ <div class="caption">
+ <h3>Newsletter</h3>
+ Receive Stone Island Newsletter
+ </div>
+ <div class="toggle">
+ <input type="checkbox" id="receive-newsletter" name="YooxLetter" class="switch" value="true">
+ <label for="receive-newsletter"></label>
+ </div>
+ </div>
+ </div>
+ <div class="container-fill">
+ <div class="container-message">
+ <span class="msg">
+ * Your personal and payment<br>
+ information will always remain private
+ </span>
+ </div>
+ </div>
+ </div>
+ </form>
+ </div>
+ </div>
+
+
+ <div id="shipping">
+ <div class="scroll">
+ <h1>SHIPPING</h1>
+ <form>
+ <div class="container">
+ <div class="container-row">
+ <div class="address"></div>
+ </div>
+ <div class="container-fill">
+ <div class="container-message">
+ <span class="msg">
+ * Your personal and payment<br>
+ information will always remain private
+ </span>
+ </div>
+ </div>
+ </div>
+ </form>
+ </div>
+ </div>
+
+ <div id="payment">
+ <div class="scroll">
+ <h1>PAYMENT</h1>
+ <form>
+ <div class="container">
+ <div class="container-row">
+ <div class="cc"></div>
+ <div class="address"></div>
+ </div>
+ <div class="container-fill">
+ <div class="container-message">
+ <span class="msg">
+ * Your personal and payment<br>
+ information will always remain private
+ </span>
+ </div>
+ </div>
+ </div>
+ </form>
+ </div>
+ </div>
+
+ <div id="settings">
+ <div class="scroll">
+ <h1>NOTIFICATIONS</h1>
+ <form>
+ <div class="toggle-container">
+ <div class="toggle-row">
+ <div class="caption">
+ <h3>Store</h3>
+ Receive notifications for Store
+ </div>
+ <div class="toggle">
+ <input type="checkbox" id="store-notifications" name="switch" class="switch">
+ <label for="store-notifications"></label>
+ </div>
+ </div>
+ <div class="toggle-row">
+ <div class="caption">
+ <h3>Hub</h3>
+ Receive notifications for Hub
+ </div>
+ <div class="toggle">
+ <input type="checkbox" id="hub-notifications" name="switch" class="switch">
+ <label for="hub-notifications"></label>
+ </div>
+ </div>
+ </div>
+ </form>
+ </div>
+ </div>
+
+ <div id="orders">
+ <h1>ORDERS</h1>
+ <div id="order_list">
+ <div class="scroll">
<script type="text/html" class="template">
- <div>
- <img src="{{image}}">
- <b>{{sku}}</b><br>
- <span class="title">{{title}}</span>
- <span class="type">{{type}}</span>
- <span class="meta">
- <b>SIZE:</b> {{size}}<br>
- <b>COLOR:</b> {{color}}<br>
- <b>QUANTITY:</b> {{quantity}}<br>
- </span>
- <span class="price">{{price}}</span>
+ <div class="item">
+ <div class="details">
+ Details &gt;
+ </div>
+ <div class="txt">
+ {{date}}<br>
+ {{order_id}}<br>
+ {{total}}
+ </div>
+ <div id="images">
+ </div>
</div>
</script>
</div>
- <div>
- <span class="label">SUB TOTAL</span>
- <span class="subtotal"></span>
- </div>
- <div>
- <span class="label">ESTIMATED SHIPPING<br>& HANDLING</span>
- <span class="shipping"></span>
- </div>
- <div>
- <span class="label">TAX</span>
- <span class="tax"></span>
- </div>
- <div>
- <span class="label">TOTAL</span>
- <span class="total"></span>
+ </div>
+ <div id="single_order">
+ <div class="scroll">
+ <div class="content">
+ </div>
+ <script type="text/html" class="template">
+ </script>
</div>
</div>
+ </div>
+
+ <!-- CART ================================================ -->
+
+ <div id="cart">
+ <h1>YOUR CART / <span class="itemcount"></h1>
+
+ <div class="steps">
+ <span class="summary_step">SUMMARY</span>
+ <span class="shipping_step">SHIPPING</span>
+ <span class="payment_step">BILLING</span>
+ </div>
- <div id="shipping">
- <div class="select_address">
- ADDRESS
- </div>
- <form class="address_form">
- <div>
- <label for="ship-name">Name</label>
- <input type="text" name="name" id="ship-name">
+ <div id="cart_summary">
+ <div class="scroll">
+ <div class="summary-container container">
+ <div class="container-row">
+ <div class="cart_body">
+ <div class="rows">
+ <script type="text/html" class="template">
+ <div class="cart_item_image">
+ <img src="{{image}}">
+ </div>
+ <div class="cart_item_info">
+ <span class="sku">{{sku}}</span>
+ <span class="title">{{title}}</span>
+ <span class="type">{{type}}</span>
+ <div class="meta">
+ <div class="meta-size"><b>SIZE:</b> {{size}}</div>
+ <div class="meta-color"><b>COLOR:</b> {{color}}</div>
+ <div class="meta-quantity"><b>QUANTITY:</b> {{quantity}}</div>
+ </div>
+ </div>
+ <div class="cart_item_price">
+ <span class="remove">x Remove from cart</span>
+ <span class="price">{{price}}</span>
+ </div>
+ </script>
+ </div>
+ <div class="cart-summary">
+ <div class="cart-summary-row">
+ <span class="label">SUB TOTAL</span>
+ <span class="subtotal"></span>
+ </div>
+ <div class="cart-summary-row">
+ <span class="label">ESTIMATED SHIPPING<br>& HANDLING</span>
+ <span class="shipping"></span>
+ </div>
+ <div class="cart-summary-row">
+ <span class="label">TAX</span>
+ <span class="tax"></span>
+ </div>
+ <div class="cart-summary-row">
+ <span class="label">TOTAL</span>
+ <span class="total"></span>
+ </div>
</div>
- <div>
- <label for="ship-address1">Address</label>
- <input type="text" name="address1" id="ship-address1">
- <input type="text" name="address2" id="ship-address2">
</div>
- <div>
- <label for="ship-city">City</label>
- <input type="text" name="city" id="ship-city">
</div>
- <div>
- <label for="ship-state">State</label>
- <select id="state" name="state" required>
- <option value="">Please select</option>
- <option value="AL">Alabama</option>
- <option value="AK">Alaska</option>
- <option value="AZ">Arizona</option>
- <option value="AR">Arkansas</option>
- <option value="CA">California</option>
- <option value="CO">Colorado</option>
- <option value="CT">Connecticut</option>
- <option value="DE">Delaware</option>
- <option value="DC">District Of Columbia</option>
- <option value="FL">Florida</option>
- <option value="GA">Georgia</option>
- <option value="HI">Hawaii</option>
- <option value="ID">Idaho</option>
- <option value="IL">Illinois</option>
- <option value="IN">Indiana</option>
- <option value="IA">Iowa</option>
- <option value="KS">Kansas</option>
- <option value="KY">Kentucky</option>
- <option value="LA">Louisiana</option>
- <option value="ME">Maine</option>
- <option value="MD">Maryland</option>
- <option value="MA">Massachusetts</option>
- <option value="MI">Michigan</option>
- <option value="MN">Minnesota</option>
- <option value="MS">Mississippi</option>
- <option value="MO">Missouri</option>
- <option value="MT">Montana</option>
- <option value="NE">Nebraska</option>
- <option value="NV">Nevada</option>
- <option value="NH">New Hampshire</option>
- <option value="NJ">New Jersey</option>
- <option value="NM">New Mexico</option>
- <option value="NY">New York</option>
- <option value="NC">North Carolina</option>
- <option value="ND">North Dakota</option>
- <option value="OH">Ohio</option>
- <option value="OK">Oklahoma</option>
- <option value="OR">Oregon</option>
- <option value="PA">Pennsylvania</option>
- <option value="RI">Rhode Island</option>
- <option value="SC">South Carolina</option>
- <option value="SD">South Dakota</option>
- <option value="TN">Tennessee</option>
- <option value="TX">Texas</option>
- <option value="UT">Utah</option>
- <option value="VT">Vermont</option>
- <option value="VA">Virginia</option>
- <option value="WA">Washington</option>
- <option value="WV">West Virginia</option>
- <option value="WI">Wisconsin</option>
- <option value="WY">Wyoming</option>
- </select>
+ <div class="container-fill">
+ <div class="container-message cart_empty">
+ You have nothing in your cart.
+ </div>
</div>
- <div>
- <label for="ship-zip">Zip Code</label>
- <input type="text" name="zip" id="ship-zip">
</div>
- </form>
-
- <h3>SHIPPING METHOD</h3>
-
- <div class="checkbox">
- <div class="box"></div>
- <b>STANDARD $10</b>
- (DELIVERY IN 5-8 WORKING DAYS)
</div>
+ </div>
+
+ <div id="cart_shipping">
+ <div class="scroll">
+ <form>
+ <div class="add_edit">add/edit</div>
+ <div class="select_address">
+ ADDRESS
+ </div>
+ <div class="address_form">
+ <div class="address"></div>
+ <div class="checkbox-container">
+ <div class="checkbox-row">
+ <div class="checkbox-toggle">
+ <input id="save_as_default_cart_shipping" type="checkbox" name="IsDefault" value="true" required>
+ <label for="save_as_default_cart_shipping"></label>
+ </div>
+ <label class="checkbox-caption" for="save_as_default_cart_shipping">
+ SAVE AS DEFAULT
+ </label>
+ </div>
+ </div>
+ </div>
+
+ <h3>SHIPPING METHOD</h3>
+
+ <div class="checkbox-container">
+ <div class="checkbox-row">
+ <div class="checkbox-toggle">
+ <input id="express-shipping" type="radio" name="ShippingType" value="Express" required>
+ <label for="express-shipping"></label>
+ </div>
+ <label class="checkbox-caption" for="express-shipping">
+ <b>COMPLIMENTARY EXPRESS $10</b><br>
+ (DELIVERY IN 2-4 WORKING DAYS)
+ </label>
+ </div>
+ <div class="checkbox-row">
+ <div class="checkbox-toggle">
+ <input id="standard-shipping" type="radio" name="ShippingType" value="Standard" checked required>
+ <label for="standard-shipping"></label>
+ </div>
+ <label class="checkbox-caption" for="standard-shipping">
+ <b>STANDARD SHIPPING</b><br>
+ (DELIVERY IN 5-8 WORKING DAYS)
+ </label>
+ </div>
+ </div>
- <div class="checkbox">
- <div class="box"></div>
- <b>EXPRESS $20</b>
- (DELIVERY IN 2-4 WORKING DAYS)
+ </form>
</div>
</div>
- <div id="billing">
+ <div id="cart_payment">
+ <div class="scroll">
+ <form>
+ <div class="billing-container container">
+ <div class="container-row">
+ <div class="cc"></div>
+ <div class="address"></div>
+ </div>
+ <div class="container-fill">
+ <div class="container-message">
+ <span class="msg">
+ * Your personal and payment<br>
+ information will always remain private
+ </span>
+ </div>
+ </div>
+ </div>
+ </form>
+ </div>
+ </div>
+
+ <div id="cart_confirm">
+ <div class="scroll">
+ <h1>CONFIRM</h1>
+ </div>
+ </div>
+
+ <div id="cart_thanks">
+ <b>THANK YOU</b>
+ <p>
+ Please check your inbox for your confirmation email.
+ </p>
</div>
</div>
-
+
+ <div id="curtain">
+ <div class="loader"></div>
+ </div>
+
+ <div id="selector">
+ <div class="options">
+ <script type="text/html" class="template">
+ <div data-id="{{id}}">{{label}}</div>
+ </script>
+ </div>
+ </div>
+
</div>
+<script type="text/html" id="creditcard_template">
+ <input type="text" name="Number" placeholder="CREDIT CARD NUMBER" required>
+ <div class="half-input">
+ <!-- NOTE text shifted to the left because of dropdown arrow -->
+ <input type="text" onfocus="(this.type='number')" name="ExpirationMonth" placeholder="EXPIRATION MONTH" required>
+ <input type="text" onfocus="(this.type='number')" name="ExpirationYear" placeholder="EXPIRATION YEAR" required>
+ </div>
+ <!-- NOTE text shifted to the left because of dropdown arrow -->
+ <input type="text" onfocus="(this.type='number')" name="CVV" placeholder="SECURITY CODE" required>
+ <span class="address"></span>
+</script>
+
+<script type="text/html" id="address_template">
+ <input type="text" name="Name" placeholder="First Name">
+ <input type="text" name="Surname" placeholder="Last Name">
+ <input type="text" name="Address1" placeholder="Address Line 1">
+ <input type="text" name="Address2" placeholder="Address Line 2">
+ <div class="half-input">
+ <input type="text" name="City" placeholder="City">
+ <div class="select-wrapper">
+ <span>STATE</span>
+ <select name="State">
+ <option value="NONE">State</option>
+ <option value="AL">Alabama</option>
+ <option value="AK">Alaska</option>
+ <option value="AZ">Arizona</option>
+ <option value="AR">Arkansas</option>
+ <option value="CA">California</option>
+ <option value="CO">Colorado</option>
+ <option value="CT">Connecticut</option>
+ <option value="DE">Delaware</option>
+ <option value="DC">District Of Columbia</option>
+ <option value="FL">Florida</option>
+ <option value="GA">Georgia</option>
+ <option value="HI">Hawaii</option>
+ <option value="ID">Idaho</option>
+ <option value="IL">Illinois</option>
+ <option value="IN">Indiana</option>
+ <option value="IA">Iowa</option>
+ <option value="KS">Kansas</option>
+ <option value="KY">Kentucky</option>
+ <option value="LA">Louisiana</option>
+ <option value="ME">Maine</option>
+ <option value="MD">Maryland</option>
+ <option value="MA">Massachusetts</option>
+ <option value="MI">Michigan</option>
+ <option value="MN">Minnesota</option>
+ <option value="MS">Mississippi</option>
+ <option value="MO">Missouri</option>
+ <option value="MT">Montana</option>
+ <option value="NE">Nebraska</option>
+ <option value="NV">Nevada</option>
+ <option value="NH">New Hampshire</option>
+ <option value="NJ">New Jersey</option>
+ <option value="NM">New Mexico</option>
+ <option value="NY">New York</option>
+ <option value="NC">North Carolina</option>
+ <option value="ND">North Dakota</option>
+ <option value="OH">Ohio</option>
+ <option value="OK">Oklahoma</option>
+ <option value="OR">Oregon</option>
+ <option value="PA">Pennsylvania</option>
+ <option value="RI">Rhode Island</option>
+ <option value="SC">South Carolina</option>
+ <option value="SD">South Dakota</option>
+ <option value="TN">Tennessee</option>
+ <option value="TX">Texas</option>
+ <option value="UT">Utah</option>
+ <option value="VT">Vermont</option>
+ <option value="VA">Virginia</option>
+ <option value="WA">Washington</option>
+ <option value="WV">West Virginia</option>
+ <option value="WI">Wisconsin</option>
+ <option value="WY">Wyoming</option>
+ </select>
+ </div>
+ </div>
+ <div class="half-input">
+ <input type="text" name="Zip" placeholder="ZIP" required>
+ <div id="country-wrapper">
+ <div id="country-select">
+ <input type="text" name="Country" placeholder="UNITED STATES" required>
+ </div>
+ </div>
+ </div>
+ <input type="number" name="Phone" placeholder="Phone Number">
+</script>
+
</body>
<script src="cordova.js"></script>
<script src="js/vendor/jquery-2.1.4.min.js"></script>
@@ -345,25 +794,58 @@
<script src="js/vendor/iscroll.js"></script>
<script src="js/vendor/loader.js"></script>
<script src="js/vendor/lodash.min.js"></script>
+<script src="js/vendor/moment.js"></script>
<script src="js/vendor/oktween.js"></script>
+<script src="js/vendor/prefixfree.js"></script>
+<script src="js/vendor/promise.js"></script>
+<script src="js/vendor/flickity.pkgd.js"></script>
<script src="js/vendor/util.js"></script>
<script src="js/vendor/view/view.js"></script>
-<script src="js/vendor/view/formview.js"></script>
<script src="js/vendor/view/router.js"></script>
+<script src="js/vendor/view/scrollable.js"></script>
+<script src="js/vendor/view/serializable.js"></script>
+
+<script src="js/sdk/_sdk.js"></script>
+<script src="js/sdk/account.js"></script>
+<script src="js/sdk/address.js"></script>
+<script src="js/sdk/auth.js"></script>
+<script src="js/sdk/cart.js"></script>
+<script src="js/sdk/payment.js"></script>
+<script src="js/sdk/product.js"></script>
+<script src="js/sdk/shipping.js"></script>
<script src="js/lib/cart/CartView.js"></script>
-<script src="js/lib/cart/CartBilling.js"></script>
+<script src="js/lib/cart/CartPayment.js"></script>
<script src="js/lib/cart/CartShipping.js"></script>
<script src="js/lib/cart/CartSummary.js"></script>
+<script src="js/lib/cart/CartConfirm.js"></script>
+<script src="js/lib/cart/CartThanks.js"></script>
<script src="js/lib/nav/IntroView.js"></script>
<script src="js/lib/nav/CurtainView.js"></script>
<script src="js/lib/nav/HeaderView.js"></script>
<script src="js/lib/nav/FooterView.js"></script>
-<script src="js/lib/nav/LoginView.js"></script>
+<script src="js/lib/nav/SearchView.js"></script>
+<script src="js/lib/nav/AddressView.js"></script>
+<script src="js/lib/nav/CreditCardView.js"></script>
<script src="js/lib/nav/NavView.js"></script>
+<script src="js/lib/auth/LoginView.js"></script>
+<script src="js/lib/auth/LogoutView.js"></script>
+<script src="js/lib/auth/SignupView.js"></script>
+
+<script src="js/lib/account/AccountView.js"></script>
+<script src="js/lib/account/ProfileView.js"></script>
+<script src="js/lib/account/PaymentView.js"></script>
+<script src="js/lib/account/ShippingView.js"></script>
+<script src="js/lib/account/SettingsView.js"></script>
+<script src="js/lib/account/OrdersView.js"></script>
+<script src="js/lib/account/orders/OrderList.js"></script>
+<script src="js/lib/account/orders/SingleOrder.js"></script>
+
<script src="js/lib/products/CollectionView.js"></script>
+<script src="js/lib/products/filters/CategoryFilter.js"></script>
+<script src="js/lib/products/ClosedStoreView.js"></script>
<script src="js/lib/products/ProductView.js"></script>
<script src="js/lib/products/GalleryView.js"></script>
<script src="js/lib/products/Selector.js"></script>
@@ -371,18 +853,10 @@
<script src="js/lib/blogs/BlogView.js"></script>
<script src="js/lib/blogs/ArchiveView.js"></script>
<script src="js/lib/blogs/HubView.js"></script>
+<script src="js/lib/blogs/PageView.js"></script>
<script src="js/lib/blogs/StoryView.js"></script>
<script src="js/lib/_router.js"></script>
-<script src="js/sdk/_sdk.js"></script>
-<script src="js/sdk/account.js"></script>
-<script src="js/sdk/address.js"></script>
-<script src="js/sdk/auth.js"></script>
-<script src="js/sdk/cart.js"></script>
-<script src="js/sdk/payment.js"></script>
-<script src="js/sdk/product.js"></script>
-<script src="js/sdk/shipping.js"></script>
-
<script src="js/index.js"></script>
</html>
diff --git a/StoneIsland/platforms/ios/www/js/index.js b/StoneIsland/platforms/ios/www/js/index.js
index e0b08351..ed8d9e5a 100644
--- a/StoneIsland/platforms/ios/www/js/index.js
+++ b/StoneIsland/platforms/ios/www/js/index.js
@@ -6,6 +6,11 @@ var app = (function(){
app.build()
sdk.init({ env: "test" })
+
+ app.iscroll_options = {
+ mouseWheel: true,
+ scrollbars: true,
+ }
if (window.cordova) {
document.addEventListener('deviceready', app.ready, false)
@@ -25,20 +30,34 @@ var app = (function(){
app.archive = new ArchiveView ()
app.hub = new HubView ()
app.story = new StoryView ()
-
app.cart = new CartView ()
+ app.intro = new IntroView ()
app.header = new HeaderView ()
app.footer = new FooterView ()
app.curtain = new CurtainView ()
app.nav = new NavView ()
+ app.account = new AccountView ()
app.login = new LoginView ()
- app.intro = new IntroView ()
+ app.logout = new LogoutView ()
+ app.signup = new SignupView ()
+ app.profile = new ProfileView ()
+ app.payment = new PaymentView ()
+ app.shipping = new ShippingView ()
+ app.settings = new SettingsView ()
+ app.orders = new OrdersView ()
- app.product = new ProductView ()
- app.collection = new CollectionView ()
+ app.terms = new PageView ({ page: "terms" })
+ app.privacy = new PageView ({ page: "privacy" })
+ app.returns = new PageView ({ page: "returns" })
+ app.care = new PageView ({ page: "care" })
+ app.collection = new CollectionView ()
+ app.product = new ProductView ()
+ app.closed = new ClosedStoreView ()
+ app.search = new SearchView ()
+
app.selector = new Selector ()
}
@@ -49,7 +68,7 @@ var app = (function(){
app.view = null
app.router = new SiteRouter ()
- app.router.route()
+ app.account.connect( app.router.route.bind(app.router) )
}
return app
diff --git a/StoneIsland/platforms/ios/www/js/lib/_router.js b/StoneIsland/platforms/ios/www/js/lib/_router.js
index 08b8b819..b70d9be8 100644
--- a/StoneIsland/platforms/ios/www/js/lib/_router.js
+++ b/StoneIsland/platforms/ios/www/js/lib/_router.js
@@ -4,20 +4,48 @@ var SiteRouter = Router.extend({
routeByHash: true,
routes: {
- '/': 'intro',
- '/intro': 'intro',
- '/store': 'store',
- '/hub': 'hub',
- '/story': 'story',
- '/archive': 'archive',
+ '/': 'intro',
+ '/intro': 'intro',
+ '/hub': 'hub',
+ '/story': 'story',
+ '/archive': 'archive',
- '/faq': 'faq',
- '/search': 'search',
+ '/store': 'collection',
+ '/store/closed': 'closed',
+ '/store/:code': 'product',
- '/cart': 'cart',
+ '/account/login': 'login',
+ '/account/logout': 'logout',
+ '/account/signup': 'signup',
+ '/account/profile': 'profile',
+ '/account/payment': 'payment',
+ '/account/shipping': 'shipping',
+ '/account/orders': 'orders',
+ '/account/settings': 'settings',
+
+ '/page/terms': 'terms',
+ '/page/privacy': 'privacy',
+ '/page/returns': 'returns',
+ '/page/care': 'care',
+
+ '/search': 'search',
+
+ '/cart': 'cart.summary',
+ '/cart/summary': 'cart.summary',
+ '/cart/payment': 'cart.payment',
+ '/cart/shipping': 'cart.shipping',
+ '/cart/confirm': 'cart.confirm',
+ '/cart/thanks': 'cart.thanks',
},
initialize: function(){
+ var fn
+ for (var route in this.routes) {
+ fn = this.routes[route]
+ if (! this[fn]) {
+ this[fn] = this.default_view(fn)
+ }
+ }
},
go: function(url){
@@ -27,35 +55,39 @@ var SiteRouter = Router.extend({
window.location.href = "#/" + url
this.parseRoute(url)
},
+
+ default_view: function(name){
+ var fn = function(){
+ console.log(name)
+ if (app.view != app.login && app.view != app.signin) {
+ app.last_view = app.view
+ }
+ if (app.view && app.view.hide) {
+ app.view.hide()
+ }
+ if (name.match(/\./)) {
+ var n = name.split(".")
+ console.log(name, n)
+ app.view = app[n[0]][n[1]]
+ }
+ else {
+ app.view = app[name]
+ }
+ app.header.set_back( !! app.view.back )
+ app.view.show()
+ }.bind(this)
+ return fn
+ },
- intro: function(){
- app.view = app.intro
- app.intro.show()
- },
-
- store: function(){
- app.view = app.store
- app.collection.show()
- },
-
- hub: function(){
- app.view = app.hub
- app.hub.show()
- },
-
- story: function(){
- app.view = app.story
- app.story.show()
- },
-
- archive: function(){
- app.view = app.archive
- app.archive.show()
- },
-
- cart: function(){
- app.view = app.cart
- app.cart.show()
+ product: function(code){
+ if (app.view && app.view.hide) {
+ app.view.hide()
+ }
+ app.view = app.product
+ app.header.set_back( true )
+ app.product.load(code)
+ app.product.show()
},
})
+
diff --git a/StoneIsland/platforms/ios/www/js/lib/account/AccountView.js b/StoneIsland/platforms/ios/www/js/lib/account/AccountView.js
new file mode 100644
index 00000000..cbd9a9c6
--- /dev/null
+++ b/StoneIsland/platforms/ios/www/js/lib/account/AccountView.js
@@ -0,0 +1,70 @@
+var AccountView = View.extend({
+
+ initialize: function(){
+ },
+
+ connect: function(cb){
+ auth.init(this.ready.bind(this, cb))
+ },
+
+ ready: function(cb){
+ if (auth.logged_in()) {
+ this.logged_in(cb)
+ }
+ else {
+ this.logged_out(cb)
+ }
+ },
+
+ populateAddresses: function(data){
+ console.log("populate addresses:", data)
+ if (! data.AddressBook) {
+ console.log("no addresses")
+ return
+ }
+ // console.log(data.AddressBook)
+ data.AddressBook.addressBookItem.forEach(function(item){
+ if (item.isDefault) {
+ // populate app.shipping.address
+ }
+ else if (item.isBillingDefault) {
+ // populate app.billing.address
+ }
+ })
+ },
+
+ logged_in: function(cb){
+ sdk.address.list({
+ success: this.populateAddresses.bind(this)
+ })
+ $("#nav .login").hide()
+ $("#nav .account, #nav .logout").show()
+ if (app.last_view && app.last_view != app.login && app.last_view != app.signin && app.last_view != app.logout) {
+ app.view && app.view.hide && app.view.hide()
+ app.view = app.last_view
+ app.view.show()
+ }
+ else {
+ cb && cb()
+ }
+ if ( ! auth.has_cart() ) {
+ auth.create_cart(auth.add_deferred_product_to_cart)
+ }
+ else {
+ if (auth.deferred_product) {
+ auth.add_deferred_product_to_cart()
+ }
+ else {
+ app.cart.load()
+ }
+ }
+ },
+
+ logged_out: function(cb){
+ $("#nav .login").show()
+ $("#nav .account, #nav .logout").hide()
+ $("#nav").removeClass("account")
+ cb && cb()
+ },
+
+})
diff --git a/StoneIsland/platforms/ios/www/js/lib/account/OrdersView.js b/StoneIsland/platforms/ios/www/js/lib/account/OrdersView.js
new file mode 100644
index 00000000..7283b65c
--- /dev/null
+++ b/StoneIsland/platforms/ios/www/js/lib/account/OrdersView.js
@@ -0,0 +1,29 @@
+var OrdersView = View.extend({
+
+ el: "#orders",
+
+ events: {
+ "click .back": "back",
+ "click .details": "load_single",
+ },
+
+ initialize: function(){
+ this.single = new SingleOrder ({ parent: this })
+ this.list = new OrderList ({ parent: this })
+ },
+
+ show: function(){
+ if (! auth.logged_in()) { return app.router.go("intro") }
+ app.footer.hide()
+ document.body.className = "orders"
+ this.el.className = "list"
+ },
+
+ load_single: function(){
+ },
+
+ back: function(){
+ this.list.show()
+ },
+
+})
diff --git a/StoneIsland/platforms/ios/www/js/lib/account/PaymentView.js b/StoneIsland/platforms/ios/www/js/lib/account/PaymentView.js
new file mode 100644
index 00000000..d61ab5ab
--- /dev/null
+++ b/StoneIsland/platforms/ios/www/js/lib/account/PaymentView.js
@@ -0,0 +1,25 @@
+var PaymentView = FormView.extend({
+
+ el: "#payment",
+
+ events: {
+ },
+
+ initialize: function(){
+ this.$form = this.$("form")
+ this.$msg = this.$(".msg")
+ this.address = new AddressView ({ parent: this })
+ this.cc = new CreditCardView ({ parent: this })
+ this.scroller = new IScroll('#payment', app.iscroll_options)
+ },
+
+ show: function(){
+ if (! auth.logged_in()) { return app.router.go("intro") }
+ app.footer.show("SAVE", "CANCEL")
+ document.body.className = "payment"
+ },
+
+ save: function(){
+ },
+
+})
diff --git a/StoneIsland/platforms/ios/www/js/lib/account/ProfileView.js b/StoneIsland/platforms/ios/www/js/lib/account/ProfileView.js
new file mode 100644
index 00000000..9150f874
--- /dev/null
+++ b/StoneIsland/platforms/ios/www/js/lib/account/ProfileView.js
@@ -0,0 +1,100 @@
+var ProfileView = FormView.extend({
+
+ el: "#profile",
+
+ events: {
+ },
+
+ initialize: function(){
+ this.$form = this.$("form")
+ this.$msg = this.$(".msg")
+ this.scroller = new IScroll('#profile', app.iscroll_options)
+ },
+
+ show: function(){
+ if (! auth.logged_in()) { return app.router.go("intro") }
+ app.footer.show("SAVE", "CANCEL")
+ document.body.className = "profile"
+
+ this.preload(auth.user)
+ },
+
+ validate_presence: {
+ "Name": "Please enter your first name.",
+ "Surname": "Please enter your last name.",
+ "Email": "Please enter a valid email address.",
+ },
+
+ validate_fields: function(data, errors){
+ if (! data.Email.match("@")) { errors.push([ "Email", "Email address is not valid." ]) }
+ if (! data.CurrentPassword && (data.NewPassword || data.Email !== auth.user.Email)) { errors.push([ "CurrentPassword", "Please enter your current password." ]) }
+ if (data.CurrentPassword && ! data.NewPassword) { errors.push([ "NewPassword", "Please enter your new password." ]) }
+ if (data.NewPassword && data.NewPassword.length < 7) { errors.push([ "CurrentPassword", "New password must be 7 characters or more." ]) }
+ if (data.Gender === "NONE") { errors.push([ "Gender", "Please supply your gender." ]) }
+
+ data.BirthDay += "T00:00:00Z"
+ data.YooxLetter = data.YooxLetter || "false"
+ },
+
+ save: function(e){
+ e && e.preventDefault()
+
+ var valid = this.validate()
+ if (valid.errors.length) {
+ this.show_errors(valid.errors)
+ return
+ }
+ else {
+ this.hide_errors()
+ }
+
+ var data = valid.data
+ if (data.CurrentPassword && (data.NewPassword || data.Email !== auth.user.Email)) {
+ data.NewPassword = data.NewPassword || data.CurrentPassword
+ data.NewEmail = data.NewEmail || auth.user.Email
+
+ sdk.account.update_mail_and_password({
+ data: {
+ Password: data.CurrentPassword,
+ NewPassword: data.NewPassword || data.CurrentPassword,
+ Email: auth.user,
+ NewEmail: data.NewEmail || auth.user.Email,
+ },
+ success: function(){ console.log("updated password") },
+ error: function(){ console.log("error updating password") },
+ })
+ }
+
+ var submissible_data = _.pick(valid.data, "Name Surname BirthDay Gender YooxLetter".split(" "))
+
+ submissible_data.idUser = auth.user_id
+ submissible_data.AccessToken = auth.access_token
+ submissible_data.Premium = "false"
+ submissible_data.LanguageId = ""
+ submissible_data.SiteCode = "STONEISLAND_US"
+ submissible_data.FuriganaName = ""
+ submissible_data.FuriganaSurname = ""
+ submissible_data.UserPromocode = ""
+ submissible_data.DataProfiling = "true"
+
+ app.curtain.show("loading")
+ sdk.account.update({
+ data: submissible_data,
+ success: function(data){
+ app.curtain.hide("loading")
+ this.success(data)
+ }.bind(this),
+ error: function(data){
+ app.curtain.hide("loading")
+ this.error(data)
+ }.bind(this),
+ })
+ },
+
+ success: function(data){
+ },
+
+ error: function(data){
+ },
+
+}) \ No newline at end of file
diff --git a/StoneIsland/platforms/ios/www/js/lib/account/SettingsView.js b/StoneIsland/platforms/ios/www/js/lib/account/SettingsView.js
new file mode 100644
index 00000000..81b8b5cc
--- /dev/null
+++ b/StoneIsland/platforms/ios/www/js/lib/account/SettingsView.js
@@ -0,0 +1,23 @@
+var SettingsView = FormView.extend({
+
+ el: "#settings",
+
+ events: {
+ },
+
+ initialize: function(){
+ this.$form = this.$("form")
+ this.$msg = this.$(".msg")
+ this.scroller = new IScroll('#settings', app.iscroll_options)
+ },
+
+ show: function(){
+ if (! auth.logged_in()) { return app.router.go("intro") }
+ app.footer.show("SAVE", "CANCEL")
+ document.body.className = "settings"
+ },
+
+ save: function(){
+ },
+
+}) \ No newline at end of file
diff --git a/StoneIsland/platforms/ios/www/js/lib/account/ShippingView.js b/StoneIsland/platforms/ios/www/js/lib/account/ShippingView.js
new file mode 100644
index 00000000..f5bf1661
--- /dev/null
+++ b/StoneIsland/platforms/ios/www/js/lib/account/ShippingView.js
@@ -0,0 +1,24 @@
+var ShippingView = FormView.extend({
+
+ el: "#shipping",
+
+ events: {
+ },
+
+ initialize: function(){
+ this.$form = this.$("form")
+ this.$msg = this.$(".msg")
+ this.address = new AddressView ({ parent: this })
+ this.scroller = new IScroll('#shipping', app.iscroll_options)
+ },
+
+ show: function(){
+ if (! auth.logged_in()) { return app.router.go("intro") }
+ app.footer.show("SAVE", "CANCEL")
+ document.body.className = "shipping"
+ },
+
+ save: function(){
+ },
+
+}) \ No newline at end of file
diff --git a/StoneIsland/platforms/ios/www/js/lib/account/orders/OrderList.js b/StoneIsland/platforms/ios/www/js/lib/account/orders/OrderList.js
new file mode 100644
index 00000000..876f609e
--- /dev/null
+++ b/StoneIsland/platforms/ios/www/js/lib/account/orders/OrderList.js
@@ -0,0 +1,17 @@
+var OrderList = ScrollableView.extend({
+
+ el: "#order_list",
+
+ template: $("#order_list .template"),
+
+ initialize: function(opt){
+ this.parent = opt.parent
+ this.scroller = new IScroll('#order_list', app.iscroll_options)
+ },
+
+ show: function(){
+ document.body.className = "orders"
+ app.orders.el.className = "list"
+ },
+
+})
diff --git a/StoneIsland/platforms/ios/www/js/lib/account/orders/SingleOrder.js b/StoneIsland/platforms/ios/www/js/lib/account/orders/SingleOrder.js
new file mode 100644
index 00000000..21416401
--- /dev/null
+++ b/StoneIsland/platforms/ios/www/js/lib/account/orders/SingleOrder.js
@@ -0,0 +1,18 @@
+var SingleOrder = ScrollableView.extend({
+
+ el: "#single_order",
+
+ template: $("#single_order .template"),
+
+ initialize: function(opt){
+ this.parent = opt.parent
+ this.scroller = new IScroll('#single_order', app.iscroll_options)
+ },
+
+ show: function(id){
+ document.body.className = "orders"
+ app.orders.el.className = "single"
+ this.deferScrollToTop()
+ },
+
+})
diff --git a/StoneIsland/platforms/ios/www/js/lib/auth/LoginView.js b/StoneIsland/platforms/ios/www/js/lib/auth/LoginView.js
new file mode 100644
index 00000000..1f7438cc
--- /dev/null
+++ b/StoneIsland/platforms/ios/www/js/lib/auth/LoginView.js
@@ -0,0 +1,53 @@
+var LoginView = FormView.extend({
+
+ el: "#login",
+
+ action: sdk.account.login,
+
+ events: {
+ "click .newuser": "new_user",
+ "submit form": "save",
+ },
+
+ initialize: function(){
+ this.$form = this.$("form")
+ this.$msg = this.$(".msg")
+ this.scroller = new IScroll('#login', app.iscroll_options)
+ },
+
+ show: function(){
+ if (auth.logged_in()) {
+ app.router.go("intro")
+ return
+ }
+ var msg = "* Your personal and payment<br>information will always remain private"
+ app.footer.show("SUBMIT", "CANCEL")
+ this.$form.get(0).reset()
+ this.$msg.html(msg)
+ document.body.className = "login"
+ },
+
+ new_user: function(){
+ app.router.go("account/signup")
+ },
+
+ validate_presence: {
+ "Email": "Please enter a valid email address.",
+ "Password": "Please enter your password.",
+ },
+
+ success: function(data){
+ // console.log(data)
+ app.account.logged_in(function(){ app.router.go("store") })
+ },
+
+ error: function(data){
+ this.$msg.html("There was an error logging you in. Bad password?")
+ this.$msg.addClass('alert-notice')
+ },
+
+ cancel: function(){
+ auth.deferred_product = null
+ },
+
+})
diff --git a/StoneIsland/platforms/ios/www/js/lib/auth/LogoutView.js b/StoneIsland/platforms/ios/www/js/lib/auth/LogoutView.js
new file mode 100644
index 00000000..735c0242
--- /dev/null
+++ b/StoneIsland/platforms/ios/www/js/lib/auth/LogoutView.js
@@ -0,0 +1,15 @@
+var LogoutView = View.extend({
+
+ el: "#logout",
+
+ events: {
+ },
+
+ show: function(){
+ document.body.className = "logout"
+ app.footer.hide()
+ app.account.logged_out()
+ auth.clear_user()
+ },
+
+}) \ No newline at end of file
diff --git a/StoneIsland/platforms/ios/www/js/lib/auth/SignupView.js b/StoneIsland/platforms/ios/www/js/lib/auth/SignupView.js
new file mode 100644
index 00000000..7f894c3c
--- /dev/null
+++ b/StoneIsland/platforms/ios/www/js/lib/auth/SignupView.js
@@ -0,0 +1,103 @@
+var SignupView = FormView.extend({
+
+ el: "#signup",
+
+ action: sdk.account.signup,
+ last_data: null,
+
+ test_data: {
+ "Email": "testit.account" + Math.floor(Math.random() * 10000000) + "@yoox.com",
+ "Password": "TestPassword",
+ "Password2": "TestPassword",
+ "Gender": "U",
+ "Name": "TestName",
+ "Surname": "TestSurname",
+ "BirthDay": "1978-11-12",
+ "DataProfiling": true,
+ "DataProfiling2": true,
+ },
+
+ events: {
+ "click .privacy-msg": "privacy_link",
+ "submit form": "save",
+ },
+
+ initialize: function(){
+ this.$form = this.$("form")
+ this.$msg = this.$(".msg")
+ this.scroller = new IScroll('#signup', app.iscroll_options)
+ },
+
+ show: function(){
+ if (auth.logged_in()) {
+ app.router.go("intro")
+ return
+ }
+ var msg = "* Your personal and payment<br>information will always remain private"
+ app.footer.show("SUBMIT", "CANCEL")
+ this.$form.get(0).reset()
+ this.$msg.html(msg)
+ document.body.className = "signup"
+
+ this.preload()
+ },
+
+ validate_presence: {
+ "Name": "Please enter your first name.",
+ "Surname": "Please enter your last name.",
+ "Email": "Please enter a valid email address.",
+ "ConfirmEmail": "Please enter a valid email address.",
+ "Password": "Please enter your password.",
+ "Password2": "Please enter your password again.",
+ "DataProfiling": "You must agree to data profiling.",
+ },
+
+ validate_fields: function(data, errors){
+ if (data.Password.length < 7) { errors.push([ "Password", "Password must be 7 characters or more." ]) }
+ if (data.Password !== data.Password2) { errors.push([ "Password2", "Passwords don't match." ]) }
+ if (! data.Email.match("@")) { errors.push([ "Email", "Email address is not valid." ]) }
+ if (data.Email.toLowerCase() !== data.ConfirmEmail.toLowerCase()) { errors.push([ "ConfirmEmail", "Email addresses don't match." ]) }
+ if (data.Gender === "NONE") { errors.push([ "Gender", "Please supply your gender." ]) }
+ if (data.DataProfiling !== "true") { errors.push([ "DataProfiling", "You must consent to use this service." ]) }
+ if (data.DataProfiling2 !== "true") { errors.push([ "DataProfiling2", "You must consent to use this service." ]) }
+ if (! data.YooxLetter) { data.YooxLetter = false }
+
+ delete data.DataProfiling2
+ delete data.ConfirmEmail
+
+ data.BirthDay += "T00:00:00Z"
+
+ this.last_data = data
+ console.log(data)
+ },
+
+ privacy_link: function(){
+ // rewrite app.privacy instance temporarily
+ app.privacy.back = function(){
+ app.router.go("account/signup")
+ }
+ app.privacy.hide = function(){
+ app.privacy.back = app.privacy.hide = null
+ }
+ app.router.go("page/privacy")
+ },
+
+ success: function(data){
+ console.log('success', data)
+ auth.user = auth.user || {}
+ auth.user.Name = this.last_data.Name
+ auth.user.Surname = this.last_data.Surname
+ auth.user.Email = this.last_data.Email
+ auth.user.BirthDay = this.last_data.BirthDay
+ app.account.logged_in(function(){ app.router.go("store") })
+ },
+
+ error: function(data){
+ console.log('error', data)
+ },
+
+ cancel: function(){
+ auth.deferred_product = null
+ },
+
+}) \ No newline at end of file
diff --git a/StoneIsland/platforms/ios/www/js/lib/blogs/ArchiveView.js b/StoneIsland/platforms/ios/www/js/lib/blogs/ArchiveView.js
index 34e8b109..051ef0c9 100644
--- a/StoneIsland/platforms/ios/www/js/lib/blogs/ArchiveView.js
+++ b/StoneIsland/platforms/ios/www/js/lib/blogs/ArchiveView.js
@@ -1,4 +1,4 @@
-var ArchiveView = View.extend({
+var ArchiveView = ScrollableView.extend({
el: "#archive",
template: $("#archive .template").html(),
@@ -9,10 +9,12 @@ var ArchiveView = View.extend({
initialize: function(){
this.$content = this.$(".content")
this.$loader = this.$(".loader")
- this.scroller = new IScroll('#archive .scroll')
+ this.scroller = new IScroll('#archive', app.iscroll_options)
},
show: function(){
+ this.deferScrollToTop()
+ app.footer.hide()
document.body.className = "archive"
},
@@ -20,14 +22,14 @@ var ArchiveView = View.extend({
this.data = data
this.$loader.hide()
this.$content.empty()
+
+ // id title images[ uri label code caption ]
this.data.forEach(function(row){
- var t = this.template.replace(/{{image}}/, row.image.url)
+ var t = this.template.replace(/{{image}}/, row.images[0].uri)
.replace(/{{code}}/, row.code)
.replace(/{{title}}/, row.title)
- .replace(/{{body}}/, row.body)
this.$content.append(t)
}.bind(this))
},
-
}) \ No newline at end of file
diff --git a/StoneIsland/platforms/ios/www/js/lib/blogs/BlogView.js b/StoneIsland/platforms/ios/www/js/lib/blogs/BlogView.js
index 70fc910a..19666f8b 100644
--- a/StoneIsland/platforms/ios/www/js/lib/blogs/BlogView.js
+++ b/StoneIsland/platforms/ios/www/js/lib/blogs/BlogView.js
@@ -17,17 +17,31 @@ var BlogView = View.extend({
},
success: function(data){
+
+ if (this.loaded) return
+
this.loaded = true
this.data = data
- this.loader.preloadImage(data.archive[0].image.url, function(img){
+
+ this.loader.preloadImage(data.archive[0].images[0].uri, function(img){
app.archive.populate(data.archive)
})
- this.loader.preloadImage(data.hub[0].image.url, function(img){
+ this.loader.preloadImage(data.hub[0].image[0].uri, function(img){
app.hub.populate(data.hub)
})
- this.loader.preloadImage(data.story[0].image.url, function(img){
+ this.loader.preloadImage(data.story[0].image.uri, function(img){
app.story.populate(data.story)
})
+ data.page.forEach(function(page){
+ app[page.tag].populate(page)
+
+ })
+ app.collection.setCollectionName( data.store[0].collection )
+
+ app.closed.populate(data.store[0].ClosedStoreImages)
+ if (data.store[0].StoreIsOpen !== "true") {
+ app.closed.storeIsClosed = true
+ }
},
}) \ No newline at end of file
diff --git a/StoneIsland/platforms/ios/www/js/lib/blogs/HubView.js b/StoneIsland/platforms/ios/www/js/lib/blogs/HubView.js
index ea9b3048..3b2900ad 100644
--- a/StoneIsland/platforms/ios/www/js/lib/blogs/HubView.js
+++ b/StoneIsland/platforms/ios/www/js/lib/blogs/HubView.js
@@ -1,18 +1,21 @@
-var HubView = View.extend({
+var HubView = ScrollableView.extend({
el: "#hub",
template: $("#hub .template").html(),
events: {
+ "click .store": "store_link",
},
initialize: function(){
this.$content = this.$(".content")
this.$loader = this.$(".loader")
- this.scroller = new IScroll('#hub .scroll')
+ this.scroller = new IScroll('#hub', app.iscroll_optionsx)
},
show: function(){
+ this.deferScrollToTop()
+ app.footer.hide()
document.body.className = "hub"
},
@@ -20,17 +23,65 @@ var HubView = View.extend({
this.data = data
this.$loader.hide()
this.$content.empty()
+ // id date subtitle body link store image[uri caption]
this.data.forEach(function(row){
- var t = this.template.replace(/{{image}}/, row.image.url)
- .replace(/{{date}}/, row.date)
- .replace(/{{code}}/, row.code)
+ // console.log(row)
+ var t = this.template.replace(/{{id}}/, row.id)
+ .replace(/{{date}}/, moment(row.date).format("MM.DD.YYYY"))
.replace(/{{title}}/, row.title)
.replace(/{{subtitle}}/, row.subtitle)
.replace(/{{link}}/, row.link)
- .replace(/{{body}}/, row.body)
- this.$content.append(t)
+ .replace(/{{body}}/, row.body.replace(/\n/g, "<br>"))
+ var $t = $(t)
+ if (row.store != "true") {
+ $t.find(".store").remove()
+ }
+ this.$content.append($t)
+
+ if (row.image.length > 1) {
+ // image gallery
+ var $gallery = $(".gallery-" + row.id)
+ row.image.forEach(function(img){
+ var el = document.createElement("div")
+ el.style.backgroundImage = "url(" + img.uri + ")"
+ el.className = "item"
+ $gallery.append(el)
+ })
+ new Flickity( ".gallery-" + row.id, {
+ selector: '.item',
+ cellAlign: 'center',
+ autoPlay: false,
+ freeScroll: false,
+ wrapAround: true,
+ imagesLoaded: true,
+ prevNextButtons: false,
+ pageDots: false,
+ contain: true,
+ draggable: true,
+ })
+ }
+ else {
+ // single image
+ var el = document.createElement("div")
+ el.style.backgroundImage = "url(" + row.image[0].uri + ")"
+ el.className = "item"
+ $(".gallery-" + row.id).append(el)
+
+ // video, append play button
+ if (row.link.match(/youtube|youtu.be|vimeo/)) {
+ var play = document.createElement("div")
+ play.className = "play"
+ $(".gallery-" + row.id).append(play)
+ }
+ }
+
}.bind(this))
+
+ this.deferScrollToTop()
+ },
+
+ store_link: function(){
+ app.router.go("store")
},
-
}) \ No newline at end of file
diff --git a/StoneIsland/platforms/ios/www/js/lib/blogs/PageView.js b/StoneIsland/platforms/ios/www/js/lib/blogs/PageView.js
new file mode 100644
index 00000000..4bf05430
--- /dev/null
+++ b/StoneIsland/platforms/ios/www/js/lib/blogs/PageView.js
@@ -0,0 +1,24 @@
+var PageView = ScrollableView.extend({
+
+ events: {
+ },
+
+ initialize: function(opt){
+ this.page = opt.page
+ this.setElement("#" + opt.page)
+ this.$content = this.$(".content")
+ this.$loader = this.$(".loader")
+ this.scroller = new IScroll('#' + this.page, app.iscroll_options)
+ },
+
+ show: function(){
+ this.deferScrollToTop()
+ app.footer.hide()
+ document.body.className = this.page
+ },
+
+ populate: function(data){
+ this.$content.html(data.body.replace(/\n/g, "<br>"))
+ },
+
+}) \ No newline at end of file
diff --git a/StoneIsland/platforms/ios/www/js/lib/blogs/StoryView.js b/StoneIsland/platforms/ios/www/js/lib/blogs/StoryView.js
index 7f9b30a1..84684ff7 100644
--- a/StoneIsland/platforms/ios/www/js/lib/blogs/StoryView.js
+++ b/StoneIsland/platforms/ios/www/js/lib/blogs/StoryView.js
@@ -1,32 +1,65 @@
-var StoryView = View.extend({
+var StoryView = ScrollableView.extend({
+
+ loaded: false,
el: "#story",
template: $("#story .template").html(),
events: {
+ "click .links li": "pick",
},
initialize: function(){
+ this.sections = {}
+ this.$img = this.$("img")
this.$content = this.$(".content")
+ this.$links = this.$(".links")
this.$loader = this.$(".loader")
- this.scroller = new IScroll('#story .scroll')
+ this.scroller = new IScroll('#story', app.iscroll_options)
},
show: function(){
+ this.deferScrollToTop()
+ app.footer.hide()
document.body.className = "story"
},
populate: function(data){
+ if (this.loaded) { console.warn("populate called twice"); return }
+ this.loaded = true
this.data = data
this.$loader.hide()
this.$content.empty()
+ // id title image[uri caption] body
this.data.forEach(function(row){
- var t = this.template.replace(/{{image}}/, row.image.url)
- .replace(/{{date}}/, row.date)
- .replace(/{{title}}/, row.title)
- .replace(/{{body}}/, row.body)
+ var t = this.template.replace(/{{id}}/, row.id)
+ .replace(/{{body}}/, row.body.replace(/\n/g, "<br>"))
+ var li = document.createElement("li")
+ li.dataset.id = row.id
+ li.innerHTML = row.title
+ this.sections[row.id] = row
+ this.$links.append(li)
this.$content.append(t)
}.bind(this))
+
+ this.set_active( this.data[0].id )
+ },
+
+ pick: function(e){
+ var id = e.currentTarget.dataset.id
+ this.set_active(id)
+ },
+
+ set_active: function(id){
+ this.$links.find(".active").removeClass("active")
+ this.$links.find("[data-id=" + id + "]").addClass("active")
+
+ this.$content.find(".active").removeClass("active")
+ this.$content.find("[data-id=" + id + "]").addClass("active")
+
+ var section = this.sections[id]
+ this.$img.attr("src", section.image.uri)
+ this.deferScrollToTop()
},
}) \ No newline at end of file
diff --git a/StoneIsland/platforms/ios/www/js/lib/cart/CartBilling.js b/StoneIsland/platforms/ios/www/js/lib/cart/CartBilling.js
deleted file mode 100644
index f3c9cbe2..00000000
--- a/StoneIsland/platforms/ios/www/js/lib/cart/CartBilling.js
+++ /dev/null
@@ -1,11 +0,0 @@
-var CartBilling = View.extend({
-
- el: "#billing",
-
- events: {
- },
-
- initialize: function(){
- },
-
-}) \ No newline at end of file
diff --git a/StoneIsland/platforms/ios/www/js/lib/cart/CartConfirm.js b/StoneIsland/platforms/ios/www/js/lib/cart/CartConfirm.js
new file mode 100644
index 00000000..687f3a93
--- /dev/null
+++ b/StoneIsland/platforms/ios/www/js/lib/cart/CartConfirm.js
@@ -0,0 +1,29 @@
+var CartConfirm = FormView.extend({
+
+ el: "#cart_confirm",
+
+ events: {
+ },
+
+ initialize: function(opt){
+ this.parent = opt.parent
+ this.scroller = new IScroll('#cart_confirm', app.iscroll_options)
+ },
+
+ show: function(){
+ document.body.className = "cart"
+ app.cart.el.className = "confirm"
+ app.footer.show("PLACE ORDER", "CANCEL")
+ this.deferScrollToTop()
+ },
+
+ populate: function(){
+ },
+
+ save: function(){
+ },
+
+ cancel: function(){
+ },
+
+}) \ No newline at end of file
diff --git a/StoneIsland/platforms/ios/www/js/lib/cart/CartPayment.js b/StoneIsland/platforms/ios/www/js/lib/cart/CartPayment.js
new file mode 100644
index 00000000..19d21ffd
--- /dev/null
+++ b/StoneIsland/platforms/ios/www/js/lib/cart/CartPayment.js
@@ -0,0 +1,40 @@
+var CartPayment = FormView.extend({
+
+ el: "#cart_payment",
+
+ events: {
+ },
+
+ initialize: function(opt){
+ this.parent = opt.parent
+ this.$form = this.$("form")
+ this.$msg = this.$(".msg")
+ this.address = new AddressView ({ parent: this })
+ this.cc = new CreditCardView ({ parent: this })
+ this.scroller = new IScroll('#cart_payment', app.iscroll_options)
+ },
+
+ // sdk.cart.set_credit_card
+ // sdk.payment.list_credit_cards
+ // sdk.payment.add_credit_card
+ // sdk.payment.delete_credit_card
+ // sdk.payment.get_payment_types
+ // sdk.cart.use_stored_credit_card
+
+ show: function(){
+ document.body.className = "cart"
+ app.cart.el.className = "payment"
+ app.footer.show("CONFIRM &gt;", "CANCEL")
+
+ this.deferScrollToTop()
+
+ sdk.cart.set_payment_type({ data: payment_id })
+ },
+
+ save: function(){
+ },
+
+ cancel: function(){
+ },
+
+}) \ No newline at end of file
diff --git a/StoneIsland/platforms/ios/www/js/lib/cart/CartShipping.js b/StoneIsland/platforms/ios/www/js/lib/cart/CartShipping.js
index beaf6bd2..7d7c8540 100644
--- a/StoneIsland/platforms/ios/www/js/lib/cart/CartShipping.js
+++ b/StoneIsland/platforms/ios/www/js/lib/cart/CartShipping.js
@@ -1,11 +1,33 @@
-var CartShipping = View.extend({
+var CartShipping = FormView.extend({
- el: "#shipping",
+ el: "#cart_shipping",
events: {
},
+
+ initialize: function(opt){
+ this.parent = opt.parent
+ this.$form = this.$("form")
+ this.$msg = this.$(".msg")
+ this.address = new AddressView ({ parent: this })
+ this.scroller = new IScroll('#cart_shipping', app.iscroll_options)
+ },
+
+ show: function(){
+ document.body.className = "cart"
+ app.cart.el.className = "shipping"
+ app.footer.show("PAYMENT &gt;", "CANCEL")
+ this.deferScrollToTop()
+ },
+
+ // sdk.cart.set_shipping_address
+ // sdk.shipping.get_delivery_types
+ // sdk.shipping.set_delivery_type
+
+ save: function(){
+ },
- initialize: function(){
+ cancel: function(){
},
}) \ No newline at end of file
diff --git a/StoneIsland/platforms/ios/www/js/lib/cart/CartSummary.js b/StoneIsland/platforms/ios/www/js/lib/cart/CartSummary.js
index 37400dd0..209e3102 100644
--- a/StoneIsland/platforms/ios/www/js/lib/cart/CartSummary.js
+++ b/StoneIsland/platforms/ios/www/js/lib/cart/CartSummary.js
@@ -1,11 +1,184 @@
-var CartSummary = View.extend({
+var CartSummary = ScrollableView.extend({
- el: "#summary",
+ el: "#cart_summary",
+
+ template: $("#cart_summary .template").html(),
events: {
+ "click .remove": "remove_item",
+ },
+
+ data: null,
+
+ initialize: function(opt){
+ this.parent = opt.parent
+ this.$loader = this.$(".loader")
+ this.$cart_body = this.$(".cart_body")
+ this.$cart_empty = this.$(".cart_empty")
+ this.scroller = new IScroll('#cart_summary', app.iscroll_options)
+
+ this.$rows = this.$(".rows")
+ this.$subtotal = this.$(".subtotal")
+ this.$shipping = this.$(".shipping")
+ this.$tax = this.$(".tax")
+ this.$total = this.$(".total")
+ },
+
+ show: function(){
+ document.body.className = "cart"
+ app.cart.el.className = "summary"
+ if (auth.has_cart()) {
+ this.load()
+ }
+ else {
+ this.empty()
+ }
+ },
+
+ load: function(){
+ this.el.className = "loading"
+ app.footer.show("SHIPPING &gt;", "CANCEL")
+ sdk.cart.get_status({
+ success: this.populate.bind(this),
+ error: this.empty.bind(this),
+ })
+ },
+
+ populate: function(data){
+ this.data = data
+
+ console.log("CART", data)
+
+ if (! data.Cart.Items || data.Cart.Items.length == 0) {
+ return this.empty()
+ }
+
+ this.updateCounts()
+
+ this.$rows.empty()
+
+ data.Cart.Items.forEach(function(item){
+ var code_ten = item['Code10']
+ var code = code_ten.substr(0, 8)
+ var size_id = item['Size']
+
+ var $el = $("<div>").addClass("cart_item_row")
+ $el.data({
+ code: code_ten,
+ size: size_id,
+ })
+ this.$rows.append($el)
+ app.product.find(code, function(data, details){
+ // console.log(data, details)
+
+ var descriptions = app.product.get_descriptions( details )
+ // console.log(descriptions)
+
+ var name_partz = descriptions['ModelNames'].split(' ')
+ var num = name_partz.shift()
+ var title = name_partz.join(' ')
+ var type = title_case( descriptions['MicroCategory'] )
+
+ var color_name, size_name
+ // console.log(code)
+ details.Item.ModelColors.some(function(color){
+ if (color['Code10'] == code_ten) {
+ color_name = color['ColorDescription']
+ // console.log(color)
+ return true
+ }
+ return false
+ })
+ details.Item.ModelSizes.some(function(size){
+ if (size['SizeId'] == size_id) {
+ // console.log(size)
+ size_name = size['Default']['Text']
+ size_name = SIZE_LOOKUP[ size_name ] || size_name
+ return true
+ }
+ return false
+ })
+
+ var t = this.template
+ .replace(/{{image}}/, sdk.image(item['Code10'], '11_f'))
+ .replace(/{{sku}}/, num)
+ .replace(/{{title}}/, title)
+ .replace(/{{type}}/, type)
+ .replace(/{{size}}/, size_name)
+ .replace(/{{color}}/, color_name)
+ .replace(/{{quantity}}/, 1)
+ .replace(/{{price}}/, as_cash(details.Item.Price.DiscountedPrice))
+ $el.data("price", details.Item.Price.DiscountedPrice)
+ $el.html(t)
+ this.deferScrollToTop()
+ }.bind(this))
+ }.bind(this))
+
+ this.updateTotals()
+
+ this.el.className = "full"
+ this.deferScrollToTop()
+ },
+
+ updateCounts: function(){
+ app.header.set_cart_count(this.data.Cart.Items.length)
+ this.parent.$itemcount.html(pluralize(this.data.Cart.Items.length, "ITEM", "S"))
+ },
+
+ updateTotals: function(){
+ var subtotal = this.data.Cart.Totals.TotalWithoutPromotions
+ var shipping_cost = this.data.Cart.DeliveryMethod.Selected.Amount.Total
+ var tax = 0
+ var total = this.data.Cart.Totals.TotalToPay
+
+ this.$subtotal.html( as_cash(subtotal) )
+ this.$shipping.html( as_cash(shipping_cost) )
+ this.$tax.html( as_cash(tax) )
+ this.$total.html( as_cash(total) )
+ },
+
+ empty: function(){
+ app.footer.hide()
+ app.header.set_cart_count(0)
+ this.parent.$itemcount.html("0 ITEMS")
+ this.el.className = "empty"
+ },
+
+ save: function(){
+ app.router.go('cart/shipping')
+ },
+
+ cancel: function(){
+ app.router.go('intro')
},
- initialize: function(){
+ remove_item: function(e){
+ var $el = $( e.currentTarget ).closest(".cart_item_row")
+ var data = $el.data()
+ data.Cart.Totals.TotalWithoutPromotions -= data.price
+ data.Cart.Totals.TotalToPay -= data.price
+
+ this.data.Cart.Items = this.data.Cart.Items.filter(function(item){
+ return ( item['Code10'] !== data.code || item['Size'] !== data.size)
+ })
+
+ this.updateTotals()
+ this.updateCounts()
+ $el.remove()
+
+ if (this.data.Cart.Items.length == 0) {
+ this.empty()
+ }
+
+ sdk.cart.delete_item({
+ data: {
+ Code10: data.code,
+ Size: data.size,
+ },
+ success: function(){
+ console.log("damn")
+ },
+ })
},
}) \ No newline at end of file
diff --git a/StoneIsland/platforms/ios/www/js/lib/cart/CartThanks.js b/StoneIsland/platforms/ios/www/js/lib/cart/CartThanks.js
new file mode 100644
index 00000000..993fd9ac
--- /dev/null
+++ b/StoneIsland/platforms/ios/www/js/lib/cart/CartThanks.js
@@ -0,0 +1,23 @@
+var CartThanks = View.extend({
+
+ el: "#cart_thanks",
+
+ events: {
+ },
+
+ initialize: function(opt){
+ this.parent = opt.parent
+ },
+
+ show: function(){
+ document.body.className = "cart"
+ app.cart.el.className = "thanks"
+ app.footer.show("&lt; BACK TO COLLECTION")
+ app.footer.hide()
+ },
+
+ ok: function(){
+ app.router.go("store")
+ },
+
+}) \ No newline at end of file
diff --git a/StoneIsland/platforms/ios/www/js/lib/cart/CartView.js b/StoneIsland/platforms/ios/www/js/lib/cart/CartView.js
index 5d741492..8bea43dc 100644
--- a/StoneIsland/platforms/ios/www/js/lib/cart/CartView.js
+++ b/StoneIsland/platforms/ios/www/js/lib/cart/CartView.js
@@ -3,16 +3,48 @@ var CartView = View.extend({
el: "#cart",
events: {
+ "click .summary_step": "show_summary",
+ "click .shipping_step": "show_shipping",
+ "click .payment_step": "show_payment",
},
initialize: function(){
- this.summary = new CartSummary ()
- this.billing = new CartBilling ()
- this.shipping = new CartShipping ()
+ this.summary = new CartSummary ({ parent: this })
+ this.payment = new CartPayment ({ parent: this })
+ this.shipping = new CartShipping ({ parent: this })
+ this.confirm = new CartConfirm ({ parent: this })
+ this.thanks = new CartThanks ({ parent: this })
+
+ this.$itemcount = this.$(".itemcount")
+ },
+
+ load: function(){
+ sdk.cart.get_status({
+ success: function(data){
+ this.summary.data = data
+ this.summary.updateCounts()
+ }.bind(this),
+ error: function(data){
+ console.log(data)
+ },
+ })
},
show: function(){
document.body.className = "cart"
+ this.show_summary()
+ },
+
+ show_summary: function(){
+ this.summary.show()
+ },
+
+ show_shipping: function(){
+ this.shipping.show()
+ },
+
+ show_payment: function(){
+ this.payment.show()
},
}) \ No newline at end of file
diff --git a/StoneIsland/platforms/ios/www/js/lib/nav/AddressView.js b/StoneIsland/platforms/ios/www/js/lib/nav/AddressView.js
new file mode 100644
index 00000000..15a5784d
--- /dev/null
+++ b/StoneIsland/platforms/ios/www/js/lib/nav/AddressView.js
@@ -0,0 +1,39 @@
+
+var AddressView = SerializableView.extend({
+
+ template: $("#address_template").html(),
+
+ events: {
+ },
+
+ initialize: function(opt){
+ this.parent = opt.parent
+ this.$el = this.parent.$(".address")
+ this.el = this.$el[0]
+ this.$el.html(this.template)
+ },
+
+ populate: function(data){
+ this.parent.$(".address input").val("")
+ Object.keys(data).forEach(function(key){
+ this.parent$(".address [name=" + key + "]").val(data[key])
+ }.bind(this))
+ },
+
+ deserialize: function(){
+ },
+
+ validate_presence: {
+ "Name": "Please enter your first name.",
+ "Surname": "Please enter your last name.",
+ "Address1": "Please enter your street address.",
+ "City": "Please enter your city.",
+ "State": "Please choose your state.",
+ "Phone": "Please enter your phone number.",
+ },
+
+ validate_fields: function(data, errors){
+ if (data.Phone.replace(/[^0-9]/g, "").length < 10) { errors.push([ "Phone", "Phone numbers must be at least 10 digits." ]) }
+ },
+
+})
diff --git a/StoneIsland/platforms/ios/www/js/lib/nav/CreditCardView.js b/StoneIsland/platforms/ios/www/js/lib/nav/CreditCardView.js
new file mode 100644
index 00000000..33ecab79
--- /dev/null
+++ b/StoneIsland/platforms/ios/www/js/lib/nav/CreditCardView.js
@@ -0,0 +1,27 @@
+
+var CreditCardView = View.extend({
+
+ template: $("#creditcard_template").html(),
+
+ events: {
+ },
+
+ initialize: function(opt){
+ this.parent = opt.parent
+ this.parent.$(".cc").html(this.template)
+ },
+
+ populate: function(data){
+ this.parent.$(".cc input").val("")
+ Object.keys(data).forEach(function(key){
+ this.parent$(".cc [name=" + key + "]").val(data[key])
+ }.bind(this))
+ },
+
+ validate_presence: {
+ },
+
+ validate_fields: function(data, errors){
+ },
+
+})
diff --git a/StoneIsland/platforms/ios/www/js/lib/nav/CurtainView.js b/StoneIsland/platforms/ios/www/js/lib/nav/CurtainView.js
index ba10e232..d444fd60 100644
--- a/StoneIsland/platforms/ios/www/js/lib/nav/CurtainView.js
+++ b/StoneIsland/platforms/ios/www/js/lib/nav/CurtainView.js
@@ -9,20 +9,30 @@ var CurtainView = View.extend({
initialize: function(){
},
- show: function(){
+ klass: null,
+ show: function(klass){
this.$el.addClass("visible")
+ if (klass) {
+ this.klass = klass
+ this.$el.addClass(klass)
+ }
},
- hide: function(){
+ hide: function(k){
this.$el.removeClass("visible")
+ if (this.klass) {
+ setTimeout( function(){
+ this.$el.removeClass(this.klass)
+ }.bind(this), 200 )
+ }
},
click: function(){
if (document.body.classList.contains("nav")) {
app.nav.hide()
}
- else if (document.body.classList.contains("login")) {
- app.login.hide()
+ if (app.selector.visible) {
+ app.selector.hide()
}
},
diff --git a/StoneIsland/platforms/ios/www/js/lib/nav/FooterView.js b/StoneIsland/platforms/ios/www/js/lib/nav/FooterView.js
index 76126102..74b249e6 100644
--- a/StoneIsland/platforms/ios/www/js/lib/nav/FooterView.js
+++ b/StoneIsland/platforms/ios/www/js/lib/nav/FooterView.js
@@ -3,28 +3,38 @@ var FooterView = View.extend({
el: "#footer",
events: {
- "click .filter": "filter",
- "click .buynow": "buynow",
- "click .addtocart": "addtocart",
+ "click .ok": "ok",
"click .cancel": "cancel",
- "click .checkout": "checkout",
- "click .checkout_proceed": "checkout_proceed",
},
initialize: function(){
+ this.$ok = this.$(".ok")
+ this.$cancel = this.$(".cancel")
},
- filter: function(){
+ show: function(ok, cancel){
+ if (cancel) {
+ this.$ok.removeClass("wide")
+ this.$cancel.show().html(cancel)
+ }
+ else {
+ this.$ok.addClass("wide")
+ this.$cancel.hide()
+ }
+ this.$ok.html(ok)
+ this.$el.show()
},
- buynow: function(){
+
+ hide: function(){
+ this.$el.hide()
},
- addtocart: function(){
+
+ ok: function(){
+ (app.view.save || app.view.ok).bind(app.view)()
},
+
cancel: function(){
+ app.view.cancel ? app.view.cancel() : app.intro.show()
},
- checkout: function(){
- },
- checkout_proceed: function(){
- },
-
+
}) \ No newline at end of file
diff --git a/StoneIsland/platforms/ios/www/js/lib/nav/HeaderView.js b/StoneIsland/platforms/ios/www/js/lib/nav/HeaderView.js
index bbf18274..7563be2d 100644
--- a/StoneIsland/platforms/ios/www/js/lib/nav/HeaderView.js
+++ b/StoneIsland/platforms/ios/www/js/lib/nav/HeaderView.js
@@ -9,10 +9,27 @@ var HeaderView = View.extend({
},
initialize: function(){
+ this.$burger = this.$(".burger")
+ this.$cart = this.$(".cart")
+ this.$cart_count = this.$(".cart_count")
+ },
+
+ set_back: function(state){
+ if (state) {
+ this.$burger[0].className = "burger ion-ios-arrow-left"
+ }
+ else {
+ this.$burger[0].className = "burger ion-android-menu"
+ }
},
nav: function(){
- app.nav.show()
+ if (app.view.back) {
+ app.view.back()
+ }
+ else {
+ app.nav.show()
+ }
},
logo: function(){
@@ -22,5 +39,17 @@ var HeaderView = View.extend({
cart: function(){
app.router.go("cart")
},
+
+ count: 0,
+ set_cart_count: function(n){
+ this.count = n
+ this.$cart_count.html(n)
+ },
+ increment_cart_count: function(){
+ this.$cart_count.html( ++this.count )
+ },
+ decrement_cart_count: function(){
+ this.$cart_count.html( --this.count )
+ },
}) \ No newline at end of file
diff --git a/StoneIsland/platforms/ios/www/js/lib/nav/IntroView.js b/StoneIsland/platforms/ios/www/js/lib/nav/IntroView.js
index 93602eb5..87e68959 100644
--- a/StoneIsland/platforms/ios/www/js/lib/nav/IntroView.js
+++ b/StoneIsland/platforms/ios/www/js/lib/nav/IntroView.js
@@ -17,6 +17,7 @@ var IntroView = View.extend({
show: function(){
document.body.className = "intro"
window.addEventListener("deviceorientation", this.orient)
+ app.footer.hide()
this.orient({ alpha: 0 })
// get location..
},
diff --git a/StoneIsland/platforms/ios/www/js/lib/nav/LoginView.js b/StoneIsland/platforms/ios/www/js/lib/nav/LoginView.js
deleted file mode 100644
index 60f6263e..00000000
--- a/StoneIsland/platforms/ios/www/js/lib/nav/LoginView.js
+++ /dev/null
@@ -1,57 +0,0 @@
-var LoginView = View.extend({
-
- el: "#login",
-
- events: {
- "click .close": "hide",
- "click .login_ask": "login",
- "click .signup_ask": "signup",
- "submit form": "submit",
- },
-
- mode: null,
-
- initialize: function(){
- this.$form = this.$("form")
- this.$email = this.$("[name=email]")
- this.$password = this.$("[name=password]")
- },
-
- show: function(){
- this.$form.hide()
- this.$email.val("")
- this.$password.val("")
- app.curtain.show()
- document.body.classList.add("login")
- },
-
- hide: function(){
- app.curtain.hide()
- document.body.classList.remove("login")
- },
-
- login: function(){
- this.mode = "login"
- this.$form.show()
- },
-
- signup: function(){
- this.mode = "signup"
- this.$form.show()
- },
-
- submit: function(e){
- e.preventDefault()
- if (this.mode == "login") {
- // login api
- }
- else {
- // signup api
- }
- },
-
- success: function(){
- // change login in ui to logout or whatever
- },
-
-}) \ No newline at end of file
diff --git a/StoneIsland/platforms/ios/www/js/lib/nav/NavView.js b/StoneIsland/platforms/ios/www/js/lib/nav/NavView.js
index 3949c3c5..1445a0d5 100644
--- a/StoneIsland/platforms/ios/www/js/lib/nav/NavView.js
+++ b/StoneIsland/platforms/ios/www/js/lib/nav/NavView.js
@@ -3,33 +3,61 @@ var NavView = View.extend({
el: "#nav",
events: {
+ "click .logo": "intro",
+
"click .store": "store",
"click .hub": "hub",
"click .story": "story",
"click .archive": "archive",
"click .login": "login",
+ "click .logout": "logout",
+ "click .account": "account",
"click .faq": "faq",
"click .search": "search",
+ "click .main": "back",
+ "click .account_back": "back",
+ "click .profile": "profile",
+ "click .payment": "payment",
+ "click .shipping": "shipping",
+ "click .settings": "settings",
+ "click .orders": "orders",
+ "click .return_link": "return_link",
+
+ "click .faq_back": "back",
+ "click .privacy": "privacy",
+ "click .returns": "returns",
+ "click .terms": "terms",
+ "click .care": "care",
+
"click .fb": "fb",
"click .insta": "insta",
"click .tw": "tw",
},
- initialize: function(){
- },
+ initialize: function(){
+ },
- show: function(){
+ show: function(klass){
$("body").addClass("nav")
- app.curtain.show()
+ app.curtain.show("dark")
+ if (klass) {
+ setTimeout(function(){
+ this.addClass(klass)
+ }.bind(this), 500)
+ }
},
hide: function(){
$("body").removeClass("nav")
- app.curtain.hide()
+ app.curtain.hide("dark")
},
+ intro: function(){
+ this.hide()
+ app.router.go("intro")
+ },
store: function(){
this.hide()
app.router.go("store")
@@ -49,18 +77,74 @@ var NavView = View.extend({
login: function(){
this.hide()
- app.router.go("login")
+ auth.last_view = app.view
+ app.router.go("account/login")
+ },
+ logout: function(){
+ this.hide()
+ auth.last_view = app.view
+ app.router.go("account/logout")
+ },
+ account: function(){
+ this.el.className = "account"
},
- search: function(){
+ back: function(){
+ this.el.className = ""
+ },
+
+ profile: function(){
this.hide()
- app.router.go("search")
+ app.router.go("account/profile")
+ },
+ payment: function(){
+ this.hide()
+ app.router.go("account/payment")
},
+ shipping: function(){
+ this.hide()
+ app.router.go("account/shipping")
+ },
+ orders: function(){
+ this.hide()
+ app.router.go("account/orders")
+ },
+ settings: function(){
+ this.hide()
+ app.router.go("account/settings")
+ },
+ return_link: function(){
+ window.open("http://www.stoneisland.com/", '_system')
+ },
+
+
faq: function(){
+ this.el.className = "faq"
+ },
+ privacy: function(){
this.hide()
- app.router.go("faq")
+ app.router.go("page/privacy")
+ },
+ returns: function(){
+ this.hide()
+ app.router.go("page/returns")
+ },
+ terms: function(){
+ this.hide()
+ app.router.go("page/terms")
+ },
+ care: function(){
+ this.hide()
+ app.router.go("page/care")
+ },
+
+
+ search: function(){
+ this.hide()
+ app.router.go("search")
},
+
fb: function(){
window.open("https://www.facebook.com/StoneIsland", '_system')
},
@@ -70,6 +154,5 @@ var NavView = View.extend({
tw: function(){
window.open("https://twitter.com/stoneisland", '_system')
},
-
})
diff --git a/StoneIsland/platforms/ios/www/js/lib/nav/SearchView.js b/StoneIsland/platforms/ios/www/js/lib/nav/SearchView.js
new file mode 100644
index 00000000..f21634a5
--- /dev/null
+++ b/StoneIsland/platforms/ios/www/js/lib/nav/SearchView.js
@@ -0,0 +1,16 @@
+var SearchView = View.extend({
+
+ el: "#search",
+
+ events: {
+ },
+
+ show: function(){
+ app.footer.show("SEARCH", "CANCEL")
+ document.body.className = "search"
+ },
+
+ save: function(){
+ },
+
+}) \ No newline at end of file
diff --git a/StoneIsland/platforms/ios/www/js/lib/products/ClosedStoreView.js b/StoneIsland/platforms/ios/www/js/lib/products/ClosedStoreView.js
new file mode 100644
index 00000000..77dc15b1
--- /dev/null
+++ b/StoneIsland/platforms/ios/www/js/lib/products/ClosedStoreView.js
@@ -0,0 +1,47 @@
+var ClosedStoreView = View.extend({
+
+ el: "#closed",
+
+ storeIsClosed: false,
+
+ events: {
+ "click .website_link": "website_link",
+ },
+
+ delay: 8000,
+
+ timeout: -1,
+ images: null,
+
+ initialize: function(){
+ this.loader = new Loader ()
+ },
+
+ show: function(){
+ document.body.className = "closed"
+ this.animate()
+ app.footer.hide()
+ },
+
+ hide: function(){
+ clearTimeout(this.timeout)
+ },
+
+ animate: function(){
+ this.timeout = setTimeout(this.animate.bind(this), this.delay)
+ if (! this.images) return
+ var url = choice(this.images)
+ this.loader.preloadImage(url, function(img){
+ this.el.style.backgroundImage = 'url(' + img.src + ')'
+ }.bind(this))
+ },
+
+ populate: function(data){
+ this.images = data.map(function(img){ return img.uri })
+ },
+
+ website_link: function(){
+ window.open("http://www.stoneisland.com/", '_system')
+ },
+
+}) \ No newline at end of file
diff --git a/StoneIsland/platforms/ios/www/js/lib/products/CollectionView.js b/StoneIsland/platforms/ios/www/js/lib/products/CollectionView.js
index 987804fc..8ea03bd4 100644
--- a/StoneIsland/platforms/ios/www/js/lib/products/CollectionView.js
+++ b/StoneIsland/platforms/ios/www/js/lib/products/CollectionView.js
@@ -1,4 +1,5 @@
-var CollectionView = View.extend({
+
+var CollectionView = ScrollableView.extend({
el: "#collection",
template: $("#collection .template").html(),
@@ -7,16 +8,27 @@ var CollectionView = View.extend({
items: {},
events: {
- "click .item": "pick",
+ "touchstart .item": "touchstart",
+ "touchmove .item": "touchmove",
+ "touchend .item": "touchend",
+ "mousedown .item": "touchstart",
+ "mousemove .item": "touchmove",
+ "mouseup .item": "touchend",
},
initialize: function(){
+ this.$title = this.$("h1")
this.$content = this.$(".content")
this.$loader = this.$(".loader")
- this.scroller = new IScroll('#collection .scroll')
+ this.scroller = new IScroll('#collection', app.iscroll_options)
+ this.filterView = new CategoryFilter ({ parent: this })
},
-
+
show: function(){
+ if (app.closed.storeIsClosed) {
+ return app.closed.show()
+ }
+ app.footer.show("FILTER")
document.body.className = "collection"
if (this.loaded) {
return this.populate(this.data)
@@ -24,32 +36,77 @@ var CollectionView = View.extend({
this.fetch()
},
+ ok: function(){
+ this.filterView.filter()
+ },
+
fetch: function(){
+ if (this.loaded) return
this.$loader.show()
sdk.product.collection({
- gallery_id: 31617,
+ gallery_id: 32780,
success: this.populate.bind(this)
})
},
populate: function(data){
- this.$loader.hide()
- this.$content.empty()
- // DefaultCode10
- console.log(data)
- data.SearchResponseFull.Results.Items.forEach(function(item){
- this.items[ item['Code8'] ] = item
- var t = this.template.replace(/{{image}}/, sdk.image(item['DefaultCode10']))
- .replace(/{{code8}}/, item['Code8'])
- this.$content.append(t)
-
- }.bind(this))
+ if (this.loaded && ! data) {
+ data = this.data
+ }
+ else {
+ this.data = data
+ }
+ if (! this.loaded) {
+ this.loaded = true
+ this.$loader.hide()
+ this.$content.empty()
+ // DefaultCode10
+ data.SearchResponseFull.Results.Items.forEach(this.append.bind(this))
+ this.deferScrollToTop()
+ }
+ this.afterFetchCallback && this.afterFetchCallback()
+ },
+
+ append: function(item){
+ this.items[ item['Code8'] ] = item
+ var t = this.template.replace(/{{image}}/, sdk.image(item['DefaultCode10'], '11_f'))
+ .replace(/{{code8}}/, item['Code8'])
+ this.$content.append(t)
},
pick: function(e){
var code = $(e.currentTarget).data("code")
var data = this.items[code]
- app.product.load(data)
+ app.product.load(code, data)
+ },
+
+ collectionName: "STONE ISLAND",
+ setCollectionName: function(name){
+ this.collectionName = name
+ this.$title.html(this.collectionName)
+ },
+
+ firstTouch: { x: 0, y: 0, id: "" },
+ lastTouch: { x: 0, y: 0, id: "" },
+ touchstart: function(e){
+ var p = e.originalEvent.touches ? e.originalEvent.touches[0] : e.originalEvent
+ this.firstTouch.x = this.lastTouch.x = p.pageX
+ this.firstTouch.y = this.lastTouch.y = p.pageY
+ this.firstTouch.id = e.currentTarget.dataset.id
+ },
+ touchmove: function(e){
+ var p = e.originalEvent.touches ? e.originalEvent.touches[0] : e.originalEvent
+ this.lastTouch.x = p.pageX
+ this.lastTouch.y = p.pageY
+ this.lastTouch.id = e.currentTarget.dataset.id
+ },
+ touchend: function(e){
+ var first = app.collection.firstTouch
+ var last = app.collection.lastTouch
+ var distance = Math.sqrt( Math.pow(first.x - last.x, 2) + Math.pow(first.y - last.y, 2) )
+ if (distance < 20) {
+ this.pick(e)
+ }
},
})
diff --git a/StoneIsland/platforms/ios/www/js/lib/products/GalleryView.js b/StoneIsland/platforms/ios/www/js/lib/products/GalleryView.js
index 2eabe2a6..ea4637eb 100644
--- a/StoneIsland/platforms/ios/www/js/lib/products/GalleryView.js
+++ b/StoneIsland/platforms/ios/www/js/lib/products/GalleryView.js
@@ -1,22 +1,54 @@
var GalleryView = View.extend({
el: "#gallery",
+ template: $("#gallery .template").html(),
events: {
"click .left": "prev",
"click .right": "next",
- "touchstart .gallery": "touchstart",
- "touchmove .gallery": "touchmove",
- "touchend .gallery": "touchend",
+// "touchstart .gallery": "touchstart",
+// "touchmove .gallery": "touchmove",
+// "touchend .gallery": "touchend",
},
initialize: function(){
- this.$prev = this.$(".prev")
- this.$next = this.$(".next")
- this.$slider = this.$(".slider")
+ this.$(".template").remove()
},
- populate: function(){
+ reset: function(){
+ this.gallery && this.gallery.destroy()
+ this.$el.empty()
+ },
+
+ populate: function(code, image_ids){
+ var valid_styles = {}
+ image_ids.forEach(function(id){
+ if (id.indexOf("_") == -1) return
+ var partz = id.split("_")
+ var size = parseInt(partz[0]), style = partz[1]
+ if (size > 13) return;
+ if (! valid_styles[style] || valid_styles[style] < size) {
+ valid_styles[style] = size
+ }
+ })
+ Object.keys(valid_styles).forEach(function(style){
+ var id = valid_styles[style] + "_" + style
+ var t = this.template.replace(/{{image}}/, sdk.image(code, id))
+ this.$el.append(t)
+ }.bind(this))
+
+ this.gallery = new Flickity( "#gallery", {
+ selector: '.item',
+ cellAlign: 'center',
+ autoPlay: false,
+ freeScroll: false,
+ wrapAround: true,
+ imagesLoaded: true,
+ prevNextButtons: false,
+ pageDots: false,
+ contain: true,
+ draggable: true,
+ })
},
prev: function(){
diff --git a/StoneIsland/platforms/ios/www/js/lib/products/ProductView.js b/StoneIsland/platforms/ios/www/js/lib/products/ProductView.js
index 76527c8b..c99ff0ab 100644
--- a/StoneIsland/platforms/ios/www/js/lib/products/ProductView.js
+++ b/StoneIsland/platforms/ios/www/js/lib/products/ProductView.js
@@ -1,14 +1,5 @@
-var SIZE_LOOKUP = {
- "XS": "X-SMALL",
- "S": "SMALL",
- "M": "MEDIUM",
- "L": "LARGE",
- "XL": "X-LARGE",
- "XXL": "XX-LARGE",
- "XXXL": "XXX-LARGE",
-};
-var ProductView = View.extend({
+var ProductView = ScrollableView.extend({
el: "#product",
@@ -20,6 +11,7 @@ var ProductView = View.extend({
initialize: function(){
this.gallery = new GalleryView ()
+ this.scroller = new IScroll('#product', app.iscroll_options)
this.$num = this.$(".num")
this.$title = this.$(".title")
@@ -31,54 +23,170 @@ var ProductView = View.extend({
},
show: function(){
+ app.footer.show("ADD TO CART", "BUY NOW")
document.body.className = "product"
},
hide: function(){
},
item: null,
+ details: null,
size: null,
color: null,
code: null,
+
+ sizes: null,
+ colors: null,
+
+ cache: {},
- load: function(data){
+ find: function(code, cb){
+ data = app.collection.items[code]
+ if (code in this.cache) {
+ return cb(data, this.cache[code])
+ }
+ sdk.product.item({
+ code: code
+ }).done(function(details){
+ this.cache[code] = details
+ cb(data, details)
+ }.bind(this))
+ },
+
+ load: function(code, data){
+ this.gallery.reset()
+ this.show()
+ if (app.view && app.view.hide) {
+ app.view.hide()
+ }
+ app.view = this
+ app.header.set_back(true)
+
+ if (! app.collection.loaded) {
+ this.el.className = "loading"
+ app.collection.afterFetchCallback = this.load.bind(this, code, data)
+ app.collection.fetch()
+ return
+ }
+ else {
+ app.collection.afterFetchCallback = null
+ }
+ window.location.href = "#/store/" + code
+
+ console.log(data)
+ if (data) {
+ app.collection.items[code] = data
+ }
+
+ this.el.className = "loading"
+ this.find(code, this.populate.bind(this))
+ },
+
+ populate: function(data, details){
+ this.el.className = ""
+
+ console.log(data, details)
+
+ var descriptions = this.get_descriptions(details)
+
+ this.gallery.populate( data['Code8'], details['Item']['ImageTypes'] )
+
var name_partz = data['ModelNames'].split(' ')
var num = name_partz.shift()
var title = name_partz.join(' ')
- var type = data['MicroCategory'].toUpperCase()
+ var type = title_case( data['MicroCategory'] )
var price = "$" + data['DiscountedPrice'] + ".00"
- var size = data['Sizes'][0]
- var size_label = SIZE_LOOKUP[size]
- var color = data['Colors'][0]
- var color_label = color['Text']
- var body = ""
-
+ var body = descriptions['EditorialDescription'].replace(/<br>/g, "<br><br>")
+
+ var default_color_id = this.populate_selectors(data, details)
+
+ var color = this.colors[default_color_id]
+ var color_label = color.label
+ var sizes = this.find_sizes_for_color(default_color_id)
+ var size = sizes[0]
+ var size_label = this.sizes[size].label
+
+ // console.log(color, color_label, size, size_label)
+
this.item = data
+ this.details = details['Item']
+ this.code = data['DefaultCode10']
+
this.color = color
this.size = size
- this.code = data['DefaultCode10']
this.$num.html(num)
this.$title.html(title)
this.$type.html(type)
this.$price.html(price)
- this.$size.html(size_label)
- this.$color.html(color)
this.$body.html(body)
- // TODO: fetch product from item API, get other Code10s so you can populate the gallery
+ this.$size.html(size_label)
+ if (color_label) {
+ this.$color.show().html(color_label)
+ }
+ else {
+ this.$color.hide()
+ }
+
+ this.deferScrollToTop()
},
- select_size: function(){
- if (this.item['Sizes'].length == 0) { return }
- var mapped_sizes = this.item['Sizes'].map(function(size){
- return {
- id: size['Id'],
- label: SIZE_LOOKUP[ size['Text'] ],
- value: size,
+ get_descriptions: function (details){
+ var descriptions = {}
+ details['Item']['Descriptions'].forEach(function(pair){
+ descriptions[pair.Key] = pair.Value
+ })
+ return descriptions
+ },
+ find_sizes_for_color: function(color_id){
+ return Object.keys( this.colors[color_id].sizes ).sort(function(a,b){
+ var ao = SIZE_ORDER[ a.label ], bo = SIZE_ORDER[ b.label ]
+ return ao<bo?-1:ao==bo?0:1
+ })
+ },
+ find_colors_for_size: function(size_id){
+ return Object.keys( this.sizes[size_id].colors )
+ },
+
+ populate_selectors: function(data, details){
+ var sizes = {}, colors = {}, size_lookup = {}, default_color
+ details['Item']['ModelColors'].forEach(function(color, index){
+ if (! default_color || color['Code10'] == data['DefaultCode10']) {
+ default_color = color['ColorId']
+ }
+ colors[ color['ColorId'] ] = {
+ id: color['Code10'],
+ code: color['Code10'],
+ label: color['ColorDescription'],
+ sizes: {},
}
})
- app.selector.select(mapped_sizes, function(size){
+ details['Item']['ModelSizes'].forEach(function(size){
+ var label = SIZE_LOOKUP[ size['Default']['Text'] ]
+ size_lookup[ label ] = size['SizeId']
+ sizes[ size['SizeId'] ] = {
+ id: label,
+ label: label,
+ colors: {},
+ }
+ })
+ details['Item']['ModelColorSize'].forEach(function(cs){
+ colors[ cs['IdColor'] ].sizes[ cs['IdSize'] ] = true
+ sizes[ cs['IdSize'] ].colors[ cs['IdColor'] ] = true
+ })
+
+ this.sizes = sizes
+ this.colors = colors
+ return default_color
+ },
+
+ select_size: function(){
+ if (this.item['Sizes'].length == 0) { return }
+ var sizes = Object.keys(this.sizes).map(function(key){
+ return this.sizes[key]
+ }.bind(this))
+ app.selector.select(sizes, function(size){
this.size = size.value
this.$size.html(size.label)
}.bind(this))
@@ -86,27 +194,79 @@ var ProductView = View.extend({
select_color: function(){
if (this.item['Colors'].length == 0) { return }
- var mapped_colors = this.item['Colors'].map(function(color){
- return {
- id: color['Id'],
- label: color['Text'],
- value: color,
- }
- })
- app.selector.select(mapped_colors, function(color){
- this.color = color.value
+ var colors = Object.keys(this.colors).map(function(key){
+ return this.colors[key]
+ }.bind(this))
+ app.selector.select(colors, function(color){
+ this.code = color.code
this.$color.html(color.label)
}.bind(this))
},
+
+ // ADD TO CART
+ save: function(){
+ auth.deferred_product = { Size: this.size, Code10: this.code }
+ if ( ! auth.logged_in() ) {
+ app.router.go("account/login")
+ app.last_view = app.cart
+ }
+ else if ( ! auth.has_cart() ) {
+ auth.create_cart(function(){
+ auth.add_deferred_product_to_cart(function(){
+ app.router.go("cart")
+ })
+ })
+ }
+ else {
+ auth.add_deferred_product_to_cart(function(){
+ app.router.go("cart")
+ })
+ }
+ },
+
+ // BUY NOW
+ cancel: function(){
+ auth.deferred_product = { Size: this.size, Code10: this.code }
+ if ( ! auth.logged_in() ) {
+ app.router.go("account/login")
+ app.last_view = app.cart
+ }
+ else if ( ! auth.has_cart() ) {
+ auth.create_cart(function(){
+ auth.add_deferred_product_to_cart(function(){
+ app.router.go("cart")
+ })
+ })
+ }
+ else {
+ auth.add_deferred_product_to_cart(function(){
+ app.router.go("cart")
+ })
+ }
+ },
+
+ back: function(){
+ app.router.go('store')
+ },
share: function(){
},
})
+var SIZE_LOOKUP = {
+ "XS": "X-SMALL",
+ "S": "SMALL",
+ "M": "MEDIUM",
+ "L": "LARGE",
+ "XL": "X-LARGE",
+ "XXL": "XX-LARGE",
+ "3XL": "3X-LARGE",
+}
+
+var SIZE_ORDER = "XS S M L XL XXL 3XL".split(" ")
/*
-
{
"Code8": "41504876",
"BrandName": "STONE ISLAND",
@@ -191,4 +351,28 @@ var ProductView = View.extend({
"MicroCategoryId": 1319
},
+DESCRIPTIONS:
+
+Age: "Adult"
+Appliqué: "Logo detail"
+ColoreFoto_ID: "3140"
+Composition: "100% Cotton"
+CustomsInvoiceDescr: "Woven"
+Design: "Solid color"
+EditorialDescription: "20081 DATA DRIP PIN<br>Short sleeve T-Shirt in cotton jersey. Garment dyed.<br>Stone Island Compass logo print on the front, made up of a series of numbers."
+ItemDescription: "Logo detail<br>Jersey<br>Round collar<br>Solid color<br>"
+KeywordDescription: "Logo detail Jersey Round collar Solid color Jersey Woven not made of fur "
+Kind of fabric: "Woven"
+MFC: "631520081CC-6315-81V0060"
+MacroCategory: "POLO SHIRTS & T-SHIRTS"
+MadeIn: "Made In Turkmenistan"
+MadeInIsoCode: "TN"
+MainMaterial: "Cotton"
+Material Description: "Jersey"
+MicroCategory: "Short sleeve t-shirt"
+MicroCategoryPlural: "Short sleeve t-shirts"
+ModelFabric: "631520081CC-6315-81"
+ModelNames: "20081 DATA DRIP PIN"
+Neckline: "Claudine or round collar"
+
*/ \ No newline at end of file
diff --git a/StoneIsland/platforms/ios/www/js/lib/products/Selector.js b/StoneIsland/platforms/ios/www/js/lib/products/Selector.js
index 1580624b..76c498ec 100644
--- a/StoneIsland/platforms/ios/www/js/lib/products/Selector.js
+++ b/StoneIsland/platforms/ios/www/js/lib/products/Selector.js
@@ -5,7 +5,7 @@ var Selector = View.extend({
events: {
"click .close": "hide",
- "click span": "pick",
+ "click .options div": "pick",
},
initialize: function(){
@@ -15,26 +15,32 @@ var Selector = View.extend({
lookup: null,
callback: null,
select: function(options, callback){
- var lookup = this.lookup = {}
+ this.lookup = {}
+ this.callback = callback || function(item){ console.log(item) }
this.$options.empty()
options.forEach(function(opt){
- lookup[opt.id] = opt
+ this.lookup[String(opt.id)] = opt
var t = this.template.replace(/{{id}}/, opt.id)
.replace(/{{label}}/, opt.label)
this.$options.append(t)
- })
+ }.bind(this))
this.$el.show()
+ app.curtain.show("white")
+ this.visible = true
},
hide: function(){
this.lookup = this.callback = null
this.$el.hide()
+ app.curtain.hide()
+ this.visible = false
},
pick: function(e){
var $option = $(e.currentTarget)
- var id = $option.data("id")
+ var id = String($option.data("id"))
var selection = this.lookup[id]
+
this.callback( selection )
this.hide()
},
diff --git a/StoneIsland/platforms/ios/www/js/lib/products/filters/CategoryFilter.js b/StoneIsland/platforms/ios/www/js/lib/products/filters/CategoryFilter.js
new file mode 100644
index 00000000..4e6baf62
--- /dev/null
+++ b/StoneIsland/platforms/ios/www/js/lib/products/filters/CategoryFilter.js
@@ -0,0 +1,40 @@
+var CategoryFilter = View.extend({
+
+ initialize: function(opt){
+ this.parent = opt.parent
+ },
+
+ filter: function(){
+ var cats = this.parent.data.SearchResponseFull.Refinements.Filters.Categories.map(function(cat){
+ return {
+ id: cat.Id,
+ label: cat.Value
+ }
+ })
+ if (this.last_choice) {
+ cats.push({
+ id: "__remove_filter",
+ label: "REMOVE FILTER",
+ })
+ }
+ app.selector.select(cats, this.pick.bind(this))
+ },
+
+ last_choice: null,
+
+ pick: function(choice){
+ this.parent.$content.empty()
+ if (choice.id == "__remove_filter") {
+ this.last_choice = null
+ this.parent.data.SearchResponseFull.Results.Items.forEach(this.parent.append.bind(this.parent))
+ }
+ else {
+ this.last_choice = choice
+ this.parent.data.SearchResponseFull.Results.Items.filter(function(item){
+ return item.MacroCategory == choice.label
+ }).forEach(this.parent.append.bind(this.parent))
+ }
+ this.parent.deferScrollToTop()
+ },
+
+})
diff --git a/StoneIsland/platforms/ios/www/js/sdk/_sdk.js b/StoneIsland/platforms/ios/www/js/sdk/_sdk.js
index 31fd96ca..27773310 100644
--- a/StoneIsland/platforms/ios/www/js/sdk/_sdk.js
+++ b/StoneIsland/platforms/ios/www/js/sdk/_sdk.js
@@ -1,11 +1,13 @@
var sdk = (function(){
var sdk = {}
-
+
+ sdk.env = "development"
+
var endpoint = "https://secure.api.yoox.biz/"
// var endpoint = "http://api.yoox.biz/"
sdk.init = function(opt){
- switch (opt.env) {
+ switch (sdk.env = opt.env || "development") {
case 'test':
endpoint = "http://lvh.me:9090/"
break
@@ -23,8 +25,8 @@ var sdk = (function(){
return endpoint + api + "/STONEISLAND_US/" + path
}
- sdk.image = function(code){
- return "http://cdn.yoox.biz/" + code.substr(0,2) + "/" + code + "_11_f.jpg"
+ sdk.image = function(code, size){
+ return "http://cdn.yoox.biz/" + code.substr(0,2) + "/" + code.substr(0,8) + "_" + size + ".jpg"
}
$.ajaxSetup({
diff --git a/StoneIsland/platforms/ios/www/js/sdk/account.js b/StoneIsland/platforms/ios/www/js/sdk/account.js
index 3dfe2cfe..fe5f03cd 100644
--- a/StoneIsland/platforms/ios/www/js/sdk/account.js
+++ b/StoneIsland/platforms/ios/www/js/sdk/account.js
@@ -5,14 +5,14 @@ sdk.account = (function(){
// https://gist.github.com/fanfare/d18498e7fa25acbd4486
var account = {}
account.signup = function(opt){
- $.ajax({
+ return $.ajax({
method: "POST",
url: sdk.path("Account.API/1.5", "users.json"),
headers: {
"x-yoox-appname": auth.appname,
"x-yoox-api-key": auth.apikey,
},
- data: opt.data,
+ data: JSON.stringify( opt.data ),
success: function(data){
user_id = data['UserAccount']['UserId']
access_token = data['UserAccount']['AccessToken']
@@ -26,21 +26,20 @@ sdk.account = (function(){
}
account.login = function(opt){
- $.ajax({
+ return $.ajax({
method: "POST",
url: sdk.path("Account.API/1.5", "authfull.json"),
headers: {
"x-yoox-appname": auth.appname,
"x-yoox-account-token": auth.access_token,
},
- data: opt.data,
+ data: JSON.stringify( opt.data ),
success: function(data){
- // console.log(data)
- // auth.user_id = data['UserFull']['UserId']
- // auth.access_token = data['UserFull']['AccessToken']
+ auth.user = data['UserFull']
+ user_id = data['UserFull']['idUser']
+ access_token = data['UserFull']['AccessToken']
- // why bother?
- // auth.set_user(user_id, access_token, name)
+ auth.set_user(user_id, access_token)
opt.success(data)
},
@@ -48,6 +47,55 @@ sdk.account = (function(){
})
}
+ account.checkin = function(opt){
+ return $.ajax({
+ method: "GET",
+ url: sdk.path("Account.API/1.5", "users/" + auth.user_id + ".json"),
+ headers: {
+ "x-yoox-appname": auth.appname,
+ "x-yoox-account-token": auth.access_token,
+ },
+ data: "{}",
+ success: function(data){
+ auth.user = data.User
+ opt.success(data)
+ },
+ error: opt.error,
+ })
+ }
+
+ account.update = function(opt){
+ return $.ajax({
+ method: "PUT",
+ url: sdk.path("Account.API/1.5", "users/" + auth.user_id + ".json"),
+ headers: {
+ "x-yoox-appname": auth.appname,
+ "x-yoox-account-token": auth.access_token,
+ },
+ data: JSON.stringify( opt.data ),
+ success: function(data){
+ opt.success(data)
+ },
+ error: opt.error,
+ })
+ }
+
+ account.update_mail_and_password = function(opt){
+ return $.ajax({
+ method: "PUT",
+ url: sdk.path("Account.API/1.5", "auth/" + auth.user_id + ".json"),
+ headers: {
+ "x-yoox-appname": auth.appname,
+ "x-yoox-account-token": auth.access_token,
+ },
+ data: JSON.stringify( opt.data ),
+ success: function(data){
+ opt.success(data)
+ },
+ error: opt.error,
+ })
+ }
+
return account
})()
diff --git a/StoneIsland/platforms/ios/www/js/sdk/address.js b/StoneIsland/platforms/ios/www/js/sdk/address.js
index 144589d0..f4e36376 100644
--- a/StoneIsland/platforms/ios/www/js/sdk/address.js
+++ b/StoneIsland/platforms/ios/www/js/sdk/address.js
@@ -2,14 +2,14 @@ sdk.address = (function(){
var address = {}
address.add = function(opt){
- $.ajax({
+ return $.ajax({
method: "POST",
url: sdk.path("Account.API/1.5", "users/" + auth.user_id + "/addressBook/item.json"),
headers: {
"x-yoox-appname": auth.appname,
"x-yoox-account-token": auth.access_token,
},
- data: opt.data,
+ data: JSON.stringify( opt.data ),
success: function(data){
// console.log(data)
opt.success(data)
@@ -19,7 +19,7 @@ sdk.address = (function(){
}
address.list = function(opt){
- $.ajax({
+ return $.ajax({
method: "GET",
url: sdk.path("Account.API/1.5", "users/" + auth.user_id + "/addressBook.json"),
headers: {
diff --git a/StoneIsland/platforms/ios/www/js/sdk/auth.js b/StoneIsland/platforms/ios/www/js/sdk/auth.js
index cea0054c..8a72dd46 100644
--- a/StoneIsland/platforms/ios/www/js/sdk/auth.js
+++ b/StoneIsland/platforms/ios/www/js/sdk/auth.js
@@ -7,7 +7,7 @@
},
*/
-var auth = (function(){
+var auth = sdk.auth = (function(){
var auth = {}
auth.appname = is_iphone ? "native-iphone-stoneisland/1.0.0" : "native-android-stoneisland/1.0.0"
@@ -16,18 +16,110 @@ var auth = (function(){
auth.access_token = ""
auth.user_id = -1
+
+ auth.next_view = null
+ auth.deferred_product = null
// ios: integrate keychain api
// android: cordova.file.externalRootDirectory api
- auth.set_user = function(user_id, access_token){
- // persist user data
- auth.user_id = user_id
+ auth.init = function(fn){
+ console.log("AUTH INIT")
+ auth.get_user(function(){
+ if (auth.logged_in()) {
+ sdk.account.checkin({
+ success: function(data){
+ fn && fn( auth.logged_in() )
+ }
+ })
+ auth.get_cart()
+ }
+ else {
+ fn && fn( auth.logged_in() )
+ }
+ })
+ }
+
+ auth.set_user = function(user_id, access_token, cb){
auth.access_token = access_token
+ auth.user_id = user_id
+
+ localStorage.setItem("yoox.access_token", access_token)
+ localStorage.setItem("yoox.user_id", user_id)
+ cb && cb()
}
auth.get_user = function(cb){
- // fetch user data
+ auth.access_token = localStorage.getItem("yoox.access_token") || ""
+ auth.user_id = localStorage.getItem("yoox.user_id") || -1
+ cb && cb()
+ }
+ auth.clear_user = function(cb){
+ auth.access_token = ""
+ auth.user_id = -1
+ localStorage.removeItem("yoox.access_token")
+ localStorage.removeItem("yoox.user_id")
+ cb && cb()
+ }
+
+ auth.set_cart = function(cart_id, cart_token, cb){
+ localStorage.setItem("yoox.cart_token", cart_token)
+ localStorage.setItem("yoox.cart_id", cart_id)
+ cb && cb()
+ }
+ auth.get_cart = function(cb){
+ sdk.cart.token = localStorage.getItem("yoox.cart_token") || ""
+ sdk.cart.id = localStorage.getItem("yoox.cart_id") || -1
+ cb && cb()
+ }
+ auth.clear_cart = function(cb){
+ sdk.cart.token = ""
+ sdk.cart.id = -1
+ localStorage.removeItem("yoox.cart_token")
+ localStorage.removeItem("yoox.cart_id")
+ cb && cb()
+ }
+ auth.create_cart = function(cb){
+ if (auth.has_cart()) { return cb() }
+ sdk.cart.initialize({
+ success: function(data){
+ sdk.cart.set_user({
+ success: function(){
+ auth.set_cart(sdk.cart.id, sdk.cart.token, function(){
+ cb && cb()
+ })
+ }
+ })
+ }
+ })
+ }
+ auth.add_deferred_product_to_cart = function(cb){
+ // auth.deferred_product
+ if (! auth.deferred_product) {
+ cb && cb()
+ return
+ }
+ sdk.cart.add_item({
+ data: auth.deferred_product,
+ success: function(){
+ console.log("ADDED")
+ cb && cb()
+ }
+ })
+ auth.deferred_product = null
+ app.header.increment_cart_count()
+ }
+
+ auth.log_out = function(){
+ auth.clear_user()
+ auth.clear_cart()
+ auth.view_logged_out()
+ }
+ auth.logged_in = function(){
+ return (auth.user_id !== -1) && (auth.user_id !== "undefined")
+ }
+ auth.has_cart = function(){
+ return (sdk.cart.id !== -1) && (sdk.cart.id !== "undefined")
}
return auth
-})()
+})() \ No newline at end of file
diff --git a/StoneIsland/platforms/ios/www/js/sdk/cart.js b/StoneIsland/platforms/ios/www/js/sdk/cart.js
index 9f9d81f1..bbd03299 100644
--- a/StoneIsland/platforms/ios/www/js/sdk/cart.js
+++ b/StoneIsland/platforms/ios/www/js/sdk/cart.js
@@ -6,18 +6,19 @@ sdk.cart = (function(){
// https://gist.github.com/fanfare/9a50c524aea417d0bf3e
cart.initialize = function(opt){
- $.ajax({
+ return $.ajax({
method: "POST",
url: sdk.path("Cart.API/1.6", "carts.json"),
headers: {
"x-yoox-appname": auth.appname,
"x-yoox-device": auth.device,
},
+ data: "{}",
// data: opt.data,
success: function(data){
- console.log(data)
cart.id = data["CartSession"]["CartId"]
cart.token = data["CartSession"]["CartToken"]
+ auth.set_cart( cart.id, cart.token )
opt.success(data)
},
error: opt.error,
@@ -25,19 +26,18 @@ sdk.cart = (function(){
}
cart.set_user = function(opt){
- $.ajax({
+ return $.ajax({
method: "PUT",
- url: sdk.path("Cart.API/1.6", "user.json"),
+ url: sdk.path("Cart.API/1.6", "carts/" + cart.id + "/user.json"),
headers: {
"x-yoox-appname": auth.appname,
"x-yoox-cart-token": cart.token,
},
- data: {
+ data: JSON.stringify({
"UserId": auth.user_id,
"UserToken": auth.access_token,
- },
+ }),
success: function(data){
- console.log(data)
opt.success(data)
},
error: opt.error,
@@ -46,16 +46,16 @@ sdk.cart = (function(){
// Code10, Size, Section
cart.add_item = function(opt){
- $.ajax({
+ return $.ajax({
method: "POST",
url: sdk.path("Cart.API/1.6", "carts/" + cart.id + "/items.json"),
headers: {
"x-yoox-appname": auth.appname,
"x-yoox-cart-token": cart.token,
},
- data: opt.data,
+ data: JSON.stringify( opt.data ),
success: function(data){
- console.log(data)
+ // console.log(data)
opt.success(data)
},
error: opt.error,
@@ -63,17 +63,18 @@ sdk.cart = (function(){
}
cart.delete_item = function(opt){
- $.ajax({
+ return $.ajax({
method: "DELETE",
url: sdk.path("Cart.API/1.6", "carts/" + cart.id +
- "/items/" + opt.code10 +
- "/" + opt.size + ".json"),
+ "/items/" + opt.data.Code10 +
+ "/" + opt.data.Size + ".json"),
headers: {
"x-yoox-appname": auth.appname,
"x-yoox-cart-token": cart.token,
},
+ data: "{}",
success: function(data){
- console.log(data)
+ // console.log(data)
opt.success(data)
},
error: opt.error,
@@ -81,21 +82,24 @@ sdk.cart = (function(){
}
cart.get_status = function(opt){
- $.ajax({
+ if (! cart.id) {
+ return opt.error({ error: "no cart" })
+ }
+ return $.ajax({
method: "GET",
- url: sdk.path("Cart.API/1.6", "carts/" + cart.id),
+ url: sdk.path("Cart.API/1.6", "carts/" + cart.id + ".json"),
headers: {
"x-yoox-appname": auth.appname,
"x-yoox-cart-token": cart.token,
"x-yoox-device": auth.device,
},
- data: {
- "UserId": auth.user_id,
- "UserToken": auth.access_token,
- },
success: function(data){
- console.log(data)
- opt.success(data)
+ if (data['Error']) {
+ opt.error && opt.error(data)
+ }
+ else {
+ opt.success(data)
+ }
},
error: opt.error,
})
@@ -103,16 +107,16 @@ sdk.cart = (function(){
// NOTE: data might be wrapped in a Receiver object
cart.set_shipping_address = function(opt){
- $.ajax({
+ return $.ajax({
method: "PUT",
- url: sdk.path("Cart.API/1.6", "receiver.json"),
+ url: sdk.path("Cart.API/1.6", "carts/" + cart.id + "/receiver.json"),
headers: {
"x-yoox-appname": auth.appname,
"x-yoox-cart-token": cart.token,
},
- data: opt.data,
+ data: JSON.stringify(opt.data),
success: function(data){
- console.log(data)
+ // console.log(data)
opt.success(data)
},
error: opt.error,
@@ -121,16 +125,16 @@ sdk.cart = (function(){
// NB: Payment type may simply be 1 (credit card)
cart.set_payment_type = function(opt){
- $.ajax({
+ return $.ajax({
method: "PUT",
url: sdk.path("Cart.API/1.6", "carts/" + cart.id + "/paymentType.json"),
headers: {
"x-yoox-appname": auth.appname,
"x-yoox-cart-token": cart.token,
},
- data: opt.data,
+ data: JSON.stringify( opt.data ),
success: function(data){
- console.log(data)
+ // console.log(data)
opt.success(data)
},
error: opt.error,
@@ -139,16 +143,16 @@ sdk.cart = (function(){
// use with full CC data if not storing it in wallet
cart.set_credit_card = function(opt){
- $.ajax({
+ return $.ajax({
method: "PUT",
url: sdk.path("Cart.API/1.6", "carts/" + cart.id + "/creditCard.json"),
headers: {
"x-yoox-appname": auth.appname,
"x-yoox-cart-token": cart.token,
},
- data: opt.data,
+ data: JSON.stringify( opt.data ),
success: function(data){
- console.log(data)
+ // console.log(data)
opt.success(data)
},
error: opt.error,
@@ -159,22 +163,22 @@ sdk.cart = (function(){
// NB: if "verification number" is 1, use CVV/CID/CVC security code
// if "verification number" is 2, use "Issue Number"
cart.use_stored_credit_card = function(opt){
- $.ajax({
+ return $.ajax({
method: "PUT",
url: sdk.path("Cart.API/1.6", "carts/" + cart.id + "/userCreditCard.json"),
headers: {
"x-yoox-appname": auth.appname,
"x-yoox-cart-token": cart.token,
},
- data: { // NB may be wrapped in UserCreditCard object
+ data: JSON.stringify({ // NB may be wrapped in UserCreditCard object
"Guid": opt.guid,
"UserId": auth.user_id,
"AccessToken": auth.access_token,
"Cvv": opt.cvv,
"Issue": opt.issue,
- },
+ }),
success: function(data){
- console.log(data)
+ // console.log(data)
opt.success(data)
},
error: opt.error,
@@ -182,7 +186,7 @@ sdk.cart = (function(){
}
cart.finalize = function(opt){
- $.ajax({
+ return $.ajax({
method: "PUT",
url: sdk.path("Cart.API/1.6", "carts/" + cart.id + "/secureFinalizer.json"),
headers: {
@@ -190,7 +194,7 @@ sdk.cart = (function(){
"x-yoox-cart-token": cart.token,
"x-yoox-device": auth.device,
},
- data: opt.data,
+ data: JSON.stringify( opt.data ),
success: function(data){
console.log(data)
// order number is:
diff --git a/StoneIsland/platforms/ios/www/js/sdk/payment.js b/StoneIsland/platforms/ios/www/js/sdk/payment.js
index 048cde4b..d0951017 100644
--- a/StoneIsland/platforms/ios/www/js/sdk/payment.js
+++ b/StoneIsland/platforms/ios/www/js/sdk/payment.js
@@ -1,26 +1,28 @@
sdk.payment = (function(){
var payment = {}
- payment.list_credit_cards = function(opt){
- $.ajax({
- method: "GET",
+ payment.add_credit_card = function(opt){
+ return $.ajax({
+ method: "POST",
url: sdk.path("Account.API/1.5", "users/" + auth.user_id + "/cards.json"),
headers: {
"x-yoox-appname": auth.appname,
"x-yoox-account-token": auth.access_token,
},
- data: opt.data,
+ data: JSON.stringify( opt.data ),
success: function(data){
- console.log(data)
+ // console.log(data)
opt.success(data)
},
error: opt.error,
})
}
-
- payment.add_credit_card = function(opt){
- $.ajax({
- method: "POST",
+
+ // LISTING A CREDIT CARD ONCE A CARD HAS BEEN ADDED PRODUCES ERROR
+
+ payment.list_credit_cards = function(opt){
+ return $.ajax({
+ method: "GET",
url: sdk.path("Account.API/1.5", "users/" + auth.user_id + "/cards.json"),
headers: {
"x-yoox-appname": auth.appname,
@@ -28,6 +30,7 @@ sdk.payment = (function(){
},
data: opt.data,
success: function(data){
+ console.log("listing credit cards")
console.log(data)
opt.success(data)
},
@@ -36,15 +39,16 @@ sdk.payment = (function(){
}
payment.delete_credit_card = function(opt){
- $.ajax({
+ return $.ajax({
method: "DELETE",
url: sdk.path("Account.API/1.5", "users/" + auth.user_id + "/cards/" + opt.guid + ".json"),
headers: {
"x-yoox-appname": auth.appname,
"x-yoox-account-token": auth.access_token,
},
+ data: "{}",
success: function(data){
- console.log(data)
+ // console.log(data)
opt.success(data)
},
error: opt.error,
@@ -52,7 +56,7 @@ sdk.payment = (function(){
}
payment.get_payment_types = function(opt){
- $.ajax({
+ return $.ajax({
method: "GET",
url: sdk.path("Cart.API/1.6", "availablePaymentTypes.json"),
headers: {
@@ -61,7 +65,7 @@ sdk.payment = (function(){
},
data: opt.data,
success: function(data){
- console.log(data)
+ // console.log(data)
opt.success(data)
},
error: opt.error,
diff --git a/StoneIsland/platforms/ios/www/js/sdk/product.js b/StoneIsland/platforms/ios/www/js/sdk/product.js
index a2ba30a1..55f1940a 100644
--- a/StoneIsland/platforms/ios/www/js/sdk/product.js
+++ b/StoneIsland/platforms/ios/www/js/sdk/product.js
@@ -1,11 +1,13 @@
sdk.product = (function(){
var product = {}
+
+ var default_gallery = 31617
product.collection = function(opt){
- $.ajax({
+ return $.ajax({
method: "GET",
url: sdk.path("Search.API/1.2", "search.json"),
- data: { format: "full", gallery: opt.gallery_id },
+ data: { format: "full", gallery: opt.gallery_id || default_gallery, productsPerPage: 100 },
success: opt.success,
error: opt.error,
})
@@ -13,7 +15,7 @@ sdk.product = (function(){
// https://gist.github.com/fanfare/2d25d1b36944188948ff
product.item = function(opt){
- $.ajax({
+ return $.ajax({
method: "GET",
url: sdk.path("Item.API/1.0", "item/" + opt.code + ".json"),
success: opt.success,
@@ -21,5 +23,15 @@ sdk.product = (function(){
})
}
+ product.search = function(opt){
+ return $.ajax({
+ method: "GET",
+ url: sdk.path("Search.API/1.2", "search.json"),
+ data: { format: "full", gallery: opt.gallery_id || default_gallery, textSearch: opt.query, productsPerPage: 100 },
+ success: opt.success,
+ error: opt.error,
+ })
+ }
+
return product
})() \ No newline at end of file
diff --git a/StoneIsland/platforms/ios/www/js/sdk/shipping.js b/StoneIsland/platforms/ios/www/js/sdk/shipping.js
index 400d3199..a4615531 100644
--- a/StoneIsland/platforms/ios/www/js/sdk/shipping.js
+++ b/StoneIsland/platforms/ios/www/js/sdk/shipping.js
@@ -1,39 +1,40 @@
-sdk.shipping = (function(){
+sdk.shipping = (function() {
var shipping = {}
+
// https://gist.github.com/fanfare/edb524128461b573d833
// BOX TYPE
shipping.get_box_types = function(opt){
- $.ajax({
+ return $.ajax({
method: "GET",
- url: sdk.path("Cart.API/1.6", "carts/" + cart.id + "/availableBoxTypes.json"),
+ url: sdk.path("Cart.API/1.6", "carts/" + sdk.cart.id + "/availableBoxTypes.json"),
headers: {
"x-yoox-appname": auth.appname,
- "x-yoox-cart-token": cart.token,
+ "x-yoox-cart-token": sdk.cart.token,
},
success: function(data){
- console.log(data)
- opt.success(data['BoxTypes']['Types'])
+ // console.log(data)
+ opt.success(data)
},
error: opt.error,
})
}
shipping.set_box_type = function(opt){
- $.ajax({
+ return $.ajax({
method: "PUT",
- url: sdk.path("Cart.API/1.6", "carts/" + cart.id + "/boxType.json"),
+ url: sdk.path("Cart.API/1.6", "carts/" + sdk.cart.id + "/boxType.json"),
headers: {
"x-yoox-appname": auth.appname,
- "x-yoox-cart-token": cart.token,
+ "x-yoox-cart-token": sdk.cart.token,
},
- data: {
+ data: JSON.stringify({
"Type": opt.type,
- },
+ }),
success: function(data){
- console.log(data)
+ // console.log(data)
opt.success(data)
},
error: opt.error,
@@ -42,36 +43,41 @@ sdk.shipping = (function(){
// DELIVERY TYPES
+
+ // The response is different than described in the API reference..
+ // https://gist.github.com/fanfare/15dfbca6a16ae6bed503
shipping.get_delivery_types = function(opt){
- $.ajax({
+ return $.ajax({
method: "GET",
- url: sdk.path("Cart.API/1.6", "carts/" + cart.id + "/availableDeliveryTypes.json"),
+ url: sdk.path("Cart.API/1.6", "carts/" + sdk.cart.id + "/availableDeliveryTypes.json"),
headers: {
"x-yoox-appname": auth.appname,
- "x-yoox-cart-token": cart.token,
+ "x-yoox-cart-token": sdk.cart.token,
},
success: function(data){
- console.log(data)
- opt.success(data['DeliveryTypes']['Types'])
+ opt.success(data)
},
error: opt.error,
})
}
shipping.set_delivery_type = function(opt){
- $.ajax({
+ return $.ajax({
method: "PUT",
- url: sdk.path("Cart.API/1.6", "carts/" + cart.id + "/availableBoxTypes.json"),
+ url: sdk.path("Cart.API/1.6", "carts/" + sdk.cart.id + "/deliveryType.json"),
headers: {
"x-yoox-appname": auth.appname,
- "x-yoox-cart-token": cart.token,
+ "x-yoox-cart-token": sdk.cart.token,
},
- data: {
+ // temporarily commented out
+ /*
+ data: JSON.stringify({
"Id": opt.id,
- },
+ }),
+ */
success: function(data){
- console.log(data)
+ //console.log(data)
opt.success(data)
},
error: opt.error,
@@ -79,4 +85,4 @@ sdk.shipping = (function(){
}
return shipping
-})() \ No newline at end of file
+})()
diff --git a/StoneIsland/platforms/ios/www/js/vendor/flickity.pkgd.js b/StoneIsland/platforms/ios/www/js/vendor/flickity.pkgd.js
new file mode 100644
index 00000000..0471fa5b
--- /dev/null
+++ b/StoneIsland/platforms/ios/www/js/vendor/flickity.pkgd.js
@@ -0,0 +1,5090 @@
+/*!
+ * Flickity PACKAGED v1.0.1
+ * Touch, responsive, flickable galleries
+ *
+ * Licensed GPLv3 for open source use
+ * or Flickity Commercial License for commercial use
+ *
+ * http://flickity.metafizzy.co
+ * Copyright 2015 Metafizzy
+ */
+
+/**
+ * Bridget makes jQuery widgets
+ * v1.1.0
+ * MIT license
+ */
+
+( function( window ) {
+
+
+
+// -------------------------- utils -------------------------- //
+
+var slice = Array.prototype.slice;
+
+function noop() {}
+
+// -------------------------- definition -------------------------- //
+
+function defineBridget( $ ) {
+
+// bail if no jQuery
+if ( !$ ) {
+ return;
+}
+
+// -------------------------- addOptionMethod -------------------------- //
+
+/**
+ * adds option method -> $().plugin('option', {...})
+ * @param {Function} PluginClass - constructor class
+ */
+function addOptionMethod( PluginClass ) {
+ // don't overwrite original option method
+ if ( PluginClass.prototype.option ) {
+ return;
+ }
+
+ // option setter
+ PluginClass.prototype.option = function( opts ) {
+ // bail out if not an object
+ if ( !$.isPlainObject( opts ) ){
+ return;
+ }
+ this.options = $.extend( true, this.options, opts );
+ };
+}
+
+// -------------------------- plugin bridge -------------------------- //
+
+// helper function for logging errors
+// $.error breaks jQuery chaining
+var logError = typeof console === 'undefined' ? noop :
+ function( message ) {
+ console.error( message );
+ };
+
+/**
+ * jQuery plugin bridge, access methods like $elem.plugin('method')
+ * @param {String} namespace - plugin name
+ * @param {Function} PluginClass - constructor class
+ */
+function bridge( namespace, PluginClass ) {
+ // add to jQuery fn namespace
+ $.fn[ namespace ] = function( options ) {
+ if ( typeof options === 'string' ) {
+ // call plugin method when first argument is a string
+ // get arguments for method
+ var args = slice.call( arguments, 1 );
+
+ for ( var i=0, len = this.length; i < len; i++ ) {
+ var elem = this[i];
+ var instance = $.data( elem, namespace );
+ if ( !instance ) {
+ logError( "cannot call methods on " + namespace + " prior to initialization; " +
+ "attempted to call '" + options + "'" );
+ continue;
+ }
+ if ( !$.isFunction( instance[options] ) || options.charAt(0) === '_' ) {
+ logError( "no such method '" + options + "' for " + namespace + " instance" );
+ continue;
+ }
+
+ // trigger method with arguments
+ var returnValue = instance[ options ].apply( instance, args );
+
+ // break look and return first value if provided
+ if ( returnValue !== undefined ) {
+ return returnValue;
+ }
+ }
+ // return this if no return value
+ return this;
+ } else {
+ return this.each( function() {
+ var instance = $.data( this, namespace );
+ if ( instance ) {
+ // apply options & init
+ instance.option( options );
+ instance._init();
+ } else {
+ // initialize new instance
+ instance = new PluginClass( this, options );
+ $.data( this, namespace, instance );
+ }
+ });
+ }
+ };
+
+}
+
+// -------------------------- bridget -------------------------- //
+
+/**
+ * converts a Prototypical class into a proper jQuery plugin
+ * the class must have a ._init method
+ * @param {String} namespace - plugin name, used in $().pluginName
+ * @param {Function} PluginClass - constructor class
+ */
+$.bridget = function( namespace, PluginClass ) {
+ addOptionMethod( PluginClass );
+ bridge( namespace, PluginClass );
+};
+
+return $.bridget;
+
+}
+
+// transport
+if ( typeof define === 'function' && define.amd ) {
+ // AMD
+ define( 'jquery-bridget/jquery.bridget',[ 'jquery' ], defineBridget );
+} else if ( typeof exports === 'object' ) {
+ defineBridget( require('jquery') );
+} else {
+ // get jquery from browser global
+ defineBridget( window.jQuery );
+}
+
+})( window );
+
+/*!
+ * classie v1.0.1
+ * class helper functions
+ * from bonzo https://github.com/ded/bonzo
+ * MIT license
+ *
+ * classie.has( elem, 'my-class' ) -> true/false
+ * classie.add( elem, 'my-new-class' )
+ * classie.remove( elem, 'my-unwanted-class' )
+ * classie.toggle( elem, 'my-class' )
+ */
+
+/*jshint browser: true, strict: true, undef: true, unused: true */
+/*global define: false, module: false */
+
+( function( window ) {
+
+
+
+// class helper functions from bonzo https://github.com/ded/bonzo
+
+function classReg( className ) {
+ return new RegExp("(^|\\s+)" + className + "(\\s+|$)");
+}
+
+// classList support for class management
+// altho to be fair, the api sucks because it won't accept multiple classes at once
+var hasClass, addClass, removeClass;
+
+if ( 'classList' in document.documentElement ) {
+ hasClass = function( elem, c ) {
+ return elem.classList.contains( c );
+ };
+ addClass = function( elem, c ) {
+ elem.classList.add( c );
+ };
+ removeClass = function( elem, c ) {
+ elem.classList.remove( c );
+ };
+}
+else {
+ hasClass = function( elem, c ) {
+ return classReg( c ).test( elem.className );
+ };
+ addClass = function( elem, c ) {
+ if ( !hasClass( elem, c ) ) {
+ elem.className = elem.className + ' ' + c;
+ }
+ };
+ removeClass = function( elem, c ) {
+ elem.className = elem.className.replace( classReg( c ), ' ' );
+ };
+}
+
+function toggleClass( elem, c ) {
+ var fn = hasClass( elem, c ) ? removeClass : addClass;
+ fn( elem, c );
+}
+
+var classie = {
+ // full names
+ hasClass: hasClass,
+ addClass: addClass,
+ removeClass: removeClass,
+ toggleClass: toggleClass,
+ // short names
+ has: hasClass,
+ add: addClass,
+ remove: removeClass,
+ toggle: toggleClass
+};
+
+// transport
+if ( typeof define === 'function' && define.amd ) {
+ // AMD
+ define( 'classie/classie',classie );
+} else if ( typeof exports === 'object' ) {
+ // CommonJS
+ module.exports = classie;
+} else {
+ // browser global
+ window.classie = classie;
+}
+
+})( window );
+
+/*!
+ * EventEmitter v4.2.11 - git.io/ee
+ * Unlicense - http://unlicense.org/
+ * Oliver Caldwell - http://oli.me.uk/
+ * @preserve
+ */
+
+;(function () {
+
+
+ /**
+ * Class for managing events.
+ * Can be extended to provide event functionality in other classes.
+ *
+ * @class EventEmitter Manages event registering and emitting.
+ */
+ function EventEmitter() {}
+
+ // Shortcuts to improve speed and size
+ var proto = EventEmitter.prototype;
+ var exports = this;
+ var originalGlobalValue = exports.EventEmitter;
+
+ /**
+ * Finds the index of the listener for the event in its storage array.
+ *
+ * @param {Function[]} listeners Array of listeners to search through.
+ * @param {Function} listener Method to look for.
+ * @return {Number} Index of the specified listener, -1 if not found
+ * @api private
+ */
+ function indexOfListener(listeners, listener) {
+ var i = listeners.length;
+ while (i--) {
+ if (listeners[i].listener === listener) {
+ return i;
+ }
+ }
+
+ return -1;
+ }
+
+ /**
+ * Alias a method while keeping the context correct, to allow for overwriting of target method.
+ *
+ * @param {String} name The name of the target method.
+ * @return {Function} The aliased method
+ * @api private
+ */
+ function alias(name) {
+ return function aliasClosure() {
+ return this[name].apply(this, arguments);
+ };
+ }
+
+ /**
+ * Returns the listener array for the specified event.
+ * Will initialise the event object and listener arrays if required.
+ * Will return an object if you use a regex search. The object contains keys for each matched event. So /ba[rz]/ might return an object containing bar and baz. But only if you have either defined them with defineEvent or added some listeners to them.
+ * Each property in the object response is an array of listener functions.
+ *
+ * @param {String|RegExp} evt Name of the event to return the listeners from.
+ * @return {Function[]|Object} All listener functions for the event.
+ */
+ proto.getListeners = function getListeners(evt) {
+ var events = this._getEvents();
+ var response;
+ var key;
+
+ // Return a concatenated array of all matching events if
+ // the selector is a regular expression.
+ if (evt instanceof RegExp) {
+ response = {};
+ for (key in events) {
+ if (events.hasOwnProperty(key) && evt.test(key)) {
+ response[key] = events[key];
+ }
+ }
+ }
+ else {
+ response = events[evt] || (events[evt] = []);
+ }
+
+ return response;
+ };
+
+ /**
+ * Takes a list of listener objects and flattens it into a list of listener functions.
+ *
+ * @param {Object[]} listeners Raw listener objects.
+ * @return {Function[]} Just the listener functions.
+ */
+ proto.flattenListeners = function flattenListeners(listeners) {
+ var flatListeners = [];
+ var i;
+
+ for (i = 0; i < listeners.length; i += 1) {
+ flatListeners.push(listeners[i].listener);
+ }
+
+ return flatListeners;
+ };
+
+ /**
+ * Fetches the requested listeners via getListeners but will always return the results inside an object. This is mainly for internal use but others may find it useful.
+ *
+ * @param {String|RegExp} evt Name of the event to return the listeners from.
+ * @return {Object} All listener functions for an event in an object.
+ */
+ proto.getListenersAsObject = function getListenersAsObject(evt) {
+ var listeners = this.getListeners(evt);
+ var response;
+
+ if (listeners instanceof Array) {
+ response = {};
+ response[evt] = listeners;
+ }
+
+ return response || listeners;
+ };
+
+ /**
+ * Adds a listener function to the specified event.
+ * The listener will not be added if it is a duplicate.
+ * If the listener returns true then it will be removed after it is called.
+ * If you pass a regular expression as the event name then the listener will be added to all events that match it.
+ *
+ * @param {String|RegExp} evt Name of the event to attach the listener to.
+ * @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.
+ * @return {Object} Current instance of EventEmitter for chaining.
+ */
+ proto.addListener = function addListener(evt, listener) {
+ var listeners = this.getListenersAsObject(evt);
+ var listenerIsWrapped = typeof listener === 'object';
+ var key;
+
+ for (key in listeners) {
+ if (listeners.hasOwnProperty(key) && indexOfListener(listeners[key], listener) === -1) {
+ listeners[key].push(listenerIsWrapped ? listener : {
+ listener: listener,
+ once: false
+ });
+ }
+ }
+
+ return this;
+ };
+
+ /**
+ * Alias of addListener
+ */
+ proto.on = alias('addListener');
+
+ /**
+ * Semi-alias of addListener. It will add a listener that will be
+ * automatically removed after its first execution.
+ *
+ * @param {String|RegExp} evt Name of the event to attach the listener to.
+ * @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.
+ * @return {Object} Current instance of EventEmitter for chaining.
+ */
+ proto.addOnceListener = function addOnceListener(evt, listener) {
+ return this.addListener(evt, {
+ listener: listener,
+ once: true
+ });
+ };
+
+ /**
+ * Alias of addOnceListener.
+ */
+ proto.once = alias('addOnceListener');
+
+ /**
+ * Defines an event name. This is required if you want to use a regex to add a listener to multiple events at once. If you don't do this then how do you expect it to know what event to add to? Should it just add to every possible match for a regex? No. That is scary and bad.
+ * You need to tell it what event names should be matched by a regex.
+ *
+ * @param {String} evt Name of the event to create.
+ * @return {Object} Current instance of EventEmitter for chaining.
+ */
+ proto.defineEvent = function defineEvent(evt) {
+ this.getListeners(evt);
+ return this;
+ };
+
+ /**
+ * Uses defineEvent to define multiple events.
+ *
+ * @param {String[]} evts An array of event names to define.
+ * @return {Object} Current instance of EventEmitter for chaining.
+ */
+ proto.defineEvents = function defineEvents(evts) {
+ for (var i = 0; i < evts.length; i += 1) {
+ this.defineEvent(evts[i]);
+ }
+ return this;
+ };
+
+ /**
+ * Removes a listener function from the specified event.
+ * When passed a regular expression as the event name, it will remove the listener from all events that match it.
+ *
+ * @param {String|RegExp} evt Name of the event to remove the listener from.
+ * @param {Function} listener Method to remove from the event.
+ * @return {Object} Current instance of EventEmitter for chaining.
+ */
+ proto.removeListener = function removeListener(evt, listener) {
+ var listeners = this.getListenersAsObject(evt);
+ var index;
+ var key;
+
+ for (key in listeners) {
+ if (listeners.hasOwnProperty(key)) {
+ index = indexOfListener(listeners[key], listener);
+
+ if (index !== -1) {
+ listeners[key].splice(index, 1);
+ }
+ }
+ }
+
+ return this;
+ };
+
+ /**
+ * Alias of removeListener
+ */
+ proto.off = alias('removeListener');
+
+ /**
+ * Adds listeners in bulk using the manipulateListeners method.
+ * If you pass an object as the second argument you can add to multiple events at once. The object should contain key value pairs of events and listeners or listener arrays. You can also pass it an event name and an array of listeners to be added.
+ * You can also pass it a regular expression to add the array of listeners to all events that match it.
+ * Yeah, this function does quite a bit. That's probably a bad thing.
+ *
+ * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add to multiple events at once.
+ * @param {Function[]} [listeners] An optional array of listener functions to add.
+ * @return {Object} Current instance of EventEmitter for chaining.
+ */
+ proto.addListeners = function addListeners(evt, listeners) {
+ // Pass through to manipulateListeners
+ return this.manipulateListeners(false, evt, listeners);
+ };
+
+ /**
+ * Removes listeners in bulk using the manipulateListeners method.
+ * If you pass an object as the second argument you can remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays.
+ * You can also pass it an event name and an array of listeners to be removed.
+ * You can also pass it a regular expression to remove the listeners from all events that match it.
+ *
+ * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to remove from multiple events at once.
+ * @param {Function[]} [listeners] An optional array of listener functions to remove.
+ * @return {Object} Current instance of EventEmitter for chaining.
+ */
+ proto.removeListeners = function removeListeners(evt, listeners) {
+ // Pass through to manipulateListeners
+ return this.manipulateListeners(true, evt, listeners);
+ };
+
+ /**
+ * Edits listeners in bulk. The addListeners and removeListeners methods both use this to do their job. You should really use those instead, this is a little lower level.
+ * The first argument will determine if the listeners are removed (true) or added (false).
+ * If you pass an object as the second argument you can add/remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays.
+ * You can also pass it an event name and an array of listeners to be added/removed.
+ * You can also pass it a regular expression to manipulate the listeners of all events that match it.
+ *
+ * @param {Boolean} remove True if you want to remove listeners, false if you want to add.
+ * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add/remove from multiple events at once.
+ * @param {Function[]} [listeners] An optional array of listener functions to add/remove.
+ * @return {Object} Current instance of EventEmitter for chaining.
+ */
+ proto.manipulateListeners = function manipulateListeners(remove, evt, listeners) {
+ var i;
+ var value;
+ var single = remove ? this.removeListener : this.addListener;
+ var multiple = remove ? this.removeListeners : this.addListeners;
+
+ // If evt is an object then pass each of its properties to this method
+ if (typeof evt === 'object' && !(evt instanceof RegExp)) {
+ for (i in evt) {
+ if (evt.hasOwnProperty(i) && (value = evt[i])) {
+ // Pass the single listener straight through to the singular method
+ if (typeof value === 'function') {
+ single.call(this, i, value);
+ }
+ else {
+ // Otherwise pass back to the multiple function
+ multiple.call(this, i, value);
+ }
+ }
+ }
+ }
+ else {
+ // So evt must be a string
+ // And listeners must be an array of listeners
+ // Loop over it and pass each one to the multiple method
+ i = listeners.length;
+ while (i--) {
+ single.call(this, evt, listeners[i]);
+ }
+ }
+
+ return this;
+ };
+
+ /**
+ * Removes all listeners from a specified event.
+ * If you do not specify an event then all listeners will be removed.
+ * That means every event will be emptied.
+ * You can also pass a regex to remove all events that match it.
+ *
+ * @param {String|RegExp} [evt] Optional name of the event to remove all listeners for. Will remove from every event if not passed.
+ * @return {Object} Current instance of EventEmitter for chaining.
+ */
+ proto.removeEvent = function removeEvent(evt) {
+ var type = typeof evt;
+ var events = this._getEvents();
+ var key;
+
+ // Remove different things depending on the state of evt
+ if (type === 'string') {
+ // Remove all listeners for the specified event
+ delete events[evt];
+ }
+ else if (evt instanceof RegExp) {
+ // Remove all events matching the regex.
+ for (key in events) {
+ if (events.hasOwnProperty(key) && evt.test(key)) {
+ delete events[key];
+ }
+ }
+ }
+ else {
+ // Remove all listeners in all events
+ delete this._events;
+ }
+
+ return this;
+ };
+
+ /**
+ * Alias of removeEvent.
+ *
+ * Added to mirror the node API.
+ */
+ proto.removeAllListeners = alias('removeEvent');
+
+ /**
+ * Emits an event of your choice.
+ * When emitted, every listener attached to that event will be executed.
+ * If you pass the optional argument array then those arguments will be passed to every listener upon execution.
+ * Because it uses `apply`, your array of arguments will be passed as if you wrote them out separately.
+ * So they will not arrive within the array on the other side, they will be separate.
+ * You can also pass a regular expression to emit to all events that match it.
+ *
+ * @param {String|RegExp} evt Name of the event to emit and execute listeners for.
+ * @param {Array} [args] Optional array of arguments to be passed to each listener.
+ * @return {Object} Current instance of EventEmitter for chaining.
+ */
+ proto.emitEvent = function emitEvent(evt, args) {
+ var listeners = this.getListenersAsObject(evt);
+ var listener;
+ var i;
+ var key;
+ var response;
+
+ for (key in listeners) {
+ if (listeners.hasOwnProperty(key)) {
+ i = listeners[key].length;
+
+ while (i--) {
+ // If the listener returns true then it shall be removed from the event
+ // The function is executed either with a basic call or an apply if there is an args array
+ listener = listeners[key][i];
+
+ if (listener.once === true) {
+ this.removeListener(evt, listener.listener);
+ }
+
+ response = listener.listener.apply(this, args || []);
+
+ if (response === this._getOnceReturnValue()) {
+ this.removeListener(evt, listener.listener);
+ }
+ }
+ }
+ }
+
+ return this;
+ };
+
+ /**
+ * Alias of emitEvent
+ */
+ proto.trigger = alias('emitEvent');
+
+ /**
+ * Subtly different from emitEvent in that it will pass its arguments on to the listeners, as opposed to taking a single array of arguments to pass on.
+ * As with emitEvent, you can pass a regex in place of the event name to emit to all events that match it.
+ *
+ * @param {String|RegExp} evt Name of the event to emit and execute listeners for.
+ * @param {...*} Optional additional arguments to be passed to each listener.
+ * @return {Object} Current instance of EventEmitter for chaining.
+ */
+ proto.emit = function emit(evt) {
+ var args = Array.prototype.slice.call(arguments, 1);
+ return this.emitEvent(evt, args);
+ };
+
+ /**
+ * Sets the current value to check against when executing listeners. If a
+ * listeners return value matches the one set here then it will be removed
+ * after execution. This value defaults to true.
+ *
+ * @param {*} value The new value to check for when executing listeners.
+ * @return {Object} Current instance of EventEmitter for chaining.
+ */
+ proto.setOnceReturnValue = function setOnceReturnValue(value) {
+ this._onceReturnValue = value;
+ return this;
+ };
+
+ /**
+ * Fetches the current value to check against when executing listeners. If
+ * the listeners return value matches this one then it should be removed
+ * automatically. It will return true by default.
+ *
+ * @return {*|Boolean} The current value to check for or the default, true.
+ * @api private
+ */
+ proto._getOnceReturnValue = function _getOnceReturnValue() {
+ if (this.hasOwnProperty('_onceReturnValue')) {
+ return this._onceReturnValue;
+ }
+ else {
+ return true;
+ }
+ };
+
+ /**
+ * Fetches the events object and creates one if required.
+ *
+ * @return {Object} The events storage object.
+ * @api private
+ */
+ proto._getEvents = function _getEvents() {
+ return this._events || (this._events = {});
+ };
+
+ /**
+ * Reverts the global {@link EventEmitter} to its previous value and returns a reference to this version.
+ *
+ * @return {Function} Non conflicting EventEmitter class.
+ */
+ EventEmitter.noConflict = function noConflict() {
+ exports.EventEmitter = originalGlobalValue;
+ return EventEmitter;
+ };
+
+ // Expose the class either via AMD, CommonJS or the global object
+ if (typeof define === 'function' && define.amd) {
+ define('eventEmitter/EventEmitter',[],function () {
+ return EventEmitter;
+ });
+ }
+ else if (typeof module === 'object' && module.exports){
+ module.exports = EventEmitter;
+ }
+ else {
+ exports.EventEmitter = EventEmitter;
+ }
+}.call(this));
+
+/*!
+ * eventie v1.0.6
+ * event binding helper
+ * eventie.bind( elem, 'click', myFn )
+ * eventie.unbind( elem, 'click', myFn )
+ * MIT license
+ */
+
+/*jshint browser: true, undef: true, unused: true */
+/*global define: false, module: false */
+
+( function( window ) {
+
+
+
+var docElem = document.documentElement;
+
+var bind = function() {};
+
+function getIEEvent( obj ) {
+ var event = window.event;
+ // add event.target
+ event.target = event.target || event.srcElement || obj;
+ return event;
+}
+
+if ( docElem.addEventListener ) {
+ bind = function( obj, type, fn ) {
+ obj.addEventListener( type, fn, false );
+ };
+} else if ( docElem.attachEvent ) {
+ bind = function( obj, type, fn ) {
+ obj[ type + fn ] = fn.handleEvent ?
+ function() {
+ var event = getIEEvent( obj );
+ fn.handleEvent.call( fn, event );
+ } :
+ function() {
+ var event = getIEEvent( obj );
+ fn.call( obj, event );
+ };
+ obj.attachEvent( "on" + type, obj[ type + fn ] );
+ };
+}
+
+var unbind = function() {};
+
+if ( docElem.removeEventListener ) {
+ unbind = function( obj, type, fn ) {
+ obj.removeEventListener( type, fn, false );
+ };
+} else if ( docElem.detachEvent ) {
+ unbind = function( obj, type, fn ) {
+ obj.detachEvent( "on" + type, obj[ type + fn ] );
+ try {
+ delete obj[ type + fn ];
+ } catch ( err ) {
+ // can't delete window object properties
+ obj[ type + fn ] = undefined;
+ }
+ };
+}
+
+var eventie = {
+ bind: bind,
+ unbind: unbind
+};
+
+// ----- module definition ----- //
+
+if ( typeof define === 'function' && define.amd ) {
+ // AMD
+ define( 'eventie/eventie',eventie );
+} else if ( typeof exports === 'object' ) {
+ // CommonJS
+ module.exports = eventie;
+} else {
+ // browser global
+ window.eventie = eventie;
+}
+
+})( window );
+
+/*!
+ * getStyleProperty v1.0.4
+ * original by kangax
+ * http://perfectionkills.com/feature-testing-css-properties/
+ * MIT license
+ */
+
+/*jshint browser: true, strict: true, undef: true */
+/*global define: false, exports: false, module: false */
+
+( function( window ) {
+
+
+
+var prefixes = 'Webkit Moz ms Ms O'.split(' ');
+var docElemStyle = document.documentElement.style;
+
+function getStyleProperty( propName ) {
+ if ( !propName ) {
+ return;
+ }
+
+ // test standard property first
+ if ( typeof docElemStyle[ propName ] === 'string' ) {
+ return propName;
+ }
+
+ // capitalize
+ propName = propName.charAt(0).toUpperCase() + propName.slice(1);
+
+ // test vendor specific properties
+ var prefixed;
+ for ( var i=0, len = prefixes.length; i < len; i++ ) {
+ prefixed = prefixes[i] + propName;
+ if ( typeof docElemStyle[ prefixed ] === 'string' ) {
+ return prefixed;
+ }
+ }
+}
+
+// transport
+if ( typeof define === 'function' && define.amd ) {
+ // AMD
+ define( 'get-style-property/get-style-property',[],function() {
+ return getStyleProperty;
+ });
+} else if ( typeof exports === 'object' ) {
+ // CommonJS for Component
+ module.exports = getStyleProperty;
+} else {
+ // browser global
+ window.getStyleProperty = getStyleProperty;
+}
+
+})( window );
+
+/*!
+ * getSize v1.2.2
+ * measure size of elements
+ * MIT license
+ */
+
+/*jshint browser: true, strict: true, undef: true, unused: true */
+/*global define: false, exports: false, require: false, module: false, console: false */
+
+( function( window, undefined ) {
+
+
+
+// -------------------------- helpers -------------------------- //
+
+// get a number from a string, not a percentage
+function getStyleSize( value ) {
+ var num = parseFloat( value );
+ // not a percent like '100%', and a number
+ var isValid = value.indexOf('%') === -1 && !isNaN( num );
+ return isValid && num;
+}
+
+function noop() {}
+
+var logError = typeof console === 'undefined' ? noop :
+ function( message ) {
+ console.error( message );
+ };
+
+// -------------------------- measurements -------------------------- //
+
+var measurements = [
+ 'paddingLeft',
+ 'paddingRight',
+ 'paddingTop',
+ 'paddingBottom',
+ 'marginLeft',
+ 'marginRight',
+ 'marginTop',
+ 'marginBottom',
+ 'borderLeftWidth',
+ 'borderRightWidth',
+ 'borderTopWidth',
+ 'borderBottomWidth'
+];
+
+function getZeroSize() {
+ var size = {
+ width: 0,
+ height: 0,
+ innerWidth: 0,
+ innerHeight: 0,
+ outerWidth: 0,
+ outerHeight: 0
+ };
+ for ( var i=0, len = measurements.length; i < len; i++ ) {
+ var measurement = measurements[i];
+ size[ measurement ] = 0;
+ }
+ return size;
+}
+
+
+
+function defineGetSize( getStyleProperty ) {
+
+// -------------------------- setup -------------------------- //
+
+var isSetup = false;
+
+var getStyle, boxSizingProp, isBoxSizeOuter;
+
+/**
+ * setup vars and functions
+ * do it on initial getSize(), rather than on script load
+ * For Firefox bug https://bugzilla.mozilla.org/show_bug.cgi?id=548397
+ */
+function setup() {
+ // setup once
+ if ( isSetup ) {
+ return;
+ }
+ isSetup = true;
+
+ var getComputedStyle = window.getComputedStyle;
+ getStyle = ( function() {
+ var getStyleFn = getComputedStyle ?
+ function( elem ) {
+ return getComputedStyle( elem, null );
+ } :
+ function( elem ) {
+ return elem.currentStyle;
+ };
+
+ return function getStyle( elem ) {
+ var style = getStyleFn( elem );
+ if ( !style ) {
+ logError( 'Style returned ' + style +
+ '. Are you running this code in a hidden iframe on Firefox? ' +
+ 'See http://bit.ly/getsizebug1' );
+ }
+ return style;
+ };
+ })();
+
+ // -------------------------- box sizing -------------------------- //
+
+ boxSizingProp = getStyleProperty('boxSizing');
+
+ /**
+ * WebKit measures the outer-width on style.width on border-box elems
+ * IE & Firefox measures the inner-width
+ */
+ if ( boxSizingProp ) {
+ var div = document.createElement('div');
+ div.style.width = '200px';
+ div.style.padding = '1px 2px 3px 4px';
+ div.style.borderStyle = 'solid';
+ div.style.borderWidth = '1px 2px 3px 4px';
+ div.style[ boxSizingProp ] = 'border-box';
+
+ var body = document.body || document.documentElement;
+ body.appendChild( div );
+ var style = getStyle( div );
+
+ isBoxSizeOuter = getStyleSize( style.width ) === 200;
+ body.removeChild( div );
+ }
+
+}
+
+// -------------------------- getSize -------------------------- //
+
+function getSize( elem ) {
+ setup();
+
+ // use querySeletor if elem is string
+ if ( typeof elem === 'string' ) {
+ elem = document.querySelector( elem );
+ }
+
+ // do not proceed on non-objects
+ if ( !elem || typeof elem !== 'object' || !elem.nodeType ) {
+ return;
+ }
+
+ var style = getStyle( elem );
+
+ // if hidden, everything is 0
+ if ( style.display === 'none' ) {
+ return getZeroSize();
+ }
+
+ var size = {};
+ size.width = elem.offsetWidth;
+ size.height = elem.offsetHeight;
+
+ var isBorderBox = size.isBorderBox = !!( boxSizingProp &&
+ style[ boxSizingProp ] && style[ boxSizingProp ] === 'border-box' );
+
+ // get all measurements
+ for ( var i=0, len = measurements.length; i < len; i++ ) {
+ var measurement = measurements[i];
+ var value = style[ measurement ];
+ value = mungeNonPixel( elem, value );
+ var num = parseFloat( value );
+ // any 'auto', 'medium' value will be 0
+ size[ measurement ] = !isNaN( num ) ? num : 0;
+ }
+
+ var paddingWidth = size.paddingLeft + size.paddingRight;
+ var paddingHeight = size.paddingTop + size.paddingBottom;
+ var marginWidth = size.marginLeft + size.marginRight;
+ var marginHeight = size.marginTop + size.marginBottom;
+ var borderWidth = size.borderLeftWidth + size.borderRightWidth;
+ var borderHeight = size.borderTopWidth + size.borderBottomWidth;
+
+ var isBorderBoxSizeOuter = isBorderBox && isBoxSizeOuter;
+
+ // overwrite width and height if we can get it from style
+ var styleWidth = getStyleSize( style.width );
+ if ( styleWidth !== false ) {
+ size.width = styleWidth +
+ // add padding and border unless it's already including it
+ ( isBorderBoxSizeOuter ? 0 : paddingWidth + borderWidth );
+ }
+
+ var styleHeight = getStyleSize( style.height );
+ if ( styleHeight !== false ) {
+ size.height = styleHeight +
+ // add padding and border unless it's already including it
+ ( isBorderBoxSizeOuter ? 0 : paddingHeight + borderHeight );
+ }
+
+ size.innerWidth = size.width - ( paddingWidth + borderWidth );
+ size.innerHeight = size.height - ( paddingHeight + borderHeight );
+
+ size.outerWidth = size.width + marginWidth;
+ size.outerHeight = size.height + marginHeight;
+
+ return size;
+}
+
+// IE8 returns percent values, not pixels
+// taken from jQuery's curCSS
+function mungeNonPixel( elem, value ) {
+ // IE8 and has percent value
+ if ( window.getComputedStyle || value.indexOf('%') === -1 ) {
+ return value;
+ }
+ var style = elem.style;
+ // Remember the original values
+ var left = style.left;
+ var rs = elem.runtimeStyle;
+ var rsLeft = rs && rs.left;
+
+ // Put in the new values to get a computed value out
+ if ( rsLeft ) {
+ rs.left = elem.currentStyle.left;
+ }
+ style.left = value;
+ value = style.pixelLeft;
+
+ // Revert the changed values
+ style.left = left;
+ if ( rsLeft ) {
+ rs.left = rsLeft;
+ }
+
+ return value;
+}
+
+return getSize;
+
+}
+
+// transport
+if ( typeof define === 'function' && define.amd ) {
+ // AMD for RequireJS
+ define( 'get-size/get-size',[ 'get-style-property/get-style-property' ], defineGetSize );
+} else if ( typeof exports === 'object' ) {
+ // CommonJS for Component
+ module.exports = defineGetSize( require('desandro-get-style-property') );
+} else {
+ // browser global
+ window.getSize = defineGetSize( window.getStyleProperty );
+}
+
+})( window );
+
+/*!
+ * docReady v1.0.4
+ * Cross browser DOMContentLoaded event emitter
+ * MIT license
+ */
+
+/*jshint browser: true, strict: true, undef: true, unused: true*/
+/*global define: false, require: false, module: false */
+
+( function( window ) {
+
+
+
+var document = window.document;
+// collection of functions to be triggered on ready
+var queue = [];
+
+function docReady( fn ) {
+ // throw out non-functions
+ if ( typeof fn !== 'function' ) {
+ return;
+ }
+
+ if ( docReady.isReady ) {
+ // ready now, hit it
+ fn();
+ } else {
+ // queue function when ready
+ queue.push( fn );
+ }
+}
+
+docReady.isReady = false;
+
+// triggered on various doc ready events
+function onReady( event ) {
+ // bail if already triggered or IE8 document is not ready just yet
+ var isIE8NotReady = event.type === 'readystatechange' && document.readyState !== 'complete';
+ if ( docReady.isReady || isIE8NotReady ) {
+ return;
+ }
+
+ trigger();
+}
+
+function trigger() {
+ docReady.isReady = true;
+ // process queue
+ for ( var i=0, len = queue.length; i < len; i++ ) {
+ var fn = queue[i];
+ fn();
+ }
+}
+
+function defineDocReady( eventie ) {
+ // trigger ready if page is ready
+ if ( document.readyState === 'complete' ) {
+ trigger();
+ } else {
+ // listen for events
+ eventie.bind( document, 'DOMContentLoaded', onReady );
+ eventie.bind( document, 'readystatechange', onReady );
+ eventie.bind( window, 'load', onReady );
+ }
+
+ return docReady;
+}
+
+// transport
+if ( typeof define === 'function' && define.amd ) {
+ // AMD
+ define( 'doc-ready/doc-ready',[ 'eventie/eventie' ], defineDocReady );
+} else if ( typeof exports === 'object' ) {
+ module.exports = defineDocReady( require('eventie') );
+} else {
+ // browser global
+ window.docReady = defineDocReady( window.eventie );
+}
+
+})( window );
+
+/**
+ * matchesSelector v1.0.3
+ * matchesSelector( element, '.selector' )
+ * MIT license
+ */
+
+/*jshint browser: true, strict: true, undef: true, unused: true */
+/*global define: false, module: false */
+
+( function( ElemProto ) {
+
+
+
+ var matchesMethod = ( function() {
+ // check for the standard method name first
+ if ( ElemProto.matches ) {
+ return 'matches';
+ }
+ // check un-prefixed
+ if ( ElemProto.matchesSelector ) {
+ return 'matchesSelector';
+ }
+ // check vendor prefixes
+ var prefixes = [ 'webkit', 'moz', 'ms', 'o' ];
+
+ for ( var i=0, len = prefixes.length; i < len; i++ ) {
+ var prefix = prefixes[i];
+ var method = prefix + 'MatchesSelector';
+ if ( ElemProto[ method ] ) {
+ return method;
+ }
+ }
+ })();
+
+ // ----- match ----- //
+
+ function match( elem, selector ) {
+ return elem[ matchesMethod ]( selector );
+ }
+
+ // ----- appendToFragment ----- //
+
+ function checkParent( elem ) {
+ // not needed if already has parent
+ if ( elem.parentNode ) {
+ return;
+ }
+ var fragment = document.createDocumentFragment();
+ fragment.appendChild( elem );
+ }
+
+ // ----- query ----- //
+
+ // fall back to using QSA
+ // thx @jonathantneal https://gist.github.com/3062955
+ function query( elem, selector ) {
+ // append to fragment if no parent
+ checkParent( elem );
+
+ // match elem with all selected elems of parent
+ var elems = elem.parentNode.querySelectorAll( selector );
+ for ( var i=0, len = elems.length; i < len; i++ ) {
+ // return true if match
+ if ( elems[i] === elem ) {
+ return true;
+ }
+ }
+ // otherwise return false
+ return false;
+ }
+
+ // ----- matchChild ----- //
+
+ function matchChild( elem, selector ) {
+ checkParent( elem );
+ return match( elem, selector );
+ }
+
+ // ----- matchesSelector ----- //
+
+ var matchesSelector;
+
+ if ( matchesMethod ) {
+ // IE9 supports matchesSelector, but doesn't work on orphaned elems
+ // check for that
+ var div = document.createElement('div');
+ var supportsOrphans = match( div, 'div' );
+ matchesSelector = supportsOrphans ? match : matchChild;
+ } else {
+ matchesSelector = query;
+ }
+
+ // transport
+ if ( typeof define === 'function' && define.amd ) {
+ // AMD
+ define( 'matches-selector/matches-selector',[],function() {
+ return matchesSelector;
+ });
+ } else if ( typeof exports === 'object' ) {
+ module.exports = matchesSelector;
+ }
+ else {
+ // browser global
+ window.matchesSelector = matchesSelector;
+ }
+
+})( Element.prototype );
+
+/**
+ * Fizzy UI utils v1.0.1
+ * MIT license
+ */
+
+/*jshint browser: true, undef: true, unused: true, strict: true */
+
+( function( window, factory ) {
+ /*global define: false, module: false, require: false */
+
+ // universal module definition
+
+ if ( typeof define == 'function' && define.amd ) {
+ // AMD
+ define( 'fizzy-ui-utils/utils',[
+ 'doc-ready/doc-ready',
+ 'matches-selector/matches-selector'
+ ], function( docReady, matchesSelector ) {
+ return factory( window, docReady, matchesSelector );
+ });
+ } else if ( typeof exports == 'object' ) {
+ // CommonJS
+ module.exports = factory(
+ window,
+ require('doc-ready'),
+ require('desandro-matches-selector')
+ );
+ } else {
+ // browser global
+ window.fizzyUIUtils = factory(
+ window,
+ window.docReady,
+ window.matchesSelector
+ );
+ }
+
+}( window, function factory( window, docReady, matchesSelector ) {
+
+
+
+var utils = {};
+
+// ----- extend ----- //
+
+// extends objects
+utils.extend = function( a, b ) {
+ for ( var prop in b ) {
+ a[ prop ] = b[ prop ];
+ }
+ return a;
+};
+
+// ----- modulo ----- //
+
+utils.modulo = function( num, div ) {
+ return ( ( num % div ) + div ) % div;
+};
+
+// ----- isArray ----- //
+
+var objToString = Object.prototype.toString;
+utils.isArray = function( obj ) {
+ return objToString.call( obj ) == '[object Array]';
+};
+
+// ----- makeArray ----- //
+
+// turn element or nodeList into an array
+utils.makeArray = function( obj ) {
+ var ary = [];
+ if ( utils.isArray( obj ) ) {
+ // use object if already an array
+ ary = obj;
+ } else if ( obj && typeof obj.length == 'number' ) {
+ // convert nodeList to array
+ for ( var i=0, len = obj.length; i < len; i++ ) {
+ ary.push( obj[i] );
+ }
+ } else {
+ // array of single index
+ ary.push( obj );
+ }
+ return ary;
+};
+
+// ----- indexOf ----- //
+
+// index of helper cause IE8
+utils.indexOf = Array.prototype.indexOf ? function( ary, obj ) {
+ return ary.indexOf( obj );
+ } : function( ary, obj ) {
+ for ( var i=0, len = ary.length; i < len; i++ ) {
+ if ( ary[i] === obj ) {
+ return i;
+ }
+ }
+ return -1;
+ };
+
+// ----- removeFrom ----- //
+
+utils.removeFrom = function( ary, obj ) {
+ var index = utils.indexOf( ary, obj );
+ if ( index != -1 ) {
+ ary.splice( index, 1 );
+ }
+};
+
+// ----- isElement ----- //
+
+// http://stackoverflow.com/a/384380/182183
+utils.isElement = ( typeof HTMLElement == 'function' || typeof HTMLElement == 'object' ) ?
+ function isElementDOM2( obj ) {
+ return obj instanceof HTMLElement;
+ } :
+ function isElementQuirky( obj ) {
+ return obj && typeof obj == 'object' &&
+ obj.nodeType == 1 && typeof obj.nodeName == 'string';
+ };
+
+// ----- setText ----- //
+
+utils.setText = ( function() {
+ var setTextProperty;
+ function setText( elem, text ) {
+ // only check setTextProperty once
+ setTextProperty = setTextProperty || ( document.documentElement.textContent !== undefined ? 'textContent' : 'innerText' );
+ elem[ setTextProperty ] = text;
+ }
+ return setText;
+})();
+
+// ----- getParent ----- //
+
+utils.getParent = function( elem, selector ) {
+ while ( elem != document.body ) {
+ elem = elem.parentNode;
+ if ( matchesSelector( elem, selector ) ) {
+ return elem;
+ }
+ }
+};
+
+// ----- getQueryElement ----- //
+
+// use element as selector string
+utils.getQueryElement = function( elem ) {
+ if ( typeof elem == 'string' ) {
+ return document.querySelector( elem );
+ }
+ return elem;
+};
+
+// ----- handleEvent ----- //
+
+// enable .ontype to trigger from .addEventListener( elem, 'type' )
+utils.handleEvent = function( event ) {
+ var method = 'on' + event.type;
+ if ( this[ method ] ) {
+ this[ method ]( event );
+ }
+};
+
+// ----- filterFindElements ----- //
+
+utils.filterFindElements = function( elems, selector ) {
+ // make array of elems
+ elems = utils.makeArray( elems );
+ var ffElems = [];
+
+ for ( var i=0, len = elems.length; i < len; i++ ) {
+ var elem = elems[i];
+ // check that elem is an actual element
+ if ( !utils.isElement( elem ) ) {
+ continue;
+ }
+ // filter & find items if we have a selector
+ if ( selector ) {
+ // filter siblings
+ if ( matchesSelector( elem, selector ) ) {
+ ffElems.push( elem );
+ }
+ // find children
+ var childElems = elem.querySelectorAll( selector );
+ // concat childElems to filterFound array
+ for ( var j=0, jLen = childElems.length; j < jLen; j++ ) {
+ ffElems.push( childElems[j] );
+ }
+ } else {
+ ffElems.push( elem );
+ }
+ }
+
+ return ffElems;
+};
+
+// ----- debounceMethod ----- //
+
+utils.debounceMethod = function( _class, methodName, threshold ) {
+ // original method
+ var method = _class.prototype[ methodName ];
+ var timeoutName = methodName + 'Timeout';
+
+ _class.prototype[ methodName ] = function() {
+ var timeout = this[ timeoutName ];
+ if ( timeout ) {
+ clearTimeout( timeout );
+ }
+ var args = arguments;
+
+ var _this = this;
+ this[ timeoutName ] = setTimeout( function() {
+ method.apply( _this, args );
+ delete _this[ timeoutName ];
+ }, threshold || 100 );
+ };
+};
+
+// ----- htmlInit ----- //
+
+// http://jamesroberts.name/blog/2010/02/22/string-functions-for-javascript-trim-to-camel-case-to-dashed-and-to-underscore/
+utils.toDashed = function( str ) {
+ return str.replace( /(.)([A-Z])/g, function( match, $1, $2 ) {
+ return $1 + '-' + $2;
+ }).toLowerCase();
+};
+
+var console = window.console;
+/**
+ * allow user to initialize classes via .js-namespace class
+ * htmlInit( Widget, 'widgetName' )
+ * options are parsed from data-namespace-option attribute
+ */
+utils.htmlInit = function( WidgetClass, namespace ) {
+ docReady( function() {
+ var dashedNamespace = utils.toDashed( namespace );
+ var elems = document.querySelectorAll( '.js-' + dashedNamespace );
+ var dataAttr = 'data-' + dashedNamespace + '-options';
+
+ for ( var i=0, len = elems.length; i < len; i++ ) {
+ var elem = elems[i];
+ var attr = elem.getAttribute( dataAttr );
+ var options;
+ try {
+ options = attr && JSON.parse( attr );
+ } catch ( error ) {
+ // log error, do not initialize
+ if ( console ) {
+ console.error( 'Error parsing ' + dataAttr + ' on ' +
+ elem.nodeName.toLowerCase() + ( elem.id ? '#' + elem.id : '' ) + ': ' +
+ error );
+ }
+ continue;
+ }
+ // initialize
+ var instance = new WidgetClass( elem, options );
+ // make available via $().data('layoutname')
+ var jQuery = window.jQuery;
+ if ( jQuery ) {
+ jQuery.data( elem, namespace, instance );
+ }
+ }
+ });
+};
+
+// ----- ----- //
+
+return utils;
+
+}));
+
+( function( window, factory ) {
+
+ // universal module definition
+
+ if ( typeof define == 'function' && define.amd ) {
+ // AMD
+ define( 'flickity/js/cell',[
+ 'get-size/get-size'
+ ], function( getSize ) {
+ return factory( window, getSize );
+ });
+ } else if ( typeof exports == 'object' ) {
+ // CommonJS
+ module.exports = factory(
+ window,
+ require('get-size')
+ );
+ } else {
+ // browser global
+ window.Flickity = window.Flickity || {};
+ window.Flickity.Cell = factory(
+ window,
+ window.getSize
+ );
+ }
+
+}( window, function factory( window, getSize ) {
+
+
+
+function Cell( elem, parent ) {
+ this.element = elem;
+ this.parent = parent;
+
+ this.create();
+}
+
+var isIE8 = 'attachEvent' in window;
+
+Cell.prototype.create = function() {
+ this.element.style.position = 'absolute';
+ // IE8 prevent child from changing focus http://stackoverflow.com/a/17525223/182183
+ if ( isIE8 ) {
+ this.element.setAttribute( 'unselectable', 'on' );
+ }
+ this.x = 0;
+ this.shift = 0;
+};
+
+Cell.prototype.destroy = function() {
+ // reset style
+ this.element.style.position = '';
+ var side = this.parent.originSide;
+ this.element.style[ side ] = '';
+};
+
+Cell.prototype.getSize = function() {
+ this.size = getSize( this.element );
+};
+
+Cell.prototype.setPosition = function( x ) {
+ this.x = x;
+ this.setDefaultTarget();
+ this.renderPosition( x );
+};
+
+Cell.prototype.setDefaultTarget = function() {
+ var marginProperty = this.parent.originSide == 'left' ? 'marginLeft' : 'marginRight';
+ this.target = this.x + this.size[ marginProperty ] +
+ this.size.width * this.parent.cellAlign;
+};
+
+Cell.prototype.renderPosition = function( x ) {
+ // render position of cell with in slider
+ var side = this.parent.originSide;
+ this.element.style[ side ] = this.parent.getPositionValue( x );
+};
+
+/**
+ * @param {Integer} factor - 0, 1, or -1
+**/
+Cell.prototype.wrapShift = function( shift ) {
+ this.shift = shift;
+ this.renderPosition( this.x + this.parent.slideableWidth * shift );
+};
+
+Cell.prototype.remove = function() {
+ this.element.parentNode.removeChild( this.element );
+};
+
+return Cell;
+
+}));
+
+( function( window, factory ) {
+
+ // universal module definition
+
+ if ( typeof define == 'function' && define.amd ) {
+ // AMD
+ define( 'flickity/js/animate',[
+ 'get-style-property/get-style-property',
+ 'fizzy-ui-utils/utils'
+ ], function( getStyleProperty, utils ) {
+ return factory( window, getStyleProperty, utils );
+ });
+ } else if ( typeof exports == 'object' ) {
+ // CommonJS
+ module.exports = factory(
+ window,
+ require('desandro-get-style-property'),
+ require('fizzy-ui-utils')
+ );
+ } else {
+ // browser global
+ window.Flickity = window.Flickity || {};
+ window.Flickity.animatePrototype = factory(
+ window,
+ window.getStyleProperty,
+ window.fizzyUIUtils
+ );
+ }
+
+}( window, function factory( window, getStyleProperty, utils ) {
+
+
+
+// -------------------------- requestAnimationFrame -------------------------- //
+
+// https://gist.github.com/1866474
+
+var lastTime = 0;
+var prefixes = 'webkit moz ms o'.split(' ');
+// get unprefixed rAF and cAF, if present
+var requestAnimationFrame = window.requestAnimationFrame;
+var cancelAnimationFrame = window.cancelAnimationFrame;
+// loop through vendor prefixes and get prefixed rAF and cAF
+var prefix;
+for( var i = 0; i < prefixes.length; i++ ) {
+ if ( requestAnimationFrame && cancelAnimationFrame ) {
+ break;
+ }
+ prefix = prefixes[i];
+ requestAnimationFrame = requestAnimationFrame || window[ prefix + 'RequestAnimationFrame' ];
+ cancelAnimationFrame = cancelAnimationFrame || window[ prefix + 'CancelAnimationFrame' ] ||
+ window[ prefix + 'CancelRequestAnimationFrame' ];
+}
+
+// fallback to setTimeout and clearTimeout if either request/cancel is not supported
+if ( !requestAnimationFrame || !cancelAnimationFrame ) {
+ requestAnimationFrame = function( callback ) {
+ var currTime = new Date().getTime();
+ var timeToCall = Math.max( 0, 16 - ( currTime - lastTime ) );
+ var id = window.setTimeout( function() {
+ callback( currTime + timeToCall );
+ }, timeToCall );
+ lastTime = currTime + timeToCall;
+ return id;
+ };
+
+ cancelAnimationFrame = function( id ) {
+ window.clearTimeout( id );
+ };
+}
+
+// -------------------------- animate -------------------------- //
+
+var proto = {};
+
+proto.startAnimation = function() {
+ if ( this.isAnimating ) {
+ return;
+ }
+
+ this.isAnimating = true;
+ this.restingFrames = 0;
+ this.animate();
+};
+
+proto.animate = function() {
+ this.applySelectedAttraction();
+
+ var previousX = this.x;
+
+ this.integratePhysics();
+ this.positionSlider();
+ this.settle( previousX );
+ // animate next frame
+ if ( this.isAnimating ) {
+ var _this = this;
+ requestAnimationFrame( function animateFrame() {
+ _this.animate();
+ });
+ }
+
+ /** /
+ // log animation frame rate
+ var now = new Date();
+ if ( this.then ) {
+ console.log( ~~( 1000 / (now-this.then)) + 'fps' )
+ }
+ this.then = now;
+ /**/
+};
+
+
+var transformProperty = getStyleProperty('transform');
+var is3d = !!getStyleProperty('perspective');
+
+proto.positionSlider = function() {
+ var x = this.x;
+ // wrap position around
+ if ( this.options.wrapAround && this.cells.length > 1 ) {
+ x = utils.modulo( x, this.slideableWidth );
+ x = x - this.slideableWidth;
+ this.shiftWrapCells( x );
+ }
+
+ x = x + this.cursorPosition;
+
+ // reverse if right-to-left and using transform
+ x = this.options.rightToLeft && transformProperty ? -x : x;
+
+ var value = this.getPositionValue( x );
+
+ if ( transformProperty ) {
+ // use 3D tranforms for hardware acceleration on iOS
+ // but use 2D when settled, for better font-rendering
+ this.slider.style[ transformProperty ] = is3d && this.isAnimating ?
+ 'translate3d(' + value + ',0,0)' : 'translateX(' + value + ')';
+ } else {
+ this.slider.style[ this.originSide ] = value;
+ }
+};
+
+proto.positionSliderAtSelected = function() {
+ if ( !this.cells.length ) {
+ return;
+ }
+ var selectedCell = this.cells[ this.selectedIndex ];
+ this.x = -selectedCell.target;
+ this.positionSlider();
+};
+
+proto.getPositionValue = function( position ) {
+ if ( this.options.percentPosition ) {
+ // percent position, round to 2 digits, like 12.34%
+ return ( Math.round( ( position / this.size.innerWidth ) * 10000 ) * 0.01 )+ '%';
+ } else {
+ // pixel positioning
+ return Math.round( position ) + 'px';
+ }
+};
+
+proto.settle = function( previousX ) {
+ // keep track of frames where x hasn't moved
+ if ( !this.isPointerDown && Math.round( this.x * 100 ) == Math.round( previousX * 100 ) ) {
+ this.restingFrames++;
+ }
+ // stop animating if resting for 3 or more frames
+ if ( this.restingFrames > 2 ) {
+ this.isAnimating = false;
+ delete this.isFreeScrolling;
+ // render position with translateX when settled
+ if ( is3d ) {
+ this.positionSlider();
+ }
+ this.dispatchEvent('settle');
+ }
+};
+
+proto.shiftWrapCells = function( x ) {
+ // shift before cells
+ var beforeGap = this.cursorPosition + x;
+ this._shiftCells( this.beforeShiftCells, beforeGap, -1 );
+ // shift after cells
+ var afterGap = this.size.innerWidth - ( x + this.slideableWidth + this.cursorPosition );
+ this._shiftCells( this.afterShiftCells, afterGap, 1 );
+};
+
+proto._shiftCells = function( cells, gap, shift ) {
+ for ( var i=0, len = cells.length; i < len; i++ ) {
+ var cell = cells[i];
+ var cellShift = gap > 0 ? shift : 0;
+ cell.wrapShift( cellShift );
+ gap -= cell.size.outerWidth;
+ }
+};
+
+proto._unshiftCells = function( cells ) {
+ if ( !cells || !cells.length ) {
+ return;
+ }
+ for ( var i=0, len = cells.length; i < len; i++ ) {
+ cells[i].wrapShift( 0 );
+ }
+};
+
+// -------------------------- physics -------------------------- //
+
+proto.integratePhysics = function() {
+ this.velocity += this.accel;
+ this.x += this.velocity;
+ this.velocity *= this.getFrictionFactor();
+ // reset acceleration
+ this.accel = 0;
+};
+
+proto.applyForce = function( force ) {
+ this.accel += force;
+};
+
+proto.getFrictionFactor = function() {
+ return 1 - this.options[ this.isFreeScrolling ? 'freeScrollFriction' : 'friction' ];
+};
+
+
+proto.getRestingPosition = function() {
+ // my thanks to Steven Wittens, who simplified this math greatly
+ return this.x + this.velocity / ( 1 - this.getFrictionFactor() );
+};
+
+
+proto.applySelectedAttraction = function() {
+ // do not attract if pointer down or no cells
+ var len = this.cells.length;
+ if ( this.isPointerDown || this.isFreeScrolling || !len ) {
+ return;
+ }
+ var cell = this.cells[ this.selectedIndex ];
+ var wrap = this.options.wrapAround && len > 1 ?
+ this.slideableWidth * Math.floor( this.selectedIndex / len ) : 0;
+ var distance = ( cell.target + wrap ) * -1 - this.x;
+ var force = distance * this.options.selectedAttraction;
+ this.applyForce( force );
+};
+
+return proto;
+
+}));
+
+/*!
+ * Flickity v1.0.1
+ * Touch, responsive, flickable galleries
+ *
+ * Licensed GPLv3 for open source use
+ * or Flickity Commercial License for commercial use
+ *
+ * http://flickity.metafizzy.co
+ * Copyright 2015 Metafizzy
+ */
+
+( function( window, factory ) {
+
+ // universal module definition
+
+ if ( typeof define == 'function' && define.amd ) {
+ // AMD
+ define( 'flickity/js/flickity',[
+ 'classie/classie',
+ 'eventEmitter/EventEmitter',
+ 'eventie/eventie',
+ 'get-size/get-size',
+ 'fizzy-ui-utils/utils',
+ './cell',
+ './animate'
+ ], function( classie, EventEmitter, eventie, getSize, utils, Cell, animatePrototype ) {
+ return factory( window, classie, EventEmitter, eventie, getSize, utils, Cell, animatePrototype );
+ });
+ } else if ( typeof exports == 'object' ) {
+ // CommonJS
+ module.exports = factory(
+ window,
+ require('desandro-classie'),
+ require('wolfy87-eventemitter'),
+ require('eventie'),
+ require('get-size'),
+ require('fizzy-ui-utils'),
+ require('./cell'),
+ require('./animate')
+ );
+ } else {
+ // browser global
+ var _Flickity = window.Flickity;
+
+ window.Flickity = factory(
+ window,
+ window.classie,
+ window.EventEmitter,
+ window.eventie,
+ window.getSize,
+ window.fizzyUIUtils,
+ _Flickity.Cell,
+ _Flickity.animatePrototype
+ );
+ }
+
+}( window, function factory( window, classie, EventEmitter, eventie, getSize,
+ utils, Cell, animatePrototype ) {
+
+
+
+// vars
+var jQuery = window.jQuery;
+var getComputedStyle = window.getComputedStyle;
+var console = window.console;
+
+function moveElements( elems, toElem ) {
+ elems = utils.makeArray( elems );
+ while ( elems.length ) {
+ toElem.appendChild( elems.shift() );
+ }
+}
+
+// -------------------------- Flickity -------------------------- //
+
+// globally unique identifiers
+var GUID = 0;
+// internal store of all Flickity intances
+var instances = {};
+
+function Flickity( element, options ) {
+ var queryElement = utils.getQueryElement( element );
+ if ( !queryElement ) {
+ if ( console ) {
+ console.error( 'Bad element for Flickity: ' + ( queryElement || element ) );
+ }
+ return;
+ }
+ this.element = queryElement;
+ // add jQuery
+ if ( jQuery ) {
+ this.$element = jQuery( this.element );
+ }
+ // options
+ this.options = utils.extend( {}, this.constructor.defaults );
+ this.option( options );
+
+ // kick things off
+ this._create();
+}
+
+Flickity.defaults = {
+ accessibility: true,
+ cellAlign: 'center',
+ // cellSelector: undefined,
+ // contain: false,
+ freeScrollFriction: 0.075, // friction when free-scrolling
+ friction: 0.28, // friction when selecting
+ // initialIndex: 0,
+ percentPosition: true,
+ resize: true,
+ selectedAttraction: 0.025,
+ setGallerySize: true
+ // watchCSS: false,
+ // wrapAround: false
+};
+
+// hash of methods triggered on _create()
+Flickity.createMethods = [];
+
+// inherit EventEmitter
+utils.extend( Flickity.prototype, EventEmitter.prototype );
+
+Flickity.prototype._create = function() {
+ // add id for Flickity.data
+ var id = this.guid = ++GUID;
+ this.element.flickityGUID = id; // expando
+ instances[ id ] = this; // associate via id
+ // initial properties
+ this.selectedIndex = this.options.initialIndex || 0;
+ // how many frames slider has been in same position
+ this.restingFrames = 0;
+ // initial physics properties
+ this.x = 0;
+ this.velocity = 0;
+ this.accel = 0;
+ this.originSide = this.options.rightToLeft ? 'right' : 'left';
+ // create viewport & slider
+ this.viewport = document.createElement('div');
+ this.viewport.className = 'flickity-viewport';
+ Flickity.setUnselectable( this.viewport );
+ this._createSlider();
+
+ if ( this.options.resize || this.options.watchCSS ) {
+ eventie.bind( window, 'resize', this );
+ this.isResizeBound = true;
+ }
+
+ for ( var i=0, len = Flickity.createMethods.length; i < len; i++ ) {
+ var method = Flickity.createMethods[i];
+ this[ method ]();
+ }
+
+ if ( this.options.watchCSS ) {
+ this.watchCSS();
+ } else {
+ this.activate();
+ }
+
+};
+
+/**
+ * set options
+ * @param {Object} opts
+ */
+Flickity.prototype.option = function( opts ) {
+ utils.extend( this.options, opts );
+};
+
+Flickity.prototype.activate = function() {
+ if ( this.isActive ) {
+ return;
+ }
+ this.isActive = true;
+ classie.add( this.element, 'flickity-enabled' );
+ if ( this.options.rightToLeft ) {
+ classie.add( this.element, 'flickity-rtl' );
+ }
+
+ // move initial cell elements so they can be loaded as cells
+ var cellElems = this._filterFindCellElements( this.element.children );
+ moveElements( cellElems, this.slider );
+ this.viewport.appendChild( this.slider );
+ this.element.appendChild( this.viewport );
+
+ this.getSize();
+ // get cells from children
+ this.reloadCells();
+
+ if ( this.options.accessibility ) {
+ // allow element to focusable
+ this.element.tabIndex = 0;
+ // listen for key presses
+ eventie.bind( this.element, 'keydown', this );
+ }
+
+ this.emit('activate');
+
+ this.positionSliderAtSelected();
+ this.select( this.selectedIndex );
+};
+
+// slider positions the cells
+Flickity.prototype._createSlider = function() {
+ // slider element does all the positioning
+ var slider = document.createElement('div');
+ slider.className = 'flickity-slider';
+ slider.style[ this.originSide ] = 0;
+ this.slider = slider;
+};
+
+Flickity.prototype._filterFindCellElements = function( elems ) {
+ return utils.filterFindElements( elems, this.options.cellSelector );
+};
+
+// goes through all children
+Flickity.prototype.reloadCells = function() {
+ // collection of item elements
+ this.cells = this._makeCells( this.slider.children );
+ this.positionCells();
+ this._getWrapShiftCells();
+ this.setGallerySize();
+};
+
+/**
+ * turn elements into Flickity.Cells
+ * @param {Array or NodeList or HTMLElement} elems
+ * @returns {Array} items - collection of new Flickity Cells
+ */
+Flickity.prototype._makeCells = function( elems ) {
+ var cellElems = this._filterFindCellElements( elems );
+
+ // create new Flickity for collection
+ var cells = [];
+ for ( var i=0, len = cellElems.length; i < len; i++ ) {
+ var elem = cellElems[i];
+ var cell = new Cell( elem, this );
+ cells.push( cell );
+ }
+
+ return cells;
+};
+
+Flickity.prototype.getLastCell = function() {
+ return this.cells[ this.cells.length - 1 ];
+};
+
+// positions all cells
+Flickity.prototype.positionCells = function() {
+ // size all cells
+ this._sizeCells( this.cells );
+ // position all cells
+ this._positionCells( 0 );
+};
+
+/**
+ * position certain cells
+ * @param {Integer} index - which cell to start with
+ */
+Flickity.prototype._positionCells = function( index ) {
+ // also measure maxCellHeight
+ // start 0 if positioning all cells
+ this.maxCellHeight = index ? this.maxCellHeight || 0 : 0;
+ var cellX = 0;
+ // get cellX
+ if ( index > 0 ) {
+ var startCell = this.cells[ index - 1 ];
+ cellX = startCell.x + startCell.size.outerWidth;
+ }
+ var cell;
+ for ( var len = this.cells.length, i=index; i < len; i++ ) {
+ cell = this.cells[i];
+ cell.setPosition( cellX );
+ cellX += cell.size.outerWidth;
+ this.maxCellHeight = Math.max( cell.size.outerHeight, this.maxCellHeight );
+ }
+ // keep track of cellX for wrap-around
+ this.slideableWidth = cellX;
+ // contain cell target
+ this._containCells();
+};
+
+/**
+ * cell.getSize() on multiple cells
+ * @param {Array} cells
+ */
+Flickity.prototype._sizeCells = function( cells ) {
+ for ( var i=0, len = cells.length; i < len; i++ ) {
+ var cell = cells[i];
+ cell.getSize();
+ }
+};
+
+// alias _init for jQuery plugin .flickity()
+Flickity.prototype._init =
+Flickity.prototype.reposition = function() {
+ this.positionCells();
+ this.positionSliderAtSelected();
+};
+
+Flickity.prototype.getSize = function() {
+ this.size = getSize( this.element );
+ this.setCellAlign();
+ this.cursorPosition = this.size.innerWidth * this.cellAlign;
+};
+
+var cellAlignShorthands = {
+ // cell align, then based on origin side
+ center: {
+ left: 0.5,
+ right: 0.5
+ },
+ left: {
+ left: 0,
+ right: 1
+ },
+ right: {
+ right: 0,
+ left: 1
+ }
+};
+
+Flickity.prototype.setCellAlign = function() {
+ var shorthand = cellAlignShorthands[ this.options.cellAlign ];
+ this.cellAlign = shorthand ? shorthand[ this.originSide ] : this.options.cellAlign;
+};
+
+Flickity.prototype.setGallerySize = function() {
+ if ( this.options.setGallerySize ) {
+ this.viewport.style.height = this.maxCellHeight + 'px';
+ }
+};
+
+Flickity.prototype._getWrapShiftCells = function() {
+ // only for wrap-around
+ if ( !this.options.wrapAround ) {
+ return;
+ }
+ // unshift previous cells
+ this._unshiftCells( this.beforeShiftCells );
+ this._unshiftCells( this.afterShiftCells );
+ // get before cells
+ // initial gap
+ var gapX = this.cursorPosition;
+ var cellIndex = this.cells.length - 1;
+ this.beforeShiftCells = this._getGapCells( gapX, cellIndex, -1 );
+ // get after cells
+ // ending gap between last cell and end of gallery viewport
+ gapX = this.size.innerWidth - this.cursorPosition;
+ // start cloning at first cell, working forwards
+ this.afterShiftCells = this._getGapCells( gapX, 0, 1 );
+};
+
+Flickity.prototype._getGapCells = function( gapX, cellIndex, increment ) {
+ // keep adding cells until the cover the initial gap
+ var cells = [];
+ while ( gapX > 0 ) {
+ var cell = this.cells[ cellIndex ];
+ if ( !cell ) {
+ break;
+ }
+ cells.push( cell );
+ cellIndex += increment;
+ gapX -= cell.size.outerWidth;
+ }
+ return cells;
+};
+
+// ----- contain ----- //
+
+// contain cell targets so no excess sliding
+Flickity.prototype._containCells = function() {
+ if ( !this.options.contain || this.options.wrapAround || !this.cells.length ) {
+ return;
+ }
+ var startMargin = this.options.rightToLeft ? 'marginRight' : 'marginLeft';
+ var endMargin = this.options.rightToLeft ? 'marginLeft' : 'marginRight';
+ var firstCellStartMargin = this.cells[0].size[ startMargin ];
+ var lastCell = this.getLastCell();
+ var contentWidth = this.slideableWidth - lastCell.size[ endMargin ];
+ var endLimit = contentWidth - this.size.innerWidth * ( 1 - this.cellAlign );
+ // content is less than gallery size
+ var isContentSmaller = contentWidth < this.size.innerWidth;
+ // contain each cell target
+ for ( var i=0, len = this.cells.length; i < len; i++ ) {
+ var cell = this.cells[i];
+ // reset default target
+ cell.setDefaultTarget();
+ if ( isContentSmaller ) {
+ // all cells fit inside gallery
+ cell.target = contentWidth * this.cellAlign;
+ } else {
+ // contain to bounds
+ cell.target = Math.max( cell.target, this.cursorPosition + firstCellStartMargin );
+ cell.target = Math.min( cell.target, endLimit );
+ }
+ }
+};
+
+// ----- ----- //
+
+/**
+ * emits events via eventEmitter and jQuery events
+ * @param {String} type - name of event
+ * @param {Event} event - original event
+ * @param {Array} args - extra arguments
+ */
+Flickity.prototype.dispatchEvent = function( type, event, args ) {
+ var emitArgs = [ event ].concat( args );
+ this.emitEvent( type, emitArgs );
+
+ if ( jQuery && this.$element ) {
+ if ( event ) {
+ // create jQuery event
+ var $event = jQuery.Event( event );
+ $event.type = type;
+ this.$element.trigger( $event, args );
+ } else {
+ // just trigger with type if no event available
+ this.$element.trigger( type, args );
+ }
+ }
+};
+
+// -------------------------- select -------------------------- //
+
+/**
+ * @param {Integer} index - index of the cell
+ * @param {Boolean} isWrap - will wrap-around to last/first if at the end
+ */
+Flickity.prototype.select = function( index, isWrap ) {
+ if ( !this.isActive ) {
+ return;
+ }
+ // wrap position so slider is within normal area
+ var len = this.cells.length;
+ if ( this.options.wrapAround && len > 1 ) {
+ if ( index < 0 ) {
+ this.x -= this.slideableWidth;
+ } else if ( index >= len ) {
+ this.x += this.slideableWidth;
+ }
+ }
+
+ if ( this.options.wrapAround || isWrap ) {
+ index = utils.modulo( index, len );
+ }
+
+ if ( this.cells[ index ] ) {
+ this.selectedIndex = index;
+ this.setSelectedCell();
+ this.startAnimation();
+ this.dispatchEvent('cellSelect');
+ }
+};
+
+Flickity.prototype.previous = function( isWrap ) {
+ this.select( this.selectedIndex - 1, isWrap );
+};
+
+Flickity.prototype.next = function( isWrap ) {
+ this.select( this.selectedIndex + 1, isWrap );
+};
+
+Flickity.prototype.setSelectedCell = function() {
+ this._removeSelectedCellClass();
+ this.selectedCell = this.cells[ this.selectedIndex ];
+ this.selectedElement = this.selectedCell.element;
+ classie.add( this.selectedElement, 'is-selected' );
+};
+
+Flickity.prototype._removeSelectedCellClass = function() {
+ if ( this.selectedCell ) {
+ classie.remove( this.selectedCell.element, 'is-selected' );
+ }
+};
+
+// -------------------------- get cells -------------------------- //
+
+/**
+ * get Flickity.Cell, given an Element
+ * @param {Element} elem
+ * @returns {Flickity.Cell} item
+ */
+Flickity.prototype.getCell = function( elem ) {
+ // loop through cells to get the one that matches
+ for ( var i=0, len = this.cells.length; i < len; i++ ) {
+ var cell = this.cells[i];
+ if ( cell.element == elem ) {
+ return cell;
+ }
+ }
+};
+
+/**
+ * get collection of Flickity.Cells, given Elements
+ * @param {Element, Array, NodeList} elems
+ * @returns {Array} cells - Flickity.Cells
+ */
+Flickity.prototype.getCells = function( elems ) {
+ elems = utils.makeArray( elems );
+ var cells = [];
+ for ( var i=0, len = elems.length; i < len; i++ ) {
+ var elem = elems[i];
+ var cell = this.getCell( elem );
+ if ( cell ) {
+ cells.push( cell );
+ }
+ }
+ return cells;
+};
+
+/**
+ * get cell elements
+ * @returns {Array} cellElems
+ */
+Flickity.prototype.getCellElements = function() {
+ var cellElems = [];
+ for ( var i=0, len = this.cells.length; i < len; i++ ) {
+ cellElems.push( this.cells[i].element );
+ }
+ return cellElems;
+};
+
+/**
+ * get parent cell from an element
+ * @param {Element} elem
+ * @returns {Flickit.Cell} cell
+ */
+Flickity.prototype.getParentCell = function( elem ) {
+ // first check if elem is cell
+ var cell = this.getCell( elem );
+ if ( cell ) {
+ return cell;
+ }
+ // try to get parent cell elem
+ elem = utils.getParent( elem, '.flickity-slider > *' );
+ return this.getCell( elem );
+};
+
+// -------------------------- events -------------------------- //
+
+Flickity.prototype.uiChange = function() {
+ this.emit('uiChange');
+};
+
+Flickity.prototype.childUIPointerDown = function( event ) {
+ this.emitEvent( 'childUIPointerDown', [ event ] );
+};
+
+// ----- resize ----- //
+
+Flickity.prototype.onresize = function() {
+ this.watchCSS();
+ this.resize();
+};
+
+utils.debounceMethod( Flickity, 'onresize', 150 );
+
+Flickity.prototype.resize = function() {
+ if ( !this.isActive ) {
+ return;
+ }
+ this.getSize();
+ // wrap values
+ if ( this.options.wrapAround ) {
+ this.x = utils.modulo( this.x, this.slideableWidth );
+ }
+ this.positionCells();
+ this._getWrapShiftCells();
+ this.setGallerySize();
+ this.positionSliderAtSelected();
+};
+
+var supportsConditionalCSS = Flickity.supportsConditionalCSS = ( function() {
+ var supports;
+ return function checkSupport() {
+ if ( supports !== undefined ) {
+ return supports;
+ }
+ if ( !getComputedStyle ) {
+ supports = false;
+ return;
+ }
+ // style body's :after and check that
+ var style = document.createElement('style');
+ var cssText = document.createTextNode('body:after { content: "foo"; display: none; }');
+ style.appendChild( cssText );
+ document.head.appendChild( style );
+ var afterContent = getComputedStyle( document.body, ':after' ).content;
+ // check if able to get :after content
+ supports = afterContent.indexOf('foo') != -1;
+ document.head.removeChild( style );
+ return supports;
+ };
+})();
+
+// watches the :after property, activates/deactivates
+Flickity.prototype.watchCSS = function() {
+ var watchOption = this.options.watchCSS;
+ if ( !watchOption ) {
+ return;
+ }
+ var supports = supportsConditionalCSS();
+ if ( !supports ) {
+ // activate if watch option is fallbackOn
+ var method = watchOption == 'fallbackOn' ? 'activate' : 'deactivate';
+ this[ method ]();
+ return;
+ }
+
+ var afterContent = getComputedStyle( this.element, ':after' ).content;
+ // activate if :after { content: 'flickity' }
+ if ( afterContent.indexOf('flickity') != -1 ) {
+ this.activate();
+ } else {
+ this.deactivate();
+ }
+};
+
+// ----- keydown ----- //
+
+// go previous/next if left/right keys pressed
+Flickity.prototype.onkeydown = function( event ) {
+ // only work if element is in focus
+ if ( !this.options.accessibility ||
+ ( document.activeElement && document.activeElement != this.element ) ) {
+ return;
+ }
+
+ if ( event.keyCode == 37 ) {
+ // go left
+ var leftMethod = this.options.rightToLeft ? 'next' : 'previous';
+ this.uiChange();
+ this[ leftMethod ]();
+ } else if ( event.keyCode == 39 ) {
+ // go right
+ var rightMethod = this.options.rightToLeft ? 'previous' : 'next';
+ this.uiChange();
+ this[ rightMethod ]();
+ }
+};
+
+// -------------------------- destroy -------------------------- //
+
+// deactivate all Flickity functionality, but keep stuff available
+Flickity.prototype.deactivate = function() {
+ if ( !this.isActive ) {
+ return;
+ }
+ classie.remove( this.element, 'flickity-enabled' );
+ classie.remove( this.element, 'flickity-rtl' );
+ // destroy cells
+ for ( var i=0, len = this.cells.length; i < len; i++ ) {
+ var cell = this.cells[i];
+ cell.destroy();
+ }
+ this._removeSelectedCellClass();
+ this.element.removeChild( this.viewport );
+ // move child elements back into element
+ moveElements( this.slider.children, this.element );
+ if ( this.options.accessibility ) {
+ this.element.removeAttribute('tabIndex');
+ eventie.unbind( this.element, 'keydown', this );
+ }
+ // set flags
+ this.isActive = false;
+ this.emit('deactivate');
+};
+
+Flickity.prototype.destroy = function() {
+ this.deactivate();
+ if ( this.isResizeBound ) {
+ eventie.unbind( window, 'resize', this );
+ }
+ this.emit('destroy');
+ if ( jQuery && this.$element ) {
+ jQuery.removeData( this.element, 'flickity' );
+ }
+ delete this.element.flickityGUID;
+ delete instances[ this.guid ];
+};
+
+// -------------------------- prototype -------------------------- //
+
+utils.extend( Flickity.prototype, animatePrototype );
+
+// -------------------------- extras -------------------------- //
+
+// quick check for IE8
+var isIE8 = 'attachEvent' in window;
+
+Flickity.setUnselectable = function( elem ) {
+ if ( !isIE8 ) {
+ return;
+ }
+ // IE8 prevent child from changing focus http://stackoverflow.com/a/17525223/182183
+ elem.setAttribute( 'unselectable', 'on' );
+};
+
+/**
+ * get Flickity instance from element
+ * @param {Element} elem
+ * @returns {Flickity}
+ */
+Flickity.data = function( elem ) {
+ elem = utils.getQueryElement( elem );
+ var id = elem && elem.flickityGUID;
+ return id && instances[ id ];
+};
+
+utils.htmlInit( Flickity, 'flickity' );
+
+if ( jQuery && jQuery.bridget ) {
+ jQuery.bridget( 'flickity', Flickity );
+}
+
+Flickity.Cell = Cell;
+
+return Flickity;
+
+}));
+
+/*!
+ * Unipointer v1.1.0
+ * base class for doing one thing with pointer event
+ * MIT license
+ */
+
+/*jshint browser: true, undef: true, unused: true, strict: true */
+/*global define: false, module: false, require: false */
+
+( function( window, factory ) {
+
+ // universal module definition
+
+ if ( typeof define == 'function' && define.amd ) {
+ // AMD
+ define( 'unipointer/unipointer',[
+ 'eventEmitter/EventEmitter',
+ 'eventie/eventie'
+ ], function( EventEmitter, eventie ) {
+ return factory( window, EventEmitter, eventie );
+ });
+ } else if ( typeof exports == 'object' ) {
+ // CommonJS
+ module.exports = factory(
+ window,
+ require('wolfy87-eventemitter'),
+ require('eventie')
+ );
+ } else {
+ // browser global
+ window.Unipointer = factory(
+ window,
+ window.EventEmitter,
+ window.eventie
+ );
+ }
+
+}( window, function factory( window, EventEmitter, eventie ) {
+
+
+
+function noop() {}
+
+function Unipointer() {}
+
+// inherit EventEmitter
+Unipointer.prototype = new EventEmitter();
+
+Unipointer.prototype.bindStartEvent = function( elem ) {
+ this._bindStartEvent( elem, true );
+};
+
+Unipointer.prototype.unbindStartEvent = function( elem ) {
+ this._bindStartEvent( elem, false );
+};
+
+/**
+ * works as unbinder, as you can ._bindStart( false ) to unbind
+ * @param {Boolean} isBind - will unbind if falsey
+ */
+Unipointer.prototype._bindStartEvent = function( elem, isBind ) {
+ // munge isBind, default to true
+ isBind = isBind === undefined ? true : !!isBind;
+ var bindMethod = isBind ? 'bind' : 'unbind';
+
+ if ( window.navigator.pointerEnabled ) {
+ // W3C Pointer Events, IE11. See https://coderwall.com/p/mfreca
+ eventie[ bindMethod ]( elem, 'pointerdown', this );
+ } else if ( window.navigator.msPointerEnabled ) {
+ // IE10 Pointer Events
+ eventie[ bindMethod ]( elem, 'MSPointerDown', this );
+ } else {
+ // listen for both, for devices like Chrome Pixel
+ eventie[ bindMethod ]( elem, 'mousedown', this );
+ eventie[ bindMethod ]( elem, 'touchstart', this );
+ }
+};
+
+// trigger handler methods for events
+Unipointer.prototype.handleEvent = function( event ) {
+ var method = 'on' + event.type;
+ if ( this[ method ] ) {
+ this[ method ]( event );
+ }
+};
+
+// returns the touch that we're keeping track of
+Unipointer.prototype.getTouch = function( touches ) {
+ for ( var i=0, len = touches.length; i < len; i++ ) {
+ var touch = touches[i];
+ if ( touch.identifier == this.pointerIdentifier ) {
+ return touch;
+ }
+ }
+};
+
+// ----- start event ----- //
+
+Unipointer.prototype.onmousedown = function( event ) {
+ // dismiss clicks from right or middle buttons
+ var button = event.button;
+ if ( button && ( button !== 0 && button !== 1 ) ) {
+ return;
+ }
+ this._pointerDown( event, event );
+};
+
+Unipointer.prototype.ontouchstart = function( event ) {
+ this._pointerDown( event, event.changedTouches[0] );
+};
+
+Unipointer.prototype.onMSPointerDown =
+Unipointer.prototype.onpointerdown = function( event ) {
+ this._pointerDown( event, event );
+};
+
+/**
+ * pointer start
+ * @param {Event} event
+ * @param {Event or Touch} pointer
+ */
+Unipointer.prototype._pointerDown = function( event, pointer ) {
+ // dismiss other pointers
+ if ( this.isPointerDown ) {
+ return;
+ }
+
+ this.isPointerDown = true;
+ // save pointer identifier to match up touch events
+ this.pointerIdentifier = pointer.pointerId !== undefined ?
+ // pointerId for pointer events, touch.indentifier for touch events
+ pointer.pointerId : pointer.identifier;
+
+ this.pointerDown( event, pointer );
+};
+
+Unipointer.prototype.pointerDown = function( event, pointer ) {
+ this._bindPostStartEvents( event );
+ this.emitEvent( 'pointerDown', [ event, pointer ] );
+};
+
+// hash of events to be bound after start event
+var postStartEvents = {
+ mousedown: [ 'mousemove', 'mouseup' ],
+ touchstart: [ 'touchmove', 'touchend', 'touchcancel' ],
+ pointerdown: [ 'pointermove', 'pointerup', 'pointercancel' ],
+ MSPointerDown: [ 'MSPointerMove', 'MSPointerUp', 'MSPointerCancel' ]
+};
+
+Unipointer.prototype._bindPostStartEvents = function( event ) {
+ if ( !event ) {
+ return;
+ }
+ // get proper events to match start event
+ var events = postStartEvents[ event.type ];
+ // IE8 needs to be bound to document
+ var node = event.preventDefault ? window : document;
+ // bind events to node
+ for ( var i=0, len = events.length; i < len; i++ ) {
+ var evnt = events[i];
+ eventie.bind( node, evnt, this );
+ }
+ // save these arguments
+ this._boundPointerEvents = {
+ events: events,
+ node: node
+ };
+};
+
+Unipointer.prototype._unbindPostStartEvents = function() {
+ var args = this._boundPointerEvents;
+ // IE8 can trigger dragEnd twice, check for _boundEvents
+ if ( !args || !args.events ) {
+ return;
+ }
+
+ for ( var i=0, len = args.events.length; i < len; i++ ) {
+ var event = args.events[i];
+ eventie.unbind( args.node, event, this );
+ }
+ delete this._boundPointerEvents;
+};
+
+// ----- move event ----- //
+
+Unipointer.prototype.onmousemove = function( event ) {
+ this._pointerMove( event, event );
+};
+
+Unipointer.prototype.onMSPointerMove =
+Unipointer.prototype.onpointermove = function( event ) {
+ if ( event.pointerId == this.pointerIdentifier ) {
+ this._pointerMove( event, event );
+ }
+};
+
+Unipointer.prototype.ontouchmove = function( event ) {
+ var touch = this.getTouch( event.changedTouches );
+ if ( touch ) {
+ this._pointerMove( event, touch );
+ }
+};
+
+/**
+ * pointer move
+ * @param {Event} event
+ * @param {Event or Touch} pointer
+ * @private
+ */
+Unipointer.prototype._pointerMove = function( event, pointer ) {
+ this.pointerMove( event, pointer );
+};
+
+// public
+Unipointer.prototype.pointerMove = function( event, pointer ) {
+ this.emitEvent( 'pointerMove', [ event, pointer ] );
+};
+
+// ----- end event ----- //
+
+
+Unipointer.prototype.onmouseup = function( event ) {
+ this._pointerUp( event, event );
+};
+
+Unipointer.prototype.onMSPointerUp =
+Unipointer.prototype.onpointerup = function( event ) {
+ if ( event.pointerId == this.pointerIdentifier ) {
+ this._pointerUp( event, event );
+ }
+};
+
+Unipointer.prototype.ontouchend = function( event ) {
+ var touch = this.getTouch( event.changedTouches );
+ if ( touch ) {
+ this._pointerUp( event, touch );
+ }
+};
+
+/**
+ * pointer up
+ * @param {Event} event
+ * @param {Event or Touch} pointer
+ * @private
+ */
+Unipointer.prototype._pointerUp = function( event, pointer ) {
+ this._pointerDone();
+ this.pointerUp( event, pointer );
+};
+
+// public
+Unipointer.prototype.pointerUp = function( event, pointer ) {
+ this.emitEvent( 'pointerUp', [ event, pointer ] );
+};
+
+// ----- pointer done ----- //
+
+// triggered on pointer up & pointer cancel
+Unipointer.prototype._pointerDone = function() {
+ // reset properties
+ this.isPointerDown = false;
+ delete this.pointerIdentifier;
+ // remove events
+ this._unbindPostStartEvents();
+ this.pointerDone();
+};
+
+Unipointer.prototype.pointerDone = noop;
+
+// ----- pointer cancel ----- //
+
+Unipointer.prototype.onMSPointerCancel =
+Unipointer.prototype.onpointercancel = function( event ) {
+ if ( event.pointerId == this.pointerIdentifier ) {
+ this._pointerCancel( event, event );
+ }
+};
+
+Unipointer.prototype.ontouchcancel = function( event ) {
+ var touch = this.getTouch( event.changedTouches );
+ if ( touch ) {
+ this._pointerCancel( event, touch );
+ }
+};
+
+/**
+ * pointer cancel
+ * @param {Event} event
+ * @param {Event or Touch} pointer
+ * @private
+ */
+Unipointer.prototype._pointerCancel = function( event, pointer ) {
+ this._pointerDone();
+ this.pointerCancel( event, pointer );
+};
+
+// public
+Unipointer.prototype.pointerCancel = function( event, pointer ) {
+ this.emitEvent( 'pointerCancel', [ event, pointer ] );
+};
+
+// ----- ----- //
+
+// utility function for getting x/y cooridinates from event, because IE8
+Unipointer.getPointerPoint = function( pointer ) {
+ return {
+ x: pointer.pageX !== undefined ? pointer.pageX : pointer.clientX,
+ y: pointer.pageY !== undefined ? pointer.pageY : pointer.clientY
+ };
+};
+
+// ----- ----- //
+
+return Unipointer;
+
+}));
+
+/*!
+ * Unidragger v1.1.3
+ * Draggable base class
+ * MIT license
+ */
+
+/*jshint browser: true, unused: true, undef: true, strict: true */
+
+( function( window, factory ) {
+ /*global define: false, module: false, require: false */
+
+ // universal module definition
+
+ if ( typeof define == 'function' && define.amd ) {
+ // AMD
+ define( 'unidragger/unidragger',[
+ 'eventie/eventie',
+ 'unipointer/unipointer'
+ ], function( eventie, Unipointer ) {
+ return factory( window, eventie, Unipointer );
+ });
+ } else if ( typeof exports == 'object' ) {
+ // CommonJS
+ module.exports = factory(
+ window,
+ require('eventie'),
+ require('unipointer')
+ );
+ } else {
+ // browser global
+ window.Unidragger = factory(
+ window,
+ window.eventie,
+ window.Unipointer
+ );
+ }
+
+}( window, function factory( window, eventie, Unipointer ) {
+
+
+
+// ----- ----- //
+
+function noop() {}
+
+// handle IE8 prevent default
+function preventDefaultEvent( event ) {
+ if ( event.preventDefault ) {
+ event.preventDefault();
+ } else {
+ event.returnValue = false;
+ }
+}
+
+// -------------------------- Unidragger -------------------------- //
+
+function Unidragger() {}
+
+// inherit Unipointer & EventEmitter
+Unidragger.prototype = new Unipointer();
+
+// ----- bind start ----- //
+
+Unidragger.prototype.bindHandles = function() {
+ this._bindHandles( true );
+};
+
+Unidragger.prototype.unbindHandles = function() {
+ this._bindHandles( false );
+};
+
+var navigator = window.navigator;
+/**
+ * works as unbinder, as you can .bindHandles( false ) to unbind
+ * @param {Boolean} isBind - will unbind if falsey
+ */
+Unidragger.prototype._bindHandles = function( isBind ) {
+ // munge isBind, default to true
+ isBind = isBind === undefined ? true : !!isBind;
+ // extra bind logic
+ var binderExtra;
+ if ( navigator.pointerEnabled ) {
+ binderExtra = function( handle ) {
+ // disable scrolling on the element
+ handle.style.touchAction = isBind ? 'none' : '';
+ };
+ } else if ( navigator.msPointerEnabled ) {
+ binderExtra = function( handle ) {
+ // disable scrolling on the element
+ handle.style.msTouchAction = isBind ? 'none' : '';
+ };
+ } else {
+ binderExtra = function() {
+ // TODO re-enable img.ondragstart when unbinding
+ if ( isBind ) {
+ disableImgOndragstart( handle );
+ }
+ };
+ }
+ // bind each handle
+ var bindMethod = isBind ? 'bind' : 'unbind';
+ for ( var i=0, len = this.handles.length; i < len; i++ ) {
+ var handle = this.handles[i];
+ this._bindStartEvent( handle, isBind );
+ binderExtra( handle );
+ eventie[ bindMethod ]( handle, 'click', this );
+ }
+};
+
+// remove default dragging interaction on all images in IE8
+// IE8 does its own drag thing on images, which messes stuff up
+
+function noDragStart() {
+ return false;
+}
+
+// TODO replace this with a IE8 test
+var isIE8 = 'attachEvent' in document.documentElement;
+
+// IE8 only
+var disableImgOndragstart = !isIE8 ? noop : function( handle ) {
+
+ if ( handle.nodeName == 'IMG' ) {
+ handle.ondragstart = noDragStart;
+ }
+
+ var images = handle.querySelectorAll('img');
+ for ( var i=0, len = images.length; i < len; i++ ) {
+ var img = images[i];
+ img.ondragstart = noDragStart;
+ }
+};
+
+// ----- start event ----- //
+
+/**
+ * pointer start
+ * @param {Event} event
+ * @param {Event or Touch} pointer
+ */
+Unidragger.prototype.pointerDown = function( event, pointer ) {
+ this._dragPointerDown( event, pointer );
+ // kludge to blur focused inputs in dragger
+ var focused = document.activeElement;
+ if ( focused && focused.blur ) {
+ focused.blur();
+ }
+ // bind move and end events
+ this._bindPostStartEvents( event );
+ this.emitEvent( 'pointerDown', [ event, pointer ] );
+};
+
+// base pointer down logic
+Unidragger.prototype._dragPointerDown = function( event, pointer ) {
+ // track to see when dragging starts
+ this.pointerDownPoint = Unipointer.getPointerPoint( pointer );
+
+ // prevent default, unless touchstart or <select>
+ var isTouchstart = event.type == 'touchstart';
+ var targetNodeName = event.target.nodeName;
+ if ( !isTouchstart && targetNodeName != 'SELECT' ) {
+ preventDefaultEvent( event );
+ }
+};
+
+// ----- move event ----- //
+
+/**
+ * drag move
+ * @param {Event} event
+ * @param {Event or Touch} pointer
+ */
+Unidragger.prototype.pointerMove = function( event, pointer ) {
+ var moveVector = this._dragPointerMove( event, pointer );
+ this.emitEvent( 'pointerMove', [ event, pointer, moveVector ] );
+ this._dragMove( event, pointer, moveVector );
+};
+
+// base pointer move logic
+Unidragger.prototype._dragPointerMove = function( event, pointer ) {
+ var movePoint = Unipointer.getPointerPoint( pointer );
+ var moveVector = {
+ x: movePoint.x - this.pointerDownPoint.x,
+ y: movePoint.y - this.pointerDownPoint.y
+ };
+ // start drag if pointer has moved far enough to start drag
+ if ( !this.isDragging && this.hasDragStarted( moveVector ) ) {
+ this._dragStart( event, pointer );
+ }
+ return moveVector;
+};
+
+// condition if pointer has moved far enough to start drag
+Unidragger.prototype.hasDragStarted = function( moveVector ) {
+ return Math.abs( moveVector.x ) > 3 || Math.abs( moveVector.y ) > 3;
+};
+
+
+// ----- end event ----- //
+
+/**
+ * pointer up
+ * @param {Event} event
+ * @param {Event or Touch} pointer
+ */
+Unidragger.prototype.pointerUp = function( event, pointer ) {
+ this.emitEvent( 'pointerUp', [ event, pointer ] );
+ this._dragPointerUp( event, pointer );
+};
+
+Unidragger.prototype._dragPointerUp = function( event, pointer ) {
+ if ( this.isDragging ) {
+ this._dragEnd( event, pointer );
+ } else {
+ // pointer didn't move enough for drag to start
+ this._staticClick( event, pointer );
+ }
+};
+
+// -------------------------- drag -------------------------- //
+
+// dragStart
+Unidragger.prototype._dragStart = function( event, pointer ) {
+ this.isDragging = true;
+ this.dragStartPoint = Unidragger.getPointerPoint( pointer );
+ // prevent clicks
+ this.isPreventingClicks = true;
+
+ this.dragStart( event, pointer );
+};
+
+Unidragger.prototype.dragStart = function( event, pointer ) {
+ this.emitEvent( 'dragStart', [ event, pointer ] );
+};
+
+// dragMove
+Unidragger.prototype._dragMove = function( event, pointer, moveVector ) {
+ // do not drag if not dragging yet
+ if ( !this.isDragging ) {
+ return;
+ }
+
+ this.dragMove( event, pointer, moveVector );
+};
+
+Unidragger.prototype.dragMove = function( event, pointer, moveVector ) {
+ preventDefaultEvent( event );
+ this.emitEvent( 'dragMove', [ event, pointer, moveVector ] );
+};
+
+// dragEnd
+Unidragger.prototype._dragEnd = function( event, pointer ) {
+ // set flags
+ this.isDragging = false;
+ // re-enable clicking async
+ var _this = this;
+ setTimeout( function() {
+ delete _this.isPreventingClicks;
+ });
+
+ this.dragEnd( event, pointer );
+};
+
+Unidragger.prototype.dragEnd = function( event, pointer ) {
+ this.emitEvent( 'dragEnd', [ event, pointer ] );
+};
+
+// ----- onclick ----- //
+
+// handle all clicks and prevent clicks when dragging
+Unidragger.prototype.onclick = function( event ) {
+ if ( this.isPreventingClicks ) {
+ preventDefaultEvent( event );
+ }
+};
+
+// ----- staticClick ----- //
+
+// triggered after pointer down & up with no/tiny movement
+Unidragger.prototype._staticClick = function( event, pointer ) {
+ // allow click in <input>s and <textarea>s
+ var nodeName = event.target.nodeName;
+ if ( nodeName == 'INPUT' || nodeName == 'TEXTAREA' ) {
+ event.target.focus();
+ }
+ this.staticClick( event, pointer );
+};
+
+Unidragger.prototype.staticClick = function( event, pointer ) {
+ this.emitEvent( 'staticClick', [ event, pointer ] );
+};
+
+// ----- ----- //
+
+Unidragger.getPointerPoint = function( pointer ) {
+ return {
+ x: pointer.pageX !== undefined ? pointer.pageX : pointer.clientX,
+ y: pointer.pageY !== undefined ? pointer.pageY : pointer.clientY
+ };
+};
+
+// ----- ----- //
+
+Unidragger.getPointerPoint = Unipointer.getPointerPoint;
+
+return Unidragger;
+
+}));
+
+( function( window, factory ) {
+
+ // universal module definition
+
+ if ( typeof define == 'function' && define.amd ) {
+ // AMD
+ define( 'flickity/js/drag',[
+ 'classie/classie',
+ 'eventie/eventie',
+ './flickity',
+ 'unidragger/unidragger',
+ 'fizzy-ui-utils/utils'
+ ], function( classie, eventie, Flickity, Unidragger, utils ) {
+ return factory( window, classie, eventie, Flickity, Unidragger, utils );
+ });
+ } else if ( typeof exports == 'object' ) {
+ // CommonJS
+ module.exports = factory(
+ window,
+ require('desandro-classie'),
+ require('eventie'),
+ require('./flickity'),
+ require('unidragger'),
+ require('fizzy-ui-utils')
+ );
+ } else {
+ // browser global
+ window.Flickity = window.Flickity || {};
+ window.Flickity.dragPrototype = factory(
+ window,
+ window.classie,
+ window.eventie,
+ window.Flickity,
+ window.Unidragger,
+ window.fizzyUIUtils
+ );
+ }
+
+}( window, function factory( window, classie, eventie, Flickity, Unidragger, utils ) {
+
+
+
+// handle IE8 prevent default
+function preventDefaultEvent( event ) {
+ if ( event.preventDefault ) {
+ event.preventDefault();
+ } else {
+ event.returnValue = false;
+ }
+}
+
+// ----- defaults ----- //
+
+utils.extend( Flickity.defaults, {
+ draggable: true,
+ touchVerticalScroll: true
+});
+
+// ----- create ----- //
+
+Flickity.createMethods.push('_createDrag');
+
+// -------------------------- drag prototype -------------------------- //
+
+var proto = {};
+utils.extend( proto, Unidragger.prototype );
+
+// -------------------------- -------------------------- //
+
+proto._createDrag = function() {
+ this.on( 'activate', this.bindDrag );
+ this.on( 'uiChange', this._uiChangeDrag );
+ this.on( 'childUIPointerDown', this._childUIPointerDownDrag );
+ this.on( 'deactivate', this.unbindDrag );
+};
+
+proto.bindDrag = function() {
+ if ( !this.options.draggable || this.isDragBound ) {
+ return;
+ }
+ classie.add( this.element, 'is-draggable' );
+ this.handles = [ this.viewport ];
+ this.bindHandles();
+ this.isDragBound = true;
+};
+
+proto.unbindDrag = function() {
+ if ( !this.isDragBound ) {
+ return;
+ }
+ classie.remove( this.element, 'is-draggable' );
+ this.unbindHandles();
+ delete this.isDragBound;
+};
+
+proto._uiChangeDrag = function() {
+ delete this.isFreeScrolling;
+};
+
+proto._childUIPointerDownDrag = function( event ) {
+ preventDefaultEvent( event );
+ this.pointerDownFocus( event );
+};
+
+// -------------------------- pointer events -------------------------- //
+
+proto.pointerDown = function( event, pointer ) {
+ this._dragPointerDown( event, pointer );
+
+ // kludge to blur focused inputs in dragger
+ var focused = document.activeElement;
+ if ( focused && focused.blur && focused != this.element &&
+ // do not blur body for IE9 & 10, #117
+ focused != document.body ) {
+ focused.blur();
+ }
+ this.pointerDownFocus( event );
+ // stop if it was moving
+ this.velocity = 0;
+ classie.add( this.viewport, 'is-pointer-down' );
+ // bind move and end events
+ this._bindPostStartEvents( event );
+ this.dispatchEvent( 'pointerDown', event, [ pointer ] );
+};
+
+var touchStartEvents = {
+ touchstart: true,
+ MSPointerDown: true
+};
+
+var focusNodes = {
+ INPUT: true,
+ SELECT: true
+};
+
+proto.pointerDownFocus = function( event ) {
+ // focus element, if not touch, and its not an input or select
+ if ( this.options.accessibility && !touchStartEvents[ event.type ] &&
+ !focusNodes[ event.target.nodeName ] ) {
+ this.element.focus();
+ }
+};
+
+// ----- move ----- //
+
+proto.pointerMove = function( event, pointer ) {
+ var moveVector = this._dragPointerMove( event, pointer );
+ this.touchVerticalScrollMove( event, pointer, moveVector );
+ this._dragMove( event, pointer, moveVector );
+ this.dispatchEvent( 'pointerMove', event, [ pointer, moveVector ] );
+};
+
+proto.hasDragStarted = function( moveVector ) {
+ return !this.isTouchScrolling && Math.abs( moveVector.x ) > 3;
+};
+
+// ----- up ----- //
+
+proto.pointerUp = function( event, pointer ) {
+ delete this.isTouchScrolling;
+ classie.remove( this.viewport, 'is-pointer-down' );
+ this.dispatchEvent( 'pointerUp', event, [ pointer ] );
+ this._dragPointerUp( event, pointer );
+};
+
+// -------------------------- vertical scroll -------------------------- //
+
+var touchScrollEvents = {
+ // move events
+ // mousemove: true,
+ touchmove: true,
+ MSPointerMove: true
+};
+
+// position of pointer, relative to window
+function getPointerWindowY( pointer ) {
+ var pointerPoint = Unidragger.getPointerPoint( pointer );
+ return pointerPoint.y - window.pageYOffset;
+}
+
+proto.touchVerticalScrollMove = function( event, pointer, moveVector ) {
+ // do not scroll if already dragging, if disabled
+ var touchVerticalScroll = this.options.touchVerticalScroll;
+ // if touchVerticalScroll is 'withDrag', allow scrolling and dragging
+ var canNotScroll = touchVerticalScroll == 'withDrag' ? !touchVerticalScroll :
+ this.isDragging || !touchVerticalScroll;
+ if ( canNotScroll || !touchScrollEvents[ event.type ] ) {
+ return;
+ }
+ // don't start vertical scrolling until pointer has moved 10 pixels in a direction
+ if ( !this.isTouchScrolling && Math.abs( moveVector.y ) > 10 ) {
+ // start touch vertical scrolling
+ // scroll & pointerY when started
+ this.startScrollY = window.pageYOffset;
+ this.pointerWindowStartY = getPointerWindowY( pointer );
+ // start scroll animation
+ this.isTouchScrolling = true;
+ }
+};
+
+// -------------------------- dragging -------------------------- //
+
+proto.dragStart = function( event, pointer ) {
+ this.dragStartPosition = this.x;
+ this.startAnimation();
+ this.dispatchEvent( 'dragStart', event, [ pointer ] );
+};
+
+proto.dragMove = function( event, pointer, moveVector ) {
+ preventDefaultEvent( event );
+
+ this.previousDragX = this.x;
+
+ var movedX = moveVector.x;
+ // reverse if right-to-left
+ var direction = this.options.rightToLeft ? -1 : 1;
+ this.x = this.dragStartPosition + movedX * direction;
+
+ if ( !this.options.wrapAround && this.cells.length ) {
+ // slow drag
+ var originBound = Math.max( -this.cells[0].target, this.dragStartPosition);
+ this.x = this.x > originBound ? ( this.x - originBound ) * 0.5 + originBound : this.x;
+ var endBound = Math.min( -this.getLastCell().target, this.dragStartPosition );
+ this.x = this.x < endBound ? ( this.x - endBound ) * 0.5 + endBound : this.x;
+ }
+
+ this.previousDragMoveTime = this.dragMoveTime;
+ this.dragMoveTime = new Date();
+ this.dispatchEvent( 'dragMove', event, [ pointer, moveVector ] );
+};
+
+proto.dragEnd = function( event, pointer ) {
+ this.dragEndFlick();
+ if ( this.options.freeScroll ) {
+ this.isFreeScrolling = true;
+ }
+ // set selectedIndex based on where flick will end up
+ var index = this.dragEndRestingSelect();
+
+ if ( this.options.freeScroll && !this.options.wrapAround ) {
+ // if free-scroll & not wrap around
+ // do not free-scroll if going outside of bounding cells
+ // so bounding cells can attract slider, and keep it in bounds
+ var restingX = this.getRestingPosition();
+ this.isFreeScrolling = -restingX > this.cells[0].target &&
+ -restingX < this.getLastCell().target;
+ } else if ( !this.options.freeScroll && index == this.selectedIndex ) {
+ // boost selection if selected index has not changed
+ index += this.dragEndBoostSelect();
+ }
+ // apply selection
+ // TODO refactor this, selecting here feels weird
+ this.select( index );
+ this.dispatchEvent( 'dragEnd', event, [ pointer ] );
+};
+
+// apply velocity after dragging
+proto.dragEndFlick = function() {
+ if ( !isFinite( this.previousDragX ) ) {
+ return;
+ }
+ // set slider velocity
+ var timeDelta = this.dragMoveTime - this.previousDragMoveTime;
+ // prevent divide by 0, if dragMove & dragEnd happened at same time
+ if ( timeDelta ) {
+ // 60 frames per second, ideally
+ // TODO, velocity should be in pixels per millisecond
+ // currently in pixels per frame
+ timeDelta /= 1000 / 60;
+ var xDelta = this.x - this.previousDragX;
+ this.velocity = xDelta / timeDelta;
+ }
+ // reset
+ delete this.previousDragX;
+};
+
+proto.dragEndRestingSelect = function() {
+ var restingX = this.getRestingPosition();
+ // how far away from selected cell
+ var distance = Math.abs( this.getCellDistance( -restingX, this.selectedIndex ) );
+ // get closet resting going up and going down
+ var positiveResting = this._getClosestResting( restingX, distance, 1 );
+ var negativeResting = this._getClosestResting( restingX, distance, -1 );
+ // use closer resting for wrap-around
+ var index = positiveResting.distance < negativeResting.distance ?
+ positiveResting.index : negativeResting.index;
+ // for contain, force boost if delta is not greater than 1
+ if ( this.options.contain && !this.options.wrapAround ) {
+ index = Math.abs( index - this.selectedIndex ) <= 1 ? this.selectedIndex : index;
+ }
+ return index;
+};
+
+/**
+ * given resting X and distance to selected cell
+ * get the distance and index of the closest cell
+ * @param {Number} restingX - estimated post-flick resting position
+ * @param {Number} distance - distance to selected cell
+ * @param {Integer} increment - +1 or -1, going up or down
+ * @returns {Object} - { distance: {Number}, index: {Integer} }
+ */
+proto._getClosestResting = function( restingX, distance, increment ) {
+ var index = this.selectedIndex;
+ var minDistance = Infinity;
+ var condition = this.options.contain && !this.options.wrapAround ?
+ // if contain, keep going if distance is equal to minDistance
+ function( d, md ) { return d <= md; } : function( d, md ) { return d < md; };
+ while ( condition( distance, minDistance ) ) {
+ // measure distance to next cell
+ index += increment;
+ minDistance = distance;
+ distance = this.getCellDistance( -restingX, index );
+ if ( distance === null ) {
+ break;
+ }
+ distance = Math.abs( distance );
+ }
+ return {
+ distance: minDistance,
+ // selected was previous index
+ index: index - increment
+ };
+};
+
+/**
+ * measure distance between x and a cell target
+ * @param {Number} x
+ * @param {Integer} index - cell index
+ */
+proto.getCellDistance = function( x, index ) {
+ var len = this.cells.length;
+ // wrap around if at least 2 cells
+ var isWrapAround = this.options.wrapAround && len > 1;
+ var cellIndex = isWrapAround ? utils.modulo( index, len ) : index;
+ var cell = this.cells[ cellIndex ];
+ if ( !cell ) {
+ return null;
+ }
+ // add distance for wrap-around cells
+ var wrap = isWrapAround ? this.slideableWidth * Math.floor( index / len ) : 0;
+ return x - ( cell.target + wrap );
+};
+
+proto.dragEndBoostSelect = function() {
+ var distance = this.getCellDistance( -this.x, this.selectedIndex );
+ if ( distance > 0 && this.velocity < -1 ) {
+ // if moving towards the right, and positive velocity, and the next attractor
+ return 1;
+ } else if ( distance < 0 && this.velocity > 1 ) {
+ // if moving towards the left, and negative velocity, and previous attractor
+ return -1;
+ }
+ return 0;
+};
+
+// ----- staticClick ----- //
+
+proto.staticClick = function( event, pointer ) {
+ // get clickedCell, if cell was clicked
+ var clickedCell = this.getParentCell( event.target );
+ var cellElem = clickedCell && clickedCell.element;
+ var cellIndex = clickedCell && utils.indexOf( this.cells, clickedCell );
+ this.dispatchEvent( 'staticClick', event, [ pointer, cellElem, cellIndex ] );
+};
+
+// ----- ----- //
+
+utils.extend( Flickity.prototype, proto );
+
+// ----- ----- //
+
+return Flickity;
+
+}));
+
+/*!
+ * Tap listener v1.1.0
+ * listens to taps
+ * MIT license
+ */
+
+/*jshint browser: true, unused: true, undef: true, strict: true */
+
+( function( window, factory ) {
+ /*global define: false, module: false, require: false */
+
+ // universal module definition
+
+ if ( typeof define == 'function' && define.amd ) {
+ // AMD
+ define( 'tap-listener/tap-listener',[
+ 'unipointer/unipointer'
+ ], function( Unipointer ) {
+ return factory( window, Unipointer );
+ });
+ } else if ( typeof exports == 'object' ) {
+ // CommonJS
+ module.exports = factory(
+ window,
+ require('unipointer')
+ );
+ } else {
+ // browser global
+ window.TapListener = factory(
+ window,
+ window.Unipointer
+ );
+ }
+
+}( window, function factory( window, Unipointer ) {
+
+
+
+// -------------------------- TapListener -------------------------- //
+
+function TapListener( elem ) {
+ this.bindTap( elem );
+}
+
+// inherit Unipointer & EventEmitter
+TapListener.prototype = new Unipointer();
+
+/**
+ * bind tap event to element
+ * @param {Element} elem
+ */
+TapListener.prototype.bindTap = function( elem ) {
+ if ( !elem ) {
+ return;
+ }
+ this.unbindTap();
+ this.tapElement = elem;
+ this._bindStartEvent( elem, true );
+};
+
+TapListener.prototype.unbindTap = function() {
+ if ( !this.tapElement ) {
+ return;
+ }
+ this._bindStartEvent( this.tapElement, true );
+ delete this.tapElement;
+};
+
+var isPageOffset = window.pageYOffset !== undefined;
+/**
+ * pointer up
+ * @param {Event} event
+ * @param {Event or Touch} pointer
+ */
+TapListener.prototype.pointerUp = function( event, pointer ) {
+ var pointerPoint = Unipointer.getPointerPoint( pointer );
+ var boundingRect = this.tapElement.getBoundingClientRect();
+ // standard or IE8 scroll positions
+ var scrollX = isPageOffset ? window.pageXOffset : document.body.scrollLeft;
+ var scrollY = isPageOffset ? window.pageYOffset : document.body.scrollTop;
+ // calculate if pointer is inside tapElement
+ var isInside = pointerPoint.x >= boundingRect.left + scrollX &&
+ pointerPoint.x <= boundingRect.right + scrollX &&
+ pointerPoint.y >= boundingRect.top + scrollY &&
+ pointerPoint.y <= boundingRect.bottom + scrollY;
+ // trigger callback if pointer is inside element
+ if ( isInside ) {
+ this.emitEvent( 'tap', [ event, pointer ] );
+ }
+};
+
+TapListener.prototype.destroy = function() {
+ this.pointerDone();
+ this.unbindTap();
+};
+
+// ----- ----- //
+
+return TapListener;
+
+}));
+
+// -------------------------- prev/next button -------------------------- //
+
+( function( window, factory ) {
+
+ // universal module definition
+
+ if ( typeof define == 'function' && define.amd ) {
+ // AMD
+ define( 'flickity/js/prev-next-button',[
+ 'eventie/eventie',
+ './flickity',
+ 'tap-listener/tap-listener',
+ 'fizzy-ui-utils/utils'
+ ], function( eventie, Flickity, TapListener, utils ) {
+ return factory( window, eventie, Flickity, TapListener, utils );
+ });
+ } else if ( typeof exports == 'object' ) {
+ // CommonJS
+ module.exports = factory(
+ window,
+ require('eventie'),
+ require('./flickity'),
+ require('tap-listener'),
+ require('fizzy-ui-utils')
+ );
+ } else {
+ // browser global
+ window.Flickity = window.Flickity || {};
+ window.Flickity.PrevNextButton = factory(
+ window,
+ window.eventie,
+ window.Flickity,
+ window.TapListener,
+ window.fizzyUIUtils
+ );
+ }
+
+}( window, function factory( window, eventie, Flickity, TapListener, utils ) {
+
+
+
+// ----- inline SVG support ----- //
+
+var svgURI = 'http://www.w3.org/2000/svg';
+
+// only check on demand, not on script load
+var supportsInlineSVG = ( function() {
+ var supports;
+ function checkSupport() {
+ if ( supports !== undefined ) {
+ return supports;
+ }
+ var div = document.createElement('div');
+ div.innerHTML = '<svg/>';
+ supports = ( div.firstChild && div.firstChild.namespaceURI ) == svgURI;
+ return supports;
+ }
+ return checkSupport;
+})();
+
+// -------------------------- PrevNextButton -------------------------- //
+
+function PrevNextButton( direction, parent ) {
+ this.direction = direction;
+ this.parent = parent;
+ this._create();
+}
+
+PrevNextButton.prototype = new TapListener();
+
+PrevNextButton.prototype._create = function() {
+ // properties
+ this.isEnabled = true;
+ this.isPrevious = this.direction == -1;
+ var leftDirection = this.parent.options.rightToLeft ? 1 : -1;
+ this.isLeft = this.direction == leftDirection;
+
+ var element = this.element = document.createElement('button');
+ element.className = 'flickity-prev-next-button';
+ element.className += this.isPrevious ? ' previous' : ' next';
+ // prevent button from submitting form http://stackoverflow.com/a/10836076/182183
+ element.setAttribute( 'type', 'button' );
+ Flickity.setUnselectable( element );
+ // create arrow
+ if ( supportsInlineSVG() ) {
+ var svg = this.createSVG();
+ element.appendChild( svg );
+ } else {
+ // SVG not supported, set button text
+ this.setArrowText();
+ element.className += ' no-svg';
+ }
+ // update on select
+ var _this = this;
+ this.onCellSelect = function() {
+ _this.update();
+ };
+ this.parent.on( 'cellSelect', this.onCellSelect );
+ // tap
+ this.on( 'tap', this.onTap );
+ // pointerDown
+ this.on( 'pointerDown', function onPointerDown( button, event ) {
+ _this.parent.childUIPointerDown( event );
+ });
+};
+
+PrevNextButton.prototype.activate = function() {
+ this.update();
+ this.bindTap( this.element );
+ // click events from keyboard
+ eventie.bind( this.element, 'click', this );
+ // add to DOM
+ this.parent.element.appendChild( this.element );
+};
+
+PrevNextButton.prototype.deactivate = function() {
+ // remove from DOM
+ this.parent.element.removeChild( this.element );
+ // do regular TapListener destroy
+ TapListener.prototype.destroy.call( this );
+ // click events from keyboard
+ eventie.unbind( this.element, 'click', this );
+};
+
+PrevNextButton.prototype.createSVG = function() {
+ var svg = document.createElementNS( svgURI, 'svg');
+ svg.setAttribute( 'viewBox', '0 0 100 100' );
+ var path = document.createElementNS( svgURI, 'path');
+ path.setAttribute( 'd', 'M 50,0 L 60,10 L 20,50 L 60,90 L 50,100 L 0,50 Z' );
+ path.setAttribute( 'class', 'arrow' );
+ // adjust arrow
+ var arrowTransform = this.isLeft ? 'translate(15,0)' :
+ 'translate(85,100) rotate(180)';
+ path.setAttribute( 'transform', arrowTransform );
+ svg.appendChild( path );
+ return svg;
+};
+
+PrevNextButton.prototype.setArrowText = function() {
+ var parentOptions = this.parent.options;
+ var arrowText = this.isLeft ? parentOptions.leftArrowText : parentOptions.rightArrowText;
+ utils.setText( this.element, arrowText );
+};
+
+PrevNextButton.prototype.onTap = function() {
+ if ( !this.isEnabled ) {
+ return;
+ }
+ this.parent.uiChange();
+ var method = this.isPrevious ? 'previous' : 'next';
+ this.parent[ method ]();
+};
+
+PrevNextButton.prototype.handleEvent = utils.handleEvent;
+
+PrevNextButton.prototype.onclick = function() {
+ // only allow clicks from keyboard
+ var focused = document.activeElement;
+ if ( focused && focused == this.element ) {
+ this.onTap();
+ }
+};
+
+// ----- ----- //
+
+PrevNextButton.prototype.enable = function() {
+ if ( this.isEnabled ) {
+ return;
+ }
+ this.element.disabled = false;
+ this.isEnabled = true;
+};
+
+PrevNextButton.prototype.disable = function() {
+ if ( !this.isEnabled ) {
+ return;
+ }
+ this.element.disabled = true;
+ this.isEnabled = false;
+};
+
+PrevNextButton.prototype.update = function() {
+ // index of first or last cell, if previous or next
+ var cells = this.parent.cells;
+ // enable is wrapAround and at least 2 cells
+ if ( this.parent.options.wrapAround && cells.length > 1 ) {
+ this.enable();
+ return;
+ }
+ var lastIndex = cells.length ? cells.length - 1 : 0;
+ var boundIndex = this.isPrevious ? 0 : lastIndex;
+ var method = this.parent.selectedIndex == boundIndex ? 'disable' : 'enable';
+ this[ method ]();
+};
+
+PrevNextButton.prototype.destroy = function() {
+ this.deactivate();
+};
+
+// -------------------------- Flickity prototype -------------------------- //
+
+utils.extend( Flickity.defaults, {
+ prevNextButtons: true,
+ leftArrowText: '‹',
+ rightArrowText: '›'
+});
+
+Flickity.createMethods.push('_createPrevNextButtons');
+
+Flickity.prototype._createPrevNextButtons = function() {
+ if ( !this.options.prevNextButtons ) {
+ return;
+ }
+
+ this.prevButton = new PrevNextButton( -1, this );
+ this.nextButton = new PrevNextButton( 1, this );
+
+ this.on( 'activate', this.activatePrevNextButtons );
+};
+
+Flickity.prototype.activatePrevNextButtons = function() {
+ this.prevButton.activate();
+ this.nextButton.activate();
+ this.on( 'deactivate', this.deactivatePrevNextButtons );
+};
+
+Flickity.prototype.deactivatePrevNextButtons = function() {
+ this.prevButton.deactivate();
+ this.nextButton.deactivate();
+ this.off( 'deactivate', this.deactivatePrevNextButtons );
+};
+
+// -------------------------- -------------------------- //
+
+Flickity.PrevNextButton = PrevNextButton;
+
+return PrevNextButton;
+
+}));
+
+( function( window, factory ) {
+
+ // universal module definition
+
+ if ( typeof define == 'function' && define.amd ) {
+ // AMD
+ define( 'flickity/js/page-dots',[
+ 'eventie/eventie',
+ './flickity',
+ 'tap-listener/tap-listener',
+ 'fizzy-ui-utils/utils'
+ ], function( eventie, Flickity, TapListener, utils ) {
+ return factory( window, eventie, Flickity, TapListener, utils );
+ });
+ } else if ( typeof exports == 'object' ) {
+ // CommonJS
+ module.exports = factory(
+ window,
+ require('eventie'),
+ require('./flickity'),
+ require('tap-listener'),
+ require('fizzy-ui-utils')
+ );
+ } else {
+ // browser global
+ window.Flickity = window.Flickity || {};
+ window.Flickity.PageDots = factory(
+ window,
+ window.eventie,
+ window.Flickity,
+ window.TapListener,
+ window.fizzyUIUtils
+ );
+ }
+
+}( window, function factory( window, eventie, Flickity, TapListener, utils ) {
+
+// -------------------------- PageDots -------------------------- //
+
+
+
+function PageDots( parent ) {
+ this.parent = parent;
+ this._create();
+}
+
+PageDots.prototype = new TapListener();
+
+PageDots.prototype._create = function() {
+ // create holder element
+ this.holder = document.createElement('ol');
+ this.holder.className = 'flickity-page-dots';
+ Flickity.setUnselectable( this.holder );
+ // create dots, array of elements
+ this.dots = [];
+ // update on select
+ var _this = this;
+ this.onCellSelect = function() {
+ _this.updateSelected();
+ };
+ this.parent.on( 'cellSelect', this.onCellSelect );
+ // tap
+ this.on( 'tap', this.onTap );
+ // pointerDown
+ this.on( 'pointerDown', function onPointerDown( button, event ) {
+ _this.parent.childUIPointerDown( event );
+ });
+};
+
+PageDots.prototype.activate = function() {
+ this.setDots();
+ this.updateSelected();
+ this.bindTap( this.holder );
+ // add to DOM
+ this.parent.element.appendChild( this.holder );
+};
+
+PageDots.prototype.deactivate = function() {
+ // remove from DOM
+ this.parent.element.removeChild( this.holder );
+ TapListener.prototype.destroy.call( this );
+};
+
+PageDots.prototype.setDots = function() {
+ // get difference between number of cells and number of dots
+ var delta = this.parent.cells.length - this.dots.length;
+ if ( delta > 0 ) {
+ this.addDots( delta );
+ } else if ( delta < 0 ) {
+ this.removeDots( -delta );
+ }
+};
+
+PageDots.prototype.addDots = function( count ) {
+ var fragment = document.createDocumentFragment();
+ var newDots = [];
+ while ( count ) {
+ var dot = document.createElement('li');
+ dot.className = 'dot';
+ fragment.appendChild( dot );
+ newDots.push( dot );
+ count--;
+ }
+ this.holder.appendChild( fragment );
+ this.dots = this.dots.concat( newDots );
+};
+
+PageDots.prototype.removeDots = function( count ) {
+ // remove from this.dots collection
+ var removeDots = this.dots.splice( this.dots.length - count, count );
+ // remove from DOM
+ for ( var i=0, len = removeDots.length; i < len; i++ ) {
+ var dot = removeDots[i];
+ this.holder.removeChild( dot );
+ }
+};
+
+PageDots.prototype.updateSelected = function() {
+ // remove selected class on previous
+ if ( this.selectedDot ) {
+ this.selectedDot.className = 'dot';
+ }
+ // don't proceed if no dots
+ if ( !this.dots.length ) {
+ return;
+ }
+ this.selectedDot = this.dots[ this.parent.selectedIndex ];
+ this.selectedDot.className = 'dot is-selected';
+};
+
+PageDots.prototype.onTap = function( event ) {
+ var target = event.target;
+ // only care about dot clicks
+ if ( target.nodeName != 'LI' ) {
+ return;
+ }
+
+ this.parent.uiChange();
+ var index = utils.indexOf( this.dots, target );
+ this.parent.select( index );
+};
+
+PageDots.prototype.destroy = function() {
+ this.deactivate();
+};
+
+Flickity.PageDots = PageDots;
+
+// -------------------------- Flickity -------------------------- //
+
+utils.extend( Flickity.defaults, {
+ pageDots: true
+});
+
+Flickity.createMethods.push('_createPageDots');
+
+Flickity.prototype._createPageDots = function() {
+ if ( !this.options.pageDots ) {
+ return;
+ }
+ this.pageDots = new PageDots( this );
+ this.on( 'activate', this.activatePageDots );
+ this.on( 'cellAddedRemoved', this.onCellAddedRemovedPageDots );
+ this.on( 'deactivate', this.deactivatePageDots );
+};
+
+Flickity.prototype.activatePageDots = function() {
+ this.pageDots.activate();
+};
+
+Flickity.prototype.onCellAddedRemovedPageDots = function() {
+ this.pageDots.setDots();
+};
+
+Flickity.prototype.deactivatePageDots = function() {
+ this.pageDots.deactivate();
+};
+
+// ----- ----- //
+
+Flickity.PageDots = PageDots;
+
+return PageDots;
+
+}));
+
+( function( window, factory ) {
+
+ // universal module definition
+
+ if ( typeof define == 'function' && define.amd ) {
+ // AMD
+ define( 'flickity/js/player',[
+ 'eventEmitter/EventEmitter',
+ 'eventie/eventie',
+ './flickity'
+ ], function( EventEmitter, eventie, Flickity ) {
+ return factory( EventEmitter, eventie, Flickity );
+ });
+ } else if ( typeof exports == 'object' ) {
+ // CommonJS
+ module.exports = factory(
+ require('wolfy87-eventemitter'),
+ require('eventie'),
+ require('./flickity')
+ );
+ } else {
+ // browser global
+ window.Flickity = window.Flickity || {};
+ window.Flickity.Player = factory(
+ window.EventEmitter,
+ window.eventie,
+ window.Flickity
+ );
+ }
+
+}( window, function factory( EventEmitter, eventie, Flickity ) {
+
+
+
+// -------------------------- Page Visibility -------------------------- //
+// https://developer.mozilla.org/en-US/docs/Web/Guide/User_experience/Using_the_Page_Visibility_API
+
+var hiddenProperty, visibilityEvent;
+if ( 'hidden' in document ) {
+ hiddenProperty = 'hidden';
+ visibilityEvent = 'visibilitychange';
+} else if ( 'webkitHidden' in document ) {
+ hiddenProperty = 'webkitHidden';
+ visibilityEvent = 'webkitvisibilitychange';
+}
+
+// -------------------------- Player -------------------------- //
+
+function Player( parent ) {
+ this.isPlaying = false;
+ this.parent = parent;
+ // visibility change event handler
+ if ( visibilityEvent ) {
+ var _this = this;
+ this.onVisibilityChange = function() {
+ _this.visibilityChange();
+ };
+ }
+}
+
+Player.prototype = new EventEmitter();
+
+// start play
+Player.prototype.play = function() {
+ this.isPlaying = true;
+ // playing kills pauses
+ delete this.isPaused;
+ // listen to visibility change
+ if ( visibilityEvent ) {
+ document.addEventListener( visibilityEvent, this.onVisibilityChange, false );
+ }
+ // start ticking
+ this.tick();
+};
+
+Player.prototype.tick = function() {
+ // do not tick if paused or not playing
+ if ( !this.isPlaying || this.isPaused ) {
+ return;
+ }
+ // keep track of when .tick()
+ this.tickTime = new Date();
+ var time = this.parent.options.autoPlay;
+ // default to 3 seconds
+ time = typeof time == 'number' ? time : 3000;
+ var _this = this;
+ this.timeout = setTimeout( function() {
+ _this.parent.next( true );
+ _this.tick();
+ }, time );
+};
+
+Player.prototype.stop = function() {
+ this.isPlaying = false;
+ // stopping kills pauses
+ delete this.isPaused;
+ this.clear();
+ // remove visibility change event
+ if ( visibilityEvent ) {
+ document.removeEventListener( visibilityEvent, this.onVisibilityChange, false );
+ }
+};
+
+Player.prototype.clear = function() {
+ clearTimeout( this.timeout );
+};
+
+Player.prototype.pause = function() {
+ if ( this.isPlaying ) {
+ this.isPaused = true;
+ this.clear();
+ }
+};
+
+Player.prototype.unpause = function() {
+ // re-start play if in unpaused state
+ if ( this.isPaused ) {
+ this.play();
+ }
+};
+
+// pause if page visibility is hidden, unpause if visible
+Player.prototype.visibilityChange = function() {
+ var isHidden = document[ hiddenProperty ];
+ this[ isHidden ? 'pause' : 'unpause' ]();
+};
+
+// -------------------------- Flickity -------------------------- //
+
+// utils.extend( Flickity.defaults, {
+// autoPlay: false
+// });
+
+Flickity.createMethods.push('_createPlayer');
+
+Flickity.prototype._createPlayer = function() {
+ this.player = new Player( this );
+
+ this.on( 'activate', this.activatePlayer );
+ this.on( 'uiChange', this.stopPlayer );
+ this.on( 'pointerDown', this.stopPlayer );
+ this.on( 'deactivate', this.deactivatePlayer );
+};
+
+Flickity.prototype.activatePlayer = function() {
+ if ( !this.options.autoPlay ) {
+ return;
+ }
+ this.player.play();
+ eventie.bind( this.element, 'mouseenter', this );
+ this.isMouseenterBound = true;
+};
+
+Flickity.prototype.stopPlayer = function() {
+ this.player.stop();
+};
+
+Flickity.prototype.deactivatePlayer = function() {
+ this.player.stop();
+ if ( this.isMouseenterBound ) {
+ eventie.unbind( this.element, 'mouseenter', this );
+ delete this.isMouseenterBound;
+ }
+};
+
+// ----- mouseenter/leave ----- //
+
+// pause auto-play on hover
+Flickity.prototype.onmouseenter = function() {
+ this.player.pause();
+ eventie.bind( this.element, 'mouseleave', this );
+};
+
+// resume auto-play on hover off
+Flickity.prototype.onmouseleave = function() {
+ this.player.unpause();
+ eventie.unbind( this.element, 'mouseleave', this );
+};
+
+// ----- ----- //
+
+Flickity.Player = Player;
+
+return Player;
+
+}));
+
+( function( window, factory ) {
+
+ // universal module definition
+
+ if ( typeof define == 'function' && define.amd ) {
+ // AMD
+ define( 'flickity/js/add-remove-cell',[
+ './flickity',
+ 'fizzy-ui-utils/utils'
+ ], function( Flickity, utils ) {
+ return factory( window, Flickity, utils );
+ });
+ } else if ( typeof exports == 'object' ) {
+ // CommonJS
+ module.exports = factory(
+ window,
+ require('./flickity'),
+ require('fizzy-ui-utils')
+ );
+ } else {
+ // browser global
+ window.Flickity = window.Flickity || {};
+ window.Flickity = factory(
+ window,
+ window.Flickity,
+ window.fizzyUIUtils
+ );
+ }
+
+}( window, function factory( window, Flickity, utils ) {
+
+
+
+// append cells to a document fragment
+function getCellsFragment( cells ) {
+ var fragment = document.createDocumentFragment();
+ for ( var i=0, len = cells.length; i < len; i++ ) {
+ var cell = cells[i];
+ fragment.appendChild( cell.element );
+ }
+ return fragment;
+}
+
+// -------------------------- add/remove cell prototype -------------------------- //
+
+/**
+ * Insert, prepend, or append cells
+ * @param {Element, Array, NodeList} elems
+ * @param {Integer} index
+ */
+Flickity.prototype.insert = function( elems, index ) {
+ var cells = this._makeCells( elems );
+ if ( !cells || !cells.length ) {
+ return;
+ }
+ var len = this.cells.length;
+ // default to append
+ index = index === undefined ? len : index;
+ // add cells with document fragment
+ var fragment = getCellsFragment( cells );
+ // append to slider
+ var isAppend = index == len;
+ if ( isAppend ) {
+ this.slider.appendChild( fragment );
+ } else {
+ var insertCellElement = this.cells[ index ].element;
+ this.slider.insertBefore( fragment, insertCellElement );
+ }
+ // add to this.cells
+ if ( index === 0 ) {
+ // prepend, add to start
+ this.cells = cells.concat( this.cells );
+ } else if ( isAppend ) {
+ // append, add to end
+ this.cells = this.cells.concat( cells );
+ } else {
+ // insert in this.cells
+ var endCells = this.cells.splice( index, len - index );
+ this.cells = this.cells.concat( cells ).concat( endCells );
+ }
+
+ this._sizeCells( cells );
+
+ var selectedIndexDelta = index > this.selectedIndex ? 0 : cells.length;
+ this._cellAddedRemoved( index, selectedIndexDelta );
+};
+
+Flickity.prototype.append = function( elems ) {
+ this.insert( elems, this.cells.length );
+};
+
+Flickity.prototype.prepend = function( elems ) {
+ this.insert( elems, 0 );
+};
+
+/**
+ * Remove cells
+ * @param {Element, Array, NodeList} elems
+ */
+Flickity.prototype.remove = function( elems ) {
+ var cells = this.getCells( elems );
+ var selectedIndexDelta = 0;
+ var i, len, cell;
+ // calculate selectedIndexDelta, easier if done in seperate loop
+ for ( i=0, len = cells.length; i < len; i++ ) {
+ cell = cells[i];
+ var wasBefore = utils.indexOf( this.cells, cell ) < this.selectedIndex;
+ selectedIndexDelta -= wasBefore ? 1 : 0;
+ }
+
+ for ( i=0, len = cells.length; i < len; i++ ) {
+ cell = cells[i];
+ cell.remove();
+ // remove item from collection
+ utils.removeFrom( this.cells, cell );
+ }
+
+ if ( cells.length ) {
+ // update stuff
+ this._cellAddedRemoved( 0, selectedIndexDelta );
+ }
+};
+
+// updates when cells are added or removed
+Flickity.prototype._cellAddedRemoved = function( changedCellIndex, selectedIndexDelta ) {
+ selectedIndexDelta = selectedIndexDelta || 0;
+ this.selectedIndex += selectedIndexDelta;
+ this.selectedIndex = Math.max( 0, Math.min( this.cells.length - 1, this.selectedIndex ) );
+
+ this.emitEvent( 'cellAddedRemoved', [ changedCellIndex, selectedIndexDelta ] );
+ this.cellChange( changedCellIndex );
+};
+
+/**
+ * logic to be run after a cell's size changes
+ * @param {Element} elem - cell's element
+ */
+Flickity.prototype.cellSizeChange = function( elem ) {
+ var cell = this.getCell( elem );
+ if ( !cell ) {
+ return;
+ }
+ cell.getSize();
+
+ var index = utils.indexOf( this.cells, cell );
+ this.cellChange( index );
+};
+
+/**
+ * logic any time a cell is changed: added, removed, or size changed
+ * @param {Integer} changedCellIndex - index of the changed cell, optional
+ */
+Flickity.prototype.cellChange = function( changedCellIndex ) {
+ // TODO maybe always size all cells unless isSkippingSizing
+ // size all cells if necessary
+ // if ( !isSkippingSizing ) {
+ // this._sizeCells( this.cells );
+ // }
+
+ changedCellIndex = changedCellIndex || 0;
+
+ this._positionCells( changedCellIndex );
+ this._getWrapShiftCells();
+ this.setGallerySize();
+ // position slider
+ if ( this.options.freeScroll ) {
+ this.positionSlider();
+ } else {
+ this.positionSliderAtSelected();
+ this.select( this.selectedIndex );
+ }
+};
+
+// ----- ----- //
+
+return Flickity;
+
+}));
+
+/**
+ * Flickity index
+ * used for AMD and CommonJS exports
+ */
+
+( function( window, factory ) {
+
+ // universal module definition
+
+ if ( typeof define == 'function' && define.amd ) {
+ // AMD
+ define( 'flickity/js/index',[
+ './flickity',
+ './drag',
+ './prev-next-button',
+ './page-dots',
+ './player',
+ './add-remove-cell'
+ ], factory );
+ } else if ( typeof exports == 'object' ) {
+ // CommonJS
+ module.exports = factory(
+ require('./flickity'),
+ require('./drag'),
+ require('./prev-next-button'),
+ require('./page-dots'),
+ require('./player'),
+ require('./add-remove-cell')
+ );
+ }
+
+})( window, function factory( Flickity ) {
+ /*jshint strict: false*/
+ return Flickity;
+});
+
+/*!
+ * Flickity asNavFor v1.0.1
+ * enable asNavFor for Flickity
+ */
+
+/*jshint browser: true, undef: true, unused: true, strict: true*/
+
+( function( window, factory ) {
+ /*global define: false, module: false, require: false */
+
+ // universal module definition
+
+ if ( typeof define == 'function' && define.amd ) {
+ // AMD
+ define( 'flickity-as-nav-for/as-nav-for',[
+ 'classie/classie',
+ 'flickity/js/index',
+ 'fizzy-ui-utils/utils'
+ ], function( classie, Flickity, utils ) {
+ return factory( window, classie, Flickity, utils );
+ });
+ } else if ( typeof exports == 'object' ) {
+ // CommonJS
+ module.exports = factory(
+ window,
+ require('desandro-classie'),
+ require('flickity'),
+ require('fizzy-ui-utils')
+ );
+ } else {
+ // browser global
+ window.Flickity = factory(
+ window,
+ window.classie,
+ window.Flickity,
+ window.fizzyUIUtils
+ );
+ }
+
+}( window, function factory( window, classie, Flickity, utils ) {
+
+
+
+// -------------------------- asNavFor prototype -------------------------- //
+
+// Flickity.defaults.asNavFor = null;
+
+Flickity.createMethods.push('_createAsNavFor');
+
+Flickity.prototype._createAsNavFor = function() {
+ this.on( 'activate', this.activateAsNavFor );
+ this.on( 'deactivate', this.deactivateAsNavFor );
+ this.on( 'destroy', this.destroyAsNavFor );
+
+ var asNavForOption = this.options.asNavFor;
+ if ( !asNavForOption ) {
+ return;
+ }
+ // HACK do async, give time for other flickity to be initalized
+ var _this = this;
+ setTimeout( function initNavCompanion() {
+ _this.setNavCompanion( asNavForOption );
+ });
+};
+
+Flickity.prototype.setNavCompanion = function( elem ) {
+ elem = utils.getQueryElement( elem );
+ var companion = Flickity.data( elem );
+ // stop if no companion or companion is self
+ if ( !companion || companion == this ) {
+ return;
+ }
+
+ this.navCompanion = companion;
+ // companion select
+ var _this = this;
+ this.onNavCompanionSelect = function() {
+ _this.navCompanionSelect();
+ };
+ companion.on( 'cellSelect', this.onNavCompanionSelect );
+ // click
+ this.on( 'staticClick', this.onNavStaticClick );
+
+ this.navCompanionSelect();
+};
+
+Flickity.prototype.navCompanionSelect = function() {
+ if ( !this.navCompanion ) {
+ return;
+ }
+ var index = this.navCompanion.selectedIndex;
+ this.select( index );
+ // set nav selected class
+ this.removeNavSelectedElement();
+ // stop if companion has more cells than this one
+ if ( this.selectedIndex != index ) {
+ return;
+ }
+ this.navSelectedElement = this.cells[ index ].element;
+ classie.add( this.navSelectedElement, 'is-nav-selected' );
+};
+
+Flickity.prototype.activateAsNavFor = function() {
+ this.navCompanionSelect();
+};
+
+Flickity.prototype.removeNavSelectedElement = function() {
+ if ( !this.navSelectedElement ) {
+ return;
+ }
+ classie.remove( this.navSelectedElement, 'is-nav-selected' );
+ delete this.navSelectedElement;
+};
+
+Flickity.prototype.onNavStaticClick = function( event, pointer, cellElement, cellIndex ) {
+ if ( typeof cellIndex == 'number' ) {
+ this.navCompanion.select( cellIndex );
+ }
+};
+
+Flickity.prototype.deactivateAsNavFor = function() {
+ this.removeNavSelectedElement();
+};
+
+Flickity.prototype.destroyAsNavFor = function() {
+ if ( !this.navCompanion ) {
+ return;
+ }
+ this.navCompanion.off( 'cellSelect', this.onNavCompanionSelect );
+ this.off( 'staticClick', this.onNavStaticClick );
+ delete this.navCompanion;
+};
+
+// ----- ----- //
+
+return Flickity;
+
+}));
+
+/*!
+ * imagesLoaded v3.1.8
+ * JavaScript is all like "You images are done yet or what?"
+ * MIT License
+ */
+
+( function( window, factory ) {
+ // universal module definition
+
+ /*global define: false, module: false, require: false */
+
+ if ( typeof define === 'function' && define.amd ) {
+ // AMD
+ define( 'imagesloaded/imagesloaded',[
+ 'eventEmitter/EventEmitter',
+ 'eventie/eventie'
+ ], function( EventEmitter, eventie ) {
+ return factory( window, EventEmitter, eventie );
+ });
+ } else if ( typeof exports === 'object' ) {
+ // CommonJS
+ module.exports = factory(
+ window,
+ require('wolfy87-eventemitter'),
+ require('eventie')
+ );
+ } else {
+ // browser global
+ window.imagesLoaded = factory(
+ window,
+ window.EventEmitter,
+ window.eventie
+ );
+ }
+
+})( window,
+
+// -------------------------- factory -------------------------- //
+
+function factory( window, EventEmitter, eventie ) {
+
+
+
+var $ = window.jQuery;
+var console = window.console;
+var hasConsole = typeof console !== 'undefined';
+
+// -------------------------- helpers -------------------------- //
+
+// extend objects
+function extend( a, b ) {
+ for ( var prop in b ) {
+ a[ prop ] = b[ prop ];
+ }
+ return a;
+}
+
+var objToString = Object.prototype.toString;
+function isArray( obj ) {
+ return objToString.call( obj ) === '[object Array]';
+}
+
+// turn element or nodeList into an array
+function makeArray( obj ) {
+ var ary = [];
+ if ( isArray( obj ) ) {
+ // use object if already an array
+ ary = obj;
+ } else if ( typeof obj.length === 'number' ) {
+ // convert nodeList to array
+ for ( var i=0, len = obj.length; i < len; i++ ) {
+ ary.push( obj[i] );
+ }
+ } else {
+ // array of single index
+ ary.push( obj );
+ }
+ return ary;
+}
+
+ // -------------------------- imagesLoaded -------------------------- //
+
+ /**
+ * @param {Array, Element, NodeList, String} elem
+ * @param {Object or Function} options - if function, use as callback
+ * @param {Function} onAlways - callback function
+ */
+ function ImagesLoaded( elem, options, onAlways ) {
+ // coerce ImagesLoaded() without new, to be new ImagesLoaded()
+ if ( !( this instanceof ImagesLoaded ) ) {
+ return new ImagesLoaded( elem, options );
+ }
+ // use elem as selector string
+ if ( typeof elem === 'string' ) {
+ elem = document.querySelectorAll( elem );
+ }
+
+ this.elements = makeArray( elem );
+ this.options = extend( {}, this.options );
+
+ if ( typeof options === 'function' ) {
+ onAlways = options;
+ } else {
+ extend( this.options, options );
+ }
+
+ if ( onAlways ) {
+ this.on( 'always', onAlways );
+ }
+
+ this.getImages();
+
+ if ( $ ) {
+ // add jQuery Deferred object
+ this.jqDeferred = new $.Deferred();
+ }
+
+ // HACK check async to allow time to bind listeners
+ var _this = this;
+ setTimeout( function() {
+ _this.check();
+ });
+ }
+
+ ImagesLoaded.prototype = new EventEmitter();
+
+ ImagesLoaded.prototype.options = {};
+
+ ImagesLoaded.prototype.getImages = function() {
+ this.images = [];
+
+ // filter & find items if we have an item selector
+ for ( var i=0, len = this.elements.length; i < len; i++ ) {
+ var elem = this.elements[i];
+ // filter siblings
+ if ( elem.nodeName === 'IMG' ) {
+ this.addImage( elem );
+ }
+ // find children
+ // no non-element nodes, #143
+ var nodeType = elem.nodeType;
+ if ( !nodeType || !( nodeType === 1 || nodeType === 9 || nodeType === 11 ) ) {
+ continue;
+ }
+ var childElems = elem.querySelectorAll('img');
+ // concat childElems to filterFound array
+ for ( var j=0, jLen = childElems.length; j < jLen; j++ ) {
+ var img = childElems[j];
+ this.addImage( img );
+ }
+ }
+ };
+
+ /**
+ * @param {Image} img
+ */
+ ImagesLoaded.prototype.addImage = function( img ) {
+ var loadingImage = new LoadingImage( img );
+ this.images.push( loadingImage );
+ };
+
+ ImagesLoaded.prototype.check = function() {
+ var _this = this;
+ var checkedCount = 0;
+ var length = this.images.length;
+ this.hasAnyBroken = false;
+ // complete if no images
+ if ( !length ) {
+ this.complete();
+ return;
+ }
+
+ function onConfirm( image, message ) {
+ if ( _this.options.debug && hasConsole ) {
+ console.log( 'confirm', image, message );
+ }
+
+ _this.progress( image );
+ checkedCount++;
+ if ( checkedCount === length ) {
+ _this.complete();
+ }
+ return true; // bind once
+ }
+
+ for ( var i=0; i < length; i++ ) {
+ var loadingImage = this.images[i];
+ loadingImage.on( 'confirm', onConfirm );
+ loadingImage.check();
+ }
+ };
+
+ ImagesLoaded.prototype.progress = function( image ) {
+ this.hasAnyBroken = this.hasAnyBroken || !image.isLoaded;
+ // HACK - Chrome triggers event before object properties have changed. #83
+ var _this = this;
+ setTimeout( function() {
+ _this.emit( 'progress', _this, image );
+ if ( _this.jqDeferred && _this.jqDeferred.notify ) {
+ _this.jqDeferred.notify( _this, image );
+ }
+ });
+ };
+
+ ImagesLoaded.prototype.complete = function() {
+ var eventName = this.hasAnyBroken ? 'fail' : 'done';
+ this.isComplete = true;
+ var _this = this;
+ // HACK - another setTimeout so that confirm happens after progress
+ setTimeout( function() {
+ _this.emit( eventName, _this );
+ _this.emit( 'always', _this );
+ if ( _this.jqDeferred ) {
+ var jqMethod = _this.hasAnyBroken ? 'reject' : 'resolve';
+ _this.jqDeferred[ jqMethod ]( _this );
+ }
+ });
+ };
+
+ // -------------------------- jquery -------------------------- //
+
+ if ( $ ) {
+ $.fn.imagesLoaded = function( options, callback ) {
+ var instance = new ImagesLoaded( this, options, callback );
+ return instance.jqDeferred.promise( $(this) );
+ };
+ }
+
+
+ // -------------------------- -------------------------- //
+
+ function LoadingImage( img ) {
+ this.img = img;
+ }
+
+ LoadingImage.prototype = new EventEmitter();
+
+ LoadingImage.prototype.check = function() {
+ // first check cached any previous images that have same src
+ var resource = cache[ this.img.src ] || new Resource( this.img.src );
+ if ( resource.isConfirmed ) {
+ this.confirm( resource.isLoaded, 'cached was confirmed' );
+ return;
+ }
+
+ // If complete is true and browser supports natural sizes,
+ // try to check for image status manually.
+ if ( this.img.complete && this.img.naturalWidth !== undefined ) {
+ // report based on naturalWidth
+ this.confirm( this.img.naturalWidth !== 0, 'naturalWidth' );
+ return;
+ }
+
+ // If none of the checks above matched, simulate loading on detached element.
+ var _this = this;
+ resource.on( 'confirm', function( resrc, message ) {
+ _this.confirm( resrc.isLoaded, message );
+ return true;
+ });
+
+ resource.check();
+ };
+
+ LoadingImage.prototype.confirm = function( isLoaded, message ) {
+ this.isLoaded = isLoaded;
+ this.emit( 'confirm', this, message );
+ };
+
+ // -------------------------- Resource -------------------------- //
+
+ // Resource checks each src, only once
+ // separate class from LoadingImage to prevent memory leaks. See #115
+
+ var cache = {};
+
+ function Resource( src ) {
+ this.src = src;
+ // add to cache
+ cache[ src ] = this;
+ }
+
+ Resource.prototype = new EventEmitter();
+
+ Resource.prototype.check = function() {
+ // only trigger checking once
+ if ( this.isChecked ) {
+ return;
+ }
+ // simulate loading on detached element
+ var proxyImage = new Image();
+ eventie.bind( proxyImage, 'load', this );
+ eventie.bind( proxyImage, 'error', this );
+ proxyImage.src = this.src;
+ // set flag
+ this.isChecked = true;
+ };
+
+ // ----- events ----- //
+
+ // trigger specified handler for event type
+ Resource.prototype.handleEvent = function( event ) {
+ var method = 'on' + event.type;
+ if ( this[ method ] ) {
+ this[ method ]( event );
+ }
+ };
+
+ Resource.prototype.onload = function( event ) {
+ this.confirm( true, 'onload' );
+ this.unbindProxyEvents( event );
+ };
+
+ Resource.prototype.onerror = function( event ) {
+ this.confirm( false, 'onerror' );
+ this.unbindProxyEvents( event );
+ };
+
+ // ----- confirm ----- //
+
+ Resource.prototype.confirm = function( isLoaded, message ) {
+ this.isConfirmed = true;
+ this.isLoaded = isLoaded;
+ this.emit( 'confirm', this, message );
+ };
+
+ Resource.prototype.unbindProxyEvents = function( event ) {
+ eventie.unbind( event.target, 'load', this );
+ eventie.unbind( event.target, 'error', this );
+ };
+
+ // ----- ----- //
+
+ return ImagesLoaded;
+
+});
+
+/*!
+ * Flickity imagesLoaded v1.0.0
+ * enables imagesLoaded option for Flickity
+ */
+
+/*jshint browser: true, strict: true, undef: true, unused: true */
+
+( function( window, factory ) {
+ /*global define: false, module: false, require: false */
+
+ // universal module definition
+
+ if ( typeof define == 'function' && define.amd ) {
+ // AMD
+ define( [
+ 'flickity/js/index',
+ 'imagesloaded/imagesloaded'
+ ], function( Flickity, imagesLoaded ) {
+ return factory( window, Flickity, imagesLoaded );
+ });
+ } else if ( typeof exports == 'object' ) {
+ // CommonJS
+ module.exports = factory(
+ window,
+ require('flickity'),
+ require('imagesloaded')
+ );
+ } else {
+ // browser global
+ window.Flickity = factory(
+ window,
+ window.Flickity,
+ window.imagesLoaded
+ );
+ }
+
+}( window, function factory( window, Flickity, imagesLoaded ) {
+
+
+Flickity.createMethods.push('_createImagesLoaded');
+
+Flickity.prototype._createImagesLoaded = function() {
+ this.on( 'activate', this.imagesLoaded );
+};
+
+Flickity.prototype.imagesLoaded = function() {
+ if ( !this.options.imagesLoaded ) {
+ return;
+ }
+ var _this = this;
+ function onImagesLoadedProgress( instance, image ) {
+ var cell = _this.getParentCell( image.img );
+ _this.cellSizeChange( cell && cell.element );
+ }
+ this.loader = imagesLoaded( this.slider ).on( 'progress', onImagesLoadedProgress );
+};
+
+return Flickity;
+
+}));
diff --git a/StoneIsland/platforms/ios/www/js/vendor/moment.js b/StoneIsland/platforms/ios/www/js/vendor/moment.js
new file mode 100644
index 00000000..30e9239a
--- /dev/null
+++ b/StoneIsland/platforms/ios/www/js/vendor/moment.js
@@ -0,0 +1,3195 @@
+//! moment.js
+//! version : 2.10.6
+//! authors : Tim Wood, Iskren Chernev, Moment.js contributors
+//! license : MIT
+//! momentjs.com
+
+(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
+ typeof define === 'function' && define.amd ? define(factory) :
+ global.moment = factory()
+}(this, function () { 'use strict';
+
+ var hookCallback;
+
+ function utils_hooks__hooks () {
+ return hookCallback.apply(null, arguments);
+ }
+
+ // This is done to register the method called with moment()
+ // without creating circular dependencies.
+ function setHookCallback (callback) {
+ hookCallback = callback;
+ }
+
+ function isArray(input) {
+ return Object.prototype.toString.call(input) === '[object Array]';
+ }
+
+ function isDate(input) {
+ return input instanceof Date || Object.prototype.toString.call(input) === '[object Date]';
+ }
+
+ function map(arr, fn) {
+ var res = [], i;
+ for (i = 0; i < arr.length; ++i) {
+ res.push(fn(arr[i], i));
+ }
+ return res;
+ }
+
+ function hasOwnProp(a, b) {
+ return Object.prototype.hasOwnProperty.call(a, b);
+ }
+
+ function extend(a, b) {
+ for (var i in b) {
+ if (hasOwnProp(b, i)) {
+ a[i] = b[i];
+ }
+ }
+
+ if (hasOwnProp(b, 'toString')) {
+ a.toString = b.toString;
+ }
+
+ if (hasOwnProp(b, 'valueOf')) {
+ a.valueOf = b.valueOf;
+ }
+
+ return a;
+ }
+
+ function create_utc__createUTC (input, format, locale, strict) {
+ return createLocalOrUTC(input, format, locale, strict, true).utc();
+ }
+
+ function defaultParsingFlags() {
+ // We need to deep clone this object.
+ return {
+ empty : false,
+ unusedTokens : [],
+ unusedInput : [],
+ overflow : -2,
+ charsLeftOver : 0,
+ nullInput : false,
+ invalidMonth : null,
+ invalidFormat : false,
+ userInvalidated : false,
+ iso : false
+ };
+ }
+
+ function getParsingFlags(m) {
+ if (m._pf == null) {
+ m._pf = defaultParsingFlags();
+ }
+ return m._pf;
+ }
+
+ function valid__isValid(m) {
+ if (m._isValid == null) {
+ var flags = getParsingFlags(m);
+ m._isValid = !isNaN(m._d.getTime()) &&
+ flags.overflow < 0 &&
+ !flags.empty &&
+ !flags.invalidMonth &&
+ !flags.invalidWeekday &&
+ !flags.nullInput &&
+ !flags.invalidFormat &&
+ !flags.userInvalidated;
+
+ if (m._strict) {
+ m._isValid = m._isValid &&
+ flags.charsLeftOver === 0 &&
+ flags.unusedTokens.length === 0 &&
+ flags.bigHour === undefined;
+ }
+ }
+ return m._isValid;
+ }
+
+ function valid__createInvalid (flags) {
+ var m = create_utc__createUTC(NaN);
+ if (flags != null) {
+ extend(getParsingFlags(m), flags);
+ }
+ else {
+ getParsingFlags(m).userInvalidated = true;
+ }
+
+ return m;
+ }
+
+ var momentProperties = utils_hooks__hooks.momentProperties = [];
+
+ function copyConfig(to, from) {
+ var i, prop, val;
+
+ if (typeof from._isAMomentObject !== 'undefined') {
+ to._isAMomentObject = from._isAMomentObject;
+ }
+ if (typeof from._i !== 'undefined') {
+ to._i = from._i;
+ }
+ if (typeof from._f !== 'undefined') {
+ to._f = from._f;
+ }
+ if (typeof from._l !== 'undefined') {
+ to._l = from._l;
+ }
+ if (typeof from._strict !== 'undefined') {
+ to._strict = from._strict;
+ }
+ if (typeof from._tzm !== 'undefined') {
+ to._tzm = from._tzm;
+ }
+ if (typeof from._isUTC !== 'undefined') {
+ to._isUTC = from._isUTC;
+ }
+ if (typeof from._offset !== 'undefined') {
+ to._offset = from._offset;
+ }
+ if (typeof from._pf !== 'undefined') {
+ to._pf = getParsingFlags(from);
+ }
+ if (typeof from._locale !== 'undefined') {
+ to._locale = from._locale;
+ }
+
+ if (momentProperties.length > 0) {
+ for (i in momentProperties) {
+ prop = momentProperties[i];
+ val = from[prop];
+ if (typeof val !== 'undefined') {
+ to[prop] = val;
+ }
+ }
+ }
+
+ return to;
+ }
+
+ var updateInProgress = false;
+
+ // Moment prototype object
+ function Moment(config) {
+ copyConfig(this, config);
+ this._d = new Date(config._d != null ? config._d.getTime() : NaN);
+ // Prevent infinite loop in case updateOffset creates new moment
+ // objects.
+ if (updateInProgress === false) {
+ updateInProgress = true;
+ utils_hooks__hooks.updateOffset(this);
+ updateInProgress = false;
+ }
+ }
+
+ function isMoment (obj) {
+ return obj instanceof Moment || (obj != null && obj._isAMomentObject != null);
+ }
+
+ function absFloor (number) {
+ if (number < 0) {
+ return Math.ceil(number);
+ } else {
+ return Math.floor(number);
+ }
+ }
+
+ function toInt(argumentForCoercion) {
+ var coercedNumber = +argumentForCoercion,
+ value = 0;
+
+ if (coercedNumber !== 0 && isFinite(coercedNumber)) {
+ value = absFloor(coercedNumber);
+ }
+
+ return value;
+ }
+
+ function compareArrays(array1, array2, dontConvert) {
+ var len = Math.min(array1.length, array2.length),
+ lengthDiff = Math.abs(array1.length - array2.length),
+ diffs = 0,
+ i;
+ for (i = 0; i < len; i++) {
+ if ((dontConvert && array1[i] !== array2[i]) ||
+ (!dontConvert && toInt(array1[i]) !== toInt(array2[i]))) {
+ diffs++;
+ }
+ }
+ return diffs + lengthDiff;
+ }
+
+ function Locale() {
+ }
+
+ var locales = {};
+ var globalLocale;
+
+ function normalizeLocale(key) {
+ return key ? key.toLowerCase().replace('_', '-') : key;
+ }
+
+ // pick the locale from the array
+ // try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each
+ // substring from most specific to least, but move to the next array item if it's a more specific variant than the current root
+ function chooseLocale(names) {
+ var i = 0, j, next, locale, split;
+
+ while (i < names.length) {
+ split = normalizeLocale(names[i]).split('-');
+ j = split.length;
+ next = normalizeLocale(names[i + 1]);
+ next = next ? next.split('-') : null;
+ while (j > 0) {
+ locale = loadLocale(split.slice(0, j).join('-'));
+ if (locale) {
+ return locale;
+ }
+ if (next && next.length >= j && compareArrays(split, next, true) >= j - 1) {
+ //the next array item is better than a shallower substring of this one
+ break;
+ }
+ j--;
+ }
+ i++;
+ }
+ return null;
+ }
+
+ function loadLocale(name) {
+ var oldLocale = null;
+ // TODO: Find a better way to register and load all the locales in Node
+ if (!locales[name] && typeof module !== 'undefined' &&
+ module && module.exports) {
+ try {
+ oldLocale = globalLocale._abbr;
+ require('./locale/' + name);
+ // because defineLocale currently also sets the global locale, we
+ // want to undo that for lazy loaded locales
+ locale_locales__getSetGlobalLocale(oldLocale);
+ } catch (e) { }
+ }
+ return locales[name];
+ }
+
+ // This function will load locale and then set the global locale. If
+ // no arguments are passed in, it will simply return the current global
+ // locale key.
+ function locale_locales__getSetGlobalLocale (key, values) {
+ var data;
+ if (key) {
+ if (typeof values === 'undefined') {
+ data = locale_locales__getLocale(key);
+ }
+ else {
+ data = defineLocale(key, values);
+ }
+
+ if (data) {
+ // moment.duration._locale = moment._locale = data;
+ globalLocale = data;
+ }
+ }
+
+ return globalLocale._abbr;
+ }
+
+ function defineLocale (name, values) {
+ if (values !== null) {
+ values.abbr = name;
+ locales[name] = locales[name] || new Locale();
+ locales[name].set(values);
+
+ // backwards compat for now: also set the locale
+ locale_locales__getSetGlobalLocale(name);
+
+ return locales[name];
+ } else {
+ // useful for testing
+ delete locales[name];
+ return null;
+ }
+ }
+
+ // returns locale data
+ function locale_locales__getLocale (key) {
+ var locale;
+
+ if (key && key._locale && key._locale._abbr) {
+ key = key._locale._abbr;
+ }
+
+ if (!key) {
+ return globalLocale;
+ }
+
+ if (!isArray(key)) {
+ //short-circuit everything else
+ locale = loadLocale(key);
+ if (locale) {
+ return locale;
+ }
+ key = [key];
+ }
+
+ return chooseLocale(key);
+ }
+
+ var aliases = {};
+
+ function addUnitAlias (unit, shorthand) {
+ var lowerCase = unit.toLowerCase();
+ aliases[lowerCase] = aliases[lowerCase + 's'] = aliases[shorthand] = unit;
+ }
+
+ function normalizeUnits(units) {
+ return typeof units === 'string' ? aliases[units] || aliases[units.toLowerCase()] : undefined;
+ }
+
+ function normalizeObjectUnits(inputObject) {
+ var normalizedInput = {},
+ normalizedProp,
+ prop;
+
+ for (prop in inputObject) {
+ if (hasOwnProp(inputObject, prop)) {
+ normalizedProp = normalizeUnits(prop);
+ if (normalizedProp) {
+ normalizedInput[normalizedProp] = inputObject[prop];
+ }
+ }
+ }
+
+ return normalizedInput;
+ }
+
+ function makeGetSet (unit, keepTime) {
+ return function (value) {
+ if (value != null) {
+ get_set__set(this, unit, value);
+ utils_hooks__hooks.updateOffset(this, keepTime);
+ return this;
+ } else {
+ return get_set__get(this, unit);
+ }
+ };
+ }
+
+ function get_set__get (mom, unit) {
+ return mom._d['get' + (mom._isUTC ? 'UTC' : '') + unit]();
+ }
+
+ function get_set__set (mom, unit, value) {
+ return mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value);
+ }
+
+ // MOMENTS
+
+ function getSet (units, value) {
+ var unit;
+ if (typeof units === 'object') {
+ for (unit in units) {
+ this.set(unit, units[unit]);
+ }
+ } else {
+ units = normalizeUnits(units);
+ if (typeof this[units] === 'function') {
+ return this[units](value);
+ }
+ }
+ return this;
+ }
+
+ function zeroFill(number, targetLength, forceSign) {
+ var absNumber = '' + Math.abs(number),
+ zerosToFill = targetLength - absNumber.length,
+ sign = number >= 0;
+ return (sign ? (forceSign ? '+' : '') : '-') +
+ Math.pow(10, Math.max(0, zerosToFill)).toString().substr(1) + absNumber;
+ }
+
+ var formattingTokens = /(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Q|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g;
+
+ var localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g;
+
+ var formatFunctions = {};
+
+ var formatTokenFunctions = {};
+
+ // token: 'M'
+ // padded: ['MM', 2]
+ // ordinal: 'Mo'
+ // callback: function () { this.month() + 1 }
+ function addFormatToken (token, padded, ordinal, callback) {
+ var func = callback;
+ if (typeof callback === 'string') {
+ func = function () {
+ return this[callback]();
+ };
+ }
+ if (token) {
+ formatTokenFunctions[token] = func;
+ }
+ if (padded) {
+ formatTokenFunctions[padded[0]] = function () {
+ return zeroFill(func.apply(this, arguments), padded[1], padded[2]);
+ };
+ }
+ if (ordinal) {
+ formatTokenFunctions[ordinal] = function () {
+ return this.localeData().ordinal(func.apply(this, arguments), token);
+ };
+ }
+ }
+
+ function removeFormattingTokens(input) {
+ if (input.match(/\[[\s\S]/)) {
+ return input.replace(/^\[|\]$/g, '');
+ }
+ return input.replace(/\\/g, '');
+ }
+
+ function makeFormatFunction(format) {
+ var array = format.match(formattingTokens), i, length;
+
+ for (i = 0, length = array.length; i < length; i++) {
+ if (formatTokenFunctions[array[i]]) {
+ array[i] = formatTokenFunctions[array[i]];
+ } else {
+ array[i] = removeFormattingTokens(array[i]);
+ }
+ }
+
+ return function (mom) {
+ var output = '';
+ for (i = 0; i < length; i++) {
+ output += array[i] instanceof Function ? array[i].call(mom, format) : array[i];
+ }
+ return output;
+ };
+ }
+
+ // format date using native date object
+ function formatMoment(m, format) {
+ if (!m.isValid()) {
+ return m.localeData().invalidDate();
+ }
+
+ format = expandFormat(format, m.localeData());
+ formatFunctions[format] = formatFunctions[format] || makeFormatFunction(format);
+
+ return formatFunctions[format](m);
+ }
+
+ function expandFormat(format, locale) {
+ var i = 5;
+
+ function replaceLongDateFormatTokens(input) {
+ return locale.longDateFormat(input) || input;
+ }
+
+ localFormattingTokens.lastIndex = 0;
+ while (i >= 0 && localFormattingTokens.test(format)) {
+ format = format.replace(localFormattingTokens, replaceLongDateFormatTokens);
+ localFormattingTokens.lastIndex = 0;
+ i -= 1;
+ }
+
+ return format;
+ }
+
+ var match1 = /\d/; // 0 - 9
+ var match2 = /\d\d/; // 00 - 99
+ var match3 = /\d{3}/; // 000 - 999
+ var match4 = /\d{4}/; // 0000 - 9999
+ var match6 = /[+-]?\d{6}/; // -999999 - 999999
+ var match1to2 = /\d\d?/; // 0 - 99
+ var match1to3 = /\d{1,3}/; // 0 - 999
+ var match1to4 = /\d{1,4}/; // 0 - 9999
+ var match1to6 = /[+-]?\d{1,6}/; // -999999 - 999999
+
+ var matchUnsigned = /\d+/; // 0 - inf
+ var matchSigned = /[+-]?\d+/; // -inf - inf
+
+ var matchOffset = /Z|[+-]\d\d:?\d\d/gi; // +00:00 -00:00 +0000 -0000 or Z
+
+ var matchTimestamp = /[+-]?\d+(\.\d{1,3})?/; // 123456789 123456789.123
+
+ // any word (or two) characters or numbers including two/three word month in arabic.
+ var matchWord = /[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i;
+
+ var regexes = {};
+
+ function isFunction (sth) {
+ // https://github.com/moment/moment/issues/2325
+ return typeof sth === 'function' &&
+ Object.prototype.toString.call(sth) === '[object Function]';
+ }
+
+
+ function addRegexToken (token, regex, strictRegex) {
+ regexes[token] = isFunction(regex) ? regex : function (isStrict) {
+ return (isStrict && strictRegex) ? strictRegex : regex;
+ };
+ }
+
+ function getParseRegexForToken (token, config) {
+ if (!hasOwnProp(regexes, token)) {
+ return new RegExp(unescapeFormat(token));
+ }
+
+ return regexes[token](config._strict, config._locale);
+ }
+
+ // Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript
+ function unescapeFormat(s) {
+ return s.replace('\\', '').replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function (matched, p1, p2, p3, p4) {
+ return p1 || p2 || p3 || p4;
+ }).replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
+ }
+
+ var tokens = {};
+
+ function addParseToken (token, callback) {
+ var i, func = callback;
+ if (typeof token === 'string') {
+ token = [token];
+ }
+ if (typeof callback === 'number') {
+ func = function (input, array) {
+ array[callback] = toInt(input);
+ };
+ }
+ for (i = 0; i < token.length; i++) {
+ tokens[token[i]] = func;
+ }
+ }
+
+ function addWeekParseToken (token, callback) {
+ addParseToken(token, function (input, array, config, token) {
+ config._w = config._w || {};
+ callback(input, config._w, config, token);
+ });
+ }
+
+ function addTimeToArrayFromToken(token, input, config) {
+ if (input != null && hasOwnProp(tokens, token)) {
+ tokens[token](input, config._a, config, token);
+ }
+ }
+
+ var YEAR = 0;
+ var MONTH = 1;
+ var DATE = 2;
+ var HOUR = 3;
+ var MINUTE = 4;
+ var SECOND = 5;
+ var MILLISECOND = 6;
+
+ function daysInMonth(year, month) {
+ return new Date(Date.UTC(year, month + 1, 0)).getUTCDate();
+ }
+
+ // FORMATTING
+
+ addFormatToken('M', ['MM', 2], 'Mo', function () {
+ return this.month() + 1;
+ });
+
+ addFormatToken('MMM', 0, 0, function (format) {
+ return this.localeData().monthsShort(this, format);
+ });
+
+ addFormatToken('MMMM', 0, 0, function (format) {
+ return this.localeData().months(this, format);
+ });
+
+ // ALIASES
+
+ addUnitAlias('month', 'M');
+
+ // PARSING
+
+ addRegexToken('M', match1to2);
+ addRegexToken('MM', match1to2, match2);
+ addRegexToken('MMM', matchWord);
+ addRegexToken('MMMM', matchWord);
+
+ addParseToken(['M', 'MM'], function (input, array) {
+ array[MONTH] = toInt(input) - 1;
+ });
+
+ addParseToken(['MMM', 'MMMM'], function (input, array, config, token) {
+ var month = config._locale.monthsParse(input, token, config._strict);
+ // if we didn't find a month name, mark the date as invalid.
+ if (month != null) {
+ array[MONTH] = month;
+ } else {
+ getParsingFlags(config).invalidMonth = input;
+ }
+ });
+
+ // LOCALES
+
+ var defaultLocaleMonths = 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_');
+ function localeMonths (m) {
+ return this._months[m.month()];
+ }
+
+ var defaultLocaleMonthsShort = 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_');
+ function localeMonthsShort (m) {
+ return this._monthsShort[m.month()];
+ }
+
+ function localeMonthsParse (monthName, format, strict) {
+ var i, mom, regex;
+
+ if (!this._monthsParse) {
+ this._monthsParse = [];
+ this._longMonthsParse = [];
+ this._shortMonthsParse = [];
+ }
+
+ for (i = 0; i < 12; i++) {
+ // make the regex if we don't have it already
+ mom = create_utc__createUTC([2000, i]);
+ if (strict && !this._longMonthsParse[i]) {
+ this._longMonthsParse[i] = new RegExp('^' + this.months(mom, '').replace('.', '') + '$', 'i');
+ this._shortMonthsParse[i] = new RegExp('^' + this.monthsShort(mom, '').replace('.', '') + '$', 'i');
+ }
+ if (!strict && !this._monthsParse[i]) {
+ regex = '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, '');
+ this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i');
+ }
+ // test the regex
+ if (strict && format === 'MMMM' && this._longMonthsParse[i].test(monthName)) {
+ return i;
+ } else if (strict && format === 'MMM' && this._shortMonthsParse[i].test(monthName)) {
+ return i;
+ } else if (!strict && this._monthsParse[i].test(monthName)) {
+ return i;
+ }
+ }
+ }
+
+ // MOMENTS
+
+ function setMonth (mom, value) {
+ var dayOfMonth;
+
+ // TODO: Move this out of here!
+ if (typeof value === 'string') {
+ value = mom.localeData().monthsParse(value);
+ // TODO: Another silent failure?
+ if (typeof value !== 'number') {
+ return mom;
+ }
+ }
+
+ dayOfMonth = Math.min(mom.date(), daysInMonth(mom.year(), value));
+ mom._d['set' + (mom._isUTC ? 'UTC' : '') + 'Month'](value, dayOfMonth);
+ return mom;
+ }
+
+ function getSetMonth (value) {
+ if (value != null) {
+ setMonth(this, value);
+ utils_hooks__hooks.updateOffset(this, true);
+ return this;
+ } else {
+ return get_set__get(this, 'Month');
+ }
+ }
+
+ function getDaysInMonth () {
+ return daysInMonth(this.year(), this.month());
+ }
+
+ function checkOverflow (m) {
+ var overflow;
+ var a = m._a;
+
+ if (a && getParsingFlags(m).overflow === -2) {
+ overflow =
+ a[MONTH] < 0 || a[MONTH] > 11 ? MONTH :
+ a[DATE] < 1 || a[DATE] > daysInMonth(a[YEAR], a[MONTH]) ? DATE :
+ a[HOUR] < 0 || a[HOUR] > 24 || (a[HOUR] === 24 && (a[MINUTE] !== 0 || a[SECOND] !== 0 || a[MILLISECOND] !== 0)) ? HOUR :
+ a[MINUTE] < 0 || a[MINUTE] > 59 ? MINUTE :
+ a[SECOND] < 0 || a[SECOND] > 59 ? SECOND :
+ a[MILLISECOND] < 0 || a[MILLISECOND] > 999 ? MILLISECOND :
+ -1;
+
+ if (getParsingFlags(m)._overflowDayOfYear && (overflow < YEAR || overflow > DATE)) {
+ overflow = DATE;
+ }
+
+ getParsingFlags(m).overflow = overflow;
+ }
+
+ return m;
+ }
+
+ function warn(msg) {
+ if (utils_hooks__hooks.suppressDeprecationWarnings === false && typeof console !== 'undefined' && console.warn) {
+ // console.warn('Deprecation warning: ' + msg);
+ }
+ }
+
+ function deprecate(msg, fn) {
+ var firstTime = true;
+
+ return extend(function () {
+ if (firstTime) {
+ warn(msg + '\n' + (new Error()).stack);
+ firstTime = false;
+ }
+ return fn.apply(this, arguments);
+ }, fn);
+ }
+
+ var deprecations = {};
+
+ function deprecateSimple(name, msg) {
+ if (!deprecations[name]) {
+ warn(msg);
+ deprecations[name] = true;
+ }
+ }
+
+ utils_hooks__hooks.suppressDeprecationWarnings = false;
+
+ var from_string__isoRegex = /^\s*(?:[+-]\d{6}|\d{4})-(?:(\d\d-\d\d)|(W\d\d$)|(W\d\d-\d)|(\d\d\d))((T| )(\d\d(:\d\d(:\d\d(\.\d+)?)?)?)?([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/;
+
+ var isoDates = [
+ ['YYYYYY-MM-DD', /[+-]\d{6}-\d{2}-\d{2}/],
+ ['YYYY-MM-DD', /\d{4}-\d{2}-\d{2}/],
+ ['GGGG-[W]WW-E', /\d{4}-W\d{2}-\d/],
+ ['GGGG-[W]WW', /\d{4}-W\d{2}/],
+ ['YYYY-DDD', /\d{4}-\d{3}/]
+ ];
+
+ // iso time formats and regexes
+ var isoTimes = [
+ ['HH:mm:ss.SSSS', /(T| )\d\d:\d\d:\d\d\.\d+/],
+ ['HH:mm:ss', /(T| )\d\d:\d\d:\d\d/],
+ ['HH:mm', /(T| )\d\d:\d\d/],
+ ['HH', /(T| )\d\d/]
+ ];
+
+ var aspNetJsonRegex = /^\/?Date\((\-?\d+)/i;
+
+ // date from iso format
+ function configFromISO(config) {
+ var i, l,
+ string = config._i,
+ match = from_string__isoRegex.exec(string);
+
+ if (match) {
+ getParsingFlags(config).iso = true;
+ for (i = 0, l = isoDates.length; i < l; i++) {
+ if (isoDates[i][1].exec(string)) {
+ config._f = isoDates[i][0];
+ break;
+ }
+ }
+ for (i = 0, l = isoTimes.length; i < l; i++) {
+ if (isoTimes[i][1].exec(string)) {
+ // match[6] should be 'T' or space
+ config._f += (match[6] || ' ') + isoTimes[i][0];
+ break;
+ }
+ }
+ if (string.match(matchOffset)) {
+ config._f += 'Z';
+ }
+ configFromStringAndFormat(config);
+ } else {
+ config._isValid = false;
+ }
+ }
+
+ // date from iso format or fallback
+ function configFromString(config) {
+ var matched = aspNetJsonRegex.exec(config._i);
+
+ if (matched !== null) {
+ config._d = new Date(+matched[1]);
+ return;
+ }
+
+ configFromISO(config);
+ if (config._isValid === false) {
+ delete config._isValid;
+ utils_hooks__hooks.createFromInputFallback(config);
+ }
+ }
+
+ utils_hooks__hooks.createFromInputFallback = deprecate(
+ 'moment construction falls back to js Date. This is ' +
+ 'discouraged and will be removed in upcoming major ' +
+ 'release. Please refer to ' +
+ 'https://github.com/moment/moment/issues/1407 for more info.',
+ function (config) {
+ config._d = new Date(config._i + (config._useUTC ? ' UTC' : ''));
+ }
+ );
+
+ function createDate (y, m, d, h, M, s, ms) {
+ //can't just apply() to create a date:
+ //http://stackoverflow.com/questions/181348/instantiating-a-javascript-object-by-calling-prototype-constructor-apply
+ var date = new Date(y, m, d, h, M, s, ms);
+
+ //the date constructor doesn't accept years < 1970
+ if (y < 1970) {
+ date.setFullYear(y);
+ }
+ return date;
+ }
+
+ function createUTCDate (y) {
+ var date = new Date(Date.UTC.apply(null, arguments));
+ if (y < 1970) {
+ date.setUTCFullYear(y);
+ }
+ return date;
+ }
+
+ addFormatToken(0, ['YY', 2], 0, function () {
+ return this.year() % 100;
+ });
+
+ addFormatToken(0, ['YYYY', 4], 0, 'year');
+ addFormatToken(0, ['YYYYY', 5], 0, 'year');
+ addFormatToken(0, ['YYYYYY', 6, true], 0, 'year');
+
+ // ALIASES
+
+ addUnitAlias('year', 'y');
+
+ // PARSING
+
+ addRegexToken('Y', matchSigned);
+ addRegexToken('YY', match1to2, match2);
+ addRegexToken('YYYY', match1to4, match4);
+ addRegexToken('YYYYY', match1to6, match6);
+ addRegexToken('YYYYYY', match1to6, match6);
+
+ addParseToken(['YYYYY', 'YYYYYY'], YEAR);
+ addParseToken('YYYY', function (input, array) {
+ array[YEAR] = input.length === 2 ? utils_hooks__hooks.parseTwoDigitYear(input) : toInt(input);
+ });
+ addParseToken('YY', function (input, array) {
+ array[YEAR] = utils_hooks__hooks.parseTwoDigitYear(input);
+ });
+
+ // HELPERS
+
+ function daysInYear(year) {
+ return isLeapYear(year) ? 366 : 365;
+ }
+
+ function isLeapYear(year) {
+ return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
+ }
+
+ // HOOKS
+
+ utils_hooks__hooks.parseTwoDigitYear = function (input) {
+ return toInt(input) + (toInt(input) > 68 ? 1900 : 2000);
+ };
+
+ // MOMENTS
+
+ var getSetYear = makeGetSet('FullYear', false);
+
+ function getIsLeapYear () {
+ return isLeapYear(this.year());
+ }
+
+ addFormatToken('w', ['ww', 2], 'wo', 'week');
+ addFormatToken('W', ['WW', 2], 'Wo', 'isoWeek');
+
+ // ALIASES
+
+ addUnitAlias('week', 'w');
+ addUnitAlias('isoWeek', 'W');
+
+ // PARSING
+
+ addRegexToken('w', match1to2);
+ addRegexToken('ww', match1to2, match2);
+ addRegexToken('W', match1to2);
+ addRegexToken('WW', match1to2, match2);
+
+ addWeekParseToken(['w', 'ww', 'W', 'WW'], function (input, week, config, token) {
+ week[token.substr(0, 1)] = toInt(input);
+ });
+
+ // HELPERS
+
+ // firstDayOfWeek 0 = sun, 6 = sat
+ // the day of the week that starts the week
+ // (usually sunday or monday)
+ // firstDayOfWeekOfYear 0 = sun, 6 = sat
+ // the first week is the week that contains the first
+ // of this day of the week
+ // (eg. ISO weeks use thursday (4))
+ function weekOfYear(mom, firstDayOfWeek, firstDayOfWeekOfYear) {
+ var end = firstDayOfWeekOfYear - firstDayOfWeek,
+ daysToDayOfWeek = firstDayOfWeekOfYear - mom.day(),
+ adjustedMoment;
+
+
+ if (daysToDayOfWeek > end) {
+ daysToDayOfWeek -= 7;
+ }
+
+ if (daysToDayOfWeek < end - 7) {
+ daysToDayOfWeek += 7;
+ }
+
+ adjustedMoment = local__createLocal(mom).add(daysToDayOfWeek, 'd');
+ return {
+ week: Math.ceil(adjustedMoment.dayOfYear() / 7),
+ year: adjustedMoment.year()
+ };
+ }
+
+ // LOCALES
+
+ function localeWeek (mom) {
+ return weekOfYear(mom, this._week.dow, this._week.doy).week;
+ }
+
+ var defaultLocaleWeek = {
+ dow : 0, // Sunday is the first day of the week.
+ doy : 6 // The week that contains Jan 1st is the first week of the year.
+ };
+
+ function localeFirstDayOfWeek () {
+ return this._week.dow;
+ }
+
+ function localeFirstDayOfYear () {
+ return this._week.doy;
+ }
+
+ // MOMENTS
+
+ function getSetWeek (input) {
+ var week = this.localeData().week(this);
+ return input == null ? week : this.add((input - week) * 7, 'd');
+ }
+
+ function getSetISOWeek (input) {
+ var week = weekOfYear(this, 1, 4).week;
+ return input == null ? week : this.add((input - week) * 7, 'd');
+ }
+
+ addFormatToken('DDD', ['DDDD', 3], 'DDDo', 'dayOfYear');
+
+ // ALIASES
+
+ addUnitAlias('dayOfYear', 'DDD');
+
+ // PARSING
+
+ addRegexToken('DDD', match1to3);
+ addRegexToken('DDDD', match3);
+ addParseToken(['DDD', 'DDDD'], function (input, array, config) {
+ config._dayOfYear = toInt(input);
+ });
+
+ // HELPERS
+
+ //http://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday
+ function dayOfYearFromWeeks(year, week, weekday, firstDayOfWeekOfYear, firstDayOfWeek) {
+ var week1Jan = 6 + firstDayOfWeek - firstDayOfWeekOfYear, janX = createUTCDate(year, 0, 1 + week1Jan), d = janX.getUTCDay(), dayOfYear;
+ if (d < firstDayOfWeek) {
+ d += 7;
+ }
+
+ weekday = weekday != null ? 1 * weekday : firstDayOfWeek;
+
+ dayOfYear = 1 + week1Jan + 7 * (week - 1) - d + weekday;
+
+ return {
+ year: dayOfYear > 0 ? year : year - 1,
+ dayOfYear: dayOfYear > 0 ? dayOfYear : daysInYear(year - 1) + dayOfYear
+ };
+ }
+
+ // MOMENTS
+
+ function getSetDayOfYear (input) {
+ var dayOfYear = Math.round((this.clone().startOf('day') - this.clone().startOf('year')) / 864e5) + 1;
+ return input == null ? dayOfYear : this.add((input - dayOfYear), 'd');
+ }
+
+ // Pick the first defined of two or three arguments.
+ function defaults(a, b, c) {
+ if (a != null) {
+ return a;
+ }
+ if (b != null) {
+ return b;
+ }
+ return c;
+ }
+
+ function currentDateArray(config) {
+ var now = new Date();
+ if (config._useUTC) {
+ return [now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate()];
+ }
+ return [now.getFullYear(), now.getMonth(), now.getDate()];
+ }
+
+ // convert an array to a date.
+ // the array should mirror the parameters below
+ // note: all values past the year are optional and will default to the lowest possible value.
+ // [year, month, day , hour, minute, second, millisecond]
+ function configFromArray (config) {
+ var i, date, input = [], currentDate, yearToUse;
+
+ if (config._d) {
+ return;
+ }
+
+ currentDate = currentDateArray(config);
+
+ //compute day of the year from weeks and weekdays
+ if (config._w && config._a[DATE] == null && config._a[MONTH] == null) {
+ dayOfYearFromWeekInfo(config);
+ }
+
+ //if the day of the year is set, figure out what it is
+ if (config._dayOfYear) {
+ yearToUse = defaults(config._a[YEAR], currentDate[YEAR]);
+
+ if (config._dayOfYear > daysInYear(yearToUse)) {
+ getParsingFlags(config)._overflowDayOfYear = true;
+ }
+
+ date = createUTCDate(yearToUse, 0, config._dayOfYear);
+ config._a[MONTH] = date.getUTCMonth();
+ config._a[DATE] = date.getUTCDate();
+ }
+
+ // Default to current date.
+ // * if no year, month, day of month are given, default to today
+ // * if day of month is given, default month and year
+ // * if month is given, default only year
+ // * if year is given, don't default anything
+ for (i = 0; i < 3 && config._a[i] == null; ++i) {
+ config._a[i] = input[i] = currentDate[i];
+ }
+
+ // Zero out whatever was not defaulted, including time
+ for (; i < 7; i++) {
+ config._a[i] = input[i] = (config._a[i] == null) ? (i === 2 ? 1 : 0) : config._a[i];
+ }
+
+ // Check for 24:00:00.000
+ if (config._a[HOUR] === 24 &&
+ config._a[MINUTE] === 0 &&
+ config._a[SECOND] === 0 &&
+ config._a[MILLISECOND] === 0) {
+ config._nextDay = true;
+ config._a[HOUR] = 0;
+ }
+
+ config._d = (config._useUTC ? createUTCDate : createDate).apply(null, input);
+ // Apply timezone offset from input. The actual utcOffset can be changed
+ // with parseZone.
+ if (config._tzm != null) {
+ config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
+ }
+
+ if (config._nextDay) {
+ config._a[HOUR] = 24;
+ }
+ }
+
+ function dayOfYearFromWeekInfo(config) {
+ var w, weekYear, week, weekday, dow, doy, temp;
+
+ w = config._w;
+ if (w.GG != null || w.W != null || w.E != null) {
+ dow = 1;
+ doy = 4;
+
+ // TODO: We need to take the current isoWeekYear, but that depends on
+ // how we interpret now (local, utc, fixed offset). So create
+ // a now version of current config (take local/utc/offset flags, and
+ // create now).
+ weekYear = defaults(w.GG, config._a[YEAR], weekOfYear(local__createLocal(), 1, 4).year);
+ week = defaults(w.W, 1);
+ weekday = defaults(w.E, 1);
+ } else {
+ dow = config._locale._week.dow;
+ doy = config._locale._week.doy;
+
+ weekYear = defaults(w.gg, config._a[YEAR], weekOfYear(local__createLocal(), dow, doy).year);
+ week = defaults(w.w, 1);
+
+ if (w.d != null) {
+ // weekday -- low day numbers are considered next week
+ weekday = w.d;
+ if (weekday < dow) {
+ ++week;
+ }
+ } else if (w.e != null) {
+ // local weekday -- counting starts from begining of week
+ weekday = w.e + dow;
+ } else {
+ // default to begining of week
+ weekday = dow;
+ }
+ }
+ temp = dayOfYearFromWeeks(weekYear, week, weekday, doy, dow);
+
+ config._a[YEAR] = temp.year;
+ config._dayOfYear = temp.dayOfYear;
+ }
+
+ utils_hooks__hooks.ISO_8601 = function () {};
+
+ // date from string and format string
+ function configFromStringAndFormat(config) {
+ // TODO: Move this to another part of the creation flow to prevent circular deps
+ if (config._f === utils_hooks__hooks.ISO_8601) {
+ configFromISO(config);
+ return;
+ }
+
+ config._a = [];
+ getParsingFlags(config).empty = true;
+
+ // This array is used to make a Date, either with `new Date` or `Date.UTC`
+ var string = '' + config._i,
+ i, parsedInput, tokens, token, skipped,
+ stringLength = string.length,
+ totalParsedInputLength = 0;
+
+ tokens = expandFormat(config._f, config._locale).match(formattingTokens) || [];
+
+ for (i = 0; i < tokens.length; i++) {
+ token = tokens[i];
+ parsedInput = (string.match(getParseRegexForToken(token, config)) || [])[0];
+ if (parsedInput) {
+ skipped = string.substr(0, string.indexOf(parsedInput));
+ if (skipped.length > 0) {
+ getParsingFlags(config).unusedInput.push(skipped);
+ }
+ string = string.slice(string.indexOf(parsedInput) + parsedInput.length);
+ totalParsedInputLength += parsedInput.length;
+ }
+ // don't parse if it's not a known token
+ if (formatTokenFunctions[token]) {
+ if (parsedInput) {
+ getParsingFlags(config).empty = false;
+ }
+ else {
+ getParsingFlags(config).unusedTokens.push(token);
+ }
+ addTimeToArrayFromToken(token, parsedInput, config);
+ }
+ else if (config._strict && !parsedInput) {
+ getParsingFlags(config).unusedTokens.push(token);
+ }
+ }
+
+ // add remaining unparsed input length to the string
+ getParsingFlags(config).charsLeftOver = stringLength - totalParsedInputLength;
+ if (string.length > 0) {
+ getParsingFlags(config).unusedInput.push(string);
+ }
+
+ // clear _12h flag if hour is <= 12
+ if (getParsingFlags(config).bigHour === true &&
+ config._a[HOUR] <= 12 &&
+ config._a[HOUR] > 0) {
+ getParsingFlags(config).bigHour = undefined;
+ }
+ // handle meridiem
+ config._a[HOUR] = meridiemFixWrap(config._locale, config._a[HOUR], config._meridiem);
+
+ configFromArray(config);
+ checkOverflow(config);
+ }
+
+
+ function meridiemFixWrap (locale, hour, meridiem) {
+ var isPm;
+
+ if (meridiem == null) {
+ // nothing to do
+ return hour;
+ }
+ if (locale.meridiemHour != null) {
+ return locale.meridiemHour(hour, meridiem);
+ } else if (locale.isPM != null) {
+ // Fallback
+ isPm = locale.isPM(meridiem);
+ if (isPm && hour < 12) {
+ hour += 12;
+ }
+ if (!isPm && hour === 12) {
+ hour = 0;
+ }
+ return hour;
+ } else {
+ // this is not supposed to happen
+ return hour;
+ }
+ }
+
+ function configFromStringAndArray(config) {
+ var tempConfig,
+ bestMoment,
+
+ scoreToBeat,
+ i,
+ currentScore;
+
+ if (config._f.length === 0) {
+ getParsingFlags(config).invalidFormat = true;
+ config._d = new Date(NaN);
+ return;
+ }
+
+ for (i = 0; i < config._f.length; i++) {
+ currentScore = 0;
+ tempConfig = copyConfig({}, config);
+ if (config._useUTC != null) {
+ tempConfig._useUTC = config._useUTC;
+ }
+ tempConfig._f = config._f[i];
+ configFromStringAndFormat(tempConfig);
+
+ if (!valid__isValid(tempConfig)) {
+ continue;
+ }
+
+ // if there is any input that was not parsed add a penalty for that format
+ currentScore += getParsingFlags(tempConfig).charsLeftOver;
+
+ //or tokens
+ currentScore += getParsingFlags(tempConfig).unusedTokens.length * 10;
+
+ getParsingFlags(tempConfig).score = currentScore;
+
+ if (scoreToBeat == null || currentScore < scoreToBeat) {
+ scoreToBeat = currentScore;
+ bestMoment = tempConfig;
+ }
+ }
+
+ extend(config, bestMoment || tempConfig);
+ }
+
+ function configFromObject(config) {
+ if (config._d) {
+ return;
+ }
+
+ var i = normalizeObjectUnits(config._i);
+ config._a = [i.year, i.month, i.day || i.date, i.hour, i.minute, i.second, i.millisecond];
+
+ configFromArray(config);
+ }
+
+ function createFromConfig (config) {
+ var res = new Moment(checkOverflow(prepareConfig(config)));
+ if (res._nextDay) {
+ // Adding is smart enough around DST
+ res.add(1, 'd');
+ res._nextDay = undefined;
+ }
+
+ return res;
+ }
+
+ function prepareConfig (config) {
+ var input = config._i,
+ format = config._f;
+
+ config._locale = config._locale || locale_locales__getLocale(config._l);
+
+ if (input === null || (format === undefined && input === '')) {
+ return valid__createInvalid({nullInput: true});
+ }
+
+ if (typeof input === 'string') {
+ config._i = input = config._locale.preparse(input);
+ }
+
+ if (isMoment(input)) {
+ return new Moment(checkOverflow(input));
+ } else if (isArray(format)) {
+ configFromStringAndArray(config);
+ } else if (format) {
+ configFromStringAndFormat(config);
+ } else if (isDate(input)) {
+ config._d = input;
+ } else {
+ configFromInput(config);
+ }
+
+ return config;
+ }
+
+ function configFromInput(config) {
+ var input = config._i;
+ if (input === undefined) {
+ config._d = new Date();
+ } else if (isDate(input)) {
+ config._d = new Date(+input);
+ } else if (typeof input === 'string') {
+ configFromString(config);
+ } else if (isArray(input)) {
+ config._a = map(input.slice(0), function (obj) {
+ return parseInt(obj, 10);
+ });
+ configFromArray(config);
+ } else if (typeof(input) === 'object') {
+ configFromObject(config);
+ } else if (typeof(input) === 'number') {
+ // from milliseconds
+ config._d = new Date(input);
+ } else {
+ utils_hooks__hooks.createFromInputFallback(config);
+ }
+ }
+
+ function createLocalOrUTC (input, format, locale, strict, isUTC) {
+ var c = {};
+
+ if (typeof(locale) === 'boolean') {
+ strict = locale;
+ locale = undefined;
+ }
+ // object construction must be done this way.
+ // https://github.com/moment/moment/issues/1423
+ c._isAMomentObject = true;
+ c._useUTC = c._isUTC = isUTC;
+ c._l = locale;
+ c._i = input;
+ c._f = format;
+ c._strict = strict;
+
+ return createFromConfig(c);
+ }
+
+ function local__createLocal (input, format, locale, strict) {
+ return createLocalOrUTC(input, format, locale, strict, false);
+ }
+
+ var prototypeMin = deprecate(
+ 'moment().min is deprecated, use moment.min instead. https://github.com/moment/moment/issues/1548',
+ function () {
+ var other = local__createLocal.apply(null, arguments);
+ return other < this ? this : other;
+ }
+ );
+
+ var prototypeMax = deprecate(
+ 'moment().max is deprecated, use moment.max instead. https://github.com/moment/moment/issues/1548',
+ function () {
+ var other = local__createLocal.apply(null, arguments);
+ return other > this ? this : other;
+ }
+ );
+
+ // Pick a moment m from moments so that m[fn](other) is true for all
+ // other. This relies on the function fn to be transitive.
+ //
+ // moments should either be an array of moment objects or an array, whose
+ // first element is an array of moment objects.
+ function pickBy(fn, moments) {
+ var res, i;
+ if (moments.length === 1 && isArray(moments[0])) {
+ moments = moments[0];
+ }
+ if (!moments.length) {
+ return local__createLocal();
+ }
+ res = moments[0];
+ for (i = 1; i < moments.length; ++i) {
+ if (!moments[i].isValid() || moments[i][fn](res)) {
+ res = moments[i];
+ }
+ }
+ return res;
+ }
+
+ // TODO: Use [].sort instead?
+ function min () {
+ var args = [].slice.call(arguments, 0);
+
+ return pickBy('isBefore', args);
+ }
+
+ function max () {
+ var args = [].slice.call(arguments, 0);
+
+ return pickBy('isAfter', args);
+ }
+
+ function Duration (duration) {
+ var normalizedInput = normalizeObjectUnits(duration),
+ years = normalizedInput.year || 0,
+ quarters = normalizedInput.quarter || 0,
+ months = normalizedInput.month || 0,
+ weeks = normalizedInput.week || 0,
+ days = normalizedInput.day || 0,
+ hours = normalizedInput.hour || 0,
+ minutes = normalizedInput.minute || 0,
+ seconds = normalizedInput.second || 0,
+ milliseconds = normalizedInput.millisecond || 0;
+
+ // representation for dateAddRemove
+ this._milliseconds = +milliseconds +
+ seconds * 1e3 + // 1000
+ minutes * 6e4 + // 1000 * 60
+ hours * 36e5; // 1000 * 60 * 60
+ // Because of dateAddRemove treats 24 hours as different from a
+ // day when working around DST, we need to store them separately
+ this._days = +days +
+ weeks * 7;
+ // It is impossible translate months into days without knowing
+ // which months you are are talking about, so we have to store
+ // it separately.
+ this._months = +months +
+ quarters * 3 +
+ years * 12;
+
+ this._data = {};
+
+ this._locale = locale_locales__getLocale();
+
+ this._bubble();
+ }
+
+ function isDuration (obj) {
+ return obj instanceof Duration;
+ }
+
+ function offset (token, separator) {
+ addFormatToken(token, 0, 0, function () {
+ var offset = this.utcOffset();
+ var sign = '+';
+ if (offset < 0) {
+ offset = -offset;
+ sign = '-';
+ }
+ return sign + zeroFill(~~(offset / 60), 2) + separator + zeroFill(~~(offset) % 60, 2);
+ });
+ }
+
+ offset('Z', ':');
+ offset('ZZ', '');
+
+ // PARSING
+
+ addRegexToken('Z', matchOffset);
+ addRegexToken('ZZ', matchOffset);
+ addParseToken(['Z', 'ZZ'], function (input, array, config) {
+ config._useUTC = true;
+ config._tzm = offsetFromString(input);
+ });
+
+ // HELPERS
+
+ // timezone chunker
+ // '+10:00' > ['10', '00']
+ // '-1530' > ['-15', '30']
+ var chunkOffset = /([\+\-]|\d\d)/gi;
+
+ function offsetFromString(string) {
+ var matches = ((string || '').match(matchOffset) || []);
+ var chunk = matches[matches.length - 1] || [];
+ var parts = (chunk + '').match(chunkOffset) || ['-', 0, 0];
+ var minutes = +(parts[1] * 60) + toInt(parts[2]);
+
+ return parts[0] === '+' ? minutes : -minutes;
+ }
+
+ // Return a moment from input, that is local/utc/zone equivalent to model.
+ function cloneWithOffset(input, model) {
+ var res, diff;
+ if (model._isUTC) {
+ res = model.clone();
+ diff = (isMoment(input) || isDate(input) ? +input : +local__createLocal(input)) - (+res);
+ // Use low-level api, because this fn is low-level api.
+ res._d.setTime(+res._d + diff);
+ utils_hooks__hooks.updateOffset(res, false);
+ return res;
+ } else {
+ return local__createLocal(input).local();
+ }
+ }
+
+ function getDateOffset (m) {
+ // On Firefox.24 Date#getTimezoneOffset returns a floating point.
+ // https://github.com/moment/moment/pull/1871
+ return -Math.round(m._d.getTimezoneOffset() / 15) * 15;
+ }
+
+ // HOOKS
+
+ // This function will be called whenever a moment is mutated.
+ // It is intended to keep the offset in sync with the timezone.
+ utils_hooks__hooks.updateOffset = function () {};
+
+ // MOMENTS
+
+ // keepLocalTime = true means only change the timezone, without
+ // affecting the local hour. So 5:31:26 +0300 --[utcOffset(2, true)]-->
+ // 5:31:26 +0200 It is possible that 5:31:26 doesn't exist with offset
+ // +0200, so we adjust the time as needed, to be valid.
+ //
+ // Keeping the time actually adds/subtracts (one hour)
+ // from the actual represented time. That is why we call updateOffset
+ // a second time. In case it wants us to change the offset again
+ // _changeInProgress == true case, then we have to adjust, because
+ // there is no such time in the given timezone.
+ function getSetOffset (input, keepLocalTime) {
+ var offset = this._offset || 0,
+ localAdjust;
+ if (input != null) {
+ if (typeof input === 'string') {
+ input = offsetFromString(input);
+ }
+ if (Math.abs(input) < 16) {
+ input = input * 60;
+ }
+ if (!this._isUTC && keepLocalTime) {
+ localAdjust = getDateOffset(this);
+ }
+ this._offset = input;
+ this._isUTC = true;
+ if (localAdjust != null) {
+ this.add(localAdjust, 'm');
+ }
+ if (offset !== input) {
+ if (!keepLocalTime || this._changeInProgress) {
+ add_subtract__addSubtract(this, create__createDuration(input - offset, 'm'), 1, false);
+ } else if (!this._changeInProgress) {
+ this._changeInProgress = true;
+ utils_hooks__hooks.updateOffset(this, true);
+ this._changeInProgress = null;
+ }
+ }
+ return this;
+ } else {
+ return this._isUTC ? offset : getDateOffset(this);
+ }
+ }
+
+ function getSetZone (input, keepLocalTime) {
+ if (input != null) {
+ if (typeof input !== 'string') {
+ input = -input;
+ }
+
+ this.utcOffset(input, keepLocalTime);
+
+ return this;
+ } else {
+ return -this.utcOffset();
+ }
+ }
+
+ function setOffsetToUTC (keepLocalTime) {
+ return this.utcOffset(0, keepLocalTime);
+ }
+
+ function setOffsetToLocal (keepLocalTime) {
+ if (this._isUTC) {
+ this.utcOffset(0, keepLocalTime);
+ this._isUTC = false;
+
+ if (keepLocalTime) {
+ this.subtract(getDateOffset(this), 'm');
+ }
+ }
+ return this;
+ }
+
+ function setOffsetToParsedOffset () {
+ if (this._tzm) {
+ this.utcOffset(this._tzm);
+ } else if (typeof this._i === 'string') {
+ this.utcOffset(offsetFromString(this._i));
+ }
+ return this;
+ }
+
+ function hasAlignedHourOffset (input) {
+ input = input ? local__createLocal(input).utcOffset() : 0;
+
+ return (this.utcOffset() - input) % 60 === 0;
+ }
+
+ function isDaylightSavingTime () {
+ return (
+ this.utcOffset() > this.clone().month(0).utcOffset() ||
+ this.utcOffset() > this.clone().month(5).utcOffset()
+ );
+ }
+
+ function isDaylightSavingTimeShifted () {
+ if (typeof this._isDSTShifted !== 'undefined') {
+ return this._isDSTShifted;
+ }
+
+ var c = {};
+
+ copyConfig(c, this);
+ c = prepareConfig(c);
+
+ if (c._a) {
+ var other = c._isUTC ? create_utc__createUTC(c._a) : local__createLocal(c._a);
+ this._isDSTShifted = this.isValid() &&
+ compareArrays(c._a, other.toArray()) > 0;
+ } else {
+ this._isDSTShifted = false;
+ }
+
+ return this._isDSTShifted;
+ }
+
+ function isLocal () {
+ return !this._isUTC;
+ }
+
+ function isUtcOffset () {
+ return this._isUTC;
+ }
+
+ function isUtc () {
+ return this._isUTC && this._offset === 0;
+ }
+
+ var aspNetRegex = /(\-)?(?:(\d*)\.)?(\d+)\:(\d+)(?:\:(\d+)\.?(\d{3})?)?/;
+
+ // from http://docs.closure-library.googlecode.com/git/closure_goog_date_date.js.source.html
+ // somewhat more in line with 4.4.3.2 2004 spec, but allows decimal anywhere
+ var create__isoRegex = /^(-)?P(?:(?:([0-9,.]*)Y)?(?:([0-9,.]*)M)?(?:([0-9,.]*)D)?(?:T(?:([0-9,.]*)H)?(?:([0-9,.]*)M)?(?:([0-9,.]*)S)?)?|([0-9,.]*)W)$/;
+
+ function create__createDuration (input, key) {
+ var duration = input,
+ // matching against regexp is expensive, do it on demand
+ match = null,
+ sign,
+ ret,
+ diffRes;
+
+ if (isDuration(input)) {
+ duration = {
+ ms : input._milliseconds,
+ d : input._days,
+ M : input._months
+ };
+ } else if (typeof input === 'number') {
+ duration = {};
+ if (key) {
+ duration[key] = input;
+ } else {
+ duration.milliseconds = input;
+ }
+ } else if (!!(match = aspNetRegex.exec(input))) {
+ sign = (match[1] === '-') ? -1 : 1;
+ duration = {
+ y : 0,
+ d : toInt(match[DATE]) * sign,
+ h : toInt(match[HOUR]) * sign,
+ m : toInt(match[MINUTE]) * sign,
+ s : toInt(match[SECOND]) * sign,
+ ms : toInt(match[MILLISECOND]) * sign
+ };
+ } else if (!!(match = create__isoRegex.exec(input))) {
+ sign = (match[1] === '-') ? -1 : 1;
+ duration = {
+ y : parseIso(match[2], sign),
+ M : parseIso(match[3], sign),
+ d : parseIso(match[4], sign),
+ h : parseIso(match[5], sign),
+ m : parseIso(match[6], sign),
+ s : parseIso(match[7], sign),
+ w : parseIso(match[8], sign)
+ };
+ } else if (duration == null) {// checks for null or undefined
+ duration = {};
+ } else if (typeof duration === 'object' && ('from' in duration || 'to' in duration)) {
+ diffRes = momentsDifference(local__createLocal(duration.from), local__createLocal(duration.to));
+
+ duration = {};
+ duration.ms = diffRes.milliseconds;
+ duration.M = diffRes.months;
+ }
+
+ ret = new Duration(duration);
+
+ if (isDuration(input) && hasOwnProp(input, '_locale')) {
+ ret._locale = input._locale;
+ }
+
+ return ret;
+ }
+
+ create__createDuration.fn = Duration.prototype;
+
+ function parseIso (inp, sign) {
+ // We'd normally use ~~inp for this, but unfortunately it also
+ // converts floats to ints.
+ // inp may be undefined, so careful calling replace on it.
+ var res = inp && parseFloat(inp.replace(',', '.'));
+ // apply sign while we're at it
+ return (isNaN(res) ? 0 : res) * sign;
+ }
+
+ function positiveMomentsDifference(base, other) {
+ var res = {milliseconds: 0, months: 0};
+
+ res.months = other.month() - base.month() +
+ (other.year() - base.year()) * 12;
+ if (base.clone().add(res.months, 'M').isAfter(other)) {
+ --res.months;
+ }
+
+ res.milliseconds = +other - +(base.clone().add(res.months, 'M'));
+
+ return res;
+ }
+
+ function momentsDifference(base, other) {
+ var res;
+ other = cloneWithOffset(other, base);
+ if (base.isBefore(other)) {
+ res = positiveMomentsDifference(base, other);
+ } else {
+ res = positiveMomentsDifference(other, base);
+ res.milliseconds = -res.milliseconds;
+ res.months = -res.months;
+ }
+
+ return res;
+ }
+
+ function createAdder(direction, name) {
+ return function (val, period) {
+ var dur, tmp;
+ //invert the arguments, but complain about it
+ if (period !== null && !isNaN(+period)) {
+ deprecateSimple(name, 'moment().' + name + '(period, number) is deprecated. Please use moment().' + name + '(number, period).');
+ tmp = val; val = period; period = tmp;
+ }
+
+ val = typeof val === 'string' ? +val : val;
+ dur = create__createDuration(val, period);
+ add_subtract__addSubtract(this, dur, direction);
+ return this;
+ };
+ }
+
+ function add_subtract__addSubtract (mom, duration, isAdding, updateOffset) {
+ var milliseconds = duration._milliseconds,
+ days = duration._days,
+ months = duration._months;
+ updateOffset = updateOffset == null ? true : updateOffset;
+
+ if (milliseconds) {
+ mom._d.setTime(+mom._d + milliseconds * isAdding);
+ }
+ if (days) {
+ get_set__set(mom, 'Date', get_set__get(mom, 'Date') + days * isAdding);
+ }
+ if (months) {
+ setMonth(mom, get_set__get(mom, 'Month') + months * isAdding);
+ }
+ if (updateOffset) {
+ utils_hooks__hooks.updateOffset(mom, days || months);
+ }
+ }
+
+ var add_subtract__add = createAdder(1, 'add');
+ var add_subtract__subtract = createAdder(-1, 'subtract');
+
+ function moment_calendar__calendar (time, formats) {
+ // We want to compare the start of today, vs this.
+ // Getting start-of-today depends on whether we're local/utc/offset or not.
+ var now = time || local__createLocal(),
+ sod = cloneWithOffset(now, this).startOf('day'),
+ diff = this.diff(sod, 'days', true),
+ format = diff < -6 ? 'sameElse' :
+ diff < -1 ? 'lastWeek' :
+ diff < 0 ? 'lastDay' :
+ diff < 1 ? 'sameDay' :
+ diff < 2 ? 'nextDay' :
+ diff < 7 ? 'nextWeek' : 'sameElse';
+ return this.format(formats && formats[format] || this.localeData().calendar(format, this, local__createLocal(now)));
+ }
+
+ function clone () {
+ return new Moment(this);
+ }
+
+ function isAfter (input, units) {
+ var inputMs;
+ units = normalizeUnits(typeof units !== 'undefined' ? units : 'millisecond');
+ if (units === 'millisecond') {
+ input = isMoment(input) ? input : local__createLocal(input);
+ return +this > +input;
+ } else {
+ inputMs = isMoment(input) ? +input : +local__createLocal(input);
+ return inputMs < +this.clone().startOf(units);
+ }
+ }
+
+ function isBefore (input, units) {
+ var inputMs;
+ units = normalizeUnits(typeof units !== 'undefined' ? units : 'millisecond');
+ if (units === 'millisecond') {
+ input = isMoment(input) ? input : local__createLocal(input);
+ return +this < +input;
+ } else {
+ inputMs = isMoment(input) ? +input : +local__createLocal(input);
+ return +this.clone().endOf(units) < inputMs;
+ }
+ }
+
+ function isBetween (from, to, units) {
+ return this.isAfter(from, units) && this.isBefore(to, units);
+ }
+
+ function isSame (input, units) {
+ var inputMs;
+ units = normalizeUnits(units || 'millisecond');
+ if (units === 'millisecond') {
+ input = isMoment(input) ? input : local__createLocal(input);
+ return +this === +input;
+ } else {
+ inputMs = +local__createLocal(input);
+ return +(this.clone().startOf(units)) <= inputMs && inputMs <= +(this.clone().endOf(units));
+ }
+ }
+
+ function diff (input, units, asFloat) {
+ var that = cloneWithOffset(input, this),
+ zoneDelta = (that.utcOffset() - this.utcOffset()) * 6e4,
+ delta, output;
+
+ units = normalizeUnits(units);
+
+ if (units === 'year' || units === 'month' || units === 'quarter') {
+ output = monthDiff(this, that);
+ if (units === 'quarter') {
+ output = output / 3;
+ } else if (units === 'year') {
+ output = output / 12;
+ }
+ } else {
+ delta = this - that;
+ output = units === 'second' ? delta / 1e3 : // 1000
+ units === 'minute' ? delta / 6e4 : // 1000 * 60
+ units === 'hour' ? delta / 36e5 : // 1000 * 60 * 60
+ units === 'day' ? (delta - zoneDelta) / 864e5 : // 1000 * 60 * 60 * 24, negate dst
+ units === 'week' ? (delta - zoneDelta) / 6048e5 : // 1000 * 60 * 60 * 24 * 7, negate dst
+ delta;
+ }
+ return asFloat ? output : absFloor(output);
+ }
+
+ function monthDiff (a, b) {
+ // difference in months
+ var wholeMonthDiff = ((b.year() - a.year()) * 12) + (b.month() - a.month()),
+ // b is in (anchor - 1 month, anchor + 1 month)
+ anchor = a.clone().add(wholeMonthDiff, 'months'),
+ anchor2, adjust;
+
+ if (b - anchor < 0) {
+ anchor2 = a.clone().add(wholeMonthDiff - 1, 'months');
+ // linear across the month
+ adjust = (b - anchor) / (anchor - anchor2);
+ } else {
+ anchor2 = a.clone().add(wholeMonthDiff + 1, 'months');
+ // linear across the month
+ adjust = (b - anchor) / (anchor2 - anchor);
+ }
+
+ return -(wholeMonthDiff + adjust);
+ }
+
+ utils_hooks__hooks.defaultFormat = 'YYYY-MM-DDTHH:mm:ssZ';
+
+ function toString () {
+ return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ');
+ }
+
+ function moment_format__toISOString () {
+ var m = this.clone().utc();
+ if (0 < m.year() && m.year() <= 9999) {
+ if ('function' === typeof Date.prototype.toISOString) {
+ // native implementation is ~50x faster, use it when we can
+ return this.toDate().toISOString();
+ } else {
+ return formatMoment(m, 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]');
+ }
+ } else {
+ return formatMoment(m, 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]');
+ }
+ }
+
+ function format (inputString) {
+ var output = formatMoment(this, inputString || utils_hooks__hooks.defaultFormat);
+ return this.localeData().postformat(output);
+ }
+
+ function from (time, withoutSuffix) {
+ if (!this.isValid()) {
+ return this.localeData().invalidDate();
+ }
+ return create__createDuration({to: this, from: time}).locale(this.locale()).humanize(!withoutSuffix);
+ }
+
+ function fromNow (withoutSuffix) {
+ return this.from(local__createLocal(), withoutSuffix);
+ }
+
+ function to (time, withoutSuffix) {
+ if (!this.isValid()) {
+ return this.localeData().invalidDate();
+ }
+ return create__createDuration({from: this, to: time}).locale(this.locale()).humanize(!withoutSuffix);
+ }
+
+ function toNow (withoutSuffix) {
+ return this.to(local__createLocal(), withoutSuffix);
+ }
+
+ function locale (key) {
+ var newLocaleData;
+
+ if (key === undefined) {
+ return this._locale._abbr;
+ } else {
+ newLocaleData = locale_locales__getLocale(key);
+ if (newLocaleData != null) {
+ this._locale = newLocaleData;
+ }
+ return this;
+ }
+ }
+
+ var lang = deprecate(
+ 'moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.',
+ function (key) {
+ if (key === undefined) {
+ return this.localeData();
+ } else {
+ return this.locale(key);
+ }
+ }
+ );
+
+ function localeData () {
+ return this._locale;
+ }
+
+ function startOf (units) {
+ units = normalizeUnits(units);
+ // the following switch intentionally omits break keywords
+ // to utilize falling through the cases.
+ switch (units) {
+ case 'year':
+ this.month(0);
+ /* falls through */
+ case 'quarter':
+ case 'month':
+ this.date(1);
+ /* falls through */
+ case 'week':
+ case 'isoWeek':
+ case 'day':
+ this.hours(0);
+ /* falls through */
+ case 'hour':
+ this.minutes(0);
+ /* falls through */
+ case 'minute':
+ this.seconds(0);
+ /* falls through */
+ case 'second':
+ this.milliseconds(0);
+ }
+
+ // weeks are a special case
+ if (units === 'week') {
+ this.weekday(0);
+ }
+ if (units === 'isoWeek') {
+ this.isoWeekday(1);
+ }
+
+ // quarters are also special
+ if (units === 'quarter') {
+ this.month(Math.floor(this.month() / 3) * 3);
+ }
+
+ return this;
+ }
+
+ function endOf (units) {
+ units = normalizeUnits(units);
+ if (units === undefined || units === 'millisecond') {
+ return this;
+ }
+ return this.startOf(units).add(1, (units === 'isoWeek' ? 'week' : units)).subtract(1, 'ms');
+ }
+
+ function to_type__valueOf () {
+ return +this._d - ((this._offset || 0) * 60000);
+ }
+
+ function unix () {
+ return Math.floor(+this / 1000);
+ }
+
+ function toDate () {
+ return this._offset ? new Date(+this) : this._d;
+ }
+
+ function toArray () {
+ var m = this;
+ return [m.year(), m.month(), m.date(), m.hour(), m.minute(), m.second(), m.millisecond()];
+ }
+
+ function toObject () {
+ var m = this;
+ return {
+ years: m.year(),
+ months: m.month(),
+ date: m.date(),
+ hours: m.hours(),
+ minutes: m.minutes(),
+ seconds: m.seconds(),
+ milliseconds: m.milliseconds()
+ };
+ }
+
+ function moment_valid__isValid () {
+ return valid__isValid(this);
+ }
+
+ function parsingFlags () {
+ return extend({}, getParsingFlags(this));
+ }
+
+ function invalidAt () {
+ return getParsingFlags(this).overflow;
+ }
+
+ addFormatToken(0, ['gg', 2], 0, function () {
+ return this.weekYear() % 100;
+ });
+
+ addFormatToken(0, ['GG', 2], 0, function () {
+ return this.isoWeekYear() % 100;
+ });
+
+ function addWeekYearFormatToken (token, getter) {
+ addFormatToken(0, [token, token.length], 0, getter);
+ }
+
+ addWeekYearFormatToken('gggg', 'weekYear');
+ addWeekYearFormatToken('ggggg', 'weekYear');
+ addWeekYearFormatToken('GGGG', 'isoWeekYear');
+ addWeekYearFormatToken('GGGGG', 'isoWeekYear');
+
+ // ALIASES
+
+ addUnitAlias('weekYear', 'gg');
+ addUnitAlias('isoWeekYear', 'GG');
+
+ // PARSING
+
+ addRegexToken('G', matchSigned);
+ addRegexToken('g', matchSigned);
+ addRegexToken('GG', match1to2, match2);
+ addRegexToken('gg', match1to2, match2);
+ addRegexToken('GGGG', match1to4, match4);
+ addRegexToken('gggg', match1to4, match4);
+ addRegexToken('GGGGG', match1to6, match6);
+ addRegexToken('ggggg', match1to6, match6);
+
+ addWeekParseToken(['gggg', 'ggggg', 'GGGG', 'GGGGG'], function (input, week, config, token) {
+ week[token.substr(0, 2)] = toInt(input);
+ });
+
+ addWeekParseToken(['gg', 'GG'], function (input, week, config, token) {
+ week[token] = utils_hooks__hooks.parseTwoDigitYear(input);
+ });
+
+ // HELPERS
+
+ function weeksInYear(year, dow, doy) {
+ return weekOfYear(local__createLocal([year, 11, 31 + dow - doy]), dow, doy).week;
+ }
+
+ // MOMENTS
+
+ function getSetWeekYear (input) {
+ var year = weekOfYear(this, this.localeData()._week.dow, this.localeData()._week.doy).year;
+ return input == null ? year : this.add((input - year), 'y');
+ }
+
+ function getSetISOWeekYear (input) {
+ var year = weekOfYear(this, 1, 4).year;
+ return input == null ? year : this.add((input - year), 'y');
+ }
+
+ function getISOWeeksInYear () {
+ return weeksInYear(this.year(), 1, 4);
+ }
+
+ function getWeeksInYear () {
+ var weekInfo = this.localeData()._week;
+ return weeksInYear(this.year(), weekInfo.dow, weekInfo.doy);
+ }
+
+ addFormatToken('Q', 0, 0, 'quarter');
+
+ // ALIASES
+
+ addUnitAlias('quarter', 'Q');
+
+ // PARSING
+
+ addRegexToken('Q', match1);
+ addParseToken('Q', function (input, array) {
+ array[MONTH] = (toInt(input) - 1) * 3;
+ });
+
+ // MOMENTS
+
+ function getSetQuarter (input) {
+ return input == null ? Math.ceil((this.month() + 1) / 3) : this.month((input - 1) * 3 + this.month() % 3);
+ }
+
+ addFormatToken('D', ['DD', 2], 'Do', 'date');
+
+ // ALIASES
+
+ addUnitAlias('date', 'D');
+
+ // PARSING
+
+ addRegexToken('D', match1to2);
+ addRegexToken('DD', match1to2, match2);
+ addRegexToken('Do', function (isStrict, locale) {
+ return isStrict ? locale._ordinalParse : locale._ordinalParseLenient;
+ });
+
+ addParseToken(['D', 'DD'], DATE);
+ addParseToken('Do', function (input, array) {
+ array[DATE] = toInt(input.match(match1to2)[0], 10);
+ });
+
+ // MOMENTS
+
+ var getSetDayOfMonth = makeGetSet('Date', true);
+
+ addFormatToken('d', 0, 'do', 'day');
+
+ addFormatToken('dd', 0, 0, function (format) {
+ return this.localeData().weekdaysMin(this, format);
+ });
+
+ addFormatToken('ddd', 0, 0, function (format) {
+ return this.localeData().weekdaysShort(this, format);
+ });
+
+ addFormatToken('dddd', 0, 0, function (format) {
+ return this.localeData().weekdays(this, format);
+ });
+
+ addFormatToken('e', 0, 0, 'weekday');
+ addFormatToken('E', 0, 0, 'isoWeekday');
+
+ // ALIASES
+
+ addUnitAlias('day', 'd');
+ addUnitAlias('weekday', 'e');
+ addUnitAlias('isoWeekday', 'E');
+
+ // PARSING
+
+ addRegexToken('d', match1to2);
+ addRegexToken('e', match1to2);
+ addRegexToken('E', match1to2);
+ addRegexToken('dd', matchWord);
+ addRegexToken('ddd', matchWord);
+ addRegexToken('dddd', matchWord);
+
+ addWeekParseToken(['dd', 'ddd', 'dddd'], function (input, week, config) {
+ var weekday = config._locale.weekdaysParse(input);
+ // if we didn't get a weekday name, mark the date as invalid
+ if (weekday != null) {
+ week.d = weekday;
+ } else {
+ getParsingFlags(config).invalidWeekday = input;
+ }
+ });
+
+ addWeekParseToken(['d', 'e', 'E'], function (input, week, config, token) {
+ week[token] = toInt(input);
+ });
+
+ // HELPERS
+
+ function parseWeekday(input, locale) {
+ if (typeof input !== 'string') {
+ return input;
+ }
+
+ if (!isNaN(input)) {
+ return parseInt(input, 10);
+ }
+
+ input = locale.weekdaysParse(input);
+ if (typeof input === 'number') {
+ return input;
+ }
+
+ return null;
+ }
+
+ // LOCALES
+
+ var defaultLocaleWeekdays = 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_');
+ function localeWeekdays (m) {
+ return this._weekdays[m.day()];
+ }
+
+ var defaultLocaleWeekdaysShort = 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_');
+ function localeWeekdaysShort (m) {
+ return this._weekdaysShort[m.day()];
+ }
+
+ var defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_');
+ function localeWeekdaysMin (m) {
+ return this._weekdaysMin[m.day()];
+ }
+
+ function localeWeekdaysParse (weekdayName) {
+ var i, mom, regex;
+
+ this._weekdaysParse = this._weekdaysParse || [];
+
+ for (i = 0; i < 7; i++) {
+ // make the regex if we don't have it already
+ if (!this._weekdaysParse[i]) {
+ mom = local__createLocal([2000, 1]).day(i);
+ regex = '^' + this.weekdays(mom, '') + '|^' + this.weekdaysShort(mom, '') + '|^' + this.weekdaysMin(mom, '');
+ this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i');
+ }
+ // test the regex
+ if (this._weekdaysParse[i].test(weekdayName)) {
+ return i;
+ }
+ }
+ }
+
+ // MOMENTS
+
+ function getSetDayOfWeek (input) {
+ var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay();
+ if (input != null) {
+ input = parseWeekday(input, this.localeData());
+ return this.add(input - day, 'd');
+ } else {
+ return day;
+ }
+ }
+
+ function getSetLocaleDayOfWeek (input) {
+ var weekday = (this.day() + 7 - this.localeData()._week.dow) % 7;
+ return input == null ? weekday : this.add(input - weekday, 'd');
+ }
+
+ function getSetISODayOfWeek (input) {
+ // behaves the same as moment#day except
+ // as a getter, returns 7 instead of 0 (1-7 range instead of 0-6)
+ // as a setter, sunday should belong to the previous week.
+ return input == null ? this.day() || 7 : this.day(this.day() % 7 ? input : input - 7);
+ }
+
+ addFormatToken('H', ['HH', 2], 0, 'hour');
+ addFormatToken('h', ['hh', 2], 0, function () {
+ return this.hours() % 12 || 12;
+ });
+
+ function meridiem (token, lowercase) {
+ addFormatToken(token, 0, 0, function () {
+ return this.localeData().meridiem(this.hours(), this.minutes(), lowercase);
+ });
+ }
+
+ meridiem('a', true);
+ meridiem('A', false);
+
+ // ALIASES
+
+ addUnitAlias('hour', 'h');
+
+ // PARSING
+
+ function matchMeridiem (isStrict, locale) {
+ return locale._meridiemParse;
+ }
+
+ addRegexToken('a', matchMeridiem);
+ addRegexToken('A', matchMeridiem);
+ addRegexToken('H', match1to2);
+ addRegexToken('h', match1to2);
+ addRegexToken('HH', match1to2, match2);
+ addRegexToken('hh', match1to2, match2);
+
+ addParseToken(['H', 'HH'], HOUR);
+ addParseToken(['a', 'A'], function (input, array, config) {
+ config._isPm = config._locale.isPM(input);
+ config._meridiem = input;
+ });
+ addParseToken(['h', 'hh'], function (input, array, config) {
+ array[HOUR] = toInt(input);
+ getParsingFlags(config).bigHour = true;
+ });
+
+ // LOCALES
+
+ function localeIsPM (input) {
+ // IE8 Quirks Mode & IE7 Standards Mode do not allow accessing strings like arrays
+ // Using charAt should be more compatible.
+ return ((input + '').toLowerCase().charAt(0) === 'p');
+ }
+
+ var defaultLocaleMeridiemParse = /[ap]\.?m?\.?/i;
+ function localeMeridiem (hours, minutes, isLower) {
+ if (hours > 11) {
+ return isLower ? 'pm' : 'PM';
+ } else {
+ return isLower ? 'am' : 'AM';
+ }
+ }
+
+
+ // MOMENTS
+
+ // Setting the hour should keep the time, because the user explicitly
+ // specified which hour he wants. So trying to maintain the same hour (in
+ // a new timezone) makes sense. Adding/subtracting hours does not follow
+ // this rule.
+ var getSetHour = makeGetSet('Hours', true);
+
+ addFormatToken('m', ['mm', 2], 0, 'minute');
+
+ // ALIASES
+
+ addUnitAlias('minute', 'm');
+
+ // PARSING
+
+ addRegexToken('m', match1to2);
+ addRegexToken('mm', match1to2, match2);
+ addParseToken(['m', 'mm'], MINUTE);
+
+ // MOMENTS
+
+ var getSetMinute = makeGetSet('Minutes', false);
+
+ addFormatToken('s', ['ss', 2], 0, 'second');
+
+ // ALIASES
+
+ addUnitAlias('second', 's');
+
+ // PARSING
+
+ addRegexToken('s', match1to2);
+ addRegexToken('ss', match1to2, match2);
+ addParseToken(['s', 'ss'], SECOND);
+
+ // MOMENTS
+
+ var getSetSecond = makeGetSet('Seconds', false);
+
+ addFormatToken('S', 0, 0, function () {
+ return ~~(this.millisecond() / 100);
+ });
+
+ addFormatToken(0, ['SS', 2], 0, function () {
+ return ~~(this.millisecond() / 10);
+ });
+
+ addFormatToken(0, ['SSS', 3], 0, 'millisecond');
+ addFormatToken(0, ['SSSS', 4], 0, function () {
+ return this.millisecond() * 10;
+ });
+ addFormatToken(0, ['SSSSS', 5], 0, function () {
+ return this.millisecond() * 100;
+ });
+ addFormatToken(0, ['SSSSSS', 6], 0, function () {
+ return this.millisecond() * 1000;
+ });
+ addFormatToken(0, ['SSSSSSS', 7], 0, function () {
+ return this.millisecond() * 10000;
+ });
+ addFormatToken(0, ['SSSSSSSS', 8], 0, function () {
+ return this.millisecond() * 100000;
+ });
+ addFormatToken(0, ['SSSSSSSSS', 9], 0, function () {
+ return this.millisecond() * 1000000;
+ });
+
+
+ // ALIASES
+
+ addUnitAlias('millisecond', 'ms');
+
+ // PARSING
+
+ addRegexToken('S', match1to3, match1);
+ addRegexToken('SS', match1to3, match2);
+ addRegexToken('SSS', match1to3, match3);
+
+ var token;
+ for (token = 'SSSS'; token.length <= 9; token += 'S') {
+ addRegexToken(token, matchUnsigned);
+ }
+
+ function parseMs(input, array) {
+ array[MILLISECOND] = toInt(('0.' + input) * 1000);
+ }
+
+ for (token = 'S'; token.length <= 9; token += 'S') {
+ addParseToken(token, parseMs);
+ }
+ // MOMENTS
+
+ var getSetMillisecond = makeGetSet('Milliseconds', false);
+
+ addFormatToken('z', 0, 0, 'zoneAbbr');
+ addFormatToken('zz', 0, 0, 'zoneName');
+
+ // MOMENTS
+
+ function getZoneAbbr () {
+ return this._isUTC ? 'UTC' : '';
+ }
+
+ function getZoneName () {
+ return this._isUTC ? 'Coordinated Universal Time' : '';
+ }
+
+ var momentPrototype__proto = Moment.prototype;
+
+ momentPrototype__proto.add = add_subtract__add;
+ momentPrototype__proto.calendar = moment_calendar__calendar;
+ momentPrototype__proto.clone = clone;
+ momentPrototype__proto.diff = diff;
+ momentPrototype__proto.endOf = endOf;
+ momentPrototype__proto.format = format;
+ momentPrototype__proto.from = from;
+ momentPrototype__proto.fromNow = fromNow;
+ momentPrototype__proto.to = to;
+ momentPrototype__proto.toNow = toNow;
+ momentPrototype__proto.get = getSet;
+ momentPrototype__proto.invalidAt = invalidAt;
+ momentPrototype__proto.isAfter = isAfter;
+ momentPrototype__proto.isBefore = isBefore;
+ momentPrototype__proto.isBetween = isBetween;
+ momentPrototype__proto.isSame = isSame;
+ momentPrototype__proto.isValid = moment_valid__isValid;
+ momentPrototype__proto.lang = lang;
+ momentPrototype__proto.locale = locale;
+ momentPrototype__proto.localeData = localeData;
+ momentPrototype__proto.max = prototypeMax;
+ momentPrototype__proto.min = prototypeMin;
+ momentPrototype__proto.parsingFlags = parsingFlags;
+ momentPrototype__proto.set = getSet;
+ momentPrototype__proto.startOf = startOf;
+ momentPrototype__proto.subtract = add_subtract__subtract;
+ momentPrototype__proto.toArray = toArray;
+ momentPrototype__proto.toObject = toObject;
+ momentPrototype__proto.toDate = toDate;
+ momentPrototype__proto.toISOString = moment_format__toISOString;
+ momentPrototype__proto.toJSON = moment_format__toISOString;
+ momentPrototype__proto.toString = toString;
+ momentPrototype__proto.unix = unix;
+ momentPrototype__proto.valueOf = to_type__valueOf;
+
+ // Year
+ momentPrototype__proto.year = getSetYear;
+ momentPrototype__proto.isLeapYear = getIsLeapYear;
+
+ // Week Year
+ momentPrototype__proto.weekYear = getSetWeekYear;
+ momentPrototype__proto.isoWeekYear = getSetISOWeekYear;
+
+ // Quarter
+ momentPrototype__proto.quarter = momentPrototype__proto.quarters = getSetQuarter;
+
+ // Month
+ momentPrototype__proto.month = getSetMonth;
+ momentPrototype__proto.daysInMonth = getDaysInMonth;
+
+ // Week
+ momentPrototype__proto.week = momentPrototype__proto.weeks = getSetWeek;
+ momentPrototype__proto.isoWeek = momentPrototype__proto.isoWeeks = getSetISOWeek;
+ momentPrototype__proto.weeksInYear = getWeeksInYear;
+ momentPrototype__proto.isoWeeksInYear = getISOWeeksInYear;
+
+ // Day
+ momentPrototype__proto.date = getSetDayOfMonth;
+ momentPrototype__proto.day = momentPrototype__proto.days = getSetDayOfWeek;
+ momentPrototype__proto.weekday = getSetLocaleDayOfWeek;
+ momentPrototype__proto.isoWeekday = getSetISODayOfWeek;
+ momentPrototype__proto.dayOfYear = getSetDayOfYear;
+
+ // Hour
+ momentPrototype__proto.hour = momentPrototype__proto.hours = getSetHour;
+
+ // Minute
+ momentPrototype__proto.minute = momentPrototype__proto.minutes = getSetMinute;
+
+ // Second
+ momentPrototype__proto.second = momentPrototype__proto.seconds = getSetSecond;
+
+ // Millisecond
+ momentPrototype__proto.millisecond = momentPrototype__proto.milliseconds = getSetMillisecond;
+
+ // Offset
+ momentPrototype__proto.utcOffset = getSetOffset;
+ momentPrototype__proto.utc = setOffsetToUTC;
+ momentPrototype__proto.local = setOffsetToLocal;
+ momentPrototype__proto.parseZone = setOffsetToParsedOffset;
+ momentPrototype__proto.hasAlignedHourOffset = hasAlignedHourOffset;
+ momentPrototype__proto.isDST = isDaylightSavingTime;
+ momentPrototype__proto.isDSTShifted = isDaylightSavingTimeShifted;
+ momentPrototype__proto.isLocal = isLocal;
+ momentPrototype__proto.isUtcOffset = isUtcOffset;
+ momentPrototype__proto.isUtc = isUtc;
+ momentPrototype__proto.isUTC = isUtc;
+
+ // Timezone
+ momentPrototype__proto.zoneAbbr = getZoneAbbr;
+ momentPrototype__proto.zoneName = getZoneName;
+
+ // Deprecations
+ momentPrototype__proto.dates = deprecate('dates accessor is deprecated. Use date instead.', getSetDayOfMonth);
+ momentPrototype__proto.months = deprecate('months accessor is deprecated. Use month instead', getSetMonth);
+ momentPrototype__proto.years = deprecate('years accessor is deprecated. Use year instead', getSetYear);
+ momentPrototype__proto.zone = deprecate('moment().zone is deprecated, use moment().utcOffset instead. https://github.com/moment/moment/issues/1779', getSetZone);
+
+ var momentPrototype = momentPrototype__proto;
+
+ function moment__createUnix (input) {
+ return local__createLocal(input * 1000);
+ }
+
+ function moment__createInZone () {
+ return local__createLocal.apply(null, arguments).parseZone();
+ }
+
+ var defaultCalendar = {
+ sameDay : '[Today at] LT',
+ nextDay : '[Tomorrow at] LT',
+ nextWeek : 'dddd [at] LT',
+ lastDay : '[Yesterday at] LT',
+ lastWeek : '[Last] dddd [at] LT',
+ sameElse : 'L'
+ };
+
+ function locale_calendar__calendar (key, mom, now) {
+ var output = this._calendar[key];
+ return typeof output === 'function' ? output.call(mom, now) : output;
+ }
+
+ var defaultLongDateFormat = {
+ LTS : 'h:mm:ss A',
+ LT : 'h:mm A',
+ L : 'MM/DD/YYYY',
+ LL : 'MMMM D, YYYY',
+ LLL : 'MMMM D, YYYY h:mm A',
+ LLLL : 'dddd, MMMM D, YYYY h:mm A'
+ };
+
+ function longDateFormat (key) {
+ var format = this._longDateFormat[key],
+ formatUpper = this._longDateFormat[key.toUpperCase()];
+
+ if (format || !formatUpper) {
+ return format;
+ }
+
+ this._longDateFormat[key] = formatUpper.replace(/MMMM|MM|DD|dddd/g, function (val) {
+ return val.slice(1);
+ });
+
+ return this._longDateFormat[key];
+ }
+
+ var defaultInvalidDate = 'Invalid date';
+
+ function invalidDate () {
+ return this._invalidDate;
+ }
+
+ var defaultOrdinal = '%d';
+ var defaultOrdinalParse = /\d{1,2}/;
+
+ function ordinal (number) {
+ return this._ordinal.replace('%d', number);
+ }
+
+ function preParsePostFormat (string) {
+ return string;
+ }
+
+ var defaultRelativeTime = {
+ future : 'in %s',
+ past : '%s ago',
+ s : 'a few seconds',
+ m : 'a minute',
+ mm : '%d minutes',
+ h : 'an hour',
+ hh : '%d hours',
+ d : 'a day',
+ dd : '%d days',
+ M : 'a month',
+ MM : '%d months',
+ y : 'a year',
+ yy : '%d years'
+ };
+
+ function relative__relativeTime (number, withoutSuffix, string, isFuture) {
+ var output = this._relativeTime[string];
+ return (typeof output === 'function') ?
+ output(number, withoutSuffix, string, isFuture) :
+ output.replace(/%d/i, number);
+ }
+
+ function pastFuture (diff, output) {
+ var format = this._relativeTime[diff > 0 ? 'future' : 'past'];
+ return typeof format === 'function' ? format(output) : format.replace(/%s/i, output);
+ }
+
+ function locale_set__set (config) {
+ var prop, i;
+ for (i in config) {
+ prop = config[i];
+ if (typeof prop === 'function') {
+ this[i] = prop;
+ } else {
+ this['_' + i] = prop;
+ }
+ }
+ // Lenient ordinal parsing accepts just a number in addition to
+ // number + (possibly) stuff coming from _ordinalParseLenient.
+ this._ordinalParseLenient = new RegExp(this._ordinalParse.source + '|' + (/\d{1,2}/).source);
+ }
+
+ var prototype__proto = Locale.prototype;
+
+ prototype__proto._calendar = defaultCalendar;
+ prototype__proto.calendar = locale_calendar__calendar;
+ prototype__proto._longDateFormat = defaultLongDateFormat;
+ prototype__proto.longDateFormat = longDateFormat;
+ prototype__proto._invalidDate = defaultInvalidDate;
+ prototype__proto.invalidDate = invalidDate;
+ prototype__proto._ordinal = defaultOrdinal;
+ prototype__proto.ordinal = ordinal;
+ prototype__proto._ordinalParse = defaultOrdinalParse;
+ prototype__proto.preparse = preParsePostFormat;
+ prototype__proto.postformat = preParsePostFormat;
+ prototype__proto._relativeTime = defaultRelativeTime;
+ prototype__proto.relativeTime = relative__relativeTime;
+ prototype__proto.pastFuture = pastFuture;
+ prototype__proto.set = locale_set__set;
+
+ // Month
+ prototype__proto.months = localeMonths;
+ prototype__proto._months = defaultLocaleMonths;
+ prototype__proto.monthsShort = localeMonthsShort;
+ prototype__proto._monthsShort = defaultLocaleMonthsShort;
+ prototype__proto.monthsParse = localeMonthsParse;
+
+ // Week
+ prototype__proto.week = localeWeek;
+ prototype__proto._week = defaultLocaleWeek;
+ prototype__proto.firstDayOfYear = localeFirstDayOfYear;
+ prototype__proto.firstDayOfWeek = localeFirstDayOfWeek;
+
+ // Day of Week
+ prototype__proto.weekdays = localeWeekdays;
+ prototype__proto._weekdays = defaultLocaleWeekdays;
+ prototype__proto.weekdaysMin = localeWeekdaysMin;
+ prototype__proto._weekdaysMin = defaultLocaleWeekdaysMin;
+ prototype__proto.weekdaysShort = localeWeekdaysShort;
+ prototype__proto._weekdaysShort = defaultLocaleWeekdaysShort;
+ prototype__proto.weekdaysParse = localeWeekdaysParse;
+
+ // Hours
+ prototype__proto.isPM = localeIsPM;
+ prototype__proto._meridiemParse = defaultLocaleMeridiemParse;
+ prototype__proto.meridiem = localeMeridiem;
+
+ function lists__get (format, index, field, setter) {
+ var locale = locale_locales__getLocale();
+ var utc = create_utc__createUTC().set(setter, index);
+ return locale[field](utc, format);
+ }
+
+ function list (format, index, field, count, setter) {
+ if (typeof format === 'number') {
+ index = format;
+ format = undefined;
+ }
+
+ format = format || '';
+
+ if (index != null) {
+ return lists__get(format, index, field, setter);
+ }
+
+ var i;
+ var out = [];
+ for (i = 0; i < count; i++) {
+ out[i] = lists__get(format, i, field, setter);
+ }
+ return out;
+ }
+
+ function lists__listMonths (format, index) {
+ return list(format, index, 'months', 12, 'month');
+ }
+
+ function lists__listMonthsShort (format, index) {
+ return list(format, index, 'monthsShort', 12, 'month');
+ }
+
+ function lists__listWeekdays (format, index) {
+ return list(format, index, 'weekdays', 7, 'day');
+ }
+
+ function lists__listWeekdaysShort (format, index) {
+ return list(format, index, 'weekdaysShort', 7, 'day');
+ }
+
+ function lists__listWeekdaysMin (format, index) {
+ return list(format, index, 'weekdaysMin', 7, 'day');
+ }
+
+ locale_locales__getSetGlobalLocale('en', {
+ ordinalParse: /\d{1,2}(th|st|nd|rd)/,
+ ordinal : function (number) {
+ var b = number % 10,
+ output = (toInt(number % 100 / 10) === 1) ? 'th' :
+ (b === 1) ? 'st' :
+ (b === 2) ? 'nd' :
+ (b === 3) ? 'rd' : 'th';
+ return number + output;
+ }
+ });
+
+ // Side effect imports
+ utils_hooks__hooks.lang = deprecate('moment.lang is deprecated. Use moment.locale instead.', locale_locales__getSetGlobalLocale);
+ utils_hooks__hooks.langData = deprecate('moment.langData is deprecated. Use moment.localeData instead.', locale_locales__getLocale);
+
+ var mathAbs = Math.abs;
+
+ function duration_abs__abs () {
+ var data = this._data;
+
+ this._milliseconds = mathAbs(this._milliseconds);
+ this._days = mathAbs(this._days);
+ this._months = mathAbs(this._months);
+
+ data.milliseconds = mathAbs(data.milliseconds);
+ data.seconds = mathAbs(data.seconds);
+ data.minutes = mathAbs(data.minutes);
+ data.hours = mathAbs(data.hours);
+ data.months = mathAbs(data.months);
+ data.years = mathAbs(data.years);
+
+ return this;
+ }
+
+ function duration_add_subtract__addSubtract (duration, input, value, direction) {
+ var other = create__createDuration(input, value);
+
+ duration._milliseconds += direction * other._milliseconds;
+ duration._days += direction * other._days;
+ duration._months += direction * other._months;
+
+ return duration._bubble();
+ }
+
+ // supports only 2.0-style add(1, 's') or add(duration)
+ function duration_add_subtract__add (input, value) {
+ return duration_add_subtract__addSubtract(this, input, value, 1);
+ }
+
+ // supports only 2.0-style subtract(1, 's') or subtract(duration)
+ function duration_add_subtract__subtract (input, value) {
+ return duration_add_subtract__addSubtract(this, input, value, -1);
+ }
+
+ function absCeil (number) {
+ if (number < 0) {
+ return Math.floor(number);
+ } else {
+ return Math.ceil(number);
+ }
+ }
+
+ function bubble () {
+ var milliseconds = this._milliseconds;
+ var days = this._days;
+ var months = this._months;
+ var data = this._data;
+ var seconds, minutes, hours, years, monthsFromDays;
+
+ // if we have a mix of positive and negative values, bubble down first
+ // check: https://github.com/moment/moment/issues/2166
+ if (!((milliseconds >= 0 && days >= 0 && months >= 0) ||
+ (milliseconds <= 0 && days <= 0 && months <= 0))) {
+ milliseconds += absCeil(monthsToDays(months) + days) * 864e5;
+ days = 0;
+ months = 0;
+ }
+
+ // The following code bubbles up values, see the tests for
+ // examples of what that means.
+ data.milliseconds = milliseconds % 1000;
+
+ seconds = absFloor(milliseconds / 1000);
+ data.seconds = seconds % 60;
+
+ minutes = absFloor(seconds / 60);
+ data.minutes = minutes % 60;
+
+ hours = absFloor(minutes / 60);
+ data.hours = hours % 24;
+
+ days += absFloor(hours / 24);
+
+ // convert days to months
+ monthsFromDays = absFloor(daysToMonths(days));
+ months += monthsFromDays;
+ days -= absCeil(monthsToDays(monthsFromDays));
+
+ // 12 months -> 1 year
+ years = absFloor(months / 12);
+ months %= 12;
+
+ data.days = days;
+ data.months = months;
+ data.years = years;
+
+ return this;
+ }
+
+ function daysToMonths (days) {
+ // 400 years have 146097 days (taking into account leap year rules)
+ // 400 years have 12 months === 4800
+ return days * 4800 / 146097;
+ }
+
+ function monthsToDays (months) {
+ // the reverse of daysToMonths
+ return months * 146097 / 4800;
+ }
+
+ function as (units) {
+ var days;
+ var months;
+ var milliseconds = this._milliseconds;
+
+ units = normalizeUnits(units);
+
+ if (units === 'month' || units === 'year') {
+ days = this._days + milliseconds / 864e5;
+ months = this._months + daysToMonths(days);
+ return units === 'month' ? months : months / 12;
+ } else {
+ // handle milliseconds separately because of floating point math errors (issue #1867)
+ days = this._days + Math.round(monthsToDays(this._months));
+ switch (units) {
+ case 'week' : return days / 7 + milliseconds / 6048e5;
+ case 'day' : return days + milliseconds / 864e5;
+ case 'hour' : return days * 24 + milliseconds / 36e5;
+ case 'minute' : return days * 1440 + milliseconds / 6e4;
+ case 'second' : return days * 86400 + milliseconds / 1000;
+ // Math.floor prevents floating point math errors here
+ case 'millisecond': return Math.floor(days * 864e5) + milliseconds;
+ default: throw new Error('Unknown unit ' + units);
+ }
+ }
+ }
+
+ // TODO: Use this.as('ms')?
+ function duration_as__valueOf () {
+ return (
+ this._milliseconds +
+ this._days * 864e5 +
+ (this._months % 12) * 2592e6 +
+ toInt(this._months / 12) * 31536e6
+ );
+ }
+
+ function makeAs (alias) {
+ return function () {
+ return this.as(alias);
+ };
+ }
+
+ var asMilliseconds = makeAs('ms');
+ var asSeconds = makeAs('s');
+ var asMinutes = makeAs('m');
+ var asHours = makeAs('h');
+ var asDays = makeAs('d');
+ var asWeeks = makeAs('w');
+ var asMonths = makeAs('M');
+ var asYears = makeAs('y');
+
+ function duration_get__get (units) {
+ units = normalizeUnits(units);
+ return this[units + 's']();
+ }
+
+ function makeGetter(name) {
+ return function () {
+ return this._data[name];
+ };
+ }
+
+ var milliseconds = makeGetter('milliseconds');
+ var seconds = makeGetter('seconds');
+ var minutes = makeGetter('minutes');
+ var hours = makeGetter('hours');
+ var days = makeGetter('days');
+ var months = makeGetter('months');
+ var years = makeGetter('years');
+
+ function weeks () {
+ return absFloor(this.days() / 7);
+ }
+
+ var round = Math.round;
+ var thresholds = {
+ s: 45, // seconds to minute
+ m: 45, // minutes to hour
+ h: 22, // hours to day
+ d: 26, // days to month
+ M: 11 // months to year
+ };
+
+ // helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize
+ function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) {
+ return locale.relativeTime(number || 1, !!withoutSuffix, string, isFuture);
+ }
+
+ function duration_humanize__relativeTime (posNegDuration, withoutSuffix, locale) {
+ var duration = create__createDuration(posNegDuration).abs();
+ var seconds = round(duration.as('s'));
+ var minutes = round(duration.as('m'));
+ var hours = round(duration.as('h'));
+ var days = round(duration.as('d'));
+ var months = round(duration.as('M'));
+ var years = round(duration.as('y'));
+
+ var a = seconds < thresholds.s && ['s', seconds] ||
+ minutes === 1 && ['m'] ||
+ minutes < thresholds.m && ['mm', minutes] ||
+ hours === 1 && ['h'] ||
+ hours < thresholds.h && ['hh', hours] ||
+ days === 1 && ['d'] ||
+ days < thresholds.d && ['dd', days] ||
+ months === 1 && ['M'] ||
+ months < thresholds.M && ['MM', months] ||
+ years === 1 && ['y'] || ['yy', years];
+
+ a[2] = withoutSuffix;
+ a[3] = +posNegDuration > 0;
+ a[4] = locale;
+ return substituteTimeAgo.apply(null, a);
+ }
+
+ // This function allows you to set a threshold for relative time strings
+ function duration_humanize__getSetRelativeTimeThreshold (threshold, limit) {
+ if (thresholds[threshold] === undefined) {
+ return false;
+ }
+ if (limit === undefined) {
+ return thresholds[threshold];
+ }
+ thresholds[threshold] = limit;
+ return true;
+ }
+
+ function humanize (withSuffix) {
+ var locale = this.localeData();
+ var output = duration_humanize__relativeTime(this, !withSuffix, locale);
+
+ if (withSuffix) {
+ output = locale.pastFuture(+this, output);
+ }
+
+ return locale.postformat(output);
+ }
+
+ var iso_string__abs = Math.abs;
+
+ function iso_string__toISOString() {
+ // for ISO strings we do not use the normal bubbling rules:
+ // * milliseconds bubble up until they become hours
+ // * days do not bubble at all
+ // * months bubble up until they become years
+ // This is because there is no context-free conversion between hours and days
+ // (think of clock changes)
+ // and also not between days and months (28-31 days per month)
+ var seconds = iso_string__abs(this._milliseconds) / 1000;
+ var days = iso_string__abs(this._days);
+ var months = iso_string__abs(this._months);
+ var minutes, hours, years;
+
+ // 3600 seconds -> 60 minutes -> 1 hour
+ minutes = absFloor(seconds / 60);
+ hours = absFloor(minutes / 60);
+ seconds %= 60;
+ minutes %= 60;
+
+ // 12 months -> 1 year
+ years = absFloor(months / 12);
+ months %= 12;
+
+
+ // inspired by https://github.com/dordille/moment-isoduration/blob/master/moment.isoduration.js
+ var Y = years;
+ var M = months;
+ var D = days;
+ var h = hours;
+ var m = minutes;
+ var s = seconds;
+ var total = this.asSeconds();
+
+ if (!total) {
+ // this is the same as C#'s (Noda) and python (isodate)...
+ // but not other JS (goog.date)
+ return 'P0D';
+ }
+
+ return (total < 0 ? '-' : '') +
+ 'P' +
+ (Y ? Y + 'Y' : '') +
+ (M ? M + 'M' : '') +
+ (D ? D + 'D' : '') +
+ ((h || m || s) ? 'T' : '') +
+ (h ? h + 'H' : '') +
+ (m ? m + 'M' : '') +
+ (s ? s + 'S' : '');
+ }
+
+ var duration_prototype__proto = Duration.prototype;
+
+ duration_prototype__proto.abs = duration_abs__abs;
+ duration_prototype__proto.add = duration_add_subtract__add;
+ duration_prototype__proto.subtract = duration_add_subtract__subtract;
+ duration_prototype__proto.as = as;
+ duration_prototype__proto.asMilliseconds = asMilliseconds;
+ duration_prototype__proto.asSeconds = asSeconds;
+ duration_prototype__proto.asMinutes = asMinutes;
+ duration_prototype__proto.asHours = asHours;
+ duration_prototype__proto.asDays = asDays;
+ duration_prototype__proto.asWeeks = asWeeks;
+ duration_prototype__proto.asMonths = asMonths;
+ duration_prototype__proto.asYears = asYears;
+ duration_prototype__proto.valueOf = duration_as__valueOf;
+ duration_prototype__proto._bubble = bubble;
+ duration_prototype__proto.get = duration_get__get;
+ duration_prototype__proto.milliseconds = milliseconds;
+ duration_prototype__proto.seconds = seconds;
+ duration_prototype__proto.minutes = minutes;
+ duration_prototype__proto.hours = hours;
+ duration_prototype__proto.days = days;
+ duration_prototype__proto.weeks = weeks;
+ duration_prototype__proto.months = months;
+ duration_prototype__proto.years = years;
+ duration_prototype__proto.humanize = humanize;
+ duration_prototype__proto.toISOString = iso_string__toISOString;
+ duration_prototype__proto.toString = iso_string__toISOString;
+ duration_prototype__proto.toJSON = iso_string__toISOString;
+ duration_prototype__proto.locale = locale;
+ duration_prototype__proto.localeData = localeData;
+
+ // Deprecations
+ duration_prototype__proto.toIsoString = deprecate('toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)', iso_string__toISOString);
+ duration_prototype__proto.lang = lang;
+
+ // Side effect imports
+
+ addFormatToken('X', 0, 0, 'unix');
+ addFormatToken('x', 0, 0, 'valueOf');
+
+ // PARSING
+
+ addRegexToken('x', matchSigned);
+ addRegexToken('X', matchTimestamp);
+ addParseToken('X', function (input, array, config) {
+ config._d = new Date(parseFloat(input, 10) * 1000);
+ });
+ addParseToken('x', function (input, array, config) {
+ config._d = new Date(toInt(input));
+ });
+
+ // Side effect imports
+
+
+ utils_hooks__hooks.version = '2.10.6';
+
+ setHookCallback(local__createLocal);
+
+ utils_hooks__hooks.fn = momentPrototype;
+ utils_hooks__hooks.min = min;
+ utils_hooks__hooks.max = max;
+ utils_hooks__hooks.utc = create_utc__createUTC;
+ utils_hooks__hooks.unix = moment__createUnix;
+ utils_hooks__hooks.months = lists__listMonths;
+ utils_hooks__hooks.isDate = isDate;
+ utils_hooks__hooks.locale = locale_locales__getSetGlobalLocale;
+ utils_hooks__hooks.invalid = valid__createInvalid;
+ utils_hooks__hooks.duration = create__createDuration;
+ utils_hooks__hooks.isMoment = isMoment;
+ utils_hooks__hooks.weekdays = lists__listWeekdays;
+ utils_hooks__hooks.parseZone = moment__createInZone;
+ utils_hooks__hooks.localeData = locale_locales__getLocale;
+ utils_hooks__hooks.isDuration = isDuration;
+ utils_hooks__hooks.monthsShort = lists__listMonthsShort;
+ utils_hooks__hooks.weekdaysMin = lists__listWeekdaysMin;
+ utils_hooks__hooks.defineLocale = defineLocale;
+ utils_hooks__hooks.weekdaysShort = lists__listWeekdaysShort;
+ utils_hooks__hooks.normalizeUnits = normalizeUnits;
+ utils_hooks__hooks.relativeTimeThreshold = duration_humanize__getSetRelativeTimeThreshold;
+
+ var _moment = utils_hooks__hooks;
+
+ return _moment;
+
+})); \ No newline at end of file
diff --git a/StoneIsland/platforms/ios/www/js/vendor/prefixfree.js b/StoneIsland/platforms/ios/www/js/vendor/prefixfree.js
new file mode 100644
index 00000000..e2c87c42
--- /dev/null
+++ b/StoneIsland/platforms/ios/www/js/vendor/prefixfree.js
@@ -0,0 +1,497 @@
+/**
+ * StyleFix 1.0.3 & PrefixFree 1.0.7
+ * @author Lea Verou
+ * MIT license
+ */
+
+(function(){
+
+if(!window.addEventListener) {
+ return;
+}
+
+var self = window.StyleFix = {
+ link: function(link) {
+ try {
+ // Ignore stylesheets with data-noprefix attribute as well as alternate stylesheets
+ if(link.rel !== 'stylesheet' || link.hasAttribute('data-noprefix')) {
+ return;
+ }
+ }
+ catch(e) {
+ return;
+ }
+
+ var url = link.href || link.getAttribute('data-href'),
+ base = url.replace(/[^\/]+$/, ''),
+ base_scheme = (/^[a-z]{3,10}:/.exec(base) || [''])[0],
+ base_domain = (/^[a-z]{3,10}:\/\/[^\/]+/.exec(base) || [''])[0],
+ base_query = /^([^?]*)\??/.exec(url)[1],
+ parent = link.parentNode,
+ xhr = new XMLHttpRequest(),
+ process;
+
+ xhr.onreadystatechange = function() {
+ if(xhr.readyState === 4) {
+ process();
+ }
+ };
+
+ process = function() {
+ var css = xhr.responseText;
+
+ if(css && link.parentNode && (!xhr.status || xhr.status < 400 || xhr.status > 600)) {
+ css = self.fix(css, true, link);
+
+ // Convert relative URLs to absolute, if needed
+ if(base) {
+ css = css.replace(/url\(\s*?((?:"|')?)(.+?)\1\s*?\)/gi, function($0, quote, url) {
+ if(/^([a-z]{3,10}:|#)/i.test(url)) { // Absolute & or hash-relative
+ return $0;
+ }
+ else if(/^\/\//.test(url)) { // Scheme-relative
+ // May contain sequences like /../ and /./ but those DO work
+ return 'url("' + base_scheme + url + '")';
+ }
+ else if(/^\//.test(url)) { // Domain-relative
+ return 'url("' + base_domain + url + '")';
+ }
+ else if(/^\?/.test(url)) { // Query-relative
+ return 'url("' + base_query + url + '")';
+ }
+ else {
+ // Path-relative
+ return 'url("' + base + url + '")';
+ }
+ });
+
+ // behavior URLs shoudn’t be converted (Issue #19)
+ // base should be escaped before added to RegExp (Issue #81)
+ var escaped_base = base.replace(/([\\\^\$*+[\]?{}.=!:(|)])/g,"\\$1");
+ css = css.replace(RegExp('\\b(behavior:\\s*?url\\(\'?"?)' + escaped_base, 'gi'), '$1');
+ }
+
+ var style = document.createElement('style');
+ style.textContent = css;
+ style.media = link.media;
+ style.disabled = link.disabled;
+ style.setAttribute('data-href', link.getAttribute('href'));
+
+ parent.insertBefore(style, link);
+ parent.removeChild(link);
+
+ style.media = link.media; // Duplicate is intentional. See issue #31
+ }
+ };
+
+ try {
+ xhr.open('GET', url);
+ xhr.send(null);
+ } catch (e) {
+ // Fallback to XDomainRequest if available
+ if (typeof XDomainRequest != "undefined") {
+ xhr = new XDomainRequest();
+ xhr.onerror = xhr.onprogress = function() {};
+ xhr.onload = process;
+ xhr.open("GET", url);
+ xhr.send(null);
+ }
+ }
+
+ link.setAttribute('data-inprogress', '');
+ },
+
+ styleElement: function(style) {
+ if (style.hasAttribute('data-noprefix')) {
+ return;
+ }
+ var disabled = style.disabled;
+
+ style.textContent = self.fix(style.textContent, true, style);
+
+ style.disabled = disabled;
+ },
+
+ styleAttribute: function(element) {
+ var css = element.getAttribute('style');
+
+ css = self.fix(css, false, element);
+
+ element.setAttribute('style', css);
+ },
+
+ process: function() {
+ // Linked stylesheets
+ $('link[rel="stylesheet"]:not([data-inprogress])').forEach(StyleFix.link);
+
+ // Inline stylesheets
+ $('style').forEach(StyleFix.styleElement);
+
+ // Inline styles
+ $('[style]').forEach(StyleFix.styleAttribute);
+ },
+
+ register: function(fixer, index) {
+ (self.fixers = self.fixers || [])
+ .splice(index === undefined? self.fixers.length : index, 0, fixer);
+ },
+
+ fix: function(css, raw, element) {
+ for(var i=0; i<self.fixers.length; i++) {
+ css = self.fixers[i](css, raw, element) || css;
+ }
+
+ return css;
+ },
+
+ camelCase: function(str) {
+ return str.replace(/-([a-z])/g, function($0, $1) { return $1.toUpperCase(); }).replace('-','');
+ },
+
+ deCamelCase: function(str) {
+ return str.replace(/[A-Z]/g, function($0) { return '-' + $0.toLowerCase() });
+ }
+};
+
+/**************************************
+ * Process styles
+ **************************************/
+(function(){
+ setTimeout(function(){
+ $('link[rel="stylesheet"]').forEach(StyleFix.link);
+ }, 10);
+
+ document.addEventListener('DOMContentLoaded', StyleFix.process, false);
+})();
+
+function $(expr, con) {
+ return [].slice.call((con || document).querySelectorAll(expr));
+}
+
+})();
+
+/**
+ * PrefixFree
+ */
+(function(root){
+
+if(!window.StyleFix || !window.getComputedStyle) {
+ return;
+}
+
+// Private helper
+function fix(what, before, after, replacement, css) {
+ what = self[what];
+
+ if(what.length) {
+ var regex = RegExp(before + '(' + what.join('|') + ')' + after, 'gi');
+
+ css = css.replace(regex, replacement);
+ }
+
+ return css;
+}
+
+var self = window.PrefixFree = {
+ prefixCSS: function(css, raw, element) {
+ var prefix = self.prefix;
+
+ // Gradient angles hotfix
+ if(self.functions.indexOf('linear-gradient') > -1) {
+ // Gradients are supported with a prefix, convert angles to legacy
+ css = css.replace(/(\s|:|,)(repeating-)?linear-gradient\(\s*(-?\d*\.?\d*)deg/ig, function ($0, delim, repeating, deg) {
+ return delim + (repeating || '') + 'linear-gradient(' + (90-deg) + 'deg';
+ });
+ }
+
+ css = fix('functions', '(\\s|:|,)', '\\s*\\(', '$1' + prefix + '$2(', css);
+ css = fix('keywords', '(\\s|:)', '(\\s|;|\\}|$)', '$1' + prefix + '$2$3', css);
+ css = fix('properties', '(^|\\{|\\s|;)', '\\s*:', '$1' + prefix + '$2:', css);
+
+ // Prefix properties *inside* values (issue #8)
+ if (self.properties.length) {
+ var regex = RegExp('\\b(' + self.properties.join('|') + ')(?!:)', 'gi');
+
+ css = fix('valueProperties', '\\b', ':(.+?);', function($0) {
+ return $0.replace(regex, prefix + "$1")
+ }, css);
+ }
+
+ if(raw) {
+ css = fix('selectors', '', '\\b', self.prefixSelector, css);
+ css = fix('atrules', '@', '\\b', '@' + prefix + '$1', css);
+ }
+
+ // Fix double prefixing
+ css = css.replace(RegExp('-' + prefix, 'g'), '-');
+
+ // Prefix wildcard
+ css = css.replace(/-\*-(?=[a-z]+)/gi, self.prefix);
+
+ return css;
+ },
+
+ property: function(property) {
+ return (self.properties.indexOf(property) >=0 ? self.prefix : '') + property;
+ },
+
+ value: function(value, property) {
+ value = fix('functions', '(^|\\s|,)', '\\s*\\(', '$1' + self.prefix + '$2(', value);
+ value = fix('keywords', '(^|\\s)', '(\\s|$)', '$1' + self.prefix + '$2$3', value);
+
+ if(self.valueProperties.indexOf(property) >= 0) {
+ value = fix('properties', '(^|\\s|,)', '($|\\s|,)', '$1'+self.prefix+'$2$3', value);
+ }
+
+ return value;
+ },
+
+ // Warning: Prefixes no matter what, even if the selector is supported prefix-less
+ prefixSelector: function(selector) {
+ return selector.replace(/^:{1,2}/, function($0) { return $0 + self.prefix })
+ },
+
+ // Warning: Prefixes no matter what, even if the property is supported prefix-less
+ prefixProperty: function(property, camelCase) {
+ var prefixed = self.prefix + property;
+
+ return camelCase? StyleFix.camelCase(prefixed) : prefixed;
+ }
+};
+
+/**************************************
+ * Properties
+ **************************************/
+(function() {
+ var prefixes = {},
+ properties = [],
+ shorthands = {},
+ style = getComputedStyle(document.documentElement, null),
+ dummy = document.createElement('div').style;
+
+ // Why are we doing this instead of iterating over properties in a .style object? Cause Webkit won't iterate over those.
+ var iterate = function(property) {
+ if(property.charAt(0) === '-') {
+ properties.push(property);
+
+ var parts = property.split('-'),
+ prefix = parts[1];
+
+ // Count prefix uses
+ prefixes[prefix] = ++prefixes[prefix] || 1;
+
+ // This helps determining shorthands
+ while(parts.length > 3) {
+ parts.pop();
+
+ var shorthand = parts.join('-');
+
+ if(supported(shorthand) && properties.indexOf(shorthand) === -1) {
+ properties.push(shorthand);
+ }
+ }
+ }
+ },
+ supported = function(property) {
+ return StyleFix.camelCase(property) in dummy;
+ }
+
+ // Some browsers have numerical indices for the properties, some don't
+ if(style.length > 0) {
+ for(var i=0; i<style.length; i++) {
+ iterate(style[i])
+ }
+ }
+ else {
+ for(var property in style) {
+ iterate(StyleFix.deCamelCase(property));
+ }
+ }
+
+ // Find most frequently used prefix
+ var highest = {uses:0};
+ for(var prefix in prefixes) {
+ var uses = prefixes[prefix];
+
+ if(highest.uses < uses) {
+ highest = {prefix: prefix, uses: uses};
+ }
+ }
+
+ self.prefix = '-' + highest.prefix + '-';
+ self.Prefix = StyleFix.camelCase(self.prefix);
+
+ self.properties = [];
+
+ // Get properties ONLY supported with a prefix
+ for(var i=0; i<properties.length; i++) {
+ var property = properties[i];
+
+ if(property.indexOf(self.prefix) === 0) { // we might have multiple prefixes, like Opera
+ var unprefixed = property.slice(self.prefix.length);
+
+ if(!supported(unprefixed)) {
+ self.properties.push(unprefixed);
+ }
+ }
+ }
+
+ // IE fix
+ if(self.Prefix == 'Ms'
+ && !('transform' in dummy)
+ && !('MsTransform' in dummy)
+ && ('msTransform' in dummy)) {
+ self.properties.push('transform', 'transform-origin');
+ }
+
+ self.properties.sort();
+})();
+
+/**************************************
+ * Values
+ **************************************/
+(function() {
+// Values that might need prefixing
+var functions = {
+ 'linear-gradient': {
+ property: 'backgroundImage',
+ params: 'red, teal'
+ },
+ 'calc': {
+ property: 'width',
+ params: '1px + 5%'
+ },
+ 'element': {
+ property: 'backgroundImage',
+ params: '#foo'
+ },
+ 'cross-fade': {
+ property: 'backgroundImage',
+ params: 'url(a.png), url(b.png), 50%'
+ }
+};
+
+
+functions['repeating-linear-gradient'] =
+functions['repeating-radial-gradient'] =
+functions['radial-gradient'] =
+functions['linear-gradient'];
+
+// Note: The properties assigned are just to *test* support.
+// The keywords will be prefixed everywhere.
+var keywords = {
+ 'initial': 'color',
+ 'zoom-in': 'cursor',
+ 'zoom-out': 'cursor',
+ 'box': 'display',
+ 'flexbox': 'display',
+ 'inline-flexbox': 'display',
+ 'flex': 'display',
+ 'inline-flex': 'display',
+ 'grid': 'display',
+ 'inline-grid': 'display',
+ 'max-content': 'width',
+ 'min-content': 'width',
+ 'fit-content': 'width',
+ 'fill-available': 'width'
+};
+
+self.functions = [];
+self.keywords = [];
+
+var style = document.createElement('div').style;
+
+function supported(value, property) {
+ style[property] = '';
+ style[property] = value;
+
+ return !!style[property];
+}
+
+for (var func in functions) {
+ var test = functions[func],
+ property = test.property,
+ value = func + '(' + test.params + ')';
+
+ if (!supported(value, property)
+ && supported(self.prefix + value, property)) {
+ // It's supported, but with a prefix
+ self.functions.push(func);
+ }
+}
+
+for (var keyword in keywords) {
+ var property = keywords[keyword];
+
+ if (!supported(keyword, property)
+ && supported(self.prefix + keyword, property)) {
+ // It's supported, but with a prefix
+ self.keywords.push(keyword);
+ }
+}
+
+})();
+
+/**************************************
+ * Selectors and @-rules
+ **************************************/
+(function() {
+
+var
+selectors = {
+ ':read-only': null,
+ ':read-write': null,
+ ':any-link': null,
+ '::selection': null
+},
+
+atrules = {
+ 'keyframes': 'name',
+ 'viewport': null,
+ 'document': 'regexp(".")'
+};
+
+self.selectors = [];
+self.atrules = [];
+
+var style = root.appendChild(document.createElement('style'));
+
+function supported(selector) {
+ style.textContent = selector + '{}'; // Safari 4 has issues with style.innerHTML
+
+ return !!style.sheet.cssRules.length;
+}
+
+for(var selector in selectors) {
+ var test = selector + (selectors[selector]? '(' + selectors[selector] + ')' : '');
+
+ if(!supported(test) && supported(self.prefixSelector(test))) {
+ self.selectors.push(selector);
+ }
+}
+
+for(var atrule in atrules) {
+ var test = atrule + ' ' + (atrules[atrule] || '');
+
+ if(!supported('@' + test) && supported('@' + self.prefix + test)) {
+ self.atrules.push(atrule);
+ }
+}
+
+root.removeChild(style);
+
+})();
+
+// Properties that accept properties as their value
+self.valueProperties = [
+ 'transition',
+ 'transition-property'
+]
+
+// Add class for current prefix
+root.className += ' ' + self.prefix;
+
+StyleFix.register(self.prefixCSS);
+
+
+})(document.documentElement); \ No newline at end of file
diff --git a/StoneIsland/platforms/ios/www/js/vendor/promise.js b/StoneIsland/platforms/ios/www/js/vendor/promise.js
new file mode 100644
index 00000000..f458ab06
--- /dev/null
+++ b/StoneIsland/platforms/ios/www/js/vendor/promise.js
@@ -0,0 +1,34 @@
+var promise = function(fn, data){
+ var my_cb, my_res, error_cb, my_error
+ data = data || {}
+ data.success = function(res){
+ my_res = res
+ if (my_cb) {
+ my_cb(res)
+ }
+ }
+ data.error = function(res){
+ my_error = res
+ if (error_cb) {
+ error_cb(res)
+ }
+ else {
+ console.log('error!')
+ console.log(res)
+ }
+ }
+ fn(data)
+ var p = {
+ then: function(cb){
+ if (my_res) cb(my_res)
+ else my_cb = cb
+ return p
+ },
+ error: function(cb){
+ if (my_error) cb(my_error)
+ else error_cb = cb
+ return p
+ }
+ }
+ return p
+}
diff --git a/StoneIsland/platforms/ios/www/js/vendor/util.js b/StoneIsland/platforms/ios/www/js/vendor/util.js
index 8a58a84c..23f55d4c 100644
--- a/StoneIsland/platforms/ios/www/js/vendor/util.js
+++ b/StoneIsland/platforms/ios/www/js/vendor/util.js
@@ -24,6 +24,17 @@ function rgba_string (rgb,a) { return "rgba(" + rgb.map(Math.round).join(",") +
function hex_string (rgb) { return "#" + rgb.map(Math.round).map(function(n){ var s = n.toString(16); return s.length == 1 ? "0"+s : s }).join("") }
function parse_rgba_string (s) { return s.match(/(\d+)/g).slice(0,3) }
+function title_case (str) {
+ return str.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
+}
+function pluralize (n,s,ss) { return n + " " + s + ( n == 1 ? "" : (ss || "s") ) }
+function as_cash(n){
+ var cents = ((n*100) % 100);
+ if (cents < 10) { cents = "0" + (cents|0) }
+ else { cents = cents|0 }
+ return "$" + (n|0) + "." + cents
+}
+
var E = Math.E
var PI = Math.PI
var PHI = (1+Math.sqrt(5))/2
@@ -41,6 +52,7 @@ function rand(n){ return (Math.random()*n) }
function randint(n){ return rand(n)|0 }
function randrange(a,b){ return a + rand(b-a) }
function choice(a){ return a[randint(a.length)] }
+function noop(){}
function range(m,n,s){
var a = []
diff --git a/StoneIsland/platforms/ios/www/js/vendor/view/formview.js b/StoneIsland/platforms/ios/www/js/vendor/view/formview.js
deleted file mode 100644
index 8cd222e3..00000000
--- a/StoneIsland/platforms/ios/www/js/vendor/view/formview.js
+++ /dev/null
@@ -1,146 +0,0 @@
-var FormView = View.extend({
-
- method: "post",
- useMinotaur: false,
-
- events: {
- "submit form": "save"
- },
-
- initialize: function(opt){
- if (opt && opt.parent) {
- this.parent = opt.parent
- }
- this.$form = this.$("form")
- this.$errors = this.$(".errors")
- this.$errorList = this.$(".errorList")
- },
-
- reset: function(){
- this.$("input,textarea").not("[type='submit']").not("[type='hidden']").val("")
- },
-
- showErrors: function(errors){
- if (errors && errors.length) {
- this.$errorList.empty();
- for (var i in errors) {
- this.$errorList.append('<div>' + errors[i] + '</div>');
- }
- this.$errors.css("opacity", 1.0);
- setTimeout(function(){
- this.$errors.show().css("opacity", 1.0);
- }.bind(this), 200)
- }
- },
-
- serialize: function(){
- var fd = new FormData(), hasCSRF = false
-
- this.$("input[name], select[name], textarea[name]").each( function(){
- if (this.type == "file") {
- if (this.files.length > 0) {
- fd.append(this.name, this.files[0]);
- }
- }
-// else if (this.type == "password") {
-// if (this.value.length > 0) {
-// fd.append(this.name, SHA1.hex('bucky$' + this.value + '$bucky'))
-// }
-// }
- else {
- fd.append(this.name, this.value);
- hasCSRF = hasCSRF || this.name == "_csrf"
- }
- });
-
-// if (! hasCSRF) {
-// fd.append("_csrf", $("[name=_csrf]").attr("value"))
-// }
-//
- return fd
- },
-
- save: function(e, successCallback, errorCallback){
- e && e.preventDefault()
-
- this.$errors.hide().css("opacity", 0.0);
-
- if (this.validate) {
- var errors = this.validate()
- if (errors && errors.length) {
- if (errorCallback) {
- errorCallback(errors)
- }
- else {
- this.showErrors(errors)
- }
- return
- }
- }
-
- var action = typeof this.action == "function" ? this.action() : this.action
- if (! action) return
-
- var request = $.ajax({
- url: action,
- type: this.method,
- data: this.serialize(),
-// headers: { "csrf-token": $("[name=_csrf]").attr("value") },
- dataType: "json",
- processData: false,
- contentType: false,
- success: function(response){
-
- if (response.error) {
- var errors = []
- for (var key in response.error.errors) {
- errors.push(response.error.errors[key].message);
- }
- if (errorCallback) {
- errorCallback(errors)
- }
- else {
- this.showErrors(errors)
- }
- return
- }
- else {
- if (successCallback) {
- successCallback(response)
- }
- if (this.success) {
- this.success(response)
- }
- }
-
-
- }.bind(this),
- error: function(response){
- }.bind(this),
- complete: function(response){
- if (this.useMinotaur) {
- Minotaur.hide()
- }
- }.bind(this),
- })
-
- if (this.useMinotaur) {
- Minotaur.show()
- }
-
- },
-
-})
-
-/*
-
-var ModalFormView = ModalView.extend(FormView.prototype).extend({
-
- load: function(){
- this.reset()
- this.show()
- }
-
-})
-
-*/ \ No newline at end of file
diff --git a/StoneIsland/platforms/ios/www/js/vendor/view/router.js b/StoneIsland/platforms/ios/www/js/vendor/view/router.js
index d766880f..a8ec331f 100644
--- a/StoneIsland/platforms/ios/www/js/vendor/view/router.js
+++ b/StoneIsland/platforms/ios/www/js/vendor/view/router.js
@@ -14,8 +14,10 @@ var Router = View.extend({
},
parseRoute: function(pathname){
-
- if (pathname[0] !== "/" && pathname[0] !== "#") { pathname = "/" + pathname }
+
+ pathname = pathname.replace(/^#/, "")
+
+ if (pathname[0] !== "/") { pathname = "/" + pathname }
var routes = this.routes,
path = pathname.split("/");
@@ -25,7 +27,7 @@ var Router = View.extend({
path[i] = null
}
}
-
+
if (pathname in routes) {
this[this.routes[pathname]]()
return
diff --git a/StoneIsland/platforms/ios/www/js/vendor/view/scrollable.js b/StoneIsland/platforms/ios/www/js/vendor/view/scrollable.js
new file mode 100644
index 00000000..7cd96f89
--- /dev/null
+++ b/StoneIsland/platforms/ios/www/js/vendor/view/scrollable.js
@@ -0,0 +1,20 @@
+var ScrollableView = View.extend({
+
+ events: {
+ "load img": "deferScrollToTop",
+ },
+
+ deferScrollToTop: function(){
+ setTimeout(this.scrollToTop.bind(this), 0)
+ },
+
+ refreshScroller: function(){
+ this.scroller.refresh()
+ },
+
+ scrollToTop: function(){
+ this.scroller.refresh()
+ app.collection.scroller.scrollTo(0, 0)
+ },
+
+}) \ No newline at end of file
diff --git a/StoneIsland/platforms/ios/www/js/vendor/view/serializable.js b/StoneIsland/platforms/ios/www/js/vendor/view/serializable.js
new file mode 100644
index 00000000..e9459229
--- /dev/null
+++ b/StoneIsland/platforms/ios/www/js/vendor/view/serializable.js
@@ -0,0 +1,129 @@
+var SerializableView = View.extend({
+
+ events: {
+ "change select": "update_select",
+ "focus input": "focus_input",
+ },
+
+ preload: function(data){
+ if (! data && sdk.env == "production") { return }
+ data = data || this.test_data
+ if (! data) { return }
+
+ Object.keys(data).forEach(function(key){
+ var value = data[key]
+ var $el = this.$("[name=" + key + "]")
+
+ if ($el.attr("type") == "checkbox") {
+ $el.prop("checked", value)
+ }
+ else if ($el.prop("tagName") == "SELECT") {
+ $el.val( value )
+ this.update_select({ currentTarget: $el })
+ }
+ else {
+ $el.val( value )
+ }
+ }.bind(this))
+ },
+
+ serialize: function(){
+ var fields = {}
+ this.$("input[name], select[name], textarea[name]").each( function(){
+ if (this.type == "checkbox") {
+ if ($(this).prop("checked")) {
+ fields[this.name] = this.value
+ }
+ }
+ else {
+ fields[this.name] = this.value
+ }
+ })
+ return fields
+ },
+
+ deserialize: function(data){
+ this.$("input[name], textarea[name]").val("")
+ Object.keys(data).forEach(function(k){
+ this.$("[" + k + "]").val(data[k])
+ })
+ },
+
+ focus_input: function(e){
+ $(e.currentTarget).removeClass("error_hilite")
+ },
+
+ update_select: function(e){
+ var $target = $(e.currentTarget), value = $target.val()
+ var label = $($("select")[0]).find("option").filter(function(){ return this.value === value }).html()
+
+ $target.parent().addClass("picked")
+ $target.parent().find("span").html(label)
+ },
+
+ validate: function(errors){
+ var data = this.serialize()
+ var errors = []
+ var presence_msgs = this.validate_presence
+ Object.keys(presence_msgs).forEach(function(k){
+ if (! data[k]) errors.push( [ k, presence_msgs[k] ] )
+ })
+ this.validate_fields && this.validate_fields(data, errors)
+ this.cc && this.cc.validate(errors)
+ this.address && this.address.validate(errors)
+ return { errors: errors, data: data }
+ },
+
+ show_errors: function(errors){
+ var msgs = []
+ errors.forEach(function(e, i){
+ if (i > 0) { return }
+ this.$("[name=" + e[0] + "]").addClass('error_hilite')
+ msgs.push(e[1])
+ }.bind(this))
+ this.$msg.html(msgs.join("<br>"))
+ this.$msg.addClass('alert-notice')
+ },
+
+ hide_errors: function(){
+ this.$msg.removeClass('alert-notice')
+ this.$msg.html("")
+ },
+
+ save: function(e){
+ e && e.preventDefault()
+
+ var valid = this.validate()
+ if (valid.errors.length) {
+ this.show_errors(valid.errors)
+ return
+ }
+ else {
+ this.hide_errors()
+ }
+
+ app.curtain.show("loading")
+ this.action({
+ data: valid.data,
+ success: function(data){
+ app.curtain.hide("loading")
+ this.success(data)
+ }.bind(this),
+ error: function(data){
+ app.curtain.hide("loading")
+ this.error(data)
+ }.bind(this),
+ })
+ },
+
+ success: function(data){
+ console.log("SUCCESS", data)
+ },
+
+ error: function(data){
+ console.log("FAIL", data)
+ },
+
+})
+
+var FormView = View.extend(SerializableView.prototype).extend(ScrollableView.prototype)
diff --git a/StoneIsland/platforms/ios/www/js/vendor/view/view.js b/StoneIsland/platforms/ios/www/js/vendor/view/view.js
index 9a8ab5b9..41638ab7 100644
--- a/StoneIsland/platforms/ios/www/js/vendor/view/view.js
+++ b/StoneIsland/platforms/ios/www/js/vendor/view/view.js
@@ -60,10 +60,15 @@ var View = (function($, _){
var eventName = match[1], selector = match[2];
method = _.bind(method, this);
eventName += '.delegateEvents' + this._id;
- if (is_mobile && (selector === 'mouseenter' || selector === 'mouseleave')) {
- continue
+ if (is_mobile) {
+ if (eventName === 'mouseenter' || eventName === 'mouseleave') {
+ continue
+ }
+// if (eventName === 'click') {
+// eventName = 'tap'
+// }
}
- else if (selector === '') {
+ if (selector === '') {
this.$el.on(eventName, method);
} else {
this.$el.on(eventName, selector, method);