aboutsummaryrefslogtreecommitdiff
path: root/js/components/ui/file-input.reel/file-input.js
diff options
context:
space:
mode:
authorPierre Frisch2011-12-22 07:25:50 -0800
committerValerio Virgillito2012-01-27 11:18:17 -0800
commitb89a7ee8b956c96a1dcee995ea840feddc5d4b27 (patch)
tree0f3136ab0ecdbbbed6a83576581af0a53124d6f1 /js/components/ui/file-input.reel/file-input.js
parent2401f05d1f4b94d45e4568b81fc73e67b969d980 (diff)
downloadninja-b89a7ee8b956c96a1dcee995ea840feddc5d4b27.tar.gz
First commit of Ninja to ninja-internal
Signed-off-by: Valerio Virgillito <rmwh84@motorola.com>
Diffstat (limited to 'js/components/ui/file-input.reel/file-input.js')
-rw-r--r--js/components/ui/file-input.reel/file-input.js65
1 files changed, 65 insertions, 0 deletions
diff --git a/js/components/ui/file-input.reel/file-input.js b/js/components/ui/file-input.reel/file-input.js
new file mode 100644
index 00000000..2ea38162
--- /dev/null
+++ b/js/components/ui/file-input.reel/file-input.js
@@ -0,0 +1,65 @@
1/* <copyright>
2This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3No 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
7var Montage = require("montage/core/core").Montage,
8Component = require("montage/ui/component").Component;
9
10var FileInput = exports.FileInput = Montage.create(Component, {
11
12 _filePath: {
13 enumerable: false,
14 value: ""
15 },
16
17 filePath: {
18 enumerable: true,
19 serializable: true,
20 get: function () {
21 return this._filePath;
22 },
23 set: function (value) {
24 if (value !== this._filePath) {
25 this._filePath = value;
26 this.needsDraw = true;
27 }
28 }
29 },
30
31 draw: {
32 value: function() {
33 this.filePathField.value = this._filePath;
34 }
35 },
36
37 handleChange:
38 {
39 value:function(event)
40 {
41 if(event.currentTarget.id === "fileInputControl")
42 {
43 this.filePath = this.inputField.value;
44 }
45 else
46 {
47 this.filePath = this.filePathField.value;
48 }
49
50 var e = document.createEvent("CustomEvent");
51 e.initEvent("change", true, true);
52 e.type = "change";
53 e.filePath = this.filePath;
54 this.dispatchEvent(e);
55 }
56 },
57
58 prepareForDraw: {
59 value: function() {
60 this.inputField.addEventListener("change", this, false);
61 this.filePathField.addEventListener("change", this, false);
62 }
63 }
64
65});