/** * Copyright 2014 Telerik AD * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ !function(e,define){define(["./kendo.core.min"],e)}(function(){return function(e,t){function n(t){t=e(t),t.children(v).children(".k-icon").remove(),t.filter(":has(.k-panel),:has(.k-content)").children(".k-link:not(:has([class*=k-i-arrow]))").each(function(){var t=e(this),n=t.parent();t.append("")})}function i(t){t=e(t),t.filter(".k-first:not(:first-child)").removeClass(x),t.filter(".k-last:not(:last-child)").removeClass(m),t.filter(":first-child").addClass(x),t.filter(":last-child").addClass(m)}var r=window.kendo,o=r.ui,a=r.keys,s=e.extend,l=e.each,d=r.template,c=o.Widget,u=/^(ul|a|div)$/i,p=".kendoPanelBar",f="img",h="href",m="k-last",g="k-link",v="."+g,_="error",k=".k-item",b=".k-group",w=b+":visible",y="k-image",x="k-first",C="expand",T="select",S="k-content",F="activate",D="collapse",E="mouseenter",A="mouseleave",H="contentLoad",I="k-state-active",N="> .k-panel",M="> .k-content",R="k-state-focused",O="k-state-disabled",z="k-state-selected",P="."+z,L="k-state-highlight",B=k+":not(.k-state-disabled)",U=B+" > .k-link",W=k+".k-state-disabled > .k-link",q="> li > "+P+", .k-panel > li > "+P,V="k-state-default",j="aria-disabled",$="aria-expanded",G="aria-hidden",Y="aria-selected",Q=":visible",K=":empty",J="single",X={content:d("
#= content(item) #
"),group:d(""),itemWrapper:d("<#= tag(item) # class='#= textClass(item, group) #' #= contentUrl(item) ##= textAttributes(item) #>#= image(item) ##= sprite(item) ##= text(item) ##= arrow(data) #"),item:d("
  • #= itemWrapper(data) ## if (item.items) { ##= subGroup({ items: item.items, panelBar: panelBar, group: { expanded: item.expanded } }) ## } else if (item.content || item.contentUrl) { ##= renderContent(data) ## } #
  • "),image:d(""),arrow:d(""),sprite:d(""),empty:d("")},Z={aria:function(e){var t="";return(e.items||e.content||e.contentUrl)&&(t+=$+"='"+(e.expanded?"true":"false")+"' "),e.enabled===!1&&(t+=j+"='true'"),t},wrapperCssClass:function(e,t){var n="k-item",i=t.index;return n+=t.enabled===!1?" "+O:t.expanded===!0?" "+I:" k-state-default",0===i&&(n+=" k-first"),i==e.length-1&&(n+=" k-last"),t.cssClass&&(n+=" "+t.cssClass),n},textClass:function(e,t){var n=g;return t.firstLevel&&(n+=" k-header"),n},textAttributes:function(e){return e.url?" href='"+e.url+"'":""},arrowClass:function(e){var t="k-icon";return t+=e.expanded?" k-i-arrow-n k-panelbar-collapse":" k-i-arrow-s k-panelbar-expand"},text:function(e){return e.encoded===!1?e.text:r.htmlEncode(e.text)},tag:function(e){return e.url||e.contentUrl?"a":"span"},groupAttributes:function(e){return e.expanded!==!0?" style='display:none'":""},groupCssClass:function(){return"k-group k-panel"},contentAttributes:function(e){return e.item.expanded!==!0?" style='display:none'":""},content:function(e){return e.content?e.content:e.contentUrl?"":" "},contentUrl:function(e){return e.contentUrl?'href="'+e.contentUrl+'"':""}},et=c.extend({init:function(t,n){var i,o=this;c.fn.init.call(o,t,n),t=o.wrapper=o.element.addClass("k-widget k-reset k-header k-panelbar"),n=o.options,t[0].id&&(o._itemId=t[0].id+"_pb_active"),o._tabindex(),o._initData(n),o._updateClasses(),o._animations(n),t.on("click"+p,U,function(t){o._click(e(t.currentTarget))&&t.preventDefault()}).on(E+p+" "+A+p,U,o._toggleHover).on("click"+p,W,!1).on("keydown"+p,e.proxy(o._keydown,o)).on("focus"+p,function(){var e=o.select();o._current(e[0]?e:o._first())}).on("blur"+p,function(){o._current(null)}).attr("role","menu"),i=t.find("li."+I+" > ."+S),i[0]&&o.expand(i.parent(),!1),r.notify(o)},events:[C,D,T,F,_,H],options:{name:"PanelBar",animation:{expand:{effects:"expand:vertical",duration:200},collapse:{duration:200}},expandMode:"multiple"},destroy:function(){c.fn.destroy.call(this),this.element.off(p),r.destroy(this.element)},_initData:function(e){var t=this;e.dataSource&&(t.element.empty(),t.append(e.dataSource,t.element))},setOptions:function(e){var t=this.options.animation;this._animations(e),e.animation=s(!0,t,e.animation),"dataSource"in e&&this._initData(e),c.fn.setOptions.call(this,e)},expand:function(t,n){var i=this,r={};return n=n!==!1,t=this.element.find(t),t.each(function(o,a){a=e(a);var s=a.find(N).add(a.find(M));if(!a.hasClass(O)&&s.length>0){if(i.options.expandMode==J&&i._collapseAllExpanded(a))return i;t.find("."+L).removeClass(L),a.addClass(L),n||(r=i.options.animation,i.options.animation={expand:{effects:{}},collapse:{hide:!0,effects:{}}}),i._triggerEvent(C,a)||i._toggleItem(a,!1),n||(i.options.animation=r)}}),i},collapse:function(t,n){var i=this,r={};return n=n!==!1,t=i.element.find(t),t.each(function(t,o){o=e(o);var a=o.find(N).add(o.find(M));!o.hasClass(O)&&a.is(Q)&&(o.removeClass(L),n||(r=i.options.animation,i.options.animation={expand:{effects:{}},collapse:{hide:!0,effects:{}}}),i._triggerEvent(D,o)||i._toggleItem(o,!0),n||(i.options.animation=r))}),i},_toggleDisabled:function(e,t){e=this.element.find(e),e.toggleClass(V,t).toggleClass(O,!t).attr(j,!t)},select:function(n){var i=this;return n===t?i.element.find(q).parent():(n=i.element.find(n),n.length?n.each(function(){var n=e(this),r=n.children(v);return n.hasClass(O)?i:(i._triggerEvent(T,n)||i._updateSelected(r),t)}):this._updateSelected(n),i)},clearSelection:function(){this.select(e())},enable:function(e,t){return this._toggleDisabled(e,t!==!1),this},disable:function(e){return this._toggleDisabled(e,!1),this},append:function(e,t){t=this.element.find(t);var r=this._insert(e,t,t.length?t.find(N):null);return l(r.items,function(){r.group.append(this),i(this)}),n(t),i(r.group.find(".k-first, .k-last")),r.group.height("auto"),this},insertBefore:function(e,t){t=this.element.find(t);var n=this._insert(e,t,t.parent());return l(n.items,function(){t.before(this),i(this)}),i(t),n.group.height("auto"),this},insertAfter:function(e,t){t=this.element.find(t);var n=this._insert(e,t,t.parent());return l(n.items,function(){t.after(this),i(this)}),i(t),n.group.height("auto"),this},remove:function(e){e=this.element.find(e);var t=this,r=e.parentsUntil(t.element,k),o=e.parent("ul");return e.remove(),!o||o.hasClass("k-panelbar")||o.children(k).length||o.remove(),r.length&&(r=r.eq(0),n(r),i(r)),t},reload:function(t){var n=this;t=n.element.find(t),t.each(function(){var t=e(this);n._ajaxRequest(t,t.children("."+S),!t.is(Q))})},_first:function(){return this.element.children(B).first()},_last:function(){var e=this.element.children(B).last(),t=e.children(w);return t[0]?t.children(B).last():e},_current:function(e){var n=this,i=n._focused,r=n._itemId;return e===t?i:(n.element.removeAttr("aria-activedescendant"),i&&(i[0].id===r&&i.removeAttr("id"),i.children(v).removeClass(R)),e&&(r=e[0].id||r,e.attr("id",r).children(v).addClass(R),n.element.attr("aria-activedescendant",r)),n._focused=e,t)},_keydown:function(e){var t=this,n=e.keyCode,i=t._current();e.target==e.currentTarget&&(n==a.DOWN||n==a.RIGHT?(t._current(t._nextItem(i)),e.preventDefault()):n==a.UP||n==a.LEFT?(t._current(t._prevItem(i)),e.preventDefault()):n==a.ENTER||n==a.SPACEBAR?(t._click(i.children(v)),e.preventDefault()):n==a.HOME?(t._current(t._first()),e.preventDefault()):n==a.END&&(t._current(t._last()),e.preventDefault()))},_nextItem:function(e){if(!e)return this._first();var t=e.children(w),n=e.next();return t[0]&&(n=t.children("."+x)),n[0]||(n=e.parent(w).parent(k).next()),n[0]&&n.is(":visible")||(n=this._first()),n.hasClass(O)&&(n=this._nextItem(n)),n},_prevItem:function(e){if(!e)return this._last();var t,n=e.prev();if(n[0])for(t=n;t[0];)t=t.children(w).children("."+m),t[0]&&(n=t);else n=e.parent(w).parent(k),n[0]||(n=this._last());return n.hasClass(O)&&(n=this._prevItem(n)),n},_insert:function(t,n,i){var r,o,a=this,l=e.isPlainObject(t),d=n&&n[0];return d||(i=a.element),o={firstLevel:i.hasClass("k-panelbar"),expanded:i.parent().hasClass(I),length:i.children().length},d&&!i.length&&(i=e(et.renderGroup({group:o})).appendTo(n)),l||e.isArray(t)?(r=e.map(l?[t]:t,function(t,n){return e("string"==typeof t?t:et.renderItem({group:o,item:s(t,{index:n})}))}),d&&n.attr($,!1)):(r="string"==typeof t&&"<"!=t[0]?a.element.find(t):e(t),a._updateItemsClasses(r)),{items:r,group:i}},_toggleHover:function(t){var n=e(t.currentTarget);n.parents("li."+O).length||n.toggleClass("k-state-hover",t.type==E)},_updateClasses:function(){var t,r,o=this;t=o.element.find("li > ul").not(function(){return e(this).parentsUntil(".k-panelbar","div").length}).addClass("k-group k-panel").attr("role","group"),t.parent().attr($,!1).not("."+I).children("ul").attr(G,!0).hide(),r=o.element.add(t).children(),o._updateItemsClasses(r),n(r),i(r)},_updateItemsClasses:function(e){for(var t=e.length,n=0;t>n;n++)this._updateItemClasses(e[n],n)},_updateItemClasses:function(t,n){var i,o,a=this._selected,s=this.options.contentUrls,l=s&&s[n],d=this.element[0];t=e(t).addClass("k-item").attr("role","menuitem"),r.support.browser.msie&&t.css("list-style-position","inside").css("list-style-position",""),t.children(f).addClass(y),o=t.children("a").addClass(g),o[0]&&(o.attr("href",l),o.children(f).addClass(y)),t.filter(":not([disabled]):not([class*=k-state])").addClass("k-state-default"),t.filter("li[disabled]").addClass("k-state-disabled").attr(j,!0).removeAttr("disabled"),t.children("div").addClass(S).attr("role","region").attr(G,!0).hide().parent().attr($,!1),o=t.children(P),o[0]&&(a&&a.removeAttr(Y).children(P).removeClass(z),o.addClass(z),this._selected=t.attr(Y,!0)),t.children(v)[0]||(i="",s&&s[n]&&t[0].parentNode==d&&(i=''),t.contents().filter(function(){return!(this.nodeName.match(u)||3==this.nodeType&&!e.trim(this.nodeValue))}).wrapAll(i)),t.parent(".k-panelbar")[0]&&t.children(v).addClass("k-header")},_click:function(e){var t,n,i,r,o,a,s,l=this,d=l.element;if(!e.parents("li."+O).length&&e.closest(".k-widget")[0]==d[0]){if(o=e.closest(v),a=o.closest(k),l._updateSelected(o),n=a.find(N).add(a.find(M)),i=o.attr(h),r=i&&("#"==i.charAt(i.length-1)||-1!=i.indexOf("#"+l.element[0].id+"-")),t=!(!r&&!n.length),n.data("animating"))return t;if(l._triggerEvent(T,a)&&(t=!0),t!==!1)return l.options.expandMode==J&&l._collapseAllExpanded(a)?t:(n.length&&(s=n.is(Q),l._triggerEvent(s?D:C,a)||(t=l._toggleItem(a,s))),t)}},_toggleItem:function(e,n){var i,r,o=this,a=e.find(N),s=e.find(v),l=s.attr(h);return a.length?(this._toggleGroup(a,n),i=!0):(r=e.children("."+S),r.length&&(i=!0,r.is(K)&&l!==t?o._ajaxRequest(e,r,n):o._toggleGroup(r,n))),i},_toggleGroup:function(e,t){var n=this,i=n.options.animation,r=i.expand,o=s({},i.collapse),a=o&&"effects"in o;e.is(Q)==t&&(e.parent().attr($,!t).attr(G,t).toggleClass(I,!t).find("> .k-link > .k-icon").toggleClass("k-i-arrow-n",!t).toggleClass("k-panelbar-collapse",!t).toggleClass("k-i-arrow-s",t).toggleClass("k-panelbar-expand",t),r=t?s(a?o:s({reverse:!0},r),{hide:!0}):s({complete:function(e){n._triggerEvent(F,e.closest(k))}},r),e.kendoStop(!0,!0).kendoAnimate(r))},_collapseAllExpanded:function(t){var n,i=this,r=!1,o=t.find(N).add(t.find(M));return o.is(Q)&&(r=!0),o.is(Q)||0===o.length||(n=t.siblings(),n.find(N).add(n.find(M)).filter(function(){return e(this).is(Q)}).each(function(t,n){n=e(n),r=i._triggerEvent(D,n.closest(k)),r||i._toggleGroup(n,!0)})),r},_ajaxRequest:function(t,n,i){var r=this,o=t.find(".k-panelbar-collapse, .k-panelbar-expand"),a=t.find(v),s=setTimeout(function(){o.addClass("k-loading")},100),l={},d=a.attr(h);e.ajax({type:"GET",cache:!1,url:d,dataType:"html",data:l,error:function(e,t){o.removeClass("k-loading"),r.trigger(_,{xhr:e,status:t})&&this.complete()},complete:function(){clearTimeout(s),o.removeClass("k-loading")},success:function(e){function o(){return{elements:n.get()}}try{r.angular("cleanup",o),n.html(e),r.angular("compile",o)}catch(a){var s=window.console;s&&s.error&&s.error(a.name+": "+a.message+" in "+d),this.error(this.xhr,"error")}r._toggleGroup(n,i),r.trigger(H,{item:t[0],contentElement:n[0]})}})},_triggerEvent:function(e,t){var n=this;return n.trigger(e,{item:t[0]})},_updateSelected:function(e){var t=this,n=t.element,i=e.parent(k),r=t._selected;r&&r.removeAttr(Y),t._selected=i.attr(Y,!0),n.find(q).removeClass(z),n.find("> ."+L+", .k-panel > ."+L).removeClass(L),e.addClass(z),e.parentsUntil(n,k).filter(":has(.k-header)").addClass(L),t._current(i[0]?i:null)},_animations:function(e){e&&"animation"in e&&!e.animation&&(e.animation={expand:{effects:{}},collapse:{hide:!0,effects:{}}})}});s(et,{renderItem:function(e){e=s({panelBar:{},group:{}},e);var t=X.empty,n=e.item;return X.item(s(e,{image:n.imageUrl?X.image:t,sprite:n.spriteCssClass?X.sprite:t,itemWrapper:X.itemWrapper,renderContent:et.renderContent,arrow:n.items||n.content||n.contentUrl?X.arrow:t,subGroup:et.renderGroup},Z))},renderGroup:function(e){return X.group(s({renderItems:function(e){for(var t="",n=0,i=e.items,r=i?i.length:0,o=s({length:r},e.group);r>n;n++)t+=et.renderItem(s(e,{group:o,item:s({index:n},i[n])}));return t}},e,Z))},renderContent:function(e){return X.content(s(e,Z))}}),r.ui.plugin(et)}(window.kendo.jQuery),window.kendo},"function"==typeof define&&define.amd?define:function(e,t){t()});