2016-09-26 09:28:47 +00:00
|
|
|
|
|
|
|
var Object = require ('./object');
|
|
|
|
var Param = require ('./param');
|
|
|
|
var Value = require ('./value');
|
|
|
|
|
2015-01-23 13:09:30 +00:00
|
|
|
/**
|
|
|
|
* Simply a linkable value holder.
|
2016-12-20 09:32:17 +00:00
|
|
|
*/
|
2016-09-26 09:28:47 +00:00
|
|
|
module.exports = new Class
|
2015-01-23 13:09:30 +00:00
|
|
|
({
|
2016-09-26 09:28:47 +00:00
|
|
|
Extends: Object
|
2015-01-23 13:09:30 +00:00
|
|
|
,Tag: 'vn-param'
|
|
|
|
,Properties:
|
|
|
|
{
|
|
|
|
value:
|
|
|
|
{
|
2015-07-03 05:49:45 +00:00
|
|
|
type: String
|
2015-01-23 13:09:30 +00:00
|
|
|
,set: function (x)
|
|
|
|
{
|
2016-09-26 09:28:47 +00:00
|
|
|
if (Value.compare (x, this._value))
|
2015-01-23 13:09:30 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (x instanceof Date)
|
|
|
|
x = x.clone ();
|
|
|
|
|
|
|
|
this._value = x;
|
|
|
|
|
|
|
|
if (this._master && !this.masterLock)
|
|
|
|
{
|
|
|
|
this.masterLock = true;
|
|
|
|
this._master.value = x;
|
|
|
|
this.masterLock = false;
|
|
|
|
}
|
|
|
|
|
2016-01-07 12:58:29 +00:00
|
|
|
this.signalEmit ('changed', this._value);
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
|
|
|
,get: function ()
|
|
|
|
{
|
|
|
|
return this._value;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
master:
|
|
|
|
{
|
2016-09-26 09:28:47 +00:00
|
|
|
type: Param
|
2015-01-23 13:09:30 +00:00
|
|
|
,set: function (x)
|
|
|
|
{
|
2015-07-28 19:14:26 +00:00
|
|
|
this.link ({_master: x}, {'changed': this._onMasterChange});
|
|
|
|
this._onMasterChange ();
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
|
|
|
,get: function ()
|
|
|
|
{
|
|
|
|
return this._master;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
,_value: undefined
|
|
|
|
,_master: null
|
|
|
|
,masterLock: false
|
|
|
|
|
2015-07-28 19:14:26 +00:00
|
|
|
,_onMasterChange: function ()
|
2015-01-23 13:09:30 +00:00
|
|
|
{
|
|
|
|
if (this.masterLock)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this.masterLock = true;
|
|
|
|
this.value = this._master.value;
|
|
|
|
this.masterLock = false;
|
|
|
|
}
|
2016-09-26 09:28:47 +00:00
|
|
|
});
|
|
|
|
|