diff options
Diffstat (limited to 'StoneIsland/platforms/ios/www/js/lib/etc')
| -rw-r--r-- | StoneIsland/platforms/ios/www/js/lib/etc/accessibility.js | 80 | ||||
| -rwxr-xr-x | StoneIsland/platforms/ios/www/js/lib/etc/push.js | 6 | ||||
| -rw-r--r-- | StoneIsland/platforms/ios/www/js/lib/etc/scroll.js | 29 |
3 files changed, 107 insertions, 8 deletions
diff --git a/StoneIsland/platforms/ios/www/js/lib/etc/accessibility.js b/StoneIsland/platforms/ios/www/js/lib/etc/accessibility.js index 614c3796..3cbda2a0 100644 --- a/StoneIsland/platforms/ios/www/js/lib/etc/accessibility.js +++ b/StoneIsland/platforms/ios/www/js/lib/etc/accessibility.js @@ -1,9 +1,75 @@ -$(function(){ - $("h1").each(function(){ - this['aria-label'] = 'Section title is ' + this.innerText - }) -}) +var accessibility = (function() { + + var accessibility = {} + accessibility.voiceOver = false + + accessibility.DEBUG = true + + accessibility.init = function(ready) { + console.log('Accessibility init') + accessibility.bind() + if (accessibility.DEBUG) { + console.log('Accessibility debug mode') + app.accessible = true + accessibility.voiceOver = true + $('html').addClass('vscroll') + $('html').addClass('accessible') + return ready() + } + if ('MobileAccessibility' in window) { + accessibility.build(ready) + } else { + ready() + } + } + + accessibility.build = function(ready) { + 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') + } + }); + MobileAccessibility.isVoiceOverRunning(function(state){ + console.log('Screen reader: ' + state) + accessibility.voiceOver = state + if (state) { + console.log(">>>>>> actual debug mode!") + app.accessible = true + $("html").addClass('accessible') + $('html').addClass('vscroll') + } else { + $('html').addClass('iscroll') + } + ready() + }) + } + + accessibility.bind = function() { + $("h1").each(function(){ + this['aria-label'] = 'Section title is ' + this.innerText + }) + if ('MobileAccessibilityNotifications' in window) { + window.addEventListener(MobileAccessibilityNotifications.SCREEN_READER_STATUS_CHANGED, + accessibility.onScreenReaderStatusChanged, false) + } + } + + accessibility.onScreenReaderStatusChanged = function(info) { + if (info && typeof info.isScreenReaderRunning !== "undefined") { + if (info.isScreenReaderRunning) { + console.log("Screen reader: ON"); + } else { + console.log("Screen reader: OFF"); + } + } + } + + return accessibility +})() function stonewash (s) { - return s.replace(/'0/g, '20').replace(/_/g, ' ') -}
\ No newline at end of file + return s.replace(/'9/g, '19').replace(/'0/g, '20').replace(/_/g, ' ').replace(/-/g, ' - ').replace(/^[013456789][0-9]+/, '') +} diff --git a/StoneIsland/platforms/ios/www/js/lib/etc/push.js b/StoneIsland/platforms/ios/www/js/lib/etc/push.js index 746172eb..74aaf7b5 100755 --- a/StoneIsland/platforms/ios/www/js/lib/etc/push.js +++ b/StoneIsland/platforms/ios/www/js/lib/etc/push.js @@ -37,6 +37,10 @@ var push = (function(){ push.settings.hub = hub_status == "true" push.settings.store = store_status == "true" + if (push.settings.requested) { + return + } + // not sure why we're also signing up for notifications here?? if (! hub_status || hub_status == "true") { push.subscribe("hub") } @@ -46,7 +50,7 @@ var push = (function(){ } push.got_registration = function(data){ var registrationId = data.registrationId - var oldRegistrationId = localStorage.getItem("yoox.registrationId") + var oldRegistrationId = localStorage.getItem("yoox.registrationId") // console.log(registrationId, oldRegistrationId) if (registrationId !== oldRegistrationId || ! push.settings.requested) { diff --git a/StoneIsland/platforms/ios/www/js/lib/etc/scroll.js b/StoneIsland/platforms/ios/www/js/lib/etc/scroll.js new file mode 100644 index 00000000..253921e1 --- /dev/null +++ b/StoneIsland/platforms/ios/www/js/lib/etc/scroll.js @@ -0,0 +1,29 @@ +// stub for native scroller when in voiceover mode +function NativeScroll(el) { + var Scroller = { + x: 0, + y: 0, + $el: $(el), + } + + Scroller.refresh = function(){} + Scroller.on = function(){} + Scroller.off = function(){} + + Scroller.scrollTo = function(x, y) { + Scroller.$el.scrollTop(y) + } + Scroller.scrollToElement = function(selector) { + var y = $(selector).offset().top + Scroller.$el.scrollTop(y) + } + + return Scroller +} + +function ScrollFactory (el, opt) { + if (accessibility.voiceOver) { + return NativeScroll(el) + } + return new IScroll(el, opt) +} |
