mirror of
https://github.com/apache/cordova-plugin-statusbar.git
synced 2026-05-16 00:03:40 +08:00
refactor(eslint): use cordova-eslint (#194)
This commit is contained in:
@@ -18,33 +18,32 @@
|
||||
*
|
||||
*/
|
||||
|
||||
function notSupported(win,fail) {
|
||||
function notSupported (win, fail) {
|
||||
//
|
||||
console.log('StatusBar is not supported');
|
||||
setTimeout(function(){
|
||||
setTimeout(function () {
|
||||
if (win) {
|
||||
win();
|
||||
}
|
||||
// note that while it is not explicitly supported, it does not fail
|
||||
// this is really just here to allow developers to test their code in the browser
|
||||
// and if we fail, then their app might as well. -jm
|
||||
},0);
|
||||
}, 0);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
isVisible: false,
|
||||
styleBlackTranslucent:notSupported,
|
||||
styleDefault:notSupported,
|
||||
styleLightContent:notSupported,
|
||||
styleBlackOpaque:notSupported,
|
||||
overlaysWebView:notSupported,
|
||||
styleBlackTranslucent: notSupported,
|
||||
styleDefault: notSupported,
|
||||
styleLightContent: notSupported,
|
||||
styleBlackOpaque: notSupported,
|
||||
overlaysWebView: notSupported,
|
||||
styleLightContect: notSupported,
|
||||
backgroundColorByName: notSupported,
|
||||
backgroundColorByHexString: notSupported,
|
||||
hide: notSupported,
|
||||
show: notSupported,
|
||||
_ready:notSupported
|
||||
_ready: notSupported
|
||||
};
|
||||
|
||||
require("cordova/exec/proxy").add("StatusBar", module.exports);
|
||||
|
||||
require('cordova/exec/proxy').add('StatusBar', module.exports);
|
||||
|
||||
@@ -22,23 +22,23 @@
|
||||
|
||||
var _supported = null; // set to null so we can check first time
|
||||
|
||||
function isSupported() {
|
||||
function isSupported () {
|
||||
// if not checked before, run check
|
||||
if (_supported === null) {
|
||||
var viewMan = Windows.UI.ViewManagement;
|
||||
_supported = (viewMan.StatusBar && viewMan.StatusBar.getForCurrentView);
|
||||
var viewMan = Windows.UI.ViewManagement;
|
||||
_supported = viewMan.StatusBar && viewMan.StatusBar.getForCurrentView;
|
||||
}
|
||||
return _supported;
|
||||
}
|
||||
|
||||
function getViewStatusBar() {
|
||||
function getViewStatusBar () {
|
||||
if (!isSupported()) {
|
||||
throw new Error("Status bar is not supported");
|
||||
throw new Error('Status bar is not supported');
|
||||
}
|
||||
return Windows.UI.ViewManagement.StatusBar.getForCurrentView();
|
||||
}
|
||||
|
||||
function hexToRgb(hex) {
|
||||
function hexToRgb (hex) {
|
||||
// Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF")
|
||||
var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
|
||||
hex = hex.replace(shorthandRegex, function (m, r, g, b) {
|
||||
@@ -46,16 +46,18 @@ function hexToRgb(hex) {
|
||||
});
|
||||
|
||||
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
||||
return result ? {
|
||||
r: parseInt(result[1], 16),
|
||||
g: parseInt(result[2], 16),
|
||||
b: parseInt(result[3], 16)
|
||||
} : null;
|
||||
return result
|
||||
? {
|
||||
r: parseInt(result[1], 16),
|
||||
g: parseInt(result[2], 16),
|
||||
b: parseInt(result[3], 16)
|
||||
}
|
||||
: null;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
_ready: function(win, fail) {
|
||||
if(isSupported()) {
|
||||
_ready: function (win, fail) {
|
||||
if (isSupported()) {
|
||||
var statusBar = getViewStatusBar();
|
||||
win(statusBar.occludedRect.height !== 0);
|
||||
}
|
||||
@@ -90,7 +92,7 @@ module.exports = {
|
||||
|
||||
backgroundColorByHexString: function (win, fail, args) {
|
||||
var rgb = hexToRgb(args[0]);
|
||||
if(isSupported()) {
|
||||
if (isSupported()) {
|
||||
var statusBar = getViewStatusBar();
|
||||
statusBar.backgroundColor = { a: 0, r: rgb.r, g: rgb.g, b: rgb.b };
|
||||
statusBar.backgroundOpacity = 1;
|
||||
@@ -111,4 +113,4 @@ module.exports = {
|
||||
}
|
||||
}
|
||||
};
|
||||
require("cordova/exec/proxy").add("StatusBar", module.exports);
|
||||
require('cordova/exec/proxy').add('StatusBar', module.exports);
|
||||
|
||||
Reference in New Issue
Block a user