feat(ionic.Platform): add ionic.Platform.setGrade() function

Closes #1104
This commit is contained in:
Andrew Joslin
2014-06-11 11:14:15 -06:00
parent a034561516
commit 05dd7b1864

View File

@@ -71,7 +71,25 @@
for(var i = 0; i < ionic.Platform.platforms.length; i++) {
document.body.classList.add('platform-' + ionic.Platform.platforms[i]);
}
document.body.classList.add('grade-' + ionic.Platform.grade);
});
},
/**
* @ngdoc method
* @name ionic.Platform#setGrade
* @description Set the grade of the device: 'a', 'b', or 'c'. 'a' is the best
* (most css features enabled), 'c' is the worst. By default, sets the grade
* depending on the current device.
* @param {string} grade The new grade to set.
*/
setGrade: function(grade) {
var oldGrade = this.grade;
this.grade = grade;
ionic.requestAnimationFrame(function() {
if (oldGrade) {
document.body.classList.remove('grade-' + oldGrade);
}
document.body.classList.add('grade-' + grade);
});
},
@@ -89,7 +107,7 @@
_checkPlatforms: function(platforms) {
this.platforms = [];
this.grade = 'a';
var grade = 'a';
if(this.isWebView()) {
this.platforms.push('webview');
@@ -115,12 +133,14 @@
this.platforms.push(platform + v);
if(this.isAndroid() && version < 4.4) {
this.grade = (version < 4 ? 'c' : 'b');
grade = (version < 4 ? 'c' : 'b');
} else if(this.isWindowsPhone()) {
this.grade = 'b';
grade = 'b';
}
}
}
this.setGrade(grade);
},
/**