datatables.net-select
Advanced tools
Comparing version 1.0.1 to 1.1.0
@@ -1,2 +0,2 @@ | ||
/*! Select for DataTables 1.0.1 | ||
/*! Select for DataTables 1.1.0 | ||
* 2015 SpryMedia Ltd - datatables.net/license/mit | ||
@@ -9,3 +9,3 @@ */ | ||
* that provides selection options of the items in a DataTable | ||
* @version 1.0.1 | ||
* @version 1.1.0 | ||
* @file dataTables.select.js | ||
@@ -25,11 +25,35 @@ * @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; | ||
// Version information for debugger | ||
DataTable.select = {}; | ||
DataTable.select.version = '1.0.1'; | ||
DataTable.select.version = '1.1.0'; | ||
@@ -242,3 +266,2 @@ /* | ||
var items = dt.select.items(); | ||
var cellIndex = dt.cell( this ).index(); | ||
var idx; | ||
@@ -253,5 +276,8 @@ | ||
var cell = $(e.target).closest('td, th'); | ||
var cellIndex = dt.cell( cell ).index(); | ||
// Check the cell actually belongs to the host DataTable (so child rows, | ||
// etc, are ignored) | ||
if ( ! dt.cell( e.target ).any() ) { | ||
if ( ! dt.cell( cell ).any() ) { | ||
return; | ||
@@ -265,7 +291,7 @@ } | ||
else if ( items === 'column' ) { | ||
idx = dt.cell( e.target ).index().column; | ||
idx = dt.cell( cell ).index().column; | ||
typeSelect( e, dt, ctx, 'column', idx ); | ||
} | ||
else if ( items === 'cell' ) { | ||
idx = dt.cell( e.target ).index(); | ||
idx = dt.cell( cell ).index(); | ||
typeSelect( e, dt, ctx, 'cell', idx ); | ||
@@ -386,3 +412,3 @@ } | ||
if ( d._select_selected ) { | ||
$( row ).addClass( 'selected' ); | ||
$( row ).addClass( ctx._select.className ); | ||
} | ||
@@ -394,3 +420,3 @@ | ||
if ( ctx.aoColumns[i]._select_selected || (d._selected_cells && d._selected_cells[i]) ) { | ||
$(d.anCells[i]).addClass( 'selected' ); | ||
$(d.anCells[i]).addClass( ctx._select.className ); | ||
} | ||
@@ -720,3 +746,3 @@ } | ||
ctx.aoData[ idx ]._select_selected = true; | ||
$( ctx.aoData[ idx ].nTr ).addClass( 'selected' ); | ||
$( ctx.aoData[ idx ].nTr ).addClass( ctx._select.className ); | ||
} ); | ||
@@ -745,6 +771,6 @@ | ||
$( column.header() ).addClass( 'selected' ); | ||
$( column.footer() ).addClass( 'selected' ); | ||
$( column.header() ).addClass( ctx._select.className ); | ||
$( column.footer() ).addClass( ctx._select.className ); | ||
column.nodes().to$().addClass( 'selected' ); | ||
column.nodes().to$().addClass( ctx._select.className ); | ||
} ); | ||
@@ -778,3 +804,3 @@ | ||
if ( data.anCells ) { | ||
$( data.anCells[ colIdx ] ).addClass( 'selected' ); | ||
$( data.anCells[ colIdx ] ).addClass( ctx._select.className ); | ||
} | ||
@@ -796,3 +822,3 @@ } ); | ||
ctx.aoData[ idx ]._select_selected = false; | ||
$( ctx.aoData[ idx ].nTr ).removeClass( 'selected' ); | ||
$( ctx.aoData[ idx ].nTr ).removeClass( ctx._select.className ); | ||
} ); | ||
@@ -816,4 +842,4 @@ | ||
$( column.header() ).removeClass( 'selected' ); | ||
$( column.footer() ).removeClass( 'selected' ); | ||
$( column.header() ).removeClass( ctx._select.className ); | ||
$( column.footer() ).removeClass( ctx._select.className ); | ||
@@ -828,3 +854,3 @@ // Need to loop over each cell, rather than just using | ||
if ( data.anCells && (! cellSelected || ! cellSelected[ cellIdx.column ]) ) { | ||
$( data.anCells[ cellIdx.column ] ).removeClass( 'selected' ); | ||
$( data.anCells[ cellIdx.column ] ).removeClass( ctx._select.className ); | ||
} | ||
@@ -853,3 +879,3 @@ } ); | ||
if ( data.anCells && ! ctx.aoColumns[ colIdx ]._select_selected ) { | ||
$( data.anCells[ colIdx ] ).removeClass( 'selected' ); | ||
$( data.anCells[ colIdx ] ).removeClass( ctx._select.className ); | ||
} | ||
@@ -959,3 +985,3 @@ } ); | ||
// using the API | ||
$(document).on( 'init.dt.dtSelect', function (e, ctx, json) { | ||
$(document).on( 'preInit.dt.dtSelect', function (e, ctx, json) { | ||
if ( e.namespace !== 'dt' ) { | ||
@@ -974,2 +1000,3 @@ return; | ||
var selector = 'td, th'; | ||
var className = 'selected'; | ||
@@ -1005,2 +1032,6 @@ ctx._select = {}; | ||
} | ||
if ( opts.className !== undefined ) { | ||
className = opts.className; | ||
} | ||
} | ||
@@ -1013,2 +1044,3 @@ | ||
dt.select.info( info ); | ||
ctx._select.className = className; | ||
@@ -1023,20 +1055,3 @@ // If the init options haven't enabled select, but there is a selectable | ||
}; // /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.select ) { | ||
// Otherwise simply initialise as normal, stopping multiple evaluation | ||
factory( jQuery, jQuery.fn.dataTable ); | ||
} | ||
})(window, document); | ||
return DataTable.select; | ||
})); |
{ | ||
"name": "datatables.net-select", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "Select for DataTables ", | ||
@@ -5,0 +5,0 @@ "files": [ |
@@ -22,3 +22,3 @@ # Select for DataTables | ||
var $ = require( 'jquery' ); | ||
require( 'datatables.net-select' )( $ ); | ||
require( 'datatables.net-select' )( 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
31104
852