From 7a20d6d4df54ab7774bef43ae3ed901ca5d00fe0 Mon Sep 17 00:00:00 2001 From: Aris Feryanto Date: Mon, 8 Aug 2011 13:05:56 +0800 Subject: [PATCH] Grid edit: turn off grid edit when AJAXEnable = off --- js/makegrid.js | 111 ++++++++++++++++++++++++++----------------------- 1 file changed, 59 insertions(+), 52 deletions(-) diff --git a/js/makegrid.js b/js/makegrid.js index 7fdbf31595..e4d4d59474 100644 --- a/js/makegrid.js +++ b/js/makegrid.js @@ -1167,6 +1167,62 @@ g.hideEditCell(true); } } + }, + + // initialize grid editing feature + initGridEdit: function() { + $(t).find('td.data') + .click(function(e) { + if (g.isCellEditActive) { + g.saveOrPostEditedCell(); + e.stopPropagation(); + } else { + g.showEditCell(this); + e.stopPropagation(); + } + // prevent default action when clicking on "link" in a table + if ($(e.target).is('a')) { + e.preventDefault(); + } + }); + $(g.cEdit).find('input[type=text]').focus(function(e) { + g.showEditArea(); + }); + $(g.cEdit).find('input[type=text], select').live('keydown', function(e) { + if (e.which == 13) { + // post on pressing "Enter" + e.preventDefault(); + g.saveOrPostEditedCell(); + } + }); + $(g.cEdit).keydown(function(e) { + if (!g.isEditCellTextEditable) { + // prevent text editing + e.preventDefault(); + } + }); + $('html').click(function(e) { + // hide edit cell if the click is not from g.cEdit + if ($(e.target).parents().index(g.cEdit) == -1) { + g.hideEditCell(); + } + }); + $('html').keydown(function(e) { + if (e.which == 27 && g.isCellEditActive) { + + // cancel on pressing "Esc" + g.hideEditCell(true); + } + }); + $('.save_edited').click(function() { + g.hideEditCell(); + g.postEditedCell(); + }); + $(window).bind('beforeunload', function(e) { + if (g.isCellEdited) { + return g.saveCellWarning; + } + }); } } @@ -1413,58 +1469,9 @@ g.hideColList(); }); // edit cell event - $(t).find('td.data') - .click(function(e) { - if (g.isCellEditActive) { - g.saveOrPostEditedCell(); - e.stopPropagation(); - } else { - g.showEditCell(this); - e.stopPropagation(); - } - // prevent default action when clicking on "link" in a table - if ($(e.target).is('a')) { - e.preventDefault(); - } - }); - $(g.cEdit).find('input[type=text]').focus(function(e) { - g.showEditArea(); - }); - $(g.cEdit).find('input[type=text], select').live('keydown', function(e) { - if (e.which == 13) { - // post on pressing "Enter" - e.preventDefault(); - g.saveOrPostEditedCell(); - } - }); - $(g.cEdit).keydown(function(e) { - if (!g.isEditCellTextEditable) { - // prevent text editing - e.preventDefault(); - } - }); - $('html').click(function(e) { - // hide edit cell if the click is not from g.cEdit - if ($(e.target).parents().index(g.cEdit) == -1) { - g.hideEditCell(); - } - }); - $('html').keydown(function(e) { - if (e.which == 27 && g.isCellEditActive) { - - // cancel on pressing "Esc" - g.hideEditCell(true); - } - }); - $('.save_edited').click(function() { - g.hideEditCell(); - g.postEditedCell(); - }); - $(window).bind('beforeunload', function(e) { - if (g.isCellEdited) { - g.saveCellWarning; - } - }); + if ($(t).is('.ajax')) { + g.initGridEdit(); + } // add table class $(t).addClass('pma_table');