Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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.config = (function() {
  18. var content = document.createElement("div");
  19. content.id = "tab-config";
  20. content.style.paddingTop = "4px";
  21. content.style.paddingLeft = "4px";
  22. content.style.paddingRight = "4px";
  23. var list = $("<ul>",{class:"tab-config-list"}).appendTo(content);
  24. $("#btn-config-nodes").click(function(){
  25. if (!RED.sidebar.containsTab("config")) {
  26. RED.sidebar.addTab("config",content,true);
  27. }
  28. refresh();
  29. RED.sidebar.show("config");
  30. });
  31. function refresh() {
  32. list.empty();
  33. RED.nodes.eachConfig(function(node) {
  34. var li = list.find("#tab-config-list-type-"+node.type);
  35. if (li.length === 0) {
  36. li = $("<li>",{id:"tab-config-list-type-"+node.type}).appendTo(list);
  37. $('<div class="tab-config-list-type">'+node.type+'</div>').appendTo(li);
  38. }
  39. var label = "";
  40. if (typeof node._def.label == "function") {
  41. label = node._def.label.call(node);
  42. } else {
  43. label = node._def.label;
  44. }
  45. label = label || "&nbsp;";
  46. var entry = $('<div class="tab-config-list-entry"></div>').appendTo(li);
  47. entry.on('dblclick',function(e) {
  48. RED.editor.editConfig("", node.type, node.id);
  49. });
  50. var userArray = node.users.map(function(n) { return n.id });
  51. entry.on('mouseover',function(e) {
  52. RED.nodes.eachNode(function(node) {
  53. if( userArray.indexOf(node.id) != -1) {
  54. node.highlighted = true;
  55. node.dirty = true;
  56. }
  57. });
  58. RED.view.redraw();
  59. });
  60. entry.on('mouseout',function(e) {
  61. RED.nodes.eachNode(function(node) {
  62. if(node.highlighted) {
  63. node.highlighted = false;
  64. node.dirty = true;
  65. }
  66. });
  67. RED.view.redraw();
  68. });
  69. $('<div class="tab-config-list-label">'+label+'</div>').appendTo(entry);
  70. $('<div class="tab-config-list-users">'+node.users.length+'</div>').appendTo(entry);
  71. });
  72. }
  73. return {
  74. refresh:refresh
  75. }
  76. })();