input_modal.blade.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <span class="btn btn-inline btn-primary input_modal hidden"
  2. data-toggle="modal"
  3. data-target=".bd-input-modal-lg" data-backdrop="static" data-keyboard="false" data-controls-modal="leave_modal"></span>
  4. <div class="modal input fade bd-input-modal-lg"
  5. role="dialog"
  6. aria-labelledby="myLargeModalLabel"
  7. aria-hidden="true">
  8. <div class="modal-dialog modal-lg">
  9. <div class="modal-content">
  10. <div class="modal-header"><!--
  11. <button type="button" class="modal-close" data-dismiss="modal" aria-label="Close">
  12. <i class="font-icon-close-2"></i>
  13. </button> -->
  14. <h4 class="modal-title"></h4>
  15. </div>
  16. <div class="modal-body">
  17. <div class="modal-result"></div>
  18. </div>
  19. <div class="modal-footer">
  20. <button type="button" class="btn btn-rounded btn-black" data-dismiss="modal">Cancel</button>
  21. <span class="btn btn-rounded btn-secondary save">Submit</span>
  22. </div>
  23. </div>
  24. </div>
  25. </div>
  26. <script type="text/javascript">
  27. function modal_input(title,link){
  28. $('.input .modal-title').html(title);
  29. input_modal(link,callback_input);
  30. }
  31. function callback_input(){
  32. $('.input_modal').click();
  33. }
  34. function input_modal(link,callback){
  35. $('.input .modal-result').load(link,callback);
  36. }
  37. $('.save').on('click', function(e){
  38. e.preventDefault();
  39. if(check_required() == true){
  40. $(this).off(e);
  41. $(this).html('Please wait..').attr('disabled', 'disabled');
  42. $(this).closest('.input').find('form').submit();
  43. }
  44. });
  45. $(document).keypress(function(e){
  46. var keycode = (e.keyCode ? e.keyCode : e.which);
  47. if(keycode == '13'){
  48. e.preventDefault();
  49. $('.save').click();
  50. }
  51. });
  52. function check_required(){
  53. var check = 0;
  54. var required = 0;
  55. $('.input .required').each(function(){
  56. required = required + 1;
  57. if($(this).val() == null || $(this).val() == ''){
  58. $(this).css('border-color','#ff0000');
  59. }else{
  60. $(this).css('border-color','#d6e2e8');
  61. check = check + 1;
  62. }
  63. });
  64. if(check == required){
  65. return true;
  66. }
  67. }
  68. </script>