support shorthand css color values like #F3D and sanity check for leading octothorp

This commit is contained in:
Jesse MacFadyen 2014-03-11 14:23:13 -07:00
parent 83cc8464e1
commit 7b648411cd

View File

@ -51,18 +51,22 @@ StatusBar.overlaysWebView = function(doOverlay) {
};
StatusBar.styleDefault = function () {
// dark text on a light background
exec(null, null, "StatusBar", "styleDefault", []);
};
StatusBar.styleLightContent = function () {
// light text on a dark background
exec(null, null, "StatusBar", "styleLightContent", []);
};
StatusBar.styleBlackTranslucent = function () {
// #88000000 ? Apple says to use lightContent instead
exec(null, null, "StatusBar", "styleBlackTranslucent", []);
};
StatusBar.styleBlackOpaque = function () {
// #FF000000 ? Apple says to use lightContent instead
exec(null, null, "StatusBar", "styleBlackOpaque", []);
};
@ -71,6 +75,15 @@ StatusBar.backgroundColorByName = function(colorname) {
}
StatusBar.backgroundColorByHexString = function (hexString) {
if (hexString.indexOf("#") < 0) {
hexString = "#" + hexString;
}
if (hexString.length == 4) {
var split = hexString.split("");
hexString = "#" + hexString[1] + hexString[1] + hexString[2] + hexString[2] + hexString[3] + hexString[3];
}
exec(null, null, "StatusBar", "backgroundColorByHexString", [hexString]);
}