diff options
Diffstat (limited to 'StoneIsland/platforms/ios/www')
28 files changed, 4998 insertions, 2006 deletions
diff --git a/StoneIsland/platforms/ios/www/cordova_plugins.js b/StoneIsland/platforms/ios/www/cordova_plugins.js index 32af05ac..8469b08b 100644 --- a/StoneIsland/platforms/ios/www/cordova_plugins.js +++ b/StoneIsland/platforms/ios/www/cordova_plugins.js @@ -130,6 +130,22 @@ module.exports = [ "merges": [ "window.plugins.sim" ] + }, + { + "id": "phonegap-plugin-mobile-accessibility.mobile-accessibility", + "file": "plugins/phonegap-plugin-mobile-accessibility/www/mobile-accessibility.js", + "pluginId": "phonegap-plugin-mobile-accessibility", + "clobbers": [ + "window.MobileAccessibility" + ] + }, + { + "id": "phonegap-plugin-mobile-accessibility.MobileAccessibilityNotifications", + "file": "plugins/phonegap-plugin-mobile-accessibility/www/MobileAccessibilityNotifications.js", + "pluginId": "phonegap-plugin-mobile-accessibility", + "clobbers": [ + "MobileAccessibilityNotifications" + ] } ]; module.exports.metadata = @@ -149,7 +165,8 @@ module.exports.metadata = "cordova-plugin-x-socialsharing": "5.1.3", "ionic-plugin-keyboard": "2.2.1", "phonegap-plugin-push": "1.9.2", - "cordova-plugin-sim": "1.3.3" + "cordova-plugin-sim": "1.3.3", + "phonegap-plugin-mobile-accessibility": "1.0.5-dev" }; // BOTTOM OF METADATA });
\ No newline at end of file diff --git a/StoneIsland/platforms/ios/www/css/account.css b/StoneIsland/platforms/ios/www/css/account.css index 32c7df79..12adb2d9 100755 --- a/StoneIsland/platforms/ios/www/css/account.css +++ b/StoneIsland/platforms/ios/www/css/account.css @@ -67,7 +67,7 @@ content:''; width:calc(100% + 100px); height:1px; - background:#bbb; + background:#666; position:absolute; bottom:0; left:-50px; @@ -77,7 +77,7 @@ position:relative; font-weight:bold; letter-spacing:0.2px; - font-size:11px; + font-size: 0.688rem; margin-bottom:10px; width:100%; box-sizing:border-box; @@ -122,26 +122,37 @@ text-align: center; margin: 0; padding: 20px 10px 8px 10px; - font-size: 14px; + font-size: 1rem; color: #000; letter-spacing: 1px; font-weight: bold; } +label { + display: flex; + align-items: center; + justify-content: center; + text-align: center; + font-size: 1rem; + color: #000; + letter-spacing:1px; + text-transform:uppercase; + height: 48px; +} input[type=text], input[type=password], input[type=number], input[type=date], input[type=email] { font-family:pfd, sans-serif; - font-size:14px; + font-size: 0.875rem; outline:none!important; color:#000; letter-spacing:1px; text-transform:uppercase; - height:35px; + height: 48px; text-align:center; margin: 0px auto; display:block; - margin-top:4px; + margin-top: 0px; width: calc(100vw - 10px); - border:1px solid #a9a9a9; + border:1px solid #696969; padding: 0; border-radius: 0; } @@ -149,27 +160,35 @@ input[type=text], input[type=password], input[type=number], input[type=date], in input[type=text], input[type=password], input[type=number], input[type=email] { -webkit-appearance: none; } - +input[type=text]:focus, input[type=password]:focus, input[type=number]:focus, input[type=email] { + border-width: 2px; +} .half-input { margin: 0px auto; - display: block; + display: flex; + flex-direction: row; + justify-content: flex-start; + align-items: center; margin-top: 4px; width: calc(100vw - 10px); overflow: auto; } +.half-input label { + width: 50%; +} .half-input input, .half-input select { position: relative; margin: 0; border:none; box-sizing: border-box; float: left; - border: 1px solid #a9a9a9; + border: 1px solid #696969; width: 50%; } .half-input > input:first-child { - border-right: 1px solid #a9a9a9; + border-right: 1px solid #696969; } #signup .toggle-container, #profile .toggle-container { @@ -179,7 +198,7 @@ input[type=text], input[type=password], input[type=number], input[type=email] { width: calc(100vw - 10px); box-sizing: border-box; padding:0px 18px 2px; - font-size:14px; + font-size: 1rem; } #settings .toggle-container { @@ -189,7 +208,7 @@ input[type=text], input[type=password], input[type=number], input[type=email] { width: calc(100vw - 10px); box-sizing: border-box; padding:10px 18px 2px; - font-size:14px; + font-size: 1rem; } .toggle-row { @@ -296,10 +315,12 @@ input.switch:checked + label:after { .container-fill { min-height:80px; + display: flex; flex: 1; align-items: center; justify-content: center; position:relative; + flex-direction: column; } .container-fill-condensed { @@ -317,26 +338,27 @@ input.switch:checked + label:after { width:calc(100vw - 10px); box-sizing:border-box; margin:10px auto 0; - position:relative + position:relative; } .container-row .container-message-condensed { margin: 2px auto!important } .container-fill .container-message { - font-size:12px; + font-size: 0.875rem; letter-spacing:0.5px; text-align:center; - position:absolute; - top:50%; - left:50%; + display: flex; + align-items: center; + justify-content: center; width:100%; - -webkit-transform: translateX(-50%) translateY(-50%); - transform: translateX(-50%) translateY(-50%); + min-height: 48px; color:#000; } - +.billing-container a { + text-decoration: none; +} .premessage { top:calc(50% - 20px)!important; @@ -351,7 +373,7 @@ input.switch:checked + label:after { } .checkbox-container { - font-size:11px; + font-size: 0.875rem; width:calc(100vw - 10px); display:table; box-sizing:border-box; @@ -381,6 +403,7 @@ input.switch:checked + label:after { vertical-align:middle; display:table-cell; box-sizing:border-box; + text-align: left; } .billing-container .checkbox-caption { @@ -442,10 +465,6 @@ input.switch:checked + label:after { } .privacy-msg { - left: 50%; - display: inline-block; - position: relative; - transform: translateX(-50%); padding-top: 15px; padding-bottom: 80px; } @@ -458,51 +477,55 @@ input.switch:checked + label:after { text-align: center; overflow: hidden; - font-size: 14px; + font-size: 0.875rem; outline: none !important; color: #000; letter-spacing: 1px; text-transform: uppercase; - height: 35px; + height: 48px; text-align: center; margin: 0px auto; display: block; margin-top: 4px; width: calc(100vw - 10px); - border: 1px solid #a9a9a9; + border: 1px solid #696969; } .date-wrapper span { display: block; } .half-input .select-wrapper { + display: flex; + align-items: center; + justify-content: center; width: 50%; border: 0; margin-top: 0px; float: left; box-sizing: border-box; - border: 1px solid #a9a9a9; + border: 1px solid #696969; +} +.half-input .select-wrapper:nth-child(2) { border-left: 0px; } .half-input .select-wrapper span { - top: 8px; color: #aaa; + top: 0; } .select-wrapper [type=date] { opacity: 0; width: 100%; - height: 35px; - line-height: 35px; + height: 48px; + line-height: 48px; position: absolute; top: -5px; left: -1px; - width: 1px; height: 1px; } .select-wrapper select { opacity: 0; width: 100%; - height: 35px; - line-height: 35px; + height: 48px; + line-height: 48px; position: absolute; top: 0; left: 0; box-sizing: border-box; @@ -512,8 +535,8 @@ input.switch:checked + label:after { } .select-wrapper span { position: relative; - top: 8px; - color: #888; + top: 15px; + color: #666; } .select-wrapper.picked span { color: #000; @@ -521,33 +544,29 @@ input.switch:checked + label:after { .country-wrapper-static { text-align: center; - color: #a9a9a9; + color: #696969; border: 1px solid; - padding-top: 9px; - font-size: 14px; - height: 35px; + border-left: 0; + font-size: 0.875rem; + height: 48px; box-sizing: border-box; -} - -.container-row input:first-child { -margin-top:10px + width: 50%; + display: flex; + justify-content: center; + align-items: center; } .container-row .half-input input { margin-top:0px } -#login .container-row input:first-child { -margin-bottom:9px!important -} - .newuser { display:inline-block; - padding:14px; + padding:18px; text-decoration:underline } .forgotpassword { - padding:14px; + padding:18px; text-decoration:underline }
\ 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 bf5ab68f..2d4a52c3 100755 --- a/StoneIsland/platforms/ios/www/css/blogs.css +++ b/StoneIsland/platforms/ios/www/css/blogs.css @@ -6,17 +6,22 @@ margin: 15px 0 0; text-align: center; text-transform:uppercase; + display:flex; + flex-direction: row; + justify-content: center; + align-items: center; + flex-wrap: wrap; } #story .links li { - padding: 10px; + display: flex; + justify-content: center; + align-items: center; + height: 48px; + padding: 0 8px; list-style-type: none; - display: inline-block; -} -#story .links li:before { - content: ' | ', -} -#story .links li:first-child:before { - content: '', + font-size: 1rem; + border: 1px solid black; + margin: 5px; } #story .links li.active { font-weight: bold; @@ -57,7 +62,7 @@ animation: mfadein 0.6s; #hub .content .body, #story .content .body { letter-spacing:0.35px; - font-size:12px; + font-size: 1rem; width:calc(100vw - 40px); box-sizing:border-box; margin:10px auto 20px; @@ -65,7 +70,7 @@ animation: mfadein 0.6s; } #hub .content .body:last-child { - margin:10px auto 100px; + margin:20px auto 100px; } #story .content .body:last-child { @@ -85,14 +90,14 @@ animation: mfadein 0.6s; .content-header .title, .content-header .subtitle { display:block; font-weight:bold; - font-size:14px; + font-size: 1rem; text-transform:uppercase } .content-header .title { margin:0; padding:0; - line-height:13px; + line-height:1.4em; } .content-header .subtitle { @@ -101,12 +106,17 @@ animation: mfadein 0.6s; .content-share { border:1px solid black; - padding:4px 8px 2px; + padding: 0 12px; + height: 48px; + font-size: 1rem; + display: flex; + justify-content: center; + align-items: center; float:right } .content-header span.date, .content-header span.store { - font-size:10px; + font-size: 1rem; } /* NOTE: optional arrows */ @@ -118,19 +128,18 @@ animation: mfadein 0.6s; background-size:5px 10px; background-repeat:no-repeat; background-position:center; - width:15px; - height:30px; + width:24px; + height:48px; top:26vh; content:''; transform:translateY(-50%); transform-origin:top right; left:20px; - font-size:18px; + font-size: 1.125rem; padding:3px 3px 3px 1px; z-index:2; position:absolute; display:block; - animation: gallery-fade 4s forwards; } .gallery-right { border:1px solid black; @@ -139,19 +148,18 @@ animation: mfadein 0.6s; background-size:5px 10px; background-repeat:no-repeat; background-position:center; - width:15px; - height:30px; + width:24px; + height:48px; top:26vh; content:''; transform:translateY(-50%); transform-origin:top right; right:20px; - font-size:18px; + font-size: 1.125rem; padding:3px 1px 3px 3px; z-index:2; position:absolute; display:block; - animation: gallery-fade 4s forwards; } @-webkit-keyframes gallery-fade { @@ -183,7 +191,7 @@ animation: mfadein 0.6s; transform:scale(1,.5) translateY(-50%); transform-origin:bottom right; content:'\25BC'; - font-size:17px; + font-size: 1.063rem; padding:9px 11px; z-index:999; position:absolute; @@ -205,11 +213,11 @@ ul.links { } .archive h1 { - font-size:26px; + font-size: 1.625rem; border-bottom:0; - margin-top:8px; + margin-top: 8px; padding-bottom:0; - line-height:24px; + line-height: 1; } .archive .subtitle { @@ -220,20 +228,20 @@ ul.links { margin:0 0 12px; padding:0; font-weight:bold; - font-size:14px; + font-size: 1rem; } .archive h2 { - font-size: 25px; + font-size: 1.563rem; font-weight: normal; } .archive h2 b { - font-size: 28px; + font-size: 1.75rem; } .archive .body { - font-size: 14px; - line-height: 1.2em; + font-size: 0.875rem; + line-height: 1.4rem; font-weight: 100; } @@ -252,6 +260,13 @@ ul.links { transform: translateZ(0) translateX(-50%) translateY(-50%); } +.accessible #archive .row .image, +.accessible #archive .row .text { + position: relative; + top: auto; left: auto; + transform: translateZ(0); +} + #archive .menu .items { border-top: 1px solid transparent; } @@ -278,11 +293,14 @@ ul.links { } #archive .menu .item { width: 100%; - text-align: center; + display: flex; + justify-content: center; + align-items: center; border-bottom: 1px solid black; background: white; - padding:12px 0; - font-size:14px; + padding:0; + height: 48px; + font-size: 1rem; letter-spacing:0.7px } @@ -318,6 +336,17 @@ ul.links { #archive .row .text { width: 80%; } +.accessible #archive .row .image { + display: block; + height: 50vh; + opacity: 1 !important; +} +.accessible #archive .row .text { + display: block; + margin: 0 auto; + opacity: 1 !important; + width: 90%; +} .gallery-video-post { position:relative; diff --git a/StoneIsland/platforms/ios/www/css/cart.css b/StoneIsland/platforms/ios/www/css/cart.css index 7619a82b..36a446a7 100755 --- a/StoneIsland/platforms/ios/www/css/cart.css +++ b/StoneIsland/platforms/ios/www/css/cart.css @@ -6,20 +6,24 @@ #cart .steps { width: 100%; - border-bottom: 1px solid #bbb; + border-bottom: 1px solid #666; font-size: 0; + display: flex; + flex-direction: row; } #cart .steps span { - display: inline-block; - font-size: 13px; + display: flex; + font-size: 1rem; text-align: center; - padding: 11px 0 10px; - color: #bbb; + color: #666; width: 33%; position:relative; + height: 48px; + justify-content: center; + align-items: center; } .summary_step, .shipping_step { - border-right: 1px solid #bbb + border-right: 1px solid #666; } #cart.summary .summary_step, @@ -95,7 +99,7 @@ min-height:50px; max-width: 50%; text-align: center; - font-size: 18px; + font-size: 1.125rem; } .summary-container { @@ -109,7 +113,11 @@ #cart h3 { padding-left: 5px; - font-size:12px; + height: 48px; + display: flex; + justify-content: flex-start; + align-items: center; + font-size: 1rem; } .cart_item_row { @@ -153,9 +161,9 @@ padding-left:5px; .cart_item_price .remove { display:block; -width:20px; -height:20px; -border:1px solid #d2d2d2; +width:48px; +height:48px; +border:1px solid #b2b2b2; float:right; margin-bottom:10px; position:relative; @@ -164,8 +172,8 @@ position:relative; .cart_item_price .remove:after { content:''; width:1px; -height:22px; -background:#bbb; +height:48px; +background:#333; position:absolute; top:50%; left:50%; @@ -177,8 +185,8 @@ transform:rotate(45deg) translateX(-50%) translateY(-50%) .cart_item_price .remove:before { content:''; width:1px; - height:22px; - background:#bbb; + height:48px; + background:#333; position:absolute; top:50%; left:50%; @@ -188,27 +196,27 @@ transform:rotate(45deg) translateX(-50%) translateY(-50%) } .cart_item_price .price { - font-size:11px; + font-size: 1rem; font-weight:bold; display:block } .cart_item_info .sku { - font-size:10px; + font-size: 1rem; font-weight:bold; - display:block + display:block; } .cart_item_info .title { - font-size:10px; + font-size: 1rem; font-weight:bold; display:block; - line-height:12px; + line-height:1.4em; text-transform:uppercase; } .cart_item_info .type { - font-size:10px; + font-size: 1rem; font-weight:bold; display:block; text-transform:capitalize; @@ -216,8 +224,8 @@ transform:rotate(45deg) translateX(-50%) translateY(-50%) .cart_item_info .meta { padding-top:5px; - letter-spacing:.75px; - font-size:8px; + letter-spacing: 0.047rem; + font-size:0.875rem; } .order_section .rows { @@ -229,7 +237,7 @@ transform:rotate(45deg) translateX(-50%) translateY(-50%) width:calc(100vw - 30px); margin:15px auto; text-decoration:underline; - font-size:11px; + font-size: 0.688rem; } .order_section_container { @@ -241,8 +249,8 @@ transform:rotate(45deg) translateX(-50%) translateY(-50%) width:calc(100vw - 30px); margin:0 auto; display:table; - color:#bbb; - font-size:11px; + color:#666; + font-size: 1rem; } .cart-summary-row { @@ -274,7 +282,7 @@ transform:rotate(45deg) translateX(-50%) translateY(-50%) #orders .order_section { padding-bottom: 16px; - border-bottom: 1px solid #bbb; + border-bottom: 1px solid #666; } @@ -294,25 +302,30 @@ color:#000; position:relative; text-align:right; width:calc(100vw - 10px); - margin:0 auto; + margin:0 auto 20px 0; box-sizing:border-box; - + display: flex; + flex-direction: column; } .dropdown-wrapper .add_edit { padding:10px; letter-spacing:0.5px; - font-size:12px; + font-size: 0.75rem; color:#a9a9a9; box-sizing:border-box; } .dropdown-wrapper .dropdown { - font-size:14px; + font-size: 1rem; box-sizing:border-box; + display: flex; + justify-content: center; align-items: center; text-align: center; - padding:10px 0; + height: 48px; + margin-left: 3px; + padding:0; border:1px solid #a9a9a9; position:relative; } @@ -355,6 +368,9 @@ color:#000; margin-left:5px; margin-bottom:6px; } +#cart .cc_confirm h3 { + justify-content: center +} #cart_shipping input:first-child { margin-top:10px diff --git a/StoneIsland/platforms/ios/www/css/index.css b/StoneIsland/platforms/ios/www/css/index.css index 4d8e5514..88022823 100755 --- a/StoneIsland/platforms/ios/www/css/index.css +++ b/StoneIsland/platforms/ios/www/css/index.css @@ -17,9 +17,12 @@ body { -webkit-user-select: none; /* prevent copy paste, to allow, change 'none' to 'text' */ background: #fff; font-family: pfd, sans-serif; - font-size: 12px; + font-size: 0.875rem; padding-top: constant(safe-area-inset-top); } +a, a:visited { + color: #000; +} .loader { z-index: 2; @@ -60,3 +63,15 @@ body { color: red !important; border-color: red !important; } +.error_hilite ~ span.err { + display: flex; +} +span.err { + display: none; + text-align: center; + justify-content: center; + align-items: center; + font-size: 0.875rem; + height: 48px; + color: red !important; +} diff --git a/StoneIsland/platforms/ios/www/css/nav.css b/StoneIsland/platforms/ios/www/css/nav.css index b7002f20..f555ce99 100755 --- a/StoneIsland/platforms/ios/www/css/nav.css +++ b/StoneIsland/platforms/ios/www/css/nav.css @@ -35,7 +35,7 @@ } #nav .menu span { display: block; - font-size: 14px; + font-size: 1rem; letter-spacing:1.25px; text-shadow:0px 0px 1px rgba(0,0,0,.2); color: #000; @@ -77,9 +77,9 @@ #nav .submenu span { display: block; - font-size: 14px; + font-size: 1rem; letter-spacing:1.25px; - color: #bbb; + color: #666; padding: 4px 0 12px 20px } @@ -94,8 +94,8 @@ float: left; width: 61px; border-left: 1px solid #ddd; - color: #bbb; - font-size: 18px; + color: #666; + font-size: 1.125rem; padding: 5px 0; text-align: center; } @@ -137,11 +137,14 @@ padding-bottom:0px; } #intro div { position: absolute; - top: 50%; left: 50%; + top: 50%; + left: 50%; width: 200px; - padding: 50px; - text-align: center; - font-size: 17px; + height: 100px; + display: flex; + justify-content: center; + align-items: center; + font-size: 1.063rem; } #intro #compass { pointer-events: none; @@ -177,7 +180,7 @@ padding-bottom:0px; box-sizing: border-box; width: calc(100vw); text-align: center; - font-size: 14pt; + font-size: 0.875rem; font-weight: bold; line-height: 0; text-transform: uppercase; @@ -198,7 +201,7 @@ padding-bottom:0px; display: block; position: absolute; top: 0; left: 0; width: 100%; - height: 42px; + height: 48px; border-bottom: 1px solid black; } #header .logo { @@ -207,43 +210,43 @@ padding-bottom:0px; background-position: center center; position: absolute; background-size: contain; - width: 100px; height: 40px; - left: 50%; top: -4px; + width: 100px; height: 48px; + left: 50%; top: -3px; margin-left: -50px; top:0px; } #header .burger { display: inline-block; font-size: 24px; - padding: 9px 10px 5px; + padding: 12px 13px 7px; } #header .cart_rapper { - display: inline-block; + display: flex; + justify-content: center; + align-items: flex-end; position: relative; float: right; - width: 40px; height: 40px; + width: 44px; height: 48px; } #header .cart { position: relative; - float: right; width: 18px; - top: 15px; + margin-bottom: 10px; height: 18px; - margin-right: 18px; background: #fff; background-image:url(../img/cart-box.png); background-size:100%; background-repeat:no-repeat; } -.cart .cart_count { +#header .cart .cart_count { position: absolute; top: 50%; left: 50%; transform: translateY(-50%) translateX(-50%); - color: #bbb; - font-size:12.35px; + color: #666; + font-size: 12.35px; } #header .cart::before { @@ -273,12 +276,16 @@ padding-bottom:0px; } #footer div { width: 50%; + height: 48px; text-align: center; - padding: 10px 0; color: #000; float: left; - font-size:14px; + font-size: 1rem; font-weight:bold; + padding: 0; + display: flex; + justify-content: center; + align-items: center; } #footer .ok { color: #000; @@ -287,7 +294,7 @@ padding-bottom:0px; width: 100%; } #footer .ok.disabled { - color: #bbb; + color: #666; } @@ -300,8 +307,10 @@ padding-bottom:0px; width: 100%; height: 100%; background: rgba(255,255,255,0.8); opacity: 0; - -webkit-transition: opacity 0.2s; - transition: opacity 0.2s; + -webkit-transition: opacity 0.2s, -webkit-transform 0.2s; + transition: opacity 0.2s, transform 0.2s; + -webkit-transform: translateZ(0) translateX(0); + transform: translateZ(0) translateX(0); } #curtain.visible { pointer-events: auto; @@ -346,13 +355,14 @@ padding-bottom:0px; #consent_modal { display: none; z-index: 2; + font-size: 1rem; } #consent_modal a { color: black; } .modal button { font-family: pfd, sans-serif; - font-size: 12px; + font-size: 0.875rem; padding: 10px; box-sizing: border-box; margin: 0; @@ -400,9 +410,9 @@ padding-bottom:0px; #selector:not(.selector-outer-wrap) .options div { background: white; text-align: center; - padding: 7px 12px; + padding: 12px 12px; box-sizing:border-box; - font-size: 14px; + font-size: 0.875rem; border-left:1px solid black; border-right:1px solid black; border-top:1px solid black; @@ -437,7 +447,7 @@ padding-bottom:0px; background: white; text-align: center; padding: 7px 12px; - font-size:14px!important; + font-size: 0.875rem!important; } .selector-outer-wrap .options div:nth-of-type(odd){ @@ -462,28 +472,31 @@ padding-bottom:0px; #cart, #profile, #shipping, #payment, #settings, #orders { position: absolute; - top: 43px; - height: -webkit-calc(100% - 43px - 39px); - height: calc(100% - 43px - 39px); + top: 49px; + height: -webkit-calc(100% - 49px - 39px); + height: calc(100% - 49px - 39px); width: 100%; overflow: hidden; } #collection.single { - height: -webkit-calc(100% - 43px); - height: calc(100% - 43px); + height: -webkit-calc(100% - 49px); + height: calc(100% - 49px); } #story, #hub, #archive, .page, #closed { /* these things do not have a footer */ - height: -webkit-calc(100% - 43px); - height: calc(100% - 43px); + height: -webkit-calc(100% - 49px); + height: calc(100% - 49px); } h1 { text-align: center; margin: 0; - padding: 16px 10px 12px 10px; + display: flex; + justify-content: center; + align-items: center; border-bottom: 1px solid #000; - font-size: 14px; + height: 48px; + font-size: 1rem; 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 59bb403f..63e9b020 100755 --- a/StoneIsland/platforms/ios/www/css/products.css +++ b/StoneIsland/platforms/ios/www/css/products.css @@ -103,7 +103,7 @@ } .product .product-header { - font-size:14px; + font-size: 1rem; margin:18px 0 0; max-width:60%; position:relative; @@ -118,7 +118,7 @@ margin-bottom: 18px; font-weight: bold; text-align: center; - font-size: 17px; + font-size: 1.063rem; } .product-group:first-child { margin-top: 0; @@ -136,33 +136,49 @@ } .product .style { - padding:4px 9px; + padding: 0; border:1px solid black; float:left } .product .share { float:right; - padding:4px 9px; + padding: 0 12px; + height: 48px; + display: flex; + justify-content: center; + align-items: center; border:1px solid black; } .product .type { display:table-cell; - font-size:14px; + font-size: 1rem; } -.product .size { - padding-right:16px; +.product .size-color { + display: flex; + flex-direction: row; +} +.product .size-color span { position:relative; - box-sizing:border-box + box-sizing:border-box; + padding: 0 12px; + height: 48px; + font-size: 1rem; + display: flex; + justify-content: center; + align-items: center; +} +.product .size-color span.size { + border-right: 1px solid #444; } .product .price { display:table-cell; - font-size:14px; + font-size: 1rem; text-align:right; - vertical-align:bottom + vertical-align:bottom; } .product .price, .product .type { @@ -179,12 +195,12 @@ .style-share { letter-spacing:0.5px; - font-size:12.35px + font-size: 1rem; } .size-color { position:relative; - font-size:12.35px + font-size: 1rem; } .type-price, .style-share { @@ -194,7 +210,7 @@ } -.size::after { +/*.size::after { content: ''; display: inline-block; width: 1px; @@ -205,12 +221,12 @@ right:5px; background: #999; } - +*/ .product .fit, .product .notAvailableInCanada { clear:both; - font-size:9px; + font-size: 0.563rem; letter-spacing:0.5px; text-decoration:underline; text-transform:uppercase; @@ -218,7 +234,7 @@ } .product .fitHeader { clear:both; - font-size:9px; + font-size: 0.563rem; letter-spacing:0.5px; text-decoration: none; text-transform:uppercase; @@ -232,7 +248,8 @@ #product .content .body { letter-spacing:0.35px; - font-size:12px; + font-size: 1rem; + line-height: 1.4em; box-sizing:border-box; margin:0px auto 20px; clear:both; diff --git a/StoneIsland/platforms/ios/www/css/vendor/flickity.css b/StoneIsland/platforms/ios/www/css/vendor/flickity.css index b8eca4e4..99a09e72 100755 --- a/StoneIsland/platforms/ios/www/css/vendor/flickity.css +++ b/StoneIsland/platforms/ios/www/css/vendor/flickity.css @@ -105,7 +105,7 @@ http://flickity.metafizzy.co /* color & size if no SVG - IE8 and Android 2.3 */ .flickity-prev-next-button.no-svg { color: #333; - font-size: 26px; + font-size: 1.625rem; } /* ---- page dots ---- */ diff --git a/StoneIsland/platforms/ios/www/index.html b/StoneIsland/platforms/ios/www/index.html index b6fc8317..c46e37c3 100755 --- a/StoneIsland/platforms/ios/www/index.html +++ b/StoneIsland/platforms/ios/www/index.html @@ -28,103 +28,97 @@ <link rel="stylesheet" type="text/css" href="css/blogs.css"> <title>Stone Island</title> </head> -<body class="loading"> +<body class="loading" role="application"> -<div id="nav"> +<div id="nav" role="directory"> <div id="nav-container"> <div id="nav-row"> <!-- flex --> - <span class="menu"> - <div class="logo"></div> - <div class="main_menu"> - <span class="store">STORE</span> - <span class="hub">HUB</span> - <span class="story">STORY</span> - <span class="archive">ARCHIVE</span> + <span role="menu" class="menu"> + <div class="logo" aria-label="Stone Island"></div> + <div role="menu" aria-label="Main Menu" class="main_menu"> + <span role="menuitem" class="store">STORE</span> + <span role="menuitem" class="hub">HUB</span> + <span role="menuitem" class="story">STORY</span> + <span role="menuitem" class="archive">ARCHIVE</span> </div> - <div class="account_menu"> - <span class="account_back menu-emphasis">< MY ACCOUNT</span> - <span class="profile">MY PROFILE</span> - <span class="payment">MY CARD</span> - <span class="shipping">ADDRESS BOOK</span> - <span class="orders">MY ORDERS</span> - <span class="return_link">RETURNS</span> - <span class="settings">NOTIFICATIONS</span> + <div role="menu" aria-label="Account Menu" class="account_menu"> + <span role="menuitem" class="account_back menu-emphasis">< MY ACCOUNT</span> + <span role="menuitem" class="profile">MY PROFILE</span> + <span role="menuitem" class="payment">MY CARD</span> + <span role="menuitem" class="shipping">ADDRESS BOOK</span> + <span role="menuitem" class="orders">MY ORDERS</span> + <span role="menuitem" class="return_link_us">RETURNS (US)</span> + <span role="menuitem" class="return_link_ca">RETURNS (CANADA)</span> + <span role="menuitem" class="settings">NOTIFICATIONS</span> </div> - <div class="faq_menu"> - <span class="faq_back menu-emphasis">< FAQ</span> - <span class="privacy">PRIVACY POLICY</span> - <span class="account_terms">MY ACCOUNT TERMS AND CONDITIONS OF USE</span> - <span class="terms">TERMS AND CONDITIONS</span> - <span class="returns">RETURN POLICY</span> - <span class="care">CUSTOMER CARE</span> + <div role="menu" aria-label="FAQ Menu" class="faq_menu"> + <span role="menuitem" class="faq_back menu-emphasis">< FAQ</span> + <span role="menuitem" class="privacy">PRIVACY POLICY</span> + <span role="menuitem" class="account_terms">MY ACCOUNT TERMS AND CONDITIONS OF USE</span> + <span role="menuitem" class="terms">TERMS AND CONDITIONS</span> + <span role="menuitem" class="returns">RETURN POLICY</span> + <span role="menuitem" class="care">CUSTOMER CARE</span> </div> </span> </div> <div id="nav-fill"> <!-- flex fill --> - <span class="submenu"> + <span role="menu" class="submenu"> <div class="main_menu"> - <span class="account">MY ACCOUNT</span> - <span class="login">LOGIN</span> - <span class="faq">FAQ</span> + <span role="menuitem" class="account">MY ACCOUNT</span> + <span role="menuitem" class="login">LOGIN</span> + <span role="menuitem" 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> + <span role="menuitem" class="logout">LOGOUT</span> + <span role="menuitem" class="faq">FAQ</span> + <span role="menuitem" class="main">MAIN MENU</span> </div> <div class="faq_menu"> - <span class="account">MY ACCOUNT</span> - <span class="login">LOGIN</span> - <span class="logout">LOGOUT</span> - <span class="main">MAIN MENU</span> + <span role="menuitem" class="account">MY ACCOUNT</span> + <span role="menuitem" class="login">LOGIN</span> + <span role="menuitem" class="logout">LOGOUT</span> + <span role="menuitem" class="main">MAIN MENU</span> </div> </span> </div> <!-- end flex --> </div> - <span class="social"> - <span class="fb ion-social-facebook"></span> - <span class="insta ion-social-instagram-outline"></span> - <span class="tw ion-social-twitter"></span> - <span class="yt ion-social-youtube"></span> + <span class="social" role="list" aria-label="Social Links"> + <span role="menuitem" class="fb ion-social-facebook"></span> + <span role="menuitem" class="insta ion-social-instagram-outline"></span> + <span role="menuitem" class="tw ion-social-twitter"></span> + <span role="menuitem" class="yt ion-social-youtube"></span> </span> </div> <div id="content"> - <div id="intro"> + <div id="intro" role="menu" aria-label="Stone Island Home Screen"> <div id="compass"></div> - <div class="store">STORE</div> - <div class="hub">HUB</div> - <div class="story">STORY</div> - <div class="archive">ARCHIVE</div> + <div role="menuitem" class="store">STORE</div> + <div role="menuitem" class="hub">HUB</div> + <div role="menuitem" class="story">STORY</div> + <div role="menuitem" class="archive">ARCHIVE</div> <div class="alert"></div> - <span class="latlng">+40° 58' 90.9" N 74° 04' 46.3" W</span> + <span class="latlng" role="note" aria-label="Your Latitude and Longitude">+40° 58' 90.9" N 74° 04' 46.3" W</span> </div> - <div id="header"> - <span class="burger ion-android-menu"></span> - <span class="logo"></span> - <span class="cart_rapper"><span class="cart"><span class="cart_count">0</span></span></span> - </div> - - <div id="footer"> - <!-- '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 id="header" role="menubar" aria-label="Menu bar"> + <span role="menu" aria-label="Show main menu" class="burger ion-android-menu"></span> + <span role="link" aria-label="Homepage. Stone Island logo" class="logo"></span> + <span role="link" aria-label="View cart" class="cart_rapper"><span class="cart"><span role="display" class="cart_count">0</span></span></span> </div> - <!-- BLOGS ================================================ --> - <div id="story"> + <div id="story" role="region" aria-label="Stone Island Story"> <div class="scroll"> - <h1>STORY</h1> + <h1 aria-label="Current section: Stone Island Story">STORY</h1> <img> <ul class="links"></ul> <div class="content"> @@ -137,21 +131,21 @@ </div> </div> - <div id="hub"> + <div id="hub" role="region" aria-label="Stone Island Hub"> <div class="scroll"> - <h1>HUB</h1> + <h1 aria-label="Current section: Stone Island Hub">HUB</h1> <div class="content"> <script type="text/html" class="template"> <div class="hub_item" data-id="{{id}}"> - <div class="gallery gallery-{{id}}"></div> - <div class="gallery-left"></div> - <div class="gallery-right"></div> - <div class="content-header"> - <div class="content-share"> - SHARE + + <div class="gallery gallery-{{id}}" role="carousel"></div> + <div role="button" class="gallery-left"></div> + <div role="button" class="gallery-right"></div> + <div role="heading" class="content-header"> + <div role="button" class="content-share"> + SHARE + </div> - <span class="title">{{title}}</span> - <span class="subtitle">{{subtitle}}</span> + <span role="heading" aria-details="{{cleantitle}}" class="title">{{title}}</span> + <span role="heading" aria-details="{{cleansubtitle}}"class="subtitle">{{subtitle}}</span> <span class="date"> {{date}} <span class="store"> @@ -167,7 +161,7 @@ <div class="fade-cover"></div> </div> - <div id="archive"> + <div id="archive" role="region" aria-label="Stone Island Archive"> <div class="scroll"> <div class="content"> @@ -187,28 +181,29 @@ </div> </div> - <div class="menu"> + <div class="menu" role="menu"> <div class="items"> <script type="text/html" class="template"> - <div class="item">{{title}}</div> + <div role="button" class="item">{{title}}</div> </script> </div> </div> <div class="heading"> - <h1>ARCHIVE</h1> - <div class="subtitle">'982'015</div> + <h1 role="heading" aria-label="Current section: Stone Island Archive">ARCHIVE</h1> + <div role="heading" class="subtitle" aria-label="1982 to 2015">'982'015</div> </div> </div> - <div id="privacy" class="page"> + <div id="privacy" role="region" aria-label="Privacy Policy" class="page"> <div class="scroll"> - <h1>PRIVACY POLICY</h1> + <h1 aria-label="Current section: Privacy Policy">PRIVACY POLICY</h1> <div class="content"></div> </div> </div> - <div id="account_terms" class="page"> + + <div id="account_terms" role="region" aria-label="My Account Terms and Conditions of Use" class="page"> <div class="scroll"> - <h1>MY ACCOUNT TERMS AND CONDITIONS OF USE</h1> + <h1 aria-label="Current section: My Account terms and conditions of use">MY ACCOUNT TERMS AND CONDITIONS OF USE</h1> <div class="content"> <h2>1. Services</h2> <p> @@ -261,21 +256,24 @@ </div> </div> </div> - <div id="terms" class="page"> + + <div id="terms" role="region" aria-label="Terms and Conditions" class="page"> <div class="scroll"> - <h1>TERMS AND CONDITIONS</h1> + <h1 aria-label="Current section: Terms and conditions">TERMS AND CONDITIONS</h1> <div class="content"></div> </div> </div> - <div id="returns" class="page"> + + <div id="returns" role="region" aria-label="Return Policy" class="page"> <div class="scroll"> - <h1>RETURN POLICY</h1> + <h1 aria-label="Current section: Return policy">RETURN POLICY</h1> <div class="content"></div> </div> </div> - <div id="care" class="page"> + + <div id="care" role="region" aria-label="Customer Care" class="page"> <div class="scroll"> - <h1>CUSTOMER CARE</h1> + <h1 aria-label="Current section: Customer care">CUSTOMER CARE</h1> <div class="content"></div> </div> </div> @@ -283,42 +281,42 @@ <!-- STORE ================================================ --> - <div id="collection"> + <div id="collection" role="region" aria-label="Store"> <div class="scroll"> - <h1>LOADING...</h1> + <h1 aria-label="Current section: Store">LOADING...</h1> <div class="loader"></div> <div class="content"> <script type="text/html" class="template"> - <div class="item" data-code="{{code8}}"> - <img src="{{image}}"> + <div role="link" class="item" data-code="{{code8}}"> + <img src="{{image}}" alt="{{title}}"> </div> </script> </div> </div> </div> - <div id="search"> + <div id="search" role="search" aria-label="Search"> <div class="scroll"> - <h1>SEARCH</h1> + <h1 aria-label="Current section: Search">SEARCH</h1> <div class="form"> <input type="text" class="q" placeholder="ENTER YOUR SEARCH"> </div> </div> </div> - <div id="product"> + <div id="product" role="region" aria-label="Product view"> <div class="scroll"> <div class="loader"></div> - <div id="gallery" class="gallery"> + <div id="gallery" class="gallery" role="carousel"> <script type="text/html" class="template"> - <div class="item" style="background-image:url({{image}})"></div> + <div role="link" class="item" aria-label="{{alt}}" style="background-image:url({{image}})"></div> </script> </div> - <div class="gallery-left"></div> - <div class="gallery-right"></div> + <div role="button" class="gallery-left" aria-label="Scroll gallery left"></div> + <div role="button" class="gallery-right" aria-label="Scroll gallery right"></div> <div class="content"> <div class="product-header"> - <span class="title"></span> + <span role="heading" class="title"></span> </div> <div class="type-price"> <span class="type"></span> @@ -327,11 +325,11 @@ <div class="style-share"> <span class="style"> <div class="size-color"> - <span class="size"></span> - <span class="color"></span> + <span role="button" class="size" aria-label="Tap to select size. Current size"></span> + <span role="button" class="color" aria-label="Tap to select color. Current color"></span> </div> </span> - <span class="share">SHARE +</span> + <span role="button" class="share">SHARE +</span> </div> <div class="fit">Fits Large</div> <div class='fitHeader'></div> @@ -347,14 +345,14 @@ </div> </div> - <div id="closed"> + <div id="closed" role="region" aria-label="The store is closed"> <div class="closed_store_msg"> <h3> LOADING THE STORE, PLEASE WAIT </h3> <h4> </h4> - <div class="website_link"> + <div role="link" class="website_link"> visit<br> <b>www.stoneisland.com</b> </div> @@ -364,33 +362,38 @@ <!-- ACCOUNT ================================================ --> - <div id="login"> + <div id="login" role="region" aria-label="Log In"> <div class="scroll"> - <h1>LOGIN</h1> + <h1 aria-label="Current section: Log In">LOGIN</h1> <div class="form"> <div class="container"> <div class="container-row"> - <input type="email" name="Email" placeholder="EMAIL ADDRESS" required tabindex="1"> - <form><input type="password" name="Password" placeholder="PASSWORD" required tabindex="2"></form> + <label for="login_email_address">Email Address</label> + <input type="email" id="login_email_address" name="Email" aria-placeholder="EMAIL ADDRESS" required tabindex="1"> + <span class='err'></span> + + <label for="login_password">Password</label> + <form><input type="password" id="login_password" name="Password" aria-placeholder="PASSWORD" required tabindex="2"></form> + <span class='err'></span> </div> <div class="container-fill"> <div class="container-message premessage"> - <div class="newuser">New User?</div> - <div class="forgotpassword">Forgot Password?</div> + <div rel="link" class="newuser">New User?</div> + <div rel="link" class="forgotpassword">Forgot Password?</div> </div> <div class="container-message submessage"> <span class="msg"></span> </div> </div> </div> - <input type="submit" style="position: absolute; left: -9999px; width: 1px; height: 1px;"> + <input type="submit" aria-label="Submit form" style="position: absolute; left: -9999px; width: 1px; height: 1px;"> </div> </div> </div> - <div id="logout"> + <div id="logout" role="region" aria-label="You are now logged out"> <div class="scroll"> - <h1>LOGOUT</h1> + <h1 aria-label="Current section: You are now Logged Out">LOGOUT</h1> <div class="container"> <div class="container-fill"> <span class="container-message msg"> @@ -401,52 +404,71 @@ </div> </div> - <div id="signup"> + <div id="signup" role="region" aria-label="New User. Create an account"> <div class="scroll"> - <h1>NEW USER</h1> + <h1 aria-label="Current section: New User. Create an account">NEW USER</h1> <div class="form"> <div class="container"> <div class="container-row"> - <input type="text" name="Name" placeholder="FIRST NAME" required tabindex="1"> - <input type="text" name="Surname" placeholder="LAST NAME" required tabindex="2"> - <input type="email" name="Email" placeholder="EMAIL ADDRESS" required tabindex="3"> - <input type="email" name="ConfirmEmail" placeholder="CONFIRM EMAIL ADDRESS" required tabindex="4"> + <label for="signup_name">First Name</label> + <input type="text" id="signup_name" name="Name" aria-placeholder="FIRST NAME" required tabindex="1"> + <span class='err'></span> + + <label for="signup_surname">Last Name</label> + <input type="text" id="signup_surname" name="Surname" aria-placeholder="LAST NAME" required tabindex="2"> + <span class='err'></span> + + <label for="signup_email">Email Address</label> + <input type="email" id="signup_email" name="Email" aria-placeholder="EMAIL ADDRESS" required tabindex="3"> + <span class='err'></span> + + <label for="signup_confirmemail">Confirm Email Address</label> + <input type="email" id="signup_confirmemail" name="ConfirmEmail" aria-placeholder="CONFIRM EMAIL ADDRESS" required tabindex="4"> + <span class='err'></span> + + <label for="signup_birthday">Birthday (MM/DD/YYYY)</label> <div class="select-wrapper date-wrapper"> - <span>BIRTHDAY (MM/DD/YYYY)</span> - <input type="date" name="BirthDay" min="1900-01-01" placeholder="BIRTHDAY (MM/DD/YYYY)" required tabindex="5"> + <span></span> + <input type="date" id="signup_birthday" name="BirthDay" aria-label="Birthday" min="1900-01-01" aria-placeholder="BIRTHDAY (MM/DD/YYYY)" required tabindex="5"> </div> + <span class='err'></span> <h2>PASSWORD</h2> - <input type="password" name="Password" placeholder="PASSWORD (7 CHARACTERS OR MORE)" required tabindex="6"> - <input type="password" name="Password2" placeholder="CONFIRM PASSWORD" required tabindex="7"> + <label for="signup_password">Password (7 Characters or more)</label> + <input type="password" id="signup_password" name="Password" aria-placeholder="PASSWORD (7 CHARACTERS OR MORE)" required tabindex="6"> + <span class='err'></span> + + <label for="signup_confirm_password">Confirm Password</label> + <input type="password" id="signup_confirm_password" name="Password2" aria-placeholder="CONFIRM PASSWORD" required tabindex="7"> + <span class='err'></span> </div> <div class="container-row"> - <div class="checkbox-container "> + <div class="checkbox-container"> <div class="checkbox-row"> <div class="checkbox-toggle"> - <input type="checkbox" id="checkbox-data-profiling" name="YooxLetter" value="true" required tabindex="8"> + <input type="checkbox" id="checkbox-data-profiling" aria-labelledby="checkbox-data-profiling-label" name="YooxLetter" value="true" required tabindex="8"> <label for="checkbox-data-profiling"></label> </div> - <label class="checkbox-caption" for="checkbox-data-profiling"> + <label class="checkbox-caption" for="checkbox-data-profiling" id="checkbox-data-profiling-label"> I AGREE TO STONE ISLAND - SPORTSWEAR COMPANY COLLECTING AND PROCESSING MY PERSONAL INFORMATION FOR MARKETING PURPOSES. </label> </div> <div class="checkbox-row"> <div class="checkbox-toggle"> - <input type="checkbox" id="checkbox-shopping-data-profiling" name="DataProfiling" value="true" required tabindex="9"> + <input type="checkbox" id="checkbox-shopping-data-profiling" aria-labelledby="checkbox-shopping-data-profiling-label" name="DataProfiling" value="true" required tabindex="9"> <label for="checkbox-shopping-data-profiling"></label> </div> - <label class="checkbox-caption" for="checkbox-shopping-data-profiling"> + <label class="checkbox-caption" for="checkbox-shopping-data-profiling" id="checkbox-shopping-data-profiling-label"> I AGREE TO STONE ISLAND - SPORTSWEAR COMPANY COLLECTING AND PROCESSING MY PERSONAL INFORMATION TO CUSTOMIZE MY SHOPPING EXPERIENCE BASED ON MY INTERESTS AND HABITS. </label> </div> <div class="checkbox-row"> <div class="checkbox-toggle"> - <input type="checkbox" id="checkbox-shopping-account-terms" name="GdprTerms" value="true" required tabindex="10"> + <input type="checkbox" id="checkbox-shopping-account-terms" aria-labelledby="checkbox-gdpr-terms-label" name="GdprTerms" value="true" required tabindex="10"> <label for="checkbox-shopping-data-profiling"></label> </div> - <label class="checkbox-caption" for="checkbox-shopping-account-terms"> + <label class="checkbox-caption" for="checkbox-shopping-account-terms" id="checkbox-gdpr-terms-label"> I ACCEPT MY ACCOUNT TERMS AND CONDITIONS OF USE * </label> </div> @@ -465,54 +487,71 @@ </div> </div> - <div id="profile"> + <div id="profile" role="region" aria-label="My Profile"> <div class="scroll"> - <h1>MY PROFILE</h1> + <h1 aria-label="Current section: My Profile">MY PROFILE</h1> <div class="form"> <div class="container"> <div class="container-row"> - <input type="text" name="Name" placeholder="FIRST NAME" required tabindex="1"> - <input type="text" name="Surname" placeholder="LAST NAME" required tabindex="2"> - <input type="email" name="Email" placeholder="EMAIL ADDRESS" required tabindex="3"> + <label for="profile_name">First Name</label> + <input type="text" id="profile_name" name="Name" aria-placeholder="FIRST NAME" required tabindex="1"> + <span class='err'></span> + + <label for="profile_surname">Last Name</label> + <input type="text" id="profile_surname" name="Surname" aria-placeholder="LAST NAME" required tabindex="2"> + <span class='err'></span> + + <label for="profile_email">Email Address</label> + <input type="email" id="profile_email" name="Email" aria-placeholder="EMAIL ADDRESS" required tabindex="3"> + <span class='err'></span> + + <label for="profile_birthday">Birthday (MM/DD/YYYY)</label> <div class="select-wrapper date-wrapper"> - <span>BIRTHDAY (MM/DD/YYYY)</span> - <input type="date" name="BirthDay" min="1900-01-01" placeholder="BIRTHDAY (MM/DD/YYYY)" required tabindex="4"> + <span></span> + <input type="date" id="profile_birthday" name="BirthDay" aria-label="Birthday" min="1900-01-01" aria-placeholder="BIRTHDAY (MM/DD/YYYY)" required tabindex="5"> </div> + <span class='err'></span> <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 tabindex="5"> - <div class="container-fill container-fill-condensed"> - <div class="container-message container-message-condensed"> - <span class="msg msg-condensed"> - </span> - </div> + <label for="profile_password">Current Password</label> + <input type="password" id="profile_password" name="CurrentPassword" aria-placeholder="CURRENT PASSWORD" required tabindex="6"> + <span class='err'></span> + + <label for="profile_confirm_password">New Password (7 characters or more)</label> + <input type="password" id="profile_confirm_password" name="NewPassword" aria-placeholder="NEW PASSWORD (7 CHARACTERS OR MORE)" required tabindex="7"> + <span class='err'></span> + </div> + + <div class="container-fill container-fill-condensed"> + <div class="container-message container-message-condensed"> + <span class="msg msg-condensed"> + </span> </div> - <div class="container-row"> - <div class="checkbox-container"> - <div class="checkbox-row"> - <div class="checkbox-toggle"> - <input type="checkbox" id="checkbox-data-profiling-profile" name="YooxLetter" value="true" required tabindex="7"> - <label for="checkbox-data-profiling-profile"></label> - </div> - <label class="checkbox-caption" for="checkbox-data-profiling-profile"> - I AGREE TO STONE ISLAND - SPORTSWEAR COMPANY COLLECTING AND PROCESSING MY PERSONAL INFORMATION FOR MARKETING PURPOSES. - </label> - </div> - <div class="checkbox-row"> - <div class="checkbox-toggle"> - <input type="checkbox" id="checkbox-shopping-data-profiling-profile" name="DataProfiling" value="true" required tabindex="8"> - <label for="checkbox-shopping-data-profiling-profile"></label> - </div> - <label class="checkbox-caption" for="checkbox-shopping-data-profiling-profile"> - I AGREE TO STONE ISLAND - SPORTSWEAR COMPANY COLLECTING AND PROCESSING MY PERSONAL INFORMATION TO CUSTOMIZE MY SHOPPING EXPERIENCE BASED ON MY INTERESTS AND HABITS. - </label> + </div> + <div class="container-row"> + <div class="checkbox-container"> + <div class="checkbox-row"> + <div class="checkbox-toggle"> + <input type="checkbox" id="checkbox-data-profiling-profile" aria-labelledby="yoox-letter-checkbox" name="YooxLetter" value="true" required tabindex="7"> + <label for="checkbox-data-profiling-profile"></label> </div> - <div class="privacy-msg"> - Personal data will be electronically processed by SPORTSWEAR COMPANY and YOOX NET-A-PORTER GROUP in order to complete your request. Please note that you are responsible for third party data that you disclose to SPORTSWEAR COMPANY and YOOX NET-A-PORTER GROUP. - <br> - Consult our <a href="#/page/privacy">PRIVACY POLICY</a> for further information. + <label class="checkbox-caption" for="checkbox-data-profiling-profile" id="yoox-letter-checkbox"> + I AGREE TO STONE ISLAND - SPORTSWEAR COMPANY COLLECTING AND PROCESSING MY PERSONAL INFORMATION FOR MARKETING PURPOSES. + </label> + </div> + <div class="checkbox-row"> + <div class="checkbox-toggle"> + <input type="checkbox" id="checkbox-shopping-data-profiling-profile" aria-labelledby="yoox-data-profiling-checkbox" name="DataProfiling" value="true" required tabindex="8"> + <label for="checkbox-shopping-data-profiling-profile"></label> </div> + <label class="checkbox-caption" for="checkbox-shopping-data-profiling-profile" id="yoox-data-profiling-checkbox"> + I AGREE TO STONE ISLAND - SPORTSWEAR COMPANY COLLECTING AND PROCESSING MY PERSONAL INFORMATION TO CUSTOMIZE MY SHOPPING EXPERIENCE BASED ON MY INTERESTS AND HABITS. + </label> + </div> + <div class="privacy-msg"> + Personal data will be electronically processed by SPORTSWEAR COMPANY and YOOX NET-A-PORTER GROUP in order to complete your request. Please note that you are responsible for third party data that you disclose to SPORTSWEAR COMPANY and YOOX NET-A-PORTER GROUP. + <br> + Consult our <a href="#/page/privacy">PRIVACY POLICY</a> for further information. </div> </div> </div> @@ -520,11 +559,10 @@ </div> </div> </div> - - <div id="shipping"> + <div id="shipping" role="region" aria-label="Address Book"> <div class="scroll"> - <h1>ADDRESS BOOK</h1> + <h1 aria-label="Current section: Your address book">ADDRESS BOOK</h1> <div class="form"> <div class="container"> <div class="container-row"> @@ -537,7 +575,7 @@ information will always remain private </span> </div> - <div class="privacy-msg"> + <div rel="link" class="privacy-msg"> Consult our <u>PRIVACY POLICY</u> for further information. </div> </div> @@ -546,9 +584,9 @@ </div> </div> - <div id="payment"> + <div id="payment" role="region" aria-label="My Card"> <div class="scroll"> - <h1>MY CARD</h1> + <h1 aria-label="Current section: My Card">MY CARD</h1> <div class="form"> <div class="container"> <div class="container-row"> @@ -562,7 +600,7 @@ information will always remain private </span> </div> - <div class="privacy-msg"> + <div rel="link" class="privacy-msg"> Consult our <u>PRIVACY POLICY</u> for further information. </div> </div> @@ -571,9 +609,9 @@ </div> </div> - <div id="settings"> + <div id="settings" role="region" aria-label="Notifications"> <div class="scroll"> - <h1>NOTIFICATIONS</h1> + <h1 aria-label="Current section: Notifications">NOTIFICATIONS</h1> <div class="form"> <div class="toggle-container"> <div class="toggle-row"> @@ -582,7 +620,7 @@ Receive notifications for Store </div> <div class="toggle"> - <input type="checkbox" id="store-notifications" name="store" class="switch"> + <input type="checkbox" aria-label="Receive notifications for Store" id="store-notifications" name="store" class="switch"> <label for="store-notifications"></label> </div> </div> @@ -592,7 +630,7 @@ Receive notifications for Hub </div> <div class="toggle"> - <input type="checkbox" id="hub-notifications" name="hub" class="switch"> + <input type="checkbox" aria-label="Receive notifications for Hub" id="hub-notifications" name="hub" class="switch"> <label for="hub-notifications"></label> </div> </div> @@ -601,9 +639,9 @@ </div> </div> - <div id="orders"> + <div id="orders" role="region" aria-label="My Orders"> <div class="scroll"> - <h1>MY ORDERS</h1> + <h1 aria-label="Current section: My orders">MY ORDERS</h1> <div id="order_list"> <div class="list"></div> <div class="empty">You have no orders.</div> @@ -681,12 +719,12 @@ <!-- CART ================================================ --> - <div id="cart"> - <h1> - <span class="full_msg"> + <div id="cart" role="region" aria-label="Your Cart"> + <h1 role="presentation"> + <span class="full_msg" role="heading" aria-label="Current section: Your cart"> YOUR CART / <span class="itemcount"></span> </span> - <span class="empty_msg"> + <span class="empty_msg" role="heading" aria-label="Current section: Your cart is empty"> YOUR CART IS EMPTY </span> </h1> @@ -694,10 +732,10 @@ <div class="steps"> <span class="summary_step">SUMMARY</span> <span class="shipping_step">SHIPPING</span> - <span class="payment_step">BILLING</span> + <span class="payment_step">PAYMENT</span> </div> - <div id="cart_summary"> + <div id="cart_summary" role="region" aria-label="Cart Summary"> <div class="scroll"> <div class="summary-container container"> <div class="container-row"> @@ -705,20 +743,20 @@ <div class="rows"> <script type="text/html" class="template"> <div class="cart_item_image"> - <img src="{{image}}"> + <a href="#/store/{{code8}}" aria-label="{{cleantitle}}"><img src="{{image}}"></a> </div> <div class="cart_item_info"> - <span class="sku">{{sku}}</span> - <span class="title">{{title}}</span> - <span class="type">{{type}}</span> + <span class="sku" aria-label="SKU">{{sku}}</span> + <span class="title" aria-label="Product name: {{cleantitle}}">{{title}}</span> + <span class="type" aria-label="Product 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 class="meta-size" aria-label="Size"><b>SIZE:</b> {{size}}</div> + <div class="meta-color" aria-label="Color"><b>COLOR:</b> {{color}}</div> + <div class="meta-quantity" aria-label="Quantity"><b>QUANTITY:</b> {{quantity}}</div> </div> </div> <div class="cart_item_price"> - <span class="remove"></span> + <span class="remove" aria-label="Remove item from your cart. Item to be removed: {{cleantitle}}"></span> <span class="price">{{price}}</span> </div> </script> @@ -752,7 +790,7 @@ </div> </div> - <div id="cart_shipping"> + <div id="cart_shipping" role="region" aria-label="Cart Shipping"> <div class="scroll"> <div class="form"> <div class="dropdown-wrapper"> @@ -810,9 +848,11 @@ information will always remain private </span> </div> - <div class="privacy-msg"> - Consult our <u>PRIVACY POLICY</u> for further information. - </div> + <a href="#/page/privacy"> + <div class="privacy-msg"> + Consult our <u>PRIVACY POLICY</u> for further information. + </div> + </a> </div> </div> @@ -820,7 +860,7 @@ </div> </div> - <div id="cart_payment"> + <div id="cart_payment" role="region" aria-label="Cart Payment"> <div class="scroll"> <div class="form"> @@ -877,7 +917,7 @@ <script type="text/html" class="cc_template"> <div class="checkbox-row"> <div class="checkbox-toggle"> - <input id="cc-checkbox-{{id}}" type="radio" name="CCId" value="{{id}}" {{checked}}> + <input id="cc-checkbox-{{id}}" aria-label="Select this credit card" type="radio" name="CCId" value="{{id}}" {{checked}}> <label for="cc-checkbox-{{id}}"></label> </div> <label class="checkbox-caption" for="cc-checkbox-{{id}}"> @@ -903,20 +943,20 @@ information will always remain private </span> </div> - <div class="privacy-msg"> - Consult our <u>PRIVACY POLICY</u> for further information. - </div> + <a class='privacy-link'> href="#/page/privacy"> + <div class="privacy-msg"> + Consult our <u>PRIVACY POLICY</u> for further information. + </div> + </a> </div> </div> - <br><br><br><br> - </div> </div> </div> - <div id="cart_confirm"> + <div id="cart_confirm" role="region" aria-label="Confirm your order"> <div class="scroll"> - <h1>CONFIRM</h1> + <h1 aria-label="Current section: Confirm your cart">CONFIRM</h1> <div class="order_section"> <h2>ORDER SUMMARY</h2> @@ -997,11 +1037,17 @@ </div> + <div id="footer" role="menubar" aria-label="Footer"> + <!-- 'Cancel' i think needs to go BACK in the navigation.. rather than jumping to the home screen --> + <div role="button" class="cancel">CANCEL</div> + <div role="button" class="ok">OK</div> + </div> + <div id="curtain"> <div class="loader"></div> </div> - <div class="modal" id="consent_modal"> + <div class="modal" id="consent_modal" role="modal" aria-label="Please accept the new terms"> YOUR MY ACCOUNT <br><br> We have improved the My Account Terms and Conditions of Use. @@ -1017,6 +1063,7 @@ </label> </div> </div> + <br><br> For more information, please consult our <a href="#/page/privacy">Privacy Policy</a> or visit <a href="#" id="care-link">Customer Care</a>. @@ -1030,22 +1077,31 @@ </div> <div id="selector"> - <div class="options"> + <div class="options" role="select"> <script type="text/html" class="template"> - <div data-id="{{id}}">{{label}}</div> + <div aria-label="Pick {{label}}" data-id="{{id}}">{{label}}</div> </script> </div> </div> </div> +<!-- Forms --> + <script type="text/html" id="creditcard_template"> - <input type="number" name="Number" placeholder="CREDIT CARD NUMBER" required> + <label for="creditcard_id_{{_id}}">Credit Card Number</label> + <input type="number" id="creditcard_id_{{_id}}" name="Number" aria-placeholder="CREDIT CARD NUMBER" required> + <span class='err'></span> + <div class="half-input"> + <label for="cc_expiration_month_{{_id}}">EXPIRATION MONTH</label> + <label for="cc_expiration_year_{{_id}}">EXPIRATION YEAR</label> + </div> + <div class="half-input"> <div class="select-wrapper"> - <span>EXPIRATION MONTH</span> - <select name="ExpirationMonth"> + <span></span> + <select name="ExpirationMonth" id="cc_expiration_month_{{_id}}"> <option value="NONE">EXPIRATION MONTH</option> <option value="01">01</option> <option value="02">02</option> @@ -1062,10 +1118,9 @@ </select> </div> <div class="select-wrapper"> - <span>EXPIRATION YEAR</span> - <select name="ExpirationYear"> + <span></span> + <select name="ExpirationYear" id="cc_expiration_year_{{_id}}"> <option value="NONE">EXPIRATION YEAR</option> - <option value="2018">2018</option> <option value="2019">2019</option> <option value="2020">2020</option> <option value="2021">2021</option> @@ -1081,25 +1136,50 @@ </select> </div> </div> - <input type="number" name="Cvv" placeholder="SECURITY CODE" required> + <label for="cc_cvv_{{_id}}">Security Code</label> + <input type="number" id="cc_cvv_{{_id}}" name="Cvv" aria-placeholder="SECURITY CODE" required> + <span class='err'></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"> + <label for="address_name_{{_id}}">First Name</label> + <input type="text" id="address_name_{{_id}}" name="Name" aria-placeholder="First Name"> + <span class="err"></span> + + <label for="address_surname_{{_id}}">Last Name</label> + <input type="text" id="address_surname_{{_id}}" name="Surname" aria-placeholder="Last Name"> + <span class="err"></span> + + <label for="address_address1_{{_id}}">Address line 1</label> + <input type="text" id="address_address1_{{_id}}" name="Address1" aria-placeholder="Address Line 1"> + <span class="err"></span> + + <label for="address_address2_{{_id}}">Address line 2</label> + <input type="text" id="address_address2_{{_id}}" name="Address2" aria-placeholder="Address Line 2"> + <span class="err"></span> + + <div class="half-input"> + <label for="address_city_{{_id}}">City</label> + <label for="address_state_{{_id}}">State</label> + </div> + <div class="half-input"> - <input type="text" name="City" placeholder="City"> + <input type="text" id="address_city_{{_id}}" name="City" aria-placeholder="City"> <div class="select-wrapper"> - <span>STATE</span> - <select name="Province"> + <span></span> + <select id="address_state_{{_id}}" name="Province"> {{PROVINCES}} </select> </div> </div> + <div class="half-input"> - <input type="text" name="ZipCode" placeholder="ZIP" required> + <label for="address_zip_{{_id}}">Zip</label> + <label>Country</label> + </div> + + <div class="half-input"> + <input type="text" id="address_zip_{{_id}}" name="ZipCode" aria-placeholder="ZIP" required> <div class="country-wrapper-static"> <span class="country-label">UNITED STATES</span> <!-- @@ -1109,7 +1189,10 @@ --> </div> </div> - <input type="number" name="Phone" placeholder="PHONE NUMBER"> + + <label for="address_phone_{{_id}}">Phone Number</label> + <input type="number" id="address_phone_{{_id}}" name="Phone" aria-placeholder="PHONE NUMBER"> + <span class="err"></span> <!-- <div class="checkbox-container save_as_default"> <div class="checkbox-row"> @@ -1227,6 +1310,7 @@ <script src="js/lib/etc/geo.js"></script> <script src="js/lib/etc/sim.js"></script> <script src="js/lib/etc/backup_db.js"></script> +<script src="js/lib/etc/accessibility.js"></script> <script src="js/lib/view/View.js"></script> <script src="js/lib/view/Router.js"></script> diff --git a/StoneIsland/platforms/ios/www/js/index.js b/StoneIsland/platforms/ios/www/js/index.js index a8caa2e5..69a0a3e0 100755 --- a/StoneIsland/platforms/ios/www/js/index.js +++ b/StoneIsland/platforms/ios/www/js/index.js @@ -18,6 +18,9 @@ var app = (function(){ app.iscroll_options = { mouseWheel: true, scrollbars: true, + disablePointer: is_android ? true : false, // important to disable the pointer events that causes the issues + disableTouch: false, // false if you want the slider to be usable with touch devices + disableMouse: false // false if you want the slider to be usable with a mouse (desktop) } if (window.cordova) { @@ -83,6 +86,15 @@ var app = (function(){ sim.fetch(app.api_ready) var image = new Image image.src = "./img/compass-logo.png" + + MobileAccessibility.usePreferredTextZoom(true); + MobileAccessibility.getTextZoom(function getTextZoomCallback(textZoom) { + console.log('WebView text should be scaled to the preferred value ' + textZoom + '%') + if (textZoom > 100) { + app.accessible = true + $("html").addClass('accessible') + } + }); } else { app.api_ready() @@ -90,8 +102,8 @@ var app = (function(){ } app.api_ready = function(){ - if (is_iphone_x) { - StatusBar.hide() + if (is_iphone_x && 'StatusBar' in window) { + window.StatusBar.hide() } app.view = null diff --git a/StoneIsland/platforms/ios/www/js/lib/account/AccountView.js b/StoneIsland/platforms/ios/www/js/lib/account/AccountView.js index 8ac7c193..af035f6a 100755 --- a/StoneIsland/platforms/ios/www/js/lib/account/AccountView.js +++ b/StoneIsland/platforms/ios/www/js/lib/account/AccountView.js @@ -74,7 +74,7 @@ var AccountView = View.extend({ }, populateCreditCards: function(data, cb){ - console.log("populate ccs:", data.CreditCards) + // console.log("populate ccs:", data.CreditCards) this.ccs = data.CreditCards this.ccLookup = {} if (! data.CreditCards || ! data.CreditCards.length) { diff --git a/StoneIsland/platforms/ios/www/js/lib/blogs/ArchiveView.js b/StoneIsland/platforms/ios/www/js/lib/blogs/ArchiveView.js index 12aaf7de..0d769e95 100755 --- a/StoneIsland/platforms/ios/www/js/lib/blogs/ArchiveView.js +++ b/StoneIsland/platforms/ios/www/js/lib/blogs/ArchiveView.js @@ -21,7 +21,6 @@ var ArchiveView = ScrollableView.extend({ this.scroller = new IScroll('#archive .scroll', app.iscroll_options) this.$subtitle = this.$('.subtitle') this.subtitle_html = this.$subtitle.html() - }, back: function(){ diff --git a/StoneIsland/platforms/ios/www/js/lib/blogs/HubView.js b/StoneIsland/platforms/ios/www/js/lib/blogs/HubView.js index b072a887..c4ebd716 100755 --- a/StoneIsland/platforms/ios/www/js/lib/blogs/HubView.js +++ b/StoneIsland/platforms/ios/www/js/lib/blogs/HubView.js @@ -57,6 +57,8 @@ var HubView = ScrollableView.extend({ .replace(/{{date}}/, moment(row.date).format("MM.DD.YYYY")) .replace(/{{title}}/, row.title) .replace(/{{subtitle}}/, row.subtitle) + .replace(/{{cleantitle}}/, stonewash(row.title)) + .replace(/{{cleansubtitle}}/, stonewash(row.subtitle)) .replace(/{{link}}/, row.link) .replace(/{{body}}/, row.body.replace(/\n/g, "<br>")) var $t = $(t) @@ -71,6 +73,7 @@ var HubView = ScrollableView.extend({ row.image.forEach(function(img){ var el = document.createElement("div") el.style.backgroundImage = "url(" + img.uri + ")" + el.setAttribute('aria-label', img.caption) el.className = "item" $gallery.append(el) }) @@ -107,6 +110,8 @@ var HubView = ScrollableView.extend({ play.className = "play" $(".gallery-" + row.id).append(play) $(".gallery-" + row.id).addClass("gallery-video-post") + $(".gallery-" + row.id).attr('role', 'link') + $(".gallery-" + row.id).attr('aria-label', stonewash(row.title) + ". Watch the video on Youtube") if (! row.image) { var url = row.link var ytid = (url.match(/v=([-_a-zA-Z0-9]{11})/i) || url.match(/youtu.be\/([-_a-zA-Z0-9]{11})/i) || url.match(/embed\/([-_a-zA-Z0-9]{11})/i))[1].split('&')[0]; @@ -125,6 +130,7 @@ var HubView = ScrollableView.extend({ store_link: function(){ app.router.go("store") }, + play_video: function(e){ var row = $(e.currentTarget).closest('.gallery-video-post').data("row") window.open(row.link, '_system') @@ -142,7 +148,9 @@ var HubView = ScrollableView.extend({ share: function(e){ var title = $(e.currentTarget).parent().find(".title").text() console.log("share", title) - window.plugins.socialsharing.share(title, null, null, "http://deeplink.me/www.stoneisland.com/hub" ) + if (window.plugins && window.plugins.socialsharing) { + window.plugins.socialsharing.share(title, null, null, "http://deeplink.me/www.stoneisland.com/hub" ) + } }, }) @@ -169,7 +177,7 @@ var HubLoader = (function(){ if (item.image && item.image.length) { loader = new Loader (HubLoader.build) images = item.image.map(function(img){ - return img.uri.replace("http:","https:") + return img.uri.replace("http:", "https:") }).filter(function(img){ return img.uri }) diff --git a/StoneIsland/platforms/ios/www/js/lib/blogs/StoryView.js b/StoneIsland/platforms/ios/www/js/lib/blogs/StoryView.js index 5a7a56d1..924a7355 100755 --- a/StoneIsland/platforms/ios/www/js/lib/blogs/StoryView.js +++ b/StoneIsland/platforms/ios/www/js/lib/blogs/StoryView.js @@ -41,6 +41,7 @@ var StoryView = ScrollableView.extend({ var li = document.createElement("li") li.dataset.id = row.id li.innerHTML = row.title + li.role = "button" this.sections[row.id] = row this.$links.append(li) this.$content.append(t) @@ -67,6 +68,7 @@ var StoryView = ScrollableView.extend({ this.$img.stop().fadeTo(110,0.65, function() { $replace.attr("src", section.image.uri) + $replace.attr("alt", section.image.caption) }).fadeTo(130,1) } diff --git a/StoneIsland/platforms/ios/www/js/lib/cart/CartSummary.js b/StoneIsland/platforms/ios/www/js/lib/cart/CartSummary.js index 9b5da7b7..bf150791 100755 --- a/StoneIsland/platforms/ios/www/js/lib/cart/CartSummary.js +++ b/StoneIsland/platforms/ios/www/js/lib/cart/CartSummary.js @@ -75,7 +75,6 @@ var CartSummary = ScrollableView.extend({ 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) @@ -110,8 +109,10 @@ var CartSummary = ScrollableView.extend({ var t = this.template .replace(/{{image}}/, sdk.image(item['Code10'], '11_f')) - .replace(/{{sku}}/, num) - .replace(/{{title}}/, title) + .replace(/{{sku}}/g, num) + .replace(/{{code8}}/g, data['Code8']) + .replace(/{{title}}/g, title) + .replace(/{{cleantitle}}/g, stonewash(title)) .replace(/{{type}}/, type) .replace(/{{size}}/, size_name) .replace(/{{color}}/, color_name) diff --git a/StoneIsland/platforms/ios/www/js/lib/etc/accessibility.js b/StoneIsland/platforms/ios/www/js/lib/etc/accessibility.js new file mode 100644 index 00000000..614c3796 --- /dev/null +++ b/StoneIsland/platforms/ios/www/js/lib/etc/accessibility.js @@ -0,0 +1,9 @@ +$(function(){ + $("h1").each(function(){ + this['aria-label'] = 'Section title is ' + this.innerText + }) +}) + +function stonewash (s) { + return s.replace(/'0/g, '20').replace(/_/g, ' ') +}
\ 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 index 9e0c49b6..fd0fa59d 100755 --- a/StoneIsland/platforms/ios/www/js/lib/nav/AddressView.js +++ b/StoneIsland/platforms/ios/www/js/lib/nav/AddressView.js @@ -1,4 +1,6 @@ +var AddressViewID = Math.round(Date.now() % 1000) + var AddressView = SerializableView.extend({ template: $("#address_template").html(), @@ -14,7 +16,7 @@ var AddressView = SerializableView.extend({ this.parent = opt.parent this.checkPhone = 'checkPhone' in opt ? opt.checkPhone : true this.setElement( this.parent.$(".address") ) - this.$el.html(this.template) + this.$el.html(this.template.replace(/{{_id}}/g, AddressViewID++)) }, populate: function(data){ @@ -34,12 +36,15 @@ var AddressView = SerializableView.extend({ "Address1": "Please enter your street address.", "City": "Please enter your city.", "ZipCode": "Please enter your zip code.", + "Phone": "Please enter your phone number.", }, validate_fields: function(data, errors){ if (this.disabled) { return } if (this.checkPhone) { - var phone_number = data.Phone ? data.Phone.replace(/[^0-9]/g, "") : "" + var phone_number = data.Phone ? String(data.Phone).replace(/[^0-9]/g, "").replace(/^[01]+/, '') : "" + data.Phone = phone_number + this.$('[name=Phone]').val(phone_number) var phone_length = phone_number.length if (phone_length === 0 || ! data.Phone) { errors.push([ "Phone", "Please enter your phone number." ]) @@ -50,10 +55,10 @@ var AddressView = SerializableView.extend({ else if (phone_length > 10) { errors.push([ "Phone", "International phone numbers are not accepted." ]) } - else if (data.Phone[0] === '+') { + else if (phone_number.charAt(0) === '+') { errors.push([ "Phone", "Please enter a valid 10 digit US/Canada phone number. International phone numbers are not accepted." ]) } - else if (phone_number[0] === '1') { + else if (phone_number.charAt(0) === '1') { errors.push([ "Phone", "Please enter a valid 10 digit US/Canada phone number. International phone numbers are not accepted." ]) } } @@ -81,7 +86,10 @@ var AddressView = SerializableView.extend({ }, scroll_up_to_phone: function(e){ - app.view.scroller && app.view.scroller.scrollTo(0, -$(e.currentTarget).position().top) + var position = $(e.currentTarget).prev('label').position() + if (app.view.scroller && position) { + app.view.scroller.scrollTo(0, -position.top) + } }, }) diff --git a/StoneIsland/platforms/ios/www/js/lib/nav/CreditCardView.js b/StoneIsland/platforms/ios/www/js/lib/nav/CreditCardView.js index 63784618..af53d964 100755 --- a/StoneIsland/platforms/ios/www/js/lib/nav/CreditCardView.js +++ b/StoneIsland/platforms/ios/www/js/lib/nav/CreditCardView.js @@ -1,4 +1,6 @@ +var CreditCardViewID = Math.round(Date.now() % 1000) + var CreditCardView = SerializableView.extend({ template: $("#creditcard_template").html(), @@ -13,7 +15,7 @@ var CreditCardView = SerializableView.extend({ initialize: function(opt){ this.parent = opt.parent this.setElement( this.parent.$(".cc") ) - this.$el.html(this.template) + this.$el.html(this.template.replace(/{{_id}}/g, CreditCardViewID++)) this.$number = this.$("[name=Number]") this.$number.validateCreditCard(this.updateCard.bind(this), this.cardOptions) diff --git a/StoneIsland/platforms/ios/www/js/lib/nav/NavView.js b/StoneIsland/platforms/ios/www/js/lib/nav/NavView.js index 86c8ecaf..958bc8ad 100755 --- a/StoneIsland/platforms/ios/www/js/lib/nav/NavView.js +++ b/StoneIsland/platforms/ios/www/js/lib/nav/NavView.js @@ -23,7 +23,8 @@ var NavView = View.extend({ "click .shipping": "shipping", "click .settings": "settings", "click .orders": "orders", - "click .return_link": "return_link", + "click .return_link_us": "return_link_us", + "click .return_link_ca": "return_link_ca", "click .faq_back": "back", "click .privacy": "privacy", @@ -115,8 +116,11 @@ var NavView = View.extend({ this.hide() app.router.go("account/settings") }, - return_link: function(){ - window.open("http://www.stoneisland.com/yTos/Plugins/AreaLocalizer/Redirectarea?area=ProductExchange&controllerName=SearchOrder&actionName=Index", '_system') + return_link_us: function(){ + window.open("https://www.stoneisland.com/us/ProductExchange/SearchOrder/Index?utm_source=AppMobile&utm_medium=referral&utm_campaign=ReturnForm", '_system') + }, + return_link_ca: function(){ + window.open("https://www.stoneisland.com/ca/ProductExchange/SearchOrder/Index?utm_source=AppMobile&utm_medium=referral&utm_campaign=ReturnForm", '_system') }, @@ -141,7 +145,7 @@ var NavView = View.extend({ }, care: function(e){ e.preventDefault() - window.open("http://www.stoneisland.com/system/web/custom/hp/email.jsp", '_system') + window.open("https://www.stoneisland.com/customercare?utm_source=AppMobile&utm_medium=referral&utm_campaign=CustomerCare", '_system') }, diff --git a/StoneIsland/platforms/ios/www/js/lib/products/CollectionView.js b/StoneIsland/platforms/ios/www/js/lib/products/CollectionView.js index 4674fc18..b7af235a 100755 --- a/StoneIsland/platforms/ios/www/js/lib/products/CollectionView.js +++ b/StoneIsland/platforms/ios/www/js/lib/products/CollectionView.js @@ -196,6 +196,7 @@ var CollectionView = ScrollableView.extend({ this.items[ item['Code8'] ] = item var t = this.template.replace(/{{image}}/, sdk.image(item['DefaultCode10'], is_single_product ? '13_f' : '11_f')) .replace(/{{code8}}/, item['Code8']) + .replace(/{{title}}/, stonewash(item['ModelNames'])) var $t = $(t) if (app.store.ShowProductNameOnCollectionPage) { var $title = $("<span>") @@ -217,6 +218,7 @@ var CollectionView = ScrollableView.extend({ setCollectionName: function(name){ this.collectionName = name this.$title.html(this.collectionName) + this.$title.attr('aria-label', stonewash(this.collectionName)) }, // filter by department diff --git a/StoneIsland/platforms/ios/www/js/lib/products/GalleryView.js b/StoneIsland/platforms/ios/www/js/lib/products/GalleryView.js index 0acd48c5..d6f5723c 100755 --- a/StoneIsland/platforms/ios/www/js/lib/products/GalleryView.js +++ b/StoneIsland/platforms/ios/www/js/lib/products/GalleryView.js @@ -39,7 +39,9 @@ var GalleryView = View.extend({ Object.keys(valid_styles).sort(sort_image_styles).forEach(function(style){ var id = valid_styles[style] + "_" + style - var t = this.template.replace(/{{image}}/, sdk.image(code, id)) + var t = this.template + .replace(/{{image}}/, sdk.image(code, id)) + .replace(/{{alt}}/, YOOX_IMAGE_STYLE_LABELS[style] || "Alternate view") this.$el.append(t) }.bind(this)) @@ -79,5 +81,8 @@ var GalleryView = View.extend({ }) var YOOX_IMAGE_STYLE_ORDER = "ZZZ f r d e a b c g l".split(" ") - +var YOOX_IMAGE_STYLE_LABELS = { + f: 'Front view', + r: 'Rear view', +} function sort_image_styles (b,a){ return (YOOX_IMAGE_STYLE_ORDER.indexOf(b)) - (YOOX_IMAGE_STYLE_ORDER.indexOf(a)) }
\ No newline at end of file diff --git a/StoneIsland/platforms/ios/www/js/lib/products/ProductView.js b/StoneIsland/platforms/ios/www/js/lib/products/ProductView.js index 3bcf5ee4..c47dfddd 100755 --- a/StoneIsland/platforms/ios/www/js/lib/products/ProductView.js +++ b/StoneIsland/platforms/ios/www/js/lib/products/ProductView.js @@ -434,7 +434,9 @@ var ProductView = ScrollableView.extend({ }, share: function(){ - window.plugins.socialsharing.share( this.item['ModelNames'], null, null, "http://deeplink.me/www.stoneisland.com/store/" + this.code) + if (window.plugins && 'socialsharing' in window.plugins) { + window.plugins.socialsharing.share( this.item['ModelNames'], null, null, "http://deeplink.me/www.stoneisland.com/store/" + this.code) + } }, }) diff --git a/StoneIsland/platforms/ios/www/js/lib/products/Selector.js b/StoneIsland/platforms/ios/www/js/lib/products/Selector.js index 9c1109f6..e3376a4d 100755 --- a/StoneIsland/platforms/ios/www/js/lib/products/Selector.js +++ b/StoneIsland/platforms/ios/www/js/lib/products/Selector.js @@ -21,7 +21,7 @@ var Selector = View.extend({ options.forEach(function(opt){ this.lookup[String(opt.id)] = opt var t = this.template.replace(/{{id}}/, opt.id) - .replace(/{{label}}/, opt.label) + .replace(/{{label}}/g, opt.label) this.$options.append(t) }.bind(this)) this.$el.show() diff --git a/StoneIsland/platforms/ios/www/js/lib/view/Serializable.js b/StoneIsland/platforms/ios/www/js/lib/view/Serializable.js index 4155f102..3181fddd 100755 --- a/StoneIsland/platforms/ios/www/js/lib/view/Serializable.js +++ b/StoneIsland/platforms/ios/www/js/lib/view/Serializable.js @@ -105,6 +105,7 @@ var SerializableView = View.extend({ console.log(errors) var msgs = [] this.$('.error_hilite').removeClass('error_hilite') + this.$('.err').html('') errors.forEach(function(e, i){ // if (i > 0) { return } if (e[0]) { @@ -112,13 +113,15 @@ var SerializableView = View.extend({ var el = $el[0] if (el && el.nodeName === 'SELECT') { $el.parent().addClass('error_hilite') + $el.parent().next('.err').html(e[1]) } else { $el.addClass('error_hilite') + $el.next('.err').html(e[1]) } } - msgs.push(e[1]) + // msgs.push(e[1]) }.bind(this)) - this.$msg.html(msgs.join("<br>")) + // this.$msg.html(msgs.join("<br>")) this.$msg.addClass('alert-notice') }, diff --git a/StoneIsland/platforms/ios/www/js/vendor/iscroll-5.1.3.js b/StoneIsland/platforms/ios/www/js/vendor/iscroll-5.1.3.js new file mode 100755 index 00000000..8bd2b8da --- /dev/null +++ b/StoneIsland/platforms/ios/www/js/vendor/iscroll-5.1.3.js @@ -0,0 +1,2011 @@ +/*! iScroll v5.1.3 ~ (c) 2008-2014 Matteo Spinelli ~ http://cubiq.org/license */ +(function (window, document, Math) { +var rAF = window.requestAnimationFrame || + window.webkitRequestAnimationFrame || + window.mozRequestAnimationFrame || + window.oRequestAnimationFrame || + window.msRequestAnimationFrame || + function (callback) { window.setTimeout(callback, 1000 / 60); }; + +var utils = (function () { + var me = {}; + + var _elementStyle = document.createElement('div').style; + var _vendor = (function () { + var vendors = ['t', 'webkitT', 'MozT', 'msT', 'OT'], + transform, + i = 0, + l = vendors.length; + + for ( ; i < l; i++ ) { + transform = vendors[i] + 'ransform'; + if ( transform in _elementStyle ) return vendors[i].substr(0, vendors[i].length-1); + } + + return false; + })(); + + function _prefixStyle (style) { + if ( _vendor === false ) return false; + if ( _vendor === '' ) return style; + return _vendor + style.charAt(0).toUpperCase() + style.substr(1); + } + + me.getTime = Date.now || function getTime () { return new Date().getTime(); }; + + me.extend = function (target, obj) { + for ( var i in obj ) { + target[i] = obj[i]; + } + }; + + me.addEvent = function (el, type, fn, capture) { + el.addEventListener(type, fn, !!capture); + }; + + me.removeEvent = function (el, type, fn, capture) { + el.removeEventListener(type, fn, !!capture); + }; + + me.prefixPointerEvent = function (pointerEvent) { + return window.MSPointerEvent ? + 'MSPointer' + pointerEvent.charAt(9).toUpperCase() + pointerEvent.substr(10): + pointerEvent; + }; + + me.momentum = function (current, start, time, lowerMargin, wrapperSize, deceleration) { + var distance = current - start, + speed = Math.abs(distance) / time, + destination, + duration; + + deceleration = deceleration === undefined ? 0.0006 : deceleration; + + destination = current + ( speed * speed ) / ( 2 * deceleration ) * ( distance < 0 ? -1 : 1 ); + duration = speed / deceleration; + + if ( destination < lowerMargin ) { + destination = wrapperSize ? lowerMargin - ( wrapperSize / 2.5 * ( speed / 8 ) ) : lowerMargin; + distance = Math.abs(destination - current); + duration = distance / speed; + } else if ( destination > 0 ) { + destination = wrapperSize ? wrapperSize / 2.5 * ( speed / 8 ) : 0; + distance = Math.abs(current) + destination; + duration = distance / speed; + } + + return { + destination: Math.round(destination), + duration: duration + }; + }; + + var _transform = _prefixStyle('transform'); + + me.extend(me, { + hasTransform: _transform !== false, + hasPerspective: _prefixStyle('perspective') in _elementStyle, + hasTouch: 'ontouchstart' in window, + hasPointer: window.PointerEvent || window.MSPointerEvent, // IE10 is prefixed + hasTransition: _prefixStyle('transition') in _elementStyle + }); + + // This should find all Android browsers lower than build 535.19 (both stock browser and webview) + me.isBadAndroid = /Android /.test(window.navigator.appVersion) && !(/Chrome\/\d/.test(window.navigator.appVersion)); + + me.extend(me.style = {}, { + transform: _transform, + transitionTimingFunction: _prefixStyle('transitionTimingFunction'), + transitionDuration: _prefixStyle('transitionDuration'), + transitionDelay: _prefixStyle('transitionDelay'), + transformOrigin: _prefixStyle('transformOrigin') + }); + + me.hasClass = function (e, c) { + var re = new RegExp("(^|\\s)" + c + "(\\s|$)"); + return re.test(e.className); + }; + + me.addClass = function (e, c) { + if ( me.hasClass(e, c) ) { + return; + } + + var newclass = e.className.split(' '); + newclass.push(c); + e.className = newclass.join(' '); + }; + + me.removeClass = function (e, c) { + if ( !me.hasClass(e, c) ) { + return; + } + + var re = new RegExp("(^|\\s)" + c + "(\\s|$)", 'g'); + e.className = e.className.replace(re, ' '); + }; + + me.offset = function (el) { + var left = -el.offsetLeft, + top = -el.offsetTop; + + // jshint -W084 + while (el = el.offsetParent) { + left -= el.offsetLeft; + top -= el.offsetTop; + } + // jshint +W084 + + return { + left: left, + top: top + }; + }; + + me.preventDefaultException = function (el, exceptions) { + for ( var i in exceptions ) { + if ( exceptions[i].test(el[i]) ) { + return true; + } + } + + return false; + }; + + me.extend(me.eventType = {}, { + touchstart: 1, + touchmove: 1, + touchend: 1, + + mousedown: 2, + mousemove: 2, + mouseup: 2, + + pointerdown: 3, + pointermove: 3, + pointerup: 3, + + MSPointerDown: 3, + MSPointerMove: 3, + MSPointerUp: 3 + }); + + me.extend(me.ease = {}, { + quadratic: { + style: 'cubic-bezier(0.25, 0.46, 0.45, 0.94)', + fn: function (k) { + return k * ( 2 - k ); + } + }, + circular: { + style: 'cubic-bezier(0.1, 0.57, 0.1, 1)', // Not properly "circular" but this looks better, it should be (0.075, 0.82, 0.165, 1) + fn: function (k) { + return Math.sqrt( 1 - ( --k * k ) ); + } + }, + back: { + style: 'cubic-bezier(0.175, 0.885, 0.32, 1.275)', + fn: function (k) { + var b = 4; + return ( k = k - 1 ) * k * ( ( b + 1 ) * k + b ) + 1; + } + }, + bounce: { + style: '', + fn: function (k) { + if ( ( k /= 1 ) < ( 1 / 2.75 ) ) { + return 7.5625 * k * k; + } else if ( k < ( 2 / 2.75 ) ) { + return 7.5625 * ( k -= ( 1.5 / 2.75 ) ) * k + 0.75; + } else if ( k < ( 2.5 / 2.75 ) ) { + return 7.5625 * ( k -= ( 2.25 / 2.75 ) ) * k + 0.9375; + } else { + return 7.5625 * ( k -= ( 2.625 / 2.75 ) ) * k + 0.984375; + } + } + }, + elastic: { + style: '', + fn: function (k) { + var f = 0.22, + e = 0.4; + + if ( k === 0 ) { return 0; } + if ( k == 1 ) { return 1; } + + return ( e * Math.pow( 2, - 10 * k ) * Math.sin( ( k - f / 4 ) * ( 2 * Math.PI ) / f ) + 1 ); + } + } + }); + + me.tap = function (e, eventName) { + var ev = document.createEvent('Event'); + ev.initEvent(eventName, true, true); + ev.pageX = e.pageX; + ev.pageY = e.pageY; + e.target.dispatchEvent(ev); + }; + + me.click = function (e) { + var target = e.target, + ev; + + if ( !(/(SELECT|INPUT|TEXTAREA)/i).test(target.tagName) ) { + ev = document.createEvent('MouseEvents'); + ev.initMouseEvent('click', true, true, e.view, 1, + target.screenX, target.screenY, target.clientX, target.clientY, + e.ctrlKey, e.altKey, e.shiftKey, e.metaKey, + 0, null); + + ev._constructed = true; + target.dispatchEvent(ev); + } + }; + + return me; +})(); + +function IScroll (el, options) { + this.wrapper = typeof el == 'string' ? document.querySelector(el) : el; + this.scroller = this.wrapper.children[0]; + this.scrollerStyle = this.scroller.style; // cache style for better performance + + this.options = { + + resizeScrollbars: true, + + mouseWheelSpeed: 20, + + snapThreshold: 0.334, + +// INSERT POINT: OPTIONS + + startX: 0, + startY: 0, + scrollY: true, + directionLockThreshold: 5, + momentum: true, + + bounce: true, + bounceTime: 600, + bounceEasing: '', + + preventDefault: true, + preventDefaultException: { tagName: /^(INPUT|TEXTAREA|BUTTON|SELECT)$/ }, + + HWCompositing: true, + useTransition: true, + useTransform: true + }; + + for ( var i in options ) { + this.options[i] = options[i]; + } + + // Normalize options + this.translateZ = this.options.HWCompositing && utils.hasPerspective ? ' translateZ(0)' : ''; + + this.options.useTransition = utils.hasTransition && this.options.useTransition; + this.options.useTransform = utils.hasTransform && this.options.useTransform; + + this.options.eventPassthrough = this.options.eventPassthrough === true ? 'vertical' : this.options.eventPassthrough; + this.options.preventDefault = !this.options.eventPassthrough && this.options.preventDefault; + + // If you want eventPassthrough I have to lock one of the axes + this.options.scrollY = this.options.eventPassthrough == 'vertical' ? false : this.options.scrollY; + this.options.scrollX = this.options.eventPassthrough == 'horizontal' ? false : this.options.scrollX; + + // With eventPassthrough we also need lockDirection mechanism + this.options.freeScroll = this.options.freeScroll && !this.options.eventPassthrough; + this.options.directionLockThreshold = this.options.eventPassthrough ? 0 : this.options.directionLockThreshold; + + this.options.bounceEasing = typeof this.options.bounceEasing == 'string' ? utils.ease[this.options.bounceEasing] || utils.ease.circular : this.options.bounceEasing; + + this.options.resizePolling = this.options.resizePolling === undefined ? 60 : this.options.resizePolling; + + if ( this.options.tap === true ) { + this.options.tap = 'tap'; + } + + if ( this.options.shrinkScrollbars == 'scale' ) { + this.options.useTransition = false; + } + + this.options.invertWheelDirection = this.options.invertWheelDirection ? -1 : 1; + +// INSERT POINT: NORMALIZATION + + // Some defaults + this.x = 0; + this.y = 0; + this.directionX = 0; + this.directionY = 0; + this._events = {}; + +// INSERT POINT: DEFAULTS + + this._init(); + this.refresh(); + + this.scrollTo(this.options.startX, this.options.startY); + this.enable(); +} + +IScroll.prototype = { + version: '5.1.3', + + _init: function () { + this._initEvents(); + + if ( this.options.scrollbars || this.options.indicators ) { + this._initIndicators(); + } + + if ( this.options.mouseWheel ) { + this._initWheel(); + } + + if ( this.options.snap ) { + this._initSnap(); + } + + if ( this.options.keyBindings ) { + this._initKeys(); + } + +// INSERT POINT: _init + + }, + + destroy: function () { + this._initEvents(true); + + this._execEvent('destroy'); + }, + + _transitionEnd: function (e) { + if ( e.target != this.scroller || !this.isInTransition ) { + return; + } + + this._transitionTime(); + if ( !this.resetPosition(this.options.bounceTime) ) { + this.isInTransition = false; + this._execEvent('scrollEnd'); + } + }, + + _start: function (e) { + // React to left mouse button only + if ( utils.eventType[e.type] != 1 ) { + if ( e.button !== 0 ) { + return; + } + } + + if ( !this.enabled || (this.initiated && utils.eventType[e.type] !== this.initiated) ) { + return; + } + + if ( this.options.preventDefault && !utils.isBadAndroid && !utils.preventDefaultException(e.target, this.options.preventDefaultException) ) { + e.preventDefault(); + } + + var point = e.touches ? e.touches[0] : e, + pos; + + this.initiated = utils.eventType[e.type]; + this.moved = false; + this.distX = 0; + this.distY = 0; + this.directionX = 0; + this.directionY = 0; + this.directionLocked = 0; + + this._transitionTime(); + + this.startTime = utils.getTime(); + + if ( this.options.useTransition && this.isInTransition ) { + this.isInTransition = false; + pos = this.getComputedPosition(); + this._translate(Math.round(pos.x), Math.round(pos.y)); + this._execEvent('scrollEnd'); + } else if ( !this.options.useTransition && this.isAnimating ) { + this.isAnimating = false; + this._execEvent('scrollEnd'); + } + + this.startX = this.x; + this.startY = this.y; + this.absStartX = this.x; + this.absStartY = this.y; + this.pointX = point.pageX; + this.pointY = point.pageY; + + this._execEvent('beforeScrollStart'); + }, + + _move: function (e) { + if ( !this.enabled || utils.eventType[e.type] !== this.initiated ) { + return; + } + + if ( this.options.preventDefault ) { // increases performance on Android? TODO: check! + e.preventDefault(); + } + + var point = e.touches ? e.touches[0] : e, + deltaX = point.pageX - this.pointX, + deltaY = point.pageY - this.pointY, + timestamp = utils.getTime(), + newX, newY, + absDistX, absDistY; + + this.pointX = point.pageX; + this.pointY = point.pageY; + + this.distX += deltaX; + this.distY += deltaY; + absDistX = Math.abs(this.distX); + absDistY = Math.abs(this.distY); + + // We need to move at least 10 pixels for the scrolling to initiate + if ( timestamp - this.endTime > 300 && (absDistX < 10 && absDistY < 10) ) { + return; + } + + // If you are scrolling in one direction lock the other + if ( !this.directionLocked && !this.options.freeScroll ) { + if ( absDistX > absDistY + this.options.directionLockThreshold ) { + this.directionLocked = 'h'; // lock horizontally + } else if ( absDistY >= absDistX + this.options.directionLockThreshold ) { + this.directionLocked = 'v'; // lock vertically + } else { + this.directionLocked = 'n'; // no lock + } + } + + if ( this.directionLocked == 'h' ) { + if ( this.options.eventPassthrough == 'vertical' ) { + e.preventDefault(); + } else if ( this.options.eventPassthrough == 'horizontal' ) { + this.initiated = false; + return; + } + + deltaY = 0; + } else if ( this.directionLocked == 'v' ) { + if ( this.options.eventPassthrough == 'horizontal' ) { + e.preventDefault(); + } else if ( this.options.eventPassthrough == 'vertical' ) { + this.initiated = false; + return; + } + + deltaX = 0; + } + + deltaX = this.hasHorizontalScroll ? deltaX : 0; + deltaY = this.hasVerticalScroll ? deltaY : 0; + + newX = this.x + deltaX; + newY = this.y + deltaY; + + // Slow down if outside of the boundaries + if ( newX > 0 || newX < this.maxScrollX ) { + newX = this.options.bounce ? this.x + deltaX / 3 : newX > 0 ? 0 : this.maxScrollX; + } + if ( newY > 0 || newY < this.maxScrollY ) { + newY = this.options.bounce ? this.y + deltaY / 3 : newY > 0 ? 0 : this.maxScrollY; + } + + this.directionX = deltaX > 0 ? -1 : deltaX < 0 ? 1 : 0; + this.directionY = deltaY > 0 ? -1 : deltaY < 0 ? 1 : 0; + + if ( !this.moved ) { + this._execEvent('scrollStart'); + } + + this.moved = true; + + this._translate(newX, newY); + +/* REPLACE START: _move */ + + if ( timestamp - this.startTime > 300 ) { + this.startTime = timestamp; + this.startX = this.x; + this.startY = this.y; + } + +/* REPLACE END: _move */ + + }, + + _end: function (e) { + if ( !this.enabled || utils.eventType[e.type] !== this.initiated ) { + return; + } + + if ( this.options.preventDefault && !utils.preventDefaultException(e.target, this.options.preventDefaultException) ) { + e.preventDefault(); + } + + var point = e.changedTouches ? e.changedTouches[0] : e, + momentumX, + momentumY, + duration = utils.getTime() - this.startTime, + newX = Math.round(this.x), + newY = Math.round(this.y), + distanceX = Math.abs(newX - this.startX), + distanceY = Math.abs(newY - this.startY), + time = 0, + easing = ''; + + this.isInTransition = 0; + this.initiated = 0; + this.endTime = utils.getTime(); + + // reset if we are outside of the boundaries + if ( this.resetPosition(this.options.bounceTime) ) { + return; + } + + this.scrollTo(newX, newY); // ensures that the last position is rounded + + // we scrolled less than 10 pixels + if ( !this.moved ) { + if ( this.options.tap ) { + utils.tap(e, this.options.tap); + } + + if ( this.options.click ) { + utils.click(e); + } + + this._execEvent('scrollCancel'); + return; + } + + if ( this._events.flick && duration < 200 && distanceX < 100 && distanceY < 100 ) { + this._execEvent('flick'); + return; + } + + // start momentum animation if needed + if ( this.options.momentum && duration < 300 ) { + momentumX = this.hasHorizontalScroll ? utils.momentum(this.x, this.startX, duration, this.maxScrollX, this.options.bounce ? this.wrapperWidth : 0, this.options.deceleration) : { destination: newX, duration: 0 }; + momentumY = this.hasVerticalScroll ? utils.momentum(this.y, this.startY, duration, this.maxScrollY, this.options.bounce ? this.wrapperHeight : 0, this.options.deceleration) : { destination: newY, duration: 0 }; + newX = momentumX.destination; + newY = momentumY.destination; + time = Math.max(momentumX.duration, momentumY.duration); + this.isInTransition = 1; + } + + + if ( this.options.snap ) { + var snap = this._nearestSnap(newX, newY); + this.currentPage = snap; + time = this.options.snapSpeed || Math.max( + Math.max( + Math.min(Math.abs(newX - snap.x), 1000), + Math.min(Math.abs(newY - snap.y), 1000) + ), 300); + newX = snap.x; + newY = snap.y; + + this.directionX = 0; + this.directionY = 0; + easing = this.options.bounceEasing; + } + +// INSERT POINT: _end + + if ( newX != this.x || newY != this.y ) { + // change easing function when scroller goes out of the boundaries + if ( newX > 0 || newX < this.maxScrollX || newY > 0 || newY < this.maxScrollY ) { + easing = utils.ease.quadratic; + } + + this.scrollTo(newX, newY, time, easing); + return; + } + + this._execEvent('scrollEnd'); + }, + + _resize: function () { + var that = this; + + clearTimeout(this.resizeTimeout); + + this.resizeTimeout = setTimeout(function () { + that.refresh(); + }, this.options.resizePolling); + }, + + resetPosition: function (time) { + var x = this.x, + y = this.y; + + time = time || 0; + + if ( !this.hasHorizontalScroll || this.x > 0 ) { + x = 0; + } else if ( this.x < this.maxScrollX ) { + x = this.maxScrollX; + } + + if ( !this.hasVerticalScroll || this.y > 0 ) { + y = 0; + } else if ( this.y < this.maxScrollY ) { + y = this.maxScrollY; + } + + if ( x == this.x && y == this.y ) { + return false; + } + + this.scrollTo(x, y, time, this.options.bounceEasing); + + return true; + }, + + disable: function () { + this.enabled = false; + }, + + enable: function () { + this.enabled = true; + }, + + refresh: function () { + var rf = this.wrapper.offsetHeight; // Force reflow + + this.wrapperWidth = this.wrapper.clientWidth; + this.wrapperHeight = this.wrapper.clientHeight; + +/* REPLACE START: refresh */ + + this.scrollerWidth = this.scroller.offsetWidth; + this.scrollerHeight = this.scroller.offsetHeight; + + this.maxScrollX = this.wrapperWidth - this.scrollerWidth; + this.maxScrollY = this.wrapperHeight - this.scrollerHeight; + +/* REPLACE END: refresh */ + + this.hasHorizontalScroll = this.options.scrollX && this.maxScrollX < 0; + this.hasVerticalScroll = this.options.scrollY && this.maxScrollY < 0; + + if ( !this.hasHorizontalScroll ) { + this.maxScrollX = 0; + this.scrollerWidth = this.wrapperWidth; + } + + if ( !this.hasVerticalScroll ) { + this.maxScrollY = 0; + this.scrollerHeight = this.wrapperHeight; + } + + this.endTime = 0; + this.directionX = 0; + this.directionY = 0; + + this.wrapperOffset = utils.offset(this.wrapper); + + this._execEvent('refresh'); + + this.resetPosition(); + +// INSERT POINT: _refresh + + }, + + on: function (type, fn) { + if ( !this._events[type] ) { + this._events[type] = []; + } + + this._events[type].push(fn); + }, + + off: function (type, fn) { + if ( !this._events[type] ) { + return; + } + + var index = this._events[type].indexOf(fn); + + if ( index > -1 ) { + this._events[type].splice(index, 1); + } + }, + + _execEvent: function (type) { + if ( !this._events[type] ) { + return; + } + + var i = 0, + l = this._events[type].length; + + if ( !l ) { + return; + } + + for ( ; i < l; i++ ) { + this._events[type][i].apply(this, [].slice.call(arguments, 1)); + } + }, + + scrollBy: function (x, y, time, easing) { + x = this.x + x; + y = this.y + y; + time = time || 0; + + this.scrollTo(x, y, time, easing); + }, + + scrollTo: function (x, y, time, easing) { + easing = easing || utils.ease.circular; + + this.isInTransition = this.options.useTransition && time > 0; + + if ( !time || (this.options.useTransition && easing.style) ) { + this._transitionTimingFunction(easing.style); + this._transitionTime(time); + this._translate(x, y); + } else { + this._animate(x, y, time, easing.fn); + } + }, + + scrollToElement: function (el, time, offsetX, offsetY, easing) { + el = el.nodeType ? el : this.scroller.querySelector(el); + + if ( !el ) { + return; + } + + var pos = utils.offset(el); + + pos.left -= this.wrapperOffset.left; + pos.top -= this.wrapperOffset.top; + + // if offsetX/Y are true we center the element to the screen + if ( offsetX === true ) { + offsetX = Math.round(el.offsetWidth / 2 - this.wrapper.offsetWidth / 2); + } + if ( offsetY === true ) { + offsetY = Math.round(el.offsetHeight / 2 - this.wrapper.offsetHeight / 2); + } + + pos.left -= offsetX || 0; + pos.top -= offsetY || 0; + + pos.left = pos.left > 0 ? 0 : pos.left < this.maxScrollX ? this.maxScrollX : pos.left; + pos.top = pos.top > 0 ? 0 : pos.top < this.maxScrollY ? this.maxScrollY : pos.top; + + time = time === undefined || time === null || time === 'auto' ? Math.max(Math.abs(this.x-pos.left), Math.abs(this.y-pos.top)) : time; + + this.scrollTo(pos.left, pos.top, time, easing); + }, + + _transitionTime: function (time) { + time = time || 0; + + this.scrollerStyle[utils.style.transitionDuration] = time + 'ms'; + + if ( !time && utils.isBadAndroid ) { + this.scrollerStyle[utils.style.transitionDuration] = '0.001s'; + } + + + if ( this.indicators ) { + for ( var i = this.indicators.length; i--; ) { + this.indicators[i].transitionTime(time); + } + } + + +// INSERT POINT: _transitionTime + + }, + + _transitionTimingFunction: function (easing) { + this.scrollerStyle[utils.style.transitionTimingFunction] = easing; + + + if ( this.indicators ) { + for ( var i = this.indicators.length; i--; ) { + this.indicators[i].transitionTimingFunction(easing); + } + } + + +// INSERT POINT: _transitionTimingFunction + + }, + + _translate: function (x, y) { + if ( this.options.useTransform ) { + +/* REPLACE START: _translate */ + + this.scrollerStyle[utils.style.transform] = 'translate(' + x + 'px,' + y + 'px)' + this.translateZ; + +/* REPLACE END: _translate */ + + } else { + x = Math.round(x); + y = Math.round(y); + this.scrollerStyle.left = x + 'px'; + this.scrollerStyle.top = y + 'px'; + } + + this.x = x; + this.y = y; + + + if ( this.indicators ) { + for ( var i = this.indicators.length; i--; ) { + this.indicators[i].updatePosition(); + } + } + + +// INSERT POINT: _translate + + }, + + _initEvents: function (remove) { + var eventType = remove ? utils.removeEvent : utils.addEvent, + target = this.options.bindToWrapper ? this.wrapper : window; + + eventType(window, 'orientationchange', this); + eventType(window, 'resize', this); + + if ( this.options.click ) { + eventType(this.wrapper, 'click', this, true); + } + + if ( !this.options.disableMouse ) { + eventType(this.wrapper, 'mousedown', this); + eventType(target, 'mousemove', this); + eventType(target, 'mousecancel', this); + eventType(target, 'mouseup', this); + } + + if ( utils.hasPointer && !this.options.disablePointer ) { + eventType(this.wrapper, utils.prefixPointerEvent('pointerdown'), this); + eventType(target, utils.prefixPointerEvent('pointermove'), this); + eventType(target, utils.prefixPointerEvent('pointercancel'), this); + eventType(target, utils.prefixPointerEvent('pointerup'), this); + } + + if ( utils.hasTouch && !this.options.disableTouch ) { + eventType(this.wrapper, 'touchstart', this); + eventType(target, 'touchmove', this); + eventType(target, 'touchcancel', this); + eventType(target, 'touchend', this); + } + + eventType(this.scroller, 'transitionend', this); + eventType(this.scroller, 'webkitTransitionEnd', this); + eventType(this.scroller, 'oTransitionEnd', this); + eventType(this.scroller, 'MSTransitionEnd', this); + }, + + getComputedPosition: function () { + var matrix = window.getComputedStyle(this.scroller, null), + x, y; + + if ( this.options.useTransform ) { + matrix = matrix[utils.style.transform].split(')')[0].split(', '); + x = +(matrix[12] || matrix[4]); + y = +(matrix[13] || matrix[5]); + } else { + x = +matrix.left.replace(/[^-\d.]/g, ''); + y = +matrix.top.replace(/[^-\d.]/g, ''); + } + + return { x: x, y: y }; + }, + + _initIndicators: function () { + var interactive = this.options.interactiveScrollbars, + customStyle = typeof this.options.scrollbars != 'string', + indicators = [], + indicator; + + var that = this; + + this.indicators = []; + + if ( this.options.scrollbars ) { + // Vertical scrollbar + if ( this.options.scrollY ) { + indicator = { + el: createDefaultScrollbar('v', interactive, this.options.scrollbars), + interactive: interactive, + defaultScrollbars: true, + customStyle: customStyle, + resize: this.options.resizeScrollbars, + shrink: this.options.shrinkScrollbars, + fade: this.options.fadeScrollbars, + listenX: false + }; + + this.wrapper.appendChild(indicator.el); + indicators.push(indicator); + } + + // Horizontal scrollbar + if ( this.options.scrollX ) { + indicator = { + el: createDefaultScrollbar('h', interactive, this.options.scrollbars), + interactive: interactive, + defaultScrollbars: true, + customStyle: customStyle, + resize: this.options.resizeScrollbars, + shrink: this.options.shrinkScrollbars, + fade: this.options.fadeScrollbars, + listenY: false + }; + + this.wrapper.appendChild(indicator.el); + indicators.push(indicator); + } + } + + if ( this.options.indicators ) { + // TODO: check concat compatibility + indicators = indicators.concat(this.options.indicators); + } + + for ( var i = indicators.length; i--; ) { + this.indicators.push( new Indicator(this, indicators[i]) ); + } + + // TODO: check if we can use array.map (wide compatibility and performance issues) + function _indicatorsMap (fn) { + for ( var i = that.indicators.length; i--; ) { + fn.call(that.indicators[i]); + } + } + + if ( this.options.fadeScrollbars ) { + this.on('scrollEnd', function () { + _indicatorsMap(function () { + this.fade(); + }); + }); + + this.on('scrollCancel', function () { + _indicatorsMap(function () { + this.fade(); + }); + }); + + this.on('scrollStart', function () { + _indicatorsMap(function () { + this.fade(1); + }); + }); + + this.on('beforeScrollStart', function () { + _indicatorsMap(function () { + this.fade(1, true); + }); + }); + } + + + this.on('refresh', function () { + _indicatorsMap(function () { + this.refresh(); + }); + }); + + this.on('destroy', function () { + _indicatorsMap(function () { + this.destroy(); + }); + + delete this.indicators; + }); + }, + + _initWheel: function () { + utils.addEvent(this.wrapper, 'wheel', this); + utils.addEvent(this.wrapper, 'mousewheel', this); + utils.addEvent(this.wrapper, 'DOMMouseScroll', this); + + this.on('destroy', function () { + utils.removeEvent(this.wrapper, 'wheel', this); + utils.removeEvent(this.wrapper, 'mousewheel', this); + utils.removeEvent(this.wrapper, 'DOMMouseScroll', this); + }); + }, + + _wheel: function (e) { + if ( !this.enabled ) { + return; + } + + e.preventDefault(); + e.stopPropagation(); + + var wheelDeltaX, wheelDeltaY, + newX, newY, + that = this; + + if ( this.wheelTimeout === undefined ) { + that._execEvent('scrollStart'); + } + + // Execute the scrollEnd event after 400ms the wheel stopped scrolling + clearTimeout(this.wheelTimeout); + this.wheelTimeout = setTimeout(function () { + that._execEvent('scrollEnd'); + that.wheelTimeout = undefined; + }, 400); + + if ( 'deltaX' in e ) { + if (e.deltaMode === 1) { + wheelDeltaX = -e.deltaX * this.options.mouseWheelSpeed; + wheelDeltaY = -e.deltaY * this.options.mouseWheelSpeed; + } else { + wheelDeltaX = -e.deltaX; + wheelDeltaY = -e.deltaY; + } + } else if ( 'wheelDeltaX' in e ) { + wheelDeltaX = e.wheelDeltaX / 120 * this.options.mouseWheelSpeed; + wheelDeltaY = e.wheelDeltaY / 120 * this.options.mouseWheelSpeed; + } else if ( 'wheelDelta' in e ) { + wheelDeltaX = wheelDeltaY = e.wheelDelta / 120 * this.options.mouseWheelSpeed; + } else if ( 'detail' in e ) { + wheelDeltaX = wheelDeltaY = -e.detail / 3 * this.options.mouseWheelSpeed; + } else { + return; + } + + wheelDeltaX *= this.options.invertWheelDirection; + wheelDeltaY *= this.options.invertWheelDirection; + + if ( !this.hasVerticalScroll ) { + wheelDeltaX = wheelDeltaY; + wheelDeltaY = 0; + } + + if ( this.options.snap ) { + newX = this.currentPage.pageX; + newY = this.currentPage.pageY; + + if ( wheelDeltaX > 0 ) { + newX--; + } else if ( wheelDeltaX < 0 ) { + newX++; + } + + if ( wheelDeltaY > 0 ) { + newY--; + } else if ( wheelDeltaY < 0 ) { + newY++; + } + + this.goToPage(newX, newY); + + return; + } + + newX = this.x + Math.round(this.hasHorizontalScroll ? wheelDeltaX : 0); + newY = this.y + Math.round(this.hasVerticalScroll ? wheelDeltaY : 0); + + if ( newX > 0 ) { + newX = 0; + } else if ( newX < this.maxScrollX ) { + newX = this.maxScrollX; + } + + if ( newY > 0 ) { + newY = 0; + } else if ( newY < this.maxScrollY ) { + newY = this.maxScrollY; + } + + this.scrollTo(newX, newY, 0); + +// INSERT POINT: _wheel + }, + + _initSnap: function () { + this.currentPage = {}; + + if ( typeof this.options.snap == 'string' ) { + this.options.snap = this.scroller.querySelectorAll(this.options.snap); + } + + this.on('refresh', function () { + var i = 0, l, + m = 0, n, + cx, cy, + x = 0, y, + stepX = this.options.snapStepX || this.wrapperWidth, + stepY = this.options.snapStepY || this.wrapperHeight, + el; + + this.pages = []; + + if ( !this.wrapperWidth || !this.wrapperHeight || !this.scrollerWidth || !this.scrollerHeight ) { + return; + } + + if ( this.options.snap === true ) { + cx = Math.round( stepX / 2 ); + cy = Math.round( stepY / 2 ); + + while ( x > -this.scrollerWidth ) { + this.pages[i] = []; + l = 0; + y = 0; + + while ( y > -this.scrollerHeight ) { + this.pages[i][l] = { + x: Math.max(x, this.maxScrollX), + y: Math.max(y, this.maxScrollY), + width: stepX, + height: stepY, + cx: x - cx, + cy: y - cy + }; + + y -= stepY; + l++; + } + + x -= stepX; + i++; + } + } else { + el = this.options.snap; + l = el.length; + n = -1; + + for ( ; i < l; i++ ) { + if ( i === 0 || el[i].offsetLeft <= el[i-1].offsetLeft ) { + m = 0; + n++; + } + + if ( !this.pages[m] ) { + this.pages[m] = []; + } + + x = Math.max(-el[i].offsetLeft, this.maxScrollX); + y = Math.max(-el[i].offsetTop, this.maxScrollY); + cx = x - Math.round(el[i].offsetWidth / 2); + cy = y - Math.round(el[i].offsetHeight / 2); + + this.pages[m][n] = { + x: x, + y: y, + width: el[i].offsetWidth, + height: el[i].offsetHeight, + cx: cx, + cy: cy + }; + + if ( x > this.maxScrollX ) { + m++; + } + } + } + + this.goToPage(this.currentPage.pageX || 0, this.currentPage.pageY || 0, 0); + + // Update snap threshold if needed + if ( this.options.snapThreshold % 1 === 0 ) { + this.snapThresholdX = this.options.snapThreshold; + this.snapThresholdY = this.options.snapThreshold; + } else { + this.snapThresholdX = Math.round(this.pages[this.currentPage.pageX][this.currentPage.pageY].width * this.options.snapThreshold); + this.snapThresholdY = Math.round(this.pages[this.currentPage.pageX][this.currentPage.pageY].height * this.options.snapThreshold); + } + }); + + this.on('flick', function () { + var time = this.options.snapSpeed || Math.max( + Math.max( + Math.min(Math.abs(this.x - this.startX), 1000), + Math.min(Math.abs(this.y - this.startY), 1000) + ), 300); + + this.goToPage( + this.currentPage.pageX + this.directionX, + this.currentPage.pageY + this.directionY, + time + ); + }); + }, + + _nearestSnap: function (x, y) { + if ( !this.pages.length ) { + return { x: 0, y: 0, pageX: 0, pageY: 0 }; + } + + var i = 0, + l = this.pages.length, + m = 0; + + // Check if we exceeded the snap threshold + if ( Math.abs(x - this.absStartX) < this.snapThresholdX && + Math.abs(y - this.absStartY) < this.snapThresholdY ) { + return this.currentPage; + } + + if ( x > 0 ) { + x = 0; + } else if ( x < this.maxScrollX ) { + x = this.maxScrollX; + } + + if ( y > 0 ) { + y = 0; + } else if ( y < this.maxScrollY ) { + y = this.maxScrollY; + } + + for ( ; i < l; i++ ) { + if ( x >= this.pages[i][0].cx ) { + x = this.pages[i][0].x; + break; + } + } + + l = this.pages[i].length; + + for ( ; m < l; m++ ) { + if ( y >= this.pages[0][m].cy ) { + y = this.pages[0][m].y; + break; + } + } + + if ( i == this.currentPage.pageX ) { + i += this.directionX; + + if ( i < 0 ) { + i = 0; + } else if ( i >= this.pages.length ) { + i = this.pages.length - 1; + } + + x = this.pages[i][0].x; + } + + if ( m == this.currentPage.pageY ) { + m += this.directionY; + + if ( m < 0 ) { + m = 0; + } else if ( m >= this.pages[0].length ) { + m = this.pages[0].length - 1; + } + + y = this.pages[0][m].y; + } + + return { + x: x, + y: y, + pageX: i, + pageY: m + }; + }, + + goToPage: function (x, y, time, easing) { + easing = easing || this.options.bounceEasing; + + if ( x >= this.pages.length ) { + x = this.pages.length - 1; + } else if ( x < 0 ) { + x = 0; + } + + if ( y >= this.pages[x].length ) { + y = this.pages[x].length - 1; + } else if ( y < 0 ) { + y = 0; + } + + var posX = this.pages[x][y].x, + posY = this.pages[x][y].y; + + time = time === undefined ? this.options.snapSpeed || Math.max( + Math.max( + Math.min(Math.abs(posX - this.x), 1000), + Math.min(Math.abs(posY - this.y), 1000) + ), 300) : time; + + this.currentPage = { + x: posX, + y: posY, + pageX: x, + pageY: y + }; + + this.scrollTo(posX, posY, time, easing); + }, + + next: function (time, easing) { + var x = this.currentPage.pageX, + y = this.currentPage.pageY; + + x++; + + if ( x >= this.pages.length && this.hasVerticalScroll ) { + x = 0; + y++; + } + + this.goToPage(x, y, time, easing); + }, + + prev: function (time, easing) { + var x = this.currentPage.pageX, + y = this.currentPage.pageY; + + x--; + + if ( x < 0 && this.hasVerticalScroll ) { + x = 0; + y--; + } + + this.goToPage(x, y, time, easing); + }, + + _initKeys: function (e) { + // default key bindings + var keys = { + pageUp: 33, + pageDown: 34, + end: 35, + home: 36, + left: 37, + up: 38, + right: 39, + down: 40 + }; + var i; + + // if you give me characters I give you keycode + if ( typeof this.options.keyBindings == 'object' ) { + for ( i in this.options.keyBindings ) { + if ( typeof this.options.keyBindings[i] == 'string' ) { + this.options.keyBindings[i] = this.options.keyBindings[i].toUpperCase().charCodeAt(0); + } + } + } else { + this.options.keyBindings = {}; + } + + for ( i in keys ) { + this.options.keyBindings[i] = this.options.keyBindings[i] || keys[i]; + } + + utils.addEvent(window, 'keydown', this); + + this.on('destroy', function () { + utils.removeEvent(window, 'keydown', this); + }); + }, + + _key: function (e) { + if ( !this.enabled ) { + return; + } + + var snap = this.options.snap, // we are using this alot, better to cache it + newX = snap ? this.currentPage.pageX : this.x, + newY = snap ? this.currentPage.pageY : this.y, + now = utils.getTime(), + prevTime = this.keyTime || 0, + acceleration = 0.250, + pos; + + if ( this.options.useTransition && this.isInTransition ) { + pos = this.getComputedPosition(); + + this._translate(Math.round(pos.x), Math.round(pos.y)); + this.isInTransition = false; + } + + this.keyAcceleration = now - prevTime < 200 ? Math.min(this.keyAcceleration + acceleration, 50) : 0; + + switch ( e.keyCode ) { + case this.options.keyBindings.pageUp: + if ( this.hasHorizontalScroll && !this.hasVerticalScroll ) { + newX += snap ? 1 : this.wrapperWidth; + } else { + newY += snap ? 1 : this.wrapperHeight; + } + break; + case this.options.keyBindings.pageDown: + if ( this.hasHorizontalScroll && !this.hasVerticalScroll ) { + newX -= snap ? 1 : this.wrapperWidth; + } else { + newY -= snap ? 1 : this.wrapperHeight; + } + break; + case this.options.keyBindings.end: + newX = snap ? this.pages.length-1 : this.maxScrollX; + newY = snap ? this.pages[0].length-1 : this.maxScrollY; + break; + case this.options.keyBindings.home: + newX = 0; + newY = 0; + break; + case this.options.keyBindings.left: + newX += snap ? -1 : 5 + this.keyAcceleration>>0; + break; + case this.options.keyBindings.up: + newY += snap ? 1 : 5 + this.keyAcceleration>>0; + break; + case this.options.keyBindings.right: + newX -= snap ? -1 : 5 + this.keyAcceleration>>0; + break; + case this.options.keyBindings.down: + newY -= snap ? 1 : 5 + this.keyAcceleration>>0; + break; + default: + return; + } + + if ( snap ) { + this.goToPage(newX, newY); + return; + } + + if ( newX > 0 ) { + newX = 0; + this.keyAcceleration = 0; + } else if ( newX < this.maxScrollX ) { + newX = this.maxScrollX; + this.keyAcceleration = 0; + } + + if ( newY > 0 ) { + newY = 0; + this.keyAcceleration = 0; + } else if ( newY < this.maxScrollY ) { + newY = this.maxScrollY; + this.keyAcceleration = 0; + } + + this.scrollTo(newX, newY, 0); + + this.keyTime = now; + }, + + _animate: function (destX, destY, duration, easingFn) { + var that = this, + startX = this.x, + startY = this.y, + startTime = utils.getTime(), + destTime = startTime + duration; + + function step () { + var now = utils.getTime(), + newX, newY, + easing; + + if ( now >= destTime ) { + that.isAnimating = false; + that._translate(destX, destY); + + if ( !that.resetPosition(that.options.bounceTime) ) { + that._execEvent('scrollEnd'); + } + + return; + } + + now = ( now - startTime ) / duration; + easing = easingFn(now); + newX = ( destX - startX ) * easing + startX; + newY = ( destY - startY ) * easing + startY; + that._translate(newX, newY); + + if ( that.isAnimating ) { + rAF(step); + } + } + + this.isAnimating = true; + step(); + }, + handleEvent: function (e) { + switch ( e.type ) { + case 'touchstart': + case 'pointerdown': + case 'MSPointerDown': + case 'mousedown': + this._start(e); + break; + case 'touchmove': + case 'pointermove': + case 'MSPointerMove': + case 'mousemove': + this._move(e); + break; + case 'touchend': + case 'pointerup': + case 'MSPointerUp': + case 'mouseup': + case 'touchcancel': + case 'pointercancel': + case 'MSPointerCancel': + case 'mousecancel': + this._end(e); + break; + case 'orientationchange': + case 'resize': + this._resize(); + break; + case 'transitionend': + case 'webkitTransitionEnd': + case 'oTransitionEnd': + case 'MSTransitionEnd': + this._transitionEnd(e); + break; + case 'wheel': + case 'DOMMouseScroll': + case 'mousewheel': + this._wheel(e); + break; + case 'keydown': + this._key(e); + break; + case 'click': + if ( !e._constructed ) { + e.preventDefault(); + e.stopPropagation(); + } + break; + } + } +}; +function createDefaultScrollbar (direction, interactive, type) { + var scrollbar = document.createElement('div'), + indicator = document.createElement('div'); + + if ( type === true ) { + scrollbar.style.cssText = 'position:absolute;z-index:9999'; + indicator.style.cssText = '-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;position:absolute;background:rgba(0,0,0,0.5);border:1px solid rgba(255,255,255,0.9);border-radius:3px'; + } + + indicator.className = 'iScrollIndicator'; + + if ( direction == 'h' ) { + if ( type === true ) { + scrollbar.style.cssText += ';height:7px;left:2px;right:2px;bottom:0'; + indicator.style.height = '100%'; + } + scrollbar.className = 'iScrollHorizontalScrollbar'; + } else { + if ( type === true ) { + scrollbar.style.cssText += ';width:7px;bottom:2px;top:2px;right:1px'; + indicator.style.width = '100%'; + } + scrollbar.className = 'iScrollVerticalScrollbar'; + } + + scrollbar.style.cssText += ';overflow:hidden'; + + if ( !interactive ) { + scrollbar.style.pointerEvents = 'none'; + } + + scrollbar.appendChild(indicator); + + return scrollbar; +} + +function Indicator (scroller, options) { + this.wrapper = typeof options.el == 'string' ? document.querySelector(options.el) : options.el; + this.wrapperStyle = this.wrapper.style; + this.indicator = this.wrapper.children[0]; + this.indicatorStyle = this.indicator.style; + this.scroller = scroller; + + this.options = { + listenX: true, + listenY: true, + interactive: false, + resize: true, + defaultScrollbars: false, + shrink: false, + fade: false, + speedRatioX: 0, + speedRatioY: 0 + }; + + for ( var i in options ) { + this.options[i] = options[i]; + } + + this.sizeRatioX = 1; + this.sizeRatioY = 1; + this.maxPosX = 0; + this.maxPosY = 0; + + if ( this.options.interactive ) { + if ( !this.options.disableTouch ) { + utils.addEvent(this.indicator, 'touchstart', this); + utils.addEvent(window, 'touchend', this); + } + if ( !this.options.disablePointer ) { + utils.addEvent(this.indicator, utils.prefixPointerEvent('pointerdown'), this); + utils.addEvent(window, utils.prefixPointerEvent('pointerup'), this); + } + if ( !this.options.disableMouse ) { + utils.addEvent(this.indicator, 'mousedown', this); + utils.addEvent(window, 'mouseup', this); + } + } + + if ( this.options.fade ) { + this.wrapperStyle[utils.style.transform] = this.scroller.translateZ; + this.wrapperStyle[utils.style.transitionDuration] = utils.isBadAndroid ? '0.001s' : '0ms'; + this.wrapperStyle.opacity = '0'; + } +} + +Indicator.prototype = { + handleEvent: function (e) { + switch ( e.type ) { + case 'touchstart': + case 'pointerdown': + case 'MSPointerDown': + case 'mousedown': + this._start(e); + break; + case 'touchmove': + case 'pointermove': + case 'MSPointerMove': + case 'mousemove': + this._move(e); + break; + case 'touchend': + case 'pointerup': + case 'MSPointerUp': + case 'mouseup': + case 'touchcancel': + case 'pointercancel': + case 'MSPointerCancel': + case 'mousecancel': + this._end(e); + break; + } + }, + + destroy: function () { + if ( this.options.interactive ) { + utils.removeEvent(this.indicator, 'touchstart', this); + utils.removeEvent(this.indicator, utils.prefixPointerEvent('pointerdown'), this); + utils.removeEvent(this.indicator, 'mousedown', this); + + utils.removeEvent(window, 'touchmove', this); + utils.removeEvent(window, utils.prefixPointerEvent('pointermove'), this); + utils.removeEvent(window, 'mousemove', this); + + utils.removeEvent(window, 'touchend', this); + utils.removeEvent(window, utils.prefixPointerEvent('pointerup'), this); + utils.removeEvent(window, 'mouseup', this); + } + + if ( this.options.defaultScrollbars ) { + this.wrapper.parentNode.removeChild(this.wrapper); + } + }, + + _start: function (e) { + var point = e.touches ? e.touches[0] : e; + + e.preventDefault(); + e.stopPropagation(); + + this.transitionTime(); + + this.initiated = true; + this.moved = false; + this.lastPointX = point.pageX; + this.lastPointY = point.pageY; + + this.startTime = utils.getTime(); + + if ( !this.options.disableTouch ) { + utils.addEvent(window, 'touchmove', this); + } + if ( !this.options.disablePointer ) { + utils.addEvent(window, utils.prefixPointerEvent('pointermove'), this); + } + if ( !this.options.disableMouse ) { + utils.addEvent(window, 'mousemove', this); + } + + this.scroller._execEvent('beforeScrollStart'); + }, + + _move: function (e) { + var point = e.touches ? e.touches[0] : e, + deltaX, deltaY, + newX, newY, + timestamp = utils.getTime(); + + if ( !this.moved ) { + this.scroller._execEvent('scrollStart'); + } + + this.moved = true; + + deltaX = point.pageX - this.lastPointX; + this.lastPointX = point.pageX; + + deltaY = point.pageY - this.lastPointY; + this.lastPointY = point.pageY; + + newX = this.x + deltaX; + newY = this.y + deltaY; + + this._pos(newX, newY); + +// INSERT POINT: indicator._move + + e.preventDefault(); + e.stopPropagation(); + }, + + _end: function (e) { + if ( !this.initiated ) { + return; + } + + this.initiated = false; + + e.preventDefault(); + e.stopPropagation(); + + utils.removeEvent(window, 'touchmove', this); + utils.removeEvent(window, utils.prefixPointerEvent('pointermove'), this); + utils.removeEvent(window, 'mousemove', this); + + if ( this.scroller.options.snap ) { + var snap = this.scroller._nearestSnap(this.scroller.x, this.scroller.y); + + var time = this.options.snapSpeed || Math.max( + Math.max( + Math.min(Math.abs(this.scroller.x - snap.x), 1000), + Math.min(Math.abs(this.scroller.y - snap.y), 1000) + ), 300); + + if ( this.scroller.x != snap.x || this.scroller.y != snap.y ) { + this.scroller.directionX = 0; + this.scroller.directionY = 0; + this.scroller.currentPage = snap; + this.scroller.scrollTo(snap.x, snap.y, time, this.scroller.options.bounceEasing); + } + } + + if ( this.moved ) { + this.scroller._execEvent('scrollEnd'); + } + }, + + transitionTime: function (time) { + time = time || 0; + this.indicatorStyle[utils.style.transitionDuration] = time + 'ms'; + + if ( !time && utils.isBadAndroid ) { + this.indicatorStyle[utils.style.transitionDuration] = '0.001s'; + } + }, + + transitionTimingFunction: function (easing) { + this.indicatorStyle[utils.style.transitionTimingFunction] = easing; + }, + + refresh: function () { + this.transitionTime(); + + if ( this.options.listenX && !this.options.listenY ) { + this.indicatorStyle.display = this.scroller.hasHorizontalScroll ? 'block' : 'none'; + } else if ( this.options.listenY && !this.options.listenX ) { + this.indicatorStyle.display = this.scroller.hasVerticalScroll ? 'block' : 'none'; + } else { + this.indicatorStyle.display = this.scroller.hasHorizontalScroll || this.scroller.hasVerticalScroll ? 'block' : 'none'; + } + + if ( this.scroller.hasHorizontalScroll && this.scroller.hasVerticalScroll ) { + utils.addClass(this.wrapper, 'iScrollBothScrollbars'); + utils.removeClass(this.wrapper, 'iScrollLoneScrollbar'); + + if ( this.options.defaultScrollbars && this.options.customStyle ) { + if ( this.options.listenX ) { + this.wrapper.style.right = '8px'; + } else { + this.wrapper.style.bottom = '8px'; + } + } + } else { + utils.removeClass(this.wrapper, 'iScrollBothScrollbars'); + utils.addClass(this.wrapper, 'iScrollLoneScrollbar'); + + if ( this.options.defaultScrollbars && this.options.customStyle ) { + if ( this.options.listenX ) { + this.wrapper.style.right = '2px'; + } else { + this.wrapper.style.bottom = '2px'; + } + } + } + + var r = this.wrapper.offsetHeight; // force refresh + + if ( this.options.listenX ) { + this.wrapperWidth = this.wrapper.clientWidth; + if ( this.options.resize ) { + this.indicatorWidth = Math.max(Math.round(this.wrapperWidth * this.wrapperWidth / (this.scroller.scrollerWidth || this.wrapperWidth || 1)), 8); + this.indicatorStyle.width = this.indicatorWidth + 'px'; + } else { + this.indicatorWidth = this.indicator.clientWidth; + } + + this.maxPosX = this.wrapperWidth - this.indicatorWidth; + + if ( this.options.shrink == 'clip' ) { + this.minBoundaryX = -this.indicatorWidth + 8; + this.maxBoundaryX = this.wrapperWidth - 8; + } else { + this.minBoundaryX = 0; + this.maxBoundaryX = this.maxPosX; + } + + this.sizeRatioX = this.options.speedRatioX || (this.scroller.maxScrollX && (this.maxPosX / this.scroller.maxScrollX)); + } + + if ( this.options.listenY ) { + this.wrapperHeight = this.wrapper.clientHeight; + if ( this.options.resize ) { + this.indicatorHeight = Math.max(Math.round(this.wrapperHeight * this.wrapperHeight / (this.scroller.scrollerHeight || this.wrapperHeight || 1)), 8); + this.indicatorStyle.height = this.indicatorHeight + 'px'; + } else { + this.indicatorHeight = this.indicator.clientHeight; + } + + this.maxPosY = this.wrapperHeight - this.indicatorHeight; + + if ( this.options.shrink == 'clip' ) { + this.minBoundaryY = -this.indicatorHeight + 8; + this.maxBoundaryY = this.wrapperHeight - 8; + } else { + this.minBoundaryY = 0; + this.maxBoundaryY = this.maxPosY; + } + + this.maxPosY = this.wrapperHeight - this.indicatorHeight; + this.sizeRatioY = this.options.speedRatioY || (this.scroller.maxScrollY && (this.maxPosY / this.scroller.maxScrollY)); + } + + this.updatePosition(); + }, + + updatePosition: function () { + var x = this.options.listenX && Math.round(this.sizeRatioX * this.scroller.x) || 0, + y = this.options.listenY && Math.round(this.sizeRatioY * this.scroller.y) || 0; + + if ( !this.options.ignoreBoundaries ) { + if ( x < this.minBoundaryX ) { + if ( this.options.shrink == 'scale' ) { + this.width = Math.max(this.indicatorWidth + x, 8); + this.indicatorStyle.width = this.width + 'px'; + } + x = this.minBoundaryX; + } else if ( x > this.maxBoundaryX ) { + if ( this.options.shrink == 'scale' ) { + this.width = Math.max(this.indicatorWidth - (x - this.maxPosX), 8); + this.indicatorStyle.width = this.width + 'px'; + x = this.maxPosX + this.indicatorWidth - this.width; + } else { + x = this.maxBoundaryX; + } + } else if ( this.options.shrink == 'scale' && this.width != this.indicatorWidth ) { + this.width = this.indicatorWidth; + this.indicatorStyle.width = this.width + 'px'; + } + + if ( y < this.minBoundaryY ) { + if ( this.options.shrink == 'scale' ) { + this.height = Math.max(this.indicatorHeight + y * 3, 8); + this.indicatorStyle.height = this.height + 'px'; + } + y = this.minBoundaryY; + } else if ( y > this.maxBoundaryY ) { + if ( this.options.shrink == 'scale' ) { + this.height = Math.max(this.indicatorHeight - (y - this.maxPosY) * 3, 8); + this.indicatorStyle.height = this.height + 'px'; + y = this.maxPosY + this.indicatorHeight - this.height; + } else { + y = this.maxBoundaryY; + } + } else if ( this.options.shrink == 'scale' && this.height != this.indicatorHeight ) { + this.height = this.indicatorHeight; + this.indicatorStyle.height = this.height + 'px'; + } + } + + this.x = x; + this.y = y; + + if ( this.scroller.options.useTransform ) { + this.indicatorStyle[utils.style.transform] = 'translate(' + x + 'px,' + y + 'px)' + this.scroller.translateZ; + } else { + this.indicatorStyle.left = x + 'px'; + this.indicatorStyle.top = y + 'px'; + } + }, + + _pos: function (x, y) { + if ( x < 0 ) { + x = 0; + } else if ( x > this.maxPosX ) { + x = this.maxPosX; + } + + if ( y < 0 ) { + y = 0; + } else if ( y > this.maxPosY ) { + y = this.maxPosY; + } + + x = this.options.listenX ? Math.round(x / this.sizeRatioX) : this.scroller.x; + y = this.options.listenY ? Math.round(y / this.sizeRatioY) : this.scroller.y; + + this.scroller.scrollTo(x, y); + }, + + fade: function (val, hold) { + if ( hold && !this.visible ) { + return; + } + + clearTimeout(this.fadeTimeout); + this.fadeTimeout = null; + + var time = val ? 250 : 500, + delay = val ? 0 : 300; + + val = val ? '1' : '0'; + + this.wrapperStyle[utils.style.transitionDuration] = time + 'ms'; + + this.fadeTimeout = setTimeout((function (val) { + this.wrapperStyle.opacity = val; + this.visible = +val; + }).bind(this, val), delay); + } +}; + +IScroll.utils = utils; + +if ( typeof module != 'undefined' && module.exports ) { + module.exports = IScroll; +} else { + window.IScroll = IScroll; +} + +})(window, document, Math);
\ No newline at end of file diff --git a/StoneIsland/platforms/ios/www/js/vendor/iscroll.js b/StoneIsland/platforms/ios/www/js/vendor/iscroll.js index 8bd2b8da..09e07d69 100755..100644 --- a/StoneIsland/platforms/ios/www/js/vendor/iscroll.js +++ b/StoneIsland/platforms/ios/www/js/vendor/iscroll.js @@ -1,2011 +1,2170 @@ -/*! iScroll v5.1.3 ~ (c) 2008-2014 Matteo Spinelli ~ http://cubiq.org/license */ +/*! iScroll v5.2.0-snapshot ~ (c) 2008-2017 Matteo Spinelli ~ http://cubiq.org/license */ (function (window, document, Math) { -var rAF = window.requestAnimationFrame || - window.webkitRequestAnimationFrame || - window.mozRequestAnimationFrame || - window.oRequestAnimationFrame || - window.msRequestAnimationFrame || - function (callback) { window.setTimeout(callback, 1000 / 60); }; +var rAF = window.requestAnimationFrame || + window.webkitRequestAnimationFrame || + window.mozRequestAnimationFrame || + window.oRequestAnimationFrame || + window.msRequestAnimationFrame || + function (callback) { window.setTimeout(callback, 1000 / 60); }; var utils = (function () { - var me = {}; + var me = {}; - var _elementStyle = document.createElement('div').style; - var _vendor = (function () { - var vendors = ['t', 'webkitT', 'MozT', 'msT', 'OT'], - transform, - i = 0, - l = vendors.length; + var _elementStyle = document.createElement('div').style; + var _vendor = (function () { + var vendors = ['t', 'webkitT', 'MozT', 'msT', 'OT'], + transform, + i = 0, + l = vendors.length; - for ( ; i < l; i++ ) { - transform = vendors[i] + 'ransform'; - if ( transform in _elementStyle ) return vendors[i].substr(0, vendors[i].length-1); - } + for ( ; i < l; i++ ) { + transform = vendors[i] + 'ransform'; + if ( transform in _elementStyle ) return vendors[i].substr(0, vendors[i].length-1); + } - return false; - })(); + return false; + })(); - function _prefixStyle (style) { - if ( _vendor === false ) return false; - if ( _vendor === '' ) return style; - return _vendor + style.charAt(0).toUpperCase() + style.substr(1); - } + function _prefixStyle (style) { + if ( _vendor === false ) return false; + if ( _vendor === '' ) return style; + return _vendor + style.charAt(0).toUpperCase() + style.substr(1); + } - me.getTime = Date.now || function getTime () { return new Date().getTime(); }; + me.getTime = Date.now || function getTime () { return new Date().getTime(); }; - me.extend = function (target, obj) { - for ( var i in obj ) { - target[i] = obj[i]; - } - }; + me.extend = function (target, obj) { + for ( var i in obj ) { + target[i] = obj[i]; + } + }; - me.addEvent = function (el, type, fn, capture) { - el.addEventListener(type, fn, !!capture); - }; + me.addEvent = function (el, type, fn, capture) { + el.addEventListener(type, fn, !!capture); + }; - me.removeEvent = function (el, type, fn, capture) { - el.removeEventListener(type, fn, !!capture); - }; + me.removeEvent = function (el, type, fn, capture) { + el.removeEventListener(type, fn, !!capture); + }; - me.prefixPointerEvent = function (pointerEvent) { - return window.MSPointerEvent ? - 'MSPointer' + pointerEvent.charAt(9).toUpperCase() + pointerEvent.substr(10): - pointerEvent; - }; + me.prefixPointerEvent = function (pointerEvent) { + return window.MSPointerEvent ? + 'MSPointer' + pointerEvent.charAt(7).toUpperCase() + pointerEvent.substr(8): + pointerEvent; + }; - me.momentum = function (current, start, time, lowerMargin, wrapperSize, deceleration) { - var distance = current - start, - speed = Math.abs(distance) / time, - destination, - duration; + me.momentum = function (current, start, time, lowerMargin, wrapperSize, deceleration) { + var distance = current - start, + speed = Math.abs(distance) / time, + destination, + duration; - deceleration = deceleration === undefined ? 0.0006 : deceleration; + deceleration = deceleration === undefined ? 0.0006 : deceleration; - destination = current + ( speed * speed ) / ( 2 * deceleration ) * ( distance < 0 ? -1 : 1 ); - duration = speed / deceleration; + destination = current + ( speed * speed ) / ( 2 * deceleration ) * ( distance < 0 ? -1 : 1 ); + duration = speed / deceleration; - if ( destination < lowerMargin ) { - destination = wrapperSize ? lowerMargin - ( wrapperSize / 2.5 * ( speed / 8 ) ) : lowerMargin; - distance = Math.abs(destination - current); - duration = distance / speed; - } else if ( destination > 0 ) { - destination = wrapperSize ? wrapperSize / 2.5 * ( speed / 8 ) : 0; - distance = Math.abs(current) + destination; - duration = distance / speed; - } + if ( destination < lowerMargin ) { + destination = wrapperSize ? lowerMargin - ( wrapperSize / 2.5 * ( speed / 8 ) ) : lowerMargin; + distance = Math.abs(destination - current); + duration = distance / speed; + } else if ( destination > 0 ) { + destination = wrapperSize ? wrapperSize / 2.5 * ( speed / 8 ) : 0; + distance = Math.abs(current) + destination; + duration = distance / speed; + } - return { - destination: Math.round(destination), - duration: duration - }; - }; + return { + destination: Math.round(destination), + duration: duration + }; + }; - var _transform = _prefixStyle('transform'); + var _transform = _prefixStyle('transform'); - me.extend(me, { - hasTransform: _transform !== false, - hasPerspective: _prefixStyle('perspective') in _elementStyle, - hasTouch: 'ontouchstart' in window, - hasPointer: window.PointerEvent || window.MSPointerEvent, // IE10 is prefixed - hasTransition: _prefixStyle('transition') in _elementStyle - }); + me.extend(me, { + hasTransform: _transform !== false, + hasPerspective: _prefixStyle('perspective') in _elementStyle, + hasTouch: 'ontouchstart' in window, + hasPointer: !!(window.PointerEvent || window.MSPointerEvent), // IE10 is prefixed + hasTransition: _prefixStyle('transition') in _elementStyle + }); - // This should find all Android browsers lower than build 535.19 (both stock browser and webview) - me.isBadAndroid = /Android /.test(window.navigator.appVersion) && !(/Chrome\/\d/.test(window.navigator.appVersion)); + /* + This should find all Android browsers lower than build 535.19 (both stock browser and webview) + - galaxy S2 is ok + - 2.3.6 : `AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1` + - 4.0.4 : `AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30` + - galaxy S3 is badAndroid (stock brower, webview) + `AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30` + - galaxy S4 is badAndroid (stock brower, webview) + `AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30` + - galaxy S5 is OK + `AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Mobile Safari/537.36 (Chrome/)` + - galaxy S6 is OK + `AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Mobile Safari/537.36 (Chrome/)` + */ + me.isBadAndroid = (function() { + var appVersion = window.navigator.appVersion; + // Android browser is not a chrome browser. + if (/Android/.test(appVersion) && !(/Chrome\/\d/.test(appVersion))) { + var safariVersion = appVersion.match(/Safari\/(\d+.\d)/); + if(safariVersion && typeof safariVersion === "object" && safariVersion.length >= 2) { + return parseFloat(safariVersion[1]) < 535.19; + } else { + return true; + } + } else { + return false; + } + })(); - me.extend(me.style = {}, { - transform: _transform, - transitionTimingFunction: _prefixStyle('transitionTimingFunction'), - transitionDuration: _prefixStyle('transitionDuration'), - transitionDelay: _prefixStyle('transitionDelay'), - transformOrigin: _prefixStyle('transformOrigin') - }); + me.extend(me.style = {}, { + transform: _transform, + transitionTimingFunction: _prefixStyle('transitionTimingFunction'), + transitionDuration: _prefixStyle('transitionDuration'), + transitionDelay: _prefixStyle('transitionDelay'), + transformOrigin: _prefixStyle('transformOrigin'), + touchAction: _prefixStyle('touchAction') + }); - me.hasClass = function (e, c) { - var re = new RegExp("(^|\\s)" + c + "(\\s|$)"); - return re.test(e.className); - }; + me.hasClass = function (e, c) { + var re = new RegExp("(^|\\s)" + c + "(\\s|$)"); + return re.test(e.className); + }; - me.addClass = function (e, c) { - if ( me.hasClass(e, c) ) { - return; - } + me.addClass = function (e, c) { + if ( me.hasClass(e, c) ) { + return; + } - var newclass = e.className.split(' '); - newclass.push(c); - e.className = newclass.join(' '); - }; + var newclass = e.className.split(' '); + newclass.push(c); + e.className = newclass.join(' '); + }; - me.removeClass = function (e, c) { - if ( !me.hasClass(e, c) ) { - return; - } + me.removeClass = function (e, c) { + if ( !me.hasClass(e, c) ) { + return; + } - var re = new RegExp("(^|\\s)" + c + "(\\s|$)", 'g'); - e.className = e.className.replace(re, ' '); - }; + var re = new RegExp("(^|\\s)" + c + "(\\s|$)", 'g'); + e.className = e.className.replace(re, ' '); + }; - me.offset = function (el) { - var left = -el.offsetLeft, - top = -el.offsetTop; + me.offset = function (el) { + var left = -el.offsetLeft, + top = -el.offsetTop; - // jshint -W084 - while (el = el.offsetParent) { - left -= el.offsetLeft; - top -= el.offsetTop; - } - // jshint +W084 + // jshint -W084 + while (el = el.offsetParent) { + left -= el.offsetLeft; + top -= el.offsetTop; + } + // jshint +W084 - return { - left: left, - top: top - }; - }; + return { + left: left, + top: top + }; + }; - me.preventDefaultException = function (el, exceptions) { - for ( var i in exceptions ) { - if ( exceptions[i].test(el[i]) ) { - return true; - } - } + me.preventDefaultException = function (el, exceptions) { + for ( var i in exceptions ) { + if ( exceptions[i].test(el[i]) ) { + return true; + } + } - return false; - }; + return false; + }; - me.extend(me.eventType = {}, { - touchstart: 1, - touchmove: 1, - touchend: 1, + me.extend(me.eventType = {}, { + touchstart: 1, + touchmove: 1, + touchend: 1, - mousedown: 2, - mousemove: 2, - mouseup: 2, + mousedown: 2, + mousemove: 2, + mouseup: 2, - pointerdown: 3, - pointermove: 3, - pointerup: 3, + pointerdown: 3, + pointermove: 3, + pointerup: 3, - MSPointerDown: 3, - MSPointerMove: 3, - MSPointerUp: 3 - }); + MSPointerDown: 3, + MSPointerMove: 3, + MSPointerUp: 3 + }); - me.extend(me.ease = {}, { - quadratic: { - style: 'cubic-bezier(0.25, 0.46, 0.45, 0.94)', - fn: function (k) { - return k * ( 2 - k ); - } - }, - circular: { - style: 'cubic-bezier(0.1, 0.57, 0.1, 1)', // Not properly "circular" but this looks better, it should be (0.075, 0.82, 0.165, 1) - fn: function (k) { - return Math.sqrt( 1 - ( --k * k ) ); - } - }, - back: { - style: 'cubic-bezier(0.175, 0.885, 0.32, 1.275)', - fn: function (k) { - var b = 4; - return ( k = k - 1 ) * k * ( ( b + 1 ) * k + b ) + 1; - } - }, - bounce: { - style: '', - fn: function (k) { - if ( ( k /= 1 ) < ( 1 / 2.75 ) ) { - return 7.5625 * k * k; - } else if ( k < ( 2 / 2.75 ) ) { - return 7.5625 * ( k -= ( 1.5 / 2.75 ) ) * k + 0.75; - } else if ( k < ( 2.5 / 2.75 ) ) { - return 7.5625 * ( k -= ( 2.25 / 2.75 ) ) * k + 0.9375; - } else { - return 7.5625 * ( k -= ( 2.625 / 2.75 ) ) * k + 0.984375; - } - } - }, - elastic: { - style: '', - fn: function (k) { - var f = 0.22, - e = 0.4; + me.extend(me.ease = {}, { + quadratic: { + style: 'cubic-bezier(0.25, 0.46, 0.45, 0.94)', + fn: function (k) { + return k * ( 2 - k ); + } + }, + circular: { + style: 'cubic-bezier(0.1, 0.57, 0.1, 1)', // Not properly "circular" but this looks better, it should be (0.075, 0.82, 0.165, 1) + fn: function (k) { + return Math.sqrt( 1 - ( --k * k ) ); + } + }, + back: { + style: 'cubic-bezier(0.175, 0.885, 0.32, 1.275)', + fn: function (k) { + var b = 4; + return ( k = k - 1 ) * k * ( ( b + 1 ) * k + b ) + 1; + } + }, + bounce: { + style: '', + fn: function (k) { + if ( ( k /= 1 ) < ( 1 / 2.75 ) ) { + return 7.5625 * k * k; + } else if ( k < ( 2 / 2.75 ) ) { + return 7.5625 * ( k -= ( 1.5 / 2.75 ) ) * k + 0.75; + } else if ( k < ( 2.5 / 2.75 ) ) { + return 7.5625 * ( k -= ( 2.25 / 2.75 ) ) * k + 0.9375; + } else { + return 7.5625 * ( k -= ( 2.625 / 2.75 ) ) * k + 0.984375; + } + } + }, + elastic: { + style: '', + fn: function (k) { + var f = 0.22, + e = 0.4; - if ( k === 0 ) { return 0; } - if ( k == 1 ) { return 1; } + if ( k === 0 ) { return 0; } + if ( k == 1 ) { return 1; } - return ( e * Math.pow( 2, - 10 * k ) * Math.sin( ( k - f / 4 ) * ( 2 * Math.PI ) / f ) + 1 ); - } - } - }); + return ( e * Math.pow( 2, - 10 * k ) * Math.sin( ( k - f / 4 ) * ( 2 * Math.PI ) / f ) + 1 ); + } + } + }); - me.tap = function (e, eventName) { - var ev = document.createEvent('Event'); - ev.initEvent(eventName, true, true); - ev.pageX = e.pageX; - ev.pageY = e.pageY; - e.target.dispatchEvent(ev); - }; + me.tap = function (e, eventName) { + var ev = document.createEvent('Event'); + ev.initEvent(eventName, true, true); + ev.pageX = e.pageX; + ev.pageY = e.pageY; + e.target.dispatchEvent(ev); + }; - me.click = function (e) { - var target = e.target, - ev; + me.click = function (e) { + var target = e.target, + ev; - if ( !(/(SELECT|INPUT|TEXTAREA)/i).test(target.tagName) ) { - ev = document.createEvent('MouseEvents'); - ev.initMouseEvent('click', true, true, e.view, 1, - target.screenX, target.screenY, target.clientX, target.clientY, - e.ctrlKey, e.altKey, e.shiftKey, e.metaKey, - 0, null); + if ( !(/(SELECT|INPUT|TEXTAREA)/i).test(target.tagName) ) { + // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/initMouseEvent + // initMouseEvent is deprecated. + ev = document.createEvent(window.MouseEvent ? 'MouseEvents' : 'Event'); + ev.initEvent('click', true, true); + ev.view = e.view || window; + ev.detail = 1; + ev.screenX = target.screenX || 0; + ev.screenY = target.screenY || 0; + ev.clientX = target.clientX || 0; + ev.clientY = target.clientY || 0; + ev.ctrlKey = !!e.ctrlKey; + ev.altKey = !!e.altKey; + ev.shiftKey = !!e.shiftKey; + ev.metaKey = !!e.metaKey; + ev.button = 0; + ev.relatedTarget = null; + ev._constructed = true; + target.dispatchEvent(ev); + } + }; - ev._constructed = true; - target.dispatchEvent(ev); - } - }; + me.getTouchAction = function(eventPassthrough, addPinch) { + var touchAction = 'none'; + if ( eventPassthrough === 'vertical' ) { + touchAction = 'pan-y'; + } else if (eventPassthrough === 'horizontal' ) { + touchAction = 'pan-x'; + } + if (addPinch && touchAction != 'none') { + // add pinch-zoom support if the browser supports it, but if not (eg. Chrome <55) do nothing + touchAction += ' pinch-zoom'; + } + return touchAction; + }; - return me; -})(); + me.getRect = function(el) { + if (el instanceof SVGElement) { + var rect = el.getBoundingClientRect(); + return { + top : rect.top, + left : rect.left, + width : rect.width, + height : rect.height + }; + } else { + return { + top : el.offsetTop, + left : el.offsetLeft, + width : el.offsetWidth, + height : el.offsetHeight + }; + } + }; + return me; +})(); function IScroll (el, options) { - this.wrapper = typeof el == 'string' ? document.querySelector(el) : el; - this.scroller = this.wrapper.children[0]; - this.scrollerStyle = this.scroller.style; // cache style for better performance + this.wrapper = typeof el == 'string' ? document.querySelector(el) : el; + this.scroller = this.wrapper.children[0]; + this.scrollerStyle = this.scroller.style; // cache style for better performance - this.options = { + this.options = { - resizeScrollbars: true, + resizeScrollbars: true, - mouseWheelSpeed: 20, + mouseWheelSpeed: 20, - snapThreshold: 0.334, + snapThreshold: 0.334, -// INSERT POINT: OPTIONS +// INSERT POINT: OPTIONS + disablePointer : !utils.hasPointer, + disableTouch : utils.hasPointer || !utils.hasTouch, + disableMouse : utils.hasPointer || utils.hasTouch, + startX: 0, + startY: 0, + scrollY: true, + directionLockThreshold: 5, + momentum: true, - startX: 0, - startY: 0, - scrollY: true, - directionLockThreshold: 5, - momentum: true, + bounce: true, + bounceTime: 600, + bounceEasing: '', - bounce: true, - bounceTime: 600, - bounceEasing: '', + preventDefault: true, + preventDefaultException: { tagName: /^(INPUT|TEXTAREA|BUTTON|SELECT)$/ }, - preventDefault: true, - preventDefaultException: { tagName: /^(INPUT|TEXTAREA|BUTTON|SELECT)$/ }, + HWCompositing: true, + useTransition: true, + useTransform: true, + bindToWrapper: typeof window.onmousedown === "undefined" + }; - HWCompositing: true, - useTransition: true, - useTransform: true - }; + for ( var i in options ) { + this.options[i] = options[i]; + } - for ( var i in options ) { - this.options[i] = options[i]; - } + // Normalize options + this.translateZ = this.options.HWCompositing && utils.hasPerspective ? ' translateZ(0)' : ''; - // Normalize options - this.translateZ = this.options.HWCompositing && utils.hasPerspective ? ' translateZ(0)' : ''; + this.options.useTransition = utils.hasTransition && this.options.useTransition; + this.options.useTransform = utils.hasTransform && this.options.useTransform; - this.options.useTransition = utils.hasTransition && this.options.useTransition; - this.options.useTransform = utils.hasTransform && this.options.useTransform; + this.options.eventPassthrough = this.options.eventPassthrough === true ? 'vertical' : this.options.eventPassthrough; + this.options.preventDefault = !this.options.eventPassthrough && this.options.preventDefault; - this.options.eventPassthrough = this.options.eventPassthrough === true ? 'vertical' : this.options.eventPassthrough; - this.options.preventDefault = !this.options.eventPassthrough && this.options.preventDefault; + // If you want eventPassthrough I have to lock one of the axes + this.options.scrollY = this.options.eventPassthrough == 'vertical' ? false : this.options.scrollY; + this.options.scrollX = this.options.eventPassthrough == 'horizontal' ? false : this.options.scrollX; - // If you want eventPassthrough I have to lock one of the axes - this.options.scrollY = this.options.eventPassthrough == 'vertical' ? false : this.options.scrollY; - this.options.scrollX = this.options.eventPassthrough == 'horizontal' ? false : this.options.scrollX; + // With eventPassthrough we also need lockDirection mechanism + this.options.freeScroll = this.options.freeScroll && !this.options.eventPassthrough; + this.options.directionLockThreshold = this.options.eventPassthrough ? 0 : this.options.directionLockThreshold; - // With eventPassthrough we also need lockDirection mechanism - this.options.freeScroll = this.options.freeScroll && !this.options.eventPassthrough; - this.options.directionLockThreshold = this.options.eventPassthrough ? 0 : this.options.directionLockThreshold; + this.options.bounceEasing = typeof this.options.bounceEasing == 'string' ? utils.ease[this.options.bounceEasing] || utils.ease.circular : this.options.bounceEasing; - this.options.bounceEasing = typeof this.options.bounceEasing == 'string' ? utils.ease[this.options.bounceEasing] || utils.ease.circular : this.options.bounceEasing; + this.options.resizePolling = this.options.resizePolling === undefined ? 60 : this.options.resizePolling; - this.options.resizePolling = this.options.resizePolling === undefined ? 60 : this.options.resizePolling; + if ( this.options.tap === true ) { + this.options.tap = 'tap'; + } - if ( this.options.tap === true ) { - this.options.tap = 'tap'; - } + // https://github.com/cubiq/iscroll/issues/1029 + if (!this.options.useTransition && !this.options.useTransform) { + if(!(/relative|absolute/i).test(this.scrollerStyle.position)) { + this.scrollerStyle.position = "relative"; + } + } - if ( this.options.shrinkScrollbars == 'scale' ) { - this.options.useTransition = false; - } + if ( this.options.shrinkScrollbars == 'scale' ) { + this.options.useTransition = false; + } - this.options.invertWheelDirection = this.options.invertWheelDirection ? -1 : 1; + this.options.invertWheelDirection = this.options.invertWheelDirection ? -1 : 1; // INSERT POINT: NORMALIZATION - // Some defaults - this.x = 0; - this.y = 0; - this.directionX = 0; - this.directionY = 0; - this._events = {}; + // Some defaults + this.x = 0; + this.y = 0; + this.directionX = 0; + this.directionY = 0; + this._events = {}; // INSERT POINT: DEFAULTS - this._init(); - this.refresh(); + this._init(); + this.refresh(); - this.scrollTo(this.options.startX, this.options.startY); - this.enable(); + this.scrollTo(this.options.startX, this.options.startY); + this.enable(); } IScroll.prototype = { - version: '5.1.3', + version: '5.2.0-snapshot', - _init: function () { - this._initEvents(); + _init: function () { + this._initEvents(); - if ( this.options.scrollbars || this.options.indicators ) { - this._initIndicators(); - } + if ( this.options.scrollbars || this.options.indicators ) { + this._initIndicators(); + } - if ( this.options.mouseWheel ) { - this._initWheel(); - } + if ( this.options.mouseWheel ) { + this._initWheel(); + } - if ( this.options.snap ) { - this._initSnap(); - } + if ( this.options.snap ) { + this._initSnap(); + } - if ( this.options.keyBindings ) { - this._initKeys(); - } + if ( this.options.keyBindings ) { + this._initKeys(); + } // INSERT POINT: _init - }, - - destroy: function () { - this._initEvents(true); - - this._execEvent('destroy'); - }, + }, - _transitionEnd: function (e) { - if ( e.target != this.scroller || !this.isInTransition ) { - return; - } + destroy: function () { + this._initEvents(true); + clearTimeout(this.resizeTimeout); + this.resizeTimeout = null; + this._execEvent('destroy'); + }, - this._transitionTime(); - if ( !this.resetPosition(this.options.bounceTime) ) { - this.isInTransition = false; - this._execEvent('scrollEnd'); - } - }, + _transitionEnd: function (e) { + if ( e.target != this.scroller || !this.isInTransition ) { + return; + } - _start: function (e) { - // React to left mouse button only - if ( utils.eventType[e.type] != 1 ) { - if ( e.button !== 0 ) { - return; - } - } + this._transitionTime(); + if ( !this.resetPosition(this.options.bounceTime) ) { + this.isInTransition = false; + this._execEvent('scrollEnd'); + } + }, - if ( !this.enabled || (this.initiated && utils.eventType[e.type] !== this.initiated) ) { - return; - } + _start: function (e) { + // React to left mouse button only + if ( utils.eventType[e.type] != 1 ) { + // for button property + // http://unixpapa.com/js/mouse.html + var button; + if (!e.which) { + /* IE case */ + button = (e.button < 2) ? 0 : + ((e.button == 4) ? 1 : 2); + } else { + /* All others */ + button = e.button; + } + if ( button !== 0 ) { + return; + } + } - if ( this.options.preventDefault && !utils.isBadAndroid && !utils.preventDefaultException(e.target, this.options.preventDefaultException) ) { - e.preventDefault(); - } + if ( !this.enabled || (this.initiated && utils.eventType[e.type] !== this.initiated) ) { + return; + } - var point = e.touches ? e.touches[0] : e, - pos; + if ( this.options.preventDefault && !utils.isBadAndroid && !utils.preventDefaultException(e.target, this.options.preventDefaultException) ) { + e.preventDefault(); + } - this.initiated = utils.eventType[e.type]; - this.moved = false; - this.distX = 0; - this.distY = 0; - this.directionX = 0; - this.directionY = 0; - this.directionLocked = 0; + var point = e.touches ? e.touches[0] : e, + pos; - this._transitionTime(); + this.initiated = utils.eventType[e.type]; + this.moved = false; + this.distX = 0; + this.distY = 0; + this.directionX = 0; + this.directionY = 0; + this.directionLocked = 0; - this.startTime = utils.getTime(); + this.startTime = utils.getTime(); - if ( this.options.useTransition && this.isInTransition ) { - this.isInTransition = false; - pos = this.getComputedPosition(); - this._translate(Math.round(pos.x), Math.round(pos.y)); - this._execEvent('scrollEnd'); - } else if ( !this.options.useTransition && this.isAnimating ) { - this.isAnimating = false; - this._execEvent('scrollEnd'); - } + if ( this.options.useTransition && this.isInTransition ) { + this._transitionTime(); + this.isInTransition = false; + pos = this.getComputedPosition(); + this._translate(Math.round(pos.x), Math.round(pos.y)); + this._execEvent('scrollEnd'); + } else if ( !this.options.useTransition && this.isAnimating ) { + this.isAnimating = false; + this._execEvent('scrollEnd'); + } - this.startX = this.x; - this.startY = this.y; - this.absStartX = this.x; - this.absStartY = this.y; - this.pointX = point.pageX; - this.pointY = point.pageY; + this.startX = this.x; + this.startY = this.y; + this.absStartX = this.x; + this.absStartY = this.y; + this.pointX = point.pageX; + this.pointY = point.pageY; - this._execEvent('beforeScrollStart'); - }, + this._execEvent('beforeScrollStart'); + }, - _move: function (e) { - if ( !this.enabled || utils.eventType[e.type] !== this.initiated ) { - return; - } + _move: function (e) { + if ( !this.enabled || utils.eventType[e.type] !== this.initiated ) { + return; + } - if ( this.options.preventDefault ) { // increases performance on Android? TODO: check! - e.preventDefault(); - } + if ( this.options.preventDefault ) { // increases performance on Android? TODO: check! + e.preventDefault(); + } - var point = e.touches ? e.touches[0] : e, - deltaX = point.pageX - this.pointX, - deltaY = point.pageY - this.pointY, - timestamp = utils.getTime(), - newX, newY, - absDistX, absDistY; + var point = e.touches ? e.touches[0] : e, + deltaX = point.pageX - this.pointX, + deltaY = point.pageY - this.pointY, + timestamp = utils.getTime(), + newX, newY, + absDistX, absDistY; - this.pointX = point.pageX; - this.pointY = point.pageY; + this.pointX = point.pageX; + this.pointY = point.pageY; - this.distX += deltaX; - this.distY += deltaY; - absDistX = Math.abs(this.distX); - absDistY = Math.abs(this.distY); + this.distX += deltaX; + this.distY += deltaY; + absDistX = Math.abs(this.distX); + absDistY = Math.abs(this.distY); - // We need to move at least 10 pixels for the scrolling to initiate - if ( timestamp - this.endTime > 300 && (absDistX < 10 && absDistY < 10) ) { - return; - } + // We need to move at least 10 pixels for the scrolling to initiate + if ( timestamp - this.endTime > 300 && (absDistX < 10 && absDistY < 10) ) { + return; + } - // If you are scrolling in one direction lock the other - if ( !this.directionLocked && !this.options.freeScroll ) { - if ( absDistX > absDistY + this.options.directionLockThreshold ) { - this.directionLocked = 'h'; // lock horizontally - } else if ( absDistY >= absDistX + this.options.directionLockThreshold ) { - this.directionLocked = 'v'; // lock vertically - } else { - this.directionLocked = 'n'; // no lock - } - } + // If you are scrolling in one direction lock the other + if ( !this.directionLocked && !this.options.freeScroll ) { + if ( absDistX > absDistY + this.options.directionLockThreshold ) { + this.directionLocked = 'h'; // lock horizontally + } else if ( absDistY >= absDistX + this.options.directionLockThreshold ) { + this.directionLocked = 'v'; // lock vertically + } else { + this.directionLocked = 'n'; // no lock + } + } - if ( this.directionLocked == 'h' ) { - if ( this.options.eventPassthrough == 'vertical' ) { - e.preventDefault(); - } else if ( this.options.eventPassthrough == 'horizontal' ) { - this.initiated = false; - return; - } + if ( this.directionLocked == 'h' ) { + if ( this.options.eventPassthrough == 'vertical' ) { + e.preventDefault(); + } else if ( this.options.eventPassthrough == 'horizontal' ) { + this.initiated = false; + return; + } - deltaY = 0; - } else if ( this.directionLocked == 'v' ) { - if ( this.options.eventPassthrough == 'horizontal' ) { - e.preventDefault(); - } else if ( this.options.eventPassthrough == 'vertical' ) { - this.initiated = false; - return; - } + deltaY = 0; + } else if ( this.directionLocked == 'v' ) { + if ( this.options.eventPassthrough == 'horizontal' ) { + e.preventDefault(); + } else if ( this.options.eventPassthrough == 'vertical' ) { + this.initiated = false; + return; + } - deltaX = 0; - } + deltaX = 0; + } - deltaX = this.hasHorizontalScroll ? deltaX : 0; - deltaY = this.hasVerticalScroll ? deltaY : 0; + deltaX = this.hasHorizontalScroll ? deltaX : 0; + deltaY = this.hasVerticalScroll ? deltaY : 0; - newX = this.x + deltaX; - newY = this.y + deltaY; + newX = this.x + deltaX; + newY = this.y + deltaY; - // Slow down if outside of the boundaries - if ( newX > 0 || newX < this.maxScrollX ) { - newX = this.options.bounce ? this.x + deltaX / 3 : newX > 0 ? 0 : this.maxScrollX; - } - if ( newY > 0 || newY < this.maxScrollY ) { - newY = this.options.bounce ? this.y + deltaY / 3 : newY > 0 ? 0 : this.maxScrollY; - } + // Slow down if outside of the boundaries + if ( newX > 0 || newX < this.maxScrollX ) { + newX = this.options.bounce ? this.x + deltaX / 3 : newX > 0 ? 0 : this.maxScrollX; + } + if ( newY > 0 || newY < this.maxScrollY ) { + newY = this.options.bounce ? this.y + deltaY / 3 : newY > 0 ? 0 : this.maxScrollY; + } - this.directionX = deltaX > 0 ? -1 : deltaX < 0 ? 1 : 0; - this.directionY = deltaY > 0 ? -1 : deltaY < 0 ? 1 : 0; + this.directionX = deltaX > 0 ? -1 : deltaX < 0 ? 1 : 0; + this.directionY = deltaY > 0 ? -1 : deltaY < 0 ? 1 : 0; - if ( !this.moved ) { - this._execEvent('scrollStart'); - } + if ( !this.moved ) { + this._execEvent('scrollStart'); + } - this.moved = true; + this.moved = true; - this._translate(newX, newY); + this._translate(newX, newY); /* REPLACE START: _move */ - if ( timestamp - this.startTime > 300 ) { - this.startTime = timestamp; - this.startX = this.x; - this.startY = this.y; - } + if ( timestamp - this.startTime > 300 ) { + this.startTime = timestamp; + this.startX = this.x; + this.startY = this.y; + } /* REPLACE END: _move */ - }, + }, - _end: function (e) { - if ( !this.enabled || utils.eventType[e.type] !== this.initiated ) { - return; - } + _end: function (e) { + if ( !this.enabled || utils.eventType[e.type] !== this.initiated ) { + return; + } - if ( this.options.preventDefault && !utils.preventDefaultException(e.target, this.options.preventDefaultException) ) { - e.preventDefault(); - } + if ( this.options.preventDefault && !utils.preventDefaultException(e.target, this.options.preventDefaultException) ) { + e.preventDefault(); + } - var point = e.changedTouches ? e.changedTouches[0] : e, - momentumX, - momentumY, - duration = utils.getTime() - this.startTime, - newX = Math.round(this.x), - newY = Math.round(this.y), - distanceX = Math.abs(newX - this.startX), - distanceY = Math.abs(newY - this.startY), - time = 0, - easing = ''; + var point = e.changedTouches ? e.changedTouches[0] : e, + momentumX, + momentumY, + duration = utils.getTime() - this.startTime, + newX = Math.round(this.x), + newY = Math.round(this.y), + distanceX = Math.abs(newX - this.startX), + distanceY = Math.abs(newY - this.startY), + time = 0, + easing = ''; - this.isInTransition = 0; - this.initiated = 0; - this.endTime = utils.getTime(); + this.isInTransition = 0; + this.initiated = 0; + this.endTime = utils.getTime(); - // reset if we are outside of the boundaries - if ( this.resetPosition(this.options.bounceTime) ) { - return; - } + // reset if we are outside of the boundaries + if ( this.resetPosition(this.options.bounceTime) ) { + return; + } - this.scrollTo(newX, newY); // ensures that the last position is rounded + this.scrollTo(newX, newY); // ensures that the last position is rounded - // we scrolled less than 10 pixels - if ( !this.moved ) { - if ( this.options.tap ) { - utils.tap(e, this.options.tap); - } + // we scrolled less than 10 pixels + if ( !this.moved ) { + if ( this.options.tap ) { + utils.tap(e, this.options.tap); + } - if ( this.options.click ) { - utils.click(e); - } + if ( this.options.click ) { + utils.click(e); + } - this._execEvent('scrollCancel'); - return; - } + this._execEvent('scrollCancel'); + return; + } - if ( this._events.flick && duration < 200 && distanceX < 100 && distanceY < 100 ) { - this._execEvent('flick'); - return; - } + if ( this._events.flick && duration < 200 && distanceX < 100 && distanceY < 100 ) { + this._execEvent('flick'); + return; + } - // start momentum animation if needed - if ( this.options.momentum && duration < 300 ) { - momentumX = this.hasHorizontalScroll ? utils.momentum(this.x, this.startX, duration, this.maxScrollX, this.options.bounce ? this.wrapperWidth : 0, this.options.deceleration) : { destination: newX, duration: 0 }; - momentumY = this.hasVerticalScroll ? utils.momentum(this.y, this.startY, duration, this.maxScrollY, this.options.bounce ? this.wrapperHeight : 0, this.options.deceleration) : { destination: newY, duration: 0 }; - newX = momentumX.destination; - newY = momentumY.destination; - time = Math.max(momentumX.duration, momentumY.duration); - this.isInTransition = 1; - } + // start momentum animation if needed + if ( this.options.momentum && duration < 300 ) { + momentumX = this.hasHorizontalScroll ? utils.momentum(this.x, this.startX, duration, this.maxScrollX, this.options.bounce ? this.wrapperWidth : 0, this.options.deceleration) : { destination: newX, duration: 0 }; + momentumY = this.hasVerticalScroll ? utils.momentum(this.y, this.startY, duration, this.maxScrollY, this.options.bounce ? this.wrapperHeight : 0, this.options.deceleration) : { destination: newY, duration: 0 }; + newX = momentumX.destination; + newY = momentumY.destination; + time = Math.max(momentumX.duration, momentumY.duration); + this.isInTransition = 1; + } - if ( this.options.snap ) { - var snap = this._nearestSnap(newX, newY); - this.currentPage = snap; - time = this.options.snapSpeed || Math.max( - Math.max( - Math.min(Math.abs(newX - snap.x), 1000), - Math.min(Math.abs(newY - snap.y), 1000) - ), 300); - newX = snap.x; - newY = snap.y; + if ( this.options.snap ) { + var snap = this._nearestSnap(newX, newY); + this.currentPage = snap; + time = this.options.snapSpeed || Math.max( + Math.max( + Math.min(Math.abs(newX - snap.x), 1000), + Math.min(Math.abs(newY - snap.y), 1000) + ), 300); + newX = snap.x; + newY = snap.y; - this.directionX = 0; - this.directionY = 0; - easing = this.options.bounceEasing; - } + this.directionX = 0; + this.directionY = 0; + easing = this.options.bounceEasing; + } // INSERT POINT: _end - if ( newX != this.x || newY != this.y ) { - // change easing function when scroller goes out of the boundaries - if ( newX > 0 || newX < this.maxScrollX || newY > 0 || newY < this.maxScrollY ) { - easing = utils.ease.quadratic; - } + if ( newX != this.x || newY != this.y ) { + // change easing function when scroller goes out of the boundaries + if ( newX > 0 || newX < this.maxScrollX || newY > 0 || newY < this.maxScrollY ) { + easing = utils.ease.quadratic; + } - this.scrollTo(newX, newY, time, easing); - return; - } + this.scrollTo(newX, newY, time, easing); + return; + } - this._execEvent('scrollEnd'); - }, + this._execEvent('scrollEnd'); + }, - _resize: function () { - var that = this; + _resize: function () { + var that = this; - clearTimeout(this.resizeTimeout); + clearTimeout(this.resizeTimeout); - this.resizeTimeout = setTimeout(function () { - that.refresh(); - }, this.options.resizePolling); - }, + this.resizeTimeout = setTimeout(function () { + that.refresh(); + }, this.options.resizePolling); + }, - resetPosition: function (time) { - var x = this.x, - y = this.y; + resetPosition: function (time) { + var x = this.x, + y = this.y; - time = time || 0; + time = time || 0; - if ( !this.hasHorizontalScroll || this.x > 0 ) { - x = 0; - } else if ( this.x < this.maxScrollX ) { - x = this.maxScrollX; - } + if ( !this.hasHorizontalScroll || this.x > 0 ) { + x = 0; + } else if ( this.x < this.maxScrollX ) { + x = this.maxScrollX; + } - if ( !this.hasVerticalScroll || this.y > 0 ) { - y = 0; - } else if ( this.y < this.maxScrollY ) { - y = this.maxScrollY; - } + if ( !this.hasVerticalScroll || this.y > 0 ) { + y = 0; + } else if ( this.y < this.maxScrollY ) { + y = this.maxScrollY; + } - if ( x == this.x && y == this.y ) { - return false; - } + if ( x == this.x && y == this.y ) { + return false; + } - this.scrollTo(x, y, time, this.options.bounceEasing); + this.scrollTo(x, y, time, this.options.bounceEasing); - return true; - }, + return true; + }, - disable: function () { - this.enabled = false; - }, + disable: function () { + this.enabled = false; + }, - enable: function () { - this.enabled = true; - }, + enable: function () { + this.enabled = true; + }, - refresh: function () { - var rf = this.wrapper.offsetHeight; // Force reflow + refresh: function () { + utils.getRect(this.wrapper); // Force reflow - this.wrapperWidth = this.wrapper.clientWidth; - this.wrapperHeight = this.wrapper.clientHeight; + this.wrapperWidth = this.wrapper.clientWidth; + this.wrapperHeight = this.wrapper.clientHeight; + var rect = utils.getRect(this.scroller); /* REPLACE START: refresh */ - this.scrollerWidth = this.scroller.offsetWidth; - this.scrollerHeight = this.scroller.offsetHeight; + this.scrollerWidth = rect.width; + this.scrollerHeight = rect.height; - this.maxScrollX = this.wrapperWidth - this.scrollerWidth; - this.maxScrollY = this.wrapperHeight - this.scrollerHeight; + this.maxScrollX = this.wrapperWidth - this.scrollerWidth; + this.maxScrollY = this.wrapperHeight - this.scrollerHeight; /* REPLACE END: refresh */ - this.hasHorizontalScroll = this.options.scrollX && this.maxScrollX < 0; - this.hasVerticalScroll = this.options.scrollY && this.maxScrollY < 0; + this.hasHorizontalScroll = this.options.scrollX && this.maxScrollX < 0; + this.hasVerticalScroll = this.options.scrollY && this.maxScrollY < 0; + + if ( !this.hasHorizontalScroll ) { + this.maxScrollX = 0; + this.scrollerWidth = this.wrapperWidth; + } - if ( !this.hasHorizontalScroll ) { - this.maxScrollX = 0; - this.scrollerWidth = this.wrapperWidth; - } + if ( !this.hasVerticalScroll ) { + this.maxScrollY = 0; + this.scrollerHeight = this.wrapperHeight; + } - if ( !this.hasVerticalScroll ) { - this.maxScrollY = 0; - this.scrollerHeight = this.wrapperHeight; - } + this.endTime = 0; + this.directionX = 0; + this.directionY = 0; + + if(utils.hasPointer && !this.options.disablePointer) { + // The wrapper should have `touchAction` property for using pointerEvent. + this.wrapper.style[utils.style.touchAction] = utils.getTouchAction(this.options.eventPassthrough, true); - this.endTime = 0; - this.directionX = 0; - this.directionY = 0; + // case. not support 'pinch-zoom' + // https://github.com/cubiq/iscroll/issues/1118#issuecomment-270057583 + if (!this.wrapper.style[utils.style.touchAction]) { + this.wrapper.style[utils.style.touchAction] = utils.getTouchAction(this.options.eventPassthrough, false); + } + } + this.wrapperOffset = utils.offset(this.wrapper); - this.wrapperOffset = utils.offset(this.wrapper); + this._execEvent('refresh'); - this._execEvent('refresh'); - - this.resetPosition(); + this.resetPosition(); // INSERT POINT: _refresh - }, - - on: function (type, fn) { - if ( !this._events[type] ) { - this._events[type] = []; - } + }, - this._events[type].push(fn); - }, + on: function (type, fn) { + if ( !this._events[type] ) { + this._events[type] = []; + } - off: function (type, fn) { - if ( !this._events[type] ) { - return; - } + this._events[type].push(fn); + }, - var index = this._events[type].indexOf(fn); + off: function (type, fn) { + if ( !this._events[type] ) { + return; + } - if ( index > -1 ) { - this._events[type].splice(index, 1); - } - }, + var index = this._events[type].indexOf(fn); - _execEvent: function (type) { - if ( !this._events[type] ) { - return; - } + if ( index > -1 ) { + this._events[type].splice(index, 1); + } + }, - var i = 0, - l = this._events[type].length; + _execEvent: function (type) { + if ( !this._events[type] ) { + return; + } - if ( !l ) { - return; - } + var i = 0, + l = this._events[type].length; - for ( ; i < l; i++ ) { - this._events[type][i].apply(this, [].slice.call(arguments, 1)); - } - }, + if ( !l ) { + return; + } - scrollBy: function (x, y, time, easing) { - x = this.x + x; - y = this.y + y; - time = time || 0; + for ( ; i < l; i++ ) { + this._events[type][i].apply(this, [].slice.call(arguments, 1)); + } + }, - this.scrollTo(x, y, time, easing); - }, + scrollBy: function (x, y, time, easing) { + x = this.x + x; + y = this.y + y; + time = time || 0; - scrollTo: function (x, y, time, easing) { - easing = easing || utils.ease.circular; + this.scrollTo(x, y, time, easing); + }, - this.isInTransition = this.options.useTransition && time > 0; + scrollTo: function (x, y, time, easing) { + easing = easing || utils.ease.circular; - if ( !time || (this.options.useTransition && easing.style) ) { - this._transitionTimingFunction(easing.style); - this._transitionTime(time); - this._translate(x, y); - } else { - this._animate(x, y, time, easing.fn); - } - }, + this.isInTransition = this.options.useTransition && time > 0; + var transitionType = this.options.useTransition && easing.style; + if ( !time || transitionType ) { + if(transitionType) { + this._transitionTimingFunction(easing.style); + this._transitionTime(time); + } + this._translate(x, y); + } else { + this._animate(x, y, time, easing.fn); + } + }, - scrollToElement: function (el, time, offsetX, offsetY, easing) { - el = el.nodeType ? el : this.scroller.querySelector(el); + scrollToElement: function (el, time, offsetX, offsetY, easing) { + el = el.nodeType ? el : this.scroller.querySelector(el); - if ( !el ) { - return; - } + if ( !el ) { + return; + } - var pos = utils.offset(el); + var pos = utils.offset(el); - pos.left -= this.wrapperOffset.left; - pos.top -= this.wrapperOffset.top; + pos.left -= this.wrapperOffset.left; + pos.top -= this.wrapperOffset.top; - // if offsetX/Y are true we center the element to the screen - if ( offsetX === true ) { - offsetX = Math.round(el.offsetWidth / 2 - this.wrapper.offsetWidth / 2); - } - if ( offsetY === true ) { - offsetY = Math.round(el.offsetHeight / 2 - this.wrapper.offsetHeight / 2); - } + // if offsetX/Y are true we center the element to the screen + var elRect = utils.getRect(el); + var wrapperRect = utils.getRect(this.wrapper); + if ( offsetX === true ) { + offsetX = Math.round(elRect.width / 2 - wrapperRect.width / 2); + } + if ( offsetY === true ) { + offsetY = Math.round(elRect.height / 2 - wrapperRect.height / 2); + } - pos.left -= offsetX || 0; - pos.top -= offsetY || 0; + pos.left -= offsetX || 0; + pos.top -= offsetY || 0; - pos.left = pos.left > 0 ? 0 : pos.left < this.maxScrollX ? this.maxScrollX : pos.left; - pos.top = pos.top > 0 ? 0 : pos.top < this.maxScrollY ? this.maxScrollY : pos.top; + pos.left = pos.left > 0 ? 0 : pos.left < this.maxScrollX ? this.maxScrollX : pos.left; + pos.top = pos.top > 0 ? 0 : pos.top < this.maxScrollY ? this.maxScrollY : pos.top; - time = time === undefined || time === null || time === 'auto' ? Math.max(Math.abs(this.x-pos.left), Math.abs(this.y-pos.top)) : time; + time = time === undefined || time === null || time === 'auto' ? Math.max(Math.abs(this.x-pos.left), Math.abs(this.y-pos.top)) : time; - this.scrollTo(pos.left, pos.top, time, easing); - }, + this.scrollTo(pos.left, pos.top, time, easing); + }, - _transitionTime: function (time) { - time = time || 0; + _transitionTime: function (time) { + if (!this.options.useTransition) { + return; + } + time = time || 0; + var durationProp = utils.style.transitionDuration; + if(!durationProp) { + return; + } - this.scrollerStyle[utils.style.transitionDuration] = time + 'ms'; + this.scrollerStyle[durationProp] = time + 'ms'; - if ( !time && utils.isBadAndroid ) { - this.scrollerStyle[utils.style.transitionDuration] = '0.001s'; - } + if ( !time && utils.isBadAndroid ) { + this.scrollerStyle[durationProp] = '0.0001ms'; + // remove 0.0001ms + var self = this; + rAF(function() { + if(self.scrollerStyle[durationProp] === '0.0001ms') { + self.scrollerStyle[durationProp] = '0s'; + } + }); + } - if ( this.indicators ) { - for ( var i = this.indicators.length; i--; ) { - this.indicators[i].transitionTime(time); - } - } + if ( this.indicators ) { + for ( var i = this.indicators.length; i--; ) { + this.indicators[i].transitionTime(time); + } + } // INSERT POINT: _transitionTime - }, + }, - _transitionTimingFunction: function (easing) { - this.scrollerStyle[utils.style.transitionTimingFunction] = easing; + _transitionTimingFunction: function (easing) { + this.scrollerStyle[utils.style.transitionTimingFunction] = easing; - if ( this.indicators ) { - for ( var i = this.indicators.length; i--; ) { - this.indicators[i].transitionTimingFunction(easing); - } - } + if ( this.indicators ) { + for ( var i = this.indicators.length; i--; ) { + this.indicators[i].transitionTimingFunction(easing); + } + } // INSERT POINT: _transitionTimingFunction - }, + }, - _translate: function (x, y) { - if ( this.options.useTransform ) { + _translate: function (x, y) { + if ( this.options.useTransform ) { /* REPLACE START: _translate */ - this.scrollerStyle[utils.style.transform] = 'translate(' + x + 'px,' + y + 'px)' + this.translateZ; + this.scrollerStyle[utils.style.transform] = 'translate(' + x + 'px,' + y + 'px)' + this.translateZ; /* REPLACE END: _translate */ - } else { - x = Math.round(x); - y = Math.round(y); - this.scrollerStyle.left = x + 'px'; - this.scrollerStyle.top = y + 'px'; - } + } else { + x = Math.round(x); + y = Math.round(y); + this.scrollerStyle.left = x + 'px'; + this.scrollerStyle.top = y + 'px'; + } - this.x = x; - this.y = y; + this.x = x; + this.y = y; - if ( this.indicators ) { - for ( var i = this.indicators.length; i--; ) { - this.indicators[i].updatePosition(); - } - } + if ( this.indicators ) { + for ( var i = this.indicators.length; i--; ) { + this.indicators[i].updatePosition(); + } + } // INSERT POINT: _translate - }, + }, - _initEvents: function (remove) { - var eventType = remove ? utils.removeEvent : utils.addEvent, - target = this.options.bindToWrapper ? this.wrapper : window; + _initEvents: function (remove) { + var eventType = remove ? utils.removeEvent : utils.addEvent, + target = this.options.bindToWrapper ? this.wrapper : window; - eventType(window, 'orientationchange', this); - eventType(window, 'resize', this); + eventType(window, 'orientationchange', this); + eventType(window, 'resize', this); - if ( this.options.click ) { - eventType(this.wrapper, 'click', this, true); - } + if ( this.options.click ) { + eventType(this.wrapper, 'click', this, true); + } - if ( !this.options.disableMouse ) { - eventType(this.wrapper, 'mousedown', this); - eventType(target, 'mousemove', this); - eventType(target, 'mousecancel', this); - eventType(target, 'mouseup', this); - } + if ( !this.options.disableMouse ) { + eventType(this.wrapper, 'mousedown', this); + eventType(target, 'mousemove', this); + eventType(target, 'mousecancel', this); + eventType(target, 'mouseup', this); + } - if ( utils.hasPointer && !this.options.disablePointer ) { - eventType(this.wrapper, utils.prefixPointerEvent('pointerdown'), this); - eventType(target, utils.prefixPointerEvent('pointermove'), this); - eventType(target, utils.prefixPointerEvent('pointercancel'), this); - eventType(target, utils.prefixPointerEvent('pointerup'), this); - } + if ( utils.hasPointer && !this.options.disablePointer ) { + eventType(this.wrapper, utils.prefixPointerEvent('pointerdown'), this); + eventType(target, utils.prefixPointerEvent('pointermove'), this); + eventType(target, utils.prefixPointerEvent('pointercancel'), this); + eventType(target, utils.prefixPointerEvent('pointerup'), this); + } - if ( utils.hasTouch && !this.options.disableTouch ) { - eventType(this.wrapper, 'touchstart', this); - eventType(target, 'touchmove', this); - eventType(target, 'touchcancel', this); - eventType(target, 'touchend', this); - } + if ( utils.hasTouch && !this.options.disableTouch ) { + eventType(this.wrapper, 'touchstart', this); + eventType(target, 'touchmove', this); + eventType(target, 'touchcancel', this); + eventType(target, 'touchend', this); + } - eventType(this.scroller, 'transitionend', this); - eventType(this.scroller, 'webkitTransitionEnd', this); - eventType(this.scroller, 'oTransitionEnd', this); - eventType(this.scroller, 'MSTransitionEnd', this); - }, + eventType(this.scroller, 'transitionend', this); + eventType(this.scroller, 'webkitTransitionEnd', this); + eventType(this.scroller, 'oTransitionEnd', this); + eventType(this.scroller, 'MSTransitionEnd', this); + }, - getComputedPosition: function () { - var matrix = window.getComputedStyle(this.scroller, null), - x, y; + getComputedPosition: function () { + var matrix = window.getComputedStyle(this.scroller, null), + x, y; - if ( this.options.useTransform ) { - matrix = matrix[utils.style.transform].split(')')[0].split(', '); - x = +(matrix[12] || matrix[4]); - y = +(matrix[13] || matrix[5]); - } else { - x = +matrix.left.replace(/[^-\d.]/g, ''); - y = +matrix.top.replace(/[^-\d.]/g, ''); - } + if ( this.options.useTransform ) { + matrix = matrix[utils.style.transform].split(')')[0].split(', '); + x = +(matrix[12] || matrix[4]); + y = +(matrix[13] || matrix[5]); + } else { + x = +matrix.left.replace(/[^-\d.]/g, ''); + y = +matrix.top.replace(/[^-\d.]/g, ''); + } - return { x: x, y: y }; - }, + return { x: x, y: y }; + }, + _initIndicators: function () { + var interactive = this.options.interactiveScrollbars, + customStyle = typeof this.options.scrollbars != 'string', + indicators = [], + indicator; - _initIndicators: function () { - var interactive = this.options.interactiveScrollbars, - customStyle = typeof this.options.scrollbars != 'string', - indicators = [], - indicator; + var that = this; - var that = this; + this.indicators = []; - this.indicators = []; + if ( this.options.scrollbars ) { + // Vertical scrollbar + if ( this.options.scrollY ) { + indicator = { + el: createDefaultScrollbar('v', interactive, this.options.scrollbars), + interactive: interactive, + defaultScrollbars: true, + customStyle: customStyle, + resize: this.options.resizeScrollbars, + shrink: this.options.shrinkScrollbars, + fade: this.options.fadeScrollbars, + listenX: false + }; - if ( this.options.scrollbars ) { - // Vertical scrollbar - if ( this.options.scrollY ) { - indicator = { - el: createDefaultScrollbar('v', interactive, this.options.scrollbars), - interactive: interactive, - defaultScrollbars: true, - customStyle: customStyle, - resize: this.options.resizeScrollbars, - shrink: this.options.shrinkScrollbars, - fade: this.options.fadeScrollbars, - listenX: false - }; + this.wrapper.appendChild(indicator.el); + indicators.push(indicator); + } - this.wrapper.appendChild(indicator.el); - indicators.push(indicator); - } + // Horizontal scrollbar + if ( this.options.scrollX ) { + indicator = { + el: createDefaultScrollbar('h', interactive, this.options.scrollbars), + interactive: interactive, + defaultScrollbars: true, + customStyle: customStyle, + resize: this.options.resizeScrollbars, + shrink: this.options.shrinkScrollbars, + fade: this.options.fadeScrollbars, + listenY: false + }; - // Horizontal scrollbar - if ( this.options.scrollX ) { - indicator = { - el: createDefaultScrollbar('h', interactive, this.options.scrollbars), - interactive: interactive, - defaultScrollbars: true, - customStyle: customStyle, - resize: this.options.resizeScrollbars, - shrink: this.options.shrinkScrollbars, - fade: this.options.fadeScrollbars, - listenY: false - }; + this.wrapper.appendChild(indicator.el); + indicators.push(indicator); + } + } - this.wrapper.appendChild(indicator.el); - indicators.push(indicator); - } - } + if ( this.options.indicators ) { + // TODO: check concat compatibility + indicators = indicators.concat(this.options.indicators); + } - if ( this.options.indicators ) { - // TODO: check concat compatibility - indicators = indicators.concat(this.options.indicators); - } + for ( var i = indicators.length; i--; ) { + this.indicators.push( new Indicator(this, indicators[i]) ); + } - for ( var i = indicators.length; i--; ) { - this.indicators.push( new Indicator(this, indicators[i]) ); - } + // TODO: check if we can use array.map (wide compatibility and performance issues) + function _indicatorsMap (fn) { + if (that.indicators) { + for ( var i = that.indicators.length; i--; ) { + fn.call(that.indicators[i]); + } + } + } - // TODO: check if we can use array.map (wide compatibility and performance issues) - function _indicatorsMap (fn) { - for ( var i = that.indicators.length; i--; ) { - fn.call(that.indicators[i]); - } - } + if ( this.options.fadeScrollbars ) { + this.on('scrollEnd', function () { + _indicatorsMap(function () { + this.fade(); + }); + }); - if ( this.options.fadeScrollbars ) { - this.on('scrollEnd', function () { - _indicatorsMap(function () { - this.fade(); - }); - }); + this.on('scrollCancel', function () { + _indicatorsMap(function () { + this.fade(); + }); + }); - this.on('scrollCancel', function () { - _indicatorsMap(function () { - this.fade(); - }); - }); + this.on('scrollStart', function () { + _indicatorsMap(function () { + this.fade(1); + }); + }); - this.on('scrollStart', function () { - _indicatorsMap(function () { - this.fade(1); - }); - }); + this.on('beforeScrollStart', function () { + _indicatorsMap(function () { + this.fade(1, true); + }); + }); + } - this.on('beforeScrollStart', function () { - _indicatorsMap(function () { - this.fade(1, true); - }); - }); - } + this.on('refresh', function () { + _indicatorsMap(function () { + this.refresh(); + }); + }); - this.on('refresh', function () { - _indicatorsMap(function () { - this.refresh(); - }); - }); + this.on('destroy', function () { + _indicatorsMap(function () { + this.destroy(); + }); - this.on('destroy', function () { - _indicatorsMap(function () { - this.destroy(); - }); + delete this.indicators; + }); + }, - delete this.indicators; - }); - }, + _initWheel: function () { + utils.addEvent(this.wrapper, 'wheel', this); + utils.addEvent(this.wrapper, 'mousewheel', this); + utils.addEvent(this.wrapper, 'DOMMouseScroll', this); - _initWheel: function () { - utils.addEvent(this.wrapper, 'wheel', this); - utils.addEvent(this.wrapper, 'mousewheel', this); - utils.addEvent(this.wrapper, 'DOMMouseScroll', this); + this.on('destroy', function () { + clearTimeout(this.wheelTimeout); + this.wheelTimeout = null; + utils.removeEvent(this.wrapper, 'wheel', this); + utils.removeEvent(this.wrapper, 'mousewheel', this); + utils.removeEvent(this.wrapper, 'DOMMouseScroll', this); + }); + }, - this.on('destroy', function () { - utils.removeEvent(this.wrapper, 'wheel', this); - utils.removeEvent(this.wrapper, 'mousewheel', this); - utils.removeEvent(this.wrapper, 'DOMMouseScroll', this); - }); - }, + _wheel: function (e) { + if ( !this.enabled ) { + return; + } - _wheel: function (e) { - if ( !this.enabled ) { - return; - } + e.preventDefault(); - e.preventDefault(); - e.stopPropagation(); + var wheelDeltaX, wheelDeltaY, + newX, newY, + that = this; - var wheelDeltaX, wheelDeltaY, - newX, newY, - that = this; + if ( this.wheelTimeout === undefined ) { + that._execEvent('scrollStart'); + } - if ( this.wheelTimeout === undefined ) { - that._execEvent('scrollStart'); - } + // Execute the scrollEnd event after 400ms the wheel stopped scrolling + clearTimeout(this.wheelTimeout); + this.wheelTimeout = setTimeout(function () { + if(!that.options.snap) { + that._execEvent('scrollEnd'); + } + that.wheelTimeout = undefined; + }, 400); - // Execute the scrollEnd event after 400ms the wheel stopped scrolling - clearTimeout(this.wheelTimeout); - this.wheelTimeout = setTimeout(function () { - that._execEvent('scrollEnd'); - that.wheelTimeout = undefined; - }, 400); + if ( 'deltaX' in e ) { + if (e.deltaMode === 1) { + wheelDeltaX = -e.deltaX * this.options.mouseWheelSpeed; + wheelDeltaY = -e.deltaY * this.options.mouseWheelSpeed; + } else { + wheelDeltaX = -e.deltaX; + wheelDeltaY = -e.deltaY; + } + } else if ( 'wheelDeltaX' in e ) { + wheelDeltaX = e.wheelDeltaX / 120 * this.options.mouseWheelSpeed; + wheelDeltaY = e.wheelDeltaY / 120 * this.options.mouseWheelSpeed; + } else if ( 'wheelDelta' in e ) { + wheelDeltaX = wheelDeltaY = e.wheelDelta / 120 * this.options.mouseWheelSpeed; + } else if ( 'detail' in e ) { + wheelDeltaX = wheelDeltaY = -e.detail / 3 * this.options.mouseWheelSpeed; + } else { + return; + } - if ( 'deltaX' in e ) { - if (e.deltaMode === 1) { - wheelDeltaX = -e.deltaX * this.options.mouseWheelSpeed; - wheelDeltaY = -e.deltaY * this.options.mouseWheelSpeed; - } else { - wheelDeltaX = -e.deltaX; - wheelDeltaY = -e.deltaY; - } - } else if ( 'wheelDeltaX' in e ) { - wheelDeltaX = e.wheelDeltaX / 120 * this.options.mouseWheelSpeed; - wheelDeltaY = e.wheelDeltaY / 120 * this.options.mouseWheelSpeed; - } else if ( 'wheelDelta' in e ) { - wheelDeltaX = wheelDeltaY = e.wheelDelta / 120 * this.options.mouseWheelSpeed; - } else if ( 'detail' in e ) { - wheelDeltaX = wheelDeltaY = -e.detail / 3 * this.options.mouseWheelSpeed; - } else { - return; - } + wheelDeltaX *= this.options.invertWheelDirection; + wheelDeltaY *= this.options.invertWheelDirection; - wheelDeltaX *= this.options.invertWheelDirection; - wheelDeltaY *= this.options.invertWheelDirection; + if ( !this.hasVerticalScroll ) { + wheelDeltaX = wheelDeltaY; + wheelDeltaY = 0; + } - if ( !this.hasVerticalScroll ) { - wheelDeltaX = wheelDeltaY; - wheelDeltaY = 0; - } + if ( this.options.snap ) { + newX = this.currentPage.pageX; + newY = this.currentPage.pageY; - if ( this.options.snap ) { - newX = this.currentPage.pageX; - newY = this.currentPage.pageY; + if ( wheelDeltaX > 0 ) { + newX--; + } else if ( wheelDeltaX < 0 ) { + newX++; + } - if ( wheelDeltaX > 0 ) { - newX--; - } else if ( wheelDeltaX < 0 ) { - newX++; - } + if ( wheelDeltaY > 0 ) { + newY--; + } else if ( wheelDeltaY < 0 ) { + newY++; + } - if ( wheelDeltaY > 0 ) { - newY--; - } else if ( wheelDeltaY < 0 ) { - newY++; - } + this.goToPage(newX, newY); - this.goToPage(newX, newY); + return; + } - return; - } + newX = this.x + Math.round(this.hasHorizontalScroll ? wheelDeltaX : 0); + newY = this.y + Math.round(this.hasVerticalScroll ? wheelDeltaY : 0); - newX = this.x + Math.round(this.hasHorizontalScroll ? wheelDeltaX : 0); - newY = this.y + Math.round(this.hasVerticalScroll ? wheelDeltaY : 0); + this.directionX = wheelDeltaX > 0 ? -1 : wheelDeltaX < 0 ? 1 : 0; + this.directionY = wheelDeltaY > 0 ? -1 : wheelDeltaY < 0 ? 1 : 0; - if ( newX > 0 ) { - newX = 0; - } else if ( newX < this.maxScrollX ) { - newX = this.maxScrollX; - } + if ( newX > 0 ) { + newX = 0; + } else if ( newX < this.maxScrollX ) { + newX = this.maxScrollX; + } - if ( newY > 0 ) { - newY = 0; - } else if ( newY < this.maxScrollY ) { - newY = this.maxScrollY; - } + if ( newY > 0 ) { + newY = 0; + } else if ( newY < this.maxScrollY ) { + newY = this.maxScrollY; + } - this.scrollTo(newX, newY, 0); + this.scrollTo(newX, newY, 0); // INSERT POINT: _wheel - }, + }, - _initSnap: function () { - this.currentPage = {}; + _initSnap: function () { + this.currentPage = {}; - if ( typeof this.options.snap == 'string' ) { - this.options.snap = this.scroller.querySelectorAll(this.options.snap); - } + if ( typeof this.options.snap == 'string' ) { + this.options.snap = this.scroller.querySelectorAll(this.options.snap); + } - this.on('refresh', function () { - var i = 0, l, - m = 0, n, - cx, cy, - x = 0, y, - stepX = this.options.snapStepX || this.wrapperWidth, - stepY = this.options.snapStepY || this.wrapperHeight, - el; + this.on('refresh', function () { + var i = 0, l, + m = 0, n, + cx, cy, + x = 0, y, + stepX = this.options.snapStepX || this.wrapperWidth, + stepY = this.options.snapStepY || this.wrapperHeight, + el, + rect; - this.pages = []; + this.pages = []; - if ( !this.wrapperWidth || !this.wrapperHeight || !this.scrollerWidth || !this.scrollerHeight ) { - return; - } + if ( !this.wrapperWidth || !this.wrapperHeight || !this.scrollerWidth || !this.scrollerHeight ) { + return; + } - if ( this.options.snap === true ) { - cx = Math.round( stepX / 2 ); - cy = Math.round( stepY / 2 ); + if ( this.options.snap === true ) { + cx = Math.round( stepX / 2 ); + cy = Math.round( stepY / 2 ); - while ( x > -this.scrollerWidth ) { - this.pages[i] = []; - l = 0; - y = 0; + while ( x > -this.scrollerWidth ) { + this.pages[i] = []; + l = 0; + y = 0; - while ( y > -this.scrollerHeight ) { - this.pages[i][l] = { - x: Math.max(x, this.maxScrollX), - y: Math.max(y, this.maxScrollY), - width: stepX, - height: stepY, - cx: x - cx, - cy: y - cy - }; + while ( y > -this.scrollerHeight ) { + this.pages[i][l] = { + x: Math.max(x, this.maxScrollX), + y: Math.max(y, this.maxScrollY), + width: stepX, + height: stepY, + cx: x - cx, + cy: y - cy + }; - y -= stepY; - l++; - } + y -= stepY; + l++; + } - x -= stepX; - i++; - } - } else { - el = this.options.snap; - l = el.length; - n = -1; + x -= stepX; + i++; + } + } else { + el = this.options.snap; + l = el.length; + n = -1; - for ( ; i < l; i++ ) { - if ( i === 0 || el[i].offsetLeft <= el[i-1].offsetLeft ) { - m = 0; - n++; - } + for ( ; i < l; i++ ) { + rect = utils.getRect(el[i]); + if ( i === 0 || rect.left <= utils.getRect(el[i-1]).left ) { + m = 0; + n++; + } - if ( !this.pages[m] ) { - this.pages[m] = []; - } + if ( !this.pages[m] ) { + this.pages[m] = []; + } - x = Math.max(-el[i].offsetLeft, this.maxScrollX); - y = Math.max(-el[i].offsetTop, this.maxScrollY); - cx = x - Math.round(el[i].offsetWidth / 2); - cy = y - Math.round(el[i].offsetHeight / 2); + x = Math.max(-rect.left, this.maxScrollX); + y = Math.max(-rect.top, this.maxScrollY); + cx = x - Math.round(rect.width / 2); + cy = y - Math.round(rect.height / 2); - this.pages[m][n] = { - x: x, - y: y, - width: el[i].offsetWidth, - height: el[i].offsetHeight, - cx: cx, - cy: cy - }; + this.pages[m][n] = { + x: x, + y: y, + width: rect.width, + height: rect.height, + cx: cx, + cy: cy + }; - if ( x > this.maxScrollX ) { - m++; - } - } - } + if ( x > this.maxScrollX ) { + m++; + } + } + } - this.goToPage(this.currentPage.pageX || 0, this.currentPage.pageY || 0, 0); + this.goToPage(this.currentPage.pageX || 0, this.currentPage.pageY || 0, 0); - // Update snap threshold if needed - if ( this.options.snapThreshold % 1 === 0 ) { - this.snapThresholdX = this.options.snapThreshold; - this.snapThresholdY = this.options.snapThreshold; - } else { - this.snapThresholdX = Math.round(this.pages[this.currentPage.pageX][this.currentPage.pageY].width * this.options.snapThreshold); - this.snapThresholdY = Math.round(this.pages[this.currentPage.pageX][this.currentPage.pageY].height * this.options.snapThreshold); - } - }); + // Update snap threshold if needed + if ( this.options.snapThreshold % 1 === 0 ) { + this.snapThresholdX = this.options.snapThreshold; + this.snapThresholdY = this.options.snapThreshold; + } else { + this.snapThresholdX = Math.round(this.pages[this.currentPage.pageX][this.currentPage.pageY].width * this.options.snapThreshold); + this.snapThresholdY = Math.round(this.pages[this.currentPage.pageX][this.currentPage.pageY].height * this.options.snapThreshold); + } + }); - this.on('flick', function () { - var time = this.options.snapSpeed || Math.max( - Math.max( - Math.min(Math.abs(this.x - this.startX), 1000), - Math.min(Math.abs(this.y - this.startY), 1000) - ), 300); + this.on('flick', function () { + var time = this.options.snapSpeed || Math.max( + Math.max( + Math.min(Math.abs(this.x - this.startX), 1000), + Math.min(Math.abs(this.y - this.startY), 1000) + ), 300); - this.goToPage( - this.currentPage.pageX + this.directionX, - this.currentPage.pageY + this.directionY, - time - ); - }); - }, + this.goToPage( + this.currentPage.pageX + this.directionX, + this.currentPage.pageY + this.directionY, + time + ); + }); + }, - _nearestSnap: function (x, y) { - if ( !this.pages.length ) { - return { x: 0, y: 0, pageX: 0, pageY: 0 }; - } + _nearestSnap: function (x, y) { + if ( !this.pages.length ) { + return { x: 0, y: 0, pageX: 0, pageY: 0 }; + } - var i = 0, - l = this.pages.length, - m = 0; + var i = 0, + l = this.pages.length, + m = 0; - // Check if we exceeded the snap threshold - if ( Math.abs(x - this.absStartX) < this.snapThresholdX && - Math.abs(y - this.absStartY) < this.snapThresholdY ) { - return this.currentPage; - } + // Check if we exceeded the snap threshold + if ( Math.abs(x - this.absStartX) < this.snapThresholdX && + Math.abs(y - this.absStartY) < this.snapThresholdY ) { + return this.currentPage; + } - if ( x > 0 ) { - x = 0; - } else if ( x < this.maxScrollX ) { - x = this.maxScrollX; - } + if ( x > 0 ) { + x = 0; + } else if ( x < this.maxScrollX ) { + x = this.maxScrollX; + } - if ( y > 0 ) { - y = 0; - } else if ( y < this.maxScrollY ) { - y = this.maxScrollY; - } + if ( y > 0 ) { + y = 0; + } else if ( y < this.maxScrollY ) { + y = this.maxScrollY; + } - for ( ; i < l; i++ ) { - if ( x >= this.pages[i][0].cx ) { - x = this.pages[i][0].x; - break; - } - } + for ( ; i < l; i++ ) { + if ( x >= this.pages[i][0].cx ) { + x = this.pages[i][0].x; + break; + } + } - l = this.pages[i].length; + l = this.pages[i].length; - for ( ; m < l; m++ ) { - if ( y >= this.pages[0][m].cy ) { - y = this.pages[0][m].y; - break; - } - } + for ( ; m < l; m++ ) { + if ( y >= this.pages[0][m].cy ) { + y = this.pages[0][m].y; + break; + } + } - if ( i == this.currentPage.pageX ) { - i += this.directionX; + if ( i == this.currentPage.pageX ) { + i += this.directionX; - if ( i < 0 ) { - i = 0; - } else if ( i >= this.pages.length ) { - i = this.pages.length - 1; - } + if ( i < 0 ) { + i = 0; + } else if ( i >= this.pages.length ) { + i = this.pages.length - 1; + } - x = this.pages[i][0].x; - } + x = this.pages[i][0].x; + } - if ( m == this.currentPage.pageY ) { - m += this.directionY; + if ( m == this.currentPage.pageY ) { + m += this.directionY; - if ( m < 0 ) { - m = 0; - } else if ( m >= this.pages[0].length ) { - m = this.pages[0].length - 1; - } + if ( m < 0 ) { + m = 0; + } else if ( m >= this.pages[0].length ) { + m = this.pages[0].length - 1; + } - y = this.pages[0][m].y; - } + y = this.pages[0][m].y; + } - return { - x: x, - y: y, - pageX: i, - pageY: m - }; - }, + return { + x: x, + y: y, + pageX: i, + pageY: m + }; + }, - goToPage: function (x, y, time, easing) { - easing = easing || this.options.bounceEasing; + goToPage: function (x, y, time, easing) { + easing = easing || this.options.bounceEasing; - if ( x >= this.pages.length ) { - x = this.pages.length - 1; - } else if ( x < 0 ) { - x = 0; - } + if ( x >= this.pages.length ) { + x = this.pages.length - 1; + } else if ( x < 0 ) { + x = 0; + } - if ( y >= this.pages[x].length ) { - y = this.pages[x].length - 1; - } else if ( y < 0 ) { - y = 0; - } + if ( y >= this.pages[x].length ) { + y = this.pages[x].length - 1; + } else if ( y < 0 ) { + y = 0; + } - var posX = this.pages[x][y].x, - posY = this.pages[x][y].y; + var posX = this.pages[x][y].x, + posY = this.pages[x][y].y; - time = time === undefined ? this.options.snapSpeed || Math.max( - Math.max( - Math.min(Math.abs(posX - this.x), 1000), - Math.min(Math.abs(posY - this.y), 1000) - ), 300) : time; + time = time === undefined ? this.options.snapSpeed || Math.max( + Math.max( + Math.min(Math.abs(posX - this.x), 1000), + Math.min(Math.abs(posY - this.y), 1000) + ), 300) : time; - this.currentPage = { - x: posX, - y: posY, - pageX: x, - pageY: y - }; + this.currentPage = { + x: posX, + y: posY, + pageX: x, + pageY: y + }; - this.scrollTo(posX, posY, time, easing); - }, + this.scrollTo(posX, posY, time, easing); + }, - next: function (time, easing) { - var x = this.currentPage.pageX, - y = this.currentPage.pageY; + next: function (time, easing) { + var x = this.currentPage.pageX, + y = this.currentPage.pageY; - x++; + x++; - if ( x >= this.pages.length && this.hasVerticalScroll ) { - x = 0; - y++; - } + if ( x >= this.pages.length && this.hasVerticalScroll ) { + x = 0; + y++; + } - this.goToPage(x, y, time, easing); - }, + this.goToPage(x, y, time, easing); + }, - prev: function (time, easing) { - var x = this.currentPage.pageX, - y = this.currentPage.pageY; + prev: function (time, easing) { + var x = this.currentPage.pageX, + y = this.currentPage.pageY; - x--; + x--; - if ( x < 0 && this.hasVerticalScroll ) { - x = 0; - y--; - } + if ( x < 0 && this.hasVerticalScroll ) { + x = 0; + y--; + } - this.goToPage(x, y, time, easing); - }, + this.goToPage(x, y, time, easing); + }, - _initKeys: function (e) { - // default key bindings - var keys = { - pageUp: 33, - pageDown: 34, - end: 35, - home: 36, - left: 37, - up: 38, - right: 39, - down: 40 - }; - var i; + _initKeys: function (e) { + // default key bindings + var keys = { + pageUp: 33, + pageDown: 34, + end: 35, + home: 36, + left: 37, + up: 38, + right: 39, + down: 40 + }; + var i; - // if you give me characters I give you keycode - if ( typeof this.options.keyBindings == 'object' ) { - for ( i in this.options.keyBindings ) { - if ( typeof this.options.keyBindings[i] == 'string' ) { - this.options.keyBindings[i] = this.options.keyBindings[i].toUpperCase().charCodeAt(0); - } - } - } else { - this.options.keyBindings = {}; - } + // if you give me characters I give you keycode + if ( typeof this.options.keyBindings == 'object' ) { + for ( i in this.options.keyBindings ) { + if ( typeof this.options.keyBindings[i] == 'string' ) { + this.options.keyBindings[i] = this.options.keyBindings[i].toUpperCase().charCodeAt(0); + } + } + } else { + this.options.keyBindings = {}; + } - for ( i in keys ) { - this.options.keyBindings[i] = this.options.keyBindings[i] || keys[i]; - } + for ( i in keys ) { + this.options.keyBindings[i] = this.options.keyBindings[i] || keys[i]; + } - utils.addEvent(window, 'keydown', this); + utils.addEvent(window, 'keydown', this); - this.on('destroy', function () { - utils.removeEvent(window, 'keydown', this); - }); - }, + this.on('destroy', function () { + utils.removeEvent(window, 'keydown', this); + }); + }, - _key: function (e) { - if ( !this.enabled ) { - return; - } + _key: function (e) { + if ( !this.enabled ) { + return; + } - var snap = this.options.snap, // we are using this alot, better to cache it - newX = snap ? this.currentPage.pageX : this.x, - newY = snap ? this.currentPage.pageY : this.y, - now = utils.getTime(), - prevTime = this.keyTime || 0, - acceleration = 0.250, - pos; + var snap = this.options.snap, // we are using this alot, better to cache it + newX = snap ? this.currentPage.pageX : this.x, + newY = snap ? this.currentPage.pageY : this.y, + now = utils.getTime(), + prevTime = this.keyTime || 0, + acceleration = 0.250, + pos; - if ( this.options.useTransition && this.isInTransition ) { - pos = this.getComputedPosition(); + if ( this.options.useTransition && this.isInTransition ) { + pos = this.getComputedPosition(); - this._translate(Math.round(pos.x), Math.round(pos.y)); - this.isInTransition = false; - } + this._translate(Math.round(pos.x), Math.round(pos.y)); + this.isInTransition = false; + } - this.keyAcceleration = now - prevTime < 200 ? Math.min(this.keyAcceleration + acceleration, 50) : 0; + this.keyAcceleration = now - prevTime < 200 ? Math.min(this.keyAcceleration + acceleration, 50) : 0; - switch ( e.keyCode ) { - case this.options.keyBindings.pageUp: - if ( this.hasHorizontalScroll && !this.hasVerticalScroll ) { - newX += snap ? 1 : this.wrapperWidth; - } else { - newY += snap ? 1 : this.wrapperHeight; - } - break; - case this.options.keyBindings.pageDown: - if ( this.hasHorizontalScroll && !this.hasVerticalScroll ) { - newX -= snap ? 1 : this.wrapperWidth; - } else { - newY -= snap ? 1 : this.wrapperHeight; - } - break; - case this.options.keyBindings.end: - newX = snap ? this.pages.length-1 : this.maxScrollX; - newY = snap ? this.pages[0].length-1 : this.maxScrollY; - break; - case this.options.keyBindings.home: - newX = 0; - newY = 0; - break; - case this.options.keyBindings.left: - newX += snap ? -1 : 5 + this.keyAcceleration>>0; - break; - case this.options.keyBindings.up: - newY += snap ? 1 : 5 + this.keyAcceleration>>0; - break; - case this.options.keyBindings.right: - newX -= snap ? -1 : 5 + this.keyAcceleration>>0; - break; - case this.options.keyBindings.down: - newY -= snap ? 1 : 5 + this.keyAcceleration>>0; - break; - default: - return; - } + switch ( e.keyCode ) { + case this.options.keyBindings.pageUp: + if ( this.hasHorizontalScroll && !this.hasVerticalScroll ) { + newX += snap ? 1 : this.wrapperWidth; + } else { + newY += snap ? 1 : this.wrapperHeight; + } + break; + case this.options.keyBindings.pageDown: + if ( this.hasHorizontalScroll && !this.hasVerticalScroll ) { + newX -= snap ? 1 : this.wrapperWidth; + } else { + newY -= snap ? 1 : this.wrapperHeight; + } + break; + case this.options.keyBindings.end: + newX = snap ? this.pages.length-1 : this.maxScrollX; + newY = snap ? this.pages[0].length-1 : this.maxScrollY; + break; + case this.options.keyBindings.home: + newX = 0; + newY = 0; + break; + case this.options.keyBindings.left: + newX += snap ? -1 : 5 + this.keyAcceleration>>0; + break; + case this.options.keyBindings.up: + newY += snap ? 1 : 5 + this.keyAcceleration>>0; + break; + case this.options.keyBindings.right: + newX -= snap ? -1 : 5 + this.keyAcceleration>>0; + break; + case this.options.keyBindings.down: + newY -= snap ? 1 : 5 + this.keyAcceleration>>0; + break; + default: + return; + } - if ( snap ) { - this.goToPage(newX, newY); - return; - } + if ( snap ) { + this.goToPage(newX, newY); + return; + } - if ( newX > 0 ) { - newX = 0; - this.keyAcceleration = 0; - } else if ( newX < this.maxScrollX ) { - newX = this.maxScrollX; - this.keyAcceleration = 0; - } + if ( newX > 0 ) { + newX = 0; + this.keyAcceleration = 0; + } else if ( newX < this.maxScrollX ) { + newX = this.maxScrollX; + this.keyAcceleration = 0; + } - if ( newY > 0 ) { - newY = 0; - this.keyAcceleration = 0; - } else if ( newY < this.maxScrollY ) { - newY = this.maxScrollY; - this.keyAcceleration = 0; - } + if ( newY > 0 ) { + newY = 0; + this.keyAcceleration = 0; + } else if ( newY < this.maxScrollY ) { + newY = this.maxScrollY; + this.keyAcceleration = 0; + } - this.scrollTo(newX, newY, 0); + this.scrollTo(newX, newY, 0); - this.keyTime = now; - }, + this.keyTime = now; + }, - _animate: function (destX, destY, duration, easingFn) { - var that = this, - startX = this.x, - startY = this.y, - startTime = utils.getTime(), - destTime = startTime + duration; + _animate: function (destX, destY, duration, easingFn) { + var that = this, + startX = this.x, + startY = this.y, + startTime = utils.getTime(), + destTime = startTime + duration; - function step () { - var now = utils.getTime(), - newX, newY, - easing; + function step () { + var now = utils.getTime(), + newX, newY, + easing; - if ( now >= destTime ) { - that.isAnimating = false; - that._translate(destX, destY); + if ( now >= destTime ) { + that.isAnimating = false; + that._translate(destX, destY); - if ( !that.resetPosition(that.options.bounceTime) ) { - that._execEvent('scrollEnd'); - } + if ( !that.resetPosition(that.options.bounceTime) ) { + that._execEvent('scrollEnd'); + } - return; - } + return; + } - now = ( now - startTime ) / duration; - easing = easingFn(now); - newX = ( destX - startX ) * easing + startX; - newY = ( destY - startY ) * easing + startY; - that._translate(newX, newY); + now = ( now - startTime ) / duration; + easing = easingFn(now); + newX = ( destX - startX ) * easing + startX; + newY = ( destY - startY ) * easing + startY; + that._translate(newX, newY); - if ( that.isAnimating ) { - rAF(step); - } - } + if ( that.isAnimating ) { + rAF(step); + } + } - this.isAnimating = true; - step(); - }, - handleEvent: function (e) { - switch ( e.type ) { - case 'touchstart': - case 'pointerdown': - case 'MSPointerDown': - case 'mousedown': - this._start(e); - break; - case 'touchmove': - case 'pointermove': - case 'MSPointerMove': - case 'mousemove': - this._move(e); - break; - case 'touchend': - case 'pointerup': - case 'MSPointerUp': - case 'mouseup': - case 'touchcancel': - case 'pointercancel': - case 'MSPointerCancel': - case 'mousecancel': - this._end(e); - break; - case 'orientationchange': - case 'resize': - this._resize(); - break; - case 'transitionend': - case 'webkitTransitionEnd': - case 'oTransitionEnd': - case 'MSTransitionEnd': - this._transitionEnd(e); - break; - case 'wheel': - case 'DOMMouseScroll': - case 'mousewheel': - this._wheel(e); - break; - case 'keydown': - this._key(e); - break; - case 'click': - if ( !e._constructed ) { - e.preventDefault(); - e.stopPropagation(); - } - break; - } - } + this.isAnimating = true; + step(); + }, + handleEvent: function (e) { + switch ( e.type ) { + case 'touchstart': + case 'pointerdown': + case 'MSPointerDown': + case 'mousedown': + this._start(e); + break; + case 'touchmove': + case 'pointermove': + case 'MSPointerMove': + case 'mousemove': + this._move(e); + break; + case 'touchend': + case 'pointerup': + case 'MSPointerUp': + case 'mouseup': + case 'touchcancel': + case 'pointercancel': + case 'MSPointerCancel': + case 'mousecancel': + this._end(e); + break; + case 'orientationchange': + case 'resize': + this._resize(); + break; + case 'transitionend': + case 'webkitTransitionEnd': + case 'oTransitionEnd': + case 'MSTransitionEnd': + this._transitionEnd(e); + break; + case 'wheel': + case 'DOMMouseScroll': + case 'mousewheel': + this._wheel(e); + break; + case 'keydown': + this._key(e); + break; + case 'click': + if ( this.enabled && !e._constructed ) { + e.preventDefault(); + e.stopPropagation(); + } + break; + } + } }; function createDefaultScrollbar (direction, interactive, type) { - var scrollbar = document.createElement('div'), - indicator = document.createElement('div'); + var scrollbar = document.createElement('div'), + indicator = document.createElement('div'); - if ( type === true ) { - scrollbar.style.cssText = 'position:absolute;z-index:9999'; - indicator.style.cssText = '-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;position:absolute;background:rgba(0,0,0,0.5);border:1px solid rgba(255,255,255,0.9);border-radius:3px'; - } + if ( type === true ) { + scrollbar.style.cssText = 'position:absolute;z-index:9999'; + indicator.style.cssText = '-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;position:absolute;background:rgba(0,0,0,0.5);border:1px solid rgba(255,255,255,0.9);border-radius:3px'; + } - indicator.className = 'iScrollIndicator'; + indicator.className = 'iScrollIndicator'; - if ( direction == 'h' ) { - if ( type === true ) { - scrollbar.style.cssText += ';height:7px;left:2px;right:2px;bottom:0'; - indicator.style.height = '100%'; - } - scrollbar.className = 'iScrollHorizontalScrollbar'; - } else { - if ( type === true ) { - scrollbar.style.cssText += ';width:7px;bottom:2px;top:2px;right:1px'; - indicator.style.width = '100%'; - } - scrollbar.className = 'iScrollVerticalScrollbar'; - } + if ( direction == 'h' ) { + if ( type === true ) { + scrollbar.style.cssText += ';height:7px;left:2px;right:2px;bottom:0'; + indicator.style.height = '100%'; + } + scrollbar.className = 'iScrollHorizontalScrollbar'; + } else { + if ( type === true ) { + scrollbar.style.cssText += ';width:7px;bottom:2px;top:2px;right:1px'; + indicator.style.width = '100%'; + } + scrollbar.className = 'iScrollVerticalScrollbar'; + } - scrollbar.style.cssText += ';overflow:hidden'; + scrollbar.style.cssText += ';overflow:hidden'; - if ( !interactive ) { - scrollbar.style.pointerEvents = 'none'; - } + if ( !interactive ) { + scrollbar.style.pointerEvents = 'none'; + } - scrollbar.appendChild(indicator); + scrollbar.appendChild(indicator); - return scrollbar; + return scrollbar; } function Indicator (scroller, options) { - this.wrapper = typeof options.el == 'string' ? document.querySelector(options.el) : options.el; - this.wrapperStyle = this.wrapper.style; - this.indicator = this.wrapper.children[0]; - this.indicatorStyle = this.indicator.style; - this.scroller = scroller; + this.wrapper = typeof options.el == 'string' ? document.querySelector(options.el) : options.el; + this.wrapperStyle = this.wrapper.style; + this.indicator = this.wrapper.children[0]; + this.indicatorStyle = this.indicator.style; + this.scroller = scroller; - this.options = { - listenX: true, - listenY: true, - interactive: false, - resize: true, - defaultScrollbars: false, - shrink: false, - fade: false, - speedRatioX: 0, - speedRatioY: 0 - }; + this.options = { + listenX: true, + listenY: true, + interactive: false, + resize: true, + defaultScrollbars: false, + shrink: false, + fade: false, + speedRatioX: 0, + speedRatioY: 0 + }; - for ( var i in options ) { - this.options[i] = options[i]; - } + for ( var i in options ) { + this.options[i] = options[i]; + } - this.sizeRatioX = 1; - this.sizeRatioY = 1; - this.maxPosX = 0; - this.maxPosY = 0; + this.sizeRatioX = 1; + this.sizeRatioY = 1; + this.maxPosX = 0; + this.maxPosY = 0; - if ( this.options.interactive ) { - if ( !this.options.disableTouch ) { - utils.addEvent(this.indicator, 'touchstart', this); - utils.addEvent(window, 'touchend', this); - } - if ( !this.options.disablePointer ) { - utils.addEvent(this.indicator, utils.prefixPointerEvent('pointerdown'), this); - utils.addEvent(window, utils.prefixPointerEvent('pointerup'), this); - } - if ( !this.options.disableMouse ) { - utils.addEvent(this.indicator, 'mousedown', this); - utils.addEvent(window, 'mouseup', this); - } - } + if ( this.options.interactive ) { + if ( !this.options.disableTouch ) { + utils.addEvent(this.indicator, 'touchstart', this); + utils.addEvent(window, 'touchend', this); + } + if ( !this.options.disablePointer ) { + utils.addEvent(this.indicator, utils.prefixPointerEvent('pointerdown'), this); + utils.addEvent(window, utils.prefixPointerEvent('pointerup'), this); + } + if ( !this.options.disableMouse ) { + utils.addEvent(this.indicator, 'mousedown', this); + utils.addEvent(window, 'mouseup', this); + } + } - if ( this.options.fade ) { - this.wrapperStyle[utils.style.transform] = this.scroller.translateZ; - this.wrapperStyle[utils.style.transitionDuration] = utils.isBadAndroid ? '0.001s' : '0ms'; - this.wrapperStyle.opacity = '0'; - } + if ( this.options.fade ) { + this.wrapperStyle[utils.style.transform] = this.scroller.translateZ; + var durationProp = utils.style.transitionDuration; + if(!durationProp) { + return; + } + this.wrapperStyle[durationProp] = utils.isBadAndroid ? '0.0001ms' : '0ms'; + // remove 0.0001ms + var self = this; + if(utils.isBadAndroid) { + rAF(function() { + if(self.wrapperStyle[durationProp] === '0.0001ms') { + self.wrapperStyle[durationProp] = '0s'; + } + }); + } + this.wrapperStyle.opacity = '0'; + } } Indicator.prototype = { - handleEvent: function (e) { - switch ( e.type ) { - case 'touchstart': - case 'pointerdown': - case 'MSPointerDown': - case 'mousedown': - this._start(e); - break; - case 'touchmove': - case 'pointermove': - case 'MSPointerMove': - case 'mousemove': - this._move(e); - break; - case 'touchend': - case 'pointerup': - case 'MSPointerUp': - case 'mouseup': - case 'touchcancel': - case 'pointercancel': - case 'MSPointerCancel': - case 'mousecancel': - this._end(e); - break; - } - }, + handleEvent: function (e) { + switch ( e.type ) { + case 'touchstart': + case 'pointerdown': + case 'MSPointerDown': + case 'mousedown': + this._start(e); + break; + case 'touchmove': + case 'pointermove': + case 'MSPointerMove': + case 'mousemove': + this._move(e); + break; + case 'touchend': + case 'pointerup': + case 'MSPointerUp': + case 'mouseup': + case 'touchcancel': + case 'pointercancel': + case 'MSPointerCancel': + case 'mousecancel': + this._end(e); + break; + } + }, - destroy: function () { - if ( this.options.interactive ) { - utils.removeEvent(this.indicator, 'touchstart', this); - utils.removeEvent(this.indicator, utils.prefixPointerEvent('pointerdown'), this); - utils.removeEvent(this.indicator, 'mousedown', this); + destroy: function () { + if ( this.options.fadeScrollbars ) { + clearTimeout(this.fadeTimeout); + this.fadeTimeout = null; + } + if ( this.options.interactive ) { + utils.removeEvent(this.indicator, 'touchstart', this); + utils.removeEvent(this.indicator, utils.prefixPointerEvent('pointerdown'), this); + utils.removeEvent(this.indicator, 'mousedown', this); - utils.removeEvent(window, 'touchmove', this); - utils.removeEvent(window, utils.prefixPointerEvent('pointermove'), this); - utils.removeEvent(window, 'mousemove', this); + utils.removeEvent(window, 'touchmove', this); + utils.removeEvent(window, utils.prefixPointerEvent('pointermove'), this); + utils.removeEvent(window, 'mousemove', this); - utils.removeEvent(window, 'touchend', this); - utils.removeEvent(window, utils.prefixPointerEvent('pointerup'), this); - utils.removeEvent(window, 'mouseup', this); - } + utils.removeEvent(window, 'touchend', this); + utils.removeEvent(window, utils.prefixPointerEvent('pointerup'), this); + utils.removeEvent(window, 'mouseup', this); + } - if ( this.options.defaultScrollbars ) { - this.wrapper.parentNode.removeChild(this.wrapper); - } - }, + if ( this.options.defaultScrollbars && this.wrapper.parentNode ) { + this.wrapper.parentNode.removeChild(this.wrapper); + } + }, - _start: function (e) { - var point = e.touches ? e.touches[0] : e; + _start: function (e) { + var point = e.touches ? e.touches[0] : e; - e.preventDefault(); - e.stopPropagation(); + e.preventDefault(); + e.stopPropagation(); - this.transitionTime(); + this.transitionTime(); - this.initiated = true; - this.moved = false; - this.lastPointX = point.pageX; - this.lastPointY = point.pageY; + this.initiated = true; + this.moved = false; + this.lastPointX = point.pageX; + this.lastPointY = point.pageY; - this.startTime = utils.getTime(); + this.startTime = utils.getTime(); - if ( !this.options.disableTouch ) { - utils.addEvent(window, 'touchmove', this); - } - if ( !this.options.disablePointer ) { - utils.addEvent(window, utils.prefixPointerEvent('pointermove'), this); - } - if ( !this.options.disableMouse ) { - utils.addEvent(window, 'mousemove', this); - } + if ( !this.options.disableTouch ) { + utils.addEvent(window, 'touchmove', this); + } + if ( !this.options.disablePointer ) { + utils.addEvent(window, utils.prefixPointerEvent('pointermove'), this); + } + if ( !this.options.disableMouse ) { + utils.addEvent(window, 'mousemove', this); + } - this.scroller._execEvent('beforeScrollStart'); - }, + this.scroller._execEvent('beforeScrollStart'); + }, - _move: function (e) { - var point = e.touches ? e.touches[0] : e, - deltaX, deltaY, - newX, newY, - timestamp = utils.getTime(); + _move: function (e) { + var point = e.touches ? e.touches[0] : e, + deltaX, deltaY, + newX, newY, + timestamp = utils.getTime(); - if ( !this.moved ) { - this.scroller._execEvent('scrollStart'); - } + if ( !this.moved ) { + this.scroller._execEvent('scrollStart'); + } - this.moved = true; + this.moved = true; - deltaX = point.pageX - this.lastPointX; - this.lastPointX = point.pageX; + deltaX = point.pageX - this.lastPointX; + this.lastPointX = point.pageX; - deltaY = point.pageY - this.lastPointY; - this.lastPointY = point.pageY; + deltaY = point.pageY - this.lastPointY; + this.lastPointY = point.pageY; - newX = this.x + deltaX; - newY = this.y + deltaY; + newX = this.x + deltaX; + newY = this.y + deltaY; - this._pos(newX, newY); + this._pos(newX, newY); // INSERT POINT: indicator._move - e.preventDefault(); - e.stopPropagation(); - }, + e.preventDefault(); + e.stopPropagation(); + }, + + _end: function (e) { + if ( !this.initiated ) { + return; + } - _end: function (e) { - if ( !this.initiated ) { - return; - } + this.initiated = false; - this.initiated = false; + e.preventDefault(); + e.stopPropagation(); - e.preventDefault(); - e.stopPropagation(); + utils.removeEvent(window, 'touchmove', this); + utils.removeEvent(window, utils.prefixPointerEvent('pointermove'), this); + utils.removeEvent(window, 'mousemove', this); - utils.removeEvent(window, 'touchmove', this); - utils.removeEvent(window, utils.prefixPointerEvent('pointermove'), this); - utils.removeEvent(window, 'mousemove', this); + if ( this.scroller.options.snap ) { + var snap = this.scroller._nearestSnap(this.scroller.x, this.scroller.y); - if ( this.scroller.options.snap ) { - var snap = this.scroller._nearestSnap(this.scroller.x, this.scroller.y); + var time = this.options.snapSpeed || Math.max( + Math.max( + Math.min(Math.abs(this.scroller.x - snap.x), 1000), + Math.min(Math.abs(this.scroller.y - snap.y), 1000) + ), 300); - var time = this.options.snapSpeed || Math.max( - Math.max( - Math.min(Math.abs(this.scroller.x - snap.x), 1000), - Math.min(Math.abs(this.scroller.y - snap.y), 1000) - ), 300); + if ( this.scroller.x != snap.x || this.scroller.y != snap.y ) { + this.scroller.directionX = 0; + this.scroller.directionY = 0; + this.scroller.currentPage = snap; + this.scroller.scrollTo(snap.x, snap.y, time, this.scroller.options.bounceEasing); + } + } - if ( this.scroller.x != snap.x || this.scroller.y != snap.y ) { - this.scroller.directionX = 0; - this.scroller.directionY = 0; - this.scroller.currentPage = snap; - this.scroller.scrollTo(snap.x, snap.y, time, this.scroller.options.bounceEasing); - } - } + if ( this.moved ) { + this.scroller._execEvent('scrollEnd'); + } + }, - if ( this.moved ) { - this.scroller._execEvent('scrollEnd'); - } - }, + transitionTime: function (time) { + time = time || 0; + var durationProp = utils.style.transitionDuration; + if(!durationProp) { + return; + } - transitionTime: function (time) { - time = time || 0; - this.indicatorStyle[utils.style.transitionDuration] = time + 'ms'; + this.indicatorStyle[durationProp] = time + 'ms'; - if ( !time && utils.isBadAndroid ) { - this.indicatorStyle[utils.style.transitionDuration] = '0.001s'; - } - }, + if ( !time && utils.isBadAndroid ) { + this.indicatorStyle[durationProp] = '0.0001ms'; + // remove 0.0001ms + var self = this; + rAF(function() { + if(self.indicatorStyle[durationProp] === '0.0001ms') { + self.indicatorStyle[durationProp] = '0s'; + } + }); + } + }, - transitionTimingFunction: function (easing) { - this.indicatorStyle[utils.style.transitionTimingFunction] = easing; - }, + transitionTimingFunction: function (easing) { + this.indicatorStyle[utils.style.transitionTimingFunction] = easing; + }, - refresh: function () { - this.transitionTime(); + refresh: function () { + this.transitionTime(); - if ( this.options.listenX && !this.options.listenY ) { - this.indicatorStyle.display = this.scroller.hasHorizontalScroll ? 'block' : 'none'; - } else if ( this.options.listenY && !this.options.listenX ) { - this.indicatorStyle.display = this.scroller.hasVerticalScroll ? 'block' : 'none'; - } else { - this.indicatorStyle.display = this.scroller.hasHorizontalScroll || this.scroller.hasVerticalScroll ? 'block' : 'none'; - } + if ( this.options.listenX && !this.options.listenY ) { + this.indicatorStyle.display = this.scroller.hasHorizontalScroll ? 'block' : 'none'; + } else if ( this.options.listenY && !this.options.listenX ) { + this.indicatorStyle.display = this.scroller.hasVerticalScroll ? 'block' : 'none'; + } else { + this.indicatorStyle.display = this.scroller.hasHorizontalScroll || this.scroller.hasVerticalScroll ? 'block' : 'none'; + } - if ( this.scroller.hasHorizontalScroll && this.scroller.hasVerticalScroll ) { - utils.addClass(this.wrapper, 'iScrollBothScrollbars'); - utils.removeClass(this.wrapper, 'iScrollLoneScrollbar'); + if ( this.scroller.hasHorizontalScroll && this.scroller.hasVerticalScroll ) { + utils.addClass(this.wrapper, 'iScrollBothScrollbars'); + utils.removeClass(this.wrapper, 'iScrollLoneScrollbar'); - if ( this.options.defaultScrollbars && this.options.customStyle ) { - if ( this.options.listenX ) { - this.wrapper.style.right = '8px'; - } else { - this.wrapper.style.bottom = '8px'; - } - } - } else { - utils.removeClass(this.wrapper, 'iScrollBothScrollbars'); - utils.addClass(this.wrapper, 'iScrollLoneScrollbar'); + if ( this.options.defaultScrollbars && this.options.customStyle ) { + if ( this.options.listenX ) { + this.wrapper.style.right = '8px'; + } else { + this.wrapper.style.bottom = '8px'; + } + } + } else { + utils.removeClass(this.wrapper, 'iScrollBothScrollbars'); + utils.addClass(this.wrapper, 'iScrollLoneScrollbar'); - if ( this.options.defaultScrollbars && this.options.customStyle ) { - if ( this.options.listenX ) { - this.wrapper.style.right = '2px'; - } else { - this.wrapper.style.bottom = '2px'; - } - } - } + if ( this.options.defaultScrollbars && this.options.customStyle ) { + if ( this.options.listenX ) { + this.wrapper.style.right = '2px'; + } else { + this.wrapper.style.bottom = '2px'; + } + } + } - var r = this.wrapper.offsetHeight; // force refresh + utils.getRect(this.wrapper); // force refresh - if ( this.options.listenX ) { - this.wrapperWidth = this.wrapper.clientWidth; - if ( this.options.resize ) { - this.indicatorWidth = Math.max(Math.round(this.wrapperWidth * this.wrapperWidth / (this.scroller.scrollerWidth || this.wrapperWidth || 1)), 8); - this.indicatorStyle.width = this.indicatorWidth + 'px'; - } else { - this.indicatorWidth = this.indicator.clientWidth; - } + if ( this.options.listenX ) { + this.wrapperWidth = this.wrapper.clientWidth; + if ( this.options.resize ) { + this.indicatorWidth = Math.max(Math.round(this.wrapperWidth * this.wrapperWidth / (this.scroller.scrollerWidth || this.wrapperWidth || 1)), 8); + this.indicatorStyle.width = this.indicatorWidth + 'px'; + } else { + this.indicatorWidth = this.indicator.clientWidth; + } - this.maxPosX = this.wrapperWidth - this.indicatorWidth; + this.maxPosX = this.wrapperWidth - this.indicatorWidth; - if ( this.options.shrink == 'clip' ) { - this.minBoundaryX = -this.indicatorWidth + 8; - this.maxBoundaryX = this.wrapperWidth - 8; - } else { - this.minBoundaryX = 0; - this.maxBoundaryX = this.maxPosX; - } + if ( this.options.shrink == 'clip' ) { + this.minBoundaryX = -this.indicatorWidth + 8; + this.maxBoundaryX = this.wrapperWidth - 8; + } else { + this.minBoundaryX = 0; + this.maxBoundaryX = this.maxPosX; + } - this.sizeRatioX = this.options.speedRatioX || (this.scroller.maxScrollX && (this.maxPosX / this.scroller.maxScrollX)); - } + this.sizeRatioX = this.options.speedRatioX || (this.scroller.maxScrollX && (this.maxPosX / this.scroller.maxScrollX)); + } - if ( this.options.listenY ) { - this.wrapperHeight = this.wrapper.clientHeight; - if ( this.options.resize ) { - this.indicatorHeight = Math.max(Math.round(this.wrapperHeight * this.wrapperHeight / (this.scroller.scrollerHeight || this.wrapperHeight || 1)), 8); - this.indicatorStyle.height = this.indicatorHeight + 'px'; - } else { - this.indicatorHeight = this.indicator.clientHeight; - } + if ( this.options.listenY ) { + this.wrapperHeight = this.wrapper.clientHeight; + if ( this.options.resize ) { + this.indicatorHeight = Math.max(Math.round(this.wrapperHeight * this.wrapperHeight / (this.scroller.scrollerHeight || this.wrapperHeight || 1)), 8); + this.indicatorStyle.height = this.indicatorHeight + 'px'; + } else { + this.indicatorHeight = this.indicator.clientHeight; + } - this.maxPosY = this.wrapperHeight - this.indicatorHeight; + this.maxPosY = this.wrapperHeight - this.indicatorHeight; - if ( this.options.shrink == 'clip' ) { - this.minBoundaryY = -this.indicatorHeight + 8; - this.maxBoundaryY = this.wrapperHeight - 8; - } else { - this.minBoundaryY = 0; - this.maxBoundaryY = this.maxPosY; - } + if ( this.options.shrink == 'clip' ) { + this.minBoundaryY = -this.indicatorHeight + 8; + this.maxBoundaryY = this.wrapperHeight - 8; + } else { + this.minBoundaryY = 0; + this.maxBoundaryY = this.maxPosY; + } - this.maxPosY = this.wrapperHeight - this.indicatorHeight; - this.sizeRatioY = this.options.speedRatioY || (this.scroller.maxScrollY && (this.maxPosY / this.scroller.maxScrollY)); - } + this.maxPosY = this.wrapperHeight - this.indicatorHeight; + this.sizeRatioY = this.options.speedRatioY || (this.scroller.maxScrollY && (this.maxPosY / this.scroller.maxScrollY)); + } - this.updatePosition(); - }, + this.updatePosition(); + }, - updatePosition: function () { - var x = this.options.listenX && Math.round(this.sizeRatioX * this.scroller.x) || 0, - y = this.options.listenY && Math.round(this.sizeRatioY * this.scroller.y) || 0; + updatePosition: function () { + var x = this.options.listenX && Math.round(this.sizeRatioX * this.scroller.x) || 0, + y = this.options.listenY && Math.round(this.sizeRatioY * this.scroller.y) || 0; - if ( !this.options.ignoreBoundaries ) { - if ( x < this.minBoundaryX ) { - if ( this.options.shrink == 'scale' ) { - this.width = Math.max(this.indicatorWidth + x, 8); - this.indicatorStyle.width = this.width + 'px'; - } - x = this.minBoundaryX; - } else if ( x > this.maxBoundaryX ) { - if ( this.options.shrink == 'scale' ) { - this.width = Math.max(this.indicatorWidth - (x - this.maxPosX), 8); - this.indicatorStyle.width = this.width + 'px'; - x = this.maxPosX + this.indicatorWidth - this.width; - } else { - x = this.maxBoundaryX; - } - } else if ( this.options.shrink == 'scale' && this.width != this.indicatorWidth ) { - this.width = this.indicatorWidth; - this.indicatorStyle.width = this.width + 'px'; - } + if ( !this.options.ignoreBoundaries ) { + if ( x < this.minBoundaryX ) { + if ( this.options.shrink == 'scale' ) { + this.width = Math.max(this.indicatorWidth + x, 8); + this.indicatorStyle.width = this.width + 'px'; + } + x = this.minBoundaryX; + } else if ( x > this.maxBoundaryX ) { + if ( this.options.shrink == 'scale' ) { + this.width = Math.max(this.indicatorWidth - (x - this.maxPosX), 8); + this.indicatorStyle.width = this.width + 'px'; + x = this.maxPosX + this.indicatorWidth - this.width; + } else { + x = this.maxBoundaryX; + } + } else if ( this.options.shrink == 'scale' && this.width != this.indicatorWidth ) { + this.width = this.indicatorWidth; + this.indicatorStyle.width = this.width + 'px'; + } - if ( y < this.minBoundaryY ) { - if ( this.options.shrink == 'scale' ) { - this.height = Math.max(this.indicatorHeight + y * 3, 8); - this.indicatorStyle.height = this.height + 'px'; - } - y = this.minBoundaryY; - } else if ( y > this.maxBoundaryY ) { - if ( this.options.shrink == 'scale' ) { - this.height = Math.max(this.indicatorHeight - (y - this.maxPosY) * 3, 8); - this.indicatorStyle.height = this.height + 'px'; - y = this.maxPosY + this.indicatorHeight - this.height; - } else { - y = this.maxBoundaryY; - } - } else if ( this.options.shrink == 'scale' && this.height != this.indicatorHeight ) { - this.height = this.indicatorHeight; - this.indicatorStyle.height = this.height + 'px'; - } - } + if ( y < this.minBoundaryY ) { + if ( this.options.shrink == 'scale' ) { + this.height = Math.max(this.indicatorHeight + y * 3, 8); + this.indicatorStyle.height = this.height + 'px'; + } + y = this.minBoundaryY; + } else if ( y > this.maxBoundaryY ) { + if ( this.options.shrink == 'scale' ) { + this.height = Math.max(this.indicatorHeight - (y - this.maxPosY) * 3, 8); + this.indicatorStyle.height = this.height + 'px'; + y = this.maxPosY + this.indicatorHeight - this.height; + } else { + y = this.maxBoundaryY; + } + } else if ( this.options.shrink == 'scale' && this.height != this.indicatorHeight ) { + this.height = this.indicatorHeight; + this.indicatorStyle.height = this.height + 'px'; + } + } - this.x = x; - this.y = y; + this.x = x; + this.y = y; - if ( this.scroller.options.useTransform ) { - this.indicatorStyle[utils.style.transform] = 'translate(' + x + 'px,' + y + 'px)' + this.scroller.translateZ; - } else { - this.indicatorStyle.left = x + 'px'; - this.indicatorStyle.top = y + 'px'; - } - }, + if ( this.scroller.options.useTransform ) { + this.indicatorStyle[utils.style.transform] = 'translate(' + x + 'px,' + y + 'px)' + this.scroller.translateZ; + } else { + this.indicatorStyle.left = x + 'px'; + this.indicatorStyle.top = y + 'px'; + } + }, - _pos: function (x, y) { - if ( x < 0 ) { - x = 0; - } else if ( x > this.maxPosX ) { - x = this.maxPosX; - } + _pos: function (x, y) { + if ( x < 0 ) { + x = 0; + } else if ( x > this.maxPosX ) { + x = this.maxPosX; + } - if ( y < 0 ) { - y = 0; - } else if ( y > this.maxPosY ) { - y = this.maxPosY; - } + if ( y < 0 ) { + y = 0; + } else if ( y > this.maxPosY ) { + y = this.maxPosY; + } - x = this.options.listenX ? Math.round(x / this.sizeRatioX) : this.scroller.x; - y = this.options.listenY ? Math.round(y / this.sizeRatioY) : this.scroller.y; + x = this.options.listenX ? Math.round(x / this.sizeRatioX) : this.scroller.x; + y = this.options.listenY ? Math.round(y / this.sizeRatioY) : this.scroller.y; - this.scroller.scrollTo(x, y); - }, + this.scroller.scrollTo(x, y); + }, - fade: function (val, hold) { - if ( hold && !this.visible ) { - return; - } + fade: function (val, hold) { + if ( hold && !this.visible ) { + return; + } - clearTimeout(this.fadeTimeout); - this.fadeTimeout = null; + clearTimeout(this.fadeTimeout); + this.fadeTimeout = null; - var time = val ? 250 : 500, - delay = val ? 0 : 300; + var time = val ? 250 : 500, + delay = val ? 0 : 300; - val = val ? '1' : '0'; + val = val ? '1' : '0'; - this.wrapperStyle[utils.style.transitionDuration] = time + 'ms'; + this.wrapperStyle[utils.style.transitionDuration] = time + 'ms'; - this.fadeTimeout = setTimeout((function (val) { - this.wrapperStyle.opacity = val; - this.visible = +val; - }).bind(this, val), delay); - } + this.fadeTimeout = setTimeout((function (val) { + this.wrapperStyle.opacity = val; + this.visible = +val; + }).bind(this, val), delay); + } }; IScroll.utils = utils; if ( typeof module != 'undefined' && module.exports ) { - module.exports = IScroll; + module.exports = IScroll; +} else if ( typeof define == 'function' && define.amd ) { + define( function () { return IScroll; } ); } else { - window.IScroll = IScroll; + window.IScroll = IScroll; } })(window, document, Math);
\ No newline at end of file diff --git a/StoneIsland/platforms/ios/www/plugins/phonegap-plugin-mobile-accessibility/www/MobileAccessibilityNotifications.js b/StoneIsland/platforms/ios/www/plugins/phonegap-plugin-mobile-accessibility/www/MobileAccessibilityNotifications.js new file mode 100644 index 00000000..f5d0aaf7 --- /dev/null +++ b/StoneIsland/platforms/ios/www/plugins/phonegap-plugin-mobile-accessibility/www/MobileAccessibilityNotifications.js @@ -0,0 +1,53 @@ +cordova.define("phonegap-plugin-mobile-accessibility.MobileAccessibilityNotifications", function(require, exports, module) { +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * +*/ + +/** + * Mobile Accessibility Notification event constants + */ +module.exports = { + /* MobileAccessibility window events */ + SCREEN_READER_STATUS_CHANGED : "screenreaderstatuschanged", + CLOSED_CAPTIONING_STATUS_CHANGED : "closedcaptioningstatuschanged", + GUIDED_ACCESS_STATUS_CHANGED : "guidedaccessstatuschanged", + INVERT_COLORS_STATUS_CHANGED : "invertcolorsstatuschanged", + MONO_AUDIO_STATUS_CHANGED : "monoaudiostatuschanged", + REDUCE_MOTION_STATUS_CHANGED : "reducemotionstatuschanged", + TOUCH_EXPLORATION_STATUS_CHANGED : "touchexplorationstatechanged", + BOLD_TEXT_STATUS_CHANGED : "boldtextstatuschanged", + DARKER_SYSTEM_COLORS_STATUS_CHANGED : "darkersystemcolorsstatuschanged", + GRAYSCALE_STATUS_CHANGED : "grayscalestatuschanged", + REDUCE_TRANSPARENCY_STATUS_CHANGED : "reducetransparencystatuschanged", + SPEAK_SCREEN_STATUS_CHANGED : "speakscreenstatuschanged", + SPEAK_SELECTION_STATUS_CHANGED : "speakselectionstatuschanged", + SWITCH_CONTROL_STATUS_CHANGED : "switchcontrolstatuschanged", + + /* iOS specific UIAccessibilityNotifications */ + SCREEN_CHANGED : 1000, + LAYOUT_CHANGED : 1001, + ANNOUNCEMENT : 1008, + PAGE_SCROLLED : 1009, + + /* Windows specific high contrast event */ + HIGH_CONTRAST_CHANGED : "highcontrastchanged" +}; + +}); diff --git a/StoneIsland/platforms/ios/www/plugins/phonegap-plugin-mobile-accessibility/www/mobile-accessibility.js b/StoneIsland/platforms/ios/www/plugins/phonegap-plugin-mobile-accessibility/www/mobile-accessibility.js new file mode 100644 index 00000000..852b8d34 --- /dev/null +++ b/StoneIsland/platforms/ios/www/plugins/phonegap-plugin-mobile-accessibility/www/mobile-accessibility.js @@ -0,0 +1,502 @@ +cordova.define("phonegap-plugin-mobile-accessibility.mobile-accessibility", function(require, exports, module) { +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * +*/ + +var argscheck = require('cordova/argscheck'), + utils = require('cordova/utils'), + exec = require('cordova/exec'), + device = require('cordova-plugin-device.device'), + network = require('cordova-plugin-network-information.network'), + connection = require('cordova-plugin-network-information.Connection'), + MobileAccessibilityNotifications = require('phonegap-plugin-mobile-accessibility.MobileAccessibilityNotifications'); + +var MobileAccessibility = function() { + this._isBoldTextEnabled = false; + this._isClosedCaptioningEnabled = false; + this._isDarkerSystemColorsEnabled = false; + this._isGrayscaleEnabled = false; + this._isGuidedAccessEnabled = false; + this._isInvertColorsEnabled = false; + this._isMonoAudioEnabled = false; + this._isReduceMotionEnabled = false; + this._isReduceTransparencyEnabled = false; + this._isScreenReaderRunning = false; + this._isSpeakScreenEnabled = false; + this._isSpeakSelectionEnabled = false; + this._isSwitchControlRunning = false; + this._isTouchExplorationEnabled = false; + this._usePreferredTextZoom = false; + this._isHighContrastEnabled = false; + this._highContrastScheme = undefined; + + // Create new event handlers on the window (returns a channel instance) + this.channels = { + boldtextstatuschanged : cordova.addWindowEventHandler(MobileAccessibilityNotifications.BOLD_TEXT_STATUS_CHANGED), + closedcaptioningstatuschanged : cordova.addWindowEventHandler(MobileAccessibilityNotifications.CLOSED_CAPTIONING_STATUS_CHANGED), + darkersystemcolorsstatuschanged : cordova.addWindowEventHandler(MobileAccessibilityNotifications.DARKER_SYSTEM_COLORS_STATUS_CHANGED), + grayscalestatuschanged : cordova.addWindowEventHandler(MobileAccessibilityNotifications.GRAYSCALE_STATUS_CHANGED), + guidedaccessstatuschanged : cordova.addWindowEventHandler(MobileAccessibilityNotifications.GUIDED_ACCESS_STATUS_CHANGED), + invertcolorsstatuschanged : cordova.addWindowEventHandler(MobileAccessibilityNotifications.INVERT_COLORS_STATUS_CHANGED), + monoaudiostatuschanged : cordova.addWindowEventHandler(MobileAccessibilityNotifications.MONO_AUDIO_STATUS_CHANGED), + reducemotionstatuschanged : cordova.addWindowEventHandler(MobileAccessibilityNotifications.REDUCE_MOTION_STATUS_CHANGED), + reducetransparencystatuschanged : cordova.addWindowEventHandler(MobileAccessibilityNotifications.REDUCE_TRANSPARENCY_STATUS_CHANGED), + screenreaderstatuschanged : cordova.addWindowEventHandler(MobileAccessibilityNotifications.SCREEN_READER_STATUS_CHANGED), + speakscreenstatuschanged : cordova.addWindowEventHandler(MobileAccessibilityNotifications.SPEAK_SCREEN_STATUS_CHANGED), + speakselectionstatuschanged : cordova.addWindowEventHandler(MobileAccessibilityNotifications.SPEAK_SELECTION_STATUS_CHANGED), + switchcontrolstatuschanged : cordova.addWindowEventHandler(MobileAccessibilityNotifications.SWITCH_CONTROL_STATUS_CHANGED), + touchexplorationstatechanged : cordova.addWindowEventHandler(MobileAccessibilityNotifications.TOUCH_EXPLORATION_STATUS_CHANGED), + highcontrastchanged : cordova.addWindowEventHandler(MobileAccessibilityNotifications.HIGH_CONTRAST_CHANGED) + }; + for (var key in this.channels) { + this.channels[key].onHasSubscribersChange = MobileAccessibility.onHasSubscribersChange; + } +}; + +/** + * @private + * @ignore + */ +function handlers() { + return mobileAccessibility.channels.boldtextstatuschanged.numHandlers + + mobileAccessibility.channels.closedcaptioningstatuschanged.numHandlers + + mobileAccessibility.channels.darkersystemcolorsstatuschanged.numHandlers + + mobileAccessibility.channels.grayscalestatuschanged.numHandlers + + mobileAccessibility.channels.guidedaccessstatuschanged.numHandlers + + mobileAccessibility.channels.invertcolorsstatuschanged.numHandlers + + mobileAccessibility.channels.monoaudiostatuschanged.numHandlers + + mobileAccessibility.channels.reducemotionstatuschanged.numHandlers + + mobileAccessibility.channels.reducetransparencystatuschanged.numHandlers + + mobileAccessibility.channels.screenreaderstatuschanged.numHandlers + + mobileAccessibility.channels.speakscreenstatuschanged.numHandlers + + mobileAccessibility.channels.speakselectionstatuschanged.numHandlers + + mobileAccessibility.channels.switchcontrolstatuschanged.numHandlers + + mobileAccessibility.channels.touchexplorationstatechanged.numHandlers + + mobileAccessibility.channels.highcontrastchanged.numHandlers; +}; + +/** + * + * Event handlers for when callback methods get registered for mobileAccessibility. + * Keep track of how many handlers we have so we can start and stop the native MobileAccessibility listener + * appropriately. + * @private + * @ignore + */ +MobileAccessibility.onHasSubscribersChange = function() { + // If we just registered the first handler, make sure native listener is started. + if (this.numHandlers === 1 && handlers() === 1) { + exec(mobileAccessibility._status, mobileAccessibility._error, "MobileAccessibility", "start", []); + } else if (handlers() === 0) { + exec(null, null, "MobileAccessibility", "stop", []); + } +}; + +/** + * Asynchronous call to native MobileAccessibility determine if a screen reader is running. + * @param {function} callback A callback method to receive the asynchronous result from the native MobileAccessibility. + */ +MobileAccessibility.prototype.isScreenReaderRunning = function(callback) { + exec(function(bool) { + mobileAccessibility.activateOrDeactivateChromeVox(bool); + callback(Boolean(bool)); + }, null, "MobileAccessibility", "isScreenReaderRunning", []); +}; +MobileAccessibility.prototype.isVoiceOverRunning = function(callback) { + if (device.platform.toLowerCase() === "ios") { + MobileAccessibility.prototype.isScreenReaderRunning(callback); + } else { + callback(false); + } +}; +MobileAccessibility.prototype.isTalkBackRunning = function(callback) { + if (device.platform.toLowerCase() === "android" || device.platform.toLowerCase() === "amazon-fireos") { + MobileAccessibility.prototype.isScreenReaderRunning(callback); + } else { + callback(false); + } +}; +MobileAccessibility.prototype.isChromeVoxActive = function () { + return typeof cvox !== "undefined" && cvox.ChromeVox.host.ttsLoaded() && cvox.Api.isChromeVoxActive(); +}; +MobileAccessibility.prototype.activateOrDeactivateChromeVox = function(bool) { + if (device.platform !== "Android") return; + if (typeof cvox === "undefined") { + if (bool) { + console.warn('A screen reader is running but ChromeVox has failed to initialize.'); + if (navigator.connection.type === Connection.UNKNOWN || navigator.connection.type === Connection.NONE) { + mobileAccessibility.injectLocalAndroidVoxScript(); + } + } + } else { + // activate or deactivate ChromeVox based on whether or not or not the screen reader is running. + try { + cvox.ChromeVox.host.activateOrDeactivateChromeVox(bool); + } catch (err) { + console.error(err); + } + } + + if (bool) { + if (!mobileAccessibility.hasOrientationChangeListener) { + window.addEventListener("orientationchange", mobileAccessibility.onOrientationChange); + mobileAccessibility.hasOrientationChangeListener = true; + } + } else if(mobileAccessibility.hasOrientationChangeListener) { + window.removeEventListener("orientationchange", mobileAccessibility.onOrientationChange); + mobileAccessibility.hasOrientationChangeListener = false; + } +}; + +MobileAccessibility.prototype.hasOrientationChangeListener = false; +MobileAccessibility.prototype.onOrientationChange = function(event) { + if (!mobileAccessibility.isChromeVoxActive()) return; + cvox.ChromeVox.navigationManager.updateIndicator(); +}; + +MobileAccessibility.prototype.scriptInjected = false; +MobileAccessibility.prototype.injectLocalAndroidVoxScript = function() { + var versionsplit = device.version.split('.'); + if (device.platform !== "Android" || + !(versionsplit[0] > 4 || (versionsplit[0] == 4 && versionsplit[1] >= 1)) || + typeof cvox !== "undefined" || mobileAccessibility.scriptInjected) return; + var script = document.createElement('script'); + script.type = 'text/javascript'; + script.async = true; + script.onload = function(){ + // console.log(this.src + ' has loaded'); + if (mobileAccessibility.isChromeVoxActive()) { + cordova.fireWindowEvent("screenreaderstatuschanged", { + isScreenReaderRunning: true + }); + } + }; + + script.src = (versionsplit[0] > 4 || versionsplit[1] > 3) + ? "plugins/com.phonegap.plugin.mobile-accessibility/android/chromeandroidvox.js" + : "plugins/com.phonegap.plugin.mobile-accessibility/android/AndroidVox_v1.js"; + document.getElementsByTagName('head')[0].appendChild(script); + mobileAccessibility.scriptInjected = true; +}; + +/** + * Asynchronous call to native MobileAccessibility to determine if Bold Text is enabled. + * @param {function} callback A callback method to receive the asynchronous result from the native MobileAccessibility. + */ +MobileAccessibility.prototype.isBoldTextEnabled = function(callback) { + exec(callback, null, "MobileAccessibility", "isBoldTextEnabled", []); +}; + +/** + * Asynchronous call to native MobileAccessibility to determine if Closed Captioning is enabled. + * @param {function} callback A callback method to receive the asynchronous result from the native MobileAccessibility. + */ +MobileAccessibility.prototype.isClosedCaptioningEnabled = function(callback) { + exec(callback, null, "MobileAccessibility", "isClosedCaptioningEnabled", []); +}; + +/** + * Asynchronous call to native MobileAccessibility to determine if Darker System Colors are enabled. + * @param {function} callback A callback method to receive the asynchronous result from the native MobileAccessibility. + */ +MobileAccessibility.prototype.isDarkerSystemColorsEnabled = function(callback) { + exec(callback, null, "MobileAccessibility", "isDarkerSystemColorsEnabled", []); +}; + +/** + * Asynchronous call to native MobileAccessibility to determine if Grayscale is enabled. + * @param {function} callback A callback method to receive the asynchronous result from the native MobileAccessibility. + */ +MobileAccessibility.prototype.isGrayscaleEnabled = function(callback) { + exec(callback, null, "MobileAccessibility", "isGrayscaleEnabled", []); +}; + +/** + * Asynchronous call to native MobileAccessibility to determine if Guided Access is enabled. + * @param {function} callback A callback method to receive the asynchronous result from the native MobileAccessibility. + */ +MobileAccessibility.prototype.isGuidedAccessEnabled = function(callback) { + exec(callback, null, "MobileAccessibility", "isGuidedAccessEnabled", []); +}; + +/** + * Asynchronous call to native MobileAccessibility to determine if the display colors have been inverted. + * @param {function} callback A callback method to receive the asynchronous result from the native MobileAccessibility. + */ +MobileAccessibility.prototype.isInvertColorsEnabled = function(callback) { + exec(callback, null, "MobileAccessibility", "isInvertColorsEnabled", []); +}; + +/** + * Asynchronous call to native MobileAccessibility to determine if Mono Audio is enabled. + * @param {function} callback A callback method to receive the asynchronous result from the native MobileAccessibility. + */ +MobileAccessibility.prototype.isMonoAudioEnabled = function(callback) { + exec(callback, null, "MobileAccessibility", "isMonoAudioEnabled", []); +}; + +/** + * Asynchronous call to native MobileAccessibility to determine if Reduce Motion is enabled. + * @param {function} callback A callback method to receive the asynchronous result from the native MobileAccessibility. + */ +MobileAccessibility.prototype.isReduceMotionEnabled = function(callback) { + exec(callback, null, "MobileAccessibility", "isReduceMotionEnabled", []); +}; + +/** + * Asynchronous call to native MobileAccessibility to determine if Reduce Transparency is enabled. + * @param {function} callback A callback method to receive the asynchronous result from the native MobileAccessibility. + */ +MobileAccessibility.prototype.isReduceTransparencyEnabled = function(callback) { + exec(callback, null, "MobileAccessibility", "isReduceTransparencyEnabled", []); +}; + +/** + * Asynchronous call to native MobileAccessibility to determine if Speak Screen is enabled. + * @param {function} callback A callback method to receive the asynchronous result from the native MobileAccessibility. + */ +MobileAccessibility.prototype.isSpeakScreenEnabled = function(callback) { + exec(callback, null, "MobileAccessibility", "isSpeakScreenEnabled", []); +}; + +/** + * Asynchronous call to native MobileAccessibility to determine if Speak Selection is enabled. + * @param {function} callback A callback method to receive the asynchronous result from the native MobileAccessibility. + */ +MobileAccessibility.prototype.isSpeakSelectionEnabled = function(callback) { + exec(callback, null, "MobileAccessibility", "isSpeakSelectionEnabled", []); +}; + +/** + * Asynchronous call to native MobileAccessibility to determine if Switch Control is running. + * @param {function} callback A callback method to receive the asynchronous result from the native MobileAccessibility. + */ +MobileAccessibility.prototype.isSwitchControlRunning = function(callback) { + exec(callback, null, "MobileAccessibility", "isSwitchControlRunning", []); +}; + +/** + * Asynchronous call to native MobileAccessibility to determine if Touch Exploration is enabled on Android. + * @param {function} callback A callback method to receive the asynchronous result from the native MobileAccessibility. + */ +MobileAccessibility.prototype.isTouchExplorationEnabled = function(callback) { + exec(callback, null, "MobileAccessibility", "isTouchExplorationEnabled", []); +}; + +/** + * Asynchronous call to native MobileAccessibility to determine if High Contrast is enabled on Windows. + * @param {function} callback A callback method to receive the asynchronous result from the native MobileAccessibility. + */ +MobileAccessibility.prototype.isHighContrastEnabled = function(callback) { + exec(callback, null, "MobileAccessibility", "isHighContrastEnabled", []); +}; + +/** + * Asynchronous call to native MobileAccessibility to return the current text zoom percent value for the WebView. + * @param {function} callback A callback method to receive the asynchronous result from the native MobileAccessibility. + */ +MobileAccessibility.prototype.getTextZoom = function(callback) { + exec(callback, null, "MobileAccessibility", "getTextZoom", []); +}; + +/** + * Asynchronous call to native MobileAccessibility to set the current text zoom percent value for the WebView. + * @param {Number} textZoom A percentage value by which text in the WebView should be scaled. + * @param {function} callback A callback method to receive the asynchronous result from the native MobileAccessibility. + */ +MobileAccessibility.prototype.setTextZoom = function(textZoom, callback) { + exec(callback, null, "MobileAccessibility", "setTextZoom", [textZoom]); +}; + +/** + * Asynchronous call to native MobileAccessibility to retrieve the user's preferred text zoom from system settings and apply it to the application WebView. + * @param {function} callback A callback method to receive the asynchronous result from the native MobileAccessibility. + */ +MobileAccessibility.prototype.updateTextZoom = function(callback) { + exec(callback, null, "MobileAccessibility", "updateTextZoom", []); +}; + +MobileAccessibility.prototype.usePreferredTextZoom = function(bool) { + var currentValue = window.localStorage.getItem("MobileAccessibility.usePreferredTextZoom") === "true"; + + if (arguments.length === 0) { + return currentValue; + } + + if (currentValue != bool) { + window.localStorage.setItem("MobileAccessibility.usePreferredTextZoom", bool); + } + + var callback = function(){ + // Wrapping updateTextZoom call in a function to stop + // the event parameter propagation. This fixes an error + // on resume where cordova tried to call apply() on the + // event, expecting a function. + mobileAccessibility.updateTextZoom(); + }; + + document.removeEventListener("resume", callback); + + if (bool) { + // console.log("We should update the text zoom at this point: " + bool) + document.addEventListener("resume", callback, false); + mobileAccessibility.updateTextZoom(); + } else { + mobileAccessibility.setTextZoom(100); + } + + return Boolean(bool); +}; + +MobileAccessibility.prototype.MobileAccessibilityNotifications = MobileAccessibilityNotifications; + +/** + * Posts a notification with a string for a screen reader to announce, if it is running. + * @param {uint} mobileAccessibilityNotification A numeric constant for the type of notification to send. Constants are defined in MobileAccessibility.MobileAccessibilityNotifications. + * @param {string} string A string to be announced by a screen reader. + * @param {function} callback A callback method to receive the asynchronous result from the native MobileAccessibility, when the announcement is finished, the function should expect an object containing the stringValue that was voiced and a boolean indicating that the announcement wasSuccessful. + */ +MobileAccessibility.prototype.postNotification = function(mobileAccessibilityNotification, string, callback) { + exec(callback, null, "MobileAccessibility", "postNotification", [mobileAccessibilityNotification, string]); +}; + +/** + * Speaks the given string, and if ChromeVox is active, it will use the specified queueMode and properties. + * @param {string} string A string to be announced by a screen reader. + * @param {number} [queueMode] Optional number. Valid modes are 0 for flush; 1 for queue. + * @param {Object} [properties] Speech properties to use for this utterance. + */ +MobileAccessibility.prototype.speak = function(string, queueMode, properties) { + if (this.isChromeVoxActive()) { + cvox.ChromeVox.tts.speak(string, queueMode, properties); + } else { + exec(null, null, "MobileAccessibility", "postNotification", [MobileAccessibilityNotifications.ANNOUNCEMENT, string]); + } +} + +/** + * Stops speech. + */ +MobileAccessibility.prototype.stop = function() { + if (this.isChromeVoxActive()) { + cvox.ChromeVox.tts.stop(); + } else { + exec(null, null, "MobileAccessibility", "postNotification", [MobileAccessibilityNotifications.ANNOUNCEMENT, "\u200b"]); + } +} + +/** + * Callback from native MobileAccessibility returning an object which describes the status of MobileAccessibility features. + * + * @param {Object} info + * @config {Boolean} [isBoldTextEnabled] Boolean to indicate bold text status (ios). + * @config {Boolean} [isClosedCaptioningEnabled] Boolean to indicate closed captioning status. + * @config {Boolean} [isDarkerSystemColorsEnabled] Boolean to indicate darker system colors status (ios). + * @config {Boolean} [isGrayscaleEnabled] Boolean to indicate grayscale status (ios). + * @config {Boolean} [isGuidedAccessEnabled] Boolean to indicate guided access status (ios). + * @config {Boolean} [isInvertColorsEnabled] Boolean to indicate invert colors status (ios). + * @config {Boolean} [isMonoAudioEnabled] Boolean to indicate mono audio status (ios). + * @config {Boolean} [isReduceMotionEnabled] Boolean to indicate reduce motion status (ios). + * @config {Boolean} [isReduceTransparencyEnabled] Boolean to indicate reduce transparency status (ios). + * @config {Boolean} [isScreenReaderRunning] Boolean to indicate screen reader status. + * @config {Boolean} [isSpeakScreenEnabled] Boolean to indicate speak screen status (ios). + * @config {Boolean} [isSpeakSelectionEnabled] Boolean to indicate speak selection status (ios). + * @config {Boolean} [isSwitchControlRunning] Boolean to indicate switch control status (ios). + * @config {Boolean} [isTouchExplorationEnabled] Boolean to indicate touch exploration status (android). + */ +MobileAccessibility.prototype._status = function(info) { + if (info) { + mobileAccessibility.activateOrDeactivateChromeVox(info.isScreenReaderRunning); + if (mobileAccessibility._isBoldTextEnabled !== info.isBoldTextEnabled) { + mobileAccessibility._isBoldTextEnabled = info.isBoldTextEnabled; + cordova.fireWindowEvent(MobileAccessibilityNotifications.BOLD_TEXT_STATUS_CHANGED, info); + } + if (mobileAccessibility._isClosedCaptioningEnabled !== info.isClosedCaptioningEnabled) { + mobileAccessibility._isClosedCaptioningEnabled = info.isClosedCaptioningEnabled; + cordova.fireWindowEvent(MobileAccessibilityNotifications.CLOSED_CAPTIONING_STATUS_CHANGED, info); + } + if (mobileAccessibility._isDarkerSystemColorsEnabled !== info.isDarkerSystemColorsEnabled) { + mobileAccessibility._isDarkerSystemColorsEnabled = info.isDarkerSystemColorsEnabled; + cordova.fireWindowEvent(MobileAccessibilityNotifications.DARKER_SYSTEM_COLORS_STATUS_CHANGED, info); + } + if (mobileAccessibility._isGrayscaleEnabled !== info.isGrayscaleEnabled) { + mobileAccessibility._isGrayscaleEnabled = info.isGrayscaleEnabled; + cordova.fireWindowEvent(MobileAccessibilityNotifications.GRAYSCALE_STATUS_CHANGED, info); + } + if (mobileAccessibility._isGuidedAccessEnabled !== info.isGuidedAccessEnabled) { + mobileAccessibility._isGuidedAccessEnabled = info.isGuidedAccessEnabled; + cordova.fireWindowEvent(MobileAccessibilityNotifications.GUIDED_ACCESS_STATUS_CHANGED, info); + } + if (mobileAccessibility._isInvertColorsEnabled !== info.isInvertColorsEnabled) { + mobileAccessibility._isInvertColorsEnabled = info.isInvertColorsEnabled; + cordova.fireWindowEvent(MobileAccessibilityNotifications.INVERT_COLORS_STATUS_CHANGED, info); + } + if (mobileAccessibility._isMonoAudioEnabled !== info.isMonoAudioEnabled) { + mobileAccessibility._isMonoAudioEnabled = info.isMonoAudioEnabled; + cordova.fireWindowEvent(MobileAccessibilityNotifications.MONO_AUDIO_STATUS_CHANGED, info); + } + if (mobileAccessibility._isReduceMotionEnabled !== info.isReduceMotionEnabled) { + mobileAccessibility._isReduceMotionEnabled = info.isReduceMotionEnabled; + cordova.fireWindowEvent(MobileAccessibilityNotifications.REDUCE_MOTION_STATUS_CHANGED, info); + } + if (mobileAccessibility._isReduceTransparencyEnabled !== info.isReduceTransparencyEnabled) { + mobileAccessibility._isReduceTransparencyEnabled = info.isReduceTransparencyEnabled; + cordova.fireWindowEvent(MobileAccessibilityNotifications.REDUCE_TRANSPARENCY_STATUS_CHANGED, info); + } + if (mobileAccessibility._isScreenReaderRunning !== info.isScreenReaderRunning) { + mobileAccessibility._isScreenReaderRunning = info.isScreenReaderRunning; + cordova.fireWindowEvent(MobileAccessibilityNotifications.SCREEN_READER_STATUS_CHANGED, info); + } + if (mobileAccessibility._isSpeakScreenEnabled !== info.isSpeakScreenEnabled) { + mobileAccessibility._isSpeakScreenEnabled = info.isSpeakScreenEnabled; + cordova.fireWindowEvent(MobileAccessibilityNotifications.SPEAK_SCREEN_STATUS_CHANGED, info); + } + if (mobileAccessibility._isSpeakSelectionEnabled !== info.isSpeakSelectionEnabled) { + mobileAccessibility._isSpeakSelectionEnabled = info.isSpeakSelectionEnabled; + cordova.fireWindowEvent(MobileAccessibilityNotifications.SPEAK_SELECTION_STATUS_CHANGED, info); + } + if (mobileAccessibility._isSwitchControlRunning !== info.isSwitchControlRunning) { + mobileAccessibility._isSwitchControlRunning = info.isSwitchControlRunning; + cordova.fireWindowEvent(MobileAccessibilityNotifications.SWITCH_CONTROL_STATUS_CHANGED, info); + } + if (mobileAccessibility._isTouchExplorationEnabled !== info.isTouchExplorationEnabled) { + mobileAccessibility._isTouchExplorationEnabled = info.isTouchExplorationEnabled; + cordova.fireWindowEvent(MobileAccessibilityNotifications.TOUCH_EXPLORATION_STATUS_CHANGED, info); + } + if (mobileAccessibility._isHighContrastEnabled !== info.isHighContrastEnabled) { + mobileAccessibility._isHighContrastEnabled = info.isHighContrastEnabled; + mobileAccessibility._highContrastScheme = info.highContrastScheme; + cordova.fireWindowEvent(MobileAccessibilityNotifications.HIGH_CONTRAST_CHANGED, info); + } + } +}; + +/** + * Error callback for MobileAccessibility start + */ +MobileAccessibility.prototype._error = function(e) { + console.log("Error initializing MobileAccessibility: " + e); +}; + +var mobileAccessibility = new MobileAccessibility(); + +module.exports = mobileAccessibility; + +}); |
