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/text-document.js | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) mode change 100644 => 100755 js/io/document/text-document.js (limited to 'js/io/document/text-document.js') diff --git a/js/io/document/text-document.js b/js/io/document/text-document.js old mode 100644 new mode 100755 index 3506891a..599d311c --- a/js/io/document/text-document.js +++ b/js/io/document/text-document.js @@ -17,16 +17,8 @@ var TextDocument = exports.TextDocument = Montage.create(baseDocumentModule.Base } }, - _textArea: { value: null, enumerable: false }, - - // Temporary Save the source _source: { value: null, enumerable: false}, - textArea: { - get: function() { return this._textArea;}, - set: function(value) { this._textArea = value; } - }, - source: { get: function() { return this._source;}, set: function(value) { this._source = value;} @@ -53,10 +45,11 @@ var TextDocument = exports.TextDocument = Montage.create(baseDocumentModule.Base // PUBLIC METHODS initialize: { value: function(doc, uuid, textArea, callback) { - this.init(doc.name, doc.uri, doc.type, textArea, uuid, callback); - this.textArea = textArea.firstChild; + this.init(doc.name, doc.uri, doc.type, textArea, uuid); + this.currentView = "code"; - this._loadContent(); + this.textArea = textArea; +// this._loadContent(); } }, -- cgit v1.2.3 From 8504b61aefb25fdab931f02c4568916d2bf8345c Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Thu, 2 Feb 2012 00:52:44 -0800 Subject: changes to open multiple code view tabs and switch between the code views, added nj-skinned css class for the buttons in file picker, new file dialog and save as dialog Signed-off-by: Ananya Sen --- js/io/document/text-document.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/io/document/text-document.js') diff --git a/js/io/document/text-document.js b/js/io/document/text-document.js index 599d311c..a9081cb5 100755 --- a/js/io/document/text-document.js +++ b/js/io/document/text-document.js @@ -45,10 +45,10 @@ var TextDocument = exports.TextDocument = Montage.create(baseDocumentModule.Base // PUBLIC METHODS initialize: { value: function(doc, uuid, textArea, callback) { - this.init(doc.name, doc.uri, doc.type, textArea, uuid); - + this.init(doc.name, doc.uri, doc.type, textArea, uuid, null, doc.externalUri); this.currentView = "code"; this.textArea = textArea; + // this._loadContent(); } }, -- 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/text-document.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'js/io/document/text-document.js') diff --git a/js/io/document/text-document.js b/js/io/document/text-document.js index a9081cb5..156aaacb 100755 --- a/js/io/document/text-document.js +++ b/js/io/document/text-document.js @@ -17,6 +17,8 @@ var TextDocument = exports.TextDocument = Montage.create(baseDocumentModule.Base } }, + _textArea: {value: null, enumerable: false }, + _source: { value: null, enumerable: false}, source: { @@ -31,6 +33,10 @@ var TextDocument = exports.TextDocument = Montage.create(baseDocumentModule.Base // GETTERS / SETTERS + textArea: { + get: function() { return this._textArea; }, + set: function(value) { this._textArea = value; } + }, editor: { get: function() { return this._codeEditor.editor; }, set: function(value) { this._codeEditor.editor = value} @@ -44,8 +50,8 @@ var TextDocument = exports.TextDocument = Montage.create(baseDocumentModule.Base // PUBLIC METHODS initialize: { - value: function(doc, uuid, textArea, callback) { - this.init(doc.name, doc.uri, doc.type, textArea, uuid, null, doc.externalUri); + value: function(doc, uuid, textArea, container, callback) { + this.init(doc.name, doc.uri, doc.type, container, uuid); this.currentView = "code"; this.textArea = textArea; -- 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/text-document.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'js/io/document/text-document.js') diff --git a/js/io/document/text-document.js b/js/io/document/text-document.js index 156aaacb..a768779f 100755 --- a/js/io/document/text-document.js +++ b/js/io/document/text-document.js @@ -85,6 +85,22 @@ var TextDocument = exports.TextDocument = Montage.create(baseDocumentModule.Base xhr.send(''); } + }, + + /** + * public method + * parameter: + * removeCodeMirrorDivFlag - for code view, tell to remove the codemirror div after saving + */ + save:{ + value:function(removeCodeMirrorDivFlag){ + this.editor.save(); + if(removeCodeMirrorDivFlag === true){ + var codemirrorDiv = this.textArea.parentNode.querySelector(".CodeMirror"); + if(!!codemirrorDiv){codemirrorDiv.parentNode.removeChild(codemirrorDiv);} + } + //persist to filesystem + } } }); \ No newline at end of file -- 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/text-document.js | 1 + 1 file changed, 1 insertion(+) (limited to 'js/io/document/text-document.js') diff --git a/js/io/document/text-document.js b/js/io/document/text-document.js index a768779f..683c513c 100755 --- a/js/io/document/text-document.js +++ b/js/io/document/text-document.js @@ -95,6 +95,7 @@ var TextDocument = exports.TextDocument = Montage.create(baseDocumentModule.Base save:{ value:function(removeCodeMirrorDivFlag){ this.editor.save(); + this.dirtyFlag=false; if(removeCodeMirrorDivFlag === true){ var codemirrorDiv = this.textArea.parentNode.querySelector(".CodeMirror"); if(!!codemirrorDiv){codemirrorDiv.parentNode.removeChild(codemirrorDiv);} -- cgit v1.2.3 From 729bc48212d7244539c99ca206be673eed011115 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Mon, 6 Feb 2012 16:07:46 -0800 Subject: integrated save for the document tabs, detect codemirror history to show document dirty indicator. Signed-off-by: Ananya Sen --- js/io/document/text-document.js | 1 + 1 file changed, 1 insertion(+) (limited to 'js/io/document/text-document.js') diff --git a/js/io/document/text-document.js b/js/io/document/text-document.js index 683c513c..7db8e91a 100755 --- a/js/io/document/text-document.js +++ b/js/io/document/text-document.js @@ -100,6 +100,7 @@ var TextDocument = exports.TextDocument = Montage.create(baseDocumentModule.Base var codemirrorDiv = this.textArea.parentNode.querySelector(".CodeMirror"); if(!!codemirrorDiv){codemirrorDiv.parentNode.removeChild(codemirrorDiv);} } + //console.log("$$$saved : "+this.uri+" : "+this.textArea.value); //persist to filesystem } } -- 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/text-document.js | 47 +++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 16 deletions(-) (limited to 'js/io/document/text-document.js') diff --git a/js/io/document/text-document.js b/js/io/document/text-document.js index 7db8e91a..81162eba 100755 --- a/js/io/document/text-document.js +++ b/js/io/document/text-document.js @@ -13,10 +13,13 @@ var TextDocument = exports.TextDocument = Montage.create(baseDocumentModule.Base _codeEditor: { value: { "editor": { value: null, enumerable: false }, - "hline": { value: null, enumerable: false } + } }, + _editor: { value: null, enumerable: false }, + _hline: { value: null, enumerable: false }, + _textArea: {value: null, enumerable: false }, _source: { value: null, enumerable: false}, @@ -28,23 +31,37 @@ var TextDocument = exports.TextDocument = Montage.create(baseDocumentModule.Base // PUBLIC MEMBERS + _savedLeftScroll: {value:null}, + _savedTopScroll: {value:null}, + //****************************************// //PUBLIC API // GETTERS / SETTERS + + savedLeftScroll:{ + get: function() { return this._savedLeftScroll; }, + set: function(value) { this._savedLeftScroll = value} + }, + + savedTopScroll:{ + get: function() { return this._savedTopScroll; }, + set: function(value) { this._savedTopScroll = value} + }, + textArea: { get: function() { return this._textArea; }, set: function(value) { this._textArea = value; } }, editor: { - get: function() { return this._codeEditor.editor; }, - set: function(value) { this._codeEditor.editor = value} + get: function() { return this._editor; }, + set: function(value) { this._editor = value} }, hline: { - get: function() { return this._codeEditor.hline; }, - set: function(value) {this._codeEditor.hline = value; } + get: function() { return this._hline; }, + set: function(value) {this._hline = value; } }, @@ -56,6 +73,7 @@ var TextDocument = exports.TextDocument = Montage.create(baseDocumentModule.Base this.textArea = textArea; // this._loadContent(); + } }, @@ -89,20 +107,17 @@ var TextDocument = exports.TextDocument = Montage.create(baseDocumentModule.Base /** * public method - * parameter: - * removeCodeMirrorDivFlag - for code view, tell to remove the codemirror div after saving */ save:{ - value:function(removeCodeMirrorDivFlag){ - this.editor.save(); - this.dirtyFlag=false; - if(removeCodeMirrorDivFlag === true){ - var codemirrorDiv = this.textArea.parentNode.querySelector(".CodeMirror"); - if(!!codemirrorDiv){codemirrorDiv.parentNode.removeChild(codemirrorDiv);} + value:function(){ + try{ + this.editor.save(); + //persist textArea.value to filesystem + this.dirtyFlag=false; + }catch(e){ + console.log("Error while saving "+this.uri); + console.log(e.stack); } - //console.log("$$$saved : "+this.uri+" : "+this.textArea.value); - //persist to filesystem } } - }); \ No newline at end of file -- cgit v1.2.3 From 018a6132d93a73d28bd349122404c236e61cb765 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Mon, 13 Feb 2012 15:03:23 -0800 Subject: Save 'code' view files Added functionality (temp) to save files in code view. --- js/io/document/text-document.js | 65 +++++++++++++++++++++++++++++++---------- 1 file changed, 49 insertions(+), 16 deletions(-) (limited to 'js/io/document/text-document.js') diff --git a/js/io/document/text-document.js b/js/io/document/text-document.js index 81162eba..e149c479 100755 --- a/js/io/document/text-document.js +++ b/js/io/document/text-document.js @@ -4,11 +4,13 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. */ -var Montage = require("montage/core/core").Montage; -var baseDocumentModule = require("js/io/document/base-document"); - - -var TextDocument = exports.TextDocument = Montage.create(baseDocumentModule.BaseDocument, { +//////////////////////////////////////////////////////////////////////// +// +var Montage = require("montage/core/core").Montage, + BaseDocument = require("js/io/document/base-document").BaseDocument; +//////////////////////////////////////////////////////////////////////// +// +var TextDocument = exports.TextDocument = Montage.create(BaseDocument, { // PRIVATE MEMBERS _codeEditor: { value: { @@ -21,7 +23,9 @@ var TextDocument = exports.TextDocument = Montage.create(baseDocumentModule.Base _hline: { value: null, enumerable: false }, _textArea: {value: null, enumerable: false }, - + + _userDocument: {value: null, enumerable: false }, + _source: { value: null, enumerable: false}, source: { @@ -65,19 +69,43 @@ var TextDocument = exports.TextDocument = Montage.create(baseDocumentModule.Base }, - // PUBLIC METHODS + //////////////////////////////////////////////////////////////////// + // initialize: { - value: function(doc, uuid, textArea, container, callback) { - this.init(doc.name, doc.uri, doc.type, container, uuid); - this.currentView = "code"; - this.textArea = textArea; - -// this._loadContent(); - + value: function(file, uuid, textArea, container, callback) { + // + this._userDocument = file; + // + this.init(file.name, file.uri, file.extension, container, uuid, callback); + // + this.currentView = "code"; + this.textArea = textArea; } }, + //////////////////////////////////////////////////////////////////// + // + save: { + enumerable: false, + value: function () { + //TODO: Improve sequence + this.editor.save(); + return {mode: this._userDocument.extension, document: this._userDocument, content: this.textArea.value}; + } + } + //////////////////////////////////////////////////////////////////// + + + + + + + + + + - // PRIVATE METHODS + /* +// PRIVATE METHODS _loadContent: { value: function() { // Start and AJAX call to load the HTML Document as a String @@ -104,11 +132,15 @@ var TextDocument = exports.TextDocument = Montage.create(baseDocumentModule.Base xhr.send(''); } }, +*/ + //////////////////////////////////////////////////////////////////// + /** * public method */ - save:{ + /* +save:{ value:function(){ try{ this.editor.save(); @@ -120,4 +152,5 @@ var TextDocument = exports.TextDocument = Montage.create(baseDocumentModule.Base } } } +*/ }); \ No newline at end of file -- cgit v1.2.3 From 5b6c62b7164cbde2845a3f7af810568e5ba53a6a Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Mon, 13 Feb 2012 22:39:28 -0800 Subject: File IO UI tweaks Making minor tweaks to the UI for file IO, will need to make much more at a later time. --- js/io/document/text-document.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/io/document/text-document.js') diff --git a/js/io/document/text-document.js b/js/io/document/text-document.js index e149c479..87fcc551 100755 --- a/js/io/document/text-document.js +++ b/js/io/document/text-document.js @@ -10,7 +10,7 @@ var Montage = require("montage/core/core").Montage, BaseDocument = require("js/io/document/base-document").BaseDocument; //////////////////////////////////////////////////////////////////////// // -var TextDocument = exports.TextDocument = Montage.create(BaseDocument, { +exports.TextDocument = Montage.create(BaseDocument, { // PRIVATE MEMBERS _codeEditor: { value: { -- cgit v1.2.3