You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
2.8 KiB
JavaScript
1 line
2.8 KiB
JavaScript
!function i(a,r,s){function o(n,t){if(!r[n]){if(!a[n]){var e="function"==typeof require&&require;if(!t&&e)return e(n,!0);if(l)return l(n,!0);throw new Error("Cannot find module '"+n+"'")}t=r[n]={exports:{}};a[n][0].call(t.exports,function(t){var e=a[n][1][t];return o(e||t)},t,t.exports,i,a,r,s)}return r[n].exports}for(var l="function"==typeof require&&require,t=0;t<s.length;t++)o(s[t]);return o}({1:[function(t,e,n){"use strict";function o(t,e,n){return t.replace("{count}",e).replace("{limit}",n).replace("{remaining}",n-e)}function l(t,e,n){var i=document.createElement("div");return i.classList.add("wpforms-field-limit-text"),i.id="wpforms-field-limit-text-"+t+"-"+e,i.setAttribute("aria-live","polite"),i.textContent=n,i}function d(e){return"string"==typeof e&&e.length?([/([A-Z]+),([A-Z]+)/gi,/([0-9]+),([A-Z]+)/gi,/([A-Z]+),([0-9]+)/gi].forEach(function(t){e=e.replace(t,"$1, $2")}),e.split(/\s+/).length):0}function u(t){return window.clipboardData&&window.clipboardData.getData?window.clipboardData.getData("Text"):t.clipboardData&&t.clipboardData.getData?t.clipboardData.getData("text/plain"):void 0}function c(t,e){var n="",i=/\s+/g,a=t.trim().match(i)||[],r=t.split(i);r.splice(e,r.length);for(var s=0;s<r.length;s++)n+=r[s]+(a[s]||"");return n.trim()}function i(t){return[].slice.call(t)}function a(){i(document.querySelectorAll(".wpforms-limit-characters-enabled")).map(function(t){function e(t){n.textContent=o(window.wpforms_settings.val_limit_characters,this.value.length,i)}var n,i,a,r=parseInt(t.dataset.textLimit,10)||0,s=(t.value=t.value.slice(0,r),l(t.dataset.formId,t.dataset.fieldId,o(window.wpforms_settings.val_limit_characters,t.value.length,r)));n=s,i=r;t.parentNode.appendChild(s),t.addEventListener("keydown",e),t.addEventListener("keyup",e),t.addEventListener("paste",(a=r,function(t){t.preventDefault();var t=u(t),e=this.selectionStart+t.length,t=this.value.substring(0,this.selectionStart)+t+this.value.substring(this.selectionStart);this.value=t.substring(0,a),this.setSelectionRange(e,e)}))}),i(document.querySelectorAll(".wpforms-limit-words-enabled")).map(function(t){function e(t){var e=d(this.value.trim());n.textContent=o(window.wpforms_settings.val_limit_words,e,i),-1<[13,32,188].indexOf(t.keyCode)&&i<=e&&t.preventDefault()}var n,i,a,r=parseInt(t.dataset.textLimit,10)||0,s=(t.value=c(t.value,r),l(t.dataset.formId,t.dataset.fieldId,o(window.wpforms_settings.val_limit_words,d(t.value.trim()),r)));n=s,i=r;t.parentNode.appendChild(s),t.addEventListener("keydown",e),t.addEventListener("keyup",e),t.addEventListener("paste",(a=r,function(t){t.preventDefault();var t=u(t),e=this.selectionStart+t.length,t=this.value.substring(0,this.selectionStart)+t+this.value.substring(this.selectionStart);this.value=c(t,a),this.setSelectionRange(e,e)}))})}"loading"===document.readyState?document.addEventListener("DOMContentLoaded",a):a()},{}]},{},[1]); |