[Rt-commit] rt branch, 4.6/inline-edit, updated. rt-4.4.1-158-g9ce8a68
Shawn Moore
shawn at bestpractical.com
Fri Sep 16 16:29:49 EDT 2016
The branch, 4.6/inline-edit has been updated
via 9ce8a68e19f8db68ca98ef5b23a99f97661d5ad4 (commit)
via 33e5a4aba8d6d8187025a5183a528d7a45afec28 (commit)
via b219b6dff4791b017c1507365bbcc4ab41dc64dd (commit)
from 3f304b2990d44f572839b37f462eb4e4dd9c3f66 (commit)
Summary of changes:
share/static/js/util.js | 119 +++++++++++++++++++++++++++++-------------------
1 file changed, 72 insertions(+), 47 deletions(-)
- Log -----------------------------------------------------------------
commit b219b6dff4791b017c1507365bbcc4ab41dc64dd
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Fri Sep 16 19:16:33 2016 +0000
Factor out a cancelInlineEdit function
diff --git a/share/static/js/util.js b/share/static/js/util.js
index d1cf489..905b4e6 100644
--- a/share/static/js/util.js
+++ b/share/static/js/util.js
@@ -587,27 +587,33 @@ jQuery(function () {
var inlineEditingDate = false;
var scrollHandler = null;
+ var cancelInlineEdit = function (editor) {
+ var cell = editor.closest('td');
+
+ inlineEditingDate = false;
+ cell.removeClass('editing').removeAttr('height');
+ editor.removeClass('wide');
+ if (scrollHandler) {
+ jQuery(window).off('scroll', scrollHandler);
+ }
+ };
+
var submitInlineEdit = function (editor) {
if (!inlineEditEnabled) {
return;
}
- var cell = editor.closest('td');
- var tbody = cell.closest('tbody');
- var table = tbody.closest('table');
- var value = cell.find('.value');
-
inlineEditingDate = false;
if (!editor.data('changed')) {
- cell.removeClass('editing').removeAttr('height');
- editor.removeClass('wide');
- if (scrollHandler) {
- jQuery(window).off('scroll', scrollHandler);
- }
+ cancelInlineEdit(editor);
return;
}
+ var cell = editor.closest('td');
+ var tbody = cell.closest('tbody');
+ var table = tbody.closest('table');
+
var params = editor.serialize();
editor.find(':input').attr('disabled', 'disabled');
commit 33e5a4aba8d6d8187025a5183a528d7a45afec28
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Fri Sep 16 20:17:02 2016 +0000
Factor out a beginInlineEdit
diff --git a/share/static/js/util.js b/share/static/js/util.js
index 905b4e6..612f6b0 100644
--- a/share/static/js/util.js
+++ b/share/static/js/util.js
@@ -587,6 +587,47 @@ jQuery(function () {
var inlineEditingDate = false;
var scrollHandler = null;
+ var beginInlineEdit = function (cell) {
+ if (!inlineEditEnabled) {
+ return;
+ }
+
+ var value = cell.find('.value');
+ var editor = cell.find('.editor');
+
+ if (jQuery('td.editable.editing').length) {
+ return;
+ }
+
+ var height = cell.height();
+
+ cell.addClass('editing');
+
+ if (editor.find('textarea').length || editor[0].clientWidth > cell[0].clientWidth) {
+ cell.attr('height', height);
+
+ var rect = editor[0].getBoundingClientRect();
+ editor.addClass('wide');
+ var top = rect.top - parseInt(editor.css('padding-top')) - parseInt(editor.css('border-top-width'));
+ var left = rect.left - parseInt(editor.css('padding-left')) - parseInt(editor.css('border-left-width'));
+ editor.css({ top: top, left: left });
+
+ var $window = jQuery(window);
+ var initialScrollTop = top + $window.scrollTop();
+
+ scrollHandler = function (e) {
+ editor.css('top', initialScrollTop - $window.scrollTop());
+ };
+ jQuery(window).scroll(scrollHandler);
+ }
+
+ editor.find(':input:visible:enabled:first').focus();
+
+ if (editor.find('.datepicker').length) {
+ inlineEditingDate = true;
+ }
+ };
+
var cancelInlineEdit = function (editor) {
var cell = editor.closest('td');
@@ -659,45 +700,8 @@ jQuery(function () {
});
jQuery(document).on('click', 'td.editable', function (e) {
- if (!inlineEditEnabled) {
- return;
- }
-
var cell = jQuery(this);
- var value = cell.find('.value');
- var editor = cell.find('.editor');
-
- if (jQuery('td.editable.editing').length) {
- return;
- }
-
- var height = cell.height();
-
- cell.addClass('editing');
-
- if (editor.find('textarea').length || editor[0].clientWidth > cell[0].clientWidth) {
- cell.attr('height', height);
-
- var rect = editor[0].getBoundingClientRect();
- editor.addClass('wide');
- var top = rect.top - parseInt(editor.css('padding-top')) - parseInt(editor.css('border-top-width'));
- var left = rect.left - parseInt(editor.css('padding-left')) - parseInt(editor.css('border-left-width'));
- editor.css({ top: top, left: left });
-
- var $window = jQuery(window);
- var initialScrollTop = $window.scrollTop();
-
- scrollHandler = function (e) {
- editor.css('top', top + initialScrollTop - $window.scrollTop());
- };
- jQuery(window).scroll(scrollHandler);
- }
-
- editor.find(':input:visible:enabled:first').focus();
-
- if (editor.find('.datepicker').length) {
- inlineEditingDate = true;
- }
+ beginInlineEdit(cell);
});
jQuery(document).on('change', 'td.editable.editing form :input', function () {
commit 9ce8a68e19f8db68ca98ef5b23a99f97661d5ad4
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Fri Sep 16 20:17:12 2016 +0000
Escape key cancels current inline edit
diff --git a/share/static/js/util.js b/share/static/js/util.js
index 612f6b0..71c04b2 100644
--- a/share/static/js/util.js
+++ b/share/static/js/util.js
@@ -586,6 +586,7 @@ jQuery(function () {
var inlineEditingDate = false;
var scrollHandler = null;
+ var escapeKeyHandler = null;
var beginInlineEdit = function (cell) {
if (!inlineEditEnabled) {
@@ -621,6 +622,14 @@ jQuery(function () {
jQuery(window).scroll(scrollHandler);
}
+ escapeKeyHandler = function (e) {
+ if (e.keyCode == 27) {
+ e.preventDefault();
+ cancelInlineEdit(editor);
+ }
+ };
+ jQuery(document).keyup(escapeKeyHandler);
+
editor.find(':input:visible:enabled:first').focus();
if (editor.find('.datepicker').length) {
@@ -637,6 +646,9 @@ jQuery(function () {
if (scrollHandler) {
jQuery(window).off('scroll', scrollHandler);
}
+ if (escapeKeyHandler) {
+ jQuery(document).off('keyup', escapeKeyHandler);
+ }
};
var submitInlineEdit = function (editor) {
@@ -675,11 +687,13 @@ jQuery(function () {
table,
function () {
jQuery(window).off('scroll', scrollHandler);
+ jQuery(document).off('keyup', escapeKeyHandler);
},
function (xhr, error) {
jQuery.jGrowl(error, { sticky: true, themeState: 'none' });
cell.addClass('error').html(loc_key('error'));
jQuery(window).off('scroll', scrollHandler);
+ jQuery(document).off('keyup', escapeKeyHandler);
disableInlineEdit();
}
);
@@ -688,6 +702,7 @@ jQuery(function () {
jQuery.jGrowl(error, { sticky: true, themeState: 'none' });
cell.addClass('error').html(loc_key('error'));
jQuery(window).off('scroll', scrollHandler);
+ jQuery(document).off('keyup', escapeKeyHandler);
disableInlineEdit();
}
});
-----------------------------------------------------------------------
More information about the rt-commit
mailing list