|
1 | 1 | (function(window, document, ionic) { |
2 | 2 |
|
| 3 | + var IOS = 'ios'; |
| 4 | + var ANDROID = 'android'; |
| 5 | + var WINDOWS_PHONE = 'windowsphone'; |
| 6 | + |
3 | 7 | /** |
4 | 8 | * @ngdoc utility |
5 | 9 | * @name ionic.Platform |
|
142 | 146 | * @returns {boolean} Whether we are running on iOS. |
143 | 147 | */ |
144 | 148 | isIOS: function() { |
145 | | - return this.is('ios'); |
| 149 | + return this.is(IOS); |
146 | 150 | }, |
147 | 151 | /** |
148 | 152 | * @ngdoc method |
149 | 153 | * @name ionic.Platform#isAndroid |
150 | 154 | * @returns {boolean} Whether we are running on Android. |
151 | 155 | */ |
152 | 156 | isAndroid: function() { |
153 | | - return this.is('android'); |
| 157 | + return this.is(ANDROID); |
| 158 | + }, |
| 159 | + /** |
| 160 | + * @ngdoc method |
| 161 | + * @name ionic.Platform#isWindowsPhone |
| 162 | + * @returns {boolean} Whether we are running on Windows Phone. |
| 163 | + */ |
| 164 | + isWindowsPhone: function() { |
| 165 | + return this.is(WINDOWS_PHONE); |
154 | 166 | }, |
155 | 167 |
|
156 | 168 | /** |
|
171 | 183 | if(typeof n != 'undefined' && n !== null && n.length) { |
172 | 184 | platformName = n.toLowerCase(); |
173 | 185 | } else if(this.ua.indexOf('Android') > 0) { |
174 | | - platformName = 'android'; |
| 186 | + platformName = ANDROID; |
175 | 187 | } else if(this.ua.indexOf('iPhone') > -1 || this.ua.indexOf('iPad') > -1 || this.ua.indexOf('iPod') > -1) { |
176 | | - platformName = 'ios'; |
| 188 | + platformName = IOS; |
| 189 | + } else if(this.ua.indexOf('Windows Phone') > -1) { |
| 190 | + platformName = WINDOWS_PHONE; |
177 | 191 | } else { |
178 | | - platformName = window.navigator.platform && window.navigator.platform.toLowerCase().split(' ')[0] || ''; |
| 192 | + platformName = window.navigator.platform && navigator.platform.toLowerCase().split(' ')[0] || ''; |
179 | 193 | } |
180 | 194 | }, |
181 | 195 |
|
|
209 | 223 | var pName = this.platform(); |
210 | 224 | var versionMatch = { |
211 | 225 | 'android': /Android (\d+).(\d+)?/, |
212 | | - 'ios': /OS (\d+)_(\d+)?/ |
| 226 | + 'ios': /OS (\d+)_(\d+)?/, |
| 227 | + 'windowsphone': /Windows Phone (\d+).(\d+)?/ |
213 | 228 | }; |
214 | 229 | if(versionMatch[pName]) { |
215 | 230 | v = this.ua.match( versionMatch[pName] ); |
|
0 commit comments