Lançado Adianti Framework 7.6!
Clique aqui para saber mais
menu

Adianti Solutions

API

Adianti, Framework, PHP, MVC, Active record, Front controller, IDE, RAD, Web, multiplataforma, geração de código, desenvolvimento rápido, relatórios, formulários, listagens, datagrids, gráficos, banco de dados, padrões de projeto, design patterns API do Adianti Framework.
API Docs
code
Selecione a classe

Source for file TExpander.php

Documentation is available at TExpander.php

  1. <?php
  2. namespace Adianti\Widget\Container;
  3.  
  4. use Adianti\Widget\Base\TElement;
  5. use Adianti\Widget\Base\TScript;
  6.  
  7. /**
  8.  * Expander Widget
  9.  *
  10.  * @version    7.4
  11.  * @package    widget
  12.  * @subpackage container
  13.  * @author     Pablo Dall'Oglio
  14.  * @copyright  Copyright (c) 2006 Adianti Solutions Ltd. (http://www.adianti.com.br)
  15.  * @license    http://www.adianti.com.br/framework-license
  16.  */
  17. class TExpander extends TElement
  18. {
  19.     private $container;
  20.     private $button;
  21.     private $caret_side;
  22.     private $label;
  23.     
  24.     /**
  25.      * Class Constructor
  26.      * @param  $value text label
  27.      */
  28.     public function __construct($label '')
  29.     {
  30.         parent::__construct('div');
  31.         $this->{'id'}    'texpander_'.mt_rand(10000000001999999999);
  32.         $this->{'class''dropdown';
  33.         
  34.         $this->button new TElement('button');
  35.         $this->button->{'class''btn btn-default dropdown-toggle';
  36.         $this->button->{'type''button';
  37.         $this->button->{'id'}   'button_'.mt_rand(10000000001999999999);
  38.         $this->button->{'data-toggle''dropdown';
  39.         $this->label $label;
  40.         
  41.         $this->container new TElement('ul');
  42.         $this->container->{'class''dropdown-menu texpander-container';
  43.         
  44.         $this->container->{'aria-labelledby'$this->button->{'id'};
  45.         
  46.         parent::add($this->button);
  47.         parent::add($this->container);
  48.     }
  49.     
  50.     /**
  51.      * Set caret side
  52.      * @caret_side Caret side (left, right)
  53.      */
  54.     public function setCaretSide($caret_side)
  55.     {
  56.         $this->caret_side $caret_side;
  57.     }
  58.     
  59.     /**
  60.      * Define the pull side
  61.      * @side left/right
  62.      */
  63.     public function setPullSide($side)
  64.     {
  65.         $this->container->{'class'"dropdown-menu texpander-container pull-{$side}";
  66.     }
  67.     
  68.     /**
  69.      * Define a button property
  70.      * @param $property Property name (Ex: style)
  71.      * @param $value    Property value
  72.      */
  73.     public function setButtonProperty($property$value)
  74.     {
  75.         $this->button->$property $value;
  76.     }
  77.     
  78.     /**
  79.      * Define a container property
  80.      * @param $property Property name (Ex: style)
  81.      * @param $value    Property value
  82.      */
  83.     public function setProperty($property$value)
  84.     {
  85.         $this->container->$property $value;
  86.     }
  87.     
  88.     /**
  89.      * Add content to the expander
  90.      * @param $content Any Object that implements show() method
  91.      */
  92.     public function add($content)
  93.     {
  94.         $this->container->add($content);
  95.     }
  96.     
  97.     /**
  98.      * Shows the expander
  99.      */
  100.     public function show()
  101.     {
  102.         if ($this->caret_side == 'left')
  103.         {
  104.             $this->button->add(TElement::tag('span'''array('class'=>'caret')));
  105.             $this->button->add($this->label);
  106.         }
  107.         else if ($this->caret_side == 'right')
  108.         {
  109.             $this->button->add($this->label);
  110.             $this->button->add('&nbsp');
  111.             $this->button->add(TElement::tag('span'''array('class'=>'caret')));
  112.         }
  113.         else
  114.         {
  115.             $this->button->add($this->label);
  116.         }
  117.         
  118.         parent::show();
  119.         TScript::create('texpander_start();');
  120.     }
  121. }