PageSourceSearch

https://www.afaindia.com/vendor/jquery.validate.js

js afaindia.com collected 2026-10-10 00:44:57 UTC 58,628 bytes, 772 lines download raw bytes

1/*! jQuery Validation Plugin - v1.11.1 - 3/22/2013\n* https://github.com/jzaefferer/jquery-validation
2* Copyright (c) 2013 Jörn Zaefferer; Licensed MIT */(function(t){t.extend(t.fn,{validate:function(e){if(!this.length)return e&&e.debug&&window.console&&console.warn("Nothing selected, can't validate, returning nothing."),void 0;var i=t.data(this[0],"validator");return i?i:(this.attr("novalidate","novalidate"),i=new t.validator(e,this[0]),t.data(this[0],"validator",i),i.settings.onsubmit&&(this.validateDelegate(":submit","click",function(e){i.settings.submitHandler&&(i.submitButton=e.target),t(e.target).hasClass("cancel")&&(i.cancelSubmit=!0),void 0!==t(e.target).attr("formnovalidate")&&(i.cancelSubmit=!0)}),this.submit(function(e){function s(){var s;return i.settings.submitHandler?(i.submitButton&&(s=t("<input type='hidden'/>").attr("name",i.submitButton.name).val(t(i.submitButton).val()).appendTo(i.currentForm)),i.settings.submitHandler.call(i,i.currentForm,e),i.submitButton&&s.remove(),!1):!0}return i.settings.debug&&e.preventDefault(),i.cancelSubmit?(i.cancelSubmit=!1,s()):i.form()?i.pendingRequest?(i.formSubmitted=!0,!1):s():(i.focusInvalid(),!1)})),i)},valid:function(){if(t(this[0]).is("form"))return this.validate().form();var e=!0,i=t(this[0].form).validate();return this.each(function(){e=e&&i.element(this)}),e},removeAttrs:function(e){var i={},s=this;return t.each(e.split(/\s/),function(t,e){i[e]=s.attr(e),s.removeAttr(e)}),i},rules:function(e,i){var s=this[0];if(e){var r=t.data(s.form,"validator").settings,n=r.rules,a=t.validator.staticRules(s);switch(e){case"add":t.extend(a,t.validator.normalizeRule(i)),delete a.messages,n[s.name]=a,i.messages&&(r.messages[s.name]=t.extend(r.messages[s.name],i.messages));break;case"remove":if(!i)return delete n[s.name],a;var u={};return t.each(i.split(/\s/),function(t,e){u[e]=a[e],delete a[e]}),u}}var o=t.validator.normalizeRules(t.extend({},t.validator.classRules(s),t.validator.attributeRules(s),t.validator.dataRules(s),t.validator.staticRules(s)),s);if(o.required){var l=o.required;delete o.required,o=t.extend({required:l},o)}return o}}),t.extend(t.expr[":"],{blank:function(e){return!t.trim(""+t(e).val())},filled:function(e){return!!t.trim(""+t(e).val())},unchecked:function(e){return!t(e).prop("checked")}}),t.validator=function(e,i){this.settings=t.extend(!0,{},t.validator.defaults,e),this.currentForm=i,this.init()},t.validator.format=function(e,i){return 1===arguments.length?function(){var i=t.makeArray(arguments);return i.unshift(e),t.validator.format.apply(this,i)}:(arguments.length>2&&i.constructor!==Array&&(i=t.makeArray(arguments).slice(1)),i.constructor!==Array&&(i=[i]),t.each(i,function(t,i){e=e.replace(RegExp("\\{"+t+"\\}","g"),function(){return i})}),e)},t.extend(t.validator,{defaults:{messages:{},groups:{},rules:{},errorClass:"error",validClass:"valid",errorElement:"label",focusInvalid:!0,errorContainer:t([]),errorLabelContainer:t([]),onsubmit:!0,ignore:":hidden",ignoreTitle:!1,onfocusin:function(t){this.lastActive=t,this.settings.focusCleanup&&!this.blockFocusCleanup&&(this.settings.unhighlight&&this.settings.unhighlight.call(this,t,this.settings.errorClass,this.settings.validClass),this.addWrapper(this.errorsFor(t)).hide())},onfocusout:function(t){this.checkable(t)||!(t.name in this.submitted)&&this.optional(t)||this.element(t)},onkeyup:function(t,e){(9!==e.which||""!==this.elementValue(t))&&(t.name in this.submitted||t===this.lastElement)&&this.element(t)},onclick:function(t){t.name in this.submitted?this.element(t):t.parentNode.name in this.submitted&&this.element(t.parentNode)},highlight:function(e,i,s){"radio"===e.type?this.findByName(e.name).addClass(i).removeClass(s):t(e).addClass(i).removeClass(s)},unhighlight:function(e,i,s){"radio"===e.type?this.findByName(e.name).removeClass(i).addClass(s):t(e).removeClass(i).addClass(s)}},setDefaults:function(e){t.extend(t.validator.defaults,e)},messages:{required:"This field is required.",remote:"Please fix this field.",email:"Please enter a valid email address.",url:"Please enter a valid URL.",date:"Please enter a valid date.",dateISO:"Please enter a valid date (ISO).",number:"Please enter a valid number.",digits:"Please enter only digits.",creditcard:"Please enter a valid credit card number.",equalTo:"Please enter the same value again.",maxlength:t.validator.format("Please enter no more than {0} characters."),minlength:t.validator.format("Please enter at least {0} characters."),rangelength:t.validator.format("Please enter a value between {0} and {1} characters long."),range:t.validator.format("Please enter a value between {0} and {1}."),max:t.validator.format("Please enter a value less than or equal to {0}."),min:t.validator.format("Please enter a value greater than or equal to {0}.")},autoCreateRanges:!1,prototype:{init:function(){function e(e){var i=t.data(this[0].form,"validator"),s="on"+e.type.replace(/^validate/,"");i.settings[s]&&i.settings[s].call(i,this[0],e)}this.labelContainer=t(this.settings.errorLabelContainer),this.errorContext=this.labelContainer.length&&this.labelContainer||t(this.currentForm),this.containers=t(this.settings.errorContainer).add(this.settings.errorLabelContainer),this.submitted={},this.valueCache={},this.pendingRequest=0,this.pending={},this.invalid={},this.reset();var i=this.groups={};t.each(this.settings.groups,function(e,s){"string"==typeof s&&(s=s.split(/\s/)),t.each(s,function(t,s){i[s]=e})});var s=this.settings.rules;t.each(s,function(e,i){s[e]=t.validator.normalizeRule(i)}),t(this.currentForm).validateDelegate(":text, [type='password'], [type='file'], select, textarea, [type='number'], [type='search'] ,[type='tel'], [type='url'], [type='email'], [type='datetime'], [type='date'], [type='month'], [type='week'], [type='time'], [type='datetime-local'], [type='range'], [type='color'] ","focusin focusout keyup",e).validateDelegate("[type='radio'], [type='checkbox'], select, option","click",e),this.settings.invalidHandler&&t(this.currentForm).bind("invalid-form.validate",this.settings.invalidHandler)},form:function(){return this.checkForm(),t.extend(this.submitted,this.errorMap),this.invalid=t.extend({},this.errorMap),this.valid()||t(this.currentForm).triggerHandler("invalid-form",[this]),this.showErrors(),this.valid()},checkForm:function(){this.prepareForm();for(var t=0,e=this.currentElements=this.elements();e[t];t++)this.check(e[t]);return this.valid()},element:function(e){e=this.validationTargetFor(this.clean(e)),this.lastElement=e,this.prepareElement(e),this.currentElements=t(e);var i=this.check(e)!==!1;return i?delete this.invalid[e.name]:this.invalid[e.name]=!0,this.numberOfInvalids()||(this.toHide=this.toHide.add(this.containers
2)),this.showErrors(),i},showErrors:function(e){if(e){t.extend(this.errorMap,e),this.errorList=[];for(var i in e)this.errorList.push({message:e[i],element:this.findByName(i)[0]});this.successList=t.grep(this.successList,function(t){return!(t.name in e)})}this.settings.showErrors?this.settings.showErrors.call(this,this.errorMap,this.errorList):this.defaultShowErrors()},resetForm:function(){t.fn.resetForm&&t(this.currentForm).resetForm(),this.submitted={},this.lastElement=null,this.prepareForm(),this.hideErrors(),this.elements().removeClass(this.settings.errorClass).removeData("previousValue")},numberOfInvalids:function(){return this.objectLength(this.invalid)},objectLength:function(t){var e=0;for(var i in t)e++;return e},hideErrors:function(){this.addWrapper(this.toHide).hide()},valid:function(){return 0===this.size()},size:function(){return this.errorList.length},focusInvalid:function(){if(this.settings.focusInvalid)try{t(this.findLastActive()||this.errorList.length&&this.errorList[0].element||[]).filter(":visible").focus().trigger("focusin")}catch(e){}},findLastActive:function(){var e=this.lastActive;return e&&1===t.grep(this.errorList,function(t){return t.element.name===e.name}).length&&e},elements:function(){var e=this,i={};return t(this.currentForm).find("input, select, textarea").not(":submit, :reset, :image, [disabled]").not(this.settings.ignore).filter(function(){return!this.name&&e.settings.debug&&window.console&&console.error("%o has no name assigned",this),this.name in i||!e.objectLength(t(this).rules())?!1:(i[this.name]=!0,!0)})},clean:function(e){return t(e)[0]},errors:function(){var e=this.settings.errorClass.replace(" ",".");return t(this.settings.errorElement+"."+e,this.errorContext)},reset:function(){this.successList=[],this.errorList=[],this.errorMap={},this.toShow=t([]),this.toHide=t([]),this.currentElements=t([])},prepareForm:function(){this.reset(),this.toHide=this.errors().add(this.containers)},prepareElement:function(t){this.reset(),this.toHide=this.errorsFor(t)},elementValue:function(e){var i=t(e).attr("type"),s=t(e).val();return"radio"===i||"checkbox"===i?t("input[name='"+t(e).attr("name")+"']:checked").val():"string"==typeof s?s.replace(/\r/g,""):s},check:function(e){e=this.validationTargetFor(this.clean(e));var i,s=t(e).rules(),r=!1,n=this.elementValue(e);for(var a in s){var u={method:a,parameters:s[a]};try{if(i=t.validator.methods[a].call(this,n,e,u.parameters),"dependency-mismatch"===i){r=!0;continue}if(r=!1,"pending"===i)return this.toHide=this.toHide.not(this.errorsFor(e)),void 0;if(!i)return this.formatAndAdd(e,u),!1}catch(o){throw this.settings.debug&&window.console&&console.log("Exception occurred when checking element "+e.id+", check the '"+u.method+"' method.",o),o}}return r?void 0:(this.objectLength(s)&&this.successList.push(e),!0)},customDataMessage:function(e,i){return t(e).data("msg-"+i.toLowerCase())||e.attributes&&t(e).attr("data-msg-"+i.toLowerCase())},customMessage:function(t,e){var i=this.settings.messages[t];return i&&(i.constructor===String?i:i[e])},findDefined:function(){for(var t=0;arguments.length>t;t++)if(void 0!==arguments[t])return arguments[t];return void 0},defaultMessage:function(e,i){return this.findDefined(this.customMessage(e.name,i),this.customDataMessage(e,i),!this.settings.ignoreTitle&&e.title||void 0,t.validator.messages[i],"<strong>Warning: No message defined for "+e.name+"</strong>")},formatAndAdd:function(e,i){var s=this.defaultMessage(e,i.method),r=/\$?\{(\d+)\}/g;"function"==typeof s?s=s.call(this,i.parameters,e):r.test(s)&&(s=t.validator.format(s.replace(r,"{$1}"),i.parameters)),this.errorList.push({message:s,element:e}),this.errorMap[e.name]=s,this.submitted[e.name]=s},addWrapper:function(t){return this.settings.wrapper&&(t=t.add(t.parent(this.settings.wrapper))),t},defaultShowErrors:function(){var t,e;for(t=0;this.errorList[t];t++){var i=this.errorList[t];this.settings.highlight&&this.settings.highlight.call(this,i.element,this.settings.errorClass,this.settings.validClass),this.showLabel(i.element,i.message)}if(this.errorList.length&&(this.toShow=this.toShow.add(this.containers
2)),this.settings.success)for(t=0;this.successList[t];t++)this.showLabel(this.successList[t]);if(this.settings.unhighlight)for(t=0,e=this.validElements();e[t];t++)this.settings.unhighlight.call(this,e[t],this.settings.errorClass,this.settings.validClass);this.toHide=this.toHide.not(this.toShow),this.hideErrors(),this.addWrapper(this.toShow).show()},validElements:function(){return this.currentElements.not(this.invalidElements())},invalidElements:function(){return t(this.errorList).map(function(){return this.element})},showLabel:function(e,i){var s=this.errorsFor(e);s.length?(s.removeClass(this.settings.validClass).addClass(this.settings.errorClass),s.html(i)):(s=t("<"+this.settings.errorElement+">").attr("for",this.idOrName(e)).addClass(this.settings.errorClass).html(i||""),this.settings.wrapper&&(s=s.hide().show().wrap("<"+this.settings.wrapper+"/>").parent()),this.labelContainer.append(s).length||(this.settings.errorPlacement?this.settings.errorPlacement(s,t(e)):s.insertAfter(e))),!i&&this.settings.success&&(s.text(""),"string"==typeof this.settings.success?s.addClass(this.settings.success):this.settings.success(s,e)),this.toShow=this.toShow.add(s)},errorsFor:function(e){var i=this.idOrName(e);return this.errors().filter(function(){return t(this).attr("for")===i})},idOrName:function(t){return this.groups[t.name]||(this.checkable(t)?t.name:t.id||t.name)},validationTargetFor:function(t){return this.checkable(t)&&(t=this.findByName(t.name).not(this.settings.ignore)[0]),t},checkable:function(t){return/radio|checkbox/i.test(t.type)},findByName:function(e){return t(this.currentForm).find("[name='"+e+"']")},getLength:function(e,i){switch(i.nodeName.toLowerCase()){case"select":return t("option:selected",i).length;case"input":if(this.checkable(i))return this.findByName(i.name).filter(":checked").length}return e.length},depend:function(t,e){return this.dependTypes[typeof t]?this.dependTypes[typeof t](t,e):!0}
2,dependTypes:{"boolean":function(t){return t},string:function(e,i){return!!t(e,i.form).length},"function":function(t,e){return t(e)}},optional:function(e){var i=this.elementValue(e);return!t.validator.methods.required.call(this,i,e)&&"dependency-mismatch"},startRequest:function(t){this.pending[t.name]||(this.pendingRequest++,this.pending[t.name]=!0)},stopRequest:function(e,i){this.pendingRequest--,0>this.pendingRequest&&(this.pendingRequest=0),delete this.pending[e.name],i&&0===this.pendingRequest&&this.formSubmitted&&this.form()?(t(this.currentForm).submit(),this.formSubmitted=!1):!i&&0===this.pendingRequest&&this.formSubmitted&&(t(this.currentForm).triggerHandler("invalid-form",[this]),this.formSubmitted=!1)},previousValue:function(e){return t.data(e,"previousValue")||t.data(e,"previousValue",{old:null,valid:!0,message:this.defaultMessage(e,"remote")})}},classRuleSettings:{required:{required:!0},email:{email:!0},url:{url:!0},date:{date:!0},dateISO:{dateISO:!0},number:{number:!0},digits:{digits:!0},creditcard:{creditcard:!0}},addClassRules:function(e,i){e.constructor===String?this.classRuleSettings[e]=i:t.extend(this.classRuleSettings,e)},classRules:function(e){var i={},s=t(e).attr("class");return s&&t.each(s.split(" "),function(){this in t.validator.classRuleSettings&&t.extend(i,t.validator.classRuleSettings[this])}),i},attributeRules:function(e){var i={},s=t(e),r=s[0].getAttribute("type");for(var n in t.validator.methods){var a;"required"===n?(a=s.get(0).getAttribute(n),""===a&&(a=!0),a=!!a):a=s.attr(n),/min|max/.test(n)&&(null===r||/number|range|text/.test(r))&&(a=Number(a)),a?i[n]=a:r===n&&"range"!==r&&(i[n]=!0)}return i.maxlength&&/-1|2147483647|524288/.test(i.maxlength)&&delete i.maxlength,i},dataRules:function(e){var i,s,r={},n=t(e);for(i in t.validator.methods)s=n.data("rule-"+i.toLowerCase()),void 0!==s&&(r[i]=s);return r},staticRules:function(e){var i={},s=t.data(e.form,"validator");return s.settings.rules&&(i=t.validator.normalizeRule(s.settings.rules[e.name])||{}),i},normalizeRules:function(e,i){return t.each(e,function(s,r){if(r===!1)return delete e[s],void 0;if(r.param||r.depends){var n=!0;switch(typeof r.depends){case"string":n=!!t(r.depends,i.form).length;break;case"function":n=r.depends.call(i,i)}n?e[s]=void 0!==r.param?r.param:!0:delete e[s]}}),t.each(e,function(s,r){e[s]=t.isFunction(r)?r(i):r}),t.each(["minlength","maxlength"],function(){e[this]&&(e[this]=Number(e[this]))}),t.each(["rangelength","range"],function(){var i;e[this]&&(t.isArray(e[this])?e[this]=[Number(e[this][0]),Number(e[this][1])]:"string"==typeof e[this]&&(i=e[this].split(/[\s,]+/),e[this]=[Number(i[0]),Number(i[1])]))}),t.validator.autoCreateRanges&&(e.min&&e.max&&(e.range=[e.min,e.max],delete e.min,delete e.max),e.minlength&&e.maxlength&&(e.rangelength=[e.minlength,e.maxlength],delete e.minlength,delete e.maxlength)),e},normalizeRule:function(e){if("string"==typeof e){var i={};t.each(e.split(/\s/),function(){i[this]=!0}),e=i}return e},addMethod:function(e,i,s){t.validator.methods[e]=i,t.validator.messages[e]=void 0!==s?s:t.validator.messages[e],3>i.length&&t.validator.addClassRules(e,t.validator.normalizeRule(e))},methods:{required:function(e,i,s){if(!this.depend(s,i))return"dependency-mismatch";if("select"===i.nodeName.toLowerCase()){var r=t(i).val();return r&&r.length>0}return this.checkable(i)?this.getLength(e,i)>0:t.trim(e).length>0},email:function(t,e){return this.optional(e)||/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i.test(t)},url:function(t,e){return this.optional(e)||/^(https?|s?ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(t)},date:function(t,e){return this.optional(e)||!/Invalid|NaN/.test(""+new Date(t))},dateISO:function(t,e){return this.optional(e)||/^\d{4}[\/\-]\d{1,2}[\/\-]\d{1,2}$/.test(t)},number:function(t,e){return this.optional(e)||/^-?(?:\d+|\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/.test(t)},digits:function(t,e){return this.optional(e)||/^\d+$/.test(t)},creditcard:function(t,e){if(this.optional(e))return"dependency-mismatch";if(/[^0-9 \-]+/.test(t))return!1;var i=0,s=0,r=!1;t=t.replace(/\D/g,"");for(var n=t.length-1;n>=0;n--){var a=t.charAt(n);s=parseInt(a,10),r&&(s*=2)>9&&(s-=9),i+=s,r=!r}return 0===i%10},minlength:function(e,i,s){var r=t.isArray(e)?e.length:this.getLength(t.trim(e),i);return this.optional(i)||r>=s},maxlength:function(e,i,s){var r=t.isArray(e)?e.length:this.getLength(t.trim(e),i);return this.optional(i)||s>=r},rangelength:function(e,i,s){var r=t.isArray(e)?e.length:this.getLength(t.trim(e),i);return this.optional(i)||r>=s[0]&&s[1]>=r}
2,min:function(t,e,i){return this.optional(e)||t>=i},max:function(t,e,i){return this.optional(e)||i>=t},range:function(t,e,i){return this.optional(e)||t>=i[0]&&i[1]>=t},equalTo:function(e,i,s){var r=t(s);return this.settings.onfocusout&&r.unbind(".validate-equalTo").bind("blur.validate-equalTo",function(){t(i).valid()}),e===r.val()},remote:function(e,i,s){if(this.optional(i))return"dependency-mismatch";var r=this.previousValue(i);if(this.settings.messages[i.name]||(this.settings.messages[i.name]={}),r.originalMessage=this.settings.messages[i.name].remote,this.settings.messages[i.name].remote=r.message,s="string"==typeof s&&{url:s}||s,r.old===e)return r.valid;r.old=e;var n=this;this.startRequest(i);var a={};return a[i.name]=e,t.ajax(t.extend(!0,{url:s,mode:"abort",port:"validate"+i.name,dataType:"json",data:a,success:function(s){n.settings.messages[i.name].remote=r.originalMessage;var a=s===!0||"true"===s;if(a){var u=n.formSubmitted;n.prepareElement(i),n.formSubmitted=u,n.successList.push(i),delete n.invalid[i.name],n.showErrors()}else{var o={},l=s||n.defaultMessage(i,"remote");o[i.name]=r.message=t.isFunction(l)?l(e):l,n.invalid[i.name]=!0,n.showErrors(o)}r.valid=a,n.stopRequest(i,a)}},s)),"pending"}}}),t.format=t.validator.format})(jQuery),function(t){var e={};if(t.ajaxPrefilter)t.ajaxPrefilter(function(t,i,s){var r=t.port;"abort"===t.mode&&(e[r]&&e[r].abort(),e[r]=s)});else{var i=t.ajax;t.ajax=function(s){var r=("mode"in s?s:t.ajaxSettings).mode,n=("port"in s?s:t.ajaxSettings).port;return"abort"===r?(e[n]&&e[n].abort(),e[n]=i.apply(this,arguments),e[n]):i.apply(this,arguments)}}}(jQuery),function(t){t.extend(t.fn,{validateDelegate:function(e,i,s){return this.bind(i,function(i){var r=t(i.target);return r.is(e)?s.apply(r,arguments):void 0})}})}(jQuery);
3
4/*! Stellar.js v0.6.2 | Copyright 2013, Mark Dalgleish | http://markdalgleish.com/projects/stellar.js | http://markdalgleish.mit-license.org */
5(function(e,t,n,r){function d(t,n){this.element=t,this.options=e.extend({},s,n),this._defaults=s,this._name=i,this.init()}var i="stellar",s={scrollProperty:"scroll",positionProperty:"position",horizontalScrolling:!0,verticalScrolling:!0,horizontalOffset:0,verticalOffset:0,responsive:!1,parallaxBackgrounds:!0,parallaxElements:!0,hideDistantElements:!0,hideElement:function(e){e.hide()},showElement:function(e){e.show()}},o={scroll:{getLeft:function(e){return e.scrollLeft()},setLeft:function(e,t){e.scrollLeft(t)},getTop:function(e){return e.scrollTop()},setTop:function(e,t){e.scrollTop(t)}},position:{getLeft:function(e){return parseInt(e.css("left"),10)*-1},getTop:function(e){return parseInt(e.css("top"),10)*-1}},margin:{getLeft:function(e){return parseInt(e.css("margin-left"),10)*-1},getTop:function(e){return parseInt(e.css("margin-top"),10)*-1}},transform:{getLeft:function(e){var t=getComputedStyle(e[0])[f];return t!=="none"?parseInt(t.match(/(-?[0-9]+)/g)[4],10)*-1:0},getTop:function(e){var t=getComputedStyle(e[0])[f];return t!=="none"?parseInt(t.match(/(-?[0-9]+)/g)[5],10)*-1:0}}},u={position:{setLeft:function(e,t){e.css("left",t)},setTop:function(e,t){e.css("top",t)}},transform:{setPosition:function(e,t,n,r,i){e[0].style[f]="translate3d("+(t-n)+"px, "+(r-i)+"px, 0)"}}},a=function(){var t=/^(Moz|Webkit|Khtml|O|ms|Icab)(?=[A-Z])/,n=e("script")[0].style,r="",i;for(i in n)if(t.test(i)){r=i.match(t)[0];break}return"WebkitOpacity"in n&&(r="Webkit"),"KhtmlOpacity"in n&&(r="Khtml"),function(e){return r+(r.length>0?e.charAt(0).toUpperCase()+e.slice(1):e)}}(),f=a("transform"),l=e("<div />",{style:"background:#fff"}).css("background-position-x")!==r,c=l?function(e,t,n){e.css({"background-position-x":t,"background-position-y":n})}:function(e,t,n){e.css("background-position",t+" "+n)},h=l?function(e){return[e.css("background-position-x"),e.css("background-position-y")]}:function(e){return e.css("background-position").split(" ")},p=t.requestAnimationFrame||t.webkitRequestAnimationFrame||t.mozRequestAnimationFrame||t.oRequestAnimationFrame||t.msRequestAnimationFrame||function(e){setTimeout(e,1e3/60)};d.prototype={init:function(){this.options.name=i+"_"+Math.floor(Math.random()*1e9),this._defineElements(),this._defineGetters(),this._defineSetters(),this._handleWindowLoadAnd
5Resize(),this._detectViewport(),this.refresh({firstLoad:!0}),this.options.scrollProperty==="scroll"?this._handleScrollEvent():this._startAnimationLoop()},_defineElements:function(){this.element===n.body&&(this.element=t),this.$scrollElement=e(this.element),this.$element=this.element===t?e("body"):this.$scrollElement,this.$viewportElement=this.options.viewportElement!==r?e(this.options.viewportElement):this.$scrollElement[0]===t||this.options.scrollProperty==="scroll"?this.$scrollElement:this.$scrollElement.parent()},_defineGetters:function(){var e=this,t=o[e.options.scrollProperty];this._getScrollLeft=function(){return t.getLeft(e.$scrollElement)},this._getScrollTop=function(){return t.getTop(e.$scrollElement)}},_defineSetters:function(){var t=this,n=o[t.options.scrollProperty],r=u[t.options.positionProperty],i=n.setLeft,s=n.setTop;this._setScrollLeft=typeof i=="function"?function(e){i(t.$scrollElement,e)}:e.noop,this._setScrollTop=typeof s=="function"?function(e){s(t.$scrollElement,e)}:e.noop,this._setPosition=r.setPosition||function(e,n,i,s,o){t.options.horizontalScrolling&&r.setLeft(e,n,i),t.options.verticalScrolling&&r.setTop(e,s,o)}},_handleWindowLoadAndResize:function(){var n=this,r=e(t);n.options.responsive&&r.bind("load."+this.name,function(){n.refresh()}),r.bind("resize."+this.name,function(){n._detectViewport(),n.options.responsive&&n.refresh()})},refresh:function(n){var r=this,i=r._getScrollLeft(),s=r._getScrollTop();(!n||!n.firstLoad)&&this._reset(),this._setScrollLeft(0),this._setScrollTop(0),this._setOffsets(),this._findParticles(),this._findBackgrounds(),n&&n.firstLoad&&/WebKit/.test(navigator.userAgent)&&e(t).load(function(){var e=r._getScrollLeft(),t=r._getScrollTop();r._setScrollLeft(e+1),r._setScrollTop(t+1),r._setScrollLeft(e),r._setScrollTop(t)}),this._setScrollLeft(i),this._setScrollTop(s)},_detectViewport:function(){var e=this.$viewportElement.offset(),t=e!==null&&e!==r;this.viewportWidth=this.$viewportElement.width(),this.viewportHeight=this.$viewportElement.height(),this.viewportOffsetTop=t?e.top:0,this.viewportOffsetLeft=t?e.left:0},_findParticles:function(){var t=this,n=this._getScrollLeft(),i=this._getScrollTop();if(this.particles!==r)for(var s=this.particles.length-1;s>=0;s--)this.particles[s].$element.data("stellar-elementIsActive",r);this.particles=[];if(!this.options.parallaxElements)return;this.$element.find("[data-stellar-ratio]").each(function(n){var i=e(this),s,o,u,a,f,l,c,h,p,d=0,v=0,m=0,g=0;if(!i.data("stellar-elementIsActive"))i.data("stellar-elementIsActive",this);else if(i.data("stellar-elementIsActive")!==this)return;t.options.showElement(i),i.data("stellar-startingLeft")?(i.css("left",i.data("stellar-startingLeft")),i.css("top",i.data("stellar-startingTop"))):(i.data("stellar-startingLeft",i.css("left")),i.data("stellar-startingTop",i.css("top"))),u=i.position().left,a=i.position().top,f=i.css("margin-left")==="auto"?0:parseInt(i.css("margin-left"),10),l=i.css("margin-top")==="auto"?0:parseInt(i.css("margin-top"),10),h=i.offset().left-f,p=i.offset().top-l,i.parents().each(function(){var t=e(this);if(t.data("stellar-offset-parent")===!0)return d=m,v=g,c=t,!1;m+=t.position().left,g+=t.position().top}),s=i.data("stellar-horizontal-offset")!==r?i.data("stellar-horizontal-offset"):c!==r&&c.data("stellar-horizontal-offset")!==r?c.data("stellar-horizontal-offset"):t.horizontalOffset,o=i.data("stellar-vertical-offset")!==r?i.data("stellar-vertical-offset"):c!==r&&c.data("stellar-vertical-offset")!==r?c.data("stellar-vertical-offset"):t.verticalOffset,t.particles.push({$element:i,$offsetParent:c,isFixed:i.css("position")==="fixed",horizontalOffset:s,verticalOffset:o,startingPositionLeft:u,startingPositionTop:a,startingOffsetLeft:h,startingOffsetTop:p,parentOffsetLeft:d,parentOffsetTop:v,stellarRatio:i.data("stellar-ratio")!==r?i.data("stellar-ratio"):1,width:i.outerWidth(!0),height:i.outerHeight(!0),isHidden:!1})})},_findBackgrounds:function(){var t=this,n=this._getScrollLeft(),i=this._getScrollTop(),s;this.backgrounds=[];if(!this.options.parallaxBackgrounds)return;s=this.$element.find("[data-stellar-background-ratio]"),this.$element.data("stellar-background-ratio")&&(s=s.add(this.$element)),s.each(function(){var s=e(this),o=h(s),u,a,f,l,p,d,v,m,g,y=0,b=0,w=0,E=0;if(!s.data("stellar-backgroundIsActive"))s.data("stellar-backgroundIsActive",this);else if(s.data("stellar-backgroundIsActive")!==this)return;s.data("stellar-backgroundStartingLeft")?c(s,s.data("stellar-backgroundStartingLeft"),s.data("stellar-backgroundStartingTop")):(s.data("stellar-backgroundStartingLeft",o[0]),s.data("stellar-backgroundStartingTop",o[1])),p=s.css("margin-left")==="auto"?0:parseInt(s.css("margin-left"),10),d=s.css("margin-top")==="auto"?0:parseInt(s.css("margin-top"),10),v=s.offset().left-p-n,m=s.offset().top-d-i,s.parents().each(function(){var t=e(this);if(t.data("stellar-offset-parent")===!0)return y=w,b=E,g=t,!1;w+=t.position().left,E+=t.position().top}),u=s.data("stellar-horizontal-offset")!==r?s.data("stellar-horizontal-offset"):g!==r&&g.data("stellar-horizontal-offset")!==r?g.data("stellar-horizontal-offset"):t.horizontalOffset,a=s.data("stellar-vertical-offset")!==r?s.data("stellar-vertical-offset"):g!==r&&g.data("stellar-vertical-offset")!==r?g.data("stellar-vertical-offset"):t.verticalOffset,t.backgrounds.push({$element:s,$offsetParent:g,isFixed:s.css("background-attachment")==="fixed",horizontalOffset:u,verticalOffset:a,startingValueLeft:o[0],startingValueTop:o[1],startingBackgroun
5dPositionLeft:isNaN(parseInt(o[0],10))?0:parseInt(o[0],10),startingBackgroundPositionTop:isNaN(parseInt(o[1],10))?0:parseInt(o[1],10),startingPositionLeft:s.position().left,startingPositionTop:s.position().top,startingOffsetLeft:v,startingOffsetTop:m,parentOffsetLeft:y,parentOffsetTop:b,stellarRatio:s.data("stellar-background-ratio")===r?1:s.data("stellar-background-ratio")})})},_reset:function(){var e,t,n,r,i;for(i=this.particles.length-1;i>=0;i--)e=this.particles[i],t=e.$element.data("stellar-startingLeft"),n=e.$element.data("stellar-startingTop"),this._setPosition(e.$element,t,t,n,n),this.options.showElement(e.$element),e.$element.data("stellar-startingLeft",null).data("stellar-elementIsActive",null).data("stellar-backgroundIsActive",null);for(i=this.backgrounds.length-1;i>=0;i--)r=this.backgrounds[i],r.$element.data("stellar-backgroundStartingLeft",null).data("stellar-backgroundStartingTop",null),c(r.$element,r.startingValueLeft,r.startingValueTop)},destroy:function(){this._reset(),this.$scrollElement.unbind("resize."+this.name).unbind("scroll."+this.name),this._animationLoop=e.noop,e(t).unbind("load."+this.name).unbind("resize."+this.name)},_setOffsets:function(){var n=this,r=e(t);r.unbind("resize.horizontal-"+this.name).unbind("resize.vertical-"+this.name),typeof this.options.horizontalOffset=="function"?(this.horizontalOffset=this.options.horizontalOffset(),r.bind("resize.horizontal-"+this.name,function(){n.horizontalOffset=n.options.horizontalOffset()})):this.horizontalOffset=this.options.horizontalOffset,typeof this.options.verticalOffset=="function"?(this.verticalOffset=this.options.verticalOffset(),r.bind("resize.vertical-"+this.name,function(){n.verticalOffset=n.options.verticalOffset()})):this.verticalOffset=this.options.verticalOffset},_repositionElements:function(){var e=this._getScrollLeft(),t=this._getScrollTop(),n,r,i,s,o,u,a,f=!0,l=!0,h,p,d,v,m;if(this.currentScrollLeft===e&&this.currentScrollTop===t&&this.currentWidth===this.viewportWidth&&this.currentHeight===this.viewportHeight)return;this.currentScrollLeft=e,this.currentScrollTop=t,this.currentWidth=this.viewportWidth,this.currentHeight=this.viewportHeight;for(m=this.particles.length-1;m>=0;m--)i=this.particles[m],s=i.isFixed?1:0,this.options.horizontalScrolling?(h=(e+i.horizontalOffset+this.viewportOffsetLeft+i.startingPositionLeft-i.startingOffsetLeft+i.parentOffsetLeft)*-(i.stellarRatio+s-1)+i.startingPositionLeft,d=h-i.startingPositionLeft+i.startingOffsetLeft):(h=i.startingPositionLeft,d=i.startingOffsetLeft),this.options.verticalScrolling?(p=(t+i.verticalOffset+this.viewportOffsetTop+i.startingPositionTop-i.startingOffsetTop+i.parentOffsetTop)*-(i.stellarRatio+s-1)+i.startingPositionTop,v=p-i.startingPositionTop+i.startingOffsetTop):(p=i.startingPositionTop,v=i.startingOffsetTop),this.options.hideDistantElements&&(l=!this.options.horizontalScrolling||d+i.width>(i.isFixed?0:e)&&d<(i.isFixed?0:e)+this.viewportWidth+this.viewportOffsetLeft,f=!this.options.verticalScrolling||v+i.height>(i.isFixed?0:t)&&v<(i.isFixed?0:t)+this.viewportHeight+this.viewportOffsetTop),l&&f?(i.isHidden&&(this.options.showElement(i.$element),i.isHidden=!1),this._setPosition(i.$element,h,i.startingPositionLeft,p,i.startingPositionTop)):i.isHidden||(this.options.hideElement(i.$element),i.isHidden=!0);for(m=this.backgrounds.length-1;m>=0;m--)o=this.backgrounds[m],s=o.isFixed?0:1,u=this.options.horizontalScrolling?(e+o.horizontalOffset-this.viewportOffsetLeft-o.startingOffsetLeft+o.parentOffsetLeft-o.startingBackgroun
5dPositionLeft)*(s-o.stellarRatio)+"px":o.startingValueLeft,a=this.options.verticalScrolling?(t+o.verticalOffset-this.viewportOffsetTop-o.startingOffsetTop+o.parentOffsetTop-o.startingBackgroundPositionTop)*(s-o.stellarRatio)+"px":o.startingValueTop,c(o.$element,u,a)},_handleScrollEvent:function(){var e=this,t=!1,n=function(){e._repositionElements(),t=!1},r=function(){t||(p(n),t=!0)};this.$scrollElement.bind("scroll."+this.name,r),r()},_startAnimationLoop:function(){var e=this;this._animationLoop=function(){p(e._animationLoop),e._repositionElements()},this._animationLoop()}},e.fn[i]=function(t){var n=arguments;if(t===r||typeof t=="object")return this.each(function(){e.data(this,"plugin_"+i)||e.data(this,"plugin_"+i,new d(this,t))});if(typeof t=="string"&&t[0]!=="_"&&t!=="init")return this.each(function(){var r=e.data(this,"plugin_"+i);r instanceof d&&typeof r[t]=="function"&&r[t].apply(r,Array.prototype.slice.call(n,1)),t==="destroy"&&e.data(this,"plugin_"+i,null)})},e[i]=function(n){var r=e(t);return r.stellar.apply(r,Array.prototype.slice.call(arguments,0))},e[i].scrollProperty=o,e[i].positionProperty=u,t.Stellar=d})(jQuery,this,document);
6
7/*!jQuery Knob*/
8/**
9 * Downward compatible, touchable dial
10 *
11 * Version: 1.2.5 (23/01/2014)
12 * Requires: jQuery v1.7+
13 *
14 * Copyright (c) 2012 Anthony Terrien
15 * Under MIT License (http://www.opensource.org/licenses/mit-license.php)
16 *
17 * Thanks to vor, eskimoblood, spiffistan, FabrizioC
18 */
19(function($) {
20
21    /**
22     * Kontrol library
23     */
24    "use strict";
25
26    /**
27     * Definition of globals and core
28     */
29    var k = {}, // kontrol
30        max = Math.max,
31        min = Math.min;
32
33    k.c = {};
34    k.c.d = $(document);
35    k.c.t = function (e) {
36        return e.originalEvent.touches.length - 1;
37    };
38
39    /**
40     * Kontrol Object
41     *
42     * Definition of an abstract UI control
43     *
44     * Each concrete component must call this one.
45     * <code>
46     * k.o.call(this);
47     * </code>
48     */
49    k.o = function () {
50        var s = this;
51
52        this.o = null; // array of options
53        this.$ = null; // jQuery wrapped element
54        this.i = null; // mixed HTMLInputElement or array of HTMLInputElement
55        this.g = null; // deprecated 2D graphics context for 'pre-rendering'
56        this.v = null; // value ; mixed array or integer
57        this.cv = null; // change value ; not commited value
58        this.x = 0; // canvas x position
59        this.y = 0; // canvas y position
60        this.w = 0; // canvas width
61        this.h = 0; // canvas height
62        this.$c = null; // jQuery canvas element
63        this.c = null; // rendered canvas context
64        this.t = 0; // touches index
65        this.isInit = false;
66        this.fgColor = null; // main color
67        this.pColor = null; // previous color
68        this.dH = null; // draw hook
69        this.cH = null; // change hook
70        this.eH = null; // cancel hook
71        this.rH = null; // release hook
72        this.scale = 1; // scale factor
73        this.relative = false;
74        this.relativeWidth = false;
75        this.relativeHeight = false;
76        this.$div = null; // component div
77
78        this.run = function () {
79            var cf = function (e, conf) {
80                var k;
81                for (k in conf) {
82                    s.o[k] = conf[k];
83                }
84                s._carve().init();
85                s._configure()
86                 ._draw();
87            };
88
89            if(this.$.data('kontroled')) return;
90            this.$.data('kontroled', true);
91
92            this.extend();
93            this.o = $.extend(
94                {
95                    // Config
96                    min : this.$.data('min') !== undefined ? this.$.data('min') : 0,
97                    max : this.$.data('max') !== undefined ? this.$.data('max') : 100,
98                    stopper : true,
99                    readOnly : this.$.data('readonly') || (this.$.attr('readonly') === 'readonly'),
100
101                    // UI
102                    cursor : (this.$.data('cursor') === true && 30) ||
103                                this.$.data('cursor') || 0,
104                    thickness : (
105                                    this.$.data('thickness') &&
106                                    Math.max(Math.min(this.$.data('thickness'), 1), 0.01)
107                                ) || 0.35,
108                    lineCap : this.$.data('linecap') || 'butt',
109                    width : this.$.data('width') || 200,
110                    height : this.$.data('height') || 200,
111                    displayInput : this.$.data('displayinput') == null || this.$.data('displayinput'),
112                    displayPrevious : this.$.data('displayprevious'),
113                    fgColor : this.$.data('fgcolor') || '#87CEEB',
114                    inputColor: this.$.data('inputcolor'),
115                    font: this.$.data('font') || 'Arial',
116                    fontWeight: this.$.data('font-weight') || 'bold',
117                    inline : false,
118                    step : this.$.data('step') || 1,
119
120                    // Hooks
121                    draw : null, // function () {}
122                    change : null, // function (value) {}
123                    cancel : null, // function () {}
124                    release : null // function (value) {}
125                }, this.o
126            );
127
128            // finalize options
129            if(!this.o.inputColor) {
130                this.o.inputColor = this.o.fgColor;
131            }
132
133            // routing value
134            if(this.$.is('fieldset')) {
135
136                // fieldset = array of integer
137                this.v = {};
138                this.i = this.$.find('input');
139                this.i.each(function(k) {
140                    var $this = $(this);
141                    s.i[k] = $this;
142                    s.v[k] = $this.val();
143
144                    $this.bind(
145                        'change blur'
146                        , function () {
147                            var val = {};
148                            val[k] = $this.val();
149                            s.val(val);
150                        }
151                    );
152                });
153                this.$.find('legend').remove();
154
155            } else {
156
157                // input = integer
158                this.i = this.$;
159                this.v = this.$.val();
160                (this.v === '') && (this.v = this.o.min);
161
162                this.$.bind(
163                    'change blur'
164                    , function () {
165                        s.val(s._validate(s.$.val()));
166                    }
167                );
168
169            }
170
171            (!this.o.displayInput) && this.$.hide();
172
173            // adds needed DOM elements (canvas, div)
174            this.$c = $(document.createElement('canvas')).attr({
175                width: this.o.width,
176                height: this.o.height
177            });
178
179            // wraps all elements in a div
180            // add to DOM before Canvas init is triggered
181            this.$div = $('<div style="'
182                + (this.o.inline ? 'display:inline;' : '')
183                + 'width:' + this.o.width + 'px;height:' + this.o.height + 'px;'
184                + '"></div>');
185
186            this.$.wrap(this.$div).before(this.$c);
187            this.$div = this.$.parent();
188
189            if (typeof G_vmlCanvasManager !== 'undefined') {
190              G_vmlCanvasManager.initElement(this.$c[0]);
191            }
192
193            this.c = this.$c[0].getContext ? this.$c[0].getContext('2d') : null;
194
195            if (!this.c) {
196                throw {
197                    name:        "CanvasNotSupportedException",
198                    message:     "Canvas not supported. Please use excanvas on IE8.0.",
199                    toString:    function(){return this.name + ": " + this.message}
200                }
201            }
202
203            // hdpi support
204            this.scale = (window.devicePixelRatio || 1) /
205                        (
206                            this.c.webkitBackingStorePixelRatio ||
207                            this.c.mozBackingStorePixelRatio ||
208                            this.c.msBackingStorePixelRatio ||
209                            this.c.oBackingStorePixelRatio ||
210                            this.c.backingStorePixelRatio || 1
211                        );
212
213            // detects relative width / height
214            this.relativeWidth = ((this.o.width % 1 !== 0) &&
215                this.o.width.indexOf('%'));
216            this.relativeHeight = ((this.o.height % 1 !== 0) &&
217                this.o.height.indexOf('%'));
218            this.relative = (this.relativeWidth || this.relativeHeight);
219
220            // computes size and carves the component
221            this._carve();
222
223            // prepares props for transaction
224            if (this.v instanceof Object) {
225                this.cv = {};
226                this.copy(this.v, this.cv);
227            } else {
228                this.cv = this.v;
229            }
230
231            // binds configure event
232            this.$
233                .bind("configure", cf)
234                .parent()
235                .bind("configure", cf);
236
237            // finalize init
238            this._listen()
239                ._configure()
240                ._xy()
241                .init();
242
243            this.isInit = true;
244
245            // the most important !
246            this._draw();
247
248            return this;
249        };
250
251        this._carve = function() {
252            if(this.relative) {
253                var w = this.relativeWidth ?
254                            this.$div.parent().width() *
255                            parseInt(this.o.width) / 100 :
256                            this.$div.parent().width(),
257                    h = this.relativeHeight ?
258                            this.$div.parent().height() *
259                            parseInt(this.o.height) / 100 :
260                            this.$div.parent().height();
261
262                // apply relative
263                this.w = this.h = Math.min(w, h);
264            } else {
265                this.w = this.o.width;
266                this.h = this.o.height;
267            }
268
269            // finalize div
270            this.$div.css({
271                'width': this.w + 'px',
272                'height': this.h + 'px'
273            });
274
275            // finalize canvas with computed width
276            this.$c.attr({
277                width: this.w,
278                height: this.h
279            });
280
281            // scaling
282            if (this.scale !== 1) {
283                this.$c[0].width = this.$c[0].width * this.scale;
284                this.$c[0].height = this.$c[0].height * this.scale;
285                this.$c.width(this.w);
286                this.$c.height(this.h);
287            }
288
289            return this;
290        }
291
292        this._draw = function () {
293
294            // canvas pre-rendering
295            var d = true;
296
297            s.g = s.c;
298
299            s.clear();
300
301            s.dH
302            && (d = s.dH());
303
304            (d !== false) && s.draw();
305
306        };
307
308        this._touch = function (e) {
309
310            var touchMove = function (e) {
311
312                var v = s.xy2val(
313                            e.originalEvent.touches[s.t].pageX,
314                            e.originalEvent.touches[s.t].pageY
315                            );
316
317                if (v == s.cv) return;
318
319                if (s.cH && (s.cH(v) === false)) return;
320
321                s.change(s._validate(v));
322                s._draw();
323            };
324
325            // get touches index
326            this.t = k.c.t(e);
327
328            // First touch
329            touchMove(e);
330
331            // Touch events listeners
332            k.c.d
333                .bind("touchmove.k", touchMove)
334                .bind(
335                    "touchend.k"
336                    , function () {
337                        k.c.d.unbind('touchmove.k touchend.k');
338                        s.val(s.cv);
339                    }
340                );
341
342            return this;
343        };
344
345        this._mouse = function (e) {
346
347            var mouseMove = function (e) {
348                var v = s.xy2val(e.pageX, e.pageY);
349
350                if (v == s.cv) return;
351
352                if (s.cH && (s.cH(v) === false)) return;
353
354                s.change(s._validate(v));
355                s._draw();
356            };
357
358            // First click
359            mouseMove(e);
360
361            // Mouse events listeners
362            k.c.d
363                .bind("mousemove.k", mouseMove)
364                .bind(
365                    // Escape key cancel current change
366                    "keyup.k"
367                    , function (e) {
368                        if (e.keyCode === 27) {
369                            k.c.d.unbind("mouseup.k mousemove.k keyup.k");
370
371                            if (
372                                s.eH
373                                && (s.eH() === false)
374                            ) return;
375
376                            s.cancel();
377                        }
378                    }
379                )
380                .bind(
381                    "mouseup.k"
382                    , function (e) {
383                        k.c.d.unbind('mousemove.k mouseup.k keyup.k');
384                        s.val(s.cv);
385                    }
386                );
387
388            return this;
389        };
390
391        this._xy = function () {
392            var o = this.$c.offset();
393            this.x = o.left;
394            this.y = o.top;
395            return this;
396        };
397
398        this._listen = function () {
399
400            if (!this.o.readOnly) {
401                this.$c
402                    .bind(
403                        "mousedown"
404                        , function (e) {
405                            e.preventDefault();
406                            s._xy()._mouse(e);
407                         }
408                    )
409                    .bind(
410                        "touchstart"
411                        , function (e) {
412                            e.preventDefault();
413                            s._xy()._touch(e);
414                         }
415                    );
416
417                this.listen();
418            } else {
419                this.$.attr('readonly', 'readonly');
420            }
421
422            if(this.relative) {
423                $(window).resize(function() {
424                    s._carve()
425                     .init();
426                    s._draw();
427                });
428            }
429
430            return this;
431        };
432
433        this._configure = function () {
434
435            // Hooks
436            if (this.o.draw) this.dH = this.o.draw;
437            if (this.o.change) this.cH = this.o.change;
438            if (this.o.cancel) this.eH = this.o.cancel;
439            if (this.o.release) this.rH = this.o.release;
440
441            if (this.o.displayPrevious) {
442                this.pColor = this.h2rgba(this.o.fgColor, "0.4");
443                this.fgColor = this.h2rgba(this.o.fgColor, "0.6");
444            } else {
445                this.fgColor = this.o.fgColor;
446            }
447
448            return this;
449        };
450
451        this._clear = function () {
452            this.$c[0].width = this.$c[0].width;
453        };
454
455        this._validate = function(v) {
456            return (~~ (((v < 0) ? -0.5 : 0.5) + (v/this.o.step))) * this.o.step;
457        };
458
459        // Abstract methods
460        this.listen = function () {}; // on start, one time
461        this.extend = function () {}; // each time configure triggered
462        this.init = function () {}; // each time configure triggered
463        this.change = function (v) {}; // on change
464        this.val = function (v) {}; // on release
465        this.xy2val = function (x, y) {}; //
466        this.draw = function () {}; // on change / on release
467        this.clear = function () { this._clear(); };
468
469        // Utils
470        this.h2rgba = function (h, a) {
471            var rgb;
472            h = h.substring(1,7)
473            rgb = [parseInt(h.substring(0,2),16)
474                   ,parseInt(h.substring(2,4),16)
475                   ,parseInt(h.substring(4,6),16)];
476            return "rgba(" + rgb[0] + "," + rgb[1] + "," + rgb[2] + "," + a + ")";
477        };
478
479        this.copy = function (f, t) {
480            for (var i in f) { t[i] = f[i]; }
481        };
482    };
483
484
485    /**
486     * k.Dial
487     */
488    k.Dial = function () {
489        k.o.call(this);
490
491        this.startAngle = null;
492        this.xy = null;
493        this.radius = null;
494        this.lineWidth = null;
495        this.cursorExt = null;
496        this.w2 = null;
497        this.PI2 = 2*Math.PI;
498
499        this.extend = function () {
500            this.o = $.extend(
501                {
502                    bgColor : this.$.data('bgcolor') || '#EEEEEE',
503                    angleOffset : this.$.data('angleoffset') || 0,
504                    angleArc : this.$.data('anglearc') || 360,
505                    inline : true
506                }, this.o
507            );
508        };
509
510        this.val = function (v, triggerRelease) {
511            if (null != v) {
512
513                if (
514                    triggerRelease !== false && (v != this.v) && this.rH &&
515                        (this.rH(v) === false)
516                ) return;
517
518                this.cv = this.o.stopper ? max(min(v, this.o.max), this.o.min) : v;
519                this.v = this.cv;
520                this.$.val(this.v);
521                this._draw();
522            } else {
523                return this.v;
524            }
525        };
526
527        this.xy2val = function (x, y) {
528            var a, ret;
529
530            a = Math.atan2(
531                        x - (this.x + this.w2)
532                        , - (y - this.y - this.w2)
533                    ) - this.angleOffset;
534
535            if(this.angleArc != this.PI2 && (a < 0) && (a > -0.5)) {
536                // if isset angleArc option, set to min if .5 under min
537                a = 0;
538            } else if (a < 0) {
539                a += this.PI2;
540            }
541
542            ret = ~~ (0.5 + (a * (this.o.max - this.o.min) / this.angleArc))
543                    + this.o.min;
544
545            this.o.stopper && (ret = max(min(ret, this.o.max), this.o.min));
546
547            return ret;
548        };
549
550        this.listen = function () {
551            // bind MouseWheel
552            var s = this, mwTimerStop, mwTimerRelease,
553                mw = function (e) {
554                    e.preventDefault();
555
556                    var ori = e.originalEvent
557                        ,deltaX = ori.detail || ori.wheelDeltaX
558                        ,deltaY = ori.detail || ori.wheelDeltaY
559                        ,v = s._validate(s.$.val())
560                            + (deltaX>0 || deltaY>
5600 ? s.o.step : deltaX<0 || deltaY<0 ? -s.o.step : 0);
561
562                    v = max(min(v, s.o.max), s.o.min);
563
564                    s.val(v, false);
565
566                    if(s.rH) {
567                        // Handle mousewheel stop
568                        clearTimeout(mwTimerStop);
569                        mwTimerStop = setTimeout(function() {
570                            s.rH(v);
571                            mwTimerStop = null;
572                        }, 100);
573
574                        // Handle mousewheel releases
575                        if(!mwTimerRelease) {
576                            mwTimerRelease = setTimeout(function() {
577                                if(mwTimerStop) s.rH(v);
578                                mwTimerRelease = null;
579                            }, 200);
580                        }
581                    }
582                }
583                , kval, to, m = 1, kv = {37:-s.o.step, 38:s.o.step, 39:s.o.step, 40:-s.o.step};
584
585            this.$
586                .bind(
587                    "keydown"
588                    ,function (e) {
589                        var kc = e.keyCode;
590
591                        // numpad support
592                        if(kc >= 96 && kc <= 105) {
593                            kc = e.keyCode = kc - 48;
594                        }
595
596                        kval = parseInt(String.fromCharCode(kc));
597
598                        if (isNaN(kval)) {
599
600                            (kc !== 13)         // enter
601                            && (kc !== 8)       // bs
602                            && (kc !== 9)       // tab
603                            && (kc !== 189)     // -
604                            && (kc !== 190 || s.$.val().match(/\./))     // . only allowed once
605                            && e.preventDefault();
606
607                            // arrows
608                            if ($.inArray(kc,[37,38,39,40]) > -1) {
609                                e.preventDefault();
610
611                                var v = parseFloat(s.$.val()) + kv[kc] * m;
612                                s.o.stopper && (v = max(min(v, s.o.max), s.o.min));
613
614                                s.change(v);
615                                s._draw();
616
617                                // long time keydown speed-up
618                                to = window.setTimeout(
619                                    function () { m *= 2; }, 30
620                                );
621                            }
622                        }
623                    }
624                )
625                .bind(
626                    "keyup"
627                    ,function (e) {
628                        if (isNaN(kval)) {
629                            if (to) {
630                                window.clearTimeout(to);
631                                to = null;
632                                m = 1;
633                                s.val(s.$.val());
634                            }
635                        } else {
636                            // kval postcond
637                            (s.$.val() > s.o.max && s.$.val(s.o.max))
638                            || (s.$.val() < s.o.min && s.$.val(s.o.min));
639                        }
640
641                    }
642                );
643
644            this.$c.bind("mousewheel DOMMouseScroll", mw);
645            this.$.bind("mousewheel DOMMouseScroll", mw)
646        };
647
648        this.init = function () {
649
650            if (
651                this.v < this.o.min
652                || this.v > this.o.max
653            ) this.v = this.o.min;
654
655            this.$.val(this.v);
656            this.w2 = this.w / 2;
657            this.cursorExt = this.o.cursor / 100;
658            this.xy = this.w2 * this.scale;
659            this.lineWidth = this.xy * this.o.thickness;
660            this.lineCap = this.o.lineCap;
661            this.radius = this.xy - this.lineWidth / 2;
662
663            this.o.angleOffset
664            && (this.o.angleOffset = isNaN(this.o.angleOffset) ? 0 : this.o.angleOffset);
665
666            this.o.angleArc
667            && (this.o.angleArc = isNaN(this.o.angleArc) ? this.PI2 : this.o.angleArc);
668
669            // deg to rad
670            this.angleOffset = this.o.angleOffset * Math.PI / 180;
671            this.angleArc = this.o.angleArc * Math.PI / 180;
672
673            // compute start and end angles
674            this.startAngle = 1.5 * Math.PI + this.angleOffset;
675            this.endAngle = 1.5 * Math.PI + this.angleOffset + this.angleArc;
676
677            var s = max(
678                            String(Math.abs(this.o.max)).length
679                            , String(Math.abs(this.o.min)).length
680                            , 2
681                            ) + 2;
682
683            this.o.displayInput
684                && this.i.css({
685                        'width' : ((this.w / 2 + 4) >> 0) + 'px'
686                        ,'height' : ((this.w / 3) >> 0) + 'px'
687                        ,'position' : 'absolute'
688                        ,'vertical-align' : 'middle'
689                        ,'margin-top' : ((this.w / 3) >> 0) + 'px'
690                        ,'margin-left' : '-' + ((this.w * 3 / 4 + 2) >> 0) + 'px'
691                        ,'border' : 0
692                        ,'background' : 'none'
693                        ,'font' : this.o.fontWeight + ' ' + ((this.w / s) >> 0) + 'px ' + this.o.font
694                        ,'text-align' : 'center'
695                        ,'color' : this.o.inputColor || this.o.fgColor
696                        ,'padding' : '0px'
697                        ,'-webkit-appearance': 'none'
698                        })
699                || this.i.css({
700                        'width' : '0px'
701                        ,'visibility' : 'hidden'
702                        });
703        };
704
705        this.change = function (v) {
706            this.cv = v;
707            this.$.val(v);
708        };
709
710        this.angle = function (v) {
711            return (v - this.o.min) * this.angleArc / (this.o.max - this.o.min);
712        };
713
714        this.draw = function () {
715
716            var c = this.g,                 // context
717                a = this.angle(this.cv)    // Angle
718                , sat = this.startAngle     // Start angle
719                , eat = sat + a             // End angle
720                , sa, ea                    // Previous angles
721                , r = 1;
722
723            c.lineWidth = this.lineWidth;
724
725            c.lineCap = this.lineCap;
726
727            this.o.cursor
728                && (sat = eat - this.cursorExt)
729                && (eat = eat + this.cursorExt);
730
731            c.beginPath();
732                c.strokeStyle = this.o.bgColor;
733                c.arc(this.xy, this.xy, this.radius, this.endAngle - 0.00001, this.startAngle + 0.00001, true);
734            c.stroke();
735
736            if (this.o.displayPrevious) {
737                ea = this.startAngle + this.angle(this.v);
738                sa = this.startAngle;
739                this.o.cursor
740                    && (sa = ea - this.cursorExt)
741                    && (ea = ea + this.cursorExt);
742
743                c.beginPath();
744                    c.strokeStyle = this.pColor;
745                    c.arc(this.xy, this.xy, this.radius, sa - 0.00001, ea + 0.00001, false);
746                c.stroke();
747                r = (this.cv == this.v);
748            }
749
750            c.beginPath();
751                c.strokeStyle = r ? this.o.fgColor : this.fgColor ;
752                c.arc(this.xy, this.xy, this.radius, sat - 0.00001, eat + 0.00001, false);
753            c.stroke();
754        };
755
756        this.cancel = function () {
757            this.val(this.v);
758        };
759    };
760
761    $.fn.dial = $.fn.knob = function (o) {
762        return this.each(
763            function () {
764                var d = new k.Dial();
765                d.o = o;
766                d.$ = $(this);
767                d.run();
768            }
769        ).parent();
770    };
771
772})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.