diff --git a/scp/js/scp.js b/scp/js/scp.js index c46c624d49ca97127b9bca3485c6dd313c53497b..f41617ce6f652b00da4b21c10e59a94db8cca5fc 100644 --- a/scp/js/scp.js +++ b/scp/js/scp.js @@ -121,7 +121,7 @@ $(document).ready(function(){ //Canned attachments. - $('#canned_attachments, #faq_attachments').delegate('input:checkbox', 'click', function(e) { + $('.canned_attachments, .faq_attachments').delegate('input:checkbox', 'click', function(e) { var elem = $(this); if(!$(this).is(':checked') && confirm("Are you sure you want to remove this attachment?")==true) { elem.parent().addClass('strike'); @@ -154,12 +154,12 @@ $(document).ready(function(){ $('#response',fObj).val(canned.response); } //Canned attachments. - if(canned.files && $('#canned_attachments',fObj).length) { + if(canned.files && $('.canned_attachments',fObj).length) { $.each(canned.files,function(i, j) { - if(!$('#canned_attachments #f'+j.id,fObj).length) { + if(!$('.canned_attachments #f'+j.id,fObj).length) { var file='<label><input type="checkbox" name="cannedattachments[]" value="' + j.id+'" id="f'+j.id+'" checked="checked">'; file+= '<a href="file.php?h=' + j.hash + j.key+ '">'+ j.name +'</a></label>'; - $('#canned_attachments', fObj).append(file); + $('.canned_attachments', fObj).append(file); } }); @@ -203,17 +203,24 @@ $(document).ready(function(){ }); /* Get config settings from the backend */ - $.get('ajax.php/config/ui.json', - function(config){ - /* - if(config && config.max_attachments) - alert(config.max_attachments); - */ - }, - 'json') - .error( function() {}); - /* Datepicker */ + var $config = null; + $.ajax({ + url: "ajax.php/config/scp", + dataType: 'json', + async: false, + success: function (config) { + $config = config; + } + }); + + /* Multifile uploads */ + $('.multifile').multifile({ + container: '.uploads', + max_uploads: ($config && $config.max_file_uploads)?$config.max_file_uploads:1, + file_types: ($config && $config.file_types)?$config.file_types:".*" + }); + /* Datepicker */ $('.dp').datepicker({ numberOfMonths: 2, showButtonPanel: true,