Example #1
0
File: Chain.php Project: atk4/atk4
 /**
  * Render and return js chain as string
  *
  * @return string
  */
 public function _render()
 {
     $ret = $this->prepend;
     if ($this->library) {
         $ret .= $this->library;
     } else {
         if ($this->str) {
             $ret .= "\$('#" . $this->owner->getJSID() . "')";
         }
     }
     $ret .= $this->str;
     if ($this->enclose === true) {
         if ($this->preventDefault) {
             $ret = 'function(ev,ui){ev.preventDefault();ev.stopPropagation(); ' . $ret . '}';
         } else {
             $ret = 'function(ev,ui){' . $ret . '}';
         }
     } elseif ($this->enclose) {
         $ret = ($this->library ?: "\$('#" . $this->owner->getJSID() . "')") . ".bind('" . $this->enclose . "',function(ev,ui){ev.preventDefault();ev.stopPropagation(); " . $ret . '})';
     }
     if (@$this->debug) {
         echo "<font color='blue'>" . htmlspecialchars($ret) . ';</font><br/>';
         $this->debug = false;
     }
     return $ret;
 }