/* # ----------------------------------------------------------------------------- # ~/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) 2022 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/master/LICENSE # 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! # ----------------------------------------------------------------------------- */ ;(function(d,h,o,g){var b=d.fn.bootstrapThemeSwitcher;var e=j1.getCookieNames();var p=j1.findCookie("_ga");var q=j1.findCookie("j1");var f=new liteURL(h.location.href);var j=f.hostname;var s=j.substring(j.lastIndexOf(".",j.lastIndexOf(".")-1)+1);var l=(f.protocol.includes("https"))?true:false;var r=log4javascript.getLogger("j1.core.switcher");var i;var c;var m={};var k;var a;var n=function(u,t){this.$element=d(u);this.settings=d.extend({},d.fn.bootstrapThemeSwitcher.defaults,t);this.themesList=[];this.getThemes();return this};n.prototype={clear:function(){r.debug("\nbootstrapThemeSwitcher.clear");return this.$element.each(function(){this.$element.empty()})},update:function(){r.debug("\nbootstrapThemeSwitcher.update");this.getThemes()},checkStyleSheetByName:function(t){var w=false;var x="/"+t+"/";var v=new RegExp(x,"i");for(var u=0;u").attr("class",D).append(''+G.name+"").on("click",function(){if(x.loadFromBootswatch){v.switchTheme(G.name,G.css)}else{v.switchTheme(G.name,G.cssCdn)}d(this).parent().find("li").removeClass("active");d(this).addClass("active")});v.$element.append(E)})}else{if(this.$element.is("select")){r.debug("\nbootstrapThemeSelector: SELECT element selected");this.$element.empty();var z;d.each(this.themesList,function(E,F){z=null;if(F.name===y){z="selected"}if(x.loadFromBootswatch){v.$element.append("")}else{v.$element.append("")}});this.$element.on("change",function(){var E=d("option:selected",this);v.switchTheme(E.text(),E.val())})}else{r.info("\nbootstrapThemeSelector: no UL or SELECT element found");r.error("\nbootstrapThemeSelector: failed")}}},getThemes:function(){var t=this;if(this.settings.localFeed!==null&&this.settings.localFeed!==""){d.ajax({url:this.settings.localFeed,dataType:"json",success:function(u){t.themesList=u.themes;t.addThemesToControl()},error:function(u,w,v){r.error("\nfailed to retrieve the local feed from: '"+t.settings.localFeed+"'")}})}else{d.ajax({url:this.settings.bootswatchApiUrl+"/"+this.settings.bootswatchApiVersion+".json",dataType:"json",success:function(u){if(typeof u.themes==="undefined"){return null}t.themesList=u.themes;t.themesList.splice(0,0,{name:"default",css:t.settings.defaultCssFile});t.addThemesToControl()}})}},themes:function(t){if(typeof t==="undefined"){return this.themesList}else{this.themesList=t}}};d.fn.bootstrapThemeSwitcher=function(v){var x;var u=Array.prototype.slice.call(arguments,1);var y=d(this);var w=y.data("bootstrapThemeSwitcher");var t=typeof v==="object"&&v;if(!w){y.data("bootstrapThemeSwitcher",(w=new n(this,t)))}if(typeof v==="string"){x=w[v].apply(w,u)}return(typeof x==="undefined")?y:x};d.fn.bootstrapThemeSwitcher.defaults={debug:false,saveToCookie:true,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:true,localFeed:"",excludeBootswatch:""};d.fn.bootstrapThemeSwitcher.Constructor=n;d.fn.bootstrapThemeSwitcher.noConflict=function(){d.fn.BootstrapThemeSwitcher=b;return this}})(jQuery,window,document);