/* NUGET: BEGIN LICENSE TEXT
*
* Microsoft grants you the right to use these script files for the sole
* purpose of either: (i) interacting through your browser with the Microsoft
* website or online service, subject to the applicable licensing or use
* terms; or (ii) using the files as included with a Microsoft product subject
* to that product's license terms. Microsoft reserves all other rights to the
* files not expressly granted by Microsoft, whether by implication, estoppel
* or otherwise. Insofar as a script file is dual licensed under GPL,
* Microsoft neither took the code under GPL nor distributes it thereunder but
* under the terms set out in this paragraph. All notices and licenses
* below are for informational purposes only.
*
* NUGET: END LICENSE TEXT */
/*
** Unobtrusive Ajax support library for jQuery
** Copyright (C) Microsoft Corporation. All rights reserved.
*/
(function(a){var b="unobtrusiveAjaxClick",d="unobtrusiveAjaxClickTarget",h="unobtrusiveValidation";function c(d,b){var a=window,c=(d||"").split(".");while(a&&c.length)a=a[c.shift()];if(typeof a==="function")return a;b.push(d);return Function.constructor.apply(null,b)}function e(a){return a==="GET"||a==="POST"}function g(b,a){!e(a)&&b.setRequestHeader("X-HTTP-Method-Override",a)}function i(c,b,e){var d;if(e.indexOf("application/x-javascript")!==-1)return;d=(c.getAttribute("data-ajax-mode")||"").toUpperCase();a(c.getAttribute("data-ajax-update")).each(function(f,c){var e;switch(d){case"BEFORE":e=c.firstChild;a("
").html(b).contents().each(function(){c.insertBefore(this,e)});break;case"AFTER":a("").html(b).contents().each(function(){c.appendChild(this)});break;case"REPLACE-WITH":a(c).replaceWith(b);break;default:a(c).html(b)}})}function f(b,d){var j,k,f,h;j=b.getAttribute("data-ajax-confirm");if(j&&!window.confirm(j))return;k=a(b.getAttribute("data-ajax-loading"));h=parseInt(b.getAttribute("data-ajax-loading-duration"),10)||0;a.extend(d,{type:b.getAttribute("data-ajax-method")||undefined,url:b.getAttribute("data-ajax-url")||undefined,cache:!!b.getAttribute("data-ajax-cache"),beforeSend:function(d){var a;g(d,f);a=c(b.getAttribute("data-ajax-begin"),["xhr"]).apply(b,arguments);a!==false&&k.show(h);return a},complete:function(){k.hide(h);c(b.getAttribute("data-ajax-complete"),["xhr","status"]).apply(b,arguments)},success:function(a,e,d){i(b,a,d.getResponseHeader("Content-Type")||"text/html");c(b.getAttribute("data-ajax-success"),["data","status","xhr"]).apply(b,arguments)},error:function(){c(b.getAttribute("data-ajax-failure"),["xhr","status","error"]).apply(b,arguments)}});d.data.push({name:"X-Requested-With",value:"XMLHttpRequest"});f=d.type.toUpperCase();if(!e(f)){d.type="POST";d.data.push({name:"X-HTTP-Method-Override",value:f})}a.ajax(d)}function j(c){var b=a(c).data(h);return!b||!b.validate||b.validate()}a(document).on("click","a[data-ajax=true]",function(a){a.preventDefault();f(this,{url:this.href,type:"GET",data:[]})});a(document).on("click","form[data-ajax=true] input[type=image]",function(c){var g=c.target.name,e=a(c.target),f=a(e.parents("form")[0]),d=e.offset();f.data(b,[{name:g+".x",value:Math.round(c.pageX-d.left)},{name:g+".y",value:Math.round(c.pageY-d.top)}]);setTimeout(function(){f.removeData(b)},0)});a(document).on("click","form[data-ajax=true] :submit",function(e){var g=e.currentTarget.name,f=a(e.target),c=a(f.parents("form")[0]);c.data(b,g?[{name:g,value:e.currentTarget.value}]:[]);c.data(d,f);setTimeout(function(){c.removeData(b);c.removeData(d)},0)});a(document).on("submit","form[data-ajax=true]",function(h){var e=a(this).data(b)||[],c=a(this).data(d),g=c&&c.hasClass("cancel");h.preventDefault();if(!g&&!j(this))return;f(this,{url:this.action,type:this.method||"GET",data:e.concat(a(this).serializeArray())})})})(jQuery);
/*! jQuery Validation Plugin - v1.14.0 - 6/30/2015
* http://jqueryvalidation.org/
* Copyright (c) 2015 Jörn Zaefferer; Licensed MIT */
!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a(jQuery)}(function(a){a.extend(a.fn,{validate:function(b){if(!this.length)return void(b&&b.debug&&window.console&&console.warn("Nothing selected, can't validate, returning nothing."));var c=a.data(this[0],"validator");return c?c:(this.attr("novalidate","novalidate"),c=new a.validator(b,this[0]),a.data(this[0],"validator",c),c.settings.onsubmit&&(this.on("click.validate",":submit",function(b){c.settings.submitHandler&&(c.submitButton=b.target),a(this).hasClass("cancel")&&(c.cancelSubmit=!0),void 0!==a(this).attr("formnovalidate")&&(c.cancelSubmit=!0)}),this.on("submit.validate",function(b){function d(){var d,e;return c.settings.submitHandler?(c.submitButton&&(d=a("").attr("name",c.submitButton.name).val(a(c.submitButton).val()).appendTo(c.currentForm)),e=c.settings.submitHandler.call(c,c.currentForm,b),c.submitButton&&d.remove(),void 0!==e?e:!1):!0}return c.settings.debug&&b.preventDefault(),c.cancelSubmit?(c.cancelSubmit=!1,d()):c.form()?c.pendingRequest?(c.formSubmitted=!0,!1):d():(c.focusInvalid(),!1)})),c)},valid:function(){var b,c,d;return a(this[0]).is("form")?b=this.validate().form():(d=[],b=!0,c=a(this[0].form).validate(),this.each(function(){b=c.element(this)&&b,d=d.concat(c.errorList)}),c.errorList=d),b},rules:function(b,c){var d,e,f,g,h,i,j=this[0];if(b)switch(d=a.data(j.form,"validator").settings,e=d.rules,f=a.validator.staticRules(j),b){case"add":a.extend(f,a.validator.normalizeRule(c)),delete f.messages,e[j.name]=f,c.messages&&(d.messages[j.name]=a.extend(d.messages[j.name],c.messages));break;case"remove":return c?(i={},a.each(c.split(/\s/),function(b,c){i[c]=f[c],delete f[c],"required"===c&&a(j).removeAttr("aria-required")}),i):(delete e[j.name],f)}return g=a.validator.normalizeRules(a.extend({},a.validator.classRules(j),a.validator.attributeRules(j),a.validator.dataRules(j),a.validator.staticRules(j)),j),g.required&&(h=g.required,delete g.required,g=a.extend({required:h},g),a(j).attr("aria-required","true")),g.remote&&(h=g.remote,delete g.remote,g=a.extend(g,{remote:h})),g}}),a.extend(a.expr[":"],{blank:function(b){return!a.trim(""+a(b).val())},filled:function(b){return!!a.trim(""+a(b).val())},unchecked:function(b){return!a(b).prop("checked")}}),a.validator=function(b,c){this.settings=a.extend(!0,{},a.validator.defaults,b),this.currentForm=c,this.init()},a.validator.format=function(b,c){return 1===arguments.length?function(){var c=a.makeArray(arguments);return c.unshift(b),a.validator.format.apply(this,c)}:(arguments.length>2&&c.constructor!==Array&&(c=a.makeArray(arguments).slice(1)),c.constructor!==Array&&(c=[c]),a.each(c,function(a,c){b=b.replace(new RegExp("\\{"+a+"\\}","g"),function(){return c})}),b)},a.extend(a.validator,{defaults:{messages:{},groups:{},rules:{},errorClass:"error",validClass:"valid",errorElement:"label",focusCleanup:!1,focusInvalid:!0,errorContainer:a([]),errorLabelContainer:a([]),onsubmit:!0,ignore:":hidden",ignoreTitle:!1,onfocusin:function(a){this.lastActive=a,this.settings.focusCleanup&&(this.settings.unhighlight&&this.settings.unhighlight.call(this,a,this.settings.errorClass,this.settings.validClass),this.hideThese(this.errorsFor(a)))},onfocusout:function(a){this.checkable(a)||!(a.name in this.submitted)&&this.optional(a)||this.element(a)},onkeyup:function(b,c){var d=[16,17,18,20,35,36,37,38,39,40,45,144,225];9===c.which&&""===this.elementValue(b)||-1!==a.inArray(c.keyCode,d)||(b.name in this.submitted||b===this.lastElement)&&this.element(b)},onclick:function(a){a.name in this.submitted?this.element(a):a.parentNode.name in this.submitted&&this.element(a.parentNode)},highlight:function(b,c,d){"radio"===b.type?this.findByName(b.name).addClass(c).removeClass(d):a(b).addClass(c).removeClass(d)},unhighlight:function(b,c,d){"radio"===b.type?this.findByName(b.name).removeClass(c).addClass(d):a(b).removeClass(c).addClass(d)}},setDefaults:function(b){a.extend(a.validator.defaults,b)},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:a.validator.format("Please enter no more than {0} characters."),minlength:a.validator.format("Please enter at least {0} characters."),rangelength:a.validator.format("Please enter a value between {0} and {1} characters long."),range:a.validator.format("Please enter a value between {0} and {1}."),max:a.validator.format("Please enter a value less than or equal to {0}."),min:a.validator.format("Please enter a value greater than or equal to {0}.")},autoCreateRanges:!1,prototype:{init:function(){function b(b){var c=a.data(this.form,"validator"),d="on"+b.type.replace(/^validate/,""),e=c.settings;e[d]&&!a(this).is(e.ignore)&&e[d].call(c,this,b)}this.labelContainer=a(this.settings.errorLabelContainer),this.errorContext=this.labelContainer.length&&this.labelContainer||a(this.currentForm),this.containers=a(this.settings.errorContainer).add(this.settings.errorLabelContainer),this.submitted={},this.valueCache={},this.pendingRequest=0,this.pending={},this.invalid={},this.reset();var c,d=this.groups={};a.each(this.settings.groups,function(b,c){"string"==typeof c&&(c=c.split(/\s/)),a.each(c,function(a,c){d[c]=b})}),c=this.settings.rules,a.each(c,function(b,d){c[b]=a.validator.normalizeRule(d)}),a(this.currentForm).on("focusin.validate focusout.validate keyup.validate",":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'], [type='radio'], [type='checkbox']",b).on("click.validate","select, option, [type='radio'], [type='checkbox']",b),this.settings.invalidHandler&&a(this.currentForm).on("invalid-form.validate",this.settings.invalidHandler),a(this.currentForm).find("[required], [data-rule-required], .required").attr("aria-required","true")},form:function(){return this.checkForm(),a.extend(this.submitted,this.errorMap),this.invalid=a.extend({},this.errorMap),this.valid()||a(this.currentForm).triggerHandler("invalid-form",[this]),this.showErrors(),this.valid()},checkForm:function(){this.prepareForm();for(var a=0,b=this.currentElements=this.elements();b[a];a++)this.check(b[a]);return this.valid()},element:function(b){var c=this.clean(b),d=this.validationTargetFor(c),e=!0;return this.lastElement=d,void 0===d?delete this.invalid[c.name]:(this.prepareElement(d),this.currentElements=a(d),e=this.check(d)!==!1,e?delete this.invalid[d.name]:this.invalid[d.name]=!0),a(b).attr("aria-invalid",!e),this.numberOfInvalids()||(this.toHide=this.toHide.add(this.containers)),this.showErrors(),e},showErrors:function(b){if(b){a.extend(this.errorMap,b),this.errorList=[];for(var c in b)this.errorList.push({message:b[c],element:this.findByName(c)[0]});this.successList=a.grep(this.successList,function(a){return!(a.name in b)})}this.settings.showErrors?this.settings.showErrors.call(this,this.errorMap,this.errorList):this.defaultShowErrors()},resetForm:function(){a.fn.resetForm&&a(this.currentForm).resetForm(),this.submitted={},this.lastElement=null,this.prepareForm(),this.hideErrors();var b,c=this.elements().removeData("previousValue").removeAttr("aria-invalid");if(this.settings.unhighlight)for(b=0;c[b];b++)this.settings.unhighlight.call(this,c[b],this.settings.errorClass,"");else c.removeClass(this.settings.errorClass)},numberOfInvalids:function(){return this.objectLength(this.invalid)},objectLength:function(a){var b,c=0;for(b in a)c++;return c},hideErrors:function(){this.hideThese(this.toHide)},hideThese:function(a){a.not(this.containers).text(""),this.addWrapper(a).hide()},valid:function(){return 0===this.size()},size:function(){return this.errorList.length},focusInvalid:function(){if(this.settings.focusInvalid)try{a(this.findLastActive()||this.errorList.length&&this.errorList[0].element||[]).filter(":visible").focus().trigger("focusin")}catch(b){}},findLastActive:function(){var b=this.lastActive;return b&&1===a.grep(this.errorList,function(a){return a.element.name===b.name}).length&&b},elements:function(){var b=this,c={};return a(this.currentForm).find("input, select, textarea").not(":submit, :reset, :image, :disabled").not(this.settings.ignore).filter(function(){return!this.name&&b.settings.debug&&window.console&&console.error("%o has no name assigned",this),this.name in c||!b.objectLength(a(this).rules())?!1:(c[this.name]=!0,!0)})},clean:function(b){return a(b)[0]},errors:function(){var b=this.settings.errorClass.split(" ").join(".");return a(this.settings.errorElement+"."+b,this.errorContext)},reset:function(){this.successList=[],this.errorList=[],this.errorMap={},this.toShow=a([]),this.toHide=a([]),this.currentElements=a([])},prepareForm:function(){this.reset(),this.toHide=this.errors().add(this.containers)},prepareElement:function(a){this.reset(),this.toHide=this.errorsFor(a)},elementValue:function(b){var c,d=a(b),e=b.type;return"radio"===e||"checkbox"===e?this.findByName(b.name).filter(":checked").val():"number"===e&&"undefined"!=typeof b.validity?b.validity.badInput?!1:d.val():(c=d.val(),"string"==typeof c?c.replace(/\r/g,""):c)},check:function(b){b=this.validationTargetFor(this.clean(b));var c,d,e,f=a(b).rules(),g=a.map(f,function(a,b){return b}).length,h=!1,i=this.elementValue(b);for(d in f){e={method:d,parameters:f[d]};try{if(c=a.validator.methods[d].call(this,i,b,e.parameters),"dependency-mismatch"===c&&1===g){h=!0;continue}if(h=!1,"pending"===c)return void(this.toHide=this.toHide.not(this.errorsFor(b)));if(!c)return this.formatAndAdd(b,e),!1}catch(j){throw this.settings.debug&&window.console&&console.log("Exception occurred when checking element "+b.id+", check the '"+e.method+"' method.",j),j instanceof TypeError&&(j.message+=". Exception occurred when checking element "+b.id+", check the '"+e.method+"' method."),j}}if(!h)return this.objectLength(f)&&this.successList.push(b),!0},customDataMessage:function(b,c){return a(b).data("msg"+c.charAt(0).toUpperCase()+c.substring(1).toLowerCase())||a(b).data("msg")},customMessage:function(a,b){var c=this.settings.messages[a];return c&&(c.constructor===String?c:c[b])},findDefined:function(){for(var a=0;aWarning: No message defined for "+b.name+"")},formatAndAdd:function(b,c){var d=this.defaultMessage(b,c.method),e=/\$?\{(\d+)\}/g;"function"==typeof d?d=d.call(this,c.parameters,b):e.test(d)&&(d=a.validator.format(d.replace(e,"{$1}"),c.parameters)),this.errorList.push({message:d,element:b,method:c.method}),this.errorMap[b.name]=d,this.submitted[b.name]=d},addWrapper:function(a){return this.settings.wrapper&&(a=a.add(a.parent(this.settings.wrapper))),a},defaultShowErrors:function(){var a,b,c;for(a=0;this.errorList[a];a++)c=this.errorList[a],this.settings.highlight&&this.settings.highlight.call(this,c.element,this.settings.errorClass,this.settings.validClass),this.showLabel(c.element,c.message);if(this.errorList.length&&(this.toShow=this.toShow.add(this.containers)),this.settings.success)for(a=0;this.successList[a];a++)this.showLabel(this.successList[a]);if(this.settings.unhighlight)for(a=0,b=this.validElements();b[a];a++)this.settings.unhighlight.call(this,b[a],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 a(this.errorList).map(function(){return this.element})},showLabel:function(b,c){var d,e,f,g=this.errorsFor(b),h=this.idOrName(b),i=a(b).attr("aria-describedby");g.length?(g.removeClass(this.settings.validClass).addClass(this.settings.errorClass),g.html(c)):(g=a("<"+this.settings.errorElement+">").attr("id",h+"-error").addClass(this.settings.errorClass).html(c||""),d=g,this.settings.wrapper&&(d=g.hide().show().wrap("<"+this.settings.wrapper+"/>").parent()),this.labelContainer.length?this.labelContainer.append(d):this.settings.errorPlacement?this.settings.errorPlacement(d,a(b)):d.insertAfter(b),g.is("label")?g.attr("for",h):0===g.parents("label[for='"+h+"']").length&&(f=g.attr("id").replace(/(:|\.|\[|\]|\$)/g,"\\$1"),i?i.match(new RegExp("\\b"+f+"\\b"))||(i+=" "+f):i=f,a(b).attr("aria-describedby",i),e=this.groups[b.name],e&&a.each(this.groups,function(b,c){c===e&&a("[name='"+b+"']",this.currentForm).attr("aria-describedby",g.attr("id"))}))),!c&&this.settings.success&&(g.text(""),"string"==typeof this.settings.success?g.addClass(this.settings.success):this.settings.success(g,b)),this.toShow=this.toShow.add(g)},errorsFor:function(b){var c=this.idOrName(b),d=a(b).attr("aria-describedby"),e="label[for='"+c+"'], label[for='"+c+"'] *";return d&&(e=e+", #"+d.replace(/\s+/g,", #")),this.errors().filter(e)},idOrName:function(a){return this.groups[a.name]||(this.checkable(a)?a.name:a.id||a.name)},validationTargetFor:function(b){return this.checkable(b)&&(b=this.findByName(b.name)),a(b).not(this.settings.ignore)[0]},checkable:function(a){return/radio|checkbox/i.test(a.type)},findByName:function(b){return a(this.currentForm).find("[name='"+b+"']")},getLength:function(b,c){switch(c.nodeName.toLowerCase()){case"select":return a("option:selected",c).length;case"input":if(this.checkable(c))return this.findByName(c.name).filter(":checked").length}return b.length},depend:function(a,b){return this.dependTypes[typeof a]?this.dependTypes[typeof a](a,b):!0},dependTypes:{"boolean":function(a){return a},string:function(b,c){return!!a(b,c.form).length},"function":function(a,b){return a(b)}},optional:function(b){var c=this.elementValue(b);return!a.validator.methods.required.call(this,c,b)&&"dependency-mismatch"},startRequest:function(a){this.pending[a.name]||(this.pendingRequest++,this.pending[a.name]=!0)},stopRequest:function(b,c){this.pendingRequest--,this.pendingRequest<0&&(this.pendingRequest=0),delete this.pending[b.name],c&&0===this.pendingRequest&&this.formSubmitted&&this.form()?(a(this.currentForm).submit(),this.formSubmitted=!1):!c&&0===this.pendingRequest&&this.formSubmitted&&(a(this.currentForm).triggerHandler("invalid-form",[this]),this.formSubmitted=!1)},previousValue:function(b){return a.data(b,"previousValue")||a.data(b,"previousValue",{old:null,valid:!0,message:this.defaultMessage(b,"remote")})},destroy:function(){this.resetForm(),a(this.currentForm).off(".validate").removeData("validator")}},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(b,c){b.constructor===String?this.classRuleSettings[b]=c:a.extend(this.classRuleSettings,b)},classRules:function(b){var c={},d=a(b).attr("class");return d&&a.each(d.split(" "),function(){this in a.validator.classRuleSettings&&a.extend(c,a.validator.classRuleSettings[this])}),c},normalizeAttributeRule:function(a,b,c,d){/min|max/.test(c)&&(null===b||/number|range|text/.test(b))&&(d=Number(d),isNaN(d)&&(d=void 0)),d||0===d?a[c]=d:b===c&&"range"!==b&&(a[c]=!0)},attributeRules:function(b){var c,d,e={},f=a(b),g=b.getAttribute("type");for(c in a.validator.methods)"required"===c?(d=b.getAttribute(c),""===d&&(d=!0),d=!!d):d=f.attr(c),this.normalizeAttributeRule(e,g,c,d);return e.maxlength&&/-1|2147483647|524288/.test(e.maxlength)&&delete e.maxlength,e},dataRules:function(b){var c,d,e={},f=a(b),g=b.getAttribute("type");for(c in a.validator.methods)d=f.data("rule"+c.charAt(0).toUpperCase()+c.substring(1).toLowerCase()),this.normalizeAttributeRule(e,g,c,d);return e},staticRules:function(b){var c={},d=a.data(b.form,"validator");return d.settings.rules&&(c=a.validator.normalizeRule(d.settings.rules[b.name])||{}),c},normalizeRules:function(b,c){return a.each(b,function(d,e){if(e===!1)return void delete b[d];if(e.param||e.depends){var f=!0;switch(typeof e.depends){case"string":f=!!a(e.depends,c.form).length;break;case"function":f=e.depends.call(c,c)}f?b[d]=void 0!==e.param?e.param:!0:delete b[d]}}),a.each(b,function(d,e){b[d]=a.isFunction(e)?e(c):e}),a.each(["minlength","maxlength"],function(){b[this]&&(b[this]=Number(b[this]))}),a.each(["rangelength","range"],function(){var c;b[this]&&(a.isArray(b[this])?b[this]=[Number(b[this][0]),Number(b[this][1])]:"string"==typeof b[this]&&(c=b[this].replace(/[\[\]]/g,"").split(/[\s,]+/),b[this]=[Number(c[0]),Number(c[1])]))}),a.validator.autoCreateRanges&&(null!=b.min&&null!=b.max&&(b.range=[b.min,b.max],delete b.min,delete b.max),null!=b.minlength&&null!=b.maxlength&&(b.rangelength=[b.minlength,b.maxlength],delete b.minlength,delete b.maxlength)),b},normalizeRule:function(b){if("string"==typeof b){var c={};a.each(b.split(/\s/),function(){c[this]=!0}),b=c}return b},addMethod:function(b,c,d){a.validator.methods[b]=c,a.validator.messages[b]=void 0!==d?d:a.validator.messages[b],c.length<3&&a.validator.addClassRules(b,a.validator.normalizeRule(b))},methods:{required:function(b,c,d){if(!this.depend(d,c))return"dependency-mismatch";if("select"===c.nodeName.toLowerCase()){var e=a(c).val();return e&&e.length>0}return this.checkable(c)?this.getLength(b,c)>0:b.length>0},email:function(a,b){return this.optional(b)||/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test(a)},url:function(a,b){return this.optional(b)||/^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})).?)(?::\d{2,5})?(?:[/?#]\S*)?$/i.test(a)},date:function(a,b){return this.optional(b)||!/Invalid|NaN/.test(new Date(a).toString())},dateISO:function(a,b){return this.optional(b)||/^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/.test(a)},number:function(a,b){return this.optional(b)||/^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/.test(a)},digits:function(a,b){return this.optional(b)||/^\d+$/.test(a)},creditcard:function(a,b){if(this.optional(b))return"dependency-mismatch";if(/[^0-9 \-]+/.test(a))return!1;var c,d,e=0,f=0,g=!1;if(a=a.replace(/\D/g,""),a.length<13||a.length>19)return!1;for(c=a.length-1;c>=0;c--)d=a.charAt(c),f=parseInt(d,10),g&&(f*=2)>9&&(f-=9),e+=f,g=!g;return e%10===0},minlength:function(b,c,d){var e=a.isArray(b)?b.length:this.getLength(b,c);return this.optional(c)||e>=d},maxlength:function(b,c,d){var e=a.isArray(b)?b.length:this.getLength(b,c);return this.optional(c)||d>=e},rangelength:function(b,c,d){var e=a.isArray(b)?b.length:this.getLength(b,c);return this.optional(c)||e>=d[0]&&e<=d[1]},min:function(a,b,c){return this.optional(b)||a>=c},max:function(a,b,c){return this.optional(b)||c>=a},range:function(a,b,c){return this.optional(b)||a>=c[0]&&a<=c[1]},equalTo:function(b,c,d){var e=a(d);return this.settings.onfocusout&&e.off(".validate-equalTo").on("blur.validate-equalTo",function(){a(c).valid()}),b===e.val()},remote:function(b,c,d){if(this.optional(c))return"dependency-mismatch";var e,f,g=this.previousValue(c);return this.settings.messages[c.name]||(this.settings.messages[c.name]={}),g.originalMessage=this.settings.messages[c.name].remote,this.settings.messages[c.name].remote=g.message,d="string"==typeof d&&{url:d}||d,g.old===b?g.valid:(g.old=b,e=this,this.startRequest(c),f={},f[c.name]=b,a.ajax(a.extend(!0,{mode:"abort",port:"validate"+c.name,dataType:"json",data:f,context:e.currentForm,success:function(d){var f,h,i,j=d===!0||"true"===d;e.settings.messages[c.name].remote=g.originalMessage,j?(i=e.formSubmitted,e.prepareElement(c),e.formSubmitted=i,e.successList.push(c),delete e.invalid[c.name],e.showErrors()):(f={},h=d||e.defaultMessage(c,"remote"),f[c.name]=g.message=a.isFunction(h)?h(b):h,e.invalid[c.name]=!0,e.showErrors(f)),g.valid=j,e.stopRequest(c,j)}},d)),"pending")}}});var b,c={};a.ajaxPrefilter?a.ajaxPrefilter(function(a,b,d){var e=a.port;"abort"===a.mode&&(c[e]&&c[e].abort(),c[e]=d)}):(b=a.ajax,a.ajax=function(d){var e=("mode"in d?d:a.ajaxSettings).mode,f=("port"in d?d:a.ajaxSettings).port;return"abort"===e?(c[f]&&c[f].abort(),c[f]=b.apply(this,arguments),c[f]):b.apply(this,arguments)})});
/* NUGET: BEGIN LICENSE TEXT
*
* Microsoft grants you the right to use these script files for the sole
* purpose of either: (i) interacting through your browser with the Microsoft
* website or online service, subject to the applicable licensing or use
* terms; or (ii) using the files as included with a Microsoft product subject
* to that product's license terms. Microsoft reserves all other rights to the
* files not expressly granted by Microsoft, whether by implication, estoppel
* or otherwise. Insofar as a script file is dual licensed under GPL,
* Microsoft neither took the code under GPL nor distributes it thereunder but
* under the terms set out in this paragraph. All notices and licenses
* below are for informational purposes only.
*
* NUGET: END LICENSE TEXT */
/*
** Unobtrusive validation support library for jQuery and jQuery Validate
** Copyright (C) Microsoft Corporation. All rights reserved.
*/
(function(a){var d=a.validator,b,e="unobtrusiveValidation";function c(a,b,c){a.rules[b]=c;if(a.message)a.messages[b]=a.message}function j(a){return a.replace(/^\s+|\s+$/g,"").split(/\s*,\s*/g)}function f(a){return a.replace(/([!"#$%&'()*+,./:;<=>?@\[\\\]^`{|}~])/g,"\\$1")}function h(a){return a.substr(0,a.lastIndexOf(".")+1)}function g(a,b){if(a.indexOf("*.")===0)a=a.replace("*.",b);return a}function m(c,e){var b=a(this).find("[data-valmsg-for='"+f(e[0].name)+"']"),d=b.attr("data-valmsg-replace"),g=d?a.parseJSON(d)!==false:null;b.removeClass("field-validation-valid").addClass("field-validation-error");c.data("unobtrusiveContainer",b);if(g){b.empty();c.removeClass("input-validation-error").appendTo(b)}else c.hide()}function l(e,d){var c=a(this).find("[data-valmsg-summary=true]"),b=c.find("ul");if(b&&b.length&&d.errorList.length){b.empty();c.addClass("validation-summary-errors").removeClass("validation-summary-valid");a.each(d.errorList,function(){a("").html(this.message).appendTo(b)})}}function k(d){var b=d.data("unobtrusiveContainer"),c=b.attr("data-valmsg-replace"),e=c?a.parseJSON(c):null;if(b){b.addClass("field-validation-valid").removeClass("field-validation-error");d.removeData("unobtrusiveContainer");e&&b.empty()}}function n(){var b=a(this);b.data("validator").resetForm();b.find(".validation-summary-errors").addClass("validation-summary-valid").removeClass("validation-summary-errors");b.find(".field-validation-error").addClass("field-validation-valid").removeClass("field-validation-error").removeData("unobtrusiveContainer").find(">*").removeData("unobtrusiveContainer")}function i(c){var b=a(c),d=b.data(e),f=a.proxy(n,c);if(!d){d={options:{errorClass:"input-validation-error",errorElement:"span",errorPlacement:a.proxy(m,c),invalidHandler:a.proxy(l,c),messages:{},rules:{},success:a.proxy(k,c)},attachValidation:function(){b.unbind("reset."+e,f).bind("reset."+e,f).validate(this.options)},validate:function(){b.validate();return b.valid()}};b.data(e,d)}return d}d.unobtrusive={adapters:[],parseElement:function(b,h){var d=a(b),f=d.parents("form")[0],c,e,g;if(!f)return;c=i(f);c.options.rules[b.name]=e={};c.options.messages[b.name]=g={};a.each(this.adapters,function(){var c="data-val-"+this.name,i=d.attr(c),h={};if(i!==undefined){c+="-";a.each(this.params,function(){h[this]=d.attr(c+this)});this.adapt({element:b,form:f,message:i,params:h,rules:e,messages:g})}});a.extend(e,{__dummy__:true});!h&&c.attachValidation()},parse:function(b){var c=a(b).parents("form").andSelf().add(a(b).find("form")).filter("form");a(b).find(":input").filter("[data-val=true]").each(function(){d.unobtrusive.parseElement(this,true)});c.each(function(){var a=i(this);a&&a.attachValidation()})}};b=d.unobtrusive.adapters;b.add=function(c,a,b){if(!b){b=a;a=[]}this.push({name:c,params:a,adapt:b});return this};b.addBool=function(a,b){return this.add(a,function(d){c(d,b||a,true)})};b.addMinMax=function(e,g,f,a,d,b){return this.add(e,[d||"min",b||"max"],function(b){var e=b.params.min,d=b.params.max;if(e&&d)c(b,a,[e,d]);else if(e)c(b,g,e);else d&&c(b,f,d)})};b.addSingleVal=function(a,b,d){return this.add(a,[b||"val"],function(e){c(e,d||a,e.params[b])})};d.addMethod("__dummy__",function(){return true});d.addMethod("regex",function(b,c,d){var a;if(this.optional(c))return true;a=(new RegExp(d)).exec(b);return a&&a.index===0&&a[0].length===b.length});d.addMethod("nonalphamin",function(c,d,b){var a;if(b){a=c.match(/\W/g);a=a&&a.length>=b}return a});if(d.methods.extension){b.addSingleVal("accept","mimtype");b.addSingleVal("extension","extension")}else b.addSingleVal("extension","extension","accept");b.addSingleVal("regex","pattern");b.addBool("creditcard").addBool("date").addBool("digits").addBool("email").addBool("number").addBool("url");b.addMinMax("length","minlength","maxlength","rangelength").addMinMax("range","min","max","range");b.add("equalto",["other"],function(b){var i=h(b.element.name),j=b.params.other,d=g(j,i),e=a(b.form).find(":input").filter("[name='"+f(d)+"']")[0];c(b,"equalTo",e)});b.add("required",function(a){(a.element.tagName.toUpperCase()!=="INPUT"||a.element.type.toUpperCase()!=="CHECKBOX")&&c(a,"required",true)});b.add("remote",["url","type","additionalfields"],function(b){var d={url:b.params.url,type:b.params.type||"GET",data:{}},e=h(b.element.name);a.each(j(b.params.additionalfields||b.element.name),function(i,h){var c=g(h,e);d.data[c]=function(){return a(b.form).find(":input").filter("[name='"+f(c)+"']").val()}});c(b,"remote",d)});b.add("password",["min","nonalphamin","regex"],function(a){a.params.min&&c(a,"minlength",a.params.min);a.params.nonalphamin&&c(a,"nonalphamin",a.params.nonalphamin);a.params.regex&&c(a,"regex",a.params.regex)});a(function(){d.unobtrusive.parse(document)})})(jQuery);
/*!
* Globalize
*
* http://github.com/jquery/globalize
*
* Copyright Software Freedom Conservancy, Inc.
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*/
(function( window, undefined ) {
var Globalize,
// private variables
regexHex,
regexInfinity,
regexParseFloat,
regexTrim,
// private JavaScript utility functions
arrayIndexOf,
endsWith,
extend,
isArray,
isFunction,
isObject,
startsWith,
trim,
truncate,
zeroPad,
// private Globalization utility functions
appendPreOrPostMatch,
expandFormat,
formatDate,
formatNumber,
getTokenRegExp,
getEra,
getEraYear,
parseExact,
parseNegativePattern;
// Global variable (Globalize) or CommonJS module (globalize)
Globalize = function( cultureSelector ) {
return new Globalize.prototype.init( cultureSelector );
};
if ( typeof require !== "undefined" &&
typeof exports !== "undefined" &&
typeof module !== "undefined" ) {
// Assume CommonJS
module.exports = Globalize;
} else {
// Export as global variable
window.Globalize = Globalize;
}
Globalize.cultures = {};
Globalize.prototype = {
constructor: Globalize,
init: function( cultureSelector ) {
this.cultures = Globalize.cultures;
this.cultureSelector = cultureSelector;
return this;
}
};
Globalize.prototype.init.prototype = Globalize.prototype;
// 1. When defining a culture, all fields are required except the ones stated as optional.
// 2. Each culture should have a ".calendars" object with at least one calendar named "standard"
// which serves as the default calendar in use by that culture.
// 3. Each culture should have a ".calendar" object which is the current calendar being used,
// it may be dynamically changed at any time to one of the calendars in ".calendars".
Globalize.cultures[ "default" ] = {
// A unique name for the culture in the form -
name: "en",
// the name of the culture in the english language
englishName: "English",
// the name of the culture in its own language
nativeName: "English",
// whether the culture uses right-to-left text
isRTL: false,
// "language" is used for so-called "specific" cultures.
// For example, the culture "es-CL" means "Spanish, in Chili".
// It represents the Spanish-speaking culture as it is in Chili,
// which might have different formatting rules or even translations
// than Spanish in Spain. A "neutral" culture is one that is not
// specific to a region. For example, the culture "es" is the generic
// Spanish culture, which may be a more generalized version of the language
// that may or may not be what a specific culture expects.
// For a specific culture like "es-CL", the "language" field refers to the
// neutral, generic culture information for the language it is using.
// This is not always a simple matter of the string before the dash.
// For example, the "zh-Hans" culture is netural (Simplified Chinese).
// And the "zh-SG" culture is Simplified Chinese in Singapore, whose lanugage
// field is "zh-CHS", not "zh".
// This field should be used to navigate from a specific culture to it's
// more general, neutral culture. If a culture is already as general as it
// can get, the language may refer to itself.
language: "en",
// numberFormat defines general number formatting rules, like the digits in
// each grouping, the group separator, and how negative numbers are displayed.
numberFormat: {
// [negativePattern]
// Note, numberFormat.pattern has no "positivePattern" unlike percent and currency,
// but is still defined as an array for consistency with them.
// negativePattern: one of "(n)|-n|- n|n-|n -"
pattern: [ "-n" ],
// number of decimal places normally shown
decimals: 2,
// string that separates number groups, as in 1,000,000
",": ",",
// string that separates a number from the fractional portion, as in 1.99
".": ".",
// array of numbers indicating the size of each number group.
// TODO: more detailed description and example
groupSizes: [ 3 ],
// symbol used for positive numbers
"+": "+",
// symbol used for negative numbers
"-": "-",
// symbol used for NaN (Not-A-Number)
"NaN": "NaN",
// symbol used for Negative Infinity
negativeInfinity: "-Infinity",
// symbol used for Positive Infinity
positiveInfinity: "Infinity",
percent: {
// [negativePattern, positivePattern]
// negativePattern: one of "-n %|-n%|-%n|%-n|%n-|n-%|n%-|-% n|n %-|% n-|% -n|n- %"
// positivePattern: one of "n %|n%|%n|% n"
pattern: [ "-n %", "n %" ],
// number of decimal places normally shown
decimals: 2,
// array of numbers indicating the size of each number group.
// TODO: more detailed description and example
groupSizes: [ 3 ],
// string that separates number groups, as in 1,000,000
",": ",",
// string that separates a number from the fractional portion, as in 1.99
".": ".",
// symbol used to represent a percentage
symbol: "%"
},
currency: {
// [negativePattern, positivePattern]
// negativePattern: one of "($n)|-$n|$-n|$n-|(n$)|-n$|n-$|n$-|-n $|-$ n|n $-|$ n-|$ -n|n- $|($ n)|(n $)"
// positivePattern: one of "$n|n$|$ n|n $"
pattern: [ "($n)", "$n" ],
// number of decimal places normally shown
decimals: 2,
// array of numbers indicating the size of each number group.
// TODO: more detailed description and example
groupSizes: [ 3 ],
// string that separates number groups, as in 1,000,000
",": ",",
// string that separates a number from the fractional portion, as in 1.99
".": ".",
// symbol used to represent currency
symbol: "$"
}
},
// calendars defines all the possible calendars used by this culture.
// There should be at least one defined with name "standard", and is the default
// calendar used by the culture.
// A calendar contains information about how dates are formatted, information about
// the calendar's eras, a standard set of the date formats,
// translations for day and month names, and if the calendar is not based on the Gregorian
// calendar, conversion functions to and from the Gregorian calendar.
calendars: {
standard: {
// name that identifies the type of calendar this is
name: "Gregorian_USEnglish",
// separator of parts of a date (e.g. "/" in 11/05/1955)
"/": "/",
// separator of parts of a time (e.g. ":" in 05:44 PM)
":": ":",
// the first day of the week (0 = Sunday, 1 = Monday, etc)
firstDay: 0,
days: {
// full day names
names: [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ],
// abbreviated day names
namesAbbr: [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ],
// shortest day names
namesShort: [ "Su", "Mo", "Tu", "We", "Th", "Fr", "Sa" ]
},
months: {
// full month names (13 months for lunar calendards -- 13th month should be "" if not lunar)
names: [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December", "" ],
// abbreviated month names
namesAbbr: [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "" ]
},
// AM and PM designators in one of these forms:
// The usual view, and the upper and lower case versions
// [ standard, lowercase, uppercase ]
// The culture does not use AM or PM (likely all standard date formats use 24 hour time)
// null
AM: [ "AM", "am", "AM" ],
PM: [ "PM", "pm", "PM" ],
eras: [
// eras in reverse chronological order.
// name: the name of the era in this culture (e.g. A.D., C.E.)
// start: when the era starts in ticks (gregorian, gmt), null if it is the earliest supported era.
// offset: offset in years from gregorian calendar
{
"name": "A.D.",
"start": null,
"offset": 0
}
],
// when a two digit year is given, it will never be parsed as a four digit
// year greater than this year (in the appropriate era for the culture)
// Set it as a full year (e.g. 2029) or use an offset format starting from
// the current year: "+19" would correspond to 2029 if the current year 2010.
twoDigitYearMax: 2029,
// set of predefined date and time patterns used by the culture
// these represent the format someone in this culture would expect
// to see given the portions of the date that are shown.
patterns: {
// short date pattern
d: "M/d/yyyy",
// long date pattern
D: "dddd, MMMM dd, yyyy",
// short time pattern
t: "h:mm tt",
// long time pattern
T: "h:mm:ss tt",
// long date, short time pattern
f: "dddd, MMMM dd, yyyy h:mm tt",
// long date, long time pattern
F: "dddd, MMMM dd, yyyy h:mm:ss tt",
// month/day pattern
M: "MMMM dd",
// month/year pattern
Y: "yyyy MMMM",
// S is a sortable format that does not vary by culture
S: "yyyy\u0027-\u0027MM\u0027-\u0027dd\u0027T\u0027HH\u0027:\u0027mm\u0027:\u0027ss"
}
// optional fields for each calendar:
/*
monthsGenitive:
Same as months but used when the day preceeds the month.
Omit if the culture has no genitive distinction in month names.
For an explaination of genitive months, see http://blogs.msdn.com/michkap/archive/2004/12/25/332259.aspx
convert:
Allows for the support of non-gregorian based calendars. This convert object is used to
to convert a date to and from a gregorian calendar date to handle parsing and formatting.
The two functions:
fromGregorian( date )
Given the date as a parameter, return an array with parts [ year, month, day ]
corresponding to the non-gregorian based year, month, and day for the calendar.
toGregorian( year, month, day )
Given the non-gregorian year, month, and day, return a new Date() object
set to the corresponding date in the gregorian calendar.
*/
}
},
// For localized strings
messages: {}
};
Globalize.cultures[ "default" ].calendar = Globalize.cultures[ "default" ].calendars.standard;
Globalize.cultures.en = Globalize.cultures[ "default" ];
Globalize.cultureSelector = "en";
//
// private variables
//
regexHex = /^0x[a-f0-9]+$/i;
regexInfinity = /^[+\-]?infinity$/i;
regexParseFloat = /^[+\-]?\d*\.?\d*(e[+\-]?\d+)?$/;
regexTrim = /^\s+|\s+$/g;
//
// private JavaScript utility functions
//
arrayIndexOf = function( array, item ) {
if ( array.indexOf ) {
return array.indexOf( item );
}
for ( var i = 0, length = array.length; i < length; i++ ) {
if ( array[i] === item ) {
return i;
}
}
return -1;
};
endsWith = function( value, pattern ) {
return value.substr( value.length - pattern.length ) === pattern;
};
extend = function() {
var options, name, src, copy, copyIsArray, clone,
target = arguments[0] || {},
i = 1,
length = arguments.length,
deep = false;
// Handle a deep copy situation
if ( typeof target === "boolean" ) {
deep = target;
target = arguments[1] || {};
// skip the boolean and the target
i = 2;
}
// Handle case when target is a string or something (possible in deep copy)
if ( typeof target !== "object" && !isFunction(target) ) {
target = {};
}
for ( ; i < length; i++ ) {
// Only deal with non-null/undefined values
if ( (options = arguments[ i ]) != null ) {
// Extend the base object
for ( name in options ) {
src = target[ name ];
copy = options[ name ];
// Prevent never-ending loop
if ( target === copy ) {
continue;
}
// Recurse if we're merging plain objects or arrays
if ( deep && copy && ( isObject(copy) || (copyIsArray = isArray(copy)) ) ) {
if ( copyIsArray ) {
copyIsArray = false;
clone = src && isArray(src) ? src : [];
} else {
clone = src && isObject(src) ? src : {};
}
// Never move original objects, clone them
target[ name ] = extend( deep, clone, copy );
// Don't bring in undefined values
} else if ( copy !== undefined ) {
target[ name ] = copy;
}
}
}
}
// Return the modified object
return target;
};
isArray = Array.isArray || function( obj ) {
return Object.prototype.toString.call( obj ) === "[object Array]";
};
isFunction = function( obj ) {
return Object.prototype.toString.call( obj ) === "[object Function]";
};
isObject = function( obj ) {
return Object.prototype.toString.call( obj ) === "[object Object]";
};
startsWith = function( value, pattern ) {
return value.indexOf( pattern ) === 0;
};
trim = function( value ) {
return ( value + "" ).replace( regexTrim, "" );
};
truncate = function( value ) {
if ( isNaN( value ) ) {
return NaN;
}
return Math[ value < 0 ? "ceil" : "floor" ]( value );
};
zeroPad = function( str, count, left ) {
var l;
for ( l = str.length; l < count; l += 1 ) {
str = ( left ? ("0" + str) : (str + "0") );
}
return str;
};
//
// private Globalization utility functions
//
appendPreOrPostMatch = function( preMatch, strings ) {
// appends pre- and post- token match strings while removing escaped characters.
// Returns a single quote count which is used to determine if the token occurs
// in a string literal.
var quoteCount = 0,
escaped = false;
for ( var i = 0, il = preMatch.length; i < il; i++ ) {
var c = preMatch.charAt( i );
switch ( c ) {
case "\'":
if ( escaped ) {
strings.push( "\'" );
}
else {
quoteCount++;
}
escaped = false;
break;
case "\\":
if ( escaped ) {
strings.push( "\\" );
}
escaped = !escaped;
break;
default:
strings.push( c );
escaped = false;
break;
}
}
return quoteCount;
};
expandFormat = function( cal, format ) {
// expands unspecified or single character date formats into the full pattern.
format = format || "F";
var pattern,
patterns = cal.patterns,
len = format.length;
if ( len === 1 ) {
pattern = patterns[ format ];
if ( !pattern ) {
throw "Invalid date format string \'" + format + "\'.";
}
format = pattern;
}
else if ( len === 2 && format.charAt(0) === "%" ) {
// %X escape format -- intended as a custom format string that is only one character, not a built-in format.
format = format.charAt( 1 );
}
return format;
};
formatDate = function( value, format, culture ) {
var cal = culture.calendar,
convert = cal.convert,
ret;
if ( !format || !format.length || format === "i" ) {
if ( culture && culture.name.length ) {
if ( convert ) {
// non-gregorian calendar, so we cannot use built-in toLocaleString()
ret = formatDate( value, cal.patterns.F, culture );
}
else {
var eraDate = new Date( value.getTime() ),
era = getEra( value, cal.eras );
eraDate.setFullYear( getEraYear(value, cal, era) );
ret = eraDate.toLocaleString();
}
}
else {
ret = value.toString();
}
return ret;
}
var eras = cal.eras,
sortable = format === "s";
format = expandFormat( cal, format );
// Start with an empty string
ret = [];
var hour,
zeros = [ "0", "00", "000" ],
foundDay,
checkedDay,
dayPartRegExp = /([^d]|^)(d|dd)([^d]|$)/g,
quoteCount = 0,
tokenRegExp = getTokenRegExp(),
converted;
function padZeros( num, c ) {
var r, s = num + "";
if ( c > 1 && s.length < c ) {
r = ( zeros[c - 2] + s);
return r.substr( r.length - c, c );
}
else {
r = s;
}
return r;
}
function hasDay() {
if ( foundDay || checkedDay ) {
return foundDay;
}
foundDay = dayPartRegExp.test( format );
checkedDay = true;
return foundDay;
}
function getPart( date, part ) {
if ( converted ) {
return converted[ part ];
}
switch ( part ) {
case 0:
return date.getFullYear();
case 1:
return date.getMonth();
case 2:
return date.getDate();
default:
throw "Invalid part value " + part;
}
}
if ( !sortable && convert ) {
converted = convert.fromGregorian( value );
}
for ( ; ; ) {
// Save the current index
var index = tokenRegExp.lastIndex,
// Look for the next pattern
ar = tokenRegExp.exec( format );
// Append the text before the pattern (or the end of the string if not found)
var preMatch = format.slice( index, ar ? ar.index : format.length );
quoteCount += appendPreOrPostMatch( preMatch, ret );
if ( !ar ) {
break;
}
// do not replace any matches that occur inside a string literal.
if ( quoteCount % 2 ) {
ret.push( ar[0] );
continue;
}
var current = ar[ 0 ],
clength = current.length;
switch ( current ) {
case "ddd":
//Day of the week, as a three-letter abbreviation
case "dddd":
// Day of the week, using the full name
var names = ( clength === 3 ) ? cal.days.namesAbbr : cal.days.names;
ret.push( names[value.getDay()] );
break;
case "d":
// Day of month, without leading zero for single-digit days
case "dd":
// Day of month, with leading zero for single-digit days
foundDay = true;
ret.push(
padZeros( getPart(value, 2), clength )
);
break;
case "MMM":
// Month, as a three-letter abbreviation
case "MMMM":
// Month, using the full name
var part = getPart( value, 1 );
ret.push(
( cal.monthsGenitive && hasDay() ) ?
( cal.monthsGenitive[ clength === 3 ? "namesAbbr" : "names" ][ part ] ) :
( cal.months[ clength === 3 ? "namesAbbr" : "names" ][ part ] )
);
break;
case "M":
// Month, as digits, with no leading zero for single-digit months
case "MM":
// Month, as digits, with leading zero for single-digit months
ret.push(
padZeros( getPart(value, 1) + 1, clength )
);
break;
case "y":
// Year, as two digits, but with no leading zero for years less than 10
case "yy":
// Year, as two digits, with leading zero for years less than 10
case "yyyy":
// Year represented by four full digits
part = converted ? converted[ 0 ] : getEraYear( value, cal, getEra(value, eras), sortable );
if ( clength < 4 ) {
part = part % 100;
}
ret.push(
padZeros( part, clength )
);
break;
case "h":
// Hours with no leading zero for single-digit hours, using 12-hour clock
case "hh":
// Hours with leading zero for single-digit hours, using 12-hour clock
hour = value.getHours() % 12;
if ( hour === 0 ) hour = 12;
ret.push(
padZeros( hour, clength )
);
break;
case "H":
// Hours with no leading zero for single-digit hours, using 24-hour clock
case "HH":
// Hours with leading zero for single-digit hours, using 24-hour clock
ret.push(
padZeros( value.getHours(), clength )
);
break;
case "m":
// Minutes with no leading zero for single-digit minutes
case "mm":
// Minutes with leading zero for single-digit minutes
ret.push(
padZeros( value.getMinutes(), clength )
);
break;
case "s":
// Seconds with no leading zero for single-digit seconds
case "ss":
// Seconds with leading zero for single-digit seconds
ret.push(
padZeros( value.getSeconds(), clength )
);
break;
case "t":
// One character am/pm indicator ("a" or "p")
case "tt":
// Multicharacter am/pm indicator
part = value.getHours() < 12 ? ( cal.AM ? cal.AM[0] : " " ) : ( cal.PM ? cal.PM[0] : " " );
ret.push( clength === 1 ? part.charAt(0) : part );
break;
case "f":
// Deciseconds
case "ff":
// Centiseconds
case "fff":
// Milliseconds
ret.push(
padZeros( value.getMilliseconds(), 3 ).substr( 0, clength )
);
break;
case "z":
// Time zone offset, no leading zero
case "zz":
// Time zone offset with leading zero
hour = value.getTimezoneOffset() / 60;
ret.push(
( hour <= 0 ? "+" : "-" ) + padZeros( Math.floor(Math.abs(hour)), clength )
);
break;
case "zzz":
// Time zone offset with leading zero
hour = value.getTimezoneOffset() / 60;
ret.push(
( hour <= 0 ? "+" : "-" ) + padZeros( Math.floor(Math.abs(hour)), 2 ) +
// Hard coded ":" separator, rather than using cal.TimeSeparator
// Repeated here for consistency, plus ":" was already assumed in date parsing.
":" + padZeros( Math.abs(value.getTimezoneOffset() % 60), 2 )
);
break;
case "g":
case "gg":
if ( cal.eras ) {
ret.push(
cal.eras[ getEra(value, eras) ].name
);
}
break;
case "/":
ret.push( cal["/"] );
break;
default:
throw "Invalid date format pattern \'" + current + "\'.";
}
}
return ret.join( "" );
};
// formatNumber
(function() {
var expandNumber;
expandNumber = function( number, precision, formatInfo ) {
var groupSizes = formatInfo.groupSizes,
curSize = groupSizes[ 0 ],
curGroupIndex = 1,
factor = Math.pow( 10, precision ),
rounded = Math.round( number * factor ) / factor;
if ( !isFinite(rounded) ) {
rounded = number;
}
number = rounded;
var numberString = number+"",
right = "",
split = numberString.split( /e/i ),
exponent = split.length > 1 ? parseInt( split[1], 10 ) : 0;
numberString = split[ 0 ];
split = numberString.split( "." );
numberString = split[ 0 ];
right = split.length > 1 ? split[ 1 ] : "";
var l;
if ( exponent > 0 ) {
right = zeroPad( right, exponent, false );
numberString += right.slice( 0, exponent );
right = right.substr( exponent );
}
else if ( exponent < 0 ) {
exponent = -exponent;
numberString = zeroPad( numberString, exponent + 1, true );
right = numberString.slice( -exponent, numberString.length ) + right;
numberString = numberString.slice( 0, -exponent );
}
if ( precision > 0 ) {
right = formatInfo[ "." ] +
( (right.length > precision) ? right.slice(0, precision) : zeroPad(right, precision) );
}
else {
right = "";
}
var stringIndex = numberString.length - 1,
sep = formatInfo[ "," ],
ret = "";
while ( stringIndex >= 0 ) {
if ( curSize === 0 || curSize > stringIndex ) {
return numberString.slice( 0, stringIndex + 1 ) + ( ret.length ? (sep + ret + right) : right );
}
ret = numberString.slice( stringIndex - curSize + 1, stringIndex + 1 ) + ( ret.length ? (sep + ret) : "" );
stringIndex -= curSize;
if ( curGroupIndex < groupSizes.length ) {
curSize = groupSizes[ curGroupIndex ];
curGroupIndex++;
}
}
return numberString.slice( 0, stringIndex + 1 ) + sep + ret + right;
};
formatNumber = function( value, format, culture ) {
if ( !isFinite(value) ) {
if ( value === Infinity ) {
return culture.numberFormat.positiveInfinity;
}
if ( value === -Infinity ) {
return culture.numberFormat.negativeInfinity;
}
return culture.numberFormat[ "NaN" ];
}
if ( !format || format === "i" ) {
return culture.name.length ? value.toLocaleString() : value.toString();
}
format = format || "D";
var nf = culture.numberFormat,
number = Math.abs( value ),
precision = -1,
pattern;
if ( format.length > 1 ) precision = parseInt( format.slice(1), 10 );
var current = format.charAt( 0 ).toUpperCase(),
formatInfo;
switch ( current ) {
case "D":
pattern = "n";
number = truncate( number );
if ( precision !== -1 ) {
number = zeroPad( "" + number, precision, true );
}
if ( value < 0 ) number = "-" + number;
break;
case "N":
formatInfo = nf;
/* falls through */
case "C":
formatInfo = formatInfo || nf.currency;
/* falls through */
case "P":
formatInfo = formatInfo || nf.percent;
pattern = value < 0 ? formatInfo.pattern[ 0 ] : ( formatInfo.pattern[1] || "n" );
if ( precision === -1 ) precision = formatInfo.decimals;
number = expandNumber( number * (current === "P" ? 100 : 1), precision, formatInfo );
break;
default:
throw "Bad number format specifier: " + current;
}
var patternParts = /n|\$|-|%/g,
ret = "";
for ( ; ; ) {
var index = patternParts.lastIndex,
ar = patternParts.exec( pattern );
ret += pattern.slice( index, ar ? ar.index : pattern.length );
if ( !ar ) {
break;
}
switch ( ar[0] ) {
case "n":
ret += number;
break;
case "$":
ret += nf.currency.symbol;
break;
case "-":
// don't make 0 negative
if ( /[1-9]/.test(number) ) {
ret += nf[ "-" ];
}
break;
case "%":
ret += nf.percent.symbol;
break;
}
}
return ret;
};
}());
getTokenRegExp = function() {
// regular expression for matching date and time tokens in format strings.
return (/\/|dddd|ddd|dd|d|MMMM|MMM|MM|M|yyyy|yy|y|hh|h|HH|H|mm|m|ss|s|tt|t|fff|ff|f|zzz|zz|z|gg|g/g);
};
getEra = function( date, eras ) {
if ( !eras ) return 0;
var start, ticks = date.getTime();
for ( var i = 0, l = eras.length; i < l; i++ ) {
start = eras[ i ].start;
if ( start === null || ticks >= start ) {
return i;
}
}
return 0;
};
getEraYear = function( date, cal, era, sortable ) {
var year = date.getFullYear();
if ( !sortable && cal.eras ) {
// convert normal gregorian year to era-shifted gregorian
// year by subtracting the era offset
year -= cal.eras[ era ].offset;
}
return year;
};
// parseExact
(function() {
var expandYear,
getDayIndex,
getMonthIndex,
getParseRegExp,
outOfRange,
toUpper,
toUpperArray;
expandYear = function( cal, year ) {
// expands 2-digit year into 4 digits.
if ( year < 100 ) {
var now = new Date(),
era = getEra( now ),
curr = getEraYear( now, cal, era ),
twoDigitYearMax = cal.twoDigitYearMax;
twoDigitYearMax = typeof twoDigitYearMax === "string" ? new Date().getFullYear() % 100 + parseInt( twoDigitYearMax, 10 ) : twoDigitYearMax;
year += curr - ( curr % 100 );
if ( year > twoDigitYearMax ) {
year -= 100;
}
}
return year;
};
getDayIndex = function ( cal, value, abbr ) {
var ret,
days = cal.days,
upperDays = cal._upperDays;
if ( !upperDays ) {
cal._upperDays = upperDays = [
toUpperArray( days.names ),
toUpperArray( days.namesAbbr ),
toUpperArray( days.namesShort )
];
}
value = toUpper( value );
if ( abbr ) {
ret = arrayIndexOf( upperDays[1], value );
if ( ret === -1 ) {
ret = arrayIndexOf( upperDays[2], value );
}
}
else {
ret = arrayIndexOf( upperDays[0], value );
}
return ret;
};
getMonthIndex = function( cal, value, abbr ) {
var months = cal.months,
monthsGen = cal.monthsGenitive || cal.months,
upperMonths = cal._upperMonths,
upperMonthsGen = cal._upperMonthsGen;
if ( !upperMonths ) {
cal._upperMonths = upperMonths = [
toUpperArray( months.names ),
toUpperArray( months.namesAbbr )
];
cal._upperMonthsGen = upperMonthsGen = [
toUpperArray( monthsGen.names ),
toUpperArray( monthsGen.namesAbbr )
];
}
value = toUpper( value );
var i = arrayIndexOf( abbr ? upperMonths[1] : upperMonths[0], value );
if ( i < 0 ) {
i = arrayIndexOf( abbr ? upperMonthsGen[1] : upperMonthsGen[0], value );
}
return i;
};
getParseRegExp = function( cal, format ) {
// converts a format string into a regular expression with groups that
// can be used to extract date fields from a date string.
// check for a cached parse regex.
var re = cal._parseRegExp;
if ( !re ) {
cal._parseRegExp = re = {};
}
else {
var reFormat = re[ format ];
if ( reFormat ) {
return reFormat;
}
}
// expand single digit formats, then escape regular expression characters.
var expFormat = expandFormat( cal, format ).replace( /([\^\$\.\*\+\?\|\[\]\(\)\{\}])/g, "\\\\$1" ),
regexp = [ "^" ],
groups = [],
index = 0,
quoteCount = 0,
tokenRegExp = getTokenRegExp(),
match;
// iterate through each date token found.
while ( (match = tokenRegExp.exec(expFormat)) !== null ) {
var preMatch = expFormat.slice( index, match.index );
index = tokenRegExp.lastIndex;
// don't replace any matches that occur inside a string literal.
quoteCount += appendPreOrPostMatch( preMatch, regexp );
if ( quoteCount % 2 ) {
regexp.push( match[0] );
continue;
}
// add a regex group for the token.
var m = match[ 0 ],
len = m.length,
add;
switch ( m ) {
case "dddd": case "ddd":
case "MMMM": case "MMM":
case "gg": case "g":
add = "(\\D+)";
break;
case "tt": case "t":
add = "(\\D*)";
break;
case "yyyy":
case "fff":
case "ff":
case "f":
add = "(\\d{" + len + "})";
break;
case "dd": case "d":
case "MM": case "M":
case "yy": case "y":
case "HH": case "H":
case "hh": case "h":
case "mm": case "m":
case "ss": case "s":
add = "(\\d\\d?)";
break;
case "zzz":
add = "([+-]?\\d\\d?:\\d{2})";
break;
case "zz": case "z":
add = "([+-]?\\d\\d?)";
break;
case "/":
add = "(\\/)";
break;
default:
throw "Invalid date format pattern \'" + m + "\'.";
}
if ( add ) {
regexp.push( add );
}
groups.push( match[0] );
}
appendPreOrPostMatch( expFormat.slice(index), regexp );
regexp.push( "$" );
// allow whitespace to differ when matching formats.
var regexpStr = regexp.join( "" ).replace( /\s+/g, "\\s+" ),
parseRegExp = { "regExp": regexpStr, "groups": groups };
// cache the regex for this format.
return re[ format ] = parseRegExp;
};
outOfRange = function( value, low, high ) {
return value < low || value > high;
};
toUpper = function( value ) {
// "he-IL" has non-breaking space in weekday names.
return value.split( "\u00A0" ).join( " " ).toUpperCase();
};
toUpperArray = function( arr ) {
var results = [];
for ( var i = 0, l = arr.length; i < l; i++ ) {
results[ i ] = toUpper( arr[i] );
}
return results;
};
parseExact = function( value, format, culture ) {
// try to parse the date string by matching against the format string
// while using the specified culture for date field names.
value = trim( value );
var cal = culture.calendar,
// convert date formats into regular expressions with groupings.
// use the regexp to determine the input format and extract the date fields.
parseInfo = getParseRegExp( cal, format ),
match = new RegExp( parseInfo.regExp ).exec( value );
if ( match === null ) {
return null;
}
// found a date format that matches the input.
var groups = parseInfo.groups,
era = null, year = null, month = null, date = null, weekDay = null,
hour = 0, hourOffset, min = 0, sec = 0, msec = 0, tzMinOffset = null,
pmHour = false;
// iterate the format groups to extract and set the date fields.
for ( var j = 0, jl = groups.length; j < jl; j++ ) {
var matchGroup = match[ j + 1 ];
if ( matchGroup ) {
var current = groups[ j ],
clength = current.length,
matchInt = parseInt( matchGroup, 10 );
switch ( current ) {
case "dd": case "d":
// Day of month.
date = matchInt;
// check that date is generally in valid range, also checking overflow below.
if ( outOfRange(date, 1, 31) ) return null;
break;
case "MMM": case "MMMM":
month = getMonthIndex( cal, matchGroup, clength === 3 );
if ( outOfRange(month, 0, 11) ) return null;
break;
case "M": case "MM":
// Month.
month = matchInt - 1;
if ( outOfRange(month, 0, 11) ) return null;
break;
case "y": case "yy":
case "yyyy":
year = clength < 4 ? expandYear( cal, matchInt ) : matchInt;
if ( outOfRange(year, 0, 9999) ) return null;
break;
case "h": case "hh":
// Hours (12-hour clock).
hour = matchInt;
if ( hour === 12 ) hour = 0;
if ( outOfRange(hour, 0, 11) ) return null;
break;
case "H": case "HH":
// Hours (24-hour clock).
hour = matchInt;
if ( outOfRange(hour, 0, 23) ) return null;
break;
case "m": case "mm":
// Minutes.
min = matchInt;
if ( outOfRange(min, 0, 59) ) return null;
break;
case "s": case "ss":
// Seconds.
sec = matchInt;
if ( outOfRange(sec, 0, 59) ) return null;
break;
case "tt": case "t":
// AM/PM designator.
// see if it is standard, upper, or lower case PM. If not, ensure it is at least one of
// the AM tokens. If not, fail the parse for this format.
pmHour = cal.PM && ( matchGroup === cal.PM[0] || matchGroup === cal.PM[1] || matchGroup === cal.PM[2] );
if (
!pmHour && (
!cal.AM || ( matchGroup !== cal.AM[0] && matchGroup !== cal.AM[1] && matchGroup !== cal.AM[2] )
)
) return null;
break;
case "f":
// Deciseconds.
case "ff":
// Centiseconds.
case "fff":
// Milliseconds.
msec = matchInt * Math.pow( 10, 3 - clength );
if ( outOfRange(msec, 0, 999) ) return null;
break;
case "ddd":
// Day of week.
case "dddd":
// Day of week.
weekDay = getDayIndex( cal, matchGroup, clength === 3 );
if ( outOfRange(weekDay, 0, 6) ) return null;
break;
case "zzz":
// Time zone offset in +/- hours:min.
var offsets = matchGroup.split( /:/ );
if ( offsets.length !== 2 ) return null;
hourOffset = parseInt( offsets[0], 10 );
if ( outOfRange(hourOffset, -12, 13) ) return null;
var minOffset = parseInt( offsets[1], 10 );
if ( outOfRange(minOffset, 0, 59) ) return null;
tzMinOffset = ( hourOffset * 60 ) + ( startsWith(matchGroup, "-") ? -minOffset : minOffset );
break;
case "z": case "zz":
// Time zone offset in +/- hours.
hourOffset = matchInt;
if ( outOfRange(hourOffset, -12, 13) ) return null;
tzMinOffset = hourOffset * 60;
break;
case "g": case "gg":
var eraName = matchGroup;
if ( !eraName || !cal.eras ) return null;
eraName = trim( eraName.toLowerCase() );
for ( var i = 0, l = cal.eras.length; i < l; i++ ) {
if ( eraName === cal.eras[i].name.toLowerCase() ) {
era = i;
break;
}
}
// could not find an era with that name
if ( era === null ) return null;
break;
}
}
}
var result = new Date(), defaultYear, convert = cal.convert;
defaultYear = convert ? convert.fromGregorian( result )[ 0 ] : result.getFullYear();
if ( year === null ) {
year = defaultYear;
}
else if ( cal.eras ) {
// year must be shifted to normal gregorian year
// but not if year was not specified, its already normal gregorian
// per the main if clause above.
year += cal.eras[( era || 0 )].offset;
}
// set default day and month to 1 and January, so if unspecified, these are the defaults
// instead of the current day/month.
if ( month === null ) {
month = 0;
}
if ( date === null ) {
date = 1;
}
// now have year, month, and date, but in the culture's calendar.
// convert to gregorian if necessary
if ( convert ) {
result = convert.toGregorian( year, month, date );
// conversion failed, must be an invalid match
if ( result === null ) return null;
}
else {
// have to set year, month and date together to avoid overflow based on current date.
result.setFullYear( year, month, date );
// check to see if date overflowed for specified month (only checked 1-31 above).
if ( result.getDate() !== date ) return null;
// invalid day of week.
if ( weekDay !== null && result.getDay() !== weekDay ) {
return null;
}
}
// if pm designator token was found make sure the hours fit the 24-hour clock.
if ( pmHour && hour < 12 ) {
hour += 12;
}
result.setHours( hour, min, sec, msec );
if ( tzMinOffset !== null ) {
// adjust timezone to utc before applying local offset.
var adjustedMin = result.getMinutes() - ( tzMinOffset + result.getTimezoneOffset() );
// Safari limits hours and minutes to the range of -127 to 127. We need to use setHours
// to ensure both these fields will not exceed this range. adjustedMin will range
// somewhere between -1440 and 1500, so we only need to split this into hours.
result.setHours( result.getHours() + parseInt(adjustedMin / 60, 10), adjustedMin % 60 );
}
return result;
};
}());
parseNegativePattern = function( value, nf, negativePattern ) {
var neg = nf[ "-" ],
pos = nf[ "+" ],
ret;
switch ( negativePattern ) {
case "n -":
neg = " " + neg;
pos = " " + pos;
/* falls through */
case "n-":
if ( endsWith(value, neg) ) {
ret = [ "-", value.substr(0, value.length - neg.length) ];
}
else if ( endsWith(value, pos) ) {
ret = [ "+", value.substr(0, value.length - pos.length) ];
}
break;
case "- n":
neg += " ";
pos += " ";
/* falls through */
case "-n":
if ( startsWith(value, neg) ) {
ret = [ "-", value.substr(neg.length) ];
}
else if ( startsWith(value, pos) ) {
ret = [ "+", value.substr(pos.length) ];
}
break;
case "(n)":
if ( startsWith(value, "(") && endsWith(value, ")") ) {
ret = [ "-", value.substr(1, value.length - 2) ];
}
break;
}
return ret || [ "", value ];
};
//
// public instance functions
//
Globalize.prototype.findClosestCulture = function( cultureSelector ) {
return Globalize.findClosestCulture.call( this, cultureSelector );
};
Globalize.prototype.format = function( value, format, cultureSelector ) {
return Globalize.format.call( this, value, format, cultureSelector );
};
Globalize.prototype.localize = function( key, cultureSelector ) {
return Globalize.localize.call( this, key, cultureSelector );
};
Globalize.prototype.parseInt = function( value, radix, cultureSelector ) {
return Globalize.parseInt.call( this, value, radix, cultureSelector );
};
Globalize.prototype.parseFloat = function( value, radix, cultureSelector ) {
return Globalize.parseFloat.call( this, value, radix, cultureSelector );
};
Globalize.prototype.culture = function( cultureSelector ) {
return Globalize.culture.call( this, cultureSelector );
};
//
// public singleton functions
//
Globalize.addCultureInfo = function( cultureName, baseCultureName, info ) {
var base = {},
isNew = false;
if ( typeof cultureName !== "string" ) {
// cultureName argument is optional string. If not specified, assume info is first
// and only argument. Specified info deep-extends current culture.
info = cultureName;
cultureName = this.culture().name;
base = this.cultures[ cultureName ];
} else if ( typeof baseCultureName !== "string" ) {
// baseCultureName argument is optional string. If not specified, assume info is second
// argument. Specified info deep-extends specified culture.
// If specified culture does not exist, create by deep-extending default
info = baseCultureName;
isNew = ( this.cultures[ cultureName ] == null );
base = this.cultures[ cultureName ] || this.cultures[ "default" ];
} else {
// cultureName and baseCultureName specified. Assume a new culture is being created
// by deep-extending an specified base culture
isNew = true;
base = this.cultures[ baseCultureName ];
}
this.cultures[ cultureName ] = extend(true, {},
base,
info
);
// Make the standard calendar the current culture if it's a new culture
if ( isNew ) {
this.cultures[ cultureName ].calendar = this.cultures[ cultureName ].calendars.standard;
}
};
Globalize.findClosestCulture = function( name ) {
var match;
if ( !name ) {
return this.findClosestCulture( this.cultureSelector ) || this.cultures[ "default" ];
}
if ( typeof name === "string" ) {
name = name.split( "," );
}
if ( isArray(name) ) {
var lang,
cultures = this.cultures,
list = name,
i, l = list.length,
prioritized = [];
for ( i = 0; i < l; i++ ) {
name = trim( list[i] );
var pri, parts = name.split( ";" );
lang = trim( parts[0] );
if ( parts.length === 1 ) {
pri = 1;
}
else {
name = trim( parts[1] );
if ( name.indexOf("q=") === 0 ) {
name = name.substr( 2 );
pri = parseFloat( name );
pri = isNaN( pri ) ? 0 : pri;
}
else {
pri = 1;
}
}
prioritized.push({ lang: lang, pri: pri });
}
prioritized.sort(function( a, b ) {
if ( a.pri < b.pri ) {
return 1;
} else if ( a.pri > b.pri ) {
return -1;
}
return 0;
});
// exact match
for ( i = 0; i < l; i++ ) {
lang = prioritized[ i ].lang;
match = cultures[ lang ];
if ( match ) {
return match;
}
}
// neutral language match
for ( i = 0; i < l; i++ ) {
lang = prioritized[ i ].lang;
do {
var index = lang.lastIndexOf( "-" );
if ( index === -1 ) {
break;
}
// strip off the last part. e.g. en-US => en
lang = lang.substr( 0, index );
match = cultures[ lang ];
if ( match ) {
return match;
}
}
while ( 1 );
}
// last resort: match first culture using that language
for ( i = 0; i < l; i++ ) {
lang = prioritized[ i ].lang;
for ( var cultureKey in cultures ) {
var culture = cultures[ cultureKey ];
if ( culture.language == lang ) {
return culture;
}
}
}
}
else if ( typeof name === "object" ) {
return name;
}
return match || null;
};
Globalize.format = function( value, format, cultureSelector ) {
var culture = this.findClosestCulture( cultureSelector );
if ( value instanceof Date ) {
value = formatDate( value, format, culture );
}
else if ( typeof value === "number" ) {
value = formatNumber( value, format, culture );
}
return value;
};
Globalize.localize = function( key, cultureSelector ) {
return this.findClosestCulture( cultureSelector ).messages[ key ] ||
this.cultures[ "default" ].messages[ key ];
};
Globalize.parseDate = function( value, formats, culture ) {
culture = this.findClosestCulture( culture );
var date, prop, patterns;
if ( formats ) {
if ( typeof formats === "string" ) {
formats = [ formats ];
}
if ( formats.length ) {
for ( var i = 0, l = formats.length; i < l; i++ ) {
var format = formats[ i ];
if ( format ) {
date = parseExact( value, format, culture );
if ( date ) {
break;
}
}
}
}
} else {
patterns = culture.calendar.patterns;
for ( prop in patterns ) {
date = parseExact( value, patterns[prop], culture );
if ( date ) {
break;
}
}
}
return date || null;
};
Globalize.parseInt = function( value, radix, cultureSelector ) {
return truncate( Globalize.parseFloat(value, radix, cultureSelector) );
};
Globalize.parseFloat = function( value, radix, cultureSelector ) {
// radix argument is optional
if ( typeof radix !== "number" ) {
cultureSelector = radix;
radix = 10;
}
var culture = this.findClosestCulture( cultureSelector );
var ret = NaN,
nf = culture.numberFormat;
if ( value.indexOf(culture.numberFormat.currency.symbol) > -1 ) {
// remove currency symbol
value = value.replace( culture.numberFormat.currency.symbol, "" );
// replace decimal seperator
value = value.replace( culture.numberFormat.currency["."], culture.numberFormat["."] );
}
//Remove percentage character from number string before parsing
if ( value.indexOf(culture.numberFormat.percent.symbol) > -1){
value = value.replace( culture.numberFormat.percent.symbol, "" );
}
// remove spaces: leading, trailing and between - and number. Used for negative currency pt-BR
value = value.replace( / /g, "" );
// allow infinity or hexidecimal
if ( regexInfinity.test(value) ) {
ret = parseFloat( value );
}
else if ( !radix && regexHex.test(value) ) {
ret = parseInt( value, 16 );
}
else {
// determine sign and number
var signInfo = parseNegativePattern( value, nf, nf.pattern[0] ),
sign = signInfo[ 0 ],
num = signInfo[ 1 ];
// #44 - try parsing as "(n)"
if ( sign === "" && nf.pattern[0] !== "(n)" ) {
signInfo = parseNegativePattern( value, nf, "(n)" );
sign = signInfo[ 0 ];
num = signInfo[ 1 ];
}
// try parsing as "-n"
if ( sign === "" && nf.pattern[0] !== "-n" ) {
signInfo = parseNegativePattern( value, nf, "-n" );
sign = signInfo[ 0 ];
num = signInfo[ 1 ];
}
sign = sign || "+";
// determine exponent and number
var exponent,
intAndFraction,
exponentPos = num.indexOf( "e" );
if ( exponentPos < 0 ) exponentPos = num.indexOf( "E" );
if ( exponentPos < 0 ) {
intAndFraction = num;
exponent = null;
}
else {
intAndFraction = num.substr( 0, exponentPos );
exponent = num.substr( exponentPos + 1 );
}
// determine decimal position
var integer,
fraction,
decSep = nf[ "." ],
decimalPos = intAndFraction.indexOf( decSep );
if ( decimalPos < 0 ) {
integer = intAndFraction;
fraction = null;
}
else {
integer = intAndFraction.substr( 0, decimalPos );
fraction = intAndFraction.substr( decimalPos + decSep.length );
}
// handle groups (e.g. 1,000,000)
var groupSep = nf[ "," ];
integer = integer.split( groupSep ).join( "" );
var altGroupSep = groupSep.replace( /\u00A0/g, " " );
if ( groupSep !== altGroupSep ) {
integer = integer.split( altGroupSep ).join( "" );
}
// build a natively parsable number string
var p = sign + integer;
if ( fraction !== null ) {
p += "." + fraction;
}
if ( exponent !== null ) {
// exponent itself may have a number patternd
var expSignInfo = parseNegativePattern( exponent, nf, "-n" );
p += "e" + ( expSignInfo[0] || "+" ) + expSignInfo[ 1 ];
}
if ( regexParseFloat.test(p) ) {
ret = parseFloat( p );
}
}
return ret;
};
Globalize.culture = function( cultureSelector ) {
// setter
if ( typeof cultureSelector !== "undefined" ) {
this.cultureSelector = cultureSelector;
}
// getter
return this.findClosestCulture( cultureSelector ) || this.cultures[ "default" ];
};
}( this ));
/**
* Globalize v1.3.0
*
* http://github.com/jquery/globalize
*
* Copyright 2010, 2014 jQuery Foundation, Inc. and other contributors
* Released under the MIT license
* http://jquery.org/license
*
* Date: 2017-07-03T21:37Z
*/
/*!
* Globalize v1.3.0 2017-07-03T21:37Z Released under the MIT license
* http://git.io/TrdQbw
*/
(function( root, factory ) {
// UMD returnExports
if ( typeof define === "function" && define.amd ) {
// AMD
define([
"cldr",
"../globalize",
"./number",
"./plural"
], factory );
} else if ( typeof exports === "object" ) {
// Node, CommonJS
module.exports = factory( require( "cldrjs" ), require( "../globalize" ) );
} else {
// Extend global
factory( root.Cldr, root.Globalize );
}
}(this, function( Cldr, Globalize ) {
var formatMessage = Globalize._formatMessage,
runtimeBind = Globalize._runtimeBind,
validateParameterPresence = Globalize._validateParameterPresence,
validateParameterTypePlainObject = Globalize._validateParameterTypePlainObject,
validateParameterTypeNumber = Globalize._validateParameterTypeNumber,
validateParameterTypeString = Globalize._validateParameterTypeString;
/**
* format( value, numberFormatter, pluralGenerator, unitProperies )
*
* @value [Number]
*
* @numberFormatter [Object]: A numberFormatter from Globalize.numberFormatter.
*
* @pluralGenerator [Object]: A pluralGenerator from Globalize.pluralGenerator.
*
* @unitProperies [Object]: localized unit data from cldr.
*
* Format units such as seconds, minutes, days, weeks, etc.
*
* OBS:
*
* Unit Sequences are not implemented.
* http://www.unicode.org/reports/tr35/tr35-35/tr35-general.html#Unit_Sequences
*
* Duration Unit (for composed time unit durations) is not implemented.
* http://www.unicode.org/reports/tr35/tr35-35/tr35-general.html#durationUnit
*/
var unitFormat = function( value, numberFormatter, pluralGenerator, unitProperties ) {
var compoundUnitPattern = unitProperties.compoundUnitPattern, dividend, dividendProperties,
formattedValue, divisor, divisorProperties, message, pluralValue;
unitProperties = unitProperties.unitProperties;
formattedValue = numberFormatter( value );
pluralValue = pluralGenerator( value );
// computed compound unit, eg. "megabyte-per-second".
if ( unitProperties instanceof Array ) {
dividendProperties = unitProperties[ 0 ];
divisorProperties = unitProperties[ 1 ];
dividend = formatMessage( dividendProperties[ pluralValue ], [ value ] );
divisor = formatMessage( divisorProperties.one, [ "" ] ).trim();
return formatMessage( compoundUnitPattern, [ dividend, divisor ] );
}
message = unitProperties[ pluralValue ];
return formatMessage( message, [ formattedValue ] );
};
var unitFormatterFn = function( numberFormatter, pluralGenerator, unitProperties ) {
return function unitFormatter( value ) {
validateParameterPresence( value, "value" );
validateParameterTypeNumber( value, "value" );
return unitFormat( value, numberFormatter, pluralGenerator, unitProperties );
};
};
/**
* categories()
*
* Return all unit categories.
*/
var unitCategories = [ "acceleration", "angle", "area", "digital", "duration", "length", "mass", "power",
"pressure", "speed", "temperature", "volume" ];
function stripPluralGarbage( data ) {
var aux, pluralCount;
if ( data ) {
aux = {};
for ( pluralCount in data ) {
aux[ pluralCount.replace( /unitPattern-count-/, "" ) ] = data[ pluralCount ];
}
}
return aux;
}
/**
* get( unit, form, cldr )
*
* @unit [String] The full type-unit name (eg. duration-second), or the short unit name
* (eg. second).
*
* @form [String] A string describing the form of the unit representation (eg. long,
* short, narrow).
*
* @cldr [Cldr instance].
*
* Return the plural map of a unit, eg: "second"
* { "one": "{0} second",
* "other": "{0} seconds" }
* }
*
* Or the Array of plural maps of a compound-unit, eg: "foot-per-second"
* [ { "one": "{0} foot",
* "other": "{0} feet" },
* { "one": "{0} second",
* "other": "{0} seconds" } ]
*
* Uses the precomputed form of a compound-unit if available, eg: "mile-per-hour"
* { "displayName": "miles per hour",
* "unitPattern-count-one": "{0} mile per hour",
* "unitPattern-count-other": "{0} miles per hour"
* },
*
* Also supports "/" instead of "-per-", eg. "foot/second", using the precomputed form if
* available.
*
* Or the Array of plural maps of a compound-unit, eg: "foot-per-second"
* [ { "one": "{0} foot",
* "other": "{0} feet" },
* { "one": "{0} second",
* "other": "{0} seconds" } ]
*
* Or undefined in case the unit (or a unit of the compound-unit) doesn't exist.
*/
var get = function( unit, form, cldr ) {
var ret;
// Ensure that we get the 'precomputed' form, if present.
unit = unit.replace( /\//, "-per-" );
// Get unit or -unit (eg. "duration-second").
[ "" ].concat( unitCategories ).some(function( category ) {
return ret = cldr.main([
"units",
form,
category.length ? category + "-" + unit : unit
]);
});
// Rename keys s/unitPattern-count-//g.
ret = stripPluralGarbage( ret );
// Compound Unit, eg. "foot-per-second" or "foot/second".
if ( !ret && ( /-per-/ ).test( unit ) ) {
// "Some units already have 'precomputed' forms, such as kilometer-per-hour;
// where such units exist, they should be used in preference" UTS#35.
// Note that precomputed form has already been handled above (!ret).
// Get both recursively.
unit = unit.split( "-per-" );
ret = unit.map(function( unit ) {
return get( unit, form, cldr );
});
if ( !ret[ 0 ] || !ret[ 1 ] ) {
return;
}
}
return ret;
};
var unitGet = get;
/**
* properties( unit, form, cldr )
*
* @unit [String] The full type-unit name (eg. duration-second), or the short unit name
* (eg. second).
*
* @form [String] A string describing the form of the unit representation (eg. long,
* short, narrow).
*
* @cldr [Cldr instance].
*/
var unitProperties = function( unit, form, cldr ) {
var compoundUnitPattern, unitProperties;
compoundUnitPattern = cldr.main( [ "units", form, "per/compoundUnitPattern" ] );
unitProperties = unitGet( unit, form, cldr );
return {
compoundUnitPattern: compoundUnitPattern,
unitProperties: unitProperties
};
};
/**
* Globalize.formatUnit( value, unit, options )
*
* @value [Number]
*
* @unit [String]: The unit (e.g "second", "day", "year")
*
* @options [Object]
* - form: [String] "long", "short" (default), or "narrow".
*
* Format units such as seconds, minutes, days, weeks, etc.
*/
Globalize.formatUnit =
Globalize.prototype.formatUnit = function( value, unit, options ) {
validateParameterPresence( value, "value" );
validateParameterTypeNumber( value, "value" );
return this.unitFormatter( unit, options )( value );
};
/**
* Globalize.unitFormatter( unit, options )
*
* @unit [String]: The unit (e.g "second", "day", "year")
*
* @options [Object]
* - form: [String] "long", "short" (default), or "narrow".
*
* - numberFormatter: [Function] a number formatter function. Defaults to Globalize
* `.numberFormatter()` for the current locale using the default options.
*/
Globalize.unitFormatter =
Globalize.prototype.unitFormatter = function( unit, options ) {
var args, form, numberFormatter, pluralGenerator, returnFn, properties;
validateParameterPresence( unit, "unit" );
validateParameterTypeString( unit, "unit" );
validateParameterTypePlainObject( options, "options" );
options = options || {};
args = [ unit, options ];
form = options.form || "long";
properties = unitProperties( unit, form, this.cldr );
numberFormatter = options.numberFormatter || this.numberFormatter();
pluralGenerator = this.pluralGenerator();
returnFn = unitFormatterFn( numberFormatter, pluralGenerator, properties );
runtimeBind( args, this.cldr, returnFn, [ numberFormatter, pluralGenerator, properties ] );
return returnFn;
};
return Globalize;
}));
/*
* Globalize Culture fr-FR
*
* http://github.com/jquery/globalize
*
* Copyright Software Freedom Conservancy, Inc.
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* This file was generated by the Globalize Culture Generator
* Translation: bugs found in this file need to be fixed in the generator
*/
(function( window, undefined ) {
var Globalize;
if ( typeof require !== "undefined" &&
typeof exports !== "undefined" &&
typeof module !== "undefined" ) {
// Assume CommonJS
Globalize = require( "globalize" );
} else {
// Global variable
Globalize = window.Globalize;
}
Globalize.addCultureInfo( "fr-FR", "default", {
name: "fr-FR",
englishName: "French (France)",
nativeName: "français (France)",
language: "fr",
numberFormat: {
",": " ",
".": ",",
"NaN": "Non Numérique",
negativeInfinity: "-Infini",
positiveInfinity: "+Infini",
percent: {
",": " ",
".": ","
},
currency: {
pattern: ["-n $","n $"],
",": " ",
".": ",",
symbol: "€"
}
},
calendars: {
standard: {
firstDay: 1,
days: {
names: ["dimanche","lundi","mardi","mercredi","jeudi","vendredi","samedi"],
namesAbbr: ["dim.","lun.","mar.","mer.","jeu.","ven.","sam."],
namesShort: ["di","lu","ma","me","je","ve","sa"]
},
months: {
names: ["janvier","février","mars","avril","mai","juin","juillet","août","septembre","octobre","novembre","décembre",""],
namesAbbr: ["janv.","févr.","mars","avr.","mai","juin","juil.","août","sept.","oct.","nov.","déc.",""]
},
AM: null,
PM: null,
eras: [{"name":"ap. J.-C.","start":null,"offset":0}],
patterns: {
d: "dd/MM/yyyy",
D: "dddd d MMMM yyyy",
t: "HH:mm",
T: "HH:mm:ss",
f: "dddd d MMMM yyyy HH:mm",
F: "dddd d MMMM yyyy HH:mm:ss",
M: "d MMMM",
Y: "MMMM yyyy"
}
}
}
});
}( this ));
/*
* Globalize Culture en-US
*
* http://github.com/jquery/globalize
*
* Copyright Software Freedom Conservancy, Inc.
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* This file was generated by the Globalize Culture Generator
* Translation: bugs found in this file need to be fixed in the generator
*/
(function( window, undefined ) {
var Globalize;
if ( typeof require !== "undefined" &&
typeof exports !== "undefined" &&
typeof module !== "undefined" ) {
// Assume CommonJS
Globalize = require( "globalize" );
} else {
// Global variable
Globalize = window.Globalize;
}
Globalize.addCultureInfo( "en-US", "default", {
name: "en-US",
englishName: "English (United States)"
});
}( this ));
/*
** validation personnalisée
*/
(function ($) {
//$.validator.methods.range = function (value, element, param) {
// var globalizedValue = value.replace(",", ".");
// return this.optional(element) || (globalizedValue >= param[0] && globalizedValue <= param[1]);
//}
//$.validator.methods.number = function (value, element) {
// return this.optional(element) || /^-?(?:\d+|\d{1,3}(?:[\s\.,]\d{3})+)(?:[\.,]\d+)?$/.test(value);
//}
$.validator.methods.number = function (value, element) {
var val = Globalize.parseFloat(value);
return this.optional(element) || ($.isNumeric(val));
};
$.validator.addMethod("pwcheck", function (value) {
return /^(?=.*[A-Z])(?=.*[a-z])(?=.*\d)(\S){8,}$/.test(value)
}, "Wrong value");
$.validator.addMethod("notEqualTo", function (value, element, param) {
return this.optional(element) || value != $(param).val();
}, "Please specify a different (non-default) value");
$.validator.addMethod('date',function (value, element) {
if (this.optional(element)) {
return true;
}
var ok = true;
try {
$.datepicker.parseDate('dd/mm/yy', value);
}
catch (err) {
ok = false;
}
return ok;
});
//$(".dateonly").datepicker({ dateFormat: 'dd/mm/yy', changeYear: true });
//requiredIf
$.validator.addMethod('requiredif', function (value, element, parameters) {
// get the target value (as a string,
// as that's what actual value will be)
var targetvalue = parameters['targetvalue'];
var input = 'input[name=' + parameters['mandatoryproperty'] + '][value=' + targetvalue + ']';
targetvalue = (targetvalue == null ? '' : targetvalue);
// get the actual value of the target control
// note - this probably needs to cater for more
// control types, e.g. radios
var control = $(input);
if (control.length == 0) {
control = $('#' + parameters['mandatoryproperty'] + '');
}
var controltype = control.attr('type');
var actualvalue = null;
if (controltype === 'radio' && control.is(':checked')) {
actualvalue = control.val();
} else if (controltype === 'checkbox' && control.is(':checked')) {
actualvalue = control.val();
}
// if the condition is true, reuse the existing
// required field validator functionality
if (targetvalue === actualvalue) {
return $.validator.methods.required.call(this, value, element, parameters);
}
return true;
});
$.validator.unobtrusive.adapters.add('requiredif', ['mandatoryproperty', 'targetvalue'],function (options) {
options.rules['requiredif'] = {
mandatoryproperty: options.params['mandatoryproperty'],
targetvalue: options.params['targetvalue']
};
options.messages['requiredif'] = options.message;
});
//Fin section RequiredIf
//isDateAfter
$.validator.addMethod("isdateafter", function (value, element, params) {
var parts = element.name.split(".");
var prefix = "";
if (parts.length > 1)
prefix = parts[0] + ".";
var startdatevalue = $('input[name="' + prefix + params.propertytested + '"]').val();
if (!value || !startdatevalue)
return true;
return Globalize.parseDate(value, "dd/MM/yyyy HH:mm") > Globalize.parseDate(startdatevalue, "dd/MM/yyyy HH:mm");
});
$.validator.unobtrusive.adapters.add('isdateafter', ['propertytested', 'allowequaldates'], function (options) {
options.rules['isdateafter'] = options.params;
options.messages['isdateafter'] = options.message;
});
//Fin section isDateAfter
}(jQuery));
/* ----- methods_fr.js ----- */
/*
* Localized default methods for the jQuery validation plugin.
* Locale: FR
*/
jQuery.extend(jQuery.validator.methods, {
min: function (value, element, param) {
return this.optional(element) || replaceComma(value) >= replaceComma(param);
},
max: function (value, element, param) {
return this.optional(element) || replaceComma(value) <= replaceComma(param);
},
range: function (value, element, param) {
value = replaceComma(value);
return this.optional(element) || (value >= replaceComma(param[0]) && value <= replaceComma(param[1]));
},
date: function (value, element) {
return this.optional(element) || /^\d\d?\.\d\d?\.\d\d\d?\d?$/.test(value);
},
number: function (value, element) {
return this.optional(element) || /^-?(?:\d+|\d{1,3}(?:\.\d{3})+)(?:,\d+)?$/.test(value);
}
});
function replaceComma(value) {
// Quick & Dirty replace "," by "." as decimal separators
if (value.toString().indexOf(",")<0) {
return value;
}
else return value.replace(",", ".");
}