app/assets/javascripts/datatables/extensions/Select/dataTables.select.js in jquery-datatables-1.10.13 vs app/assets/javascripts/datatables/extensions/Select/dataTables.select.js in jquery-datatables-1.10.15
- old
+ new
@@ -1,14 +1,14 @@
-/*! Select for DataTables 1.2.1
+/*! Select for DataTables 1.2.2
* 2015-2016 SpryMedia Ltd - datatables.net/license/mit
*/
/**
* @summary Select for DataTables
* @description A collection of API methods, events and buttons for DataTables
* that provides selection options of the items in a DataTable
- * @version 1.2.1
+ * @version 1.2.2
* @file dataTables.select.js
* @author SpryMedia Ltd (www.sprymedia.co.uk)
* @contact datatables.net/forums
* @copyright Copyright 2015-2016 SpryMedia Ltd.
*
@@ -52,11 +52,11 @@
// Version information for debugger
DataTable.select = {};
-DataTable.select.version = '1.2.1';
+DataTable.select.version = '1.2.2';
DataTable.select.init = function ( dt ) {
var ctx = dt.settings()[0];
var init = ctx.oInit.select;
var defaults = DataTable.defaults.select;
@@ -308,11 +308,11 @@
$( dt.table().container() )
.off( 'mousedown.dtSelect', selector )
.off( 'mouseup.dtSelect', selector )
.off( 'click.dtSelect', selector );
- $('body').off( 'click.dtSelect' );
+ $('body').off( 'click.dtSelect' + dt.table().node().id );
}
/**
* Attach mouse listeners to the table to allow mouse selection of items
*
@@ -346,11 +346,11 @@
var items = dt.select.items();
var idx;
// If text was selected (click and drag), then we shouldn't change
// the row's selected state
- if ( window.getSelection && window.getSelection().toString() ) {
+ if ( window.getSelection && $.trim( window.getSelection().toString() ) ) {
return;
}
var ctx = dt.settings()[0];
@@ -390,17 +390,23 @@
ctx._select_lastCell = cellIndex;
} );
// Blurable
- $('body').on( 'click.dtSelect', function ( e ) {
+ $('body').on( 'click.dtSelect' + dt.table().node().id, function ( e ) {
if ( ctx._select.blurable ) {
// If the click was inside the DataTables container, don't blur
if ( $(e.target).parents().filter( dt.table().container() ).length ) {
return;
}
+ // Ignore elements which have been removed from the DOM (i.e. paging
+ // buttons)
+ if ( e.target.getRootNode() !== document ) {
+ return;
+ }
+
// Don't blur in Editor form
if ( $(e.target).parents('div.DTE').length ) {
return;
}
@@ -429,11 +435,11 @@
type = type +'.dt';
}
args.unshift( api );
- $(api.table().node()).triggerHandler( type, args );
+ $(api.table().node()).trigger( type, args );
}
/**
* Update the information element of the DataTable showing information about the
* items selected. This is done by adding tags to the existing text
@@ -447,25 +453,29 @@
if ( ! ctx._select.info || ! ctx.aanFeatures.i ) {
return;
}
- var output = $('<span class="select-info"/>');
- var add = function ( name, num ) {
- output.append( $('<span class="select-item"/>').append( api.i18n(
+ var rows = api.rows( { selected: true } ).flatten().length;
+ var columns = api.columns( { selected: true } ).flatten().length;
+ var cells = api.cells( { selected: true } ).flatten().length;
+
+ var add = function ( el, name, num ) {
+ el.append( $('<span class="select-item"/>').append( api.i18n(
'select.'+name+'s',
{ _: '%d '+name+'s selected', 0: '', 1: '1 '+name+' selected' },
num
) ) );
};
- add( 'row', api.rows( { selected: true } ).flatten().length );
- add( 'column', api.columns( { selected: true } ).flatten().length );
- add( 'cell', api.cells( { selected: true } ).flatten().length );
-
// Internal knowledge of DataTables to loop over all information elements
$.each( ctx.aanFeatures.i, function ( i, el ) {
el = $(el);
+
+ var output = $('<span class="select-info"/>');
+ add( output, 'row', rows );
+ add( output, 'column', columns );
+ add( output, 'cell', cells );
var exisiting = el.children('span.select-info');
if ( exisiting.length ) {
exisiting.remove();
}