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

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