').attr('id', 'swipe-action').html($('
').append($(''))).hide());
// down swipe on message list container
var swipe_config = {
'source_obj': rcmail.env.swipe_parent,
'parent_obj': null,
'vertical': {
'minmove': $(window).height() * 0.1,
'maxmove': $(window).height() * 0.2,
'action_sytle': function(o) {
return {
'top': 0,
'left': 0,
'width': rcmail.env.swipe_parent.width() + 'px',
'height': $(window).height() * 0.2 + 'px'
};
},
'target_obj': $(rcmail.gui_objects.messagelist),
'uid': null
}
};
rcmail.swipe_event(swipe_config);
});
// right/left/down 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),
'parent_obj': rcmail.env.swipe_parent,
'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
},
'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
}
};
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]);
});
$('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'));
}
});