trAvis - MANAGER
Edit File: envira-permissions-min.js
(()=>{var n={311:e=>{"use strict";e.exports=jQuery}},r={};function o(e){var t=r[e];return void 0!==t||(t=r[e]={exports:{}},n[e](t,t.exports,o)),t.exports}function f(e,t){var n,r,o,i,s="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(s)return o=!(r=!0),{s:function(){s=s.call(e)},n:function(){var e=s.next();return r=e.done,e},e:function(e){o=!0,n=e},f:function(){try{r||null==s.return||s.return()}finally{if(o)throw n}}};if(Array.isArray(e)||(s=function(e,t){{var n;if(e)return"string"==typeof e?a(e,t):"Map"===(n="Object"===(n={}.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:n)||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?a(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length)return s&&(e=s),i=0,{s:t=function(){},n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:t};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}o(311)(document).ready(function(l){for(var e=document.getElementById("envira-permissions-dialog-id"),u=null,u=new A11yDialog(e),t=document.getElementsByClassName("envira-permissions-select-field"),d=[],n=0;n<t.length;n++){var r,o=t[n];0<o.length&&(r=o.getAttribute("id")+"_select",d[r]=new Choices(o,{allowHTML:!0,searchChoices:!1,searchEnabled:!1,removeItemButton:!0,itemSelectText:"",addItemText:"",shouldSort:!1,shouldSortItems:!1,classNames:{containerInner:"choices__inner roles_inner",containerOuter:"choices roles_inner"}}),o.addEventListener("addItem",function(e){s(l(this).attr("id"),e.detail.value,e.detail.label,"add"),i()},!1),o.addEventListener("removeItem",function(e){s(l(this).attr("id"),e.detail.value,e.detail.label,"remove"),i()},!1))}function i(){l(".choices__item").each(function(){"administrator"===l(this).attr("data-value")&&(l(this).removeClass("choices__item--selectable"),l(this).removeAttr("data-deletable"),l(this).removeAttr("data-item"),l(this).addClass("demos"),l(this).off("click"))}),l(".choices__button").each(function(){"Remove item: 'administrator'"===l(this).attr("aria-label")&&l(this).hide()})}function s(e,t,n,r){var o,i,s,a,c;enviraPermissions&&enviraPermissions.hasOwnProperty(e)&&(o=enviraPermissionsLabels[e],i=enviraPermissions[e],s=e+"_select",e="",c=1<(a=(a=function(i,s,a){for(var c=[],l=0;l<i.length;l++)!function(){var e,t=i[l],n=[],r=f(document.querySelector("#"+t).selectedOptions);try{for(r.s();!(e=r.n()).done;){var o=e.value;n.push(o.value)}}catch(e){r.e(e)}finally{r.f()}"add"===s?-1===n.indexOf(a)&&(n.push(a),c.push(enviraPermissionsLabels[t])):-1!==n.indexOf(a)&&(n=n.filter(function(e){return e!==a}),c=c.filter(function(e){return e!==enviraPermissionsLabels[t]}))}();return c}(i,r,t)).filter(function(e){return e!==o})).length?"permissions":"permission","add"===r?(e="<p>In order to give <strong>".concat(o,"</strong> permission,\n\t\t\t\t<strong>").concat(a,"</strong> ").concat(c," ").concat(1<a.length?"are":"is"," also required.</p>"),e+="<p>Would you like to also grant <strong>".concat(a,"</strong> ").concat(c," to ").concat(n,"?</p>")):(e="<p>In order to remove <strong>".concat(o,"</strong> permission,\n\t\t\t\t<strong>").concat(a,"</strong> ").concat(c," will also be removed.</p>"),e+="<p>Would you like to also remove <strong>".concat(a,"</strong> ").concat(c," to <strong>").concat(n,"</strong>?</p>")),0<a.length?(l("#envira-permissions-alert").html(e),u.show(),l(".envira-permissions-yes").on("click",function(){m(i,t,r),u.hide()}),l(".envira-permissions-cancel").on("click",function(){"add"===r&&d[s].removeActiveItemsByValue(t),"remove"===r&&d[s].setChoiceByValue(t),u.hide()})):m(i,t,r),setTimeout(function(){return d[s].hideDropdown()},0))}function m(a,c,l){for(var u=0;u<a.length;u++)!function(){var e,t=a[u],n=document.querySelector("#"+t).selectedOptions,r=[],o=enviraPermissionsLabels[t],i=f(n);try{for(i.s();!(e=i.n()).done;){var s=e.value;r.push(s.value)}}catch(e){i.e(e)}finally{i.f()}t=Object.keys(enviraPermissionsLabels).find(function(e){return enviraPermissionsLabels[e]===o}),n=d[t+"_select"];"add"===l?-1===r.indexOf(c)&&(r.push(c),n.setChoiceByValue(c)):-1!==r.indexOf(c)&&(r=r.filter(function(e){return e!==c}),n.removeActiveItemsByValue(c))}()}i()})})();