From b1daf0b285a4a96bfd0086709c20e3682d75551a Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 21 Feb 2012 14:32:17 -0800 Subject: fixing the dirty flag and removing sass changes Signed-off-by: Valerio Virgillito --- .../layout/document-entry.reel/document-entry.html | 1 - .../layout/document-entry.reel/document-entry.js | 24 +++++++-------- .../layout/documents-tab.reel/documents-tab.html | 4 +-- js/controllers/document-controller.js | 15 ++------- js/document/html-document.js | 9 ------ js/document/text-document.js | 36 ++++++++-------------- js/mediators/element-mediator.js | 4 +-- js/stage/stage-view.reel/stage-view.js | 4 +-- scss/imports/scss/_MainWindow.scss | 2 -- 9 files changed, 32 insertions(+), 67 deletions(-) diff --git a/js/components/layout/document-entry.reel/document-entry.html b/js/components/layout/document-entry.reel/document-entry.html index ba17449a..1cf01737 100755 --- a/js/components/layout/document-entry.reel/document-entry.html +++ b/js/components/layout/document-entry.reel/document-entry.html @@ -26,7 +26,6 @@
  • -
  • diff --git a/js/components/layout/document-entry.reel/document-entry.js b/js/components/layout/document-entry.reel/document-entry.js index a1bed79b..9e4110e2 100755 --- a/js/components/layout/document-entry.reel/document-entry.js +++ b/js/components/layout/document-entry.reel/document-entry.js @@ -77,19 +77,17 @@ exports.DocumentEntry = Montage.create(Component, { } }, - _dirtyFlag:{ - enumerable:false, - value:false + _saveFlag: { + value: false }, - dirtyFlag:{ + + saveFlag: { get: function() { - return this._dirtyFlag; + return this._saveFlag; }, set: function(value) { - var previousValue = this._dirtyFlag; - this._dirtyFlag = value; - - if (previousValue !== this._dirtyFlag) { + if(this._saveFlag !== value) { + this._saveFlag = value; this.needsDraw = true; } } @@ -110,10 +108,10 @@ exports.DocumentEntry = Montage.create(Component, { this._active ? this.element.classList.add("activeTab") : this.element.classList.remove("activeTab"); - if(this.dirtyFlag === true){ - if(!this.label.classList.contains("dirty")){this.label.classList.add("dirty");} - }else{ - if(this.label.classList.contains("dirty")){this.label.classList.remove("dirty");} + if(this.saveFlag) { + this.label.classList.add("dirty"); + } else { + this.label.classList.remove("dirty"); } } }, diff --git a/js/components/layout/documents-tab.reel/documents-tab.html b/js/components/layout/documents-tab.reel/documents-tab.html index 82ba8782..737dfbcb 100755 --- a/js/components/layout/documents-tab.reel/documents-tab.html +++ b/js/components/layout/documents-tab.reel/documents-tab.html @@ -38,9 +38,9 @@ "boundObjectPropertyPath": "objectAtCurrentIteration.name", "oneway": true }, - "dirtyFlag": { + "saveFlag": { "boundObject": {"@": "repetition1"}, - "boundObjectPropertyPath": "objectAtCurrentIteration.dirtyFlag", + "boundObjectPropertyPath": "objectAtCurrentIteration.needsSave", "oneway": true }, "active": { diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 9a063280..e0402219 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -131,20 +131,11 @@ var DocumentController = exports.DocumentController = Montage.create(Component, fileSaveResult: { value: function (result) { if(result.status === 204){ - this.clearDocumentDirtyFlag(); + this.activeDocument.needsSave = false; } } }, - //////////////////////////////////////////////////////////////////// - - - clearDocumentDirtyFlag:{ - value: function(){ - this.activeDocument.dirtyFlag = false; - } - }, - - + createNewFile:{ value:function(newFileObj){ //console.log(newFileObj);//contains the template uri and the new file uri @@ -282,7 +273,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, closeDocument: { value: function(id) { - if(this.activeDocument.dirtyFlag === true){ + if(this.activeDocument.needsSave === true){ //if file dirty then alert user to save } diff --git a/js/document/html-document.js b/js/document/html-document.js index 28818774..01d042d6 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -290,15 +290,6 @@ exports.HTMLDocument = Montage.create(TextDocument, { } }, - - - AppendElement: { - value: function(element, parent) { - this.dirtyFlag = true; - } - }, - - /** * Return the specified inline attribute from the element. */ diff --git a/js/document/text-document.js b/js/document/text-document.js index 1132ba65..88464d87 100755 --- a/js/document/text-document.js +++ b/js/document/text-document.js @@ -120,15 +120,15 @@ var TextDocument = exports.TextDocument = Montage.create(Component, { /** Private Members **/ - _name: { value: null, enumerable: false }, - _uri: { value: null, enumerable: false }, - _documentType: { value: null, enumerable: false }, - _container: {value: null, enumerable: false }, - _uuid: { value: null, enumerable: false }, - _isActive: { value: true, enumerable: false }, - _dirtyFlag: { value: false, enumerable: false }, - _callback: { value: null, enumerable: false }, - _currentView: { value: null, enumerable: false}, + _name: { value: null, enumerable: false }, + _uri: { value: null, enumerable: false }, + _documentType: { value: null, enumerable: false }, + _container: { value: null, enumerable: false }, + _uuid: { value: null, enumerable: false }, + _isActive: { value: true, enumerable: false }, + _needsSave: { value: false, enumarable: false }, + _callback: { value: null, enumerable: false }, + _currentView: { value: null, enumerable: false}, /** Getters/Setters **/ name: { @@ -161,9 +161,9 @@ var TextDocument = exports.TextDocument = Montage.create(Component, { set: function(value) { this._isActive = value; } }, - dirtyFlag: { - get: function() { return this._dirtyFlag; }, - set: function(value) { this._dirtyFlag = value; } + needsSave: { + get: function() { return this._needsSave; }, + set: function(value) { this._needsSave = value } }, callback: { @@ -192,17 +192,5 @@ var TextDocument = exports.TextDocument = Montage.create(Component, { value: function() { // Have the XHR here? } - }, - - markEdited:{ - value: function() { - this.dirtyFlag = true; - } - }, - - markUnedited:{ - value: function() { - this.dirtyFlag = false; - } } }); \ No newline at end of file diff --git a/js/mediators/element-mediator.js b/js/mediators/element-mediator.js index 6088aeab..95a72c89 100755 --- a/js/mediators/element-mediator.js +++ b/js/mediators/element-mediator.js @@ -102,7 +102,7 @@ exports.ElementMediator = Montage.create(NJComponent, { el.elementModel.controller["set3DProperties"](el, [p3d], 0, true); } if(!noEvent) { - this.application.ninja.documentController.activeDocument.markEdited(); + this.application.ninja.documentController.activeDocument.needsSave = true; NJevent("elementAdded", el); } } @@ -130,7 +130,7 @@ exports.ElementMediator = Montage.create(NJComponent, { _removeElement: { value: function(el, rules) { ElementController.removeElement(el, rules); - this.application.ninja.documentController.activeDocument.markEdited(); + this.application.ninja.documentController.activeDocument.needsSave = true; NJevent("elementDeleted", el); } }, diff --git a/js/stage/stage-view.reel/stage-view.js b/js/stage/stage-view.reel/stage-view.js index 31f40d09..dc9980f0 100755 --- a/js/stage/stage-view.reel/stage-view.js +++ b/js/stage/stage-view.reel/stage-view.js @@ -98,9 +98,9 @@ exports.StageView = Montage.create(Component, { onChange: function(){ var historySize = doc.editor.historySize(); if(historySize.undo>0){ - doc.markEdited(); + doc.needsSave = true; }else if(historySize.undo===0 && historySize.redo>0){ - doc.markUnedited(); + doc.needsSave = false; } }, onCursorActivity: function() { diff --git a/scss/imports/scss/_MainWindow.scss b/scss/imports/scss/_MainWindow.scss index 1340a18f..97344b1e 100755 --- a/scss/imports/scss/_MainWindow.scss +++ b/scss/imports/scss/_MainWindow.scss @@ -204,14 +204,12 @@ background:$color-stage; height:15px; margin-bottom: 0px; - display:none; } #rulerLeft { // TODO: temporary background please replace when component is implemented background:$color-stage; width:16px; - display:none; } #stateBar { -- cgit v1.2.3