setting foldernames now as text and (optional) style

This commit is contained in:
Ralf Becker 2014-02-05 12:23:04 +00:00
parent 8e35567e6a
commit 92701be185
4 changed files with 67 additions and 61 deletions

View File

@ -88,11 +88,7 @@ class etemplate_widget_tree extends etemplate_widget
{
$item['text'] = html::htmlspecialchars($item['text']);
if (!empty($item['tooltip']))
{
$item['tooltip'] = html::htmlspecialchars($item['tooltip']);
}
if ($item['child'] && isset($item['item']) && is_array($item['item']))
if (isset($item['item']) && is_array($item['item']))
{
foreach($item['item'] as &$child)
{

View File

@ -268,7 +268,7 @@ var et2_tree = et2_inputWidget.extend(
// Item color - not working
if(options[key].data && typeof options[key].data.color !== 'undefined' && options[key].data.color)
{
options[key].style = options[key].style || "" + "background-color ='"+options[key].data.color+"';";
options[key].style = options[key].style || "" + "background-color:'"+options[key].data.color+"';";
}
// Tooltip
@ -309,28 +309,39 @@ var et2_tree = et2_inputWidget.extend(
},
/**
* Regexp used by _htmlencode_node
* Regexp used by _htmlencode
*/
_lt_regexp: /</g,
/**
* Minimal html encoding of text and tooltip of node incl. all children
* html encoding of text of node
*
* @param {object} _item with required attributes text, id and optional tooltip, child and item
* We only do a minimal html encoding by replacing opening bracket < with &lt;
* as tree seems not to need more and we dont want to waste time.
*
* @param {string} _text text to encode
* @return {string}
*/
_htmlencode: function(_text)
{
if (_text && _text.indexOf('<') >= 0)
{
_text = _text.replace(this._lt_regexp, '&lt;');
}
return _text;
},
/**
* html encoding of text of node incl. all children
*
* @param {object} _item with required attributes text, id and optional tooltip and item
* @return {object} encoded node
*/
_htmlencode_node: function(_item)
{
// htmlencode text and tooltip
if (_item.text && _item.text.indexOf('<') >= 0)
{
_item.text = _item.text.replace(this._lt_regexp, '&lt;');
}
if (_item.tooltip && _item.tooltip.indexOf('<') >= 0)
{
_item.tooltip = _item.tooltip.replace(this._lt_regexp, '&lt;');
}
if (_item.child && jQuery.isArray(_item.item))
_item.text = this._htmlencode(_item.text);
if (_item.item && jQuery.isArray(_item.item))
{
for(var i=0; i < _item.item.length; ++i)
{
@ -469,7 +480,7 @@ var et2_tree = et2_inputWidget.extend(
}
}
if (typeof _label != 'undefined') this.input.setItemText(_newItemId,_label);
if (typeof _label != 'undefined') this.setLabel(_newItemId, _label);
},
/**
@ -602,14 +613,27 @@ var et2_tree = et2_inputWidget.extend(
},
/**
* setLabel, sets the Label of of an item by id
* Sets label of an item by id
*
* @param _id ID of the node
* @param _label label to set
* @return void
*/
setLabel: function(_id, _label) {
if(this.input == null) return null;
this.input.setItemText(_id,_label);
this.input.setItemText(_id, this._htmlencode(_label));
},
/**
* Sets a style for an item by id
*
* @param {string} _id ID of node
* @param {string} _style style to set
* @return void
*/
setStyle: function(_id, _style) {
if(this.input == null) return null;
this.input.setItemStyle(_id, _style);
},
/**

View File

@ -585,9 +585,7 @@ class mail_ui
$data = $this->getFolderTree($fetchCounters, $nodeID, $subscribedOnly);
//error_log(__METHOD__.__LINE__.':'.$nodeID.'->'.array2string($data));
if (!is_null($_nodeID)) return $data;
header('Content-Type: application/json; charset=utf-8');
echo json_encode($data);
common::egw_exit();
etemplate_widget_tree::send_quote_json($data);
}
/**
@ -640,7 +638,7 @@ class mail_ui
if ($_profileID && $acc_id != $_profileID) continue;
$oA = array('id' => $acc_id,
'text' => str_replace(array('<','>'),array('[',']'),$identity_name),// htmlspecialchars($identity_name),
'text' => $identity_name,// htmlspecialchars($identity_name),
'tooltip' => '('.$acc_id.') '.htmlspecialchars_decode($identity_name),
'im0' => 'thunderbird.png',
'im1' => 'thunderbird.png',
@ -710,7 +708,11 @@ class mail_ui
$oA['im1'] = "folderOpen.gif";
$oA['im2'] = "MailFolderClosed.png"; // has Children
}
if ($fS['unseen']) $oA['text'] = '<b>'.$oA['text'].' ('.$fS['unseen'].')</b>';
if ($fS['unseen'])
{
$oA['text'] = $oA['text'].' ('.$fS['unseen'].')';
$oA['style'] = 'font-weight: bold';
}
$path = $this->mail_bo->profileID.self::$delimiter.$key; //$obj->folderName; //$obj->delimiter
$oA['id'] = $path; // ID holds the PATH
if (!empty($fS['attributes']) && stripos(array2string($fS['attributes']),'\noselect')!== false)
@ -3253,12 +3255,11 @@ blockquote[type=cite] {
//error_log(__METHOD__.__LINE__.array2string($fS));
if ($fS['unseen'])
{
$oA[$_folderName] = '<b>'.$fS['shortDisplayName'].' ('.$fS['unseen'].')</b>';
$oA[$_folderName] = $fS['shortDisplayName'].' ('.$fS['unseen'].')';
}
if ($fS['unseen']==0 && $fS['shortDisplayName'])
{
$oA[$_folderName] = $fS['shortDisplayName'];
}
}
}
@ -3427,7 +3428,7 @@ blockquote[type=cite] {
$oA[$_folderName]['olddesc'] = $oldFolderInfo['shortDisplayName'];
if ($fS['unseen'])
{
$oA[$_folderName]['desc'] = '<b>'.$fS['shortDisplayName'].' ('.$fS['unseen'].')</b>';
$oA[$_folderName]['desc'] = $fS['shortDisplayName'].' ('.$fS['unseen'].')';
}
else
@ -3442,7 +3443,7 @@ blockquote[type=cite] {
$fS = $this->mail_bo->getFolderStatus($newFolderName.$fragment,false);
if ($fS['unseen'])
{
$oA[$oldFolderName]['desc'] = '<b>'.$fS['shortDisplayName'].' ('.$fS['unseen'].')</b>';
$oA[$oldFolderName]['desc'] = $fS['shortDisplayName'].' ('.$fS['unseen'].')';
}
else

View File

@ -584,7 +584,7 @@ app.classes.mail = AppJS.extend(
/**
* Set values for mail dispaly From,Sender,To,Cc, and Bcc
* Additionally, apply expand on click feature on thier widgets
*
*
*/
mail_display: function()
{
@ -604,7 +604,7 @@ app.classes.mail = AppJS.extend(
this.url_email_expandOnClick(expand_content, dataElem);
}
},
/**
@ -678,8 +678,8 @@ app.classes.mail = AppJS.extend(
];
dataElem = this.url_email_expandOnClick(expand_content,dataElem);
// Update the internal list of selected mails, if needed
if(this.mail_selectedMails.indexOf(_id) < 0)
{
@ -840,6 +840,8 @@ app.classes.mail = AppJS.extend(
var ftree = this.et2.getWidgetById(this.nm_index+'[foldertree]');
for (var i in _status) {
ftree.setLabel(i,_status[i]);
// display folder-name bold for unseen mails
ftree.setStyle(i, 'font-weight: '+(_status[i].match(this._unseen_regexp) ? 'bold' : 'normal'));
//alert(i +'->'+_status[i]);
}
},
@ -1003,6 +1005,11 @@ app.classes.mail = AppJS.extend(
if (calledFromPopup && this.mail_isMainWindow==false) window.close();
},
/**
* Regular expression to find (and remove) unseen count from folder-name
*/
_unseen_regexp: / \([0-9]\)$/,
/**
* Delete mails - actually calls the backend function for deletion
* takes in all arguments
@ -1014,18 +1021,7 @@ app.classes.mail = AppJS.extend(
ftree = this.et2.getWidgetById(this.nm_index+'[foldertree]');
var _foldernode = ftree.getSelectedNode();
var displayname = _foldernode.label;
var inBraket = displayname.indexOf('\(');
if (inBraket!=-1)
{
var outBraket = displayname.indexOf('\)');
if (outBraket!=-1)
{
displayname = displayname.replace(/\((.*?)\)/,"");
displayname = displayname.replace(/<b>/,"");
displayname = displayname.replace(/<\/b>/,"");
}
}
var displayname = _foldernode.label.replace(this._unseen_regexp, '');
// Tell server
egw.json('mail.mail_ui.ajax_deleteMessages',[_msg,(typeof _action == 'undefined'?'no':_action)])
.sendRequest(true);
@ -1189,19 +1185,8 @@ app.classes.mail = AppJS.extend(
// Get nice folder name for message, if selected is not a profile
if(!profile_selected)
{
var displayname = _widget.getSelectedLabel();
var inBraket = displayname.indexOf('\(');
if (inBraket!=-1)
{
var outBraket = displayname.indexOf('\)');
if (outBraket!=-1)
{
displayname = displayname.replace(/\((.*?)\)/,"");
displayname = displayname.replace(/<b>/,"");
displayname = displayname.replace(/<\/b>/,"");
}
}
{
var displayname = _widget.getSelectedLabel().replace(this._remove_unseen_regexp, '');
var myMsg = (displayname?displayname:_folder)+' '+this.egw.lang('selected');
egw_message(myMsg);
}
@ -1944,7 +1929,7 @@ app.classes.mail = AppJS.extend(
*/
mail_getFormData: function(_actionObjects) {
var messages = {};
// if
// if
if (typeof _actionObjects['msg'] != 'undefined' && _actionObjects['msg'].length>0) return _actionObjects;
if (_actionObjects.length>0)
{