/* * Kendo UI Web v2012.3.1114 (http://kendoui.com) * Copyright 2012 Telerik AD. All rights reserved. * * Kendo UI Web commercial licenses may be obtained at * https://www.kendoui.com/purchase/license-agreement/kendo-ui-web-commercial.aspx * If you do not own a commercial license, this file shall be governed by the * GNU General Public License (GPL) version 3. * For GPL requirements, please review: http://www.gnu.org/copyleft/gpl.html */ (function(e,n){function s(n){return e.trim(n).replace(/ /gi,"")}var t=window.kendo,l=t.ui,i=e.proxy,o=e.extend,r=e.grep,a=e.map,u=e.inArray,c="k-state-selected",d="asc",f="desc",p="change",m="kendoPopup",k="kendoFilterMenu",h="kendoMenu",w=".kendoColumnMenu",b=/(\[|\]|\$|\.|\:|\+)/g,C=l.Widget,_=C.extend({init:function(n,s){var l,o=this;C.fn.init.call(o,n,s),n=o.element,s=o.options,o.owner=s.owner,o.dataSource=s.dataSource,o.field=n.attr(t.attr("field")),l=n.find(".k-header-column-menu"),l[0]||(l=n.prepend('').find(".k-header-column-menu")),o.link=l.attr("tabindex",-1).on("click"+w,i(o._click,o)),o.wrapper=e('
'),o.wrapper.html(t.template(v)({ns:t.ns,messages:s.messages,sortable:s.sortable,filterable:s.filterable,columns:o._ownerColumns(),showColumns:s.columns})),o.popup=o.wrapper[m]({anchor:l,open:i(o._open,o),activate:i(o._activate,o),close:o.options.closeCallback}).data(m),o._menu(),o._sort(),o._columns(),o._filter()},options:{name:"ColumnMenu",messages:{sortAscending:"Sort Ascending",sortDescending:"Sort Descending",filter:"Filter",columns:"Columns"},columns:!0,sortable:!0,filterable:!0},destroy:function(){var e=this;C.fn.destroy.call(e),e.filterMenu&&e.filterMenu.destroy(),e.dataSource.unbind("refresh",e._refreshHandler),e.options.columns&&(e.owner.unbind("columnShow",e._updateColumnsMenuHandler),e.owner.unbind("columnHide",e._updateColumnsMenuHandler)),e.menu.element.off(w),e.menu.destroy(),e.wrapper.off(w),e.popup.destroy(),e.link.off(w)},close:function(){this.menu.close(),this.popup.close(),this.popup.element.off("keydown"+w)},_click:function(e){e.preventDefault(),e.stopPropagation(),this.popup.toggle()},_open:function(){var n=this;e(".k-column-menu").not(n.wrapper).each(function(){e(this).data(m).close()}),n.popup.element.on("keydown"+w,function(e){e.keyCode==t.keys.ESC&&n.close()})},_activate:function(){this.menu.element.focus()},_ownerColumns:function(){var e=this.owner.columns,n=r(e,function(e){var n=!0,t=s(e.title||"");return(e.menu===!1||!e.field&&!t.length)&&(n=!1),n});return a(n,function(n){return{field:n.field||n.title,title:n.title||n.field,hidden:n.hidden,index:u(n,e)}})},_menu:function(){this.menu=this.wrapper.children()[h]({orientation:"vertical",closeOnClick:!1}).data(h)},_sort:function(){var n=this;n.options.sortable&&(n.refresh(),n._refreshHandler=i(n.refresh,n),n.dataSource.bind(p,n._refreshHandler),n.menu.element.on("click"+w,".k-sort-asc, .k-sort-desc",function(){var s=e(this),t=s.hasClass("k-sort-asc")?d:f;s.parent().find(".k-sort-"+(t==d?f:d)).removeClass(c),n._sortDataSource(s,t),n.close()}))},_sortDataSource:function(e,s){var t,l,i=this,o=i.options.sortable,r=i.dataSource,a=r.sort()||[];if(e.hasClass(c)&&o&&o.allowUnsort!==!1?(e.removeClass(c),s=n):e.addClass(c),o===!0||"single"===o.mode)a=[{field:i.field,dir:s}];else{for(t=0,l=a.length;l>t;t++)if(a[t].field===i.field){a.splice(t,1);break}a.push({field:i.field,dir:s})}r.sort(a)},_columns:function(){var n=this;n.options.columns&&(n._updateColumnsMenu(),n._updateColumnsMenuHandler=i(n._updateColumnsMenu,n),n.owner.bind(["columnHide","columnShow"],n._updateColumnsMenuHandler),n.menu.bind("select",function(s){var l,i,o,a,c=e(s.item),d=n.owner.columns;c.parent().closest("li.k-columns-item")[0]&&(l=c.find(":checkbox"),l.attr("disabled")||(a=l.attr(t.attr("field")),o=r(d,function(e){return e.field==a||e.title==a})[0],i=u(o,d),o.hidden===!0?n.owner.showColumn(i):n.owner.hideColumn(i)))}))},_updateColumnsMenu:function(){var e="["+t.attr("field")+"=",n=this._ownerColumns(),s=a(n,function(n){return e+n.field.replace(b,"\\$1")+"]"}).join(","),l=r(n,function(e){return!e.hidden}),i=a(l,function(n){return e+n.field.replace(b,"\\$1")+"]"}).join(",");this.wrapper.find(s).attr("checked",!1),this.wrapper.find(i).attr("checked",!0).attr("disabled",1==l.length)},_filter:function(){var e=this,n=e.options;n.filterable!==!1&&(e.filterMenu=e.wrapper.find(".k-filterable")[k](o(!0,{},{appendToElement:!0,dataSource:n.dataSource,values:n.values,field:e.field},n.filterable)).data(k))},refresh:function(){var e,n,s,t=this,l=t.options.dataSource.sort()||[],i=t.field;for(t.wrapper.find(".k-sort-asc, .k-sort-desc").removeClass(c),n=0,s=l.length;s>n;n++)e=l[n],i==e.field&&t.wrapper.find(".k-sort-"+e.dir).addClass(c)}}),v='