<?php 

class ToggleSlider {
  private $scope;
  private $position;
  private $label;
  private $idProp;
  private $disabled;

  public function __construct ($field) {
    if (isset($field)) {
      $this->field    = $field->field;
      $this->disabled = $field->disabled;
      $this->form = $field->form;
      $this->label    = $field->label;

      $this->onOpenClose = "";
      if (null !== $field->onOpenClose) {
        $close = explode(",", $field->onOpenClose);
        for ($i=0; $i<count($close); $i++) {
          $this->onOpenClose .= "$('.slide$close[$i]').slideUp('slow'); ";
        }
      }    

      if (isset($field->position) && $field->position == "left")
        $this->position = "left";
      else
        $this->position = "right";
    }
  }
  
  public function outputLayout() {
  
    $html = "
<button id='$this->field' class='btn btn-inverse tog$this->form'
  $this->disabled style='float:$this->position;'>$this->label</button>
    ";
  	return $html;
  }
  
  public function outputScript() {
		
    $script = " 

$('#$this->field').click(function(){
  $('.slide$this->field').toggle('slow');
  $this->onOpenClose  
});


    
    ";
    return $script;
  }
}

?>
