sonarr-repo-only/NzbDrone.Web/Scripts/2011.2.712/telerik.grid.grouping.min.js

1 line
8.2 KiB
JavaScript
Raw Normal View History

(function(d){var b=d.telerik;var c=3;var a=0;b.scripts.push("telerik.grid.grouping.js");b.grouping={};b.grouping.initialize=function(f){d.extend(f,b.grouping.implementation);f.$groupDropCue=d('<div class="t-grouping-dropclue"/>');f.$groupHeader=d("> .t-grouping-header",f.element);function h(){var k=d.map(f.$groupHeader.find(".t-group-indicator"),function(l){var m=d(l);var n=m.offset().left;var o=m.outerWidth();return{left:n,right:n+o,width:o,$group:m}});return{first:k[0],all:k,last:k[k.length-1]}}function g(u){var l=u.$cue.text();if(!d.contains(f.element,u.target)||!d(u.target).closest(".t-grouping-header").length||(f.groupFromTitle(l)&&u.$draggable.closest(".t-header").length)){f.$groupDropCue.remove();return}var w=d(f.element),o=w.find("> .t-grid-toolbar"),m=o.outerHeight()+c,q=h(),p=w.closest(".t-rtl").length;if(!q.all.length){var r=p?o.width()-a:a;f.$groupDropCue.css({top:m,left:r}).appendTo(f.$groupHeader);return}var v=q.first;var t=q.last;var k=parseInt(v.$group.css("marginLeft"));var s=parseInt(v.$group.css("marginRight"));var n=d.grep(q.all,function(x){return u.pageX>=x.left-k-s&&u.pageX<=x.right})[0];if(!n&&v){if(!p&&u.pageX<v.left){n=v}else{if(p&&u.pageX<t.left){n=t}}}if(p){if(n){f.$groupDropCue.css({top:m,left:n.$group.position().left-k+a}).insertAfter(n.$group)}else{f.$groupDropCue.css({top:m,left:o.width()-a}).prependTo(f.$groupHeader)}}else{if(n){f.$groupDropCue.css({top:m,left:n.$group.position().left-k+a}).insertBefore(n.$group)}else{f.$groupDropCue.css({top:m,left:t.$group.position().left+t.$group.outerWidth()+s+a}).appendTo(f.$groupHeader)}}}function j(n){if(n.$draggable.hasClass("t-header")){var k=f.columnFromTitle(n.$draggable.text());return b.dragCue(k?k.title:"")}else{var m=d(".t-link",n.$draggable);var l=m.text().substr(d(".t-icon",m).text().length);var k=f.columnFromTitle(l);return b.dragCue(k?k.title:l)}}function i(k){var l=k.$cue.text();f.$groupDropCue.remove();if(k.$draggable.is(".t-group-indicator")&&k.keyCode!=27){f.unGroup(l);return false}}function e(k){k.$cue.remove()}new b.draggable({owner:f.$header,selector:".t-header:not(.t-group-cell,.t-hierarchy-cell)",scope:f.element.id+"-grouping",cue:j,start:function(k){var l=f.columnFromTitle(k.$draggable.text());return !!l.member&&l.groupable!==false},stop:i,drag:g,destroy:e});new b.draggable({owner:f.$groupingHeader,selector:".t-group-indicator",scope:f.element.id+"-grouping",cue:j,stop:i,drag:g,destroy:e});new b.droppable({owner:f.element,selector:".t-grouping-header",scope:f.element.id+"-grouping",over:function(k){b.dragCueStatus(k.$cue,"t-add")},out:function(k){b.dragCueStatus(k.$cue,"t-denied")},drop:function(o){var k=o.$cue.text();var l=f.groupFromTitle(k);var n=d.inArray(l,f.groups);var m=f.$groupHeader.find("div").index(f.$groupDropCue);var p=n-m;if(!l||(f.$groupDropCue.is(":visible")&&p!=0&&p!=-1)){f.group(k,m)}f.$groupDropCue.remove()}});if(f.isAjax()){f.$groupHeader.delegate(".t-button","click",function(m){m.preventDefault();var l=d(this).parent().find(".t-link");var k=l.text().substr(d(".t-icon",l).text().length);f.unGroup(k)}).delegate(".t-link","click",function(n){n.preventDefault();var m=d(this);var k=m.text().substr(d(".t-icon",m).text().length);var l=f.groupFromTitle(k);l.order=l.order=="asc"?"desc":"asc";f.group(l.title)})}f.$groupHeader.delegate(".t-group-indicator","mouseenter",function(){f.$currentGroupItem=d(this)}).delegate(".t-group-indicator","mouseleave",function(){f.$currentGroupItem=null});f.$tbody.delegate(".t-grouping-row .t-collapse, .t-grouping-row .t-expand","click",b.stop(function(l){l.preventDefault();var m=d(this),k=m.closest("tr");if(m.hasClass("t-collapse")){f.collapseGroup(k)}else{f.expandGroup(k)}}));f.groupFromTitle=function(k){return d.grep(f.groups,function(l){return l.title==k})[0]};f.expandGroup=function(l){var m=d(l);var k=m.find(".t-group-cell").length;m.nextAll("tr").each(function(o,p){var n=d(p);var q=n.find(".t-group-cell").length;if(q<=k){return false}if(q==k+1&&!n.hasClass("t-detail-row")){n.show();if(n.hasClass("t-grouping-row")&&n.find(".t-icon").hasClass("t-collapse")){f.expandGroup(n)}if(n.h