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.

toolbar_toggler.js 3.2KB

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