+++ /dev/null
-/**
- * Jcrop v.0.9.5 (packed)
- * (c) 2008 Kelly Hallman and DeepLiquid.com
- * More information: http://deepliquid.com/content/Jcrop.html
- * Released under MIT License - this header must remain with code
- */
-
-eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('$.1n=7(G,F){d G=G,F=F;g(1p(G)!==\'2d\')G=$(G)[0];g(1p(F)!==\'2d\')F={};g(!(\'2x\'1a F))F.2x=$.3d.3e?K:M;g(!(\'2c\'1a F))F.2c=$.3d.3e?K:M;d 4f={2x:K,3W:\'4C\',1f:4D,3T:\'4Y\',3x:.6,3O:.4,3P:.5,53:5,3N:9,3D:5,51:14,25:0,2c:M,3I:M,3B:M,30:M,3A:M,49:0,4p:0,4k:8,3V:20,3X:3,2f:K,3n:[0,0],2z:[0,0],2O:[0,0],2D:7(){},2G:7(){}};d j=4f;21(F);d $I=$(G).B({16:\'1b\'});47($I,j.49,j.4p);d S=$I.W(),L=$I.U(),$12=$(\'<12 />\').W(S).U(L).1f(1L(\'4F\')).B({16:\'4H\',4B:j.3T});g(j.1f)$12.1f(j.1f);$I.54($12);d $34=$(\'<I />\').3Y(\'2N\',$I.3Y(\'2N\')).B(\'16\',\'1b\').W(S).U(L);d $2C=$(\'<12 />\').W(1t(V)).U(1t(V)).B({1l:59,16:\'1b\',4o:\'4g\'}).1P($34);d $2g=$(\'<12 />\').W(1t(V)).U(1t(V)).B({1l:5b});d $28=$(\'<12 />\').B({16:\'1b\',1l:55}).3U($I).1P($2C,$2g);d 23=j.4k;d $1S=$(\'<12 />\').1f(1L(\'3v\')).W(S+(23*2)).U(L+(23*2)).B({16:\'1b\',R:D(-23),P:D(-23),1l:3R,1z:0}).3q(48);d 1I,1Q;d 2u=2Q(G),1q,1B,3i,58,3h,1O;g(\'36\'1a j){1I=j.36[0]/S;1Q=j.36[1]/L}d E=7(){d A=0,u=0,q=0,m=0,Z,Y;7 1A(z){d z=2T(z);q=A=z[0];m=u=z[1]};7 1y(z){d z=2T(z);Z=z[0]-q;Y=z[1]-m;q=z[0];m=z[1]};7 3f(){k[Z,Y]};7 2b(2y){d Z=2y[0],Y=2y[1];g(0>A+Z)Z-=Z+A;g(0>u+Y)Y-=Y+u;g(L<m+Y)Y+=L-(m+Y);g(S<q+Z)Z+=S-(q+Z);A+=Z;q+=Z;u+=Y;m+=Y};7 2K(T){d c=Q();1E(T){C\'1s\':k[c.q,c.y];C\'11\':k[c.x,c.y];C\'2e\':k[c.q,c.m];C\'1M\':k[c.x,c.m]}};7 Q(){g(!j.25&&!1B)k 3F();d 1k=j.25?j.25:1B,5c=j.2O,4u=j.2z,1V=q-A,1Z=m-u,3c=N.17(1V),3j=N.17(1Z),3M=3c/3j,15,13;g(3M<1k){13=m;w=3j*1k;15=1V<0?A-w:w+A;g(15<0){15=0;h=N.17((15-A)/1k);13=1Z<0?u-h:h+u}1g g(15>S){15=S;h=N.17((15-A)/1k);13=1Z<0?u-h:h+u}}1g{15=q;h=3c/1k;13=1Z<0?u-h:u+h;g(13<0){13=0;w=N.17((13-u)*1k);15=1V<0?A-w:w+A}1g g(13>L){13=L;w=N.17(13-u)*1k;15=1V<0?A-w:w+A}}k 4E=3g(1F(A,u,15,13))};7 2T(p){g(p[0]<0)p[0]=0;g(p[1]<0)p[1]=0;g(p[0]>S)p[0]=S;g(p[1]>L)p[1]=L;k[p[0],p[1]]};7 1F(A,u,q,m){d 2R=A,3r=q,3o=u,3l=m;g(q<A){2R=q;3r=A}g(m<u){3o=m;3l=u}k[N.1K(2R),N.1K(3o),N.1K(3r),N.1K(3l)]};7 3F(){d 1U=q-A;d 22=m-u;g(2q&&(N.17(1U)>2q))q=(1U>0)?(A+2q):(A-2q);g(2n&&(N.17(22)>2n))m=(22>0)?(u+2n):(u-2n);g(2i&&(N.17(22)<2i))m=(22>0)?(u+2i):(u-2i);g(2m&&(N.17(1U)<2m))q=(1U>0)?(A+2m):(A-2m);g(A<0){q-=A;A-=A}g(u<0){m-=u;u-=u}g(q<0){A-=q;q-=q}g(m<0){u-=m;m-=m}g(q>S){d X=q-S;A-=X;q-=X}g(m>L){d X=m-L;u-=X;m-=X}g(A>S){d X=A-L;m-=X;u-=X}g(u>L){d X=u-L;m-=X;u-=X}k 3g(1F(A,u,q,m))};7 3g(a){k{x:a[0],y:a[1],q:a[2],m:a[3],w:a[2]-a[0],h:a[3]-a[1]}};k{1F:1F,1A:1A,1y:1y,3f:3f,2b:2b,2K:2K,Q:Q}}();d J=7(){d 4v,4z,4y,1R,2U=4x;d 2F={};d H={};d 2E=K;d 1i=j.3D;g(j.30){2F={R:1Y(\'3C\').B(\'R\',$.3d.3e?D(-1):D(0)),3Q:1Y(\'3C\'),P:1Y(\'3z\'),3L:1Y(\'3z\')}}g(j.3A){H.t=1W(\'n\');H.b=1W(\'s\');H.r=1W(\'e\');H.l=1W(\'w\')}j.3B&&2Y([\'n\',\'s\',\'e\',\'w\']);j.3I&&2Y([\'1M\',\'11\',\'1s\',\'2e\']);7 1Y(1u){d 1J=$(\'<12 />\').B({16:\'1b\',1z:j.3O}).1f(1L(1u));$2C.1P(1J);k 1J};7 2W(T,3y){d 1J=$(\'<12 />\').3q(3b(T)).B({3p:T+\'-2A\',16:\'1b\',1l:3y});$2g.1P(1J);k 1J};7 3J(T){k 2W(T,2U++).B({R:D(-1i+1),P:D(-1i+1),1z:j.3P}).1f(1L(\'H\'))};7 1W(T){d s=j.3N,o=1i,h=s,w=s,t=o,l=o;1E(T){C\'n\':C\'s\':w=1t(V);O;C\'e\':C\'w\':h=1t(V);O}k 2W(T,2U++).W(w).U(h).B({R:D(-t+1),P:D(-l+1)})};7 2Y(2J){4U(i 1a 2J)H[2J[i]]=3J(2J[i])};7 31(c){d 3a=N.1K((c.h/2)-1i),35=N.1K((c.w/2)-1i),4V=4W=-1i+1,2a=c.w-1i,1X=c.h-1i,x,y;\'e\'1a H&&H.e.B({R:D(3a),P:D(2a)})&&H.w.B({R:D(3a)})&&H.s.B({R:D(1X),P:D(35)})&&H.n.B({P:D(35)});\'1s\'1a H&&H.1s.B({P:D(2a)})&&H.2e.B({R:D(1X),P:D(2a)})&&H.1M.B({R:D(1X)});\'b\'1a H&&H.b.B({R:D(1X)})&&H.r.B({P:D(2a)})};7 3K(x,y){$34.B({R:D(-y),P:D(-x)});$28.B({R:D(y),P:D(x)})};7 2A(w,h){$28.W(w).U(h)};7 3s(){d p=E.Q();E.1A([p.x,p.y]);E.1y([p.q,p.m])};7 2I(){g(1R)k 1e()};7 1e(){d c=E.Q();2A(c.w,c.h);3K(c.x,c.y);j.30&&2F[\'3L\'].B({P:D(c.w-1)})&&2F[\'3Q\'].B({R:D(c.h-1)});2E&&31(c);1R||1w();j.2D(2H(c))};7 1w(){$28.1w();$I.B(\'1z\',j.3x);1R=M};7 1r(){1o();$28.1v();$I.B(\'1z\',1);1R=K};7 1v(){1r();$I.B(\'1z\',1);1R=K};7 2t(){2E=M;31(E.Q());$2g.1w()};7 1o(){2E=K;$2g.1v()};7 2o(v){(3h=v)?1o():2t()};7 1h(){d c=E.Q();2o(K);3s()};1o();$2C.1P($(\'<12 />\').1f(1L(\'3v\')).3q(3b(\'1N\')).B({3p:\'1N\',16:\'1b\',1l:4M,1z:0}));k{2I:2I,1e:1e,1r:1r,1w:1w,1v:1v,2t:2t,1o:1o,2o:2o,1h:1h}}();d 1j=7(){d 2w=7(){},2v=7(){},2L=j.2x;g(!2L){$1S.3k(2B).2S(26).4N(26)}7 4j(){g(2L){$(3t).3k(2B).2S(26)}$1S.B({1l:4G})}7 4i(){g(2L){$(3t).3H(\'3k\',2B).3H(\'2S\',26)}$1S.B({1l:3R})}7 2B(e){2w(2r(e))};7 26(e){e.2j();e.2k();g(1q){1q=K;2v(2r(e));j.2G(2H(E.Q()));4i();2w=7(){};2v=7(){}}k K};7 1G(1N,1h){1q=M;2w=1N;2v=1h;4j();k K};7 1x(t){$1S.B(\'3p\',t)};$I.4s($1S);k{1G:1G,1x:1x}}();d 33=7(){d $24=$(\'<4w 1u="4L" />\').B({16:\'1b\',P:\'-4O\'}).57(43).56(2f).5a(41),$3S=$(\'<12 />\').B({16:\'1b\',4o:\'4g\'}).1P($24);7 2l(){g(j.2c){$24.1w();$24.4Z()}};7 41(e){$24.1v()};7 2f(e){g(!j.2f)k;d 42=1O,1C;1O=e.4Q?M:K;g(42!=1O){g(1O&&1q){1C=E.Q();1B=1C.w/1C.h}1g 1B=0;J.1e()}e.2k();e.2j();k K};7 29(e,x,y){E.2b([x,y]);J.2I();e.2j();e.2k()};7 43(e){g(e.4T)k M;2f(e);d 2h=1O?10:1;1E(e.5d){C 37:29(e,-2h,0);O;C 39:29(e,2h,0);O;C 38:29(e,0,-2h);O;C 40:29(e,0,2h);O;C 27:J.1r();O;C 9:k M}k K};g(j.2c)$3S.3U($I);k{2l:2l}}();7 D(n){k\'\'+1m(n)+\'D\'};7 1t(n){k\'\'+1m(n)+\'%\'};7 1L(44){k j.3W+\'-\'+44};7 2Q(G){d z=$(G).2y();k[z.P,z.R]};7 2r(e){k[(e.4q-2u[0]),(e.4r-2u[1])]};7 46(1u){g(1u!=3i){1j.1x(1u);3i=1u}};7 4a(19,z){2u=2Q(G);1j.1x(19==\'1N\'?19:19+\'-2A\');g(19==\'1N\')k 1j.1G(4e(z),2P);d 1C=E.Q();E.1A(E.2K(4b(19)));1j.1G(45(19,1C),2P)};7 45(19,f){k 7(z){g(!j.25&&!1B)1E(19){C\'e\':z[1]=f.m;O;C\'w\':z[1]=f.m;O;C\'n\':z[0]=f.q;O;C\'s\':z[0]=f.q;O}1g 1E(19){C\'e\':z[1]=f.y+1;O;C\'w\':z[1]=f.y+1;O;C\'n\':z[0]=f.x+1;O;C\'s\':z[0]=f.x+1;O}E.1y(z);J.1e()}};7 4e(z){d 2M=z;33.2l();k 7(z){E.2b([z[0]-2M[0],z[1]-2M[1]]);2M=z;J.1e()}};7 4b(T){1E(T){C\'n\':k\'1M\';C\'s\':k\'11\';C\'e\':k\'11\';C\'w\':k\'1s\';C\'1s\':k\'1M\';C\'11\':k\'2e\';C\'2e\':k\'11\';C\'1M\':k\'1s\'}};7 3b(T){k 7(e){1q=M;4a(T,2r(e));e.2k();e.2j();k K}};7 47($G,w,h){d 11=$G.W(),1H=$G.U();g((11>w)&&w>0){11=w;1H=(w/$G.W())*$G.U()}g((1H>h)&&h>0){1H=h;11=(h/$G.U())*$G.W()}1I=$G.W()/11;1Q=$G.U()/1H;$G.W(11).U(1H)};7 2H(c){k{x:1m(c.x*1I),y:1m(c.y*1Q),q:1m(c.q*1I),m:1m(c.m*1Q),w:1m(c.w*1I),h:1m(c.h*1Q)}};7 2P(z){d c=E.Q();g(c.w>j.3n[0]&&c.h>j.3n[1]){J.2t();J.1h()}1g{J.1r()}1j.1x(\'2X\')};7 48(e){1q=M;2u=2Q(G);J.1r();J.1o();46(\'2X\');E.1A(2r(e));1j.1G(4c,2P);33.2l();e.2k();e.2j();k K};7 4c(z){E.1y(z);J.1e()};7 2Z(a){d A=a[0],u=a[1],q=a[2],m=a[3];g(3h)k;d 2s=E.1F(A,u,q,m);d c=E.Q();d 18=2p=[c.x,c.y,c.q,c.m];d 3w=j.3V;d x=18[0];d y=18[1];d q=18[2];d m=18[3];d 3Z=2s[0]-2p[0];d 4m=2s[1]-2p[1];d 4n=2s[2]-2p[2];d 4l=2s[3]-2p[3];d 1c=0;d 4h=j.3X;J.2o(M);d 3u=7(){k 7(){1c+=(V-1c)/4h;18[0]=x+((1c/V)*3Z);18[1]=y+((1c/V)*4m);18[2]=q+((1c/V)*4n);18[3]=m+((1c/V)*4l);g(1c<V)32();1g J.1h();g(1c>=4K.8)1c=V;1d(18)}}();7 32(){4I.4t(3u,3w)};32()};7 1d(l){E.1A([l[0],l[1]]);E.1y([l[2],l[3]]);J.1e()};7 21(F){g(1p(F)!=\'2d\')F={};j=$.4X(j,F);g(1p(j.2D)!==\'7\')j.2D=7(){};g(1p(j.2G)!==\'7\')j.2G=7(){}};7 3m(){k 2H(E.Q())};7 2V(){k E.Q()};7 3E(F){21(F);g(\'1d\'1a F){1d(F.1d);J.1h()}};g(1p(F)!=\'2d\')F={};g(\'1d\'1a F){1d(F.1d);J.1h()}d 2q=j.2z[0]||0;d 2n=j.2z[1]||0;d 2m=j.2O[0]||0;d 2i=j.2O[1]||0;1j.1x(\'2X\');k{2Z:2Z,1d:1d,21:3E,3m:3m,2V:2V}};$.5e.1n=7(j){7 3G(1D){d 4d=j.4R||1D.2N;d I=4P 4S();d 1D=1D;I.50=7(){$(1D).1v().4A(I);1D.1n=$.1n(I,j)};I.2N=4d};g(1p(j)!==\'2d\')j={};1T.4J(7(){g(\'1n\'1a 1T){g(j==\'52\')k 1T.1n;1g 1T.1n.21(j)}1g 3G(1T)});k 1T};',62,325,'|||||||function||||||var|||if|||options|return||y2||||x2||||y1|||||pos|x1|css|case|px|Coords|opt|obj|handle|img|Selection|false|boundy|true|Math|break|left|getFixed|top|boundx|ord|height|100|width|delta|oy|ox||nw|div|yy||xx|position|abs|animat|mode|in|absolute|pcent|setSelect|update|addClass|else|done|hhs|Tracker|aspect|zIndex|parseInt|Jcrop|disableHandles|typeof|btndown|release|ne|pct|type|hide|show|setCursor|setCurrent|opacity|setPressed|aspectLock|fc|from|switch|flipCoords|activateHandlers|nh|xscale|jq|round|cssClass|sw|move|shift_down|append|yscale|awake|trk|this|xsize|rw|insertDragbar|south|insertBorder|rh||setOptions|ysize|bound|keymgr|aspectRatio|trackUp||sel|doNudge|east|moveOffset|keySupport|object|se|watchShift|hdl_holder|nudge|ymin|preventDefault|stopPropagation|watchKeys|xmin|ylimit|animMode|initcr|xlimit|mouseAbs|animto|enableHandles|docOffset|onDone|onMove|trackDocument|offset|maxSize|resize|trackMove|img_holder|onChange|seehandles|borders|onSelect|unscale|updateVisible|li|getCorner|trackDoc|lloc|src|minSize|doneSelect|getPos|xa|mouseup|rebound|hdep|tellScaled|dragDiv|crosshair|createHandles|animateTo|drawBorders|moveHandles|animateStart|KeyManager|img2|midhoriz|trueSize||||midvert|createDragger|rwa|browser|msie|getOffset|makeObj|animating|lastcurs|rha|mousemove|yb|tellSelect|minSelect|ya|cursor|mousedown|xb|refresh|document|animator|tracker|interv|bgOpacity|zi|vline|dragEdges|sideHandles|hline|handleOffset|setOptionsNew|getRect|attachWhenDone|unbind|cornerHandles|insertHandle|moveto|right|real_ratio|handleSize|borderOpacity|handleOpacity|bottom|290|keywrap|bgColor|insertBefore|animationDelay|baseClass|swingSpeed|attr|ix1||onBlur|init_shift|parseKey|cl|dragmodeHandler|myCursor|presize|newSelection|boxWidth|startDragMode|oppLockCorner|selectDrag|loadsrc|createMover|defaults|hidden|velocity|toBack|toFront|boundary|iy2|iy1|ix2|overflow|boxHeight|pageX|pageY|before|setTimeout|max|start|input|370|dragmode|end|after|backgroundColor|jcrop|null|last|holder|450|relative|window|each|99|radio|360|mouseout|30px|new|shiftKey|useImg|Image|ctrlKey|for|north|west|extend|black|focus|onload|edgeMargin|api|handlePad|wrap|300|keyup|keydown|dimmed|310|blur|320|min|keyCode|fn'.split('|'),0,{}))
+++ /dev/null
-/*\r
- * jQuery Form Plugin\r
- * version: 2.17 (06-NOV-2008)\r
- * @requires jQuery v1.2.2 or later\r
- *\r
- * Examples and documentation at: http://malsup.com/jquery/form/\r
- * Dual licensed under the MIT and GPL licenses:\r
- * http://www.opensource.org/licenses/mit-license.php\r
- * http://www.gnu.org/licenses/gpl.html\r
- *\r
- * Revision: $Id$\r
- */\r
-;(function($) {\r
-\r
-/*\r
- Usage Note: \r
- -----------\r
- Do not use both ajaxSubmit and ajaxForm on the same form. These\r
- functions are intended to be exclusive. Use ajaxSubmit if you want\r
- to bind your own submit handler to the form. For example,\r
-\r
- $(document).ready(function() {\r
- $('#myForm').bind('submit', function() {\r
- $(this).ajaxSubmit({\r
- target: '#output'\r
- });\r
- return false; // <-- important!\r
- });\r
- });\r
-\r
- Use ajaxForm when you want the plugin to manage all the event binding\r
- for you. For example,\r
-\r
- $(document).ready(function() {\r
- $('#myForm').ajaxForm({\r
- target: '#output'\r
- });\r
- });\r
- \r
- When using ajaxForm, the ajaxSubmit function will be invoked for you\r
- at the appropriate time. \r
-*/\r
-\r
-/**\r
- * ajaxSubmit() provides a mechanism for immediately submitting \r
- * an HTML form using AJAX.\r
- */\r
-$.fn.ajaxSubmit = function(options) {\r
- // fast fail if nothing selected (http://dev.jquery.com/ticket/2752)\r
- if (!this.length) {\r
- log('ajaxSubmit: skipping submit process - no element selected');\r
- return this;\r
- }\r
-\r
- if (typeof options == 'function')\r
- options = { success: options };\r
-\r
- options = $.extend({\r
- url: this.attr('action') || window.location.toString(),\r
- type: this.attr('method') || 'GET'\r
- }, options || {});\r
-\r
- // hook for manipulating the form data before it is extracted;\r
- // convenient for use with rich editors like tinyMCE or FCKEditor\r
- var veto = {};\r
- this.trigger('form-pre-serialize', [this, options, veto]);\r
- if (veto.veto) {\r
- log('ajaxSubmit: submit vetoed via form-pre-serialize trigger');\r
- return this;\r
- }\r
-\r
- // provide opportunity to alter form data before it is serialized\r
- if (options.beforeSerialize && options.beforeSerialize(this, options) === false) {\r
- log('ajaxSubmit: submit aborted via beforeSerialize callback');\r
- return this;\r
- } \r
- \r
- var a = this.formToArray(options.semantic);\r
- if (options.data) {\r
- options.extraData = options.data;\r
- for (var n in options.data) {\r
- if(options.data[n] instanceof Array) {\r
- for (var k in options.data[n])\r
- a.push( { name: n, value: options.data[n][k] } )\r
- } \r
- else\r
- a.push( { name: n, value: options.data[n] } );\r
- }\r
- }\r
-\r
- // give pre-submit callback an opportunity to abort the submit\r
- if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) {\r
- log('ajaxSubmit: submit aborted via beforeSubmit callback');\r
- return this;\r
- } \r
-\r
- // fire vetoable 'validate' event\r
- this.trigger('form-submit-validate', [a, this, options, veto]);\r
- if (veto.veto) {\r
- log('ajaxSubmit: submit vetoed via form-submit-validate trigger');\r
- return this;\r
- } \r
-\r
- var q = $.param(a);\r
-\r
- if (options.type.toUpperCase() == 'GET') {\r
- options.url += (options.url.indexOf('?') >= 0 ? '&' : '?') + q;\r
- options.data = null; // data is null for 'get'\r
- }\r
- else\r
- options.data = q; // data is the query string for 'post'\r
-\r
- var $form = this, callbacks = [];\r
- if (options.resetForm) callbacks.push(function() { $form.resetForm(); });\r
- if (options.clearForm) callbacks.push(function() { $form.clearForm(); });\r
-\r
- // perform a load on the target only if dataType is not provided\r
- if (!options.dataType && options.target) {\r
- var oldSuccess = options.success || function(){};\r
- callbacks.push(function(data) {\r
- $(options.target).html(data).each(oldSuccess, arguments);\r
- });\r
- }\r
- else if (options.success)\r
- callbacks.push(options.success);\r
-\r
- options.success = function(data, status) {\r
- for (var i=0, max=callbacks.length; i < max; i++)\r
- callbacks[i].apply(options, [data, status, $form]);\r
- };\r
-\r
- // are there files to upload?\r
- var files = $('input:file', this).fieldValue();\r
- var found = false;\r
- for (var j=0; j < files.length; j++)\r
- if (files[j])\r
- found = true;\r
-\r
- // options.iframe allows user to force iframe mode\r
- if (options.iframe || found) { \r
- // hack to fix Safari hang (thanks to Tim Molendijk for this)\r
- // see: http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d\r
- if ($.browser.safari && options.closeKeepAlive)\r
- $.get(options.closeKeepAlive, fileUpload);\r
- else\r
- fileUpload();\r
- }\r
- else\r
- $.ajax(options);\r
-\r
- // fire 'notify' event\r
- this.trigger('form-submit-notify', [this, options]);\r
- return this;\r
-\r
-\r
- // private function for handling file uploads (hat tip to YAHOO!)\r
- function fileUpload() {\r
- var form = $form[0];\r
- \r
- if ($(':input[@name=submit]', form).length) {\r
- alert('Error: Form elements must not be named "submit".');\r
- return;\r
- }\r
- \r
- var opts = $.extend({}, $.ajaxSettings, options);\r
- var s = jQuery.extend(true, {}, $.extend(true, {}, $.ajaxSettings), opts);\r
-\r
- var id = 'jqFormIO' + (new Date().getTime());\r
- var $io = $('<iframe id="' + id + '" name="' + id + '" />');\r
- var io = $io[0];\r
-\r
- if ($.browser.msie || $.browser.opera) \r
- io.src = 'javascript:false;document.write("");';\r
- $io.css({ position: 'absolute', top: '-1000px', left: '-1000px' });\r
-\r
- var xhr = { // mock object\r
- aborted: 0,\r
- responseText: null,\r
- responseXML: null,\r
- status: 0,\r
- statusText: 'n/a',\r
- getAllResponseHeaders: function() {},\r
- getResponseHeader: function() {},\r
- setRequestHeader: function() {},\r
- abort: function() { \r
- this.aborted = 1; \r
- $io.attr('src','about:blank'); // abort op in progress\r
- }\r
- };\r
-\r
- var g = opts.global;\r
- // trigger ajax global events so that activity/block indicators work like normal\r
- if (g && ! $.active++) $.event.trigger("ajaxStart");\r
- if (g) $.event.trigger("ajaxSend", [xhr, opts]);\r
-\r
- if (s.beforeSend && s.beforeSend(xhr, s) === false) {\r
- s.global && jQuery.active--;\r
- return;\r
- }\r
- if (xhr.aborted)\r
- return;\r
- \r
- var cbInvoked = 0;\r
- var timedOut = 0;\r
-\r
- // add submitting element to data if we know it\r
- var sub = form.clk;\r
- if (sub) {\r
- var n = sub.name;\r
- if (n && !sub.disabled) {\r
- options.extraData = options.extraData || {};\r
- options.extraData[n] = sub.value;\r
- if (sub.type == "image") {\r
- options.extraData[name+'.x'] = form.clk_x;\r
- options.extraData[name+'.y'] = form.clk_y;\r
- }\r
- }\r
- }\r
-\r
- // take a breath so that pending repaints get some cpu time before the upload starts\r
- setTimeout(function() {\r
- // make sure form attrs are set\r
- var t = $form.attr('target'), a = $form.attr('action');\r
- $form.attr({\r
- target: id,\r
- method: 'POST',\r
- action: opts.url\r
- });\r
- \r
- // ie borks in some cases when setting encoding\r
- if (! options.skipEncodingOverride) {\r
- $form.attr({\r
- encoding: 'multipart/form-data',\r
- enctype: 'multipart/form-data'\r
- });\r
- }\r
-\r
- // support timout\r
- if (opts.timeout)\r
- setTimeout(function() { timedOut = true; cb(); }, opts.timeout);\r
-\r
- // add "extra" data to form if provided in options\r
- var extraInputs = [];\r
- try {\r
- if (options.extraData)\r
- for (var n in options.extraData)\r
- extraInputs.push(\r
- $('<input type="hidden" name="'+n+'" value="'+options.extraData[n]+'" />')\r
- .appendTo(form)[0]);\r
- \r
- // add iframe to doc and submit the form\r
- $io.appendTo('body');\r
- io.attachEvent ? io.attachEvent('onload', cb) : io.addEventListener('load', cb, false);\r
- form.submit();\r
- }\r
- finally {\r
- // reset attrs and remove "extra" input elements\r
- $form.attr('action', a);\r
- t ? $form.attr('target', t) : $form.removeAttr('target');\r
- $(extraInputs).remove();\r
- }\r
- }, 10);\r
-\r
- function cb() {\r
- if (cbInvoked++) return;\r
- \r
- io.detachEvent ? io.detachEvent('onload', cb) : io.removeEventListener('load', cb, false);\r
-\r
- var operaHack = 0;\r
- var ok = true;\r
- try {\r
- if (timedOut) throw 'timeout';\r
- // extract the server response from the iframe\r
- var data, doc;\r
-\r
- doc = io.contentWindow ? io.contentWindow.document : io.contentDocument ? io.contentDocument : io.document;\r
- \r
- if (doc.body == null && !operaHack && $.browser.opera) {\r
- // In Opera 9.2.x the iframe DOM is not always traversable when\r
- // the onload callback fires so we give Opera 100ms to right itself\r
- operaHack = 1;\r
- cbInvoked--;\r
- setTimeout(cb, 100);\r
- return;\r
- }\r
- \r
- xhr.responseText = doc.body ? doc.body.innerHTML : null;\r
- xhr.responseXML = doc.XMLDocument ? doc.XMLDocument : doc;\r
- xhr.getResponseHeader = function(header){\r
- var headers = {'content-type': opts.dataType};\r
- return headers[header];\r
- };\r
-\r
- if (opts.dataType == 'json' || opts.dataType == 'script') {\r
- var ta = doc.getElementsByTagName('textarea')[0];\r
- xhr.responseText = ta ? ta.value : xhr.responseText;\r
- }\r
- else if (opts.dataType == 'xml' && !xhr.responseXML && xhr.responseText != null) {\r
- xhr.responseXML = toXml(xhr.responseText);\r
- }\r
- data = $.httpData(xhr, opts.dataType);\r
- }\r
- catch(e){\r
- ok = false;\r
- $.handleError(opts, xhr, 'error', e);\r
- }\r
-\r
- // ordering of these callbacks/triggers is odd, but that's how $.ajax does it\r
- if (ok) {\r
- opts.success(data, 'success');\r
- if (g) $.event.trigger("ajaxSuccess", [xhr, opts]);\r
- }\r
- if (g) $.event.trigger("ajaxComplete", [xhr, opts]);\r
- if (g && ! --$.active) $.event.trigger("ajaxStop");\r
- if (opts.complete) opts.complete(xhr, ok ? 'success' : 'error');\r
-\r
- // clean up\r
- setTimeout(function() {\r
- $io.remove();\r
- xhr.responseXML = null;\r
- }, 100);\r
- };\r
-\r
- function toXml(s, doc) {\r
- if (window.ActiveXObject) {\r
- doc = new ActiveXObject('Microsoft.XMLDOM');\r
- doc.async = 'false';\r
- doc.loadXML(s);\r
- }\r
- else\r
- doc = (new DOMParser()).parseFromString(s, 'text/xml');\r
- return (doc && doc.documentElement && doc.documentElement.tagName != 'parsererror') ? doc : null;\r
- };\r
- };\r
-};\r
-\r
-/**\r
- * ajaxForm() provides a mechanism for fully automating form submission.\r
- *\r
- * The advantages of using this method instead of ajaxSubmit() are:\r
- *\r
- * 1: This method will include coordinates for <input type="image" /> elements (if the element\r
- * is used to submit the form).\r
- * 2. This method will include the submit element's name/value data (for the element that was\r
- * used to submit the form).\r
- * 3. This method binds the submit() method to the form for you.\r
- *\r
- * The options argument for ajaxForm works exactly as it does for ajaxSubmit. ajaxForm merely\r
- * passes the options argument along after properly binding events for submit elements and\r
- * the form itself.\r
- */ \r
-$.fn.ajaxForm = function(options) {\r
- return this.ajaxFormUnbind().bind('submit.form-plugin',function() {\r
- $(this).ajaxSubmit(options);\r
- return false;\r
- }).each(function() {\r
- // store options in hash\r
- $(":submit,input:image", this).bind('click.form-plugin',function(e) {\r
- var form = this.form;\r
- form.clk = this;\r
- if (this.type == 'image') {\r
- if (e.offsetX != undefined) {\r
- form.clk_x = e.offsetX;\r
- form.clk_y = e.offsetY;\r
- } else if (typeof $.fn.offset == 'function') { // try to use dimensions plugin\r
- var offset = $(this).offset();\r
- form.clk_x = e.pageX - offset.left;\r
- form.clk_y = e.pageY - offset.top;\r
- } else {\r
- form.clk_x = e.pageX - this.offsetLeft;\r
- form.clk_y = e.pageY - this.offsetTop;\r
- }\r
- }\r
- // clear form vars\r
- setTimeout(function() { form.clk = form.clk_x = form.clk_y = null; }, 10);\r
- });\r
- });\r
-};\r
-\r
-// ajaxFormUnbind unbinds the event handlers that were bound by ajaxForm\r
-$.fn.ajaxFormUnbind = function() {\r
- this.unbind('submit.form-plugin');\r
- return this.each(function() {\r
- $(":submit,input:image", this).unbind('click.form-plugin');\r
- });\r
-\r
-};\r
-\r
-/**\r
- * formToArray() gathers form element data into an array of objects that can\r
- * be passed to any of the following ajax functions: $.get, $.post, or load.\r
- * Each object in the array has both a 'name' and 'value' property. An example of\r
- * an array for a simple login form might be:\r
- *\r
- * [ { name: 'username', value: 'jresig' }, { name: 'password', value: 'secret' } ]\r
- *\r
- * It is this array that is passed to pre-submit callback functions provided to the\r
- * ajaxSubmit() and ajaxForm() methods.\r
- */\r
-$.fn.formToArray = function(semantic) {\r
- var a = [];\r
- if (this.length == 0) return a;\r
-\r
- var form = this[0];\r
- var els = semantic ? form.getElementsByTagName('*') : form.elements;\r
- if (!els) return a;\r
- for(var i=0, max=els.length; i < max; i++) {\r
- var el = els[i];\r
- var n = el.name;\r
- if (!n) continue;\r
-\r
- if (semantic && form.clk && el.type == "image") {\r
- // handle image inputs on the fly when semantic == true\r
- if(!el.disabled && form.clk == el)\r
- a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});\r
- continue;\r
- }\r
-\r
- var v = $.fieldValue(el, true);\r
- if (v && v.constructor == Array) {\r
- for(var j=0, jmax=v.length; j < jmax; j++)\r
- a.push({name: n, value: v[j]});\r
- }\r
- else if (v !== null && typeof v != 'undefined')\r
- a.push({name: n, value: v});\r
- }\r
-\r
- if (!semantic && form.clk) {\r
- // input type=='image' are not found in elements array! handle them here\r
- var inputs = form.getElementsByTagName("input");\r
- for(var i=0, max=inputs.length; i < max; i++) {\r
- var input = inputs[i];\r
- var n = input.name;\r
- if(n && !input.disabled && input.type == "image" && form.clk == input)\r
- a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});\r
- }\r
- }\r
- return a;\r
-};\r
-\r
-/**\r
- * Serializes form data into a 'submittable' string. This method will return a string\r
- * in the format: name1=value1&name2=value2\r
- */\r
-$.fn.formSerialize = function(semantic) {\r
- //hand off to jQuery.param for proper encoding\r
- return $.param(this.formToArray(semantic));\r
-};\r
-\r
-/**\r
- * Serializes all field elements in the jQuery object into a query string.\r
- * This method will return a string in the format: name1=value1&name2=value2\r
- */\r
-$.fn.fieldSerialize = function(successful) {\r
- var a = [];\r
- this.each(function() {\r
- var n = this.name;\r
- if (!n) return;\r
- var v = $.fieldValue(this, successful);\r
- if (v && v.constructor == Array) {\r
- for (var i=0,max=v.length; i < max; i++)\r
- a.push({name: n, value: v[i]});\r
- }\r
- else if (v !== null && typeof v != 'undefined')\r
- a.push({name: this.name, value: v});\r
- });\r
- //hand off to jQuery.param for proper encoding\r
- return $.param(a);\r
-};\r
-\r
-/**\r
- * Returns the value(s) of the element in the matched set. For example, consider the following form:\r
- *\r
- * <form><fieldset>\r
- * <input name="A" type="text" />\r
- * <input name="A" type="text" />\r
- * <input name="B" type="checkbox" value="B1" />\r
- * <input name="B" type="checkbox" value="B2"/>\r
- * <input name="C" type="radio" value="C1" />\r
- * <input name="C" type="radio" value="C2" />\r
- * </fieldset></form>\r
- *\r
- * var v = $(':text').fieldValue();\r
- * // if no values are entered into the text inputs\r
- * v == ['','']\r
- * // if values entered into the text inputs are 'foo' and 'bar'\r
- * v == ['foo','bar']\r
- *\r
- * var v = $(':checkbox').fieldValue();\r
- * // if neither checkbox is checked\r
- * v === undefined\r
- * // if both checkboxes are checked\r
- * v == ['B1', 'B2']\r
- *\r
- * var v = $(':radio').fieldValue();\r
- * // if neither radio is checked\r
- * v === undefined\r
- * // if first radio is checked\r
- * v == ['C1']\r
- *\r
- * The successful argument controls whether or not the field element must be 'successful'\r
- * (per http://www.w3.org/TR/html4/interact/forms.html#successful-controls).\r
- * The default value of the successful argument is true. If this value is false the value(s)\r
- * for each element is returned.\r
- *\r
- * Note: This method *always* returns an array. If no valid value can be determined the\r
- * array will be empty, otherwise it will contain one or more values.\r
- */\r
-$.fn.fieldValue = function(successful) {\r
- for (var val=[], i=0, max=this.length; i < max; i++) {\r
- var el = this[i];\r
- var v = $.fieldValue(el, successful);\r
- if (v === null || typeof v == 'undefined' || (v.constructor == Array && !v.length))\r
- continue;\r
- v.constructor == Array ? $.merge(val, v) : val.push(v);\r
- }\r
- return val;\r
-};\r
-\r
-/**\r
- * Returns the value of the field element.\r
- */\r
-$.fieldValue = function(el, successful) {\r
- var n = el.name, t = el.type, tag = el.tagName.toLowerCase();\r
- if (typeof successful == 'undefined') successful = true;\r
-\r
- if (successful && (!n || el.disabled || t == 'reset' || t == 'button' ||\r
- (t == 'checkbox' || t == 'radio') && !el.checked ||\r
- (t == 'submit' || t == 'image') && el.form && el.form.clk != el ||\r
- tag == 'select' && el.selectedIndex == -1))\r
- return null;\r
-\r
- if (tag == 'select') {\r
- var index = el.selectedIndex;\r
- if (index < 0) return null;\r
- var a = [], ops = el.options;\r
- var one = (t == 'select-one');\r
- var max = (one ? index+1 : ops.length);\r
- for(var i=(one ? index : 0); i < max; i++) {\r
- var op = ops[i];\r
- if (op.selected) {\r
- // extra pain for IE...\r
- var v = $.browser.msie && !(op.attributes['value'].specified) ? op.text : op.value;\r
- if (one) return v;\r
- a.push(v);\r
- }\r
- }\r
- return a;\r
- }\r
- return el.value;\r
-};\r
-\r
-/**\r
- * Clears the form data. Takes the following actions on the form's input fields:\r
- * - input text fields will have their 'value' property set to the empty string\r
- * - select elements will have their 'selectedIndex' property set to -1\r
- * - checkbox and radio inputs will have their 'checked' property set to false\r
- * - inputs of type submit, button, reset, and hidden will *not* be effected\r
- * - button elements will *not* be effected\r
- */\r
-$.fn.clearForm = function() {\r
- return this.each(function() {\r
- $('input,select,textarea', this).clearFields();\r
- });\r
-};\r
-\r
-/**\r
- * Clears the selected form elements.\r
- */\r
-$.fn.clearFields = $.fn.clearInputs = function() {\r
- return this.each(function() {\r
- var t = this.type, tag = this.tagName.toLowerCase();\r
- if (t == 'text' || t == 'password' || tag == 'textarea')\r
- this.value = '';\r
- else if (t == 'checkbox' || t == 'radio')\r
- this.checked = false;\r
- else if (tag == 'select')\r
- this.selectedIndex = -1;\r
- });\r
-};\r
-\r
-/**\r
- * Resets the form data. Causes all form elements to be reset to their original value.\r
- */\r
-$.fn.resetForm = function() {\r
- return this.each(function() {\r
- // guard against an input with the name of 'reset'\r
- // note that IE reports the reset function as an 'object'\r
- if (typeof this.reset == 'function' || (typeof this.reset == 'object' && !this.reset.nodeType))\r
- this.reset();\r
- });\r
-};\r
-\r
-/**\r
- * Enables or disables any matching elements.\r
- */\r
-$.fn.enable = function(b) { \r
- if (b == undefined) b = true;\r
- return this.each(function() { \r
- this.disabled = !b \r
- });\r
-};\r
-\r
-/**\r
- * Checks/unchecks any matching checkboxes or radio buttons and\r
- * selects/deselects and matching option elements.\r
- */\r
-$.fn.selected = function(select) {\r
- if (select == undefined) select = true;\r
- return this.each(function() { \r
- var t = this.type;\r
- if (t == 'checkbox' || t == 'radio')\r
- this.checked = select;\r
- else if (this.tagName.toLowerCase() == 'option') {\r
- var $sel = $(this).parent('select');\r
- if (select && $sel[0] && $sel[0].type == 'select-one') {\r
- // deselect all other options\r
- $sel.find('option').selected(false);\r
- }\r
- this.selected = select;\r
- }\r
- });\r
-};\r
-\r
-// helper fn for console logging\r
-// set $.fn.ajaxSubmit.debug to true to enable debug logging\r
-function log() {\r
- if ($.fn.ajaxSubmit.debug && window.console && window.console.log)\r
- window.console.log('[jquery.form] ' + Array.prototype.join.call(arguments,''));\r
-};\r
-\r
-})(jQuery);\r