Created
July 25, 2012 20:57
-
-
Save chicks/3178635 to your computer and use it in GitHub Desktop.
Tree Control
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{* | |
/********************************************************************************* | |
* The contents of this file are subject to the SugarCRM Enterprise End User | |
* License Agreement ("License") which can be viewed at | |
* http://www.sugarcrm.com/crm/products/sugar-enterprise-eula.html | |
* By installing or using this file, You have unconditionally agreed to the | |
* terms and conditions of the License, and You may not use this file except in | |
* compliance with the License. Under the terms of the license, You shall not, | |
* among other things: 1) sublicense, resell, rent, lease, redistribute, assign | |
* or otherwise transfer Your rights to the Software, and 2) use the Software | |
* for timesharing or service bureau purposes such as hosting the Software for | |
* commercial gain and/or for the benefit of a third party. Use of the Software | |
* may be subject to applicable fees and any use of the Software without first | |
* paying applicable fees is strictly prohibited. You do not have the right to | |
* remove SugarCRM copyrights from the source code or user interface. | |
* | |
* All copies of the Covered Code must include on each user interface screen: | |
* (i) the "Powered by SugarCRM" logo and | |
* (ii) the SugarCRM copyright notice | |
* in the same form as they appear in the distribution. See full license for | |
* requirements. | |
* | |
* Your Warranty, Limitations of liability and Indemnity are expressly stated | |
* in the License. Please refer to the License for the specific language | |
* governing these rights and limitations under the License. Portions created | |
* by SugarCRM are Copyright (C) 2004-2006 SugarCRM, Inc.; All Rights Reserved. | |
********************************************************************************/ | |
*} | |
<link rel="stylesheet" type="text/css" href="include/javascript/yui/assets/menu.css" /> | |
<link rel="stylesheet" type="text/css" href="modules/Emails/EmailUI.css" /> | |
{include file="modules/Emails/templates/_baseJsVars.tpl"} | |
<script type="text/javascript" src='{sugar_getjspath file='include/javascript/tiny_mce/tiny_mce.js'}'></script> | |
<script type="text/javascript" src='{sugar_getjspath file='include/javascript/sugar_grp_emails.js'}'></script> | |
<script type="text/javascript" src='{sugar_getjspath file='include/javascript/sugar_grp_yui_widgets.js'}'></script> | |
<script type="text/javascript" language="Javascript"> | |
{include file="modules/Emails/templates/_baseConfigData.tpl"} | |
var calFormat = '{$calFormat}'; | |
var theme = "{$theme}"; | |
{$quickSearchForAssignedUser} | |
SUGAR.email2.detailView.qcmodules = {$qcModules}; | |
<!--//BEGIN SUGARCRM flav=pro ONLY --> | |
//SUGAR.email2.composeLayout.teamsSettingsFolder = {$teamsSettingsFolder}; | |
<!--//END SUGARCRM flav=pro ONLY --> | |
var isAdmin = {$is_admin}; | |
var loadingSprite = app_strings.LBL_EMAIL_LOADING + " <img src='include/javascript/yui/build/assets/skins/sam/wait.gif' height='14' align='absmiddle'>"; | |
</script> | |
<div class="email"> | |
<form id="emailUIForm" name="emailUIForm"> | |
<input type="hidden" id="module" name="module" value="Emails"> | |
<input type="hidden" id="action" name="action" value="EmailUIAjax"> | |
<input type="hidden" id="to_pdf" name="to_pdf" value="true"> | |
<input type="hidden" id="emailUIAction" name="emailUIAction"> | |
<input type="hidden" id="mbox" name="mbox"> | |
<input type="hidden" id="uid" name="uid"> | |
<input type="hidden" id="ieId" name="ieId"> | |
<input type="hidden" id="forceRefresh" name="forceRefresh"> | |
<input type="hidden" id="focusFolder" name="focusFolder"> | |
<input type="hidden" id="focusFolderOpen" name="focusFolderOpen"> | |
<input type="hidden" id="sortBy" name="sortBy"> | |
<input type="hidden" id="reverse" name="reverse"> | |
</form> | |
<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div> | |
<table cellpadding="0" cellspacing="0" border="0" width="100%"> | |
<tr> | |
<td NOWRAP style="padding-bottom: 2px;"> | |
<button class="button" id="checkEmailButton" onclick="SUGAR.email2.folders.startEmailAccountCheck();"><img src="themes/default/images/icon_email_check.gif" align="absmiddle" border="0"> {$app_strings.LBL_EMAIL_CHECK}</button> | |
<button class="button" id="composeButton" onclick="SUGAR.email2.composeLayout.c0_composeNewEmail();"><img src="themes/default/images/icon_email_compose.gif" align="absmiddle" border="0"> {$mod_strings.LNK_NEW_SEND_EMAIL}</button> | |
<button class="button" id="settingsButton" onclick="SUGAR.email2.settings.showSettings();"><img src="themes/default/images/icon_email_settings.gif" align="absmiddle" border="0"> {$app_strings.LBL_EMAIL_SETTINGS}</button> | |
</td> | |
<td NOWRAP align="right" style="padding-bottom: 2px;"> | |
<a href="index.php?module=Administration&action=SupportPortal&view=documentation&version={$sugar_version}&edition={$sugar_flavor}&lang={$current_language}&help_module=Emails&help_action=index&key={$server_unique_key}" width='13' height='13' alt='{$app_strings.LNK_HELP}' border='0' align='absmiddle' target="_blank"></a> | |
| |
<a href="index.php?module=Administration&action=SupportPortal&view=documentation&version={$sugar_version}&edition={$sugar_flavor}&lang={$current_language}&help_module=Emails&help_action=index&key={$server_unique_key}" class='utilsLink' target="_blank">{$app_strings.LNK_HELP}</a> | |
</td> | |
</tr> | |
</table> | |
{include file="modules/Emails/templates/overlay.tpl"} | |
<div id="emailContextMenu"></div> | |
<div id="folderContextMenu"></div> | |
<div id="container" class="email" style="position:relative; height:550px; overflow:hidden;"></div> | |
<div id="innerLayout" class="yui-hidden"></div> | |
<div id="listViewLayout" class="yui-hidden"></div> | |
<div id="settingsDialog"></div> | |
<!-- Hidden Content --> | |
<div class="yui-hidden"> | |
<div id="searchTab" style="padding:5px"> | |
{include file="modules/Emails/templates/advancedSearch.tpl"} | |
</div> | |
<div id="settings"> | |
{include file="modules/Emails/templates/emailSettings.tpl"} | |
</div> | |
<div id="footerLinks" class="yui-hidden"></div> | |
<!--//BEGIN SUGARCRM flav=int ONLY --> | |
<div id="todo" class="yui-hidden"> | |
{include file="modules/Emails/templates/_todos.tpl"} | |
</div> | |
<!--//END SUGARCRM flav=int ONLY --> | |
</div> | |
<div id="editContact" class="yui-hidden"></div> | |
<div id="editContactTab" class="yui-hidden"></div> | |
<div id="editMailingList" class="yui-hidden"></div> | |
<div id="editMailingListTab" class="yui-hidden"></div> | |
<!-- for detailView quickCreate() calls --> | |
<div id="quickCreate"></div> | |
<div id="quickCreateContent"></div> | |
<div id="importDialog"></div> | |
<div id="importDialogContent" ></div> | |
<div id="relateDialog" ></div> | |
<div id="relateDialogContent" ></div> | |
<div id="assignmentDialog" ></div> | |
<div id="assignmentDialogContent" ></div> | |
<div id="emailDetailDialog" ></div> | |
<div id="emailDetailDialogContent" ></div> | |
<!-- for detailView views --> | |
<div id="viewDialog"></div> | |
<div id="viewDialogContent"></div> | |
<!-- addressBook select --> | |
{include file="modules/Emails/templates/addressSearchContent.tpl"} | |
<!-- accounts outbound server dialogue --> | |
<div id="outboundDialog" class="yui-hidden"> | |
{include file="modules/Emails/templates/outboundDialog.tpl"} | |
</div> | |
<!-- accounts edit dialogue --> | |
<div id="editAccountDialogue" class="yui-hidden"> | |
{include file="modules/Emails/templates/editAccountDialogue.tpl"} | |
</div> | |
<div id="testOutboundDialog" class="yui-hidden"> | |
{include file="modules/Emails/templates/outboundDialogTest.tpl"} | |
</div> | |
<div id="assignToDiv" class="yui-hidden"> | |
{include file="modules/Emails/templates/assignTo.tpl"} | |
</div> | |
<script type="text/javascript" language="Javascript"> | |
enableQS(true); | |
</script> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/////////////////////////////////////////////////////////////////////// | |
//// FOLDERS & TreeView | |
$this->smarty->assign('groupUserOptions', $ie->getGroupsWithSelectOptions(array('' => $app_strings['LBL_EMAIL_CREATE_NEW']))); | |
$tree = $this->getMailboxNodes(); | |
// preloaded folder | |
$preloadFolder = 'lazyLoadFolder = '; | |
$focusFolderSerial = $current_user->getPreference('focusFolder', 'Emails'); | |
if(!empty($focusFolderSerial)) { | |
$focusFolder = unserialize($focusFolderSerial); | |
//$focusFolder['ieId'], $focusFolder['folder'] | |
$preloadFolder .= json_encode($focusFolder).";"; | |
} else { | |
$preloadFolder .= "new Object();"; | |
} | |
//// END FOLDERS | |
/////////////////////////////////////////////////////////////////////// | |
$out = ""; | |
$out .= $this->smarty->fetch("modules/Emails/templates/_baseEmail.tpl"); | |
$out .= $tree->generate_header(); | |
$out .= $tree->generateNodesNoInit(true, 'email2treeinit'); | |
$out .=<<<eoq | |
<script type="text/javascript" language="javascript"> | |
var loader = new YAHOO.util.YUILoader({ | |
require : [ | |
"layout", "element", "tabview", "menu", | |
"cookie", "sugarwidgets" | |
], | |
loadOptional: true, | |
skin: { base: 'blank', defaultSkin: '' }, | |
onSuccess: email2init, | |
allowRollup: true, | |
base: "include/javascript/yui/build/" | |
}); | |
loader.addModule({ | |
name :"sugarwidgets", | |
type : "js", | |
fullpath: "include/javascript/sugarwidgets/SugarYUIWidgets.js", | |
varName: "YAHOO.SUGAR", | |
requires: ["datatable", "dragdrop", "treeview", "tabview", "calendar"] | |
}); | |
loader.insert(); | |
{$preloadFolder}; | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/********************************************************************************* | |
* The contents of this file are subject to the SugarCRM Professional Subscription | |
* Agreement ("License") which can be viewed at | |
* http://www.sugarcrm.com/crm/products/sugar-professional-eula.html | |
* By installing or using this file, You have unconditionally agreed to the | |
* terms and conditions of the License, and You may not use this file except in | |
* compliance with the License. Under the terms of the license, You shall not, | |
* among other things: 1) sublicense, resell, rent, lease, redistribute, assign | |
* or otherwise transfer Your rights to the Software, and 2) use the Software | |
* for timesharing or service bureau purposes such as hosting the Software for | |
* commercial gain and/or for the benefit of a third party. Use of the Software | |
* may be subject to applicable fees and any use of the Software without first | |
* paying applicable fees is strictly prohibited. You do not have the right to | |
* remove SugarCRM copyrights from the source code or user interface. | |
* | |
* All copies of the Covered Code must include on each user interface screen: | |
* (i) the "Powered by SugarCRM" logo and | |
* (ii) the SugarCRM copyright notice | |
* in the same form as they appear in the distribution. See full license for | |
* requirements. | |
* | |
* Your Warranty, Limitations of liability and Indemnity are expressly stated | |
* in the License. Please refer to the License for the specific language | |
* governing these rights and limitations under the License. Portions created | |
* by SugarCRM are Copyright (C) 2004-2011 SugarCRM, Inc.; All Rights Reserved. | |
********************************************************************************/ | |
/****************************************************************************** | |
* Initialize Email 2.0 Application | |
*/ | |
//Override Sugar Languge so quick creates work properly | |
function email2init() { | |
//Init Tiny MCE | |
// var tinyConfig = "code,bold,italic,underline,strikethrough,separator,justifyleft,justifycenter,justifyright,justifyfull," + | |
// "separator,bullist,numlist,outdent,indent,separator,forecolor,backcolor,fontselect,fontsizeselect"; | |
if (!SUGAR.util.isTouchScreen()) { | |
tinyMCE.init({ | |
convert_urls : false, | |
theme_advanced_toolbar_align : tinyConfig.theme_advanced_toolbar_align, | |
width: tinyConfig.width, | |
theme: tinyConfig.theme, | |
theme_advanced_toolbar_location : tinyConfig.theme_advanced_toolbar_location, | |
theme_advanced_buttons1 : tinyConfig.theme_advanced_buttons1, | |
theme_advanced_buttons2 : tinyConfig.theme_advanced_buttons2, | |
theme_advanced_buttons3 : tinyConfig.theme_advanced_buttons3, | |
plugins : tinyConfig.plugins, | |
elements : tinyConfig.elements, | |
language : tinyConfig.language, | |
extended_valid_elements : tinyConfig.extended_valid_elements, | |
mode: tinyConfig.mode, | |
strict_loading_mode : true, | |
force_br_newlines : true, | |
forced_root_block : '' | |
}); | |
} | |
//alert('loadedTiny'); | |
// initialze message overlay | |
SUGAR.email2.e2overlay = new YAHOO.widget.Dialog("SUGAR.email2.e2overlay", { | |
//iframe : true, | |
modal : false, | |
autoTabs : true, | |
width : 300, | |
height : 120, | |
shadow : true | |
} | |
); | |
// Hide Sugar menu | |
if (SUGAR.themes.tempHideLeftCol) | |
SUGAR.themes.tempHideLeftCol(); | |
// add key listener for kb shortcust - disable backspace nav in mozilla/ie | |
// YAHOO.util.Event.addListener(window.document, 'keypress', SUGAR.email2.keys.overall); | |
// set defaults for YAHOO.util.DragDropManager | |
YAHOO.util.DDM.mode = 0; // point mode, default is point (0) | |
SUGAR.email2.nextYear = new Date(); | |
SUGAR.email2.nextYear.setDate(SUGAR.email2.nextYear.getDate() + 360); | |
// initialize and display UI framework (complexLayout.js) | |
complexLayoutInit(); | |
// initialize and display grid (grid.js) | |
gridInit(); | |
// initialize treeview for folders | |
//onloadTreeinit(); | |
SUGAR.email2.folders.rebuildFolders(true); | |
//SUGAR.email2.folders.retrieveTeamInfo(); | |
//Setup the Message Box overlay | |
/*Ext.MessageBox.maxWidth = 350; | |
Ext.MessageBox.minProgressWidth = 350; | |
/////////////////////////////////////////////////////////////////////////// | |
//// CONTEXT MENUS | |
// detailView array | |
SUGAR.email2.contextMenus.detailViewContextMenus = new Object(); | |
*/ | |
var SEC = SUGAR.email2.contextMenus; | |
//Grid menu | |
var emailMenu = SEC.emailListContextMenu = new YAHOO.widget.ContextMenu("emailContextMenu", { | |
trigger: SUGAR.email2.grid.get("element"), | |
lazyload: true | |
}); | |
emailMenu.subscribe("beforeShow", function() { | |
var oTarget = this.contextEventTarget; | |
if (typeof(oTarget) == "undefined") | |
return; | |
var grid = SUGAR.email2.grid; | |
var selectedRows = grid.getSelectedRows(); | |
var multipleSelected = (selectedRows.length > 1) ? true: false; | |
if (!multipleSelected) | |
{ | |
grid.unselectAllRows(); | |
grid.selectRow(oTarget); | |
SUGAR.email2.contextMenus.showEmailsListMenu(grid, grid.getRecord(oTarget)); | |
} | |
else if(multipleSelected) | |
{ | |
SUGAR.email2.contextMenus.showEmailsListMenu(grid, grid.getRecord(oTarget)); | |
} | |
}); | |
//When we need to access menu items later we can only do so by indexes so we create a mapping to allow | |
//us to access individual elements easier by name rather than by index | |
emailMenu.itemsMapping = {'viewRelationships':0, 'openMultiple': 1, 'archive' : 2, 'reply' : 3,'replyAll' : 4,'forward' : 5, | |
'delete' : 6,'print' : 7,'mark' : 8,'assignTo' : 9, 'relateTo' : 10}; | |
emailMenu.addItems([ | |
{ | |
text: "<img src='index.php?entryPoint=getImage&themeName="+SUGAR.themes.theme_name+"&imageName=icon_email_relate.gif'/>" + app_strings.LBL_EMAIL_VIEW_RELATIONSHIPS, | |
id: 'showDetailView', | |
onclick: { fn: SEC.showDetailView } | |
}, | |
{ | |
text: "<img src='index.php?entryPoint=getImage&themeName="+SUGAR.themes.theme_name+"&imageName=open_multiple.gif'/>" + app_strings.LBL_EMAIL_OPEN_ALL, | |
onclick: { fn: SEC.openMultiple } | |
}, | |
{ | |
text: "<img src='index.php?entryPoint=getImage&themeName="+SUGAR.themes.theme_name+"&imageName=icon_email_archive.gif'/>" + app_strings.LBL_EMAIL_ARCHIVE_TO_SUGAR, | |
onclick: { fn: SEC.archiveToSugar } | |
}, | |
{ | |
text: "<img src='index.php?entryPoint=getImage&themeName="+SUGAR.themes.theme_name+"&imageName=icon_email_reply.gif'/>"+ app_strings.LBL_EMAIL_REPLY, | |
id: 'reply', | |
onclick: { fn: SEC.replyForwardEmailContext } | |
}, | |
{ | |
text: "<img src='index.php?entryPoint=getImage&themeName="+SUGAR.themes.theme_name+"&imageName=icon_email_replyall.gif'/>" + app_strings.LBL_EMAIL_REPLY_ALL, | |
id: 'replyAll', | |
onclick: { fn: SEC.replyForwardEmailContext } | |
}, | |
{ | |
text: "<img src='index.php?entryPoint=getImage&themeName="+SUGAR.themes.theme_name+"&imageName=icon_email_forward.gif'/>" + app_strings.LBL_EMAIL_FORWARD, | |
id: 'forward', | |
onclick: { fn: SEC.replyForwardEmailContext } | |
}, | |
{ | |
text: "<img src='index.php?entryPoint=getImage&themeName="+SUGAR.themes.theme_name+"&imageName=icon_email_delete.gif'/>" + app_strings.LBL_EMAIL_DELETE, | |
id: 'delete', | |
onclick: { fn: SEC.markDeleted } | |
}, | |
{ | |
text: "<img src='themes/default/images/Print_Email.gif'/>" + app_strings.LBL_EMAIL_PRINT, | |
id: 'print', | |
onclick: { fn: SEC.viewPrintable } | |
}, | |
// Mark... submenu | |
{ | |
text: "<img src='index.php?entryPoint=getImage&themeName="+SUGAR.themes.theme_name+"&imageName=icon_email_mark.gif'/>" + app_strings.LBL_EMAIL_MARK, | |
submenu: { | |
id: "markEmailMenu", | |
itemdata : [ | |
{ | |
text: app_strings.LBL_EMAIL_MARK + " " + app_strings.LBL_EMAIL_MARK_UNREAD, | |
onclick: { fn: SEC.markUnread } | |
}, | |
{ | |
text: app_strings.LBL_EMAIL_MARK + " " + app_strings.LBL_EMAIL_MARK_READ, | |
onclick: { fn: SEC.markRead } | |
}, | |
{ | |
text: app_strings.LBL_EMAIL_MARK + " " + app_strings.LBL_EMAIL_MARK_FLAGGED, | |
onclick: { fn: SEC.markFlagged } | |
}, | |
{ | |
text: app_strings.LBL_EMAIL_MARK + " " + app_strings.LBL_EMAIL_MARK_UNFLAGGED, | |
onclick: { fn: SEC.markUnflagged } | |
} | |
] | |
} | |
}, | |
{ | |
text: "<img src='index.php?entryPoint=getImage&themeName="+SUGAR.themes.theme_name+"&imageName=icon_email_assign.gif'/>" + app_strings.LBL_EMAIL_ASSIGN_TO, | |
id: 'assignTo', | |
onclick: { fn: SEC.assignEmailsTo } | |
}, | |
{ | |
text: "<img src='index.php?entryPoint=getImage&themeName="+SUGAR.themes.theme_name+"&imageName=icon_email_relate.gif'/>" + app_strings.LBL_EMAIL_RELATE_TO, | |
id: 'relateTo', | |
onclick: { fn: SEC.relateTo } | |
} | |
]); | |
SEC.emailListContextMenu.render(); | |
//Handle the Tree folder menu trigger ourselves | |
YAHOO.util.Event.addListener(YAHOO.util.Dom.get("emailtree"), "contextmenu", SUGAR.email2.folders.handleRightClick) | |
//Folder Menu | |
SEC.frameFoldersContextMenu = new YAHOO.widget.ContextMenu("folderContextMenu", { | |
trigger: "", | |
lazyload: true | |
}); | |
SEC.frameFoldersContextMenu.addItems([ | |
{ text: "<img src='index.php?entryPoint=getImage&themeName="+SUGAR.themes.theme_name+"&imageName=icon_email_check.gif'/>" + app_strings.LBL_EMAIL_CHECK, | |
//helptext: "<i>" + app_strings.LBL_EMAIL_MENU_HELP_ADD_FOLDER + "</i>", | |
onclick: { fn: function() { | |
var node = SUGAR.email2.clickedFolderNode; | |
if (node.data.ieId) { | |
SUGAR.email2.folders.startEmailCheckOneAccount(node.data.ieId, false)}; | |
}} | |
}, | |
{ text: app_strings.LBL_EMAIL_MENU_SYNCHRONIZE, | |
//helptext: "<i>" + app_strings.LBL_EMAIL_MENU_HELP_ADD_FOLDER + "</i>", | |
onclick: { fn: function() { | |
var node = SUGAR.email2.clickedFolderNode; | |
if (node.data.ieId) { | |
SUGAR.email2.folders.startEmailCheckOneAccount(node.data.ieId, true)}; | |
}} | |
}, | |
{ | |
text: app_strings.LBL_EMAIL_MENU_ADD_FOLDER, | |
//helptext: "<i>" + app_strings.LBL_EMAIL_MENU_HELP_ADD_FOLDER + "</i>", | |
onclick: { fn: SUGAR.email2.folders.folderAdd } | |
}, | |
{ | |
text: app_strings.LBL_EMAIL_MENU_DELETE_FOLDER, | |
//helptext: "<i>" + app_strings.LBL_EMAIL_MENU_HELP_DELETE_FOLDER + "</i>", | |
onclick: { fn: SUGAR.email2.folders.folderDelete } | |
}, | |
{ | |
text: app_strings.LBL_EMAIL_MENU_RENAME_FOLDER, | |
//helptext: "<i>" + app_strings.LBL_EMAIL_MENU_HELP_RENAME_FOLDER + "</i>", | |
onclick: { fn: SUGAR.email2.folders.folderRename } | |
}, | |
{ | |
text: app_strings.LBL_EMAIL_MENU_EMPTY_TRASH, | |
//helptext: "<i>" + app_strings.LBL_EMAIL_MENU_HELP_EMPTY_TRASH + "</i>", | |
onclick: { fn: SUGAR.email2.folders.emptyTrash } | |
}, | |
{ | |
text: app_strings.LBL_EMAIL_MENU_CLEAR_CACHE, | |
onclick: { fn: function() { | |
var node = SUGAR.email2.clickedFolderNode; | |
if (node.data.ieId) { | |
SUGAR.email2.folders.clearCacheFiles(node.data.ieId)}; | |
}} | |
} | |
]); | |
SEC.frameFoldersContextMenu.render(); | |
SEC.initContactsMenu = function() { | |
// contacts | |
SEC.contactsContextMenu = new YAHOO.widget.ContextMenu("contactsMenu", { | |
trigger: "contacts", | |
lazyload: true | |
}); | |
SEC.contactsContextMenu.addItems([ | |
{ | |
text: app_strings.LBL_EMAIL_MENU_REMOVE, | |
onclick:{ fn: SUGAR.email2.addressBook.removeContact } | |
}, | |
{ | |
text: app_strings.LBL_EMAIL_MENU_COMPOSE, | |
onclick:{ fn: function() {SUGAR.email2.addressBook.composeTo('contacts')}} | |
} | |
]); | |
SEC.contactsContextMenu.subscribe("beforeShow", function() { | |
var oTarget = this.contextEventTarget, grid = SUGAR.email2.contactView; | |
if (oTarget && !grid.isSelected(oTarget)) { | |
grid.unselectAllRows(); | |
grid.selectRow(oTarget); | |
} | |
}); | |
SEC.contactsContextMenu.render(); | |
} | |
SEC.initListsMenu = function() { | |
// contact mailing lists | |
SEC.mailingListContextMenu = new YAHOO.widget.ContextMenu("listsMenu", { | |
trigger: "lists", | |
lazyload: true | |
}); | |
SEC.mailingListContextMenu.addItems([ | |
{ | |
text: app_strings.LBL_EMAIL_MENU_REMOVE, | |
onclick:{ fn: SUGAR.email2.addressBook.removeMailingList } | |
}, | |
{ | |
text: app_strings.LBL_EMAIL_MENU_COMPOSE, | |
onclick:{ fn:function() {SUGAR.email2.addressBook.composeTo('lists')} } | |
}, | |
{ | |
text: app_strings.LBL_EMAIL_MENU_RENAME, | |
onclick:{ fn: function() { overlay(app_strings.LBL_EMAIL_LIST_RENAME_TITLE, app_strings.LBL_EMAIL_LIST_RENAME_DESC, | |
'prompt', {fn: SUGAR.email2.addressBook.renameMailingList}); } } | |
} | |
]); | |
SEC.mailingListContextMenu.subscribe("beforeShow", function() { | |
var oTarget = this.contextEventTarget, grid = SUGAR.email2.emailListsView; | |
if (oTarget && !grid.isSelected(oTarget)) { | |
grid.unselectAllRows(); | |
grid.selectRow(oTarget); | |
} | |
}); | |
SEC.mailingListContextMenu.render(); | |
} | |
// set auto-check timer | |
SUGAR.email2.folders.startCheckTimer(); | |
// check if we're coming from an email-link click | |
setTimeout("SUGAR.email2.composeLayout.composePackage()", 2000); | |
YAHOO.util.Event.on(window, 'resize', SUGAR.email2.autoSetLayout); | |
//Init fix for YUI 2.7.0 datatable sort. | |
SUGAR.email2.addressBook.initFixForDatatableSort(); | |
} | |
function createTreePanel(treeData, params) { | |
var tree = new YAHOO.widget.TreeView(params.id); | |
var root = tree.getRoot(); | |
//if (treeData.nodes && treeData[0].id == "Home") | |
// treeData = treeData[0]; | |
addChildNodes(root, treeData); | |
return tree; | |
} | |
function addChildNodes(parentNode, parentData) { | |
var Ck = YAHOO.util.Cookie; | |
var nextyear = SUGAR.email2.nextYear; | |
var nodes = parentData.nodes || parentData.children; | |
for (i in nodes) { | |
if (typeof(nodes[i]) == 'object') { | |
if (nodes[i].data) { | |
nodes[i].data.href = '#'; | |
var node = new YAHOO.widget.TextNode(nodes[i].data, parentNode) | |
node.action = nodes[i].data.action; | |
} else { | |
if (nodes[i].id == SUGAR.language.get('app_strings','LBL_EMAIL_HOME_FOLDER')) { | |
addChildNodes(parentNode, nodes[i]); | |
return; | |
} | |
nodes[i].expanded = Ck.getSub("EmailTreeLayout", nodes[i].id + "") == "true"; | |
Ck.setSub("EmailTreeLayout", nodes[i].id + "", nodes[i].expanded ? true : false, {expires: SUGAR.email2.nextYear}); | |
if (nodes[i].cls) { | |
nodes[i].className = nodes[i].cls; | |
} | |
nodes[i].href = "#"; | |
if (nodes[i].text) nodes[i].label = nodes[i].text; | |
//Override YUI child node creation | |
if (nodes[i].children) { | |
nodes[i].nodes = nodes[i].children; | |
nodes[i].children = [ ]; | |
} | |
var node = new YAHOO.widget.TextNode(nodes[i], parentNode); | |
} | |
if (typeof(nodes[i].nodes) == 'object') { | |
addChildNodes(node, nodes[i]); | |
} | |
} | |
} | |
} | |
/** | |
* Custom TreeView initialization sequence to setup DragDrop targets for every tree node | |
*/ | |
function email2treeinit(tree, treedata, treediv, params) { | |
//ensure the tree data is not corrupt | |
if (!treedata) { | |
return; | |
} | |
if (SUGAR.email2.tree) { | |
SUGAR.email2.tree.destroy(); | |
SUGAR.email2.tree = null; | |
} | |
var tree = SUGAR.email2.tree = createTreePanel({nodes : {}}, { | |
id: 'emailtree' | |
}); | |
tree.subscribe("clickEvent", SUGAR.email2.folders.handleClick); | |
tree.subscribe("collapseComplete", function(node){YAHOO.util.Cookie.setSub("EmailTreeLayout", node.data.id + "", false, {expires: SUGAR.email2.nextYear});}); | |
tree.subscribe("expandComplete", function(node){ | |
YAHOO.util.Cookie.setSub("EmailTreeLayout", node.data.id + "", true, {expires: SUGAR.email2.nextYear}); | |
for (var i in node.children) { | |
SE.accounts.setupDDTarget(node.children[i]); | |
} | |
}); | |
tree.setCollapseAnim("TVSlideOut"); | |
tree.setExpandAnim("TVSlideIn"); | |
var root = tree.root; | |
while (root.hasChildren()) { | |
var node = root.children[0]; | |
node.destroy(); | |
tree.removeNode(root.children[0], false); | |
} | |
addChildNodes(root, treedata); | |
tree.render(); | |
SUGAR.email2.accounts.renderTree(); | |
} | |
SUGAR.email2.folders.folderDD = function(id, sGroup, config) { | |
SUGAR.email2.folders.folderDD.superclass.constructor.call(this, id, sGroup, config); | |
}; | |
YAHOO.extend(SUGAR.email2.folders.folderDD, YAHOO.util.DDProxy, { | |
startDrag: function(x, y) { | |
var Dom = YAHOO.util.Dom; | |
this.dragNode = SUGAR.email2.tree.getNodeByElement(this.getEl()); | |
this.dragId = ""; | |
var dragEl = this.getDragEl(); | |
var clickEl = this.getEl(); | |
Dom.setStyle(clickEl, "color", "#AAA"); | |
Dom.setStyle(clickEl, "opacity", "0.25"); | |
dragEl.innerHTML = clickEl.innerHTML; | |
Dom.addClass(dragEl, "ygtvcell"); | |
Dom.addClass(dragEl, "ygtvcontent"); | |
Dom.addClass(dragEl, "folderDragProxy"); | |
Dom.setStyle(dragEl, "height", (clickEl.clientHeight - 5) + "px"); | |
Dom.setStyle(dragEl, "width", (clickEl.clientWidth - 5) + "px"); | |
Dom.setStyle(dragEl, "backgroundColor", "#FFF"); | |
Dom.setStyle(dragEl, "opacity", "0.5"); | |
Dom.setStyle(dragEl, "border", "1px solid #AAA"); | |
}, | |
onDragOver: function(ev, id) { | |
var Dom = YAHOO.util.Dom; | |
if (id != this.dragId) | |
{ | |
var node = SUGAR.email2.tree.getNodeByElement(YAHOO.util.Dom.get(id)); | |
if(node.data.cls != "sugarFolder") { | |
SUGAR.email2.folders.unhighliteAll(); | |
return; | |
} | |
this.dragId = id; | |
this.targetNode = node; | |
SUGAR.email2.folders.unhighliteAll(); | |
node.highlight(); | |
} | |
}, | |
onDragOut: function(e, id) { | |
if (this.targetNode) { | |
SUGAR.email2.folders.unhighliteAll(); | |
this.targetNode = false; | |
this.dragId = false; | |
} | |
}, | |
endDrag: function() { | |
YAHOO.util.Dom.setStyle(this.getEl(), "opacity", "1.0"); | |
if (this.targetNode) { | |
SUGAR.email2.folders.moveFolder(this.dragNode.data.id, this.targetNode.data.id); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment