/* * jQuery Twitter Bootstrap Theme Switcher v1.1.5 * https://github.com/jguadagno/bootstrapThemeSwitcher * * Copyright 2014, Joseph Guadagno * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) */ (function(d,c,a,f){var b=d.fn.bootstrapThemeSwitcher;var e=function(h,g){this.$element=d(h);this.settings=d.extend({},d.fn.bootstrapThemeSwitcher.defaults,g);this.themesList=[];this.getThemes();return this};e.prototype={clear:function(){console.log("bootstrapThemeSwitcher.clear");return this.$element.each(function(){this.$element.empty()})},update:function(){console.log("bootstrapThemeSwitcher.update");this.getThemes()},checkStyleSheetByName:function(g){var k=false;var l="/"+g+"/";var j=new RegExp(l,"i");for(var h=0;h";var k=d('head link[rel="stylesheet"]:first');if(k.length===0){d("head").append(p)}else{k.before(p)}g=d(l)}g.attr("href",o);if(m.saveToCookie){if(d.cookie===f){if(i=="true"){console.warn("bootstrapThemeSwitcher: saveToCookie is set to true but jQuery.cookie is not present")}return}d.cookie(m.cookieThemeName,h,{expires:m.cookieExpiration,path:m.cookiePath});d.cookie(m.cookieThemeCss,o,{expires:m.cookieExpiration,path:m.cookiePath})}d('head link[href*="bootstrap.min.css"][id!="'+j+'"]').remove();if(i=="true"){console.log('bootstrapThemeSwitcher.enableTheme: name: "'+n+'"')}setTimeout(function(){d("#no_flicker").css("display","block")},m.hideOnReload)},loadThemeFromCookie:function(g){if(d.cookie===f){console.warn("bootstrapThemeSwitcher: loadThemeFromCookie was called but jQuery.cookie is not present");return}var h=d.extend({},d.fn.bootstrapThemeSwitcher.defaults,g);var j=d.cookie(h.cookieThemeName);var i=d.cookie(h.cookieThemeCss);this.switchTheme(j,i)},addTheme:function(h,g,j,i){if(j===f){j=0}if(i===f){i=0}this.themesList.splice(j,i,{name:h,cssCdn:g});this.addThemesToControl()},addThemesToControl:function(){if(this.$element===f){console.error("bootstrapThemeSelector: addThemesToControl: Element is undefined");return}if(this.themesList===f){console.error("bootstrapThemeSelector: addThemesToControl: Themes is undefined");return}if(this.settings.excludeBootswatch){if(this.settings.excludeBootswatch.indexOf(",")!==-1){var n=this.settings.excludeBootswatch.split(",")}else{var n=[];n.push(this.settings.excludeBootswatch)}var j=this.themesList;d.each(j,function(r,s){if(s&&s.name){if(jQuery.inArray(s.name,n)!==-1){j.splice(r,1)}}});this.themesList=j}var i=this;if(this.$element.is("ul")){var o=d(this);var k=d.extend({},d.fn.bootstrapThemeSwitcher.defaults,o.data("bootstrapThemeSwitcher"));var h=k.cssThemeLink;var g=k.debug;var p=d.cookie(k.cookieDefaultThemeName);var l=d.cookie(k.cookieThemeName);if(g=="true"){console.log("bootstrapThemeSelector: UL element selected")}this.$element.empty();var q;d.each(this.themesList,function(s,t){q=null;if(t.name===d.cookie(k.cookieThemeName)){q="active"}var r=d("
  • ").attr("class",q).append(""+t.name+"").on("click",function(){i.switchTheme(t.name,t.cssCdn);d(this).parent().find("li").removeClass("active");d(this).addClass("active")});i.$element.append(r)})}else{if(this.$element.is("select")){if(g=="true"){console.log("bootstrapThemeSelector: SELECT element selected")}this.$element.empty();var m;d.each(this.themesList,function(r,s){m=null;if(s.name===d.cookie(k.cookieThemeName)){m="selected"}i.$element.append("")});this.$element.on("change",function(){var r=d("option:selected",this);i.switchTheme(r.text(),r.val())})}else{}}},getThemes:function(){var g=this;if(this.settings.localFeed!==null&&this.settings.localFeed!==""){d.ajax({url:this.settings.localFeed,dataType:"json",success:function(h){g.themesList=h.themes;g.addThemesToControl()},error:function(h,j,i){console.error("Failed to retrieve the local feed from '"+g.settings.localFeed+"'")}});return}d.ajax({url:this.settings.bootswatchApiUrl+"/"+this.settings.bootswatchApiVersion+".json",dataType:"json",success:function(h){if(h.themes===f){return null}g.themesList=h.themes;g.themesList.splice(0,0,{name:"default",cssCdn:g.settings.defaultCssFile});g.addThemesToControl()}})},themes:function(g){if(g===f){return this.themesList}else{this.themesList=g}}};d.fn.bootstrapThemeSwitcher=function(i){var h=Array.prototype.slice.call(arguments,1);var k;var l=d(this);var j=l.data("bootstrapThemeSwitcher");var g=typeof i==="object"&&i;if(!j){l.data("bootstrapThemeSwitcher",(j=new e(this,g)))}if(typeof i==="string"){k=j[i].apply(j,h)}return(k===f)?l:k};d.fn.bootstrapThemeSwitcher.defaults={debug:false,cssThemeLink:"bootstrapTheme",saveToCookie:true,cookieThemeName:"bootstrapTheme.name",cookieDefaultThemeName:"bootstrapTheme.default",cookieThemeCss:"boostrapTheme.css",cookieExpiration:7,cookiePath:"/",defaultCssFile:"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css",bootswatchApiUrl:"https://bootswatch.com/api/",bootswatchApiVersion:"3",loadFromBootswatch:true,hideOnReload:150,localFeed:"",excludeBootswatch:""};d.fn.bootstrapThemeSwitcher.Constructor=e;d.fn.bootstrapThemeSwitcher.noConflict=function(){d.fn.BootstrapThemeSwitcher=b;return this}})(jQuery,window,document);