By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,850 Members | 2,007 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,850 IT Pros & Developers. It's quick & easy.

upgrading MooTools version

100+
P: 162
i need to upgrade a script for MoolTools that was built on version Build 86. I need it upgraded to work with v1.2. I have looked on the web for info on build 86, but im not finding much help. Im sure someone firmiliar with MooTools will be able to spot the upgraded functions that are needed. Thanks much in advance.

This is the script that is need upgrading. Found here, http://www.zed23.com/2007/01/23/moot...rea-component/

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. ResizingTextArea = new Class(
  3.     {
  4.         iRows: 1,
  5.         initialize: function(element, options)
  6.         {
  7.             this.element = $(element.id);
  8.             this.element.setStyle('overflow','hidden');
  9.             this.element.setStyle('overflow-x','auto');
  10.             this.element.setProperty('wrap','vitual');
  11.             this.iRows = this.getRows();
  12.             this.opt = Object.extend(
  13.                 {
  14.                     resizeStep: 1
  15.                 },
  16.                 options || {}
  17.             );
  18.             this.resize(this); // Boot up just in case we used an onload
  19.             this.element.onclick = this.resize.bindAsEventListener(this);
  20.             this.element.onkeyup = this.resize.bindAsEventListener(this);
  21.         },
  22.         getRows: function()
  23.         {
  24.             return Math.max(this.element.getProperty('rows'), 10)
  25.         },
  26.         resize: function()
  27.         {
  28.             var lines = this.element.getValue().split('\n');
  29.             var newRows = lines.length + this.opt.resizeStep;
  30.             var oldRows = this.iRows;
  31.             var cols = this.element.getProperty('cols');
  32.             for (var i = 0; i < lines.length; i++)
  33.             {
  34.                 var line = lines[i];
  35.                 if (line.length >= cols) newRows += Math.floor(line.length / cols);    
  36.             }
  37.             if (newRows > this.element.rows) this.element.setProperty('rows', newRows);
  38.             if (newRows < this.element.rows) this.element.setProperty('rows', Math.max(this.iRows, newRows));
  39.         }
  40.     }
  41. );
  42.  
  43. window.onload = function()
  44. {
  45.     $A(document.getElementsByTagName('textarea')).each(
  46.         function(el)
  47.         {
  48.             el.onfocus = new ResizingTextArea(el);
  49.         }
  50.     );
  51. }
  52. </script>
  53.  
Sep 26 '08 #1
Share this Question
Share on Google+
1 Reply


100+
P: 162
Thanks to CroNIX for this link to an even better version of the textarea plugin using MooTools v1.2, http://tools.uvumi.com/textarea.html.
Sep 26 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.