bludit/themes/admin-kube/js/kube.min.js

1 line
41 KiB
JavaScript
Raw Normal View History

2015-03-14 15:45:30 +01:00
(function(b){b.fn.accordion=function(c){return this.each(function(){b.data(this,"accordion",{});b.data(this,"accordion",a(this,c))})};function a(d,c){return new a.prototype.init(d,c)}b.Accordion=a;b.Accordion.NAME="accordion";b.Accordion.VERSION="1.0";b.Accordion.opts={scroll:false,collapse:true,toggle:true,titleClass:".accordion-title",panelClass:".accordion-panel"};a.fn=b.Accordion.prototype={init:function(d,c){this.$element=d!==false?b(d):false;this.loadOptions(c);this.build();if(this.opts.collapse){this.closeAll()}else{this.openAll()}this.loadFromHash()},loadOptions:function(c){this.opts=b.extend({},b.extend(true,{},b.Accordion.opts),this.$element.data(),c)},setCallback:function(j,h,d){var m=b._data(this.$element[0],"events");if(m&&typeof m[j]!="undefined"){var k=[];var g=m[j].length;for(var f=0;f<g;f++){var c=m[j][f].namespace;if(c=="tools."+b.Accordion.NAME||c==b.Accordion.NAME+".tools"){var l=m[j][f].handler;k.push((typeof d=="undefined")?l.call(this,h):l.call(this,h,d))}}if(k.length==1){return k[0]}else{return k}}return(typeof d=="undefined")?h:d},getTitles:function(){this.titles=this.$element.find(this.opts.titleClass);this.titles.append(b("<span />").addClass("accordion-toggle"));this.titles.each(function(){var c=b(this);c.attr("rel",c.attr("href"))})},getPanels:function(){this.panels=this.$element.find(this.opts.panelClass)},build:function(){this.getTitles();this.getPanels();this.titles.on("click",b.proxy(this.toggle,this))},loadFromHash:function(){if(top.location.hash===""){return}if(!this.opts.scroll){return}if(this.$element.find("[rel="+top.location.hash+"]").size()===0){return}this.open(top.location.hash);this.scrollTo(top.location.hash)},toggle:function(g){g.preventDefault();g.stopPropagation();var f=b(g.target).attr("rel");if(this.opts.toggle){var c=b(g.target);var d=c.closest(this.opts.titleClass);var h=d.hasClass("accordion-title-opened");this.closeAll();if(!h){this.open(f)}}else{if(b("[rel="+f+"]").hasClass("accordion-title-opened")){this.close(f)}else{this.open(f)}}},open:function(c){this.$title=b("[rel="+c+"]");this.$panel=b(c);top.location.hash=c;this.setStatus("open");this.$panel.show();this.setCallback("opened",this.$title,this.$panel)},close:function(c){this.$title=b("[rel="+c+"]");this.$panel=b(c);this.setStatus("close");this.$panel.hide();this.setCallback("closed",this.$title,this.$panel)},setStatus:function(d){var c={toggle:this.$title.find("span.accordion-toggle"),title:this.$title,panel:this.$panel};b.each(c,function(e,f){if(d=="close"){f.removeClass("accordion-"+e+"-opened").addClass("accordion-"+e+"-closed")}else{f.removeClass("accordion-"+e+"-closed").addClass("accordion-"+e+"-opened")}})},openAll:function(){this.titles.each(b.proxy(function(c,d){this.open(b(d).attr("rel"))},this))},closeAll:function(){this.titles.each(b.proxy(function(c,d){this.close(b(d).attr("rel"))},this))},scrollTo:function(c){b("html, body").animate({scrollTop:b(c).offset().top-50},500)}};b(window).on("load.tools.accordion",function(){b('[data-tools="accordion"]').accordion()});a.prototype.init.prototype=a.prototype})(jQuery);(function(b){b.fn.autocomplete=function(c){return this.each(function(){b.data(this,"autocomplete",{});b.data(this,"autocomplete",a(this,c))})};function a(d,c){return new a.prototype.init(d,c)}b.Autocomplete=a;b.Autocomplete.NAME="autocomplete";b.Autocomplete.VERSION="1.0";b.Autocomplete.opts={url:false,min:2,set:"value"};a.fn=b.Autocomplete.prototype={init:function(d,c){this.$element=d!==false?b(d):false;this.loadOptions(c);this.build()},loadOptions:function(c){this.opts=b.extend({},b.extend(true,{},b.Autocomplete.opts),this.$element.data(),c)},setCallback:function(j,h,d){var m=b._data(this.$element[0],"events");if(m&&typeof m[j]!="undefined"){var k=[];var g=m[j].length;for(var f=0;f<g;f++){var c=m[j][f].namespace;if(c=="tools."+b.Autocomplete.NAME||c==b.Autocomplete.NAME+".tools"){var l=m[j][f].handler;k.push((typeof d=="undefined")?l.call(this,h):l.call(this,h,d))}}if(k.length==1){return k[0]}else{return k}}return(typeof d=="undefined")?h:d},build:function(){this.result=b('<ul class="autoco