/*
# -----------------------------------------------------------------------------
# ~/assets/themes/j1/modules/bsThemeSwitcher/js/switcher.js
# Provides Javascript functions for Bootstrap ThemeSwitcher
#
# Product/Info:
# https://jekyll.one
# https://github.com/jguadagno/bootstrapThemeSwitcher
#
# Copyright (C) 2023 Juergen Adams
# Copyright (C) 2014 Joseph Guadagno
#
# J1 Template is licensed under the MIT License.
# See: https://github.com/jekyll-one-org/j1-template/blob/main/LICENSE.md
# Bootstrap Theme Switcher is licensed under the MIT License.
# See: https://github.com/jguadagno/bootstrapThemeSwitcher
# -----------------------------------------------------------------------------
# NOTE: This modules is MODIFIED to be used with MobileMenu (mmenuLight).
# The original version cannot be used with J1 for theme menu creation!
# -----------------------------------------------------------------------------
*/
;"use strict";!function(e,t,o,s){var i=e.fn.bootstrapThemeSwitcher,n=j1.getCookieNames(),r=j1.findCookie("_ga"),a=j1.findCookie("j1"),h=new liteURL(t.location.href),c=h.hostname,l=(c.substring(c.lastIndexOf(".",c.lastIndexOf(".")-1)+1),!!h.protocol.includes("https")),m=log4javascript.getLogger("j1.core.switcher"),d={},u=function(t,o){return this.$element=e(t),this.settings=e.extend({},e.fn.bootstrapThemeSwitcher.defaults,o),this.themesList=[],this.getThemes(),this};u.prototype={clear:function(){return m.debug("\nbootstrapThemeSwitcher.clear"),this.$element.each(function(){this.$element.empty()})},update:function(){m.debug("\nbootstrapThemeSwitcher.update"),this.getThemes()},checkStyleSheetByName:function(e){for(var t=!1,s=new RegExp("/"+e+"/","i"),i=0;i").attr("class",h).append(''+o.name+"").on("click",function(){l.loadFromBootswatch?s.switchTheme(o.name,o.css):s.switchTheme(o.name,o.cssCdn),e(this).parent().find("li").removeClass("active"),e(this).addClass("active")});s.$element.append(n)})}else if(this.$element.is("select")){var f;m.debug("\nbootstrapThemeSelector: SELECT element selected"),this.$element.empty(),e.each(this.themesList,function(e,t){f=null,t.name===i&&(f="selected"),l.loadFromBootswatch?s.$element.append(""):s.$element.append("")}),this.$element.on("change",function(){var t=e("option:selected",this);s.switchTheme(t.text(),t.val())})}else m.info("\nbootstrapThemeSelector: no UL or SELECT element found"),m.error("\nbootstrapThemeSelector: failed")},getThemes:function(){var t=this;null!==this.settings.localFeed&&""!==this.settings.localFeed?e.ajax({url:this.settings.localFeed,dataType:"json",success:function(e){t.themesList=e.themes,t.addThemesToControl()},error:function(e,o,s){m.error("\nfailed to retrieve the local feed from: '"+t.settings.localFeed+"'")}}):e.ajax({url:this.settings.bootswatchApiUrl+"/"+this.settings.bootswatchApiVersion+".json",dataType:"json",success:function(e){if(void 0===e.themes)return null;t.themesList=e.themes,t.themesList.splice(0,0,{name:"default",css:t.settings.defaultCssFile}),t.addThemesToControl()}})},themes:function(e){if(void 0===e)return this.themesList;this.themesList=e}},e.fn.bootstrapThemeSwitcher=function(t){var o,s=Array.prototype.slice.call(arguments,1),i=e(this),n=i.data("bootstrapThemeSwitcher"),r="object"==typeof t&&t;return n||i.data("bootstrapThemeSwitcher",n=new u(this,r)),"string"==typeof t&&(o=n[t].apply(n,s)),void 0===o?i:o},e.fn.bootstrapThemeSwitcher.defaults={debug:!1,saveToCookie:!0,cssThemeLink:"bootstrapTheme",cookieThemeName:"bootstrapTheme.name",cookieThemeCss:"boostrapTheme.css",cookieExpiration:365,cookiePath:"/",defaultCssFile:"https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css",bootswatchApiUrl:"https://bootswatch.com/api/",bootswatchApiVersion:"4",loadFromBootswatch:!0,localFeed:"",excludeBootswatch:""},e.fn.bootstrapThemeSwitcher.Constructor=u,e.fn.bootstrapThemeSwitcher.noConflict=function(){return e.fn.BootstrapThemeSwitcher=i,this}}(jQuery,window,document);