Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

statusbar.js 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. cordova.define("cordova-plugin-statusbar.statusbar", function(require, exports, module) {
  2. /*
  3. *
  4. * Licensed to the Apache Software Foundation (ASF) under one
  5. * or more contributor license agreements. See the NOTICE file
  6. * distributed with this work for additional information
  7. * regarding copyright ownership. The ASF licenses this file
  8. * to you under the Apache License, Version 2.0 (the
  9. * "License"); you may not use this file except in compliance
  10. * with the License. You may obtain a copy of the License at
  11. *
  12. * http://www.apache.org/licenses/LICENSE-2.0
  13. *
  14. * Unless required by applicable law or agreed to in writing,
  15. * software distributed under the License is distributed on an
  16. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  17. * KIND, either express or implied. See the License for the
  18. * specific language governing permissions and limitations
  19. * under the License.
  20. *
  21. */
  22. /* global cordova */
  23. var exec = require('cordova/exec');
  24. var namedColors = {
  25. "black": "#000000",
  26. "darkGray": "#A9A9A9",
  27. "lightGray": "#D3D3D3",
  28. "white": "#FFFFFF",
  29. "gray": "#808080",
  30. "red": "#FF0000",
  31. "green": "#00FF00",
  32. "blue": "#0000FF",
  33. "cyan": "#00FFFF",
  34. "yellow": "#FFFF00",
  35. "magenta": "#FF00FF",
  36. "orange": "#FFA500",
  37. "purple": "#800080",
  38. "brown": "#A52A2A"
  39. };
  40. var StatusBar = {
  41. isVisible: true,
  42. overlaysWebView: function (doOverlay) {
  43. exec(null, null, "StatusBar", "overlaysWebView", [doOverlay]);
  44. },
  45. styleDefault: function () {
  46. // dark text ( to be used on a light background )
  47. exec(null, null, "StatusBar", "styleDefault", []);
  48. },
  49. styleLightContent: function () {
  50. // light text ( to be used on a dark background )
  51. exec(null, null, "StatusBar", "styleLightContent", []);
  52. },
  53. styleBlackTranslucent: function () {
  54. // #88000000 ? Apple says to use lightContent instead
  55. exec(null, null, "StatusBar", "styleBlackTranslucent", []);
  56. },
  57. styleBlackOpaque: function () {
  58. // #FF000000 ? Apple says to use lightContent instead
  59. exec(null, null, "StatusBar", "styleBlackOpaque", []);
  60. },
  61. backgroundColorByName: function (colorname) {
  62. return StatusBar.backgroundColorByHexString(namedColors[colorname]);
  63. },
  64. backgroundColorByHexString: function (hexString) {
  65. if (hexString.charAt(0) !== "#") {
  66. hexString = "#" + hexString;
  67. }
  68. if (hexString.length === 4) {
  69. var split = hexString.split("");
  70. hexString = "#" + split[1] + split[1] + split[2] + split[2] + split[3] + split[3];
  71. }
  72. exec(null, null, "StatusBar", "backgroundColorByHexString", [hexString]);
  73. },
  74. hide: function () {
  75. exec(null, null, "StatusBar", "hide", []);
  76. StatusBar.isVisible = false;
  77. },
  78. show: function () {
  79. exec(null, null, "StatusBar", "show", []);
  80. StatusBar.isVisible = true;
  81. }
  82. };
  83. // prime it. setTimeout so that proxy gets time to init
  84. window.setTimeout(function () {
  85. exec(function (res) {
  86. if (typeof res == 'object') {
  87. if (res.type == 'tap') {
  88. cordova.fireWindowEvent('statusTap');
  89. }
  90. } else {
  91. StatusBar.isVisible = res;
  92. }
  93. }, null, "StatusBar", "_ready", []);
  94. }, 0);
  95. module.exports = StatusBar;
  96. });