-
-
Save raido/d1d0ace0204c365103c6 to your computer and use it in GitHub Desktop.
Ember Snippets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Service.extend({ | |
isPrivate: Ember.computed(() => { | |
let nativeStorage; | |
try { | |
nativeStorage = localStorage || sessionStorage; | |
nativeStorage.setItem('emberlocalstorage.demo', true); | |
nativeStorage.removeItem('emberlocalstorage.demo'); | |
} catch (e) { | |
nativeStorage = false; | |
} | |
return nativeStorage ? true : false; | |
}), | |
isAndroid: Ember.computed(() => { | |
return !!navigator.userAgent.match(/Android/i); | |
}), | |
isIOS: Ember.computed(() => { | |
return !!navigator.userAgent.match(/iPhone|iPad|iPod/i); | |
}), | |
isWindows: Ember.computed(() => { | |
return !!navigator.userAgent.match(/IEMobile/i) || navigator.userAgent.match(/WPDesktop/i); | |
}), | |
isMobile: Ember.computed.or('isAndroid', 'isIOS', 'isWindows') | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment