選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /** Modified from original Node-Red source, for audio system visualization
  2. * vim: set ts=4:
  3. * Copyright 2013 IBM Corp.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. **/
  17. RED.sidebar = (function() {
  18. //$('#sidebar').tabs();
  19. var sidebar_tabs = RED.tabs.create({
  20. id:"sidebar-tabs",
  21. onchange:function(tab) {
  22. $("#sidebar-content").children().hide();
  23. $("#"+tab.id).show();
  24. },
  25. onremove: function(tab) {
  26. $("#"+tab.id).remove();
  27. }
  28. });
  29. function addTab(title,content,closeable) {
  30. $("#sidebar-content").append(content);
  31. $(content).hide();
  32. sidebar_tabs.addTab({id:"tab-"+title,label:title,closeable:closeable});
  33. //content.style.position = "absolute";
  34. //$('#sidebar').tabs("refresh");
  35. }
  36. $('#btn-sidebar').click(function() {toggleSidebar();});
  37. RED.keyboard.add(/* SPACE */ 32,{ctrl:true},function(){toggleSidebar();d3.event.preventDefault();});
  38. var sidebarSeparator = {};
  39. $("#sidebar-separator").draggable({
  40. axis: "x",
  41. start:function(event,ui) {
  42. sidebarSeparator.closing = false;
  43. sidebarSeparator.opening = false;
  44. var winWidth = $(window).width();
  45. sidebarSeparator.start = ui.position.left;
  46. sidebarSeparator.chartWidth = $("#workspace").width();
  47. sidebarSeparator.chartRight = winWidth-$("#workspace").width()-$("#workspace").offset().left-2;
  48. if (!btnSidebar.hasClass("active")) {
  49. sidebarSeparator.opening = true;
  50. var newChartRight = 15;
  51. $("#sidebar").addClass("closing");
  52. $("#workspace").css("right",newChartRight);
  53. $("#chart-zoom-controls").css("right",newChartRight+20);
  54. $("#sidebar").width(0);
  55. toggleSidebar();
  56. RED.view.resize();
  57. }
  58. sidebarSeparator.width = $("#sidebar").width();
  59. },
  60. drag: function(event,ui) {
  61. var d = ui.position.left-sidebarSeparator.start;
  62. var newSidebarWidth = sidebarSeparator.width-d;
  63. if (sidebarSeparator.opening) {
  64. newSidebarWidth -= 13;
  65. }
  66. if (newSidebarWidth > 150) {
  67. if (sidebarSeparator.chartWidth+d < 200) {
  68. ui.position.left = 200+sidebarSeparator.start-sidebarSeparator.chartWidth;
  69. d = ui.position.left-sidebarSeparator.start;
  70. newSidebarWidth = sidebarSeparator.width-d;
  71. }
  72. }
  73. if (newSidebarWidth < 150) {
  74. if (!sidebarSeparator.closing) {
  75. $("#sidebar").addClass("closing");
  76. sidebarSeparator.closing = true;
  77. }
  78. if (!sidebarSeparator.opening) {
  79. newSidebarWidth = 150;
  80. ui.position.left = sidebarSeparator.width-(150 - sidebarSeparator.start);
  81. d = ui.position.left-sidebarSeparator.start;
  82. }
  83. } else if (newSidebarWidth > 150 && (sidebarSeparator.closing || sidebarSeparator.opening)) {
  84. sidebarSeparator.closing = false;
  85. $("#sidebar").removeClass("closing");
  86. }
  87. var newChartRight = sidebarSeparator.chartRight-d;
  88. $("#workspace").css("right",newChartRight);
  89. $("#chart-zoom-controls").css("right",newChartRight+20);
  90. $("#sidebar").width(newSidebarWidth);
  91. sidebar_tabs.resize();
  92. RED.view.resize();
  93. },
  94. stop:function(event,ui) {
  95. RED.view.resize();
  96. if (sidebarSeparator.closing) {
  97. $("#sidebar").removeClass("closing");
  98. toggleSidebar();
  99. if ($("#sidebar").width() < 180) {
  100. $("#sidebar").width(180);
  101. $("#workspace").css("right",208);
  102. $("#chart-zoom-controls").css("right",228);
  103. }
  104. }
  105. $("#sidebar-separator").css("left","auto");
  106. $("#sidebar-separator").css("right",($("#sidebar").width()+13)+"px");
  107. }
  108. });
  109. var btnSidebar = $("#btn-sidebar");
  110. function toggleSidebar() {
  111. //if ($('#sidebar').tabs( "option", "active" ) === false) {
  112. // $('#sidebar').tabs( "option", "active",0);
  113. //}
  114. btnSidebar.toggleClass("active");
  115. if (!btnSidebar.hasClass("active")) {
  116. $("#main-container").addClass("sidebar-closed");
  117. } else {
  118. $("#main-container").removeClass("sidebar-closed");
  119. }
  120. }
  121. toggleSidebar();
  122. function showSidebar(id) {
  123. if (!$("#btn-sidebar").hasClass("active")) {
  124. toggleSidebar();
  125. }
  126. sidebar_tabs.activateTab("tab-"+id);
  127. }
  128. function containsTab(id) {
  129. return sidebar_tabs.contains("tab-"+id);
  130. }
  131. return {
  132. addTab: addTab,
  133. show: showSidebar,
  134. containsTab: containsTab
  135. }
  136. })();