1 /* 2 * ***** BEGIN LICENSE BLOCK ***** 3 * Zimbra Collaboration Suite Web Client 4 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013, 2014, 2015, 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) 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013, 2014, 2015, 2016 Synacor, Inc. All Rights Reserved. 21 * ***** END LICENSE BLOCK ***** 22 */ 23 24 /** 25 * 26 * @private 27 */ 28 DwtGrouper = function(parent, className, posStyle) { 29 if (arguments.length == 0) return; 30 className = className || "DwtGrouper"; 31 posStyle = posStyle || DwtControl.STATIC_STYLE; 32 DwtComposite.call(this, {parent:parent, posStyle:posStyle}); 33 34 this._labelEl = document.createElement("LEGEND"); 35 this._labelEl.id = Dwt.getNextId(); 36 this._insetEl = document.createElement("DIV"); 37 this._borderEl = document.createElement("FIELDSET"); 38 this._borderEl.appendChild(this._labelEl); 39 this._borderEl.appendChild(this._insetEl); 40 41 this._tabGroup = new DwtTabGroup(this.toString()); 42 43 var element = this.getHtmlElement(); 44 element.appendChild(this._borderEl); 45 } 46 47 DwtGrouper.prototype = new DwtComposite; 48 DwtGrouper.prototype.constructor = DwtGrouper; 49 50 // Public methods 51 52 DwtGrouper.prototype.setLabel = function(htmlContent) { 53 Dwt.setVisible(this._labelEl, Boolean(htmlContent)); 54 // HACK: undo block display set by Dwt.setVisible 55 this._labelEl.style.display = ""; 56 this._labelEl.innerHTML = htmlContent ? htmlContent : ""; 57 }; 58 59 DwtGrouper.prototype.setContent = function(htmlContent) { 60 var element = this._insetEl; 61 element.innerHTML = htmlContent; 62 var inputElements = element.getElementsByTagName('input'); 63 for (var i=0; i < inputElements.length; i++) { 64 this._tabGroup.addMember(inputElements[i]); 65 } 66 }; 67 68 DwtGrouper.prototype.setElement = function(htmlElement) { 69 var element = this._insetEl; 70 Dwt.removeChildren(element); 71 element.appendChild(htmlElement); 72 }; 73 74 DwtGrouper.prototype.setView = function(control) { 75 this.setElement(control.getHtmlElement()); 76 }; 77 78 DwtGrouper.prototype.getInsetHtmlElement = function() { 79 return this._insetEl; 80 }; 81 82 DwtGrouper.prototype.getTabGroupMember = function(){ 83 return this._tabGroup; 84 }; 85