diff options
Diffstat (limited to 'plugins/managesieve/managesieve.js')
-rw-r--r-- | plugins/managesieve/managesieve.js | 51 |
1 files changed, 44 insertions, 7 deletions
diff --git a/plugins/managesieve/managesieve.js b/plugins/managesieve/managesieve.js index 15637026e..7fcd9d9c6 100644 --- a/plugins/managesieve/managesieve.js +++ b/plugins/managesieve/managesieve.js @@ -50,6 +50,18 @@ if (window.rcmail) { $('textarea[data-type="list"]', rcmail.gui_objects.sieveform).each(function() { smart_field_init(this); }); + + // enable date pickers on date fields + if ($.datepicker && rcmail.env.date_format) { + $.datepicker.setDefaults({ + dateFormat: rcmail.env.date_format, + changeMonth: true, + showOtherMonths: true, + selectOtherMonths: true, + onSelect: function(dateText) { $(this).focus().val(dateText) } + }); + $('input.datepicker').datepicker(); + } } else { rcmail.enable_command('plugin.managesieve-add', 'plugin.managesieve-setadd', !rcmail.env.sieveconnerror); @@ -226,7 +238,7 @@ rcube_webmail.prototype.managesieve_updatelist = function(action, o) // Delete filter row case 'del': - var i = 0, list = this.filters_list; + var id = o.id, list = this.filters_list; list.remove_row(this.managesieve_rowid(o.id)); list.clear_selection(); @@ -241,8 +253,14 @@ rcube_webmail.prototype.managesieve_updatelist = function(action, o) return; } - // modify ID and remove all attached events - $(this).attr('id', 'rcmrow'+(i++)).unbind(); + var rowid = this.id.substr(6); + + // remove all attached events + $(this).unbind(); + + // update row id + if (rowid > id) + $(this).attr('id', 'rcmrow' + (rowid-1)); }); list.init(); @@ -437,6 +455,12 @@ rcube_webmail.prototype.managesieve_unfocus_filter = function(row) // Form submition rcube_webmail.prototype.managesieve_save = function() { + if (this.env.action == 'plugin.managesieve-vacation') { + var data = $(this.gui_objects.sieveform).serialize(); + this.http_post('plugin.managesieve-vacation', data, this.display_message(this.get_label('managesieve.vacation.saving'), 'loading')); + return; + } + if (parent.rcmail && parent.rcmail.filters_list && this.gui_objects.sieveform.name != 'filtersetform') { var id = parent.rcmail.filters_list.get_single_selection(); if (id != null) @@ -502,6 +526,11 @@ rcube_webmail.prototype.managesieve_actionfill = function(content, id, after) row.setAttribute('id', 'actionrow'+id); row.innerHTML = content; + // initialize smart list inputs + $('textarea[data-type="list"]', row).each(function() { + smart_field_init(this); + }); + this.managesieve_formbuttons(div); } }; @@ -790,9 +819,17 @@ rcube_webmail.prototype.managesieve_tip_register = function(tips) /********* Mail UI methods *********/ /*********************************************************/ -rcube_webmail.prototype.managesieve_create = function() +rcube_webmail.prototype.managesieve_create = function(force) { - if (!rcmail.env.sieve_headers || !rcmail.env.sieve_headers.length) + if (!force && this.env.action != 'show' && !$('#'+this.env.contentframe).is(':visible')) { + var uid = this.message_list.get_single_selection(), + lock = this.set_busy(true, 'loading'); + + this.http_post('plugin.managesieve-action', {_uid: uid}, lock); + return; + } + + if (!this.env.sieve_headers || !this.env.sieve_headers.length) return; var i, html, buttons = {}, dialog = $("#sievefilterform"); @@ -805,9 +842,9 @@ rcube_webmail.prototype.managesieve_create = function() // build dialog window content html = '<fieldset><legend>'+this.gettext('managesieve.usedata')+'</legend><ul>'; - for (i in rcmail.env.sieve_headers) + for (i in this.env.sieve_headers) html += '<li><input type="checkbox" name="headers[]" id="sievehdr'+i+'" value="'+i+'" checked="checked" />' - +'<label for="sievehdr'+i+'">'+rcmail.env.sieve_headers[i][0]+':</label> '+rcmail.env.sieve_headers[i][1]+'</li>'; + +'<label for="sievehdr'+i+'">'+this.env.sieve_headers[i][0]+':</label> '+this.env.sieve_headers[i][1]+'</li>'; html += '</ul></fieldset>'; dialog.html(html); |