diff options
| author | LV-426 <lv-426@taproot.org.il> | 2014-12-16 15:30:45 +0200 |
|---|---|---|
| committer | LV-426 <lv-426@taproot.org.il> | 2014-12-16 15:40:10 +0200 |
| commit | 2797072203d9a2e3b794948ca0754704661ec245 (patch) | |
| tree | 6a7e5ba3d2c6139e08c79c30d4c38cb331b5cde3 /src/model | |
| parent | 7240992e2535ff35b2d2a75b5eeb3cba491c463d (diff) | |
Attr_Diff: add_link_attr_write, add_link_attr_rm
Diffstat (limited to 'src/model')
| -rw-r--r-- | src/model/diff.js | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/src/model/diff.js b/src/model/diff.js index 6d70f929..8903b161 100644 --- a/src/model/diff.js +++ b/src/model/diff.js @@ -58,20 +58,18 @@ define([], * node,link types are supported */ function Attr_Diff(obj_spec) { - this.__type_node = {} - this.__type_link = {} + this.__type_node = {}; + this.__type_link = {}; } - Attr_Diff.prototype.init_attr_diff = function(type, id) { + Attr_Diff.prototype.init_attr_diff = function(type_name, id) { - if ('node' != type && 'link' != type) { - console - .error('attempt to init attribute diff for unsupported type: ' - + type); + if ('node' != type_name && 'link' != type_name) { + console.error('attempt to init attribute diff for unsupported type: ' + type_name); return; } - var type_field = '__type_' + type; + var type_field = '__type_' + type_name; this[type_field][id] = { '__attr_write' : {}, '__attr_remove' : [] @@ -106,6 +104,24 @@ define([], return this; } + Attr_Diff.prototype.add_link_attr_write = function(l_id, attr_name, + attr_val) { + + if (undefined == this.__type_link[l_id]) { + this.init_attr_diff_link(l_id); + } + this.__type_link[l_id].__attr_write[attr_name] = attr_val; + return this; + } + + Attr_Diff.prototype.add_link_attr_rm = function(l_id, attr_name) { + if (undefined == this[l_id]) { + this.init_attr_diff(l_id); + } + this.__type_link[l_id].__attr_remove.push(attr_name); + return this; + } + /** * Visual diff object expressing any visual change to the state of a * particular visualization type. |
