1 /*********************************************************************************
2 * SugarCRM Community Edition is a customer relationship management program developed by
3 * SugarCRM, Inc. Copyright (C) 2004-2012 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 var viewHeight = document.documentElement ? document.documentElement.clientHeight : self.innerHeight;
106 var heightOffset = $('#dcmenu').length > 0 ? $('#dcmenu').height() : $('#header').height();
107 se.complexLayout = new YAHOO.widget.Layout("container", {
110 height: Dom.getViewportHeight() - heightOffset - 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);
154 tp.on("activeTabChange", function ()
156 se.complexLayout.resize();
159 se.leftTabs = new YAHOO.widget.TabView("lefttabs");
160 var folderTab = new YAHOO.widget.Tab({
161 label: app_strings.LBL_EMAIL_FOLDERS_SHORT,
163 content : "<div id='emailtree'/>",
167 folderTab.on("activeChange", function(o){
169 se.complexLayout.getUnitByPosition("left").set("header", app_strings.LBL_EMAIL_FOLDERS);
172 se.leftTabs.addTab(folderTab);
174 var tabContent = SUGAR.util.getAndRemove("searchTab");
175 var searchTab = new YAHOO.widget.Tab({
176 label: app_strings.LBL_EMAIL_SEARCH_SHORT,
178 content : tabContent.innerHTML,
181 searchTab.on("activeChange", function(o){
184 se.complexLayout.getUnitByPosition("left").set("header", app_strings.LBL_EMAIL_SEARCH);
185 //Setup the calendars if needed
186 Calendar.setup ({inputField : "searchDateFrom", ifFormat : calFormat, showsTime : false, button : "searchDateFrom_trigger", singleClick : true, step : 1, weekNumbers:false});
187 Calendar.setup ({inputField : "searchDateTo", ifFormat : calFormat, showsTime : false, button : "searchDateTo_trigger", singleClick : true, step : 1, weekNumbers:false});
189 //Initalize sqs object for assigned user name
190 se.e2Layout.initSQSObject('advancedSearchForm','assigned_user_name');
192 //Attach event handler for when the relate module option is selected for the correct sqs object
193 var parentSearchArgs = {'formName':'advancedSearchForm','fieldName':'data_parent_name_search',
194 'moduleSelectField':'data_parent_type_search','fieldId':'data_parent_id_search'};
195 YAHOO.util.Event.addListener('data_parent_type_search', 'change',function(){
196 SUGAR.email2.composeLayout.enableQuickSearchRelate(null,parentSearchArgs) });
198 //If enter key is pressed, perform search
199 var addKeyPressFields = ['searchSubject','searchFrom','searchTo','data_parent_name_search','searchDateTo','searchDateFrom','attachmentsSearch','assigned_user_name'];
200 for(var i=0; i < addKeyPressFields.length;i++)
202 YAHOO.util.Event.addListener(window.document.forms['advancedSearchForm'].elements[addKeyPressFields[i]],"keydown", function(e){
203 if (e.keyCode == 13) {
204 YAHOO.util.Event.stopEvent(e);
205 SUGAR.email2.search.searchAdvanced();
209 //Initiate quick search for the search tab. Do this only when the tab is selected rather than onDomLoad for perf. gains.
211 //Clear parent values if selecting another parent type.
212 YAHOO.util.Event.addListener('data_parent_type_search','change',
214 document.getElementById('data_parent_id_search').value ='';
215 document.getElementById('data_parent_name_search').value ='';
220 se.leftTabs.addTab(searchTab);
222 var resizeTabBody = function() {
223 var height = SUGAR.email2.leftTabs.get("element").clientHeight - 30;
224 SUGAR.email2.leftTabs.get("activeTab").get("contentEl").parentNode.style.height = height + "px";
227 se.complexLayout.on("render", resizeTabBody);
228 se.leftTabs.on("activeTabChange", resizeTabBody);
229 //hack to allow left pane scroll bar to fully show
230 var lefttabsDiv = document.getElementById('lefttabs');
231 var lefttabsDivParent = Dom.getAncestorBy(lefttabsDiv);
232 var lefttabsDivGParent = Dom.getAncestorBy(lefttabsDivParent);
233 lefttabsDivParent.style.width = lefttabsDivGParent.offsetWidth - 10 + "px";
236 initSQSObject: function(formName,fieldName)
238 var fullFieldName = formName + '_' + fieldName; //SQS Convention
239 var resultName = fullFieldName + '_' + 'results';
241 if (QSFieldsArray[fullFieldName] != null)
243 QSFieldsArray[fullFieldName].destroy();
244 delete QSFieldsArray[fullFieldName];
246 if (QSProcessedFieldsArray[fullFieldName])
247 QSProcessedFieldsArray[fullFieldName] = false;
249 if( Dom.get(resultName) )
251 var obj = document.getElementById(resultName);
252 obj.parentNode.removeChild(obj);
255 setPreviewPanel: function(rows) {
257 SUGAR.email2.listViewLayout.getUnitByPosition("right").set("width", 0);
258 SUGAR.email2.listViewLayout.getUnitByPosition("bottom").set("height", 250);
259 Dom.get("listRight").innerHTML = "";
260 Dom.get("listBottom").innerHTML = "<div id='_blank' />";
262 SUGAR.email2.listViewLayout.getUnitByPosition("bottom").set("height", 0);
263 SUGAR.email2.listViewLayout.getUnitByPosition("right").set("width", 250);
264 Dom.get("listBottom").innerHTML = "";
265 Dom.get("listRight").innerHTML = "<div id='_blank' />";
272 var myBufferedListenerObject = new Object();
273 myBufferedListenerObject.refit = function() {
274 if(SUGAR.email2.grid) {
275 SUGAR.email2.grid.autoSize();