Refactoring in UploadFile.class.php to simplify things.
[timetracker.git] / WEB-INF / lib / form / TextArea.class.php
index a9c0c80..be884f0 100644 (file)
@@ -29,8 +29,6 @@
 import('form.FormElement');
        
 class TextArea extends FormElement {
-    var $mColumns      = "";
-    var $mRows         = "";
     var $mOnKeyPress   = "";
 
   function __construct($name)
@@ -39,32 +37,17 @@ class TextArea extends FormElement {
     $this->name = $name;
   }
 
-       function setColumns($value)     { $this->mColumns = $value;     }
-       function getColumns()   { return $this->mColumns; }
-
-       function setRows($value)        { $this->mRows = $value;        }
-       function getRows()      { return $this->mRows; }
-       
        function getHtml() {
     
            if (empty($this->id))
                 $this->id = $this->name;
            
-           $js_maxlen = "";
-           
                $html = "\n\t<textarea";
                $html .= " name=\"$this->name\" id=\"$this->id\"";
-               
-               if ($this->mColumns!="")
-                 $html .= " cols=\"$this->mColumns\"";
-                 
-               if ($this->mRows!="")
-                  $html .= " rows=\"$this->mRows\"";
-                  
+
                if ($this->max_length!="") {
                        if ($this->mOnKeyPress) $this->mOnKeyPress .= ";";
                        $this->mOnKeyPress .= "return validateMaxLenght_".$this->name."(this, event);";
-                       $js_maxlen = $this->getExtraScript();
                        $html .= " maxlength=\"$this->max_length\"";
                }
 
@@ -76,26 +59,7 @@ class TextArea extends FormElement {
                }
                        
                $html .= ">".htmlspecialchars($this->getValue())."</textarea>";
-               if ($js_maxlen) $html = $js_maxlen."\n".$html;
                
                return $html;
        }
-       
-       function getExtraScript() {
-               $s = "<script>\n";
-               $s .= "var isNS4 = (navigator.appName==\"Netscape\")?1:0;\n";
-               $s .= "function validateMaxLenght_".$this->name."(element, event) {\n";
-               $s .= "\tmaxlength=".$this->max_length.";\n";
-               $s .= "\tvar iKey = (!isNS4?event.keyCode:event.which);\n";
-               //$s .= "alert(iKey);";
-               $s .= "\tvar re = new RegExp(\"".'\r\n'."\",\"g\");\n";
-               $s .= "\tvar x = element.value.replace(re,\"\").length;\n";
-               $s .= "\tif ((x>=maxlength) && ((iKey > 31 && iKey < 1200) || (iKey > 95 && iKey < 106)) && (iKey != 13)) {\n";
-               $s .= "\t\treturn false;\n";
-               $s .= "\t} else {\n";
-               $s .= "\t\treturn true;\n";
-               $s .= "\t}\n}\n";
-               $s .= "</script>\n";
-               return $s;
-       }
 }