add options menu to addressbook task

dev_contacts
PhilW 6 years ago
parent 2cdd60af44
commit f438bba101

@ -206,4 +206,31 @@
.swipe-active:not(#swipe-action),
.swipe-active > td {
background-color: @color-layout-list-background;
}
.toolbar a.button.swipe {
display: none;
}
html.layout-small,
html.layout-phone {
.toolbar {
a.button {
&.swipe {
display: inline-block;
&:before {
content: @fa-var-hand-point-up;
}
}
}
}
}
fieldset.swipe-menu {
margin: .25em;
legend {
display: none;
}
}

@ -314,6 +314,21 @@ rcube_webmail.prototype.swipe = {
if (swipedata.axis)
swipeevents.clearswipe(e);
});
},
setup_options: function() {
$.each(rcmail.env.swipe_actions, function(direction, action) {
var option_input = $('.swipeoptions-' + direction).find('select,input');
if (option_input.is('input[type="radio"]')) {
option_input.filter('[value="' + action + '"]').prop('checked', true);
}
else if (option_input.is('select') && option_input.first().children('option').length > 0) {
option_input.val(action);
}
else {
$('.swipeoptions-' + direction).hide();
}
});
}
};
@ -378,6 +393,14 @@ $(document).ready(function() {
return false;
}
});
rcmail.register_command('plugin.swipe.options', function() {
rcmail.show_popup_dialog($('#swipeoptions').clone(), rcmail.get_label('swipeactions', 'swipe'), [
{ text: rcmail.get_label('save'), 'class': 'mainaction save', click: function(e, ui, dialog) { rcmail.set_list_options(); (rcmail.is_framed() ? parent.$ : $)(dialog || this).dialog('close'); } },
{ text: rcmail.get_label('cancel'), 'class': 'cancel', click: function(e, ui, dialog) { (rcmail.is_framed() ? parent.$ : $)(dialog || this).dialog('close'); } }
]);
rcmail.swipe.setup_options();
}, true);
}
});
@ -461,18 +484,7 @@ $(document).ready(function() {
// done in menu-open not beforemenu-open because of Elastic's Bootstrap popovers
rcmail.addEventListener('menu-open', function(p) {
if (p.name == rcmail.env.swipe_menuname && $('.swipe-menu').is(':visible')) {
$.each(rcmail.env.swipe_actions, function(direction, action) {
var option_input = $('.swipeoptions-' + direction).find('select,input');
if (option_input.is('input[type="radio"]')) {
option_input.filter('[value="' + action + '"]').prop('checked', true);
}
else if (option_input.is('select') && option_input.first().children('option').length > 0) {
option_input.val(action);
}
else {
$('.swipeoptions-' + direction).hide();
}
});
rcmail.swipe.setup_options();
}
});
});

@ -84,22 +84,43 @@ class swipe extends rcube_plugin
'down' => $config['down']
));
$this->add_hook('template_container', array($this, 'options_menu'));
$this->include_stylesheet($this->local_skin_path() . '/swipe.css');
$this->include_script('swipe.js');
$this->rcube->output->add_label('swipe.markasflagged', 'swipe.markasunflagged', 'swipe.markasread', 'swipe.markasunread',
'refresh', 'moveto', 'reply', 'replyall', 'forward', 'select', 'swipe.deselect', 'compose');
$this->rcube->output->add_label('swipe.swipeactions', 'swipe.markasflagged', 'swipe.markasunflagged', 'swipe.markasread',
'swipe.markasunread', 'refresh', 'moveto', 'reply', 'replyall', 'forward', 'select', 'swipe.deselect', 'compose');
$this->rcube->output->add_handler('swipeoptionslist', array($this, 'options_list'));
if ($this->rcube->task == 'mail') {
$this->add_hook('template_container', array($this, 'options_menu'));
}
elseif ($this->rcube->task == 'addressbook') {
$this->add_button(array(
'command' => 'plugin.swipe.options',
'type' => 'link',
'class' => 'button swipe',
'title' => 'swipe.swipeactions',
'innerclass' => 'inner',
'label' => 'swipe.swipeactions'
), 'toolbar');
$this->add_hook('render_page', array($this, 'options_menu'));
}
}
}
}
public function options_menu($args)
{
if ($args['name'] == 'listoptions') {
if ($args['name'] == 'listoptions' || ($this->rcube->task == 'addressbook' && $args['write'])) {
// add additional menus from skins folder to list options menu
$html = $this->rcube->output->just_parse("<roundcube:include file=\"$this->menu_file\" skinpath=\"plugins/swipe\" />");
$args['content'] .= $html;
if ($this->rcube->task == 'addressbook') {
$html = html::div(array('id' => 'swipeoptions', 'class' => 'popupmenu'), $html);
$args['content'] = str_replace('</body>', $html . '</body>', $args['content']);
}
else {
$args['content'] .= $html;
}
return $args;
}

Loading…
Cancel
Save