Permalink
Browse files

Initial commit

  • Loading branch information...
0 parents commit 45761506346f98fd0c19dd1c089f2e33e947d7ef Joshua Partogi committed Dec 4, 2009
Showing with 133 additions and 0 deletions.
  1. +21 −0 LICENSE
  2. +4 −0 README.rst
  3. BIN images/grippie.png
  4. +99 −0 mootools-textarea-resizer.js
  5. +9 −0 textarea-resizer.css
@@ -0,0 +1,21 @@
+The MIT License
+
+Copyright (c) 2009 Joshua Partogi (http://scrum8.com/)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
@@ -0,0 +1,4 @@
+Mootools Textarea Resizer
+=========================
+
+A simple `Mootools <http://mootools.net>` textarea resizer plugin.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,99 @@
+/*
+description: Mootools TextareaResizer plugin for Mootools 1.2.x
+
+license: MIT-style license.
+
+copyright: Copyright (c) 2009 [Joshua Partogi](http://scrum8.com/).
+
+authors: Joshua Partogi (http://scrum8.com/)
+
+*/
+var TextareaResizer = new Class({
+
+ initialize: function(element){
+ this.textarea = element;
+ this.element = element;
+ },
+
+ resizable: function(){
+
+ var staticOffset = 0;
+ var iLastMousePos = 0;
+ var iMin = 32;
+
+ var textarea = this.element;
+ var div = new Element('div').addClass('resizable-textarea');
+
+ div.wraps(textarea);
+ div.setStyle('width', textarea.getStyle('width').toInt());
+
+ var grippie = new Element('div').addClass('grippie');
+ grippie.inject(div, 'bottom');
+
+ var endDrag = function(e) {
+ document.removeEvent('mousemove', performDrag);
+ document.removeEvent('mouseup', endDrag);
+
+ textarea.setStyle('opacity', 1.0);
+ textarea.focus();
+
+ staticOffset = 0;
+ iLastMousePos = 0;
+ }
+
+ var performDrag = function(e) {
+ var iThisMousePos = mousePosition(e).y;
+ var iMousePos = staticOffset + iThisMousePos;
+
+ if (iLastMousePos >= (iThisMousePos)) {
+ iMousePos -= 5;
+ }
+
+ iLastMousePos = iThisMousePos;
+ iMousePos = Math.max(iMin, iMousePos);
+
+ textarea.setStyle('height', iMousePos);
+
+ if (iMousePos < iMin) {
+ endDrag(e);
+ }
+ }
+
+ var startDrag = function(e){
+ textarea.blur();
+
+ iLastMousePos = mousePosition(e).y;
+ staticOffset = textarea.getSize().y - iLastMousePos;
+ textarea.setStyle('opacity', 0.25);
+
+ document.addEvent('mousemove', performDrag);
+ document.addEvent('mouseup', endDrag);
+ }
+
+ var mousePosition = function(e) {
+ return {
+ x: e.event.clientX + document.documentElement.scrollLeft,
+ y: e.event.clientY + document.documentElement.scrollTop
+ };
+ }
+
+ grippie.addEvent('mousedown', startDrag);
+ }
+
+
+});
+
+
+(function(){
+
+ Element.implement({
+
+ resizable: function(){
+ var resizer = new TextareaResizer(this);
+
+ resizer.resizable();
+ }
+
+ });
+
+})();
@@ -0,0 +1,9 @@
+.grippie {
+ background:#EEEEEE url('images/grippie.png') no-repeat scroll center 2px;
+ border-color:#DDDDDD;
+ border-style:solid;
+ border-width:0pt 1px 1px;
+ cursor:s-resize;
+ height:9px;
+ overflow:hidden;
+}

0 comments on commit 4576150

Please sign in to comment.