Socket
Socket
Sign inDemoInstall

datatables.net-rowreorder

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

datatables.net-rowreorder - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

156

js/dataTables.rowReorder.js

@@ -1,3 +0,3 @@

/*! RowReorder 1.1.0
* 2015 SpryMedia Ltd - datatables.net/license
/*! RowReorder 1.1.1
* 2015-2016 SpryMedia Ltd - datatables.net/license
*/

@@ -8,7 +8,7 @@

* @description Row reordering extension for DataTables
* @version 1.1.0
* @version 1.1.1
* @file dataTables.rowReorder.js
* @author SpryMedia Ltd (www.sprymedia.co.uk)
* @contact www.sprymedia.co.uk/contact
* @copyright Copyright 2015 SpryMedia Ltd.
* @copyright Copyright 2015-2016 SpryMedia Ltd.
*

@@ -103,2 +103,8 @@ * This source file is free software, available under the following license:

/** @type {Object} Cached dimension information for use in the mouse move event handler */
scroll: {},
/** @type {integer} Interval object used for smooth scrolling */
scrollInterval: null,
/** @type {function} Data set function */

@@ -123,3 +129,6 @@ setDataFn: DataTable.ext.oApi._fnSetObjectDataFn( this.c.dataSrc ),

/** @type {jQuery} Cloned row being moved around */
clone: null
clone: null,
/** @type {jQuery} DataTables scrolling container */
dtScroll: $('div.dataTables_scrollBody', this.s.dt.table().container())
};

@@ -363,2 +372,15 @@

}
// Cache scrolling information so mouse move doesn't need to read.
// This assumes that the window and DT scroller will not change size
// during an row drag, which I think is a fair assumption
var scrollWrapper = this.dom.dtScroll;
this.s.scroll = {
windowHeight: $(window).height(),
windowWidth: $(window).width(),
dtTop: scrollWrapper.length ? scrollWrapper.offset().top : null,
dtLeft: scrollWrapper.length ? scrollWrapper.offset().left : null,
dtHeight: scrollWrapper.length ? scrollWrapper.outerHeight() : null,
dtWidth: scrollWrapper.length ? scrollWrapper.outerWidth() : null
};
},

@@ -407,6 +429,6 @@

if ( insertPoint > this.s.lastInsert ) {
this.dom.target.before( nodes[ insertPoint-1 ] );
this.dom.target.insertAfter( nodes[ insertPoint-1 ] );
}
else {
this.dom.target.after( nodes[ insertPoint ] );
this.dom.target.insertBefore( nodes[ insertPoint ] );
}

@@ -420,24 +442,3 @@ }

// scroll window up and down when reaching the edges
var windowY = this._eventToPage( e, 'Y' ) - document.body.scrollTop;
var scrollInterval = this.s.scrollInterval;
if ( windowY < 65 ) {
if ( ! scrollInterval ) {
this.s.scrollInterval = setInterval( function () {
document.body.scrollTop -= 5;
}, 15 );
}
}
else if ( this.s.windowHeight - windowY < 65 ) {
if ( ! scrollInterval ) {
this.s.scrollInterval = setInterval( function () {
document.body.scrollTop += 5;
}, 15 );
}
}
else {
clearInterval( scrollInterval );
this.s.scrollInterval = null;
}
this._shiftScroll( e );
},

@@ -502,4 +503,4 @@

// Emit event
this._emitEvent( 'row-reorder', [ fullDiff, {
// Create event args
var eventArgs = [ fullDiff, {
dataSrc: dataSrc,

@@ -509,3 +510,6 @@ nodes: diffNodes,

triggerRow: dt.row( this.dom.target )
} ] );
} ];
// Emit event
this._emitEvent( 'row-reorder', eventArgs );

@@ -537,5 +541,91 @@ // Editor interface

}
// Trigger row reordered event
this._emitEvent( 'row-reordered', eventArgs );
dt.draw( false );
}
},
/**
* Move the window and DataTables scrolling during a drag to scroll new
* content into view.
*
* This matches the `_shiftScroll` method used in AutoFill, but only
* horizontal scrolling is considered here.
*
* @param {object} e Mouse move event object
* @private
*/
_shiftScroll: function ( e )
{
var that = this;
var dt = this.s.dt;
var scroll = this.s.scroll;
var runInterval = false;
var scrollSpeed = 5;
var buffer = 65;
var
windowY = e.pageY - document.body.scrollTop,
windowVert,
dtVert;
// Window calculations - based on the mouse position in the window,
// regardless of scrolling
if ( windowY < buffer ) {
windowVert = scrollSpeed * -1;
}
else if ( windowY > scroll.windowHeight - buffer ) {
windowVert = scrollSpeed;
}
// DataTables scrolling calculations - based on the table's position in
// the document and the mouse position on the page
if ( scroll.dtTop !== null && e.pageY < scroll.dtTop + buffer ) {
dtVert = scrollSpeed * -1;
}
else if ( scroll.dtTop !== null && e.pageY > scroll.dtTop + scroll.dtHeight - buffer ) {
dtVert = scrollSpeed;
}
// This is where it gets interesting. We want to continue scrolling
// without requiring a mouse move, so we need an interval to be
// triggered. The interval should continue until it is no longer needed,
// but it must also use the latest scroll commands (for example consider
// that the mouse might move from scrolling up to scrolling left, all
// with the same interval running. We use the `scroll` object to "pass"
// this information to the interval. Can't use local variables as they
// wouldn't be the ones that are used by an already existing interval!
if ( windowVert || dtVert ) {
scroll.windowVert = windowVert;
scroll.dtVert = dtVert;
runInterval = true;
}
else if ( this.s.scrollInterval ) {
// Don't need to scroll - remove any existing timer
clearInterval( this.s.scrollInterval );
this.s.scrollInterval = null;
}
// If we need to run the interval to scroll and there is no existing
// interval (if there is an existing one, it will continue to run)
if ( ! this.s.scrollInterval && runInterval ) {
this.s.scrollInterval = setInterval( function () {
// Don't need to worry about setting scroll <0 or beyond the
// scroll bound as the browser will just reject that.
if ( scroll.windowVert ) {
document.body.scrollTop += scroll.windowVert;
}
// DataTables scrolling
if ( scroll.dtVert ) {
var scroller = that.dom.dtScroll[0];
if ( scroll.dtVert ) {
scroller.scrollTop += scroll.dtVert;
}
}
}, 20 );
}
}

@@ -601,3 +691,3 @@ } );

*/
RowReorder.version = '1.1.0';
RowReorder.version = '1.1.1';

@@ -604,0 +694,0 @@

{
"name": "datatables.net-rowreorder",
"version": "1.1.0",
"version": "1.1.1",
"description": "RowReorder for DataTables ",

@@ -5,0 +5,0 @@ "files": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc