Source: js/popup_window.js

  1. /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- /
  2. /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
  3. 'use strict';
  4. /* global AppWindow */
  5. (function(exports) {
  6. /**
  7. * This window is inherit the AppWindow, and modifies some properties
  8. * different from the later.
  9. *
  10. * @constructor PopupWindow
  11. * @augments AppWindow
  12. */
  13. var PopupWindow = function(configs) {
  14. if (configs && configs.rearWindow) {
  15. // Render inside its opener.
  16. this.containerElement = configs.rearWindow.element;
  17. }
  18. configs.chrome = {
  19. bar: true
  20. };
  21. AppWindow.call(this, configs);
  22. // Replicate the theme color from the parent window.
  23. // See http://bugzil.la/1132418
  24. if (!this.rearWindow) {
  25. return;
  26. }
  27. this.themeColor = this.rearWindow.themeColor;
  28. if (this.rearWindow.appChrome) {
  29. this.element.classList.toggle('light',
  30. this.rearWindow.appChrome.useLightTheming());
  31. // We have to apply the style on the title bar element because the
  32. // popup appChrome element doesn't overlap. See http://bugzil.la/1132418
  33. this.statusbar.titleBar.style.backgroundColor =
  34. this.rearWindow.appChrome.element.style.backgroundColor;
  35. }
  36. };
  37. /**
  38. * @borrows AppWindow.prototype as PopupWindow.prototype
  39. * @memberof PopupWindow
  40. */
  41. PopupWindow.prototype = Object.create(AppWindow.prototype);
  42. PopupWindow.REGISTERED_EVENTS =
  43. ['mozbrowserclose', 'mozbrowsererror', 'mozbrowservisibilitychange',
  44. 'mozbrowserloadend', 'mozbrowseractivitydone', 'mozbrowserloadstart',
  45. 'mozbrowsertitlechange', 'mozbrowserlocationchange',
  46. 'mozbrowsericonchange'];
  47. PopupWindow.SUB_COMPONENTS = {
  48. 'transitionController': 'AppTransitionController',
  49. 'modalDialog': 'AppModalDialog',
  50. 'valueSelector': 'ValueSelector',
  51. 'authDialog': 'AppAuthenticationDialog',
  52. 'childWindowFactory': 'ChildWindowFactory',
  53. 'statusbar': 'AppStatusbar'
  54. };
  55. PopupWindow.SUB_MODULES = {
  56. 'contextmenu': 'BrowserContextMenu'
  57. };
  58. /**
  59. * We would maintain our own events by other components.
  60. *
  61. * @type String
  62. * @memberof PopupWindow
  63. */
  64. PopupWindow.prototype.eventPrefix = 'popup';
  65. /**
  66. * Default opening animation.
  67. *
  68. * @type String
  69. * @memberof PopupWindow
  70. */
  71. PopupWindow.prototype.openAnimation = 'slide-from-bottom';
  72. /**
  73. * Default closing animation.
  74. *
  75. * @type String
  76. * @memberof PopupWindow
  77. */
  78. PopupWindow.prototype.closeAnimation = 'slide-to-bottom';
  79. PopupWindow.prototype.CLASS_LIST = 'appWindow popupWindow';
  80. PopupWindow.prototype._DEBUG = false;
  81. PopupWindow.prototype.CLASS_NAME = 'PopupWindow';
  82. /**
  83. * We don't need to request to open because:
  84. * We are always overlapping above an app window or
  85. * another popup window instance which is not sent to
  86. * background. This behavior may change later but in
  87. * current stage we don't care.
  88. */
  89. PopupWindow.prototype.requestOpen = function() {
  90. this.open();
  91. };
  92. PopupWindow.prototype.requestClose = function() {
  93. this.close();
  94. };
  95. /**
  96. * @exports PopupWindow
  97. */
  98. exports.PopupWindow = PopupWindow;
  99. })(window);