diff --git a/CHANGELOG.md b/CHANGELOG.md index 42c533257b..62fa73bde0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## 0.9.23-alpha (pre-release) - Android back button correctly goes back a view or closes the app - CustomEvent polyfill improvements for Android + - Fix tab icon alignments + - Fix $ionicPlatform.ready() ## 0.9.22 "Alpha Narwhal" (2014-01-30) diff --git a/dist/js/ionic-angular.js b/dist/js/ionic-angular.js index 18538b0015..a5ebc2ed17 100644 --- a/dist/js/ionic-angular.js +++ b/dist/js/ionic-angular.js @@ -483,10 +483,7 @@ angular.module('ionic.service.platform', []) .provider('$ionicPlatform', function() { return { - setPlatform: function(p) { - platform = p; - }, - $get: ['$q', '$timeout', function($q, $timeout) { + $get: ['$q', function($q) { return { /** * Some platforms have hardware back buttons, so this is one way to bind to it. @@ -519,17 +516,12 @@ angular.module('ionic.service.platform', []) * ready. */ ready: function(cb) { - var self = this; var q = $q.defer(); - $timeout(function readyWait() { - if(ionic.Platform.isReady) { - q.resolve(); - cb(); - } else { - $timeout(readyWait, 50); - } - }, 50); + ionic.Platform.ready(function(){ + q.resolve(); + cb(); + }); return q.promise; } @@ -621,7 +613,7 @@ angular.module('ionic.service.templateLoad', []) }; }]); ; -angular.module('ionic.service.view', ['ui.router']) +angular.module('ionic.service.view', ['ui.router', 'ionic.service.platform']) .run( ['$rootScope', '$state', '$location', '$document', '$animate', '$ionicPlatform', @@ -1290,7 +1282,7 @@ angular.module('ionic.ui.checkbox', []) (function() { 'use strict'; -angular.module('ionic.ui.content', ['ionic.ui.service']) +angular.module('ionic.ui.content', ['ionic.ui.service', 'ionic.service.platform']) /** * Panel is a simple 100% width and height, fixed panel. It's meant for content to be diff --git a/dist/js/ionic.js b/dist/js/ionic.js index 4feb1eec44..18411d94a5 100644 --- a/dist/js/ionic.js +++ b/dist/js/ionic.js @@ -1767,7 +1767,9 @@ window.ionic = { 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); } }, @@ -1815,16 +1817,28 @@ window.ionic = { return navigator.userAgent.toLowerCase().indexOf('ipad') >= 0; }, isIOS7: function() { - return this.device().platform == 'iOS' && parseFloat(window.device.version) >= 7.0; + return this.platformName == 'iOS' && parseFloat(window.device.version) >= 7.0; }, isAndroid: function() { - return this.device().platform === "Android"; + return this.platformName === "Android"; + }, + + platform: function() { + if(!platformName) { + this.setPlatform(this.device().platform); + } + return platformName; + }, + + setPlatform: function(name) { + if(name) platformName = name.toLowerCase(); }, // 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; @@ -1868,6 +1882,8 @@ window.ionic = { }; + var readyCallbacks = []; + var platformName; // setup listeners to know when the device is ready to go function onWindowLoad() { @@ -1881,6 +1897,11 @@ window.ionic = { // 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')(scope); timeout.flush(); var newScope = element.isolateScope(); @@ -46,7 +39,7 @@ describe('Ionic Content directive', function() { }); it('Disables bouncing when has-bouncing = false', function() { - platform = 'iPhone'; + ionic.Platform.setPlatform('iPhone'); element = compile('')(scope); timeout.flush(); var newScope = element.isolateScope(); @@ -55,7 +48,7 @@ describe('Ionic Content directive', function() { }); it('Disables bouncing by default on Android', function() { - platform = 'Android'; + ionic.Platform.setPlatform('Android'); element = compile('')(scope); timeout.flush(); var newScope = element.isolateScope(); @@ -64,7 +57,7 @@ describe('Ionic Content directive', function() { }); it('Disables bouncing by default on Android unless has-bouncing = true', function() { - platform = 'Android'; + ionic.Platform.setPlatform('Android'); element = compile('')(scope); timeout.flush(); var newScope = element.isolateScope(); diff --git a/js/ext/angular/test/service/ionicModal.unit.js b/js/ext/angular/test/service/ionicModal.unit.js index cdf996bf0d..d384b26122 100644 --- a/js/ext/angular/test/service/ionicModal.unit.js +++ b/js/ext/angular/test/service/ionicModal.unit.js @@ -44,7 +44,7 @@ describe('Ionic Modal', function() { var modalInstance = modal.fromTemplate(template); modalInstance.show(); - timeout.flush(); + //timeout.flush(); expect(modalInstance.el.classList.contains('active')).toBe(true);