change all paths to use ionic2/

This commit is contained in:
Andrew
2015-03-27 11:52:33 -06:00
parent 53e0f865ba
commit 18d82fb50d
34 changed files with 64 additions and 182 deletions

0
src/platform/detect.js Normal file
View File

61
src/platform/platform.js Normal file
View File

@ -0,0 +1,61 @@
import * as util from 'ionic2/util';
class Platform {
constructor(options) {
util.extend(this, options);
}
}
class PlatformController {
current: Platform;
constructor() {
this.registry = [];
}
set(platform) {
this.current = platform;
}
get() {
return this.current;
}
register(platform) {
if (!platform instanceof Platform) {
platform = new Platform(platform);
}
this.registry.push(platform);
}
isRegistered(platformName) {
return this.registry.some(platform => {
return platform.name === platformName;
});
}
detect() {
for (let platform of this.registry) {
if (platform.matcher()) {
return platform;
}
}
}
}
export let platform = new PlatformController();
// TODO(ajoslin): move this to a facade somewhere else?
var ua = window.navigator.userAgent;
// TODO(ajoslin): move these to their own files
platform.register({
name: 'android',
matcher() {
return /android/i.test(ua);
}
});
platform.register({
name: 'ios',
// For now always default to ios
matcher() {
return true;
}
});
platform.set( platform.detect() );