Skip to content

Commit

Permalink
bugfix: after cell editing reimplementation, cell selection was not m…
Browse files Browse the repository at this point in the history
…oved down when editing was finished with Enter key (in IE7, IE8)
  • Loading branch information
warpech committed Feb 26, 2013
1 parent a760588 commit e5af5d7
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 196 deletions.
9 changes: 1 addition & 8 deletions dist/jquery.handsontable.full.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Licensed under the MIT license.
* http://handsontable.com/
*
* Date: Tue Feb 26 2013 15:57:20 GMT+0100 (Central European Standard Time)
* Date: Tue Feb 26 2013 19:20:27 GMT+0100 (Central European Standard Time)
*/

.handsontable {
Expand Down Expand Up @@ -193,19 +193,12 @@ textarea.handsontableInput {
resize: none;
}

.handsontableInputHolder.htHidden textarea.handsontableInput {
border-color: #5292F7;
background: #5292F7;
color: #5292F7;
}

.handsontableInputHolder {
position: absolute;
top: 0;
left: 0;
width: 1px;
height: 1px;
overflow: hidden;
}

/*
Expand Down
70 changes: 25 additions & 45 deletions dist/jquery.handsontable.full.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Licensed under the MIT license.
* http://handsontable.com/
*
* Date: Tue Feb 26 2013 15:57:20 GMT+0100 (Central European Standard Time)
* Date: Tue Feb 26 2013 19:20:27 GMT+0100 (Central European Standard Time)
*/
/*jslint white: true, browser: true, plusplus: true, indent: 4, maxerr: 50 */

Expand Down Expand Up @@ -2602,24 +2602,32 @@ function HandsontableTextEditorClass(instance) {
this.col;
this.prop;

this.createElements();

/*instance.that.TEXTAREA.on('blur.editor', function () {
if (that.isCellEdited) {
that.finishEditing(false);
}
});*/

this.bindEvents();
}

HandsontableTextEditorClass.prototype.createElements = function () {
this.TEXTAREA = $('<textarea class="handsontableInput">');
this.TEXTAREA.css({
width: 0,
height: 0
});

this.TEXTAREA_PARENT = $('<div class="handsontableInputHolder">').append(this.TEXTAREA);
this.TEXTAREA_PARENT.addClass('htHidden').css({
this.TEXTAREA_PARENT.css({
top: 0,
left: 0,
overflow: 'hidden'
display: 'none'
});

/*instance.that.TEXTAREA.on('blur.editor', function () {
if (that.isCellEdited) {
that.finishEditing(false);
}
});*/
this.instance.rootElement.append(this.TEXTAREA_PARENT);

var that = this;
Handsontable.PluginHooks.push('afterRender', function () {
Expand Down Expand Up @@ -2775,8 +2783,6 @@ HandsontableTextEditorClass.prototype.beginEditing = function (row, col, prop, u
this.TEXTAREA[0].value = '';
}

this.instance.rootElement.append(this.TEXTAREA_PARENT);

this.refreshDimensions(); //need it instantly, to prevent https://github.com/warpech/jquery-handsontable/issues/348
this.TEXTAREA[0].focus();
this.setCaretPosition(this.TEXTAREA[0], this.TEXTAREA[0].value.length);
Expand Down Expand Up @@ -2852,17 +2858,7 @@ HandsontableTextEditorClass.prototype.refreshDimensions = function () {
extraSpace: 0
});

this.TEXTAREA_PARENT.removeClass('htHidden');

this.instance.rootElement.triggerHandler('beginediting.handsontable');

var that = this;
setTimeout(function () {
//async fix for Firefox 3.6.28 (needs manual testing)
that.TEXTAREA_PARENT.css({
overflow: 'visible'
});
}, 1);
this.TEXTAREA_PARENT[0].style.display = 'block';
}

HandsontableTextEditorClass.prototype.finishEditing = function (isCancelled, ctrlDown) {
Expand Down Expand Up @@ -2892,9 +2888,7 @@ HandsontableTextEditorClass.prototype.finishEditing = function (isCancelled, ctr
this.instance.$table[0].focus();
this.instance.view.wt.update('onCellDblClick', null);

this.TEXTAREA_PARENT.remove();

this.instance.rootElement.triggerHandler('finishediting.handsontable');
this.TEXTAREA_PARENT[0].style.display = 'none';
}

/**
Expand All @@ -2912,8 +2906,6 @@ Handsontable.TextEditor = function (instance, td, row, col, prop, value, cellPro
instance.textEditor = new HandsontableTextEditorClass(instance);
}

instance.textEditor.bindEvents();

instance.textEditor.isCellEdited = false;
instance.textEditor.originalValue = value;

Expand Down Expand Up @@ -2963,18 +2955,13 @@ function HandsontableAutocompleteEditorClass(instance) {
this.col;
this.prop;

this.TEXTAREA = $('<textarea class="handsontableInput">');
this.TEXTAREA.css({
width: 0,
height: 0
});
this.createElements();

this.TEXTAREA_PARENT = $('<div class="handsontableInputHolder">').append(this.TEXTAREA);
this.TEXTAREA_PARENT.addClass('htHidden').css({
top: 0,
left: 0,
overflow: 'hidden'
});
/*instance.that.TEXTAREA.on('blur.editor', function () {
if (that.isCellEdited) {
that.finishEditing(false);
}
});*/

var that = this;

Expand All @@ -2998,12 +2985,7 @@ function HandsontableAutocompleteEditorClass(instance) {
return true;
};

var that = this;
Handsontable.PluginHooks.push('afterRender', function () {
setTimeout(function () {
that.refreshDimensions();
}, 0);
});
this.bindEvents();
}

for (var i in HandsontableTextEditorClass.prototype) {
Expand Down Expand Up @@ -3086,8 +3068,6 @@ Handsontable.AutocompleteEditor = function (instance, td, row, col, prop, value,
instance.autocompleteEditor = new HandsontableAutocompleteEditorClass(instance);
}

instance.autocompleteEditor.bindEvents();

instance.autocompleteEditor.isCellEdited = false;
instance.autocompleteEditor.originalValue = value;

Expand Down
9 changes: 1 addition & 8 deletions jquery.handsontable.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Licensed under the MIT license.
* http://handsontable.com/
*
* Date: Tue Feb 26 2013 15:57:20 GMT+0100 (Central European Standard Time)
* Date: Tue Feb 26 2013 19:20:27 GMT+0100 (Central European Standard Time)
*/

.handsontable {
Expand Down Expand Up @@ -193,19 +193,12 @@ textarea.handsontableInput {
resize: none;
}

.handsontableInputHolder.htHidden textarea.handsontableInput {
border-color: #5292F7;
background: #5292F7;
color: #5292F7;
}

.handsontableInputHolder {
position: absolute;
top: 0;
left: 0;
width: 1px;
height: 1px;
overflow: hidden;
}

/*
Expand Down
70 changes: 25 additions & 45 deletions jquery.handsontable.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Licensed under the MIT license.
* http://handsontable.com/
*
* Date: Tue Feb 26 2013 15:57:20 GMT+0100 (Central European Standard Time)
* Date: Tue Feb 26 2013 19:20:27 GMT+0100 (Central European Standard Time)
*/
/*jslint white: true, browser: true, plusplus: true, indent: 4, maxerr: 50 */

Expand Down Expand Up @@ -2602,24 +2602,32 @@ function HandsontableTextEditorClass(instance) {
this.col;
this.prop;

this.createElements();

/*instance.that.TEXTAREA.on('blur.editor', function () {
if (that.isCellEdited) {
that.finishEditing(false);
}
});*/

this.bindEvents();
}

HandsontableTextEditorClass.prototype.createElements = function () {
this.TEXTAREA = $('<textarea class="handsontableInput">');
this.TEXTAREA.css({
width: 0,
height: 0
});

this.TEXTAREA_PARENT = $('<div class="handsontableInputHolder">').append(this.TEXTAREA);
this.TEXTAREA_PARENT.addClass('htHidden').css({
this.TEXTAREA_PARENT.css({
top: 0,
left: 0,
overflow: 'hidden'
display: 'none'
});

/*instance.that.TEXTAREA.on('blur.editor', function () {
if (that.isCellEdited) {
that.finishEditing(false);
}
});*/
this.instance.rootElement.append(this.TEXTAREA_PARENT);

var that = this;
Handsontable.PluginHooks.push('afterRender', function () {
Expand Down Expand Up @@ -2775,8 +2783,6 @@ HandsontableTextEditorClass.prototype.beginEditing = function (row, col, prop, u
this.TEXTAREA[0].value = '';
}

this.instance.rootElement.append(this.TEXTAREA_PARENT);

this.refreshDimensions(); //need it instantly, to prevent https://github.com/warpech/jquery-handsontable/issues/348
this.TEXTAREA[0].focus();
this.setCaretPosition(this.TEXTAREA[0], this.TEXTAREA[0].value.length);
Expand Down Expand Up @@ -2852,17 +2858,7 @@ HandsontableTextEditorClass.prototype.refreshDimensions = function () {
extraSpace: 0
});

this.TEXTAREA_PARENT.removeClass('htHidden');

this.instance.rootElement.triggerHandler('beginediting.handsontable');

var that = this;
setTimeout(function () {
//async fix for Firefox 3.6.28 (needs manual testing)
that.TEXTAREA_PARENT.css({
overflow: 'visible'
});
}, 1);
this.TEXTAREA_PARENT[0].style.display = 'block';
}

HandsontableTextEditorClass.prototype.finishEditing = function (isCancelled, ctrlDown) {
Expand Down Expand Up @@ -2892,9 +2888,7 @@ HandsontableTextEditorClass.prototype.finishEditing = function (isCancelled, ctr
this.instance.$table[0].focus();
this.instance.view.wt.update('onCellDblClick', null);

this.TEXTAREA_PARENT.remove();

this.instance.rootElement.triggerHandler('finishediting.handsontable');
this.TEXTAREA_PARENT[0].style.display = 'none';
}

/**
Expand All @@ -2912,8 +2906,6 @@ Handsontable.TextEditor = function (instance, td, row, col, prop, value, cellPro
instance.textEditor = new HandsontableTextEditorClass(instance);
}

instance.textEditor.bindEvents();

instance.textEditor.isCellEdited = false;
instance.textEditor.originalValue = value;

Expand Down Expand Up @@ -2963,18 +2955,13 @@ function HandsontableAutocompleteEditorClass(instance) {
this.col;
this.prop;

this.TEXTAREA = $('<textarea class="handsontableInput">');
this.TEXTAREA.css({
width: 0,
height: 0
});
this.createElements();

this.TEXTAREA_PARENT = $('<div class="handsontableInputHolder">').append(this.TEXTAREA);
this.TEXTAREA_PARENT.addClass('htHidden').css({
top: 0,
left: 0,
overflow: 'hidden'
});
/*instance.that.TEXTAREA.on('blur.editor', function () {
if (that.isCellEdited) {
that.finishEditing(false);
}
});*/

var that = this;

Expand All @@ -2998,12 +2985,7 @@ function HandsontableAutocompleteEditorClass(instance) {
return true;
};

var that = this;
Handsontable.PluginHooks.push('afterRender', function () {
setTimeout(function () {
that.refreshDimensions();
}, 0);
});
this.bindEvents();
}

for (var i in HandsontableTextEditorClass.prototype) {
Expand Down Expand Up @@ -3086,8 +3068,6 @@ Handsontable.AutocompleteEditor = function (instance, td, row, col, prop, value,
instance.autocompleteEditor = new HandsontableAutocompleteEditorClass(instance);
}

instance.autocompleteEditor.bindEvents();

instance.autocompleteEditor.isCellEdited = false;
instance.autocompleteEditor.originalValue = value;

Expand Down
7 changes: 0 additions & 7 deletions src/css/jquery.handsontable.css
Original file line number Diff line number Diff line change
Expand Up @@ -193,19 +193,12 @@ textarea.handsontableInput {
resize: none;
}

.handsontableInputHolder.htHidden textarea.handsontableInput {
border-color: #5292F7;
background: #5292F7;
color: #5292F7;
}

.handsontableInputHolder {
position: absolute;
top: 0;
left: 0;
width: 1px;
height: 1px;
overflow: hidden;
}

/*
Expand Down
Loading

0 comments on commit e5af5d7

Please sign in to comment.