UNPKG

@progress/kendo-ui

Version:

This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.

1 lines 3.77 kB
module.exports=function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return e[n].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}({0:function(e,t,r){e.exports=r(1113)},3:function(e,t){e.exports=function(){throw Error("define cannot be used indirect")}},1048:function(e,t){e.exports=require("./kendo.core")},1113:function(e,t,r){var n,o,i;!function(s,define){o=[r(1048)],n=s,i="function"==typeof n?n.apply(t,o):n,!(void 0!==i&&(e.exports=i))}(function(){return function(e,t){function r(r){var n=r.find("tr:not(.k-filter-row)"),i=o.attr("index"),s=n.find("th["+i+"]:visible");return s.sort(function(r,n){var o,s;return r=e(r),n=e(n),o=r.attr(i),s=n.attr(i),o===t&&(o=e(r).index()),s===t&&(s=e(n).index()),o=parseInt(o,10),s=parseInt(s,10),o>s?1:o<s?-1:0}),s}function n(e){var t=null;return e.is("th")&&(t=e.closest("table"),t.parent().hasClass("k-grid-header-wrap")?t=t.closest(".k-grid").find(".k-grid-content > table"):t.parent().hasClass("k-grid-header-locked")&&(t=t.closest(".k-grid").find(".k-grid-content-locked > table"))),t}var o=window.kendo,i=o.ui,s=i.Widget,a="dir",d="asc",l="single",c="multiple",p="mixed",u="field",f="desc",h=".kendoColumnSorter",k=".k-link",g="aria-sort",m=e.proxy,x=s.extend({init:function(e,t){var r,n=this;s.fn.init.call(n,e,t),n._refreshHandler=m(n.refresh,n),n.dataSource=n.options.dataSource.bind("change",n._refreshHandler),n.directions=n.options.initialDirection===d?[d,f]:[f,d],r=n.element.find(k),r[0]||(r=n.element.wrapInner('<a class="k-link" href="#"/>').find(k)),n.link=r,n.element.on("click"+h,m(n._click,n))},options:{name:"ColumnSorter",mode:l,allowUnsort:!0,compare:null,filter:"",initialDirection:d,showIndexes:!1},events:["change"],destroy:function(){var e=this;s.fn.destroy.call(e),e.element.off(h),e.dataSource.unbind("change",e._refreshHandler),e._refreshHandler=e.element=e.link=e.dataSource=null},refresh:function(i){if(!i||"itemchange"!==i.action&&"sync"!==i.action){var s,l,c,p,h,k=this,m=k.dataSource.sort()||[],x=k.element,S=x.attr(o.attr(u)),v=(k.dataSource._sortFields||{})[S];x.removeAttr(o.attr(a)),x.removeAttr(g),v&&(s=v.dir,x.attr(o.attr(a),s),h=v.index),x.is("th")&&v&&(l=n(x),l&&(x.attr(o.attr("index"))?(c=r(x.closest("table")),p=c.index(x)):p=x.parent().children(":visible").index(x),l.find("col:not(.k-group-col):not(.k-hierarchy-col)").eq(p).toggleClass("k-sorted",s!==t))),x.toggleClass("k-sorted",s!==t),x.find(".k-i-sort-asc-sm,.k-i-sort-desc-sm,.k-sort-order").remove(),s===d?(e('<span class="k-icon k-i-sort-asc-sm" />').appendTo(k.link),x.attr(g,"ascending")):s===f&&(e('<span class="k-icon k-i-sort-desc-sm" />').appendTo(k.link),x.attr(g,"descending")),k.options.showIndexes&&m.length>1&&h&&e('<span class="k-sort-order" />').html(h).appendTo(k.link)}},_toggleSortDirection:function(e){var r=this.directions;return e===r[r.length-1]&&this.options.allowUnsort?t:r[0]===e?r[1]:r[0]},_click:function(e){var r,n,i=this,s=i.element,d=s.attr(o.attr(u)),f=s.attr(o.attr(a)),h=i.options,k=null===i.options.compare?t:i.options.compare,g=i.dataSource.sort()||[],m=e.ctrlKey||e.metaKey;if(e.preventDefault(),(!h.filter||s.is(h.filter))&&(f=this._toggleSortDirection(f),!this.trigger("change",{sort:{field:d,dir:f,compare:k}}))){if(h.mode===l||h.mode===p&&!m)g=[{field:d,dir:f,compare:k}];else if(h.mode===c||h.mode===p&&m){for(r=0,n=g.length;r<n;r++)if(g[r].field===d){g.splice(r,1);break}g.push({field:d,dir:f,compare:k})}this.dataSource.options.endless&&(this.dataSource.options.endless=null,s.closest(".k-grid").getKendoGrid()._endlessPageSize=i.dataSource.options.pageSize,this.dataSource.pageSize(i.dataSource.options.pageSize)),this.dataSource.sort(g)}}});i.plugin(x)}(window.kendo.jQuery),window.kendo},r(3))}});