datatables.net-rowreorder
Advanced tools
Comparing version 1.2.0 to 1.2.1
@@ -1,2 +0,2 @@ | ||
/*! RowReorder 1.2.0 | ||
/*! RowReorder 1.2.1 | ||
* 2015-2016 SpryMedia Ltd - datatables.net/license | ||
@@ -8,3 +8,3 @@ */ | ||
* @description Row reordering extension for DataTables | ||
* @version 1.2.0 | ||
* @version 1.2.1 | ||
* @file dataTables.rowReorder.js | ||
@@ -122,3 +122,9 @@ * @author SpryMedia Ltd (www.sprymedia.co.uk) | ||
/** @type {integer} Window height cached value */ | ||
windowHeight: 0 | ||
windowHeight: 0, | ||
/** @type {integer} Document outer height cached value */ | ||
documentOuterHeight: 0, | ||
/** @type {integer} DOM clone outer height cached value */ | ||
domCloneOuterHeight: 0, | ||
}; | ||
@@ -175,3 +181,3 @@ | ||
$(dt.table().container()).on( 'mousedown.rowReorder touchstart.rowReorder', this.c.selector, function (e) { | ||
if ( ! that.c.enabled ) { | ||
if ( ! that.c.enable ) { | ||
return; | ||
@@ -181,5 +187,11 @@ } | ||
var tr = $(this).closest('tr'); | ||
var row = dt.row( tr ); | ||
// Double check that it is a DataTable row | ||
if ( dt.row( tr ).any() ) { | ||
if ( row.any() ) { | ||
that._emitEvent( 'pre-row-reorder', { | ||
node: row.node(), | ||
index: row.index() | ||
} ); | ||
that._mouseDown( e, tr ); | ||
@@ -233,2 +245,3 @@ return false; | ||
this.s.windowHeight = $(window).height(); | ||
this.s.documentOuterHeight = $(document).outerHeight(); | ||
}, | ||
@@ -270,2 +283,3 @@ | ||
this.dom.clone = clone; | ||
this.s.domCloneOuterHeight = clone.outerHeight(); | ||
}, | ||
@@ -287,2 +301,3 @@ | ||
var left; | ||
var top = topDiff + start.offsetTop; | ||
@@ -299,4 +314,11 @@ if ( snap === true ) { | ||
if(top < 0) { | ||
top = 0 | ||
} | ||
else if(top + this.s.domCloneOuterHeight > this.s.documentOuterHeight) { | ||
top = this.s.documentOuterHeight - this.s.domCloneOuterHeight; | ||
} | ||
this.dom.clone.css( { | ||
top: topDiff + start.offsetTop, | ||
top: top, | ||
left: left | ||
@@ -521,6 +543,29 @@ } ); | ||
var update = function () { | ||
if ( that.c.update ) { | ||
for ( i=0, ien=fullDiff.length ; i<ien ; i++ ) { | ||
var row = dt.row( fullDiff[i].node ); | ||
var rowData = row.data(); | ||
setDataFn( rowData, fullDiff[i].newData ); | ||
// Invalidate the cell that has the same data source as the dataSrc | ||
dt.columns().every( function () { | ||
if ( this.dataSrc() === dataSrc ) { | ||
dt.cell( fullDiff[i].node, this.index() ).invalidate( 'data' ); | ||
} | ||
} ); | ||
} | ||
// Trigger row reordered event | ||
that._emitEvent( 'row-reordered', eventArgs ); | ||
dt.draw( false ); | ||
} | ||
}; | ||
// Editor interface | ||
if ( this.c.editor ) { | ||
// Disable user interaction while Editor is submitting | ||
this.c.enabled = false; | ||
this.c.enable = false; | ||
@@ -534,28 +579,16 @@ this.c.editor | ||
.multiSet( dataSrc, idDiff ) | ||
.one( 'submitUnsuccessful.rowReorder', function () { | ||
dt.draw( false ); | ||
} ) | ||
.one( 'submitSuccess.rowReorder', function () { | ||
update(); | ||
} ) | ||
.one( 'submitComplete', function () { | ||
that.c.enabled = true; | ||
that.c.enable = true; | ||
that.c.editor.off( '.rowReorder' ); | ||
} ) | ||
.submit(); | ||
} | ||
// Do update if required | ||
if ( this.c.update ) { | ||
for ( i=0, ien=fullDiff.length ; i<ien ; i++ ) { | ||
var row = dt.row( fullDiff[i].node ); | ||
var rowData = row.data(); | ||
setDataFn( rowData, fullDiff[i].newData ); | ||
// Invalidate the cell that has the same data source as the dataSrc | ||
dt.columns().every( function () { | ||
if ( this.dataSrc() === dataSrc ) { | ||
dt.cell( fullDiff[i].node, this.index() ).invalidate( 'data' ); | ||
} | ||
} ); | ||
} | ||
// Trigger row reordered event | ||
this._emitEvent( 'row-reordered', eventArgs ); | ||
dt.draw( false ); | ||
else { | ||
update(); | ||
} | ||
@@ -677,3 +710,3 @@ }, | ||
*/ | ||
enabled: true, | ||
enable: true, | ||
@@ -731,3 +764,3 @@ /** | ||
if ( ctx.rowreorder ) { | ||
ctx.rowreorder.c.enabled = toggle; | ||
ctx.rowreorder.c.enable = toggle; | ||
} | ||
@@ -740,3 +773,3 @@ } ); | ||
if ( ctx.rowreorder ) { | ||
ctx.rowreorder.c.enabled = false; | ||
ctx.rowreorder.c.enable = false; | ||
} | ||
@@ -753,3 +786,3 @@ } ); | ||
*/ | ||
RowReorder.version = '1.2.0'; | ||
RowReorder.version = '1.2.1'; | ||
@@ -756,0 +789,0 @@ |
{ | ||
"name": "datatables.net-rowreorder", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "RowReorder for DataTables ", | ||
@@ -25,3 +25,3 @@ "files": [ | ||
"jquery": ">=1.7", | ||
"datatables.net": ">=1.10.9" | ||
"datatables.net": "^1.10.15" | ||
}, | ||
@@ -28,0 +28,0 @@ "repository": { |
# RowReorder for DataTables | ||
This package contains distribution files for the [RowReorder extension](https://datatables.net/extensions/rowreorder) for [DataTables](https://datatables.net/). Only the core software for this library is contained in this package - to be correctly styled, a styling package for RowReorder must also be included. Styling options include DataTable's native styling, [Bootstrap](http://getboostrap.com) and [Foundation](http://foundation.zurb.com/). | ||
This package contains distribution files for the [RowReorder extension](https://datatables.net/extensions/rowreorder) for [DataTables](https://datatables.net/). Only the core software for this library is contained in this package - to be correctly styled, a styling package for RowReorder must also be included. Styling options include DataTable's native styling, [Bootstrap](http://getbootstrap.com) and [Foundation](http://foundation.zurb.com/). | ||
@@ -5,0 +5,0 @@ RowReorder adds end user reordering of rows in a DataTable through click-and-drag mouse and touch operations. RowReorder provides full support for Editor allowing end users to update sequential information in a fast and easy manner. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23873
675
+ Addeddatatables.net@1.13.11(transitive)
- Removeddatatables.net@2.1.7(transitive)
Updateddatatables.net@^1.10.15