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

1 line
8.8 KiB
JavaScript
Raw Normal View History

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