mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
readyCallbacks array and platform() method to get name
This commit is contained in:
2
dist/js/ionic-angular.min.js
vendored
2
dist/js/ionic-angular.min.js
vendored
File diff suppressed because one or more lines are too long
20
dist/js/ionic.js
vendored
20
dist/js/ionic.js
vendored
@@ -1817,16 +1817,15 @@ window.ionic = {
|
||||
return navigator.userAgent.toLowerCase().indexOf('ipad') >= 0;
|
||||
},
|
||||
isIOS7: function() {
|
||||
return this.platformName == 'iOS' && parseFloat(window.device.version) >= 7.0;
|
||||
return this.platform() == 'ios' && this.version() >= 7.0;
|
||||
},
|
||||
isAndroid: function() {
|
||||
return this.platformName === "Android";
|
||||
return this.platform() === "android";
|
||||
},
|
||||
|
||||
platform: function() {
|
||||
if(!platformName) {
|
||||
this.setPlatform(this.device().platform);
|
||||
}
|
||||
// singleton to get the platform name
|
||||
if(!platformName) this.setPlatform(this.device().platform);
|
||||
return platformName;
|
||||
},
|
||||
|
||||
@@ -1834,6 +1833,16 @@ window.ionic = {
|
||||
if(name) platformName = name.toLowerCase();
|
||||
},
|
||||
|
||||
version: function() {
|
||||
// singleton to get the platform version
|
||||
if(!platformVersion) this.setVersion(this.device().version);
|
||||
return platformVersion;
|
||||
},
|
||||
|
||||
setVersion: function(v) {
|
||||
if( !isNaN(v) ) version = parseFloat(v);
|
||||
},
|
||||
|
||||
// Check if the platform is the one detected by cordova
|
||||
is: function(type) {
|
||||
var pName = this.platform();
|
||||
@@ -1884,6 +1893,7 @@ window.ionic = {
|
||||
|
||||
var readyCallbacks = [];
|
||||
var platformName;
|
||||
var platformVersion;
|
||||
|
||||
// setup listeners to know when the device is ready to go
|
||||
function onWindowLoad() {
|
||||
|
||||
6
dist/js/ionic.min.js
vendored
6
dist/js/ionic.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -11,7 +11,9 @@
|
||||
if(this.isReady) {
|
||||
cb();
|
||||
} else {
|
||||
ionic.on('platformready', cb, document);
|
||||
// the platform isn't ready yet, add it to this array
|
||||
// which will be called once the platform is ready
|
||||
readyCallbacks.push(cb);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -59,16 +61,37 @@
|
||||
return navigator.userAgent.toLowerCase().indexOf('ipad') >= 0;
|
||||
},
|
||||
isIOS7: function() {
|
||||
return this.device().platform == 'iOS' && parseFloat(window.device.version) >= 7.0;
|
||||
return this.platform() == 'ios' && this.version() >= 7.0;
|
||||
},
|
||||
isAndroid: function() {
|
||||
return this.device().platform === "Android";
|
||||
return this.platform() === "android";
|
||||
},
|
||||
|
||||
platform: function() {
|
||||
// singleton to get the platform name
|
||||
if(!platformName) this.setPlatform(this.device().platform);
|
||||
return platformName;
|
||||
},
|
||||
|
||||
setPlatform: function(name) {
|
||||
if(name) platformName = name.toLowerCase();
|
||||
},
|
||||
|
||||
version: function() {
|
||||
// singleton to get the platform version
|
||||
if(!platformVersion) this.setVersion(this.device().version);
|
||||
return platformVersion;
|
||||
},
|
||||
|
||||
setVersion: function(v) {
|
||||
if( !isNaN(v) ) version = parseFloat(v);
|
||||
},
|
||||
|
||||
// Check if the platform is the one detected by cordova
|
||||
is: function(type) {
|
||||
if(this.device.platform) {
|
||||
return window.device.platform.toLowerCase() === type.toLowerCase();
|
||||
var pName = this.platform();
|
||||
if(pName) {
|
||||
return pName === type.toLowerCase();
|
||||
}
|
||||
// A quick hack for
|
||||
return navigator.userAgent.toLowerCase().indexOf(type.toLowerCase()) >= 0;
|
||||
@@ -112,6 +135,9 @@
|
||||
|
||||
};
|
||||
|
||||
var readyCallbacks = [];
|
||||
var platformName;
|
||||
var platformVersion;
|
||||
|
||||
// setup listeners to know when the device is ready to go
|
||||
function onWindowLoad() {
|
||||
@@ -125,6 +151,11 @@
|
||||
// the device is all set to go, init our own stuff then fire off our event
|
||||
ionic.Platform.isReady = true;
|
||||
ionic.Platform.detect();
|
||||
for(var x=0; x<readyCallbacks.length; x++) {
|
||||
// fire off all the callbacks that were added before the platform was ready
|
||||
readyCallbacks[x]();
|
||||
}
|
||||
readyCallbacks = [];
|
||||
ionic.trigger('platformready', { target: document });
|
||||
document.removeEventListener("deviceready", onCordovaReady, false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user