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/io-mediator.js') 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/io-mediator.js') 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