1 (function(b
){function p(){if(b
.fn
.ajaxSubmit
.debug
){var a
="[jquery.form] "+Array
.prototype.join
.call(arguments
,"");if(window
.console
&&window
.console
.log
)window
.console
.log(a
);else window
.opera
&&window
.opera
.postError
&&window
.opera
.postError(a
)}}b
.fn
.ajaxSubmit=function(a
){function g(){function t(){var n
=k
.attr("target"),m
=k
.attr("action");l
.setAttribute("target",u
);l
.getAttribute("method")!="POST"&&l
.setAttribute("method","POST");l
.getAttribute("action")!=e
.url
&&l
.setAttribute("action",e
.url
);e
.skipEncodingOverride
||
2 k
.attr({encoding
:"multipart/form-data",enctype
:"multipart/form-data"});e
.timeout
&&setTimeout(function(){F
=true;s()},e
.timeout
);var v
=[];try{if(e
.extraData
)for(var w
in e
.extraData
)v
.push(b('<input type="hidden" name="'+w
+'" value="'+e
.extraData
[w
]+'" />').appendTo(l
)[0]);q
.appendTo("body");q
.data("form-plugin-onload",s
);l
.submit()}finally{l
.setAttribute("action",m
);n
?l
.setAttribute("target",n
):k
.removeAttr("target");b(v
).remove()}}function s(){if(!G
){q
.removeData("form-plugin-onload");var n
=true;
3 try{if(F
)throw"timeout";o
=x
.contentWindow
?x
.contentWindow
.document
:x
.contentDocument
?x
.contentDocument
:x
.document
;var m
=e
.dataType
=="xml"||o
.XMLDocument
||b
.isXMLDoc(o
);p("isXml="+m
);if(!m
&&window
.opera
&&(o
.body
==null||o
.body
.innerHTML
==""))if(--K
){p("requeing onLoad callback, DOM not available");setTimeout(s
,250);return}G
=true;i
.responseText
=o
.documentElement
?o
.documentElement
.innerHTML
:null;i
.responseXML
=o
.XMLDocument
?o
.XMLDocument
:o
;i
.getResponseHeader=function(L
){var M
={"content-type":e
.dataType
};
4 return M
[L
]};var v
=/(json|script)/.test(e
.dataType
);if(v
||e
.textarea
){var w
=o
.getElementsByTagName("textarea")[0];if(w
)i
.responseText
=w
.value
;else if(v
){var H
=o
.getElementsByTagName("pre")[0],I
=o
.getElementsByTagName("body")[0];if(H
)i
.responseText
=H
.textContent
;else if(I
)i
.responseText
=I
.innerHTML
}}else if(e
.dataType
=="xml"&&!i
.responseXML
&&i
.responseText
!=null)i
.responseXML
=C(i
.responseText
);J
=b
.httpData(i
,e
.dataType
)}catch(D
){p("error caught:",D
);n
=false;i
.error
=D
;b
.handleError(e
,i
,"error",D
)}if(i
.aborted
){p("upload aborted");
5 n
=false}if(n
){e
.success
.call(e
.context
,J
,"success",i
);y
&&b
.event
.trigger("ajaxSuccess",[i
,e
])}y
&&b
.event
.trigger("ajaxComplete",[i
,e
]);y
&&!--b
.active
&&b
.event
.trigger("ajaxStop");if(e
.complete
)e
.complete
.call(e
.context
,i
,n
?"success":"error");setTimeout(function(){q
.removeData("form-plugin-onload");q
.remove();i
.responseXML
=null},100)}}function C(n
,m
){if(window
.ActiveXObject
){m
=new ActiveXObject("Microsoft.XMLDOM");m
.async
="false";m
.loadXML(n
)}else m
=(new DOMParser
).parseFromString(n
,"text/xml");return m
&&
6 m
.documentElement
&&m
.documentElement
.tagName
!="parsererror"?m
:null}var l
=k
[0];if(b(":input[name=submit],:input[id=submit]",l
).length
)alert('Error: Form elements must not have name or id of "submit".');else{var e
=b
.extend(true,{},b
.ajaxSettings
,a
);e
.context
=e
.context
||e
;var u
="jqFormIO"+(new Date
).getTime(),E
="_"+u
;window
[E
]=function(){var n
=q
.data("form-plugin-onload");if(n
){n();window
[E
]=undefined;try{delete window
[E
]}catch(m
){}}};var q
=b('<iframe id="'+u
+'" name="'+u
+'" src="'+e
.iframeSrc
+'" onload="window[\'_\'+this.id]()" />'),
7 x
=q
[0];q
.css({position
:"absolute",top
:"-1000px",left
:"-1000px"});var i
={aborted
:0,responseText
:null,responseXML
:null,status
:0,statusText
:"n/a",getAllResponseHeaders:function(){},getResponseHeader:function(){},setRequestHeader:function(){},abort:function(){this.aborted
=1;q
.attr("src",e
.iframeSrc
)}},y
=e
.global
;y
&&!b
.active
++&&b
.event
.trigger("ajaxStart");y
&&b
.event
.trigger("ajaxSend",[i
,e
]);if(e
.beforeSend
&&e
.beforeSend
.call(e
.context
,i
,e
)===false)e
.global
&&b
.active
--;else if(!i
.aborted
){var G
=false,
8 F
=0,z
=l
.clk
;if(z
){var A
=z
.name
;if(A
&&!z
.disabled
){e
.extraData
=e
.extraData
||{};e
.extraData
[A
]=z
.value
;if(z
.type
=="image"){e
.extraData
[A
+".x"]=l
.clk_x
;e
.extraData
[A
+".y"]=l
.clk_y
}}}e
.forceSync
?t():setTimeout(t
,10);var J
,o
,K
=50}}}if(!this.length
){p("ajaxSubmit: skipping submit process - no element selected");return this}if(typeof a
=="function")a
={success
:a
};var d
=this.attr("action");if(d
=typeof d
==="string"?b
.trim(d
):"")d
=(d
.match(/^([^#]+)/)||[])[1];d
=d
||window
.location
.href
||"";a
=b
.extend(true,{url
:d
,
9 type
:this.attr("method")||"GET",iframeSrc
:/^https/i.test(window
.location
.href
||"")?"javascript:false":"about:blank"},a
);d
={};this.trigger("form-pre-serialize",[this,a
,d
]);if(d
.veto
){p("ajaxSubmit: submit vetoed via form-pre-serialize trigger");return this}if(a
.beforeSerialize
&&a
.beforeSerialize(this,a
)===false){p("ajaxSubmit: submit aborted via beforeSerialize callback");return this}var c
,f
,h
=this.formToArray(a
.semantic
);if(a
.data
){a
.extraData
=a
.data
;for(c
in a
.data
)if(a
.data
[c
]instanceof Array
)for(var j
in a
.data
[c
])h
.push({name
:c
,
10 value
:a
.data
[c
][j
]});else{f
=a
.data
[c
];f
=b
.isFunction(f
)?f():f
;h
.push({name
:c
,value
:f
})}}if(a
.beforeSubmit
&&a
.beforeSubmit(h
,this,a
)===false){p("ajaxSubmit: submit aborted via beforeSubmit callback");return this}this.trigger("form-submit-validate",[h
,this,a
,d
]);if(d
.veto
){p("ajaxSubmit: submit vetoed via form-submit-validate trigger");return this}c
=b
.param(h
);if(a
.type
.toUpperCase()=="GET"){a
.url
+=(a
.url
.indexOf("?")>=0?"&":"?")+c
;a
.data
=null}else a
.data
=c
;var k
=this,r
=[];a
.resetForm
&&r
.push(function(){k
.resetForm()});
11 a
.clearForm
&&r
.push(function(){k
.clearForm()});if(!a
.dataType
&&a
.target
){var B
=a
.success
||function(){};r
.push(function(t
){var s
=a
.replaceTarget
?"replaceWith":"html";b(a
.target
)[s
](t
).each(B
,arguments
)})}else a
.success
&&r
.push(a
.success
);a
.success=function(t
,s
,C
){for(var l
=a
.context
||a
,e
=0,u
=r
.length
;e
<u
;e
++)r
[e
].apply(l
,[t
,s
,C
||k
,k
])};c
=b("input:file",this).length
>0;j
="multipart/form-data";j
=k
.attr("enctype")==j
||k
.attr("encoding")==j
;if(a
.iframe
!==false&&(c
||a
.iframe
||j
))a
.closeKeepAlive
?b
.get(a
.closeKeepAlive
,
12 g
):g();else b
.ajax(a
);this.trigger("form-submit-notify",[this,a
]);return this};b
.fn
.ajaxForm=function(a
){if(this.length
===0){var g
={s
:this.selector
,c
:this.context
};if(!b
.isReady
&&g
.s
){p("DOM not ready, queuing ajaxForm");b(function(){b(g
.s
,g
.c
).ajaxForm(a
)});return this}p("terminating; zero elements found by selector"+(b
.isReady
?"":" (DOM not ready)"));return this}return this.ajaxFormUnbind().bind("submit.form-plugin",function(d
){if(!d
.isDefaultPrevented()){d
.preventDefault();b(this).ajaxSubmit(a
)}}).bind("click.form-plugin",
13 function(d
){var c
=d
.target
,f
=b(c
);if(!f
.is(":submit,input:image")){c
=f
.closest(":submit");if(c
.length
==0)return;c
=c
[0]}var h
=this;h
.clk
=c
;if(c
.type
=="image")if(d
.offsetX
!=undefined){h
.clk_x
=d
.offsetX
;h
.clk_y
=d
.offsetY
}else if(typeof b
.fn
.offset
=="function"){f
=f
.offset();h
.clk_x
=d
.pageX
-f
.left
;h
.clk_y
=d
.pageY
-f
.top
}else{h
.clk_x
=d
.pageX
-c
.offsetLeft
;h
.clk_y
=d
.pageY
-c
.offsetTop
}setTimeout(function(){h
.clk
=h
.clk_x
=h
.clk_y
=null},100)})};b
.fn
.ajaxFormUnbind=function(){return this.unbind("submit.form-plugin click.form-plugin")};
14 b
.fn
.formToArray=function(a
){var g
=[];if(this.length
===0)return g
;var d
=this[0],c
=a
?d
.getElementsByTagName("*"):d
.elements
;if(!c
)return g
;var f
,h
,j
,k
,r
,B
;f
=0;for(r
=c
.length
;f
<r
;f
++){h
=c
[f
];if(j
=h
.name
)if(a
&&d
.clk
&&h
.type
=="image"){if(!h
.disabled
&&d
.clk
==h
){g
.push({name
:j
,value
:b(h
).val()});g
.push({name
:j
+".x",value
:d
.clk_x
},{name
:j
+".y",value
:d
.clk_y
})}}else if((k
=b
.fieldValue(h
,true))&&k
.constructor==Array
){h
=0;for(B
=k
.length
;h
<B
;h
++)g
.push({name
:j
,value
:k
[h
]})}else k
!==null&&typeof k
!="undefined"&&
15 g
.push({name
:j
,value
:k
})}if(!a
&&d
.clk
){a
=b(d
.clk
);c
=a
[0];if((j
=c
.name
)&&!c
.disabled
&&c
.type
=="image"){g
.push({name
:j
,value
:a
.val()});g
.push({name
:j
+".x",value
:d
.clk_x
},{name
:j
+".y",value
:d
.clk_y
})}}return g
};b
.fn
.formSerialize=function(a
){return b
.param(this.formToArray(a
))};b
.fn
.fieldSerialize=function(a
){var g
=[];this.each(function(){var d
=this.name
;if(d
){var c
=b
.fieldValue(this,a
);if(c
&&c
.constructor==Array
)for(var f
=0,h
=c
.length
;f
<h
;f
++)g
.push({name
:d
,value
:c
[f
]});else c
!==null&&typeof c
!="undefined"&&
16 g
.push({name
:this.name
,value
:c
})}});return b
.param(g
)};b
.fn
.fieldValue=function(a
){for(var g
=[],d
=0,c
=this.length
;d
<c
;d
++){var f
=this[d
];f
=b
.fieldValue(f
,a
);f
===null||typeof f
=="undefined"||f
.constructor==Array
&&!f
.length
||(f
.constructor==Array
?b
.merge(g
,f
):g
.push(f
))}return g
};b
.fieldValue=function(a
,g
){var d
=a
.name
,c
=a
.type
,f
=a
.tagName
.toLowerCase();if(g
===undefined)g
=true;if(g
&&(!d
||a
.disabled
||c
=="reset"||c
=="button"||(c
=="checkbox"||c
=="radio")&&!a
.checked
||(c
=="submit"||c
=="image")&&a
.form
&&
17 a
.form
.clk
!=a
||f
=="select"&&a
.selectedIndex
==-1))return null;if(f
=="select"){f
=a
.selectedIndex
;if(f
<0)return null;g
=[];a
=a
.options
;d
=(c
=c
=="select-one")?f
+1:a
.length
;for(f
=c
?f
:0;f
<d
;f
++){var h
=a
[f
];if(h
.selected
){var j
=h
.value
;j
||(j
=h
.attributes
&&h
.attributes
.value
&&!h
.attributes
.value
.specified
?h
.text
:h
.value
);if(c
)return j
;g
.push(j
)}}return g
}return b(a
).val()};b
.fn
.clearForm=function(){return this.each(function(){b("input,select,textarea",this).clearFields()})};b
.fn
.clearFields
=b
.fn
.clearInputs
=
18 function(){return this.each(function(){var a
=this.type
,g
=this.tagName
.toLowerCase();if(a
=="text"||a
=="password"||g
=="textarea")this.value
="";else if(a
=="checkbox"||a
=="radio")this.checked
=false;else if(g
=="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(a
){if(a
===undefined)a
=true;return this.each(function(){this.disabled
=!a
})};b
.fn
.selected
=
19 function(a
){if(a
===undefined)a
=true;return this.each(function(){var g
=this.type
;if(g
=="checkbox"||g
=="radio")this.checked
=a
;else if(this.tagName
.toLowerCase()=="option"){g
=b(this).parent("select");a
&&g
[0]&&g
[0].type
=="select-one"&&g
.find("option").selected(false);this.selected
=a
}})}})(jQuery
);