viewsertoolbar.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /// <reference path="raphael.js" />
  2. /// <reference path="actionKinds.js" />
  3. /// <reference path="viewer.js" />
  4. var AB;
  5. (function (AB) {
  6. var ToolBar = (function () {
  7. function ToolBar(viewer) {
  8. // Members
  9. this.element = document.getElementById("ToolbarList");
  10. this.viewer = viewer;
  11. // Configure
  12. this._attachControl();
  13. }
  14. //
  15. // Private methods
  16. //
  17. // Attaches controls to each button
  18. ToolBar.prototype._attachControl = function () {
  19. var scope = this;
  20. var events = new Array();
  21. // Create event handlers and add them to the events array
  22. var onReduce = function () {
  23. scope.viewer.utils.onReduceAll(false);
  24. };
  25. events.push(onReduce);
  26. var onExpand = function () {
  27. scope.viewer.utils.onReduceAll(true);
  28. };
  29. events.push(onExpand);
  30. var onDisconnect = function () {
  31. scope.viewer.utils.onDetachAll(true, false);
  32. };
  33. events.push(onDisconnect);
  34. var onReconnect = function () {
  35. scope.viewer.utils.onDetachAll(false, true);
  36. };
  37. events.push(onReconnect);
  38. var onDeZoom = function () {
  39. if (scope.viewer.zoom > 0.0)
  40. scope.viewer.zoom -= 0.1;
  41. scope.viewer.update();
  42. };
  43. events.push(onDeZoom);
  44. var onZoom = function () {
  45. if (scope.viewer.zoom < 1.0)
  46. scope.viewer.zoom += 0.1;
  47. scope.viewer.update();
  48. };
  49. events.push(onZoom);
  50. // Add events
  51. var onEvent = function (id, element) {
  52. return function (event) {
  53. element.style.backgroundColor = "rgb(155, 155, 155)";
  54. events[id](event);
  55. setTimeout(function () {
  56. element.style.backgroundColor = "rgb(0, 0, 0)";
  57. }, 100);
  58. };
  59. };
  60. var list = this.element.getElementsByTagName("li");
  61. for (var i = 0; i < events.length; i++) {
  62. list[i].addEventListener("click", onEvent(i, list[i]));
  63. }
  64. }
  65. ToolBar.VIEW_HEIGHT = 40;
  66. return ToolBar;
  67. })();
  68. AB.ToolBar = ToolBar;
  69. })(AB || (AB = {}));