Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ctrly

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ctrly - npm Package Compare versions

Comparing version 0.4.0 to 0.5.0

71

dist/ctrly.esm.js
/*!
* ctrly v0.4.0
* ctrly v0.5.0
* Copyright (c) 2018 Jan Sorgalla

@@ -539,32 +539,30 @@ * License: MIT

}
ready(function () {
find(controlSelector).forEach(function (control) {
var target = findTarget(control);
if (!target) {
resetControl(control);
return;
find(controlSelector).forEach(function (control) {
var target = findTarget(control);
if (!target) {
resetControl(control);
return;
}
control.setAttribute('aria-controls', target.id);
var labelledBy = findControls(target).map(function (control) {
if (!control.id) {
control.setAttribute('id', 'ctrly-control-' + ++idCounter);
}
control.setAttribute('aria-controls', target.id);
var labelledBy = findControls(target).map(function (control) {
if (!control.id) {
control.setAttribute('id', 'ctrly-control-' + ++idCounter);
}
return control.id;
});
var newLabelledBy = (target.getAttribute('aria-labelledby') || '').split(' ').concat(labelledBy).filter(function (id, pos, arr) {
return id !== '' && arr.indexOf(id) === pos;
});
target.setAttribute('aria-labelledby', newLabelledBy.join(' '));
if (control.getAttribute('aria-expanded') === 'true' || control.hasAttribute('data-ctrly-open')) {
open(control);
return;
}
control.setAttribute('aria-expanded', 'false');
target.setAttribute('aria-hidden', 'true');
target.removeAttribute('tabindex');
return control.id;
});
var newLabelledBy = (target.getAttribute('aria-labelledby') || '').split(' ').concat(labelledBy).filter(function (id, pos, arr) {
return id !== '' && arr.indexOf(id) === pos;
});
target.setAttribute('aria-labelledby', newLabelledBy.join(' '));
if (control.getAttribute('aria-expanded') === 'true' || control.hasAttribute('data-ctrly-open')) {
open(control);
return;
}
control.setAttribute('aria-expanded', 'false');
target.setAttribute('aria-hidden', 'true');
target.removeAttribute('tabindex');
});
}
function destroy() {
if (removeControlClick) {
function reset(fullReset) {
if (fullReset && removeControlClick) {
removeControlClick();

@@ -574,5 +572,11 @@ removeControlClick = null;

find(controlSelector).forEach(function (control) {
if (fullReset) {
resetControl(control);
}
var target = findTarget(control);
if (target) {
close(target, false);
if (fullReset) {
target.removeAttribute('aria-hidden');
}
}

@@ -587,8 +591,15 @@ });

}
function closeAll() {
reset(false);
}
function destroy() {
reset(true);
}
if (options.autoInit) {
init();
ready(init);
}
return {
init: init,
destroy: destroy
closeAll: closeAll,
destroy: destroy,
init: init
};

@@ -595,0 +606,0 @@ }

/*!
* ctrly v0.4.0
* ctrly v0.5.0
* Copyright (c) 2018 Jan Sorgalla

@@ -545,32 +545,30 @@ * License: MIT

}
ready(function () {
find(controlSelector).forEach(function (control) {
var target = findTarget(control);
if (!target) {
resetControl(control);
return;
find(controlSelector).forEach(function (control) {
var target = findTarget(control);
if (!target) {
resetControl(control);
return;
}
control.setAttribute('aria-controls', target.id);
var labelledBy = findControls(target).map(function (control) {
if (!control.id) {
control.setAttribute('id', 'ctrly-control-' + ++idCounter);
}
control.setAttribute('aria-controls', target.id);
var labelledBy = findControls(target).map(function (control) {
if (!control.id) {
control.setAttribute('id', 'ctrly-control-' + ++idCounter);
}
return control.id;
});
var newLabelledBy = (target.getAttribute('aria-labelledby') || '').split(' ').concat(labelledBy).filter(function (id, pos, arr) {
return id !== '' && arr.indexOf(id) === pos;
});
target.setAttribute('aria-labelledby', newLabelledBy.join(' '));
if (control.getAttribute('aria-expanded') === 'true' || control.hasAttribute('data-ctrly-open')) {
open(control);
return;
}
control.setAttribute('aria-expanded', 'false');
target.setAttribute('aria-hidden', 'true');
target.removeAttribute('tabindex');
return control.id;
});
var newLabelledBy = (target.getAttribute('aria-labelledby') || '').split(' ').concat(labelledBy).filter(function (id, pos, arr) {
return id !== '' && arr.indexOf(id) === pos;
});
target.setAttribute('aria-labelledby', newLabelledBy.join(' '));
if (control.getAttribute('aria-expanded') === 'true' || control.hasAttribute('data-ctrly-open')) {
open(control);
return;
}
control.setAttribute('aria-expanded', 'false');
target.setAttribute('aria-hidden', 'true');
target.removeAttribute('tabindex');
});
}
function destroy() {
if (removeControlClick) {
function reset(fullReset) {
if (fullReset && removeControlClick) {
removeControlClick();

@@ -580,5 +578,11 @@ removeControlClick = null;

find(controlSelector).forEach(function (control) {
if (fullReset) {
resetControl(control);
}
var target = findTarget(control);
if (target) {
close(target, false);
if (fullReset) {
target.removeAttribute('aria-hidden');
}
}

@@ -593,8 +597,15 @@ });

}
function closeAll() {
reset(false);
}
function destroy() {
reset(true);
}
if (options.autoInit) {
init();
ready(init);
}
return {
init: init,
destroy: destroy
closeAll: closeAll,
destroy: destroy,
init: init
};

@@ -601,0 +612,0 @@ }

/*!
* ctrly v0.4.0
* ctrly v0.5.0
* Copyright (c) 2018 Jan Sorgalla
* License: MIT
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.ctrly=t()}(this,function(){"use strict";function f(){try{var e=document.activeElement;return e&&e.nodeName?e:document.body}catch(e){return document.body}}function r(e){for(var t=[];e&&e.parentNode&&1===e.parentNode.nodeType;)e=e.parentNode,t.push(e);return t}function p(e){var t,n;(1<arguments.length&&void 0!==arguments[1]?arguments[1]:{}).restoreScrollPosition&&(n=r(e).map(function(e){return[e,e.scrollTop,e.scrollLeft]}),t=function(){n.forEach(function(e){e[0].scrollTop=e[1],e[0].scrollLeft=e[2]})});try{e.focus()}catch(e){}t&&t()}function v(e,t){var n=1<arguments.length?t:document;return n&&"function"==typeof n.querySelectorAll?[].slice.call(n.querySelectorAll(e)):[]}function n(e,t){if(!e)return!1;var n=e.matches||e.webkitMatchesSelector||e.msMatchesSelector;return"function"==typeof n&&n.call(e,t)}function b(e,t){if(!e)return null;if("function"==typeof e.closest)return e.closest(t);do{if(n(e,t))return e;e=e.parentNode}while(e&&1===e.nodeType);return null}var t;function a(){if(t)return t;t={capture:!1,once:!1,passive:!1};var e={get capture(){return!(t.capture=!0)},get once(){return!(t.once=!0)},get passive(){return!(t.passive=!0)}};return window.addEventListener("test",e,e),window.removeEventListener("test",e,e),t}function h(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},t=a(),n=t.once,r=t.passive,o=t.capture;return n||r||o?(n||delete e.once,r||delete e.passive,o||delete e.capture,e):Boolean(e.capture)}function m(t,e,n){var r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{capture:!1};if(!t||"function"!=typeof t.addEventListener)return function(){};var o=n,i=function(){!function(e,t,n){var r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{capture:!1};e&&"function"==typeof e.removeEventListener&&e.removeEventListener(t,n,h(r))}(t,e,o,r)};return r.once&&!a().once&&(o=function(e){i(),n.call(t,e)}),t.addEventListener(e,o,h(r)),i}var o=["a[href]","area[href]","input","select","textarea","button","iframe","object","audio[controls]","video[controls]","[contenteditable]","[tabindex]"].join(","),i=/^(input|select|textarea|button|object)$/;function u(e){var t=e.nodeName.toLowerCase();if("area"===t)return function(e){var t=e.parentNode,n=t.name;if(!e.href||!n||"map"!==t.nodeName.toLowerCase())return!1;var r=v('img[usemap="#'.concat(n,'"]'));return 0<r.length&&s(r[0])}(e);if(e.disabled)return!1;if(i.test(t)){var n=b(e,"fieldset");if(n&&n.disabled)return!1}return s(e)}function c(e){var t=d(e);return u(e)&&0<=t}function l(e,t){var n=d(e,!0),r=d(t,!0);return n===r?2&e.compareDocumentPosition(t)?1:-1:n-r}function s(e){var t=getComputedStyle(e);return"hidden"!==t.visibility&&"collapse"!==t.visibility&&"none"!==t.display&&r(e).every(function(e){return"none"!==getComputedStyle(e).display})}function d(e){var t=1<arguments.length&&void 0!==arguments[1]&&arguments[1],n=parseInt(e.getAttribute("tabindex"),10);return isNaN(n)?0:t&&n<0?0:n}function y(e){return v(o,0<arguments.length?e:document).filter(c).sort(l)}var g={selector:"[data-ctrly]",context:null,focusTarget:!0,closeOnBlur:!0,closeOnEsc:!0,closeOnOutsideClick:!0,closeOnScroll:!1,trapFocus:!1,allowMultiple:!1,on:null,autoInit:!0};function A(e){return"which"in e?e.which:e.keyCode}function E(e){return v('[aria-controls="'.concat(e.id,'"]'))}function w(e){return document.getElementById(e.getAttribute("aria-controls")||e.getAttribute("data-ctrly"))}function x(e){e.removeAttribute("aria-controls"),e.removeAttribute("aria-expanded")}var O=0;return function(){var n,r,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},a=(n={},[g,e].forEach(function(e){for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(n[t]=e[t])}),n),u=a.selector,o=a.on||{},c={};function l(e,t){return("function"!=typeof o[t]||!1!==o[t](e))&&!1!==function(e,t){var n,r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};if(!e||"function"!=typeof e.dispatchEvent)return!0;r.bubbles=r.bubbles||!1,r.cancelable=r.cancelable||!1,r.composed=r.composed||!1,r.detail=r.detail||null;try{n=new CustomEvent(t,r)}catch(e){(n=document.createEvent("CustomEvent")).initCustomEvent(t,r.bubbles,r.cancelable,r.detail)}return e.dispatchEvent(n)}(e,"ctrly:".concat(t),{bubbles:!0,cancelable:!0})}function s(e){var t=!(1<arguments.length&&void 0!==arguments[1])||arguments[1];if(!e)return!1;if(!e.hasAttribute("data-ctrly-opened"))return!1;if(!l(e,"close"))return!1;var n=f(),r=c[e.id]||{},o=r.lastActiveElement,i=r.destroy;return delete c[e.id],i&&i(),E(e).forEach(function(e){e.setAttribute("aria-expanded","false")}),e.removeAttribute("data-ctrly-opened"),e.setAttribute("aria-hidden","true"),e.removeAttribute("tabindex"),e.blur(),t&&o&&e.contains(n)&&p(o,{restoreScrollPosition:!0}),l(e,"closed"),e}function i(n){var e;v(u,(e=n,a.context?b(e,a.context):document)).forEach(function(e){var t=w(e);t&&t.id!==n.id&&s(t,!1)})}function d(e){var t=w(e);return t?!t.hasAttribute("data-ctrly-opened")&&!!l(t,"open")&&(c[t.id]={lastActiveElement:f(),destroy:function(e,i){var t=[];if(a.closeOnBlur&&!a.trapFocus&&t.push(m(document,"focusin",function(e){i.contains(e.target)||s(i,!1)},{capture:!0,passive:!0})),a.closeOnEsc&&t.push(m(document,"keydown",function(e){27===A(e)&&s(i)&&e.preventDefault()})),a.closeOnOutsideClick&&t.push(m(document,"click",function(e){1!==A(e)||i.contains(e.target)||b(e.target,u)||s(i)},{passive:!0})),a.closeOnScroll){var n=!1,r=function(){n=!0},o=function(){n=!1};t.push(m(i,"mouseenter",r,{passive:!0})),t.push(m(i,"mouseleave",o,{passive:!0})),t.push(m(i,"touchstart",r,{passive:!0})),t.push(m(i,"touchend",o,{passive:!0})),t.push(m(window,"scroll",function(){n||s(i)},{passive:!0}))}return a.trapFocus&&t.push(m(document,"keydown",function(e){if(9===A(e)){var t=y(i);if(!t[0])return e.preventDefault(),void p(i);var n=f(),r=t[0],o=t[t.length-1];if(e.shiftKey&&n===r)return e.preventDefault(),void p(o);e.shiftKey||n!==o||(p(r),e.preventDefault())}})),function(){for(;t.length;)t.shift().call()}}(0,t)},E(t).forEach(function(e){e.setAttribute("aria-expanded","true")}),t.setAttribute("data-ctrly-opened",""),t.setAttribute("aria-hidden","false"),t.setAttribute("tabindex","-1"),l(t,"opened"),t):(x(e),!1)}function t(){var e,t;r||(r=function(e,t,n,r){var o=4<arguments.length&&void 0!==arguments[4]?arguments[4]:{capture:!1},i=!0===o.once;delete o.once;var a=m(e,t,function(e){var t=b(e.target,n);t&&(i&&a(),r.call(t,e,t))},o);return a}(document,"click",u,function(e,t){if(1===A(e)){var n=w(t);n?"true"!==t.getAttribute("aria-expanded")?(a.allowMultiple||i(n),d(t),n&&(e.preventDefault(),a.focusTarget&&p(y(n)[0]||n),n.scrollTop=0,n.scrollLeft=0)):s(n)&&e.preventDefault():s(function(e){for(var t=e;t;){if(t.id&&c[t.id])return t;t=t.parentElement}}(t))&&e.preventDefault()}})),e=function(){v(u).forEach(function(e){var t=w(e);if(t){e.setAttribute("aria-controls",t.id);var n=E(t).map(function(e){return e.id||e.setAttribute("id","ctrly-control-"+ ++O),e.id}),r=(t.getAttribute("aria-labelledby")||"").split(" ").concat(n).filter(function(e,t,n){return""!==e&&n.indexOf(e)===t});t.setAttribute("aria-labelledby",r.join(" ")),"true"===e.getAttribute("aria-expanded")||e.hasAttribute("data-ctrly-open")?d(e):(e.setAttribute("aria-expanded","false"),t.setAttribute("aria-hidden","true"),t.removeAttribute("tabindex"))}else x(e)})},"complete"!==(t=document.readyState)&&"interactive"!==t?document.addEventListener("DOMContentLoaded",function(){e()},h({capture:!0,once:!0,passive:!0})):setTimeout(e,0)}return a.autoInit&&t(),{init:t,destroy:function(){for(var e in r&&(r(),r=null),v(u).forEach(function(e){var t=w(e);t&&s(t,!1)}),c)Object.prototype.hasOwnProperty.call(c,e)&&(c[e].destroy(),delete c[e])}}}});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.ctrly=t()}(this,function(){"use strict";function b(){try{var e=document.activeElement;return e&&e.nodeName?e:document.body}catch(e){return document.body}}function r(e){for(var t=[];e&&e.parentNode&&1===e.parentNode.nodeType;)e=e.parentNode,t.push(e);return t}function h(e){var t,n;(1<arguments.length&&void 0!==arguments[1]?arguments[1]:{}).restoreScrollPosition&&(n=r(e).map(function(e){return[e,e.scrollTop,e.scrollLeft]}),t=function(){n.forEach(function(e){e[0].scrollTop=e[1],e[0].scrollLeft=e[2]})});try{e.focus()}catch(e){}t&&t()}function m(e,t){var n=1<arguments.length?t:document;return n&&"function"==typeof n.querySelectorAll?[].slice.call(n.querySelectorAll(e)):[]}function n(e,t){if(!e)return!1;var n=e.matches||e.webkitMatchesSelector||e.msMatchesSelector;return"function"==typeof n&&n.call(e,t)}function y(e,t){if(!e)return null;if("function"==typeof e.closest)return e.closest(t);do{if(n(e,t))return e;e=e.parentNode}while(e&&1===e.nodeType);return null}var t;function a(){if(t)return t;t={capture:!1,once:!1,passive:!1};var e={get capture(){return!(t.capture=!0)},get once(){return!(t.once=!0)},get passive(){return!(t.passive=!0)}};return window.addEventListener("test",e,e),window.removeEventListener("test",e,e),t}function g(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},t=a(),n=t.once,r=t.passive,o=t.capture;return n||r||o?(n||delete e.once,r||delete e.passive,o||delete e.capture,e):Boolean(e.capture)}function A(t,e,n){var r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{capture:!1};if(!t||"function"!=typeof t.addEventListener)return function(){};var o=n,i=function(){!function(e,t,n){var r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{capture:!1};e&&"function"==typeof e.removeEventListener&&e.removeEventListener(t,n,g(r))}(t,e,o,r)};return r.once&&!a().once&&(o=function(e){i(),n.call(t,e)}),t.addEventListener(e,o,g(r)),i}var o=["a[href]","area[href]","input","select","textarea","button","iframe","object","audio[controls]","video[controls]","[contenteditable]","[tabindex]"].join(","),i=/^(input|select|textarea|button|object)$/;function u(e){var t=e.nodeName.toLowerCase();if("area"===t)return function(e){var t=e.parentNode,n=t.name;if(!e.href||!n||"map"!==t.nodeName.toLowerCase())return!1;var r=m('img[usemap="#'.concat(n,'"]'));return 0<r.length&&s(r[0])}(e);if(e.disabled)return!1;if(i.test(t)){var n=y(e,"fieldset");if(n&&n.disabled)return!1}return s(e)}function c(e){var t=d(e);return u(e)&&0<=t}function l(e,t){var n=d(e,!0),r=d(t,!0);return n===r?2&e.compareDocumentPosition(t)?1:-1:n-r}function s(e){var t=getComputedStyle(e);return"hidden"!==t.visibility&&"collapse"!==t.visibility&&"none"!==t.display&&r(e).every(function(e){return"none"!==getComputedStyle(e).display})}function d(e){var t=1<arguments.length&&void 0!==arguments[1]&&arguments[1],n=parseInt(e.getAttribute("tabindex"),10);return isNaN(n)?0:t&&n<0?0:n}function E(e){return m(o,0<arguments.length?e:document).filter(c).sort(l)}var w={selector:"[data-ctrly]",context:null,focusTarget:!0,closeOnBlur:!0,closeOnEsc:!0,closeOnOutsideClick:!0,closeOnScroll:!1,trapFocus:!1,allowMultiple:!1,on:null,autoInit:!0};function x(e){return"which"in e?e.which:e.keyCode}function O(e){return m('[aria-controls="'.concat(e.id,'"]'))}function L(e){return document.getElementById(e.getAttribute("aria-controls")||e.getAttribute("data-ctrly"))}function C(e){e.removeAttribute("aria-controls"),e.removeAttribute("aria-expanded")}var S=0;return function(){var n,t,e,r,o=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},a=(n={},[w,o].forEach(function(e){for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(n[t]=e[t])}),n),u=a.selector,i=a.on||{},c={};function l(e,t){return("function"!=typeof i[t]||!1!==i[t](e))&&!1!==function(e,t){var n,r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};if(!e||"function"!=typeof e.dispatchEvent)return!0;r.bubbles=r.bubbles||!1,r.cancelable=r.cancelable||!1,r.composed=r.composed||!1,r.detail=r.detail||null;try{n=new CustomEvent(t,r)}catch(e){(n=document.createEvent("CustomEvent")).initCustomEvent(t,r.bubbles,r.cancelable,r.detail)}return e.dispatchEvent(n)}(e,"ctrly:".concat(t),{bubbles:!0,cancelable:!0})}function s(e){var t=!(1<arguments.length&&void 0!==arguments[1])||arguments[1];if(!e)return!1;if(!e.hasAttribute("data-ctrly-opened"))return!1;if(!l(e,"close"))return!1;var n=b(),r=c[e.id]||{},o=r.lastActiveElement,i=r.destroy;return delete c[e.id],i&&i(),O(e).forEach(function(e){e.setAttribute("aria-expanded","false")}),e.removeAttribute("data-ctrly-opened"),e.setAttribute("aria-hidden","true"),e.removeAttribute("tabindex"),e.blur(),t&&o&&e.contains(n)&&h(o,{restoreScrollPosition:!0}),l(e,"closed"),e}function d(n){var e;m(u,(e=n,a.context?y(e,a.context):document)).forEach(function(e){var t=L(e);t&&t.id!==n.id&&s(t,!1)})}function f(e){var t=L(e);return t?!t.hasAttribute("data-ctrly-opened")&&!!l(t,"open")&&(c[t.id]={lastActiveElement:b(),destroy:function(e,i){var t=[];if(a.closeOnBlur&&!a.trapFocus&&t.push(A(document,"focusin",function(e){i.contains(e.target)||s(i,!1)},{capture:!0,passive:!0})),a.closeOnEsc&&t.push(A(document,"keydown",function(e){27===x(e)&&s(i)&&e.preventDefault()})),a.closeOnOutsideClick&&t.push(A(document,"click",function(e){1!==x(e)||i.contains(e.target)||y(e.target,u)||s(i)},{passive:!0})),a.closeOnScroll){var n=!1,r=function(){n=!0},o=function(){n=!1};t.push(A(i,"mouseenter",r,{passive:!0})),t.push(A(i,"mouseleave",o,{passive:!0})),t.push(A(i,"touchstart",r,{passive:!0})),t.push(A(i,"touchend",o,{passive:!0})),t.push(A(window,"scroll",function(){n||s(i)},{passive:!0}))}return a.trapFocus&&t.push(A(document,"keydown",function(e){if(9===x(e)){var t=E(i);if(!t[0])return e.preventDefault(),void h(i);var n=b(),r=t[0],o=t[t.length-1];if(e.shiftKey&&n===r)return e.preventDefault(),void h(o);e.shiftKey||n!==o||(h(r),e.preventDefault())}})),function(){for(;t.length;)t.shift().call()}}(0,t)},O(t).forEach(function(e){e.setAttribute("aria-expanded","true")}),t.setAttribute("data-ctrly-opened",""),t.setAttribute("aria-hidden","false"),t.setAttribute("tabindex","-1"),l(t,"opened"),t):(C(e),!1)}function p(){t||(t=function(e,t,n,r){var o=4<arguments.length&&void 0!==arguments[4]?arguments[4]:{capture:!1},i=!0===o.once;delete o.once;var a=A(e,t,function(e){var t=y(e.target,n);t&&(i&&a(),r.call(t,e,t))},o);return a}(document,"click",u,function(e,t){if(1===x(e)){var n=L(t);n?"true"!==t.getAttribute("aria-expanded")?(a.allowMultiple||d(n),f(t),n&&(e.preventDefault(),a.focusTarget&&h(E(n)[0]||n),n.scrollTop=0,n.scrollLeft=0)):s(n)&&e.preventDefault():s(function(e){for(var t=e;t;){if(t.id&&c[t.id])return t;t=t.parentElement}}(t))&&e.preventDefault()}})),m(u).forEach(function(e){var t=L(e);if(t){e.setAttribute("aria-controls",t.id);var n=O(t).map(function(e){return e.id||e.setAttribute("id","ctrly-control-"+ ++S),e.id}),r=(t.getAttribute("aria-labelledby")||"").split(" ").concat(n).filter(function(e,t,n){return""!==e&&n.indexOf(e)===t});t.setAttribute("aria-labelledby",r.join(" ")),"true"===e.getAttribute("aria-expanded")||e.hasAttribute("data-ctrly-open")?f(e):(e.setAttribute("aria-expanded","false"),t.setAttribute("aria-hidden","true"),t.removeAttribute("tabindex"))}else C(e)})}function v(n){for(var e in n&&t&&(t(),t=null),m(u).forEach(function(e){n&&C(e);var t=L(e);t&&(s(t,!1),n&&t.removeAttribute("aria-hidden"))}),c)Object.prototype.hasOwnProperty.call(c,e)&&(c[e].destroy(),delete c[e])}return a.autoInit&&(e=p,"complete"!==(r=document.readyState)&&"interactive"!==r?document.addEventListener("DOMContentLoaded",function(){e()},g({capture:!0,once:!0,passive:!0})):setTimeout(e,0)),{closeAll:function(){v(!1)},destroy:function(){v(!0)},init:p}}});
{
"name": "ctrly",
"version": "0.4.0",
"version": "0.5.0",
"description": "Lightweight and dependency-free content toggling with a focus on accessibility.",

@@ -5,0 +5,0 @@ "repository": "git@github.com:jsor/ctrly.git",

@@ -135,8 +135,23 @@ ctrly

* [closeAll](#closeall)
* [destroy](#destroy)
* [init](#init)
### closeAll
This function closes all open targets.
#### Example
```js
const { closeAll } = ctrly();
closeAll();
```
### destroy
This function closes all open targets and unbinds all event listeners.
This function reverts all elements to their initial state and unbinds all event
listeners.

@@ -143,0 +158,0 @@ #### Example

@@ -364,47 +364,45 @@ import {

ready(() => {
find(controlSelector).forEach(control => {
const target = findTarget(control);
find(controlSelector).forEach(control => {
const target = findTarget(control);
if (!target) {
resetControl(control);
return;
if (!target) {
resetControl(control);
return;
}
control.setAttribute('aria-controls', target.id);
const labelledBy = findControls(target).map(control => {
if (!control.id) {
control.setAttribute('id', 'ctrly-control-' + ++idCounter);
}
control.setAttribute('aria-controls', target.id);
return control.id;
});
const labelledBy = findControls(target).map(control => {
if (!control.id) {
control.setAttribute('id', 'ctrly-control-' + ++idCounter);
}
return control.id;
const newLabelledBy = (target.getAttribute('aria-labelledby') || '')
.split(' ')
.concat(labelledBy)
.filter((id, pos, arr) => {
return id !== '' && arr.indexOf(id) === pos;
});
const newLabelledBy = (target.getAttribute('aria-labelledby') || '')
.split(' ')
.concat(labelledBy)
.filter((id, pos, arr) => {
return id !== '' && arr.indexOf(id) === pos;
});
target.setAttribute('aria-labelledby', newLabelledBy.join(' '));
target.setAttribute('aria-labelledby', newLabelledBy.join(' '));
if (
control.getAttribute('aria-expanded') === 'true' ||
control.hasAttribute('data-ctrly-open')
) {
open(control);
return;
}
if (
control.getAttribute('aria-expanded') === 'true' ||
control.hasAttribute('data-ctrly-open')
) {
open(control);
return;
}
control.setAttribute('aria-expanded', 'false');
target.setAttribute('aria-hidden', 'true');
target.removeAttribute('tabindex');
});
control.setAttribute('aria-expanded', 'false');
target.setAttribute('aria-hidden', 'true');
target.removeAttribute('tabindex');
});
}
function destroy() {
if (removeControlClick) {
function reset(fullReset) {
if (fullReset && removeControlClick) {
removeControlClick();

@@ -415,2 +413,6 @@ removeControlClick = null;

find(controlSelector).forEach(control => {
if (fullReset) {
resetControl(control);
}
const target = findTarget(control);

@@ -420,2 +422,6 @@

close(target, false);
if (fullReset) {
target.removeAttribute('aria-hidden');
}
}

@@ -433,7 +439,19 @@ });

function closeAll() {
reset(false);
}
function destroy() {
reset(true);
}
if (options.autoInit) {
init();
ready(init);
}
return {init, destroy};
return {
closeAll,
destroy,
init
};
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc