2013-10-05 09:03:18 +08:00
|
|
|
/*
|
2014-03-13 03:17:04 +08:00
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one
|
|
|
|
* or more contributor license agreements. See the NOTICE file
|
|
|
|
* distributed with this work for additional information
|
|
|
|
* regarding copyright ownership. The ASF licenses this file
|
|
|
|
* to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance
|
|
|
|
* with the License. You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing,
|
|
|
|
* software distributed under the License is distributed on an
|
|
|
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
* KIND, either express or implied. See the License for the
|
|
|
|
* specific language governing permissions and limitations
|
|
|
|
* under the License.
|
|
|
|
*
|
2020-07-02 18:12:16 +08:00
|
|
|
*/
|
2014-03-13 03:17:04 +08:00
|
|
|
|
2016-02-24 15:28:04 +08:00
|
|
|
/* global cordova */
|
|
|
|
|
2014-03-13 03:17:04 +08:00
|
|
|
var exec = require('cordova/exec');
|
|
|
|
|
|
|
|
var namedColors = {
|
2020-07-02 18:12:16 +08:00
|
|
|
black: '#000000',
|
|
|
|
darkGray: '#A9A9A9',
|
|
|
|
lightGray: '#D3D3D3',
|
|
|
|
white: '#FFFFFF',
|
|
|
|
gray: '#808080',
|
|
|
|
red: '#FF0000',
|
|
|
|
green: '#00FF00',
|
|
|
|
blue: '#0000FF',
|
|
|
|
cyan: '#00FFFF',
|
|
|
|
yellow: '#FFFF00',
|
|
|
|
magenta: '#FF00FF',
|
|
|
|
orange: '#FFA500',
|
|
|
|
purple: '#800080',
|
|
|
|
brown: '#A52A2A'
|
2014-03-13 03:17:04 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
var StatusBar = {
|
|
|
|
isVisible: true,
|
|
|
|
|
|
|
|
overlaysWebView: function (doOverlay) {
|
2020-07-02 18:12:16 +08:00
|
|
|
exec(null, null, 'StatusBar', 'overlaysWebView', [doOverlay]);
|
2014-03-13 03:17:04 +08:00
|
|
|
},
|
2014-03-12 05:23:13 +08:00
|
|
|
|
2014-03-13 03:17:04 +08:00
|
|
|
styleDefault: function () {
|
|
|
|
// dark text ( to be used on a light background )
|
2020-07-02 18:12:16 +08:00
|
|
|
exec(null, null, 'StatusBar', 'styleDefault', []);
|
2014-03-13 03:17:04 +08:00
|
|
|
},
|
2014-03-12 05:23:13 +08:00
|
|
|
|
2014-03-13 03:17:04 +08:00
|
|
|
styleLightContent: function () {
|
|
|
|
// light text ( to be used on a dark background )
|
2020-07-02 18:12:16 +08:00
|
|
|
exec(null, null, 'StatusBar', 'styleLightContent', []);
|
2014-03-13 03:17:04 +08:00
|
|
|
},
|
2014-03-12 05:23:13 +08:00
|
|
|
|
2014-03-13 03:17:04 +08:00
|
|
|
backgroundColorByName: function (colorname) {
|
2014-03-12 05:23:13 +08:00
|
|
|
return StatusBar.backgroundColorByHexString(namedColors[colorname]);
|
2014-03-13 03:17:04 +08:00
|
|
|
},
|
2014-03-12 05:23:13 +08:00
|
|
|
|
2014-03-13 03:17:04 +08:00
|
|
|
backgroundColorByHexString: function (hexString) {
|
2020-07-02 18:12:16 +08:00
|
|
|
if (hexString.charAt(0) !== '#') {
|
|
|
|
hexString = '#' + hexString;
|
2014-03-12 05:23:13 +08:00
|
|
|
}
|
|
|
|
|
2014-07-21 15:42:44 +08:00
|
|
|
if (hexString.length === 4) {
|
2020-07-02 18:12:16 +08:00
|
|
|
var split = hexString.split('');
|
|
|
|
hexString = '#' + split[1] + split[1] + split[2] + split[2] + split[3] + split[3];
|
2014-03-12 05:23:13 +08:00
|
|
|
}
|
|
|
|
|
2020-07-02 18:12:16 +08:00
|
|
|
exec(null, null, 'StatusBar', 'backgroundColorByHexString', [hexString]);
|
2014-03-13 03:17:04 +08:00
|
|
|
},
|
2014-03-12 05:23:13 +08:00
|
|
|
|
2014-03-13 03:17:04 +08:00
|
|
|
hide: function () {
|
2020-07-02 18:12:16 +08:00
|
|
|
exec(null, null, 'StatusBar', 'hide', []);
|
2014-03-12 06:22:54 +08:00
|
|
|
StatusBar.isVisible = false;
|
2014-03-13 03:17:04 +08:00
|
|
|
},
|
2014-03-12 05:23:13 +08:00
|
|
|
|
2014-03-13 03:17:04 +08:00
|
|
|
show: function () {
|
2020-07-02 18:12:16 +08:00
|
|
|
exec(null, null, 'StatusBar', 'show', []);
|
2014-03-12 06:22:54 +08:00
|
|
|
StatusBar.isVisible = true;
|
2014-03-12 05:23:13 +08:00
|
|
|
}
|
2014-03-13 03:17:04 +08:00
|
|
|
};
|
2014-03-12 05:23:13 +08:00
|
|
|
|
2016-02-24 15:32:46 +08:00
|
|
|
// prime it. setTimeout so that proxy gets time to init
|
|
|
|
window.setTimeout(function () {
|
2020-07-02 18:12:16 +08:00
|
|
|
exec(
|
|
|
|
function (res) {
|
|
|
|
if (typeof res === 'object') {
|
|
|
|
if (res.type === 'tap') {
|
|
|
|
cordova.fireWindowEvent('statusTap');
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
StatusBar.isVisible = res;
|
2016-02-24 15:32:46 +08:00
|
|
|
}
|
2020-07-02 18:12:16 +08:00
|
|
|
},
|
|
|
|
null,
|
|
|
|
'StatusBar',
|
|
|
|
'_ready',
|
|
|
|
[]
|
|
|
|
);
|
2016-02-24 15:32:46 +08:00
|
|
|
}, 0);
|
2014-03-19 18:48:59 +08:00
|
|
|
|
2014-03-13 03:17:04 +08:00
|
|
|
module.exports = StatusBar;
|