From 3b862fe489a3320882f91ab56781fc5dc400c3d1 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Fri, 17 Feb 2012 11:26:02 -0800 Subject: changed the document dirtying logic to be done in the feature that edits the document. Signed-off-by: Ananya Sen --- js/controllers/document-controller.js | 12 ------------ js/mediators/element-mediator.js | 6 +++++- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 6f31e24d..232af4c9 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -59,12 +59,6 @@ DocumentController = exports.DocumentController = Montage.create(Component, { this.eventManager.addEventListener("recordStyleChanged", this, false); - //event listener to detect a change in the html design view - this.eventManager.addEventListener("elementAdded", function(evt){self.markCurrentDocumentChanged()}, false); - this.eventManager.addEventListener("elementDeleted", function(evt){self.markCurrentDocumentChanged()}, false); - //todo: add all applicable event listeners - //end-event listener to detect a change in the html design view - } }, @@ -438,11 +432,5 @@ DocumentController = exports.DocumentController = Montage.create(Component, { value: function() { return "userDocument_" + (this._iframeCounter++); } - }, - - markCurrentDocumentChanged:{ - value: function(){ - this.activeDocument.dirtyFlag = true; - } } }); diff --git a/js/mediators/element-mediator.js b/js/mediators/element-mediator.js index 95aec2a3..e1eadda9 100755 --- a/js/mediators/element-mediator.js +++ b/js/mediators/element-mediator.js @@ -101,7 +101,10 @@ exports.ElementMediator = Montage.create(NJComponent, { { el.elementModel.controller["set3DProperties"](el, [p3d], 0, true); } - if(!noEvent) NJevent("elementAdded", el); + if(!noEvent) { + this.application.ninja.documentController.activeDocument.dirtyFlag = true; + NJevent("elementAdded", el); + } } }, @@ -127,6 +130,7 @@ exports.ElementMediator = Montage.create(NJComponent, { _removeElement: { value: function(el, rules) { ElementController.removeElement(el, rules); + this.application.ninja.documentController.activeDocument.dirtyFlag = true; NJevent("elementDeleted", el); } }, -- cgit v1.2.3