/** 
 * Kendo UI v2016.3.1118 (http://www.telerik.com/kendo-ui)                                                                                                                                              
 * Copyright 2016 Telerik AD. All rights reserved.                                                                                                                                                      
 *                                                                                                                                                                                                      
 * Kendo UI commercial licenses may be obtained at                                                                                                                                                      
 * http://www.telerik.com/purchase/license-agreement/kendo-ui-complete                                                                                                                                  
 * If you do not own a commercial license, this file shall be governed by the trial license terms.                                                                                                      
                                                                                                                                                                                                       
                                                                                                                                                                                                       
                                                                                                                                                                                                       
                                                                                                                                                                                                       
                                                                                                                                                                                                       
                                                                                                                                                                                                       
                                                                                                                                                                                                       
                                                                                                                                                                                                       
                                                                                                                                                                                                       
                                                                                                                                                                                                       
                                                                                                                                                                                                       
                                                                                                                                                                                                       
                                                                                                                                                                                                       
                                                                                                                                                                                                       
                                                                                                                                                                                                       

*/
!function(t,define){define("kendo.groupable.min",["kendo.core.min","kendo.draganddrop.min"],t)}(function(){return function(t,e){function r(t){return t.position().top+3}var n=window.kendo,a=n.ui.Widget,i=n._outerWidth,o=t.proxy,d=!1,s=".kendoGroupable",g="change",l=n.template('<div class="k-group-indicator" data-#=data.ns#field="${data.field}" data-#=data.ns#title="${data.title || ""}" data-#=data.ns#dir="${data.dir || "asc"}"><a href="\\#" class="k-link"><span class="k-icon k-i-sarrow-${(data.dir || "asc") == "asc" ? "n" : "s"}">(sorted ${(data.dir || "asc") == "asc" ? "ascending": "descending"})</span>${data.title ? data.title: data.field}</a><a class="k-button k-button-icon k-button-bare"><span class="k-icon k-i-group-delete"></span></a></div>',{useWithBlock:!1}),u=function(e){var r=e.attr(n.attr("title"));return r&&(r=n.htmlEncode(r)),t('<div class="k-header k-drag-clue" />').css({width:e.width(),paddingLeft:e.css("paddingLeft"),paddingRight:e.css("paddingRight"),lineHeight:e.height()+"px",paddingTop:e.css("paddingTop"),paddingBottom:e.css("paddingBottom")}).html(r||e.attr(n.attr("field"))).prepend('<span class="k-icon k-drag-status k-i-denied" />')},c=t('<div class="k-grouping-dropclue"/>'),p=a.extend({init:function(l,p){var f,h,m=this,k=n.guid(),v=o(m._intializePositions,m),_=m._dropCuePositions=[];a.fn.init.call(m,l,p),d=n.support.isRtl(l),h=d?"right":"left",m.draggable=f=m.options.draggable||new n.ui.Draggable(m.element,{filter:m.options.draggableElements,hint:u,group:k}),m.groupContainer=t(m.options.groupContainer,m.element).kendoDropTarget({group:f.options.group,dragenter:function(t){m._canDrag(t.draggable.currentTarget)&&(t.draggable.hint.find(".k-drag-status").removeClass("k-i-denied").addClass("k-i-add"),c.css("top",r(m.groupContainer)).css(h,0).appendTo(m.groupContainer))},dragleave:function(t){t.draggable.hint.find(".k-drag-status").removeClass("k-i-add").addClass("k-i-denied"),c.remove()},drop:function(e){var r,a=e.draggable.currentTarget,i=a.attr(n.attr("field")),o=a.attr(n.attr("title")),s=m.indicator(i),g=m._dropCuePositions,l=g[g.length-1];(a.hasClass("k-group-indicator")||m._canDrag(a))&&(l?(r=m._dropCuePosition(n.getOffset(c).left+parseInt(l.element.css("marginLeft"),10)*(d?-1:1)+parseInt(l.element.css("marginRight"),10)),r&&m._canDrop(t(s),r.element,r.left)&&(r.before?r.element.before(s||m.buildIndicator(i,o)):r.element.after(s||m.buildIndicator(i,o)),m._change())):(m.groupContainer.append(m.buildIndicator(i,o)),m._change()))}}).kendoDraggable({filter:"div.k-group-indicator",hint:u,group:f.options.group,dragcancel:o(m._dragCancel,m),dragstart:function(t){var e=t.currentTarget,n=parseInt(e.css("marginLeft"),10),a=e.position(),o=d?a.left-n:a.left+i(e);v(),c.css({top:r(m.groupContainer),left:o}).appendTo(m.groupContainer),this.hint.find(".k-drag-status").removeClass("k-i-denied").addClass("k-i-add")},dragend:function(){m._dragEnd(this)},drag:o(m._drag,m)}).on("click"+s,".k-button",function(e){e.preventDefault(),m._removeIndicator(t(this).parent())}).on("click"+s,".k-link",function(e){var r=t(this).parent(),a=m.buildIndicator(r.attr(n.attr("field")),r.attr(n.attr("title")),"asc"==r.attr(n.attr("dir"))?"desc":"asc");r.before(a).remove(),m._change(),e.preventDefault()}),f.bind(["dragend","dragcancel","dragstart","drag"],{dragend:function(){m._dragEnd(this)},dragcancel:o(m._dragCancel,m),dragstart:function(t){var r,n,a;return m.options.allowDrag||m._canDrag(t.currentTarget)?(v(),_.length?(r=_[_.length-1].element,n=parseInt(r.css("marginRight"),10),a=r.position().left+i(r)+n):a=0,e):(t.preventDefault(),e)},drag:o(m._drag,m)}),m.dataSource=m.options.dataSource,m.dataSource&&m._refreshHandler?m.dataSource.unbind(g,m._refreshHandler):m._refreshHandler=o(m.refresh,m),m.dataSource&&(m.dataSource.bind("change",m._refreshHandler),m.refresh())},refresh:function(){var e=this,r=e.dataSource;e.groupContainer&&e.groupContainer.empty().append(t.map(r.group()||[],function(r){var a=r.field,i=n.attr("field"),o=e.element.find(e.options.filter).filter(function(){return t(this).attr(i)===a});return e.buildIndicator(r.field,o.attr(n.attr("title")),r.dir)}).join("")),e._invalidateGroupContainer()},destroy:function(){var t=this;a.fn.destroy.call(t),t.groupContainer.off(s),t.groupContainer.data("kendoDropTarget")&&t.groupContainer.data("kendoDropTarget").destroy(),t.groupContainer.data("kendoDraggable")&&t.groupContainer.data("kendoDraggable").destroy(),t.options.draggable||t.draggable.destroy(),t.dataSource&&t._refreshHandler&&(t.dataSource.unbind("change",t._refreshHandler),t._refreshHandler=null),t.groupContainer=t.element=t.draggable=null},events:["change"],options:{name:"Groupable",filter:"th",draggableElements:"th",messages:{empty:"Drag a column header and drop it here to group by that column"}},indicator:function(e){var r=t(".k-group-indicator",this.groupContainer);return t.grep(r,function(r){return t(r).attr(n.attr("field"))===e})[0]},buildIndicator:function(t,e,r){return l({field:t.replace(/"/g,"'"),dir:r,title:e,ns:n.ns})},descriptors:function(){var e,r,a,i,o,d=this,s=t(".k-group-indicator",d.groupContainer);return e=d.element.find(d.options.filter).map(function(){var e=t(this),a=e.attr(n.attr("aggregates")),d=e.attr(n.attr("field"));if(a&&""!==a)for(r=a.split(","),a=[],i=0,o=r.length;i<o;i++)a.push({field:d,aggregate:r[i]});return a}).toArray(),t.map(s,function(r){return r=t(r),a=r.attr(n.attr("field")),{field:a,dir:r.attr(n.attr("dir")),aggregates:e||[]}})},_removeIndicator:function(t){var e=this;t.remove(),e._invalidateGroupContainer(),e._change()},_change:function(){var t,r=this;if(r.dataSource){if(t=r.descriptors(),r.trigger("change",{groups:t}))return r.refresh(),e;r.dataSource.group(t)}},_dropCuePosition:function(e){var r,n,a,o,s,g=this._dropCuePositions;if(c.is(":visible")&&0!==g.length)return e=Math.ceil(e),r=g[g.length-1],n=r.left,a=r.right,o=parseInt(r.element.css("marginLeft"),10),s=parseInt(r.element.css("marginRight"),10),e>=a&&!d||e<n&&d?e={left:r.element.position().left+(d?-o:i(r.element)+s),element:r.element,before:!1}:(e=t.grep(g,function(t){return t.left<=e&&e<=t.right||d&&e>t.right})[0],e&&(e={left:d?e.element.position().left+i(e.element)+s:e.element.position().left-o,element:e.element,before:!0})),e},_drag:function(t){var e=this._dropCuePosition(t.x.location);e&&c.css({left:e.left,right:"auto"})},_canDrag:function(t){var e=t.attr(n.attr("field"));return"false"!=t.attr(n.attr("groupable"))&&e&&(t.hasClass("k-group-indicator")||!this.indicator(e))},_canDrop:function(t,e,r){var n=t.next(),a=t[0]!==e[0]&&(!n[0]||e[0]!==n[0]||!d&&r>n.position().left||d&&r<n.position().left);return a},_dragEnd:function(e){var r=this,a=e.currentTarget.attr(n.attr("field")),i=r.indicator(a);e!==r.options.draggable&&!e.dropped&&i&&r._removeIndicator(t(i)),r._dragCancel()},_dragCancel:function(){c.remove(),this._dropCuePositions=[]},_intializePositions:function(){var e,r=this,a=t(".k-group-indicator",r.groupContainer);r._dropCuePositions=t.map(a,function(r){return r=t(r),e=n.getOffset(r).left,{left:parseInt(e,10),right:parseInt(e+i(r),10),element:r}})},_invalidateGroupContainer:function(){var t=this.groupContainer;t&&t.is(":empty")&&t.html(this.options.messages.empty)}});n.ui.plugin(p)}(window.kendo.jQuery),window.kendo},"function"==typeof define&&define.amd?define:function(t,e,r){(r||e)()});
//# sourceMappingURL=kendo.groupable.min.js.map
