diff options
author | Eric Guzman | 2012-02-22 23:19:45 -0800 |
---|---|---|
committer | Eric Guzman | 2012-02-22 23:19:45 -0800 |
commit | 9e8cd4448a6d0f809a55c3bdea8b45ed75339794 (patch) | |
tree | c7b5105153f17aedecd0669c611dbea44be7374c /js/io/ui/file-picker/file-input-field.reel/file-input-field.js | |
parent | a5ee11857f923d3e49b44c0a8c480e9d0b026d5b (diff) | |
parent | 2afef244a3f8124f8a049e504e9782c05904ce23 (diff) | |
download | ninja-9e8cd4448a6d0f809a55c3bdea8b45ed75339794.tar.gz |
Merge branch 'refs/heads/master' into CSSPanelUpdates
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 | ||