mirror of
https://github.com/Radarr/Radarr
synced 2024-12-24 17:01:38 +00:00
1 line
7.1 KiB
JavaScript
1 line
7.1 KiB
JavaScript
|
(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(k){var l=f.columnFromTitle(k.$draggable.text());return b.dragCue(l.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(k){k.preventDefault();f.unGroup(d(this).parent().text())}).delegate(".t-link","click",function(l){l.preventDefault();var k=f.groupFromTitle(d(this).parent().text());k.order=k.order=="asc"?"desc":"asc";f.group(k.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.hide()});m.find(".t-icon").addClass("t-expand").removeClass("t-collapse")};f.group=function(l,o){if(this.groups.length==0&&this.isAjax()){f.$groupHeader.empty()}var m=d.grep(f.groups,function(q){return q.title==l})[0];if(!m){var n=f.columnFromTitle(l);m={order:"asc",member:n.member,title:l};f.g
|