general.js 990B

123456789101112131415161718192021222324252627282930
  1. $(document).ready(function(){
  2. // Enable tooltips
  3. $('td.actions button[rel="tooltip"]').tooltip();
  4. // Convert object action buttons into POST requests
  5. $("td.actions button, .form-actions .btn-toolbar button").click(function(e) {
  6. e.preventDefault();
  7. // Create hidden form
  8. var form = $('<form />').attr({
  9. method: 'POST',
  10. action: $(this).data('action'),
  11. style: 'visibility: hidden'
  12. }).appendTo($('body'));
  13. if($(this).data('csrf-token')) {
  14. // Add csrf protection token
  15. $('<input />').attr({
  16. type: 'hidden',
  17. name: '_csrf_token',
  18. value: $(this).data('csrf-token')
  19. }).appendTo(form);
  20. }
  21. // Submit POST request, if required promt for confirmation
  22. if(!$(this).data('confirm') || confirm($(this).data('confirm'))) {
  23. form.submit();
  24. }
  25. });
  26. });