From 9c38c58e1e60c5d6d793eaa35692c8d80ece2d58 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Mon, 20 Apr 2015 05:47:38 -0400 Subject: Add option to prepopulate vacation addresses on form init (#1490030) --- plugins/managesieve/managesieve.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'plugins/managesieve/managesieve.js') diff --git a/plugins/managesieve/managesieve.js b/plugins/managesieve/managesieve.js index f0b5dc83e..1098b5b9e 100644 --- a/plugins/managesieve/managesieve.js +++ b/plugins/managesieve/managesieve.js @@ -581,6 +581,20 @@ rcube_webmail.prototype.managesieve_formbuttons = function(div) } }; +// update vacation addresses field with user identities +rcube_webmail.prototype.managesieve_vacation_addresses = function(id) +{ + var lock = this.set_busy(true, 'loading'); + this.http_post('plugin.managesieve-action', {_act: 'addresses', _aid: id}, lock); +}; + +// update vacation addresses field with user identities +rcube_webmail.prototype.managesieve_vacation_addresses_update = function(id, addresses) +{ + var field = $('#vacation_addresses,#action_addresses' + (id || '')); + smart_field_reset(field.get(0), addresses); +}; + function rule_header_select(id) { var obj = document.getElementById('header' + id), @@ -802,6 +816,21 @@ function smart_field_row(value, name, idx, size) return elem; } +// Reset and fill the smart list input with new data +function smart_field_reset(field, data) +{ + var id = field.id + '_list', + list = data.length ? data : ['']; + area = $('#' + id); + + area.empty(); + + // add input rows + $.each(list, function(i, v) { + area.append(smart_field_row(v, field.name, i, $(field).data('size'))); + }); +} + // Register onmouse(leave/enter) events for tips on specified form element rcube_webmail.prototype.managesieve_tip_register = function(tips) { -- cgit v1.2.3