ProcessIconToolbar.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. o2.widget = o2.widget || {};
  2. o2.widget.ProcessIconToolbar = o2.PITB = new Class({
  3. css: {
  4. toolbarNodeHide: {
  5. // borderLeftWidth: 1,
  6. // borderLeftStyle: "solid",
  7. // borderLeftColor: "#ddd",
  8. //
  9. // borderTopWidth: 1,
  10. // borderTopStyle: "solid",
  11. // borderTopColor: "#ddd",
  12. //
  13. // borderRightWidth: 1,
  14. // borderRightStyle: "solid",
  15. // borderRightColor: "#bbb",
  16. //
  17. // borderBottomWidth: 1,
  18. // borderBottomStyle: "solid",
  19. // borderBottomColor: "#bbb",
  20. width: 16,
  21. paddingTop: 4,
  22. paddingLeft: 2,
  23. paddingRight: 2,
  24. paddingBottom: 0,
  25. //backgroundColor: "#fff",
  26. //backgroundColor: "e8edf6",
  27. //opacity: 0,
  28. top: 0,
  29. left: 0,
  30. position: "relative",
  31. display: "none"
  32. },
  33. toolbarNodeShow: {
  34. borderWidth: 1,
  35. borderStyle: "solid",
  36. borderColor: "#ccc",
  37. width: 16,
  38. paddingTop: 4,
  39. paddingLeft: 2,
  40. paddingRight: 2,
  41. paddingBottom: 0,
  42. backgroundColor: "#fff",
  43. //backgroundColor: "e8edf6",
  44. //opacity: 1,
  45. top: 0,
  46. left: 0,
  47. position: "relative",
  48. display: "block"
  49. },
  50. img: {
  51. cursor: "pointer",
  52. marginBottom: 4,
  53. borderWidth: 0,
  54. width: 16,
  55. height: 16
  56. }
  57. },
  58. node: null,
  59. targetNode: null,
  60. initialize: function(targetNode){
  61. this.targetNode = targetNode;
  62. this.node = new Element("div", {
  63. styles: this.css.toolbarNodeHide
  64. }).inject(this.targetNode);
  65. var itb = this;
  66. this.targetNode.addEvents({
  67. mouseover: function(obj){
  68. itb._mouseOver.apply(itb, [this, obj]);
  69. },
  70. mousemove: function(obj){
  71. itb._mouseOver.apply(itb, [this, obj]);
  72. },
  73. mouseout: function(obj){
  74. itb._mouseOut.apply(itb, [this, obj]);
  75. }
  76. });
  77. // this.node.addEvent("mousemove", function(obj){
  78. // itb._mouseOver.apply(itb, [this, obj]);
  79. // });
  80. // this.node.addEvent("mouseover", function(obj){
  81. // itb._mouseOver.apply(itb, [this, obj]);
  82. // });
  83. // var Children = this.targetNode.getChildren()
  84. //// Children.addEvent("mouseout", function(obj){
  85. //// //itb._mouseOut.apply(itb, [this, obj]);
  86. //// obj.preventDefault();
  87. //// });
  88. // Children.addEvent("mouseover", function(obj){
  89. // //itb._mouseOver.apply(itb, [this, obj]);
  90. // //obj.preventDefault();
  91. // });
  92. this.targetNode.store("tools", this);
  93. },
  94. addTool: function(img, title, fun, obj){
  95. var itb = this;
  96. this.css.img.background = "url("+img+") no-repeat center center";
  97. var imgNode = new Element("div",{
  98. title: title,
  99. styles: this.css.img
  100. }).inject(this.node);
  101. imgNode.addEvents({
  102. click: function(event){
  103. if (fun){
  104. fun.apply(obj, [itb, this, event]);
  105. }
  106. }
  107. // mouseover: function(obj){
  108. // itb._mouseOver.apply(itb, [this, obj]);
  109. // },
  110. // mousemove: function(obj){
  111. // itb._mouseOver.apply(itb, [this, obj]);
  112. // }
  113. // mouseout: function(obj){
  114. // itb._mouseOut.apply(itb, [this, obj]);
  115. // }
  116. });
  117. },
  118. _mouseOver: function(el, obj){
  119. this.show();
  120. },
  121. _mouseOut: function(el, obj){
  122. // if (!this.targetNode.contains(window.event.toElement)){
  123. this.hide();
  124. // };
  125. },
  126. _setNodePosition: function(){
  127. var objs = this.node.getAllPrevious();
  128. var y = 0;
  129. for (var i=0; i<objs.length; i++){
  130. y += objs[i].getSize().y;
  131. }
  132. var targetNodeSize = this.targetNode.getSize();
  133. var top = 0-y;
  134. var left = targetNodeSize.x - 16;
  135. this.node.setStyles({
  136. top: top,
  137. left: left
  138. });
  139. this.css.toolbarNodeHide.top = top;
  140. this.css.toolbarNodeHide.left = left;
  141. this.css.toolbarNodeShow.top = top;
  142. this.css.toolbarNodeShow.left = left;
  143. },
  144. show: function(){
  145. this._setNodePosition();
  146. if (!this.morph){
  147. this.morph = new Fx.Morph(this.node);
  148. }
  149. window.status = "show";
  150. //this.morph.start(this.css.toolbarNodeShow);
  151. this.node.setStyle("display", "block");
  152. },
  153. hide: function(){
  154. this._setNodePosition();
  155. if (!this.morph){
  156. this.morph = new Fx.Morph(this.node);
  157. }
  158. window.status = "hide";
  159. //this.node.setStyle("display", "none");
  160. //this.morph.start(this.css.toolbarNodeHide);
  161. this.node.setStyle("display", "none");
  162. }
  163. });