mirror of
https://github.com/Mottie/tablesorter.git
synced 2024-11-15 23:54:22 +00:00
17 lines
3.6 KiB
JavaScript
17 lines
3.6 KiB
JavaScript
/**
|
|
* @fileOverview jui_theme_switch: jquery plugin to switch juery-ui themes
|
|
* <p>License MIT
|
|
* <br />Copyright 2012 Christos Pontikis <a href="http://pontikis.net">http://pontikis.net</a>
|
|
* <br />Project page <a href="http://pontikis.net/labs/jui_theme_switch">http://pontikis.net/labs/jui_theme_switch</a>
|
|
* <br />Minified using Online YUI Compressor http://www.refresh-sf.com/yui/
|
|
* @version 1.0.6 (21 Jan 2013)
|
|
* @author Christos Pontikis http://pontikis.net
|
|
* @requires jquery, jquery-ui
|
|
*/
|
|
"use strict";(function(c){var h={init:function(g){var d=this;return this.each(function(){var a=d.data("jui_theme_switch");if("undefined"==typeof a)var m=d.jui_theme_switch("getDefaults"),a=c.extend({},m,g);else a=c.extend({},a,g);d.data("jui_theme_switch",a);"undefined"===typeof d.data("jui_theme_switch_status")&&(d.data("jui_theme_switch_status",{}),d.data("jui_theme_switch_status").selected_theme={});d.unbind("onChangeTheme").bind("onChangeTheme",a.onChangeTheme);d.unbind("onDisplay").bind("onDisplay",a.onDisplay);
|
|
var m=d.attr("id"),n,b,f="",p=a.switcher_id_prefix+m,h=a.switcher_label_id_prefix+m,k,u,w=c("#"+a.stylesheet_link_id),q="",l,r="",t="",v;c.ajax({url:a.datasource_url,dataType:"json",cache:!1,success:function(e){n=e.length;f+='<label id="'+h+'" for="'+p+'">'+a.switcher_label+"</label>";f+='<select id="'+p+'" size="'+a.list_size+'">';for(b=0;b<n;b++)if(l="yes"==e[b].active||"yes"==a.show_all)"yes"==a.use_groups&&(l=e[b].group,l!==r&&(f+='<optgroup label="'+l+'">',r=l)),a.default_theme==e[b].theme_name?
|
|
(d.data("jui_theme_switch_status").selected_theme=e[b],q=' selected="selected"'):q="",t="",e[b].hasOwnProperty("hosted_locally")&&"yes"==e[b].hosted_locally&&(t=a.project_url),f+='<option value="'+t+e[b].theme_url+'"'+q+">",f+=e[b].theme_name,f+="</option>","yes"==a.use_groups&&b<n-1&&e[parseInt(b)+1].group!==r&&(f+="</optgroup>");f+="</select>";d.html(f);u=c("#"+h);k=c("#"+p);u.removeClass().addClass(a.labelClass);k.removeClass().addClass(a.listClass);d.removeClass().addClass(a.containerClass);d.off("change",
|
|
k).on("change",k,function(){v=(k.val()||"").replace(/\{version\}/g,c.ui&&c.ui.version||"1.12.0");w.attr("href",v);for(b=0;b<n;b++)if(c("#"+p+" option:selected").text()==e[b].theme_name){d.data("jui_theme_switch_status").selected_theme=e[b];break}d.triggerHandler("onChangeTheme",e[b])});d.triggerHandler("onDisplay")}})})},getDefaults:function(){return{switcher_label:"Select theme",default_theme:"ui-lightness",list_size:"1",use_groups:"yes",show_all:"no",project_url:"",containerClass:"switcher_container",
|
|
labelClass:"switcher_label",listClass:"switcher_list",switcher_label_id_prefix:"lbl_",switcher_id_prefix:"switcher_",onChangeTheme:function(){},onDisplay:function(){}}},getOption:function(c){return this.data("jui_theme_switch")[c]},getAllOptions:function(){return this.data("jui_theme_switch")},setOption:function(c,d,a){this.data("jui_theme_switch")[c]=d;a&&this.jui_theme_switch("init")},refresh:function(){this.jui_theme_switch()},destroy:function(){return c(this).each(function(){c(this).removeData("jui_theme_switch")})},
|
|
getTheme:function(){return this.data("jui_theme_switch_status").selected_theme}};c.fn.jui_theme_switch=function(g){1!=this.length&&(this.html('<span style="color: red;">ERROR: You must use this plugin (jui_theme_switch) with a unique element (at once)</span>'),c.error("You must use this plugin (jui_theme_switch) with a unique element (at once)"));if(h[g])return h[g].apply(this,Array.prototype.slice.call(arguments,1));if("object"!==typeof g&&g)c.error("Method "+g+" does not exist on jQuery.jui_theme_switch");
|
|
else return h.init.apply(this,arguments)}})(jQuery); |