UvumiTools Textarea Plugin

Description

The UvumiTools Textarea is a basic textarea with a couple extra features, built with the Mootools Javascript Framework. It doesn't have any WYSIWG formatting features, because we like to keep things simple. So it's just a basic <textarea> element, the kind you would find in, say, a comment form or a feedback page. It features a fancy remaining countdown of how many characters are still available, which isn't really anything new, we just use a nifty progress-style indicator instead of simply a number.

We feel that having a visual indicator of how much space is remaining in the textarea makes it easier for web users to plan what they are going to write, which helps provide an more pleasing overall experience at your web site. Remove some text from the above example and start typing to see just how it works, or paste a huge blob into the empty textarea. Works well, doesn't it?

Finally, we really like Apple's Safari browser feature that lets you resize textareas. As a web designer you may not want a huge textarea taking up half of the page, but you also don't want to restrict the user to a little tiny box for typing comments or descriptions. At first we added small buttons to manually grow and shrink the textarea, but then we decided those buttons were not even necessary since we could just make the textarea auto-adjust to its content. Sure, it's a gadget, but it's built in, so it just works without any hassles on your part.

Features

Requirements

What you'll need :

How To

Initialization

new UvumiTextarea(options);

Arguments

Options

How To

First, you simply import the files provided in the zip archive into your document. While you can insert <script> tags anywhere, we recommend you put them inside the <head> tag:

<head>
<!-- Insert these lines in your document's head -->
<link rel="stylesheet" type="text/css" media="screen" href="css/uvumi-textarea.css"/>
<script type="text/javascript" src="js/mootools-for-textarea.js"> </script>
<script type="text/javascript" src="js/UvumiTextarea.js"> </script>
</head>

The script needs at least one textarea. We are going to put this textarea in a form.

<form id="comment-form" action="submit-comment.php" method="post" >
<p>
<!-- This is our textarea. The rows and cols properties are not necessary for the script,
but the strict doctype requires them -->

<textarea id="text-input" name="text" rows="6" cols="12" > </textarea>
</p>
<p>
<button type="submit">Send</button>
</p>
</form>

Then we are ready to execute the script. We just add the following code in our document.

<script type="text/javascript">
new UvumiTextarea();
</script>

If we put everything together, we get something like this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html>
<head>
<link rel="stylesheet" type="text/css" media="screen" href="css/uvumi-textarea.css"/>
<script type="text/javascript" src="js/mootools-for-textarea.js"> </script>
<script type="text/javascript" src="js/UvumiTextarea.js"> </script>
<script type="text/javascript">
new UvumiTextarea();
</script>
</head>
<body>
<div>
<form id="comment-form" action="submit-comment.php" method="post" >
<p>
<textarea id="text-input" name="text" rows="6" cols="12" > </textarea>
</p>
<p>
<button type="submit">Send</button>
</p>
</form>
</div>
</body>
</html>

Technically, that should work.

Finally, you can use optional parameters when you initialize the plugin:

<script type="text/javascript">
/*
This form contains two textareas,
but we use the selector option to apply the plugin only to
the one with id 'text-input1'.
We also set the minimum size to 100px and maximum to 500px.
*/

new UvumiTextarea({
selector : 'textarea#text-input1',
minSize : 100,
maxSize : 500
});
</script>
<div>
<form action="submit-comment.php" method="post" >
<p>
<textarea id="text-input1" name="text1" rows="6" cols="12" > </textarea>
</p>
<p>
<textarea id="text-input2" name="text2" rows="6" cols="12" > </textarea>
</p>
<p>
<button type="submit">Send</button>
</p>
</form>
</div>

Another example:

<script type="text/javascript">
/*
This form contains three textareas,
We want the first to allow 512 characters,
the second one should allow 1024,
but the third should have no limit.
We declare three instances, with different selectors by class.
*/

new UvumiTextarea({
selector : 'textarea.textarea512',
maxChar : 512
});
new UvumiTextarea({
selector : 'textarea.textarea1024',
maxChar : 1024
});
new UvumiTextarea({
selector : 'textarea.textareaNoLimit',
maxChar : 0
});
</script>
<div>
<form action="submit-comments.php" method="post" >
<p>
<textarea class="textarea512" name="text1" rows="6" cols="12" > </textarea>
</p>
<p>
<textarea class="textarea104" name="text2" rows="6" cols="12" > </textarea>
</p>
<p>
<textarea class="textareaNoLimit" name="text3" rows="6" cols="12" > </textarea>
</p>
<p>
<button type="submit">Send</button>
</p>
</form>
</div>

Known Issues

Download

Change Log