diff options
3 files changed, 51 insertions, 11 deletions
diff --git a/js/io/document/document-controller.js b/js/io/document/document-controller.js index dd62b40b..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 | |||
15 | var Montage = require("montage/core/core").Montage, | 15 | var 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= require("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 | ||
@@ -123,7 +122,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
123 | } | 122 | } |
124 | 123 | ||
125 | //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"); |
126 | filename = nj.getFileNameFromPath(uri); | 125 | filename = this.getFileNameFromPath(uri); |
127 | if(uri.indexOf('.') != -1){ | 126 | if(uri.indexOf('.') != -1){ |
128 | fileType = uri.substr(uri.lastIndexOf('.') + 1); | 127 | fileType = uri.substr(uri.lastIndexOf('.') + 1); |
129 | } | 128 | } |
@@ -430,5 +429,14 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
430 | value: function() { | 429 | value: function() { |
431 | return "userDocument_" + (this._iframeCounter++); | 430 | return "userDocument_" + (this._iframeCounter++); |
432 | } | 431 | } |
433 | } | 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 | } | ||
434 | }); \ No newline at end of file | 442 | }); \ No newline at end of file |
diff --git a/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js b/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js index 467c5452..f17b15d5 100644 --- a/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js +++ b/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js | |||
@@ -8,8 +8,7 @@ var Montage = require("montage/core/core").Montage, | |||
8 | Component = require("montage/ui/component").Component, | 8 | Component = require("montage/ui/component").Component, |
9 | iconsListModule = require("js/components/ui/icon-list-basic/iconsList.reel"), | 9 | iconsListModule = require("js/components/ui/icon-list-basic/iconsList.reel"), |
10 | treeModule = require("js/components/ui/tree-basic/tree.reel"), | 10 | treeModule = require("js/components/ui/tree-basic/tree.reel"), |
11 | newFileLocationSelectionModule = require("js/io/ui/new-file-dialog/new-file-workflow-controller"), | 11 | newFileLocationSelectionModule = require("js/io/ui/new-file-dialog/new-file-workflow-controller"); |
12 | nj= require("js/lib/NJUtils.js").NJUtils; | ||
13 | 12 | ||
14 | var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(Component, { | 13 | var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(Component, { |
15 | 14 | ||
@@ -364,7 +363,7 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C | |||
364 | }, | 363 | }, |
365 | isValidFileName:{ | 364 | isValidFileName:{ |
366 | value: function(fileName){ | 365 | value: function(fileName){ |
367 | var status = nj.isValidFileName(fileName); | 366 | var status = this.isValidFileName(fileName); |
368 | if(fileName !== ""){ | 367 | if(fileName !== ""){ |
369 | if(!status){ | 368 | if(!status){ |
370 | this.showError("! Invalid file name."); | 369 | this.showError("! Invalid file name."); |
@@ -391,6 +390,23 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C | |||
391 | this.okButton.setAttribute("disabled", "true"); | 390 | this.okButton.setAttribute("disabled", "true"); |
392 | } | 391 | } |
393 | } | 392 | } |
394 | } | 393 | }, |
394 | |||
395 | /*** | ||
396 | * file name validation | ||
397 | */ | ||
398 | isValidFileName:{ | ||
399 | value: function(fileName){ | ||
400 | var status = false; | ||
401 | if(fileName !== ""){ | ||
402 | fileName = fileName.replace(/^\s+|\s+$/g,""); | ||
403 | status = !(/[/\\]/g.test(fileName)); | ||
404 | if(status && navigator.userAgent.indexOf("Macintosh") != -1){//for Mac files beginning with . are hidden | ||
405 | status = !(/^\./g.test(fileName)); | ||
406 | } | ||
407 | } | ||
408 | return status; | ||
409 | } | ||
410 | } | ||
395 | 411 | ||
396 | }); \ No newline at end of file | 412 | }); \ No newline at end of file |
diff --git a/js/io/ui/save-as-dialog.reel/save-as-dialog.js b/js/io/ui/save-as-dialog.reel/save-as-dialog.js index b20bed87..1de2eaf1 100644 --- a/js/io/ui/save-as-dialog.reel/save-as-dialog.js +++ b/js/io/ui/save-as-dialog.reel/save-as-dialog.js | |||
@@ -5,8 +5,7 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
5 | </copyright> */ | 5 | </copyright> */ |
6 | 6 | ||
7 | var Montage = require("montage/core/core").Montage, | 7 | var Montage = require("montage/core/core").Montage, |
8 | Component = require("montage/ui/component").Component, | 8 | Component = require("montage/ui/component").Component; |
9 | nj= require("js/lib/NJUtils.js").NJUtils; | ||
10 | 9 | ||
11 | var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { | 10 | var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { |
12 | 11 | ||
@@ -163,7 +162,7 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { | |||
163 | }, | 162 | }, |
164 | isValidFileName:{ | 163 | isValidFileName:{ |
165 | value: function(fileName){ | 164 | value: function(fileName){ |
166 | var status = nj.isValidFileName(fileName); | 165 | var status = this.isValidFileName(fileName); |
167 | if(fileName !== ""){ | 166 | if(fileName !== ""){ |
168 | if(!status){ | 167 | if(!status){ |
169 | this.showError("! Invalid file name."); | 168 | this.showError("! Invalid file name."); |
@@ -191,6 +190,23 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { | |||
191 | this.okButton.setAttribute("disabled", "true"); | 190 | this.okButton.setAttribute("disabled", "true"); |
192 | } | 191 | } |
193 | } | 192 | } |
194 | } | 193 | }, |
194 | |||
195 | /*** | ||
196 | * file name validation | ||
197 | */ | ||
198 | isValidFileName:{ | ||
199 | value: function(fileName){ | ||
200 | var status = false; | ||
201 | if(fileName !== ""){ | ||
202 | fileName = fileName.replace(/^\s+|\s+$/g,""); | ||
203 | status = !(/[/\\]/g.test(fileName)); | ||
204 | if(status && navigator.userAgent.indexOf("Macintosh") != -1){//for Mac files beginning with . are hidden | ||
205 | status = !(/^\./g.test(fileName)); | ||
206 | } | ||
207 | } | ||
208 | return status; | ||
209 | } | ||
210 | } | ||
195 | 211 | ||
196 | }); \ No newline at end of file | 212 | }); \ No newline at end of file |