From fbea89c0fd2b06b6dd119adb95704a2969e0a614 Mon Sep 17 00:00:00 2001 From: gamekid Date: Wed, 27 Aug 2014 12:21:19 -0500 Subject: [PATCH 1/2] More intuitive arrow navigation. Using the arrow keys to navigate elements, when editing the element value, will only work if the cursor is in the first or last position of the input element. Example: When the entire input value is selected, hitting the right arrow will drop the cursor at the end of the input as you would expect it to. When the cursor is at the end of the input and you hit the right arrow, it will then move to the next element. --- mindmup-editabletable.js | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/mindmup-editabletable.js b/mindmup-editabletable.js index 36be540..bcf56c4 100644 --- a/mindmup-editabletable.js +++ b/mindmup-editabletable.js @@ -41,14 +41,16 @@ $.fn.editableTableWidget = function (options) { active.html(originalContent); } }, - movement = function (element, keycode) { - if (keycode === ARROW_RIGHT) { + movement = function (element, keycode, start, end) { + start = (typeof start === 'undefined') ? true : start; + end = (typeof end === 'undefined') ? true : end; + if (keycode === ARROW_RIGHT && end) { return element.next('td'); - } else if (keycode === ARROW_LEFT) { + } else if (keycode === ARROW_LEFT && start) { return element.prev('td'); - } else if (keycode === ARROW_UP) { + } else if (keycode === ARROW_UP && start) { return element.parent().prev().children().eq(element.index()); - } else if (keycode === ARROW_DOWN) { + } else if (keycode === ARROW_DOWN && end) { return element.parent().next().children().eq(element.index()); } return []; @@ -71,8 +73,13 @@ $.fn.editableTableWidget = function (options) { active.focus(); } else if (e.which === TAB) { active.focus(); - } else if (this.selectionEnd - this.selectionStart === this.value.length) { - var possibleMove = movement(active, e.which); + } else { + var possibleMove = movement( + active, + e.which, + this.selectionEnd===0, + this.selectionStart===this.value.length + ); if (possibleMove.length > 0) { possibleMove.focus(); e.preventDefault(); From e1b23a99761d52568bffcc5dacfe7b8b751c7ab8 Mon Sep 17 00:00:00 2001 From: gamekid Date: Wed, 10 Sep 2014 10:24:56 -0500 Subject: [PATCH 2/2] Accepts multiple editors and 'noedit' attribute Use different editors per column. $('table').editableTableWidget({ editor: [ $('