1 /*********************************************************************************
2 * SugarCRM is a customer relationship management program developed by
3 * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU Affero General Public License version 3 as published by the
7 * Free Software Foundation with the addition of the following permission added
8 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
9 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
10 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
17 * You should have received a copy of the GNU Affero General Public License along with
18 * this program; if not, see http://www.gnu.org/licenses or write to the Free
19 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
23 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
25 * The interactive user interfaces in modified source and object code versions
26 * of this program must display Appropriate Legal Notices, as required under
27 * Section 5 of the GNU Affero General Public License version 3.
29 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
30 * these Appropriate Legal Notices must retain the display of the "Powered by
31 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
32 * technical reasons, the Appropriate Legal Notices must display the words
33 * "Powered by SugarCRM".
34 ********************************************************************************/
39 function complexLayoutInit() {
40 var se = SUGAR.email2;
41 var Dom = YAHOO.util.Dom;
43 getInnerLayout : function(rows) {
44 se.listViewLayout = new YAHOO.widget.Layout('listViewDiv', {
45 parent: se.complexLayout,
51 scroll:false, // grid should autoScroll itself
53 body: "<div id='emailGrid'></div><div id='dt-pag-nav'></div> "
61 body: "<div id='listBottom' />"
69 body: "<div id='listRight' />",
70 titlebar: false //,header: "right"
73 se.complexLayout.on("render", function(){
74 var height = SUGAR.email2.innerLayout.get("element").clientHeight - 30;
75 SUGAR.email2.innerLayout.get("activeTab").get("contentEl").parentNode.style.height = height + "px";
76 SUGAR.email2.listViewLayout.set("height", height);
77 SUGAR.email2.listViewLayout.render();
79 se.listViewLayout.render();
81 se.listViewLayout.get("element").parentNode.parentNode.style.padding = "0px"
82 var rp = se.listViewLayout.resizePreview = function() {
83 var pre = Dom.get("displayEmailFramePreview");
85 var parent = Dom.getAncestorByClassName(pre, "yui-layout-bd");
86 pre.style.height = (parent.clientHeight - pre.offsetTop) + "px";
89 se.listViewLayout.getUnitByPosition("bottom").on("heightChange", se.autoSetLayout);
90 se.listViewLayout.getUnitByPosition("right").on("endResize", se.autoSetLayout);
91 se.e2Layout.setPreviewPanel(rows);
92 se.previewLayout = se.listViewLayout;
93 return se.listViewLayout;
96 getInnerLayout2Rows : function() {
97 return this.getInnerLayout(true);
99 getInnerLayout2Columns : function() {
100 return this.getInnerLayout(false);
104 // initialize state manager, we will use cookies
105 // Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
106 var viewHeight = document.documentElement ? document.documentElement.clientHeight : self.innerHeight;
107 se.complexLayout = new YAHOO.widget.Layout("container", {
110 height: Dom.getViewportHeight() - (document.getElementById('header').clientHeight ) - 65,
111 width: Dom.getViewportWidth() - 40,
115 body: "<div id='emailtabs'></div>"
120 body: "<div id='lefttabs'></div>",
130 header: Dom.get('footerLinks').innerHTML,
137 se.complexLayout.render();
138 var tp = se.innerLayout = new YAHOO.widget.TabView("emailtabs");
139 tp.addTab(new YAHOO.widget.Tab({
142 content : "<div id='listViewDiv'/>",
146 var centerEl = se.complexLayout.getUnitByPosition('center').get('wrap');
147 tp.appendTo(centerEl);
149 tp.get("element").style.borderRight = "1px solid #666"
151 var listV = this.getInnerLayout2Rows();
152 listV.set("height", tp.get("element").clientHeight - 25);
155 se.leftTabs = new YAHOO.widget.TabView("lefttabs");
156 var folderTab = new YAHOO.widget.Tab({
157 label: app_strings.LBL_EMAIL_FOLDERS_SHORT,
159 content : "<div id='emailtree'/>",
163 folderTab.on("activeChange", function(o){
165 se.complexLayout.getUnitByPosition("left").set("header", app_strings.LBL_EMAIL_FOLDERS);
168 se.leftTabs.addTab(folderTab);
170 var tabContent = SUGAR.util.getAndRemove("searchTab");
171 var searchTab = new YAHOO.widget.Tab({
172 label: app_strings.LBL_EMAIL_SEARCH_SHORT,
174 content : tabContent.innerHTML,
177 searchTab.on("activeChange", function(o){
180 se.complexLayout.getUnitByPosition("left").set("header", app_strings.LBL_EMAIL_SEARCH);
181 //Setup the calendars if needed
182 Calendar.setup ({inputField : "searchDateFrom", ifFormat : calFormat, showsTime : false, button : "searchDateFrom_trigger", singleClick : true, step : 1, weekNumbers:false});
183 Calendar.setup ({inputField : "searchDateTo", ifFormat : calFormat, showsTime : false, button : "searchDateTo_trigger", singleClick : true, step : 1, weekNumbers:false});
185 //Initalize sqs object for assigned user name
186 se.e2Layout.initSQSObject('advancedSearchForm','assigned_user_name');
188 //Attach event handler for when the relate module option is selected for the correct sqs object
189 var parentSearchArgs = {'formName':'advancedSearchForm','fieldName':'data_parent_name_search',
190 'moduleSelectField':'data_parent_type_search','fieldId':'data_parent_id_search'};
191 YAHOO.util.Event.addListener('data_parent_type_search', 'change',function(){
192 SUGAR.email2.composeLayout.enableQuickSearchRelate(null,parentSearchArgs) });
194 //If enter key is pressed, perform search
195 var addKeyPressFields = ['searchSubject','searchFrom','searchTo','data_parent_name_search','searchDateTo','searchDateFrom','attachmentsSearch','assigned_user_name'];
196 for(var i=0; i < addKeyPressFields.length;i++)
198 YAHOO.util.Event.addListener(window.document.forms['advancedSearchForm'].elements[addKeyPressFields[i]],"keydown", function(e){
199 if (e.keyCode == 13) {
200 YAHOO.util.Event.stopEvent(e);
201 SUGAR.email2.search.searchAdvanced();
205 //Initiate quick search for the search tab. Do this only when the tab is selected rather than onDomLoad for perf. gains.
207 //Clear parent values if selecting another parent type.
208 YAHOO.util.Event.addListener('data_parent_type_search','change',
210 document.getElementById('data_parent_id_search').value ='';
211 document.getElementById('data_parent_name_search').value ='';
216 se.leftTabs.addTab(searchTab);
218 var resizeTabBody = function() {
219 var height = SUGAR.email2.leftTabs.get("element").clientHeight - 30;
220 SUGAR.email2.leftTabs.get("activeTab").get("contentEl").parentNode.style.height = height + "px";
223 se.complexLayout.on("render", resizeTabBody);
224 se.leftTabs.on("activeTabChange", resizeTabBody);
225 //hack to allow left pane scroll bar to fully show
226 var lefttabsDiv = document.getElementById('lefttabs');
227 var lefttabsDivParent = Dom.getAncestorBy(lefttabsDiv);
228 var lefttabsDivGParent = Dom.getAncestorBy(lefttabsDivParent);
229 lefttabsDivParent.style.width = lefttabsDivGParent.offsetWidth - 10 + "px";
232 initSQSObject: function(formName,fieldName)
234 var fullFieldName = formName + '_' + fieldName; //SQS Convention
235 var resultName = fullFieldName + '_' + 'results';
237 if (QSFieldsArray[fullFieldName] != null)
239 QSFieldsArray[fullFieldName].destroy();
240 delete QSFieldsArray[fullFieldName];
242 if (QSProcessedFieldsArray[fullFieldName])
243 QSProcessedFieldsArray[fullFieldName] = false;
245 if( Dom.get(resultName) )
247 var obj = document.getElementById(resultName);
248 obj.parentNode.removeChild(obj);
251 setPreviewPanel: function(rows) {
253 SUGAR.email2.listViewLayout.getUnitByPosition("right").set("width", 0);
254 SUGAR.email2.listViewLayout.getUnitByPosition("bottom").set("height", 250);
255 Dom.get("listRight").innerHTML = "";
256 Dom.get("listBottom").innerHTML = "<div id='_blank' />";
258 SUGAR.email2.listViewLayout.getUnitByPosition("bottom").set("height", 0);
259 SUGAR.email2.listViewLayout.getUnitByPosition("right").set("width", 250);
260 Dom.get("listBottom").innerHTML = "";
261 Dom.get("listRight").innerHTML = "<div id='_blank' />";
268 var myBufferedListenerObject = new Object();
269 myBufferedListenerObject.refit = function() {
270 if(SUGAR.email2.grid) {
271 SUGAR.email2.grid.autoSize();