From 6632e2b6785845d4bd4de42dcdcd6130d387e960 Mon Sep 17 00:00:00 2001 From: Stefan Lage Date: Tue, 28 May 2013 17:42:15 -0400 Subject: [PATCH] nitdoc: Added function to resize textbox Adding a function which resize a textbox in terms of its content Signed-off-by: Stefan Lage --- share/nitdoc/scripts/js-facilities.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/share/nitdoc/scripts/js-facilities.js b/share/nitdoc/scripts/js-facilities.js index 87e760a..1349c66 100644 --- a/share/nitdoc/scripts/js-facilities.js +++ b/share/nitdoc/scripts/js-facilities.js @@ -488,6 +488,7 @@ $(document).ready(function() { if($(this).next().val() == "" || $(this).next().val() != adapt){ $(this).next().val(adapt); } // Resize edit box $(this).next().height($(this).next().prop("scrollHeight")); + resizeTextarea($(this).next()); // Select it $(this).next().select(); preElement = $(this); @@ -531,6 +532,7 @@ $(document).ready(function() { $(this).next().hide(); if(editComment > 0){ editComment -= 1; } $('#chkSignedOff').attr('checked', false); + removeSignedOff(); }); //Close Popups and Fade Layer @@ -541,6 +543,7 @@ $(document).ready(function() { }); $('#modalQuestion').hide(); $('#chkSignedOff').attr('checked', false); + removeSignedOff(); }); $('#loginAction').click(function(){ @@ -634,6 +637,7 @@ $(document).ready(function() { $(this).next().next().next().show(); // Resize edit box $(this).next().height($(this).next().prop("scrollHeight")); + resizeTextarea($(this).next()); // Select it $(this).next().select(); preElement = $(this); @@ -1435,8 +1439,15 @@ function addSignedOff(){ $('#commitMessage').val($('#commitMessage').val() + "\n\nSigned-off-by: "+signedOff+" <"+userEmail+">"); }); }); + resizeTextarea($('#commitMessage')); } function removeSignedOff(){ $('#commitMessage').val(commitMessage); + resizeTextarea($('#commitMessage')); +} + +function resizeTextarea(element){ + var nLines = element.val().split('\n').length + 1; + element.attr('rows', nLines); } -- 1.7.9.5