init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
263
KretaWeb/Scripts/KendoHelper/KretaWizard.js
Normal file
263
KretaWeb/Scripts/KendoHelper/KretaWizard.js
Normal file
|
@ -0,0 +1,263 @@
|
|||
var KretaWizardHelper = (function () {
|
||||
var kretaWizardHelper = function () {};
|
||||
|
||||
kretaWizardHelper.loadView = function (instance) {
|
||||
AjaxHelper.DoPost(
|
||||
instance.currentUrl,
|
||||
instance.dataToBeSentOnNextPage,
|
||||
function (data) {
|
||||
fillViewArea(instance, data, instance.oldData);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
function fillViewArea(instance, data) {
|
||||
var area = $(instance.wizardBodyId);
|
||||
area.empty();
|
||||
area.append(data);
|
||||
setButtonVisible(instance);
|
||||
if (instance.oldData != null) {
|
||||
readyEventPopulate(instance.wizardFormId, instance.oldData);
|
||||
}
|
||||
instance.onReadyEvent(instance);
|
||||
}
|
||||
|
||||
function setButtonVisible(instance) {
|
||||
if (instance.historyList.length > 0) {
|
||||
$(instance.backButtonId).show();
|
||||
} else {
|
||||
$(instance.backButtonId).hide();
|
||||
}
|
||||
|
||||
if (instance.showCancel) {
|
||||
$(instance.cancelButtonId).show();
|
||||
} else {
|
||||
$(instance.cancelButtonId).hide();
|
||||
}
|
||||
|
||||
if (instance.showNext) {
|
||||
$(instance.nextButtonId).show();
|
||||
} else {
|
||||
$(instance.nextButtonId).hide();
|
||||
}
|
||||
|
||||
if (instance.showEnd) {
|
||||
$(instance.endButtonId).show();
|
||||
} else {
|
||||
$(instance.endButtonId).hide();
|
||||
}
|
||||
}
|
||||
|
||||
function readyEventPopulate(frm, data) {
|
||||
$.each(data, function (key, value) {
|
||||
var $ctrl = $(frm + ' ' + '[name=' + key + ']');
|
||||
switch ($ctrl.attr('type')) {
|
||||
case 'text':
|
||||
case 'input':
|
||||
if ($ctrl.attr('data-role') == 'combobox') {
|
||||
$ctrl.data('kendoComboBox').value(value);
|
||||
} else {
|
||||
$ctrl.val(value);
|
||||
}
|
||||
case 'hidden':
|
||||
$ctrl.val(value);
|
||||
break;
|
||||
case 'radio':
|
||||
case 'checkbox':
|
||||
$ctrl.each(function () {
|
||||
if ($(this).attr('value') == value) {
|
||||
$(this).attr('checked', value);
|
||||
}
|
||||
});
|
||||
break;
|
||||
default:
|
||||
$ctrl.val(value);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return kretaWizardHelper;
|
||||
})();
|
||||
|
||||
function KretaWizard(
|
||||
url,
|
||||
baseModel,
|
||||
showNext,
|
||||
showEnd,
|
||||
showCancel,
|
||||
showProgressBar,
|
||||
showStepDisplay
|
||||
) {
|
||||
this.currentUrl = url;
|
||||
this.baseModel = baseModel;
|
||||
this.backButtonId = '#wizardBackBtn';
|
||||
this.nextButtonId = '#wizardNextBtn';
|
||||
this.wizardBodyId = '#wizardContent';
|
||||
this.endButtonId = '#wizardEndBtn';
|
||||
this.cancelButtonId = '#wizardCancelBtn';
|
||||
this.wizardFormId = '#WizardForm';
|
||||
this.progressBarId = '#wizardProgressBar';
|
||||
this.stepDisplayId = '#wizardStepDisplay';
|
||||
this.historyList = [];
|
||||
this.onNextEvent = function () {};
|
||||
this.onBackEvent = function () {};
|
||||
this.onReadyEvent = function () {};
|
||||
this.onEndEvent = function () {};
|
||||
this.onCancelEvent = function () {};
|
||||
this.oldData = null;
|
||||
this.justTrigerNext = false; /*next button just trugger event*/
|
||||
this.showEnd = false;
|
||||
this.showNext = showNext == null ? true : showNext;
|
||||
this.showEnd = showEnd == null ? false : showEnd;
|
||||
this.overrideWindowSize = false;
|
||||
this.dataToBeSentOnNextPage = null;
|
||||
this.showCancel = showCancel == null ? false : showCancel;
|
||||
this.showProgressBar = showProgressBar == null ? false : showProgressBar;
|
||||
this.showStepDisplay = showStepDisplay == null ? false : showStepDisplay;
|
||||
}
|
||||
|
||||
KretaWizard.prototype.ManualNext = function (
|
||||
nextUrl,
|
||||
nextStepId,
|
||||
showNextButton,
|
||||
showEnd
|
||||
) {
|
||||
this.historyList.push({
|
||||
url: this.currentUrl,
|
||||
model: $(this.wizardFormId).toObject(),
|
||||
showNext: this.showNext,
|
||||
showEnd: this.showEnd,
|
||||
actualStepId: this.baseModel.actualStepId,
|
||||
justTrigerNext: this.justTrigerNext
|
||||
});
|
||||
this.currentUrl = nextUrl;
|
||||
this.baseModel.actualStepId = nextStepId;
|
||||
this.showNext = showNextButton == null ? true : showNextButton;
|
||||
this.showEnd = showEnd == null ? false : showEnd;
|
||||
this.oldData = null;
|
||||
|
||||
KretaWizardHelper.loadView(this);
|
||||
};
|
||||
|
||||
KretaWizard.prototype.GetModel = function (index) {
|
||||
if (CommonUtils.isNullOrUndefined(index) || index == 0) {
|
||||
var result = $(this.wizardFormId).toObject();
|
||||
for (var i = this.historyList.length - 1; i > 0; i--) {
|
||||
$.extend(result, this.historyList[i].model);
|
||||
}
|
||||
return result;
|
||||
} else {
|
||||
var historyIndex = this.historyList.length - index;
|
||||
if (historyIndex >= 0 && historyIndex < this.historyList.length) {
|
||||
return this.historyList[historyIndex].model;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
KretaWizard.prototype.Next = function () {
|
||||
if (this.justTrigerNext) {
|
||||
this.onNextEvent(this);
|
||||
} else {
|
||||
this.historyList.push({
|
||||
url: this.currentUrl,
|
||||
model: $(this.wizardFormId).toObject(),
|
||||
showNext: this.showNext,
|
||||
showEnd: this.showEnd,
|
||||
actualStepId: this.baseModel.actualStepId,
|
||||
justTrigerNext: this.justTrigerNext
|
||||
});
|
||||
this.oldData = null;
|
||||
|
||||
var result = this.onNextEvent(this);
|
||||
if (result == null || result) {
|
||||
KretaWizardHelper.loadView(this);
|
||||
} else {
|
||||
this.historyList.pop();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
KretaWizard.prototype.Back = function () {
|
||||
if (this.historyList.length > 0) {
|
||||
var lastView = this.historyList.pop();
|
||||
this.currentUrl = lastView.url;
|
||||
this.oldData = lastView.model;
|
||||
this.showNext = lastView.showNext;
|
||||
this.showEnd = lastView.showEnd;
|
||||
this.baseModel.actualStepId = lastView.actualStepId;
|
||||
this.justTrigerNext = lastView.justTrigerNext;
|
||||
}
|
||||
|
||||
this.onBackEvent(this);
|
||||
KretaWizardHelper.loadView(this);
|
||||
};
|
||||
|
||||
KretaWizard.prototype.Open = function (
|
||||
url,
|
||||
title,
|
||||
onmodal,
|
||||
formContentContainer
|
||||
) {
|
||||
var wizardThis = this;
|
||||
wizardThis.onmodal = onmodal;
|
||||
wizardThis.formContentContainer = formContentContainer;
|
||||
|
||||
AjaxHelper.DoPost(url, null, getWizardGlobalContent);
|
||||
|
||||
function getWizardGlobalContent(data) {
|
||||
var config = KretaWindowHelper.getWindowConfigContainer();
|
||||
config.content = data;
|
||||
config.title = title;
|
||||
|
||||
if (wizardThis.overrideWindowSize === false) {
|
||||
config.width = 600;
|
||||
config.height = 265;
|
||||
}
|
||||
|
||||
var modal;
|
||||
if (wizardThis.onmodal !== false) {
|
||||
modal = KretaWindowHelper.createWindow('wizardWindow', config);
|
||||
}
|
||||
|
||||
KretaWizardHelper.loadView(wizardThis);
|
||||
|
||||
if (wizardThis.onmodal === false) {
|
||||
$(wizardThis.formContentContainer.selector).html(data);
|
||||
$(wizardThis.formContentContainer.selector)
|
||||
.first()
|
||||
.css('height', wizardThis.formContentContainer.height);
|
||||
}
|
||||
|
||||
$(wizardThis.nextButtonId).bind('click', function () {
|
||||
wizardThis.Next();
|
||||
});
|
||||
$(wizardThis.backButtonId).bind('click', function () {
|
||||
wizardThis.Back();
|
||||
});
|
||||
$(wizardThis.endButtonId).bind('click', function () {
|
||||
wizardThis.onEndEvent(wizardThis);
|
||||
});
|
||||
$(wizardThis.cancelButtonId).bind('click', function () {
|
||||
wizardThis.onCancelEvent(wizardThis);
|
||||
});
|
||||
|
||||
if (wizardThis.showProgressBar === true) {
|
||||
$(wizardThis.progressBarId).css('display', '');
|
||||
}
|
||||
if (wizardThis.showStepDisplay === true) {
|
||||
$(wizardThis.stepDisplayId).css('visibility', '');
|
||||
} else {
|
||||
$(wizardThis.stepDisplayId).css('display', 'none');
|
||||
}
|
||||
|
||||
if (modal) {
|
||||
KretaWindowHelper.openWindow(modal, true);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
KretaWizard.prototype.RemoveLastFromHistory = function () {
|
||||
this.historyList.pop();
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue