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/mediators/drag-drop-mediator.js | 0 js/mediators/element-mediator.js | 0 js/mediators/keyboard-mediator.js | 0 js/mediators/mouse-mediator.js | 0 4 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 js/mediators/drag-drop-mediator.js mode change 100644 => 100755 js/mediators/element-mediator.js mode change 100644 => 100755 js/mediators/keyboard-mediator.js mode change 100644 => 100755 js/mediators/mouse-mediator.js (limited to 'js/mediators') diff --git a/js/mediators/drag-drop-mediator.js b/js/mediators/drag-drop-mediator.js old mode 100644 new mode 100755 diff --git a/js/mediators/element-mediator.js b/js/mediators/element-mediator.js old mode 100644 new mode 100755 diff --git a/js/mediators/keyboard-mediator.js b/js/mediators/keyboard-mediator.js old mode 100644 new mode 100755 diff --git a/js/mediators/mouse-mediator.js b/js/mediators/mouse-mediator.js old mode 100644 new mode 100755 -- cgit v1.2.3 From 33e655cbbb0816340c5a2e5d5cc0a6b0c7d9f53c Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Wed, 1 Feb 2012 23:31:36 -0800 Subject: File IO clean up and setting up Cleaned up file IO templates and removed app-caching from Ninja since it would be needed. Setting up io-mediator to hook up to controller. Still need to address naming conventions and clean up more in the io directory. --- js/mediators/io-mediator.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 js/mediators/io-mediator.js (limited to 'js/mediators') diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js new file mode 100644 index 00000000..b392a065 --- /dev/null +++ b/js/mediators/io-mediator.js @@ -0,0 +1,27 @@ +/* +This file contains proprietary software owned by Motorola Mobility, Inc.
+No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
+(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. +
*/ + +//////////////////////////////////////////////////////////////////////// +// +var Montage = require("montage/core/core").Montage, + FileIo = require("js/io/system/fileio").FileIo, + ProjectIo = require("js/io/system/projectio").ProjectIo; +//////////////////////////////////////////////////////////////////////// +// +exports.IoMediator = Montage.create(Object.prototype, { + //////////////////////////////////////////////////////////////////// + // + name: { + enumerable: false, + value: function () { + // + } + } + //////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////// +}); +//////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////// \ No newline at end of file -- cgit v1.2.3 From 4d8306b638c53899403a4f0328c02bf1ab893e8f Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Thu, 2 Feb 2012 17:52:13 -0800 Subject: Setting up mediator for UI in FileIO --- js/mediators/io-mediator.js | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'js/mediators') diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index b392a065..f778c849 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js @@ -14,9 +14,34 @@ var Montage = require("montage/core/core").Montage, exports.IoMediator = Montage.create(Object.prototype, { //////////////////////////////////////////////////////////////////// // - name: { + fileNew: { enumerable: false, - value: function () { + value: function (file, template, callback) { + // + + } + }, + //////////////////////////////////////////////////////////////////// + // + fileOpen: { + enumerable: false, + value: function (file, callback) { + // + } + }, + //////////////////////////////////////////////////////////////////// + // + fileSave: { + enumerable: false, + value: function (file, callback) { + // + } + }, + //////////////////////////////////////////////////////////////////// + // + fileSaveAs: { + enumerable: false, + value: function (file, copy, callback) { // } } -- cgit v1.2.3 From 8e06b63e5eab5558823f4923e20a832c8b36cbe2 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Thu, 2 Feb 2012 23:55:33 -0800 Subject: Chrome FileSystem API Testing Doing benchmark testing of the native HTML5 FileSystem API available in Chrome. Need to run testing of local XHR requests and also getting files from packaged app. --- js/mediators/io-mediator.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'js/mediators') diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index f778c849..8d0a671e 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js @@ -6,9 +6,9 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot //////////////////////////////////////////////////////////////////////// // -var Montage = require("montage/core/core").Montage, - FileIo = require("js/io/system/fileio").FileIo, - ProjectIo = require("js/io/system/projectio").ProjectIo; +var Montage = require("montage/core/core").Montage, + FileIo = require("js/io/system/fileio").FileIo, + ProjectIo = require("js/io/system/projectio").ProjectIo; //////////////////////////////////////////////////////////////////////// // exports.IoMediator = Montage.create(Object.prototype, { -- 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/mediators/io-mediator.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'js/mediators') diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index 8d0a671e..3d75771f 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js @@ -11,14 +11,17 @@ var Montage = require("montage/core/core").Montage, ProjectIo = require("js/io/system/projectio").ProjectIo; //////////////////////////////////////////////////////////////////////// // -exports.IoMediator = Montage.create(Object.prototype, { +exports.IoMediator = Montage.create(require("montage/ui/component").Component, { //////////////////////////////////////////////////////////////////// // fileNew: { enumerable: false, - value: function (file, template, callback) { + value: function (file, template, callback, callbackScope) { // - + + + var returnObj = null; //like {"type": "js", "name": "filename", "source": "test file content", "uri": "/fs/fsd/"} + callback.call(callbackScope, returnObj); } }, //////////////////////////////////////////////////////////////////// -- 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/mediators/io-mediator.js | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) (limited to 'js/mediators') diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index 3d75771f..76f78a7d 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js @@ -16,12 +16,12 @@ exports.IoMediator = Montage.create(require("montage/ui/component").Component, { // fileNew: { enumerable: false, - value: function (file, template, callback, callbackScope) { + value: function (file, template, callback) { // var returnObj = null; //like {"type": "js", "name": "filename", "source": "test file content", "uri": "/fs/fsd/"} - callback.call(callbackScope, returnObj); + callback.operation.call(callback.thisScope, returnObj); } }, //////////////////////////////////////////////////////////////////// @@ -29,7 +29,23 @@ exports.IoMediator = Montage.create(require("montage/ui/component").Component, { fileOpen: { enumerable: false, value: function (file, callback) { - // + var response = "", fileContent="", filename="", fileType="js", returnObj=null; + + response = this.application.ninja.coreIoApi.openFile({"uri":file.uri}); + if((response.success === true) && ((response.status === 200) || (response.status === 304))){ + fileContent = response.content; + } + + + //TODO : format html content to render in design view + + + filename = this.getFileNameFromPath(file.uri); + if(file.uri.indexOf('.') != -1){ + fileType = file.uri.substr(file.uri.lastIndexOf('.') + 1); + } + returnObj = {"type": ""+fileType, "name": ""+filename, "source": fileContent, "uri": file.uri}; + callback.operation.call(callback.thisScope, returnObj); } }, //////////////////////////////////////////////////////////////////// @@ -47,8 +63,16 @@ exports.IoMediator = Montage.create(require("montage/ui/component").Component, { value: function (file, copy, callback) { // } - } + }, //////////////////////////////////////////////////////////////////// + ///// Return the last part of a path (e.g. filename) + getFileNameFromPath : { + value: function(path) { + path = path.replace(/[/\\]$/g,""); + path = path.replace(/\\/g,"/"); + return path.substr(path.lastIndexOf('/') + 1); + } + } //////////////////////////////////////////////////////////////////// }); //////////////////////////////////////////////////////////////////////// -- 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/mediators/io-mediator.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'js/mediators') diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index 76f78a7d..fbabd780 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js @@ -20,8 +20,8 @@ exports.IoMediator = Montage.create(require("montage/ui/component").Component, { // - var returnObj = null; //like {"type": "js", "name": "filename", "source": "test file content", "uri": "/fs/fsd/"} - callback.operation.call(callback.thisScope, returnObj); + var returnObj = null; //like {"uri": "/gfdg/gdf/dfg.js", "success": true,...} + callback(returnObj); } }, //////////////////////////////////////////////////////////////////// @@ -45,7 +45,7 @@ exports.IoMediator = Montage.create(require("montage/ui/component").Component, { fileType = file.uri.substr(file.uri.lastIndexOf('.') + 1); } returnObj = {"type": ""+fileType, "name": ""+filename, "source": fileContent, "uri": file.uri}; - callback.operation.call(callback.thisScope, returnObj); + callback(returnObj); } }, //////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From 04d375a02e44d1c11054ace16cd243ada8e6bd23 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Thu, 9 Feb 2012 00:05:25 -0800 Subject: Fixing URI for templates, need UI to use correct data --- js/mediators/io-mediator.js | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) (limited to 'js/mediators') diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index fbabd780..b6d0e598 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js @@ -7,21 +7,52 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot //////////////////////////////////////////////////////////////////////// // var Montage = require("montage/core/core").Montage, + Component = require("montage/ui/component").Component, FileIo = require("js/io/system/fileio").FileIo, ProjectIo = require("js/io/system/projectio").ProjectIo; //////////////////////////////////////////////////////////////////////// // -exports.IoMediator = Montage.create(require("montage/ui/component").Component, { +exports.IoMediator = Montage.create(Component, { + //////////////////////////////////////////////////////////////////// + // + deserializedFromTemplate: { + enumerable: false, + value: function () { + } + }, + //////////////////////////////////////////////////////////////////// + // + fio: { + enumerable: false, + value: FileIo + }, //////////////////////////////////////////////////////////////////// // fileNew: { enumerable: false, value: function (file, template, callback) { // + var xhr = new XMLHttpRequest(); + xhr.open("GET", template, false); + xhr.send(); + if (xhr.readyState === 4) { + // + console.log(this.fio.newFile({uri: file, contents: xhr.response})); + } else { + //Error + } + + + + + + - - var returnObj = null; //like {"uri": "/gfdg/gdf/dfg.js", "success": true,...} + //callback('win'); + /* +var returnObj = null; //like {"uri": "/gfdg/gdf/dfg.js", "success": true,...} callback(returnObj); +*/ } }, //////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From 9140a5bb6e7ecc24e6b4e540308042e10165e604 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Thu, 9 Feb 2012 11:07:10 -0800 Subject: New File Adding new file functionality, awaiting UI to implement correct file path for templates to hook into mediator. --- js/mediators/io-mediator.js | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) (limited to 'js/mediators') diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index b6d0e598..66fea8b3 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js @@ -14,10 +14,17 @@ var Montage = require("montage/core/core").Montage, // exports.IoMediator = Montage.create(Component, { //////////////////////////////////////////////////////////////////// + // + hasTemplate: { + enumerable: false, + value: false + }, + //////////////////////////////////////////////////////////////////// // deserializedFromTemplate: { enumerable: false, value: function () { + // } }, //////////////////////////////////////////////////////////////////// @@ -32,27 +39,30 @@ exports.IoMediator = Montage.create(Component, { enumerable: false, value: function (file, template, callback) { // - var xhr = new XMLHttpRequest(); + var xhr = new XMLHttpRequest(), result; xhr.open("GET", template, false); xhr.send(); if (xhr.readyState === 4) { // - console.log(this.fio.newFile({uri: file, contents: xhr.response})); + switch (this.fio.newFile({uri: file, contents: xhr.response})) { + case 201: + result = {status: 201, success: true, uri: file}; + break; + case 204: + result = {status: 204, success: false, uri: file}; + break; + case 400: + result = {status: 400, success: false, uri: file}; + break; + default: + result = {status: 500, success: false, uri: file}; + break; + } } else { - //Error + result = {status: 500, success: false, uri: file}; } - - - - - - - - //callback('win'); - /* -var returnObj = null; //like {"uri": "/gfdg/gdf/dfg.js", "success": true,...} - callback(returnObj); -*/ + // + if (callback) callback(result); } }, //////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From 74efc1238f51e9c0ffdeffe2a349f66011ef9f17 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Thu, 9 Feb 2012 15:02:16 -0800 Subject: File Open Adding file open functionality. --- js/mediators/io-mediator.js | 85 +++++++++++++++++++++++++++++---------------- 1 file changed, 56 insertions(+), 29 deletions(-) (limited to 'js/mediators') diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index 66fea8b3..f2f2f642 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js @@ -32,18 +32,24 @@ exports.IoMediator = Montage.create(Component, { fio: { enumerable: false, value: FileIo + }, + //////////////////////////////////////////////////////////////////// + // + pio: { + enumerable: false, + value: ProjectIo }, //////////////////////////////////////////////////////////////////// // fileNew: { enumerable: false, value: function (file, template, callback) { - // + //Loading template from template URL var xhr = new XMLHttpRequest(), result; xhr.open("GET", template, false); xhr.send(); if (xhr.readyState === 4) { - // + //Making call to create file, checking for return code switch (this.fio.newFile({uri: file, contents: xhr.response})) { case 201: result = {status: 201, success: true, uri: file}; @@ -61,8 +67,11 @@ exports.IoMediator = Montage.create(Component, { } else { result = {status: 500, success: false, uri: file}; } - // + //Sending result to callback if requested for handling if (callback) callback(result); + //Codes + // 204: File exists | 400: File exists + // 201: File succesfully created | 500: Unknown (Probably cloud API not running) } }, //////////////////////////////////////////////////////////////////// @@ -70,23 +79,50 @@ exports.IoMediator = Montage.create(Component, { fileOpen: { enumerable: false, value: function (file, callback) { - var response = "", fileContent="", filename="", fileType="js", returnObj=null; - - response = this.application.ninja.coreIoApi.openFile({"uri":file.uri}); - if((response.success === true) && ((response.status === 200) || (response.status === 304))){ - fileContent = response.content; - } - - - //TODO : format html content to render in design view - - - filename = this.getFileNameFromPath(file.uri); - if(file.uri.indexOf('.') != -1){ - fileType = file.uri.substr(file.uri.lastIndexOf('.') + 1); - } - returnObj = {"type": ""+fileType, "name": ""+filename, "source": fileContent, "uri": file.uri}; - callback(returnObj); + //Reading file (Ninja doesn't really open a file, all in browser memory) + var read = this.fio.readFile({uri: file}), result; + //Checking for status + switch(read.status) { + case 204: + //Creating and formatting result object for callbak + result = read.file.details; + //TODO: Add handling for converting HTML to Ninja format + result.content = read.file.content; + result.status = read.status; + // + if (callback) callback(result); + break; + case 404: + //File does not exists + if (callback) callback({status: read.status}); + break; + default: + //Unknown + if (callback) callback({status: 500}); + break; + } + /* + //////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////// + //Return Object Description + Object.status (Always presents for handling) + 204: File exists (Success) + 404: File does not exists (Failure) + 500: Unknown (Probably cloud API not running) + + (Below only present if succesfull 204) + + Object.content + Object.extension + Object.name + Object.uri + Object.creationDate + Object.modifiedDate + Object.readOnly + Object.size + //////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////// + */ } }, //////////////////////////////////////////////////////////////////// @@ -104,15 +140,6 @@ exports.IoMediator = Montage.create(Component, { value: function (file, copy, callback) { // } - }, - //////////////////////////////////////////////////////////////////// - ///// Return the last part of a path (e.g. filename) - getFileNameFromPath : { - value: function(path) { - path = path.replace(/[/\\]$/g,""); - path = path.replace(/\\/g,"/"); - return path.substr(path.lastIndexOf('/') + 1); - } } //////////////////////////////////////////////////////////////////// }); -- cgit v1.2.3 From e8f7453c2b70960c63f81b5ec81d8e642a609900 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Thu, 9 Feb 2012 21:38:02 -0800 Subject: New/Open HTML document parsing --- js/mediators/io-mediator.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'js/mediators') diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index f2f2f642..630b0aa2 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js @@ -87,7 +87,13 @@ exports.IoMediator = Montage.create(Component, { //Creating and formatting result object for callbak result = read.file.details; //TODO: Add handling for converting HTML to Ninja format - result.content = read.file.content; + if (result.extension !== 'html' && result.extension !== 'htm') { + result.content = read.file.content; + } else { + // + result.content = this.parseHtmlToNinjaTemplate(read.file.content); + } + result.status = read.status; // if (callback) callback(result); @@ -140,6 +146,20 @@ exports.IoMediator = Montage.create(Component, { value: function (file, copy, callback) { // } + }, + //////////////////////////////////////////////////////////////////// + // + parseHtmlToNinjaTemplate: { + enumerable: false, + value: function (html) { + var doc = window.document.implementation.createHTMLDocument(), template; + // + doc.getElementsByTagName('html')[0].innerHTML = html; + template = {head: doc.head, body: doc.body, document: doc}; + doc = null; + // + return template; + } } //////////////////////////////////////////////////////////////////// }); -- cgit v1.2.3 From fbe830fabe497d01f4f2eaddb867161a8187c101 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Thu, 9 Feb 2012 23:42:04 -0800 Subject: Adding download cloud app UI --- js/mediators/io-mediator.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'js/mediators') diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index 630b0aa2..2f286e5e 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js @@ -86,16 +86,17 @@ exports.IoMediator = Montage.create(Component, { case 204: //Creating and formatting result object for callbak result = read.file.details; - //TODO: Add handling for converting HTML to Ninja format + //Checking for type of content to returns if (result.extension !== 'html' && result.extension !== 'htm') { + //Simple string result.content = read.file.content; } else { - // + //Object to be used by Ninja Template result.content = this.parseHtmlToNinjaTemplate(read.file.content); } - + //Status of call result.status = read.status; - // + //Calling back with result if (callback) callback(result); break; case 404: @@ -143,7 +144,7 @@ exports.IoMediator = Montage.create(Component, { // fileSaveAs: { enumerable: false, - value: function (file, copy, callback) { + value: function (copyTo, copyFrom, callback) { // } }, @@ -152,13 +153,12 @@ exports.IoMediator = Montage.create(Component, { parseHtmlToNinjaTemplate: { enumerable: false, value: function (html) { + //Creating temp object to mimic HTML var doc = window.document.implementation.createHTMLDocument(), template; - // + //Setting content to temp doc.getElementsByTagName('html')[0].innerHTML = html; - template = {head: doc.head, body: doc.body, document: doc}; - doc = null; - // - return template; + //Creating return object + return {head: doc.head.innerHTML, body: doc.body.innerHTML, document: doc}; } } //////////////////////////////////////////////////////////////////// -- 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