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.3KB

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