1 /* 2 * ***** BEGIN LICENSE BLOCK ***** 3 * Zimbra Collaboration Suite Web Client 4 * Copyright (C) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2016 Synacor, Inc. 5 * 6 * The contents of this file are subject to the Common Public Attribution License Version 1.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at: https://www.zimbra.com/license 9 * The License is based on the Mozilla Public License Version 1.1 but Sections 14 and 15 10 * have been added to cover use of software over a computer network and provide for limited attribution 11 * for the Original Developer. In addition, Exhibit A has been modified to be consistent with Exhibit B. 12 * 13 * Software distributed under the License is distributed on an "AS IS" basis, 14 * WITHOUT WARRANTY OF ANY KIND, either express or implied. 15 * See the License for the specific language governing rights and limitations under the License. 16 * The Original Code is Zimbra Open Source Web Client. 17 * The Initial Developer of the Original Code is Zimbra, Inc. All rights to the Original Code were 18 * transferred by Zimbra, Inc. to Synacor, Inc. on September 14, 2015. 19 * 20 * All portions of the code are Copyright (C) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2016 Synacor, Inc. All Rights Reserved. 21 * ***** END LICENSE BLOCK ***** 22 */ 23 24 /** 25 * Creates the briefcase icon view. 26 * @class 27 * This class represents the briefcase icon view. 28 * 29 * @param {Hash} params a hash of parameters 30 * 31 * @extends ZmBriefcaseBaseView 32 */ 33 ZmBriefcaseIconView = function(params) { 34 ZmBriefcaseBaseView.call(this, params); 35 this.getHtmlElement().style.backgroundColor = "white"; 36 } 37 38 ZmBriefcaseIconView.prototype = new ZmBriefcaseBaseView; 39 ZmBriefcaseIconView.prototype.constructor = ZmBriefcaseIconView; 40 41 /** 42 * Returns a string representation of the object. 43 * 44 * @return {String} a string representation of the object 45 */ 46 ZmBriefcaseIconView.prototype.toString = 47 function() { 48 return "ZmBriefcaseIconView"; 49 }; 50 51 // Data 52 ZmBriefcaseIconView.prototype._createItemHtml = 53 function(item, params) { 54 55 var name = item.name; 56 var contentType = item.contentType; 57 58 if(contentType && contentType.match(/;/)) { 59 contentType = contentType.split(";")[0]; 60 } 61 var mimeInfo = contentType ? ZmMimeTable.getInfo(contentType) : null; 62 icon = "Img" + ( mimeInfo ? mimeInfo.imageLarge : "UnknownDoc_48"); 63 64 if(item.isFolder) { 65 icon = "ImgBriefcase_48"; 66 } 67 68 if(name.length>14){ 69 name = name.substring(0,14)+"..."; 70 } 71 72 var div = document.createElement("div"); 73 div.className = "ZmBriefcaseItemSmall"; 74 75 var htmlArr = []; 76 var idx = 0; 77 78 var icon = null; 79 if (!icon) { 80 var contentType = item.contentType; 81 if(contentType && contentType.match(/;/)) { 82 contentType = contentType.split(";")[0]; 83 } 84 var mimeInfo = contentType ? ZmMimeTable.getInfo(contentType) : null; 85 icon = mimeInfo ? mimeInfo.image : "UnknownDoc" ; 86 if(item.isFolder){ 87 icon = "Folder"; 88 } 89 } 90 91 htmlArr[idx++] = "<table><tr>"; 92 if (appCtxt.get(ZmSetting.SHOW_SELECTION_CHECKBOX)) { 93 htmlArr[idx++] = "<td>"; 94 idx = this._getImageHtml(htmlArr, idx, "CheckboxUnchecked", this._getFieldId(item, ZmItem.F_SELECTION)); 95 htmlArr[idx++] = "</td>"; 96 } 97 htmlArr[idx++] = "<td><div class='Img"; 98 htmlArr[idx++] = icon; 99 htmlArr[idx++] = "'></div></td><td nowrap>"; 100 htmlArr[idx++] = AjxStringUtil.htmlEncode(item.name); 101 htmlArr[idx++] = "</td><tr></table>"; 102 103 if (params && params.isDragProxy) { 104 Dwt.setPosition(div, Dwt.ABSOLUTE_STYLE); 105 } 106 div.innerHTML = htmlArr.join(""); 107 108 this.associateItemWithElement(item, div); 109 return div; 110 }; 111 112 ZmBriefcaseIconView.prototype.set = 113 function(list, sortField, doNotIncludeFolders){ 114 115 doNotIncludeFolders = true; 116 117 ZmBriefcaseBaseView.prototype.set.call(this, list, sortField, doNotIncludeFolders); 118 119 };