diff options
Diffstat (limited to 'js/io')
-rwxr-xr-x | js/io/system/coreioapi.js | 64 | ||||
-rwxr-xr-x | js/io/system/fileio.js | 4 | ||||
-rw-r--r-- | js/io/system/ninjalibrary.js | 137 | ||||
-rw-r--r-- | js/io/system/ninjalibrary.json | 4 | ||||
-rw-r--r-- | js/io/templates/descriptor.json | 68 | ||||
-rwxr-xr-x | js/io/templates/files/animation.txt | 23 | ||||
-rwxr-xr-x | js/io/templates/files/banner.txt | 23 | ||||
-rwxr-xr-x | js/io/templates/files/html.txt | 1 | ||||
-rwxr-xr-x | js/io/ui/file-picker/file-input-field.reel/file-input-field.js | 2 | ||||
-rwxr-xr-x | js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.js | 2 | ||||
-rw-r--r-- | js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js | 11 | ||||
-rw-r--r-- | js/io/ui/save-as-dialog.reel/save-as-dialog.js | 2 |
12 files changed, 249 insertions, 92 deletions
diff --git a/js/io/system/coreioapi.js b/js/io/system/coreioapi.js index a06f45c6..1e6518fe 100755 --- a/js/io/system/coreioapi.js +++ b/js/io/system/coreioapi.js | |||
@@ -193,6 +193,23 @@ exports.CoreIoApi = Montage.create(Component, { | |||
193 | this._fileServiceURL = value; | 193 | this._fileServiceURL = value; |
194 | } | 194 | } |
195 | }, | 195 | }, |
196 | //////////////////////////////////////////////////////////////////// | ||
197 | //File service API URL | ||
198 | _webServiceURL: { | ||
199 | enumerable: false, | ||
200 | value: '/web' | ||
201 | }, | ||
202 | //////////////////////////////////////////////////////////////////// | ||
203 | // | ||
204 | webServiceURL: { | ||
205 | enumerable: false, | ||
206 | get: function() { | ||
207 | return String(this.rootUrl+this._webServiceURL); | ||
208 | }, | ||
209 | set: function(value) { | ||
210 | this._webServiceURL = value; | ||
211 | } | ||
212 | }, | ||
196 | //////////////////////////////////////////////////////////////////// | 213 | //////////////////////////////////////////////////////////////////// |
197 | //Directory service API URL | 214 | //Directory service API URL |
198 | _directoryServiceURL: { | 215 | _directoryServiceURL: { |
@@ -647,6 +664,53 @@ exports.CoreIoApi = Montage.create(Component, { | |||
647 | } | 664 | } |
648 | }, | 665 | }, |
649 | //////////////////////////////////////////////////////////////////// | 666 | //////////////////////////////////////////////////////////////////// |
667 | // Reads an external file (cross-domain) | ||
668 | // Parameters: | ||
669 | // the file parameter must contain the following properties | ||
670 | // url: string value containing the full file path/URL i.e. "http://google.com/motorola.html" | ||
671 | // binary parameter is optional if the content is to be binary | ||
672 | // Return values: | ||
673 | // returns an object with two properties | ||
674 | // success: boolean indicating if the call succeeded or failed | ||
675 | // content: string containing the file contents | ||
676 | // status: int indicating the request HTTP status code | ||
677 | // 200 - the file was read and its contents were returned | ||
678 | // 404 - the file does not exist | ||
679 | // 500 - unknown server error occurred | ||
680 | readExternalFile: { | ||
681 | enumerable: false, | ||
682 | value: function(file) { | ||
683 | // | ||
684 | var retValue = {success:null, content:null, status:null}; | ||
685 | // | ||
686 | if(file && file.url && file.url.length) { | ||
687 | try { | ||
688 | var serviceURL = this._prepareServiceURL(this.webServiceURL, ''), | ||
689 | xhr = new XMLHttpRequest(); | ||
690 | // | ||
691 | xhr.open("GET", serviceURL+"?url="+file.url, false); | ||
692 | if (file.binary) xhr.setRequestHeader("return-type", "binary"); | ||
693 | xhr.setRequestHeader("Content-Type", "text/plain"); | ||
694 | xhr.send(); | ||
695 | // | ||
696 | if (xhr.readyState === 4) { | ||
697 | retValue.status = xhr.status; | ||
698 | if(xhr.status == 200) { | ||
699 | retValue.content = xhr.response; | ||
700 | } | ||
701 | retValue.success = true; | ||
702 | } | ||
703 | } | ||
704 | catch(error) { | ||
705 | xhr = null; | ||
706 | retValue.success = false; | ||
707 | } | ||
708 | } | ||
709 | // | ||
710 | return retValue; | ||
711 | } | ||
712 | }, | ||
713 | //////////////////////////////////////////////////////////////////// | ||
650 | // Create a new directory/folder | 714 | // Create a new directory/folder |
651 | // Parameters: | 715 | // Parameters: |
652 | // the dir parameter must contain the following properties | 716 | // the dir parameter must contain the following properties |
diff --git a/js/io/system/fileio.js b/js/io/system/fileio.js index f78ad173..1680ca7f 100755 --- a/js/io/system/fileio.js +++ b/js/io/system/fileio.js | |||
@@ -146,7 +146,7 @@ exports.FileIo = Montage.create(Component, { | |||
146 | } | 146 | } |
147 | }, | 147 | }, |
148 | //////////////////////////////////////////////////////////////////// | 148 | //////////////////////////////////////////////////////////////////// |
149 | // | 149 | //TODO: Add functionality |
150 | deleteFile: { | 150 | deleteFile: { |
151 | enumerable: true, | 151 | enumerable: true, |
152 | value: function() { | 152 | value: function() { |
@@ -159,7 +159,7 @@ exports.FileIo = Montage.create(Component, { | |||
159 | } | 159 | } |
160 | }, | 160 | }, |
161 | //////////////////////////////////////////////////////////////////// | 161 | //////////////////////////////////////////////////////////////////// |
162 | // | 162 | //TODO: Add functionality |
163 | copyFile: { | 163 | copyFile: { |
164 | enumerable: true, | 164 | enumerable: true, |
165 | value: function() { | 165 | value: function() { |
diff --git a/js/io/system/ninjalibrary.js b/js/io/system/ninjalibrary.js index f4915a91..12af5988 100644 --- a/js/io/system/ninjalibrary.js +++ b/js/io/system/ninjalibrary.js | |||
@@ -4,12 +4,7 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | 4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. |
5 | </copyright> */ | 5 | </copyright> */ |
6 | 6 | ||
7 | /* ///////////////////////////////////////////////////////////////////// | ||
8 | //////////////////////////////////////////////////////////////////////// | 7 | //////////////////////////////////////////////////////////////////////// |
9 | NOTES: | ||
10 | |||
11 | //////////////////////////////////////////////////////////////////////// | ||
12 | ///////////////////////////////////////////////////////////////////// */ | ||
13 | // | 8 | // |
14 | var Montage = require("montage/core/core").Montage; | 9 | var Montage = require("montage/core/core").Montage; |
15 | //////////////////////////////////////////////////////////////////////// | 10 | //////////////////////////////////////////////////////////////////////// |
@@ -18,96 +13,80 @@ exports.NinjaLibrary = Montage.create(Object.prototype, { | |||
18 | //////////////////////////////////////////////////////////////////// | 13 | //////////////////////////////////////////////////////////////////// |
19 | // | 14 | // |
20 | _chromeApi: { | 15 | _chromeApi: { |
21 | enumerable: false, | ||
22 | value: null | 16 | value: null |
23 | }, | 17 | }, |
24 | //////////////////////////////////////////////////////////////////// | 18 | //////////////////////////////////////////////////////////////////// |
25 | // | 19 | // |
26 | chromeApi: { | 20 | chromeApi: { |
27 | enumerable: false, | 21 | get: function() {return this._chromeApi;}, |
28 | get: function() { | 22 | set: function(value) {this._chromeApi = value;} |
29 | return this._chromeApi; | ||
30 | }, | ||
31 | set: function(value) { | ||
32 | this._chromeApi = value; | ||
33 | } | ||
34 | }, | 23 | }, |
35 | //////////////////////////////////////////////////////////////////// | 24 | //////////////////////////////////////////////////////////////////// |
36 | // | 25 | // |
37 | _coreApi: { | 26 | _coreApi: { |
38 | enumerable: false, | ||
39 | value: null | 27 | value: null |
40 | }, | 28 | }, |
41 | //////////////////////////////////////////////////////////////////// | 29 | //////////////////////////////////////////////////////////////////// |
42 | // | 30 | // |
43 | coreApi: { | 31 | coreApi: { |
44 | enumerable: false, | 32 | get: function() {return this._coreApi;}, |
45 | get: function() { | 33 | set: function(value) {this._coreApi = value;} |
46 | return this._coreApi; | ||
47 | }, | ||
48 | set: function(value) { | ||
49 | this._coreApi = value; | ||
50 | } | ||
51 | }, | 34 | }, |
52 | //////////////////////////////////////////////////////////////////// | 35 | //////////////////////////////////////////////////////////////////// |
53 | // | 36 | // |
54 | _libs: { | 37 | _libs: { |
55 | enumerable: false, | ||
56 | value: null | 38 | value: null |
57 | }, | 39 | }, |
58 | //////////////////////////////////////////////////////////////////// | 40 | //////////////////////////////////////////////////////////////////// |
59 | // | 41 | // |
60 | libs: { | 42 | libs: { |
61 | enumerable: false, | 43 | get: function() {return this._libs;}, |
62 | get: function() { | 44 | set: function(value) {this._libs = value;} |
63 | return this._libs; | ||
64 | }, | ||
65 | set: function(value) { | ||
66 | this._libs = value; | ||
67 | } | ||
68 | }, | 45 | }, |
69 | //////////////////////////////////////////////////////////////////// | 46 | //////////////////////////////////////////////////////////////////// |
70 | // | 47 | // |
71 | _libsToSync: { | 48 | _libsToSync: { |
72 | enumerable: false, | ||
73 | value: 0 | 49 | value: 0 |
74 | }, | 50 | }, |
75 | //////////////////////////////////////////////////////////////////// | 51 | //////////////////////////////////////////////////////////////////// |
76 | // | 52 | // |
77 | _syncedLibs: { | 53 | _syncedLibs: { |
78 | enumerable: false, | ||
79 | value: 0 | 54 | value: 0 |
80 | }, | 55 | }, |
81 | //////////////////////////////////////////////////////////////////// | 56 | //////////////////////////////////////////////////////////////////// |
82 | // | 57 | // |
83 | copyLibToCloud: { | 58 | copyLibToCloud: { |
84 | enumerable: false, | ||
85 | value: function (path, libName, callback) { | 59 | value: function (path, libName, callback) { |
86 | // | 60 | //Checking for library to exists |
87 | if(this.coreApi.directoryExists({uri: path+libName}).status === 404) { | 61 | if(this.coreApi.directoryExists({uri: path+libName}).status === 404) { |
62 | //Getting contents to begin copying | ||
88 | this.chromeApi.directoryContents(this.chromeApi.fileSystem.root, function (contents) { |