From 60d8339199d00690375254cc86338018a7a61dc9 Mon Sep 17 00:00:00 2001 From: Jim Lindstrom Date: Wed, 17 Aug 2011 20:54:38 -0400 Subject: [PATCH] Introduced a 'show function' that allows you to use jQuery fadeIn or slideDown for smoother transitions. --- README.textile | 4 ++++ default.html | 24 ++++++++++++++++-------- jquery.jeditable.js | 11 +++++++++-- 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/README.textile b/README.textile index ddab36f..f24ebdf 100644 --- a/README.textile +++ b/README.textile @@ -1,5 +1,9 @@ h3. Changelog +h4. 1.7.3 + +* Elements can have a 'show function', using jQuery fadeIn/slideDown for smoother transitions ("jimlindstrom":http://github.com/jimlindstrom) + h4. 1.7.2 * Submit on change if input type select and no submit button defined ("gregpyp":http://github.com/gregpyp) diff --git a/default.html b/default.html index dd26e3c..4f00501 100644 --- a/default.html +++ b/default.html @@ -29,14 +29,16 @@ style : "inherit", submitdata : function() { return {id : 2}; - } + }, + showfn : function (elem) { elem.fadeIn('fast'); } }); $(".editable_select_json").editable("save.php", { indicator : '', loadurl : "json.php", type : "select", submit : "OK", - style : "inherit" + style : "inherit", + showfn : function (elem) { elem.fadeIn('fast'); } }); $(".editable_textarea").editable("save.php", { indicator : "", @@ -45,7 +47,8 @@ select : true, submit : 'OK', cancel : 'cancel', - cssclass : "editable" + cssclass : "editable", + showfn : function (elem) { elem.fadeIn('fast'); } }); $(".editable_textile").editable("save.php?renderer=textile", { indicator : "", @@ -53,32 +56,37 @@ type : "textarea", submit : "OK", cancel : "Cancel", - tooltip : "Click to edit..." + tooltip : "Click to edit...", + showfn : function (elem) { elem.fadeIn('fast'); } }); $(".click").editable("echo.php", { indicator : "", tooltip : "Click to edit...", - style : "inherit" + style : "inherit", + showfn : function (elem) { elem.fadeIn('fast'); } }); $(".dblclick").editable("echo.php", { indicator : "", tooltip : "Doubleclick to edit...", event : "dblclick", - style : "inherit" + style : "inherit", + showfn : function (elem) { elem.fadeIn('fast'); } }); $(".mouseover").editable("echo.php", { indicator : "", tooltip : "Move mouseover to edit...", event : "mouseover", - style : "inherit" + style : "inherit", + showfn : function (elem) { elem.fadeIn('fast'); } }); /* Should not cause error. */ $("#nosuch").editable("echo.php", { indicator : "", type : 'textarea', - submit : 'OK' + submit : 'OK', + showfn : function (elem) { elem.fadeIn('fast'); } }); }); diff --git a/jquery.jeditable.js b/jquery.jeditable.js index eb8a911..4da9413 100644 --- a/jquery.jeditable.js +++ b/jquery.jeditable.js @@ -15,7 +15,7 @@ */ /** - * Version 1.7.2-dev + * Version 1.7.3-dev * * ** means there is basic unit tests for this parameter. * @@ -48,6 +48,7 @@ * @param String options[select] true or false, when true text is highlighted ?? * @param String options[placeholder] Placeholder text or html to insert when element is empty. ** * @param String options[onblur] 'cancel', 'submit', 'ignore' or function ?? + * @param Function options[showfn] function that can animate ethe element when switching to edit mode ** * * @param Function options[onsubmit] function(settings, original) { ... } called before submit * @param Function options[onreset] function(settings, original) { ... } called before reset @@ -240,9 +241,15 @@ /* Add buttons to the form. */ buttons.apply(form, [settings, self]); - + /* Add created form to self. */ + if (settings.showfn) { + form.hide(); + } $(self).append(form); + if (settings.showfn) { + settings.showfn(form); + } /* Attach 3rd party plugin if requested. */ plugin.apply(form, [settings, self]);