diff options
Diffstat (limited to 'js/mediators')
-rwxr-xr-x[-rw-r--r--] | js/mediators/drag-drop-mediator.js | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | js/mediators/element-mediator.js | 0 | ||||
-rw-r--r-- | js/mediators/io-mediator.js | 79 | ||||
-rwxr-xr-x[-rw-r--r--] | js/mediators/keyboard-mediator.js | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | js/mediators/mouse-mediator.js | 0 |
5 files changed, 79 insertions, 0 deletions
diff --git a/js/mediators/drag-drop-mediator.js b/js/mediators/drag-drop-mediator.js index aacb228c..aacb228c 100644..100755 --- a/js/mediators/drag-drop-mediator.js +++ b/js/mediators/drag-drop-mediator.js | |||
diff --git a/js/mediators/element-mediator.js b/js/mediators/element-mediator.js index c44e1cb5..c44e1cb5 100644..100755 --- a/js/mediators/element-mediator.js +++ b/js/mediators/element-mediator.js | |||
diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js new file mode 100644 index 00000000..76f78a7d --- /dev/null +++ b/js/mediators/io-mediator.js | |||
@@ -0,0 +1,79 @@ | |||
1 | /* <copyright> | ||
2 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | ||
3 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> | ||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | ||
5 | </copyright> */ | ||
6 | |||
7 | //////////////////////////////////////////////////////////////////////// | ||
8 | // | ||
9 | var Montage = require("montage/core/core").Montage, | ||
10 | FileIo = require("js/io/system/fileio").FileIo, | ||
11 | ProjectIo = require("js/io/system/projectio").ProjectIo; | ||
12 | //////////////////////////////////////////////////////////////////////// | ||
13 | // | ||
14 | exports.IoMediator = Montage.create(require("montage/ui/component").Component, { | ||
15 | //////////////////////////////////////////////////////////////////// | ||
16 | // | ||
17 | fileNew: { | ||
18 | enumerable: false, | ||
19 | value: function (file, template, callback) { | ||
20 | // | ||
21 | |||
22 | |||
23 | var returnObj = null; //like {"type": "js", "name": "filename", "source": "test file content", "uri": "/fs/fsd/"} | ||
24 | callback.operation.call(callback.thisScope, returnObj); | ||
25 | } | ||
26 | }, | ||
27 | //////////////////////////////////////////////////////////////////// | ||
28 | // | ||
29 | fileOpen: { | ||
30 | enumerable: false, | ||
31 | value: function (file, callback) { | ||
32 | var response = "", fileContent="", filename="", fileType="js", returnObj=null; | ||
33 | |||
34 | response = this.application.ninja.coreIoApi.openFile({"uri":file.uri}); | ||
35 | if((response.success === true) && ((response.status === 200) || (response.status === 304))){ | ||
36 | fileContent = response.content; | ||
37 | } | ||
38 | |||
39 | |||
40 | //TODO : format html content to render in design view | ||
41 | |||
42 | |||
43 | filename = this.getFileNameFromPath(file.uri); | ||
44 | if(file.uri.indexOf('.') != -1){ | ||
45 | fileType = file.uri.substr(file.uri.lastIndexOf('.') + 1); | ||
46 | } | ||
47 | returnObj = {"type": ""+fileType, "name": ""+filename, "source": fileContent, "uri": file.uri}; | ||
48 | callback.operation.call(callback.thisScope, returnObj); | ||
49 | } | ||
50 | }, | ||
51 | //////////////////////////////////////////////////////////////////// | ||
52 | // | ||
53 | fileSave: { | ||
54 | enumerable: false, | ||
55 | value: function (file, callback) { | ||
56 | // | ||
57 | } | ||
58 | }, | ||
59 | //////////////////////////////////////////////////////////////////// | ||
60 | // | ||
61 | fileSaveAs: { | ||
62 | enumerable: false, | ||
63 | value: function (file, copy, callback) { | ||
64 | // | ||
65 | } | ||
66 | }, | ||
67 | //////////////////////////////////////////////////////////////////// | ||
68 | ///// Return the last part of a path (e.g. filename) | ||
69 | getFileNameFromPath : { | ||
70 | value: function(path) { | ||
71 | path = path.replace(/[/\\]$/g,""); | ||
72 | path = path.replace(/\\/g,"/"); | ||
73 | return path.substr(path.lastIndexOf('/') + 1); | ||
74 | } | ||
75 | } | ||
76 | //////////////////////////////////////////////////////////////////// | ||
77 | }); | ||
78 | //////////////////////////////////////////////////////////////////////// | ||
79 | //////////////////////////////////////////////////////////////////////// \ No newline at end of file | ||
diff --git a/js/mediators/keyboard-mediator.js b/js/mediators/keyboard-mediator.js index a1fdead3..a1fdead3 100644..100755 --- a/js/mediators/keyboard-mediator.js +++ b/js/mediators/keyboard-mediator.js | |||
diff --git a/js/mediators/mouse-mediator.js b/js/mediators/mouse-mediator.js index cef6c6c4..cef6c6c4 100644..100755 --- a/js/mediators/mouse-mediator.js +++ b/js/mediators/mouse-mediator.js | |||