aboutsummaryrefslogtreecommitdiff
path: root/js/document
diff options
context:
space:
mode:
authorAnanya Sen2012-02-23 13:43:35 -0800
committerAnanya Sen2012-02-23 13:43:35 -0800
commit7283884c39df537694b21419a3ea9e3ca7793b4b (patch)
treebd48aebcfdb2ba36721360a47c1654f22b9f75b6 /js/document
parentdbf0ca5637a3bca87c21c65ada47f8a4d794f78c (diff)
downloadninja-7283884c39df537694b21419a3ea9e3ca7793b4b.tar.gz
switch html document - re-initialize draw-utils and snap-manager on opening a document and while switching documents
Signed-off-by: Ananya Sen <Ananya.Sen@motorola.com>
Diffstat (limited to 'js/document')
-rwxr-xr-xjs/document/html-document.js59
1 files changed, 57 insertions, 2 deletions
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, {
53 }, 53 },
54 54
55 55
56 //drawUtils state
57 _gridHorizontalSpacing: {value:0},
58 _gridVerticalSpacing: {value:0},
59 //end - drawUtils state
60
56 61
57 // GETTERS / SETTERS 62 // GETTERS / SETTERS
58 63
@@ -71,6 +76,16 @@ exports.HTMLDocument = Montage.create(TextDocument, {
71 set: function(value) { this._savedTopScroll = value} 76 set: function(value) { this._savedTopScroll = value}
72 }, 77 },
73 78
79 gridHorizontalSpacing:{
80 get: function() { return this._gridHorizontalSpacing; },
81 set: function(value) { this._gridHorizontalSpacing = value}
82 },
83
84 gridVerticalSpacing:{
85 get: function() { return this._gridVerticalSpacing; },
86 set: function(value) { this._gridVerticalSpacing = value}
87 },
88
74 selectionExclude: { 89 selectionExclude: {
75 get: function() { return this._selectionExclude; }, 90 get: function() { return this._selectionExclude; },
76 set: function(value) { this._selectionExclude = value; } 91 set: function(value) { this._selectionExclude = value; }
@@ -444,7 +459,7 @@ exports.HTMLDocument = Montage.create(TextDocument, {
444 this._styles = this._document.styleSheets[1]; 459 this._styles = this._document.styleSheets[1];
445 this._stylesheets = this._document.styleSheets; // Entire stlyesheets array 460 this._stylesheets = this._document.styleSheets; // Entire stlyesheets array
446 461
447 console.log(this._document.styleSheets); 462 //console.log(this._document.styleSheets);
448 463
449 //////////////////////////////////////////////////////////////////////////// 464 ////////////////////////////////////////////////////////////////////////////
450 //////////////////////////////////////////////////////////////////////////// 465 ////////////////////////////////////////////////////////////////////////////
@@ -570,7 +585,47 @@ exports.HTMLDocument = Montage.create(TextDocument, {
570 //Error 585 //Error
571 } 586 }
572 } 587 }
573 } 588 },
574 //////////////////////////////////////////////////////////////////// 589 ////////////////////////////////////////////////////////////////////
590 saveAppState:{
591 enumerable: false,
592 value: function () {
593
594 this.savedLeftScroll = this.application.ninja.stage._iframeContainer.scrollLeft;
595 this.savedTopScroll = this.application.ninja.stage._iframeContainer.scrollTop;
596
597 this.gridHorizontalSpacing = this.application.ninja.stage.drawUtils.gridHorizontalSpacing;
598 this.gridVerticalSpacing = this.application.ninja.stage.drawUtils.gridVerticalSpacing;
599
600 //TODO:selection should be saved as an element state data, to avoid duplicate dom elements store in memory
601 if(typeof this.application.ninja.selectedElements !== 'undefined'){
602 this.selectionModel = this.application.ninja.selectedElements;
603 }
604 }
605 },
606
607 ////////////////////////////////////////////////////////////////////
608 restoreAppState:{
609 enumerable: false,
610 value: function () {
611 if((this.savedLeftScroll!== null) && (this.savedTopScroll !== null)){
612 this.application.ninja.stage._iframeContainer.scrollLeft = this.savedLeftScroll;
613 this.application.ninja.stage._scrollLeft = this.savedLeftScroll;
614 this.application.ninja.stage._iframeContainer.scrollTop = this.savedTopScroll;
615 this.application.ninja.stage._scrollTop = this.savedTopScroll;
616 }
617
618 this.application.ninja.stage.drawUtils.gridHorizontalSpacing = this.gridHorizontalSpacing;
619 this.application.ninja.stage.drawUtils.gridVerticalSpacing = this.gridVerticalSpacing;
620
621 //TODO:selectionController.initWithDocument should loop over elements in documentRoot to repopulate
622 if((typeof this.selectionModel !== 'undefined') && (this.selectionModel !== null) && (this.selectionModel.length > 0)){
623 this.application.ninja.selectionController.initWithDocument(this.selectionModel);
624 }
625
626
627 }
628 }
629
575 //////////////////////////////////////////////////////////////////// 630 ////////////////////////////////////////////////////////////////////
576}); \ No newline at end of file 631}); \ No newline at end of file