aboutsummaryrefslogtreecommitdiff
path: root/js/io/document/document-controller.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/io/document/document-controller.js')
-rwxr-xr-xjs/io/document/document-controller.js31
1 files changed, 27 insertions, 4 deletions
diff --git a/js/io/document/document-controller.js b/js/io/document/document-controller.js
index d7a19e35..7cc0eeeb 100755
--- a/js/io/document/document-controller.js
+++ b/js/io/document/document-controller.js
@@ -15,7 +15,6 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
15var Montage = require("montage/core/core").Montage, 15var Montage = require("montage/core/core").Montage,
16 Component = require("montage/ui/component").Component, 16 Component = require("montage/ui/component").Component,
17 Uuid = require("montage/core/uuid").Uuid, 17 Uuid = require("montage/core/uuid").Uuid,
18 //nj= ("js/lib/NJUtils.js").NJUtils,
19 HTMLDocument = require("js/io/document/html-document").HTMLDocument, 18 HTMLDocument = require("js/io/document/html-document").HTMLDocument,
20 TextDocument = require("js/io/document/text-document").TextDocument; 19 TextDocument = require("js/io/document/text-document").TextDocument;
21 20
@@ -71,8 +70,8 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
71 deserializedFromTemplate: { 70 deserializedFromTemplate: {
72 value: function() { 71 value: function() {
73 this.eventManager.addEventListener("appLoaded", this, false); 72 this.eventManager.addEventListener("appLoaded", this, false);
74
75 this.eventManager.addEventListener("executeFileOpen", this, false); 73 this.eventManager.addEventListener("executeFileOpen", this, false);
74 this.eventManager.addEventListener("executeNewFile", this, false);
76 } 75 }
77 }, 76 },
78 77
@@ -93,6 +92,21 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
93 } 92 }
94 }, 93 },
95 94
95 handleExecuteNewFile: {
96 value: function(event) {
97 var newFileSettings = event._event.settings || {};
98 newFileSettings.callback = this.createNewFile;
99 newFileSettings.callbackScope = this;
100 this.application.ninja.newFileController.showNewFileDialog(newFileSettings);
101 }
102 },
103
104 createNewFile:{
105 value:function(newFileObj){
106 //console.log(newFileObj);
107 }
108 },
109
96 openFileWithURI: { 110 openFileWithURI: {
97 value: function(uriArrayObj) { 111 value: function(uriArrayObj) {
98 var uri = "", fileContent = "", response=null, filename="", fileType="js"; 112 var uri = "", fileContent = "", response=null, filename="", fileType="js";
@@ -108,7 +122,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
108 } 122 }
109 123
110 //console.log("$$$ "+uri+"\n content = \n\n\n"+ fileContent+"\n\n\n"); 124 //console.log("$$$ "+uri+"\n content = \n\n\n"+ fileContent+"\n\n\n");
111 filename = nj.getFileNameFromPath(uri); 125 filename = this.getFileNameFromPath(uri);
112 if(uri.indexOf('.') != -1){ 126 if(uri.indexOf('.') != -1){
113 fileType = uri.substr(uri.lastIndexOf('.') + 1); 127 fileType = uri.substr(uri.lastIndexOf('.') + 1);
114 } 128 }
@@ -415,5 +429,14 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
415 value: function() { 429 value: function() {
416 return "userDocument_" + (this._iframeCounter++); 430 return "userDocument_" + (this._iframeCounter++);
417 } 431 }
418 } 432 },
433
434 ///// Return the last part of a path (e.g. filename)
435 getFileNameFromPath : {
436 value: function(path) {
437 path = path.replace(/[/\\]$/g,"");
438 path = path.replace(/\\/g,"/");
439 return path.substr(path.lastIndexOf('/') + 1);
440 }
441 }
419}); \ No newline at end of file 442}); \ No newline at end of file