embeddedaichatux 1.0.0 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AIChat.npm.csproj +8 -7
- package/EmbeddedChat.js +15 -2
- package/bin/Debug/net7.0/AIChat.npm.deps.json +23 -0
- package/bin/Debug/net7.0/AIChat.npm.dll +0 -0
- package/bin/Debug/net7.0/AIChat.npm.exe +0 -0
- package/bin/Debug/net7.0/AIChat.npm.pdb +0 -0
- package/bin/Debug/net7.0/AIChat.npm.runtimeconfig.json +19 -0
- package/bin/Debug/net7.0/AIChat.npm.staticwebassets.runtime.json +1 -0
- package/bin/Debug/net7.0/appsettings.Development.json +9 -0
- package/bin/Debug/net7.0/appsettings.json +9 -0
- package/bin/Debug/net7.0/package.json +11 -0
- package/obj/Debug/net7.0/AIChat.npm.GeneratedMSBuildEditorConfig.editorconfig +0 -28
- package/obj/Debug/net7.0/AIChat.npm.MvcApplicationPartsAssemblyInfo.cache +0 -0
- package/obj/Debug/net7.0/AIChat.npm.csproj.CoreCompileInputs.cache +1 -0
- package/obj/Debug/net7.0/AIChat.npm.csproj.FileListAbsolute.txt +27 -0
- package/obj/Debug/net7.0/AIChat.npm.dll +0 -0
- package/obj/Debug/net7.0/AIChat.npm.genruntimeconfig.cache +1 -0
- package/obj/Debug/net7.0/AIChat.npm.pdb +0 -0
- package/obj/Debug/net7.0/apphost.exe +0 -0
- package/obj/Debug/net7.0/project.razor.vs.json +1 -1
- package/obj/Debug/net7.0/ref/AIChat.npm.dll +0 -0
- package/obj/Debug/net7.0/refint/AIChat.npm.dll +0 -0
- package/obj/Debug/net7.0/staticwebassets/msbuild.build.AIChat.npm.props +3 -0
- package/obj/Debug/net7.0/staticwebassets/msbuild.buildMultiTargeting.AIChat.npm.props +3 -0
- package/obj/Debug/net7.0/staticwebassets/msbuild.buildTransitive.AIChat.npm.props +3 -0
- package/obj/Debug/net7.0/staticwebassets.build.json +19 -0
- package/obj/Debug/net7.0/staticwebassets.development.json +1 -0
- package/obj/Release/net7.0/.NETCoreApp,Version=v7.0.AssemblyAttributes.cs +4 -0
- package/obj/Release/net7.0/AIChat.npm.AssemblyInfo.cs +23 -0
- package/obj/Release/net7.0/AIChat.npm.AssemblyInfoInputs.cache +1 -0
- package/obj/Release/net7.0/AIChat.npm.GeneratedMSBuildEditorConfig.editorconfig +17 -0
- package/obj/Release/net7.0/AIChat.npm.GlobalUsings.g.cs +17 -0
- package/obj/Release/net7.0/AIChat.npm.assets.cache +0 -0
- package/package.json +1 -1
- package/Pages/Error.cshtml +0 -26
- package/Pages/Error.cshtml.cs +0 -27
- package/Pages/Index.cshtml +0 -10
- package/Pages/Index.cshtml.cs +0 -20
- package/Pages/Privacy.cshtml +0 -8
- package/Pages/Privacy.cshtml.cs +0 -19
- package/Pages/Shared/_Layout.cshtml +0 -51
- package/Pages/Shared/_Layout.cshtml.css +0 -48
- package/Pages/Shared/_ValidationScriptsPartial.cshtml +0 -2
- package/Pages/_ViewImports.cshtml +0 -3
- package/Pages/_ViewStart.cshtml +0 -3
- package/wwwroot/css/site.css +0 -22
- package/wwwroot/favicon.ico +0 -0
- package/wwwroot/js/site.js +0 -4
- package/wwwroot/lib/bootstrap/LICENSE +0 -22
- package/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.css +0 -4997
- package/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.css.map +0 -1
- package/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.min.css +0 -7
- package/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.min.css.map +0 -1
- package/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.rtl.css +0 -4996
- package/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.rtl.css.map +0 -1
- package/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.rtl.min.css +0 -7
- package/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.rtl.min.css.map +0 -1
- package/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.css +0 -427
- package/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.css.map +0 -1
- package/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.min.css +0 -8
- package/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.min.css.map +0 -1
- package/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.rtl.css +0 -424
- package/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.rtl.css.map +0 -1
- package/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.rtl.min.css +0 -8
- package/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.rtl.min.css.map +0 -1
- package/wwwroot/lib/bootstrap/dist/css/bootstrap-utilities.css +0 -4866
- package/wwwroot/lib/bootstrap/dist/css/bootstrap-utilities.css.map +0 -1
- package/wwwroot/lib/bootstrap/dist/css/bootstrap-utilities.min.css +0 -7
- package/wwwroot/lib/bootstrap/dist/css/bootstrap-utilities.min.css.map +0 -1
- package/wwwroot/lib/bootstrap/dist/css/bootstrap-utilities.rtl.css +0 -4857
- package/wwwroot/lib/bootstrap/dist/css/bootstrap-utilities.rtl.css.map +0 -1
- package/wwwroot/lib/bootstrap/dist/css/bootstrap-utilities.rtl.min.css +0 -7
- package/wwwroot/lib/bootstrap/dist/css/bootstrap-utilities.rtl.min.css.map +0 -1
- package/wwwroot/lib/bootstrap/dist/css/bootstrap.css +0 -11221
- package/wwwroot/lib/bootstrap/dist/css/bootstrap.css.map +0 -1
- package/wwwroot/lib/bootstrap/dist/css/bootstrap.min.css +0 -7
- package/wwwroot/lib/bootstrap/dist/css/bootstrap.min.css.map +0 -1
- package/wwwroot/lib/bootstrap/dist/css/bootstrap.rtl.css +0 -11197
- package/wwwroot/lib/bootstrap/dist/css/bootstrap.rtl.css.map +0 -1
- package/wwwroot/lib/bootstrap/dist/css/bootstrap.rtl.min.css +0 -7
- package/wwwroot/lib/bootstrap/dist/css/bootstrap.rtl.min.css.map +0 -1
- package/wwwroot/lib/bootstrap/dist/js/bootstrap.bundle.js +0 -6780
- package/wwwroot/lib/bootstrap/dist/js/bootstrap.bundle.js.map +0 -1
- package/wwwroot/lib/bootstrap/dist/js/bootstrap.bundle.min.js +0 -7
- package/wwwroot/lib/bootstrap/dist/js/bootstrap.bundle.min.js.map +0 -1
- package/wwwroot/lib/bootstrap/dist/js/bootstrap.esm.js +0 -4977
- package/wwwroot/lib/bootstrap/dist/js/bootstrap.esm.js.map +0 -1
- package/wwwroot/lib/bootstrap/dist/js/bootstrap.esm.min.js +0 -7
- package/wwwroot/lib/bootstrap/dist/js/bootstrap.esm.min.js.map +0 -1
- package/wwwroot/lib/bootstrap/dist/js/bootstrap.js +0 -5026
- package/wwwroot/lib/bootstrap/dist/js/bootstrap.js.map +0 -1
- package/wwwroot/lib/bootstrap/dist/js/bootstrap.min.js +0 -7
- package/wwwroot/lib/bootstrap/dist/js/bootstrap.min.js.map +0 -1
- package/wwwroot/lib/jquery/LICENSE.txt +0 -21
- package/wwwroot/lib/jquery/dist/jquery.js +0 -10881
- package/wwwroot/lib/jquery/dist/jquery.min.js +0 -2
- package/wwwroot/lib/jquery/dist/jquery.min.map +0 -1
- package/wwwroot/lib/jquery-validation/LICENSE.md +0 -22
- package/wwwroot/lib/jquery-validation/dist/additional-methods.js +0 -1158
- package/wwwroot/lib/jquery-validation/dist/additional-methods.min.js +0 -4
- package/wwwroot/lib/jquery-validation/dist/jquery.validate.js +0 -1601
- package/wwwroot/lib/jquery-validation/dist/jquery.validate.min.js +0 -4
- package/wwwroot/lib/jquery-validation-unobtrusive/LICENSE.txt +0 -23
- package/wwwroot/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.js +0 -435
- package/wwwroot/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js +0 -8
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/*! jQuery Validation Plugin - v1.17.0 - 7/29/2017
|
|
2
|
-
* https://jqueryvalidation.org/
|
|
3
|
-
* Copyright (c) 2017 Jörn Zaefferer; Licensed MIT */
|
|
4
|
-
!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof module&&module.exports?module.exports=a(require("jquery")):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.submitButton=b.currentTarget,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.submitButton&&(c.settings.submitHandler||c.formSubmitted)&&(d=a("<input type='hidden'/>").attr("name",c.submitButton.name).val(a(c.submitButton).val()).appendTo(c.currentForm)),!c.settings.submitHandler||(e=c.settings.submitHandler.call(c,c.currentForm,b),d&&d.remove(),void 0!==e&&e)}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,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(null!=j&&(!j.form&&j.hasAttribute("contenteditable")&&(j.form=this.closest("form")[0],j.name=this.attr("name")),null!=j.form)){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(a,b){i[b]=f[b],delete f[b]}),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)),g.remote&&(h=g.remote,delete g.remote,g=a.extend(g,{remote:h})),g}}}),a.extend(a.expr.pseudos||a.expr[":"],{blank:function(b){return!a.trim(""+a(b).val())},filled:function(b){var c=a(b).val();return null!==c&&!!a.trim(""+c)},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)}:void 0===c?b:(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",pendingClass:"pending",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)||a.inArray(c.keyCode,d)!==-1||(b.name in this.submitted||b.name in this.invalid)&&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.",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}."),step:a.validator.format("Please enter a multiple of {0}.")},autoCreateRanges:!1,prototype:{init:function(){function b(b){!this.form&&this.hasAttribute("contenteditable")&&(this.form=a(this).closest("form")[0],this.name=a(this).attr("name"));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'], [contenteditable], [type='button']",b).on("click.validate","select, option, [type='radio'], [type='checkbox']",b),this.settings.invalidHandler&&a(this.currentForm).on("invalid-form.validate",this.settings.invalidHandler)},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,d,e=this.clean(b),f=this.validationTargetFor(e),g=this,h=!0;return void 0===f?delete this.invalid[e.name]:(this.prepareElement(f),this.currentElements=a(f),d=this.groups[f.name],d&&a.each(this.groups,function(a,b){b===d&&a!==f.name&&(e=g.validationTargetFor(g.clean(g.findByName(a))),e&&e.name in g.invalid&&(g.currentElements.push(e),h=g.check(e)&&h))}),c=this.check(f)!==!1,h=h&&c,c?this.invalid[f.name]=!1:this.invalid[f.name]=!0,this.numberOfInvalids()||(this.toHide=this.toHide.add(this.containers)),this.showErrors(),a(b).attr("aria-invalid",!c)),h},showErrors:function(b){if(b){var c=this;a.extend(this.errorMap,b),this.errorList=a.map(this.errorMap,function(a,b){return{message:a,element:c.findByName(b)[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.invalid={},this.submitted={},this.prepareForm(),this.hideErrors();var b=this.elements().removeData("previousValue").removeAttr("aria-invalid");this.resetElements(b)},resetElements:function(a){var b;if(this.settings.unhighlight)for(b=0;a[b];b++)this.settings.unhighlight.call(this,a[b],this.settings.errorClass,""),this.findByName(a[b].name).removeClass(this.settings.validClass);else a.removeClass(this.settings.errorClass).removeClass(this.settings.validClass)},numberOfInvalids:function(){return this.objectLength(this.invalid)},objectLength:function(a){var b,c=0;for(b in a)void 0!==a[b]&&null!==a[b]&&a[b]!==!1&&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, [contenteditable]").not(":submit, :reset, :image, :disabled").not(this.settings.ignore).filter(function(){var d=this.name||a(this).attr("name");return!d&&b.settings.debug&&window.console&&console.error("%o has no name assigned",this),this.hasAttribute("contenteditable")&&(this.form=a(this).closest("form")[0],this.name=d),!(d in c||!b.objectLength(a(this).rules()))&&(c[d]=!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)},resetInternals:function(){this.successList=[],this.errorList=[],this.errorMap={},this.toShow=a([]),this.toHide=a([])},reset:function(){this.resetInternals(),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,e=a(b),f=b.type;return"radio"===f||"checkbox"===f?this.findByName(b.name).filter(":checked").val():"number"===f&&"undefined"!=typeof b.validity?b.validity.badInput?"NaN":e.val():(c=b.hasAttribute("contenteditable")?e.text():e.val(),"file"===f?"C:\\fakepath\\"===c.substr(0,12)?c.substr(12):(d=c.lastIndexOf("/"),d>=0?c.substr(d+1):(d=c.lastIndexOf("\\"),d>=0?c.substr(d+1):c)):"string"==typeof c?c.replace(/\r/g,""):c)},check:function(b){b=this.validationTargetFor(this.clean(b));var c,d,e,f,g=a(b).rules(),h=a.map(g,function(a,b){return b}).length,i=!1,j=this.elementValue(b);if("function"==typeof g.normalizer?f=g.normalizer:"function"==typeof this.settings.normalizer&&(f=this.settings.normalizer),f){if(j=f.call(b,j),"string"!=typeof j)throw new TypeError("The normalizer should return a string value.");delete g.normalizer}for(d in g){e={method:d,parameters:g[d]};try{if(c=a.validator.methods[d].call(this,j,b,e.parameters),"dependency-mismatch"===c&&1===h){i=!0;continue}if(i=!1,"pending"===c)return void(this.toHide=this.toHide.not(this.errorsFor(b)));if(!c)return this.formatAndAdd(b,e),!1}catch(k){throw this.settings.debug&&window.console&&console.log("Exception occurred when checking element "+b.id+", check the '"+e.method+"' method.",k),k instanceof TypeError&&(k.message+=". Exception occurred when checking element "+b.id+", check the '"+e.method+"' method."),k}}if(!i)return this.objectLength(g)&&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;a<arguments.length;a++)if(void 0!==arguments[a])return arguments[a]},defaultMessage:function(b,c){"string"==typeof c&&(c={method:c});var d=this.findDefined(this.customMessage(b.name,c.method),this.customDataMessage(b,c.method),!this.settings.ignoreTitle&&b.title||void 0,a.validator.messages[c.method],"<strong>Warning: No message defined for "+b.name+"</strong>"),e=/\$?\{(\d+)\}/g;return"function"==typeof d?d=d.call(this,c.parameters,b):e.test(d)&&(d=a.validator.format(d.replace(e,"{$1}"),c.parameters)),d},formatAndAdd:function(a,b){var c=this.defaultMessage(a,b);this.errorList.push({message:c,element:a,method:b.method}),this.errorMap[a.name]=c,this.submitted[a.name]=c},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,h=this.errorsFor(b),i=this.idOrName(b),j=a(b).attr("aria-describedby");h.length?(h.removeClass(this.settings.validClass).addClass(this.settings.errorClass),h.html(c)):(h=a("<"+this.settings.errorElement+">").attr("id",i+"-error").addClass(this.settings.errorClass).html(c||""),d=h,this.settings.wrapper&&(d=h.hide().show().wrap("<"+this.settings.wrapper+"/>").parent()),this.labelContainer.length?this.labelContainer.append(d):this.settings.errorPlacement?this.settings.errorPlacement.call(this,d,a(b)):d.insertAfter(b),h.is("label")?h.attr("for",i):0===h.parents("label[for='"+this.escapeCssMeta(i)+"']").length&&(f=h.attr("id"),j?j.match(new RegExp("\\b"+this.escapeCssMeta(f)+"\\b"))||(j+=" "+f):j=f,a(b).attr("aria-describedby",j),e=this.groups[b.name],e&&(g=this,a.each(g.groups,function(b,c){c===e&&a("[name='"+g.escapeCssMeta(b)+"']",g.currentForm).attr("aria-describedby",h.attr("id"))})))),!c&&this.settings.success&&(h.text(""),"string"==typeof this.settings.success?h.addClass(this.settings.success):this.settings.success(h,b)),this.toShow=this.toShow.add(h)},errorsFor:function(b){var c=this.escapeCssMeta(this.idOrName(b)),d=a(b).attr("aria-describedby"),e="label[for='"+c+"'], label[for='"+c+"'] *";return d&&(e=e+", #"+this.escapeCssMeta(d).replace(/\s+/g,", #")),this.errors().filter(e)},escapeCssMeta:function(a){return a.replace(/([\\!"#$%&'()*+,.\/:;<=>?@\[\]^`{|}~])/g,"\\$1")},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='"+this.escapeCssMeta(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)},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(b){this.pending[b.name]||(this.pendingRequest++,a(b).addClass(this.settings.pendingClass),this.pending[b.name]=!0)},stopRequest:function(b,c){this.pendingRequest--,this.pendingRequest<0&&(this.pendingRequest=0),delete this.pending[b.name],a(b).removeClass(this.settings.pendingClass),c&&0===this.pendingRequest&&this.formSubmitted&&this.form()?(a(this.currentForm).submit(),this.submitButton&&a("input:hidden[name='"+this.submitButton.name+"']",this.currentForm).remove(),this.formSubmitted=!1):!c&&0===this.pendingRequest&&this.formSubmitted&&(a(this.currentForm).triggerHandler("invalid-form",[this]),this.formSubmitted=!1)},previousValue:function(b,c){return c="string"==typeof c&&c||"remote",a.data(b,"previousValue")||a.data(b,"previousValue",{old:null,valid:!0,message:this.defaultMessage(b,{method:c})})},destroy:function(){this.resetForm(),a(this.currentForm).off(".validate").removeData("validator").find(".validate-equalTo-blur").off(".validate-equalTo").removeClass("validate-equalTo-blur")}},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|step/.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:(a.data(c.form,"validator").resetElements(a(c)),delete b[d])}}),a.each(b,function(d,e){b[d]=a.isFunction(e)&&"normalizer"!==d?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)},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)||e<=d},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)||a<=c},range:function(a,b,c){return this.optional(b)||a>=c[0]&&a<=c[1]},step:function(b,c,d){var e,f=a(c).attr("type"),g="Step attribute on input type "+f+" is not supported.",h=["text","number","range"],i=new RegExp("\\b"+f+"\\b"),j=f&&!i.test(h.join()),k=function(a){var b=(""+a).match(/(?:\.(\d+))?$/);return b&&b[1]?b[1].length:0},l=function(a){return Math.round(a*Math.pow(10,e))},m=!0;if(j)throw new Error(g);return e=k(d),(k(b)>e||l(b)%l(d)!==0)&&(m=!1),this.optional(c)||m},equalTo:function(b,c,d){var e=a(d);return this.settings.onfocusout&&e.not(".validate-equalTo-blur").length&&e.addClass("validate-equalTo-blur").on("blur.validate-equalTo",function(){a(c).valid()}),b===e.val()},remote:function(b,c,d,e){if(this.optional(c))return"dependency-mismatch";e="string"==typeof e&&e||"remote";var f,g,h,i=this.previousValue(c,e);return this.settings.messages[c.name]||(this.settings.messages[c.name]={}),i.originalMessage=i.originalMessage||this.settings.messages[c.name][e],this.settings.messages[c.name][e]=i.message,d="string"==typeof d&&{url:d}||d,h=a.param(a.extend({data:b},d.data)),i.old===h?i.valid:(i.old=h,f=this,this.startRequest(c),g={},g[c.name]=b,a.ajax(a.extend(!0,{mode:"abort",port:"validate"+c.name,dataType:"json",data:g,context:f.currentForm,success:function(a){var d,g,h,j=a===!0||"true"===a;f.settings.messages[c.name][e]=i.originalMessage,j?(h=f.formSubmitted,f.resetInternals(),f.toHide=f.errorsFor(c),f.formSubmitted=h,f.successList.push(c),f.invalid[c.name]=!1,f.showErrors()):(d={},g=a||f.defaultMessage(c,{method:e,parameters:b}),d[c.name]=i.message=g,f.invalid[c.name]=!0,f.showErrors(d)),i.valid=j,f.stopRequest(c,j)}},d)),"pending")}}});var b,c={};return 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)}),a});
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright (c) .NET Foundation and Contributors
|
|
4
|
-
|
|
5
|
-
All rights reserved.
|
|
6
|
-
|
|
7
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
-
in the Software without restriction, including without limitation the rights
|
|
10
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
furnished to do so, subject to the following conditions:
|
|
13
|
-
|
|
14
|
-
The above copyright notice and this permission notice shall be included in all
|
|
15
|
-
copies or substantial portions of the Software.
|
|
16
|
-
|
|
17
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
-
SOFTWARE.
|
|
@@ -1,435 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Unobtrusive validation support library for jQuery and jQuery Validate
|
|
4
|
-
* Copyright (c) .NET Foundation. All rights reserved.
|
|
5
|
-
* Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
|
6
|
-
* @version v4.0.0
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
/*jslint white: true, browser: true, onevar: true, undef: true, nomen: true, eqeqeq: true, plusplus: true, bitwise: true, regexp: true, newcap: true, immed: true, strict: false */
|
|
10
|
-
/*global document: false, jQuery: false */
|
|
11
|
-
|
|
12
|
-
(function (factory) {
|
|
13
|
-
if (typeof define === 'function' && define.amd) {
|
|
14
|
-
// AMD. Register as an anonymous module.
|
|
15
|
-
define("jquery.validate.unobtrusive", ['jquery-validation'], factory);
|
|
16
|
-
} else if (typeof module === 'object' && module.exports) {
|
|
17
|
-
// CommonJS-like environments that support module.exports
|
|
18
|
-
module.exports = factory(require('jquery-validation'));
|
|
19
|
-
} else {
|
|
20
|
-
// Browser global
|
|
21
|
-
jQuery.validator.unobtrusive = factory(jQuery);
|
|
22
|
-
}
|
|
23
|
-
}(function ($) {
|
|
24
|
-
var $jQval = $.validator,
|
|
25
|
-
adapters,
|
|
26
|
-
data_validation = "unobtrusiveValidation";
|
|
27
|
-
|
|
28
|
-
function setValidationValues(options, ruleName, value) {
|
|
29
|
-
options.rules[ruleName] = value;
|
|
30
|
-
if (options.message) {
|
|
31
|
-
options.messages[ruleName] = options.message;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function splitAndTrim(value) {
|
|
36
|
-
return value.replace(/^\s+|\s+$/g, "").split(/\s*,\s*/g);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function escapeAttributeValue(value) {
|
|
40
|
-
// As mentioned on http://api.jquery.com/category/selectors/
|
|
41
|
-
return value.replace(/([!"#$%&'()*+,./:;<=>?@\[\\\]^`{|}~])/g, "\\$1");
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function getModelPrefix(fieldName) {
|
|
45
|
-
return fieldName.substr(0, fieldName.lastIndexOf(".") + 1);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function appendModelPrefix(value, prefix) {
|
|
49
|
-
if (value.indexOf("*.") === 0) {
|
|
50
|
-
value = value.replace("*.", prefix);
|
|
51
|
-
}
|
|
52
|
-
return value;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function onError(error, inputElement) { // 'this' is the form element
|
|
56
|
-
var container = $(this).find("[data-valmsg-for='" + escapeAttributeValue(inputElement[0].name) + "']"),
|
|
57
|
-
replaceAttrValue = container.attr("data-valmsg-replace"),
|
|
58
|
-
replace = replaceAttrValue ? $.parseJSON(replaceAttrValue) !== false : null;
|
|
59
|
-
|
|
60
|
-
container.removeClass("field-validation-valid").addClass("field-validation-error");
|
|
61
|
-
error.data("unobtrusiveContainer", container);
|
|
62
|
-
|
|
63
|
-
if (replace) {
|
|
64
|
-
container.empty();
|
|
65
|
-
error.removeClass("input-validation-error").appendTo(container);
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
error.hide();
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function onErrors(event, validator) { // 'this' is the form element
|
|
73
|
-
var container = $(this).find("[data-valmsg-summary=true]"),
|
|
74
|
-
list = container.find("ul");
|
|
75
|
-
|
|
76
|
-
if (list && list.length && validator.errorList.length) {
|
|
77
|
-
list.empty();
|
|
78
|
-
container.addClass("validation-summary-errors").removeClass("validation-summary-valid");
|
|
79
|
-
|
|
80
|
-
$.each(validator.errorList, function () {
|
|
81
|
-
$("<li />").html(this.message).appendTo(list);
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function onSuccess(error) { // 'this' is the form element
|
|
87
|
-
var container = error.data("unobtrusiveContainer");
|
|
88
|
-
|
|
89
|
-
if (container) {
|
|
90
|
-
var replaceAttrValue = container.attr("data-valmsg-replace"),
|
|
91
|
-
replace = replaceAttrValue ? $.parseJSON(replaceAttrValue) : null;
|
|
92
|
-
|
|
93
|
-
container.addClass("field-validation-valid").removeClass("field-validation-error");
|
|
94
|
-
error.removeData("unobtrusiveContainer");
|
|
95
|
-
|
|
96
|
-
if (replace) {
|
|
97
|
-
container.empty();
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
function onReset(event) { // 'this' is the form element
|
|
103
|
-
var $form = $(this),
|
|
104
|
-
key = '__jquery_unobtrusive_validation_form_reset';
|
|
105
|
-
if ($form.data(key)) {
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
// Set a flag that indicates we're currently resetting the form.
|
|
109
|
-
$form.data(key, true);
|
|
110
|
-
try {
|
|
111
|
-
$form.data("validator").resetForm();
|
|
112
|
-
} finally {
|
|
113
|
-
$form.removeData(key);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
$form.find(".validation-summary-errors")
|
|
117
|
-
.addClass("validation-summary-valid")
|
|
118
|
-
.removeClass("validation-summary-errors");
|
|
119
|
-
$form.find(".field-validation-error")
|
|
120
|
-
.addClass("field-validation-valid")
|
|
121
|
-
.removeClass("field-validation-error")
|
|
122
|
-
.removeData("unobtrusiveContainer")
|
|
123
|
-
.find(">*") // If we were using valmsg-replace, get the underlying error
|
|
124
|
-
.removeData("unobtrusiveContainer");
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
function validationInfo(form) {
|
|
128
|
-
var $form = $(form),
|
|
129
|
-
result = $form.data(data_validation),
|
|
130
|
-
onResetProxy = $.proxy(onReset, form),
|
|
131
|
-
defaultOptions = $jQval.unobtrusive.options || {},
|
|
132
|
-
execInContext = function (name, args) {
|
|
133
|
-
var func = defaultOptions[name];
|
|
134
|
-
func && $.isFunction(func) && func.apply(form, args);
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
if (!result) {
|
|
138
|
-
result = {
|
|
139
|
-
options: { // options structure passed to jQuery Validate's validate() method
|
|
140
|
-
errorClass: defaultOptions.errorClass || "input-validation-error",
|
|
141
|
-
errorElement: defaultOptions.errorElement || "span",
|
|
142
|
-
errorPlacement: function () {
|
|
143
|
-
onError.apply(form, arguments);
|
|
144
|
-
execInContext("errorPlacement", arguments);
|
|
145
|
-
},
|
|
146
|
-
invalidHandler: function () {
|
|
147
|
-
onErrors.apply(form, arguments);
|
|
148
|
-
execInContext("invalidHandler", arguments);
|
|
149
|
-
},
|
|
150
|
-
messages: {},
|
|
151
|
-
rules: {},
|
|
152
|
-
success: function () {
|
|
153
|
-
onSuccess.apply(form, arguments);
|
|
154
|
-
execInContext("success", arguments);
|
|
155
|
-
}
|
|
156
|
-
},
|
|
157
|
-
attachValidation: function () {
|
|
158
|
-
$form
|
|
159
|
-
.off("reset." + data_validation, onResetProxy)
|
|
160
|
-
.on("reset." + data_validation, onResetProxy)
|
|
161
|
-
.validate(this.options);
|
|
162
|
-
},
|
|
163
|
-
validate: function () { // a validation function that is called by unobtrusive Ajax
|
|
164
|
-
$form.validate();
|
|
165
|
-
return $form.valid();
|
|
166
|
-
}
|
|
167
|
-
};
|
|
168
|
-
$form.data(data_validation, result);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
return result;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
$jQval.unobtrusive = {
|
|
175
|
-
adapters: [],
|
|
176
|
-
|
|
177
|
-
parseElement: function (element, skipAttach) {
|
|
178
|
-
/// <summary>
|
|
179
|
-
/// Parses a single HTML element for unobtrusive validation attributes.
|
|
180
|
-
/// </summary>
|
|
181
|
-
/// <param name="element" domElement="true">The HTML element to be parsed.</param>
|
|
182
|
-
/// <param name="skipAttach" type="Boolean">[Optional] true to skip attaching the
|
|
183
|
-
/// validation to the form. If parsing just this single element, you should specify true.
|
|
184
|
-
/// If parsing several elements, you should specify false, and manually attach the validation
|
|
185
|
-
/// to the form when you are finished. The default is false.</param>
|
|
186
|
-
var $element = $(element),
|
|
187
|
-
form = $element.parents("form")[0],
|
|
188
|
-
valInfo, rules, messages;
|
|
189
|
-
|
|
190
|
-
if (!form) { // Cannot do client-side validation without a form
|
|
191
|
-
return;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
valInfo = validationInfo(form);
|
|
195
|
-
valInfo.options.rules[element.name] = rules = {};
|
|
196
|
-
valInfo.options.messages[element.name] = messages = {};
|
|
197
|
-
|
|
198
|
-
$.each(this.adapters, function () {
|
|
199
|
-
var prefix = "data-val-" + this.name,
|
|
200
|
-
message = $element.attr(prefix),
|
|
201
|
-
paramValues = {};
|
|
202
|
-
|
|
203
|
-
if (message !== undefined) { // Compare against undefined, because an empty message is legal (and falsy)
|
|
204
|
-
prefix += "-";
|
|
205
|
-
|
|
206
|
-
$.each(this.params, function () {
|
|
207
|
-
paramValues[this] = $element.attr(prefix + this);
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
this.adapt({
|
|
211
|
-
element: element,
|
|
212
|
-
form: form,
|
|
213
|
-
message: message,
|
|
214
|
-
params: paramValues,
|
|
215
|
-
rules: rules,
|
|
216
|
-
messages: messages
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
});
|
|
220
|
-
|
|
221
|
-
$.extend(rules, { "__dummy__": true });
|
|
222
|
-
|
|
223
|
-
if (!skipAttach) {
|
|
224
|
-
valInfo.attachValidation();
|
|
225
|
-
}
|
|
226
|
-
},
|
|
227
|
-
|
|
228
|
-
parse: function (selector) {
|
|
229
|
-
/// <summary>
|
|
230
|
-
/// Parses all the HTML elements in the specified selector. It looks for input elements decorated
|
|
231
|
-
/// with the [data-val=true] attribute value and enables validation according to the data-val-*
|
|
232
|
-
/// attribute values.
|
|
233
|
-
/// </summary>
|
|
234
|
-
/// <param name="selector" type="String">Any valid jQuery selector.</param>
|
|
235
|
-
|
|
236
|
-
// $forms includes all forms in selector's DOM hierarchy (parent, children and self) that have at least one
|
|
237
|
-
// element with data-val=true
|
|
238
|
-
var $selector = $(selector),
|
|
239
|
-
$forms = $selector.parents()
|
|
240
|
-
.addBack()
|
|
241
|
-
.filter("form")
|
|
242
|
-
.add($selector.find("form"))
|
|
243
|
-
.has("[data-val=true]");
|
|
244
|
-
|
|
245
|
-
$selector.find("[data-val=true]").each(function () {
|
|
246
|
-
$jQval.unobtrusive.parseElement(this, true);
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
$forms.each(function () {
|
|
250
|
-
var info = validationInfo(this);
|
|
251
|
-
if (info) {
|
|
252
|
-
info.attachValidation();
|
|
253
|
-
}
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
};
|
|
257
|
-
|
|
258
|
-
adapters = $jQval.unobtrusive.adapters;
|
|
259
|
-
|
|
260
|
-
adapters.add = function (adapterName, params, fn) {
|
|
261
|
-
/// <summary>Adds a new adapter to convert unobtrusive HTML into a jQuery Validate validation.</summary>
|
|
262
|
-
/// <param name="adapterName" type="String">The name of the adapter to be added. This matches the name used
|
|
263
|
-
/// in the data-val-nnnn HTML attribute (where nnnn is the adapter name).</param>
|
|
264
|
-
/// <param name="params" type="Array" optional="true">[Optional] An array of parameter names (strings) that will
|
|
265
|
-
/// be extracted from the data-val-nnnn-mmmm HTML attributes (where nnnn is the adapter name, and
|
|
266
|
-
/// mmmm is the parameter name).</param>
|
|
267
|
-
/// <param name="fn" type="Function">The function to call, which adapts the values from the HTML
|
|
268
|
-
/// attributes into jQuery Validate rules and/or messages.</param>
|
|
269
|
-
/// <returns type="jQuery.validator.unobtrusive.adapters" />
|
|
270
|
-
if (!fn) { // Called with no params, just a function
|
|
271
|
-
fn = params;
|
|
272
|
-
params = [];
|
|
273
|
-
}
|
|
274
|
-
this.push({ name: adapterName, params: params, adapt: fn });
|
|
275
|
-
return this;
|
|
276
|
-
};
|
|
277
|
-
|
|
278
|
-
adapters.addBool = function (adapterName, ruleName) {
|
|
279
|
-
/// <summary>Adds a new adapter to convert unobtrusive HTML into a jQuery Validate validation, where
|
|
280
|
-
/// the jQuery Validate validation rule has no parameter values.</summary>
|
|
281
|
-
/// <param name="adapterName" type="String">The name of the adapter to be added. This matches the name used
|
|
282
|
-
/// in the data-val-nnnn HTML attribute (where nnnn is the adapter name).</param>
|
|
283
|
-
/// <param name="ruleName" type="String" optional="true">[Optional] The name of the jQuery Validate rule. If not provided, the value
|
|
284
|
-
/// of adapterName will be used instead.</param>
|
|
285
|
-
/// <returns type="jQuery.validator.unobtrusive.adapters" />
|
|
286
|
-
return this.add(adapterName, function (options) {
|
|
287
|
-
setValidationValues(options, ruleName || adapterName, true);
|
|
288
|
-
});
|
|
289
|
-
};
|
|
290
|
-
|
|
291
|
-
adapters.addMinMax = function (adapterName, minRuleName, maxRuleName, minMaxRuleName, minAttribute, maxAttribute) {
|
|
292
|
-
/// <summary>Adds a new adapter to convert unobtrusive HTML into a jQuery Validate validation, where
|
|
293
|
-
/// the jQuery Validate validation has three potential rules (one for min-only, one for max-only, and
|
|
294
|
-
/// one for min-and-max). The HTML parameters are expected to be named -min and -max.</summary>
|
|
295
|
-
/// <param name="adapterName" type="String">The name of the adapter to be added. This matches the name used
|
|
296
|
-
/// in the data-val-nnnn HTML attribute (where nnnn is the adapter name).</param>
|
|
297
|
-
/// <param name="minRuleName" type="String">The name of the jQuery Validate rule to be used when you only
|
|
298
|
-
/// have a minimum value.</param>
|
|
299
|
-
/// <param name="maxRuleName" type="String">The name of the jQuery Validate rule to be used when you only
|
|
300
|
-
/// have a maximum value.</param>
|
|
301
|
-
/// <param name="minMaxRuleName" type="String">The name of the jQuery Validate rule to be used when you
|
|
302
|
-
/// have both a minimum and maximum value.</param>
|
|
303
|
-
/// <param name="minAttribute" type="String" optional="true">[Optional] The name of the HTML attribute that
|
|
304
|
-
/// contains the minimum value. The default is "min".</param>
|
|
305
|
-
/// <param name="maxAttribute" type="String" optional="true">[Optional] The name of the HTML attribute that
|
|
306
|
-
/// contains the maximum value. The default is "max".</param>
|
|
307
|
-
/// <returns type="jQuery.validator.unobtrusive.adapters" />
|
|
308
|
-
return this.add(adapterName, [minAttribute || "min", maxAttribute || "max"], function (options) {
|
|
309
|
-
var min = options.params.min,
|
|
310
|
-
max = options.params.max;
|
|
311
|
-
|
|
312
|
-
if (min && max) {
|
|
313
|
-
setValidationValues(options, minMaxRuleName, [min, max]);
|
|
314
|
-
}
|
|
315
|
-
else if (min) {
|
|
316
|
-
setValidationValues(options, minRuleName, min);
|
|
317
|
-
}
|
|
318
|
-
else if (max) {
|
|
319
|
-
setValidationValues(options, maxRuleName, max);
|
|
320
|
-
}
|
|
321
|
-
});
|
|
322
|
-
};
|
|
323
|
-
|
|
324
|
-
adapters.addSingleVal = function (adapterName, attribute, ruleName) {
|
|
325
|
-
/// <summary>Adds a new adapter to convert unobtrusive HTML into a jQuery Validate validation, where
|
|
326
|
-
/// the jQuery Validate validation rule has a single value.</summary>
|
|
327
|
-
/// <param name="adapterName" type="String">The name of the adapter to be added. This matches the name used
|
|
328
|
-
/// in the data-val-nnnn HTML attribute(where nnnn is the adapter name).</param>
|
|
329
|
-
/// <param name="attribute" type="String">[Optional] The name of the HTML attribute that contains the value.
|
|
330
|
-
/// The default is "val".</param>
|
|
331
|
-
/// <param name="ruleName" type="String" optional="true">[Optional] The name of the jQuery Validate rule. If not provided, the value
|
|
332
|
-
/// of adapterName will be used instead.</param>
|
|
333
|
-
/// <returns type="jQuery.validator.unobtrusive.adapters" />
|
|
334
|
-
return this.add(adapterName, [attribute || "val"], function (options) {
|
|
335
|
-
setValidationValues(options, ruleName || adapterName, options.params[attribute]);
|
|
336
|
-
});
|
|
337
|
-
};
|
|
338
|
-
|
|
339
|
-
$jQval.addMethod("__dummy__", function (value, element, params) {
|
|
340
|
-
return true;
|
|
341
|
-
});
|
|
342
|
-
|
|
343
|
-
$jQval.addMethod("regex", function (value, element, params) {
|
|
344
|
-
var match;
|
|
345
|
-
if (this.optional(element)) {
|
|
346
|
-
return true;
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
match = new RegExp(params).exec(value);
|
|
350
|
-
return (match && (match.index === 0) && (match[0].length === value.length));
|
|
351
|
-
});
|
|
352
|
-
|
|
353
|
-
$jQval.addMethod("nonalphamin", function (value, element, nonalphamin) {
|
|
354
|
-
var match;
|
|
355
|
-
if (nonalphamin) {
|
|
356
|
-
match = value.match(/\W/g);
|
|
357
|
-
match = match && match.length >= nonalphamin;
|
|
358
|
-
}
|
|
359
|
-
return match;
|
|
360
|
-
});
|
|
361
|
-
|
|
362
|
-
if ($jQval.methods.extension) {
|
|
363
|
-
adapters.addSingleVal("accept", "mimtype");
|
|
364
|
-
adapters.addSingleVal("extension", "extension");
|
|
365
|
-
} else {
|
|
366
|
-
// for backward compatibility, when the 'extension' validation method does not exist, such as with versions
|
|
367
|
-
// of JQuery Validation plugin prior to 1.10, we should use the 'accept' method for
|
|
368
|
-
// validating the extension, and ignore mime-type validations as they are not supported.
|
|
369
|
-
adapters.addSingleVal("extension", "extension", "accept");
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
adapters.addSingleVal("regex", "pattern");
|
|
373
|
-
adapters.addBool("creditcard").addBool("date").addBool("digits").addBool("email").addBool("number").addBool("url");
|
|
374
|
-
adapters.addMinMax("length", "minlength", "maxlength", "rangelength").addMinMax("range", "min", "max", "range");
|
|
375
|
-
adapters.addMinMax("minlength", "minlength").addMinMax("maxlength", "minlength", "maxlength");
|
|
376
|
-
adapters.add("equalto", ["other"], function (options) {
|
|
377
|
-
var prefix = getModelPrefix(options.element.name),
|
|
378
|
-
other = options.params.other,
|
|
379
|
-
fullOtherName = appendModelPrefix(other, prefix),
|
|
380
|
-
element = $(options.form).find(":input").filter("[name='" + escapeAttributeValue(fullOtherName) + "']")[0];
|
|
381
|
-
|
|
382
|
-
setValidationValues(options, "equalTo", element);
|
|
383
|
-
});
|
|
384
|
-
adapters.add("required", function (options) {
|
|
385
|
-
// jQuery Validate equates "required" with "mandatory" for checkbox elements
|
|
386
|
-
if (options.element.tagName.toUpperCase() !== "INPUT" || options.element.type.toUpperCase() !== "CHECKBOX") {
|
|
387
|
-
setValidationValues(options, "required", true);
|
|
388
|
-
}
|
|
389
|
-
});
|
|
390
|
-
adapters.add("remote", ["url", "type", "additionalfields"], function (options) {
|
|
391
|
-
var value = {
|
|
392
|
-
url: options.params.url,
|
|
393
|
-
type: options.params.type || "GET",
|
|
394
|
-
data: {}
|
|
395
|
-
},
|
|
396
|
-
prefix = getModelPrefix(options.element.name);
|
|
397
|
-
|
|
398
|
-
$.each(splitAndTrim(options.params.additionalfields || options.element.name), function (i, fieldName) {
|
|
399
|
-
var paramName = appendModelPrefix(fieldName, prefix);
|
|
400
|
-
value.data[paramName] = function () {
|
|
401
|
-
var field = $(options.form).find(":input").filter("[name='" + escapeAttributeValue(paramName) + "']");
|
|
402
|
-
// For checkboxes and radio buttons, only pick up values from checked fields.
|
|
403
|
-
if (field.is(":checkbox")) {
|
|
404
|
-
return field.filter(":checked").val() || field.filter(":hidden").val() || '';
|
|
405
|
-
}
|
|
406
|
-
else if (field.is(":radio")) {
|
|
407
|
-
return field.filter(":checked").val() || '';
|
|
408
|
-
}
|
|
409
|
-
return field.val();
|
|
410
|
-
};
|
|
411
|
-
});
|
|
412
|
-
|
|
413
|
-
setValidationValues(options, "remote", value);
|
|
414
|
-
});
|
|
415
|
-
adapters.add("password", ["min", "nonalphamin", "regex"], function (options) {
|
|
416
|
-
if (options.params.min) {
|
|
417
|
-
setValidationValues(options, "minlength", options.params.min);
|
|
418
|
-
}
|
|
419
|
-
if (options.params.nonalphamin) {
|
|
420
|
-
setValidationValues(options, "nonalphamin", options.params.nonalphamin);
|
|
421
|
-
}
|
|
422
|
-
if (options.params.regex) {
|
|
423
|
-
setValidationValues(options, "regex", options.params.regex);
|
|
424
|
-
}
|
|
425
|
-
});
|
|
426
|
-
adapters.add("fileextensions", ["extensions"], function (options) {
|
|
427
|
-
setValidationValues(options, "extension", options.params.extensions);
|
|
428
|
-
});
|
|
429
|
-
|
|
430
|
-
$(function () {
|
|
431
|
-
$jQval.unobtrusive.parse(document);
|
|
432
|
-
});
|
|
433
|
-
|
|
434
|
-
return $jQval.unobtrusive;
|
|
435
|
-
}));
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Unobtrusive validation support library for jQuery and jQuery Validate
|
|
4
|
-
* Copyright (c) .NET Foundation. All rights reserved.
|
|
5
|
-
* Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
|
6
|
-
* @version v4.0.0
|
|
7
|
-
*/
|
|
8
|
-
!function(a){"function"==typeof define&&define.amd?define("jquery.validate.unobtrusive",["jquery-validation"],a):"object"==typeof module&&module.exports?module.exports=a(require("jquery-validation")):jQuery.validator.unobtrusive=a(jQuery)}(function(s){var a,o=s.validator,d="unobtrusiveValidation";function l(a,e,n){a.rules[e]=n,a.message&&(a.messages[e]=a.message)}function u(a){return a.replace(/([!"#$%&'()*+,./:;<=>?@\[\\\]^`{|}~])/g,"\\$1")}function n(a){return a.substr(0,a.lastIndexOf(".")+1)}function m(a,e){return a=0===a.indexOf("*.")?a.replace("*.",e):a}function f(a){var e=s(this),n="__jquery_unobtrusive_validation_form_reset";if(!e.data(n)){e.data(n,!0);try{e.data("validator").resetForm()}finally{e.removeData(n)}e.find(".validation-summary-errors").addClass("validation-summary-valid").removeClass("validation-summary-errors"),e.find(".field-validation-error").addClass("field-validation-valid").removeClass("field-validation-error").removeData("unobtrusiveContainer").find(">*").removeData("unobtrusiveContainer")}}function p(n){function a(a,e){(a=r[a])&&s.isFunction(a)&&a.apply(n,e)}var e=s(n),t=e.data(d),i=s.proxy(f,n),r=o.unobtrusive.options||{};return t||(t={options:{errorClass:r.errorClass||"input-validation-error",errorElement:r.errorElement||"span",errorPlacement:function(){!function(a,e){var e=s(this).find("[data-valmsg-for='"+u(e[0].name)+"']"),n=(n=e.attr("data-valmsg-replace"))?!1!==s.parseJSON(n):null;e.removeClass("field-validation-valid").addClass("field-validation-error"),a.data("unobtrusiveContainer",e),n?(e.empty(),a.removeClass("input-validation-error").appendTo(e)):a.hide()}.apply(n,arguments),a("errorPlacement",arguments)},invalidHandler:function(){!function(a,e){var n=s(this).find("[data-valmsg-summary=true]"),t=n.find("ul");t&&t.length&&e.errorList.length&&(t.empty(),n.addClass("validation-summary-errors").removeClass("validation-summary-valid"),s.each(e.errorList,function(){s("<li />").html(this.message).appendTo(t)}))}.apply(n,arguments),a("invalidHandler",arguments)},messages:{},rules:{},success:function(){!function(a){var e,n=a.data("unobtrusiveContainer");n&&(e=(e=n.attr("data-valmsg-replace"))?s.parseJSON(e):null,n.addClass("field-validation-valid").removeClass("field-validation-error"),a.removeData("unobtrusiveContainer"),e&&n.empty())}.apply(n,arguments),a("success",arguments)}},attachValidation:function(){e.off("reset."+d,i).on("reset."+d,i).validate(this.options)},validate:function(){return e.validate(),e.valid()}},e.data(d,t)),t}return o.unobtrusive={adapters:[],parseElement:function(t,a){var e,i,r,o=s(t),d=o.parents("form")[0];d&&((e=p(d)).options.rules[t.name]=i={},e.options.messages[t.name]=r={},s.each(this.adapters,function(){var a="data-val-"+this.name,e=o.attr(a),n={};void 0!==e&&(a+="-",s.each(this.params,function(){n[this]=o.attr(a+this)}),this.adapt({element:t,form:d,message:e,params:n,rules:i,messages:r}))}),s.extend(i,{__dummy__:!0}),a||e.attachValidation())},parse:function(a){var a=s(a),e=a.parents().addBack().filter("form").add(a.find("form")).has("[data-val=true]");a.find("[data-val=true]").each(function(){o.unobtrusive.parseElement(this,!0)}),e.each(function(){var a=p(this);a&&a.attachValidation()})}},(a=o.unobtrusive.adapters).add=function(a,e,n){return n||(n=e,e=[]),this.push({name:a,params:e,adapt:n}),this},a.addBool=function(e,n){return this.add(e,function(a){l(a,n||e,!0)})},a.addMinMax=function(a,t,i,r,e,n){return this.add(a,[e||"min",n||"max"],function(a){var e=a.params.min,n=a.params.max;e&&n?l(a,r,[e,n]):e?l(a,t,e):n&&l(a,i,n)})},a.addSingleVal=function(e,n,t){return this.add(e,[n||"val"],function(a){l(a,t||e,a.params[n])})},o.addMethod("__dummy__",function(a,e,n){return!0}),o.addMethod("regex",function(a,e,n){return!!this.optional(e)||(e=new RegExp(n).exec(a))&&0===e.index&&e[0].length===a.length}),o.addMethod("nonalphamin",function(a,e,n){var t;return t=n?(t=a.match(/\W/g))&&t.length>=n:t}),o.methods.extension?(a.addSingleVal("accept","mimtype"),a.addSingleVal("extension","extension")):a.addSingleVal("extension","extension","accept"),a.addSingleVal("regex","pattern"),a.addBool("creditcard").addBool("date").addBool("digits").addBool("email").addBool("number").addBool("url"),a.addMinMax("length","minlength","maxlength","rangelength").addMinMax("range","min","max","range"),a.addMinMax("minlength","minlength").addMinMax("maxlength","minlength","maxlength"),a.add("equalto",["other"],function(a){var e=n(a.element.name),e=m(a.params.other,e);l(a,"equalTo",s(a.form).find(":input").filter("[name='"+u(e)+"']")[0])}),a.add("required",function(a){"INPUT"===a.element.tagName.toUpperCase()&&"CHECKBOX"===a.element.type.toUpperCase()||l(a,"required",!0)}),a.add("remote",["url","type","additionalfields"],function(t){var i={url:t.params.url,type:t.params.type||"GET",data:{}},r=n(t.element.name);s.each((t.params.additionalfields||t.element.name).replace(/^\s+|\s+$/g,"").split(/\s*,\s*/g),function(a,e){var n=m(e,r);i.data[n]=function(){var a=s(t.form).find(":input").filter("[name='"+u(n)+"']");return a.is(":checkbox")?a.filter(":checked").val()||a.filter(":hidden").val()||"":a.is(":radio")?a.filter(":checked").val()||"":a.val()}}),l(t,"remote",i)}),a.add("password",["min","nonalphamin","regex"],function(a){a.params.min&&l(a,"minlength",a.params.min),a.params.nonalphamin&&l(a,"nonalphamin",a.params.nonalphamin),a.params.regex&&l(a,"regex",a.params.regex)}),a.add("fileextensions",["extensions"],function(a){l(a,"extension",a.params.extensions)}),s(function(){o.unobtrusive.parse(document)}),o.unobtrusive});
|