1 line
3.8 KiB
JavaScript
1 line
3.8 KiB
JavaScript
(function(c){var a=c.telerik;var b={single:0,multi:1};c.extend(a,{panelbar:function(f,g){this.element=f;var h=c(f);c.extend(this,g);var d=".t-item:not(.t-state-disabled) > .t-link";h.delegate(d,"click",a.delegate(this,this._click)).delegate(d,"mouseenter",a.hover).delegate(d,"mouseleave",a.leave).delegate(".t-item.t-state-disabled > .t-link","click",a.preventDefault);a.bind(this,{expand:this.onExpand,collapse:this.onCollapse,select:c.proxy(function(i){if(i.target==this.element&&this.onSelect){this.onSelect(i)}},this),error:this.onError,load:this.onLoad});var e=h.find("li.t-state-active > .t-content");if(e.length>0&&e.eq(0).children().length==0){this.expand(e.parent())}}});a.panelbar.prototype={expand:function(d){c(d).each(c.proxy(function(f,g){var e=c(g);if(!e.hasClass(".t-state-disabled")&&e.find("> .t-group, > .t-content").length>0){if(this.expandMode==b.single&&this._collapseAllExpanded(e)){return}this._toggleItem(e,false,null)}},this))},collapse:function(d){c(d).each(c.proxy(function(f,g){var e=c(g);if(!e.hasClass(".t-state-disabled")&&e.find("> .t-group, > .t-content").is(":visible")){this._toggleItem(e,true,null)}},this))},toggle:function(e,d){c(e).each(function(){c(this).toggleClass("t-state-default",d).toggleClass("t-state-disabled",!d)})},enable:function(d){this.toggle(d,true)},disable:function(d){this.toggle(d,false)},_click:function(m,d){var f=c(m.target);if(f.closest(".t-link")[0]!=d||f.closest(".t-widget")[0]!=this.element){return}var h=c(d);var j=h.closest(".t-item");h.find(".t-link").removeClass("t-state-selected").end().addClass("t-state-selected");if(a.trigger(this.element,"select",{item:j[0]})){m.preventDefault()}var l=j.find("> .t-content, > .t-group");var i=h.attr("href");var k=(i&&(i.charAt(i.length-1)=="#"||i.indexOf("#"+this.element.id+"-")!=-1));if(k||l.length>0){m.preventDefault()}else{return}if(this.expandMode==b.single){if(this._collapseAllExpanded(j)){return}}if(l.length!=0){var g=l.is(":visible");if(!a.trigger(this.element,!g?"expand":"collapse",{item:j[0]})){this._toggleItem(j,g,m)}}},_toggleItem:function(f,h,i){var j=f.find("> .t-group");if(j.length!=0){this._toggleGroup(j,h);if(i!=null){i.preventDefault()}}else{var g=f.parent().children().index(f);var d=f.find("> .t-content");if(d.length>0){if(i!=null){i.preventDefault()}if(c.trim(d.html()).length>0){this._toggleGroup(d,h)}else{this._ajaxRequest(f,d,h)}}}},_toggleGroup:function(d,e){if(d.data("animating")){return}d.data("animating",true).parent().toggleClass("t-state-default",e).toggleClass("t-state-active",!e).find("> .t-link > .t-icon").toggleClass("t-arrow-up",!e).toggleClass("t-panelbar-collapse",!e).toggleClass("t-arrow-down",e).toggleClass("t-panelbar-expand",e);a.fx[!e?"play":"rewind"](this.effects,d,null,function(){d.data("animating",false)})},_collapseAllExpanded:function(d){if(d.find("> .t-link").hasClass("t-header")){if(d.find("> .t-content, > .t-group").is(":visible")||d.find("> .t-content, > .t-group").length==0){return true}else{c(this.element).children().find("> .t-content, > .t-group").filter(function(){return c(this).is(":visible")}).each(c.proxy(function(f,e){this._toggleGroup(c(e),true)},this))}}},_ajaxRequest:function(e,d,g){var h=e.find(".t-panelbar-collapse, .t-panelbar-expand");var f=setTimeout(function(){h.addClass("t-loading")},100);var i={};c.ajax({type:"GET",cache:false,url:e.find(".t-link").attr("href"),dataType:"html",data:i,error:c.proxy(function(k,j){if(a.ajaxError(this.element,"error",k,j)){return}},this),complete:function(){clearTimeout(f);h.removeClass("t-loading")},success:c.proxy(function(j,l){d.html(j);this._toggleGroup(d,g);var k=d.prev(".t-link");k.data("ContentUrl",k.attr("href")).attr("href","#")},this)})}};c.fn.tPanelBar=function(d){return a.create(this,{name:"tPanelBar",init:function(e,f){return new a.panelbar(e,f)},options:d})};c.fn.tPanelBar.defaults={effects:a.fx.property.defaults("height")}})(jQuery); |