1 /*
  2  * ***** BEGIN LICENSE BLOCK *****
  3  * Zimbra Collaboration Suite Web Client
  4  * Copyright (C) 2009, 2010, 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) 2009, 2010, 2013, 2014, 2016 Synacor, Inc. All Rights Reserved.
 21  * ***** END LICENSE BLOCK *****
 22  */
 23 
 24 /**
 25  * Creates a preferences section. This is a "pseudo" organizer for
 26  * the preferences application tree view.
 27  * @constructor
 28  * @class
 29  * This class represents the preference page in the preferences application.
 30  * 
 31  * @param {Hash}	params    a hash of parameters
 32  * @param	{int}	     params.id			the numeric ID
 33  * @param	{String}	params.name		the name
 34  * @param	{ZmOrganizer}	params.parent		the parent folder
 35  * @param	{ZmTree}	params.tree		the tree model that contains this folder
 36  * @param	{String}	params.pageId		the ID of pref page
 37  * @param	{String}	params.icon		the icon name
 38  * @param	{String}	params.tooltip		the tool tip text
 39  * 
 40  * @extends		ZmOrganizer
 41  */
 42 ZmPrefPage = function(params) {
 43 	if (arguments.length == 0) { return; }
 44 	params.type = params.type || ZmOrganizer.PREF_PAGE;
 45 	ZmOrganizer.call(this, params);
 46 	this.pageId = params.pageId;
 47 	this.icon = params.icon;
 48 	this.tooltip = params.tooltip;
 49 };
 50 
 51 ZmPrefPage.prototype = new ZmOrganizer;
 52 ZmPrefPage.prototype.constructor = ZmPrefPage;
 53 
 54 ZmPrefPage.prototype.toString = function() {
 55 	return "ZmPrefPage";
 56 };
 57 
 58 //
 59 // Constants
 60 //
 61 
 62 ZmOrganizer.ORG_CLASS[ZmId.ORG_PREF_PAGE] = "ZmPrefPage";
 63 
 64 //
 65 // Static functions
 66 //
 67 
 68 ZmPrefPage.createFromSection = function(section) {
 69 	var overviewController = appCtxt.getOverviewController(); 
 70 	var treeController = overviewController.getTreeController(ZmOrganizer.PREF_PAGE);
 71 	var params = {
 72 		id: ZmId.getPrefPageId(section.id),
 73 		name: section.title,
 74 		parent: null,
 75 		tree: treeController.getDataTree(),
 76 		icon: section.icon,
 77 		tooltip: section.description
 78 	};
 79 	return new ZmPrefPage(params);
 80 };
 81 
 82 //
 83 // Public methods
 84 //
 85 
 86 // ZmOrganizer methods
 87 
 88 ZmPrefPage.prototype.getIcon = function() {
 89 	return this.icon || "Preferences";
 90 };
 91 
 92 ZmPrefPage.prototype.getToolTip = function(force) {
 93 	return this.tooltip || "";
 94 };
 95 
 96