aboutsummaryrefslogtreecommitdiff
path: root/js/components/ui/icon-list-basic/icon.reel/icon.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/components/ui/icon-list-basic/icon.reel/icon.js')
-rw-r--r--js/components/ui/icon-list-basic/icon.reel/icon.js192
1 files changed, 192 insertions, 0 deletions
diff --git a/js/components/ui/icon-list-basic/icon.reel/icon.js b/js/components/ui/icon-list-basic/icon.reel/icon.js
new file mode 100644
index 00000000..d934e7f1
--- /dev/null
+++ b/js/components/ui/icon-list-basic/icon.reel/icon.js
@@ -0,0 +1,192 @@
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;
8var Component = require("montage/ui/component").Component;
9
10var Icon = exports.Icon = Montage.create(Component, {
11
12 _icondata:{
13 enumerable : false,
14 value:null
15 },
16 icondata:{
17 get:function(){
18 return this._icondata;
19 },
20 set:function(value){
21 this._icondata = value;
22 this.needsDraw = true;
23 }
24 },
25 metadata:{
26 enumerable:true,
27 writable:true,
28 value:null
29 },
30
31 willDraw: {
32 enumerable: false,
33 value: function() {
34
35 }
36 },
37 draw: {
38 enumerable: false,
39 value: function() {
40 if(this.icondata.type === "directory"){
41 this.iconImg.src = this.imgStore.img_root + this.imgStore.directory;
42 }else{
43 var fileImg = "";
44 //get extension to map again right icon image
45 var extension = this.icondata.name.substring(this.icondata.name.lastIndexOf(".")).toLowerCase();
46 if(typeof this.imgStore[extension] !== "undefined"){
47 fileImg = this.imgStore.img_root + this.imgStore[extension];
48 }else{
49 fileImg = this.imgStore.img_root + this.imgStore.file_default;
50 }
51 this.iconImg.src = fileImg;
52 }
53 }
54 },
55 didDraw: {
56 enumerable: false,
57 value: function() {
58 var that = this;
59
60 var icon = this.iconImg;
61 var iconLabel = this.iconLabel;
62 if(this.icondata !== null){
63 if(((typeof this.icondata.iconUrl !== "undefined")) && !this.icondata.hasIcon){
64 icon.className = icon.className + " iconBox";
65 }else if((typeof this.icondata.iconUrl !== "undefined") && (this.icondata.iconUrl !== null)){
66 icon.style.backgroundImage = "url("+this.icondata.iconUrl+")";
67 icon.style.backgroundRepeat = "no-repeat";
68 icon.style.backgroundPosition = "center";
69 }
70 iconLabel.innerHTML = this.icondata.name;
71 }
72
73 this.element.addEventListener("dblclick", function(evt){that.handleIconDblclick(evt);}, false);
74 this.element.addEventListener("mouseover", function(evt){that.handleIconMouseover(evt);}, false);
75 this.element.addEventListener("click", function(evt){that.handleIconClick(evt);}, false);
76
77 //prepare metadata string
78 if(this.icondata.name !== ""){
79 this.metadata = "Name: "+this.icondata.name;
80 }
81 this.metadata = this.metadata + "<br />" + "Type: "+this.icondata.type;
82 if(this.icondata.size){this.metadata = this.metadata + "<br />" + "Size: "+this.icondata.size;}
83 if(this.icondata.creationDate){this.metadata = this.metadata + "<br />" + "Creation date: "+ this.formatTimestamp(this.icondata.creationDate);}
84 if(this.icondata.modifiedDate){this.metadata = this.metadata + "<br />" + "Modified date: "+ this.formatTimestamp(this.icondata.modifiedDate);}
85
86 }
87 },
88
89 /**
90 * Event Listeners
91 */
92
93 handleIconClick : {
94 value: function(evt){
95 var selectedItemEvent = document.createEvent("Events");
96 selectedItemEvent.initEvent("selectedItem", false, false);
97 selectedItemEvent.uri = this.icondata.uri;
98 this.element.dispatchEvent(selectedItemEvent);
99
100 var showMetadataEvent = document.createEvent("Events");
101 showMetadataEvent.initEvent("updateMetadata", false, false);
102 showMetadataEvent.metadata = this.metadata;
103 this.element.dispatchEvent(showMetadataEvent);
104
105 //stop propagation so that the container click handler does not deselect it
106 if(evt.bubbles){
107 evt.stopPropagation ();
108 }
109 }
110 },
111
112 handleIconDblclick:{
113 value:function(evt){
114 //console.log(""+ JSON.stringify(that.icondata));
115 if(this.icondata.type === "directory"){
116 var openFolderEvent = document.createEvent("Events");
117 openFolderEvent.initEvent("openFolder", false, false);
118 openFolderEvent.folderUri = this.icondata.uri;
119 this.element.dispatchEvent(openFolderEvent);
120 }
121 if(evt.bubbles){
122 evt.stopPropagation();
123 }
124 }
125 },
126
127 handleIconMouseover:{
128 value: function(evt){
129 //console.log(""+ JSON.stringify(that.icondata));
130 var showMetadataEvent = document.createEvent("Events");
131 showMetadataEvent.initEvent("showMetadata", false, false);
132 showMetadataEvent.metadata = this.metadata;
133 this.element.dispatchEvent(showMetadataEvent);
134 }
135 },
136
137 /**
138 * convert timestamp to human readable form
139 *
140 * @param: timestamp - UTC milliseconds
141 */
142 formatTimestamp:{
143 writable:false,
144 enumerable: false,
145 value: function(timestamp) {
146 var aDate = new Date();
147 timestamp = timestamp - (aDate.getTimezoneOffset()*60*1000);//convert from GMT to local timestamp
148 aDate = new Date(timestamp);
149 return aDate.toLocaleString();
150 }
151 },
152
153 imgStore:{
154 writable:false,
155 enumerable: true,
156 value:{
157 "img_root":"images/picker/",
158 ".png":"png_file.png",
159 ".jpg":"jpeg_file.png",
160 ".js":"js_file.png",
161 ".css":"css_file.png",
162 ".html":"html_file.png",
163 ".xml":"xml_file.png",
164 ".php":"php_file.png",
165 ".doc":"doc_file.png",
166 ".docx":"doc_file.png",
167 ".rtf":"rtf_file.png",
168 ".pdf":"pdf_file.png",
169 ".zip":"zip_file.png",
170 ".rar":"zip_file.png",
171 ".app":"executable.png",
172 ".exe":"executable.png",
173 "file_default":"file.png",
174 "directory":"folder.png"
175 }
176 },
177
178 folderImg:{
179 writable:false,
180 enumerable:true,
181 //value: "data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%0F%00%00%00%0D%08%06%00%00%00v%1E4A%00%00%00%19tEXtSoftware%00Adobe%20ImageReadyq%C9e%3C%00%00%03diTXtXML%3Acom.adobe.xmp%00%00%00%00%00%3C%3Fxpacket%20begin%3D%22%EF%BB%BF%22%20id%3D%22W5M0MpCehiHzreSzNTczkc9d%22%3F%3E%20%3Cx%3Axmpmeta%20xmlns%3Ax%3D%22adobe%3Ans%3Ameta%2F%22%20x%3Axmptk%3D%22Adobe%20XMP%20Core%205.0-c060%2061.134777%2C%202010%2F02%2F12-17%3A32%3A00%20%20%20%20%20%20%20%20%22%3E%20%3Crdf%3ARDF%20xmlns%3Ardf%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2F02%2F22-rdf-syntax-ns%23%22%3E%20%3Crdf%3ADescription%20rdf%3Aabout%3D%22%22%20xmlns%3AxmpMM%3D%22http%3A%2F%2Fns.adobe.com%2Fxap%2F1.0%2Fmm%2F%22%20xmlns%3AstRef%3D%22http%3A%2F%2Fns.adobe.com%2Fxap%2F1.0%2FsType%2FResourceRef%23%22%20xmlns%3Axmp%3D%22http%3A%2F%2Fns.adobe.com%2Fxap%2F1.0%2F%22%20xmpMM%3AOriginalDocumentID%3D%22xmp.did%3A3DDD06742B8DE011952EC04AE9C71C6E%22%20xmpMM%3ADocumentID%3D%22xmp.did%3ACB1289EEB95B11E0A3E0F320D5639EA0%22%20xmpMM%3AInstanceID%3D%22xmp.iid%3ACB1289EDB95B11E0A3E0F320D5639EA0%22%20xmp%3ACreatorTool%3D%22Adobe%20Photoshop%20CS5%20Windows%22%3E%20%3CxmpMM%3ADerivedFrom%20stRef%3AinstanceID%3D%22xmp.iid%3ABB242C8D4AB9E011B013F72FE65B91B8%22%20stRef%3AdocumentID%3D%22xmp.did%3A3DDD06742B8DE011952EC04AE9C71C6E%22%2F%3E%20%3C%2Frdf%3ADescription%3E%20%3C%2Frdf%3ARDF%3E%20%3C%2Fx%3Axmpmeta%3E%20%3C%3Fxpacket%20end%3D%22r%22%3F%3E%0Di%17%A8%00%00%01%16IDATx%DA%9CQ%BB%8D%84%40%0C5%60%10%3D%20%D1%01!%11%E9%5D%13%2B!%9DD%0A%3DP%015%1C1%25lL%01%D4%40%0D%87%F8%CF%ED%1B%C9%C8%BB%DAK%CE%C1%F8%FF%FC%ECq%8C1%04I%92%E43%CB%B2%2F%C7q%AC%0F%DD%F7%FD%F70%0Cw%FAC%18O%9E%E7%A6m%5B%1B%08%C3%90%98%99%3C%CF%23%DF%F7oeY%DA8%86%08%F08%8E%16%DF6o%DBF%D34%5D%88A%10X%90%A2(h%DFw%3A%CF%D3%D6%1C%C7A%CB%B2P%D34%94%A6)%B9%F4O%A9%EB%9A%9C%AA%AA%EEq%1C%7F%00%5D%E8A%E0%8B-%1A%93%85%3E%F2%FCx%CE(%8Al%D2u%DD%2B)%85%02%02-%B6%F8%0C%03%7B%E0%40r%10)%80%60g%F1%A5Ij%18%13%E4%18%F2E%BAP7%CA%3AW3%D8%AE%EBj)%BF~%89%DE%5B%0Bb%18%06%DA%8Cf%D0F1%1A%F5%F4W0m%B3%3E%86F%16%00%7D%07%BD%164%B8%1A%9D%D4%8D%1A%EC%1Du%9E%E7%F9%A7%EB%BA'%BA%EFD%BEQ3%F8%15%60%00%93%E1%09(%04O%F3%95%00%00%00%00IEND%AEB%60%82"
182 value:"images/picker/folder.png"
183 },
184
185 fileImg:{
186 writable:false,
187 enumerable:true,
188 //value: "data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%0C%00%00%00%0F%08%06%00%00%00%D0%E1.I%00%00%00%19tEXtSoftware%00Adobe%20ImageReadyq%C9e%3C%00%00%03diTXtXML%3Acom.adobe.xmp%00%00%00%00%00%3C%3Fxpacket%20begin%3D%22%EF%BB%BF%22%20id%3D%22W5M0MpCehiHzreSzNTczkc9d%22%3F%3E%20%3Cx%3Axmpmeta%20xmlns%3Ax%3D%22adobe%3Ans%3Ameta%2F%22%20x%3Axmptk%3D%22Adobe%20XMP%20Core%205.0-c060%2061.134777%2C%202010%2F02%2F12-17%3A32%3A00%20%20%20%20%20%20%20%20%22%3E%20%3Crdf%3ARDF%20xmlns%3Ardf%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2F02%2F22-rdf-syntax-ns%23%22%3E%20%3Crdf%3ADescription%20rdf%3Aabout%3D%22%22%20xmlns%3AxmpMM%3D%22http%3A%2F%2Fns.adobe.com%2Fxap%2F1.0%2Fmm%2F%22%20xmlns%3AstRef%3D%22http%3A%2F%2Fns.adobe.com%2Fxap%2F1.0%2FsType%2FResourceRef%23%22%20xmlns%3Axmp%3D%22http%3A%2F%2Fns.adobe.com%2Fxap%2F1.0%2F%22%20xmpMM%3AOriginalDocumentID%3D%22xmp.did%3A3DDD06742B8DE011952EC04AE9C71C6E%22%20xmpMM%3ADocumentID%3D%22xmp.did%3AFB8694A1B95B11E089FD9315AFFFFC35%22%20xmpMM%3AInstanceID%3D%22xmp.iid%3AFB8694A0B95B11E089FD9315AFFFFC35%22%20xmp%3ACreatorTool%3D%22Adobe%20Photoshop%20CS5%20Windows%22%3E%20%3CxmpMM%3ADerivedFrom%20stRef%3AinstanceID%3D%22xmp.iid%3ABB242C8D4AB9E011B013F72FE65B91B8%22%20stRef%3AdocumentID%3D%22xmp.did%3A3DDD06742B8DE011952EC04AE9C71C6E%22%2F%3E%20%3C%2Frdf%3ADescription%3E%20%3C%2Frdf%3ARDF%3E%20%3C%2Fx%3Axmpmeta%3E%20%3C%3Fxpacket%20end%3D%22r%22%3F%3E3%FD%7F%2B%00%00%018IDATx%DAt%91%BBJCA%10%40w%D7%DCB%23%DC%80%8A%82U%AA%60e%9DJH-%82%8D%85X)ha!X%24%A5%F8H%FE%20%8D_%60%E3%2F%A4%B2%13%D1%D2%CAB%10%95%D8%04%7C%E0%7DzFv%C3%25%EC%1D8%CC%EC0%EF%D5i%9An%18c.U%B9%F4%93%249'NeY%A6%0C%8EY%1C%CA%C3%85%D5%87Z%EB%9E%CB68%86%92%E9%E1%1Ab%B1%A9%BEK%D2%A9%24Tx%04%BE9%18%F3%15%F5%94%E7yC%DE%24%1C%A0%96%2BT%C8%7D%09%04%AA8%8E%D7%82%20%D8%C3%5E%C5%B5%05%EB%D2%A1l%D97%180%F2%2F%FA%0EF%10J%07e%5B%3E%60%EF%60%CEK%03X%84%25xa%BC%0E%5DB%EC%CFb%87%3At%A1f%DF%99M%FC%A6P%E8V%2B%26%3C%C3%09%2C%C0%94%0D%D6%F0%0EG%F0%BF%FCx%24d%05%AE%A0%3A%B1%CB%8F%1DO%B9%B3%3A%FB%166a%AE%10%2C%1D%3E%A0%0D%C7%93%235Y%EE%1E%3Dc%03%9D%7C1%85%2B%92%8E%FF%81%2B%0D%A2(%DAF%FBN%BCO%B13%F9%1B%E9%E0.%D0%92%DB%8B%D3'v%D7%AAtx%2C%2CgJ%3EQ%A2%A7%E1%E6O%80%01%00%20%DB%B8%A6Z%92%D9)%00%00%00%00IEND%AEB%60%82"
189 value:"images/picker/file.png"
190 }
191
192}); \ No newline at end of file