{"version":3,"sources":["kendo.groupable.js"],"names":["f","define","$","undefined","dropCueOffsetTop","element","position","top","kendo","window","Widget","ui","outerWidth","_outerWidth","proxy","isRtl","NS","CHANGE","indicatorTmpl","template","useWithBlock","hint","target","title","attr","htmlEncode","css","width","paddingLeft","paddingRight","lineHeight","height","paddingTop","paddingBottom","html","prepend","dropCue","Groupable","extend","init","options","draggable","horizontalCuePosition","that","this","group","guid","intializePositions","_intializePositions","dropCuePositions","_dropCuePositions","fn","call","support","Draggable","filter","draggableElements","groupContainer","kendoDropTarget","dragenter","e","_canDrag","currentTarget","find","removeClass","addClass","appendTo","dragleave","remove","drop","targetElement","field","sourceIndicator","indicator","lastCuePosition","length","hasClass","_dropCuePosition","getOffset","left","parseInt","_canDrop","before","buildIndicator","after","_change","append","kendoDraggable","dragcancel","_dragCancel","dragstart","marginLeft","elementPosition","dragend","_dragEnd","drag","_drag","on","preventDefault","_removeIndicator","parent","current","newIndicator","bind","marginRight","allowDrag","dataSource","_refreshHandler","unbind","refresh","empty","map","item","fieldName","dir","join","_invalidateGroupContainer","destroy","off","data","events","name","messages","indicators","grep","replace","ns","descriptors","aggregates","names","idx","cell","aggregate","member","split","push","toArray","trigger","groups","right","is","Math","ceil","event","x","location","source","next","result","dropped","plugin","jQuery","amd","a1","a2","a3"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;CAwBC,SAAUA,EAAGC,QACVA,OAAO,mBACH,aACA,qBACDD,IACL,WAsTE,MA3SC,UAAUE,EAAGC,GAeV,QAASC,GAAiBC,GACtB,MAAOA,GAAQC,WAAWC,IAAM,EAhBvC,GACOC,GAAQC,OAAOD,MAAOE,EAASF,EAAMG,GAAGD,OAAQE,EAAaJ,EAAMK,YAAaC,EAAQZ,EAAEY,MAAOC,GAAQ,EAAOC,EAAK,kBAAmBC,EAAS,SAAUC,EAAgBV,EAAMW,SAAS,keAA4gBC,cAAc,IAAUC,EAAO,SAAUC,GAC3uB,GAAIC,GAAQD,EAAOE,KAAKhB,EAA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H,EAAO,MAAQ6H,EAAK,IAAM7H,EAAO,KAAO6H,EAAK,KAAQpI,GAAST,EAAW6I,EAAK7I,WAAWyE,MAAQhE,GAAST,EAAW6I,EAAK7I,WAAWyE,KACtL,OAAOqE,IAEXtD,SAAU,SAAUrD,GAChB,GAAIE,GAAOC,KAAM2B,EAAQ9B,EAAUqB,cAActC,KAAKhB,EAAMgB,KAAK,UAAWgD,EAAkB7B,EAAK8B,UAAUF,EACzG9B,KAAcE,EAAKH,QAAQC,YAAcA,EAAU4G,SAAW7E,GAC9D7B,EAAKwD,iBAAiBjG,EAAEsE,IAE5B7B,EAAK8C,eAETA,YAAa,WACTrD,EAAQgC,SACRxB,KAAKM,sBAETF,oBAAqB,WACjB,GAA4E+B,GAAxEpC,EAAOC,KAAM+E,EAAazH,EAAE,qBAAsByC,EAAKc,eAC3Dd,GAAKO,kBAAoBhD,EAAE6G,IAAIY,EAAY,SAAUX,GAGjD,MAFAA,GAAO9G,EAAE8G,GACTjC,EAAOvE,EAAMsE,UAAUkC,GAAMjC,MAEzBA,KAAMC,SAASD,EAAM,IACrB4D,MAAO3D,SAASD,EAAOnE,EAAWoG,GAAO,IACzC3G,QAAS2G,MAIrBI,0BAA2B,WACvB,GAAI3D,GAAiBb,KAAKa,cACtBA,IAAkBA,EAAemF,GAAG,WACpCnF,EAAevB,KAAKU,KAAKJ,QAAQkF,SAASZ,SAItDtG,GAAMG,GAAG2I,OAAOjH,IAClB5B,OAAOD,MAAM+I,QACR9I,OAAOD,OACE,kBAAVP,SAAwBA,OAAOuJ,IAAMvJ,OAAS,SAAUwJ,EAAIC,EAAIC,IACrEA,GAAMD","file":"kendo.groupable.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.groupable', [\n 'kendo.core',\n 'kendo.draganddrop'\n ], f);\n}(function () {\n var __meta__ = {\n id: 'groupable',\n name: 'Groupable',\n category: 'framework',\n depends: [\n 'core',\n 'draganddrop'\n ],\n advanced: true\n };\n (function ($, undefined) {\n var kendo = window.kendo, Widget = kendo.ui.Widget, outerWidth = kendo._outerWidth, proxy = $.proxy, isRtl = false, NS = '.kendoGroupable', CHANGE = 'change', indicatorTmpl = kendo.template('
' + '' + '(sorted ${(data.dir || \"asc\") == \"asc\" ? \"ascending\": \"descending\"})' + '${data.title ? data.title: data.field}' + '' + '' + '' + '' + '
', { useWithBlock: false }), hint = function (target) {\n var title = target.attr(kendo.attr('title'));\n if (title) {\n title = kendo.htmlEncode(title);\n }\n return $('
').css({\n width: target.width(),\n paddingLeft: target.css('paddingLeft'),\n paddingRight: target.css('paddingRight'),\n lineHeight: target.height() + 'px',\n paddingTop: target.css('paddingTop'),\n paddingBottom: target.css('paddingBottom')\n }).html(title || target.attr(kendo.attr('field'))).prepend('');\n }, dropCue = $('
');\n function dropCueOffsetTop(element) {\n return element.position().top + 3;\n }\n var Groupable = Widget.extend({\n init: function (element, options) {\n var that = this, group = kendo.guid(), intializePositions = proxy(that._intializePositions, that), draggable, horizontalCuePosition, dropCuePositions = that._dropCuePositions = [];\n Widget.fn.init.call(that, element, options);\n isRtl = kendo.support.isRtl(element);\n horizontalCuePosition = isRtl ? 'right' : 'left';\n that.draggable = draggable = that.options.draggable || new kendo.ui.Draggable(that.element, {\n filter: that.options.draggableElements,\n hint: hint,\n group: group\n });\n that.groupContainer = $(that.options.groupContainer, that.element).kendoDropTarget({\n group: draggable.options.group,\n dragenter: function (e) {\n if (that._canDrag(e.draggable.currentTarget)) {\n e.draggable.hint.find('.k-drag-status').removeClass('k-i-denied').addClass('k-i-add');\n dropCue.css('top', dropCueOffsetTop(that.groupContainer)).css(horizontalCuePosition, 0).appendTo(that.groupContainer);\n }\n },\n dragleave: function (e) {\n e.draggable.hint.find('.k-drag-status').removeClass('k-i-add').addClass('k-i-denied');\n dropCue.remove();\n },\n drop: function (e) {\n var targetElement = e.draggable.currentTarget, field = targetElement.attr(kendo.attr('field')), title = targetElement.attr(kendo.attr('title')), sourceIndicator = that.indicator(field), dropCuePositions = that._dropCuePositions, lastCuePosition = dropCuePositions[dropCuePositions.length - 1], position;\n if (!targetElement.hasClass('k-group-indicator') && !that._canDrag(targetElement)) {\n return;\n }\n if (lastCuePosition) {\n position = that._dropCuePosition(kendo.getOffset(dropCue).left + parseInt(lastCuePosition.element.css('marginLeft'), 10) * (isRtl ? -1 : 1) + parseInt(lastCuePosition.element.css('marginRight'), 10));\n if (position && that._canDrop($(sourceIndicator), position.element, position.left)) {\n if (position.before) {\n position.element.before(sourceIndicator || that.buildIndicator(field, title));\n } else {\n position.element.after(sourceIndicator || that.buildIndicator(field, title));\n }\n that._change();\n }\n } else {\n that.groupContainer.append(that.buildIndicator(field, title));\n that._change();\n }\n }\n }).kendoDraggable({\n filter: 'div.k-group-indicator',\n hint: hint,\n group: draggable.options.group,\n dragcancel: proxy(that._dragCancel, that),\n dragstart: function (e) {\n var element = e.currentTarget, marginLeft = parseInt(element.css('marginLeft'), 10), elementPosition = element.position(), left = isRtl ? elementPosition.left - marginLeft : elementPosition.left + outerWidth(element);\n intializePositions();\n dropCue.css({\n top: dropCueOffsetTop(that.groupContainer),\n left: left\n }).appendTo(that.groupContainer);\n this.hint.find('.k-drag-status').removeClass('k-i-denied').addClass('k-i-add');\n },\n dragend: function () {\n that._dragEnd(this);\n },\n drag: proxy(that._drag, that)\n }).on('click' + NS, '.k-button', function (e) {\n e.preventDefault();\n that._removeIndicator($(this).parent());\n }).on('click' + NS, '.k-link', function (e) {\n var current = $(this).parent(), newIndicator = that.buildIndicator(current.attr(kendo.attr('field')), current.attr(kendo.attr('title')), current.attr(kendo.attr('dir')) == 'asc' ? 'desc' : 'asc');\n current.before(newIndicator).remove();\n that._change();\n e.preventDefault();\n });\n draggable.bind([\n 'dragend',\n 'dragcancel',\n 'dragstart',\n 'drag'\n ], {\n dragend: function () {\n that._dragEnd(this);\n },\n dragcancel: proxy(that._dragCancel, that),\n dragstart: function (e) {\n var element, marginRight, left;\n if (!that.options.allowDrag && !that._canDrag(e.currentTarget)) {\n e.preventDefault();\n return;\n }\n intializePositions();\n if (dropCuePositions.length) {\n element = dropCuePositions[dropCuePositions.length - 1].element;\n marginRight = parseInt(element.css('marginRight'), 10);\n left = element.position().left + outerWidth(element) + marginRight;\n } else {\n left = 0;\n }\n },\n drag: proxy(that._drag, that)\n });\n that.dataSource = that.options.dataSource;\n if (that.dataSource && that._refreshHandler) {\n that.dataSource.unbind(CHANGE, that._refreshHandler);\n } else {\n that._refreshHandler = proxy(that.refresh, that);\n }\n if (that.dataSource) {\n that.dataSource.bind('change', that._refreshHandler);\n that.refresh();\n }\n },\n refresh: function () {\n var that = this, dataSource = that.dataSource;\n if (that.groupContainer) {\n that.groupContainer.empty().append($.map(dataSource.group() || [], function (item) {\n var fieldName = item.field;\n var attr = kendo.attr('field');\n var element = that.element.find(that.options.filter).filter(function () {\n return $(this).attr(attr) === fieldName;\n });\n return that.buildIndicator(item.field, element.attr(kendo.attr('title')), item.dir);\n }).join(''));\n }\n that._invalidateGroupContainer();\n },\n destroy: function () {\n var that = this;\n Widget.fn.destroy.call(that);\n that.groupContainer.off(NS);\n if (that.groupContainer.data('kendoDropTarget')) {\n that.groupContainer.data('kendoDropTarget').destroy();\n }\n if (that.groupContainer.data('kendoDraggable')) {\n that.groupContainer.data('kendoDraggable').destroy();\n }\n if (!that.options.draggable) {\n that.draggable.destroy();\n }\n if (that.dataSource && that._refreshHandler) {\n that.dataSource.unbind('change', that._refreshHandler);\n that._refreshHandler = null;\n }\n that.groupContainer = that.element = that.draggable = null;\n },\n events: ['change'],\n options: {\n name: 'Groupable',\n filter: 'th',\n draggableElements: 'th',\n messages: { empty: 'Drag a column header and drop it here to group by that column' }\n },\n indicator: function (field) {\n var indicators = $('.k-group-indicator', this.groupContainer);\n return $.grep(indicators, function (item) {\n return $(item).attr(kendo.attr('field')) === field;\n })[0];\n },\n buildIndicator: function (field, title, dir) {\n return indicatorTmpl({\n field: field.replace(/\"/g, '\\''),\n dir: dir,\n title: title,\n ns: kendo.ns\n });\n },\n descriptors: function () {\n var that = this, indicators = $('.k-group-indicator', that.groupContainer), aggregates, names, field, idx, length;\n aggregates = that.element.find(that.options.filter).map(function () {\n var cell = $(this), aggregate = cell.attr(kendo.attr('aggregates')), member = cell.attr(kendo.attr('field'));\n if (aggregate && aggregate !== '') {\n names = aggregate.split(',');\n aggregate = [];\n for (idx = 0, length = names.length; idx < length; idx++) {\n aggregate.push({\n field: member,\n aggregate: names[idx]\n });\n }\n }\n return aggregate;\n }).toArray();\n return $.map(indicators, function (item) {\n item = $(item);\n field = item.attr(kendo.attr('field'));\n return {\n field: field,\n dir: item.attr(kendo.attr('dir')),\n aggregates: aggregates || []\n };\n });\n },\n _removeIndicator: function (indicator) {\n var that = this;\n indicator.remove();\n that._invalidateGroupContainer();\n that._change();\n },\n _change: function () {\n var that = this;\n if (that.dataSource) {\n var descriptors = that.descriptors();\n if (that.trigger('change', { groups: descriptors })) {\n that.refresh();\n return;\n }\n that.dataSource.group(descriptors);\n }\n },\n _dropCuePosition: function (position) {\n var dropCuePositions = this._dropCuePositions;\n if (!dropCue.is(':visible') || dropCuePositions.length === 0) {\n return;\n }\n position = Math.ceil(position);\n var lastCuePosition = dropCuePositions[dropCuePositions.length - 1], left = lastCuePosition.left, right = lastCuePosition.right, marginLeft = parseInt(lastCuePosition.element.css('marginLeft'), 10), marginRight = parseInt(lastCuePosition.element.css('marginRight'), 10);\n if (position >= right && !isRtl || position < left && isRtl) {\n position = {\n left: lastCuePosition.element.position().left + (!isRtl ? outerWidth(lastCuePosition.element) + marginRight : -marginLeft),\n element: lastCuePosition.element,\n before: false\n };\n } else {\n position = $.grep(dropCuePositions, function (item) {\n return item.left <= position && position <= item.right || isRtl && position > item.right;\n })[0];\n if (position) {\n position = {\n left: isRtl ? position.element.position().left + outerWidth(position.element) + marginRight : position.element.position().left - marginLeft,\n element: position.element,\n before: true\n };\n }\n }\n return position;\n },\n _drag: function (event) {\n var position = this._dropCuePosition(event.x.location);\n if (position) {\n dropCue.css({\n left: position.left,\n right: 'auto'\n });\n }\n },\n _canDrag: function (element) {\n var field = element.attr(kendo.attr('field'));\n return element.attr(kendo.attr('groupable')) != 'false' && field && (element.hasClass('k-group-indicator') || !this.indicator(field));\n },\n _canDrop: function (source, target, position) {\n var next = source.next(), result = source[0] !== target[0] && (!next[0] || target[0] !== next[0] || (!isRtl && position > next.position().left || isRtl && position < next.position().left));\n return result;\n },\n _dragEnd: function (draggable) {\n var that = this, field = draggable.currentTarget.attr(kendo.attr('field')), sourceIndicator = that.indicator(field);\n if (draggable !== that.options.draggable && !draggable.dropped && sourceIndicator) {\n that._removeIndicator($(sourceIndicator));\n }\n that._dragCancel();\n },\n _dragCancel: function () {\n dropCue.remove();\n this._dropCuePositions = [];\n },\n _intializePositions: function () {\n var that = this, indicators = $('.k-group-indicator', that.groupContainer), left;\n that._dropCuePositions = $.map(indicators, function (item) {\n item = $(item);\n left = kendo.getOffset(item).left;\n return {\n left: parseInt(left, 10),\n right: parseInt(left + outerWidth(item), 10),\n element: item\n };\n });\n },\n _invalidateGroupContainer: function () {\n var groupContainer = this.groupContainer;\n if (groupContainer && groupContainer.is(':empty')) {\n groupContainer.html(this.options.messages.empty);\n }\n }\n });\n kendo.ui.plugin(Groupable);\n }(window.kendo.jQuery));\n return window.kendo;\n}, typeof define == 'function' && define.amd ? define : function (a1, a2, a3) {\n (a3 || a2)();\n}));"],"sourceRoot":"/source/"}