From 07c48708a99b94a220c043ad5951a331bbd4fc2d Mon Sep 17 00:00:00 2001 From: hwc487 Date: Wed, 29 Feb 2012 15:23:28 -0800 Subject: WebGL file I/O --- js/document/html-document.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/document') diff --git a/js/document/html-document.js b/js/document/html-document.js index 76436732..7dd28385 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -185,7 +185,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { var elt = this.documentRoot; if (elt) { - console.log( "load canvas data: " , value ); + //console.log( "load canvas data: " , value ); var cdm = new CanvasDataManager(); cdm.loadGLData(elt, value); } -- cgit v1.2.3 From 232784ffafe834f75a46ca7fc311e8ca2ff5eec9 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Mon, 5 Mar 2012 16:33:51 -0800 Subject: Corrections for canvas file IO --- js/document/html-document.js | 69 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 66 insertions(+), 3 deletions(-) (limited to 'js/document') diff --git a/js/document/html-document.js b/js/document/html-document.js index 7dd28385..f1b99866 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -185,9 +185,51 @@ exports.HTMLDocument = Montage.create(TextDocument, { var elt = this.documentRoot; if (elt) { - //console.log( "load canvas data: " , value ); - var cdm = new CanvasDataManager(); - cdm.loadGLData(elt, value); + var loadForRuntime = true; + if (loadForRuntime) + { + //console.log( "load canvas data: " , value ); + var cdm = new CanvasDataManager(); + cdm.loadGLData(elt, value, NJUtils); + } + else + { + var nWorlds= value.length; + for (var i=0; i= 0) + { + var endIndex = importStr.indexOf( "\n", startIndex ); + if (endIndex > 0) + { + var id = importStr.substring( startIndex+4, endIndex ); + if (id) + { + var canvas = this.findCanvasWithID( id, elt ); + if (canvas) + { + if (!canvas.elementModel) + { + NJUtils.makeElementModel(canvas, "Canvas", "shape", true); + } + + if (canvas.elementModel) + { + if (canvas.elementModel.shapeModel.GLWorld) + canvas.elementModel.shapeModel.GLWorld.clearTree(); + + var world = new GLWorld( canvas ); + canvas.elementModel.shapeModel.GLWorld = world; + world.import( importStr ); + } + } + } + } + } + } + } } } }, @@ -219,6 +261,27 @@ exports.HTMLDocument = Montage.create(TextDocument, { } } }, + + /** + * search the DOM tree to find a canvas with the given id + */ + findCanvasWithID: { + value: function( id, elt ) { + var cid = elt.getAttribute( "data-RDGE-id" ); + if (cid == id) return elt; + + if (elt.children) + { + var nKids = elt.children.length; + for (var i=0; i= 0) + var world = new GLWorld( canvas, useWebGL ); world.import( importStr ); + canvas.elementModel.shapeModel.GLWorld = world; + + /////////////////////////// + //something.buildShapeModel( world ); // to come from Nivesh } } } -- cgit v1.2.3 From 11c3fa444217a34fa481b156d4d919d10e817350 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Tue, 6 Mar 2012 13:10:19 -0800 Subject: update the shapeModel after import --- js/document/html-document.js | 48 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) (limited to 'js/document') diff --git a/js/document/html-document.js b/js/document/html-document.js index 8722e223..f1847357 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -226,8 +226,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { world.import( importStr ); canvas.elementModel.shapeModel.GLWorld = world; - /////////////////////////// - //something.buildShapeModel( world ); // to come from Nivesh + this.buildShapeModel( canvas.elementModel.shapeModel, world ); } } } @@ -239,6 +238,51 @@ exports.HTMLDocument = Montage.create(TextDocument, { } }, + buildShapeModel: + { + value: function( shapeModel, world ) + { + shapeModel.shapeCount = 1; // for now... + shapeModel.useWebGl = world._useWebGL; + shapeModel.GLWorld = world; + var root = world.getGeomRoot(); + if (root) + { + shapeModel.GLGeomObj = root; + shapeModel.strokeSize = root._strokeWidth; + shapeModel.stroke = root._strokeColor.slice(); + shapeModel.strokeMaterial = root._strokeMaterial.dup(); + shapeModel.strokeStyle = "solid"; + //shapeModel.strokeStyleIndex + //shapeModel.border + shapeModel.fill = root._fillColor.slice(); + shapeModel.fillMaterial = root._fillMaterial.dup(); + //shapeModel.background + switch (root.geomType()) + { + case root.GEOM_TYPE_RECTANGLE: + shapeModel.tlRadius = root._tlRadius; + shapeModel.trRadius = root._trRadius; + shapeModel.blRadius = root._blRadius; + shapeModel.brRadius = root._brRadius; + break; + + case root.GEOM_TYPE_CIRCLE: + shapeModel.innerRadius = root._innerRadius; + break; + + case root.GEOM_TYPE_LINE: + shapeModel.slope = root._slope; + break; + + default: + console.log( "geometry type not supported for file I/O, " + root.geomType()); + break; + } + } + } + }, + zoomFactor: { get: function() { return this._zoomFactor; }, set: function(value) { this._zoomFactor = value; } -- cgit v1.2.3 From 3fcb463816a399b5474114725322653a20a22e9a Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 6 Mar 2012 13:42:27 -0800 Subject: Updated buildShapeModel to set PI and selection values too and also avoid fill material for lines. Signed-off-by: Nivesh Rajbhandari --- js/document/html-document.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'js/document') diff --git a/js/document/html-document.js b/js/document/html-document.js index f1847357..00cf0164 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -226,7 +226,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { world.import( importStr ); canvas.elementModel.shapeModel.GLWorld = world; - this.buildShapeModel( canvas.elementModel.shapeModel, world ); + this.buildShapeModel( canvas.elementModel, world ); } } } @@ -240,8 +240,9 @@ exports.HTMLDocument = Montage.create(TextDocument, { buildShapeModel: { - value: function( shapeModel, world ) + value: function( elementModel, world ) { + var shapeModel = elementModel.shapeModel; shapeModel.shapeCount = 1; // for now... shapeModel.useWebGl = world._useWebGL; shapeModel.GLWorld = world; @@ -255,12 +256,14 @@ exports.HTMLDocument = Montage.create(TextDocument, { shapeModel.strokeStyle = "solid"; //shapeModel.strokeStyleIndex //shapeModel.border - shapeModel.fill = root._fillColor.slice(); - shapeModel.fillMaterial = root._fillMaterial.dup(); //shapeModel.background switch (root.geomType()) { case root.GEOM_TYPE_RECTANGLE: + elementModel.selection = "Rectangle"; + elementModel.pi = "RectanglePi"; + shapeModel.fill = root._fillColor.slice(); + shapeModel.fillMaterial = root._fillMaterial.dup(); shapeModel.tlRadius = root._tlRadius; shapeModel.trRadius = root._trRadius; shapeModel.blRadius = root._blRadius; @@ -268,10 +271,16 @@ exports.HTMLDocument = Montage.create(TextDocument, { break; case root.GEOM_TYPE_CIRCLE: + elementModel.selection = "Oval"; + elementModel.pi = "OvalPi"; + shapeModel.fill = root._fillColor.slice(); + shapeModel.fillMaterial = root._fillMaterial.dup(); shapeModel.innerRadius = root._innerRadius; break; case root.GEOM_TYPE_LINE: + elementModel.selection = "Line"; + elementModel.pi = "LinePi"; shapeModel.slope = root._slope; break; -- cgit v1.2.3 From 9e4ee2470726e3334eb47d904a6f4079d4ed7aef Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Tue, 6 Mar 2012 17:01:39 -0800 Subject: IKNINJA-1270: fixed browser crashing when you close a document while playing a video then wait for a while Signed-off-by: Ananya Sen --- js/document/html-document.js | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) (limited to 'js/document') diff --git a/js/document/html-document.js b/js/document/html-document.js index 80930af2..d90231e3 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -824,6 +824,9 @@ exports.HTMLDocument = Montage.create(TextDocument, { this.undoStack = this.application.ninja.undocontroller.undoQueue.slice(0); this.redoStack = this.application.ninja.undocontroller.redoQueue.slice(0); this.application.ninja.undocontroller.clearHistory();//clear history to give the next document a fresh start + + //pause videos on switching or closing the document, so that the browser does not keep downloading the media data + this.pauseVideos(); } }, @@ -852,6 +855,42 @@ exports.HTMLDocument = Montage.create(TextDocument, { } - } + }, //////////////////////////////////////////////////////////////////// + /** + *pause videos on switching or closing the document, so that the browser does not keep downloading the media data + *removeSrc : boolean to remove the src if the video... set only in the close document flow + */ + pauseVideos:{ + value:function(removeSrc){ + console.log("$$$ pauseVideos"); + var videosArr = this.documentRoot.getElementsByTagName("video"), i=0; + for(i=0;i --- js/document/html-document.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'js/document') diff --git a/js/document/html-document.js b/js/document/html-document.js index d90231e3..924a013d 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -863,16 +863,16 @@ exports.HTMLDocument = Montage.create(TextDocument, { */ pauseVideos:{ value:function(removeSrc){ - console.log("$$$ pauseVideos"); + //console.log("$$$ pauseVideos"); var videosArr = this.documentRoot.getElementsByTagName("video"), i=0; for(i=0;i --- js/document/html-document.js | 1 - 1 file changed, 1 deletion(-) (limited to 'js/document') diff --git a/js/document/html-document.js b/js/document/html-document.js index 9670e0c4..83f91c19 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -894,7 +894,6 @@ exports.HTMLDocument = Montage.create(TextDocument, { /** * remove the video src on closing the document, so that the browser does not keep downloading the media data, if the tag does not get garbage collected - *removeSrc : boolean to remove the src if the video... set only in the close document flow */ stopVideos:{ value:function(){ -- cgit v1.2.3 From 250420d8c6154172b27fe53aff30e78c227e8a67 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Wed, 7 Mar 2012 14:26:37 -0800 Subject: minor fixes Signed-off-by: Ananya Sen --- js/document/html-document.js | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'js/document') diff --git a/js/document/html-document.js b/js/document/html-document.js index 83f91c19..f730b853 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -872,22 +872,15 @@ exports.HTMLDocument = Montage.create(TextDocument, { }, //////////////////////////////////////////////////////////////////// /** - *pause videos on switching or closing the document, so that the browser does not keep downloading the media data - *removeSrc : boolean to remove the src if the video... set only in the close document flow + *pause videos on switching or closing the document */ pauseVideos:{ - value:function(removeSrc){ - //console.log("$$$ pauseVideos"); + value:function(){ var videosArr = this.documentRoot.getElementsByTagName("video"), i=0; for(i=0;i= 0) var world = new GLWorld( canvas, useWebGL ); world.import( importStr ); - canvas.elementModel.shapeModel.GLWorld = world; this.buildShapeModel( canvas.elementModel, world ); } @@ -789,8 +790,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { } } } - //return {mode: 'html', document: this._userDocument, webgl: this.glData, styles: styles, head: this._templateDocument.head.innerHTML, body: this._templateDocument.body.innerHTML}; - return {mode: 'html', document: this._userDocument, styles: styles, head: this._templateDocument.head.innerHTML, body: this._templateDocument.body.innerHTML}; + return {mode: 'html', document: this._userDocument, webgl: this.glData, styles: styles, head: this._templateDocument.head.innerHTML, body: this._templateDocument.body.innerHTML}; } else if (this.currentView === "code"){ //TODO: Would this get call when we are in code of HTML? } else { @@ -813,8 +813,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { } } } - //return {mode: 'html', document: this._userDocument, webgl: this.glData, css: css, head: this._templateDocument.head.innerHTML, body: this._templateDocument.body.innerHTML}; - return {mode: 'html', document: this._userDocument, css: css, head: this._templateDocument.head.innerHTML, body: this._templateDocument.body.innerHTML}; + return {mode: 'html', document: this._userDocument, webgl: this.glData, css: css, head: this._templateDocument.head.innerHTML, body: this._templateDocument.body.innerHTML}; } else if (this.currentView === "code"){ //TODO: Would this get call when we are in code of HTML? } else { -- cgit v1.2.3 From 9e812f35ffa751e9215c5427c0c44005bd357924 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Wed, 7 Mar 2012 17:18:38 -0800 Subject: Fixed a few problems with Plasma material. --- js/document/html-document.js | 1 - 1 file changed, 1 deletion(-) (limited to 'js/document') diff --git a/js/document/html-document.js b/js/document/html-document.js index 44f90d41..0a3497f1 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -190,7 +190,6 @@ exports.HTMLDocument = Montage.create(TextDocument, { var loadForRuntime = true; if (loadForRuntime) { - //console.log( "load canvas data: " , value ); var cdm = new CanvasDataManager(); cdm.loadGLData(elt, value, NJUtils); } -- cgit v1.2.3 From 710a17a23dee948304bad79d40424c3a477b6cc4 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Thu, 8 Mar 2012 09:50:40 -0800 Subject: Commented out code for loading for runtime --- js/document/html-document.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'js/document') diff --git a/js/document/html-document.js b/js/document/html-document.js index 0a3497f1..b75eb226 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -187,13 +187,15 @@ exports.HTMLDocument = Montage.create(TextDocument, { var elt = this.documentRoot; if (elt) { - var loadForRuntime = true; - if (loadForRuntime) - { - var cdm = new CanvasDataManager(); - cdm.loadGLData(elt, value, NJUtils); - } - else +// FOR JOSE: The following commented out lines are what the runtime +// version should execute. +// var loadForRuntime = true; +// if (loadForRuntime) +// { +// var cdm = new CanvasDataManager(); +// cdm.loadGLData(elt, value, NJUtils); +// } +// else { var nWorlds= value.length; for (var i=0; i= 0) - { - var endIndex = importStr.indexOf( "\n", startIndex ); - if (endIndex > 0) - { - var id = importStr.substring( startIndex+4, endIndex ); - if (id) - { - var canvas = this.findCanvasWithID( id, elt ); - if (canvas) - { - if (!canvas.elementModel) - { - NJUtils.makeElementModel(canvas, "Canvas", "shape", true); - } - - if (canvas.elementModel) - { - if (canvas.elementModel.shapeModel.GLWorld) - canvas.elementModel.shapeModel.GLWorld.clearTree(); - - var index = importStr.indexOf( "webGL: " ); - var useWebGL = (index >= 0) - var world = new GLWorld( canvas, useWebGL ); - world.import( importStr ); - - this.buildShapeModel( canvas.elementModel, world ); + var nWorlds= value.length; + for (var i=0; i= 0) { + var endIndex = importStr.indexOf("\n", startIndex); + if (endIndex > 0) { + var id = importStr.substring( startIndex+4, endIndex); + if (id) { + var canvas = this.findCanvasWithID(id, elt); + if (canvas) { + if (!canvas.elementModel) { + NJUtils.makeElementModel(canvas, "Canvas", "shape", true); + } + if (canvas.elementModel) { + if (canvas.elementModel.shapeModel.GLWorld) { + canvas.elementModel.shapeModel.GLWorld.clearTree(); } + var index = importStr.indexOf( "webGL: " ); + var useWebGL = (index >= 0) + var world = new GLWorld(canvas, useWebGL); + world.import( importStr ); + this.buildShapeModel(canvas.elementModel, world); } } } -- cgit v1.2.3 From 7b6e8194b91168abdeb94702eb350d14f147858b Mon Sep 17 00:00:00 2001 From: hwc487 Date: Thu, 8 Mar 2012 17:29:18 -0800 Subject: Canvas IO --- js/document/html-document.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'js/document') diff --git a/js/document/html-document.js b/js/document/html-document.js index 078a73b5..b2113623 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -9,7 +9,6 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot var Montage = require("montage/core/core").Montage, TextDocument = require("js/document/text-document").TextDocument, NJUtils = require("js/lib/NJUtils").NJUtils, - CanvasDataManager = require("js/lib/rdge/runtime/CanvasDataManager").CanvasDataManager, GLWorld = require("js/lib/drawing/world").World; //////////////////////////////////////////////////////////////////////// // @@ -174,9 +173,9 @@ exports.HTMLDocument = Montage.create(TextDocument, { this._glData = null; if (elt) { - var cdm = new CanvasDataManager(); this._glData = []; - cdm.collectGLData( elt, this._glData ); + var path = "assets/"; + this.collectGLData( elt, this._glData, path ); } return this._glData; @@ -187,9 +186,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { var elt = this.documentRoot; if (elt) { -// FOR JOSE: The following commented out lines are what the runtime -// version should execute. -// var loadForRuntime = true; +// var loadForRuntime = false; // if (loadForRuntime) // { // var cdm = new CanvasDataManager(); @@ -367,11 +364,11 @@ exports.HTMLDocument = Montage.create(TextDocument, { collectGLData: { - value: function( elt, dataArray ) + value: function( elt, dataArray, imagePath ) { if (elt.elementModel && elt.elementModel.shapeModel && elt.elementModel.shapeModel.GLWorld) { - var data = elt.elementModel.shapeModel.GLWorld.export(); + var data = elt.elementModel.shapeModel.GLWorld.export( imagePath ); dataArray.push( data ); } @@ -381,7 +378,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { for (var i=0; i= 0) - { - var endIndex = importStr.indexOf( "\n", startIndex ); - if (endIndex > 0) - { - var id = importStr.substring( startIndex+4, endIndex ); - if (id) - { - var canvas = this.findCanvasWithID( id, elt ); - if (canvas) - { - if (!canvas.elementModel) - { - NJUtils.makeElementModel(canvas, "Canvas", "shape", true); - } - - if (canvas.elementModel) - { - if (canvas.elementModel.shapeModel.GLWorld) - canvas.elementModel.shapeModel.GLWorld.clearTree(); - - var index = importStr.indexOf( "webGL: " ); - var useWebGL = (index >= 0) - var world = new GLWorld( canvas, useWebGL ); - world.import( importStr ); - - this.buildShapeModel( canvas.elementModel, world ); + if (elt) { + var nWorlds= value.length; + for (var i=0; i= 0) { + var endIndex = importStr.indexOf( "\n", startIndex ); + if (endIndex > 0) { + var id = importStr.substring( startIndex+4, endIndex ); + if (id) { + var canvas = this.findCanvasWithID( id, elt ); + if (canvas) { + if (!canvas.elementModel) { + NJUtils.makeElementModel(canvas, "Canvas", "shape", true); + } + if (canvas.elementModel) { + if (canvas.elementModel.shapeModel.GLWorld) { + canvas.elementModel.shapeModel.GLWorld.clearTree(); } + var index = importStr.indexOf( "webGL: " ); + var useWebGL = (index >= 0) + var world = new GLWorld( canvas, useWebGL ); + world.import( importStr ); + this.buildShapeModel( canvas.elementModel, world ); } } } -- cgit v1.2.3 From e92a6da7b84c58803489d70efedf74837ddfe4cd Mon Sep 17 00:00:00 2001 From: hwc487 Date: Fri, 9 Mar 2012 13:34:09 -0800 Subject: Removed asset path replacement at authortime. --- js/document/html-document.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'js/document') diff --git a/js/document/html-document.js b/js/document/html-document.js index aa56fd0e..f57c61ee 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -197,7 +197,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { //if (path) { //this.collectGLData(elt, this._glData, path); //} else { - this.collectGLData(elt, this._glData, "assets/"); + this.collectGLData(elt, this._glData ); //} } else { this._glData = null @@ -368,11 +368,11 @@ exports.HTMLDocument = Montage.create(TextDocument, { collectGLData: { - value: function( elt, dataArray, imagePath ) + value: function( elt, dataArray ) { if (elt.elementModel && elt.elementModel.shapeModel && elt.elementModel.shapeModel.GLWorld) { - var data = elt.elementModel.shapeModel.GLWorld.export( imagePath ); + var data = elt.elementModel.shapeModel.GLWorld.export(); dataArray.push( data ); } -- cgit v1.2.3 From a5d4d57a3575bb3b97fe692ddffca3127463ae94 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Fri, 9 Mar 2012 14:27:23 -0800 Subject: further removal of authortime asset path replacement. --- js/document/html-document.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/document') diff --git a/js/document/html-document.js b/js/document/html-document.js index f57c61ee..79450494 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -382,7 +382,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { for (var i=0; i 0) { + setTimeout(function () {window.open(this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController._activeDocument.uri.split(this.application.ninja.coreIoApi.cloudData.root)[1]);}.bind(this), 3500); + } else { + window.open(this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController._activeDocument.uri.split(this.application.ninja.coreIoApi.cloudData.root)[1]); + } //chrome.tabs.create({url: this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController._activeDocument.uri.split(this.application.ninja.coreIoApi.cloudData.root)[1]}); } }, -- cgit v1.2.3 From 9b40878fcc82d3ec08361e30d2029de261f0f80e Mon Sep 17 00:00:00 2001 From: hwc487 Date: Tue, 13 Mar 2012 16:32:46 -0700 Subject: Fixed BumpMetal material --- js/document/html-document.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'js/document') diff --git a/js/document/html-document.js b/js/document/html-document.js index 051490f5..f4ec3184 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -207,9 +207,17 @@ exports.HTMLDocument = Montage.create(TextDocument, { }, set: function(value) { var elt = this.documentRoot; - if (elt) { + if (elt) + { var nWorlds= value.length; - for (var i=0; i= 0) { -- cgit v1.2.3 From 57d4a82977a1f0e809511fe894886f88581d9615 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Wed, 14 Mar 2012 16:22:22 -0700 Subject: Corrections for Uber shader IO --- js/document/html-document.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'js/document') diff --git a/js/document/html-document.js b/js/document/html-document.js index f4ec3184..d4db6e2f 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -218,6 +218,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { cdm.loadGLData(elt, value, null ); */ + // /* var importStr = value[i]; var startIndex = importStr.indexOf( "id: " ); if (startIndex >= 0) { @@ -244,6 +245,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { } } } + // */ } } } -- cgit v1.2.3 From 9b8a24a7360416d5750828c9580e33dd336ff882 Mon Sep 17 00:00:00 2001 From: François Frisch Date: Fri, 16 Mar 2012 17:57:18 -0700 Subject: Getting ownerComponent bindings --- .../templates/montage-html/main.reel/main.js | 43 +++++++++++----------- 1 file changed, 22 insertions(+), 21 deletions(-) (limited to 'js/document') diff --git a/js/document/templates/montage-html/main.reel/main.js b/js/document/templates/montage-html/main.reel/main.js index 567f481c..ee23e844 100644 --- a/js/document/templates/montage-html/main.reel/main.js +++ b/js/document/templates/montage-html/main.reel/main.js @@ -17,7 +17,25 @@ exports.Main = Montage.create(Component, { */ templateDidLoad: { value: function(){ - window.addComponent = this.addComponentToUserDocument; + var self = this; + window.addComponent = function(element, data, callback) { + var component; + + component = require.async(data.path) + .then(function(component) { + var componentRequire = component[data.name]; + var componentInstance = componentRequire.create(); + + componentInstance.element = element; + //componentInstance.deserializedFromTemplate(); + componentInstance.needsDraw = true; + componentInstance.ownerComponent = self; + + callback(componentInstance, element); + }) + .end(); + + }; // window.addBinding = this.addBindingToUserDocument; // Dispatch event when this template has loaded. @@ -29,26 +47,9 @@ exports.Main = Montage.create(Component, { } }, - // Adding components to the user document by using a async require. - addComponentToUserDocument:{ - value:function(element, data, callback){ - - var component; - - component = require.async(data.path) - .then(function(component) { - var componentRequire = component[data.name]; - var componentInstance = componentRequire.create(); - - componentInstance.element = element; - //componentInstance.deserializedFromTemplate(); - componentInstance.needsDraw = true; - - callback(componentInstance, element); - }) - .end(); - - } + location: { + value:null, + enumerable:false } }); \ No newline at end of file -- cgit v1.2.3 From 9b53d2dac464cb9217b217e6707dbb97c1d65490 Mon Sep 17 00:00:00 2001 From: François Frisch Date: Sat, 17 Mar 2012 11:25:52 -0700 Subject: Deleting unecessary property --- js/document/templates/montage-html/main.reel/main.js | 6 ------ 1 file changed, 6 deletions(-) (limited to 'js/document') diff --git a/js/document/templates/montage-html/main.reel/main.js b/js/document/templates/montage-html/main.reel/main.js index ee23e844..6c141108 100644 --- a/js/document/templates/montage-html/main.reel/main.js +++ b/js/document/templates/montage-html/main.reel/main.js @@ -45,11 +45,5 @@ exports.Main = Montage.create(Component, { document.body.dispatchEvent( newEvent ); } - }, - - location: { - value:null, - enumerable:false } - }); \ No newline at end of file -- cgit v1.2.3 From fda7b595c96d99177fdd93de8da9030348a3f8fb Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Sun, 18 Mar 2012 12:34:29 -0700 Subject: Temp I/O functionality for M-JS components Added the ability to save montages component serialization from Ninja. Very rough, but functional. --- js/document/html-document.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/document') diff --git a/js/document/html-document.js b/js/document/html-document.js index d4db6e2f..be1f89e2 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -905,7 +905,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { } } } - return {mode: 'html', document: this._userDocument, webgl: this.glData, styles: styles, head: this._templateDocument.head.innerHTML, body: this._templateDocument.body.innerHTML}; + return {mode: 'html', document: this._userDocument, mjs: this._userComponents, webgl: this.glData, styles: styles, head: this._templateDocument.head.innerHTML, body: this._templateDocument.body.innerHTML}; } else if (this.currentView === "code"){ //TODO: Would this get call when we are in code of HTML? } else { @@ -928,7 +928,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { } } } - return {mode: 'html', document: this._userDocument, webgl: this.glData, css: css, head: this._templateDocument.head.innerHTML, body: this._templateDocument.body.innerHTML}; + return {mode: 'html', document: this._userDocument, mjs: this._userComponents, webgl: this.glData, css: css, head: this._templateDocument.head.innerHTML, body: this._templateDocument.body.innerHTML}; } else if (this.currentView === "code"){ //TODO: Would this get call when we are in code of HTML? } else { -- cgit v1.2.3 From 19aca6ec6f3c10922646f0ca760a375acdffaf56 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Wed, 21 Mar 2012 16:35:20 -0700 Subject: Adding 'addComponentFirstDraw' event from the user document main component. Signed-off-by: Valerio Virgillito --- js/document/templates/montage-html/main.reel/main.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'js/document') diff --git a/js/document/templates/montage-html/main.reel/main.js b/js/document/templates/montage-html/main.reel/main.js index 6c141108..2970f37a 100644 --- a/js/document/templates/montage-html/main.reel/main.js +++ b/js/document/templates/montage-html/main.reel/main.js @@ -27,16 +27,17 @@ exports.Main = Montage.create(Component, { var componentInstance = componentRequire.create(); componentInstance.element = element; - //componentInstance.deserializedFromTemplate(); + componentInstance.needsDraw = true; componentInstance.ownerComponent = self; + componentInstance.addEventListener("firstDraw", self, false); + callback(componentInstance, element); }) .end(); }; -// window.addBinding = this.addBindingToUserDocument; // Dispatch event when this template has loaded. var newEvent = document.createEvent( "CustomEvent" ); @@ -45,5 +46,14 @@ exports.Main = Montage.create(Component, { document.body.dispatchEvent( newEvent ); } + }, + + handleFirstDraw: { + value: function() { + var newEvent = document.createEvent( "CustomEvent" ); + newEvent.initCustomEvent( "addComponentFirstDraw", false, true ); + + document.body.dispatchEvent( newEvent ); + } } }); \ No newline at end of file -- cgit v1.2.3 From efcec76362a652033254fc6465dd127e8bebc04c Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Thu, 22 Mar 2012 09:57:32 -0700 Subject: Adding firstDraw event to components added This will allow us to re-parse the document for styles added dynamically. --- js/document/templates/montage-html/main.reel/main.js | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'js/document') diff --git a/js/document/templates/montage-html/main.reel/main.js b/js/document/templates/montage-html/main.reel/main.js index 2970f37a..019c675e 100644 --- a/js/document/templates/montage-html/main.reel/main.js +++ b/js/document/templates/montage-html/main.reel/main.js @@ -31,8 +31,6 @@ exports.Main = Montage.create(Component, { componentInstance.needsDraw = true; componentInstance.ownerComponent = self; - componentInstance.addEventListener("firstDraw", self, false); - callback(componentInstance, element); }) .end(); @@ -46,14 +44,5 @@ exports.Main = Montage.create(Component, { document.body.dispatchEvent( newEvent ); } - }, - - handleFirstDraw: { - value: function() { - var newEvent = document.createEvent( "CustomEvent" ); - newEvent.initCustomEvent( "addComponentFirstDraw", false, true ); - - document.body.dispatchEvent( newEvent ); - } } }); \ No newline at end of file -- cgit v1.2.3 From 61a419422b1a05a779fd9a66c53de3fa8ab5f65a Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Thu, 22 Mar 2012 10:28:34 -0700 Subject: - enable/disable save, saveAs, saveAll, close, closeAll as per documents open - added close file and close all menu items Signed-off-by: Ananya Sen Conflicts: js/helper-classes/3D/draw-utils.js Signed-off-by: Ananya Sen --- js/document/text-document.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'js/document') diff --git a/js/document/text-document.js b/js/document/text-document.js index 88464d87..54a53999 100755 --- a/js/document/text-document.js +++ b/js/document/text-document.js @@ -163,7 +163,13 @@ var TextDocument = exports.TextDocument = Montage.create(Component, { needsSave: { get: function() { return this._needsSave; }, - set: function(value) { this._needsSave = value } + set: function(value) { + var i=0, canSaveAll=false; + this._needsSave = value; + + this.application.ninja.documentController.canSave = value;//for save menu state update + this.application.ninja.documentController.canSaveAll = value;//for save menu state update..currently save all is tried to the current document only + } }, callback: { -- cgit v1.2.3 From fea875906664f12feaad0f282901fa8d9a8b054a Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Thu, 22 Mar 2012 11:52:44 -0700 Subject: Presets Panel - Adding presets controller and removing functionality from panel code --- js/document/templates/montage-html/default_html.css | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'js/document') diff --git a/js/document/templates/montage-html/default_html.css b/js/document/templates/montage-html/default_html.css index 68300edf..24a752bc 100755 --- a/js/document/templates/montage-html/default_html.css +++ b/js/document/templates/montage-html/default_html.css @@ -72,4 +72,9 @@ body .elem-red-outline { outline: red solid thin; +} + +.nj-preset-transition { + -webkit-transition: all 450ms linear !important; + background-color: red; } \ No newline at end of file -- cgit v1.2.3 From fdeed8051c3af538d28ca3bc599121cea483c22c Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 22 Mar 2012 15:47:56 -0700 Subject: Squashed commit of the following GL integration Signed-off-by: Valerio Virgillito --- js/document/html-document.js | 108 ++++++++++++++++++++++++++++++------------- 1 file changed, 76 insertions(+), 32 deletions(-) (limited to 'js/document') diff --git a/js/document/html-document.js b/js/document/html-document.js index be1f89e2..aa57d848 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -9,7 +9,8 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot var Montage = require("montage/core/core").Montage, TextDocument = require("js/document/text-document").TextDocument, NJUtils = require("js/lib/NJUtils").NJUtils, - GLWorld = require("js/lib/drawing/world").World; + GLWorld = require("js/lib/drawing/world").World, + MaterialsModel = require("js/models/materials-model").MaterialsModel; //////////////////////////////////////////////////////////////////////// // exports.HTMLDocument = Montage.create(TextDocument, { @@ -193,12 +194,9 @@ exports.HTMLDocument = Montage.create(TextDocument, { var elt = this.iframe.contentWindow.document.getElementById("UserContent"); // if (elt) { - this._glData = []; - //if (path) { - //this.collectGLData(elt, this._glData, path); - //} else { - this.collectGLData(elt, this._glData ); - //} + var matLib = MaterialsModel.exportMaterials(); + this._glData = [matLib]; + this.collectGLData(elt, this._glData ); } else { this._glData = null } @@ -219,29 +217,74 @@ exports.HTMLDocument = Montage.create(TextDocument, { */ // /* + // get the data for the next canvas var importStr = value[i]; - var startIndex = importStr.indexOf( "id: " ); - if (startIndex >= 0) { - var endIndex = importStr.indexOf( "\n", startIndex ); - if (endIndex > 0) { - var id = importStr.substring( startIndex+4, endIndex ); - if (id) { - var canvas = this.findCanvasWithID( id, elt ); - if (canvas) { - if (!canvas.elementModel) { - NJUtils.makeElementModel(canvas, "Canvas", "shape", true); - } - if (canvas.elementModel) { - if (canvas.elementModel.shapeModel.GLWorld) { - canvas.elementModel.shapeModel.GLWorld.clearTree(); - } - var index = importStr.indexOf( "webGL: " ); - var useWebGL = (index >= 0) - var world = new GLWorld( canvas, useWebGL ); - world.import( importStr ); - this.buildShapeModel( canvas.elementModel, world ); - } + + // determine if it is the new (JSON) or old style format + var id = null; + var jObj = null; + var index = importStr.indexOf( ';' ); + if ((importStr[0] === 'v') && (index < 24)) + { + // JSON format. pull off the + importStr = importStr.substr( index+1 ); + jObj = jObj = JSON.parse( importStr ); + id = jObj.id; + } + else + { + // at this point the data could be either the materials library or + // an old style world. We can determine which by converting the string + // to an object via JSON.parse. That operation will fail if the string + // is an old style world. + var matLibStr = 'materialLibrary;'; + index = importStr.indexOf( matLibStr ); + if (index == 0) + { + importStr = importStr.substr( matLibStr.length ); + var matLibObj = JSON.parse( importStr ); + MaterialsModel.importMaterials( matLibObj ); + } + else + { + var startIndex = importStr.indexOf( "id: " ); + if (startIndex >= 0) { + var endIndex = importStr.indexOf( "\n", startIndex ); + if (endIndex > 0) + id = importStr.substring( startIndex+4, endIndex ); + } + } + } + + if (id != null) + { + var canvas = this.findCanvasWithID( id, elt ); + if (canvas) + { + if (!canvas.elementModel) + { + NJUtils.makeElementModel(canvas, "Canvas", "shape", true); + } + if (canvas.elementModel) + { + if (canvas.elementModel.shapeModel.GLWorld) + canvas.elementModel.shapeModel.GLWorld.clearTree(); + + if (jObj) + { + var useWebGL = jObj.webGL; + var world = new GLWorld( canvas, useWebGL ); + world.importJSON( jObj ); + } + else + { + var index = importStr.indexOf( "webGL: " ); + var useWebGL = (index >= 0); + var world = new GLWorld( canvas, useWebGL ); + world.import( importStr ); } + + this.buildShapeModel( canvas.elementModel, world ); } } } @@ -265,7 +308,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { shapeModel.GLGeomObj = root; shapeModel.strokeSize = root._strokeWidth; shapeModel.stroke = root._strokeColor.slice(); - shapeModel.strokeMaterial = root._strokeMaterial.dup(); + shapeModel.strokeMaterial = root._strikeMaterial ? root._strokeMaterial.dup() : null; shapeModel.strokeStyle = "solid"; //shapeModel.strokeStyleIndex //shapeModel.border @@ -276,7 +319,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { elementModel.selection = "Rectangle"; elementModel.pi = "RectanglePi"; shapeModel.fill = root._fillColor.slice(); - shapeModel.fillMaterial = root._fillMaterial.dup(); + shapeModel.fillMaterial = root._fillMaterial ? root._fillMaterial.dup() : null; shapeModel.tlRadius = root._tlRadius; shapeModel.trRadius = root._trRadius; shapeModel.blRadius = root._blRadius; @@ -287,7 +330,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { elementModel.selection = "Oval"; elementModel.pi = "OvalPi"; shapeModel.fill = root._fillColor.slice(); - shapeModel.fillMaterial = root._fillMaterial.dup(); + shapeModel.fillMaterial = root._fillMaterial ? root._fillMaterial.dup() : null; shapeModel.innerRadius = root._innerRadius; break; @@ -382,7 +425,8 @@ exports.HTMLDocument = Montage.create(TextDocument, { { if (elt.elementModel && elt.elementModel.shapeModel && elt.elementModel.shapeModel.GLWorld) { - var data = elt.elementModel.shapeModel.GLWorld.export(); + var data = elt.elementModel.shapeModel.GLWorld.exportJSON(); + //var data = elt.elementModel.shapeModel.GLWorld.export(); dataArray.push( data ); } -- cgit v1.2.3 From 7fbda862c62f37d4c67e4d5a619b7e3cffc309ff Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Thu, 22 Mar 2012 16:23:40 -0700 Subject: Adding Ninja URL method to io-mediator --- js/document/html-document.js | 65 ++++---------------------------------------- 1 file changed, 5 insertions(+), 60 deletions(-) (limited to 'js/document') diff --git a/js/document/html-document.js b/js/document/html-document.js index be1f89e2..9de2d8d6 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -520,67 +520,13 @@ exports.HTMLDocument = Montage.create(TextDocument, { } // if(!this.documentRoot.Ninja) this.documentRoot.Ninja = {}; - //Inserting user's document into template - - - - - - - - - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - //TODO: Clean up and make public method to prepend properties with Ninja URL - this._templateDocument.head.innerHTML = (this._userDocument.content.head.replace(/\b(href|src)\s*=\s*"([^"]*)"/g, ninjaUrlRedirect.bind(this))).replace(/url\(([^"]*)(.+?)\1\)/g, ninjaUrlRedirect.bind(this)); - this._templateDocument.body.innerHTML = (this._userDocument.content.body.replace(/\b(href|src)\s*=\s*"([^"]*)"/g, ninjaUrlRedirect.bind(this))).replace(/url\(([^"]*)(.+?)\1\)/g, ninjaUrlRedirect.bind(this)); - // - //var docRootUrl = this.application.ninja.coreIoApi.rootUrl+escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]).replace(/\/\//gi, '/')); - // - function ninjaUrlRedirect (prop) { - //Checking for property value to not contain a full direct URL - if (!prop.match(/(\b(?:(?:https?|ftp|file|[A-Za-z]+):\/\/|www\.|ftp\.)(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[-A-Z0-9+&@#\/%=~_|$?!:,.])*(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[A-Z0-9+&@#\/%=~_|$]))/gi)) { - //Checking for attributes and type of source - if (prop.indexOf('href') !== -1 || prop.indexOf('src') !== -1) { //From HTML attribute - // - prop = prop.replace(/"([^"]*)"/gi, ninjaUrlPrepend.bind(this)); - } else if (prop.indexOf('url') !== -1) { //From CSS property - //TODO: Add functionality - var docRootUrl = this.application.ninja.coreIoApi.rootUrl+escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]).replace(/\/\//gi, '/')); - prop = prop.replace(/[^()\\""\\'']+/g, cssUrlToNinjaUrl); - function cssUrlToNinjaUrl (s) { - if (s !== 'url') { - s = docRootUrl + s; - } - return s; - } - } - } - return prop; - } - // - function ninjaUrlPrepend (url) { - var docRootUrl = this.application.ninja.coreIoApi.rootUrl+escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]).replace(/\/\//gi, '/')); - if (url.indexOf('data:image') !== -1) { - return url; - } else { - return '"'+docRootUrl+url.replace(/\"/gi, '')+'"'; - } - } - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - - - - + //TODO: Clean up, using for prototyping + this._templateDocument.head.innerHTML = (this._userDocument.content.head.replace(/\b(href|src)\s*=\s*"([^"]*)"/g, this.application.ninja.ioMediator.getNinjaPropUrlRedirect.bind(this.application.ninja.ioMediator))).replace(/url\(([^"]*)(.+?)\1\)/g, this.application.ninja.ioMediator.getNinjaPropUrlRedirect.bind(this.application.ninja.ioMediator)); + this._templateDocument.body.innerHTML = (this._userDocument.content.body.replace(/\b(href|src)\s*=\s*"([^"]*)"/g, this.application.ninja.ioMediator.getNinjaPropUrlRedirect.bind(this.application.ninja.ioMediator))).replace(/url\(([^"]*)(.+?)\1\)/g, this.application.ninja.ioMediator.getNinjaPropUrlRedirect.bind(this.application.ninja.ioMediator)); + var scripttags = this._templateDocument.html.getElementsByTagName('script'), webgldata; //TODO: Use querySelectorAll @@ -603,7 +549,6 @@ exports.HTMLDocument = Montage.create(TextDocument, { - //Temporarily checking for disabled special case var stags = this.iframe.contentWindow.document.getElementsByTagName('style'), ltags = this.iframe.contentWindow.document.getElementsByTagName('link'); @@ -628,7 +573,6 @@ exports.HTMLDocument = Montage.create(TextDocument, { - //Adding a handler for the main user document reel to finish loading this._document.body.addEventListener("userTemplateDidLoad", this.userTemplateDidLoad.bind(this), false); @@ -687,6 +631,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { // fileCouldDirUrl = this._document.styleSheets[i].href.split(this._document.styleSheets[i].href.split('/')[this._document.styleSheets[i].href.split('/').length-1])[0]; + //TODO: Make public version of this.application.ninja.ioMediator.getNinjaPropUrlRedirect with dynamic ROOT tag.innerHTML = cssData.content.replace(/url\(()(.+?)\1\)/g, detectUrl); function detectUrl (prop) { -- cgit v1.2.3 From 7e61ce5aba0c8465595804da21e365baf4d8c15d Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Fri, 23 Mar 2012 13:22:42 -0700 Subject: Removing m-js components I/O and fix for webGL Removed saving m-js components as new components broke I/O when present. Also made a fix for checking length of webGL array since first item now is non-user data. (That is to be removed) --- js/document/html-document.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'js/document') diff --git a/js/document/html-document.js b/js/do