META-INF.resources.bower_components.datatables.net-rowreorder.js.dataTables.rowReorder.min.js Maven / Gradle / Ivy
/*! RowReorder 1.2.5
* 2015-2018 SpryMedia Ltd - datatables.net/license
*/
(function(a){if(typeof define==="function"&&define.amd){define(["jquery","datatables.net"],function(b){return a(b,window,document)})}else{if(typeof exports==="object"){module.exports=function(b,c){if(!b){b=window}if(!c||!c.fn.dataTable){c=require("datatables.net")(b,c).$}return a(c,b,b.document)}}else{a(jQuery,window,document)}}}(function(f,d,a,g){var e=f.fn.dataTable;var c=function(k,j){if(!e.versionCheck||!e.versionCheck("1.10.8")){throw"DataTables RowReorder requires DataTables 1.10.8 or newer"}this.c=f.extend(true,{},e.defaults.rowReorder,c.defaults,j);this.s={bodyTop:null,dt:new e.Api(k),getDataFn:e.ext.oApi._fnGetObjectDataFn(this.c.dataSrc),middles:null,scroll:{},scrollInterval:null,setDataFn:e.ext.oApi._fnSetObjectDataFn(this.c.dataSrc),start:{top:0,left:0,offsetTop:0,offsetLeft:0,nodes:[]},windowHeight:0,documentOuterHeight:0,domCloneOuterHeight:0};this.dom={clone:null,dtScroll:f("div.dataTables_scrollBody",this.s.dt.table().container())};var i=this.s.dt.settings()[0];var h=i.rowreorder;if(h){return h}i.rowreorder=this;this._constructor()};f.extend(c.prototype,{_constructor:function(){var j=this;var i=this.s.dt;var h=f(i.table().node());if(h.css("position")==="static"){h.css("position","relative")}f(i.table().container()).on("mousedown.rowReorder touchstart.rowReorder",this.c.selector,function(l){if(!j.c.enable){return}if(f(l.target).is(j.c.excludedChildren)){return true}var k=f(this).closest("tr");var m=i.row(k);if(m.any()){j._emitEvent("pre-row-reorder",{node:m.node(),index:m.index()});j._mouseDown(l,k);return false}});i.on("destroy.rowReorder",function(){f(i.table().container()).off(".rowReorder");i.off(".rowReorder")})},_cachePositions:function(){var k=this.s.dt;var h=f(k.table().node()).find("thead").outerHeight();var i=f.unique(k.rows({page:"current"}).nodes().toArray());var l=f.map(i,function(n,m){return f(n).position().top-h});var j=f.map(l,function(n,m){return l.length").append(l.clone(false));var h=l.outerWidth();var i=l.outerHeight();var j=l.children().map(function(){return f(this).width()});m.width(h).height(i).find("tr").children().each(function(n){this.style.width=j[n]+"px"});m.appendTo("body");this.dom.clone=m;this.s.domCloneOuterHeight=m.outerHeight()},_clonePosition:function(l){var n=this.s.start;var i=this._eventToPage(l,"Y")-n.top;var m=this._eventToPage(l,"X")-n.left;var h=this.c.snapX;var k;var j=i+n.offsetTop;if(h===true){k=n.offsetLeft}else{if(typeof h==="number"){k=n.offsetLeft+h}else{k=m+n.offsetLeft}}if(j<0){j=0}else{if(j+this.s.domCloneOuterHeight>this.s.documentOuterHeight){j=this.s.documentOuterHeight-this.s.domCloneOuterHeight}}this.dom.clone.css({top:j,left:k})},_emitEvent:function(i,h){this.s.dt.iterator("table",function(j,k){f(j.nTable).triggerHandler(i+".dt",h)})},_eventToPage:function(h,i){if(h.type.indexOf("touch")!==-1){return h.originalEvent.touches[0]["page"+i]}return h["page"+i]},_mouseDown:function(l,k){var j=this;var i=this.s.dt;var n=this.s.start;var m=k.offset();n.top=this._eventToPage(l,"Y");n.left=this._eventToPage(l,"X");n.offsetTop=m.top;n.offsetLeft=m.left;n.nodes=f.unique(i.rows({page:"current"}).nodes().toArray());this._cachePositions();this._clone(k);this._clonePosition(l);this.dom.target=k;k.addClass("dt-rowReorder-moving");f(a).on("mouseup.rowReorder touchend.rowReorder",function(o){j._mouseUp(o)}).on("mousemove.rowReorder touchmove.rowReorder",function(o){j._mouseMove(o)});if(f(d).width()===f(a).width()){f(a.body).addClass("dt-rowReorder-noOverflow")}var h=this.dom.dtScroll;this.s.scroll={windowHeight:f(d).height(),windowWidth:f(d).width(),dtTop:h.length?h.offset().top:null,dtLeft:h.length?h.offset().left:null,dtHeight:h.length?h.outerHeight():null,dtWidth:h.length?h.outerWidth():null}},_mouseMove:function(o){this._clonePosition(o);var l=this._eventToPage(o,"Y")-this.s.bodyTop;var p=this.s.middles;var k=null;var j=this.s.dt;var n=j.table().body();for(var m=0,q=p.length;mthis.s.lastInsert){this.dom.target.insertAfter(h[k-1])}else{this.dom.target.insertBefore(h[k])}}this._cachePositions();this.s.lastInsert=k}this._shiftScroll(o)},_mouseUp:function(z){var n=this;var v=this.s.dt;var y,h;var s=this.c.dataSrc;this.dom.clone.remove();this.dom.clone=null;this.dom.target.removeClass("dt-rowReorder-moving");f(a).off(".rowReorder");f(a.body).removeClass("dt-rowReorder-noOverflow");clearInterval(this.s.scrollInterval);this.s.scrollInterval=null;var u=this.s.start.nodes;var r=f.unique(v.rows({page:"current"}).nodes().toArray());var l={};var t=[];var m=[];var q=this.s.getDataFn;var j=this.s.setDataFn;for(y=0,h=u.length;yp.windowHeight-j){i=n}}if(p.dtTop!==null&&m.pageYp.dtTop+p.dtHeight-j){k=n}}if(i||k){p.windowVert=i;p.dtVert=k;o=true}else{if(this.s.scrollInterval){clearInterval(this.s.scrollInterval);this.s.scrollInterval=null}}if(!this.s.scrollInterval&&o){this.s.scrollInterval=setInterval(function(){if(p.windowVert){a.body.scrollTop+=p.windowVert}if(p.dtVert){var r=l.dom.dtScroll[0];if(p.dtVert){r.scrollTop+=p.dtVert}}},20)}}});c.defaults={dataSrc:0,editor:null,enable:true,formOptions:{},selector:"td:first-child",snapX:false,update:true,excludedChildren:"a"};var b=f.fn.dataTable.Api;b.register("rowReorder()",function(){return this});b.register("rowReorder.enable()",function(h){if(h===g){h=true}return this.iterator("table",function(i){if(i.rowreorder){i.rowreorder.c.enable=h}})});b.register("rowReorder.disable()",function(){return this.iterator("table",function(h){if(h.rowreorder){h.rowreorder.c.enable=false}})});c.version="1.2.5";f.fn.dataTable.RowReorder=c;f.fn.DataTable.RowReorder=c;f(a).on("init.dt.dtr",function(l,i,h){if(l.namespace!=="dt"){return}var m=i.oInit.rowReorder;var k=e.defaults.rowReorder;if(m||k){var j=f.extend({},m,k);if(m!==false){new c(i,j)}}});return c}));
© 2015 - 2025 Weber Informatics LLC | Privacy Policy