snipe-it/public/js/dist/bootstrap-table.js

2 lines
1.2 MiB
JavaScript
Raw Normal View History

!function(t){t.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:t.noop,beforeMoving:t.noop,beforeReorganize:t.noop,beforeStop:t.noop},originalTable:{el:null,selectedHandle:null,sortOrder:null,startIndex:0,endIndex:0},sortableTable:{el:t(),selectedHandle:t(),movingRow:t()},persistState:function(){var e=this;this.originalTable.el.find("th").each((function(t){""!==this.id&&(e.originalTable.sortOrder[this.id]=t)})),t.ajax({url:this.options.persistState,data:this.originalTable.sortOrder})},_restoreState:function(e){for(var r in e)this.originalTable.startIndex=t("#"+r).closest("th").prevAll().length+1,this.originalTable.endIndex=parseInt(e[r],10)+1,this._bubbleCols()},_bubbleCols:function(){var t,e,r,i,o=this.originalTable.startIndex,a=this.originalTable.endIndex,s=this.originalTable.el.children();if(this.options.excludeFooter&&(s=s.not("tfoot")),o<a)for(t=o;t<a;t++)for(r=s.find("> tr > td:nth-child("+t+")").add(s.find("> tr > th:nth-child("+t+")")),i=s.find("> tr > td:nth-child("+(t+1)+")").add(s.find("> tr > th:nth-child("+(t+1)+")")),e=0;e<r.length;e++)n(r[e],i[e]);else for(t=o;t>a;t--)for(r=s.find("> tr > td:nth-child("+t+")").add(s.find("> tr > th:nth-child("+t+")")),i=s.find("> tr > td:nth-child("+(t-1)+")").add(s.find("> tr > th:nth-child("+(t-1)+")")),e=0;e<r.length;e++)n(r[e],i[e])},_rearrangeTableBackroundProcessing:function(){var n=this;return function(){n._bubbleCols(),n.options.beforeStop(n.originalTable),n.sortableTable.el.remove(),function(){t("#__dragtable_disable_text_selection__").remove(),e?t(document.body).attr("onselectstart",e):t(document.body).removeAttr("onselectstart");r?t(document.body).attr("unselectable",r):t(document.body).removeAttr("unselectable")}(),null!==n.options.persistState&&(t.isFunction(n.options.persistState)?n.options.persistState(n.originalTable):n.persistState())}},_rearrangeTable:function(){var t=this;return function(){t.originalTable.selectedHandle.removeClass("dragtable-handle-selected"),t.sortableTable.el.sortable("disable"),t.sortableTable.el.addClass("dragtable-disabled"),t.options.beforeReorganize(t.originalTable,t.sortableTable),t.originalTable.endIndex=t.sortableTable.movingRow.prevAll().length+1,setTimeout(t._rearrangeTableBackroundProcessing(),50)}},_generateSortable:function(e){!e.cancelBubble&&(e.cancelBubble=!0);for(var r=this,n=this.originalTable.el[0].attributes,i="",o=0;o<n.length;o++)n[o].nodeValue&&"id"!=n[o].nodeName&&"width"!=n[o].nodeName&&(i+=n[o].nodeName+'="'+n[o].nodeValue+'" ');var a=[],s=[];this.originalTable.el.find("tr").slice(0,this.options.maxMovingRows).each((function(e,r){for(var n=this.attributes,i="",o=0;o<n.length;o++)n[o].nodeValue&&"id"!=n[o].nodeName&&(i+=" "+n[o].nodeName+'="'+n[o].nodeValue+'"');a.push(i),s.push(t(this).height())}));var c=[],l=0,u=r.originalTable.el.children();if(this.options.excludeFooter&&(u=u.not("tfoot")),u.find("> tr > th").each((function(e,r){var n=t(this).is(":visible")?t(this).outerWidth():0;c.push(n),l+=n})),r.options.exact){var f=l-r.originalTable.el.outerWidth();c[0]-=f}var h='<ul class="dragtable-sortable" style="position:absolute; width:'+(l+=2)+'px;">';u.find("> tr > th").each((function(e,n){var o=t(this).is(":visible")?t(this).outerWidth():0;h+='<li style="width:'+o+'px;">',h+="<table "+i+">";var c=u.find("> tr > th:nth-child("+(e+1)+")");r.options.maxMovingRows>1&&(c=c.add(u.find("> tr > td:nth-child("+(e+1)+")").slice(0,r.options.maxMovingRows-1))),c.each((function(e){var r=t(this).clone().wrap("<div></div>").parent().html();0===r.toLowerCase().indexOf("<th")&&(h+="<thead>"),h+="<tr "+a[e]+'" style="height:'+s[e]+'px;">',h+=r,0===r.toLowerCase().indexOf("<th")&&(h+="</thead>"),h+="</tr>"})),h+="</table>",h+="</li>"})),h+="</ul>",this.sortableTable.el=this.originalTable.el.before(h).prev(),this.sortableTable.el.find("> li > table").each((function(e,r){t(this).css