Wizard.js
资源名称:oa.rar [点击查看]
上传用户:kimgenplus
上传日期:2016-06-05
资源大小:20877k
文件大小:6k
源码类别:
OA系统
开发平台:
Java
- /*
- Copyright (c) 2004-2006, The Dojo Foundation
- All Rights Reserved.
- Licensed under the Academic Free License version 2.1 or above OR the
- modified BSD license. For more information on Dojo licensing, see:
- http://dojotoolkit.org/community/licensing.shtml
- */
- dojo.provide("dojo.widget.Wizard");
- dojo.require("dojo.widget.*");
- dojo.require("dojo.widget.LayoutContainer");
- dojo.require("dojo.widget.ContentPane");
- dojo.require("dojo.event.*");
- dojo.require("dojo.html.style");
- 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) {
- dojo.event.connect(this.nextButton, "onclick", this, "_onNextButtonClick");
- dojo.event.connect(this.previousButton, "onclick", this, "_onPreviousButtonClick");
- if (this.cancelFunction) {
- dojo.event.connect(this.cancelButton, "onclick", this.cancelFunction);
- } else {
- this.cancelButton.style.display = "none";
- }
- dojo.event.connect(this.doneButton, "onclick", this, "done");
- this.nextButton.value = this.nextButtonLabel;
- this.previousButton.value = this.previousButtonLabel;
- this.cancelButton.value = this.cancelButtonLabel;
- this.doneButton.value = this.doneButtonLabel;
- }, _checkButtons:function () {
- var lastStep = !this.hasNextPanel();
- this.nextButton.disabled = lastStep;
- this._setButtonClass(this.nextButton);
- if (this.selected.doneFunction) {
- this.doneButton.style.display = "";
- if (lastStep) {
- this.nextButton.style.display = "none";
- }
- } else {
- this.doneButton.style.display = "none";
- }
- this.previousButton.disabled = ((!this.hasPreviousPanel()) || (!this.selected.canGoBack));
- this._setButtonClass(this.previousButton);
- }, _setButtonClass:function (button) {
- if (!this.hideDisabledButtons) {
- button.style.display = "";
- dojo.html.setClass(button, button.disabled ? "WizardButtonDisabled" : "WizardButton");
- } else {
- button.style.display = button.disabled ? "none" : "";
- }
- }, registerChild:function (panel, insertionIndex) {
- dojo.widget.WizardContainer.superclass.registerChild.call(this, panel, insertionIndex);
- this.wizardPanelContainerNode.appendChild(panel.domNode);
- panel.hide();
- if (!this.selected) {
- this.onSelected(panel);
- }
- this._checkButtons();
- }, onSelected:function (panel) {
- if (this.selected) {
- if (this.selected._checkPass()) {
- this.selected.hide();
- } else {
- return;
- }
- }
- panel.show();
- this.selected = panel;
- }, getPanels:function () {
- return this.getChildrenOfType("WizardPane", false);
- }, selectedIndex:function () {
- if (this.selected) {
- return dojo.lang.indexOf(this.getPanels(), this.selected);
- }
- return -1;
- }, _onNextButtonClick:function () {
- var selectedIndex = this.selectedIndex();
- if (selectedIndex > -1) {
- var childPanels = this.getPanels();
- if (childPanels[selectedIndex + 1]) {
- this.onSelected(childPanels[selectedIndex + 1]);
- }
- }
- this._checkButtons();
- }, _onPreviousButtonClick:function () {
- var selectedIndex = this.selectedIndex();
- if (selectedIndex > -1) {
- var childPanels = this.getPanels();
- if (childPanels[selectedIndex - 1]) {
- this.onSelected(childPanels[selectedIndex - 1]);
- }
- }
- this._checkButtons();
- }, hasNextPanel:function () {
- var selectedIndex = this.selectedIndex();
- return (selectedIndex < (this.getPanels().length - 1));
- }, hasPreviousPanel:function () {
- var selectedIndex = this.selectedIndex();
- return (selectedIndex > 0);
- }, done:function () {
- this.selected.done();
- }});
- dojo.widget.defineWidget("dojo.widget.WizardPane", dojo.widget.ContentPane, {canGoBack:true, passFunction:"", doneFunction:"", postMixInProperties:function (args, frag) {
- if (this.passFunction) {
- this.passFunction = dj_global[this.passFunction];
- }
- if (this.doneFunction) {
- this.doneFunction = dj_global[this.doneFunction];
- }
- dojo.widget.WizardPane.superclass.postMixInProperties.apply(this, arguments);
- }, _checkPass:function () {
- if (this.passFunction && dojo.lang.isFunction(this.passFunction)) {
- var failMessage = this.passFunction();
- if (failMessage) {
- alert(failMessage);
- return false;
- }
- }
- return true;
- }, done:function () {
- if (this.doneFunction && dojo.lang.isFunction(this.doneFunction)) {
- this.doneFunction();
- }
- }});