1 /*
  2  * ***** BEGIN LICENSE BLOCK *****
  3  * Zimbra Collaboration Suite Web Client
  4  * Copyright (C) 2010, 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) 2010, 2012, 2013, 2014, 2016 Synacor, Inc. All Rights Reserved.
 21  * ***** END LICENSE BLOCK *****
 22  */
 23 
 24 /**
 25  * Creates the filters page, with tabs for incoming and outgoing filters.
 26  * @class
 27  * This class represents the filters page.
 28  * 
 29  * @param {DwtControl}	            parent			the containing widget
 30  * @param {Object}	                section			the page
 31  * @param {ZmFilterController}	    controller		the filter controller
 32  * 
 33  * @extends	ZmPreferencesPage
 34  * 
 35  * @private
 36  */
 37 ZmFilterPage = function(parent, section, controller) {
 38 	ZmPreferencesPage.apply(this, arguments);
 39 };
 40 
 41 ZmFilterPage.prototype = new ZmPreferencesPage;
 42 ZmFilterPage.prototype.constructor = ZmFilterPage;
 43 
 44 ZmFilterPage.prototype.isZmFilterPage = true;
 45 ZmFilterPage.prototype.toString = function () { return "ZmFilterPage"; };
 46 
 47 ZmFilterPage.prototype._createControls =
 48 function() {
 49 	if (appCtxt.get(ZmSetting.PRIORITY_INBOX_ENABLED)) {
 50 		this._activityStreamsButton = new DwtButton({parent:this, parentElement: this._htmlElId+"_ACTIVITY_STREAM_BUTTON" });
 51 		this._activityStreamsButton.setText(ZmMsg.activityStreamSettings);
 52 		this._activityStreamsButton.addSelectionListener(new AjxListener(this, this._activityStreamDialog));
 53 	}
 54 	this._tabView = new DwtTabView({parent:this, posStyle:Dwt.STATIC_STYLE});
 55 	this._tabView.reparentHtmlElement(this._htmlElId+"_tabview");
 56 	var incomingController = this._controller.getIncomingFilterRulesController();
 57 	this._tabView.addTab(ZmMsg.incomingMessageFilters, incomingController.getFilterRulesView());
 58 	var outgoingController = this._controller.getOutgoingFilterRulesController();
 59 	this._tabView.addTab(ZmMsg.outgoingMessageFilters, outgoingController.getFilterRulesView());
 60 	this.setVisible(true);
 61 	
 62 	this.hasRendered = true;
 63 };
 64 
 65 ZmFilterPage.prototype.reset =
 66 function() {
 67 	ZmPreferencesPage.prototype.reset.apply(this, arguments);
 68 	this._controller._stateChangeListener();
 69 };
 70 
 71 ZmFilterPage.prototype.getTabView =
 72 function () {
 73 	return this._tabView;
 74 };
 75 
 76 ZmFilterPage.prototype.hasResetButton =
 77 function() {
 78 	return false;
 79 };
 80 
 81 
 82 //
 83 // Protected methods
 84 //
 85 
 86 ZmFilterPage.prototype._setupCustom = function(id, setup, value) {
 87 	if (id == "FILTER_TABS") {
 88 		return this.getTabView();
 89 	}
 90 	return ZmPreferencesPage.prototype._setupCustom.apply(this, arguments);
 91 };
 92 
 93 ZmFilterPage.prototype._activityStreamDialog = function() {
 94 	var priorityFilterDialog = appCtxt.getPriorityMessageFilterDialog();
 95 	ZmController.showDialog(priorityFilterDialog);
 96 };
 97