hedera-web/js/htk/assistant.js

110 lines
1.6 KiB
JavaScript

Htk.Assistant = new Class
({
Extends: Vn.Object
,Tag: 'htk-assistant'
,Properties:
{
stepCount:
{
type: Number
,set: function (x)
{
this._stepCount = x;
if (x > 0)
this.setStep (0);
else
this.setStep (-1);
}
,get: function ()
{
return this._stepCount;
}
},
step:
{
type: Number
,set: function (x)
{
this.setStep (x);
}
,get: function ()
{
return this._stepIndex;
}
},
stepFunc:
{
type: Function
,set: function (x)
{
this._stepFunc = x;
this.setStep (this._stepIndex);
}
,get: function ()
{
return this._stepFunc;
}
},
node:
{
type: Object
,set: function (x)
{
x.className = 'htk-assistant';
}
},
}
,_stepNode: null
,_stepIndex: -1
,_stepCount: 0
,_stepFunc: null
,setStep: function (stepIndex)
{
if (!(stepIndex >= -1 && stepIndex < this.stepCount))
return;
if (this._stepFunc && stepIndex != -1)
{
var stepNode = this._stepFunc (stepIndex);
if (stepNode)
{
if (this._stepNode)
this._stepNode.style.display = 'none';
this._stepNode = stepNode;
stepNode.style.display = 'block';
this._setStepIndex (stepIndex);
}
else if (this._stepIndex < stepIndex)
this.setStep (stepIndex + 1);
else
this.setStep (stepIndex - 1);
}
else
this._setStepIndex (stepIndex);
}
,_setStepIndex: function (stepIndex)
{
this._stepIndex = stepIndex;
this.signalEmit ('step-change', stepIndex);
}
,movePrevious: function ()
{
this.setStep (this._stepIndex - 1);
}
,moveNext: function ()
{
this.setStep (this._stepIndex + 1);
}
});