| | |
| | | /* (Manage)Sieve Filters */ |
| | | /** |
| | | * (Manage)Sieve Filters plugin |
| | | * |
| | | * @licstart The following is the entire license notice for the |
| | | * JavaScript code in this file. |
| | | * |
| | | * Copyright (c) 2012-2014, The Roundcube Dev Team |
| | | * |
| | | * The JavaScript code in this page is free software: you can redistribute it |
| | | * and/or modify it under the terms of the GNU General Public License |
| | | * as published by the Free Software Foundation, either version 3 of |
| | | * the License, or (at your option) any later version. |
| | | * |
| | | * @licend The above is the entire license notice |
| | | * for the JavaScript code in this file. |
| | | */ |
| | | |
| | | if (window.rcmail) { |
| | | rcmail.addEventListener('init', function(evt) { |
| | |
| | | changeMonth: true, |
| | | showOtherMonths: true, |
| | | selectOtherMonths: true, |
| | | onSelect: function(dateText) { $(this).focus().val(dateText) } |
| | | onSelect: function(dateText) { $(this).focus().val(dateText); } |
| | | }); |
| | | $('input.datepicker').datepicker(); |
| | | } |
| | |
| | | rcmail.enable_command('plugin.managesieve-add', 'plugin.managesieve-setadd', !rcmail.env.sieveconnerror); |
| | | } |
| | | |
| | | var i, p = rcmail, setcnt, set = rcmail.env.currentset; |
| | | var setcnt, set = rcmail.env.currentset; |
| | | |
| | | if (rcmail.gui_objects.filterslist) { |
| | | rcmail.filters_list = new rcube_list_widget(rcmail.gui_objects.filterslist, |
| | | {multiselect:false, draggable:true, keyboard:false}); |
| | | rcmail.filters_list.addEventListener('select', function(e) { p.managesieve_select(e); }); |
| | | rcmail.filters_list.addEventListener('dragstart', function(e) { p.managesieve_dragstart(e); }); |
| | | rcmail.filters_list.addEventListener('dragend', function(e) { p.managesieve_dragend(e); }); |
| | | rcmail.filters_list.row_init = function (row) { |
| | | row.obj.onmouseover = function() { p.managesieve_focus_filter(row); }; |
| | | row.obj.onmouseout = function() { p.managesieve_unfocus_filter(row); }; |
| | | }; |
| | | rcmail.filters_list.init(); |
| | | rcmail.filters_list.focus(); |
| | | {multiselect:false, draggable:true, keyboard:true}); |
| | | |
| | | rcmail.filters_list |
| | | .addEventListener('select', function(e) { rcmail.managesieve_select(e); }) |
| | | .addEventListener('dragstart', function(e) { rcmail.managesieve_dragstart(e); }) |
| | | .addEventListener('dragend', function(e) { rcmail.managesieve_dragend(e); }) |
| | | .addEventListener('initrow', function(row) { |
| | | row.obj.onmouseover = function() { rcmail.managesieve_focus_filter(row); }; |
| | | row.obj.onmouseout = function() { rcmail.managesieve_unfocus_filter(row); }; |
| | | }) |
| | | .init(); |
| | | } |
| | | |
| | | if (rcmail.gui_objects.filtersetslist) { |
| | | rcmail.filtersets_list = new rcube_list_widget(rcmail.gui_objects.filtersetslist, {multiselect:false, draggable:false, keyboard:false}); |
| | | rcmail.filtersets_list.addEventListener('select', function(e) { p.managesieve_setselect(e); }); |
| | | rcmail.filtersets_list.init(); |
| | | rcmail.filtersets_list.focus(); |
| | | rcmail.filtersets_list = new rcube_list_widget(rcmail.gui_objects.filtersetslist, |
| | | {multiselect:false, draggable:false, keyboard:true}); |
| | | |
| | | rcmail.filtersets_list.init().focus(); |
| | | |
| | | if (set != null) { |
| | | set = rcmail.managesieve_setid(set); |
| | | rcmail.filtersets_list.shift_start = set; |
| | | rcmail.filtersets_list.highlight_row(set, false); |
| | | rcmail.filtersets_list.select(set); |
| | | } |
| | | |
| | | // attach select event after initial record was selected |
| | | rcmail.filtersets_list.addEventListener('select', function(e) { rcmail.managesieve_setselect(e); }); |
| | | |
| | | setcnt = rcmail.filtersets_list.rowcount; |
| | | rcmail.enable_command('plugin.managesieve-set', true); |
| | |
| | | rcmail.enable_command('plugin.managesieve-setdel', setcnt > 1); |
| | | |
| | | // Fix dragging filters over sets list |
| | | $('tr', rcmail.gui_objects.filtersetslist).each(function (i, e) { p.managesieve_fixdragend(e); }); |
| | | $('tr', rcmail.gui_objects.filtersetslist).each(function (i, e) { rcmail.managesieve_fixdragend(e); }); |
| | | } |
| | | } |
| | | |
| | | if (rcmail.gui_objects.sieveform && rcmail.env.rule_disabled) |
| | | $('#disabled').attr('checked', true); |
| | | }); |
| | |
| | | |
| | | input = $('input', elem).attr(attrs).keydown(function(e) { |
| | | var input = $(this); |
| | | |
| | | // element creation event (on Enter) |
| | | if (e.which == 13) { |
| | | var name = input.attr('name').replace(/\[\]$/, ''), |
| | |
| | | |
| | | input.parent().after(elem); |
| | | $('input', elem).focus(); |
| | | } |
| | | // backspace or delete: remove input, focus previous one |
| | | else if ((e.which == 8 || e.which == 46) && input.val() == '') { |
| | | |
| | | var parent = input.parent(), siblings = parent.parent().children(); |
| | | |
| | | if (siblings.length > 1) { |
| | | if (parent.prev().length) |
| | | parent.prev().children('input').focus(); |
| | | else |
| | | parent.next().children('input').focus(); |
| | | |
| | | parent.remove(); |
| | | return false; |
| | | } |
| | | } |
| | | }); |
| | | |
| | |
| | | // show dialog window |
| | | dialog.dialog({ |
| | | modal: false, |
| | | resizable: !bw.ie6, |
| | | closeOnEscape: (!bw.ie6 && !bw.ie7), // disable for performance reasons |
| | | resizable: true, |
| | | closeOnEscape: !bw.ie7, // disable for performance reasons |
| | | title: this.gettext('managesieve.newfilter'), |
| | | close: function() { rcmail.managesieve_dialog_close(); }, |
| | | buttons: buttons, |