xi-conversations

Minimal clone of thunderbird conversations
git clone https://git.ce9e.org/xi-conversations.git

commit
e5295892bc5f08cddcc45dd4e57b2e86f6967295
parent
dfb2321f6864ffbfd13664f0d0332f6346df9614
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2023-09-06 03:18
button helper

Diffstat

M content/js/message.js 32 ++++++++++++++++++++------------

1 files changed, 20 insertions, 12 deletions


diff --git a/content/js/message.js b/content/js/message.js

@@ -47,9 +47,17 @@ export default function(msg, expanded) {
   47    47 
   48    48 	var canReplyAll = msg.recipients.length + msg.ccList.length + msg.bccList.length > 1;
   49    49 
   -1    50 	var createButton = function(attrs, icon, label, labelVisible) {
   -1    51 		if (labelVisible) {
   -1    52 			return h('button', Object.assign({'type': 'button'}, attrs), [util.createIcon(icon), ' ', label]);
   -1    53 		} else {
   -1    54 			return h('button', Object.assign({'type': 'button'}, attrs), [util.createIcon(icon, label)]);
   -1    55 		}
   -1    56 	};
   -1    57 
   50    58 	var e = h('article', {'class': expanded ? 'message is-expanded' : 'message', 'id': `msg-${msg.id}`, 'tabindex': -1}, [
   51    59 		h('header', {'class': 'message__header'}, [
   52    -1 			h('button', {'class': 'star', 'aria-pressed': msg.flagged, 'data-action': 'toggleFlagged'}, [util.createIcon('star', _('star'))]),
   -1    60 			createButton({'class': 'star', 'aria-pressed': msg.flagged, 'data-action': 'toggleFlagged'}, 'star', _('star')),
   53    61 			...util.parseContacts([msg.author]).map(author => h('a', {
   54    62 				'class': 'message__author',
   55    63 				'href': `mailto:${author.email}`,
@@ -68,19 +76,19 @@ export default function(msg, expanded) {
   68    76 			util.createDate(msg.date),
   69    77 			h('span', {'class': 'message__actions'}, [
   70    78 				canReplyAll
   71    -1 					? h('button', {'class': 'button', 'data-action': 'replyAll'}, [util.createIcon('reply_all', _('replyAll'))])
   -1    79 					? createButton({'class': 'button', 'data-action': 'replyAll'}, 'reply_all', _('replyAll'))
   72    80 					: msg.canReplyToList
   73    -1 						? h('button', {'class': 'button', 'data-action': 'replyToList'}, [util.createIcon('list', _('replyList'))])
   74    -1 						: h('button', {'class': 'button', 'data-action': 'replyToSender'}, [util.createIcon('reply', _('reply'))]),
   75    -1 				h('button', {'class': 'button dropdownToggle'}, [util.createIcon('menu', _('more'))]),
   -1    81 						? createButton({'class': 'button', 'data-action': 'replyToList'}, 'list', _('replyList'))
   -1    82 						: createButton({'class': 'button', 'data-action': 'replyToSender'}, 'reply', _('reply')),
   -1    83 				createButton({'class': 'button dropdownToggle'}, 'menu', _('more')),
   76    84 				h('div', {'class': 'dropdown'}, [
   77    -1 					h('button', {'class': 'dropdown-item', 'data-action': 'replyToSender'}, [util.createIcon('reply'), ' ', _('reply')]),
   78    -1 					canReplyAll ? h('button', {'class': 'dropdown-item', 'data-action': 'replyAll'}, [util.createIcon('reply_all'), ' ', _('replyAll')]) : null,
   79    -1 					msg.canReplyToList ? h('button', {'class': 'dropdown-item', 'data-action': 'replyToList'}, [util.createIcon('list'), ' ', _('replyList')]) : null,
   80    -1 					h('button', {'class': 'dropdown-item', 'data-action': 'forward'}, [util.createIcon('forward'), ' ', _('forward')]),
   81    -1 					h('button', {'class': 'dropdown-item', 'data-action': 'editAsNew'}, [util.createIcon('create'), ' ', _('edit')]),
   82    -1 					h('button', {'class': 'dropdown-item', 'data-action': 'viewClassic'}, [util.createIcon('open_in_new'), ' ', _('viewClassic')]),
   83    -1 					h('button', {'class': 'dropdown-item', 'data-action': 'viewSource'}, [util.createIcon('code'), ' ', _('viewSource')]),
   -1    85 					createButton({'class': 'dropdown-item', 'data-action': 'replyToSender'}, 'reply', _('reply'), true),
   -1    86 					canReplyAll ? createButton({'class': 'dropdown-item', 'data-action': 'replyAll'}, 'reply_all', _('replyAll'), true) : null,
   -1    87 					msg.canReplyToList ? createButton({'class': 'dropdown-item', 'data-action': 'replyToList'}, 'list', _('replyList'), true) : null,
   -1    88 					createButton({'class': 'dropdown-item', 'data-action': 'forward'}, 'forward', _('forward'), true),
   -1    89 					createButton({'class': 'dropdown-item', 'data-action': 'editAsNew'}, 'create', _('edit'), true),
   -1    90 					createButton({'class': 'dropdown-item', 'data-action': 'viewClassic'}, 'open_in_new', _('viewClassic'), true),
   -1    91 					createButton({'class': 'dropdown-item', 'data-action': 'viewSource'}, 'code', _('viewSource'), true),
   84    92 				]),
   85    93 			]),
   86    94 		]),