actionsbuilder.toolbar.js 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. var ActionsBuilder;
  2. (function (ActionsBuilder) {
  3. var Toolbar = (function () {
  4. function Toolbar(viewer) {
  5. var _this = this;
  6. // Get HTML elements
  7. this.toolbarElement = document.getElementById("ToolbarElementID");
  8. // Configure this
  9. this._viewer = viewer;
  10. // Manage events
  11. window.addEventListener("resize", function (event) {
  12. _this.onResize();
  13. });
  14. // Bottom toolbar
  15. document.getElementById("ViewerDeZoomID").addEventListener("click", function (event) {
  16. if (_this._viewer.zoom > 0.1) {
  17. _this._viewer.zoom -= 0.1;
  18. }
  19. _this._viewer.update();
  20. });
  21. document.getElementById("ViewerZoomID").addEventListener("click", function (event) {
  22. if (_this._viewer.zoom < 1.0) {
  23. _this._viewer.zoom += 0.1;
  24. }
  25. _this._viewer.update();
  26. });
  27. document.getElementById("ViewerReconnectAll").addEventListener("click", function (event) {
  28. for (var i = 0; i < _this._viewer.root.children.length; i++) {
  29. _this._viewer.selectedNode = _this._viewer.root.children[i];
  30. _this._viewer.utils.onDetachAction(false, true);
  31. }
  32. _this._viewer.update();
  33. _this._viewer.selectedNode = null;
  34. });
  35. document.getElementById("ViewerDisconnectAll").addEventListener("click", function (event) {
  36. for (var i = 0; i < _this._viewer.root.children.length; i++) {
  37. _this._viewer.selectedNode = _this._viewer.root.children[i];
  38. _this._viewer.utils.onDetachAction(true, false);
  39. }
  40. _this._viewer.update();
  41. _this._viewer.selectedNode = null;
  42. });
  43. document.getElementById("ViewerReduceAll").addEventListener("click", function (event) {
  44. for (var i = 0; i < _this._viewer.root.children.length; i++) {
  45. _this._viewer.selectedNode = _this._viewer.root.children[i];
  46. _this._viewer.utils.onReduceAll(false);
  47. }
  48. _this._viewer.update();
  49. _this._viewer.selectedNode = null;
  50. });
  51. document.getElementById("ViewerExpandAll").addEventListener("click", function (event) {
  52. for (var i = 0; i < _this._viewer.root.children.length; i++) {
  53. _this._viewer.selectedNode = _this._viewer.root.children[i];
  54. _this._viewer.utils.onReduceAll(true);
  55. }
  56. _this._viewer.update();
  57. _this._viewer.selectedNode = null;
  58. });
  59. // Top toolbar
  60. this.saveActionGraphElement = document.getElementById("ToolsButtonIDSaveActionGraph");
  61. this.drawSaveActionGraphButton(false);
  62. document.getElementById("ResetActionGraphID").addEventListener("click", function (event) {
  63. if (confirm("Are you sure?")) {
  64. for (var i = 0; i < _this._viewer.root.children.length; i++) {
  65. _this._viewer.selectedNode = _this._viewer.root.children[i];
  66. _this._viewer.utils.onRemoveBranch();
  67. }
  68. _this._viewer.update();
  69. _this._viewer.selectedNode = null;
  70. }
  71. });
  72. document.getElementById("TestActionGraphID").addEventListener("click", function (event) {
  73. _this._viewer.utils.onTestGraph();
  74. });
  75. }
  76. Toolbar.prototype.onResize = function () {
  77. this.toolbarElement.style.top = this._viewer.viewerElement.clientHeight + 20 + "px";
  78. };
  79. Toolbar.prototype.drawSaveActionGraphButton = function (draw) {
  80. this.saveActionGraphElement.style.display = draw ? "block" : "none";
  81. };
  82. return Toolbar;
  83. })();
  84. ActionsBuilder.Toolbar = Toolbar;
  85. })(ActionsBuilder || (ActionsBuilder = {}));