CMenuItem.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941
  1. /********************************************************************************************************************************
  2. * Licensed Materials - Property of IBM *
  3. * *
  4. * IBM Cognos Products: AGS *
  5. * *
  6. * (C) Copyright IBM Corp. 2005, 2014 *
  7. * *
  8. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. *
  9. *********************************************************************************************************************************/
  10. /*-----------------------------------------------------------------------------------------------------
  11. Class : CMenuItem
  12. Description :
  13. -----------------------------------------------------------------------------------------------------*/
  14. var theMenuCnt = 1;
  15. function CMenuItem(parent, label, id, action, iconPath, style, tooltip,itemTooltip, capability) {
  16. this.m_label = label;
  17. this.m_id = id;
  18. this.m_bVisible = true;
  19. this.m_bEnabled = true;
  20. this.m_action = action;
  21. this.m_icon = new CIcon(iconPath,tooltip);
  22. this.m_parent = parent;
  23. this.m_menu = null;
  24. this.m_menuType='';
  25. this.m_style = style;
  26. this.m_observers = new CObserver(this);
  27. this.itemTooltip = itemTooltip;
  28. this.m_capability = capability;
  29. //skin folder
  30. this.m_sSkin = (typeof getPromptSkin != "undefined" ? getPromptSkin() : "../skins/corporate");
  31. if(typeof this.m_parent == "object" && typeof this.m_parent.add == "function")
  32. this.m_parent.add(this);
  33. }
  34. function CMenuItem_getId() {
  35. return this.m_id;
  36. }
  37. function CMenuItem_getObservers() {
  38. return this.m_observers;
  39. }
  40. function CMenuItem_setParent(parent) {
  41. this.m_parent = parent;
  42. }
  43. function CMenuItem_getParent() {
  44. return this.m_parent;
  45. }
  46. function CMenuItem_draw() {
  47. var html = '<div>';
  48. var tabindexVal = -1 ;
  49. if (typeof AccessibilityHandler != "undefined" && AccessibilityHandler.isEnabled()) {
  50. tabindexVal = AccessibilityHandler.getTabindex(this);
  51. }
  52. if(this.m_menu == null || this.m_menuType=='dropDown') {
  53. html += '<table';
  54. if (this.itemTooltip) {
  55. html += ' title="' + this.itemTooltip + '"';
  56. }
  57. if (this.isEnabled())
  58. html += ' hideFocus="true"';
  59. html += ' width="100%" ';
  60. html += 'class="';
  61. if(typeof this.getStyle() == "object") {
  62. if(this.isEnabled())
  63. html += this.getStyle().getNormalState();
  64. else
  65. html += this.getStyle().getDisabledState();
  66. }
  67. html += '" id="';
  68. html += this.getId();
  69. html += '" tabindex="'+ tabindexVal +'" role="menuitem" cellpadding="0" cellspacing="0" style="margin-bottom:1px;"><tr>';
  70. html += '<td unselectable="on"';
  71. var bSiblingContainsIcon = false;
  72. if(this.m_icon.getPath() == '') {
  73. var siblingCount = this.m_parent.getNumItems();
  74. for(var siblingIdx = 0; siblingIdx < siblingCount; ++siblingIdx) {
  75. siblingMenuItem = this.m_parent.get(siblingIdx);
  76. if(typeof siblingMenuItem.getIcon == "function" && siblingMenuItem.getIcon().getPath()) {
  77. // temporary for now to get alignment working on the context menu.
  78. bSiblingContainsIcon = true;
  79. break;
  80. }
  81. }
  82. }
  83. if(bSiblingContainsIcon || this.m_icon.getPath() != '') {
  84. html += ' width="16px" style="padding-right: 3px"';
  85. } else {
  86. html += ' width="7px" height="18px"';
  87. }
  88. html += '>';
  89. if(bSiblingContainsIcon) {
  90. html += '<img src="../common/images/spacer.gif" width="16px" alt=""/>';
  91. }
  92. else {
  93. html += this.m_icon.draw();
  94. }
  95. html += '</td>';
  96. html += '<td unselectable="on" nowrap="nowrap" align="left">';
  97. if(this.m_label.indexOf('<')>-1) {
  98. html += xmlEncode(this.m_label);
  99. }else{
  100. html += this.m_label;
  101. }
  102. html += '</td>';
  103. html += '<td unselectable="on" nowrap="nowrap" align="right" width="7px" height="18px">';
  104. if (this.getParent().hasCascadedChildren && this.getParent().hasCascadedChildren()) {
  105. html += '<img src="../common/images/spacer.gif" WIDTH="12px" alt=""/>';
  106. //} else if(!(this.getParent() instanceof CBar)) {
  107. //html += '<img src="../common/images/spacer.gif" WIDTH="12"/>';
  108. }else {
  109. html += '<img src="../common/images/spacer.gif" WIDTH="1px" alt=""/>';
  110. }
  111. html += '</td>';
  112. html += '</tr></table></div>';
  113. } else {
  114. html += '<table';
  115. if (this.isEnabled())
  116. html += ' hideFocus="true"';
  117. html += ' width="100%" class="';
  118. if(typeof this.getStyle() == "object") {
  119. if(this.isEnabled())
  120. html += this.getStyle().getNormalState();
  121. else
  122. html += this.getStyle().getDisabledState();
  123. }
  124. html += '" id="';
  125. html += this.getId();
  126. html += '" tabindex="'+ tabindexVal +'" role="menuitem" cellpadding="0" cellspacing="0" style="margin-bottom:1px;"><tr>';
  127. html += '<td unselectable="on"';
  128. var bSiblingContainsIcon = false;
  129. if(this.m_icon.getPath() == '') {
  130. var siblingCount = this.m_parent.getNumItems();
  131. for(var siblingIdx = 0; siblingIdx < siblingCount; ++siblingIdx) {
  132. siblingMenuItem = this.m_parent.get(siblingIdx);
  133. if(typeof siblingMenuItem.getIcon == "function" && siblingMenuItem.getIcon().getPath()) {
  134. // temporary for now to get alignment working on the context menu.
  135. bSiblingContainsIcon = true;
  136. break;
  137. }
  138. }
  139. }
  140. if(bSiblingContainsIcon || this.m_icon.getPath() != '') {
  141. html += ' width="16px" style="padding-right: 3px">';
  142. } else {
  143. html += ' width="7px" height="18px">';
  144. }
  145. html += this.m_icon.draw();
  146. html += '</td>';
  147. html += '<td unselectable="on" nowrap="nowrap" align="left">';
  148. html += this.m_label;
  149. html += '</td>';
  150. html += '<td unselectable="on" align="right">';
  151. html += '<img src="' +'../ags/images/menu_arrow.gif" alt="Arrow for cascaded list"/>';
  152. html += '</td>';
  153. html += '</tr></table>';
  154. html += '</div>';
  155. }
  156. return html;
  157. }
  158. //To POST the XML it must be encoded. This is done here. Therefore we
  159. //can build a more readable XML string.
  160. window.xmlEncode = function(text)
  161. {
  162. var entityMap = {
  163. ">" : "gt",
  164. "<" : "lt",
  165. "\"" : null,
  166. "&" : null
  167. };
  168. var retval = "";
  169. if(!text)
  170. {
  171. return "";
  172. }
  173. for(var i =0; i < text.length; i++)
  174. {
  175. var ch = text.charAt(i);
  176. if(entityMap[ch])
  177. {
  178. retval += "&"+entityMap[ch]+";";
  179. }
  180. else
  181. {
  182. retval += ch;
  183. }
  184. }
  185. return retval;
  186. }
  187. function CMenuItem_onmouseover(evt) {
  188. //get the event in a cross-browser fashion
  189. evt = (evt) ? evt : ((event) ? event : null);
  190. // get the menu item from the html element which is handling the event
  191. var menuItem = null;
  192. var htmlElement = null;
  193. if(typeof this.menuItem != 'undefined') {
  194. menuItem = this.menuItem;
  195. htmlElement = this;
  196. }
  197. else if (this instanceof CMenuItem) {
  198. menuItem = this;
  199. htmlElement = this.getHTMLElement();
  200. }
  201. if(menuItem == null || !(menuItem instanceof CMenuItem) || !menuItem.isEnabled())
  202. return;
  203. if(typeof menuItem.getStyle() == "object") {
  204. htmlElement.className = menuItem.getStyle().getRolloverState();
  205. }
  206. menu = menuItem.getMenu();
  207. if(menu != null) {
  208. var pageWidth = 0;
  209. var pageHeight = 0;
  210. if(typeof window.innerWidth != "undefined")
  211. pageWidth = window.innerWidth;
  212. else
  213. pageWidth = document.body.clientWidth;
  214. if(typeof window.innerHeight != "undefined")
  215. pageHeight = window.innerHeight;
  216. else
  217. pageHeight = document.body.clientHeight;
  218. if(menuItem.getMenuType() == 'cascaded') {
  219. if(menu.isVisible() == false) {
  220. menu.setHTMLContainer((document.all && typeof htmlElement.document != "undefined") ? htmlElement.document.body : htmlElement.ownerDocument.body);
  221. menu.draw();
  222. menu.show();
  223. if(menu.get(0) != null) {
  224. menu.get(0).setFocus();
  225. }
  226. }
  227. } else if(menuItem.getMenuType() == 'dropDown') {
  228. // check with the parent to see if there current are menus open. If there are, we'll automatically open this menu
  229. menuItemParent = menuItem.getParent();
  230. var numOfItems = menuItemParent.getNumItems();
  231. for(var i = 0; i < numOfItems; ++i) {
  232. currentItem = menuItemParent.get(i);
  233. if(currentItem != menuItem && typeof currentItem.getMenu == "function" && currentItem.getMenu() && currentItem.getMenu().isVisible()) {
  234. // the user clicked on the menu
  235. menu.setHTMLContainer((document.all && typeof htmlElement.document != "undefined") ? htmlElement.document.body : htmlElement.ownerDocument.body);
  236. menu.draw();
  237. menu.show();
  238. break;
  239. }
  240. }
  241. }
  242. }
  243. // send the message up to our parent
  244. if(menuItem.getParent() != null && typeof menuItem.getParent().onmouseover == "function")
  245. menuItem.getParent().onmouseover(evt);
  246. // notify our observers of this event
  247. menuItem.getObservers().notify(CMenuItem_onmouseover);
  248. }
  249. function CMenuItem_onfocus(evt) {
  250. //get the event in a cross-browser fashion
  251. evt = (evt) ? evt : ((event) ? event : null);
  252. // get the menu item from the html element which is handling the event
  253. var menuItem = null;
  254. var htmlElement = null;
  255. if(typeof this.menuItem != 'undefined') {
  256. menuItem = this.menuItem;
  257. htmlElement = this;
  258. }
  259. else if (this instanceof CMenuItem) {
  260. menuItem = this;
  261. htmlElement = this.getHTMLElement();
  262. }
  263. if(menuItem == null || !(menuItem instanceof CMenuItem) || !menuItem.isEnabled())
  264. return;
  265. if(menuItem.getMenuType() == "dropDown") {
  266. AccessibilityHandler.setTabindex(menuItem);
  267. }
  268. if(typeof menuItem.getStyle() == "object") {
  269. htmlElement.className = menuItem.getStyle().getRolloverState();
  270. AccessibilityHandler.setRolloverState(menuItem);
  271. }
  272. // send the message up to our parent (a fake mouseover)
  273. if(menuItem.getParent() != null && typeof menuItem.getParent().onmouseover == "function")
  274. menuItem.getParent().onmouseover(evt);
  275. // notify our observers of this event
  276. menuItem.getObservers().notify(CMenuItem_onfocus);
  277. }
  278. function CMenuItem_onmouseout(evt) {
  279. //get the event in a cross-browser fashion
  280. evt = (evt) ? evt : ((event) ? event : null);
  281. var menuItem = null;
  282. var htmlElement = null;
  283. if(typeof this.menuItem != 'undefined') {
  284. menuItem = this.menuItem;
  285. htmlElement = this;
  286. }
  287. else if (this instanceof CMenuItem) {
  288. menuItem = this;
  289. htmlElement = this.getHTMLElement();
  290. }
  291. // get the menu item from the html element which is handling the event
  292. if(menuItem == null || !(menuItem instanceof CMenuItem) || !menuItem.isEnabled())
  293. return;
  294. if(typeof menuItem.getStyle() == "object" && !(menuItem.getMenu() != null && menuItem.getMenu().isVisible())) {
  295. htmlElement.className = menuItem.getStyle().getNormalState();
  296. }
  297. // send the message up to our parent
  298. if(menuItem.getParent() != null && typeof menuItem.getParent().onmouseout == "function")
  299. menuItem.getParent().onmouseout(evt);
  300. // notify our observers of this event
  301. menuItem.getObservers().notify(CMenuItem_onmouseout);
  302. }
  303. function CMenuItem_ondragstart(evt) {
  304. event.cancelBubble = true;
  305. return false;
  306. }
  307. function CMenuItem_onmouseup(evt) {
  308. //get the event in a cross-browser fashion
  309. evt = (evt) ? evt : ((event) ? event : null);
  310. var buttonValue = (document.all && typeof this.document != "undefined")?1:0;
  311. if (evt.button != buttonValue) {
  312. //Only do it for left click
  313. return;
  314. }
  315. var menuItem = null;
  316. var htmlElement = null;
  317. if(typeof this.menuItem != 'undefined') {
  318. menuItem = this.menuItem;
  319. htmlElement = this;
  320. }
  321. else if (this instanceof CMenuItem) {
  322. menuItem = this;
  323. htmlElement = this.getHTMLElement();
  324. }
  325. if(menuItem != null && menuItem instanceof CMenuItem) {
  326. if(!menuItem.isEnabled())
  327. return;
  328. if(menuItem.getMenu() != null) {
  329. if(menuItem.getMenuType() == 'cascaded') {
  330. // do nothing
  331. } else if(menuItem.getMenuType() == 'dropDown') {
  332. menu = menuItem.getMenu();
  333. if(menu.isVisible() == false) {
  334. // the user clicked on the menu
  335. menu.setHTMLContainer((document.all && typeof htmlElement.document != "undefined") ? htmlElement.document.body : htmlElement.ownerDocument.body);
  336. menu.draw();
  337. menu.show();
  338. if(menu.get(0) != null) {
  339. menu.get(0).setFocus();
  340. }
  341. } else {
  342. menu.remove(true);
  343. }
  344. }
  345. } else {
  346. // handle the event
  347. eval(menuItem.getAction());
  348. }
  349. if (typeof getReportFrame != "undefined")
  350. getReportFrame().clearTextSelection();
  351. else if (typeof clearTextSelection != "undefined")
  352. clearTextSelection();
  353. // send the message up to our parent
  354. if(menuItem.getParent() != null && typeof menuItem.getParent().onmouseup == "function")
  355. menuItem.getParent().onmouseup(evt);
  356. // notify our observers of this event
  357. if(menuItem.getMenuType() != 'cascaded')
  358. menuItem.getObservers().notify(CMenuItem_onmouseup);
  359. }
  360. if(evt != null)
  361. evt.cancelBubble = true;
  362. return false;
  363. }
  364. function CMenuItem_onkeydown(evt) {
  365. // do nothing
  366. }
  367. function CMenuItem_onkeypress(evt) {
  368. //get the event in a cross-browser fashion
  369. evt = (evt) ? evt : ((event) ? event : null);
  370. var keyCode = evt.keyCode || evt.which;
  371. if(AccessibilityHandler.isEnabled() && AccessibilityHandler.isSupportedKeycode(keyCode)) {
  372. var menuItem = null;
  373. if(typeof this.menuItem != 'undefined') {
  374. menuItem = this.menuItem;
  375. }
  376. else if (this instanceof CMenuItem) {
  377. menuItem = this;
  378. }
  379. if(menuItem != null && menuItem instanceof CMenuItem && typeof evt == "object" && evt != null) {
  380. //flag which determines if we notify observers of the event
  381. var performNotification = true;
  382. //check for Tab key press
  383. if (keyCode == 9) {
  384. // for "dropDown" and "dynamic" menu item, transfer the event to HTML body.
  385. if (menuItem.getMenuType() == "dropDown" || menuItem.getMenuType() == "dynamic") {
  386. return true;
  387. }
  388. // block the Tab key press for others menu item.
  389. else {
  390. return false;
  391. }
  392. }
  393. //check for the Enter key press
  394. else if (keyCode == 13) {
  395. //menu item should always be enabled if you can tab to it, but just in case
  396. if(!menuItem.isEnabled())
  397. return;
  398. if(isNormalMenuItem(menuItem)){
  399. if(menuItem.getMenu() != null) {
  400. performNotification = false;
  401. var menu = menuItem.getMenu();
  402. menuItem.showMenu(menu);
  403. } else {
  404. // handle the event
  405. eval(menuItem.getAction());
  406. }
  407. } else {
  408. performNotification = false;
  409. }
  410. }
  411. //check for Esc key press
  412. else if (keyCode == 27) {
  413. if (menuItem.getMenuType() == "dynamic") {
  414. menuItem.setFocus();
  415. }
  416. if (menuItem.getMenuType() == "dropDown") {
  417. var menu = menuItem.getMenu();
  418. menu.remove(true);
  419. }
  420. //close the menu
  421. menuItem.getParent().hide();
  422. //cancel event being bubbled up the hierarchy since only one level of menus needs to hide
  423. return;
  424. }
  425. //check for Space key press
  426. else if (keyCode == 32) {
  427. if(isNormalMenuItem(menuItem)) {
  428. var menu = menuItem.getMenu();
  429. menuItem.showMenu(menu);
  430. }
  431. performNotification = false;
  432. }
  433. //check for Left and Right key press
  434. else if (keyCode == 37 || keyCode == 39) {
  435. if (isMenubarItem(menuItem)) {
  436. var nextItem = AccessibilityHandler.getNextItem(menuItem, keyCode);
  437. nextItem.setFocus();
  438. }
  439. else if (isCascadedMenuItem(menuItem) && keyCode == 39) {
  440. var menu = menuItem.getMenu();
  441. menuItem.showMenu(menu);
  442. }
  443. else if (isCascadedSubMenuItem(menuItem) && keyCode == 37) {
  444. menuItem.getParent().hide();
  445. return;
  446. }
  447. performNotification = false;
  448. }
  449. //check for Up and Down key press
  450. else if (keyCode == 38 || keyCode == 40) {
  451. if (isNormalMenuItem(menuItem) && !isMenubarItem(menuItem)) {
  452. var nextItem = AccessibilityHandler.getNextItem(menuItem, keyCode);
  453. nextItem.setFocus();
  454. }
  455. else if (isMenubarItem(menuItem) && keyCode == 40) {
  456. var menu = menuItem.getMenu();
  457. menuItem.showMenu(menu);
  458. }
  459. performNotification = false;
  460. }
  461. // send the message up to our parent
  462. if (menuItem.getParent() != null && typeof menuItem.getParent().onkeypress == "function")
  463. menuItem.getParent().onkeypress(evt);
  464. if (performNotification) {
  465. // notify our observers of this event
  466. menuItem.getObservers().notify(CMenuItem_onkeypress);
  467. }
  468. }
  469. }
  470. if(evt != null)
  471. evt.cancelBubble = true;
  472. return false;
  473. }
  474. function isMenubarItem(menuItem) {
  475. // the visible is false means the sub menu is hidden, so it can response to the key press
  476. if (menuItem.getMenuType() == "dropDown" && menuItem.getMenu().isVisible() == false)
  477. return true;
  478. return false;
  479. }
  480. function isCascadedMenuItem(menuItem) {
  481. // the visible is false means the sub menu is hidden, so it can response to the key press
  482. if (menuItem.getMenuType() == "cascaded" && menuItem.getMenu().isVisible() == false)
  483. return true;
  484. return false;
  485. }
  486. function isCascadedSubMenuItem(menuItem) {
  487. var parentItem = menuItem.getParent();
  488. if (parentItem.getParent() != null && parentItem.getParent().getMenuType() == "cascaded")
  489. return true;
  490. return false;
  491. }
  492. function isNormalMenuItem(menuItem) {
  493. // if the menuItem itself is not a menu or even it is the sub menu is hidden, response the key press
  494. if (menuItem.getMenu() == null || menuItem.getMenu().isVisible() == false)
  495. return true;
  496. return false;
  497. }
  498. function CMenuItem_showMenu(menu) {
  499. // show the menu
  500. if(this.getMenuType() == 'cascaded') {
  501. menu.draw();
  502. menu.show();
  503. if(menu.get(0) != null) {
  504. menu.get(0).setFocus();
  505. }
  506. }
  507. else if(this.getMenuType() == 'dropDown') {
  508. menu.draw();
  509. menu.show();
  510. if(menu.get(0) != null) {
  511. menu.get(0).setFocus();
  512. }
  513. }
  514. }
  515. function CMenuItem_enableTabindex() {
  516. this.getHTMLElement().setAttribute("tabindex", "0");
  517. }
  518. function CMenuItem_disableTabindex() {
  519. this.getHTMLElement().setAttribute("tabindex", "-1");
  520. }
  521. function CMenuItem_createDropDownMenu(menuStyle) {
  522. this.m_menu = new CMenu('dropDownMenu_'+this.getId(),menuStyle);
  523. this.m_menu.setParent(this);
  524. this.m_menuType = 'dropDown';
  525. return this.m_menu;
  526. }
  527. function CMenuItem_createCascadedMenu(menuStyle,offsetXCoords, offsetYCoords) {
  528. this.m_menu = new CMenu('cascadedMenu_'+this.getId(),menuStyle);
  529. this.m_menu.setOffsetXCoords(offsetXCoords);
  530. this.m_menu.setOffsetYCoords(offsetYCoords);
  531. this.m_menu.setParent(this);
  532. this.getParent().setContainsCascadedChildren(true);
  533. this.m_menuType = 'cascaded';
  534. return this.m_menu;
  535. }
  536. function CMenuItem_addOwnerDrawControl(control, type) {
  537. this.m_menu = control;
  538. this.m_menuType = type;
  539. if(typeof control.setParent != "undefined")
  540. this.m_menu.setParent(this);
  541. }
  542. function CMenuItem_attachEvents() {
  543. var hMenuItem = this.getHTMLElement();
  544. if(hMenuItem == null)
  545. return; // just to be safe
  546. hMenuItem.onmouseover = this.onmouseover;
  547. hMenuItem.onmouseout = this.onmouseout;
  548. hMenuItem.onmouseup = this.onmouseup;
  549. hMenuItem.onkeypress = this.onkeypress;
  550. hMenuItem.onfocus = this.onfocus;
  551. hMenuItem.onblur = this.onblur;
  552. hMenuItem.onkeydown = this.onkeydown;
  553. hMenuItem.ondragstart = this.ondragstart;
  554. hMenuItem.menuItem = eval(this);
  555. }
  556. function CMenuItem_remove() {
  557. }
  558. function CMenuItem_getMenu() {
  559. return this.m_menu;
  560. }
  561. function CMenuItem_getMenuType() {
  562. return this.m_menuType;
  563. }
  564. function CMenuItem_setMenuType(menuType) {
  565. return this.m_menuType = menuType;
  566. }
  567. function CMenuItem_getStyle() {
  568. return this.m_style;
  569. }
  570. function CMenuItem_setStyle(style) {
  571. this.m_style = style;
  572. }
  573. function CMenuItem_hide() {
  574. this.m_bVisible = false;
  575. }
  576. function CMenuItem_show() {
  577. this.m_bVisible = true;
  578. }
  579. function CMenuItem_setCapability(capability) {
  580. this.m_capability = capability;
  581. }
  582. function CMenuItem_getCapability() {
  583. return this.m_capability;
  584. }
  585. function CMenuItem_enable() {
  586. if(typeof this.getStyle() == "object") {
  587. var htmlElement = this.getHTMLElement();
  588. if(htmlElement != null) {
  589. htmlElement.className = this.getStyle().getNormalState();
  590. }
  591. this.m_bEnabled = true;
  592. this.getIcon().enable();
  593. }
  594. }
  595. function CMenuItem_disable() {
  596. if(typeof this.getStyle() == "object") {
  597. var htmlElement = this.getHTMLElement();
  598. if(htmlElement != null) {
  599. htmlElement.className = this.getStyle().getDisabledState();
  600. }
  601. this.m_bEnabled = false;
  602. this.getIcon().disable();
  603. }
  604. }
  605. function CMenuItem_isVisible() {
  606. return this.m_bVisible;
  607. }
  608. function CMenuItem_isEnabled() {
  609. return this.m_bEnabled;
  610. }
  611. function CMenuItem_getAction() {
  612. return this.m_action;
  613. }
  614. function CMenuItem_getIcon() {
  615. return this.m_icon;
  616. }
  617. function CMenuItem_getLabel() {
  618. return this.m_label;
  619. }
  620. function CMenuItem_getHTMLElement() {
  621. var htmlElement = null;
  622. if(this.getParent && typeof this.getParent().getHTMLContainer == "function") {
  623. var htmlContainer = this.getParent().getHTMLContainer();
  624. if(htmlContainer != null) {
  625. htmlElement = htmlContainer.ownerDocument.getElementById(this.getId());
  626. }
  627. }
  628. return htmlElement;
  629. }
  630. function CMenuItem_setFocus() {
  631. if (document.getElementById(this.m_id).focus) {
  632. document.getElementById(this.m_id).focus();
  633. }
  634. }
  635. CMenuItem.prototype.draw = CMenuItem_draw;
  636. CMenuItem.prototype.onmouseover = CMenuItem_onmouseover;
  637. CMenuItem.prototype.onmouseout = CMenuItem_onmouseout;
  638. CMenuItem.prototype.onmouseup = CMenuItem_onmouseup;
  639. CMenuItem.prototype.onkeypress = CMenuItem_onkeypress;
  640. CMenuItem.prototype.onkeydown = CMenuItem_onkeydown;
  641. CMenuItem.prototype.onfocus = CMenuItem_onfocus;
  642. CMenuItem.prototype.ondragstart = CMenuItem_ondragstart;
  643. CMenuItem.prototype.onblur = CMenuItem_onmouseout;
  644. CMenuItem.prototype.attachEvents = CMenuItem_attachEvents;
  645. CMenuItem.prototype.getMenu = CMenuItem_getMenu;
  646. CMenuItem.prototype.setMenuType = CMenuItem_setMenuType;
  647. CMenuItem.prototype.getMenuType = CMenuItem_getMenuType;
  648. CMenuItem.prototype.setParent = CMenuItem_setParent;
  649. CMenuItem.prototype.getParent = CMenuItem_getParent;
  650. CMenuItem.prototype.getObservers = CMenuItem_getObservers;
  651. CMenuItem.prototype.getId = CMenuItem_getId;
  652. CMenuItem.prototype.remove = CMenuItem_remove;
  653. CMenuItem.prototype.setStyle = CMenuItem_setStyle;
  654. CMenuItem.prototype.getStyle = CMenuItem_getStyle;
  655. CMenuItem.prototype.createDropDownMenu = CMenuItem_createDropDownMenu;
  656. CMenuItem.prototype.createCascadedMenu = CMenuItem_createCascadedMenu;
  657. CMenuItem.prototype.addOwnerDrawControl = CMenuItem_addOwnerDrawControl;
  658. CMenuItem.prototype.isVisible = CMenuItem_isVisible;
  659. CMenuItem.prototype.hide = CMenuItem_hide;
  660. CMenuItem.prototype.show = CMenuItem_show;
  661. CMenuItem.prototype.isEnabled = CMenuItem_isEnabled;
  662. CMenuItem.prototype.enable = CMenuItem_enable;
  663. CMenuItem.prototype.disable = CMenuItem_disable;
  664. CMenuItem.prototype.getAction = CMenuItem_getAction;
  665. CMenuItem.prototype.getIcon = CMenuItem_getIcon;
  666. CMenuItem.prototype.getLabel = CMenuItem_getLabel;
  667. CMenuItem.prototype.getHTMLElement = CMenuItem_getHTMLElement;
  668. CMenuItem.prototype.setFocus = CMenuItem_setFocus;
  669. CMenuItem.prototype.update = new Function("return true");
  670. CMenuItem.prototype.setCapability = CMenuItem_setCapability;
  671. CMenuItem.prototype.getCapability = CMenuItem_getCapability;
  672. CMenuItem.prototype.showMenu = CMenuItem_showMenu;
  673. CMenuItem.prototype.enableTabindex = CMenuItem_enableTabindex;
  674. CMenuItem.prototype.disableTabindex = CMenuItem_disableTabindex;
  675. /*/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  676. Class CSeperator
  677. todo : Add commments describing class....
  678. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/
  679. /*
  680. CSeperator styles:
  681. 1. horizonal_blank
  682. 2. vertical_blank
  683. 3. vertical_line
  684. 4. horizonal_line
  685. */
  686. function CSeperator(type, size, style) {
  687. this.m_type=type;
  688. this.m_size=size;
  689. this.m_bVisible = true;
  690. if(typeof style == "object")
  691. this.m_style = new CUIStyle(style.getNormalState(),style.getRolloverState(),style.getDepressedState(),style.getDepressedRolloverState(),style.getDisabledState());
  692. else
  693. this.m_style = new CUIStyle('','','','','');
  694. }
  695. function CSeperator_draw() {
  696. if(this.m_style == '')
  697. return;
  698. html='';
  699. switch(this.m_type) {
  700. case "horizonal_blank": {
  701. html += '<td style="padding:0px;"><img border="0" src="../common/images/spacer.gif" alt="" height="1" width="';
  702. html += this.m_size + "px";
  703. html += '"/></td>';
  704. break;
  705. }
  706. case "horizontal_line": {
  707. html += '<hr SIZE="1px" NOSHADE="NOSHADE" CLASS="';
  708. html += this.getStyle().getActiveState();
  709. html += '"/>';
  710. break;
  711. }
  712. case "vertical_blank": {
  713. html += '<tr>';
  714. html += '<td style="padding:0px;"><img border="0" src="../common/images/spacer.gif" alt="" width="1px" height="';
  715. html += this.m_size + "px";
  716. html += '"/></td></tr>';
  717. break;
  718. }
  719. case "vertical_line": {
  720. html += '<td style="padding:0px;"><hr NOSHADE="NOSHADE" WIDTH="1px" ALIGN="CENTER" CLASS="';
  721. html += this.getStyle().getActiveState();
  722. html += '" SIZE="'
  723. html += this.getSize() + "px";
  724. html += '"/></td>';
  725. break;
  726. }
  727. case "vertical_line_img": {
  728. //html += '<tr>';
  729. html += '<td ALIGN="center" role="separator" style="padding:0px;width:16px;align:center;"><img border="0" src="../ags/images/toolbar/tool_sep.gif" alt="" width="1px" height="';
  730. html += this.m_size + "px";
  731. html += '"/></td>';
  732. //</tr>';
  733. break;
  734. }
  735. }
  736. return html;
  737. }
  738. function CSeperator_getSize() {
  739. return this.m_size;
  740. }
  741. function CSeperator_setSize(size) {
  742. this.m_size = size;
  743. }
  744. function CSeperator_setStyle(style) {
  745. this.m_style = style;
  746. }
  747. function CSeperator_getStyle() {
  748. return this.m_style;
  749. }
  750. function CSeperator_setType(type) {
  751. this.m_type = type;
  752. }
  753. function CSeperator_getType() {
  754. return this.m_type;
  755. }
  756. function CSeperator_hide() {
  757. this.m_bVisible = false;
  758. }
  759. function CSeperator_show() {
  760. this.m_bVisible = true;
  761. }
  762. function CSeperator_isVisible() {
  763. return this.m_bVisible;
  764. }
  765. CSeperator.prototype.draw = CSeperator_draw;
  766. CSeperator.prototype.setSize = CSeperator_setSize;
  767. CSeperator.prototype.getSize = CSeperator_getSize;
  768. CSeperator.prototype.setStyle = CSeperator_setStyle;
  769. CSeperator.prototype.getStyle = CSeperator_getStyle;
  770. CSeperator.prototype.getType = CSeperator_getType;
  771. CSeperator.prototype.setType = CSeperator_setType;
  772. CSeperator.prototype.isVisible = CSeperator_isVisible;
  773. CSeperator.prototype.show = CSeperator_show;
  774. CSeperator.prototype.hide = CSeperator_hide;