| 886 | } |
| 887 | |
| 888 | function captureSubmittingElement(e) { |
| 889 | /*jshint validthis:true */ |
| 890 | var target = e.target; |
| 891 | var $el = $(target); |
| 892 | if (!($el.is("[type=submit],[type=image]"))) { |
| 893 | // is this a child element of the submit el? (ex: a span within a button) |
| 894 | var t = $el.closest('[type=submit]'); |
| 895 | if (t.length === 0) { |
| 896 | return; |
| 897 | } |
| 898 | target = t[0]; |
| 899 | } |
| 900 | var form = this; |
| 901 | form.clk = target; |
| 902 | if (target.type == 'image') { |
| 903 | if (e.offsetX !== undefined) { |
| 904 | form.clk_x = e.offsetX; |
| 905 | form.clk_y = e.offsetY; |
| 906 | } else if (typeof $.fn.offset == 'function') { |
| 907 | var offset = $el.offset(); |
| 908 | form.clk_x = e.pageX - offset.left; |
| 909 | form.clk_y = e.pageY - offset.top; |
| 910 | } else { |
| 911 | form.clk_x = e.pageX - target.offsetLeft; |
| 912 | form.clk_y = e.pageY - target.offsetTop; |
| 913 | } |
| 914 | } |
| 915 | // clear form vars |
| 916 | setTimeout(function() { form.clk = form.clk_x = form.clk_y = null; }, 100); |
| 917 | } |
| 918 | |
| 919 | |
| 920 | // ajaxFormUnbind unbinds the event handlers that were bound by ajaxForm |