CIcon.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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 CIcon
  14. todo : Add commments describing class....
  15. */
  16. function CIcon(iconPath, toolTip) {
  17. this.m_iconPath = iconPath;
  18. this.m_toolTip = toolTip;
  19. this.m_enabled = true;
  20. // The UI framework defaults the icon width/height to 16. If you need to change this, call setHeight and/or setWidth
  21. this.m_height = 16;
  22. this.m_width = 16;
  23. }
  24. function CIcon_draw() {
  25. var html='';
  26. html += '<img src="';
  27. if(typeof this.m_iconPath != "undefined" && this.m_iconPath !== '' && this.m_iconPath != "blankIcon") {
  28. if(this.m_enabled == true) {
  29. html += this.m_iconPath;
  30. }
  31. else {
  32. html += this.getDisabledImagePath();
  33. }
  34. html += '" title="';
  35. if(typeof this.m_toolTip == "string" && this.m_toolTip.length > 0) {
  36. html += this.m_toolTip;
  37. }
  38. html += '" width="';
  39. html += this.m_width;
  40. html += '" height="';
  41. html += this.m_height;
  42. html += '"/>';
  43. } else {
  44. html += '../common/images/spacer.gif';
  45. if (this.m_iconPath == "blankIcon")
  46. {
  47. html += '" width="';
  48. html += this.m_width;
  49. html += '" height="';
  50. html += this.m_height;
  51. html += '"/>';
  52. }
  53. else
  54. {
  55. html += '" width="1" height="1"/>';
  56. }
  57. }
  58. return html;
  59. }
  60. function CIcon_getDisabledImagePath() {
  61. var imagePathArray = this.m_iconPath.split('/');
  62. var iconPath='';
  63. for(var i = 0; i < (imagePathArray.length -1); ++i) {
  64. iconPath += imagePathArray[i] + '/';
  65. }
  66. iconPath += 'dis_' + imagePathArray[imagePathArray.length-1];
  67. return iconPath;
  68. }
  69. function CIcon_getPath() {
  70. return this.m_iconPath;
  71. }
  72. function CIcon_setPath(path) {
  73. this.m_iconPath = path;
  74. }
  75. function CIcon_getToolTip() {
  76. return this.m_toolTip;
  77. }
  78. function CIcon_setToolTip(toolTip) {
  79. this.m_toolTip = toolTip;
  80. }
  81. function CIcon_enable() {
  82. this.m_enabled = true;
  83. }
  84. function CIcon_disable() {
  85. this.m_enabled = false;
  86. }
  87. function CIcon_isEnabled() {
  88. return this.m_enabled;
  89. }
  90. function CIcon_setHeight(height) {
  91. this.m_height = height;
  92. }
  93. function CIcon_getHeight() {
  94. return this.m_height;
  95. }
  96. function CIcon_setWidth(width) {
  97. this.m_width = width;
  98. }
  99. function CIcon_getWidth() {
  100. return this.m_width;
  101. }
  102. CIcon.prototype.draw = CIcon_draw;
  103. CIcon.prototype.enable = CIcon_enable;
  104. CIcon.prototype.disable = CIcon_disable;
  105. CIcon.prototype.isEnabled = CIcon_isEnabled;
  106. CIcon.prototype.getDisabledImagePath = CIcon_getDisabledImagePath;
  107. CIcon.prototype.getPath = CIcon_getPath;
  108. CIcon.prototype.setPath = CIcon_setPath;
  109. CIcon.prototype.setHeight = CIcon_setHeight;
  110. CIcon.prototype.getHeight = CIcon_getHeight;
  111. CIcon.prototype.setWidth = CIcon_setWidth;
  112. CIcon.prototype.getWidth = CIcon_getWidth;