datatables.net-keytable
Advanced tools
Comparing version 2.2.1 to 2.3.0
@@ -1,3 +0,3 @@ | ||
/*! KeyTable 2.2.1 | ||
* ©2009-2016 SpryMedia Ltd - datatables.net/license | ||
/*! KeyTable 2.3.0 | ||
* ©2009-2017 SpryMedia Ltd - datatables.net/license | ||
*/ | ||
@@ -8,7 +8,7 @@ | ||
* @description Spreadsheet like keyboard navigation for DataTables | ||
* @version 2.2.1 | ||
* @version 2.3.0 | ||
* @file dataTables.keyTable.js | ||
* @author SpryMedia Ltd (www.sprymedia.co.uk) | ||
* @contact www.sprymedia.co.uk/contact | ||
* @copyright Copyright 2009-2016 SpryMedia Ltd. | ||
* @copyright Copyright 2009-2017 SpryMedia Ltd. | ||
* | ||
@@ -230,2 +230,21 @@ * This source file is free software, available under the following license: | ||
if ( this.c.editor ) { | ||
// Need to disable KeyTable when the main editor is shown | ||
editor.on( 'open.keyTableMain', function (e, mode, action) { | ||
if ( mode !== 'inline' && that.s.enable ) { | ||
that.enable( false ); | ||
editor.one( 'close.keyTable', function () { | ||
that.enable( true ); | ||
} ); | ||
} | ||
} ); | ||
if ( this.c.editOnFocus ) { | ||
dt.on( 'key-focus.keyTable key-refocus.keyTable', function ( e, dt, cell, orig ) { | ||
that._editor( null, orig ); | ||
} ); | ||
} | ||
// Activate Editor when a key is pressed (will be ignored, if | ||
// already active). | ||
dt.on( 'key.keyTable', function ( e, dt, key, cell, orig ) { | ||
@@ -326,3 +345,43 @@ that._editor( key, orig ); | ||
/** | ||
* Copy text from the focused cell to clipboard | ||
* | ||
* @private | ||
*/ | ||
_clipboardCopy: function () | ||
{ | ||
var dt = this.s.dt; | ||
// If there is a cell focused, and there is no other text selected | ||
// allow the focused cell's text to be copied to clipboard | ||
if ( this.s.lastFocus && window.getSelection && !window.getSelection().toString() ) { | ||
var cell = this.s.lastFocus.cell; | ||
var text = cell.render('display'); | ||
var hiddenDiv = $('<div/>') | ||
.css( { | ||
height: 1, | ||
width: 1, | ||
overflow: 'hidden', | ||
position: 'fixed', | ||
top: 0, | ||
left: 0 | ||
} ); | ||
var textarea = $('<textarea readonly/>') | ||
.val( text ) | ||
.appendTo( hiddenDiv ); | ||
try { | ||
hiddenDiv.appendTo( dt.table().container() ); | ||
textarea[0].focus(); | ||
textarea[0].select(); | ||
document.execCommand( 'copy' ); | ||
} | ||
catch (e) {} | ||
hiddenDiv.remove(); | ||
} | ||
}, | ||
/** | ||
@@ -364,2 +423,7 @@ * Get an array of the column indexes that KeyTable can operate on. This | ||
// Do nothing if there is already an inline edit in this cell | ||
if ( $('div.DTE', this.s.lastFocus.cell.node()).length ) { | ||
return; | ||
} | ||
// Don't activate inline editing when the shift key is pressed | ||
@@ -372,3 +436,3 @@ if ( key === 16 ) { | ||
// Return key should do nothing - for textareas's it would empty the | ||
// Return key should do nothing - for textareas it would empty the | ||
// contents | ||
@@ -385,3 +449,5 @@ if ( key === 13 ) { | ||
// Excel style - select all text | ||
$('div.DTE input, div.DTE textarea').select(); | ||
if ( that.c.editAutoSelect ) { | ||
$('div.DTE_Field_InputControl input, div.DTE_Field_InputControl textarea').select(); | ||
} | ||
@@ -506,2 +572,3 @@ // Reduce the keys the Keys listens for | ||
if ( lastFocus.node === cell.node() ) { | ||
this._emitEvent( 'key-refocus', [ this.s.dt, cell, originalEvent || null ] ); | ||
return; | ||
@@ -567,2 +634,7 @@ } | ||
if ( e.ctrlKey && e.keyCode === 67 ) { // c | ||
this._clipboardCopy(); | ||
return; | ||
} | ||
if ( e.keyCode === 0 || e.ctrlKey || e.metaKey || e.altKey ) { | ||
@@ -885,2 +957,14 @@ return; | ||
/** | ||
* Set if Editor should automatically select the text in the input | ||
* @type {Boolean} | ||
*/ | ||
editAutoSelect: true, | ||
/** | ||
* Control if editing should be activated immediately upon focus | ||
* @type {Boolean} | ||
*/ | ||
editOnFocus: false, | ||
/** | ||
* Select a cell to automatically select on start up. `null` for no | ||
@@ -907,3 +991,3 @@ * automatic selection | ||
KeyTable.version = "2.2.1"; | ||
KeyTable.version = "2.3.0"; | ||
@@ -910,0 +994,0 @@ |
{ | ||
"name": "datatables.net-keytable", | ||
"version": "2.2.1", | ||
"version": "2.3.0", | ||
"description": "KeyTable for DataTables ", | ||
@@ -5,0 +5,0 @@ "files": [ |
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
27887
881