You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Radarr/NzbDrone.Web/Scripts/2011.1.315/telerik.grid.grouping.min.js

1 line
7.8 KiB

(function(d){var b=d.telerik;var c=3;var a=0;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(r){var m=r.$cue.text();if(!d.contains(f.element,r.target)||!d(r.target).closest(".t-grouping-header").length||(f.groupFromTitle(m)&&r.$draggable.closest(".t-header").length)){f.$groupDropCue.remove();return}var n=d("> .t-grid-toolbar",f.element).outerHeight()+c;var o=h();if(!o.all.length){f.$groupDropCue.css({top:n,left:a}).appendTo(f.$groupHeader);return}var q=o.first;var s=o.last;var l=parseInt(q.$group.css("marginLeft"));var k=parseInt(q.$group.css("marginRight"));var p=d.grep(o.all,function(t){return r.pageX>=t.left-l-k&&r.pageX<=t.right})[0];if(!p&&q&&r.pageX<q.left){p=q}if(p){f.$groupDropCue.css({top:n,left:p.$group.position().left-l+a}).insertBefore(p.$group)}else{f.$groupDropCue.css({top:n,left:s.$group.position().left+s.$group.outerWidth()+k+a}).appendTo(f.$groupHeader)}}function j(n){if(n.$draggable.hasClass("t-header")){var k=f.columnFromTitle(n.$draggable.text());return b.dragCue(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.title)}}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.hasClass("t-master-row")&&n.find(".t-icon").hasClass("t-minus")){n.next().show()}}});m.find(".t-icon").addClass("t-collapse").removeClass("t-expand")};f.collapseGroup=function(l){var m=d(l);var k=m.find(".t-group-cell").length;m.nextAll("tr").each(function(){var n=d(this);var o=n.find(".t-group-cell").length;if(o<=k){return false}n.h