Socket
Socket
Sign inDemoInstall

datatables.net-colreorder

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

datatables.net-colreorder - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

177

js/dataTables.colReorder.js

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

/*! ColReorder 1.2.0
* ©2010-2014 SpryMedia Ltd - datatables.net/license
/*! ColReorder 1.3.0
* ©2010-2015 SpryMedia Ltd - datatables.net/license
*/

@@ -8,3 +8,3 @@

* @description Provide the ability to reorder columns in a DataTable
* @version 1.2.0
* @version 1.3.0
* @file dataTables.colReorder.js

@@ -24,6 +24,32 @@ * @author SpryMedia Ltd (www.sprymedia.co.uk)

*/
(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;
}
(function(window, document, undefined) {
if ( ! $ || ! $.fn.dataTable ) {
$ = require('datatables.net')(root, $).$;
}
return factory( $, root, root.document );
};
}
else {
// Browser
factory( jQuery, window, document );
}
}(function( $, window, document, undefined ) {
'use strict';
var DataTable = $.fn.dataTable;
/**

@@ -94,6 +120,2 @@ * Switch the key value pairing of an index array to be value key (i.e. the old value is now the

var factory = function( $, DataTable ) {
"use strict";
/**

@@ -106,5 +128,7 @@ * Plug-in for DataTables which will reorder the internal column structure by taking the column

* @param int iTo and insert it into this point
* @param bool drop Indicate if the reorder is the final one (i.e. a drop)
* not a live reorder
* @returns void
*/
$.fn.dataTableExt.oApi.fnColReorder = function ( oSettings, iFrom, iTo )
$.fn.dataTableExt.oApi.fnColReorder = function ( oSettings, iFrom, iTo, drop )
{

@@ -325,2 +349,3 @@ var i, iLen, j, jLen, iCols=oSettings.aoColumns.length, nTrs, oCol;

mapping: aiInvertMapping,
drop: drop,

@@ -470,3 +495,3 @@ // Old style parameters for compatibility

ColReorder.prototype = {
$.extend( ColReorder.prototype, {
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

@@ -495,10 +520,4 @@ * Public methods

{
var a = [];
for ( var i=0, iLen=this.s.dt.aoColumns.length ; i<iLen ; i++ )
{
a.push( this.s.dt.aoColumns[i]._ColReorder_iOrigCol );
}
this._fnOrderColumns( this.fnOrder() );
this._fnOrderColumns( a );
return this;

@@ -554,14 +573,28 @@ },

*/
"fnOrder": function ( set )
"fnOrder": function ( set, original )
{
if ( set === undefined )
{
var a = [];
for ( var i=0, iLen=this.s.dt.aoColumns.length ; i<iLen ; i++ )
{
a.push( this.s.dt.aoColumns[i]._ColReorder_iOrigCol );
var a = [], i, ien, j, jen;
var columns = this.s.dt.aoColumns;
if ( set === undefined ){
for ( i=0, ien=columns.length ; i<ien ; i++ ) {
a.push( columns[i]._ColReorder_iOrigCol );
}
return a;
}
// The order given is based on the original indexes, rather than the
// existing ones, so we need to translate from the original to current
// before then doing the order
if ( original ) {
var order = this.fnOrder();
for ( i=0, ien=set.length ; i<ien ; i++ ) {
a.push( $.inArray( set[i], order ) );
}
set = a;
}
this._fnOrderColumns( fnInvertKeyValues( set ) );

@@ -573,2 +606,38 @@

/**
* Convert from the original column index, to the original
*
* @param {int|array} idx Index(es) to convert
* @param {string} dir Transpose direction - `fromOriginal` / `toCurrent`
* or `'toOriginal` / `fromCurrent`
* @return {int|array} Converted values
*/
fnTranspose: function ( idx, dir )
{
if ( ! dir ) {
dir = 'toCurrent';
}
var order = this.fnOrder();
var columns = this.s.dt.aoColumns;
if ( dir === 'toCurrent' ) {
// Given an original index, want the current
return ! $.isArray( idx ) ?
$.inArray( idx, order ) :
$.map( idx, function ( index ) {
return $.inArray( index, order );
} );
}
else {
// Given a current index, want the original
return ! $.isArray( idx ) ?
columns[idx]._ColReorder_iOrigCol :
$.map( idx, function ( index ) {
return columns[index]._ColReorder_iOrigCol;
} );
}
},
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

@@ -696,2 +765,4 @@ * Private methods (they are of course public in JS, but recommended as private)

{
var changed = false;
if ( a.length != this.s.dt.aoColumns.length )

@@ -713,6 +784,15 @@ {

/* Do the column reorder in the table */
this.s.dt.oInstance.fnColReorder( currIndex, i );
this.s.dt.oInstance.fnColReorder( currIndex, i, true );
changed = true;
}
}
this._fnSetColumnIndexes();
// Has anything actually changed? If not, then nothing else to do
if ( ! changed ) {
return;
}
/* When scrolling we need to recalculate the column sizes to allow for the shift */

@@ -726,4 +806,2 @@ if ( this.s.dt.oScroll.sX !== "" || this.s.dt.oScroll.sY !== "" )

this.s.dt.oInstance.oApi._fnSaveState( this.s.dt );
this._fnSetColumnIndexes();

@@ -920,3 +998,3 @@ if ( this.s.reorderCallback !== null )

if ( this.s.init.bRealtime && lastToIndex !== this.s.mouse.toIndex ) {
this.s.dt.oInstance.fnColReorder( this.s.mouse.fromIndex, this.s.mouse.toIndex );
this.s.dt.oInstance.fnColReorder( this.s.mouse.fromIndex, this.s.mouse.toIndex, false );
this.s.mouse.fromIndex = this.s.mouse.toIndex;

@@ -950,3 +1028,3 @@ this._fnRegions();

/* Actually do the reorder */
this.s.dt.oInstance.fnColReorder( this.s.mouse.fromIndex, this.s.mouse.toIndex );
this.s.dt.oInstance.fnColReorder( this.s.mouse.fromIndex, this.s.mouse.toIndex, true );
this._fnSetColumnIndexes();

@@ -990,6 +1068,8 @@

var iToPoint = 0;
var total = $(aoColumns[0].nTh).offset().left; // Offset of the first column
for ( var i=0, iLen=aoColumns.length ; i<iLen ; i++ )
{
/* For the column / header in question, we want it's position to remain the same if the
* position is just to it's immediate left or right, so we only incremement the counter for
* position is just to it's immediate left or right, so we only increment the counter for
* other columns

@@ -1004,4 +1084,6 @@ */

{
total += $(aoColumns[i].nTh).outerWidth();
this.s.aoTargets.push( {
"x": $(aoColumns[i].nTh).offset().left + $(aoColumns[i].nTh).outerWidth(),
"x": total,
"to": iToPoint

@@ -1091,3 +1173,3 @@ } );

}
};
} );

@@ -1170,3 +1252,3 @@

*/
ColReorder.version = "1.2.0";
ColReorder.version = "1.3.0";

@@ -1241,6 +1323,6 @@

$.fn.dataTable.Api.register( 'colReorder.order()', function ( set ) {
$.fn.dataTable.Api.register( 'colReorder.order()', function ( set, original ) {
if ( set ) {
return this.iterator( 'table', function ( ctx ) {
ctx._colReorder.fnOrder( set );
ctx._colReorder.fnOrder( set, original );
} );

@@ -1254,21 +1336,10 @@ }

$.fn.dataTable.Api.register( 'colReorder.transpose()', function ( idx, dir ) {
return this.context.length && this.context[0]._colReorder ?
this.context[0]._colReorder.fnTranspose( idx, dir ) :
idx;
} );
return ColReorder;
}; // /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.ColReorder ) {
// Otherwise simply initialise as normal, stopping multiple evaluation
factory( jQuery, jQuery.fn.dataTable );
}
})(window, document);
}));
{
"name": "datatables.net-colreorder",
"version": "1.2.0",
"version": "1.3.0",
"description": "ColReorder for DataTables ",

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

@@ -22,3 +22,3 @@ # ColReorder for DataTables

var $ = require( 'jquery' );
require( 'datatables.net-colreorder' )( $ );
require( 'datatables.net-colreorder' )( window, $ );
```

@@ -25,0 +25,0 @@

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