CToolbarSelect.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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 : CToolbarSelect
  14. Description :
  15. -----------------------------------------------------------------------------------------------------*/
  16. function CToolbarSelect(parent, name, command, label, toolTip) {
  17. this.m_parent = parent;
  18. this.m_name = name;
  19. this.m_command = command;
  20. this.m_label = label;
  21. this.m_toolTip = toolTip;
  22. this.m_items = [];
  23. if(typeof this.m_parent == "object" && typeof this.m_parent.add == "function")
  24. {
  25. this.m_parent.add(this);
  26. }
  27. //add a defalt item
  28. if (label)
  29. {
  30. this.add("", label);
  31. }
  32. }
  33. function CSelectItem (sUse, sDisplay) {
  34. this.m_sUse = sUse;
  35. this.m_sDisplay = sDisplay;
  36. }
  37. function CSelectItem_getUse() {
  38. return this.m_sUse;
  39. }
  40. function CSelectItem_getDisplay() {
  41. return this.m_sDisplay;
  42. }
  43. CSelectItem.prototype.getUse = CSelectItem_getUse;
  44. CSelectItem.prototype.getDisplay = CSelectItem_getDisplay;
  45. function CToolbarSelect_draw() {
  46. var html = '<select id="' + this.m_name + '" name="' + this.m_name + '" onchange="' + this.m_command + '"';
  47. if (this.m_toolTip != "") {
  48. html += ' title="' + this.m_toolTip + '"';
  49. }
  50. html += '>';
  51. html += this.drawItems();
  52. html += '</select>';
  53. return html;
  54. }
  55. function CToolbarSelect_drawItems()
  56. {
  57. var html='';
  58. for (var i=0; i<this.m_items.length; i++)
  59. {
  60. html += '<option value="'+ this.m_items[i].getUse() +'">'+ this.m_items[i].getDisplay() +'</option>';
  61. }
  62. return html;
  63. }
  64. function CToolbarSelect_add(sUse, sDisplay)
  65. {
  66. var newItem = new CSelectItem(sUse, sDisplay);
  67. this.m_items = this.m_items.concat(newItem);
  68. }
  69. function CToolbarSelect_isVisible() {
  70. //return this.m_bVisible;
  71. return true;
  72. }
  73. CToolbarSelect.prototype.draw = CToolbarSelect_draw;
  74. CToolbarSelect.prototype.drawItems = CToolbarSelect_drawItems;
  75. CToolbarSelect.prototype.isVisible = CToolbarSelect_isVisible;
  76. CToolbarSelect.prototype.add = CToolbarSelect_add;