forked from verdnatura/hedera-web
89 lines
1.2 KiB
JavaScript
Executable File
89 lines
1.2 KiB
JavaScript
Executable File
|
|
Vn.HashLink = new Class
|
|
({
|
|
Extends: Vn.Object
|
|
,Tag: 'vn-hash-link'
|
|
,Parent: 'param'
|
|
,Properties:
|
|
{
|
|
param:
|
|
{
|
|
type: Vn.Param
|
|
,set: function (x)
|
|
{
|
|
this.link ({_param: x}, {'changed': this.onParamChange});
|
|
this.onHashChange ();
|
|
}
|
|
,get: function ()
|
|
{
|
|
return this._param;
|
|
}
|
|
},
|
|
hash:
|
|
{
|
|
type: Vn.Hash
|
|
,set: function (x)
|
|
{
|
|
this.link ({_hash: x}, {'changed': this.onHashChange});
|
|
this.onHashChange ();
|
|
}
|
|
,get: function ()
|
|
{
|
|
return this._hash;
|
|
}
|
|
},
|
|
key:
|
|
{
|
|
type: String
|
|
,set: function (x)
|
|
{
|
|
this._key = x;
|
|
this.onHashChange ();
|
|
}
|
|
,get: function ()
|
|
{
|
|
return this._key;
|
|
}
|
|
}
|
|
}
|
|
|
|
,lock: false
|
|
,value: null
|
|
,_key: null
|
|
|
|
,onHashChange: function ()
|
|
{
|
|
if (!this._key || !this._hash)
|
|
return;
|
|
|
|
var newValue = this._hash.get (this._key);
|
|
|
|
if (this.value != newValue)
|
|
{
|
|
this.value = newValue;
|
|
this.signalEmit ('changed');
|
|
|
|
if (this._param && !this.lock)
|
|
{
|
|
this.lock = true;
|
|
this._param.value = newValue;
|
|
this.lock = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
,onParamChange: function ()
|
|
{
|
|
if (this.lock)
|
|
return;
|
|
|
|
var map = {};
|
|
map[this.key] = this._param.value;
|
|
|
|
this.lock = true;
|
|
this._hash.add (map);
|
|
this.lock = false;
|
|
}
|
|
});
|
|
|