Skip to content

Commit

Permalink
fix: address lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jcesarmobile committed Aug 8, 2024
1 parent 6c1ebbe commit e36146c
Showing 1 changed file with 51 additions and 66 deletions.
117 changes: 51 additions & 66 deletions www/statusbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ var StatusBar = {
disableViewportFitiOS12: false,

overlaysWebView: function (doOverlay) {
exec(checkIfStatusBarOverlaysWebview, null, "StatusBar", "overlaysWebView", [doOverlay]);
exec(checkIfStatusBarOverlaysWebview, null, 'StatusBar', 'overlaysWebView', [doOverlay]);
},

styleDefault: function () {
Expand Down Expand Up @@ -90,119 +90,104 @@ var StatusBar = {
},

hide: function () {
exec(onVisibilityChange, null, "StatusBar", "hide", []);
exec(onVisibilityChange, null, 'StatusBar', 'hide', []);
StatusBar.isVisible = false;
},

show: function () {
exec(onVisibilityChange, null, "StatusBar", "show", []);
exec(onVisibilityChange, null, 'StatusBar', 'show', []);
StatusBar.isVisible = true;
}
};

var onVisibilityChange = function (){

var onVisibilityChange = function () {
exec(checkIfStatusBarOverlaysWebview,
null,
"StatusBar",
"isStatusBarOverlayingWebview",
null,
'StatusBar',
'isStatusBarOverlayingWebview',
[]);
};

}


var checkIfStatusBarOverlaysWebview = function(overlaying){

var overlayClassName = "statusbar-overlay";
var checkIfStatusBarOverlaysWebview = function (overlaying) {
var overlayClassName = 'statusbar-overlay';

var statusBarOverlaysWebview = document.body.className.indexOf(overlayClassName);

if(StatusBar.isVisible){
if(overlaying){
if(statusBarOverlaysWebview < 0){
document.body.className += (document.body.className.length > 0 ? " ":"")+overlayClassName;
if (StatusBar.isVisible) {
if (overlaying) {
if (statusBarOverlaysWebview < 0) {
document.body.className += (document.body.className.length > 0 ? ' ' : '') + overlayClassName;
}

addStatusBarDataElement();
} else {
document.body.className = document.body.className.replace(overlayClassName, '').trim();
document.body.removeAttribute('data-status-bar-height');
}
else{
document.body.className = document.body.className.replace(overlayClassName,"").trim();
document.body.removeAttribute("data-status-bar-height");
} else {
if (statusBarOverlaysWebview >= 0) {
document.body.className = document.body.className.replace(overlayClassName, '').trim();
document.body.removeAttribute('data-status-bar-height');
}
}
else {
if(statusBarOverlaysWebview >= 0){
document.body.className = document.body.className.replace(overlayClassName,"").trim();
document.body.removeAttribute("data-status-bar-height");
}
}
}

var addStatusBarDataElement = function(){
};

var getStatusBarHeight = function (height){
document.body.setAttribute("data-status-bar-height",height);
document.body.style.setProperty('--status-bar-height', height + "px");
var addStatusBarDataElement = function () {
var getStatusBarHeight = function (height) {
document.body.setAttribute('data-status-bar-height', height);
document.body.style.setProperty('--status-bar-height', height + 'px');
};

exec(getStatusBarHeight,
null,
"StatusBar",
"getStatusBarHeight",
null,
'StatusBar',
'getStatusBarHeight',
[]);
}

var injectViewportMetaTag = function(){
};

var injectViewportMetaTag = function () {
if (/(iPad)|(iPhone)/i.test(navigator.userAgent)) {
var version = navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);

if(Array.isArray(version) && version.length > 1 && !isNaN(version[1])){
if(Number(version[1]) == IOS_11_VERSION || (Number(version[1]) > IOS_11_VERSION && !StatusBar.disableViewportFitiOS12)){
var viewportMetaElem = document.getElementsByTagName("meta").namedItem("viewport");
if (Array.isArray(version) && version.length > 1 && !isNaN(version[1])) {
if (Number(version[1]) === IOS_11_VERSION || (Number(version[1]) > IOS_11_VERSION && !StatusBar.disableViewportFitiOS12)) {
var viewportMetaElem = document.getElementsByTagName('meta').namedItem('viewport');

if(viewportMetaElem && !viewportMetaElem.content.includes("viewport-fit")) {
viewportMetaElem.setAttribute("content", "viewport-fit=cover," + viewportMetaElem.content)
if (viewportMetaElem && !viewportMetaElem.content.includes('viewport-fit')) {
viewportMetaElem.setAttribute('content', 'viewport-fit=cover,' + viewportMetaElem.content);
}
}
}
}

}


};

module.exports = StatusBar;


// Called after 'deviceready' event
channel.deviceready.subscribe(function () {

exec(function (res) {
if (typeof res == 'object') {
if (res.type == 'tap') {
cordova.fireWindowEvent('statusTap');
}
else{
if (res.type == 'viewport'){
StatusBar.disableViewportFitiOS12 = res.disableiOS12;
injectViewportMetaTag();
}
}
if (typeof res === 'object') {
if (res.type === 'tap') {
cordova.fireWindowEvent('statusTap');
} else {
StatusBar.isVisible = res;
if (res.type === 'viewport') {
StatusBar.disableViewportFitiOS12 = res.disableiOS12;
injectViewportMetaTag();
}
}
}, null, "StatusBar", "_ready", []);

} else {
StatusBar.isVisible = res;
}
}, null, 'StatusBar', '_ready', []);

onVisibilityChange();
});

// Called by the native side when a configuration change
cordova.callbacks["StatusBarStaticChannel"] = {
success: function() {
cordova.callbacks.StatusBarStaticChannel = {
success: function () {
onVisibilityChange();
},
fail: function() {
fail: function () {
}
};

0 comments on commit e36146c

Please sign in to comment.