synapse-registration/static/halfmoon.min.js

12 lines
11 KiB
JavaScript
Raw Permalink Normal View History

2023-08-16 16:00:44 +02:00
/*
* -----------------------------------------------------------------------------
* Halfmoon JS
* Version: 1.1.1
* https://www.gethalfmoon.com
* Copyright, Halfmoon UI
* Licensed under MIT (https://www.gethalfmoon.com/license)
* -----------------------------------------------------------------------------
* The above notice must be included in its entirety when this file is used.
*/
Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector),Element.prototype.closest||(Element.prototype.closest=function(e){var t=this;do{if(t.matches(e))return t;t=t.parentElement||t.parentNode}while(null!==t&&1===t.nodeType);return null}),"document"in self&&("classList"in document.createElement("_")&&(!document.createElementNS||"classList"in document.createElementNS("http://www.w3.org/2000/svg","g"))||function(e){"use strict";if("Element"in e){var t="classList",o="prototype",a=e.Element[o],s=Object,n=String[o].trim||function(){return this.replace(/^\s+|\s+$/g,"")},i=Array[o].indexOf||function(e){for(var t=0,o=this.length;t<o;t++)if(t in this&&this[t]===e)return t;return-1},r=function(e,t){this.name=e,this.code=DOMException[e],this.message=t},d=function(e,t){if(""===t)throw new r("SYNTAX_ERR","The token must not be empty.");if(/\s/.test(t))throw new r("INVALID_CHARACTER_ERR","The token must not contain space characters.");return i.call(e,t)},l=function(e){for(var t=n.call(e.getAttribute("class")||""),o=t?t.split(/\s+/):[],a=0,s=o.length;a<s;a++)this.push(o[a]);this._updateClassName=function(){e.setAttribute("class",this.toString())}},c=l[o]=[],m=function(){return new l(this)};if(r[o]=Error[o],c.item=function(e){return this[e]||null},c.contains=function(e){return~d(this,e+"")},c.add=function(){for(var e,t=arguments,o=0,a=t.length,s=!1;~d(this,e=t[o]+"")||(this.push(e),s=!0),++o<a;);s&&this._updateClassName()},c.remove=function(){var e,t,o=arguments,a=0,s=o.length,n=!1;do{for(t=d(this,e=o[a]+"");~t;)this.splice(t,1),n=!0,t=d(this,e)}while(++a<s);n&&this._updateClassName()},c.toggle=function(e,t){var o=this.contains(e),a=o?!0!==t&&"remove":!1!==t&&"add";return a&&this[a](e),!0===t||!1===t?t:!o},c.replace=function(e,t){var o=d(e+"");~o&&(this.splice(o,1,t),this._updateClassName())},c.toString=function(){return this.join(" ")},s.defineProperty){var h={get:m,enumerable:!0,configurable:!0};try{s.defineProperty(a,t,h)}catch(e){void 0!==e.number&&-2146823252!==e.number||(h.enumerable=!1,s.defineProperty(a,t,h))}}else s[o].__defineGetter__&&a.__defineGetter__(t,m)}}(self),function(){"use strict";var e,o,t=document.createElement("_");t.classList.add("c1","c2"),t.classList.contains("c2")||((e=function(e){var a=DOMTokenList.prototype[e];DOMTokenList.prototype[e]=function(e){for(var t=arguments.length,o=0;o<t;o++)e=arguments[o],a.call(this,e)}})("add"),e("remove")),t.classList.toggle("c3",!1),t.classList.contains("c3")&&(o=DOMTokenList.prototype.toggle,DOMTokenList.prototype.toggle=function(e,t){return 1 in arguments&&!this.contains(e)==!t?t:o.call(this,e)}),"replace"in document.createElement("_").classList||(DOMTokenList.prototype.replace=function(e,t){var o=this.toString().split(" "),a=o.indexOf(e+"");~a&&(o=o.slice(a),this.remove.apply(this,o),this.add(t),this.add.apply(this,o.slice(1)))}),t=null}());var halfmoon={pageWrapper:document.getElementsByClassName("page-wrapper")[0],stickyAlerts:document.getElementsByClassName("sticky-alerts")[0],darkModeOn:!1,createCookie:function(e,t,o){var a,s=o?((a=new Date).setTime(a.getTime()+24*o*60*60*1e3),"; expires="+a.toGMTString()):"";document.cookie=e+"="+t+s+"; path=/"},readCookie:function(e){for(var t=e+"=",o=document.cookie.split(";"),a=0;a<o.length;a++){for(var s=o[a];" "===s.charAt(0);)s=s.substring(1,s.length);if(0===s.indexOf(t))return s.substring(t.length,s.length)}return null},eraseCookie:function(e){this.createCookie(e,"",-1)},toggleDarkMode:function(){document.body.classList.contains("dark-mode")?(document.body.classList.remove("dark-mode"),this.darkModeOn=!1,this.createCookie("halfmoon_preferredMode","light-mode",365)):(document.body.classList.add("dark-mode"),this.darkModeOn=!0,this.createCookie("halfmoon_preferredMode","dark-mode",365))},getPreferredMode:function(){return this.readCookie("halfmoon_preferredMode")?this.readCookie("halfmoon_preferredMode"):"not-set"},toggleSidebar:function(){this.pageWrapper&&(this.pageWrapper.getAttribute("data-sidebar-hidden")?this.pageWrapper.removeAttribute("data-sideb