00001 <?php 00002 00003 namespace Habari; 00004 00009 class FormControlTextMulti extends FormControl 00010 { 00011 public static $outpre = false; 00012 00017 public function pre_out() 00018 { 00019 $out = ''; 00020 if ( !FormControlTextMulti::$outpre ) { 00021 FormControlTextMulti::$outpre = true; 00022 $out .= ' 00023 <script type="text/javascript"> 00024 controls.textmulti = { 00025 add: function(e, field){ 00026 $(e).before(" <span class=\"textmulti_item\"><input type=\"text\" name=\"" + field + "[]\"> <a href=\"#\" onclick=\"return controls.textmulti.remove(this);\" title=\"'. _t( 'Remove item' ).'\" class=\"textmulti_remove opa50\">[' . _t( 'remove' ) . ']</a></span>"); 00027 return false; 00028 }, 00029 remove: function(e){ 00030 if (confirm("' . _t( 'Remove this item?' ) . '")) { 00031 if ( $(e).parent().parent().find("input").length == 1) { 00032 field = $(e).prev().attr("name"); 00033 $(e).parent().prev().before("<input type=\"hidden\" name=\"" + field + "\" value=\"\">"); 00034 } 00035 $(e).parent().prev("input").remove(); 00036 $(e).parent().remove(); 00037 } 00038 return false; 00039 } 00040 } 00041 </script> 00042 '; 00043 } 00044 return $this->controls_js($out); 00045 } 00046 00047 } 00048 00049 ?>