Wizard.js
上传用户:kimgenplus
上传日期:2016-06-05
资源大小:20877k
文件大小:6k
源码类别:

OA系统

开发平台:

Java

  1. /*
  2. Copyright (c) 2004-2006, The Dojo Foundation
  3. All Rights Reserved.
  4. Licensed under the Academic Free License version 2.1 or above OR the
  5. modified BSD license. For more information on Dojo licensing, see:
  6. http://dojotoolkit.org/community/licensing.shtml
  7. */
  8. dojo.provide("dojo.widget.Wizard");
  9. dojo.require("dojo.widget.*");
  10. dojo.require("dojo.widget.LayoutContainer");
  11. dojo.require("dojo.widget.ContentPane");
  12. dojo.require("dojo.event.*");
  13. dojo.require("dojo.html.style");
  14. dojo.widget.defineWidget("dojo.widget.WizardContainer", dojo.widget.LayoutContainer, {templateString:"<div class="WizardContainer" dojoAttachPoint="wizardNode">n <div class="WizardText" dojoAttachPoint="wizardPanelContainerNode">n </div>n <div class="WizardButtonHolder" dojoAttachPoint="wizardControlContainerNode">n <input class="WizardButton" type="button" dojoAttachPoint="previousButton"/>n <input class="WizardButton" type="button" dojoAttachPoint="nextButton"/>n <input class="WizardButton" type="button" dojoAttachPoint="doneButton" style="display:none"/>n <input class="WizardButton" type="button" dojoAttachPoint="cancelButton"/>n </div>n</div>n", templateCssString:".WizardContainer {ntbackground: #EEEEEE;ntborder: #798EC5 1px solid;ntpadding: 2px;n}nn.WizardTitle {ntcolor: #003366;ntpadding: 8px 5px 15px 2px;ntfont-weight: bold;ntfont-size: x-small;ntfont-style: normal;ntfont-family: Verdana, Arial, Helvetica;nttext-align: left;n}nn.WizardText {ntcolor: #000033;ntfont-weight: normal;ntfont-size: xx-small;ntfont-family: Verdana, Arial, Helvetica;ntpadding: 2 50; text-align: justify;n}nn.WizardLightText {ntcolor: #666666;ntfont-weight: normal;ntfont-size: xx-small;ntfont-family: verdana, arial, helvetica;ntpadding: 2px 50px;nttext-align: justify;n}nn.WizardButtonHolder {nttext-align: right;ntpadding: 10px 5px;n}nn.WizardButton {ntcolor: #ffffff;ntbackground: #798EC5;ntfont-size: xx-small;ntfont-family: verdana, arial, helvetica, sans-serif;ntborder-right: #000000 1px solid;ntborder-bottom: #000000 1px solid;ntborder-left: #666666 1px solid;ntborder-top: #666666 1px solid;ntpadding-right: 4px;ntpadding-left: 4px;nttext-decoration: none; height: 18px;n}nn.WizardButton:hover {ntcursor: pointer;n}nn.WizardButtonDisabled {ntcolor: #eeeeee;ntbackground-color: #999999;ntfont-size: xx-small;ntFONT-FAMILY: verdana, arial, helvetica, sans-serif;ntborder-right: #000000 1px solid;ntborder-bottom: #000000 1px solid;ntborder-left: #798EC5 1px solid;ntborder-top: #798EC5 1px solid;ntpadding-right: 4px;ntpadding-left: 4px;nttext-decoration: none;ntheight: 18px;n}nnn", templateCssPath:dojo.uri.moduleUri("dojo.widget", "templates/Wizard.css"), selected:null, nextButtonLabel:"next", previousButtonLabel:"previous", cancelButtonLabel:"cancel", doneButtonLabel:"done", cancelFunction:"", hideDisabledButtons:false, fillInTemplate:function (args, frag) {
  15. dojo.event.connect(this.nextButton, "onclick", this, "_onNextButtonClick");
  16. dojo.event.connect(this.previousButton, "onclick", this, "_onPreviousButtonClick");
  17. if (this.cancelFunction) {
  18. dojo.event.connect(this.cancelButton, "onclick", this.cancelFunction);
  19. } else {
  20. this.cancelButton.style.display = "none";
  21. }
  22. dojo.event.connect(this.doneButton, "onclick", this, "done");
  23. this.nextButton.value = this.nextButtonLabel;
  24. this.previousButton.value = this.previousButtonLabel;
  25. this.cancelButton.value = this.cancelButtonLabel;
  26. this.doneButton.value = this.doneButtonLabel;
  27. }, _checkButtons:function () {
  28. var lastStep = !this.hasNextPanel();
  29. this.nextButton.disabled = lastStep;
  30. this._setButtonClass(this.nextButton);
  31. if (this.selected.doneFunction) {
  32. this.doneButton.style.display = "";
  33. if (lastStep) {
  34. this.nextButton.style.display = "none";
  35. }
  36. } else {
  37. this.doneButton.style.display = "none";
  38. }
  39. this.previousButton.disabled = ((!this.hasPreviousPanel()) || (!this.selected.canGoBack));
  40. this._setButtonClass(this.previousButton);
  41. }, _setButtonClass:function (button) {
  42. if (!this.hideDisabledButtons) {
  43. button.style.display = "";
  44. dojo.html.setClass(button, button.disabled ? "WizardButtonDisabled" : "WizardButton");
  45. } else {
  46. button.style.display = button.disabled ? "none" : "";
  47. }
  48. }, registerChild:function (panel, insertionIndex) {
  49. dojo.widget.WizardContainer.superclass.registerChild.call(this, panel, insertionIndex);
  50. this.wizardPanelContainerNode.appendChild(panel.domNode);
  51. panel.hide();
  52. if (!this.selected) {
  53. this.onSelected(panel);
  54. }
  55. this._checkButtons();
  56. }, onSelected:function (panel) {
  57. if (this.selected) {
  58. if (this.selected._checkPass()) {
  59. this.selected.hide();
  60. } else {
  61. return;
  62. }
  63. }
  64. panel.show();
  65. this.selected = panel;
  66. }, getPanels:function () {
  67. return this.getChildrenOfType("WizardPane", false);
  68. }, selectedIndex:function () {
  69. if (this.selected) {
  70. return dojo.lang.indexOf(this.getPanels(), this.selected);
  71. }
  72. return -1;
  73. }, _onNextButtonClick:function () {
  74. var selectedIndex = this.selectedIndex();
  75. if (selectedIndex > -1) {
  76. var childPanels = this.getPanels();
  77. if (childPanels[selectedIndex + 1]) {
  78. this.onSelected(childPanels[selectedIndex + 1]);
  79. }
  80. }
  81. this._checkButtons();
  82. }, _onPreviousButtonClick:function () {
  83. var selectedIndex = this.selectedIndex();
  84. if (selectedIndex > -1) {
  85. var childPanels = this.getPanels();
  86. if (childPanels[selectedIndex - 1]) {
  87. this.onSelected(childPanels[selectedIndex - 1]);
  88. }
  89. }
  90. this._checkButtons();
  91. }, hasNextPanel:function () {
  92. var selectedIndex = this.selectedIndex();
  93. return (selectedIndex < (this.getPanels().length - 1));
  94. }, hasPreviousPanel:function () {
  95. var selectedIndex = this.selectedIndex();
  96. return (selectedIndex > 0);
  97. }, done:function () {
  98. this.selected.done();
  99. }});
  100. dojo.widget.defineWidget("dojo.widget.WizardPane", dojo.widget.ContentPane, {canGoBack:true, passFunction:"", doneFunction:"", postMixInProperties:function (args, frag) {
  101. if (this.passFunction) {
  102. this.passFunction = dj_global[this.passFunction];
  103. }
  104. if (this.doneFunction) {
  105. this.doneFunction = dj_global[this.doneFunction];
  106. }
  107. dojo.widget.WizardPane.superclass.postMixInProperties.apply(this, arguments);
  108. }, _checkPass:function () {
  109. if (this.passFunction && dojo.lang.isFunction(this.passFunction)) {
  110. var failMessage = this.passFunction();
  111. if (failMessage) {
  112. alert(failMessage);
  113. return false;
  114. }
  115. }
  116. return true;
  117. }, done:function () {
  118. if (this.doneFunction && dojo.lang.isFunction(this.doneFunction)) {
  119. this.doneFunction();
  120. }
  121. }});