custom.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. $(document).ready(function() {
  2. $('.btn-group').button();
  3. $('[data-toggle="tooltip"]').tooltip();
  4. $('.fileinput').click(function() {
  5. if(!$(this).hasClass('btn-danger')) {
  6. var realinputid = '#' + $(this).attr('id').replace(/_chooser.*/, '');
  7. $(realinputid).click();
  8. }
  9. });
  10. $('.deletefile').click(function() {
  11. var chooserbtnid = '#' + $(this).attr('id').replace(/_deletebtn$/, '_chooserbtn');
  12. var choosertxtid = '#' + $(this).attr('id').replace(/_deletebtn$/, '_choosertxt');
  13. var fileinputid = '#' + $(this).attr('id').replace(/_deletebtn$/, '');
  14. var deleteinputid = '#' + $(this).attr('id').replace(/btn$/, '');
  15. $(deleteinputid).click();
  16. $(chooserbtnid).toggleClass('btn-danger');
  17. $(chooserbtnid).toggleClass('not-allowed');
  18. $(choosertxtid).toggleClass('btn-danger');
  19. $(choosertxtid).val($(choosertxtid).hasClass('btn-danger') ? 'Removal requested' : '');
  20. $(fileinputid).val('');
  21. if($(this).attr('id').search('_key') >= 0) {
  22. if($(choosertxtid).hasClass('btn-danger') != $('#crt_client_choosertxt').hasClass('btn-danger')) {
  23. $('#crt_client_deletebtn').click();
  24. }
  25. } else {
  26. if($(choosertxtid).hasClass('btn-danger') != $('#crt_client_key_choosertxt').hasClass('btn-danger')) {
  27. $('#crt_client_key_deletebtn').click();
  28. }
  29. }
  30. });
  31. $('input[type="file"]').change(function() {
  32. var choosertxtid = '#' + $(this).attr('id') + '_choosertxt';
  33. $(choosertxtid).val($(this).val());
  34. });
  35. $('#save').click(function() {
  36. $(this).prop('disabled', true);
  37. $('#save-loading').show();
  38. });
  39. $('#status .close').click(function() {
  40. $(this).parent().hide();
  41. });
  42. $('#statusbtn').click(function() {
  43. $('#status-loading').show();
  44. $.ajax({
  45. url: '?/status',
  46. }).done(function(data) {
  47. $('#status-loading').hide();
  48. $('#status-text').html('<ul>' + data + '</ul>');
  49. $('#status').show('slow');
  50. });
  51. });
  52. });