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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. $('#desktopsharing').css({display: "inline"});
  8. } else {
  9. $('#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. var header = $("#header"),
  50. bottomToolbar = $("#bottomToolbar");
  51. if (!header.is(':visible') || !bottomToolbar.is(":visible")) {
  52. header.show("slide", { direction: "up", duration: 300});
  53. $('#subject').animate({top: "+=40"}, 300);
  54. if (!bottomToolbar.is(":visible")) {
  55. bottomToolbar.show(
  56. "slide", {direction: "right", duration: 300});
  57. }
  58. if (toolbarTimeoutObject) {
  59. clearTimeout(toolbarTimeoutObject);
  60. toolbarTimeoutObject = null;
  61. }
  62. toolbarTimeoutObject = setTimeout(hideToolbar, toolbarTimeout);
  63. toolbarTimeout = interfaceConfig.TOOLBAR_TIMEOUT;
  64. }
  65. if (APP.xmpp.isModerator())
  66. {
  67. // TODO: Enable settings functionality.
  68. // Need to uncomment the settings button in index.html.
  69. // $('#settingsButton').css({visibility:"visible"});
  70. }
  71. // Show/hide desktop sharing button
  72. showDesktopSharingButton();
  73. },
  74. /**
  75. * Docks/undocks the toolbar.
  76. *
  77. * @param isDock indicates what operation to perform
  78. */
  79. dockToolbar: function (isDock) {
  80. if (isDock) {
  81. // First make sure the toolbar is shown.
  82. if (!$('#header').is(':visible')) {
  83. this.showToolbar();
  84. }
  85. // Then clear the time out, to dock the toolbar.
  86. if (toolbarTimeoutObject) {
  87. clearTimeout(toolbarTimeoutObject);
  88. toolbarTimeoutObject = null;
  89. }
  90. }
  91. else {
  92. if (!$('#header').is(':visible')) {
  93. this.showToolbar();
  94. }
  95. else {
  96. toolbarTimeoutObject = setTimeout(hideToolbar, toolbarTimeout);
  97. }
  98. }
  99. },
  100. showDesktopSharingButton: showDesktopSharingButton
  101. };
  102. module.exports = ToolbarToggler;