mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
chore(): rename IonicPlatform to Platform
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
+* @name platform
|
||||
+* @module ionic
|
||||
+* @description
|
||||
+* IonicPlatform returns the availble information about your current platform
|
||||
+* Platform returns the availble information about your current platform
|
||||
+*/
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import * as dom from '../util/dom';
|
||||
/**
|
||||
* TODO
|
||||
*/
|
||||
export class IonicPlatform {
|
||||
export class Platform {
|
||||
|
||||
constructor(platforms=[]) {
|
||||
this._platforms = platforms;
|
||||
@@ -33,9 +33,9 @@ export class IonicPlatform {
|
||||
* @returns {bool}
|
||||
*
|
||||
* ```
|
||||
* import {IonicPlatform} 'ionic/ionic';
|
||||
* import {Platform} 'ionic/ionic';
|
||||
* export MyClass {
|
||||
* constructor(platform: IonicPlatform){
|
||||
* constructor(platform: Platform){
|
||||
* this.platform = platform;
|
||||
* if(this.platform.is('ios'){
|
||||
* // what ever you need to do for
|
||||
@@ -57,9 +57,9 @@ export class IonicPlatform {
|
||||
* it would return mobile, ios, and iphone.
|
||||
*
|
||||
* ```
|
||||
* import {IonicPlatform} 'ionic/ionic';
|
||||
* import {Platform} 'ionic/ionic';
|
||||
* export MyClass {
|
||||
* constructor(platform: IonicPlatform){
|
||||
* constructor(platform: Platform){
|
||||
* this.platform = platform;
|
||||
* console.log(this.platform.platforms());
|
||||
* // This will return an array of all the availble platforms
|
||||
@@ -82,9 +82,9 @@ export class IonicPlatform {
|
||||
* Returns an object containing the os version
|
||||
*
|
||||
* ```
|
||||
* import {IonicPlatform} 'ionic/ionic';
|
||||
* import {Platform} 'ionic/ionic';
|
||||
* export MyClass {
|
||||
* constructor(platform: IonicPlatform){
|
||||
* constructor(platform: Platform){
|
||||
* this.platform = platform;
|
||||
* console.log(this.platform.versions('android'));
|
||||
* // Returns an object with the os version as a string,
|
||||
@@ -112,9 +112,9 @@ export class IonicPlatform {
|
||||
* Returns a promise when the platform is ready and native functionality can be called
|
||||
*
|
||||
* ```
|
||||
* import {IonicPlatform} 'ionic/ionic';
|
||||
* import {Platform} 'ionic/ionic';
|
||||
* export MyClass {
|
||||
* constructor(platform: IonicPlatform){
|
||||
* constructor(platform: Platform){
|
||||
* this.platform = platform;
|
||||
* this.platform.ready().then(() => {
|
||||
* console.log('Platform ready');
|
||||
@@ -450,7 +450,7 @@ function insertSuperset(platformNode) {
|
||||
class PlatformNode {
|
||||
|
||||
constructor(platformName) {
|
||||
this.c = IonicPlatform.get(platformName);
|
||||
this.c = Platform.get(platformName);
|
||||
this.isEngine = this.c.isEngine;
|
||||
}
|
||||
|
||||
@@ -538,7 +538,7 @@ class PlatformNode {
|
||||
}
|
||||
|
||||
getSubsetParents(subsetPlatformName) {
|
||||
let platformRegistry = IonicPlatform.registry();
|
||||
let platformRegistry = Platform.registry();
|
||||
|
||||
let parentPlatformNames = [];
|
||||
let platform = null;
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
import {IonicPlatform} from './platform';
|
||||
import {Platform} from './platform';
|
||||
import {windowLoad} from '../util/dom';
|
||||
|
||||
|
||||
IonicPlatform.register({
|
||||
Platform.register({
|
||||
name: 'core',
|
||||
settings: {
|
||||
mode: 'ios',
|
||||
keyboardHeight: 290,
|
||||
}
|
||||
});
|
||||
IonicPlatform.setDefault('core');
|
||||
Platform.setDefault('core');
|
||||
|
||||
|
||||
IonicPlatform.register({
|
||||
Platform.register({
|
||||
name: 'mobile'
|
||||
});
|
||||
|
||||
|
||||
IonicPlatform.register({
|
||||
Platform.register({
|
||||
name: 'phablet',
|
||||
isMatch(p) {
|
||||
let smallest = Math.min(p.width(), p.height());
|
||||
@@ -28,7 +28,7 @@ IonicPlatform.register({
|
||||
});
|
||||
|
||||
|
||||
IonicPlatform.register({
|
||||
Platform.register({
|
||||
name: 'tablet',
|
||||
isMatch(p) {
|
||||
let smallest = Math.min(p.width(), p.height());
|
||||
@@ -39,7 +39,7 @@ IonicPlatform.register({
|
||||
});
|
||||
|
||||
|
||||
IonicPlatform.register({
|
||||
Platform.register({
|
||||
name: 'android',
|
||||
superset: 'mobile',
|
||||
subsets: [
|
||||
@@ -62,7 +62,7 @@ IonicPlatform.register({
|
||||
|
||||
|
||||
|
||||
IonicPlatform.register({
|
||||
Platform.register({
|
||||
name: 'ios',
|
||||
superset: 'mobile',
|
||||
subsets: [
|
||||
@@ -91,7 +91,7 @@ IonicPlatform.register({
|
||||
});
|
||||
|
||||
|
||||
IonicPlatform.register({
|
||||
Platform.register({
|
||||
name: 'ipad',
|
||||
superset: 'tablet',
|
||||
settings: {
|
||||
@@ -103,7 +103,7 @@ IonicPlatform.register({
|
||||
});
|
||||
|
||||
|
||||
IonicPlatform.register({
|
||||
Platform.register({
|
||||
name: 'iphone',
|
||||
subsets: [
|
||||
'phablet'
|
||||
@@ -114,7 +114,7 @@ IonicPlatform.register({
|
||||
});
|
||||
|
||||
|
||||
IonicPlatform.register({
|
||||
Platform.register({
|
||||
name: 'windowsphone',
|
||||
superset: 'mobile',
|
||||
subsets: [
|
||||
@@ -133,7 +133,7 @@ IonicPlatform.register({
|
||||
});
|
||||
|
||||
|
||||
IonicPlatform.register({
|
||||
Platform.register({
|
||||
name: 'cordova',
|
||||
isEngine: true,
|
||||
methods: {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import {IonicPlatform} from 'ionic/ionic';
|
||||
import {Platform} from 'ionic/ionic';
|
||||
|
||||
export function run() {
|
||||
|
||||
it('should set core as the fallback', () => {
|
||||
let platform = new IonicPlatform();
|
||||
let platform = new Platform();
|
||||
platform.userAgent('idk');
|
||||
platform.load();
|
||||
|
||||
@@ -13,7 +13,7 @@ export function run() {
|
||||
});
|
||||
|
||||
it('should set android via platformOverride, despite ios user agent', () => {
|
||||
let platform = new IonicPlatform();
|
||||
let platform = new Platform();
|
||||
platform.userAgent(IPAD_UA);
|
||||
platform.load('android');
|
||||
|
||||
@@ -22,7 +22,7 @@ export function run() {
|
||||
});
|
||||
|
||||
it('should set ios via platformOverride, despite android querystring', () => {
|
||||
let platform = new IonicPlatform();
|
||||
let platform = new Platform();
|
||||
platform.url('/?ionicplatform=android');
|
||||
platform.load('ios');
|
||||
|
||||
@@ -31,7 +31,7 @@ export function run() {
|
||||
});
|
||||
|
||||
it('should set ios via platformOverride', () => {
|
||||
let platform = new IonicPlatform();
|
||||
let platform = new Platform();
|
||||
platform.load('ios');
|
||||
|
||||
expect(platform.is('android')).toEqual(false);
|
||||
@@ -39,7 +39,7 @@ export function run() {
|
||||
});
|
||||
|
||||
it('should set android via platformOverride', () => {
|
||||
let platform = new IonicPlatform();
|
||||
let platform = new Platform();
|
||||
platform.load('android');
|
||||
|
||||
expect(platform.is('android')).toEqual(true);
|
||||
@@ -47,7 +47,7 @@ export function run() {
|
||||
});
|
||||
|
||||
it('should set ios via querystring', () => {
|
||||
let platform = new IonicPlatform();
|
||||
let platform = new Platform();
|
||||
platform.url('/?ionicplatform=ios');
|
||||
platform.load();
|
||||
|
||||
@@ -58,7 +58,7 @@ export function run() {
|
||||
});
|
||||
|
||||
it('should set ios via querystring, even with android user agent', () => {
|
||||
let platform = new IonicPlatform();
|
||||
let platform = new Platform();
|
||||
platform.url('/?ionicplatform=ios');
|
||||
platform.userAgent(ANDROID_UA);
|
||||
platform.load();
|
||||
@@ -68,7 +68,7 @@ export function run() {
|
||||
});
|
||||
|
||||
it('should set android via querystring', () => {
|
||||
let platform = new IonicPlatform();
|
||||
let platform = new Platform();
|
||||
platform.url('/?ionicplatform=android');
|
||||
platform.load();
|
||||
|
||||
@@ -77,7 +77,7 @@ export function run() {
|
||||
});
|
||||
|
||||
it('should set android via querystring, even with ios user agent', () => {
|
||||
let platform = new IonicPlatform();
|
||||
let platform = new Platform();
|
||||
platform.url('/?ionicplatform=android');
|
||||
platform.userAgent(IPHONE_UA);
|
||||
platform.load();
|
||||
@@ -87,7 +87,7 @@ export function run() {
|
||||
});
|
||||
|
||||
it('should set android via user agent', () => {
|
||||
let platform = new IonicPlatform();
|
||||
let platform = new Platform();
|
||||
platform.userAgent(ANDROID_UA);
|
||||
platform.load();
|
||||
|
||||
@@ -97,7 +97,7 @@ export function run() {
|
||||
});
|
||||
|
||||
it('should set iphone via user agent', () => {
|
||||
let platform = new IonicPlatform();
|
||||
let platform = new Platform();
|
||||
platform.userAgent(IPHONE_UA);
|
||||
platform.load();
|
||||
|
||||
@@ -109,7 +109,7 @@ export function run() {
|
||||
});
|
||||
|
||||
it('should set ipad via user agent', () => {
|
||||
let platform = new IonicPlatform();
|
||||
let platform = new Platform();
|
||||
platform.userAgent(IPAD_UA);
|
||||
platform.load();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user