X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/2d586b8b6946ba269b14e728ceba8148a406ef10..d21ddfcea0160743077c29ecd6ff9141258c2ca5:/js/kivi.Order.js diff --git a/js/kivi.Order.js b/js/kivi.Order.js index 7c97a97e4..729407274 100644 --- a/js/kivi.Order.js +++ b/js/kivi.Order.js @@ -96,6 +96,9 @@ namespace('kivi.Order', function(ns) { $('#print_options_form table').first().remove().appendTo('#email_form_print_options'); + $('select#format').change(kivi.Order.adjust_email_attachment_name_for_template_format); + kivi.Order.adjust_email_attachment_name_for_template_format(); + var to_focus = $('#email_form_to').val() === '' ? 'to' : 'subject'; $('#email_form_' + to_focus).focus(); }; @@ -155,6 +158,20 @@ namespace('kivi.Order', function(ns) { email_dialog.dialog("close"); }; + ns.adjust_email_attachment_name_for_template_format = function() { + var $filename_elt = $('#email_form_attachment_filename'); + var $format_elt = $('select#format'); + + if (!$filename_elt || !$format_elt) + return; + + var format = $format_elt.val().toLowerCase(); + var new_ext = format == 'html' ? 'html' : format == 'opendocument' ? 'odt' : 'pdf'; + var filename = $filename_elt.val(); + + $filename_elt.val(filename.replace(/[^.]+$/, new_ext)); + }; + ns.set_number_in_title = function(elt) { $('#nr_in_title').html($(elt).val()); };