From 792c83a0fe8f7f22d139684ed6d711a2c334c098 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Thu, 17 May 2012 16:55:19 -0700 Subject: Adding component initialization on open This is for opening components, selection is still not reflecting component data. --- js/document/views/design.js | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'js/document') diff --git a/js/document/views/design.js b/js/document/views/design.js index 2ccb82d1..bd8c25ec 100755 --- a/js/document/views/design.js +++ b/js/document/views/design.js @@ -184,8 +184,7 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { this._bodyFragment = null; //Calling standard method to finish opening document this.bodyContentLoaded(null); - - // TODO: Clean up this code + //TODO: Move this to be set via the controller this.application.ninja.stage.documentOffsetLeft = parseInt((this.document.body.scrollWidth - this._template.size.width)/2); this.application.ninja.stage.documentOffsetTop = parseInt((this.document.body.scrollHeight - this._template.size.height)/2); } @@ -243,17 +242,15 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { } } } - //Checking and initializing webGL + //Checking for script tags then parsing check for montage and webgl if (scripttags.length > 0) { + //Checking and initializing webGL this.initWebGl(scripttags); - } //Else there is not data to parse - - - - //TODO: Load Montage Components (blocking) - //this.initMontage(); - - + //Checking and initializing Montage + this.initMontage(scripttags); + } else { + //Else there is not data to parse + } //Makign callback if specified if (this._callback) this._callback(); } @@ -350,8 +347,14 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { //////////////////////////////////////////////////////////////////// // initMontage: { - value: function () { - //initWithDocument(window.document) instantiateWithOwnerAndDocument(null, window.document) + value: function (scripttags) { + // + this.iframe.contentWindow.document.body.addEventListener('mjsTemplateReady', function () { + //Initializing template with user's seriliazation + var template = this.iframe.contentWindow.mjsTemplate.create(); + template.initWithDocument(this.iframe.contentWindow.document); + template.instantiateWithOwnerAndDocument(null, this.iframe.contentWindow.document, function (e){/*Nothing just a required extra parameter*/}); + }.bind(this), false); } }, //////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From eff40602cac6821f8272177c24b6bf3de399f8b1 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 17 May 2012 21:11:33 -0700 Subject: multiple documents - enable opening multiple documents and initial switching Signed-off-by: Valerio Virgillito --- js/document/document-html.js | 2 -- 1 file changed, 2 deletions(-) (limited to 'js/document') diff --git a/js/document/document-html.js b/js/document/document-html.js index 56d9db02..c77ed7bc 100755 --- a/js/document/document-html.js +++ b/js/document/document-html.js @@ -119,8 +119,6 @@ exports.HtmlDocument = Montage.create(Component, { this._observer = null; //Making callback after view is loaded this.loaded.callback.call(this.loaded.context, this); - //Setting opacity to be viewable after load - this.model.views.design.iframe.style.opacity = 1; } }, //////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From 7a94696e19b14e15261df516e2ba75e693b1313d Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Fri, 18 May 2012 00:21:56 -0700 Subject: enabling basic document switching Signed-off-by: Valerio Virgillito --- js/document/document-html.js | 20 ++++++++++-- js/document/html-document.js | 78 +------------------------------------------- js/document/models/base.js | 2 +- 3 files changed, 20 insertions(+), 80 deletions(-) (limited to 'js/document') diff --git a/js/document/document-html.js b/js/document/document-html.js index c77ed7bc..0037c94d 100755 --- a/js/document/document-html.js +++ b/js/document/document-html.js @@ -134,7 +134,7 @@ exports.HtmlDocument = Montage.create(Component, { // serializeDocument: { value: function () { - // There are not needed for now ssince we cannot change them + // There are not needed for now since we cannot change them //this.gridHorizontalSpacing = this.application.ninja.stage.drawUtils.gridHorizontalSpacing; //this.gridVerticalSpacing = this.application.ninja.stage.drawUtils.gridVerticalSpacing; @@ -150,13 +150,29 @@ exports.HtmlDocument = Montage.create(Component, { // Pause the videos this.model.views.design.pauseVideos(); + + this.model.isActive = false; } }, //////////////////////////////////////////////////////////////////// // deserializeDocument: { value: function () { - //TODO: Import functionality + // There are not needed for now since we cannot change them + //this.application.ninja.stage.drawUtils.gridHorizontalSpacing = this.gridHorizontalSpacing; + //this.application.ninja.stage.drawUtils.gridVerticalSpacing = this.gridVerticalSpacing; + + // Deserialize the current scroll position + // TODO: Implement + + this.application.ninja.selectedElements = this.model.selection.slice(0); + + this.application.ninja.appModel.show3dGrid = this.draw3DGrid; + + // Serialize the undo + // TODO: Save the montage undo queue + + this.model.isActive = true; } } //////////////////////////////////////////////////////////////////// diff --git a/js/document/html-document.js b/js/document/html-document.js index 68c2a9fb..bcf2b5c2 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -454,55 +454,6 @@ exports.HTMLDocument = Montage.create(TextDocument, { } }, - /** - * Return the specified inline attribute from the element. - */ - GetElementAttribute: { - value: function(element, attribute) { - - var value; - - if(attribute === "src") { - return element[attribute].replace(window.location.href, ''); - } - - value = element[attribute]; - - if(value !== undefined) return value; -// if(value || value === false) return [value, "inline"]; - - // 3. - //value = this._document.defaultView.getComputedStyle(element,null).getPropertyValue(attribute); - //if(value) return value; - - return null; - } - }, - - GetElementStyle: { - value: function(element, style) { -// return this._queryStylesheets(element, style); - } - }, - - SetStyle: { - value: function(type, selector, style, value) { - try { - for(var j=0; j --- js/document/document-html.js | 11 +++++++++-- js/document/models/html.js | 17 +++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) (limited to 'js/document') diff --git a/js/document/document-html.js b/js/document/document-html.js index 0037c94d..983da966 100755 --- a/js/document/document-html.js +++ b/js/document/document-html.js @@ -139,7 +139,11 @@ exports.HtmlDocument = Montage.create(Component, { //this.gridVerticalSpacing = this.application.ninja.stage.drawUtils.gridVerticalSpacing; // Serialize the current scroll position - // TODO: Implement + this.model.scrollLeft = this.application.ninja.stage._scrollLeft; + this.model.scrollTop = this.application.ninja.stage._scrollTop; + this.model.userContentLeft = this.application.ninja.stage._userContentLeft; + this.model.userContentTop = this.application.ninja.stage._userContentTop; + // Serialize the selection this.model.selection = this.application.ninja.selectedElements.slice(0); @@ -163,7 +167,10 @@ exports.HtmlDocument = Montage.create(Component, { //this.application.ninja.stage.drawUtils.gridVerticalSpacing = this.gridVerticalSpacing; // Deserialize the current scroll position - // TODO: Implement + this.application.ninja.stage._scrollLeft = this.model.scrollLeft; + this.application.ninja.stage._scrollTop = this.model.scrollTop; + this.application.ninja.stage._userContentLeft = this.model.userContentLeft; + this.application.ninja.stage._userContentTop = this.model.userContentTop; this.application.ninja.selectedElements = this.model.selection.slice(0); diff --git a/js/document/models/html.js b/js/document/models/html.js index 67457863..a97b4b5a 100755 --- a/js/document/models/html.js +++ b/js/document/models/html.js @@ -27,6 +27,23 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, { draw3DGrid: { value: false }, + //////////////////////////////////////////////////////////////////// + // + scrollLeft: { + value: null + }, + + scrollTop: { + value: null + }, + + userContentLeft: { + value: null + }, + + userContentTop: { + value: null + }, //////////////////////////////////////////////////////////////////// // baseHref: { -- cgit v1.2.3 From d878aa470074d5698a316512b513949fa22073f2 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Fri, 18 May 2012 15:23:15 -0700 Subject: Fixing save logic Moved dirty marker clearing code to model. --- js/document/models/base.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'js/document') diff --git a/js/document/models/base.js b/js/document/models/base.js index df341b2f..c99e36c7 100755 --- a/js/document/models/base.js +++ b/js/document/models/base.js @@ -151,7 +151,7 @@ exports.BaseDocumentModel = Montage.create(Component, { head: this.views.design.iframe.contentWindow.document.head, body: this.views.design.iframe.contentWindow.document.body, mjsTemplateCreator: this.views.design.iframe.contentWindow.mjsTemplateCreator - }, callback.bind(this)); + }, this.handleSaved.bind({callback: callback, model: this})); } else { //TODO: Add logic to save code view data } @@ -180,7 +180,7 @@ exports.BaseDocumentModel = Montage.create(Component, { head: this.views.design.iframe.contentWindow.document.head, body: this.views.design.iframe.contentWindow.document.body, mjsTemplateCreator: this.views.design.iframe.contentWindow.mjsTemplateCreator - }, callback.bind(this)); + }, this.handleSaved.bind({callback: callback, model: this})); } else { //TODO: Add logic to save code view data } @@ -190,7 +190,7 @@ exports.BaseDocumentModel = Montage.create(Component, { //////////////////////////////////////////////////////////////////// // saveAs: { - value: function () { + value: function (callback) { // if (this.needsSave) { //Save current file on memory @@ -199,6 +199,18 @@ exports.BaseDocumentModel = Montage.create(Component, { } } }, + //////////////////////////////////////////////////////////////////// + // + handleSaved: { + value: function (result) { + // + if (result.status === 204) { + this.model.needsSave = false; + } + // + if (this.callback) this.callback(result); + } + }, //////////////////////////////////////////////////////////////////// // close: { -- cgit v1.2.3 From fdfba499f0b84360b96096fa866a981e96e8756c Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Fri, 18 May 2012 16:35:56 -0700 Subject: fixing the color chip for the document root Signed-off-by: Valerio Virgillito --- js/document/views/design.js | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'js/document') diff --git a/js/document/views/design.js b/js/document/views/design.js index 2ccb82d1..44f1a5e8 100755 --- a/js/document/views/design.js +++ b/js/document/views/design.js @@ -64,6 +64,11 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { }, //////////////////////////////////////////////////////////////////// // + propertiesPanel: { + value: null + }, + //////////////////////////////////////////////////////////////////// + // initialize: { value: function (parent) { //Creating iFrame for view -- cgit v1.2.3