dhtmlxprotobar.js 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. /*
  2. * Copyright DHTMLX LTD. http://www.dhtmlx.com You allowed to use this component
  3. * or parts of it under GPL terms To use it on other terms or get Professional
  4. * edition of the component please contact us at sales@dhtmlx.com
  5. */
  6. function dhtmlXProtobarObject() {
  7. return this
  8. };
  9. dhtmlXProtobarObject.prototype.setOnShowHandler = function(func) {
  10. if (typeof(func) == "function")
  11. this.onShow = func;
  12. else
  13. this.onShow = eval(func)
  14. };
  15. dhtmlXProtobarObject.prototype._getItemIndex = function(id) {
  16. for (var i = 0; i < this.itemsCount; i++) {
  17. if (this.items[i].id == id)
  18. return i
  19. };
  20. return -1
  21. };
  22. dhtmlXProtobarObject.prototype.setGfxPath = function(path) {
  23. this.sysGfxPath = path;
  24. if (this._adjustGFXPath)
  25. this._adjustGFXPath(path)
  26. };
  27. dhtmlXProtobarObject.prototype.setOnHideHandler = function(func) {
  28. if (typeof(func) == "function")
  29. this.onHide = func;
  30. else
  31. this.onHide = eval(func)
  32. };
  33. dhtmlXProtobarObject.prototype.setItemAction = function(id, action) {
  34. var z = this._getItemIndex(id);
  35. if (z >= 0) {
  36. this.items[z].setSecondAction(action)
  37. }
  38. };
  39. dhtmlXProtobarObject.prototype.getItem = function(itemId) {
  40. var z = this._getItemIndex(itemId);
  41. if (z >= 0)
  42. return this.items[z]
  43. };
  44. dhtmlXProtobarObject.prototype.hideButtons = function(idList) {
  45. if (!idList) {
  46. for (var i = 0; i < this.itemsCount; i++) {
  47. var z = this.items[i].getTopNode();
  48. z.style.display = "none";
  49. if (this.extraMode)
  50. z.parentNode.style.display = "none";
  51. this.items[i].hide = 1
  52. };
  53. return 0
  54. };
  55. var temp = idList.split(",");
  56. for (var i = 0; i < temp.length; i++) {
  57. this.hideItem(temp[i])
  58. }
  59. };
  60. dhtmlXProtobarObject.prototype.showButtons = function(idList) {
  61. if (!idList) {
  62. for (var i = 0; i < this.itemsCount; i++) {
  63. var w = this.items[i].getTopNode();
  64. w.style.display = "";
  65. if (this.extraMode)
  66. w.parentNode.style.display = "";
  67. this.items[i].hide = 0
  68. };
  69. return 0
  70. };
  71. var temp = idList.split(",");
  72. for (var i = 0; i < temp.length; i++) {
  73. this.showItem(temp[i])
  74. }
  75. };
  76. dhtmlXProtobarObject.prototype.disableItem = function(itemId) {
  77. var z = this.getItem(itemId);
  78. if (z) {
  79. if (z.disable)
  80. z.disable()
  81. }
  82. };
  83. dhtmlXProtobarObject.prototype.enableItem = function(itemId) {
  84. var z = this.getItem(itemId);
  85. if (z) {
  86. if (z.enable)
  87. z.enable()
  88. }
  89. };
  90. dhtmlXProtobarObject.prototype.hideItem = function(itemId) {
  91. var z = this.getItem(itemId);
  92. if (z) {
  93. var w = z.getTopNode();
  94. w.style.display = "none";
  95. if (this.extraMode)
  96. w.parentNode.style.display = "none";
  97. z.hide = 1;
  98. if (z.parentPanel) {
  99. this._scrollClear(z.parentPanel);
  100. this._scrollCheck(z.parentPanel)
  101. }
  102. }
  103. };
  104. dhtmlXProtobarObject.prototype.showItem = function(id) {
  105. var z = this.getItem(id);
  106. if (z) {
  107. var w = z.getTopNode();
  108. w.style.display = "";
  109. if (this.extraMode)
  110. w.parentNode.style.display = "";
  111. z.hide = 0;
  112. if (z.parentPanel) {
  113. this._scrollClear(z.parentPanel);
  114. this._scrollCheck(z.parentPanel)
  115. }
  116. }
  117. };
  118. dhtmlXProtobarObject.prototype.setOnClickHandler = function(func) {
  119. if (typeof(func) == "function")
  120. this.defaultAction = func;
  121. else
  122. this.defaultAction = eval(func)
  123. };
  124. dhtmlXProtobarObject.prototype.setTitleText = function(newText) {
  125. this.tname = newText;
  126. this.nameCell.innerHTML = newText;
  127. this.preNameCell.innerHTML = newText
  128. };
  129. dhtmlXProtobarObject.prototype.setBarSize = function(width, height) {
  130. if (width)
  131. this.topNod.width = width;
  132. if (height)
  133. this.topNod.height = height
  134. };
  135. dhtmlXProtobarObject.prototype.resetBar = function(idList) {
  136. for (var i = 0; i < this.itemsCount; i++)
  137. this.hideItem(this.items[i].id);
  138. var temp = idList.split(",");
  139. for (var i = 0; i < temp.length; i++) {
  140. this.showItem(temp[i])
  141. }
  142. };
  143. dhtmlXProtobarObject.prototype.loadXMLFor = function(file, itemId, afterCall) {
  144. var z = this._getItemIndex(itemId);
  145. if (z >= 0)
  146. this._awaitXML = this.gitems[z];
  147. this.xmlLoader.waitCall = afterCall || 0;
  148. this.xmlLoader.loadXML(file)
  149. };
  150. dhtmlXProtobarObject.prototype.loadXML = function(file, afterCall) {
  151. this.xmlLoader.waitCall = afterCall || 0;
  152. this.xmlLoader.loadXML(file)
  153. };
  154. dhtmlXProtobarObject.prototype.loadXMLString = function(xmlString, afterCall) {
  155. this.waitCall = afterCall || 0;
  156. this.xmlLoader.loadXMLString(xmlString)
  157. };
  158. dhtmlXProtobarObject.prototype.showBar = function() {
  159. this.topNod.style.display = "";
  160. if ((this.topNod.ieFix) && (this.topNod.style.position == "absolute")) {
  161. this.topNod.ieFix.style.display = "";
  162. this.topNod.ieFix.style.position = "absolute";
  163. this.topNod.ieFix.style.top = this.topNod.style.top;
  164. this.topNod.ieFix.style.left = this.topNod.style.left;
  165. this.topNod.ieFix.style.width = this.topNod.offsetWidth + "px";
  166. this.topNod.ieFix.style.height = this.topNod.offsetHeight + "px"
  167. };
  168. if (this.onShow)
  169. this.onShow()
  170. };
  171. dhtmlXProtobarObject.prototype.hideBar = function() {
  172. this.topNod.style.display = "none";
  173. if (this.topNod.ieFix)
  174. this.topNod.ieFix.style.display = "none";
  175. if (this.onHide)
  176. this.onHide()
  177. };
  178. dhtmlXProtobarObject.prototype.setBarAlign = function(align) {
  179. if ((align == "left") || (align == "top")) {
  180. this.preNameCell.innerHTML = "";
  181. this.preNameCell.style.display = "none";
  182. this.nameCell.style.display = "";
  183. this.nameCell.width = "100%";
  184. this.nameCell.innerHTML = this.tname
  185. };
  186. if ((align == "center") || (align == "middle")) {
  187. this.preNameCell.style.display = "";
  188. this.preNameCell.width = "50%";
  189. this.nameCell.style.display = "";
  190. this.nameCell.width = "50%";
  191. this.nameCell.innerHTML = this.tname;
  192. this.preNameCell.innerHTML = this.tname
  193. };
  194. if ((align == "right") || (align == "bottom")) {
  195. this.nameCell.innerHTML = "";
  196. this.nameCell.style.display = "none";
  197. this.preNameCell.style.display = "";
  198. this.preNameCell.width = "100%";
  199. this.preNameCell.innerHTML = this.tname
  200. }
  201. };
  202. dhtmlXProtobarObject.prototype.dummyFunc = function() {
  203. return true
  204. };
  205. dhtmlXProtobarObject.prototype.badDummy = function() {
  206. return false
  207. };
  208. function dhtmlXButtonPrototypeObject() {
  209. return this
  210. };
  211. dhtmlXButtonPrototypeObject.prototype.setAction = function(func) {
  212. if (typeof(func) == "function")
  213. this.action = func;
  214. else
  215. this.action = eval(func)
  216. };
  217. dhtmlXButtonPrototypeObject.prototype.setSecondAction = function(func) {
  218. if (typeof(func) == "function")
  219. this.persAction = func;
  220. else
  221. this.persAction = eval(func)
  222. };
  223. dhtmlXButtonPrototypeObject.prototype.enable = function() {
  224. if (this.disableImage)
  225. this.imageTag.src = this.src;
  226. else if (!this.className)
  227. this.topNod.className = this.objectNode.className;
  228. else
  229. this.topNod.className = this.className;
  230. if (this.textTag)
  231. this.textTag.className = this.textClassName;
  232. this.topNod.onclick = this._onclickX;
  233. this.topNod.onmouseover = this._onmouseoverX;
  234. this.topNod.onmouseout = this._onmouseoutX;
  235. this.topNod.onmousedown = this._onmousedownX;
  236. this.topNod.onmouseup = this._onmouseupX
  237. };
  238. dhtmlXButtonPrototypeObject.prototype.disable = function() {
  239. if (this.disableImage) {
  240. this.imageTag.src = this.disableImage
  241. } else
  242. this.topNod.className = "iconGray";
  243. if (this.textTag)
  244. this.textTag.className = "buttonTextDisabled";
  245. this.topNod.onclick = this.dummy;
  246. this.topNod.onmouseover = this.dummy;
  247. this.topNod.onmouseout = this.dummy;
  248. this.topNod.onmousedown = this.dummy;
  249. this.topNod.onmouseup = this.dummy
  250. };
  251. dhtmlXButtonPrototypeObject.prototype._onclickX = function(e, that) {
  252. if (!that)
  253. that = this.objectNode;
  254. if (that.topNod.dstatus)
  255. return;
  256. if ((!that.persAction) || (that.persAction()))
  257. if (that.action) {
  258. that.action(that.id)
  259. }
  260. };
  261. dhtmlXButtonPrototypeObject.prototype.setHTML = function(htmlText) {
  262. this.topNod.innerHTML = htmlText
  263. };
  264. dhtmlXButtonPrototypeObject.prototype.setAltText = function(imageText) {
  265. this.imageTag.alt = imageText
  266. };
  267. dhtmlXButtonPrototypeObject.prototype.setImage = function(imageSrc,
  268. disabledImageSrc) {
  269. this.src = imageSrc;
  270. if (disabledImageSrc)
  271. this.disableImage = disabledImageSrc;
  272. if (this.topNod.onclick == this.dummy) {
  273. if (disabledImageSrc)
  274. this.imageTag.src = disabledImageSrc
  275. } else
  276. this.imageTag.src = imageSrc
  277. };
  278. dhtmlXButtonPrototypeObject.prototype.dummy = function() {
  279. };
  280. dhtmlXButtonPrototypeObject.prototype.getTopNode = function() {
  281. return this.topNod
  282. };
  283. dhtmlXButtonPrototypeObject.prototype._onmouseoverY = function() {
  284. if (this._mvImage)
  285. this.imageTag.src = this._mvImage;
  286. else
  287. this.topNod.className = this.className + 'Over'
  288. };
  289. dhtmlXButtonPrototypeObject.prototype._onmouseoutY = function() {
  290. if (this._mnImage)
  291. this.imageTag.src = this._mnImage;
  292. else
  293. this.topNod.className = this.className
  294. };
  295. dhtmlXButtonPrototypeObject.prototype._onmousedownX = function() {
  296. this.className = this.objectNode.className + 'Down';
  297. return true
  298. };
  299. dhtmlXButtonPrototypeObject.prototype._onmouseupX = function() {
  300. this.className = this.objectNode.className;
  301. return true
  302. };
  303. dhtmlXButtonPrototypeObject.prototype._onmouseoutX = function(e) {
  304. if (!e)
  305. e = event;
  306. if (this.timeoutop)
  307. clearTimeout(this.timeoutop);
  308. this.timeoutop = setTimeout(this.objectNode._delayedTimerCall(
  309. this.objectNode, "_onmouseoutY"), 100)
  310. };
  311. dhtmlXButtonPrototypeObject.prototype._onmouseoverX = function(e) {
  312. if (!e)
  313. e = event;
  314. if (this.timeoutop)
  315. clearTimeout(this.timeoutop);
  316. this.timeoutop = setTimeout(this.objectNode._delayedTimerCall(
  317. this.objectNode, "_onmouseoverY"), 50)
  318. };
  319. dhtmlXButtonPrototypeObject.prototype._delayedTimerCall = function(object,
  320. functionName, time) {
  321. this.callFunc = function() {
  322. eval("object." + functionName + "();")
  323. };
  324. return this.callFunc
  325. };
  326. dhtmlXButtonPrototypeObject.prototype._arg2obj = function(n, list) {
  327. var nAtr = new Object();
  328. for (var i = 0; i < n.length; i++)
  329. nAtr[list[i]] = n[i];
  330. return nAtr
  331. };
  332. /*
  333. * Copyright DHTMLX LTD. http://www.dhtmlx.com You allowed to use this component
  334. * or parts of it under GPL terms To use it on other terms or get Professional
  335. * edition of the component please contact us at sales@dhtmlx.com
  336. */