/* * Kendo UI Beta v2013.2.716 (http://kendoui.com) * Copyright 2013 Telerik AD. All rights reserved. * * Kendo UI Beta license terms available at * http://www.kendoui.com/purchase/license-agreement/kendo-ui-beta.aspx */ ("function"==typeof define&&define.amd?define:function(e,n){return n()})(["./kendo.popup.min","./kendo.filtermenu.min","./kendo.menu.min"],function(){!function(e,n){function i(n){return e.trim(n).replace(/ /gi,"")}var s=window.kendo,t=s.ui,o=e.proxy,l=e.extend,r=e.grep,a=e.map,u=e.inArray,c="k-state-selected",d="asc",p="desc",f="change",m="init",k="kendoPopup",h="kendoFilterMenu",w="kendoMenu",_=".kendoColumnMenu",b=/(\[|\]|\$|\.|\:|\+)/g,g=t.Widget,v=g.extend({init:function(n,i){var t,l=this;g.fn.init.call(l,n,i),n=l.element,i=l.options,l.owner=i.owner,l.dataSource=i.dataSource,l.field=n.attr(s.attr("field")),t=n.find(".k-header-column-menu"),t[0]||(t=n.prepend('').find(".k-header-column-menu")),l.link=t.attr("tabindex",-1).on("click"+_,o(l._click,l)),l.wrapper=e('
')},_init:function(){var e=this,n=e.options;e.wrapper.html(s.template(C)({ns:s.ns,messages:n.messages,sortable:n.sortable,filterable:n.filterable,columns:e._ownerColumns(),showColumns:n.columns})),e.popup=e.wrapper[k]({anchor:e.link,open:o(e._open,e),activate:o(e._activate,e),close:e.options.closeCallback}).data(k),e._menu(),e._sort(),e._columns(),e._filter(),e.trigger(m,{field:e.field,container:e.wrapper})},events:[m],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;g.fn.destroy.call(e),e.filterMenu&&e.filterMenu.destroy(),e._refreshHandler&&e.dataSource.unbind(f,e._refreshHandler),e.options.columns&&(e.owner.unbind("columnShow",e._updateColumnsMenuHandler),e.owner.unbind("columnHide",e._updateColumnsMenuHandler)),e.menu&&(e.menu.element.off(_),e.menu.destroy()),e.wrapper.off(_),e.popup&&e.popup.destroy(),e.link.off(_)},close:function(){this.menu.close(),this.popup.close(),this.popup.element.off("keydown"+_)},_click:function(e){e.preventDefault(),e.stopPropagation(),this.popup||this._init(),this.popup.toggle()},_open:function(){var n=this;e(".k-column-menu").not(n.wrapper).each(function(){e(this).data(k).close()}),n.popup.element.on("keydown"+_,function(e){e.keyCode==s.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,s=i(e.title||"");return(e.menu===!1||!e.field&&!s.length)&&(n=!1),n});return a(n,function(n){return{originalField:n.field,field:n.field||n.title,title:n.title||n.field,hidden:n.hidden,index:u(n,e)}})},_menu:function(){this.menu=this.wrapper.children()[w]({orientation:"vertical",closeOnClick:!1}).data(w)},_sort:function(){var n=this;n.options.sortable&&(n.refresh(),n._refreshHandler=o(n.refresh,n),n.dataSource.bind(f,n._refreshHandler),n.menu.bind("select",function(i){var s,t=e(i.item);t.hasClass("k-sort-asc")?s=d:t.hasClass("k-sort-desc")&&(s=p),s&&(t.parent().find(".k-sort-"+(s==d?p:d)).removeClass(c),n._sortDataSource(t,s),n.close())}))},_sortDataSource:function(e,i){var s,t,o=this,l=o.options.sortable,r=o.dataSource,a=r.sort()||[];if(e.hasClass(c)&&l&&l.allowUnsort!==!1?(e.removeClass(c),i=n):e.addClass(c),l===!0||"single"===l.mode)a=[{field:o.field,dir:i}];else{for(s=0,t=a.length;t>s;s++)if(a[s].field===o.field){a.splice(s,1);break}a.push({field:o.field,dir:i})}r.sort(a)},_columns:function(){var n=this;n.options.columns&&(n._updateColumnsMenu(),n._updateColumnsMenuHandler=o(n._updateColumnsMenu,n),n.owner.bind(["columnHide","columnShow"],n._updateColumnsMenuHandler),n.menu.bind("select",function(i){var t,o,l,a,c=e(i.item),d=n.owner.columns;c.parent().closest("li.k-columns-item")[0]&&(t=c.find(":checkbox"),t.attr("disabled")||(a=t.attr(s.attr("field")),l=r(d,function(e){return e.field==a||e.title==a})[0],o=u(l,d),l.hidden===!0?n.owner.showColumn(o):n.owner.hideColumn(o)))}))},_updateColumnsMenu:function(){var e="["+s.attr("field")+"=",n=this._ownerColumns(),i=a(n,function(n){return e+'"'+n.field.replace(b,"\\$1")+'"]'}).join(","),t=r(n,function(e){return!e.hidden}),o=r(t,function(e){return e.originalField}).length,l=a(t,function(n){return e+'"'+n.field.replace(b,"\\$1")+'"]'}).join(",");this.wrapper.find(i).prop("checked",!1),this.wrapper.find(l).prop("checked",!0).prop("disabled",1==o)},_filter:function(){var e=this,n=e.options;n.filterable!==!1&&(e.filterMenu=e.wrapper.find(".k-filterable")[h](l(!0,{},{appendToElement:!0,dataSource:n.dataSource,values:n.values,field:e.field},n.filterable)).data(h))},refresh:function(){var e,n,i,s=this,t=s.options.dataSource.sort()||[],o=s.field;for(s.wrapper.find(".k-sort-asc, .k-sort-desc").removeClass(c),n=0,i=t.length;i>n;n++)e=t[n],o==e.field&&s.wrapper.find(".k-sort-"+e.dir).addClass(c)}}),C='';t.plugin(v)}(window.kendo.jQuery)});