').attr('id', 'swipe-action').html($('
').append($(''))).hide());
// down swipe on message list container
var swipe_config = {
'source_obj': rcmail.env.swipe_parent,
'axis': 'vertical',
'minmove': $(window).height() * 0.1,
'maxmove': $(window).height() * 0.2,
'action_sytle': function(o) {
return {
'top': o.children('tbody').position().top,
'left': o.children('tbody').position().left,
'width': o.children('tbody').width() + 'px',
'height': $(window).height() * 0.2 + 'px'
};
},
'target_obj': $(rcmail.gui_objects.messagelist),
'uid': null,
'parent_obj': rcmail.env.swipe_parent.parent()
};
rcmail.swipe_event(swipe_config);
});
// right/left swipe on message list
rcmail.addEventListener('insertrow', function(props) {
if (rcmail.message_list.draggable || !$('#' + props.row.id)[0].addEventListener)
return;
var swipe_config = {
'source_obj': $('#' + props.row.id),
'axis': 'horizontal',
'minmove': $('#' + props.row.id).width() * 0.25,
'maxmove': $('#' + props.row.id).width() * 0.6,
'action_sytle': function(o) {
return {
'top': o.position().top,
'left': o.position().left,
'width': o.width() + 'px',
'height': (o.height() - 2) + 'px' // subtract the border
};
},
'target_obj': $('#' + props.row.id),
'uid': props.uid,
'parent_obj': rcmail.env.swipe_parent
};
rcmail.swipe_event(swipe_config);
});
// disable delayed commands (eg move)
$(document.body).on('click', function(e) {
if (rcmail.env.swipe_delayed_action)
rcmail.env.swipe_delayed_action(e);
});
// add swipe options to list options menu
rcmail.addEventListener('menu-open', function(p) {
if (p.name == $('#swipeoptions-menu').data('options-menuname')) {
if (!rcmail.message_list.draggable) {
// set form values
$.each(['left', 'right', 'down'], function() {
$('select[name="swipe_' + this + '"]:visible').val(rcmail.env.swipe_actions[this]);
});
if (bw.pointer && !bw.touch) {
// TODO find a way to allow vertical actions but also scrolling of message list in Edge
$('div.swipeoptions-down').hide();
}
$('fieldset.swipe').show();
}
else {
$('fieldset.swipe').hide();
}
}
});
// save swipe options
rcmail.set_list_options_core = rcmail.set_list_options;
rcmail.set_list_options = function(cols, sort_col, sort_order, threads, layout)
{
var post = {};
$.each(['left', 'right', 'down'], function() {
if ($('select[name="swipe_' + this + '"]:visible').val() != rcmail.env.swipe_actions[this]) {
rcmail.env.swipe_actions[this] = $('select[name="swipe_' + this + '"]:visible').val();
post['swipe_' + this] = rcmail.env.swipe_actions[this];
}
});
if (!$.isEmptyObject(post))
rcmail.http_post('plugin.swipe.save_settings', post);
rcmail.set_list_options_core(cols, sort_col, sort_order, threads, layout);
}
if ($('#swipeoptions-menu > fieldset').find('select').length > 0)
$('#swipeoptions-menu > fieldset').appendTo('#' + $('#swipeoptions-menu').data('options-menuid'));
}
});