Changeset View
Changeset View
Standalone View
Standalone View
plugins/csv_export/csv_export.js
Show All 19 Lines | |||||
* | * | ||||
* You should have received a copy of the GNU Affero General Public License | * You should have received a copy of the GNU Affero General Public License | ||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
* | * | ||||
* @licend The above is the entire license notice | * @licend The above is the entire license notice | ||||
* for the JavaScript code in this file. | * for the JavaScript code in this file. | ||||
*/ | */ | ||||
if (window.rcmail) { | window.rcmail && rcmail.addEventListener('init', function() { | ||||
if (rcmail.task == 'addressbook') { | |||||
rcmail.addEventListener('beforeexport', function(e) { return csv_export_dialog(e, 'export'); }) | rcmail.addEventListener('beforeexport', function(e) { return csv_export_dialog(e, 'export'); }) | ||||
.addEventListener('beforeexport-selected', function(e) { return csv_export_dialog(e, 'export-selected'); }); | .addEventListener('beforeexport-selected', function(e) { return csv_export_dialog(e, 'export-selected'); }); | ||||
} | } | ||||
// for tasks export we already have dialog, add format selector there | |||||
else if (rcmail.task == 'tasks') { | |||||
var options = [ | |||||
$('<option>').attr({value: 'itip', selected: true}).text('iCal'), | |||||
$('<option>').attr({value: 'csv'}).text('csv') | |||||
], | |||||
entry = $('<div>').attr('class', 'form-section') | |||||
.append($('<label>').attr('for', 'tasks-export-form-format').text(rcmail.get_label('csv_export.format'))) | |||||
.append($('<select>').attr({name: '_format', id: 'tasks-export-form-format'}).append(options)); | |||||
$('#tasks-export-form').append(entry); | |||||
} | |||||
}); | |||||
// Display dialog with format selection | // Display dialog with format selection | ||||
function csv_export_dialog(event, action) | function csv_export_dialog(event, action) | ||||
{ | { | ||||
// goto the default export if vcard format was selected | // goto the default export if vcard format was selected | ||||
if (rcmail.env.csv_export_bypass) { | if (rcmail.env.csv_export_bypass) { | ||||
return; | return; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | function csv_export_dialog_action(format, action) | ||||
// bypass the dialog and execute default export | // bypass the dialog and execute default export | ||||
if (format != 'csv') { | if (format != 'csv') { | ||||
rcmail.env.csv_export_bypass = true; | rcmail.env.csv_export_bypass = true; | ||||
rcmail.command(action); | rcmail.command(action); | ||||
rcmail.env.csv_export_bypass = false; | rcmail.env.csv_export_bypass = false; | ||||
return; | return; | ||||
} | } | ||||
var params = {_source: rcmail.env.source, _gid: rcmail.env.group, _format: 'csv'}; | var params = { | ||||
_source: rcmail.env.source, | |||||
_gid: rcmail.env.group, | |||||
_format: 'csv', | |||||
_token: rcmail.env.request_token | |||||
}; | |||||
if (action == 'export') { | if (action == 'export') { | ||||
params._search = rcmail.env.search_request; | params._search = rcmail.env.search_request; | ||||
} | } | ||||
else { // 'export-selected' | else { // 'export-selected' | ||||
params._cid = rcmail.contact_list.get_selection().join(','); | params._cid = rcmail.contact_list.get_selection().join(','); | ||||
} | } | ||||
rcmail.goto_url('export', params); | rcmail.goto_url('export', params); | ||||
} | } |