FTB-ToolbarItems.js
上传用户:tongfeicq
上传日期:2022-07-20
资源大小:2856k
文件大小:3k
源码类别:

.net编程

开发平台:

Visual C++

  1. /* FTB_Button
  2. ---------------------------------------------- */
  3. function FTB_Button(id, commandIdentifier, customAction, customStateQuery, htmlModeEnabled, customEnabled) {
  4. this.state = FTB_BUTTON_OFF;
  5. this.id = id;
  6. this.ftb = null;
  7. this.commandIdentifier = commandIdentifier;
  8. this.customAction = customAction;
  9. this.customStateQuery = customStateQuery;
  10. this.disabled = false;
  11. this.htmlModeEnabled = htmlModeEnabled ;
  12. this.customEnabled = customEnabled;
  13. this.td = document.getElementById(id);
  14. this.td.button = this;
  15. if (FTB_Browser.isIE) {
  16. this.buttonImage = this.td.childNodes[0];
  17. } else {
  18. this.buttonImage = this.td.childNodes[0];
  19. }
  20. };
  21. FTB_Button.prototype.Initialize = function() {
  22. var id=this.td.button.id;
  23. FTB_AddEvent(this.td,"click",function() { if(FTB_Browser.isIE) document.getElementById(id).button.Click(); else this.button.Click(); } );
  24. FTB_AddEvent(this.td,"mouseover",function() { if(FTB_Browser.isIE) document.getElementById(id).button.MouseOver(); else this.button.MouseOver(); } );
  25. FTB_AddEvent(this.td,"mouseout",function() { if(FTB_Browser.isIE) document.getElementById(id).button.MouseOut(); else this.button.MouseOut(); } );
  26. };
  27. FTB_Button.prototype.Click = function() {
  28. if (!this.disabled) {
  29. if (this.customAction) 
  30. this.customAction();
  31. else if (this.commandIdentifier != null && this.commandIdentifier != '') 
  32. this.ftb.ExecuteCommand(this.commandIdentifier);
  33. this.ftb.Event();
  34. }
  35. };
  36. FTB_Button.prototype.MouseOver = function() {
  37. if (!this.disabled) this.SetButtonBackground("Over");
  38. };
  39. FTB_Button.prototype.MouseOut = function() {
  40. if (!this.disabled) this.SetButtonBackground("Out");
  41. };
  42. FTB_Button.prototype.SetButtonBackground = function(mouseState) {
  43. this.SetButtonStyle(mouseState);
  44. }
  45. FTB_Button.prototype.SetButtonStyle = function(mouseState) {
  46. this.td.className = this.ftb.id + "_Button_" + ((this.state == FTB_BUTTON_ON) ? "On" : "Off") + "_" + mouseState;
  47. }
  48. /* FTB_DropDownList
  49. ---------------------------------------------- */
  50. function FTB_DropDownList(id, commandIdentifier, customAction, customStateQuery, customEnabled) {
  51. this.id = id;
  52. this.ftb = null;
  53. this.commandIdentifier = commandIdentifier;
  54. this.customAction = customAction;
  55. this.customStateQuery = customStateQuery;
  56. this.customEnabled = customEnabled;
  57. this.list = document.getElementById(id);
  58. if (this.list) {
  59. this.list.dropDownList = this;
  60. FTB_AddEvent(this.list,"change",function() { if(FTB_Browser.isIE) document.getElementById(id).dropDownList.Select(); else this.dropDownList.Select(); } );
  61. } else {
  62. alert(id + ' is not setup properly');
  63. }
  64. };
  65. FTB_DropDownList.prototype.Select = function() {
  66. if (this.customAction) 
  67. this.customAction();
  68. else if (this.commandIdentifier != null && this.commandIdentifier != '') 
  69. this.ftb.ExecuteCommand(this.commandIdentifier, '', this.list.options[this.list.selectedIndex].value);
  70. this.list.selectedIndex = 0;
  71. this.ftb.Event();
  72. };
  73. FTB_DropDownList.prototype.SetSelected = function(commandValue) {
  74. value = String(commandValue).toLowerCase();
  75. for (var i=0; i<this.list.options.length; i++) {
  76. if (this.list.options[i].value.toLowerCase() == value || this.list.options[i].text.toLowerCase() == value) {
  77. this.list.selectedIndex = i;
  78. return;
  79. }
  80. }
  81. };