mirror of
https://github.com/Mottie/tablesorter.git
synced 2025-01-12 15:24:21 +00:00
Editable: all text callback parameters are now trimmed
This commit is contained in:
parent
3bf7700fec
commit
10215591c2
@ -94,7 +94,7 @@
|
|||||||
var $this = $(this),
|
var $this = $(this),
|
||||||
selAll = wo.editable_selectAll,
|
selAll = wo.editable_selectAll,
|
||||||
column = $this.closest('td').index(),
|
column = $this.closest('td').index(),
|
||||||
txt = $this.html();
|
txt = $.trim( $this.text() );
|
||||||
if (wo.editable_enterToAccept) {
|
if (wo.editable_enterToAccept) {
|
||||||
// prevent enter from adding into the content
|
// prevent enter from adding into the content
|
||||||
$this.on('keydown.tseditable', function(e){
|
$this.on('keydown.tseditable', function(e){
|
||||||
@ -124,6 +124,7 @@
|
|||||||
var t, validate,
|
var t, validate,
|
||||||
valid = false,
|
valid = false,
|
||||||
$this = $(e.target),
|
$this = $(e.target),
|
||||||
|
txt = $.trim( $this.text() ),
|
||||||
column = $this.closest('td').index();
|
column = $this.closest('td').index();
|
||||||
if ( e.which === 27 ) {
|
if ( e.which === 27 ) {
|
||||||
// user cancelled
|
// user cancelled
|
||||||
@ -133,15 +134,15 @@
|
|||||||
}
|
}
|
||||||
t = e.which === 13 && ( wo.editable_enterToAccept || e.altKey ) || wo.editable_autoAccept && e.type !== 'keydown';
|
t = e.which === 13 && ( wo.editable_enterToAccept || e.altKey ) || wo.editable_autoAccept && e.type !== 'keydown';
|
||||||
// change if new or user hits enter (if option set)
|
// change if new or user hits enter (if option set)
|
||||||
if ( t && $this.data('before') !== $this.html() ) {
|
if ( t && $this.data('before') !== txt ) {
|
||||||
|
|
||||||
validate = wo.editable_validate;
|
validate = wo.editable_validate;
|
||||||
valid = $this.html();
|
valid = txt;
|
||||||
|
|
||||||
if (typeof(validate) === "function") {
|
if (typeof(validate) === "function") {
|
||||||
valid = validate( $this.html(), $this.data('original'), column, $this );
|
valid = validate( txt, $this.data('original'), column, $this );
|
||||||
} else if (typeof (validate = $.tablesorter.getColumnData( table, validate, column )) === 'function') {
|
} else if (typeof (validate = $.tablesorter.getColumnData( table, validate, column )) === 'function') {
|
||||||
valid = validate( $this.html(), $this.data('original'), column, $this );
|
valid = validate( txt, $this.data('original'), column, $this );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( t && valid !== false ) {
|
if ( t && valid !== false ) {
|
||||||
@ -152,7 +153,7 @@
|
|||||||
.data('before', valid)
|
.data('before', valid)
|
||||||
.data('original', valid)
|
.data('original', valid)
|
||||||
.trigger('change');
|
.trigger('change');
|
||||||
c.$table.trigger('updateCell', [ $this.closest('td'), false, function(table){
|
c.$table.trigger('updateCell', [ $this.closest('td'), false, function(){
|
||||||
if (wo.editable_autoResort) {
|
if (wo.editable_autoResort) {
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
c.$table.trigger("sorton", [ c.sortList, function(){
|
c.$table.trigger("sorton", [ c.sortList, function(){
|
||||||
@ -169,7 +170,7 @@
|
|||||||
clearTimeout( $this.data('timer') );
|
clearTimeout( $this.data('timer') );
|
||||||
$this.data('timer', setTimeout(function(){
|
$this.data('timer', setTimeout(function(){
|
||||||
if ($.isFunction(wo.editable_blur)) {
|
if ($.isFunction(wo.editable_blur)) {
|
||||||
wo.editable_blur( $this.text(), column, $this );
|
wo.editable_blur( $.trim( $this.text() ), column, $this );
|
||||||
}
|
}
|
||||||
}, 100));
|
}, 100));
|
||||||
// restore original content on blur
|
// restore original content on blur
|
||||||
|
Loading…
Reference in New Issue
Block a user