Change mail display layout, and apply click on expand for url-email instead of tagist. Additionally, build an extra function for url-email expand on click

This commit is contained in:
Hadi Nategh 2014-02-04 12:51:15 +00:00
parent c9da3b7dfd
commit 4cce431c6f
2 changed files with 127 additions and 74 deletions

View File

@ -107,6 +107,7 @@ app.classes.mail = AppJS.extend(
case 'mail.display':
this.mail_isMainWindow = false;
isDisplay=true;
this.mail_display();
break;
case 'mail.compose':
this.mail_isMainWindow = false;
@ -503,6 +504,109 @@ app.classes.mail = AppJS.extend(
}
},
/**
* Create an expand on click box
*
* @param {object} _expContent an object with at least these elements
* {build_children, data_one, data, widget, line}
*
* @param {object} _dataElem includes data of the widget which need to be expand
*
* @return _dataElem content of widgets
*/
url_email_expandOnClick: function (_expContent, _dataElem)
{
for(var j = 0; j < _expContent.length; j++)
{
var field = _expContent[j] || [];
var content = _dataElem.data[field.data] || [];
// Add in single address, if there
if(typeof field.data_one != 'undefined')
{
content.unshift(_dataElem.data[field.data_one]);
// Unique
content = content.filter(function(value, index, self) {
return self.indexOf(value) === index;
});
}
// Disable whole box if there are none
var line = this.et2.getWidgetById(field.line);
if(line != null) line.set_disabled(content.length == 0);
var widget = this.et2.getWidgetById(field.widget);
if(widget == null) continue;
$j(widget.getDOMNode()).removeClass('visible');
// Programatically build the child elements
if(field.build_children)
{
// Remove any existing
var children = widget.getChildren();
for(var i = children.length-1; i >= 0; i--)
{
children[i].destroy();
widget.removeChild(children[i]);
}
// Add for current record
for(var i = 0; i < content.length; i++)
{
var value = content[i];
var email = et2_createWidget('url-email',{value:value,readonly:true},widget);
email.loadingFinished();
}
}
else
{
widget.set_value({content: content});
}
// Show or hide button, as needed
line.iterateOver(function(button) {
// Avoid binding to any child buttons
if(button.getParent() != line) return;
button.set_disabled(
// Disable if only 1 address
content.length <=1 || (
// Disable if all content is visible
$j(widget.getDOMNode()).innerWidth() >= widget.getDOMNode().scrollWidth &&
$j(widget.getDOMNode()).innerHeight() >= widget.getDOMNode().scrollHeight)
);
},this,et2_button);
}
return _dataElem;
},
/**
* Set values for mail dispaly From,Sender,To,Cc, and Bcc
* Additionally, apply expand on click feature on thier widgets
*
*/
mail_display: function()
{
var dataElem = {data:{FROM:"",SENDER:"",TO:"",CC:"",BCC:""}};
var content = this.et2.getArrayMgr('content').data;
var expand_content = [
{build_children: true, data_one: 'FROM', data: 'FROM', widget: 'FROM', line: 'mailDisplayHeadersFrom'},
{build_children: true, data: 'SENDER', widget: 'SENDER', line: 'mailDisplayHeadersSender'},
{build_children: true, data: 'TO', widget: 'TO', line: 'mailDisplayHeadersTo'},
{build_children: true, data: 'CC', widget: 'CC', line: 'mailDisplayHeadersCc'},
{build_children: true, data: 'BCC', widget:'BCC', line: 'mailDisplayHeadersBcc'}
];
if (typeof content != 'undefiend')
{
dataElem.data = jQuery.extend(dataElem.data, content);
this.url_email_expandOnClick(expand_content, dataElem);
}
},
/**
* mail_preview - implementation of the preview action
*
@ -572,69 +676,10 @@ app.classes.mail = AppJS.extend(
{build_children: true, data: 'ccaddress', widget: 'additionalCCAddress', line: 'mailPreviewHeadersCC'},
{build_children: false, data: 'attachmentsBlock', widget:'previewAttachmentArea', line: 'mailPreviewHeadersAttachments'}
];
for(var j = 0; j < expand_content.length; j++)
{
var field = expand_content[j] || [];
var content = dataElem.data[field.data] || [];
// Add in single address, if there
if(typeof field.data_one != 'undefined')
{
content.unshift(dataElem.data[field.data_one]);
// Unique
content = content.filter(function(value, index, self) {
return self.indexOf(value) === index;
});
}
// Disable whole box if there are none
var line = this.et2.getWidgetById(field.line);
if(line != null) line.set_disabled(content.length == 0);
var widget = this.et2.getWidgetById(field.widget);
if(widget == null) continue;
$j(widget.getDOMNode()).removeClass('visible');
// Programatically build the child elements
if(field.build_children)
{
// Remove any existing
var children = widget.getChildren();
for(var i = children.length-1; i >= 0; i--)
{
children[i].destroy();
widget.removeChild(children[i]);
}
// Add for current record
for(var i = 0; i < content.length; i++)
{
var value = content[i];
var email = et2_createWidget('url-email',{value:value,readonly:true},widget);
email.loadingFinished();
}
}
else
{
widget.set_value({content: content});
}
// Show or hide button, as needed
line.iterateOver(function(button) {
// Avoid binding to any child buttons
if(button.getParent() != line) return;
button.set_disabled(
// Disable if only 1 address
content.length <=1 || (
// Disable if all content is visible
$j(widget.getDOMNode()).innerWidth() >= widget.getDOMNode().scrollWidth &&
$j(widget.getDOMNode()).innerHeight() >= widget.getDOMNode().scrollHeight)
);
},this,et2_button);
}
//console.log("mail_preview",dataElem);
dataElem = this.url_email_expandOnClick(expand_content,dataElem);
// Update the internal list of selected mails, if needed
if(this.mail_selectedMails.indexOf(_id) < 0)
{

View File

@ -3,27 +3,35 @@
<overlay>
<template id="mail.display" template="" lang="" group="0" version="1.9.001">
<html id="msg"/>
<vbox class="mailDisplay mailDisplayHeaderSection" >
<toolbar id="toolbar"/>
<hbox class="mailDisplayHeaders" disabled="!@FROM" width="100%">
<vbox class="mailDisplay">
<hbox>
<toolbar id="toolbar"/>
</hbox>
<hbox class="mailDisplayHeaders" id="mailDisplayHeadersFrom" disabled="!@FROM" width="100%">
<description value="From"/>
<taglist id="FROM" readonly="true" onclick="app.mail.address_click"/>
<url-email id="FROM" readonly="true"/>
</hbox>
<hbox class="mailDisplayHeaders" disabled="!@SENDER" width="100%">
<hbox class="mailDisplayHeaders" id="mailDisplayHeadersSender" disabled="!@SENDER" width="100%">
<description value="on behalf of"/>
<taglist id="SENDER" readonly="true" onclick="app.mail.address_click"/>
<url-email id="SENDER" readonly="true"/>
</hbox>
<hbox class="mailDisplayHeaders" disabled="!@TO" width="100%">
<hbox class="mailDisplayHeaders" id="mailDisplayHeadersTo" disabled="!@TO" width="100%">
<description value="To"/>
<taglist id="TO" readonly="true" onclick="app.mail.address_click"/>
<hbox id="TO" class="mail_extraEmails">
</hbox>
<buttononly class="et2_button ui-button" label="Show all Addresses" image="foldertree_nolines_plus" onclick="app.mail.showAllHeader"/>
</hbox>
<hbox class="mailDisplayHeaders" disabled="!@CC" width="100%">
<hbox class="mailDisplayHeaders" id="mailDisplayHeadersCc" disabled="!@CC" width="100%">
<description value="Cc"/>
<taglist id="CC" readonly="true" onclick="app.mail.address_click"/>
<hbox id="CC" class="mail_extraEmails">
</hbox>
<buttononly class="et2_button ui-button" label="Show all Addresses" image="foldertree_nolines_plus" onclick="app.mail.showAllHeader"/>
</hbox>
<hbox class="mailDisplayHeaders" disabled="!@BCC" width="100%">
<hbox class="mailDisplayHeaders" id="mailDisplayHeadersBcc" disabled="!@BCC" width="100%">
<description value="Bcc"/>
<taglist id="BCC" readonly="true" onclick="app.mail.address_click"/>
<hbox id="BCC" class="mail_extraEmails">
</hbox>
<buttononly class="et2_button ui-button" label="Show all Addresses" image="foldertree_nolines_plus" onclick="app.mail.showAllHeader"/>
</hbox>
<hbox class="mailDisplayHeaders" width="100%">
<description value="Date"/>