Advertisement
Guest User

Untitled

a guest
Dec 18th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. $.fn.orderWindows = function()
  2. {
  3. return this.each(function()
  4. {
  5. var $a = $(this);
  6.  
  7. $a.bind("click", function(e)
  8. {
  9. e.preventDefault();
  10.  
  11. $.get($a.attr("href"), function (a)
  12. {
  13. var $modal = $(a).clone();
  14.  
  15. $("body").append($modal);
  16.  
  17. $modal.on("hidden.bs.modal", function()
  18. {
  19. $modal.remove();
  20. })
  21.  
  22. $modal.find("[name='phone']").mask("+7 (999) 999-99-99");
  23.  
  24. $modal.find("form").on("submit", function (e)
  25. {
  26. e.preventDefault();
  27. var $form = $(this), $req = $form.find("[required='required']").filter(function ()
  28. {
  29. return !$(this).val().length;
  30. });
  31.  
  32. if ($req.length)
  33. {
  34. $req.first().focus();
  35. return false;
  36. }
  37.  
  38. var post = $.post($form.attr("action"), $form.serializeArray(), function (a)
  39. {
  40. $modal.find("form").html(a);
  41. $modal.find(":submit").hide();
  42. });
  43. });
  44.  
  45. $modal.modal("show");
  46. });
  47. });
  48. })
  49. }
  50.  
  51. if($(".staff-order").length)
  52. {
  53. $(".staff-order").orderWindows();
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement