forked from verdnatura/hedera-web
88 lines
1.3 KiB
JavaScript
Executable File
88 lines
1.3 KiB
JavaScript
Executable File
|
|
Vn.HashParam = new Class
|
|
({
|
|
Extends: Vn.Object
|
|
,Tag: 'vn-hash-param'
|
|
,Parent: 'param'
|
|
,Properties:
|
|
{
|
|
param:
|
|
{
|
|
type: Vn.Param
|
|
,set: function (x)
|
|
{
|
|
this.link ({_param: x}, {'changed': this._onParamChange});
|
|
this._refreshParam ();
|
|
}
|
|
,get: function ()
|
|
{
|
|
return this._param;
|
|
}
|
|
},
|
|
key:
|
|
{
|
|
type: String
|
|
,set: function (x)
|
|
{
|
|
this._key = x;
|
|
this._onHashChange ();
|
|
}
|
|
,get: function ()
|
|
{
|
|
return this._key;
|
|
}
|
|
}
|
|
}
|
|
|
|
,lock: false
|
|
,value: undefined
|
|
,_key: null
|
|
|
|
,initialize: function (props)
|
|
{
|
|
this.parent (props);
|
|
var listener = Vn.Hash.getListener ();
|
|
this.link ({_listener: listener}, {'changed': this._onHashChange});
|
|
this._onHashChange ();
|
|
}
|
|
|
|
,_onHashChange: function ()
|
|
{
|
|
if (!this._key || !this._listener)
|
|
return;
|
|
|
|
var newValue = Vn.Hash.get (this._key);
|
|
|
|
if (this.value != newValue)
|
|
{
|
|
this.value = newValue;
|
|
this.signalEmit ('changed');
|
|
this._refreshParam ();
|
|
}
|
|
}
|
|
|
|
,_refreshParam: function ()
|
|
{
|
|
if (this._param && !this.lock)
|
|
{
|
|
this.lock = true;
|
|
this._param.value = this.value;
|
|
this.lock = false;
|
|
}
|
|
}
|
|
|
|
,_onParamChange: function ()
|
|
{
|
|
if (this.lock)
|
|
return;
|
|
|
|
var map = {};
|
|
map[this.key] = this._param.value;
|
|
|
|
this.lock = true;
|
|
Vn.Hash.add (map);
|
|
this.lock = false;
|
|
}
|
|
});
|
|
|