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