您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

SidePanelToggler.js 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /* global require, $ */
  2. import Chat from "./chat/Chat";
  3. import ContactList from "./contactlist/ContactList";
  4. import Settings from "./../../settings/Settings";
  5. import SettingsMenu from "./settings/SettingsMenu";
  6. import VideoLayout from "../videolayout/VideoLayout";
  7. import ToolbarToggler from "../toolbars/ToolbarToggler";
  8. import UIUtil from "../util/UIUtil";
  9. const buttons = {
  10. '#chatspace': '#chatBottomButton',
  11. '#contactlist': '#contactListButton',
  12. '#settingsmenu': '#toolbar_button_settings'
  13. };
  14. var currentlyOpen = null;
  15. /**
  16. * Toggles the windows in the side panel
  17. * @param object the window that should be shown
  18. * @param selector the selector for the element containing the panel
  19. * @param onOpenComplete function to be called when the panel is opened
  20. * @param onOpen function to be called if the window is going to be opened
  21. * @param onClose function to be called if the window is going to be closed
  22. */
  23. function toggle (object, selector, onOpenComplete, onOpen, onClose) {
  24. UIUtil.buttonClick(buttons[selector], "active");
  25. if (object.isVisible()) {
  26. $("#toast-container").animate({
  27. right: 5
  28. }, {
  29. queue: false,
  30. duration: 500
  31. });
  32. $(selector).hide("slide", {
  33. direction: "right",
  34. queue: false,
  35. duration: 500
  36. });
  37. if(typeof onClose === "function") {
  38. onClose();
  39. }
  40. currentlyOpen = null;
  41. } else {
  42. // Undock the toolbar when the chat is shown and if we're in a
  43. // video mode.
  44. if (VideoLayout.isLargeVideoVisible()) {
  45. ToolbarToggler.dockToolbar(false);
  46. }
  47. if (currentlyOpen) {
  48. var current = $(currentlyOpen);
  49. UIUtil.buttonClick(buttons[currentlyOpen], "active");
  50. current.css('z-index', 4);
  51. setTimeout(function () {
  52. current.css('display', 'none');
  53. current.css('z-index', 5);
  54. }, 500);
  55. }
  56. $("#toast-container").animate({
  57. right: (UIUtil.getSidePanelSize()[0] + 5)
  58. }, {
  59. queue: false,
  60. duration: 500
  61. });
  62. $(selector).show("slide", {
  63. direction: "right",
  64. queue: false,
  65. duration: 500,
  66. complete: onOpenComplete
  67. });
  68. if(typeof onOpen === "function") {
  69. onOpen();
  70. }
  71. currentlyOpen = selector;
  72. }
  73. }
  74. /**
  75. * Toggler for the chat, contact list, settings menu, etc..
  76. */
  77. var PanelToggler = {
  78. /**
  79. * Opens / closes the chat area.
  80. */
  81. toggleChat () {
  82. var chatCompleteFunction = Chat.isVisible()
  83. ? function () {}
  84. : function () {
  85. Chat.scrollChatToBottom();
  86. $('#chatspace').trigger('shown');
  87. };
  88. VideoLayout.resizeVideoArea(!Chat.isVisible(),
  89. false,
  90. true,
  91. chatCompleteFunction);
  92. toggle(Chat, //Object
  93. '#chatspace', // Selector
  94. function () { //onOpenComplete
  95. // Request the focus in the nickname field or the chat input
  96. // field.
  97. if ($('#nickname').css('visibility') === 'visible') {
  98. $('#nickinput').focus();
  99. } else {
  100. $('#usermsg').focus();
  101. }
  102. },
  103. () => this.resizeChat(), //OnOpen
  104. null); //OnClose
  105. },
  106. resizeChat () {
  107. let [width, height] = UIUtil.getSidePanelSize();
  108. Chat.resizeChat(width, height);
  109. },
  110. /**
  111. * Opens / closes the contact list area.
  112. */
  113. toggleContactList () {
  114. var completeFunction = ContactList.isVisible()
  115. ? function () {}
  116. : function () {
  117. $('#contactlist').trigger('shown');
  118. };
  119. VideoLayout.resizeVideoArea(
  120. !ContactList.isVisible(),
  121. false,
  122. true,
  123. completeFunction);
  124. toggle(ContactList,
  125. '#contactlist',
  126. null,
  127. function() {
  128. ContactList.setVisualNotification(false);
  129. },
  130. null);
  131. },
  132. /**
  133. * Opens / closes the settings menu
  134. */
  135. toggleSettingsMenu () {
  136. VideoLayout.resizeVideoArea(
  137. !SettingsMenu.isVisible(), false, true, function (){});
  138. toggle(SettingsMenu,
  139. '#settingsmenu',
  140. null,
  141. function() {
  142. $('#setDisplayName').val(Settings.getDisplayName());
  143. $('#setEmail').val(Settings.getEmail());
  144. },
  145. null);
  146. },
  147. isVisible () {
  148. return (Chat.isVisible() ||
  149. ContactList.isVisible() ||
  150. SettingsMenu.isVisible());
  151. }
  152. };
  153. export default PanelToggler;