datatables.net-rowreorder
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -1,2 +0,2 @@ | ||
/*! RowReorder 1.0.0 | ||
/*! RowReorder 1.1.0 | ||
* 2015 SpryMedia Ltd - datatables.net/license | ||
@@ -8,3 +8,3 @@ */ | ||
* @description Row reordering extension for DataTables | ||
* @version 1.0.0 | ||
* @version 1.1.0 | ||
* @file dataTables.rowReorder.js | ||
@@ -25,8 +25,32 @@ * @author SpryMedia Ltd (www.sprymedia.co.uk) | ||
(function(window, document, undefined) { | ||
(function( factory ){ | ||
if ( typeof define === 'function' && define.amd ) { | ||
// AMD | ||
define( ['jquery', 'datatables.net'], function ( $ ) { | ||
return factory( $, window, document ); | ||
} ); | ||
} | ||
else if ( typeof exports === 'object' ) { | ||
// CommonJS | ||
module.exports = function (root, $) { | ||
if ( ! root ) { | ||
root = window; | ||
} | ||
if ( ! $ || ! $.fn.dataTable ) { | ||
$ = require('datatables.net')(root, $).$; | ||
} | ||
var factory = function( $, DataTable ) { | ||
"use strict"; | ||
return factory( $, root, root.document ); | ||
}; | ||
} | ||
else { | ||
// Browser | ||
factory( jQuery, window, document ); | ||
} | ||
}(function( $, window, document, undefined ) { | ||
'use strict'; | ||
var DataTable = $.fn.dataTable; | ||
/** | ||
@@ -114,3 +138,3 @@ * RowReorder provides the ability in DataTables to click and drag rows to | ||
RowReorder.prototype = { | ||
$.extend( RowReorder.prototype, { | ||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | ||
@@ -139,4 +163,6 @@ * Constructor | ||
// appear to work on table rows at this time. Also mobile browsers are | ||
// not supported | ||
$( table ).on( 'mousedown.rowReorder touchstart.rowReorder', this.c.selector, function (e) { | ||
// not supported. | ||
// Use `table().container()` rather than just the table node for IE8 - | ||
// otherwise it only works once... | ||
$(dt.table().container()).on( 'mousedown.rowReorder touchstart.rowReorder', this.c.selector, function (e) { | ||
var tr = $(this).closest('tr'); | ||
@@ -151,4 +177,5 @@ | ||
dt.on( 'destroy', function () { | ||
table.off( 'mousedown.rowReorder' ); | ||
dt.on( 'destroy.rowReorder', function () { | ||
$(dt.table().container()).off( '.rowReorder' ); | ||
dt.off( '.rowReorder' ); | ||
} ); | ||
@@ -429,2 +456,3 @@ }, | ||
var i, ien; | ||
var dataSrc = this.c.dataSrc; | ||
@@ -440,2 +468,5 @@ this.dom.clone.remove(); | ||
clearInterval( this.s.scrollInterval ); | ||
this.s.scrollInterval = null; | ||
// Calculate the difference | ||
@@ -474,5 +505,6 @@ var startNodes = this.s.start.nodes; | ||
this._emitEvent( 'row-reorder', [ fullDiff, { | ||
dataSrc: this.c.dataSrc, | ||
nodes: diffNodes, | ||
values: idDiff | ||
dataSrc: dataSrc, | ||
nodes: diffNodes, | ||
values: idDiff, | ||
triggerRow: dt.row( this.dom.target ) | ||
} ] ); | ||
@@ -486,3 +518,3 @@ | ||
} ) | ||
.multiSet( this.c.dataSrc, idDiff ) | ||
.multiSet( dataSrc, idDiff ) | ||
.submit(); | ||
@@ -499,3 +531,8 @@ } | ||
row.invalidate( 'data' ); | ||
// 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' ); | ||
} | ||
} ); | ||
} | ||
@@ -506,3 +543,3 @@ | ||
} | ||
}; | ||
} ); | ||
@@ -566,3 +603,3 @@ | ||
*/ | ||
RowReorder.version = '1.0.0'; | ||
RowReorder.version = '1.1.0'; | ||
@@ -592,20 +629,4 @@ | ||
return RowReorder; | ||
}; // /factory | ||
// Define as an AMD module if possible | ||
if ( typeof define === 'function' && define.amd ) { | ||
define( ['jquery', 'datatables'], factory ); | ||
} | ||
else if ( typeof exports === 'object' ) { | ||
// Node/CommonJS | ||
factory( require('jquery'), require('datatables') ); | ||
} | ||
else if ( jQuery && !jQuery.fn.dataTable.RowReorder ) { | ||
// Otherwise simply initialise as normal, stopping multiple evaluation | ||
factory( jQuery, jQuery.fn.dataTable ); | ||
} | ||
})(window, document); | ||
})); |
{ | ||
"name": "datatables.net-rowreorder", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "RowReorder for DataTables ", | ||
@@ -5,0 +5,0 @@ "files": [ |
@@ -22,3 +22,3 @@ # RowReorder for DataTables | ||
var $ = require( 'jquery' ); | ||
require( 'datatables.net-rowreorder' )( $ ); | ||
require( 'datatables.net-rowreorder' )( window, $ ); | ||
``` | ||
@@ -25,0 +25,0 @@ |
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
18490
521