/*! Dragtable Mod for TableSorter - 2/7/2015 (v2.19.0) */ !function(a){"use strict";function b(){var b=a('');a(document.head).append(b),a(document.body).attr("onselectstart","return false;").attr("unselectable","on"),window.getSelection?window.getSelection().removeAllRanges():document.selection.empty()}function c(){a("#__dragtable_disable_text_selection__").remove(),f?a(document.body).attr("onselectstart",f):a(document.body).removeAttr("onselectstart"),g?a(document.body).attr("unselectable",g):a(document.body).removeAttr("unselectable")}var d,e=a.tablesorter;e.dragtable={create:function(b){var c,d=b.originalTable.el,e=b.options.dragHandle.replace(".","");d.children("thead").children().children("th,td").each(function(){var d=a(this);d.find(b.options.dragHandle+",."+e+"-disabled").length||(c=b.options.dragaccept?d.hasClass(b.options.dragaccept.replace(".","")):!0,d.wrapInner('
').prepend('
'))})},start:function(b){b=a(b)[0],b&&b.config&&(b.config.widgetOptions.dragtableLast={search:a(b).data("lastSearch"),order:e.dragtable.getOrder(b)})},update:function(b){var c,d,f,g=b.originalTable,h=g.el[0],i=a(h),j=h.config,k=j&&j.widgetOptions,l=g.startIndex-1,m=g.endIndex-1,n=e.dragtable.getOrder(h)||[],o=e.hasWidget(i,"filter")||!1,p=k&&k.dragtableLast||{},q=[];(p.order||[]).join("")!==n.join("")&&(j.sortList.length&&(d=a.extend(!0,[],j.sortList),a.each(n,function(a,b){f=e.isValueInArray(parseInt(b,10),d),b!==p.order[a]&&f>=0&&(j.sortList[f][0]=a)})),o&&a.each(p.search||[],function(a){q[a]=p.search[n[a]]}),c=e.hasWidget(j.$table,"editable")?k.editable_columnsArray:!1,c&&(j.widgetOptions.editable_columnsArray=e.dragtable.reindexArrayItem(c,l,m)),c=e.hasWidget(j.$table,"math")?k.math_ignore:!1,c&&(j.widgetOptions.math_ignore=e.dragtable.reindexArrayItem(c,l,m)),c=e.hasWidget(j.$table,"resizable")?k.resizable_widths:!1,c&&(k.resizable_widths=e.dragtable.moveArrayItem(c,l,m)),e.updateAll(j,!1,function(){o&&setTimeout(function(){j.lastCombinedFilter=null,j.$table.data("lastSearch",q),e.setFilters(i,q),a.isFunction(b.options.tablesorterComplete)&&b.options.tablesorterComplete(j.table)},10)}))},getOrder:function(b){return a(b).children("thead").children("."+e.css.headerRow).children().map(function(){return a(this).attr("data-column")}).get()||[]},startColumnMove:function(b){var c,d=b.el[0].config,e=b.startIndex-1,f=b.endIndex-1,g=d.columns-1,h=f===g?!1:e>=f,i=d.$table.children().children("tr");d.debug&&console.log("Inserting column "+e+(h?" before":" after")+" column "+f),i.each(function(){c=a(this).children(),c.eq(e)[h?"insertBefore":"insertAfter"](c.eq(f))}),c=d.$table.children("colgroup").children(),c.eq(e)[h?"insertBefore":"insertAfter"](c.eq(f))},swapNodes:function(a,b){var c,d,e,f=a.length;for(c=0;f>c;c++)d=a[c].parentNode,e=a[c].nextSibling===b[c]?a[c]:a[c].nextSibling,b[c].parentNode.insertBefore(a[c],b[c]),d.insertBefore(b[c],e)},moveArrayItem:function(a,b,c){var e,f=a.length;if(c>=f)for(e=c-f;e--+1;)a.push(d);return a.splice(c,0,a.splice(b,1)[0]),a},reindexArrayItem:function(b,c,d){var e=a.inArray(d,b),f=a.inArray(c,b),g=(Math.max.apply(Math,b),[]);return e>=0&&f>=0?b:(a.each(b,function(a,b){c>d?b>=d?g.push(b+(c>b?1:0)):g.push(b):d>c&&(b===c?g.push(d):d>b&&b>=c?g.push(b-1):d>=b?g.push(b):b>c&&g.push(b+(d>b?0:1)))}),g.sort())}},/*! dragtable v2.0.14 Mod */ a.widget("akottr.dragtable",{options:{revert:!1,dragHandle:".table-handle",maxMovingRows:40,excludeFooter:!1,onlyHeaderThreshold:100,dragaccept:null,persistState:null,restoreState:null,exact:!0,clickDelay:10,containment:null,cursor:"move",cursorAt:!1,distance:0,tolerance:"pointer",axis:"x",beforeStart:a.noop,beforeMoving:a.noop,beforeReorganize:a.noop,beforeStop:a.noop,tablesorterComplete:null,sortClass:".sorter"},originalTable:{el:null,selectedHandle:null,sortOrder:null,startIndex:0,endIndex:0},sortableTable:{el:a(),selectedHandle:a(),movingRow:a()},persistState:function(){var b=this;this.originalTable.el.find("th").each(function(a){""!==this.id&&(b.originalTable.sortOrder[this.id]=a)}),a.ajax({url:this.options.persistState,data:this.originalTable.sortOrder})},_restoreState:function(b){for(var c in b)c in b&&(this.originalTable.startIndex=a("#"+c).closest("th").prevAll().length+1,this.originalTable.endIndex=parseInt(b[c],10)+1,this._bubbleCols())},_bubbleCols:function(){e.dragtable.startColumnMove(this.originalTable)},_rearrangeTableBackroundProcessing:function(){var b=this;return function(){b._bubbleCols(),b.options.beforeStop(b.originalTable),b.sortableTable.el.remove(),c(),e.dragtable.update(b),a.isFunction(b.options.persistState)?b.options.persistState(b.originalTable):b.persistState()}},_rearrangeTable:function(){var a=this;return function(){a.originalTable.selectedHandle.removeClass("dragtable-handle-selected"),a.sortableTable.el.sortable("disable"),a.sortableTable.el.addClass("dragtable-disabled"),a.options.beforeReorganize(a.originalTable,a.sortableTable),a.originalTable.endIndex=a.sortableTable.movingRow.prevAll().length+1,setTimeout(a._rearrangeTableBackroundProcessing(),50)}},_generateSortable:function(c){c.cancelBubble?c.cancelBubble=!0:c.stopPropagation();for(var d=this,e=this.originalTable.el[0].attributes,f="",g=0;g',s=[],t=m.eq(0).children("th, td").length;for(g=0;t>g;g++){var u=m.children(":nth-child("+(g+1)+")");u.is(":visible")&&(q=0,s[g]='
  • "+(p?'':"")+"",m.each(function(a){s[g]+=""+u[a].outerHTML+""}),s[g]+="",u=n.children(":nth-child("+(g+1)+")"),d.options.maxMovingRows>1&&(u=u.add(n.children(":nth-child("+(g+1)+")").slice(0,d.options.maxMovingRows-1))),u.each(function(a){s[g]+=""+this.outerHTML+""}),s[g]+="",d.options.excludeFooter||(s[g]+=""+l.filter("tfoot").children("tr:visible").children()[g].outerHTML+""),s[g]+="
  • ")}r+=s.join("")+"",this.sortableTable.el=this.originalTable.el.before(r).prev(),this.sortableTable.el.find("> li > table").each(function(b){a(this).css("width",j[b]+"px")}),this.sortableTable.selectedHandle=this.sortableTable.el.find("th .dragtable-handle-selected");var v=this.options.dragaccept?"li:has("+this.options.dragaccept+")":"li";this.sortableTable.el.sortable({items:v,stop:this._rearrangeTable(),revert:this.options.revert,tolerance:this.options.tolerance,containment:this.options.containment,cursor:this.options.cursor,cursorAt:this.options.cursorAt,distance:this.options.distance,axis:this.options.axis}),this.originalTable.startIndex=a(c.target).closest("th,td").prevAll().length+1,this.options.beforeMoving(this.originalTable,this.sortableTable),this.sortableTable.movingRow=this.sortableTable.el.children("li:nth-child("+this.originalTable.startIndex+")"),b(),this.sortableTable.movingRow.trigger(a.extend(a.Event(c.type),{which:1,clientX:c.clientX,clientY:c.clientY,pageX:c.pageX,pageY:c.pageY,screenX:c.screenX,screenY:c.screenY}));var w=this.sortableTable.el.find(".ui-sortable-placeholder");w.height()>0&&w.css("height",this.sortableTable.el.find(".ui-sortable-helper").height()),w.html('
    ')},bindTo:{},_create:function(){var b=this;b.originalTable={el:b.element,selectedHandle:a(),sortOrder:{},startIndex:0,endIndex:0},e.dragtable.create(b),b.bindTo="> thead > tr > "+(b.options.dragaccept||"th, td"),b.element.find(b.bindTo).find(b.options.dragHandle).length&&(b.bindTo+=" "+b.options.dragHandle),a.isFunction(b.options.restoreState)?b.options.restoreState(b.originalTable):b._restoreState(b.options.restoreState),b.originalTable.el.on("mousedown.dragtable",b.bindTo,function(c){1===c.which&&(e.dragtable.start(b.originalTable.el),b.options.beforeStart(b.originalTable)!==!1&&(clearTimeout(b.downTimer),b.downTimer=setTimeout(function(){b.originalTable.selectedHandle=a(b),b.originalTable.selectedHandle.addClass("dragtable-handle-selected"),b._generateSortable(c)},b.options.clickDelay)))}).on("mouseup.dragtable",b.options.dragHandle,function(){clearTimeout(b.downTimer)})},redraw:function(){this.destroy(),this._create()},destroy:function(){this.originalTable.el.off("mousedown.dragtable mouseup.dragtable",this.bindTo),a.Widget.prototype.destroy.apply(this,arguments)}});var f=a(document.body).attr("onselectstart"),g=a(document.body).attr("unselectable")}(jQuery);