CMenuItem.js 21 KB

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