From bd57bcadd12c7a11591bbfb583eac98e664792f9 Mon Sep 17 00:00:00 2001 From: Aaron Sadler Date: Wed, 7 Apr 2021 10:49:53 +0100 Subject: [PATCH 1/6] Updated to Umbraco Forms 8.7 --- .../packages/installedPackages.config | 87 +- .../dist/aspnet-validation.min.js | 2 + .../UmbracoForms/Assets/datepicker.init.js | 6 +- .../promise-polyfill/dist/polyfill.min.js | 1 + .../Assets/themes/default/umbracoforms.js | 294 +- .../Common/FieldTypes/password.html | 2 +- .../Common/FieldTypes/recaptcha3.html | 1 + .../Common/FieldTypes/textarea.html | 11 +- .../Common/FieldTypes/textfield.html | 5 +- .../Common/SettingTypes/documentmapper.html | 4 +- .../Common/SettingTypes/fieldmapper.html | 9 +- .../Common/SettingTypes/file-upload.html | 2 +- .../Backoffice/Common/SettingTypes/file.html | 3 +- .../Common/SettingTypes/numericfield.html | 1 + .../SettingTypes/passwordnoautocomplete.html | 1 + .../pickers.contentwithxpath.html | 4 +- .../Common/SettingTypes/pickers.datatype.html | 2 +- .../SettingTypes/pickers.documenttype.html | 2 +- .../Backoffice/Common/SettingTypes/range.html | 6 + .../SettingTypes/textfieldnoautocomplete.html | 1 + .../Backoffice/DataSource/edit.html | 8 +- .../UmbracoForms/Backoffice/Form/create.html | 72 +- .../Form/dialogs/fieldsettings.html | 11 +- .../UmbracoForms/Backoffice/Form/entries.html | 10 +- .../fieldsetsettings/fieldset-settings.html | 4 +- .../fieldsettings/field-settings.html | 50 +- .../fieldtypepicker/field-type-picker.html | 7 +- .../Form/overlays/formpicker/formpicker.html | 11 +- .../submit-message-workflow-settings.html | 3 +- .../overlays/workflows/workflow-settings.html | 11 +- .../overlays/workflows/workflow-types.html | 4 +- .../workflows/workflows-overview.html | 3 +- .../Form/views/settings/settings.html | 80 +- .../Backoffice/FormSecurity/edit.html | 171 +- .../Backoffice/PreValueSource/edit.html | 10 +- .../PropertyEditors/formpicker.html | 8 +- .../Directives/umb-forms-designer-new.html | 74 +- .../Directives/umb-forms-entry-detail.html | 78 +- .../umb-forms-file-upload-editor.html | 38 + .../Directives/umb-forms-prevalue-editor.html | 35 +- .../Directives/umb-forms-render-type.html | 4 +- .../UmbracoForms/UmbracoForms.config | 28 +- .../UmbracoForms/css/umbraco.forms.css | 211 +- .../UmbracoForms/js/umbraco.forms.js | 2538 ++++++++++------- .../0h5ihztm/4730684907_8a7f8759cb_b.jpg | 3 + .../2nsciu0a/18095416144_44a566a5f4_h.jpg | 3 + .../4ergp4y4/14272036539_469ca21d5c_h.jpg | 3 + .../b1njl0jx/18720470241_ff77768544_h.jpg | 3 + .../bd4jngkw/7373036208_30257976a0_b.jpg | 3 + .../ifsdri2r/7377957524_347859faac_b.jpg | 3 + .../imbihesm/18531852339_981b067419_h.jpg | 3 + .../krwd4fdg/18531854019_351c579559_h.jpg | 3 + .../lxqhuqdk/16403439029_f500be349b_o.jpg | 3 + .../ndhexmpp/5852022091_87c5d045ab_b.jpg | 3 + .../px2ib32e/18530280048_459b8b61b2_h.jpg | 3 + .../sacpsyu3/7373036290_5e8420bf36_b.jpg | 3 + .../te4j0d12/7371127652_e01b6ab56f_b.jpg | 3 + .../ybobktzf/5852022211_9028df67c0_b.jpg | 3 + TestSite/TestSite.csproj | 30 +- .../Fieldtypes/FieldType.CheckBox.cshtml | 4 +- .../Fieldtypes/FieldType.CheckBoxList.cshtml | 6 +- .../Fieldtypes/FieldType.DataConsent.cshtml | 4 +- .../Fieldtypes/FieldType.DatePicker.cshtml | 2 +- .../Fieldtypes/FieldType.DropDownList.cshtml | 2 +- .../Fieldtypes/FieldType.FileUpload.cshtml | 4 +- .../Fieldtypes/FieldType.HiddenField.cshtml | 2 +- .../Fieldtypes/FieldType.PasswordField.cshtml | 4 +- .../FieldType.RadioButtonList.cshtml | 6 +- .../Forms/Fieldtypes/FieldType.Text.cshtml | 11 +- .../Fieldtypes/FieldType.Textarea.cshtml | 8 +- .../Fieldtypes/FieldType.Textfield.cshtml | 4 +- .../Fieldtypes/Fieldtype.Recaptcha3.cshtml | 40 + .../FieldType.RadioButtonList.cshtml | 7 +- .../Themes/bootstrap3-horizontal/Form.cshtml | 2 +- .../Fieldtypes/FieldType.CheckBox.cshtml | 4 +- .../Fieldtypes/FieldType.CheckBoxList.cshtml | 6 +- .../Fieldtypes/FieldType.DataConsent.cshtml | 4 +- .../Fieldtypes/FieldType.DatePicker.cshtml | 4 +- .../Fieldtypes/FieldType.DropDownList.cshtml | 2 +- .../Fieldtypes/FieldType.FileUpload.cshtml | 4 +- .../Fieldtypes/FieldType.HiddenField.cshtml | 2 +- .../Fieldtypes/FieldType.PasswordField.cshtml | 4 +- .../FieldType.RadioButtonList.cshtml | 6 +- .../default/Fieldtypes/FieldType.Text.cshtml | 9 +- .../Fieldtypes/FieldType.Textarea.cshtml | 10 +- .../Fieldtypes/FieldType.Textfield.cshtml | 4 +- .../Fieldtypes/Fieldtype.Recaptcha3.cshtml | 40 + .../Partials/Forms/Themes/default/Form.cshtml | 6 +- TestSite/Web.config | 51 +- TestSite/config/ClientDependency.config | 2 +- TestSite/packages.config | 4 +- .../UmbracoForms.uCaptcha.csproj | 14 +- UmbracoForms.uCaptcha/packages.config | 2 +- 93 files changed, 2560 insertions(+), 1709 deletions(-) create mode 100644 TestSite/App_Plugins/UmbracoForms/Assets/aspnet-validation/dist/aspnet-validation.min.js create mode 100644 TestSite/App_Plugins/UmbracoForms/Assets/promise-polyfill/dist/polyfill.min.js create mode 100644 TestSite/App_Plugins/UmbracoForms/Backoffice/Common/FieldTypes/recaptcha3.html create mode 100644 TestSite/App_Plugins/UmbracoForms/Backoffice/Common/SettingTypes/numericfield.html create mode 100644 TestSite/App_Plugins/UmbracoForms/Backoffice/Common/SettingTypes/passwordnoautocomplete.html create mode 100644 TestSite/App_Plugins/UmbracoForms/Backoffice/Common/SettingTypes/range.html create mode 100644 TestSite/App_Plugins/UmbracoForms/Backoffice/Common/SettingTypes/textfieldnoautocomplete.html create mode 100644 TestSite/App_Plugins/UmbracoForms/Directives/umb-forms-file-upload-editor.html create mode 100644 TestSite/Media/0h5ihztm/4730684907_8a7f8759cb_b.jpg create mode 100644 TestSite/Media/2nsciu0a/18095416144_44a566a5f4_h.jpg create mode 100644 TestSite/Media/4ergp4y4/14272036539_469ca21d5c_h.jpg create mode 100644 TestSite/Media/b1njl0jx/18720470241_ff77768544_h.jpg create mode 100644 TestSite/Media/bd4jngkw/7373036208_30257976a0_b.jpg create mode 100644 TestSite/Media/ifsdri2r/7377957524_347859faac_b.jpg create mode 100644 TestSite/Media/imbihesm/18531852339_981b067419_h.jpg create mode 100644 TestSite/Media/krwd4fdg/18531854019_351c579559_h.jpg create mode 100644 TestSite/Media/lxqhuqdk/16403439029_f500be349b_o.jpg create mode 100644 TestSite/Media/ndhexmpp/5852022091_87c5d045ab_b.jpg create mode 100644 TestSite/Media/px2ib32e/18530280048_459b8b61b2_h.jpg create mode 100644 TestSite/Media/sacpsyu3/7373036290_5e8420bf36_b.jpg create mode 100644 TestSite/Media/te4j0d12/7371127652_e01b6ab56f_b.jpg create mode 100644 TestSite/Media/ybobktzf/5852022211_9028df67c0_b.jpg create mode 100644 TestSite/Views/Partials/Forms/Fieldtypes/Fieldtype.Recaptcha3.cshtml create mode 100644 TestSite/Views/Partials/Forms/Themes/default/Fieldtypes/Fieldtype.Recaptcha3.cshtml diff --git a/TestSite/App_Data/packages/installedPackages.config b/TestSite/App_Data/packages/installedPackages.config index 7ebe955..56fe396 100644 --- a/TestSite/App_Data/packages/installedPackages.config +++ b/TestSite/App_Data/packages/installedPackages.config @@ -1,91 +1,6 @@  - - - - - - - 1060,1061,1062,1063,1064,1065,1066,1067,1068,1069,1070,1071,1072,1073,1074,1075,1076,1077,1078,1079,1080 - - 1081,1082,1083,1084,1085,1086,1087,1088,1089,1090 - - 1092,1093,1094,1095,1096,1097,1098,1099,1100,1101,1102,1103 - 1,2 - - Media\SK_Temp\7373036290_5e8420bf36_b.jpg - Media\SK_Temp\14272036539_469ca21d5c_h.jpg - Media\SK_Temp\7373036208_30257976a0_b.jpg - Media\SK_Temp\7371127652_e01b6ab56f_b.jpg - Media\SK_Temp\18530280048_459b8b61b2_h.jpg - Media\SK_Temp\7377957524_347859faac_b.jpg - Media\SK_Temp\16403439029_f500be349b_o.jpg - Media\SK_Temp\4730684907_8a7f8759cb_b.jpg - Media\SK_Temp\5852022091_87c5d045ab_b.jpg - Media\SK_Temp\18095416144_44a566a5f4_h.jpg - Media\SK_Temp\5852022211_9028df67c0_b.jpg - Media\SK_Temp\18720470241_ff77768544_h.jpg - Media\SK_Temp\18531852339_981b067419_h.jpg - Media\SK_Temp\18531854019_351c579559_h.jpg - scripts\umbraco-starterkit-app.js - bin\Umbraco.SampleSite.dll - App_Plugins\StarterKit\lessons.service.js - App_Plugins\StarterKit\package.manifest - App_Plugins\StarterKit\StarterKitHelp.Controller.js - App_Plugins\StarterKit\starterkithelp.html - App_Plugins\StarterKit\backoffice\tours\create-content.json - App_Plugins\StarterKit\backoffice\tours\data-structure.json - App_Plugins\StarterKit\lang\en-GB.xml - App_Plugins\StarterKit\lang\en-US.xml - App_Plugins\StarterKit\tours\views\validatetext.controller.js - App_Plugins\StarterKit\tours\views\validatetext.html - App_Plugins\StarterKit\tours\views\medialibrary\uploadimages.controller.js - App_Plugins\StarterKit\tours\views\medialibrary\uploadimages.html - Views\Partials\Navigation\TopNavigation.cshtml - Views\Partials\CategoryLinks.cshtml - Views\Partials\SectionHeader.cshtml - Views\Partials\Navigation\SubNavigation.cshtml - Views\Partials\Navigation\TopNavigation.cshtml - css\umbraco-starterkit-style.css - Views\MacroPartials\FeaturedProducts.cshtml - Views\MacroPartials\LatestBlogposts.cshtml - bin\Our.Umbraco.OsmMaps.dll - App_Plugins\OsmMaps\OsmMaps.controller.js - App_Plugins\OsmMaps\OsmMaps.html - App_Plugins\OsmMaps\package.manifest - App_Plugins\OsmMaps\assets\css\osmmaps.css - App_Plugins\OsmMaps\assets\leaflet\leaflet-src.js - App_Plugins\OsmMaps\assets\leaflet\leaflet.css - App_Plugins\OsmMaps\assets\leaflet\leaflet.js - App_Plugins\OsmMaps\assets\leaflet\images\layers-2x.png - App_Plugins\OsmMaps\assets\leaflet\images\layers.png - App_Plugins\OsmMaps\assets\leaflet\images\marker-icon-2x.png - App_Plugins\OsmMaps\assets\leaflet\images\marker-icon.png - App_Plugins\OsmMaps\assets\leaflet\images\marker-shadow.png - App_Plugins\OsmMaps\langs\da-dk.js - App_Plugins\OsmMaps\langs\de-de.js - App_Plugins\OsmMaps\langs\en-gb.js - App_Plugins\OsmMaps\langs\en-us.js - App_Plugins\OsmMaps\langs\es-es.js - App_Plugins\OsmMaps\langs\fr-fr.js - App_Plugins\OsmMaps\langs\he-il.js - App_Plugins\OsmMaps\langs\it-it.js - App_Plugins\OsmMaps\langs\ja-jp.js - App_Plugins\OsmMaps\langs\ko-kr.js - App_Plugins\OsmMaps\langs\nb-no.js - App_Plugins\OsmMaps\langs\nl-nl.js - App_Plugins\OsmMaps\langs\pl-pl.js - App_Plugins\OsmMaps\langs\pt-br.js - App_Plugins\OsmMaps\langs\ru-ru.js - App_Plugins\OsmMaps\langs\sv-se.js - App_Plugins\OsmMaps\langs\zh-cn.js - - - - - + diff --git a/TestSite/App_Plugins/UmbracoForms/Assets/aspnet-validation/dist/aspnet-validation.min.js b/TestSite/App_Plugins/UmbracoForms/Assets/aspnet-validation/dist/aspnet-validation.min.js new file mode 100644 index 0000000..e442df5 --- /dev/null +++ b/TestSite/App_Plugins/UmbracoForms/Assets/aspnet-validation/dist/aspnet-validation.min.js @@ -0,0 +1,2 @@ +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.aspnetValidation=t():e.aspnetValidation=t()}(window,function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var a=t[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,r),a.l=!0,a.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)r.d(n,a,function(t){return e[t]}.bind(null,a));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){"use strict";r.r(t),r.d(t,"MvcValidationProviders",function(){return o}),r.d(t,"ValidationService",function(){return s});var n=function(e,t,r,n){return new(r||(r=Promise))(function(a,i){function o(e){try{u(n.next(e))}catch(e){i(e)}}function s(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){e.done?a(e.value):new r(function(t){t(e.value)}).then(o,s)}u((n=n.apply(e,t||[])).next())})},a=function(e,t){var r,n,a,i,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(a=2&i[0]?n.return:i[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,i[1])).done)return a;switch(n=0,a&&(i=[2&i[0],a.value]),i[0]){case 0:case 1:a=i;break;case 4:return o.label++,{value:i[1],done:!1};case 5:o.label++,n=i[1],i=[0];continue;case 7:i=o.ops.pop(),o.trys.pop();continue;default:if(!(a=(a=o.trys).length>0&&a[a.length-1])&&(6===i[0]||2===i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]-1){var a=e.substr(0,n)+"."+r,i=document.getElementsByName(a)[0];if(i)return i}return document.getElementsByName(r)[0]}var o=function(){return function(){this.required=function(e,t,r){return Boolean(e)},this.stringLength=function(e,t,r){if(!e)return!0;if(r.min){var n=parseInt(r.min);if(e.lengtha)return!1}return!0},this.compare=function(e,t,r){if(!r.other)return!0;var n=i(t.name,r.other);return!n||n.value===e},this.range=function(e,t,r){if(!e)return!0;var n=parseFloat(e);return!isNaN(n)&&(!(r.min&&nparseFloat(r.max)))},this.regex=function(e,t,r){return!e||!r.pattern||new RegExp(r.pattern).test(e)},this.email=function(e,t,r){return!e||/^([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22))*\x40([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d))*(\.\w{2,})+$/.test(e)},this.creditcard=function(e,t,r){if(!e)return!0;if(/[^0-9 \-]+/.test(e))return!1;var n,a,i=0,o=0,s=!1;if((e=e.replace(/\D/g,"")).length<13||e.length>19)return!1;for(n=e.length-1;n>=0;n--)a=e.charAt(n),o=parseInt(a,10),s&&(o*=2)>9&&(o-=9),i+=o,s=!s;return i%10==0},this.url=function(e,t,r){return!e||new RegExp("^(?:(?: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(e)},this.phone=function(e,t,r){return!e||!/[\+\-\s][\-\s]/g.test(e)&&/^\+?[0-9\-\s]+$/.test(e)},this.remote=function(e,t,r){if(!e)return!0;for(var n=r.additionalfields.split(","),a={},o=0,s=n;o=200&&n.status<300){var a=JSON.parse(n.responseText);e(a)}else t({status:n.status,statusText:n.statusText,data:n.responseText})},n.onerror=function(e){t({status:n.status,statusText:n.statusText,data:n.responseText})}})}}}(),s=function(){function e(){this.providers={},this.messageFor={},this.elementUIDs=[],this.elementByUID={},this.formInputs={},this.validators={},this.elementEvents={},this.summary={},this.debounce=300}return e.prototype.addProvider=function(e,t){this.providers[e]||(this.providers[e]=t)},e.prototype.addMvcProviders=function(){var e=new o;this.addProvider("required",e.required),this.addProvider("length",e.stringLength),this.addProvider("maxlength",e.stringLength),this.addProvider("minlength",e.stringLength),this.addProvider("equalto",e.compare),this.addProvider("range",e.range),this.addProvider("regex",e.regex),this.addProvider("creditcard",e.creditcard),this.addProvider("email",e.email),this.addProvider("url",e.url),this.addProvider("phone",e.phone),this.addProvider("remote",e.remote)},e.prototype.scanMessages=function(){for(var e=document.querySelectorAll("[data-valmsg-for]"),t=0;tn;n++)r(e,e._deferreds[n]);e._deferreds=null}function c(e,n){var t=!1;try{e(function(e){t||(t=!0,i(n,e))},function(e){t||(t=!0,f(n,e))})}catch(o){if(t)return;t=!0,f(n,o)}}var a=setTimeout;o.prototype["catch"]=function(e){return this.then(null,e)},o.prototype.then=function(e,n){var o=new this.constructor(t);return r(this,new function(e,n,t){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof n?n:null,this.promise=t}(e,n,o)),o},o.prototype["finally"]=e,o.all=function(e){return new o(function(t,o){function r(e,n){try{if(n&&("object"==typeof n||"function"==typeof n)){var u=n.then;if("function"==typeof u)return void u.call(n,function(n){r(e,n)},o)}i[e]=n,0==--f&&t(i)}catch(c){o(c)}}if(!n(e))return o(new TypeError("Promise.all accepts an array"));var i=Array.prototype.slice.call(e);if(0===i.length)return t([]);for(var f=i.length,u=0;i.length>u;u++)r(u,i[u])})},o.resolve=function(e){return e&&"object"==typeof e&&e.constructor===o?e:new o(function(n){n(e)})},o.reject=function(e){return new o(function(n,t){t(e)})},o.race=function(e){return new o(function(t,r){if(!n(e))return r(new TypeError("Promise.race accepts an array"));for(var i=0,f=e.length;f>i;i++)o.resolve(e[i]).then(t,r)})},o._immediateFn="function"==typeof setImmediate&&function(e){setImmediate(e)}||function(e){a(e,0)},o._unhandledRejectionFn=function(e){void 0!==console&&console&&console.warn("Possible Unhandled Promise Rejection:",e)};var l=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw Error("unable to locate global object")}();"Promise"in l?l.Promise.prototype["finally"]||(l.Promise.prototype["finally"]=e):l.Promise=o}); diff --git a/TestSite/App_Plugins/UmbracoForms/Assets/themes/default/umbracoforms.js b/TestSite/App_Plugins/UmbracoForms/Assets/themes/default/umbracoforms.js index 5143447..692700c 100644 --- a/TestSite/App_Plugins/UmbracoForms/Assets/themes/default/umbracoforms.js +++ b/TestSite/App_Plugins/UmbracoForms/Assets/themes/default/umbracoforms.js @@ -1,4 +1,19 @@ -(function () { +(function () { + + + // polyfill for matches and closest + if (!Element.prototype.matches) Element.prototype.matches = Element.prototype.msMatchesSelector; + if (!Element.prototype.closest) Element.prototype.closest = function (selector) { + var el = this; + while (el) { + if (el.matches(selector)) { + return el; + } + el = el.parentElement; + } + }; + + //execute init() on document ready if (document.readyState === "complete" || (document.readyState !== "loading" && !document.documentElement.doScroll)) { @@ -22,7 +37,7 @@ configureUmbracoFormsValidation(); for (var i = 0; i < formsCollection.length; i++) { - init({ form: JSON.parse(decodeURI(formsCollection[i])) }); + init({ form: formsCollection[i] }); } } @@ -30,23 +45,93 @@ var formItem = e.form; - var forms = $('.umbraco-forms-form'); + var forms = document.querySelectorAll('.umbraco-forms-form'); + + for( var i = 0; i < forms.length; i++) { + var form = forms[i]; - forms.each(function (i, form) { dependencyCheck(form); - var page = $(this).find('.umbraco-forms-page'); + var page = form.querySelector('.umbraco-forms-page'); var conditions = new UmbracoFormsConditions(page, formItem.fieldSetConditions, formItem.fieldConditions, formItem.recordValues); conditions.watch(); - }); + }; } /** Configures the jquery validation for Umbraco forms */ function configureUmbracoFormsValidation() { - if ($.validator !== undefined) { + + if (window.aspnetValidation !== undefined) { + // Asp-net validation setup: + + var validationService = new aspnetValidation.ValidationService(); + + // TODO: equivilant to this: + /* + $.validator.setDefaults({ + ignore: ":hidden" + }); + */ + + function required(value, element, params) { + // Handle single and multiple checkboxes: + if(element.type.toLowerCase() === "checkbox" || element.type.toLowerCase() === "radio") { + var allCheckboxesOfThisName = element.form.querySelectorAll("input[name='"+element.name+"']"); + for (var i=0; i