- Created complete documentation in docs/ directory - Added PROJECT_OVERVIEW.md with feature highlights and getting started guide - Added ARCHITECTURE.md with system design and technical details - Added SECURITY.md with comprehensive security implementation guide - Added DEVELOPMENT.md with development workflows and best practices - Added DEPLOYMENT.md with production deployment instructions - Added API.md with complete REST API documentation - Added CONTRIBUTING.md with contribution guidelines - Added CHANGELOG.md with version history and migration notes - Reorganized all documentation files into docs/ directory for better organization - Updated README.md with proper documentation links and quick navigation - Enhanced project structure with professional documentation standards
1 line
14 KiB
JavaScript
1 line
14 KiB
JavaScript
(function(C){"use strict";var y={};y.fileapi=C("<input type='file'/>").get(0).files!==undefined;y.formdata=window.FormData!==undefined;C.fn.ajaxSubmit=function(M){if(!this.length){_("ajaxSubmit: skipping submit process - no element selected");return this}var F,e,t,O=this;if(typeof M=="function"){M={success:M}}F=this.attr("method");e=this.attr("action");t=typeof e==="string"?C.trim(e):"";t=t||window.location.href||"";if(t){t=(t.match(/^([^#]+)/)||[])[1]}M=C.extend(true,{url:t,success:C.ajaxSettings.success,type:F||"GET",iframeSrc:/^https/i.test(window.location.href||"")?"javascript:false":"about:blank"},M);var r={};this.trigger("form-pre-serialize",[this,M,r]);if(r.veto){_("ajaxSubmit: submit vetoed via form-pre-serialize trigger");return this}if(M.beforeSerialize&&M.beforeSerialize(this,M)===false){_("ajaxSubmit: submit aborted via beforeSerialize callback");return this}var a=M.traditional;if(a===undefined){a=C.ajaxSettings.traditional}var X=[];var i,n=this.formToArray(M.semantic,X);if(M.data){M.extraData=M.data;i=C.param(M.data,a)}if(M.beforeSubmit&&M.beforeSubmit(n,this,M)===false){_("ajaxSubmit: submit aborted via beforeSubmit callback");return this}this.trigger("form-submit-validate",[n,this,M,r]);if(r.veto){_("ajaxSubmit: submit vetoed via form-submit-validate trigger");return this}var o=C.param(n,a);if(i){o=o?o+"&"+i:i}if(M.type.toUpperCase()=="GET"){M.url+=(M.url.indexOf("?")>=0?"&":"?")+o;M.data=null}else{M.data=o}var s=[];if(M.resetForm){s.push(function(){O.resetForm()})}if(M.clearForm){s.push(function(){O.clearForm(M.includeHidden)})}if(!M.dataType&&M.target){var u=M.success||function(){};s.push(function(e){var t=M.replaceTarget?"replaceWith":"html";C(M.target)[t](e).each(u,arguments)})}else if(M.success){s.push(M.success)}M.success=function(e,t,r){var a=M.context||this;for(var i=0,n=s.length;i<n;i++){s[i].apply(a,[e,t,r||O,O])}};var f=C("input:file:enabled[value]",this);var l=f.length>0;var c="multipart/form-data";var d=O.attr("enctype")==c||O.attr("encoding")==c;var m=y.fileapi&&y.formdata;_("fileAPI :"+m);var p=(l||d)&&!m;var v;if(M.iframe!==false&&(M.iframe||p)){if(M.closeKeepAlive){C.get(M.closeKeepAlive,function(){v=b(n)})}else{v=b(n)}}else if((l||d)&&m){v=x(n)}else{v=C.ajax(M)}O.removeData("jqxhr").data("jqxhr",v);for(var h=0;h<X.length;h++)X[h]=null;this.trigger("form-submit-notify",[this,M]);return this;function g(e){var t=C.param(e).split("&");var r=t.length;var a={};var i,n;for(i=0;i<r;i++){n=t[i].split("=");a[decodeURIComponent(n[0])]=decodeURIComponent(n[1])}return a}function x(e){var r=new FormData;for(var t=0;t<e.length;t++){r.append(e[t].name,e[t].value)}if(M.extraData){var a=g(M.extraData);for(var i in a)if(a.hasOwnProperty(i))r.append(i,a[i])}M.data=null;var n=C.extend(true,{},C.ajaxSettings,M,{contentType:false,processData:false,cache:false,type:F||"POST"});if(M.uploadProgress){n.xhr=function(){var e=jQuery.ajaxSettings.xhr();if(e.upload){e.upload.onprogress=function(e){var t=0;var r=e.loaded||e.position;var a=e.total;if(e.lengthComputable){t=Math.ceil(r/a*100)}M.uploadProgress(e,r,a,t)}}return e}}n.data=null;var o=n.beforeSend;n.beforeSend=function(e,t){t.data=r;if(o)o.call(this,e,t)};return C.ajax(n)}function b(e){var n=O[0],t,r,l,c,o,d,m,p,a,i,v,h;var s=!!C.fn.prop;var g=C.Deferred();if(C(":input[name=submit],:input[id=submit]",n).length){alert('Error: Form elements must not have name or id of "submit".');g.reject();return g}if(e){for(r=0;r<X.length;r++){t=C(X[r]);if(s)t.prop("disabled",false);else t.removeAttr("disabled")}}l=C.extend(true,{},C.ajaxSettings,M);l.context=l.context||l;o="jqFormIO"+(new Date).getTime();if(l.iframeTarget){d=C(l.iframeTarget);i=d.attr("name");if(!i)d.attr("name",o);else o=i}else{d=C('<iframe name="'+o+'" src="'+l.iframeSrc+'" />');d.css({position:"absolute",top:"-1000px",left:"-1000px"})}m=d[0];p={aborted:0,responseText:null,responseXML:null,status:0,statusText:"n/a",getAllResponseHeaders:function(){},getResponseHeader:function(){},setRequestHeader:function(){},abort:function(e){var t=e==="timeout"?"timeout":"aborted";_("aborting upload... "+t);this.aborted=1;if(m.contentWindow.document.execCommand){try{m.contentWindow.document.execCommand("Stop")}catch(e){}}d.attr("src",l.iframeSrc);p.error=t;if(l.error)l.error.call(l.context,p,t,e);if(c)C.event.trigger("ajaxError",[p,l,t]);if(l.complete)l.complete.call(l.context,p,t)}};c=l.global;if(c&&0===C.active++){C.event.trigger("ajaxStart")}if(c){C.event.trigger("ajaxSend",[p,l])}if(l.beforeSend&&l.beforeSend.call(l.context,p,l)===false){if(l.global){C.active--}g.reject();return g}if(p.aborted){g.reject();return g}a=n.clk;if(a){i=a.name;if(i&&!a.disabled){l.extraData=l.extraData||{};l.extraData[i]=a.value;if(a.type=="image"){l.extraData[i+".x"]=n.clk_x;l.extraData[i+".y"]=n.clk_y}}}var x=1;var b=2;function y(e){var t=e.contentWindow?e.contentWindow.document:e.contentDocument?e.contentDocument:e.document;return t}var u=C("meta[name=csrf-token]").attr("content");var f=C("meta[name=csrf-param]").attr("content");if(f&&u){l.extraData=l.extraData||{};l.extraData[f]=u}function T(){var e=O.attr("target"),t=O.attr("action");n.setAttribute("target",o);if(!F){n.setAttribute("method","POST")}if(t!=l.url){n.setAttribute("action",l.url)}if(!l.skipEncodingOverride&&(!F||/post/i.test(F))){O.attr({encoding:"multipart/form-data",enctype:"multipart/form-data"})}if(l.timeout){h=setTimeout(function(){v=true;D(x)},l.timeout)}function r(){try{var e=y(m).readyState;_("state = "+e);if(e&&e.toLowerCase()=="uninitialized")setTimeout(r,50)}catch(e){_("Server abort: ",e," (",e.name,")");D(b);if(h)clearTimeout(h);h=undefined}}var a=[];try{if(l.extraData){for(var i in l.extraData){if(l.extraData.hasOwnProperty(i)){if(C.isPlainObject(l.extraData[i])&&l.extraData[i].hasOwnProperty("name")&&l.extraData[i].hasOwnProperty("value")){a.push(C('<input type="hidden" name="'+l.extraData[i].name+'">').attr("value",l.extraData[i].value).appendTo(n)[0])}else{a.push(C('<input type="hidden" name="'+i+'">').attr("value",l.extraData[i]).appendTo(n)[0])}}}}if(!l.iframeTarget){d.appendTo("body");if(m.attachEvent)m.attachEvent("onload",D);else m.addEventListener("load",D,false)}setTimeout(r,15);n.submit()}finally{n.setAttribute("action",t);if(e){n.setAttribute("target",e)}else{O.removeAttr("target")}C(a).remove()}}if(l.forceSync){T()}else{setTimeout(T,10)}var j,w,S=50,k;function D(t){if(p.aborted||k){return}try{w=y(m)}catch(e){_("cannot access response document: ",e);t=b}if(t===x&&p){p.abort("timeout");g.reject(p,"timeout");return}else if(t==b&&p){p.abort("server abort");g.reject(p,"error","server abort");return}if(!w||w.location.href==l.iframeSrc){if(!v)return}if(m.detachEvent)m.detachEvent("onload",D);else m.removeEventListener("load",D,false);var e="success",r;try{if(v){throw"timeout"}var a=l.dataType=="xml"||w.XMLDocument||C.isXMLDoc(w);_("isXml="+a);if(!a&&window.opera&&(w.body===null||!w.body.innerHTML)){if(--S){_("requeing onLoad callback, DOM not available");setTimeout(D,250);return}}var i=w.body?w.body:w.documentElement;p.responseText=i?i.innerHTML:null;p.responseXML=w.XMLDocument?w.XMLDocument:w;if(a)l.dataType="xml";p.getResponseHeader=function(e){var t={"content-type":l.dataType};return t[e]};if(i){p.status=Number(i.getAttribute("status"))||p.status;p.statusText=i.getAttribute("statusText")||p.statusText}var n=(l.dataType||"").toLowerCase();var o=/(json|script|text)/.test(n);if(o||l.textarea){var s=w.getElementsByTagName("textarea")[0];if(s){p.responseText=s.value;p.status=Number(s.getAttribute("status"))||p.status;p.statusText=s.getAttribute("statusText")||p.statusText}else if(o){var u=w.getElementsByTagName("pre")[0];var f=w.getElementsByTagName("body")[0];if(u){p.responseText=u.textContent?u.textContent:u.innerText}else if(f){p.responseText=f.textContent?f.textContent:f.innerText}}}else if(n=="xml"&&!p.responseXML&&p.responseText){p.responseXML=A(p.responseText)}try{j=E(p,n,l)}catch(t){e="parsererror";p.error=r=t||e}}catch(t){_("error caught: ",t);e="error";p.error=r=t||e}if(p.aborted){_("upload aborted");e=null}if(p.status){e=p.status>=200&&p.status<300||p.status===304?"success":"error"}if(e==="success"){if(l.success)l.success.call(l.context,j,"success",p);g.resolve(p.responseText,"success",p);if(c)C.event.trigger("ajaxSuccess",[p,l])}else if(e){if(r===undefined)r=p.statusText;if(l.error)l.error.call(l.context,p,e,r);g.reject(p,"error",r);if(c)C.event.trigger("ajaxError",[p,l,r])}if(c)C.event.trigger("ajaxComplete",[p,l]);if(c&&!--C.active){C.event.trigger("ajaxStop")}if(l.complete)l.complete.call(l.context,p,e);k=true;if(l.timeout)clearTimeout(h);setTimeout(function(){if(!l.iframeTarget)d.remove();p.responseXML=null},100)}var A=C.parseXML||function(e,t){if(window.ActiveXObject){t=new ActiveXObject("Microsoft.XMLDOM");t.async="false";t.loadXML(e)}else{t=(new DOMParser).parseFromString(e,"text/xml")}return t&&t.documentElement&&t.documentElement.nodeName!="parsererror"?t:null};var L=C.parseJSON||function(e){return window["eval"]("("+e+")")};var E=function(e,t,r){var a=e.getResponseHeader("content-type")||"",i=t==="xml"||!t&&a.indexOf("xml")>=0,n=i?e.responseXML:e.responseText;if(i&&n.documentElement.nodeName==="parsererror"){if(C.error)C.error("parsererror")}if(r&&r.dataFilter){n=r.dataFilter(n,t)}if(typeof n==="string"){if(t==="json"||!t&&a.indexOf("json")>=0){n=L(n)}else if(t==="script"||!t&&a.indexOf("javascript")>=0){C.globalEval(n)}}return n};return g}};C.fn.ajaxForm=function(e){e=e||{};e.delegation=e.delegation&&C.isFunction(C.fn.on);if(!e.delegation&&this.length===0){var t={s:this.selector,c:this.context};if(!C.isReady&&t.s){_("DOM not ready, queuing ajaxForm");C(function(){C(t.s,t.c).ajaxForm(e)});return this}_("terminating; zero elements found by selector"+(C.isReady?"":" (DOM not ready)"));return this}if(e.delegation){C(document).off("submit.form-plugin",this.selector,r).off("click.form-plugin",this.selector,a).on("submit.form-plugin",this.selector,e,r).on("click.form-plugin",this.selector,e,a);return this}return this.ajaxFormUnbind().bind("submit.form-plugin",e,r).bind("click.form-plugin",e,a)};function r(e){var t=e.data;if(!e.isDefaultPrevented()){e.preventDefault();C(this).ajaxSubmit(t)}}function a(e){var t=e.target;var r=C(t);if(!r.is(":submit,input:image")){var a=r.closest(":submit");if(a.length===0){return}t=a[0]}var i=this;i.clk=t;if(t.type=="image"){if(e.offsetX!==undefined){i.clk_x=e.offsetX;i.clk_y=e.offsetY}else if(typeof C.fn.offset=="function"){var n=r.offset();i.clk_x=e.pageX-n.left;i.clk_y=e.pageY-n.top}else{i.clk_x=e.pageX-t.offsetLeft;i.clk_y=e.pageY-t.offsetTop}}setTimeout(function(){i.clk=i.clk_x=i.clk_y=null},100)}C.fn.ajaxFormUnbind=function(){return this.unbind("submit.form-plugin click.form-plugin")};C.fn.formToArray=function(e,t){var r=[];if(this.length===0){return r}var a=this[0];var i=e?a.getElementsByTagName("*"):a.elements;if(!i){return r}var n,o,s,u,f,l,c;for(n=0,l=i.length;n<l;n++){f=i[n];s=f.name;if(!s){continue}if(e&&a.clk&&f.type=="image"){if(!f.disabled&&a.clk==f){r.push({name:s,value:C(f).val(),type:f.type});r.push({name:s+".x",value:a.clk_x},{name:s+".y",value:a.clk_y})}continue}u=C.fieldValue(f,true);if(u&&u.constructor==Array){if(t)t.push(f);for(o=0,c=u.length;o<c;o++){r.push({name:s,value:u[o]})}}else if(y.fileapi&&f.type=="file"&&!f.disabled){if(t)t.push(f);var d=f.files;if(d.length){for(o=0;o<d.length;o++){r.push({name:s,value:d[o],type:f.type})}}else{r.push({name:s,value:"",type:f.type})}}else if(u!==null&&typeof u!="undefined"){if(t)t.push(f);r.push({name:s,value:u,type:f.type,required:f.required})}}if(!e&&a.clk){var m=C(a.clk),p=m[0];s=p.name;if(s&&!p.disabled&&p.type=="image"){r.push({name:s,value:m.val()});r.push({name:s+".x",value:a.clk_x},{name:s+".y",value:a.clk_y})}}return r};C.fn.formSerialize=function(e){return C.param(this.formToArray(e))};C.fn.fieldSerialize=function(i){var n=[];this.each(function(){var e=this.name;if(!e){return}var t=C.fieldValue(this,i);if(t&&t.constructor==Array){for(var r=0,a=t.length;r<a;r++){n.push({name:e,value:t[r]})}}else if(t!==null&&typeof t!="undefined"){n.push({name:this.name,value:t})}});return C.param(n)};C.fn.fieldValue=function(e){for(var t=[],r=0,a=this.length;r<a;r++){var i=this[r];var n=C.fieldValue(i,e);if(n===null||typeof n=="undefined"||n.constructor==Array&&!n.length){continue}if(n.constructor==Array)C.merge(t,n);else t.push(n)}return t};C.fieldValue=function(e,t){var r=e.name,a=e.type,i=e.tagName.toLowerCase();if(t===undefined){t=true}if(t&&(!r||e.disabled||a=="reset"||a=="button"||(a=="checkbox"||a=="radio")&&!e.checked||(a=="submit"||a=="image")&&e.form&&e.form.clk!=e||i=="select"&&e.selectedIndex==-1)){return null}if(i=="select"){var n=e.selectedIndex;if(n<0){return null}var o=[],s=e.options;var u=a=="select-one";var f=u?n+1:s.length;for(var l=u?n:0;l<f;l++){var c=s[l];if(c.selected){var d=c.value;if(!d){d=c.attributes&&c.attributes["value"]&&!c.attributes["value"].specified?c.text:c.value}if(u){return d}o.push(d)}}return o}return C(e).val()};C.fn.clearForm=function(e){return this.each(function(){C("input,select,textarea",this).clearFields(e)})};C.fn.clearFields=C.fn.clearInputs=function(r){var a=/^(?:color|date|datetime|email|month|number|password|range|search|tel|text|time|url|week)$/i;return this.each(function(){var e=this.type,t=this.tagName.toLowerCase();if(a.test(e)||t=="textarea"){this.value=""}else if(e=="checkbox"||e=="radio"){this.checked=false}else if(t=="select"){this.selectedIndex=-1}else if(r){if(r===true&&/hidden/.test(e)||typeof r=="string"&&C(this).is(r))this.value=""}})};C.fn.resetForm=function(){return this.each(function(){if(typeof this.reset=="function"||typeof this.reset=="object"&&!this.reset.nodeType){this.reset()}})};C.fn.enable=function(e){if(e===undefined){e=true}return this.each(function(){this.disabled=!e})};C.fn.selected=function(r){if(r===undefined){r=true}return this.each(function(){var e=this.type;if(e=="checkbox"||e=="radio"){this.checked=r}else if(this.tagName.toLowerCase()=="option"){var t=C(this).parent("select");if(r&&t[0]&&t[0].type=="select-one"){t.find("option").selected(false)}this.selected=r}})};C.fn.ajaxSubmit.debug=false;function _(){if(!C.fn.ajaxSubmit.debug)return;var e="[jquery.form] "+Array.prototype.join.call(arguments,"");if(window.console&&window.console.log){window.console.log(e)}else if(window.opera&&window.opera.postError){window.opera.postError(e)}}})(jQuery); |