From 3a754133dbc138390503341fd2e9beba3e43aa4b Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Fri, 27 Jan 2012 12:05:17 -0800 Subject: Merged old FileIO --- js/io/document/html-document.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 js/io/document/html-document.js (limited to 'js/io/document/html-document.js') diff --git a/js/io/document/html-document.js b/js/io/document/html-document.js old mode 100644 new mode 100755 -- cgit v1.2.3 From d26a13de2aca25c36cb35f85604de1ac2b9befbb Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Wed, 1 Feb 2012 14:37:30 -0800 Subject: Simple button native widget test. Added a controller, pi and panel code. Signed-off-by: Valerio Virgillito --- js/io/document/html-document.js | 47 ++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 19 deletions(-) (limited to 'js/io/document/html-document.js') diff --git a/js/io/document/html-document.js b/js/io/document/html-document.js index c44dfe75..a8e06c69 100644 --- a/js/io/document/html-document.js +++ b/js/io/document/html-document.js @@ -27,6 +27,7 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base _initialUserDocument: { value: null, enumerable: false }, _htmlSource: {value: "", enumerable: false}, _glData: {value: null, enumerable: false }, + _userComponents: { value: {}, enumarable: false}, _elementCounter: { value: 1, enumerable: false }, _snapping : { value: true, enumerable: false }, @@ -108,23 +109,11 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base } }, - _userComponentSet: { - value: {}, - writable: true, - enumerable:true + userComponents: { + get: function() { + return this._userComponents; + } }, - -// userComponentSet:{ -// enumerable: true, -// get: function() { -// return this._userComponentSet; -// }, -// set: function(value) { -// this._userComponentSet = value; -// this._drawUserComponentsOnOpen(); -// } -// }, -// // _drawUserComponentsOnOpen:{ // value:function(){ // for(var i in this._userComponentSet){ @@ -191,6 +180,29 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base set: function(value) { this._zoomFactor = value; } }, + /** + * Add a reference to a component instance to the userComponents hash using the + * element UUID + */ + setComponentInstance: { + value: function(instance, el) { + this.userComponents[el.uuid] = instance; + } + }, + + /** + * Returns the component instance obj from the element + */ + getComponentFromElement: { + value: function(el) { + if(el) { + if(el.uuid) return this.userComponents[el.uuid]; + } else { + return null; + } + } + }, + //****************************************// // PUBLIC METHODS initialize: { @@ -353,9 +365,6 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base this.callback(this); } }.bind(this), 50); - - // TODO - Not sure where this goes - this._userComponentSet = {}; } else { this._styles = this._document.styleSheets[this._document.styleSheets.length - 1]; this._stylesheets = this._document.styleSheets; // Entire stlyesheets array -- cgit v1.2.3 From 87e247e74040b5e80ff40003d233d5317881102a Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Thu, 2 Feb 2012 03:30:54 -0800 Subject: fixed code view container, and switching code view Signed-off-by: Ananya Sen --- js/io/document/html-document.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'js/io/document/html-document.js') diff --git a/js/io/document/html-document.js b/js/io/document/html-document.js index c44dfe75..fc7dd05b 100755 --- a/js/io/document/html-document.js +++ b/js/io/document/html-document.js @@ -36,6 +36,13 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base _zoomFactor: { value: 100, enumerable: false }, + _codeEditor: { + value: { + "editor": { value: null, enumerable: false }, + "hline": { value: null, enumerable: false } + } + }, + // PUBLIC MEMBERS cssLoadInterval: { value: null, enumerable: false }, @@ -44,6 +51,11 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base */ // GETTERS / SETTERS + editor: { + get: function() { return this._codeEditor.editor; }, + set: function(value) { this._codeEditor.editor = value} + }, + selectionExclude: { get: function() { return this._selectionExclude; }, set: function(value) { this._selectionExclude = value; } -- cgit v1.2.3 From 1daf146c849a0a8dbd2b61b14218c9a39bdee3a7 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Fri, 3 Feb 2012 17:22:48 -0800 Subject: added editor tab save while switching code view tabs, integrated new file dialog with io mediator to open the new file in a new tab Signed-off-by: Ananya Sen --- js/io/document/html-document.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'js/io/document/html-document.js') diff --git a/js/io/document/html-document.js b/js/io/document/html-document.js index fc7dd05b..24d4e7e4 100755 --- a/js/io/document/html-document.js +++ b/js/io/document/html-document.js @@ -43,9 +43,16 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base } }, + // PUBLIC MEMBERS cssLoadInterval: { value: null, enumerable: false }, + codeViewDocument:{ + writable: true, + enumerable: true, + value:null + }, + /* * PUBLIC API */ @@ -432,5 +439,26 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base */ } } + }, + + /** + * public method + * parameter: + * removeCodeMirrorDivFlag - for code view, tell to remove the codemirror div after saving + */ + save:{ + value:function(removeCodeMirrorDivFlag){ + if(this.currentView === "design"){ + //generate html and save + }else if((this.currentView === "code") && (this.codeViewDocument !== null)){ + if(removeCodeMirrorDivFlag === true){ + this.codeViewDocument.save(true); + }else{ + this.codeViewDocument.save(); + } + //persist to filesystem + } + + } } }); \ No newline at end of file -- cgit v1.2.3 From 45cfffd9261ab1aa714554c584f0d0d8fe627c91 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Fri, 3 Feb 2012 18:04:26 -0800 Subject: allow to open html file in design view, integrated file open with io mediator Signed-off-by: Ananya Sen --- js/io/document/html-document.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'js/io/document/html-document.js') diff --git a/js/io/document/html-document.js b/js/io/document/html-document.js index 24d4e7e4..da1bbe4a 100755 --- a/js/io/document/html-document.js +++ b/js/io/document/html-document.js @@ -216,8 +216,9 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base value: function(doc, uuid, iframe, callback) { // Shell mode is not used anymore //if(!window.IsInShellMode()) { - - this.init("index-cloud", this._cloudTemplateUri, doc.type, iframe, uuid, callback); + if(!doc.name){doc.name = "index-cloud"}; + if(!doc.uri){doc.uri = this._cloudTemplateUri}; + this.init(doc.name, doc.uri, doc.type, iframe, uuid, callback); /* } else { var tmpurl = doc.uri.split('\\'); -- cgit v1.2.3 From 272c5f74f4ce76fec9cbe360817bf23639307d3a Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Sun, 5 Feb 2012 19:20:37 -0800 Subject: changes to show document dirty indicator on editing code view, and to remove dirty indicator on save. Signed-off-by: Ananya Sen --- js/io/document/html-document.js | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'js/io/document/html-document.js') diff --git a/js/io/document/html-document.js b/js/io/document/html-document.js index da1bbe4a..8e1eb614 100755 --- a/js/io/document/html-document.js +++ b/js/io/document/html-document.js @@ -449,17 +449,22 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base */ save:{ value:function(removeCodeMirrorDivFlag){ - if(this.currentView === "design"){ - //generate html and save - }else if((this.currentView === "code") && (this.codeViewDocument !== null)){ - if(removeCodeMirrorDivFlag === true){ - this.codeViewDocument.save(true); - }else{ - this.codeViewDocument.save(); + try{ + if(this.currentView === "design"){ + //generate html and save + }else if((this.currentView === "code") && (this.codeViewDocument !== null)){ + if(removeCodeMirrorDivFlag === true){ + this.codeViewDocument.save(true); + }else{ + this.codeViewDocument.save(); + } + //persist to filesystem } - //persist to filesystem + this.dirtyFlag=false; + }catch(e){ + console.log("Error while saving "+this.uri); + console.log(e.stack); } - } } }); \ No newline at end of file -- cgit v1.2.3 From 36b2e540f06cef3887e7d0fea60527fee51e2a40 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Wed, 8 Feb 2012 15:36:53 -0800 Subject: fixed undo/redo for each code view document, changed new file integration with io mediator Signed-off-by: Ananya Sen --- js/io/document/html-document.js | 45 ++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 21 deletions(-) (limited to 'js/io/document/html-document.js') diff --git a/js/io/document/html-document.js b/js/io/document/html-document.js index 8e1eb614..d51cd279 100755 --- a/js/io/document/html-document.js +++ b/js/io/document/html-document.js @@ -36,18 +36,13 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base _zoomFactor: { value: 100, enumerable: false }, - _codeEditor: { - value: { - "editor": { value: null, enumerable: false }, - "hline": { value: null, enumerable: false } - } - }, - - // PUBLIC MEMBERS cssLoadInterval: { value: null, enumerable: false }, - codeViewDocument:{ + _savedLeftScroll: {value:null}, + _savedTopScroll: {value:null}, + + _codeViewDocument:{ writable: true, enumerable: true, value:null @@ -58,10 +53,21 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base */ // GETTERS / SETTERS - editor: { - get: function() { return this._codeEditor.editor; }, - set: function(value) { this._codeEditor.editor = value} - }, + + codeViewDocument:{ + get: function() { return this._codeViewDocument; }, + set: function(value) { this._codeViewDocument = value} + }, + + savedLeftScroll:{ + get: function() { return this._savedLeftScroll; }, + set: function(value) { this._savedLeftScroll = value} + }, + + savedTopScroll:{ + get: function() { return this._savedTopScroll; }, + set: function(value) { this._savedTopScroll = value} + }, selectionExclude: { get: function() { return this._selectionExclude; }, @@ -233,6 +239,7 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base this.currentView = "design"; this._loadDocument(this.uri); + } }, @@ -444,20 +451,15 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base /** * public method - * parameter: - * removeCodeMirrorDivFlag - for code view, tell to remove the codemirror div after saving + * */ save:{ - value:function(removeCodeMirrorDivFlag){ + value:function(){ try{ if(this.currentView === "design"){ //generate html and save }else if((this.currentView === "code") && (this.codeViewDocument !== null)){ - if(removeCodeMirrorDivFlag === true){ - this.codeViewDocument.save(true); - }else{ - this.codeViewDocument.save(); - } + this.codeViewDocument.editor.save(); //persist to filesystem } this.dirtyFlag=false; @@ -467,4 +469,5 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base } } } + }); \ No newline at end of file -- cgit v1.2.3 From 632a5daca17acb774b9344ccc0e9107f1643924c Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Fri, 10 Feb 2012 15:29:12 -0800 Subject: File Open Adding the functionality to open a basic file. --- js/io/document/html-document.js | 84 ++++++++++++++++++++++------------------- 1 file changed, 46 insertions(+), 38 deletions(-) (limited to 'js/io/document/html-document.js') diff --git a/js/io/document/html-document.js b/js/io/document/html-document.js index d51cd279..fbb34a1d 100755 --- a/js/io/document/html-document.js +++ b/js/io/document/html-document.js @@ -11,7 +11,7 @@ var Montage = require("montage/core/core").Montage, var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.BaseDocument, { // PRIVATE MEMBERS _selectionExclude: { value: null, enumerable: false }, - _cloudTemplateUri: { value: "user-document-templates/montage-application-cloud/index.html", enumerable: false}, + _htmlTemplateUrl: { value: "user-document-templates/montage-application-cloud/index.html", enumerable: false}, _iframe: { value: null, enumerable: false }, _server: { value: null, enumerable: false }, _selectionModel: { value: [], enumerable: false }, @@ -24,7 +24,7 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base _styles: { value: null, enumerable: false }, _stylesheets: { value: null, enumerable: false }, _stageStyleSheetId : { value: 'nj-stage-stylesheet', enumerable: false }, - _initialUserDocument: { value: null, enumerable: false }, + _userDocument: { value: null, enumerable: false }, _htmlSource: {value: "", enumerable: false}, _glData: {value: null, enumerable: false }, @@ -218,30 +218,27 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base //****************************************// // PUBLIC METHODS - initialize: { - value: function(doc, uuid, iframe, callback) { - // Shell mode is not used anymore - //if(!window.IsInShellMode()) { - if(!doc.name){doc.name = "index-cloud"}; - if(!doc.uri){doc.uri = this._cloudTemplateUri}; - this.init(doc.name, doc.uri, doc.type, iframe, uuid, callback); - /* - } else { - var tmpurl = doc.uri.split('\\'); - var fileUrl = doc.server.url + "/" + tmpurl[tmpurl.length -1] + "?fileio=true&template=/user-document-templates/montage-application/index.html"; - this.init(name, fileUrl, doc.type, iframe, uuid, callback); - this.server = doc.server; - this._initialUserDocument = doc; - } - */ - this.iframe = iframe; - this.selectionExclude = ["HTML", "BODY", "Viewport", "UserContent", "stageBG"]; - this.currentView = "design"; - - this._loadDocument(this.uri); - + + + //////////////////////////////////////////////////////////////////// + // + initialize: { + value: function(file, uuid, iframe, callback) { + // + this._userDocument = file; + // + this.init(file.name, file.uri, file.extension, iframe, uuid, callback); + // + this.iframe = iframe; + this.selectionExclude = ["HTML", "BODY", "Viewport", "UserContent", "stageBG"]; + this.currentView = "design"; + // + this.iframe.src = this._htmlTemplateUrl; + this.iframe.addEventListener("load", this, true); } }, + //////////////////////////////////////////////////////////////////// + collectGLData: { value: function( elt, dataArray ) @@ -345,7 +342,8 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base } }, - // Private + /* +// Private _loadDocument: { value: function(uri) { // Load the document into the Iframe @@ -353,23 +351,32 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base this.iframe.addEventListener("load", this, true); } }, - +*/ + + + + //////////////////////////////////////////////////////////////////// + // handleEvent: { value: function(event){ - this.documentRoot = this.iframe.contentWindow.document.getElementById("UserContent"); + // + this.documentRoot = this.iframe.contentWindow.document.getElementById("UserContent"); this.stageBG = this.iframe.contentWindow.document.getElementById("stageBG"); this.stageBG.onclick = null; this._document = this.iframe.contentWindow.document; this._window = this.iframe.contentWindow; - if(!this.documentRoot.Ninja) - { - this.documentRoot.Ninja = {}; - } - - if(this._initialUserDocument) { - // Now load the user content - this.documentRoot.innerHTML = this._initialUserDocument.body; - this.iframe.contentWindow.document.getElementById("userHead").innerHTML = this._initialUserDocument.head; + // + if(!this.documentRoot.Ninja) this.documentRoot.Ninja = {}; + // + + this.documentRoot.innerHTML = this._userDocument.content.body; + this.iframe.contentWindow.document.getElementById("userHead").innerHTML = this._userDocument.content.head; + + + + + + this.cssLoadInterval = setInterval(function() { if(this._document.styleSheets.length > 1) { @@ -383,7 +390,8 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base // TODO - Not sure where this goes this._userComponentSet = {}; - } else { + + this._styles = this._document.styleSheets[this._document.styleSheets.length - 1]; this._stylesheets = this._document.styleSheets; // Entire stlyesheets array @@ -429,7 +437,7 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base } this.callback(this); - } + } }, -- cgit v1.2.3 From b1fc4f84d92efeaa33ec239b662235c9e8218d0c Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Sun, 12 Feb 2012 16:50:33 -0800 Subject: File Save (HTML only) Added the ability to save an HTML file from design view, need to add CSS detection and saving (of styles in