/* * 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(t,e){return e()})(["./kendo.core.min","./kendo.draganddrop.min"],function(){!function(t){function e(t){return t.position().top+3}var r=window.kendo,a=r.ui.Widget,n=t.proxy,i=!1,o=".kendoGroupable",d=r.template('
(sorted ${(data.dir || "asc") == "asc" ? "ascending": "descending"})${data.title ? data.title: data.field}
',{useWithBlock:!1}),s=function(e){return t('
').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(e.attr(r.attr("title"))||e.attr(r.attr("field"))).prepend('')},l=t('
'),g=/("|\%|'|\[|\]|\$|\.|\,|\:|\;|\+|\*|\&|\!|\#|\(|\)|<|>|\=|\?|\@|\^|\{|\}|\~|\/|\||`)/g,c=a.extend({init:function(d,g){var c,u,p,f=this,h=r.guid(),m=n(f._intializePositions,f),k=f._dropCuePositions=[];a.fn.init.call(f,d,g),i=r.support.isRtl(d),p=i?"right":"left",f.draggable=u=f.options.draggable||new r.ui.Draggable(f.element,{filter:f.options.draggableElements,hint:s,group:h}),c=f.groupContainer=t(f.options.groupContainer,f.element).kendoDropTarget({group:u.options.group,dragenter:function(t){f._canDrag(t.draggable.currentTarget)&&(t.draggable.hint.find(".k-drag-status").removeClass("k-denied").addClass("k-add"),l.css("top",e(c)).css(p,0).appendTo(c))},dragleave:function(t){t.draggable.hint.find(".k-drag-status").removeClass("k-add").addClass("k-denied"),l.remove()},drop:function(e){var a,n=e.draggable.currentTarget,o=n.attr(r.attr("field")),d=n.attr(r.attr("title")),s=f.indicator(o),g=f._dropCuePositions,c=g[g.length-1];(n.hasClass("k-group-indicator")||f._canDrag(n))&&(c?(a=f._dropCuePosition(r.getOffset(l).left+parseInt(c.element.css("marginLeft"),10)*(i?-1:1)+parseInt(c.element.css("marginRight"),10)),a&&f._canDrop(t(s),a.element,a.left)&&(a.before?a.element.before(s||f.buildIndicator(o,d)):a.element.after(s||f.buildIndicator(o,d)),f._change())):(f.groupContainer.append(f.buildIndicator(o,d)),f._change()))}}).kendoDraggable({filter:"div.k-group-indicator",hint:s,group:u.options.group,dragcancel:n(f._dragCancel,f),dragstart:function(t){var r=t.currentTarget,a=parseInt(r.css("marginLeft"),10),n=r.position(),o=i?n.left-a:n.left+r.outerWidth();m(),l.css({top:e(c),left:o}).appendTo(c),this.hint.find(".k-drag-status").removeClass("k-denied").addClass("k-add")},dragend:function(){f._dragEnd(this)},drag:n(f._drag,f)}).on("click"+o,".k-button",function(e){e.preventDefault(),f._removeIndicator(t(this).parent())}).on("click"+o,".k-link",function(e){var a=t(this).parent(),n=f.buildIndicator(a.attr(r.attr("field")),a.attr(r.attr("title")),"asc"==a.attr(r.attr("dir"))?"desc":"asc");a.before(n).remove(),f._change(),e.preventDefault()}),u.bind(["dragend","dragcancel","dragstart","drag"],{dragend:function(){f._dragEnd(this)},dragcancel:n(f._dragCancel,f),dragstart:function(t){var e,r,a;return f.options.allowDrag||f._canDrag(t.currentTarget)?(m(),k.length?(e=k[k.length-1].element,r=parseInt(e.css("marginRight"),10),a=e.position().left+e.outerWidth()+r):a=0,undefined):(t.preventDefault(),undefined)},drag:n(f._drag,f)}),f.dataSource=f.options.dataSource,f.dataSource&&(f._refreshHandler=n(f.refresh,f),f.dataSource.bind("change",f._refreshHandler))},refresh:function(){var e=this,a=e.dataSource;e.groupContainer.empty().append(t.map(a.group()||[],function(t){var a=t.field.replace(g,"\\$1"),n=e.element.find(e.options.filter).filter("["+r.attr("field")+"="+a+"]");return e.buildIndicator(t.field,n.attr(r.attr("title")),t.dir)}).join("")),e._invalidateGroupContainer()},destroy:function(){var t=this;a.fn.destroy.call(t),t.groupContainer.off(o).kendoDropTarget("destroy").kendoDraggable("destroy"),t.options.draggable||t.draggable.destroy(),t.dataSource&&t._refreshHandler&&t.dataSource.unbind("change",t._refreshHandler)},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 a=t(".k-group-indicator",this.groupContainer);return t.grep(a,function(a){return t(a).attr(r.attr("field"))===e})[0]},buildIndicator:function(t,e,a){return d({field:t.replace(/"/g,"'"),dir:a,title:e,ns:r.ns})},descriptors:function(){var e,a,n,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),n=e.attr(r.attr("aggregates")),d=e.attr(r.attr("field"));if(n&&""!==n)for(a=n.split(","),n=[],i=0,o=a.length;o>i;i++)n.push({field:d,aggregate:a[i]});return n}).toArray(),t.map(s,function(a){return a=t(a),n=a.attr(r.attr("field")),{field:n,dir:a.attr(r.attr("dir")),aggregates:e||[]}})},_removeIndicator:function(t){var e=this;t.remove(),e._invalidateGroupContainer(),e._change()},_change:function(){var t=this;t.dataSource&&t.dataSource.group(t.descriptors())},_dropCuePosition:function(e){var r,a,n,o,d,s=this._dropCuePositions;if(l.is(":visible")&&0!==s.length)return e=Math.ceil(e),r=s[s.length-1],a=r.left,n=r.right,o=parseInt(r.element.css("marginLeft"),10),d=parseInt(r.element.css("marginRight"),10),e>=n&&!i||a>e&&i?e={left:r.element.position().left+(i?-o:r.element.outerWidth()+d),element:r.element,before:!1}:(e=t.grep(s,function(t){return t.left<=e&&e<=t.right||i&&e>t.right})[0],e&&(e={left:i?e.element.position().left+e.element.outerWidth()+d:e.element.position().left-o,element:e.element,before:!0})),e},_drag:function(t){var e=this._dropCuePosition(t.x.location);e&&l.css({left:e.left,right:"auto"})},_canDrag:function(t){var e=t.attr(r.attr("field"));return"false"!=t.attr(r.attr("groupable"))&&e&&(t.hasClass("k-group-indicator")||!this.indicator(e))},_canDrop:function(t,e,r){var a=t.next(),n=t[0]!==e[0]&&(!a[0]||e[0]!==a[0]||!i&&r>a.position().left||i&&r