You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ToolbarToggler.js 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /* global APP, config, $, interfaceConfig, Moderator,
  2. DesktopStreaming.showDesktopSharingButton */
  3. var toolbarTimeoutObject,
  4. toolbarTimeout = interfaceConfig.INITIAL_TOOLBAR_TIMEOUT;
  5. function showDesktopSharingButton() {
  6. if (APP.desktopsharing.isDesktopSharingEnabled()) {
  7. $('#toolbar_button_desktopsharing').css({display: "inline-block"});
  8. } else {
  9. $('#toolbar_button_desktopsharing').css({display: "none"});
  10. }
  11. }
  12. /**
  13. * Hides the toolbar.
  14. */
  15. function hideToolbar() {
  16. if(config.alwaysVisibleToolbar)
  17. return;
  18. var header = $("#header"),
  19. bottomToolbar = $("#bottomToolbar");
  20. var isToolbarHover = false;
  21. header.find('*').each(function () {
  22. var id = $(this).attr('id');
  23. if ($("#" + id + ":hover").length > 0) {
  24. isToolbarHover = true;
  25. }
  26. });
  27. if ($("#bottomToolbar:hover").length > 0) {
  28. isToolbarHover = true;
  29. }
  30. clearTimeout(toolbarTimeoutObject);
  31. toolbarTimeoutObject = null;
  32. if (!isToolbarHover) {
  33. header.hide("slide", { direction: "up", duration: 300});
  34. $('#subject').animate({top: "-=40"}, 300);
  35. if ($("#remoteVideos").hasClass("hidden")) {
  36. bottomToolbar.hide(
  37. "slide", {direction: "right", duration: 300});
  38. }
  39. }
  40. else {
  41. toolbarTimeoutObject = setTimeout(hideToolbar, toolbarTimeout);
  42. }
  43. }
  44. var ToolbarToggler = {
  45. /**
  46. * Shows the main toolbar.
  47. */
  48. showToolbar: function () {
  49. if (interfaceConfig.filmStripOnly)
  50. return;
  51. var header = $("#header"),
  52. bottomToolbar = $("#bottomToolbar");
  53. if (!header.is(':visible') || !bottomToolbar.is(":visible")) {
  54. header.show("slide", { direction: "up", duration: 300});
  55. $('#subject').animate({top: "+=40"}, 300);
  56. if (!bottomToolbar.is(":visible")) {
  57. bottomToolbar.show(
  58. "slide", {direction: "right", duration: 300});
  59. }
  60. if (toolbarTimeoutObject) {
  61. clearTimeout(toolbarTimeoutObject);
  62. toolbarTimeoutObject = null;
  63. }
  64. toolbarTimeoutObject = setTimeout(hideToolbar, toolbarTimeout);
  65. toolbarTimeout = interfaceConfig.TOOLBAR_TIMEOUT;
  66. }
  67. if (APP.xmpp.isModerator())
  68. {
  69. // TODO: Enable settings functionality.
  70. // Need to uncomment the settings button in index.html.
  71. // $('#settingsButton').css({visibility:"visible"});
  72. }
  73. // Show/hide desktop sharing button
  74. showDesktopSharingButton();
  75. },
  76. /**
  77. * Docks/undocks the toolbar.
  78. *
  79. * @param isDock indicates what operation to perform
  80. */
  81. dockToolbar: function (isDock) {
  82. if (interfaceConfig.filmStripOnly)
  83. return;
  84. if (isDock) {
  85. // First make sure the toolbar is shown.
  86. if (!$('#header').is(':visible')) {
  87. this.showToolbar();
  88. }
  89. // Then clear the time out, to dock the toolbar.
  90. if (toolbarTimeoutObject) {
  91. clearTimeout(toolbarTimeoutObject);
  92. toolbarTimeoutObject = null;
  93. }
  94. }
  95. else {
  96. if (!$('#header').is(':visible')) {
  97. this.showToolbar();
  98. }
  99. else {
  100. toolbarTimeoutObject = setTimeout(hideToolbar, toolbarTimeout);
  101. }
  102. }
  103. },
  104. showDesktopSharingButton: showDesktopSharingButton
  105. };
  106. module.exports = ToolbarToggler;