{"version":3,"sources":["kendo.columnsorter.js"],"names":["f","define","$","undefined","kendo","window","ui","Widget","DIR","ASC","SINGLE","FIELD","DESC","sorterNS","TLINK","ARIASORT","proxy","ColumnSorter","extend","init","element","options","link","that","this","fn","call","_refreshHandler","refresh","dataSource","bind","directions","initialDirection","find","wrapInner","on","_click","name","mode","allowUnsort","compare","filter","showIndexes","events","destroy","off","unbind","idx","length","descriptor","dir","sortOrder","table","sort","field","attr","removeAttr","is","closest","parent","hasClass","toggleClass","children","eq","index","remove","appendTo","html","_toggleSortDirection","e","preventDefault","trigger","splice","push","endless","getKendoGrid","_endlessPageSize","pageSize","plugin","jQuery","amd","a1","a2","a3"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;CAwBC,SAAUA,EAAGC,QACVA,OAAO,sBAAuB,cAAeD,IAC/C,WAkJE,MA1IC,UAAUE,EAAGC,GAAb,GACOC,GAAQC,OAAOD,MACfE,EAAKF,EAAME,GACXC,EAASD,EAAGC,OACZC,EAAM,MACNC,EAAM,MACNC,EAAS,SACTC,EAAQ,QACRC,EAAO,OACPC,EAAW,qBACXC,EAAQ,UACRC,EAAW,YACXC,EAAQd,EAAEc,MACVC,EAAeV,EAAOW,QACtBC,KAAM,SAAUC,EAASC,GACrB,GAAiBC,GAAbC,EAAOC,IACXjB,GAAOkB,GAAGN,KAAKO,KAAKH,EAAMH,EAASC,GACnCE,EAAKI,gBAAkBX,EAAMO,EAAKK,QAASL,GAC3CA,EAAKM,WAAaN,EAAKF,QAAQQ,WAAWC,KAAK,SAAUP,EAAKI,iBAC9DJ,EAAKQ,WAAaR,EAAKF,QAAQW,mBAAqBvB,GAChDA,EACAG,IAEAA,EACAH,GAEJa,EAAOC,EAAKH,QAAQa,KAAKnB,GACpBQ,EAAK,KACNA,EAAOC,EAAKH,QAAQc,UAAU,gCAAgCD,KAAKnB,IAEvES,EAAKD,KAAOA,EACZC,EAAKH,QAAQe,GAAG,QAAUtB,EAAUG,EAAMO,EAAKa,OAAQb,KAE3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D,KAAKK,WAAWR,QAAQqD,QAAU,KAClCtD,EAAQsC,QAAQ,WAAWiB,eAAeC,iBAAmBrD,EAAKM,WAAWR,QAAQwD,SACrFrD,KAAKK,WAAWgD,SAAStD,EAAKM,WAAWR,QAAQwD,WAErDrD,KAAKK,WAAWwB,KAAKA,MAG7B/C,GAAGwE,OAAO7D,IACZZ,OAAOD,MAAM2E,QACR1E,OAAOD,OACE,kBAAVH,SAAwBA,OAAO+E,IAAM/E,OAAS,SAAUgF,EAAIC,EAAIC,IACrEA,GAAMD","file":"kendo.columnsorter.min.js","sourcesContent":["/*!\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n*/\n(function (f, define) {\n define('kendo.columnsorter', ['kendo.core'], f);\n}(function () {\n var __meta__ = {\n id: 'columnsorter',\n name: 'Column Sorter',\n category: 'framework',\n depends: ['core'],\n advanced: true\n };\n (function ($, undefined) {\n var kendo = window.kendo;\n var ui = kendo.ui;\n var Widget = ui.Widget;\n var DIR = 'dir';\n var ASC = 'asc';\n var SINGLE = 'single';\n var FIELD = 'field';\n var DESC = 'desc';\n var sorterNS = '.kendoColumnSorter';\n var TLINK = '.k-link';\n var ARIASORT = 'aria-sort';\n var proxy = $.proxy;\n var ColumnSorter = Widget.extend({\n init: function (element, options) {\n var that = this, link;\n Widget.fn.init.call(that, element, options);\n that._refreshHandler = proxy(that.refresh, that);\n that.dataSource = that.options.dataSource.bind('change', that._refreshHandler);\n that.directions = that.options.initialDirection === ASC ? [\n ASC,\n DESC\n ] : [\n DESC,\n ASC\n ];\n link = that.element.find(TLINK);\n if (!link[0]) {\n link = that.element.wrapInner('').find(TLINK);\n }\n that.link = link;\n that.element.on('click' + sorterNS, proxy(that._click, that));\n },\n options: {\n name: 'ColumnSorter',\n mode: SINGLE,\n allowUnsort: true,\n compare: null,\n filter: '',\n initialDirection: ASC,\n showIndexes: false\n },\n events: ['change'],\n destroy: function () {\n var that = this;\n Widget.fn.destroy.call(that);\n that.element.off(sorterNS);\n that.dataSource.unbind('change', that._refreshHandler);\n that._refreshHandler = that.element = that.link = that.dataSource = null;\n },\n refresh: function () {\n var that = this, sort = that.dataSource.sort() || [], idx, length, descriptor, dir, element = that.element, field = element.attr(kendo.attr(FIELD)), sortOrder;\n element.removeAttr(kendo.attr(DIR));\n element.removeAttr(ARIASORT);\n for (idx = 0, length = sort.length; idx < length; idx++) {\n descriptor = sort[idx];\n if (field == descriptor.field) {\n element.attr(kendo.attr(DIR), descriptor.dir);\n sortOrder = idx + 1;\n }\n }\n dir = element.attr(kendo.attr(DIR));\n if (element.is('th')) {\n var table = element.closest('table');\n if (table.parent().hasClass('k-grid-header-wrap')) {\n table = table.closest('.k-grid').find('.k-grid-content > table');\n } else if (!table.parent().hasClass('k-grid')) {\n table = null;\n }\n if (table) {\n element.toggleClass('k-sorted', dir !== undefined);\n table.children('colgroup').children().eq(element.index()).toggleClass('k-sorted', dir !== undefined);\n }\n }\n element.find('.k-i-sort-asc-sm,.k-i-sort-desc-sm,.k-sort-order').remove();\n if (dir === ASC) {\n $('').appendTo(that.link);\n element.attr(ARIASORT, 'ascending');\n } else if (dir === DESC) {\n $('').appendTo(that.link);\n element.attr(ARIASORT, 'descending');\n }\n if (that.options.showIndexes && sort.length > 1 && sortOrder) {\n $('').html(sortOrder).appendTo(that.link);\n }\n },\n _toggleSortDirection: function (dir) {\n var directions = this.directions;\n if (dir === directions[directions.length - 1] && this.options.allowUnsort) {\n return undefined;\n }\n return directions[0] === dir ? directions[1] : directions[0];\n },\n _click: function (e) {\n var that = this, element = that.element, field = element.attr(kendo.attr(FIELD)), dir = element.attr(kendo.attr(DIR)), options = that.options, compare = that.options.compare === null ? undefined : that.options.compare, sort = that.dataSource.sort() || [], idx, length;\n e.preventDefault();\n if (options.filter && !element.is(options.filter)) {\n return;\n }\n dir = this._toggleSortDirection(dir);\n if (this.trigger('change', {\n sort: {\n field: field,\n dir: dir,\n compare: compare\n }\n })) {\n return;\n }\n if (options.mode === SINGLE) {\n sort = [{\n field: field,\n dir: dir,\n compare: compare\n }];\n } else if (options.mode === 'multiple') {\n for (idx = 0, length = sort.length; idx < length; idx++) {\n if (sort[idx].field === field) {\n sort.splice(idx, 1);\n break;\n }\n }\n sort.push({\n field: field,\n dir: dir,\n compare: compare\n });\n }\n if (this.dataSource.options.endless) {\n this.dataSource.options.endless = null;\n element.closest('.k-grid').getKendoGrid()._endlessPageSize = that.dataSource.options.pageSize;\n this.dataSource.pageSize(that.dataSource.options.pageSize);\n }\n this.dataSource.sort(sort);\n }\n });\n ui.plugin(ColumnSorter);\n }(window.kendo.jQuery));\n return window.kendo;\n}, typeof define == 'function' && define.amd ? define : function (a1, a2, a3) {\n (a3 || a2)();\n}));"]}