diff options
Diffstat (limited to 'js/components/ui/file-input.reel/file-input.js')
-rw-r--r-- | js/components/ui/file-input.reel/file-input.js | 65 |
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> | ||
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 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 | }); | ||