diff options
author | Ananya Sen | 2012-02-16 13:11:48 -0800 |
---|---|---|
committer | Ananya Sen | 2012-02-16 13:11:48 -0800 |
commit | a9c369c2e5d8f6fc8d936f7e1e6b84f693226ddf (patch) | |
tree | c82b8845ed4dee8d30797d317d44aa8b169bc62f /js/io/ui/file-picker/file-input-field.reel/file-input-field.js | |
parent | 302ae3c1812086d976eb67c9cf693c43205f3904 (diff) | |
download | ninja-a9c369c2e5d8f6fc8d936f7e1e6b84f693226ddf.tar.gz |
moved file picker in file io
Signed-off-by: Ananya Sen <Ananya.Sen@motorola.com>
Diffstat (limited to 'js/io/ui/file-picker/file-input-field.reel/file-input-field.js')
-rwxr-xr-x | js/io/ui/file-picker/file-input-field.reel/file-input-field.js | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/js/io/ui/file-picker/file-input-field.reel/file-input-field.js b/js/io/ui/file-picker/file-input-field.reel/file-input-field.js new file mode 100755 index 00000000..235be8ad --- /dev/null +++ b/js/io/ui/file-picker/file-input-field.reel/file-input-field.js | |||
@@ -0,0 +1,120 @@ | |||
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 | var Montage = require("montage/core/core").Montage, | ||
8 | Component = require("montage/ui/component").Component; | ||
9 | |||
10 | var FileInputField = exports.FileInputField = Montage.create(Component, { | ||
11 | |||
12 | hasReel: { | ||
13 | value: true | ||
14 | }, | ||
15 | |||
16 | willDraw: { | ||
17 | enumerable: false, | ||
18 | value: function() {} | ||
19 | }, | ||
20 | draw: { | ||
21 | enumerable: false, | ||
22 | value: function() {} | ||
23 | }, | ||
24 | didDraw: { | ||
25 | enumerable: false, | ||
26 | value: function() { | ||
27 | var that = this; | ||
28 | this.findDirectory.identifier = "findDirectory"; | ||
29 | this.findDirectory.addEventListener("click", function(evt){that.handleFindDirectoryClick(evt);}, false); | ||
30 | |||
31 | this.eventManager.addEventListener("pickerSelectionsDone", function(evt){that.handleFileInputPickerSelectionsDone(evt);}, false); | ||
32 | |||
33 | this.newFileDirectory.addEventListener("keyup", function(evt){that.handleNewFileDirectoryOnkeyup(evt);}, false); | ||
34 | } | ||
35 | }, | ||
36 | |||
37 | /** | ||
38 | * Either selectDirectory OR selectFile can be true | ||
39 | * If both are false then the file picker will default to file selection mode | ||
40 | */ | ||
41 | |||
42 | selectDirectory:{ | ||
43 | writable: true, | ||
44 | enumerable:false, | ||
45 | value: false | ||
46 | }, | ||
47 | |||
48 | pickerName:{ | ||
49 | writable: true, | ||
50 | enumerable:false, | ||
51 | value: null | ||
52 | }, | ||
53 | |||
54 | selectFile:{ | ||
55 | writable: true, | ||
56 | enumerable:false, | ||
57 | value: false | ||
58 | }, | ||
59 | |||
60 | |||
61 | handleFindDirectoryClick: { | ||
62 | value: function(evt){ | ||
63 | var openFilePicker = document.createEvent("Events"); | ||
64 | openFilePicker.initEvent("openFilePicker", false, false); | ||
65 | var settings = {}; | ||
66 | if(this.selectDirectory === true){ | ||
67 | settings.inFileMode = false; | ||
68 | settings.pickerName = this.pickerName || "newFileDirectorySelector"; | ||
69 | }else{ | ||
70 | settings.inFileMode = true; | ||
71 | settings.pickerName = this.pickerName || "fileSelector"; | ||
72 | } | ||
73 | settings.callback = this.filePickerCallback.bind(this); | ||
74 | openFilePicker.settings = settings; | ||
75 | this.eventManager.dispatchEvent(openFilePicker); | ||
76 | } | ||
77 | }, | ||
78 | |||
79 | handleNewFileDirectoryOnkeyup:{ | ||
80 | value:function(evt){ | ||
81 | if(this.newFileDirectory.value !== ""){ | ||
82 | var newFileDirectorySetEvent = document.createEvent("Events"); | ||
83 | newFileDirectorySetEvent.initEvent("newFileDirectorySet", false, false); | ||
84 | newFileDirectorySetEvent.newFileDirectory = this.newFileDirectory.value; | ||
85 | this.eventManager.dispatchEvent(newFileDirectorySetEvent); | ||
86 | } | ||
87 | } | ||
88 | }, | ||
89 | |||
90 | handleFileInputPickerSelectionsDone:{ | ||
91 | value: function(evt){ | ||
92 | var selectedUri = ""; | ||
93 | if(!!evt._event.selectedItems && evt._event.selectedItems.length > 0){ | ||
94 | selectedUri = evt._event.selectedItems[0]; | ||
95 | this.newFileDirectory.value = selectedUri; | ||
96 | |||
97 | var newFileDirectorySetEvent = document.createEvent("Events"); | ||
98 | newFileDirectorySetEvent.initEvent("newFileDirectorySet", false, false); | ||
99 | newFileDirectorySetEvent.newFileDirectory = this.newFileDirectory.value; | ||
100 | this.eventManager.dispatchEvent(newFileDirectorySetEvent); | ||
101 | } | ||
102 | } | ||
103 | }, | ||
104 | |||
105 | filePickerCallback:{ | ||
106 | value: function(obj){ | ||
107 | var selectedUri = ""; | ||
108 | if(!!obj && obj.uri && obj.uri.length > 0){ | ||
109 | selectedUri = obj.uri[0]; | ||
110 | this.newFileDirectory.value = selectedUri; | ||
111 | |||
112 | var newFileDirectorySetEvent = document.createEvent("Events"); | ||
113 | newFileDirectorySetEvent.initEvent("newFileDirectorySet", false, false); | ||
114 | newFileDirectorySetEvent.newFileDirectory = this.newFileDirectory.value; | ||
115 | this.eventManager.dispatchEvent(newFileDirectorySetEvent); | ||
116 | } | ||
117 | } | ||
118 | } | ||
119 | |||
120 | }); \ No newline at end of file | ||