(empty log message)
@@ -4,6 +4,18 @@ | ||
4 | 4 | 対応内容: |
5 | 5 | エンジン対応Ver:X.X.X.X |
6 | 6 | |
7 | + | |
8 | + | |
9 | +7.0.7.2 (2020/01/07) | |
10 | + [新着情報で画面遷移しない] | |
11 | + 問合・トラブル (61200-191228-01) の続きで、新着情報で登録後にリロードされない件の対応です。 | |
12 | + src\script\common\jquery\jquery.form.js | |
13 | + version: 2.21(jQuery v1.2.2 or later) ⇒ version: 4.2.2(jQuery v1.7.2 or later) 更新 | |
14 | + src\script\common\option\ajaxSubmit.js | |
15 | + $form.data(…) ⇒ $('form').data(…) 更新 | |
16 | + src\script\common\option\noTransition.js(404): | |
17 | + $form.data(…) ⇒ $('form').data(…) 更新 | |
18 | + | |
7 | 19 | 7.0.7.2 (2019/12/28) |
8 | 20 | [ソースチェック] |
9 | 21 | dataCheck の JavaScript の廃止予定に対して、from属性があれば、 |
@@ -1 +1,22 @@ | ||
1 | -(function(b){b.fn.ajaxSubmit=function(l){if(!this.length){a("ajaxSubmit: skipping submit process - no element selected");return this}if(typeof l=="function"){l={success:l}}l=b.extend({url:this.attr("action")||window.location.toString(),type:this.attr("method")||"GET"},l||{});var o={};this.trigger("form-pre-serialize",[this,l,o]);if(o.veto){a("ajaxSubmit: submit vetoed via form-pre-serialize trigger");return this}if(l.beforeSerialize&&l.beforeSerialize(this,l)===false){a("ajaxSubmit: submit aborted via beforeSerialize callback");return this}var g=this.formToArray(l.semantic);if(l.data){l.extraData=l.data;for(var d in l.data){if(l.data[d] instanceof Array){for(var e in l.data[d]){g.push({name:d,value:l.data[d][e]})}}else{g.push({name:d,value:l.data[d]})}}}if(l.beforeSubmit&&l.beforeSubmit(g,this,l)===false){a("ajaxSubmit: submit aborted via beforeSubmit callback");return this}this.trigger("form-submit-validate",[g,this,l,o]);if(o.veto){a("ajaxSubmit: submit vetoed via form-submit-validate trigger");return this}var c=b.param(g);if(l.type.toUpperCase()=="GET"){l.url+=(l.url.indexOf("?")>=0?"&":"?")+c;l.data=null}else{l.data=c}var m=this,f=[];if(l.resetForm){f.push(function(){m.resetForm()})}if(l.clearForm){f.push(function(){m.clearForm()})}if(!l.dataType&&l.target){var i=l.success||function(){};f.push(function(k){b(l.target).html(k).each(i,arguments)})}else{if(l.success){f.push(l.success)}}l.success=function(q,n){for(var p=0,k=f.length;p<k;p++){f[p].apply(l,[q,n,m])}};var j=b("input:file",this).length>0?true:false;if(l.iframe||j){if(l.closeKeepAlive){b.get(l.closeKeepAlive,h)}else{h()}}else{b.ajax(l)}this.trigger("form-submit-notify",[this,l]);return this;function h(){var t=m[0];if(b(":input[name=submit]",t).length){alert('Error: Form elements must not be named "submit".');return}var q=b.extend({},b.ajaxSettings,l);var D=jQuery.extend(true,{},b.extend(true,{},b.ajaxSettings),q);var r="jqFormIO"+(new Date().getTime());var z=b('<iframe id="'+r+'" name="'+r+'" src="about:blank" />');var B=z[0];z.css({position:"absolute",top:"-1000px",left:"-1000px"});var C={aborted:0,responseText:null,responseXML:null,status:0,statusText:"n/a",getAllResponseHeaders:function(){},getResponseHeader:function(){},setRequestHeader:function(){},abort:function(){this.aborted=1;z.attr("src","about:blank")}};var A=q.global;if(A&&!b.active++){b.event.trigger("ajaxStart")}if(A){b.event.trigger("ajaxSend",[C,q])}if(D.beforeSend&&D.beforeSend(C,D)===false){D.global&&jQuery.active--;return}if(C.aborted){return}var p=0;var v=0;var k=t.clk;if(k){var u=k.name;if(u&&!k.disabled){l.extraData=l.extraData||{};l.extraData[u]=k.value;if(k.type=="image"){l.extraData[name+".x"]=t.clk_x;l.extraData[name+".y"]=t.clk_y}}}setTimeout(function(){var F=m.attr("target"),s=m.attr("action");t.setAttribute("target",r);if(t.getAttribute("method")!="POST"){t.setAttribute("method","POST")}if(t.getAttribute("action")!=q.url){t.setAttribute("action",q.url)}if(!l.skipEncodingOverride){m.attr({encoding:"multipart/form-data",enctype:"multipart/form-data"})}if(q.timeout){setTimeout(function(){v=true;w()},q.timeout)}var E=[];try{if(l.extraData){for(var G in l.extraData){E.push(b('<input type="hidden" name="'+G+'" value="'+l.extraData[G]+'" />').appendTo(t)[0])}}z.appendTo("body");B.attachEvent?B.attachEvent("onload",w):B.addEventListener("load",w,false);t.submit()}finally{t.setAttribute("action",s);F?t.setAttribute("target",F):m.removeAttr("target");b(E).remove()}},10);var x=0;function w(){if(p++){return}B.detachEvent?B.detachEvent("onload",w):B.removeEventListener("load",w,false);var s=true;try{if(v){throw"timeout"}var E,G;G=B.contentWindow?B.contentWindow.document:B.contentDocument?B.contentDocument:B.document;if((G.body==null||G.body.innerHTML=="")&&!x){x=1;p--;setTimeout(w,100);return}C.responseText=G.body?G.body.innerHTML:null;C.responseXML=G.XMLDocument?G.XMLDocument:G;C.getResponseHeader=function(I){var H={"content-type":q.dataType};return H[I]};if(q.dataType=="json"||q.dataType=="script"){var n=G.getElementsByTagName("textarea")[0];C.responseText=n?n.value:C.responseText}else{if(q.dataType=="xml"&&!C.responseXML&&C.responseText!=null){C.responseXML=y(C.responseText)}}E=b.httpData(C,q.dataType)}catch(F){s=false;b.handleError(q,C,"error",F)}if(s){q.success(E,"success");if(A){b.event.trigger("ajaxSuccess",[C,q])}}if(A){b.event.trigger("ajaxComplete",[C,q])}if(A&&!--b.active){b.event.trigger("ajaxStop")}if(q.complete){q.complete(C,s?"success":"error")}setTimeout(function(){z.remove();C.responseXML=null},100)}function y(n,E){if(window.ActiveXObject){E=new ActiveXObject("Microsoft.XMLDOM");E.async="false";E.loadXML(n)}else{E=(new DOMParser()).parseFromString(n,"text/xml")}return(E&&E.documentElement&&E.documentElement.tagName!="parsererror")?E:null}}};b.fn.ajaxForm=function(c){return this.ajaxFormUnbind().bind("submit.form-plugin",function(){b(this).ajaxSubmit(c);return false}).each(function(){b(":submit,input:image",this).bind("click.form-plugin",function(f){var d=this.form;d.clk=this;if(this.type=="image"){if(f.offsetX!=undefined){d.clk_x=f.offsetX;d.clk_y=f.offsetY}else{if(typeof b.fn.offset=="function"){var g=b(this).offset();d.clk_x=f.pageX-g.left;d.clk_y=f.pageY-g.top}else{d.clk_x=f.pageX-this.offsetLeft;d.clk_y=f.pageY-this.offsetTop}}}setTimeout(function(){d.clk=d.clk_x=d.clk_y=null},10)})})};b.fn.ajaxFormUnbind=function(){this.unbind("submit.form-plugin");return this.each(function(){b(":submit,input:image",this).unbind("click.form-plugin")})};b.fn.formToArray=function(q){var p=[];if(this.length==0){return p}var d=this[0];var h=q?d.getElementsByTagName("*"):d.elements;if(!h){return p}for(var k=0,m=h.length;k<m;k++){var e=h[k];var f=e.name;if(!f){continue}if(q&&d.clk&&e.type=="image"){if(!e.disabled&&d.clk==e){p.push({name:f+".x",value:d.clk_x},{name:f+".y",value:d.clk_y})}continue}var r=b.fieldValue(e,true);if(r&&r.constructor==Array){for(var g=0,c=r.length;g<c;g++){p.push({name:f,value:r[g]})}}else{if(r!==null&&typeof r!="undefined"){p.push({name:f,value:r})}}}if(!q&&d.clk){var l=d.getElementsByTagName("input");for(var k=0,m=l.length;k<m;k++){var o=l[k];var f=o.name;if(f&&!o.disabled&&o.type=="image"&&d.clk==o){p.push({name:f+".x",value:d.clk_x},{name:f+".y",value:d.clk_y})}}}return p};b.fn.formSerialize=function(c){return b.param(this.formToArray(c))};b.fn.fieldSerialize=function(d){var c=[];this.each(function(){var h=this.name;if(!h){return}var f=b.fieldValue(this,d);if(f&&f.constructor==Array){for(var g=0,e=f.length;g<e;g++){c.push({name:h,value:f[g]})}}else{if(f!==null&&typeof f!="undefined"){c.push({name:this.name,value:f})}}});return b.param(c)};b.fn.fieldValue=function(h){for(var g=[],e=0,c=this.length;e<c;e++){var f=this[e];var d=b.fieldValue(f,h);if(d===null||typeof d=="undefined"||(d.constructor==Array&&!d.length)){continue}d.constructor==Array?b.merge(g,d):g.push(d)}return g};b.fieldValue=function(c,j){var e=c.name,p=c.type,q=c.tagName.toLowerCase();if(typeof j=="undefined"){j=true}if(j&&(!e||c.disabled||p=="reset"||p=="button"||(p=="checkbox"||p=="radio")&&!c.checked||(p=="submit"||p=="image")&&c.form&&c.form.clk!=c||q=="select"&&c.selectedIndex==-1)){return null}if(q=="select"){var k=c.selectedIndex;if(k<0){return null}var m=[],d=c.options;var g=(p=="select-one");var l=(g?k+1:d.length);for(var f=(g?k:0);f<l;f++){var h=d[f];if(h.selected){var o=h.value;if(!o){o=(h.attributes&&h.attributes.value&&!(h.attributes.value.specified))?h.text:h.value}if(g){return o}m.push(o)}}return m}return c.value};b.fn.clearForm=function(){return this.each(function(){b("input,select,textarea",this).clearFields()})};b.fn.clearFields=b.fn.clearInputs=function(){return this.each(function(){var d=this.type,c=this.tagName.toLowerCase();if(d=="text"||d=="password"||c=="textarea"){this.value=""}else{if(d=="checkbox"||d=="radio"){this.checked=false}else{if(c=="select"){this.selectedIndex=-1}}}})};b.fn.resetForm=function(){return this.each(function(){if(typeof this.reset=="function"||(typeof this.reset=="object"&&!this.reset.nodeType)){this.reset()}})};b.fn.enable=function(c){if(c==undefined){c=true}return this.each(function(){this.disabled=!c})};b.fn.selected=function(c){if(c==undefined){c=true}return this.each(function(){var d=this.type;if(d=="checkbox"||d=="radio"){this.checked=c}else{if(this.tagName.toLowerCase()=="option"){var e=b(this).parent("select");if(c&&e[0]&&e[0].type=="select-one"){e.find("option").selected(false)}this.selected=c}}})};function a(){if(b.fn.ajaxSubmit.debug&&window.console&&window.console.log){window.console.log("[jquery.form] "+Array.prototype.join.call(arguments,""))}}})(jQuery); | |
\ No newline at end of file | ||
1 | +/*! | |
2 | + * jQuery Form Plugin | |
3 | + * version: 4.2.2 | |
4 | + * Requires jQuery v1.7.2 or later | |
5 | + * Project repository: https://github.com/jquery-form/form | |
6 | + | |
7 | + * Copyright 2017 Kevin Morris | |
8 | + * Copyright 2006 M. Alsup | |
9 | + | |
10 | + * Dual licensed under the LGPL-2.1+ or MIT licenses | |
11 | + * https://github.com/jquery-form/form#license | |
12 | + | |
13 | + * This library is free software; you can redistribute it and/or | |
14 | + * modify it under the terms of the GNU Lesser General Public | |
15 | + * License as published by the Free Software Foundation; either | |
16 | + * version 2.1 of the License, or (at your option) any later version. | |
17 | + * This library is distributed in the hope that it will be useful, | |
18 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
20 | + * Lesser General Public License for more details. | |
21 | + */ | |
22 | +(function(a){if(typeof define==="function"&&define.amd){define(["jquery"],a)}else{if(typeof module==="object"&&module.exports){module.exports=function(b,c){if(typeof c==="undefined"){if(typeof window!=="undefined"){c=require("jquery")}else{c=require("jquery")(b)}}a(c);return c}}else{a(jQuery)}}}(function(g){var f=/\r?\n/g;var c={};c.fileapi=g('<input type="file">').get(0).files!==undefined;c.formdata=(typeof window.FormData!=="undefined");var e=!!g.fn.prop;g.fn.attr2=function(){if(!e){return this.attr.apply(this,arguments)}var h=this.prop.apply(this,arguments);if((h&&h.jquery)||typeof h==="string"){return h}return this.attr.apply(this,arguments)};g.fn.ajaxSubmit=function(l,M,E,o){if(!this.length){d("ajaxSubmit: skipping submit process - no element selected");return this}var j,F,n,r=this;if(typeof l==="function"){l={success:l}}else{if(typeof l==="string"||(l===false&&arguments.length>0)){l={url:l,data:M,dataType:E};if(typeof o==="function"){l.success=o}}else{if(typeof l==="undefined"){l={}}}}j=l.method||l.type||this.attr2("method");F=l.url||this.attr2("action");n=(typeof F==="string")?g.trim(F):"";n=n||window.location.href||"";if(n){n=(n.match(/^([^#]+)/)||[])[1]}l=g.extend(true,{url:n,success:g.ajaxSettings.success,type:j||g.ajaxSettings.type,iframeSrc:/^https/i.test(window.location.href||"")?"javascript:false":"about:blank"},l);var w={};this.trigger("form-pre-serialize",[this,l,w]);if(w.veto){d("ajaxSubmit: submit vetoed via form-pre-serialize trigger");return this}if(l.beforeSerialize&&l.beforeSerialize(this,l)===false){d("ajaxSubmit: submit aborted via beforeSerialize callback");return this}var p=l.traditional;if(typeof p==="undefined"){p=g.ajaxSettings.traditional}var u=[];var I,J=this.formToArray(l.semantic,u,l.filtering);if(l.data){var H=g.isFunction(l.data)?l.data(J):l.data;l.extraData=H;I=g.param(H,p)}if(l.beforeSubmit&&l.beforeSubmit(J,this,l)===false){d("ajaxSubmit: submit aborted via beforeSubmit callback");return this}this.trigger("form-submit-validate",[J,this,l,w]);if(w.veto){d("ajaxSubmit: submit vetoed via form-submit-validate trigger");return this}var A=g.param(J,p);if(I){A=(A?(A+"&"+I):I)}if(l.type.toUpperCase()==="GET"){l.url+=(l.url.indexOf("?")>=0?"&":"?")+A;l.data=null}else{l.data=A}var L=[];if(l.resetForm){L.push(function(){r.resetForm()})}if(l.clearForm){L.push(function(){r.clearForm(l.includeHidden)})}if(!l.dataType&&l.target){var m=l.success||function(){};L.push(function(O,P,N){var k=arguments,q=l.replaceTarget?"replaceWith":"html";g(l.target)[q](O).each(function(){m.apply(this,k)})})}else{if(l.success){if(g.isArray(l.success)){g.merge(L,l.success)}else{L.push(l.success)}}}l.success=function(P,q,Q){var O=l.context||this;for(var N=0,k=L.length;N<k;N++){L[N].apply(O,[P,q,Q||r,r])}};if(l.error){var B=l.error;l.error=function(O,k,q){var N=l.context||this;B.apply(N,[O,k,q,r])}}if(l.complete){var i=l.complete;l.complete=function(N,k){var q=l.context||this;i.apply(q,[N,k,r])}}var G=g("input[type=file]:enabled",this).filter(function(){return g(this).val()!==""});var s=G.length>0;var D="multipart/form-data";var z=(r.attr("enctype")===D||r.attr("encoding")===D);var y=c.fileapi&&c.formdata;d("fileAPI :"+y);var t=(s||z)&&!y;var x;if(l.iframe!==false&&(l.iframe||t)){if(l.closeKeepAlive){g.get(l.closeKeepAlive,function(){x=K(J)})}else{x=K(J)}}else{if((s||z)&&y){x=v(J)}else{x=g.ajax(l)}}r.removeData("jqxhr").data("jqxhr",x);for(var C=0;C<u.length;C++){u[C]=null}this.trigger("form-submit-notify",[this,l]);return this;function h(P){var Q=g.param(P,l.traditional).split("&");var q=Q.length;var k=[];var O,N;for(O=0;O<q;O++){Q[O]=Q[O].replace(/\+/g," ");N=Q[O].split("=");k.push([decodeURIComponent(N[0]),decodeURIComponent(N[1])])}return k}function v(q){var k=new FormData();for(var N=0;N<q.length;N++){k.append(q[N].name,q[N].value)}if(l.extraData){var Q=h(l.extraData);for(N=0;N<Q.length;N++){if(Q[N]){k.append(Q[N][0],Q[N][1])}}}l.data=null;var P=g.extend(true,{},g.ajaxSettings,l,{contentType:false,processData:false,cache:false,type:j||"POST"});if(l.uploadProgress){P.xhr=function(){var R=g.ajaxSettings.xhr();if(R.upload){R.upload.addEventListener("progress",function(V){var U=0;var S=V.loaded||V.position;var T=V.total;if(V.lengthComputable){U=Math.ceil(S/T*100)}l.uploadProgress(V,S,T,U)},false)}return R}}P.data=null;var O=P.beforeSend;P.beforeSend=function(S,R){if(l.formData){R.data=l.formData}else{R.data=k}if(O){O.call(this,S,R)}};return g.ajax(P)}function K(al){var Q=r[0],P,ah,aa,aj,ad,S,V,T,U,ae,ai,Z;var ap=g.Deferred();ap.abort=function(aq){T.abort(aq)};if(al){for(ah=0;ah<u.length;ah++){P=g(u[ah]);if(e){P.prop("disabled",false)}else{P.removeAttr("disabled")}}}aa=g.extend(true,{},g.ajaxSettings,l);aa.context=aa.context||aa;ad="jqFormIO"+new Date().getTime();var an=Q.ownerDocument;var ag=r.closest("body");if(aa.iframeTarget){S=g(aa.iframeTarget,an);ae=S.attr2("name");if(!ae){S.attr2("name",ad)}else{ad=ae}}else{S=g('<iframe name="'+ad+'" src="'+aa.iframeSrc+'" />',an);S.css({position:"absolute",top:"-1000px",left:"-1000px"})}V=S[0];T={aborted:0,responseText:null,responseXML:null,status:0,statusText:"n/a",getAllResponseHeaders:function(){},getResponseHeader:function(){},setRequestHeader:function(){},abort:function(aq){var ar=(aq==="timeout"?"timeout":"aborted");d("aborting upload... "+ar);this.aborted=1;try{if(V.contentWindow.document.execCommand){V.contentWindow.document.execCommand("Stop")}}catch(at){}S.attr("src",aa.iframeSrc);T.error=ar;if(aa.error){aa.error.call(aa.context,T,ar,aq)}if(aj){g.event.trigger("ajaxError",[T,aa,ar])}if(aa.complete){aa.complete.call(aa.context,T,ar)}}};aj=aa.global;if(aj&&g.active++===0){g.event.trigger("ajaxStart")}if(aj){g.event.trigger("ajaxSend",[T,aa])}if(aa.beforeSend&&aa.beforeSend.call(aa.context,T,aa)===false){if(aa.global){g.active--}ap.reject();return ap}if(T.aborted){ap.reject();return ap}U=Q.clk;if(U){ae=U.name;if(ae&&!U.disabled){aa.extraData=aa.extraData||{};aa.extraData[ae]=U.value;if(U.type==="image"){aa.extraData[ae+".x"]=Q.clk_x;aa.extraData[ae+".y"]=Q.clk_y}}}var Y=1;var W=2;function X(at){var ar=null;try{if(at.contentWindow){ar=at.contentWindow.document}}catch(aq){d("cannot get iframe.contentWindow document: "+aq)}if(ar){return ar}try{ar=at.contentDocument?at.contentDocument:at.document}catch(aq){d("cannot get iframe.contentDocument: "+aq);ar=at.document}return ar}var O=g("meta[name=csrf-token]").attr("content");var N=g("meta[name=csrf-param]").attr("content");if(N&&O){aa.extraData=aa.extraData||{};aa.extraData[N]=O}function af(){var az=r.attr2("target"),av=r.attr2("action"),at="multipart/form-data",aw=r.attr("enctype")||r.attr("encoding")||at;Q.setAttribute("target",ad);if(!j||/post/i.test(j)){Q.setAttribute("method","POST")}if(av!==aa.url){Q.setAttribute("action",aa.url)}if(!aa.skipEncodingOverride&&(!j||/post/i.test(j))){r.attr({encoding:"multipart/form-data",enctype:"multipart/form-data"})}if(aa.timeout){Z=setTimeout(function(){ai=true;ac(Y)},aa.timeout)}function ax(){try{var aA=X(V).readyState;d("state = "+aA);if(aA&&aA.toLowerCase()==="uninitialized"){setTimeout(ax,50)}}catch(aB){d("Server abort: ",aB," (",aB.name,")");ac(W);if(Z){clearTimeout(Z)}Z=undefined}}var ay=[];try{if(aa.extraData){for(var ar in aa.extraData){if(aa.extraData.hasOwnProperty(ar)){if(g.isPlainObject(aa.extraData[ar])&&aa.extraData[ar].hasOwnProperty("name")&&aa.extraData[ar].hasOwnProperty("value")){ay.push(g('<input type="hidden" name="'+aa.extraData[ar].name+'">',an).val(aa.extraData[ar].value).appendTo(Q)[0])}else{ay.push(g('<input type="hidden" name="'+ar+'">',an).val(aa.extraData[ar]).appendTo(Q)[0])}}}}if(!aa.iframeTarget){S.appendTo(ag)}if(V.attachEvent){V.attachEvent("onload",ac)}else{V.addEventListener("load",ac,false)}setTimeout(ax,15);try{Q.submit()}catch(au){var aq=document.createElement("form").submit;aq.apply(Q)}}finally{Q.setAttribute("action",av);Q.setAttribute("enctype",aw);if(az){Q.setAttribute("target",az)}else{r.removeAttr("target")}g(ay).remove()}}if(aa.forceSync){af()}else{setTimeout(af,10)}var am,ao,ak=50,R;function ac(ax){if(T.aborted||R){return}ao=X(V);if(!ao){d("cannot access response document");ax=W}if(ax===Y&&T){T.abort("timeout");ap.reject(T,"timeout");return}if(ax===W&&T){T.abort("server abort");ap.reject(T,"error","server abort");return}if(!ao||ao.location.href===aa.iframeSrc){if(!ai){return}}if(V.detachEvent){V.detachEvent("onload",ac)}else{V.removeEventListener("load",ac,false)}var av="success",az;try{if(ai){throw"timeout"}var au=aa.dataType==="xml"||ao.XMLDocument||g.isXMLDoc(ao);d("isXml="+au);if(!au&&window.opera&&(ao.body===null||!ao.body.innerHTML)){if(--ak){d("requeing onLoad callback, DOM not available");setTimeout(ac,250);return}}var aA=ao.body?ao.body:ao.documentElement;T.responseText=aA?aA.innerHTML:null;T.responseXML=ao.XMLDocument?ao.XMLDocument:ao;if(au){aa.dataType="xml"}T.getResponseHeader=function(aD){var aC={"content-type":aa.dataType};return aC[aD.toLowerCase()]};if(aA){T.status=Number(aA.getAttribute("status"))||T.status;T.statusText=aA.getAttribute("statusText")||T.statusText}var aq=(aa.dataType||"").toLowerCase();var ay=/(json|script|text)/.test(aq);if(ay||aa.textarea){var aw=ao.getElementsByTagName("textarea")[0];if(aw){T.responseText=aw.value;T.status=Number(aw.getAttribute("status"))||T.status;T.statusText=aw.getAttribute("statusText")||T.statusText}else{if(ay){var ar=ao.getElementsByTagName("pre")[0];var aB=ao.getElementsByTagName("body")[0];if(ar){T.responseText=ar.textContent?ar.textContent:ar.innerText}else{if(aB){T.responseText=aB.textContent?aB.textContent:aB.innerText}}}}}else{if(aq==="xml"&&!T.responseXML&&T.responseText){T.responseXML=ab(T.responseText)}}try{am=k(T,aq,aa)}catch(at){av="parsererror";T.error=az=(at||av)}}catch(at){d("error caught: ",at);av="error";T.error=az=(at||av)}if(T.aborted){d("upload aborted");av=null}if(T.status){av=((T.status>=200&&T.status<300)||T.status===304)?"success":"error"}if(av==="success"){if(aa.success){aa.success.call(aa.context,am,"success",T)}ap.resolve(T.responseText,"success",T);if(aj){g.event.trigger("ajaxSuccess",[T,aa])}}else{if(av){if(typeof az==="undefined"){az=T.statusText}if(aa.error){aa.error.call(aa.context,T,av,az)}ap.reject(T,"error",az);if(aj){g.event.trigger("ajaxError",[T,aa,az])}}}if(aj){g.event.trigger("ajaxComplete",[T,aa])}if(aj&&!--g.active){g.event.trigger("ajaxStop")}if(aa.complete){aa.complete.call(aa.context,T,av)}R=true;if(aa.timeout){clearTimeout(Z)}setTimeout(function(){if(!aa.iframeTarget){S.remove()}else{S.attr("src",aa.iframeSrc)}T.responseXML=null},100)}var ab=g.parseXML||function(aq,ar){if(window.ActiveXObject){ar=new ActiveXObject("Microsoft.XMLDOM");ar.async="false";ar.loadXML(aq)}else{ar=(new DOMParser()).parseFromString(aq,"text/xml")}return(ar&&ar.documentElement&&ar.documentElement.nodeName!=="parsererror")?ar:null};var q=g.parseJSON||function(aq){return window["eval"]("("+aq+")")};var k=function(aw,au,at){var ar=aw.getResponseHeader("content-type")||"",aq=((au==="xml"||!au)&&ar.indexOf("xml")>=0),av=aq?aw.responseXML:aw.responseText;if(aq&&av.documentElement.nodeName==="parsererror"){if(g.error){g.error("parsererror")}}if(at&&at.dataFilter){av=at.dataFilter(av,au)}if(typeof av==="string"){if((au==="json"||!au)&&ar.indexOf("json")>=0){av=q(av)}else{if((au==="script"||!au)&&ar.indexOf("javascript")>=0){g.globalEval(av)}}}return av};return ap}};g.fn.ajaxForm=function(i,j,h,l){if(typeof i==="string"||(i===false&&arguments.length>0)){i={url:i,data:j,dataType:h};if(typeof l==="function"){i.success=l}}i=i||{};i.delegation=i.delegation&&g.isFunction(g.fn.on);if(!i.delegation&&this.length===0){var k={s:this.selector,c:this.context};if(!g.isReady&&k.s){d("DOM not ready, queuing ajaxForm");g(function(){g(k.s,k.c).ajaxForm(i)});return this}d("terminating; zero elements found by selector"+(g.isReady?"":" (DOM not ready)"));return this}if(i.delegation){g(document).off("submit.form-plugin",this.selector,b).off("click.form-plugin",this.selector,a).on("submit.form-plugin",this.selector,i,b).on("click.form-plugin",this.selector,i,a);return this}return this.ajaxFormUnbind().on("submit.form-plugin",i,b).on("click.form-plugin",i,a)};function b(i){var h=i.data;if(!i.isDefaultPrevented()){i.preventDefault();g(i.target).closest("form").ajaxSubmit(h)}}function a(l){var k=l.target;var i=g(k);if(!i.is("[type=submit],[type=image]")){var h=i.closest("[type=submit]");if(h.length===0){return}k=h[0]}var j=k.form;j.clk=k;if(k.type==="image"){if(typeof l.offsetX!=="undefined"){j.clk_x=l.offsetX;j.clk_y=l.offsetY}else{if(typeof g.fn.offset==="function"){var m=i.offset();j.clk_x=l.pageX-m.left;j.clk_y=l.pageY-m.top}else{j.clk_x=l.pageX-k.offsetLeft;j.clk_y=l.pageY-k.offsetTop}}}setTimeout(function(){j.clk=j.clk_x=j.clk_y=null},100)}g.fn.ajaxFormUnbind=function(){return this.off("submit.form-plugin click.form-plugin")};g.fn.formToArray=function(p,s,A){var B=[];if(this.length===0){return B}var l=this[0];var C=this.attr("id");var m=(p||typeof l.elements==="undefined")?l.getElementsByTagName("*"):l.elements;var z;if(m){m=g.makeArray(m)}if(C&&(p||/(Edge|Trident)\//.test(navigator.userAgent))){z=g(':input[form="'+C+'"]').get();if(z.length){m=(m||[]).concat(z)}}if(!m||!m.length){return B}if(g.isFunction(A)){m=g.map(m,A)}var y,w,u,r,k,x,t;for(y=0,x=m.length;y<x;y++){k=m[y];u=k.name;if(!u||k.disabled){continue}if(p&&l.clk&&k.type==="image"){if(l.clk===k){B.push({name:u,value:g(k).val(),type:k.type});B.push({name:u+".x",value:l.clk_x},{name:u+".y",value:l.clk_y})}continue}r=g.fieldValue(k,true);if(r&&r.constructor===Array){if(s){s.push(k)}for(w=0,t=r.length;w<t;w++){B.push({name:u,value:r[w]})}}else{if(c.fileapi&&k.type==="file"){if(s){s.push(k)}var o=k.files;if(o.length){for(w=0;w<o.length;w++){B.push({name:u,value:o[w],type:k.type})}}else{B.push({name:u,value:"",type:k.type})}}else{if(r!==null&&typeof r!=="undefined"){if(s){s.push(k)}B.push({name:u,value:r,type:k.type,required:k.required})}}}}if(!p&&l.clk){var h=g(l.clk),q=h[0];u=q.name;if(u&&!q.disabled&&q.type==="image"){B.push({name:u,value:h.val()});B.push({name:u+".x",value:l.clk_x},{name:u+".y",value:l.clk_y})}}return B};g.fn.formSerialize=function(h){return g.param(this.formToArray(h))};g.fn.fieldSerialize=function(i){var h=[];this.each(function(){var m=this.name;if(!m){return}var k=g.fieldValue(this,i);if(k&&k.constructor===Array){for(var l=0,j=k.length;l<j;l++){h.push({name:m,value:k[l]})}}else{if(k!==null&&typeof k!=="undefined"){h.push({name:this.name,value:k})}}});return g.param(h)};g.fn.fieldValue=function(n){for(var m=[],k=0,h=this.length;k<h;k++){var l=this[k];var j=g.fieldValue(l,n);if(j===null||typeof j==="undefined"||(j.constructor===Array&&!j.length)){continue}if(j.constructor===Array){g.merge(m,j)}else{m.push(j)}}return m};g.fieldValue=function(h,p){var k=h.name,w=h.type,x=h.tagName.toLowerCase();if(typeof p==="undefined"){p=true}if(p&&(!k||h.disabled||w==="reset"||w==="button"||(w==="checkbox"||w==="radio")&&!h.checked||(w==="submit"||w==="image")&&h.form&&h.form.clk!==h||x==="select"&&h.selectedIndex===-1)){return null}if(x==="select"){var q=h.selectedIndex;if(q<0){return null}var s=[],j=h.options;var m=(w==="select-one");var r=(m?q+1:j.length);for(var l=(m?q:0);l<r;l++){var o=j[l];if(o.selected&&!o.disabled){var u=o.value;if(!u){u=(o.attributes&&o.attributes.value&&!(o.attributes.value.specified))?o.text:o.value}if(m){return u}s.push(u)}}return s}return g(h).val().replace(f,"\r\n")};g.fn.clearForm=function(h){return this.each(function(){g("input,select,textarea",this).clearFields(h)})};g.fn.clearFields=g.fn.clearInputs=function(h){var i=/^(?:color|date|datetime|email|month|number|password|range|search|tel|text|time|url|week)$/i;return this.each(function(){var k=this.type,j=this.tagName.toLowerCase();if(i.test(k)||j==="textarea"){this.value=""}else{if(k==="checkbox"||k==="radio"){this.checked=false}else{if(j==="select"){this.selectedIndex=-1}else{if(k==="file"){if(/MSIE/.test(navigator.userAgent)){g(this).replaceWith(g(this).clone(true))}else{g(this).val("")}}else{if(h){if((h===true&&/hidden/.test(k))||(typeof h==="string"&&g(this).is(h))){this.value=""}}}}}}})};g.fn.resetForm=function(){return this.each(function(){var j=g(this);var i=this.tagName.toLowerCase();switch(i){case"input":this.checked=this.defaultChecked;case"textarea":this.value=this.defaultValue;return true;case"option":case"optgroup":var h=j.parents("select");if(h.length&&h[0].multiple){if(i==="option"){this.selected=this.defaultSelected}else{j.find("option").resetForm()}}else{h.resetForm()}return true;case"select":j.find("option").each(function(m){this.selected=this.defaultSelected;if(this.defaultSelected&&!j[0].multiple){j[0].selectedIndex=m;return false}});return true;case"label":var k=g(j.attr("for"));var l=j.find("input,select,textarea");if(k[0]){l.unshift(k[0])}l.resetForm();return true;case"form":if(typeof this.reset==="function"||(typeof this.reset==="object"&&!this.reset.nodeType)){this.reset()}return true;default:j.find("form,input,label,select,textarea").resetForm();return true}})};g.fn.enable=function(h){if(typeof h==="undefined"){h=true}return this.each(function(){this.disabled=!h})};g.fn.selected=function(h){if(typeof h==="undefined"){h=true}return this.each(function(){var i=this.type;if(i==="checkbox"||i==="radio"){this.checked=h}else{if(this.tagName.toLowerCase()==="option"){var j=g(this).parent("select");if(h&&j[0]&&j[0].type==="select-one"){j.find("option").selected(false)}this.selected=h}}})};g.fn.ajaxSubmit.debug=false;function d(){if(!g.fn.ajaxSubmit.debug){return}var h="[jquery.form] "+Array.prototype.join.call(arguments,"");if(window.console&&window.console.log){window.console.log(h)}else{if(window.opera&&window.opera.postError){window.opera.postError(h)}}}})); | |
\ No newline at end of file |
@@ -1 +1 @@ | ||
1 | -(function($){$(window).load(function(event){var jForm=$("form#ajaxSubmit");((0<jForm.size())?jForm:$("form:first")).formMan2()});$.fn.sort=function(){return this.pushStack($.makeArray([].sort.apply(this,arguments)))};$.fn.formMan2=function(opts){var settings={sFMsgCls:"errmsg",sMsgSaved:"\u767b\u9332\u3057\u307e\u3057\u305f\u3002",sKeepCls:"unreplaceable",onRowPlace:null};$.extend(settings,$.hybs.defaults,opts||{});return this.each(function(){var oForm,mParams,formOpts;oForm=this;mParams={};mParams[settings.sAjxSbmtKey]="true";formOpts={};formOpts.data=mParams;formOpts.beforeSubmit=function(formData,jqForm,options){return(settings.beforeSubmit)?settings.beforeSubmit(formData,jqForm,options):true};formOpts.success=function(data,status,$form){var sHybsCmd,match,sUrl,sFrame,oFrame;sHybsCmd=$form.data($.hybs.defaults.sHybsCmd).cmd;if(data.indexOf("row_error")>=0){$(oForm).removeData($.hybs.defaults.sHybsCmd);isClicked=false;match=/(?:<\/table>)*[\S\s]*(\[\d+ - \d+\]\/\[\d+\])[\S\s]*(<table[^>]*?>[\S\s]+?row_error[\S\s]*<\/table>)/m.exec(data);$.hybs.ogAlert(match?(match[1]+match[2]):data)}else{if($.inArray(sHybsCmd,[settings.sCmdInsert,settings.sCmdCopy,settings.sCmdModify,settings.sCmdDelete,settings.sCmdEntry,settings.sCmdUndo])>=0){if(sHybsCmd==settings.sCmdEntry){match=/<div id="?noTransitionUrl"?>(.*)<\/div>[\s\S]*<div id="?noTransitionTarget"?>(.*)<\/div>/mi.exec(data);if(match){sUrl=match[1].replace(/&/g,"&");sFrame=match[2];oFrame=(sFrame!="null")?eval("top."+sFrame):window;oFrame=oFrame?oFrame:eval("top.CONTENTS."+sFrame);oFrame.location.href=sUrl}}}}};formOpts.error=function(xhr,status,e){$.hybs.ogLog(status+"\n"+xhr.responseText);$.hybs.ogAlert(status+"<br/>"+xhr.responseText)};formOpts.complete=function(xhr,status){};formOpts.cmds=formOpts.cmds||[settings.sCmdEntry];$(oForm).ajaxHybsForm(formOpts)})}})(jQuery); | |
\ No newline at end of file | ||
1 | +(function($){$(window).load(function(event){var jForm=$("form#ajaxSubmit");((0<jForm.size())?jForm:$("form:first")).formMan2()});$.fn.sort=function(){return this.pushStack($.makeArray([].sort.apply(this,arguments)))};$.fn.formMan2=function(opts){var settings={sFMsgCls:"errmsg",sMsgSaved:"\u767b\u9332\u3057\u307e\u3057\u305f\u3002",sKeepCls:"unreplaceable",onRowPlace:null};$.extend(settings,$.hybs.defaults,opts||{});return this.each(function(){var oForm,mParams,formOpts;oForm=this;mParams={};mParams[settings.sAjxSbmtKey]="true";formOpts={};formOpts.data=mParams;formOpts.beforeSubmit=function(formData,jqForm,options){return(settings.beforeSubmit)?settings.beforeSubmit(formData,jqForm,options):true};formOpts.success=function(data,status,$form){var sHybsCmd,match,sUrl,sFrame,oFrame;sHybsCmd=$("form").data($.hybs.defaults.sHybsCmd).cmd;if(data.indexOf("row_error")>=0){$(oForm).removeData($.hybs.defaults.sHybsCmd);isClicked=false;match=/(?:<\/table>)*[\S\s]*(\[\d+ - \d+\]\/\[\d+\])[\S\s]*(<table[^>]*?>[\S\s]+?row_error[\S\s]*<\/table>)/m.exec(data);$.hybs.ogAlert(match?(match[1]+match[2]):data)}else{if($.inArray(sHybsCmd,[settings.sCmdInsert,settings.sCmdCopy,settings.sCmdModify,settings.sCmdDelete,settings.sCmdEntry,settings.sCmdUndo])>=0){if(sHybsCmd==settings.sCmdEntry){match=/<div id="?noTransitionUrl"?>(.*)<\/div>[\s\S]*<div id="?noTransitionTarget"?>(.*)<\/div>/mi.exec(data);if(match){sUrl=match[1].replace(/&/g,"&");sFrame=match[2];oFrame=(sFrame!="null")?eval("top."+sFrame):window;oFrame=oFrame?oFrame:eval("top.CONTENTS."+sFrame);oFrame.location.href=sUrl}}}}};formOpts.error=function(xhr,status,e){$.hybs.ogLog(status+"\n"+xhr.responseText);$.hybs.ogAlert(status+"<br/>"+xhr.responseText)};formOpts.complete=function(xhr,status){};formOpts.cmds=formOpts.cmds||[settings.sCmdEntry];$(oForm).ajaxHybsForm(formOpts)})}})(jQuery); | |
\ No newline at end of file |
@@ -1 +1 @@ | ||
1 | -(function($){$(window).load(function(event){var jForm=$("form#noTransition");((0<jForm.size())?jForm:$("form:first")).formMan()});$.fn.sort=function(){return this.pushStack($.makeArray([].sort.apply(this,arguments)))};$.fn.formMan=function(opts){var settings={sFMsgCls:"errmsg",sMsgSaved:"\u767b\u9332\u3057\u307e\u3057\u305f\u3002",sKeepCls:"unreplaceable",onRowPlace:null};$.extend(settings,$.hybs.defaults,opts||{});return this.each(function(){var oForm=this;var replaceRow=function(jTr,sRowHtml,bHiLight){var sSrc,sClass;sSrc=jTr.find("."+settings.sKeepCls).attr("src");sClass=jTr.find("."+settings.sKeepCls).attr("class");jTr=$(sRowHtml).replaceAll(jTr);if(settings.onRowPlace){settings.onRowPlace(sHybsCmd,jTr)}else{if(sSrc){jTr.find("."+settings.sKeepCls).attr("src",sSrc)}if(sClass){jTr.find("."+settings.sKeepCls).removeClass().addClass(sClass)}}if(bHiLight&&!jTr.hasClass("row_hilight")){jTr.removeClass("row_0 row_1").addClass("row_hilight")}return jTr};var operateOnRows=function(jTab,jTr1st,sHybsCmd,data){var jChks=jTab.find("input[name="+settings.sHybsSel+"]:checked");var bHasChecked=(jChks.length>0);var jTBodyTr=$.hybs.getHybsTr(jTr1st);var bUnitRow=jTBodyTr.is("tr");var nKhColId=0;var nNoColId=$.hybs.getNoColId(jTab);var aDelRid=[],jTrFix2;var jTrs;switch(sHybsCmd){case settings.sCmdInsert:case settings.sCmdInsertOne:case settings.sCmdCopy:case settings.sCmdModify:case settings.sCmdDelete:case settings.sCmdUndo:case settings.sCmdEntry:if(bUnitRow){jTrs=(bHasChecked)?jChks.parents("tr"):jTBodyTr}else{jTrs=(bHasChecked)?jChks.parents("tbody"):jTBodyTr}break;default:break}jTrs.sort(function(a,b){return a.getAttribute(settings.sHybsRid,2)-b.getAttribute(settings.sHybsRid,2)});var bPassOnce=false;var match,re,sText;jTrs.each(function(index){if(sHybsCmd==settings.sCmdInsertOne&&index<jTrs.length-1){return}var jTr=$(this);if(sHybsCmd==settings.sCmdUndo&&"A"==jTr.attr(settings.sHybsKh)){if(!jTrFix2){jTrFix2=jTr.prev()}aDelRid.push(parseInt(jTr.attr(settings.sHybsRid),10));jTr.remove()}else{if(!bPassOnce){if(bUnitRow){match=/(<tbody[^>]*>[\S\s]*<\/tbody>)/m.exec(data);re=/(<tr[^>]*?>[\S\s]*?<\/tr>)/m}else{match=/(<tbody[^>]*>[\S\s]*<\/tbody>)/m.exec(data);re=/(<tbody[^>]*?>[\S\s]*?<\/tbody>)/m}if(match){sText=match[1]}bPassOnce=true}if(sText){match=re.exec(sText);if(match){var sRowText=match[1].replace(/<a href="#top"[^>]*><\/a>/m,"");var _checkedRow=jTr.find("input[name="+settings.sHybsSel+"]:first").val();if(!_checkedRow){_checkedRow=0}if(sHybsCmd==settings.sCmdCopy&&bHasChecked){_checkedRow++}var rowSel_reg=new RegExp('(<input type="checkbox" name="'+settings.sHybsSel+'"[^>]*>)',"m");sRowText=sRowText.replace(rowSel_reg,'$1<input type="hidden" name="'+settings.sSelRow+'" value="'+_checkedRow+'" />');var sNoCol,cChgType;switch(sHybsCmd){case settings.sCmdInsert:case settings.sCmdInsertOne:case settings.sCmdCopy:var jTrNew=(bHasChecked)?$(sRowText).insertAfter(jTr):$(sRowText).insertBefore(jTr);jTrNew.removeClass("row_0 row_1").addClass("row_hilight");if(0<=nNoColId){jTrNew.find("td:eq("+nNoColId+")").empty()}if(!jTr.attr(settings.sHybsKh)){jTr.find("input[name="+settings.sHybsSel+"]:first").removeAttr("checked")}bindEvents();break;case settings.sCmdModify:case settings.sCmdDelete:if(!jTr.attr(settings.sHybsKh)){sNoCol=((0<=nNoColId)?jTr.find("td:nth("+nNoColId+")").text():"");jTr=replaceRow(jTr,sRowText,true);if((0<=nNoColId)&&!sNoCol){jTr.find("td:nth("+nNoColId+")").empty()}}bindEvents(jTr);break;case settings.sCmdEntry:cChgType=jTr.attr(settings.sHybsKh)||"";sNoCol=((0<=nNoColId)?jTr.find("td:nth("+nNoColId+")").text():"");var bChecked=jTr.find("input[name="+settings.sHybsSel+"]:first").attr("checked");jTr=replaceRow(jTr,sRowText,true);if(bChecked){switch(cChgType){case"D":if(!jTrFix2){jTrFix2=jTr.prev()}aDelRid.push(parseInt(jTr.attr(settings.sHybsRid),10));jTr.remove();break;case"A":case"C":if(0<=nKhColId){jTr.find("td:eq("+nKhColId+")").empty()}jTr.removeAttr(settings.sHybsKh);jTr.find("input[name="+settings.sHybsSel+"]:first").removeAttr("checked");if((0<=nNoColId)&&!sNoCol){jTr.find("td:nth("+nNoColId+")").empty()}break;default:break}}$("."+settings.sFMsgCls).html(settings.sMsgSaved);bindEvents(jTr);break;case settings.sCmdUndo:cChgType=jTr.attr(settings.sHybsKh)||"";sNoCol=((0<=nNoColId)?jTr.find("td:nth("+nNoColId+")").text():"");jTr=replaceRow(jTr,sRowText,true);switch(cChgType){case"C":case"D":if(0<=nKhColId){jTr.find("td:eq("+nKhColId+")").empty()}jTr.removeAttr(settings.sHybsKh);jTr.find("input[name="+settings.sHybsSel+"]:first").removeAttr("checked");if((0<=nNoColId)&&!sNoCol){jTr.find("td:nth("+nNoColId+")").empty()}break;default:break}bindEvents(jTr);break;default:break}sText=sText.substr(match.index+match[0].length)}}}});if(jTrFix2){var jRun;var bHasTrFix=jTrFix2[0]&&(bUnitRow?jTrFix2.parent().is("tbody"):jTrFix2.children(":first").is("tr"));if(bHasTrFix){jRun=jTrFix2.next()}else{jTBodyTr=jTab.find("tbody tr:first");jRun=bUnitRow?jTBodyTr:jTBodyTr.parent()}aDelRid.sort();var nDelLen=aDelRid.length;while(jRun[0]){var nDiff=0,nRidRun=parseInt(jRun.attr(settings.sHybsRid),10);for(var iCntUp=(nDelLen-1);0<=iCntUp;iCntUp--){if(nRidRun>aDelRid[iCntUp]){nDiff=iCntUp+1;break}}if(nDiff>0){nRidRun-=nDiff;jRun.attr(settings.sHybsRid,nRidRun).find("input[name="+settings.sHybsSel+"]:first").attr({id:"cb"+nRidRun,value:nRidRun});if(0<=nNoColId){var jNoCol=jRun.find("td:nth("+nNoColId+")");if(jNoCol.text()){jNoCol.text(nRidRun+1)}}}jRun=jRun.next()}$("tbody:first:not(:has(tr:first-child))",jTab).remove()}if(jTrs.length>0){jTab.resizeView();buttonControl()}};var addToNoTBody=function(jTab,sCmd,data){if(sCmd==settings.sCmdInsert||sCmd==settings.sCmdInsertOne||sCmd==settings.sCmdCopy){var match=/(?:<tbody>)?\r?\n?(<tbody>[\S\s]*<\/tbody>)\r?\n?(?:<\/tbody>)?/m.exec(data);if(match){var sText=$.trim(match[1].replace(/<a href="#top"[^>]*><\/a>/m,""));if(sText){jTab.append(sText);jTab.resizeView();buttonControl();bindEvents(jTab)}}}};var addToNoTable=function(jForm,sCmd,data){if(sCmd==settings.sCmdInsert||sCmd==settings.sCmdInsertOne||sCmd==settings.sCmdCopy){var match=/(<div id="divHlr)|(\[\d+ - \d+\]\/\[\d+\])|(<div id="divPos)|(<table id="viewTable)/m.exec(data);if(match){match=/([\S\s]*<table[^>]*?>[\S\s]*<\/table>[\S\s]*)/m.exec(data.substr(match.index));if(match){var jPSize=$("input:hidden[name=pageSize]",jForm);jPSize.prev("div[onclick]:empty").remove();jPSize.nextAll().andSelf().remove();jForm.append(match[1]);var jTab=jForm.find("table#viewTable");jTab.resizeView(true);buttonControl();bindEvents(jTab)}}}};var buttonControl=function(isInit){var jForm=$(oForm);var jBtnEnt=jForm.find("input:submit."+settings.sEntryCls);if(isInit){jBtnEnt.attr("disabled","disabled")}else{var jBtnMess=$(jForm.data($.hybs.defaults.sHybsCmd).obj);if(jBtnMess.hasClass(settings.sEditCls)){jBtnEnt.removeAttr("disabled")}if(jBtnMess.hasClass(settings.sEntryCls)){jBtnEnt.attr("disabled","disabled")}}};var mParams={};mParams[settings.sNoTsKey]="true";var formOpts={};formOpts.data=mParams;formOpts.beforeSubmit=function(formData,jqForm,options){return(settings.beforeSubmit)?settings.beforeSubmit(formData,jqForm,options):true};formOpts.success=function(data,status,$form){var sHybsCmd=$form.data($.hybs.defaults.sHybsCmd).cmd;var match;if(data.indexOf("row_error")>=0){match=/(?:<\/table>)*[\S\s]*(\[\d+ - \d+\]\/\[\d+\])[\S\s]*(<table[^>]*?>[\S\s]+?row_error[\S\s]*<\/table>)/m.exec(data);$.hybs.ogAlert(match?(match[1]+match[2]):data)}else{if($.inArray(sHybsCmd,[settings.sCmdInsert,settings.sCmdInsertOne,settings.sCmdCopy,settings.sCmdModify,settings.sCmdDelete,settings.sCmdEntry,settings.sCmdUndo])>=0){var bSpecialCase=false;if(sHybsCmd==settings.sCmdEntry){match=/<div id="noTransitionUrl">(.*)<\/div><div id="noTransitionTarget">(.*)<\/div>/m.exec(data);if(match){var sUrl=match[1];var sFrame=match[2];var oFrame=(sFrame!="null")?eval("top."+sFrame):window;oFrame.location.href=sUrl;bSpecialCase=true}}if(!bSpecialCase){var jTab=$form.find("table#viewTable"),jTr1st=jTab.find("tbody tr:first");if(jTr1st[0]){operateOnRows(jTab,jTr1st,sHybsCmd,data)}else{if(jTab[0]){addToNoTBody(jTab,sHybsCmd,data)}else{addToNoTable($form,sHybsCmd,data)}}}}}};formOpts.error=function(xhr,status,e){$.hybs.ogLog(status+"\n"+xhr.responseText);$.hybs.ogAlert(status+"<br/>"+xhr.responseText)};formOpts.complete=function(xhr,status){$(oForm).removeData($.hybs.defaults.sHybsCmd)};formOpts.cmds=formOpts.cmds||[settings.sCmdInsert,settings.sCmdInsertOne,settings.sCmdCopy,settings.sCmdModify,settings.sCmdDelete,settings.sCmdEntry,settings.sCmdUndo];buttonControl(true);$(oForm).ajaxHybsForm(formOpts)})}})(jQuery); | |
\ No newline at end of file | ||
1 | +(function($){$(window).load(function(event){var jForm=$("form#noTransition");((0<jForm.size())?jForm:$("form:first")).formMan()});$.fn.sort=function(){return this.pushStack($.makeArray([].sort.apply(this,arguments)))};$.fn.formMan=function(opts){var settings={sFMsgCls:"errmsg",sMsgSaved:"\u767b\u9332\u3057\u307e\u3057\u305f\u3002",sKeepCls:"unreplaceable",onRowPlace:null};$.extend(settings,$.hybs.defaults,opts||{});return this.each(function(){var oForm=this;var replaceRow=function(jTr,sRowHtml,bHiLight){var sSrc,sClass;sSrc=jTr.find("."+settings.sKeepCls).attr("src");sClass=jTr.find("."+settings.sKeepCls).attr("class");jTr=$(sRowHtml).replaceAll(jTr);if(settings.onRowPlace){settings.onRowPlace(sHybsCmd,jTr)}else{if(sSrc){jTr.find("."+settings.sKeepCls).attr("src",sSrc)}if(sClass){jTr.find("."+settings.sKeepCls).removeClass().addClass(sClass)}}if(bHiLight&&!jTr.hasClass("row_hilight")){jTr.removeClass("row_0 row_1").addClass("row_hilight")}return jTr};var operateOnRows=function(jTab,jTr1st,sHybsCmd,data){var jChks=jTab.find("input[name="+settings.sHybsSel+"]:checked");var bHasChecked=(jChks.length>0);var jTBodyTr=$.hybs.getHybsTr(jTr1st);var bUnitRow=jTBodyTr.is("tr");var nKhColId=0;var nNoColId=$.hybs.getNoColId(jTab);var aDelRid=[],jTrFix2;var jTrs;switch(sHybsCmd){case settings.sCmdInsert:case settings.sCmdInsertOne:case settings.sCmdCopy:case settings.sCmdModify:case settings.sCmdDelete:case settings.sCmdUndo:case settings.sCmdEntry:if(bUnitRow){jTrs=(bHasChecked)?jChks.parents("tr"):jTBodyTr}else{jTrs=(bHasChecked)?jChks.parents("tbody"):jTBodyTr}break;default:break}jTrs.sort(function(a,b){return a.getAttribute(settings.sHybsRid,2)-b.getAttribute(settings.sHybsRid,2)});var bPassOnce=false;var match,re,sText;jTrs.each(function(index){if(sHybsCmd==settings.sCmdInsertOne&&index<jTrs.length-1){return}var jTr=$(this);if(sHybsCmd==settings.sCmdUndo&&"A"==jTr.attr(settings.sHybsKh)){if(!jTrFix2){jTrFix2=jTr.prev()}aDelRid.push(parseInt(jTr.attr(settings.sHybsRid),10));jTr.remove()}else{if(!bPassOnce){if(bUnitRow){match=/(<tbody[^>]*>[\S\s]*<\/tbody>)/m.exec(data);re=/(<tr[^>]*?>[\S\s]*?<\/tr>)/m}else{match=/(<tbody[^>]*>[\S\s]*<\/tbody>)/m.exec(data);re=/(<tbody[^>]*?>[\S\s]*?<\/tbody>)/m}if(match){sText=match[1]}bPassOnce=true}if(sText){match=re.exec(sText);if(match){var sRowText=match[1].replace(/<a href="#top"[^>]*><\/a>/m,"");var _checkedRow=jTr.find("input[name="+settings.sHybsSel+"]:first").val();if(!_checkedRow){_checkedRow=0}if(sHybsCmd==settings.sCmdCopy&&bHasChecked){_checkedRow++}var rowSel_reg=new RegExp('(<input type="checkbox" name="'+settings.sHybsSel+'"[^>]*>)',"m");sRowText=sRowText.replace(rowSel_reg,'$1<input type="hidden" name="'+settings.sSelRow+'" value="'+_checkedRow+'" />');var sNoCol,cChgType;switch(sHybsCmd){case settings.sCmdInsert:case settings.sCmdInsertOne:case settings.sCmdCopy:var jTrNew=(bHasChecked)?$(sRowText).insertAfter(jTr):$(sRowText).insertBefore(jTr);jTrNew.removeClass("row_0 row_1").addClass("row_hilight");if(0<=nNoColId){jTrNew.find("td:eq("+nNoColId+")").empty()}if(!jTr.attr(settings.sHybsKh)){jTr.find("input[name="+settings.sHybsSel+"]:first").removeAttr("checked")}bindEvents();break;case settings.sCmdModify:case settings.sCmdDelete:if(!jTr.attr(settings.sHybsKh)){sNoCol=((0<=nNoColId)?jTr.find("td:nth("+nNoColId+")").text():"");jTr=replaceRow(jTr,sRowText,true);if((0<=nNoColId)&&!sNoCol){jTr.find("td:nth("+nNoColId+")").empty()}}bindEvents(jTr);break;case settings.sCmdEntry:cChgType=jTr.attr(settings.sHybsKh)||"";sNoCol=((0<=nNoColId)?jTr.find("td:nth("+nNoColId+")").text():"");var bChecked=jTr.find("input[name="+settings.sHybsSel+"]:first").attr("checked");jTr=replaceRow(jTr,sRowText,true);if(bChecked){switch(cChgType){case"D":if(!jTrFix2){jTrFix2=jTr.prev()}aDelRid.push(parseInt(jTr.attr(settings.sHybsRid),10));jTr.remove();break;case"A":case"C":if(0<=nKhColId){jTr.find("td:eq("+nKhColId+")").empty()}jTr.removeAttr(settings.sHybsKh);jTr.find("input[name="+settings.sHybsSel+"]:first").removeAttr("checked");if((0<=nNoColId)&&!sNoCol){jTr.find("td:nth("+nNoColId+")").empty()}break;default:break}}$("."+settings.sFMsgCls).html(settings.sMsgSaved);bindEvents(jTr);break;case settings.sCmdUndo:cChgType=jTr.attr(settings.sHybsKh)||"";sNoCol=((0<=nNoColId)?jTr.find("td:nth("+nNoColId+")").text():"");jTr=replaceRow(jTr,sRowText,true);switch(cChgType){case"C":case"D":if(0<=nKhColId){jTr.find("td:eq("+nKhColId+")").empty()}jTr.removeAttr(settings.sHybsKh);jTr.find("input[name="+settings.sHybsSel+"]:first").removeAttr("checked");if((0<=nNoColId)&&!sNoCol){jTr.find("td:nth("+nNoColId+")").empty()}break;default:break}bindEvents(jTr);break;default:break}sText=sText.substr(match.index+match[0].length)}}}});if(jTrFix2){var jRun;var bHasTrFix=jTrFix2[0]&&(bUnitRow?jTrFix2.parent().is("tbody"):jTrFix2.children(":first").is("tr"));if(bHasTrFix){jRun=jTrFix2.next()}else{jTBodyTr=jTab.find("tbody tr:first");jRun=bUnitRow?jTBodyTr:jTBodyTr.parent()}aDelRid.sort();var nDelLen=aDelRid.length;while(jRun[0]){var nDiff=0,nRidRun=parseInt(jRun.attr(settings.sHybsRid),10);for(var iCntUp=(nDelLen-1);0<=iCntUp;iCntUp--){if(nRidRun>aDelRid[iCntUp]){nDiff=iCntUp+1;break}}if(nDiff>0){nRidRun-=nDiff;jRun.attr(settings.sHybsRid,nRidRun).find("input[name="+settings.sHybsSel+"]:first").attr({id:"cb"+nRidRun,value:nRidRun});if(0<=nNoColId){var jNoCol=jRun.find("td:nth("+nNoColId+")");if(jNoCol.text()){jNoCol.text(nRidRun+1)}}}jRun=jRun.next()}$("tbody:first:not(:has(tr:first-child))",jTab).remove()}if(jTrs.length>0){jTab.resizeView();buttonControl()}};var addToNoTBody=function(jTab,sCmd,data){if(sCmd==settings.sCmdInsert||sCmd==settings.sCmdInsertOne||sCmd==settings.sCmdCopy){var match=/(?:<tbody>)?\r?\n?(<tbody>[\S\s]*<\/tbody>)\r?\n?(?:<\/tbody>)?/m.exec(data);if(match){var sText=$.trim(match[1].replace(/<a href="#top"[^>]*><\/a>/m,""));if(sText){jTab.append(sText);jTab.resizeView();buttonControl();bindEvents(jTab)}}}};var addToNoTable=function(jForm,sCmd,data){if(sCmd==settings.sCmdInsert||sCmd==settings.sCmdInsertOne||sCmd==settings.sCmdCopy){var match=/(<div id="divHlr)|(\[\d+ - \d+\]\/\[\d+\])|(<div id="divPos)|(<table id="viewTable)/m.exec(data);if(match){match=/([\S\s]*<table[^>]*?>[\S\s]*<\/table>[\S\s]*)/m.exec(data.substr(match.index));if(match){var jPSize=$("input:hidden[name=pageSize]",jForm);jPSize.prev("div[onclick]:empty").remove();jPSize.nextAll().andSelf().remove();jForm.append(match[1]);var jTab=jForm.find("table#viewTable");jTab.resizeView(true);buttonControl();bindEvents(jTab)}}}};var buttonControl=function(isInit){var jForm=$(oForm);var jBtnEnt=jForm.find("input:submit."+settings.sEntryCls);if(isInit){jBtnEnt.attr("disabled","disabled")}else{var jBtnMess=$(jForm.data($.hybs.defaults.sHybsCmd).obj);if(jBtnMess.hasClass(settings.sEditCls)){jBtnEnt.removeAttr("disabled")}if(jBtnMess.hasClass(settings.sEntryCls)){jBtnEnt.attr("disabled","disabled")}}};var mParams={};mParams[settings.sNoTsKey]="true";var formOpts={};formOpts.data=mParams;formOpts.beforeSubmit=function(formData,jqForm,options){return(settings.beforeSubmit)?settings.beforeSubmit(formData,jqForm,options):true};formOpts.success=function(data,status,$form){var sHybsCmd=$("form").data($.hybs.defaults.sHybsCmd).cmd;var match;if(data.indexOf("row_error")>=0){match=/(?:<\/table>)*[\S\s]*(\[\d+ - \d+\]\/\[\d+\])[\S\s]*(<table[^>]*?>[\S\s]+?row_error[\S\s]*<\/table>)/m.exec(data);$.hybs.ogAlert(match?(match[1]+match[2]):data)}else{if($.inArray(sHybsCmd,[settings.sCmdInsert,settings.sCmdInsertOne,settings.sCmdCopy,settings.sCmdModify,settings.sCmdDelete,settings.sCmdEntry,settings.sCmdUndo])>=0){var bSpecialCase=false;if(sHybsCmd==settings.sCmdEntry){match=/<div id="noTransitionUrl">(.*)<\/div><div id="noTransitionTarget">(.*)<\/div>/m.exec(data);if(match){var sUrl=match[1];var sFrame=match[2];var oFrame=(sFrame!="null")?eval("top."+sFrame):window;oFrame.location.href=sUrl;bSpecialCase=true}}if(!bSpecialCase){var jTab=$form.find("table#viewTable"),jTr1st=jTab.find("tbody tr:first");if(jTr1st[0]){operateOnRows(jTab,jTr1st,sHybsCmd,data)}else{if(jTab[0]){addToNoTBody(jTab,sHybsCmd,data)}else{addToNoTable($form,sHybsCmd,data)}}}}}};formOpts.error=function(xhr,status,e){$.hybs.ogLog(status+"\n"+xhr.responseText);$.hybs.ogAlert(status+"<br/>"+xhr.responseText)};formOpts.complete=function(xhr,status){$(oForm).removeData($.hybs.defaults.sHybsCmd)};formOpts.cmds=formOpts.cmds||[settings.sCmdInsert,settings.sCmdInsertOne,settings.sCmdCopy,settings.sCmdModify,settings.sCmdDelete,settings.sCmdEntry,settings.sCmdUndo];buttonControl(true);$(oForm).ajaxHybsForm(formOpts)})}})(jQuery); | |
\ No newline at end of file |
@@ -1 +1,22 @@ | ||
1 | -(function(b){b.fn.ajaxSubmit=function(l){if(!this.length){a("ajaxSubmit: skipping submit process - no element selected");return this}if(typeof l=="function"){l={success:l}}l=b.extend({url:this.attr("action")||window.location.toString(),type:this.attr("method")||"GET"},l||{});var o={};this.trigger("form-pre-serialize",[this,l,o]);if(o.veto){a("ajaxSubmit: submit vetoed via form-pre-serialize trigger");return this}if(l.beforeSerialize&&l.beforeSerialize(this,l)===false){a("ajaxSubmit: submit aborted via beforeSerialize callback");return this}var g=this.formToArray(l.semantic);if(l.data){l.extraData=l.data;for(var d in l.data){if(l.data[d] instanceof Array){for(var e in l.data[d]){g.push({name:d,value:l.data[d][e]})}}else{g.push({name:d,value:l.data[d]})}}}if(l.beforeSubmit&&l.beforeSubmit(g,this,l)===false){a("ajaxSubmit: submit aborted via beforeSubmit callback");return this}this.trigger("form-submit-validate",[g,this,l,o]);if(o.veto){a("ajaxSubmit: submit vetoed via form-submit-validate trigger");return this}var c=b.param(g);if(l.type.toUpperCase()=="GET"){l.url+=(l.url.indexOf("?")>=0?"&":"?")+c;l.data=null}else{l.data=c}var m=this,f=[];if(l.resetForm){f.push(function(){m.resetForm()})}if(l.clearForm){f.push(function(){m.clearForm()})}if(!l.dataType&&l.target){var i=l.success||function(){};f.push(function(k){b(l.target).html(k).each(i,arguments)})}else{if(l.success){f.push(l.success)}}l.success=function(q,n){for(var p=0,k=f.length;p<k;p++){f[p].apply(l,[q,n,m])}};var j=b("input:file",this).length>0?true:false;if(l.iframe||j){if(l.closeKeepAlive){b.get(l.closeKeepAlive,h)}else{h()}}else{b.ajax(l)}this.trigger("form-submit-notify",[this,l]);return this;function h(){var t=m[0];if(b(":input[name=submit]",t).length){alert('Error: Form elements must not be named "submit".');return}var q=b.extend({},b.ajaxSettings,l);var D=jQuery.extend(true,{},b.extend(true,{},b.ajaxSettings),q);var r="jqFormIO"+(new Date().getTime());var z=b('<iframe id="'+r+'" name="'+r+'" src="about:blank" />');var B=z[0];z.css({position:"absolute",top:"-1000px",left:"-1000px"});var C={aborted:0,responseText:null,responseXML:null,status:0,statusText:"n/a",getAllResponseHeaders:function(){},getResponseHeader:function(){},setRequestHeader:function(){},abort:function(){this.aborted=1;z.attr("src","about:blank")}};var A=q.global;if(A&&!b.active++){b.event.trigger("ajaxStart")}if(A){b.event.trigger("ajaxSend",[C,q])}if(D.beforeSend&&D.beforeSend(C,D)===false){D.global&&jQuery.active--;return}if(C.aborted){return}var p=0;var v=0;var k=t.clk;if(k){var u=k.name;if(u&&!k.disabled){l.extraData=l.extraData||{};l.extraData[u]=k.value;if(k.type=="image"){l.extraData[name+".x"]=t.clk_x;l.extraData[name+".y"]=t.clk_y}}}setTimeout(function(){var F=m.attr("target"),s=m.attr("action");t.setAttribute("target",r);if(t.getAttribute("method")!="POST"){t.setAttribute("method","POST")}if(t.getAttribute("action")!=q.url){t.setAttribute("action",q.url)}if(!l.skipEncodingOverride){m.attr({encoding:"multipart/form-data",enctype:"multipart/form-data"})}if(q.timeout){setTimeout(function(){v=true;w()},q.timeout)}var E=[];try{if(l.extraData){for(var G in l.extraData){E.push(b('<input type="hidden" name="'+G+'" value="'+l.extraData[G]+'" />').appendTo(t)[0])}}z.appendTo("body");B.attachEvent?B.attachEvent("onload",w):B.addEventListener("load",w,false);t.submit()}finally{t.setAttribute("action",s);F?t.setAttribute("target",F):m.removeAttr("target");b(E).remove()}},10);var x=0;function w(){if(p++){return}B.detachEvent?B.detachEvent("onload",w):B.removeEventListener("load",w,false);var s=true;try{if(v){throw"timeout"}var E,G;G=B.contentWindow?B.contentWindow.document:B.contentDocument?B.contentDocument:B.document;if((G.body==null||G.body.innerHTML=="")&&!x){x=1;p--;setTimeout(w,100);return}C.responseText=G.body?G.body.innerHTML:null;C.responseXML=G.XMLDocument?G.XMLDocument:G;C.getResponseHeader=function(I){var H={"content-type":q.dataType};return H[I]};if(q.dataType=="json"||q.dataType=="script"){var n=G.getElementsByTagName("textarea")[0];C.responseText=n?n.value:C.responseText}else{if(q.dataType=="xml"&&!C.responseXML&&C.responseText!=null){C.responseXML=y(C.responseText)}}E=b.httpData(C,q.dataType)}catch(F){s=false;b.handleError(q,C,"error",F)}if(s){q.success(E,"success");if(A){b.event.trigger("ajaxSuccess",[C,q])}}if(A){b.event.trigger("ajaxComplete",[C,q])}if(A&&!--b.active){b.event.trigger("ajaxStop")}if(q.complete){q.complete(C,s?"success":"error")}setTimeout(function(){z.remove();C.responseXML=null},100)}function y(n,E){if(window.ActiveXObject){E=new ActiveXObject("Microsoft.XMLDOM");E.async="false";E.loadXML(n)}else{E=(new DOMParser()).parseFromString(n,"text/xml")}return(E&&E.documentElement&&E.documentElement.tagName!="parsererror")?E:null}}};b.fn.ajaxForm=function(c){return this.ajaxFormUnbind().bind("submit.form-plugin",function(){b(this).ajaxSubmit(c);return false}).each(function(){b(":submit,input:image",this).bind("click.form-plugin",function(f){var d=this.form;d.clk=this;if(this.type=="image"){if(f.offsetX!=undefined){d.clk_x=f.offsetX;d.clk_y=f.offsetY}else{if(typeof b.fn.offset=="function"){var g=b(this).offset();d.clk_x=f.pageX-g.left;d.clk_y=f.pageY-g.top}else{d.clk_x=f.pageX-this.offsetLeft;d.clk_y=f.pageY-this.offsetTop}}}setTimeout(function(){d.clk=d.clk_x=d.clk_y=null},10)})})};b.fn.ajaxFormUnbind=function(){this.unbind("submit.form-plugin");return this.each(function(){b(":submit,input:image",this).unbind("click.form-plugin")})};b.fn.formToArray=function(q){var p=[];if(this.length==0){return p}var d=this[0];var h=q?d.getElementsByTagName("*"):d.elements;if(!h){return p}for(var k=0,m=h.length;k<m;k++){var e=h[k];var f=e.name;if(!f){continue}if(q&&d.clk&&e.type=="image"){if(!e.disabled&&d.clk==e){p.push({name:f+".x",value:d.clk_x},{name:f+".y",value:d.clk_y})}continue}var r=b.fieldValue(e,true);if(r&&r.constructor==Array){for(var g=0,c=r.length;g<c;g++){p.push({name:f,value:r[g]})}}else{if(r!==null&&typeof r!="undefined"){p.push({name:f,value:r})}}}if(!q&&d.clk){var l=d.getElementsByTagName("input");for(var k=0,m=l.length;k<m;k++){var o=l[k];var f=o.name;if(f&&!o.disabled&&o.type=="image"&&d.clk==o){p.push({name:f+".x",value:d.clk_x},{name:f+".y",value:d.clk_y})}}}return p};b.fn.formSerialize=function(c){return b.param(this.formToArray(c))};b.fn.fieldSerialize=function(d){var c=[];this.each(function(){var h=this.name;if(!h){return}var f=b.fieldValue(this,d);if(f&&f.constructor==Array){for(var g=0,e=f.length;g<e;g++){c.push({name:h,value:f[g]})}}else{if(f!==null&&typeof f!="undefined"){c.push({name:this.name,value:f})}}});return b.param(c)};b.fn.fieldValue=function(h){for(var g=[],e=0,c=this.length;e<c;e++){var f=this[e];var d=b.fieldValue(f,h);if(d===null||typeof d=="undefined"||(d.constructor==Array&&!d.length)){continue}d.constructor==Array?b.merge(g,d):g.push(d)}return g};b.fieldValue=function(c,j){var e=c.name,p=c.type,q=c.tagName.toLowerCase();if(typeof j=="undefined"){j=true}if(j&&(!e||c.disabled||p=="reset"||p=="button"||(p=="checkbox"||p=="radio")&&!c.checked||(p=="submit"||p=="image")&&c.form&&c.form.clk!=c||q=="select"&&c.selectedIndex==-1)){return null}if(q=="select"){var k=c.selectedIndex;if(k<0){return null}var m=[],d=c.options;var g=(p=="select-one");var l=(g?k+1:d.length);for(var f=(g?k:0);f<l;f++){var h=d[f];if(h.selected){var o=h.value;if(!o){o=(h.attributes&&h.attributes.value&&!(h.attributes.value.specified))?h.text:h.value}if(g){return o}m.push(o)}}return m}return c.value};b.fn.clearForm=function(){return this.each(function(){b("input,select,textarea",this).clearFields()})};b.fn.clearFields=b.fn.clearInputs=function(){return this.each(function(){var d=this.type,c=this.tagName.toLowerCase();if(d=="text"||d=="password"||c=="textarea"){this.value=""}else{if(d=="checkbox"||d=="radio"){this.checked=false}else{if(c=="select"){this.selectedIndex=-1}}}})};b.fn.resetForm=function(){return this.each(function(){if(typeof this.reset=="function"||(typeof this.reset=="object"&&!this.reset.nodeType)){this.reset()}})};b.fn.enable=function(c){if(c==undefined){c=true}return this.each(function(){this.disabled=!c})};b.fn.selected=function(c){if(c==undefined){c=true}return this.each(function(){var d=this.type;if(d=="checkbox"||d=="radio"){this.checked=c}else{if(this.tagName.toLowerCase()=="option"){var e=b(this).parent("select");if(c&&e[0]&&e[0].type=="select-one"){e.find("option").selected(false)}this.selected=c}}})};function a(){if(b.fn.ajaxSubmit.debug&&window.console&&window.console.log){window.console.log("[jquery.form] "+Array.prototype.join.call(arguments,""))}}})(jQuery); | |
\ No newline at end of file | ||
1 | +/*! | |
2 | + * jQuery Form Plugin | |
3 | + * version: 4.2.2 | |
4 | + * Requires jQuery v1.7.2 or later | |
5 | + * Project repository: https://github.com/jquery-form/form | |
6 | + | |
7 | + * Copyright 2017 Kevin Morris | |
8 | + * Copyright 2006 M. Alsup | |
9 | + | |
10 | + * Dual licensed under the LGPL-2.1+ or MIT licenses | |
11 | + * https://github.com/jquery-form/form#license | |
12 | + | |
13 | + * This library is free software; you can redistribute it and/or | |
14 | + * modify it under the terms of the GNU Lesser General Public | |
15 | + * License as published by the Free Software Foundation; either | |
16 | + * version 2.1 of the License, or (at your option) any later version. | |
17 | + * This library is distributed in the hope that it will be useful, | |
18 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
20 | + * Lesser General Public License for more details. | |
21 | + */ | |
22 | +(function(a){if(typeof define==="function"&&define.amd){define(["jquery"],a)}else{if(typeof module==="object"&&module.exports){module.exports=function(b,c){if(typeof c==="undefined"){if(typeof window!=="undefined"){c=require("jquery")}else{c=require("jquery")(b)}}a(c);return c}}else{a(jQuery)}}}(function(g){var f=/\r?\n/g;var c={};c.fileapi=g('<input type="file">').get(0).files!==undefined;c.formdata=(typeof window.FormData!=="undefined");var e=!!g.fn.prop;g.fn.attr2=function(){if(!e){return this.attr.apply(this,arguments)}var h=this.prop.apply(this,arguments);if((h&&h.jquery)||typeof h==="string"){return h}return this.attr.apply(this,arguments)};g.fn.ajaxSubmit=function(l,M,E,o){if(!this.length){d("ajaxSubmit: skipping submit process - no element selected");return this}var j,F,n,r=this;if(typeof l==="function"){l={success:l}}else{if(typeof l==="string"||(l===false&&arguments.length>0)){l={url:l,data:M,dataType:E};if(typeof o==="function"){l.success=o}}else{if(typeof l==="undefined"){l={}}}}j=l.method||l.type||this.attr2("method");F=l.url||this.attr2("action");n=(typeof F==="string")?g.trim(F):"";n=n||window.location.href||"";if(n){n=(n.match(/^([^#]+)/)||[])[1]}l=g.extend(true,{url:n,success:g.ajaxSettings.success,type:j||g.ajaxSettings.type,iframeSrc:/^https/i.test(window.location.href||"")?"javascript:false":"about:blank"},l);var w={};this.trigger("form-pre-serialize",[this,l,w]);if(w.veto){d("ajaxSubmit: submit vetoed via form-pre-serialize trigger");return this}if(l.beforeSerialize&&l.beforeSerialize(this,l)===false){d("ajaxSubmit: submit aborted via beforeSerialize callback");return this}var p=l.traditional;if(typeof p==="undefined"){p=g.ajaxSettings.traditional}var u=[];var I,J=this.formToArray(l.semantic,u,l.filtering);if(l.data){var H=g.isFunction(l.data)?l.data(J):l.data;l.extraData=H;I=g.param(H,p)}if(l.beforeSubmit&&l.beforeSubmit(J,this,l)===false){d("ajaxSubmit: submit aborted via beforeSubmit callback");return this}this.trigger("form-submit-validate",[J,this,l,w]);if(w.veto){d("ajaxSubmit: submit vetoed via form-submit-validate trigger");return this}var A=g.param(J,p);if(I){A=(A?(A+"&"+I):I)}if(l.type.toUpperCase()==="GET"){l.url+=(l.url.indexOf("?")>=0?"&":"?")+A;l.data=null}else{l.data=A}var L=[];if(l.resetForm){L.push(function(){r.resetForm()})}if(l.clearForm){L.push(function(){r.clearForm(l.includeHidden)})}if(!l.dataType&&l.target){var m=l.success||function(){};L.push(function(O,P,N){var k=arguments,q=l.replaceTarget?"replaceWith":"html";g(l.target)[q](O).each(function(){m.apply(this,k)})})}else{if(l.success){if(g.isArray(l.success)){g.merge(L,l.success)}else{L.push(l.success)}}}l.success=function(P,q,Q){var O=l.context||this;for(var N=0,k=L.length;N<k;N++){L[N].apply(O,[P,q,Q||r,r])}};if(l.error){var B=l.error;l.error=function(O,k,q){var N=l.context||this;B.apply(N,[O,k,q,r])}}if(l.complete){var i=l.complete;l.complete=function(N,k){var q=l.context||this;i.apply(q,[N,k,r])}}var G=g("input[type=file]:enabled",this).filter(function(){return g(this).val()!==""});var s=G.length>0;var D="multipart/form-data";var z=(r.attr("enctype")===D||r.attr("encoding")===D);var y=c.fileapi&&c.formdata;d("fileAPI :"+y);var t=(s||z)&&!y;var x;if(l.iframe!==false&&(l.iframe||t)){if(l.closeKeepAlive){g.get(l.closeKeepAlive,function(){x=K(J)})}else{x=K(J)}}else{if((s||z)&&y){x=v(J)}else{x=g.ajax(l)}}r.removeData("jqxhr").data("jqxhr",x);for(var C=0;C<u.length;C++){u[C]=null}this.trigger("form-submit-notify",[this,l]);return this;function h(P){var Q=g.param(P,l.traditional).split("&");var q=Q.length;var k=[];var O,N;for(O=0;O<q;O++){Q[O]=Q[O].replace(/\+/g," ");N=Q[O].split("=");k.push([decodeURIComponent(N[0]),decodeURIComponent(N[1])])}return k}function v(q){var k=new FormData();for(var N=0;N<q.length;N++){k.append(q[N].name,q[N].value)}if(l.extraData){var Q=h(l.extraData);for(N=0;N<Q.length;N++){if(Q[N]){k.append(Q[N][0],Q[N][1])}}}l.data=null;var P=g.extend(true,{},g.ajaxSettings,l,{contentType:false,processData:false,cache:false,type:j||"POST"});if(l.uploadProgress){P.xhr=function(){var R=g.ajaxSettings.xhr();if(R.upload){R.upload.addEventListener("progress",function(V){var U=0;var S=V.loaded||V.position;var T=V.total;if(V.lengthComputable){U=Math.ceil(S/T*100)}l.uploadProgress(V,S,T,U)},false)}return R}}P.data=null;var O=P.beforeSend;P.beforeSend=function(S,R){if(l.formData){R.data=l.formData}else{R.data=k}if(O){O.call(this,S,R)}};return g.ajax(P)}function K(al){var Q=r[0],P,ah,aa,aj,ad,S,V,T,U,ae,ai,Z;var ap=g.Deferred();ap.abort=function(aq){T.abort(aq)};if(al){for(ah=0;ah<u.length;ah++){P=g(u[ah]);if(e){P.prop("disabled",false)}else{P.removeAttr("disabled")}}}aa=g.extend(true,{},g.ajaxSettings,l);aa.context=aa.context||aa;ad="jqFormIO"+new Date().getTime();var an=Q.ownerDocument;var ag=r.closest("body");if(aa.iframeTarget){S=g(aa.iframeTarget,an);ae=S.attr2("name");if(!ae){S.attr2("name",ad)}else{ad=ae}}else{S=g('<iframe name="'+ad+'" src="'+aa.iframeSrc+'" />',an);S.css({position:"absolute",top:"-1000px",left:"-1000px"})}V=S[0];T={aborted:0,responseText:null,responseXML:null,status:0,statusText:"n/a",getAllResponseHeaders:function(){},getResponseHeader:function(){},setRequestHeader:function(){},abort:function(aq){var ar=(aq==="timeout"?"timeout":"aborted");d("aborting upload... "+ar);this.aborted=1;try{if(V.contentWindow.document.execCommand){V.contentWindow.document.execCommand("Stop")}}catch(at){}S.attr("src",aa.iframeSrc);T.error=ar;if(aa.error){aa.error.call(aa.context,T,ar,aq)}if(aj){g.event.trigger("ajaxError",[T,aa,ar])}if(aa.complete){aa.complete.call(aa.context,T,ar)}}};aj=aa.global;if(aj&&g.active++===0){g.event.trigger("ajaxStart")}if(aj){g.event.trigger("ajaxSend",[T,aa])}if(aa.beforeSend&&aa.beforeSend.call(aa.context,T,aa)===false){if(aa.global){g.active--}ap.reject();return ap}if(T.aborted){ap.reject();return ap}U=Q.clk;if(U){ae=U.name;if(ae&&!U.disabled){aa.extraData=aa.extraData||{};aa.extraData[ae]=U.value;if(U.type==="image"){aa.extraData[ae+".x"]=Q.clk_x;aa.extraData[ae+".y"]=Q.clk_y}}}var Y=1;var W=2;function X(at){var ar=null;try{if(at.contentWindow){ar=at.contentWindow.document}}catch(aq){d("cannot get iframe.contentWindow document: "+aq)}if(ar){return ar}try{ar=at.contentDocument?at.contentDocument:at.document}catch(aq){d("cannot get iframe.contentDocument: "+aq);ar=at.document}return ar}var O=g("meta[name=csrf-token]").attr("content");var N=g("meta[name=csrf-param]").attr("content");if(N&&O){aa.extraData=aa.extraData||{};aa.extraData[N]=O}function af(){var az=r.attr2("target"),av=r.attr2("action"),at="multipart/form-data",aw=r.attr("enctype")||r.attr("encoding")||at;Q.setAttribute("target",ad);if(!j||/post/i.test(j)){Q.setAttribute("method","POST")}if(av!==aa.url){Q.setAttribute("action",aa.url)}if(!aa.skipEncodingOverride&&(!j||/post/i.test(j))){r.attr({encoding:"multipart/form-data",enctype:"multipart/form-data"})}if(aa.timeout){Z=setTimeout(function(){ai=true;ac(Y)},aa.timeout)}function ax(){try{var aA=X(V).readyState;d("state = "+aA);if(aA&&aA.toLowerCase()==="uninitialized"){setTimeout(ax,50)}}catch(aB){d("Server abort: ",aB," (",aB.name,")");ac(W);if(Z){clearTimeout(Z)}Z=undefined}}var ay=[];try{if(aa.extraData){for(var ar in aa.extraData){if(aa.extraData.hasOwnProperty(ar)){if(g.isPlainObject(aa.extraData[ar])&&aa.extraData[ar].hasOwnProperty("name")&&aa.extraData[ar].hasOwnProperty("value")){ay.push(g('<input type="hidden" name="'+aa.extraData[ar].name+'">',an).val(aa.extraData[ar].value).appendTo(Q)[0])}else{ay.push(g('<input type="hidden" name="'+ar+'">',an).val(aa.extraData[ar]).appendTo(Q)[0])}}}}if(!aa.iframeTarget){S.appendTo(ag)}if(V.attachEvent){V.attachEvent("onload",ac)}else{V.addEventListener("load",ac,false)}setTimeout(ax,15);try{Q.submit()}catch(au){var aq=document.createElement("form").submit;aq.apply(Q)}}finally{Q.setAttribute("action",av);Q.setAttribute("enctype",aw);if(az){Q.setAttribute("target",az)}else{r.removeAttr("target")}g(ay).remove()}}if(aa.forceSync){af()}else{setTimeout(af,10)}var am,ao,ak=50,R;function ac(ax){if(T.aborted||R){return}ao=X(V);if(!ao){d("cannot access response document");ax=W}if(ax===Y&&T){T.abort("timeout");ap.reject(T,"timeout");return}if(ax===W&&T){T.abort("server abort");ap.reject(T,"error","server abort");return}if(!ao||ao.location.href===aa.iframeSrc){if(!ai){return}}if(V.detachEvent){V.detachEvent("onload",ac)}else{V.removeEventListener("load",ac,false)}var av="success",az;try{if(ai){throw"timeout"}var au=aa.dataType==="xml"||ao.XMLDocument||g.isXMLDoc(ao);d("isXml="+au);if(!au&&window.opera&&(ao.body===null||!ao.body.innerHTML)){if(--ak){d("requeing onLoad callback, DOM not available");setTimeout(ac,250);return}}var aA=ao.body?ao.body:ao.documentElement;T.responseText=aA?aA.innerHTML:null;T.responseXML=ao.XMLDocument?ao.XMLDocument:ao;if(au){aa.dataType="xml"}T.getResponseHeader=function(aD){var aC={"content-type":aa.dataType};return aC[aD.toLowerCase()]};if(aA){T.status=Number(aA.getAttribute("status"))||T.status;T.statusText=aA.getAttribute("statusText")||T.statusText}var aq=(aa.dataType||"").toLowerCase();var ay=/(json|script|text)/.test(aq);if(ay||aa.textarea){var aw=ao.getElementsByTagName("textarea")[0];if(aw){T.responseText=aw.value;T.status=Number(aw.getAttribute("status"))||T.status;T.statusText=aw.getAttribute("statusText")||T.statusText}else{if(ay){var ar=ao.getElementsByTagName("pre")[0];var aB=ao.getElementsByTagName("body")[0];if(ar){T.responseText=ar.textContent?ar.textContent:ar.innerText}else{if(aB){T.responseText=aB.textContent?aB.textContent:aB.innerText}}}}}else{if(aq==="xml"&&!T.responseXML&&T.responseText){T.responseXML=ab(T.responseText)}}try{am=k(T,aq,aa)}catch(at){av="parsererror";T.error=az=(at||av)}}catch(at){d("error caught: ",at);av="error";T.error=az=(at||av)}if(T.aborted){d("upload aborted");av=null}if(T.status){av=((T.status>=200&&T.status<300)||T.status===304)?"success":"error"}if(av==="success"){if(aa.success){aa.success.call(aa.context,am,"success",T)}ap.resolve(T.responseText,"success",T);if(aj){g.event.trigger("ajaxSuccess",[T,aa])}}else{if(av){if(typeof az==="undefined"){az=T.statusText}if(aa.error){aa.error.call(aa.context,T,av,az)}ap.reject(T,"error",az);if(aj){g.event.trigger("ajaxError",[T,aa,az])}}}if(aj){g.event.trigger("ajaxComplete",[T,aa])}if(aj&&!--g.active){g.event.trigger("ajaxStop")}if(aa.complete){aa.complete.call(aa.context,T,av)}R=true;if(aa.timeout){clearTimeout(Z)}setTimeout(function(){if(!aa.iframeTarget){S.remove()}else{S.attr("src",aa.iframeSrc)}T.responseXML=null},100)}var ab=g.parseXML||function(aq,ar){if(window.ActiveXObject){ar=new ActiveXObject("Microsoft.XMLDOM");ar.async="false";ar.loadXML(aq)}else{ar=(new DOMParser()).parseFromString(aq,"text/xml")}return(ar&&ar.documentElement&&ar.documentElement.nodeName!=="parsererror")?ar:null};var q=g.parseJSON||function(aq){return window["eval"]("("+aq+")")};var k=function(aw,au,at){var ar=aw.getResponseHeader("content-type")||"",aq=((au==="xml"||!au)&&ar.indexOf("xml")>=0),av=aq?aw.responseXML:aw.responseText;if(aq&&av.documentElement.nodeName==="parsererror"){if(g.error){g.error("parsererror")}}if(at&&at.dataFilter){av=at.dataFilter(av,au)}if(typeof av==="string"){if((au==="json"||!au)&&ar.indexOf("json")>=0){av=q(av)}else{if((au==="script"||!au)&&ar.indexOf("javascript")>=0){g.globalEval(av)}}}return av};return ap}};g.fn.ajaxForm=function(i,j,h,l){if(typeof i==="string"||(i===false&&arguments.length>0)){i={url:i,data:j,dataType:h};if(typeof l==="function"){i.success=l}}i=i||{};i.delegation=i.delegation&&g.isFunction(g.fn.on);if(!i.delegation&&this.length===0){var k={s:this.selector,c:this.context};if(!g.isReady&&k.s){d("DOM not ready, queuing ajaxForm");g(function(){g(k.s,k.c).ajaxForm(i)});return this}d("terminating; zero elements found by selector"+(g.isReady?"":" (DOM not ready)"));return this}if(i.delegation){g(document).off("submit.form-plugin",this.selector,b).off("click.form-plugin",this.selector,a).on("submit.form-plugin",this.selector,i,b).on("click.form-plugin",this.selector,i,a);return this}return this.ajaxFormUnbind().on("submit.form-plugin",i,b).on("click.form-plugin",i,a)};function b(i){var h=i.data;if(!i.isDefaultPrevented()){i.preventDefault();g(i.target).closest("form").ajaxSubmit(h)}}function a(l){var k=l.target;var i=g(k);if(!i.is("[type=submit],[type=image]")){var h=i.closest("[type=submit]");if(h.length===0){return}k=h[0]}var j=k.form;j.clk=k;if(k.type==="image"){if(typeof l.offsetX!=="undefined"){j.clk_x=l.offsetX;j.clk_y=l.offsetY}else{if(typeof g.fn.offset==="function"){var m=i.offset();j.clk_x=l.pageX-m.left;j.clk_y=l.pageY-m.top}else{j.clk_x=l.pageX-k.offsetLeft;j.clk_y=l.pageY-k.offsetTop}}}setTimeout(function(){j.clk=j.clk_x=j.clk_y=null},100)}g.fn.ajaxFormUnbind=function(){return this.off("submit.form-plugin click.form-plugin")};g.fn.formToArray=function(p,s,A){var B=[];if(this.length===0){return B}var l=this[0];var C=this.attr("id");var m=(p||typeof l.elements==="undefined")?l.getElementsByTagName("*"):l.elements;var z;if(m){m=g.makeArray(m)}if(C&&(p||/(Edge|Trident)\//.test(navigator.userAgent))){z=g(':input[form="'+C+'"]').get();if(z.length){m=(m||[]).concat(z)}}if(!m||!m.length){return B}if(g.isFunction(A)){m=g.map(m,A)}var y,w,u,r,k,x,t;for(y=0,x=m.length;y<x;y++){k=m[y];u=k.name;if(!u||k.disabled){continue}if(p&&l.clk&&k.type==="image"){if(l.clk===k){B.push({name:u,value:g(k).val(),type:k.type});B.push({name:u+".x",value:l.clk_x},{name:u+".y",value:l.clk_y})}continue}r=g.fieldValue(k,true);if(r&&r.constructor===Array){if(s){s.push(k)}for(w=0,t=r.length;w<t;w++){B.push({name:u,value:r[w]})}}else{if(c.fileapi&&k.type==="file"){if(s){s.push(k)}var o=k.files;if(o.length){for(w=0;w<o.length;w++){B.push({name:u,value:o[w],type:k.type})}}else{B.push({name:u,value:"",type:k.type})}}else{if(r!==null&&typeof r!=="undefined"){if(s){s.push(k)}B.push({name:u,value:r,type:k.type,required:k.required})}}}}if(!p&&l.clk){var h=g(l.clk),q=h[0];u=q.name;if(u&&!q.disabled&&q.type==="image"){B.push({name:u,value:h.val()});B.push({name:u+".x",value:l.clk_x},{name:u+".y",value:l.clk_y})}}return B};g.fn.formSerialize=function(h){return g.param(this.formToArray(h))};g.fn.fieldSerialize=function(i){var h=[];this.each(function(){var m=this.name;if(!m){return}var k=g.fieldValue(this,i);if(k&&k.constructor===Array){for(var l=0,j=k.length;l<j;l++){h.push({name:m,value:k[l]})}}else{if(k!==null&&typeof k!=="undefined"){h.push({name:this.name,value:k})}}});return g.param(h)};g.fn.fieldValue=function(n){for(var m=[],k=0,h=this.length;k<h;k++){var l=this[k];var j=g.fieldValue(l,n);if(j===null||typeof j==="undefined"||(j.constructor===Array&&!j.length)){continue}if(j.constructor===Array){g.merge(m,j)}else{m.push(j)}}return m};g.fieldValue=function(h,p){var k=h.name,w=h.type,x=h.tagName.toLowerCase();if(typeof p==="undefined"){p=true}if(p&&(!k||h.disabled||w==="reset"||w==="button"||(w==="checkbox"||w==="radio")&&!h.checked||(w==="submit"||w==="image")&&h.form&&h.form.clk!==h||x==="select"&&h.selectedIndex===-1)){return null}if(x==="select"){var q=h.selectedIndex;if(q<0){return null}var s=[],j=h.options;var m=(w==="select-one");var r=(m?q+1:j.length);for(var l=(m?q:0);l<r;l++){var o=j[l];if(o.selected&&!o.disabled){var u=o.value;if(!u){u=(o.attributes&&o.attributes.value&&!(o.attributes.value.specified))?o.text:o.value}if(m){return u}s.push(u)}}return s}return g(h).val().replace(f,"\r\n")};g.fn.clearForm=function(h){return this.each(function(){g("input,select,textarea",this).clearFields(h)})};g.fn.clearFields=g.fn.clearInputs=function(h){var i=/^(?:color|date|datetime|email|month|number|password|range|search|tel|text|time|url|week)$/i;return this.each(function(){var k=this.type,j=this.tagName.toLowerCase();if(i.test(k)||j==="textarea"){this.value=""}else{if(k==="checkbox"||k==="radio"){this.checked=false}else{if(j==="select"){this.selectedIndex=-1}else{if(k==="file"){if(/MSIE/.test(navigator.userAgent)){g(this).replaceWith(g(this).clone(true))}else{g(this).val("")}}else{if(h){if((h===true&&/hidden/.test(k))||(typeof h==="string"&&g(this).is(h))){this.value=""}}}}}}})};g.fn.resetForm=function(){return this.each(function(){var j=g(this);var i=this.tagName.toLowerCase();switch(i){case"input":this.checked=this.defaultChecked;case"textarea":this.value=this.defaultValue;return true;case"option":case"optgroup":var h=j.parents("select");if(h.length&&h[0].multiple){if(i==="option"){this.selected=this.defaultSelected}else{j.find("option").resetForm()}}else{h.resetForm()}return true;case"select":j.find("option").each(function(m){this.selected=this.defaultSelected;if(this.defaultSelected&&!j[0].multiple){j[0].selectedIndex=m;return false}});return true;case"label":var k=g(j.attr("for"));var l=j.find("input,select,textarea");if(k[0]){l.unshift(k[0])}l.resetForm();return true;case"form":if(typeof this.reset==="function"||(typeof this.reset==="object"&&!this.reset.nodeType)){this.reset()}return true;default:j.find("form,input,label,select,textarea").resetForm();return true}})};g.fn.enable=function(h){if(typeof h==="undefined"){h=true}return this.each(function(){this.disabled=!h})};g.fn.selected=function(h){if(typeof h==="undefined"){h=true}return this.each(function(){var i=this.type;if(i==="checkbox"||i==="radio"){this.checked=h}else{if(this.tagName.toLowerCase()==="option"){var j=g(this).parent("select");if(h&&j[0]&&j[0].type==="select-one"){j.find("option").selected(false)}this.selected=h}}})};g.fn.ajaxSubmit.debug=false;function d(){if(!g.fn.ajaxSubmit.debug){return}var h="[jquery.form] "+Array.prototype.join.call(arguments,"");if(window.console&&window.console.log){window.console.log(h)}else{if(window.opera&&window.opera.postError){window.opera.postError(h)}}}})); | |
\ No newline at end of file |
@@ -1 +1 @@ | ||
1 | -(function($){$(window).load(function(event){var jForm=$("form#ajaxSubmit");((0<jForm.size())?jForm:$("form:first")).formMan2()});$.fn.sort=function(){return this.pushStack($.makeArray([].sort.apply(this,arguments)))};$.fn.formMan2=function(opts){var settings={sFMsgCls:"errmsg",sMsgSaved:"\u767b\u9332\u3057\u307e\u3057\u305f\u3002",sKeepCls:"unreplaceable",onRowPlace:null};$.extend(settings,$.hybs.defaults,opts||{});return this.each(function(){var oForm,mParams,formOpts;oForm=this;mParams={};mParams[settings.sAjxSbmtKey]="true";formOpts={};formOpts.data=mParams;formOpts.beforeSubmit=function(formData,jqForm,options){return(settings.beforeSubmit)?settings.beforeSubmit(formData,jqForm,options):true};formOpts.success=function(data,status,$form){var sHybsCmd,match,sUrl,sFrame,oFrame;sHybsCmd=$form.data($.hybs.defaults.sHybsCmd).cmd;if(data.indexOf("row_error")>=0){$(oForm).removeData($.hybs.defaults.sHybsCmd);isClicked=false;match=/(?:<\/table>)*[\S\s]*(\[\d+ - \d+\]\/\[\d+\])[\S\s]*(<table[^>]*?>[\S\s]+?row_error[\S\s]*<\/table>)/m.exec(data);$.hybs.ogAlert(match?(match[1]+match[2]):data)}else{if($.inArray(sHybsCmd,[settings.sCmdInsert,settings.sCmdCopy,settings.sCmdModify,settings.sCmdDelete,settings.sCmdEntry,settings.sCmdUndo])>=0){if(sHybsCmd==settings.sCmdEntry){match=/<div id="?noTransitionUrl"?>(.*)<\/div>[\s\S]*<div id="?noTransitionTarget"?>(.*)<\/div>/mi.exec(data);if(match){sUrl=match[1].replace(/&/g,"&");sFrame=match[2];oFrame=(sFrame!="null")?eval("top."+sFrame):window;oFrame=oFrame?oFrame:eval("top.CONTENTS."+sFrame);oFrame.location.href=sUrl}}}}};formOpts.error=function(xhr,status,e){$.hybs.ogLog(status+"\n"+xhr.responseText);$.hybs.ogAlert(status+"<br/>"+xhr.responseText)};formOpts.complete=function(xhr,status){};formOpts.cmds=formOpts.cmds||[settings.sCmdEntry];$(oForm).ajaxHybsForm(formOpts)})}})(jQuery); | |
\ No newline at end of file | ||
1 | +(function($){$(window).load(function(event){var jForm=$("form#ajaxSubmit");((0<jForm.size())?jForm:$("form:first")).formMan2()});$.fn.sort=function(){return this.pushStack($.makeArray([].sort.apply(this,arguments)))};$.fn.formMan2=function(opts){var settings={sFMsgCls:"errmsg",sMsgSaved:"\u767b\u9332\u3057\u307e\u3057\u305f\u3002",sKeepCls:"unreplaceable",onRowPlace:null};$.extend(settings,$.hybs.defaults,opts||{});return this.each(function(){var oForm,mParams,formOpts;oForm=this;mParams={};mParams[settings.sAjxSbmtKey]="true";formOpts={};formOpts.data=mParams;formOpts.beforeSubmit=function(formData,jqForm,options){return(settings.beforeSubmit)?settings.beforeSubmit(formData,jqForm,options):true};formOpts.success=function(data,status,$form){var sHybsCmd,match,sUrl,sFrame,oFrame;sHybsCmd=$("form").data($.hybs.defaults.sHybsCmd).cmd;if(data.indexOf("row_error")>=0){$(oForm).removeData($.hybs.defaults.sHybsCmd);isClicked=false;match=/(?:<\/table>)*[\S\s]*(\[\d+ - \d+\]\/\[\d+\])[\S\s]*(<table[^>]*?>[\S\s]+?row_error[\S\s]*<\/table>)/m.exec(data);$.hybs.ogAlert(match?(match[1]+match[2]):data)}else{if($.inArray(sHybsCmd,[settings.sCmdInsert,settings.sCmdCopy,settings.sCmdModify,settings.sCmdDelete,settings.sCmdEntry,settings.sCmdUndo])>=0){if(sHybsCmd==settings.sCmdEntry){match=/<div id="?noTransitionUrl"?>(.*)<\/div>[\s\S]*<div id="?noTransitionTarget"?>(.*)<\/div>/mi.exec(data);if(match){sUrl=match[1].replace(/&/g,"&");sFrame=match[2];oFrame=(sFrame!="null")?eval("top."+sFrame):window;oFrame=oFrame?oFrame:eval("top.CONTENTS."+sFrame);oFrame.location.href=sUrl}}}}};formOpts.error=function(xhr,status,e){$.hybs.ogLog(status+"\n"+xhr.responseText);$.hybs.ogAlert(status+"<br/>"+xhr.responseText)};formOpts.complete=function(xhr,status){};formOpts.cmds=formOpts.cmds||[settings.sCmdEntry];$(oForm).ajaxHybsForm(formOpts)})}})(jQuery); | |
\ No newline at end of file |
@@ -1 +1 @@ | ||
1 | -(function($){$(window).load(function(event){var jForm=$("form#noTransition");((0<jForm.size())?jForm:$("form:first")).formMan()});$.fn.sort=function(){return this.pushStack($.makeArray([].sort.apply(this,arguments)))};$.fn.formMan=function(opts){var settings={sFMsgCls:"errmsg",sMsgSaved:"\u767b\u9332\u3057\u307e\u3057\u305f\u3002",sKeepCls:"unreplaceable",onRowPlace:null};$.extend(settings,$.hybs.defaults,opts||{});return this.each(function(){var oForm=this;var replaceRow=function(jTr,sRowHtml,bHiLight){var sSrc,sClass;sSrc=jTr.find("."+settings.sKeepCls).attr("src");sClass=jTr.find("."+settings.sKeepCls).attr("class");jTr=$(sRowHtml).replaceAll(jTr);if(settings.onRowPlace){settings.onRowPlace(sHybsCmd,jTr)}else{if(sSrc){jTr.find("."+settings.sKeepCls).attr("src",sSrc)}if(sClass){jTr.find("."+settings.sKeepCls).removeClass().addClass(sClass)}}if(bHiLight&&!jTr.hasClass("row_hilight")){jTr.removeClass("row_0 row_1").addClass("row_hilight")}return jTr};var operateOnRows=function(jTab,jTr1st,sHybsCmd,data){var jChks=jTab.find("input[name="+settings.sHybsSel+"]:checked");var bHasChecked=(jChks.length>0);var jTBodyTr=$.hybs.getHybsTr(jTr1st);var bUnitRow=jTBodyTr.is("tr");var nKhColId=0;var nNoColId=$.hybs.getNoColId(jTab);var aDelRid=[],jTrFix2;var jTrs;switch(sHybsCmd){case settings.sCmdInsert:case settings.sCmdInsertOne:case settings.sCmdCopy:case settings.sCmdModify:case settings.sCmdDelete:case settings.sCmdUndo:case settings.sCmdEntry:if(bUnitRow){jTrs=(bHasChecked)?jChks.parents("tr"):jTBodyTr}else{jTrs=(bHasChecked)?jChks.parents("tbody"):jTBodyTr}break;default:break}jTrs.sort(function(a,b){return a.getAttribute(settings.sHybsRid,2)-b.getAttribute(settings.sHybsRid,2)});var bPassOnce=false;var match,re,sText;jTrs.each(function(index){if(sHybsCmd==settings.sCmdInsertOne&&index<jTrs.length-1){return}var jTr=$(this);if(sHybsCmd==settings.sCmdUndo&&"A"==jTr.attr(settings.sHybsKh)){if(!jTrFix2){jTrFix2=jTr.prev()}aDelRid.push(parseInt(jTr.attr(settings.sHybsRid),10));jTr.remove()}else{if(!bPassOnce){if(bUnitRow){match=/(<tbody[^>]*>[\S\s]*<\/tbody>)/m.exec(data);re=/(<tr[^>]*?>[\S\s]*?<\/tr>)/m}else{match=/(<tbody[^>]*>[\S\s]*<\/tbody>)/m.exec(data);re=/(<tbody[^>]*?>[\S\s]*?<\/tbody>)/m}if(match){sText=match[1]}bPassOnce=true}if(sText){match=re.exec(sText);if(match){var sRowText=match[1].replace(/<a href="#top"[^>]*><\/a>/m,"");var _checkedRow=jTr.find("input[name="+settings.sHybsSel+"]:first").val();if(!_checkedRow){_checkedRow=0}if(sHybsCmd==settings.sCmdCopy&&bHasChecked){_checkedRow++}var rowSel_reg=new RegExp('(<input type="checkbox" name="'+settings.sHybsSel+'"[^>]*>)',"m");sRowText=sRowText.replace(rowSel_reg,'$1<input type="hidden" name="'+settings.sSelRow+'" value="'+_checkedRow+'" />');var sNoCol,cChgType;switch(sHybsCmd){case settings.sCmdInsert:case settings.sCmdInsertOne:case settings.sCmdCopy:var jTrNew=(bHasChecked)?$(sRowText).insertAfter(jTr):$(sRowText).insertBefore(jTr);jTrNew.removeClass("row_0 row_1").addClass("row_hilight");if(0<=nNoColId){jTrNew.find("td:eq("+nNoColId+")").empty()}if(!jTr.attr(settings.sHybsKh)){jTr.find("input[name="+settings.sHybsSel+"]:first").removeAttr("checked")}bindEvents();break;case settings.sCmdModify:case settings.sCmdDelete:if(!jTr.attr(settings.sHybsKh)){sNoCol=((0<=nNoColId)?jTr.find("td:nth("+nNoColId+")").text():"");jTr=replaceRow(jTr,sRowText,true);if((0<=nNoColId)&&!sNoCol){jTr.find("td:nth("+nNoColId+")").empty()}}bindEvents(jTr);break;case settings.sCmdEntry:cChgType=jTr.attr(settings.sHybsKh)||"";sNoCol=((0<=nNoColId)?jTr.find("td:nth("+nNoColId+")").text():"");var bChecked=jTr.find("input[name="+settings.sHybsSel+"]:first").attr("checked");jTr=replaceRow(jTr,sRowText,true);if(bChecked){switch(cChgType){case"D":if(!jTrFix2){jTrFix2=jTr.prev()}aDelRid.push(parseInt(jTr.attr(settings.sHybsRid),10));jTr.remove();break;case"A":case"C":if(0<=nKhColId){jTr.find("td:eq("+nKhColId+")").empty()}jTr.removeAttr(settings.sHybsKh);jTr.find("input[name="+settings.sHybsSel+"]:first").removeAttr("checked");if((0<=nNoColId)&&!sNoCol){jTr.find("td:nth("+nNoColId+")").empty()}break;default:break}}$("."+settings.sFMsgCls).html(settings.sMsgSaved);bindEvents(jTr);break;case settings.sCmdUndo:cChgType=jTr.attr(settings.sHybsKh)||"";sNoCol=((0<=nNoColId)?jTr.find("td:nth("+nNoColId+")").text():"");jTr=replaceRow(jTr,sRowText,true);switch(cChgType){case"C":case"D":if(0<=nKhColId){jTr.find("td:eq("+nKhColId+")").empty()}jTr.removeAttr(settings.sHybsKh);jTr.find("input[name="+settings.sHybsSel+"]:first").removeAttr("checked");if((0<=nNoColId)&&!sNoCol){jTr.find("td:nth("+nNoColId+")").empty()}break;default:break}bindEvents(jTr);break;default:break}sText=sText.substr(match.index+match[0].length)}}}});if(jTrFix2){var jRun;var bHasTrFix=jTrFix2[0]&&(bUnitRow?jTrFix2.parent().is("tbody"):jTrFix2.children(":first").is("tr"));if(bHasTrFix){jRun=jTrFix2.next()}else{jTBodyTr=jTab.find("tbody tr:first");jRun=bUnitRow?jTBodyTr:jTBodyTr.parent()}aDelRid.sort();var nDelLen=aDelRid.length;while(jRun[0]){var nDiff=0,nRidRun=parseInt(jRun.attr(settings.sHybsRid),10);for(var iCntUp=(nDelLen-1);0<=iCntUp;iCntUp--){if(nRidRun>aDelRid[iCntUp]){nDiff=iCntUp+1;break}}if(nDiff>0){nRidRun-=nDiff;jRun.attr(settings.sHybsRid,nRidRun).find("input[name="+settings.sHybsSel+"]:first").attr({id:"cb"+nRidRun,value:nRidRun});if(0<=nNoColId){var jNoCol=jRun.find("td:nth("+nNoColId+")");if(jNoCol.text()){jNoCol.text(nRidRun+1)}}}jRun=jRun.next()}$("tbody:first:not(:has(tr:first-child))",jTab).remove()}if(jTrs.length>0){jTab.resizeView();buttonControl()}};var addToNoTBody=function(jTab,sCmd,data){if(sCmd==settings.sCmdInsert||sCmd==settings.sCmdInsertOne||sCmd==settings.sCmdCopy){var match=/(?:<tbody>)?\r?\n?(<tbody>[\S\s]*<\/tbody>)\r?\n?(?:<\/tbody>)?/m.exec(data);if(match){var sText=$.trim(match[1].replace(/<a href="#top"[^>]*><\/a>/m,""));if(sText){jTab.append(sText);jTab.resizeView();buttonControl();bindEvents(jTab)}}}};var addToNoTable=function(jForm,sCmd,data){if(sCmd==settings.sCmdInsert||sCmd==settings.sCmdInsertOne||sCmd==settings.sCmdCopy){var match=/(<div id="divHlr)|(\[\d+ - \d+\]\/\[\d+\])|(<div id="divPos)|(<table id="viewTable)/m.exec(data);if(match){match=/([\S\s]*<table[^>]*?>[\S\s]*<\/table>[\S\s]*)/m.exec(data.substr(match.index));if(match){var jPSize=$("input:hidden[name=pageSize]",jForm);jPSize.prev("div[onclick]:empty").remove();jPSize.nextAll().andSelf().remove();jForm.append(match[1]);var jTab=jForm.find("table#viewTable");jTab.resizeView(true);buttonControl();bindEvents(jTab)}}}};var buttonControl=function(isInit){var jForm=$(oForm);var jBtnEnt=jForm.find("input:submit."+settings.sEntryCls);if(isInit){jBtnEnt.attr("disabled","disabled")}else{var jBtnMess=$(jForm.data($.hybs.defaults.sHybsCmd).obj);if(jBtnMess.hasClass(settings.sEditCls)){jBtnEnt.removeAttr("disabled")}if(jBtnMess.hasClass(settings.sEntryCls)){jBtnEnt.attr("disabled","disabled")}}};var mParams={};mParams[settings.sNoTsKey]="true";var formOpts={};formOpts.data=mParams;formOpts.beforeSubmit=function(formData,jqForm,options){return(settings.beforeSubmit)?settings.beforeSubmit(formData,jqForm,options):true};formOpts.success=function(data,status,$form){var sHybsCmd=$form.data($.hybs.defaults.sHybsCmd).cmd;var match;if(data.indexOf("row_error")>=0){match=/(?:<\/table>)*[\S\s]*(\[\d+ - \d+\]\/\[\d+\])[\S\s]*(<table[^>]*?>[\S\s]+?row_error[\S\s]*<\/table>)/m.exec(data);$.hybs.ogAlert(match?(match[1]+match[2]):data)}else{if($.inArray(sHybsCmd,[settings.sCmdInsert,settings.sCmdInsertOne,settings.sCmdCopy,settings.sCmdModify,settings.sCmdDelete,settings.sCmdEntry,settings.sCmdUndo])>=0){var bSpecialCase=false;if(sHybsCmd==settings.sCmdEntry){match=/<div id="noTransitionUrl">(.*)<\/div><div id="noTransitionTarget">(.*)<\/div>/m.exec(data);if(match){var sUrl=match[1];var sFrame=match[2];var oFrame=(sFrame!="null")?eval("top."+sFrame):window;oFrame.location.href=sUrl;bSpecialCase=true}}if(!bSpecialCase){var jTab=$form.find("table#viewTable"),jTr1st=jTab.find("tbody tr:first");if(jTr1st[0]){operateOnRows(jTab,jTr1st,sHybsCmd,data)}else{if(jTab[0]){addToNoTBody(jTab,sHybsCmd,data)}else{addToNoTable($form,sHybsCmd,data)}}}}}};formOpts.error=function(xhr,status,e){$.hybs.ogLog(status+"\n"+xhr.responseText);$.hybs.ogAlert(status+"<br/>"+xhr.responseText)};formOpts.complete=function(xhr,status){$(oForm).removeData($.hybs.defaults.sHybsCmd)};formOpts.cmds=formOpts.cmds||[settings.sCmdInsert,settings.sCmdInsertOne,settings.sCmdCopy,settings.sCmdModify,settings.sCmdDelete,settings.sCmdEntry,settings.sCmdUndo];buttonControl(true);$(oForm).ajaxHybsForm(formOpts)})}})(jQuery); | |
\ No newline at end of file | ||
1 | +(function($){$(window).load(function(event){var jForm=$("form#noTransition");((0<jForm.size())?jForm:$("form:first")).formMan()});$.fn.sort=function(){return this.pushStack($.makeArray([].sort.apply(this,arguments)))};$.fn.formMan=function(opts){var settings={sFMsgCls:"errmsg",sMsgSaved:"\u767b\u9332\u3057\u307e\u3057\u305f\u3002",sKeepCls:"unreplaceable",onRowPlace:null};$.extend(settings,$.hybs.defaults,opts||{});return this.each(function(){var oForm=this;var replaceRow=function(jTr,sRowHtml,bHiLight){var sSrc,sClass;sSrc=jTr.find("."+settings.sKeepCls).attr("src");sClass=jTr.find("."+settings.sKeepCls).attr("class");jTr=$(sRowHtml).replaceAll(jTr);if(settings.onRowPlace){settings.onRowPlace(sHybsCmd,jTr)}else{if(sSrc){jTr.find("."+settings.sKeepCls).attr("src",sSrc)}if(sClass){jTr.find("."+settings.sKeepCls).removeClass().addClass(sClass)}}if(bHiLight&&!jTr.hasClass("row_hilight")){jTr.removeClass("row_0 row_1").addClass("row_hilight")}return jTr};var operateOnRows=function(jTab,jTr1st,sHybsCmd,data){var jChks=jTab.find("input[name="+settings.sHybsSel+"]:checked");var bHasChecked=(jChks.length>0);var jTBodyTr=$.hybs.getHybsTr(jTr1st);var bUnitRow=jTBodyTr.is("tr");var nKhColId=0;var nNoColId=$.hybs.getNoColId(jTab);var aDelRid=[],jTrFix2;var jTrs;switch(sHybsCmd){case settings.sCmdInsert:case settings.sCmdInsertOne:case settings.sCmdCopy:case settings.sCmdModify:case settings.sCmdDelete:case settings.sCmdUndo:case settings.sCmdEntry:if(bUnitRow){jTrs=(bHasChecked)?jChks.parents("tr"):jTBodyTr}else{jTrs=(bHasChecked)?jChks.parents("tbody"):jTBodyTr}break;default:break}jTrs.sort(function(a,b){return a.getAttribute(settings.sHybsRid,2)-b.getAttribute(settings.sHybsRid,2)});var bPassOnce=false;var match,re,sText;jTrs.each(function(index){if(sHybsCmd==settings.sCmdInsertOne&&index<jTrs.length-1){return}var jTr=$(this);if(sHybsCmd==settings.sCmdUndo&&"A"==jTr.attr(settings.sHybsKh)){if(!jTrFix2){jTrFix2=jTr.prev()}aDelRid.push(parseInt(jTr.attr(settings.sHybsRid),10));jTr.remove()}else{if(!bPassOnce){if(bUnitRow){match=/(<tbody[^>]*>[\S\s]*<\/tbody>)/m.exec(data);re=/(<tr[^>]*?>[\S\s]*?<\/tr>)/m}else{match=/(<tbody[^>]*>[\S\s]*<\/tbody>)/m.exec(data);re=/(<tbody[^>]*?>[\S\s]*?<\/tbody>)/m}if(match){sText=match[1]}bPassOnce=true}if(sText){match=re.exec(sText);if(match){var sRowText=match[1].replace(/<a href="#top"[^>]*><\/a>/m,"");var _checkedRow=jTr.find("input[name="+settings.sHybsSel+"]:first").val();if(!_checkedRow){_checkedRow=0}if(sHybsCmd==settings.sCmdCopy&&bHasChecked){_checkedRow++}var rowSel_reg=new RegExp('(<input type="checkbox" name="'+settings.sHybsSel+'"[^>]*>)',"m");sRowText=sRowText.replace(rowSel_reg,'$1<input type="hidden" name="'+settings.sSelRow+'" value="'+_checkedRow+'" />');var sNoCol,cChgType;switch(sHybsCmd){case settings.sCmdInsert:case settings.sCmdInsertOne:case settings.sCmdCopy:var jTrNew=(bHasChecked)?$(sRowText).insertAfter(jTr):$(sRowText).insertBefore(jTr);jTrNew.removeClass("row_0 row_1").addClass("row_hilight");if(0<=nNoColId){jTrNew.find("td:eq("+nNoColId+")").empty()}if(!jTr.attr(settings.sHybsKh)){jTr.find("input[name="+settings.sHybsSel+"]:first").removeAttr("checked")}bindEvents();break;case settings.sCmdModify:case settings.sCmdDelete:if(!jTr.attr(settings.sHybsKh)){sNoCol=((0<=nNoColId)?jTr.find("td:nth("+nNoColId+")").text():"");jTr=replaceRow(jTr,sRowText,true);if((0<=nNoColId)&&!sNoCol){jTr.find("td:nth("+nNoColId+")").empty()}}bindEvents(jTr);break;case settings.sCmdEntry:cChgType=jTr.attr(settings.sHybsKh)||"";sNoCol=((0<=nNoColId)?jTr.find("td:nth("+nNoColId+")").text():"");var bChecked=jTr.find("input[name="+settings.sHybsSel+"]:first").attr("checked");jTr=replaceRow(jTr,sRowText,true);if(bChecked){switch(cChgType){case"D":if(!jTrFix2){jTrFix2=jTr.prev()}aDelRid.push(parseInt(jTr.attr(settings.sHybsRid),10));jTr.remove();break;case"A":case"C":if(0<=nKhColId){jTr.find("td:eq("+nKhColId+")").empty()}jTr.removeAttr(settings.sHybsKh);jTr.find("input[name="+settings.sHybsSel+"]:first").removeAttr("checked");if((0<=nNoColId)&&!sNoCol){jTr.find("td:nth("+nNoColId+")").empty()}break;default:break}}$("."+settings.sFMsgCls).html(settings.sMsgSaved);bindEvents(jTr);break;case settings.sCmdUndo:cChgType=jTr.attr(settings.sHybsKh)||"";sNoCol=((0<=nNoColId)?jTr.find("td:nth("+nNoColId+")").text():"");jTr=replaceRow(jTr,sRowText,true);switch(cChgType){case"C":case"D":if(0<=nKhColId){jTr.find("td:eq("+nKhColId+")").empty()}jTr.removeAttr(settings.sHybsKh);jTr.find("input[name="+settings.sHybsSel+"]:first").removeAttr("checked");if((0<=nNoColId)&&!sNoCol){jTr.find("td:nth("+nNoColId+")").empty()}break;default:break}bindEvents(jTr);break;default:break}sText=sText.substr(match.index+match[0].length)}}}});if(jTrFix2){var jRun;var bHasTrFix=jTrFix2[0]&&(bUnitRow?jTrFix2.parent().is("tbody"):jTrFix2.children(":first").is("tr"));if(bHasTrFix){jRun=jTrFix2.next()}else{jTBodyTr=jTab.find("tbody tr:first");jRun=bUnitRow?jTBodyTr:jTBodyTr.parent()}aDelRid.sort();var nDelLen=aDelRid.length;while(jRun[0]){var nDiff=0,nRidRun=parseInt(jRun.attr(settings.sHybsRid),10);for(var iCntUp=(nDelLen-1);0<=iCntUp;iCntUp--){if(nRidRun>aDelRid[iCntUp]){nDiff=iCntUp+1;break}}if(nDiff>0){nRidRun-=nDiff;jRun.attr(settings.sHybsRid,nRidRun).find("input[name="+settings.sHybsSel+"]:first").attr({id:"cb"+nRidRun,value:nRidRun});if(0<=nNoColId){var jNoCol=jRun.find("td:nth("+nNoColId+")");if(jNoCol.text()){jNoCol.text(nRidRun+1)}}}jRun=jRun.next()}$("tbody:first:not(:has(tr:first-child))",jTab).remove()}if(jTrs.length>0){jTab.resizeView();buttonControl()}};var addToNoTBody=function(jTab,sCmd,data){if(sCmd==settings.sCmdInsert||sCmd==settings.sCmdInsertOne||sCmd==settings.sCmdCopy){var match=/(?:<tbody>)?\r?\n?(<tbody>[\S\s]*<\/tbody>)\r?\n?(?:<\/tbody>)?/m.exec(data);if(match){var sText=$.trim(match[1].replace(/<a href="#top"[^>]*><\/a>/m,""));if(sText){jTab.append(sText);jTab.resizeView();buttonControl();bindEvents(jTab)}}}};var addToNoTable=function(jForm,sCmd,data){if(sCmd==settings.sCmdInsert||sCmd==settings.sCmdInsertOne||sCmd==settings.sCmdCopy){var match=/(<div id="divHlr)|(\[\d+ - \d+\]\/\[\d+\])|(<div id="divPos)|(<table id="viewTable)/m.exec(data);if(match){match=/([\S\s]*<table[^>]*?>[\S\s]*<\/table>[\S\s]*)/m.exec(data.substr(match.index));if(match){var jPSize=$("input:hidden[name=pageSize]",jForm);jPSize.prev("div[onclick]:empty").remove();jPSize.nextAll().andSelf().remove();jForm.append(match[1]);var jTab=jForm.find("table#viewTable");jTab.resizeView(true);buttonControl();bindEvents(jTab)}}}};var buttonControl=function(isInit){var jForm=$(oForm);var jBtnEnt=jForm.find("input:submit."+settings.sEntryCls);if(isInit){jBtnEnt.attr("disabled","disabled")}else{var jBtnMess=$(jForm.data($.hybs.defaults.sHybsCmd).obj);if(jBtnMess.hasClass(settings.sEditCls)){jBtnEnt.removeAttr("disabled")}if(jBtnMess.hasClass(settings.sEntryCls)){jBtnEnt.attr("disabled","disabled")}}};var mParams={};mParams[settings.sNoTsKey]="true";var formOpts={};formOpts.data=mParams;formOpts.beforeSubmit=function(formData,jqForm,options){return(settings.beforeSubmit)?settings.beforeSubmit(formData,jqForm,options):true};formOpts.success=function(data,status,$form){var sHybsCmd=$("form").data($.hybs.defaults.sHybsCmd).cmd;var match;if(data.indexOf("row_error")>=0){match=/(?:<\/table>)*[\S\s]*(\[\d+ - \d+\]\/\[\d+\])[\S\s]*(<table[^>]*?>[\S\s]+?row_error[\S\s]*<\/table>)/m.exec(data);$.hybs.ogAlert(match?(match[1]+match[2]):data)}else{if($.inArray(sHybsCmd,[settings.sCmdInsert,settings.sCmdInsertOne,settings.sCmdCopy,settings.sCmdModify,settings.sCmdDelete,settings.sCmdEntry,settings.sCmdUndo])>=0){var bSpecialCase=false;if(sHybsCmd==settings.sCmdEntry){match=/<div id="noTransitionUrl">(.*)<\/div><div id="noTransitionTarget">(.*)<\/div>/m.exec(data);if(match){var sUrl=match[1];var sFrame=match[2];var oFrame=(sFrame!="null")?eval("top."+sFrame):window;oFrame.location.href=sUrl;bSpecialCase=true}}if(!bSpecialCase){var jTab=$form.find("table#viewTable"),jTr1st=jTab.find("tbody tr:first");if(jTr1st[0]){operateOnRows(jTab,jTr1st,sHybsCmd,data)}else{if(jTab[0]){addToNoTBody(jTab,sHybsCmd,data)}else{addToNoTable($form,sHybsCmd,data)}}}}}};formOpts.error=function(xhr,status,e){$.hybs.ogLog(status+"\n"+xhr.responseText);$.hybs.ogAlert(status+"<br/>"+xhr.responseText)};formOpts.complete=function(xhr,status){$(oForm).removeData($.hybs.defaults.sHybsCmd)};formOpts.cmds=formOpts.cmds||[settings.sCmdInsert,settings.sCmdInsertOne,settings.sCmdCopy,settings.sCmdModify,settings.sCmdDelete,settings.sCmdEntry,settings.sCmdUndo];buttonControl(true);$(oForm).ajaxHybsForm(formOpts)})}})(jQuery); | |
\ No newline at end of file |
@@ -1,636 +1,1532 @@ | ||
1 | -/* | |
2 | - * jQuery Form Plugin | |
3 | - * version: 2.21 (08-FEB-2009) | |
4 | - * @requires jQuery v1.2.2 or later | |
5 | - * | |
6 | - * Examples and documentation at: http://malsup.com/jquery/form/ | |
7 | - * Dual licensed under the MIT and GPL licenses: | |
8 | - * http://www.opensource.org/licenses/mit-license.php | |
9 | - * http://www.gnu.org/licenses/gpl.html | |
10 | - */ | |
11 | -;(function($) { | |
12 | - | |
13 | -/* | |
14 | - Usage Note: | |
15 | - ----------- | |
16 | - Do not use both ajaxSubmit and ajaxForm on the same form. These | |
17 | - functions are intended to be exclusive. Use ajaxSubmit if you want | |
18 | - to bind your own submit handler to the form. For example, | |
19 | - | |
20 | - $(document).ready(function() { | |
21 | - $('#myForm').bind('submit', function() { | |
22 | - $(this).ajaxSubmit({ | |
23 | - target: '#output' | |
24 | - }); | |
25 | - return false; // <-- important! | |
26 | - }); | |
27 | - }); | |
28 | - | |
29 | - Use ajaxForm when you want the plugin to manage all the event binding | |
30 | - for you. For example, | |
31 | - | |
32 | - $(document).ready(function() { | |
33 | - $('#myForm').ajaxForm({ | |
34 | - target: '#output' | |
35 | - }); | |
36 | - }); | |
37 | - | |
38 | - When using ajaxForm, the ajaxSubmit function will be invoked for you | |
39 | - at the appropriate time. | |
40 | -*/ | |
41 | - | |
42 | -/** | |
43 | - * ajaxSubmit() provides a mechanism for immediately submitting | |
44 | - * an HTML form using AJAX. | |
45 | - */ | |
46 | -$.fn.ajaxSubmit = function(options) { | |
47 | - // fast fail if nothing selected (http://dev.jquery.com/ticket/2752) | |
48 | - if (!this.length) { | |
49 | - log('ajaxSubmit: skipping submit process - no element selected'); | |
50 | - return this; | |
51 | - } | |
52 | - | |
53 | - if (typeof options == 'function') | |
54 | - options = { success: options }; | |
55 | - | |
56 | - options = $.extend({ | |
57 | - url: this.attr('action') || window.location.toString(), | |
58 | - type: this.attr('method') || 'GET' | |
59 | - }, options || {}); | |
60 | - | |
61 | - // hook for manipulating the form data before it is extracted; | |
62 | - // convenient for use with rich editors like tinyMCE or FCKEditor | |
63 | - var veto = {}; | |
64 | - this.trigger('form-pre-serialize', [this, options, veto]); | |
65 | - if (veto.veto) { | |
66 | - log('ajaxSubmit: submit vetoed via form-pre-serialize trigger'); | |
67 | - return this; | |
68 | - } | |
69 | - | |
70 | - // provide opportunity to alter form data before it is serialized | |
71 | - if (options.beforeSerialize && options.beforeSerialize(this, options) === false) { | |
72 | - log('ajaxSubmit: submit aborted via beforeSerialize callback'); | |
73 | - return this; | |
74 | - } | |
75 | - | |
76 | - var a = this.formToArray(options.semantic); | |
77 | - if (options.data) { | |
78 | - options.extraData = options.data; | |
79 | - for (var n in options.data) { | |
80 | - if(options.data[n] instanceof Array) { | |
81 | - for (var k in options.data[n]) | |
82 | - a.push( { name: n, value: options.data[n][k] } ) | |
83 | - } | |
84 | - else | |
85 | - a.push( { name: n, value: options.data[n] } ); | |
86 | - } | |
87 | - } | |
88 | - | |
89 | - // give pre-submit callback an opportunity to abort the submit | |
90 | - if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) { | |
91 | - log('ajaxSubmit: submit aborted via beforeSubmit callback'); | |
92 | - return this; | |
93 | - } | |
94 | - | |
95 | - // fire vetoable 'validate' event | |
96 | - this.trigger('form-submit-validate', [a, this, options, veto]); | |
97 | - if (veto.veto) { | |
98 | - log('ajaxSubmit: submit vetoed via form-submit-validate trigger'); | |
99 | - return this; | |
100 | - } | |
101 | - | |
102 | - var q = $.param(a); | |
103 | - | |
104 | - if (options.type.toUpperCase() == 'GET') { | |
105 | - options.url += (options.url.indexOf('?') >= 0 ? '&' : '?') + q; | |
106 | - options.data = null; // data is null for 'get' | |
107 | - } | |
108 | - else | |
109 | - options.data = q; // data is the query string for 'post' | |
110 | - | |
111 | - var $form = this, callbacks = []; | |
112 | - if (options.resetForm) callbacks.push(function() { $form.resetForm(); }); | |
113 | - if (options.clearForm) callbacks.push(function() { $form.clearForm(); }); | |
114 | - | |
115 | - // perform a load on the target only if dataType is not provided | |
116 | - if (!options.dataType && options.target) { | |
117 | - var oldSuccess = options.success || function(){}; | |
118 | - callbacks.push(function(data) { | |
119 | - $(options.target).html(data).each(oldSuccess, arguments); | |
120 | - }); | |
121 | - } | |
122 | - else if (options.success) | |
123 | - callbacks.push(options.success); | |
124 | - | |
125 | - options.success = function(data, status) { | |
126 | - for (var i=0, max=callbacks.length; i < max; i++) | |
127 | - callbacks[i].apply(options, [data, status, $form]); | |
128 | - }; | |
129 | - | |
130 | - // are there files to upload? | |
131 | -// Modified MIS on 5.3.5.0 (2011/05/01) | |
132 | -/* | |
133 | - var files = $('input:file', this).fieldValue(); | |
134 | - var found = false; | |
135 | - for (var j=0; j < files.length; j++) | |
136 | - if (files[j]) | |
137 | - found = true; | |
138 | -*/ | |
139 | - var found = $('input:file', this).length > 0 ? true : false; | |
140 | - | |
141 | - // options.iframe allows user to force iframe mode | |
142 | - if (options.iframe || found) { | |
143 | - // hack to fix Safari hang (thanks to Tim Molendijk for this) | |
144 | - // see: http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d | |
145 | - if (options.closeKeepAlive) | |
146 | - $.get(options.closeKeepAlive, fileUpload); | |
147 | - else | |
148 | - fileUpload(); | |
149 | - } | |
150 | - else | |
151 | - $.ajax(options); | |
152 | - | |
153 | - // fire 'notify' event | |
154 | - this.trigger('form-submit-notify', [this, options]); | |
155 | - return this; | |
156 | - | |
157 | - | |
158 | - // private function for handling file uploads (hat tip to YAHOO!) | |
159 | - function fileUpload() { | |
160 | - var form = $form[0]; | |
161 | - | |
162 | - if ($(':input[name=submit]', form).length) { | |
163 | - alert('Error: Form elements must not be named "submit".'); | |
164 | - return; | |
165 | - } | |
166 | - | |
167 | - var opts = $.extend({}, $.ajaxSettings, options); | |
168 | - var s = jQuery.extend(true, {}, $.extend(true, {}, $.ajaxSettings), opts); | |
169 | - | |
170 | - var id = 'jqFormIO' + (new Date().getTime()); | |
171 | - var $io = $('<iframe id="' + id + '" name="' + id + '" src="about:blank" />'); | |
172 | - var io = $io[0]; | |
173 | - | |
174 | - $io.css({ position: 'absolute', top: '-1000px', left: '-1000px' }); | |
175 | - | |
176 | - var xhr = { // mock object | |
177 | - aborted: 0, | |
178 | - responseText: null, | |
179 | - responseXML: null, | |
180 | - status: 0, | |
181 | - statusText: 'n/a', | |
182 | - getAllResponseHeaders: function() {}, | |
183 | - getResponseHeader: function() {}, | |
184 | - setRequestHeader: function() {}, | |
185 | - abort: function() { | |
186 | - this.aborted = 1; | |
187 | - $io.attr('src','about:blank'); // abort op in progress | |
188 | - } | |
189 | - }; | |
190 | - | |
191 | - var g = opts.global; | |
192 | - // trigger ajax global events so that activity/block indicators work like normal | |
193 | - if (g && ! $.active++) $.event.trigger("ajaxStart"); | |
194 | - if (g) $.event.trigger("ajaxSend", [xhr, opts]); | |
195 | - | |
196 | - if (s.beforeSend && s.beforeSend(xhr, s) === false) { | |
197 | - s.global && jQuery.active--; | |
198 | - return; | |
199 | - } | |
200 | - if (xhr.aborted) | |
201 | - return; | |
202 | - | |
203 | - var cbInvoked = 0; | |
204 | - var timedOut = 0; | |
205 | - | |
206 | - // add submitting element to data if we know it | |
207 | - var sub = form.clk; | |
208 | - if (sub) { | |
209 | - var n = sub.name; | |
210 | - if (n && !sub.disabled) { | |
211 | - options.extraData = options.extraData || {}; | |
212 | - options.extraData[n] = sub.value; | |
213 | - if (sub.type == "image") { | |
214 | - options.extraData[name+'.x'] = form.clk_x; | |
215 | - options.extraData[name+'.y'] = form.clk_y; | |
216 | - } | |
217 | - } | |
218 | - } | |
219 | - | |
220 | - // take a breath so that pending repaints get some cpu time before the upload starts | |
221 | - setTimeout(function() { | |
222 | - // make sure form attrs are set | |
223 | - var t = $form.attr('target'), a = $form.attr('action'); | |
224 | - | |
225 | - // update form attrs in IE friendly way | |
226 | - form.setAttribute('target',id); | |
227 | - if (form.getAttribute('method') != 'POST') | |
228 | - form.setAttribute('method', 'POST'); | |
229 | - if (form.getAttribute('action') != opts.url) | |
230 | - form.setAttribute('action', opts.url); | |
231 | - | |
232 | - // ie borks in some cases when setting encoding | |
233 | - if (! options.skipEncodingOverride) { | |
234 | - $form.attr({ | |
235 | - encoding: 'multipart/form-data', | |
236 | - enctype: 'multipart/form-data' | |
237 | - }); | |
238 | - } | |
239 | - | |
240 | - // support timout | |
241 | - if (opts.timeout) | |
242 | - setTimeout(function() { timedOut = true; cb(); }, opts.timeout); | |
243 | - | |
244 | - // add "extra" data to form if provided in options | |
245 | - var extraInputs = []; | |
246 | - try { | |
247 | - if (options.extraData) | |
248 | - for (var n in options.extraData) | |
249 | - extraInputs.push( | |
250 | - $('<input type="hidden" name="'+n+'" value="'+options.extraData[n]+'" />') | |
251 | - .appendTo(form)[0]); | |
252 | - | |
253 | - // add iframe to doc and submit the form | |
254 | - $io.appendTo('body'); | |
255 | - io.attachEvent ? io.attachEvent('onload', cb) : io.addEventListener('load', cb, false); | |
256 | - form.submit(); | |
257 | - } | |
258 | - finally { | |
259 | - // reset attrs and remove "extra" input elements | |
260 | - form.setAttribute('action',a); | |
261 | - t ? form.setAttribute('target', t) : $form.removeAttr('target'); | |
262 | - $(extraInputs).remove(); | |
263 | - } | |
264 | - }, 10); | |
265 | - | |
266 | - var nullCheckFlag = 0; | |
267 | - | |
268 | - function cb() { | |
269 | - if (cbInvoked++) return; | |
270 | - | |
271 | - io.detachEvent ? io.detachEvent('onload', cb) : io.removeEventListener('load', cb, false); | |
272 | - | |
273 | - var ok = true; | |
274 | - try { | |
275 | - if (timedOut) throw 'timeout'; | |
276 | - // extract the server response from the iframe | |
277 | - var data, doc; | |
278 | - | |
279 | - doc = io.contentWindow ? io.contentWindow.document : io.contentDocument ? io.contentDocument : io.document; | |
280 | - | |
281 | - if ((doc.body == null || doc.body.innerHTML == '') && !nullCheckFlag) { | |
282 | - // in some browsers (cough, Opera 9.2.x) the iframe DOM is not always traversable when | |
283 | - // the onload callback fires, so we give them a 2nd chance | |
284 | - nullCheckFlag = 1; | |
285 | - cbInvoked--; | |
286 | - setTimeout(cb, 100); | |
287 | - return; | |
288 | - } | |
289 | - | |
290 | - xhr.responseText = doc.body ? doc.body.innerHTML : null; | |
291 | - xhr.responseXML = doc.XMLDocument ? doc.XMLDocument : doc; | |
292 | - xhr.getResponseHeader = function(header){ | |
293 | - var headers = {'content-type': opts.dataType}; | |
294 | - return headers[header]; | |
295 | - }; | |
296 | - | |
297 | - if (opts.dataType == 'json' || opts.dataType == 'script') { | |
298 | - var ta = doc.getElementsByTagName('textarea')[0]; | |
299 | - xhr.responseText = ta ? ta.value : xhr.responseText; | |
300 | - } | |
301 | - else if (opts.dataType == 'xml' && !xhr.responseXML && xhr.responseText != null) { | |
302 | - xhr.responseXML = toXml(xhr.responseText); | |
303 | - } | |
304 | - data = $.httpData(xhr, opts.dataType); | |
305 | - } | |
306 | - catch(e){ | |
307 | - ok = false; | |
308 | - $.handleError(opts, xhr, 'error', e); | |
309 | - } | |
310 | - | |
311 | - // ordering of these callbacks/triggers is odd, but that's how $.ajax does it | |
312 | - if (ok) { | |
313 | - opts.success(data, 'success'); | |
314 | - if (g) $.event.trigger("ajaxSuccess", [xhr, opts]); | |
315 | - } | |
316 | - if (g) $.event.trigger("ajaxComplete", [xhr, opts]); | |
317 | - if (g && ! --$.active) $.event.trigger("ajaxStop"); | |
318 | - if (opts.complete) opts.complete(xhr, ok ? 'success' : 'error'); | |
319 | - | |
320 | - // clean up | |
321 | - setTimeout(function() { | |
322 | - $io.remove(); | |
323 | - xhr.responseXML = null; | |
324 | - }, 100); | |
325 | - }; | |
326 | - | |
327 | - function toXml(s, doc) { | |
328 | - if (window.ActiveXObject) { | |
329 | - doc = new ActiveXObject('Microsoft.XMLDOM'); | |
330 | - doc.async = 'false'; | |
331 | - doc.loadXML(s); | |
332 | - } | |
333 | - else | |
334 | - doc = (new DOMParser()).parseFromString(s, 'text/xml'); | |
335 | - return (doc && doc.documentElement && doc.documentElement.tagName != 'parsererror') ? doc : null; | |
336 | - }; | |
337 | - }; | |
338 | -}; | |
339 | - | |
340 | -/** | |
341 | - * ajaxForm() provides a mechanism for fully automating form submission. | |
342 | - * | |
343 | - * The advantages of using this method instead of ajaxSubmit() are: | |
344 | - * | |
345 | - * 1: This method will include coordinates for <input type="image" /> elements (if the element | |
346 | - * is used to submit the form). | |
347 | - * 2. This method will include the submit element's name/value data (for the element that was | |
348 | - * used to submit the form). | |
349 | - * 3. This method binds the submit() method to the form for you. | |
350 | - * | |
351 | - * The options argument for ajaxForm works exactly as it does for ajaxSubmit. ajaxForm merely | |
352 | - * passes the options argument along after properly binding events for submit elements and | |
353 | - * the form itself. | |
354 | - */ | |
355 | -$.fn.ajaxForm = function(options) { | |
356 | - return this.ajaxFormUnbind().bind('submit.form-plugin',function() { | |
357 | - $(this).ajaxSubmit(options); | |
358 | - return false; | |
359 | - }).each(function() { | |
360 | - // store options in hash | |
361 | - $(":submit,input:image", this).bind('click.form-plugin',function(e) { | |
362 | - var form = this.form; | |
363 | - form.clk = this; | |
364 | - if (this.type == 'image') { | |
365 | - if (e.offsetX != undefined) { | |
366 | - form.clk_x = e.offsetX; | |
367 | - form.clk_y = e.offsetY; | |
368 | - } else if (typeof $.fn.offset == 'function') { // try to use dimensions plugin | |
369 | - var offset = $(this).offset(); | |
370 | - form.clk_x = e.pageX - offset.left; | |
371 | - form.clk_y = e.pageY - offset.top; | |
372 | - } else { | |
373 | - form.clk_x = e.pageX - this.offsetLeft; | |
374 | - form.clk_y = e.pageY - this.offsetTop; | |
375 | - } | |
376 | - } | |
377 | - // clear form vars | |
378 | - setTimeout(function() { form.clk = form.clk_x = form.clk_y = null; }, 10); | |
379 | - }); | |
380 | - }); | |
381 | -}; | |
382 | - | |
383 | -// ajaxFormUnbind unbinds the event handlers that were bound by ajaxForm | |
384 | -$.fn.ajaxFormUnbind = function() { | |
385 | - this.unbind('submit.form-plugin'); | |
386 | - return this.each(function() { | |
387 | - $(":submit,input:image", this).unbind('click.form-plugin'); | |
388 | - }); | |
389 | - | |
390 | -}; | |
391 | - | |
392 | -/** | |
393 | - * formToArray() gathers form element data into an array of objects that can | |
394 | - * be passed to any of the following ajax functions: $.get, $.post, or load. | |
395 | - * Each object in the array has both a 'name' and 'value' property. An example of | |
396 | - * an array for a simple login form might be: | |
397 | - * | |
398 | - * [ { name: 'username', value: 'jresig' }, { name: 'password', value: 'secret' } ] | |
399 | - * | |
400 | - * It is this array that is passed to pre-submit callback functions provided to the | |
401 | - * ajaxSubmit() and ajaxForm() methods. | |
402 | - */ | |
403 | -$.fn.formToArray = function(semantic) { | |
404 | - var a = []; | |
405 | - if (this.length == 0) return a; | |
406 | - | |
407 | - var form = this[0]; | |
408 | - var els = semantic ? form.getElementsByTagName('*') : form.elements; | |
409 | - if (!els) return a; | |
410 | - for(var i=0, max=els.length; i < max; i++) { | |
411 | - var el = els[i]; | |
412 | - var n = el.name; | |
413 | - if (!n) continue; | |
414 | - | |
415 | - if (semantic && form.clk && el.type == "image") { | |
416 | - // handle image inputs on the fly when semantic == true | |
417 | - if(!el.disabled && form.clk == el) | |
418 | - a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y}); | |
419 | - continue; | |
420 | - } | |
421 | - | |
422 | - var v = $.fieldValue(el, true); | |
423 | - if (v && v.constructor == Array) { | |
424 | - for(var j=0, jmax=v.length; j < jmax; j++) | |
425 | - a.push({name: n, value: v[j]}); | |
426 | - } | |
427 | - else if (v !== null && typeof v != 'undefined') | |
428 | - a.push({name: n, value: v}); | |
429 | - } | |
430 | - | |
431 | - if (!semantic && form.clk) { | |
432 | - // input type=='image' are not found in elements array! handle them here | |
433 | - var inputs = form.getElementsByTagName("input"); | |
434 | - for(var i=0, max=inputs.length; i < max; i++) { | |
435 | - var input = inputs[i]; | |
436 | - var n = input.name; | |
437 | - if(n && !input.disabled && input.type == "image" && form.clk == input) | |
438 | - a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y}); | |
439 | - } | |
440 | - } | |
441 | - return a; | |
442 | -}; | |
443 | - | |
444 | -/** | |
445 | - * Serializes form data into a 'submittable' string. This method will return a string | |
446 | - * in the format: name1=value1&name2=value2 | |
447 | - */ | |
448 | -$.fn.formSerialize = function(semantic) { | |
449 | - //hand off to jQuery.param for proper encoding | |
450 | - return $.param(this.formToArray(semantic)); | |
451 | -}; | |
452 | - | |
453 | -/** | |
454 | - * Serializes all field elements in the jQuery object into a query string. | |
455 | - * This method will return a string in the format: name1=value1&name2=value2 | |
456 | - */ | |
457 | -$.fn.fieldSerialize = function(successful) { | |
458 | - var a = []; | |
459 | - this.each(function() { | |
460 | - var n = this.name; | |
461 | - if (!n) return; | |
462 | - var v = $.fieldValue(this, successful); | |
463 | - if (v && v.constructor == Array) { | |
464 | - for (var i=0,max=v.length; i < max; i++) | |
465 | - a.push({name: n, value: v[i]}); | |
466 | - } | |
467 | - else if (v !== null && typeof v != 'undefined') | |
468 | - a.push({name: this.name, value: v}); | |
469 | - }); | |
470 | - //hand off to jQuery.param for proper encoding | |
471 | - return $.param(a); | |
472 | -}; | |
473 | - | |
474 | -/** | |
475 | - * Returns the value(s) of the element in the matched set. For example, consider the following form: | |
476 | - * | |
477 | - * <form><fieldset> | |
478 | - * <input name="A" type="text" /> | |
479 | - * <input name="A" type="text" /> | |
480 | - * <input name="B" type="checkbox" value="B1" /> | |
481 | - * <input name="B" type="checkbox" value="B2"/> | |
482 | - * <input name="C" type="radio" value="C1" /> | |
483 | - * <input name="C" type="radio" value="C2" /> | |
484 | - * </fieldset></form> | |
485 | - * | |
486 | - * var v = $(':text').fieldValue(); | |
487 | - * // if no values are entered into the text inputs | |
488 | - * v == ['',''] | |
489 | - * // if values entered into the text inputs are 'foo' and 'bar' | |
490 | - * v == ['foo','bar'] | |
491 | - * | |
492 | - * var v = $(':checkbox').fieldValue(); | |
493 | - * // if neither checkbox is checked | |
494 | - * v === undefined | |
495 | - * // if both checkboxes are checked | |
496 | - * v == ['B1', 'B2'] | |
497 | - * | |
498 | - * var v = $(':radio').fieldValue(); | |
499 | - * // if neither radio is checked | |
500 | - * v === undefined | |
501 | - * // if first radio is checked | |
502 | - * v == ['C1'] | |
503 | - * | |
504 | - * The successful argument controls whether or not the field element must be 'successful' | |
505 | - * (per http://www.w3.org/TR/html4/interact/forms.html#successful-controls). | |
506 | - * The default value of the successful argument is true. If this value is false the value(s) | |
507 | - * for each element is returned. | |
508 | - * | |
509 | - * Note: This method *always* returns an array. If no valid value can be determined the | |
510 | - * array will be empty, otherwise it will contain one or more values. | |
511 | - */ | |
512 | -$.fn.fieldValue = function(successful) { | |
513 | - for (var val=[], i=0, max=this.length; i < max; i++) { | |
514 | - var el = this[i]; | |
515 | - var v = $.fieldValue(el, successful); | |
516 | - if (v === null || typeof v == 'undefined' || (v.constructor == Array && !v.length)) | |
517 | - continue; | |
518 | - v.constructor == Array ? $.merge(val, v) : val.push(v); | |
519 | - } | |
520 | - return val; | |
521 | -}; | |
522 | - | |
523 | -/** | |
524 | - * Returns the value of the field element. | |
525 | - */ | |
526 | -$.fieldValue = function(el, successful) { | |
527 | - var n = el.name, t = el.type, tag = el.tagName.toLowerCase(); | |
528 | - if (typeof successful == 'undefined') successful = true; | |
529 | - | |
530 | - if (successful && (!n || el.disabled || t == 'reset' || t == 'button' || | |
531 | - (t == 'checkbox' || t == 'radio') && !el.checked || | |
532 | - (t == 'submit' || t == 'image') && el.form && el.form.clk != el || | |
533 | - tag == 'select' && el.selectedIndex == -1)) | |
534 | - return null; | |
535 | - | |
536 | - if (tag == 'select') { | |
537 | - var index = el.selectedIndex; | |
538 | - if (index < 0) return null; | |
539 | - var a = [], ops = el.options; | |
540 | - var one = (t == 'select-one'); | |
541 | - var max = (one ? index+1 : ops.length); | |
542 | - for(var i=(one ? index : 0); i < max; i++) { | |
543 | - var op = ops[i]; | |
544 | - if (op.selected) { | |
545 | - var v = op.value; | |
546 | - if (!v) // extra pain for IE... | |
547 | - v = (op.attributes && op.attributes['value'] && !(op.attributes['value'].specified)) ? op.text : op.value; | |
548 | - if (one) return v; | |
549 | - a.push(v); | |
550 | - } | |
551 | - } | |
552 | - return a; | |
553 | - } | |
554 | - return el.value; | |
555 | -}; | |
556 | - | |
557 | -/** | |
558 | - * Clears the form data. Takes the following actions on the form's input fields: | |
559 | - * - input text fields will have their 'value' property set to the empty string | |
560 | - * - select elements will have their 'selectedIndex' property set to -1 | |
561 | - * - checkbox and radio inputs will have their 'checked' property set to false | |
562 | - * - inputs of type submit, button, reset, and hidden will *not* be effected | |
563 | - * - button elements will *not* be effected | |
564 | - */ | |
565 | -$.fn.clearForm = function() { | |
566 | - return this.each(function() { | |
567 | - $('input,select,textarea', this).clearFields(); | |
568 | - }); | |
569 | -}; | |
570 | - | |
571 | -/** | |
572 | - * Clears the selected form elements. | |
573 | - */ | |
574 | -$.fn.clearFields = $.fn.clearInputs = function() { | |
575 | - return this.each(function() { | |
576 | - var t = this.type, tag = this.tagName.toLowerCase(); | |
577 | - if (t == 'text' || t == 'password' || tag == 'textarea') | |
578 | - this.value = ''; | |
579 | - else if (t == 'checkbox' || t == 'radio') | |
580 | - this.checked = false; | |
581 | - else if (tag == 'select') | |
582 | - this.selectedIndex = -1; | |
583 | - }); | |
584 | -}; | |
585 | - | |
586 | -/** | |
587 | - * Resets the form data. Causes all form elements to be reset to their original value. | |
588 | - */ | |
589 | -$.fn.resetForm = function() { | |
590 | - return this.each(function() { | |
591 | - // guard against an input with the name of 'reset' | |
592 | - // note that IE reports the reset function as an 'object' | |
593 | - if (typeof this.reset == 'function' || (typeof this.reset == 'object' && !this.reset.nodeType)) | |
594 | - this.reset(); | |
595 | - }); | |
596 | -}; | |
597 | - | |
598 | -/** | |
599 | - * Enables or disables any matching elements. | |
600 | - */ | |
601 | -$.fn.enable = function(b) { | |
602 | - if (b == undefined) b = true; | |
603 | - return this.each(function() { | |
604 | - this.disabled = !b | |
605 | - }); | |
606 | -}; | |
607 | - | |
608 | -/** | |
609 | - * Checks/unchecks any matching checkboxes or radio buttons and | |
610 | - * selects/deselects and matching option elements. | |
611 | - */ | |
612 | -$.fn.selected = function(select) { | |
613 | - if (select == undefined) select = true; | |
614 | - return this.each(function() { | |
615 | - var t = this.type; | |
616 | - if (t == 'checkbox' || t == 'radio') | |
617 | - this.checked = select; | |
618 | - else if (this.tagName.toLowerCase() == 'option') { | |
619 | - var $sel = $(this).parent('select'); | |
620 | - if (select && $sel[0] && $sel[0].type == 'select-one') { | |
621 | - // deselect all other options | |
622 | - $sel.find('option').selected(false); | |
623 | - } | |
624 | - this.selected = select; | |
625 | - } | |
626 | - }); | |
627 | -}; | |
628 | - | |
629 | -// helper fn for console logging | |
630 | -// set $.fn.ajaxSubmit.debug to true to enable debug logging | |
631 | -function log() { | |
632 | - if ($.fn.ajaxSubmit.debug && window.console && window.console.log) | |
633 | - window.console.log('[jquery.form] ' + Array.prototype.join.call(arguments,'')); | |
634 | -}; | |
635 | - | |
636 | -})(jQuery); | |
1 | +/*! | |
2 | + * jQuery Form Plugin | |
3 | + * version: 4.2.2 | |
4 | + * Requires jQuery v1.7.2 or later | |
5 | + * Project repository: https://github.com/jquery-form/form | |
6 | + | |
7 | + * Copyright 2017 Kevin Morris | |
8 | + * Copyright 2006 M. Alsup | |
9 | + | |
10 | + * Dual licensed under the LGPL-2.1+ or MIT licenses | |
11 | + * https://github.com/jquery-form/form#license | |
12 | + | |
13 | + * This library is free software; you can redistribute it and/or | |
14 | + * modify it under the terms of the GNU Lesser General Public | |
15 | + * License as published by the Free Software Foundation; either | |
16 | + * version 2.1 of the License, or (at your option) any later version. | |
17 | + * This library is distributed in the hope that it will be useful, | |
18 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
20 | + * Lesser General Public License for more details. | |
21 | + */ | |
22 | +/* global ActiveXObject */ | |
23 | + | |
24 | +/* eslint-disable */ | |
25 | +(function (factory) { | |
26 | + if (typeof define === 'function' && define.amd) { | |
27 | + // AMD. Register as an anonymous module. | |
28 | + define(['jquery'], factory); | |
29 | + } else if (typeof module === 'object' && module.exports) { | |
30 | + // Node/CommonJS | |
31 | + module.exports = function( root, jQuery ) { | |
32 | + if (typeof jQuery === 'undefined') { | |
33 | + // require('jQuery') returns a factory that requires window to build a jQuery instance, we normalize how we use modules | |
34 | + // that require this pattern but the window provided is a noop if it's defined (how jquery works) | |
35 | + if (typeof window !== 'undefined') { | |
36 | + jQuery = require('jquery'); | |
37 | + } | |
38 | + else { | |
39 | + jQuery = require('jquery')(root); | |
40 | + } | |
41 | + } | |
42 | + factory(jQuery); | |
43 | + return jQuery; | |
44 | + }; | |
45 | + } else { | |
46 | + // Browser globals | |
47 | + factory(jQuery); | |
48 | + } | |
49 | + | |
50 | +}(function ($) { | |
51 | +/* eslint-enable */ | |
52 | + 'use strict'; | |
53 | + | |
54 | + /* | |
55 | + Usage Note: | |
56 | + ----------- | |
57 | + Do not use both ajaxSubmit and ajaxForm on the same form. These | |
58 | + functions are mutually exclusive. Use ajaxSubmit if you want | |
59 | + to bind your own submit handler to the form. For example, | |
60 | + | |
61 | + $(document).ready(function() { | |
62 | + $('#myForm').on('submit', function(e) { | |
63 | + e.preventDefault(); // <-- important | |
64 | + $(this).ajaxSubmit({ | |
65 | + target: '#output' | |
66 | + }); | |
67 | + }); | |
68 | + }); | |
69 | + | |
70 | + Use ajaxForm when you want the plugin to manage all the event binding | |
71 | + for you. For example, | |
72 | + | |
73 | + $(document).ready(function() { | |
74 | + $('#myForm').ajaxForm({ | |
75 | + target: '#output' | |
76 | + }); | |
77 | + }); | |
78 | + | |
79 | + You can also use ajaxForm with delegation (requires jQuery v1.7+), so the | |
80 | + form does not have to exist when you invoke ajaxForm: | |
81 | + | |
82 | + $('#myForm').ajaxForm({ | |
83 | + delegation: true, | |
84 | + target: '#output' | |
85 | + }); | |
86 | + | |
87 | + When using ajaxForm, the ajaxSubmit function will be invoked for you | |
88 | + at the appropriate time. | |
89 | + */ | |
90 | + | |
91 | + var rCRLF = /\r?\n/g; | |
92 | + | |
93 | + /** | |
94 | + * Feature detection | |
95 | + */ | |
96 | + var feature = {}; | |
97 | + | |
98 | + feature.fileapi = $('<input type="file">').get(0).files !== undefined; | |
99 | + feature.formdata = (typeof window.FormData !== 'undefined'); | |
100 | + | |
101 | + var hasProp = !!$.fn.prop; | |
102 | + | |
103 | + // attr2 uses prop when it can but checks the return type for | |
104 | + // an expected string. This accounts for the case where a form | |
105 | + // contains inputs with names like "action" or "method"; in those | |
106 | + // cases "prop" returns the element | |
107 | + $.fn.attr2 = function() { | |
108 | + if (!hasProp) { | |
109 | + return this.attr.apply(this, arguments); | |
110 | + } | |
111 | + | |
112 | + var val = this.prop.apply(this, arguments); | |
113 | + | |
114 | + if ((val && val.jquery) || typeof val === 'string') { | |
115 | + return val; | |
116 | + } | |
117 | + | |
118 | + return this.attr.apply(this, arguments); | |
119 | + }; | |
120 | + | |
121 | + /** | |
122 | + * ajaxSubmit() provides a mechanism for immediately submitting | |
123 | + * an HTML form using AJAX. | |
124 | + * | |
125 | + * @param {object|string} options jquery.form.js parameters or custom url for submission | |
126 | + * @param {object} data extraData | |
127 | + * @param {string} dataType ajax dataType | |
128 | + * @param {function} onSuccess ajax success callback function | |
129 | + */ | |
130 | + $.fn.ajaxSubmit = function(options, data, dataType, onSuccess) { | |
131 | + // fast fail if nothing selected (http://dev.jquery.com/ticket/2752) | |
132 | + if (!this.length) { | |
133 | + log('ajaxSubmit: skipping submit process - no element selected'); | |
134 | + | |
135 | + return this; | |
136 | + } | |
137 | + | |
138 | + /* eslint consistent-this: ["error", "$form"] */ | |
139 | + var method, action, url, $form = this; | |
140 | + | |
141 | + if (typeof options === 'function') { | |
142 | + options = {success: options}; | |
143 | + | |
144 | + } else if (typeof options === 'string' || (options === false && arguments.length > 0)) { | |
145 | + options = { | |
146 | + 'url' : options, | |
147 | + 'data' : data, | |
148 | + 'dataType' : dataType | |
149 | + }; | |
150 | + | |
151 | + if (typeof onSuccess === 'function') { | |
152 | + options.success = onSuccess; | |
153 | + } | |
154 | + | |
155 | + } else if (typeof options === 'undefined') { | |
156 | + options = {}; | |
157 | + } | |
158 | + | |
159 | + method = options.method || options.type || this.attr2('method'); | |
160 | + action = options.url || this.attr2('action'); | |
161 | + | |
162 | + url = (typeof action === 'string') ? $.trim(action) : ''; | |
163 | + url = url || window.location.href || ''; | |
164 | + if (url) { | |
165 | + // clean url (don't include hash vaue) | |
166 | + url = (url.match(/^([^#]+)/) || [])[1]; | |
167 | + } | |
168 | + | |
169 | + options = $.extend(true, { | |
170 | + url : url, | |
171 | + success : $.ajaxSettings.success, | |
172 | + type : method || $.ajaxSettings.type, | |
173 | + iframeSrc : /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank' // eslint-disable-line no-script-url | |
174 | + }, options); | |
175 | + | |
176 | + // hook for manipulating the form data before it is extracted; | |
177 | + // convenient for use with rich editors like tinyMCE or FCKEditor | |
178 | + var veto = {}; | |
179 | + | |
180 | + this.trigger('form-pre-serialize', [this, options, veto]); | |
181 | + | |
182 | + if (veto.veto) { | |
183 | + log('ajaxSubmit: submit vetoed via form-pre-serialize trigger'); | |
184 | + | |
185 | + return this; | |
186 | + } | |
187 | + | |
188 | + // provide opportunity to alter form data before it is serialized | |
189 | + if (options.beforeSerialize && options.beforeSerialize(this, options) === false) { | |
190 | + log('ajaxSubmit: submit aborted via beforeSerialize callback'); | |
191 | + | |
192 | + return this; | |
193 | + } | |
194 | + | |
195 | + var traditional = options.traditional; | |
196 | + | |
197 | + if (typeof traditional === 'undefined') { | |
198 | + traditional = $.ajaxSettings.traditional; | |
199 | + } | |
200 | + | |
201 | + var elements = []; | |
202 | + var qx, a = this.formToArray(options.semantic, elements, options.filtering); | |
203 | + | |
204 | + if (options.data) { | |
205 | + var optionsData = $.isFunction(options.data) ? options.data(a) : options.data; | |
206 | + | |
207 | + options.extraData = optionsData; | |
208 | + qx = $.param(optionsData, traditional); | |
209 | + } | |
210 | + | |
211 | + // give pre-submit callback an opportunity to abort the submit | |
212 | + if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) { | |
213 | + log('ajaxSubmit: submit aborted via beforeSubmit callback'); | |
214 | + | |
215 | + return this; | |
216 | + } | |
217 | + | |
218 | + // fire vetoable 'validate' event | |
219 | + this.trigger('form-submit-validate', [a, this, options, veto]); | |
220 | + if (veto.veto) { | |
221 | + log('ajaxSubmit: submit vetoed via form-submit-validate trigger'); | |
222 | + | |
223 | + return this; | |
224 | + } | |
225 | + | |
226 | + var q = $.param(a, traditional); | |
227 | + | |
228 | + if (qx) { | |
229 | + q = (q ? (q + '&' + qx) : qx); | |
230 | + } | |
231 | + | |
232 | + if (options.type.toUpperCase() === 'GET') { | |
233 | + options.url += (options.url.indexOf('?') >= 0 ? '&' : '?') + q; | |
234 | + options.data = null; // data is null for 'get' | |
235 | + } else { | |
236 | + options.data = q; // data is the query string for 'post' | |
237 | + } | |
238 | + | |
239 | + var callbacks = []; | |
240 | + | |
241 | + if (options.resetForm) { | |
242 | + callbacks.push(function() { | |
243 | + $form.resetForm(); | |
244 | + }); | |
245 | + } | |
246 | + | |
247 | + if (options.clearForm) { | |
248 | + callbacks.push(function() { | |
249 | + $form.clearForm(options.includeHidden); | |
250 | + }); | |
251 | + } | |
252 | + | |
253 | + // perform a load on the target only if dataType is not provided | |
254 | + if (!options.dataType && options.target) { | |
255 | + var oldSuccess = options.success || function(){}; | |
256 | + | |
257 | + callbacks.push(function(data, textStatus, jqXHR) { | |
258 | + var successArguments = arguments, | |
259 | + fn = options.replaceTarget ? 'replaceWith' : 'html'; | |
260 | + | |
261 | + $(options.target)[fn](data).each(function(){ | |
262 | + oldSuccess.apply(this, successArguments); | |
263 | + }); | |
264 | + }); | |
265 | + | |
266 | + } else if (options.success) { | |
267 | + if ($.isArray(options.success)) { | |
268 | + $.merge(callbacks, options.success); | |
269 | + } else { | |
270 | + callbacks.push(options.success); | |
271 | + } | |
272 | + } | |
273 | + | |
274 | + options.success = function(data, status, xhr) { // jQuery 1.4+ passes xhr as 3rd arg | |
275 | + var context = options.context || this; // jQuery 1.4+ supports scope context | |
276 | + | |
277 | + for (var i = 0, max = callbacks.length; i < max; i++) { | |
278 | + callbacks[i].apply(context, [data, status, xhr || $form, $form]); | |
279 | + } | |
280 | + }; | |
281 | + | |
282 | + if (options.error) { | |
283 | + var oldError = options.error; | |
284 | + | |
285 | + options.error = function(xhr, status, error) { | |
286 | + var context = options.context || this; | |
287 | + | |
288 | + oldError.apply(context, [xhr, status, error, $form]); | |
289 | + }; | |
290 | + } | |
291 | + | |
292 | + if (options.complete) { | |
293 | + var oldComplete = options.complete; | |
294 | + | |
295 | + options.complete = function(xhr, status) { | |
296 | + var context = options.context || this; | |
297 | + | |
298 | + oldComplete.apply(context, [xhr, status, $form]); | |
299 | + }; | |
300 | + } | |
301 | + | |
302 | + // are there files to upload? | |
303 | + | |
304 | + // [value] (issue #113), also see comment: | |
305 | + // https://github.com/malsup/form/commit/588306aedba1de01388032d5f42a60159eea9228#commitcomment-2180219 | |
306 | + var fileInputs = $('input[type=file]:enabled', this).filter(function() { | |
307 | + return $(this).val() !== ''; | |
308 | + }); | |
309 | + var hasFileInputs = fileInputs.length > 0; | |
310 | + var mp = 'multipart/form-data'; | |
311 | + var multipart = ($form.attr('enctype') === mp || $form.attr('encoding') === mp); | |
312 | + var fileAPI = feature.fileapi && feature.formdata; | |
313 | + | |
314 | + log('fileAPI :' + fileAPI); | |
315 | + | |
316 | + var shouldUseFrame = (hasFileInputs || multipart) && !fileAPI; | |
317 | + var jqxhr; | |
318 | + | |
319 | + // options.iframe allows user to force iframe mode | |
320 | + // 06-NOV-09: now defaulting to iframe mode if file input is detected | |
321 | + if (options.iframe !== false && (options.iframe || shouldUseFrame)) { | |
322 | + // hack to fix Safari hang (thanks to Tim Molendijk for this) | |
323 | + // see: http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d | |
324 | + if (options.closeKeepAlive) { | |
325 | + $.get(options.closeKeepAlive, function() { | |
326 | + jqxhr = fileUploadIframe(a); | |
327 | + }); | |
328 | + | |
329 | + } else { | |
330 | + jqxhr = fileUploadIframe(a); | |
331 | + } | |
332 | + | |
333 | + } else if ((hasFileInputs || multipart) && fileAPI) { | |
334 | + jqxhr = fileUploadXhr(a); | |
335 | + | |
336 | + } else { | |
337 | + jqxhr = $.ajax(options); | |
338 | + } | |
339 | + | |
340 | + $form.removeData('jqxhr').data('jqxhr', jqxhr); | |
341 | + | |
342 | + // clear element array | |
343 | + for (var k = 0; k < elements.length; k++) { | |
344 | + elements[k] = null; | |
345 | + } | |
346 | + | |
347 | + // fire 'notify' event | |
348 | + this.trigger('form-submit-notify', [this, options]); | |
349 | + | |
350 | + return this; | |
351 | + | |
352 | + // utility fn for deep serialization | |
353 | + function deepSerialize(extraData) { | |
354 | + var serialized = $.param(extraData, options.traditional).split('&'); | |
355 | + var len = serialized.length; | |
356 | + var result = []; | |
357 | + var i, part; | |
358 | + | |
359 | + for (i = 0; i < len; i++) { | |
360 | + // #252; undo param space replacement | |
361 | + serialized[i] = serialized[i].replace(/\+/g, ' '); | |
362 | + part = serialized[i].split('='); | |
363 | + // #278; use array instead of object storage, favoring array serializations | |
364 | + result.push([decodeURIComponent(part[0]), decodeURIComponent(part[1])]); | |
365 | + } | |
366 | + | |
367 | + return result; | |
368 | + } | |
369 | + | |
370 | + // XMLHttpRequest Level 2 file uploads (big hat tip to francois2metz) | |
371 | + function fileUploadXhr(a) { | |
372 | + var formdata = new FormData(); | |
373 | + | |
374 | + for (var i = 0; i < a.length; i++) { | |
375 | + formdata.append(a[i].name, a[i].value); | |
376 | + } | |
377 | + | |
378 | + if (options.extraData) { | |
379 | + var serializedData = deepSerialize(options.extraData); | |
380 | + | |
381 | + for (i = 0; i < serializedData.length; i++) { | |
382 | + if (serializedData[i]) { | |
383 | + formdata.append(serializedData[i][0], serializedData[i][1]); | |
384 | + } | |
385 | + } | |
386 | + } | |
387 | + | |
388 | + options.data = null; | |
389 | + | |
390 | + var s = $.extend(true, {}, $.ajaxSettings, options, { | |
391 | + contentType : false, | |
392 | + processData : false, | |
393 | + cache : false, | |
394 | + type : method || 'POST' | |
395 | + }); | |
396 | + | |
397 | + if (options.uploadProgress) { | |
398 | + // workaround because jqXHR does not expose upload property | |
399 | + s.xhr = function() { | |
400 | + var xhr = $.ajaxSettings.xhr(); | |
401 | + | |
402 | + if (xhr.upload) { | |
403 | + xhr.upload.addEventListener('progress', function(event) { | |
404 | + var percent = 0; | |
405 | + var position = event.loaded || event.position; /* event.position is deprecated */ | |
406 | + var total = event.total; | |
407 | + | |
408 | + if (event.lengthComputable) { | |
409 | + percent = Math.ceil(position / total * 100); | |
410 | + } | |
411 | + | |
412 | + options.uploadProgress(event, position, total, percent); | |
413 | + }, false); | |
414 | + } | |
415 | + | |
416 | + return xhr; | |
417 | + }; | |
418 | + } | |
419 | + | |
420 | + s.data = null; | |
421 | + | |
422 | + var beforeSend = s.beforeSend; | |
423 | + | |
424 | + s.beforeSend = function(xhr, o) { | |
425 | + // Send FormData() provided by user | |
426 | + if (options.formData) { | |
427 | + o.data = options.formData; | |
428 | + } else { | |
429 | + o.data = formdata; | |
430 | + } | |
431 | + | |
432 | + if (beforeSend) { | |
433 | + beforeSend.call(this, xhr, o); | |
434 | + } | |
435 | + }; | |
436 | + | |
437 | + return $.ajax(s); | |
438 | + } | |
439 | + | |
440 | + // private function for handling file uploads (hat tip to YAHOO!) | |
441 | + function fileUploadIframe(a) { | |
442 | + var form = $form[0], el, i, s, g, id, $io, io, xhr, sub, n, timedOut, timeoutHandle; | |
443 | + var deferred = $.Deferred(); | |
444 | + | |
445 | + // #341 | |
446 | + deferred.abort = function(status) { | |
447 | + xhr.abort(status); | |
448 | + }; | |
449 | + | |
450 | + if (a) { | |
451 | + // ensure that every serialized input is still enabled | |
452 | + for (i = 0; i < elements.length; i++) { | |
453 | + el = $(elements[i]); | |
454 | + if (hasProp) { | |
455 | + el.prop('disabled', false); | |
456 | + } else { | |
457 | + el.removeAttr('disabled'); | |
458 | + } | |
459 | + } | |
460 | + } | |
461 | + | |
462 | + s = $.extend(true, {}, $.ajaxSettings, options); | |
463 | + s.context = s.context || s; | |
464 | + id = 'jqFormIO' + new Date().getTime(); | |
465 | + var ownerDocument = form.ownerDocument; | |
466 | + var $body = $form.closest('body'); | |
467 | + | |
468 | + if (s.iframeTarget) { | |
469 | + $io = $(s.iframeTarget, ownerDocument); | |
470 | + n = $io.attr2('name'); | |
471 | + if (!n) { | |
472 | + $io.attr2('name', id); | |
473 | + } else { | |
474 | + id = n; | |
475 | + } | |
476 | + | |
477 | + } else { | |
478 | + $io = $('<iframe name="' + id + '" src="' + s.iframeSrc + '" />', ownerDocument); | |
479 | + $io.css({position: 'absolute', top: '-1000px', left: '-1000px'}); | |
480 | + } | |
481 | + io = $io[0]; | |
482 | + | |
483 | + | |
484 | + xhr = { // mock object | |
485 | + aborted : 0, | |
486 | + responseText : null, | |
487 | + responseXML : null, | |
488 | + status : 0, | |
489 | + statusText : 'n/a', | |
490 | + getAllResponseHeaders : function() {}, | |
491 | + getResponseHeader : function() {}, | |
492 | + setRequestHeader : function() {}, | |
493 | + abort : function(status) { | |
494 | + var e = (status === 'timeout' ? 'timeout' : 'aborted'); | |
495 | + | |
496 | + log('aborting upload... ' + e); | |
497 | + this.aborted = 1; | |
498 | + | |
499 | + try { // #214, #257 | |
500 | + if (io.contentWindow.document.execCommand) { | |
501 | + io.contentWindow.document.execCommand('Stop'); | |
502 | + } | |
503 | + } catch (ignore) {} | |
504 | + | |
505 | + $io.attr('src', s.iframeSrc); // abort op in progress | |
506 | + xhr.error = e; | |
507 | + if (s.error) { | |
508 | + s.error.call(s.context, xhr, e, status); | |
509 | + } | |
510 | + | |
511 | + if (g) { | |
512 | + $.event.trigger('ajaxError', [xhr, s, e]); | |
513 | + } | |
514 | + | |
515 | + if (s.complete) { | |
516 | + s.complete.call(s.context, xhr, e); | |
517 | + } | |
518 | + } | |
519 | + }; | |
520 | + | |
521 | + g = s.global; | |
522 | + // trigger ajax global events so that activity/block indicators work like normal | |
523 | + if (g && $.active++ === 0) { | |
524 | + $.event.trigger('ajaxStart'); | |
525 | + } | |
526 | + if (g) { | |
527 | + $.event.trigger('ajaxSend', [xhr, s]); | |
528 | + } | |
529 | + | |
530 | + if (s.beforeSend && s.beforeSend.call(s.context, xhr, s) === false) { | |
531 | + if (s.global) { | |
532 | + $.active--; | |
533 | + } | |
534 | + deferred.reject(); | |
535 | + | |
536 | + return deferred; | |
537 | + } | |
538 | + | |
539 | + if (xhr.aborted) { | |
540 | + deferred.reject(); | |
541 | + | |
542 | + return deferred; | |
543 | + } | |
544 | + | |
545 | + // add submitting element to data if we know it | |
546 | + sub = form.clk; | |
547 | + if (sub) { | |
548 | + n = sub.name; | |
549 | + if (n && !sub.disabled) { | |
550 | + s.extraData = s.extraData || {}; | |
551 | + s.extraData[n] = sub.value; | |
552 | + if (sub.type === 'image') { | |
553 | + s.extraData[n + '.x'] = form.clk_x; | |
554 | + s.extraData[n + '.y'] = form.clk_y; | |
555 | + } | |
556 | + } | |
557 | + } | |
558 | + | |
559 | + var CLIENT_TIMEOUT_ABORT = 1; | |
560 | + var SERVER_ABORT = 2; | |
561 | + | |
562 | + function getDoc(frame) { | |
563 | + /* it looks like contentWindow or contentDocument do not | |
564 | + * carry the protocol property in ie8, when running under ssl | |
565 | + * frame.document is the only valid response document, since | |
566 | + * the protocol is know but not on the other two objects. strange? | |
567 | + * "Same origin policy" http://en.wikipedia.org/wiki/Same_origin_policy | |
568 | + */ | |
569 | + | |
570 | + var doc = null; | |
571 | + | |
572 | + // IE8 cascading access check | |
573 | + try { | |
574 | + if (frame.contentWindow) { | |
575 | + doc = frame.contentWindow.document; | |
576 | + } | |
577 | + } catch (err) { | |
578 | + // IE8 access denied under ssl & missing protocol | |
579 | + log('cannot get iframe.contentWindow document: ' + err); | |
580 | + } | |
581 | + | |
582 | + if (doc) { // successful getting content | |
583 | + return doc; | |
584 | + } | |
585 | + | |
586 | + try { // simply checking may throw in ie8 under ssl or mismatched protocol | |
587 | + doc = frame.contentDocument ? frame.contentDocument : frame.document; | |
588 | + } catch (err) { | |
589 | + // last attempt | |
590 | + log('cannot get iframe.contentDocument: ' + err); | |
591 | + doc = frame.document; | |
592 | + } | |
593 | + | |
594 | + return doc; | |
595 | + } | |
596 | + | |
597 | + // Rails CSRF hack (thanks to Yvan Barthelemy) | |
598 | + var csrf_token = $('meta[name=csrf-token]').attr('content'); | |
599 | + var csrf_param = $('meta[name=csrf-param]').attr('content'); | |
600 | + | |
601 | + if (csrf_param && csrf_token) { | |
602 | + s.extraData = s.extraData || {}; | |
603 | + s.extraData[csrf_param] = csrf_token; | |
604 | + } | |
605 | + | |
606 | + // take a breath so that pending repaints get some cpu time before the upload starts | |
607 | + function doSubmit() { | |
608 | + // make sure form attrs are set | |
609 | + var t = $form.attr2('target'), | |
610 | + a = $form.attr2('action'), | |
611 | + mp = 'multipart/form-data', | |
612 | + et = $form.attr('enctype') || $form.attr('encoding') || mp; | |
613 | + | |
614 | + // update form attrs in IE friendly way | |
615 | + form.setAttribute('target', id); | |
616 | + if (!method || /post/i.test(method)) { | |
617 | + form.setAttribute('method', 'POST'); | |
618 | + } | |
619 | + if (a !== s.url) { | |
620 | + form.setAttribute('action', s.url); | |
621 | + } | |
622 | + | |
623 | + // ie borks in some cases when setting encoding | |
624 | + if (!s.skipEncodingOverride && (!method || /post/i.test(method))) { | |
625 | + $form.attr({ | |
626 | + encoding : 'multipart/form-data', | |
627 | + enctype : 'multipart/form-data' | |
628 | + }); | |
629 | + } | |
630 | + | |
631 | + // support timout | |
632 | + if (s.timeout) { | |
633 | + timeoutHandle = setTimeout(function() { | |
634 | + timedOut = true; cb(CLIENT_TIMEOUT_ABORT); | |
635 | + }, s.timeout); | |
636 | + } | |
637 | + | |
638 | + // look for server aborts | |
639 | + function checkState() { | |
640 | + try { | |
641 | + var state = getDoc(io).readyState; | |
642 | + | |
643 | + log('state = ' + state); | |
644 | + if (state && state.toLowerCase() === 'uninitialized') { | |
645 | + setTimeout(checkState, 50); | |
646 | + } | |
647 | + | |
648 | + } catch (e) { | |
649 | + log('Server abort: ', e, ' (', e.name, ')'); | |
650 | + cb(SERVER_ABORT); // eslint-disable-line callback-return | |
651 | + if (timeoutHandle) { | |
652 | + clearTimeout(timeoutHandle); | |
653 | + } | |
654 | + timeoutHandle = undefined; | |
655 | + } | |
656 | + } | |
657 | + | |
658 | + // add "extra" data to form if provided in options | |
659 | + var extraInputs = []; | |
660 | + | |
661 | + try { | |
662 | + if (s.extraData) { | |
663 | + for (var n in s.extraData) { | |
664 | + if (s.extraData.hasOwnProperty(n)) { | |
665 | + // if using the $.param format that allows for multiple values with the same name | |
666 | + if ($.isPlainObject(s.extraData[n]) && s.extraData[n].hasOwnProperty('name') && s.extraData[n].hasOwnProperty('value')) { | |
667 | + extraInputs.push( | |
668 | + $('<input type="hidden" name="' + s.extraData[n].name + '">', ownerDocument).val(s.extraData[n].value) | |
669 | + .appendTo(form)[0]); | |
670 | + } else { | |
671 | + extraInputs.push( | |
672 | + $('<input type="hidden" name="' + n + '">', ownerDocument).val(s.extraData[n]) | |
673 | + .appendTo(form)[0]); | |
674 | + } | |
675 | + } | |
676 | + } | |
677 | + } | |
678 | + | |
679 | + if (!s.iframeTarget) { | |
680 | + // add iframe to doc and submit the form | |
681 | + $io.appendTo($body); | |
682 | + } | |
683 | + | |
684 | + if (io.attachEvent) { | |
685 | + io.attachEvent('onload', cb); | |
686 | + } else { | |
687 | + io.addEventListener('load', cb, false); | |
688 | + } | |
689 | + | |
690 | + setTimeout(checkState, 15); | |
691 | + | |
692 | + try { | |
693 | + form.submit(); | |
694 | + | |
695 | + } catch (err) { | |
696 | + // just in case form has element with name/id of 'submit' | |
697 | + var submitFn = document.createElement('form').submit; | |
698 | + | |
699 | + submitFn.apply(form); | |
700 | + } | |
701 | + | |
702 | + } finally { | |
703 | + // reset attrs and remove "extra" input elements | |
704 | + form.setAttribute('action', a); | |
705 | + form.setAttribute('enctype', et); // #380 | |
706 | + if (t) { | |
707 | + form.setAttribute('target', t); | |
708 | + } else { | |
709 | + $form.removeAttr('target'); | |
710 | + } | |
711 | + $(extraInputs).remove(); | |
712 | + } | |
713 | + } | |
714 | + | |
715 | + if (s.forceSync) { | |
716 | + doSubmit(); | |
717 | + } else { | |
718 | + setTimeout(doSubmit, 10); // this lets dom updates render | |
719 | + } | |
720 | + | |
721 | + var data, doc, domCheckCount = 50, callbackProcessed; | |
722 | + | |
723 | + function cb(e) { | |
724 | + if (xhr.aborted || callbackProcessed) { | |
725 | + return; | |
726 | + } | |
727 | + | |
728 | + doc = getDoc(io); | |
729 | + if (!doc) { | |
730 | + log('cannot access response document'); | |
731 | + e = SERVER_ABORT; | |
732 | + } | |
733 | + if (e === CLIENT_TIMEOUT_ABORT && xhr) { | |
734 | + xhr.abort('timeout'); | |
735 | + deferred.reject(xhr, 'timeout'); | |
736 | + | |
737 | + return; | |
738 | + | |
739 | + } | |
740 | + if (e === SERVER_ABORT && xhr) { | |
741 | + xhr.abort('server abort'); | |
742 | + deferred.reject(xhr, 'error', 'server abort'); | |
743 | + | |
744 | + return; | |
745 | + } | |
746 | + | |
747 | + if (!doc || doc.location.href === s.iframeSrc) { | |
748 | + // response not received yet | |
749 | + if (!timedOut) { | |
750 | + return; | |
751 | + } | |
752 | + } | |
753 | + | |
754 | + if (io.detachEvent) { | |
755 | + io.detachEvent('onload', cb); | |
756 | + } else { | |
757 | + io.removeEventListener('load', cb, false); | |
758 | + } | |
759 | + | |
760 | + var status = 'success', errMsg; | |
761 | + | |
762 | + try { | |
763 | + if (timedOut) { | |
764 | + throw 'timeout'; | |
765 | + } | |
766 | + | |
767 | + var isXml = s.dataType === 'xml' || doc.XMLDocument || $.isXMLDoc(doc); | |
768 | + | |
769 | + log('isXml=' + isXml); | |
770 | + | |
771 | + if (!isXml && window.opera && (doc.body === null || !doc.body.innerHTML)) { | |
772 | + if (--domCheckCount) { | |
773 | + // in some browsers (Opera) the iframe DOM is not always traversable when | |
774 | + // the onload callback fires, so we loop a bit to accommodate | |
775 | + log('requeing onLoad callback, DOM not available'); | |
776 | + setTimeout(cb, 250); | |
777 | + | |
778 | + return; | |
779 | + } | |
780 | + // let this fall through because server response could be an empty document | |
781 | + // log('Could not access iframe DOM after mutiple tries.'); | |
782 | + // throw 'DOMException: not available'; | |
783 | + } | |
784 | + | |
785 | + // log('response detected'); | |
786 | + var docRoot = doc.body ? doc.body : doc.documentElement; | |
787 | + | |
788 | + xhr.responseText = docRoot ? docRoot.innerHTML : null; | |
789 | + xhr.responseXML = doc.XMLDocument ? doc.XMLDocument : doc; | |
790 | + if (isXml) { | |
791 | + s.dataType = 'xml'; | |
792 | + } | |
793 | + xhr.getResponseHeader = function(header){ | |
794 | + var headers = {'content-type': s.dataType}; | |
795 | + | |
796 | + return headers[header.toLowerCase()]; | |
797 | + }; | |
798 | + // support for XHR 'status' & 'statusText' emulation : | |
799 | + if (docRoot) { | |
800 | + xhr.status = Number(docRoot.getAttribute('status')) || xhr.status; | |
801 | + xhr.statusText = docRoot.getAttribute('statusText') || xhr.statusText; | |
802 | + } | |
803 | + | |
804 | + var dt = (s.dataType || '').toLowerCase(); | |
805 | + var scr = /(json|script|text)/.test(dt); | |
806 | + | |
807 | + if (scr || s.textarea) { | |
808 | + // see if user embedded response in textarea | |
809 | + var ta = doc.getElementsByTagName('textarea')[0]; | |
810 | + | |
811 | + if (ta) { | |
812 | + xhr.responseText = ta.value; | |
813 | + // support for XHR 'status' & 'statusText' emulation : | |
814 | + xhr.status = Number(ta.getAttribute('status')) || xhr.status; | |
815 | + xhr.statusText = ta.getAttribute('statusText') || xhr.statusText; | |
816 | + | |
817 | + } else if (scr) { | |
818 | + // account for browsers injecting pre around json response | |
819 | + var pre = doc.getElementsByTagName('pre')[0]; | |
820 | + var b = doc.getElementsByTagName('body')[0]; | |
821 | + | |
822 | + if (pre) { | |
823 | + xhr.responseText = pre.textContent ? pre.textContent : pre.innerText; | |
824 | + } else if (b) { | |
825 | + xhr.responseText = b.textContent ? b.textContent : b.innerText; | |
826 | + } | |
827 | + } | |
828 | + | |
829 | + } else if (dt === 'xml' && !xhr.responseXML && xhr.responseText) { | |
830 | + xhr.responseXML = toXml(xhr.responseText); // eslint-disable-line no-use-before-define | |
831 | + } | |
832 | + | |
833 | + try { | |
834 | + data = httpData(xhr, dt, s); // eslint-disable-line no-use-before-define | |
835 | + | |
836 | + } catch (err) { | |
837 | + status = 'parsererror'; | |
838 | + xhr.error = errMsg = (err || status); | |
839 | + } | |
840 | + | |
841 | + } catch (err) { | |
842 | + log('error caught: ', err); | |
843 | + status = 'error'; | |
844 | + xhr.error = errMsg = (err || status); | |
845 | + } | |
846 | + | |
847 | + if (xhr.aborted) { | |
848 | + log('upload aborted'); | |
849 | + status = null; | |
850 | + } | |
851 | + | |
852 | + if (xhr.status) { // we've set xhr.status | |
853 | + status = ((xhr.status >= 200 && xhr.status < 300) || xhr.status === 304) ? 'success' : 'error'; | |
854 | + } | |
855 | + | |
856 | + // ordering of these callbacks/triggers is odd, but that's how $.ajax does it | |
857 | + if (status === 'success') { | |
858 | + if (s.success) { | |
859 | + s.success.call(s.context, data, 'success', xhr); | |
860 | + } | |
861 | + | |
862 | + deferred.resolve(xhr.responseText, 'success', xhr); | |
863 | + | |
864 | + if (g) { | |
865 | + $.event.trigger('ajaxSuccess', [xhr, s]); | |
866 | + } | |
867 | + | |
868 | + } else if (status) { | |
869 | + if (typeof errMsg === 'undefined') { | |
870 | + errMsg = xhr.statusText; | |
871 | + } | |
872 | + if (s.error) { | |
873 | + s.error.call(s.context, xhr, status, errMsg); | |
874 | + } | |
875 | + deferred.reject(xhr, 'error', errMsg); | |
876 | + if (g) { | |
877 | + $.event.trigger('ajaxError', [xhr, s, errMsg]); | |
878 | + } | |
879 | + } | |
880 | + | |
881 | + if (g) { | |
882 | + $.event.trigger('ajaxComplete', [xhr, s]); | |
883 | + } | |
884 | + | |
885 | + if (g && !--$.active) { | |
886 | + $.event.trigger('ajaxStop'); | |
887 | + } | |
888 | + | |
889 | + if (s.complete) { | |
890 | + s.complete.call(s.context, xhr, status); | |
891 | + } | |
892 | + | |
893 | + callbackProcessed = true; | |
894 | + if (s.timeout) { | |
895 | + clearTimeout(timeoutHandle); | |
896 | + } | |
897 | + | |
898 | + // clean up | |
899 | + setTimeout(function() { | |
900 | + if (!s.iframeTarget) { | |
901 | + $io.remove(); | |
902 | + } else { // adding else to clean up existing iframe response. | |
903 | + $io.attr('src', s.iframeSrc); | |
904 | + } | |
905 | + xhr.responseXML = null; | |
906 | + }, 100); | |
907 | + } | |
908 | + | |
909 | + var toXml = $.parseXML || function(s, doc) { // use parseXML if available (jQuery 1.5+) | |
910 | + if (window.ActiveXObject) { | |
911 | + doc = new ActiveXObject('Microsoft.XMLDOM'); | |
912 | + doc.async = 'false'; | |
913 | + doc.loadXML(s); | |
914 | + | |
915 | + } else { | |
916 | + doc = (new DOMParser()).parseFromString(s, 'text/xml'); | |
917 | + } | |
918 | + | |
919 | + return (doc && doc.documentElement && doc.documentElement.nodeName !== 'parsererror') ? doc : null; | |
920 | + }; | |
921 | + var parseJSON = $.parseJSON || function(s) { | |
922 | + /* jslint evil:true */ | |
923 | + return window['eval']('(' + s + ')'); // eslint-disable-line dot-notation | |
924 | + }; | |
925 | + | |
926 | + var httpData = function(xhr, type, s) { // mostly lifted from jq1.4.4 | |
927 | + | |
928 | + var ct = xhr.getResponseHeader('content-type') || '', | |
929 | + xml = ((type === 'xml' || !type) && ct.indexOf('xml') >= 0), | |
930 | + data = xml ? xhr.responseXML : xhr.responseText; | |
931 | + | |
932 | + if (xml && data.documentElement.nodeName === 'parsererror') { | |
933 | + if ($.error) { | |
934 | + $.error('parsererror'); | |
935 | + } | |
936 | + } | |
937 | + if (s && s.dataFilter) { | |
938 | + data = s.dataFilter(data, type); | |
939 | + } | |
940 | + if (typeof data === 'string') { | |
941 | + if ((type === 'json' || !type) && ct.indexOf('json') >= 0) { | |
942 | + data = parseJSON(data); | |
943 | + } else if ((type === 'script' || !type) && ct.indexOf('javascript') >= 0) { | |
944 | + $.globalEval(data); | |
945 | + } | |
946 | + } | |
947 | + | |
948 | + return data; | |
949 | + }; | |
950 | + | |
951 | + return deferred; | |
952 | + } | |
953 | + }; | |
954 | + | |
955 | + /** | |
956 | + * ajaxForm() provides a mechanism for fully automating form submission. | |
957 | + * | |
958 | + * The advantages of using this method instead of ajaxSubmit() are: | |
959 | + * | |
960 | + * 1: This method will include coordinates for <input type="image"> elements (if the element | |
961 | + * is used to submit the form). | |
962 | + * 2. This method will include the submit element's name/value data (for the element that was | |
963 | + * used to submit the form). | |
964 | + * 3. This method binds the submit() method to the form for you. | |
965 | + * | |
966 | + * The options argument for ajaxForm works exactly as it does for ajaxSubmit. ajaxForm merely | |
967 | + * passes the options argument along after properly binding events for submit elements and | |
968 | + * the form itself. | |
969 | + */ | |
970 | + $.fn.ajaxForm = function(options, data, dataType, onSuccess) { | |
971 | + if (typeof options === 'string' || (options === false && arguments.length > 0)) { | |
972 | + options = { | |
973 | + 'url' : options, | |
974 | + 'data' : data, | |
975 | + 'dataType' : dataType | |
976 | + }; | |
977 | + | |
978 | + if (typeof onSuccess === 'function') { | |
979 | + options.success = onSuccess; | |
980 | + } | |
981 | + } | |
982 | + | |
983 | + options = options || {}; | |
984 | + options.delegation = options.delegation && $.isFunction($.fn.on); | |
985 | + | |
986 | + // in jQuery 1.3+ we can fix mistakes with the ready state | |
987 | + if (!options.delegation && this.length === 0) { | |
988 | + var o = {s: this.selector, c: this.context}; | |
989 | + | |
990 | + if (!$.isReady && o.s) { | |
991 | + log('DOM not ready, queuing ajaxForm'); | |
992 | + $(function() { | |
993 | + $(o.s, o.c).ajaxForm(options); | |
994 | + }); | |
995 | + | |
996 | + return this; | |
997 | + } | |
998 | + | |
999 | + // is your DOM ready? http://docs.jquery.com/Tutorials:Introducing_$(document).ready() | |
1000 | + log('terminating; zero elements found by selector' + ($.isReady ? '' : ' (DOM not ready)')); | |
1001 | + | |
1002 | + return this; | |
1003 | + } | |
1004 | + | |
1005 | + if (options.delegation) { | |
1006 | + $(document) | |
1007 | + .off('submit.form-plugin', this.selector, doAjaxSubmit) | |
1008 | + .off('click.form-plugin', this.selector, captureSubmittingElement) | |
1009 | + .on('submit.form-plugin', this.selector, options, doAjaxSubmit) | |
1010 | + .on('click.form-plugin', this.selector, options, captureSubmittingElement); | |
1011 | + | |
1012 | + return this; | |
1013 | + } | |
1014 | + | |
1015 | + return this.ajaxFormUnbind() | |
1016 | + .on('submit.form-plugin', options, doAjaxSubmit) | |
1017 | + .on('click.form-plugin', options, captureSubmittingElement); | |
1018 | + }; | |
1019 | + | |
1020 | + // private event handlers | |
1021 | + function doAjaxSubmit(e) { | |
1022 | + /* jshint validthis:true */ | |
1023 | + var options = e.data; | |
1024 | + | |
1025 | + if (!e.isDefaultPrevented()) { // if event has been canceled, don't proceed | |
1026 | + e.preventDefault(); | |
1027 | + $(e.target).closest('form').ajaxSubmit(options); // #365 | |
1028 | + } | |
1029 | + } | |
1030 | + | |
1031 | + function captureSubmittingElement(e) { | |
1032 | + /* jshint validthis:true */ | |
1033 | + var target = e.target; | |
1034 | + var $el = $(target); | |
1035 | + | |
1036 | + if (!$el.is('[type=submit],[type=image]')) { | |
1037 | + // is this a child element of the submit el? (ex: a span within a button) | |
1038 | + var t = $el.closest('[type=submit]'); | |
1039 | + | |
1040 | + if (t.length === 0) { | |
1041 | + return; | |
1042 | + } | |
1043 | + target = t[0]; | |
1044 | + } | |
1045 | + | |
1046 | + var form = target.form; | |
1047 | + | |
1048 | + form.clk = target; | |
1049 | + | |
1050 | + if (target.type === 'image') { | |
1051 | + if (typeof e.offsetX !== 'undefined') { | |
1052 | + form.clk_x = e.offsetX; | |
1053 | + form.clk_y = e.offsetY; | |
1054 | + | |
1055 | + } else if (typeof $.fn.offset === 'function') { | |
1056 | + var offset = $el.offset(); | |
1057 | + | |
1058 | + form.clk_x = e.pageX - offset.left; | |
1059 | + form.clk_y = e.pageY - offset.top; | |
1060 | + | |
1061 | + } else { | |
1062 | + form.clk_x = e.pageX - target.offsetLeft; | |
1063 | + form.clk_y = e.pageY - target.offsetTop; | |
1064 | + } | |
1065 | + } | |
1066 | + // clear form vars | |
1067 | + setTimeout(function() { | |
1068 | + form.clk = form.clk_x = form.clk_y = null; | |
1069 | + }, 100); | |
1070 | + } | |
1071 | + | |
1072 | + | |
1073 | + // ajaxFormUnbind unbinds the event handlers that were bound by ajaxForm | |
1074 | + $.fn.ajaxFormUnbind = function() { | |
1075 | + return this.off('submit.form-plugin click.form-plugin'); | |
1076 | + }; | |
1077 | + | |
1078 | + /** | |
1079 | + * formToArray() gathers form element data into an array of objects that can | |
1080 | + * be passed to any of the following ajax functions: $.get, $.post, or load. | |
1081 | + * Each object in the array has both a 'name' and 'value' property. An example of | |
1082 | + * an array for a simple login form might be: | |
1083 | + * | |
1084 | + * [ { name: 'username', value: 'jresig' }, { name: 'password', value: 'secret' } ] | |
1085 | + * | |
1086 | + * It is this array that is passed to pre-submit callback functions provided to the | |
1087 | + * ajaxSubmit() and ajaxForm() methods. | |
1088 | + */ | |
1089 | + $.fn.formToArray = function(semantic, elements, filtering) { | |
1090 | + var a = []; | |
1091 | + | |
1092 | + if (this.length === 0) { | |
1093 | + return a; | |
1094 | + } | |
1095 | + | |
1096 | + var form = this[0]; | |
1097 | + var formId = this.attr('id'); | |
1098 | + var els = (semantic || typeof form.elements === 'undefined') ? form.getElementsByTagName('*') : form.elements; | |
1099 | + var els2; | |
1100 | + | |
1101 | + if (els) { | |
1102 | + els = $.makeArray(els); // convert to standard array | |
1103 | + } | |
1104 | + | |
1105 | + // #386; account for inputs outside the form which use the 'form' attribute | |
1106 | + // FinesseRus: in non-IE browsers outside fields are already included in form.elements. | |
1107 | + if (formId && (semantic || /(Edge|Trident)\//.test(navigator.userAgent))) { | |
1108 | + els2 = $(':input[form="' + formId + '"]').get(); // hat tip @thet | |
1109 | + if (els2.length) { | |
1110 | + els = (els || []).concat(els2); | |
1111 | + } | |
1112 | + } | |
1113 | + | |
1114 | + if (!els || !els.length) { | |
1115 | + return a; | |
1116 | + } | |
1117 | + | |
1118 | + if ($.isFunction(filtering)) { | |
1119 | + els = $.map(els, filtering); | |
1120 | + } | |
1121 | + | |
1122 | + var i, j, n, v, el, max, jmax; | |
1123 | + | |
1124 | + for (i = 0, max = els.length; i < max; i++) { | |
1125 | + el = els[i]; | |
1126 | + n = el.name; | |
1127 | + if (!n || el.disabled) { | |
1128 | + continue; | |
1129 | + } | |
1130 | + | |
1131 | + if (semantic && form.clk && el.type === 'image') { | |
1132 | + // handle image inputs on the fly when semantic == true | |
1133 | + if (form.clk === el) { | |
1134 | + a.push({name: n, value: $(el).val(), type: el.type}); | |
1135 | + a.push({name: n + '.x', value: form.clk_x}, {name: n + '.y', value: form.clk_y}); | |
1136 | + } | |
1137 | + continue; | |
1138 | + } | |
1139 | + | |
1140 | + v = $.fieldValue(el, true); | |
1141 | + if (v && v.constructor === Array) { | |
1142 | + if (elements) { | |
1143 | + elements.push(el); | |
1144 | + } | |
1145 | + for (j = 0, jmax = v.length; j < jmax; j++) { | |
1146 | + a.push({name: n, value: v[j]}); | |
1147 | + } | |
1148 | + | |
1149 | + } else if (feature.fileapi && el.type === 'file') { | |
1150 | + if (elements) { | |
1151 | + elements.push(el); | |
1152 | + } | |
1153 | + | |
1154 | + var files = el.files; | |
1155 | + | |
1156 | + if (files.length) { | |
1157 | + for (j = 0; j < files.length; j++) { | |
1158 | + a.push({name: n, value: files[j], type: el.type}); | |
1159 | + } | |
1160 | + } else { | |
1161 | + // #180 | |
1162 | + a.push({name: n, value: '', type: el.type}); | |
1163 | + } | |
1164 | + | |
1165 | + } else if (v !== null && typeof v !== 'undefined') { | |
1166 | + if (elements) { | |
1167 | + elements.push(el); | |
1168 | + } | |
1169 | + a.push({name: n, value: v, type: el.type, required: el.required}); | |
1170 | + } | |
1171 | + } | |
1172 | + | |
1173 | + if (!semantic && form.clk) { | |
1174 | + // input type=='image' are not found in elements array! handle it here | |
1175 | + var $input = $(form.clk), input = $input[0]; | |
1176 | + | |
1177 | + n = input.name; | |
1178 | + | |
1179 | + if (n && !input.disabled && input.type === 'image') { | |
1180 | + a.push({name: n, value: $input.val()}); | |
1181 | + a.push({name: n + '.x', value: form.clk_x}, {name: n + '.y', value: form.clk_y}); | |
1182 | + } | |
1183 | + } | |
1184 | + | |
1185 | + return a; | |
1186 | + }; | |
1187 | + | |
1188 | + /** | |
1189 | + * Serializes form data into a 'submittable' string. This method will return a string | |
1190 | + * in the format: name1=value1&name2=value2 | |
1191 | + */ | |
1192 | + $.fn.formSerialize = function(semantic) { | |
1193 | + // hand off to jQuery.param for proper encoding | |
1194 | + return $.param(this.formToArray(semantic)); | |
1195 | + }; | |
1196 | + | |
1197 | + /** | |
1198 | + * Serializes all field elements in the jQuery object into a query string. | |
1199 | + * This method will return a string in the format: name1=value1&name2=value2 | |
1200 | + */ | |
1201 | + $.fn.fieldSerialize = function(successful) { | |
1202 | + var a = []; | |
1203 | + | |
1204 | + this.each(function() { | |
1205 | + var n = this.name; | |
1206 | + | |
1207 | + if (!n) { | |
1208 | + return; | |
1209 | + } | |
1210 | + | |
1211 | + var v = $.fieldValue(this, successful); | |
1212 | + | |
1213 | + if (v && v.constructor === Array) { | |
1214 | + for (var i = 0, max = v.length; i < max; i++) { | |
1215 | + a.push({name: n, value: v[i]}); | |
1216 | + } | |
1217 | + | |
1218 | + } else if (v !== null && typeof v !== 'undefined') { | |
1219 | + a.push({name: this.name, value: v}); | |
1220 | + } | |
1221 | + }); | |
1222 | + | |
1223 | + // hand off to jQuery.param for proper encoding | |
1224 | + return $.param(a); | |
1225 | + }; | |
1226 | + | |
1227 | + /** | |
1228 | + * Returns the value(s) of the element in the matched set. For example, consider the following form: | |
1229 | + * | |
1230 | + * <form><fieldset> | |
1231 | + * <input name="A" type="text"> | |
1232 | + * <input name="A" type="text"> | |
1233 | + * <input name="B" type="checkbox" value="B1"> | |
1234 | + * <input name="B" type="checkbox" value="B2"> | |
1235 | + * <input name="C" type="radio" value="C1"> | |
1236 | + * <input name="C" type="radio" value="C2"> | |
1237 | + * </fieldset></form> | |
1238 | + * | |
1239 | + * var v = $('input[type=text]').fieldValue(); | |
1240 | + * // if no values are entered into the text inputs | |
1241 | + * v === ['',''] | |
1242 | + * // if values entered into the text inputs are 'foo' and 'bar' | |
1243 | + * v === ['foo','bar'] | |
1244 | + * | |
1245 | + * var v = $('input[type=checkbox]').fieldValue(); | |
1246 | + * // if neither checkbox is checked | |
1247 | + * v === undefined | |
1248 | + * // if both checkboxes are checked | |
1249 | + * v === ['B1', 'B2'] | |
1250 | + * | |
1251 | + * var v = $('input[type=radio]').fieldValue(); | |
1252 | + * // if neither radio is checked | |
1253 | + * v === undefined | |
1254 | + * // if first radio is checked | |
1255 | + * v === ['C1'] | |
1256 | + * | |
1257 | + * The successful argument controls whether or not the field element must be 'successful' | |
1258 | + * (per http://www.w3.org/TR/html4/interact/forms.html#successful-controls). | |
1259 | + * The default value of the successful argument is true. If this value is false the value(s) | |
1260 | + * for each element is returned. | |
1261 | + * | |
1262 | + * Note: This method *always* returns an array. If no valid value can be determined the | |
1263 | + * array will be empty, otherwise it will contain one or more values. | |
1264 | + */ | |
1265 | + $.fn.fieldValue = function(successful) { | |
1266 | + for (var val = [], i = 0, max = this.length; i < max; i++) { | |
1267 | + var el = this[i]; | |
1268 | + var v = $.fieldValue(el, successful); | |
1269 | + | |
1270 | + if (v === null || typeof v === 'undefined' || (v.constructor === Array && !v.length)) { | |
1271 | + continue; | |
1272 | + } | |
1273 | + | |
1274 | + if (v.constructor === Array) { | |
1275 | + $.merge(val, v); | |
1276 | + } else { | |
1277 | + val.push(v); | |
1278 | + } | |
1279 | + } | |
1280 | + | |
1281 | + return val; | |
1282 | + }; | |
1283 | + | |
1284 | + /** | |
1285 | + * Returns the value of the field element. | |
1286 | + */ | |
1287 | + $.fieldValue = function(el, successful) { | |
1288 | + var n = el.name, t = el.type, tag = el.tagName.toLowerCase(); | |
1289 | + | |
1290 | + if (typeof successful === 'undefined') { | |
1291 | + successful = true; | |
1292 | + } | |
1293 | + | |
1294 | + /* eslint-disable no-mixed-operators */ | |
1295 | + if (successful && (!n || el.disabled || t === 'reset' || t === 'button' || | |
1296 | + (t === 'checkbox' || t === 'radio') && !el.checked || | |
1297 | + (t === 'submit' || t === 'image') && el.form && el.form.clk !== el || | |
1298 | + tag === 'select' && el.selectedIndex === -1)) { | |
1299 | + /* eslint-enable no-mixed-operators */ | |
1300 | + return null; | |
1301 | + } | |
1302 | + | |
1303 | + if (tag === 'select') { | |
1304 | + var index = el.selectedIndex; | |
1305 | + | |
1306 | + if (index < 0) { | |
1307 | + return null; | |
1308 | + } | |
1309 | + | |
1310 | + var a = [], ops = el.options; | |
1311 | + var one = (t === 'select-one'); | |
1312 | + var max = (one ? index + 1 : ops.length); | |
1313 | + | |
1314 | + for (var i = (one ? index : 0); i < max; i++) { | |
1315 | + var op = ops[i]; | |
1316 | + | |
1317 | + if (op.selected && !op.disabled) { | |
1318 | + var v = op.value; | |
1319 | + | |
1320 | + if (!v) { // extra pain for IE... | |
1321 | + v = (op.attributes && op.attributes.value && !(op.attributes.value.specified)) ? op.text : op.value; | |
1322 | + } | |
1323 | + | |
1324 | + if (one) { | |
1325 | + return v; | |
1326 | + } | |
1327 | + | |
1328 | + a.push(v); | |
1329 | + } | |
1330 | + } | |
1331 | + | |
1332 | + return a; | |
1333 | + } | |
1334 | + | |
1335 | + return $(el).val().replace(rCRLF, '\r\n'); | |
1336 | + }; | |
1337 | + | |
1338 | + /** | |
1339 | + * Clears the form data. Takes the following actions on the form's input fields: | |
1340 | + * - input text fields will have their 'value' property set to the empty string | |
1341 | + * - select elements will have their 'selectedIndex' property set to -1 | |
1342 | + * - checkbox and radio inputs will have their 'checked' property set to false | |
1343 | + * - inputs of type submit, button, reset, and hidden will *not* be effected | |
1344 | + * - button elements will *not* be effected | |
1345 | + */ | |
1346 | + $.fn.clearForm = function(includeHidden) { | |
1347 | + return this.each(function() { | |
1348 | + $('input,select,textarea', this).clearFields(includeHidden); | |
1349 | + }); | |
1350 | + }; | |
1351 | + | |
1352 | + /** | |
1353 | + * Clears the selected form elements. | |
1354 | + */ | |
1355 | + $.fn.clearFields = $.fn.clearInputs = function(includeHidden) { | |
1356 | + var re = /^(?:color|date|datetime|email|month|number|password|range|search|tel|text|time|url|week)$/i; // 'hidden' is not in this list | |
1357 | + | |
1358 | + return this.each(function() { | |
1359 | + var t = this.type, tag = this.tagName.toLowerCase(); | |
1360 | + | |
1361 | + if (re.test(t) || tag === 'textarea') { | |
1362 | + this.value = ''; | |
1363 | + | |
1364 | + } else if (t === 'checkbox' || t === 'radio') { | |
1365 | + this.checked = false; | |
1366 | + | |
1367 | + } else if (tag === 'select') { | |
1368 | + this.selectedIndex = -1; | |
1369 | + | |
1370 | + } else if (t === 'file') { | |
1371 | + if (/MSIE/.test(navigator.userAgent)) { | |
1372 | + $(this).replaceWith($(this).clone(true)); | |
1373 | + } else { | |
1374 | + $(this).val(''); | |
1375 | + } | |
1376 | + | |
1377 | + } else if (includeHidden) { | |
1378 | + // includeHidden can be the value true, or it can be a selector string | |
1379 | + // indicating a special test; for example: | |
1380 | + // $('#myForm').clearForm('.special:hidden') | |
1381 | + // the above would clean hidden inputs that have the class of 'special' | |
1382 | + if ((includeHidden === true && /hidden/.test(t)) || | |
1383 | + (typeof includeHidden === 'string' && $(this).is(includeHidden))) { | |
1384 | + this.value = ''; | |
1385 | + } | |
1386 | + } | |
1387 | + }); | |
1388 | + }; | |
1389 | + | |
1390 | + | |
1391 | + /** | |
1392 | + * Resets the form data or individual elements. Takes the following actions | |
1393 | + * on the selected tags: | |
1394 | + * - all fields within form elements will be reset to their original value | |
1395 | + * - input / textarea / select fields will be reset to their original value | |
1396 | + * - option / optgroup fields (for multi-selects) will defaulted individually | |
1397 | + * - non-multiple options will find the right select to default | |
1398 | + * - label elements will be searched against its 'for' attribute | |
1399 | + * - all others will be searched for appropriate children to default | |
1400 | + */ | |
1401 | + $.fn.resetForm = function() { | |
1402 | + return this.each(function() { | |
1403 | + var el = $(this); | |
1404 | + var tag = this.tagName.toLowerCase(); | |
1405 | + | |
1406 | + switch (tag) { | |
1407 | + case 'input': | |
1408 | + this.checked = this.defaultChecked; | |
1409 | + // fall through | |
1410 | + | |
1411 | + case 'textarea': | |
1412 | + this.value = this.defaultValue; | |
1413 | + | |
1414 | + return true; | |
1415 | + | |
1416 | + case 'option': | |
1417 | + case 'optgroup': | |
1418 | + var select = el.parents('select'); | |
1419 | + | |
1420 | + if (select.length && select[0].multiple) { | |
1421 | + if (tag === 'option') { | |
1422 | + this.selected = this.defaultSelected; | |
1423 | + } else { | |
1424 | + el.find('option').resetForm(); | |
1425 | + } | |
1426 | + } else { | |
1427 | + select.resetForm(); | |
1428 | + } | |
1429 | + | |
1430 | + return true; | |
1431 | + | |
1432 | + case 'select': | |
1433 | + el.find('option').each(function(i) { // eslint-disable-line consistent-return | |
1434 | + this.selected = this.defaultSelected; | |
1435 | + if (this.defaultSelected && !el[0].multiple) { | |
1436 | + el[0].selectedIndex = i; | |
1437 | + | |
1438 | + return false; | |
1439 | + } | |
1440 | + }); | |
1441 | + | |
1442 | + return true; | |
1443 | + | |
1444 | + case 'label': | |
1445 | + var forEl = $(el.attr('for')); | |
1446 | + var list = el.find('input,select,textarea'); | |
1447 | + | |
1448 | + if (forEl[0]) { | |
1449 | + list.unshift(forEl[0]); | |
1450 | + } | |
1451 | + | |
1452 | + list.resetForm(); | |
1453 | + | |
1454 | + return true; | |
1455 | + | |
1456 | + case 'form': | |
1457 | + // guard against an input with the name of 'reset' | |
1458 | + // note that IE reports the reset function as an 'object' | |
1459 | + if (typeof this.reset === 'function' || (typeof this.reset === 'object' && !this.reset.nodeType)) { | |
1460 | + this.reset(); | |
1461 | + } | |
1462 | + | |
1463 | + return true; | |
1464 | + | |
1465 | + default: | |
1466 | + el.find('form,input,label,select,textarea').resetForm(); | |
1467 | + | |
1468 | + return true; | |
1469 | + } | |
1470 | + }); | |
1471 | + }; | |
1472 | + | |
1473 | + /** | |
1474 | + * Enables or disables any matching elements. | |
1475 | + */ | |
1476 | + $.fn.enable = function(b) { | |
1477 | + if (typeof b === 'undefined') { | |
1478 | + b = true; | |
1479 | + } | |
1480 | + | |
1481 | + return this.each(function() { | |
1482 | + this.disabled = !b; | |
1483 | + }); | |
1484 | + }; | |
1485 | + | |
1486 | + /** | |
1487 | + * Checks/unchecks any matching checkboxes or radio buttons and | |
1488 | + * selects/deselects and matching option elements. | |
1489 | + */ | |
1490 | + $.fn.selected = function(select) { | |
1491 | + if (typeof select === 'undefined') { | |
1492 | + select = true; | |
1493 | + } | |
1494 | + | |
1495 | + return this.each(function() { | |
1496 | + var t = this.type; | |
1497 | + | |
1498 | + if (t === 'checkbox' || t === 'radio') { | |
1499 | + this.checked = select; | |
1500 | + | |
1501 | + } else if (this.tagName.toLowerCase() === 'option') { | |
1502 | + var $sel = $(this).parent('select'); | |
1503 | + | |
1504 | + if (select && $sel[0] && $sel[0].type === 'select-one') { | |
1505 | + // deselect all other options | |
1506 | + $sel.find('option').selected(false); | |
1507 | + } | |
1508 | + | |
1509 | + this.selected = select; | |
1510 | + } | |
1511 | + }); | |
1512 | + }; | |
1513 | + | |
1514 | + // expose debug var | |
1515 | + $.fn.ajaxSubmit.debug = false; | |
1516 | + | |
1517 | + // helper fn for console logging | |
1518 | + function log() { | |
1519 | + if (!$.fn.ajaxSubmit.debug) { | |
1520 | + return; | |
1521 | + } | |
1522 | + | |
1523 | + var msg = '[jquery.form] ' + Array.prototype.join.call(arguments, ''); | |
1524 | + | |
1525 | + if (window.console && window.console.log) { | |
1526 | + window.console.log(msg); | |
1527 | + | |
1528 | + } else if (window.opera && window.opera.postError) { | |
1529 | + window.opera.postError(msg); | |
1530 | + } | |
1531 | + } | |
1532 | +})); |
@@ -54,7 +54,8 @@ | ||
54 | 54 | formOpts.success = function(data, status, $form) { |
55 | 55 | var sHybsCmd , match , sUrl , sFrame , oFrame ; |
56 | 56 | |
57 | - sHybsCmd = $form.data($.hybs.defaults.sHybsCmd).cmd; | |
57 | +// sHybsCmd = $form.data($.hybs.defaults.sHybsCmd).cmd; | |
58 | + sHybsCmd = $('form').data($.hybs.defaults.sHybsCmd).cmd; // 7.0.7.2 (2020/01/07) | |
58 | 59 | // var match ; |
59 | 60 | // サーバーから帰ってきたデータにrow_errorの有無を確認する |
60 | 61 | if(data.indexOf("row_error") >=0) { |
@@ -401,7 +401,8 @@ | ||
401 | 401 | formOpts.success = function(data, status, $form) { |
402 | 402 | //var sHybsCmd = $form.data($.hybs.defaults.sHybsCmd); |
403 | 403 | // 2009/02/09 $.hybs.defaults.sHybsCmd中のオブジェクト変更 |
404 | - var sHybsCmd = $form.data($.hybs.defaults.sHybsCmd).cmd; | |
404 | +// var sHybsCmd = $form.data($.hybs.defaults.sHybsCmd).cmd; | |
405 | + var sHybsCmd = $('form').data($.hybs.defaults.sHybsCmd).cmd; // 7.0.7.2 (2020/01/07) | |
405 | 406 | var match; |
406 | 407 | |
407 | 408 | // サーバーから帰ってきたデータにrow_errorの有無を確認する |