X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/4dae03fed5ec90a39dea2473a3e3f0188df90ffe..51a333278c2989a5a0022c19404bd257bf55cb27:/src/editor/modules/documentCanvas/canvas/documentElement.js diff --git a/src/editor/modules/documentCanvas/canvas/documentElement.js b/src/editor/modules/documentCanvas/canvas/documentElement.js index 3073e72..956d0a7 100644 --- a/src/editor/modules/documentCanvas/canvas/documentElement.js +++ b/src/editor/modules/documentCanvas/canvas/documentElement.js @@ -11,6 +11,10 @@ define([ var DocumentElement = function(wlxmlNode, canvas) { this.wlxmlNode = wlxmlNode; this.canvas = canvas; + this.state = { + exposed: false, + active: false + }; this.dom = this.createDOM(); this.dom.data('canvas-element', this); @@ -26,6 +30,21 @@ $.extend(DocumentElement.prototype, { refresh: function() { // noop }, + updateState: function(toUpdate) { + var changes = {}; + _.keys(toUpdate) + .filter(function(key) { + return this.state.hasOwnProperty(key); + }.bind(this)) + .forEach(function(key) { + if(this.state !== toUpdate[key]) { + this.state[key] = changes[key] = toUpdate[key]; + } + }.bind(this)); + if(_.isFunction(this.onStateChange)) { + this.onStateChange(changes); + } + }, parent: function() { var parents = this.dom.parents('[document-node-element]'); if(parents.length) { @@ -102,7 +121,7 @@ $.extend(DocumentNodeElement.prototype, { contentContainer = $('