aboutsummaryrefslogtreecommitdiff
path: root/js/stage/stage.reel
diff options
context:
space:
mode:
authorAnanya Sen2012-05-01 13:39:30 -0700
committerAnanya Sen2012-05-01 13:39:30 -0700
commitc360d1a5cfe894591ae65f892ead11d0ca537b18 (patch)
tree13964f810d3516dbc02e27ab5bb576fe62366f26 /js/stage/stage.reel
parent3137d919e6b4ccbb2fb68c5920f4376acde3f1f5 (diff)
parente3fa4c7db57b63c5ac604c9420062de5d0fe413a (diff)
downloadninja-c360d1a5cfe894591ae65f892ead11d0ca537b18.tar.gz
Merge branch 'refs/heads/ninja-internal-master' into Codeview-improvements
Diffstat (limited to 'js/stage/stage.reel')
-rwxr-xr-xjs/stage/stage.reel/stage.html17
-rwxr-xr-xjs/stage/stage.reel/stage.js154
2 files changed, 87 insertions, 84 deletions
diff --git a/js/stage/stage.reel/stage.html b/js/stage/stage.reel/stage.html
index f796303c..12a331c3 100755
--- a/js/stage/stage.reel/stage.html
+++ b/js/stage/stage.reel/stage.html
@@ -1,4 +1,4 @@
1<!DOCTYPE html> 1<!DOCTYPE html>
2<!-- <copyright> 2<!-- <copyright>
3 This file contains proprietary software owned by Motorola Mobility, Inc.<br/> 3 This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
4 No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> 4 No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
@@ -12,24 +12,21 @@
12 <script type="text/montage-serialization"> 12 <script type="text/montage-serialization">
13 { 13 {
14 "stageView" : { 14 "stageView" : {
15 "module": "js/stage/stage-view.reel", 15 "prototype": "js/stage/stage-view.reel",
16 "name": "StageView",
17 "properties": { 16 "properties": {
18 "element": {"#": "stageView"} 17 "element": {"#": "stageView"}
19 } 18 }
20 }, 19 },
21 20
22 "StageDeps1": { 21 "StageDeps1": {
23 "module": "js/stage/stage-deps", 22 "prototype": "js/stage/stage-deps",
24 "name": "StageDeps",
25 "properties": { 23 "properties": {
26 "stage": {"@": "owner"} 24 "stage": {"@": "owner"}
27 } 25 }
28 }, 26 },
29 27
30 "layout1": { 28 "layout1": {
31 "module": "js/stage/layout", 29 "prototype": "js/stage/layout",
32 "name": "Layout",
33 "properties": { 30 "properties": {
34 "canvas": {"#": "layoutCanvas"}, 31 "canvas": {"#": "layoutCanvas"},
35 "stage": {"@": "owner"} 32 "stage": {"@": "owner"}
@@ -44,8 +41,7 @@
44 }, 41 },
45 42
46 "textTool": { 43 "textTool": {
47 "module": "node_modules/labs/rich-text-editor.reel", 44 "prototype": "node_modules/labs/rich-text-editor.reel",
48 "name": "RichTextEditor",
49 "properties": { 45 "properties": {
50 "element" : {"#": "textToolObject"} 46 "element" : {"#": "textToolObject"}
51 } 47 }
@@ -56,8 +52,7 @@
56 }, 52 },
57 53
58 "owner": { 54 "owner": {
59 "module": "js/stage/stage.reel", 55 "prototype": "js/stage/stage.reel",
60 "name": "Stage",
61 "properties": { 56 "properties": {
62 "element": {"#": "stageAndScenesContainer"}, 57 "element": {"#": "stageAndScenesContainer"},
63 "_iframeContainer": {"#": "iframeContainer"}, 58 "_iframeContainer": {"#": "iframeContainer"},
diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js
index 8382135d..515165bf 100755
--- a/js/stage/stage.reel/stage.js
+++ b/js/stage/stage.reel/stage.js
@@ -224,14 +224,6 @@ exports.Stage = Montage.create(Component, {
224 // Event details will contain the active document prior to opening a new one 224 // Event details will contain the active document prior to opening a new one
225 handleOpenDocument: { 225 handleOpenDocument: {
226 value: function(evt) { 226 value: function(evt) {
227
228 var prevActiveDocument = evt.detail;
229 // Hide current document is one is open
230 if(prevActiveDocument) {
231 prevActiveDocument.container.style["display"] = "none";
232 if(prevActiveDocument.documentType === "htm" || prevActiveDocument.documentType === "html") this.hideCanvas(true);
233 }
234
235 this.hideCanvas(false); 227 this.hideCanvas(false);
236 228
237 // Recalculate the canvas sizes because of splitter resizing 229 // Recalculate the canvas sizes because of splitter resizing
@@ -239,29 +231,43 @@ exports.Stage = Montage.create(Component, {
239 this._canvas.height = this._layoutCanvas.height = this._drawingCanvas.height = this.element.offsetHeight - 11; 231 this._canvas.height = this._layoutCanvas.height = this._drawingCanvas.height = this.element.offsetHeight - 11;
240 232
241 this._documentRoot = this.application.ninja.currentDocument.documentRoot; 233 this._documentRoot = this.application.ninja.currentDocument.documentRoot;
242 this._viewport = this.application.ninja.currentDocument.documentRoot.parentNode;
243 234
244 this.documentOffsetLeft = this._viewport.offsetLeft; 235 // Hardcode this value so that it does not fail for the new stage architecture
245 this.documentOffsetTop = this._viewport.offsetTop; 236 // TODO: Remove marker for old template: NINJA-STAGE-REWORK
237 if(this.application.ninja.currentDocument.documentRoot.id === "UserContent") {
238 this._viewport = this.application.ninja.currentDocument.documentRoot.parentNode;
246 239
247 // Center the stage 240 this.documentOffsetLeft = this._viewport.offsetLeft;
248 this.centerStage(); 241 this.documentOffsetTop = this._viewport.offsetTop;
249 242
250 this._scrollLeft = this._iframeContainer.scrollLeft; 243 // Center the stage
251 this._scrollTop = this._iframeContainer.scrollTop; 244 this.centerStage();
252 this.application.ninja.currentDocument.savedLeftScroll = this._iframeContainer.scrollLeft;
253 this.application.ninja.currentDocument.savedTopScroll = this._iframeContainer.scrollTop;
254 245
255 // Hardcode this value so that it does not fail for the new stage architecture 246 this._scrollLeft = this._iframeContainer.scrollLeft;
256 // TODO: Remove marker for old template: NINJA-STAGE-REWORK 247 this._scrollTop = this._iframeContainer.scrollTop;
257 this.userContentBorder = 1; //parseInt(this._documentRoot.elementModel.controller.getProperty(this._documentRoot, "border")); 248 this.application.ninja.currentDocument.savedLeftScroll = this._iframeContainer.scrollLeft;
249 this.application.ninja.currentDocument.savedTopScroll = this._iframeContainer.scrollTop;
258 250
259 this._userContentLeft = this._documentOffsetLeft - this._scrollLeft + this._userContentBorder; 251 this.userContentBorder = parseInt(this._documentRoot.elementModel.controller.getProperty(this._documentRoot, "border"));
260 this._userContentTop = this._documentOffsetTop - this._scrollTop + this._userContentBorder; 252
253 this._userContentLeft = this._documentOffsetLeft - this._scrollLeft + this._userContentBorder;
254 this._userContentTop = this._documentOffsetTop - this._scrollTop + this._userContentBorder;
255
256 this._iframeContainer.addEventListener("scroll", this, false);
257
258 this.application.ninja.currentDocument.iframe.style.opacity = 1.0;
259 } else {
260 this.userContentBorder = 0;
261
262 this._scrollLeft = 0;
263 this._scrollTop = 0;
264 this._userContentLeft = 0;
265 this._userContentTop = 0;
266
267 this.application.ninja.currentDocument._window.addEventListener("scroll", this, false);
268 }
261 269
262 this.application.ninja.currentDocument.iframe.style.opacity = 1.0;
263 270
264 this._iframeContainer.addEventListener("scroll", this, false);
265 271
266 // TODO - We will need to modify this once we support switching between multiple documents 272 // TODO - We will need to modify this once we support switching between multiple documents
267 this.application.ninja.toolsData.selectedToolInstance._configure(true); 273 this.application.ninja.toolsData.selectedToolInstance._configure(true);
@@ -419,13 +425,10 @@ exports.Stage = Montage.create(Component, {
419 handleSelectionChange: { 425 handleSelectionChange: {
420 value: function(event) { 426 value: function(event) {
421 // TODO - this is a hack for now because some tools depend on selectionDrawn event for some logic 427 // TODO - this is a hack for now because some tools depend on selectionDrawn event for some logic
422 if(this.drawNow) 428 if(this.drawNow) {
423 {
424 this.draw(); 429 this.draw();
425 this.drawNow = false; 430 this.drawNow = false;
426 } 431 } else {
427 else
428 {
429 this.needsDraw = true; 432 this.needsDraw = true;
430 } 433 }
431 } 434 }
@@ -448,11 +451,20 @@ exports.Stage = Montage.create(Component, {
448 */ 451 */
449 handleScroll: { 452 handleScroll: {
450 value: function() { 453 value: function() {
451 this._scrollLeft = this._iframeContainer.scrollLeft; 454 // TODO: Remove marker for old template: NINJA-STAGE-REWORK
452 this._scrollTop = this._iframeContainer.scrollTop; 455 if(this.application.ninja.currentDocument.documentRoot.id === "UserContent") {
456 this._scrollLeft = this._iframeContainer.scrollLeft;
457 this._scrollTop = this._iframeContainer.scrollTop;
458
459 this.userContentLeft = this._documentOffsetLeft - this._scrollLeft + this._userContentBorder;
460 this.userContentTop = this._documentOffsetTop - this._scrollTop + this._userContentBorder;
461 } else {
462 this._scrollLeft = this.application.ninja.currentDocument.documentRoot.scrollLeft;
463 this._scrollTop = this.application.ninja.currentDocument.documentRoot.scrollTop;
453 464
454 this.userContentLeft = this._documentOffsetLeft - this._scrollLeft + this._userContentBorder; 465 this.userContentLeft = -this._scrollLeft;
455 this.userContentTop = this._documentOffsetTop - this._scrollTop + this._userContentBorder; 466 this.userContentTop = -this._scrollTop;
467 }
456 468
457 // Need to clear the snap cache and set up the drag plane 469 // Need to clear the snap cache and set up the drag plane
458 //snapManager.setupDragPlaneFromPlane( workingPlane ); 470 //snapManager.setupDragPlaneFromPlane( workingPlane );
@@ -461,7 +473,6 @@ exports.Stage = Montage.create(Component, {
461 this.needsDraw = true; 473 this.needsDraw = true;
462 this.layout.draw(); 474 this.layout.draw();
463 //this._toolsList.action("DrawHandles"); 475 //this._toolsList.action("DrawHandles");
464
465 } 476 }
466 }, 477 },
467 478
@@ -521,62 +532,59 @@ exports.Stage = Montage.create(Component, {
521 }, 532 },
522 533
523 /** 534 /**
524 * GetSelectableElement: Returns a selectable object (direct child of current container) at clicked point 535 * GetElement: Returns the element or selectable element under the X,Y coordinates passed as an obj with x,y
525 * 536 *
526 * @param: X,Y 537 * @param position: mouse event
527 * @return: Returns the current container if the the X,Y hits an element in the exclusion list 538 * @param selectable (default == null) if true this will return the current container element
539 * @return: Returns the element or container or null if the the X,Y hits the exclusion list and tool cannot operate on stage
528 */ 540