CoreFiles by mySites.guru
short-and-sweet.min.js5 lines, 2,849 bytes, from Joomla_4.0.0-beta6-Beta-Full_Package.zip
Raw History Compare with 4.0.0-beta5
md5
7f999854080434ebea8d40a04a2c4e23
sha1
20464931104db3812fd4061f2b825dc2957a979a
sha256
5ebc8b063bd38d66aacf73239717fb5c32c262ffc5ffc6dd0a5599949a8dbfe1
/*
 * short-and-sweet v1.0.2 - Accessible character counter for input elements
 * Copyright (c) 2018 Rik Schennink <[email protected]> (http://rikschennink.nl/)
 */
!function(e,t){if("function"==typeof define&&define.amd)define(["module","exports"],t);else if("undefined"!=typeof exports)t(module,exports);else{var n={exports:{}};t(n,n.exports),e.shortAndSweet=n.exports}}(this,function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e};t.default=function(e){if(typeof window==="undefined"?null:window){var d=function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},n=document.createElement(e);return Object.keys(t).forEach(function(e){n.setAttribute(e,t[e])}),n},p=0,n=function(s,e){if(s.getAttribute("maxlength")){var u=s.dataset.counterLabel||e.counterLabel,l=function(e){var n=e.assistDelay,t=e.counterClassName,r=d("span",{class:t,"aria-hidden":"true"}),a=d("span",{style:"position:absolute;overflow:hidden;height:1px;width:1px;padding:0;border:0;clip:rect(1px, 1px, 1px, 1px);clip-path:inset(50%);white-space:nowrap;",id:"short-and-sweet-counter-"+p++,role:"status","aria-live":"polite"}),i=document.createDocumentFragment();i.appendChild(r),i.appendChild(a);var o=null;return{id:a.id,fragment:i,updateText:function(e){r.textContent=e},updateAssist:function(e,t){clearTimeout(o),t?a.textContent=e:o=setTimeout(function(){a.textContent=e},n)},syncAssist:function(){clearTimeout(o),a.textContent=r.textContent},resetAssist:function(){clearTimeout(o),a.textContent=""}}}(e);s.setAttribute("aria-controls",l.id),e.append(s,l.fragment);var c=!0,t=function(){var e,t,n=null!=(e=s.getAttribute("maxlength"))?parseInt(e,10):null,r=s.value.length>n;r&&((t=s).value=s.value.substr(0,t));var a,i=s.value.length,o=(a={maxlength:n,length:i,remaining:n-i},u.replace(/(?:{([a-zA-Z]+)})/g,function(e,t){return a[t]}));l.updateText(o),c?c=!1:l.updateAssist(o,r)};s.addEventListener("focus",l.syncAssist),s.addEventListener("blur",l.resetAssist),s.addEventListener("input",t),t()}},r={counterClassName:"short-and-sweet-counter",counterLabel:"{remaining} characters left",assistDelay:2e3,append:function(e,t){e.parentNode.appendChild(t)}},a=function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};return e.map(function(e){return n(e,i({},r,t))})};return function(e,t){return"string"==typeof e?a([].concat(function(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}(document.querySelectorAll(e))),t):a([e],t)[0]}}}(),e.exports=t.default});document.addEventListener('DOMContentLoaded', function(){shortAndSweet('textarea.charcount', {counterClassName: 'small text-muted'}); });

The same content is in 12 releases, Joomla 4.0.0-beta to 4.0.0-rc5. See them all, or every version of this file.