Editable: allow Shift+Enter to create a new line

This commit is contained in:
Mottie 2015-06-26 10:39:40 -05:00
parent 14bb009de6
commit 482586bd8a
3 changed files with 4 additions and 3 deletions

File diff suppressed because one or more lines are too long

View File

@ -113,6 +113,7 @@ td.no-edit, span.no-edit {
<ul>
<li>This widget can not be applied to the original plugin and requires jQuery 1.7+ and a browser that supports <a href="http://caniuse.com/#feat=contenteditable"><code>contenteditable</code> attributes</a> (almost all modern browsers).</li>
<li><span class="label warning">Important</span>: In Internet Explorer, please wrap the cell content with a DIV or SPAN as <a href="http://msdn.microsoft.com/en-us/library/ie/ms533690(v=vs.85).aspx">it is not possible to make table cells directly contenteditable</a>. Wrapping the content in the markup is much more efficient than using javascript to do it for you (especially in IE).<br><br></li>
<li>In <span class="version">v2.22.2</span>, <kbd>Shift</kbd>+<kbd>Enter</kbd> can now be used to start a new line even if <code>editable_enterToAccept</code> is <code>true</code>.</li>
<li>In <span class="version">v2.22.0</span>,
<ul>
<li>The cell content now only <em>automatically updates</em> when the user hovers over the table header. Prior to this version, the automatic update would occur when the mouse left the tbody of the table. The reason this is necessary is because initiating a sort would change the row indexing set prior to the cell content being updated, so the cache would end up not matching the table content.</li>

View File

@ -150,7 +150,7 @@ var tse = $.tablesorter.editable = {
$this
.off( 'keydown' + namespace )
.on( 'keydown' + namespace, function( e ){
if ( wo.editable_enterToAccept && e.which === 13 ) {
if ( wo.editable_enterToAccept && e.which === 13 && !e.shiftKey ) {
e.preventDefault();
}
});
@ -187,7 +187,7 @@ var tse = $.tablesorter.editable = {
return false;
}
// accept on enter ( if set ), alt-enter ( always ) or if autoAccept is set and element is blurred or unfocused
t = e.which === 13 && ( wo.editable_enterToAccept || e.altKey ) || wo.editable_autoAccept && e.type !== 'keydown';
t = e.which === 13 && !e.shiftKey && ( wo.editable_enterToAccept || e.altKey ) || wo.editable_autoAccept && e.type !== 'keydown';
// change if new or user hits enter ( if option set )
if ( t && $this.data( 'before' ) !== txt ) {