From 7283884c39df537694b21419a3ea9e3ca7793b4b Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Thu, 23 Feb 2012 13:43:35 -0800 Subject: switch html document - re-initialize draw-utils and snap-manager on opening a document and while switching documents Signed-off-by: Ananya Sen --- js/document/html-document.js | 59 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 2 deletions(-) (limited to 'js/document') diff --git a/js/document/html-document.js b/js/document/html-document.js index 02e9918f..f260b665 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -53,6 +53,11 @@ exports.HTMLDocument = Montage.create(TextDocument, { }, + //drawUtils state + _gridHorizontalSpacing: {value:0}, + _gridVerticalSpacing: {value:0}, + //end - drawUtils state + // GETTERS / SETTERS @@ -71,6 +76,16 @@ exports.HTMLDocument = Montage.create(TextDocument, { set: function(value) { this._savedTopScroll = value} }, + gridHorizontalSpacing:{ + get: function() { return this._gridHorizontalSpacing; }, + set: function(value) { this._gridHorizontalSpacing = value} + }, + + gridVerticalSpacing:{ + get: function() { return this._gridVerticalSpacing; }, + set: function(value) { this._gridVerticalSpacing = value} + }, + selectionExclude: { get: function() { return this._selectionExclude; }, set: function(value) { this._selectionExclude = value; } @@ -444,7 +459,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { this._styles = this._document.styleSheets[1]; this._stylesheets = this._document.styleSheets; // Entire stlyesheets array - console.log(this._document.styleSheets); + //console.log(this._document.styleSheets); //////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// @@ -570,7 +585,47 @@ exports.HTMLDocument = Montage.create(TextDocument, { //Error } } - } + }, //////////////////////////////////////////////////////////////////// + saveAppState:{ + enumerable: false, + value: function () { + + this.savedLeftScroll = this.application.ninja.stage._iframeContainer.scrollLeft; + this.savedTopScroll = this.application.ninja.stage._iframeContainer.scrollTop; + + this.gridHorizontalSpacing = this.application.ninja.stage.drawUtils.gridHorizontalSpacing; + this.gridVerticalSpacing = this.application.ninja.stage.drawUtils.gridVerticalSpacing; + + //TODO:selection should be saved as an element state data, to avoid duplicate dom elements store in memory + if(typeof this.application.ninja.selectedElements !== 'undefined'){ + this.selectionModel = this.application.ninja.selectedElements; + } + } + }, + + //////////////////////////////////////////////////////////////////// + restoreAppState:{ + enumerable: false, + value: function () { + if((this.savedLeftScroll!== null) && (this.savedTopScroll !== null)){ + this.application.ninja.stage._iframeContainer.scrollLeft = this.savedLeftScroll; + this.application.ninja.stage._scrollLeft = this.savedLeftScroll; + this.application.ninja.stage._iframeContainer.scrollTop = this.savedTopScroll; + this.application.ninja.stage._scrollTop = this.savedTopScroll; + } + + this.application.ninja.stage.drawUtils.gridHorizontalSpacing = this.gridHorizontalSpacing; + this.application.ninja.stage.drawUtils.gridVerticalSpacing = this.gridVerticalSpacing; + + //TODO:selectionController.initWithDocument should loop over elements in documentRoot to repopulate + if((typeof this.selectionModel !== 'undefined') && (this.selectionModel !== null) && (this.selectionModel.length > 0)){ + this.application.ninja.selectionController.initWithDocument(this.selectionModel); + } + + + } + } + //////////////////////////////////////////////////////////////////// }); \ No newline at end of file -- cgit v1.2.3 From 6e66f411ba02eaaeb33471115345ecf3c7ce4ce9 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Thu, 23 Feb 2012 17:55:59 -0800 Subject: refresh draw-utils, snap-manager, view-utils for html document stitching Signed-off-by: Ananya Sen --- js/document/html-document.js | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'js/document') diff --git a/js/document/html-document.js b/js/document/html-document.js index d38709e3..c5293386 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -645,7 +645,6 @@ exports.HTMLDocument = Montage.create(TextDocument, { this.gridHorizontalSpacing = this.application.ninja.stage.drawUtils.gridHorizontalSpacing; this.gridVerticalSpacing = this.application.ninja.stage.drawUtils.gridVerticalSpacing; - //TODO:selection should be saved as an element state data, to avoid duplicate dom elements store in memory if(typeof this.application.ninja.selectedElements !== 'undefined'){ this.selectionModel = this.application.ninja.selectedElements; } @@ -656,24 +655,21 @@ exports.HTMLDocument = Montage.create(TextDocument, { restoreAppState:{ enumerable: false, value: function () { - if((this.savedLeftScroll!== null) && (this.savedTopScroll !== null)){ - this.application.ninja.stage._iframeContainer.scrollLeft = this.savedLeftScroll; - this.application.ninja.stage._scrollLeft = this.savedLeftScroll; - this.application.ninja.stage._iframeContainer.scrollTop = this.savedTopScroll; - this.application.ninja.stage._scrollTop = this.savedTopScroll; - } - this.application.ninja.stage.drawUtils.gridHorizontalSpacing = this.gridHorizontalSpacing; this.application.ninja.stage.drawUtils.gridVerticalSpacing = this.gridVerticalSpacing; - //TODO:selectionController.initWithDocument should loop over elements in documentRoot to repopulate if((typeof this.selectionModel !== 'undefined') && (this.selectionModel !== null) && (this.selectionModel.length > 0)){ this.application.ninja.selectionController.initWithDocument(this.selectionModel); } - + if((this.savedLeftScroll!== null) && (this.savedTopScroll !== null)){ + this.application.ninja.stage._iframeContainer.scrollLeft = this.savedLeftScroll; + this.application.ninja.stage._scrollLeft = this.savedLeftScroll; + this.application.ninja.stage._iframeContainer.scrollTop = this.savedTopScroll; + this.application.ninja.stage._scrollLeft = this.savedTopScroll; + } + this.application.ninja.stage.handleScroll(); } } - //////////////////////////////////////////////////////////////////// }); \ No newline at end of file -- cgit v1.2.3