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 TSlider.php

Documentation is available at TSlider.php

  1. <?php
  2. namespace Adianti\Widget\Form;
  3.  
  4. use Adianti\Widget\Form\AdiantiWidgetInterface;
  5. use Adianti\Widget\Base\TElement;
  6. use Adianti\Widget\Base\TScript;
  7. use Adianti\Widget\Form\TField;
  8.  
  9. /**
  10.  * Slider Widget
  11.  *
  12.  * @version    7.4
  13.  * @package    widget
  14.  * @subpackage form
  15.  * @author     Pablo Dall'Oglio
  16.  * @copyright  Copyright (c) 2006 Adianti Solutions Ltd. (http://www.adianti.com.br)
  17.  * @license    http://www.adianti.com.br/framework-license
  18.  */
  19. class TSlider extends TField implements AdiantiWidgetInterface
  20. {
  21.     protected $id;
  22.     private $min;
  23.     private $max;
  24.     private $step;
  25.     
  26.     /**
  27.      * Class Constructor
  28.      * @param $name Name of the widget
  29.      */
  30.     public function __construct($name)
  31.     {
  32.         parent::__construct($name);
  33.         $this->id   = 'tslider_'.mt_rand(10000000001999999999);
  34.         $this->tag->{'widget''tslider';
  35.     }
  36.     
  37.     /**
  38.      * Define the field's range
  39.      * @param $min Minimal value
  40.      * @param $max Maximal value
  41.      * @param $step Step value
  42.      */
  43.     public function setRange($min$max$step)
  44.     {
  45.         $this->min = $min;
  46.         $this->max = $max;
  47.         $this->step $step;
  48.         $this->value $min;
  49.     }
  50.     
  51.     /**
  52.      * Enable the field
  53.      * @param $form_name Form name
  54.      * @param $field Field name
  55.      */
  56.     public static function enableField($form_name$field)
  57.     {
  58.         TScript::create" tslider_enable_field('{$form_name}', '{$field}'); );
  59.     }
  60.     
  61.     /**
  62.      * Disable the field
  63.      * @param $form_name Form name
  64.      * @param $field Field name
  65.      */
  66.     public static function disableField($form_name$field)
  67.     {
  68.         TScript::create" tslider_disable_field('{$form_name}', '{$field}'); );
  69.     }
  70.     
  71.     /**
  72.      * Shows the widget at the screen
  73.      */
  74.     public function show()
  75.     {
  76.         // define the tag properties
  77.         $this->tag->{'name'}  $this->name;    // TAG name
  78.         $this->tag->{'value'$this->value;   // TAG value
  79.         $this->tag->{'type'}  'range';         // input type
  80.         $this->tag->{'min'}   $this->min;
  81.         $this->tag->{'max'}   $this->max;
  82.         $this->tag->{'step'}  $this->step;
  83.         
  84.         if (strstr((string) $this->size'%'!== FALSE)
  85.         {
  86.             $this->setProperty('style'"width:{$this->size};"false)//aggregate style info
  87.         }
  88.         else
  89.         {
  90.             $this->setProperty('style'"width:{$this->size}px;"false)//aggregate style info
  91.         }
  92.         
  93.         if ($this->id)
  94.         {
  95.             $this->tag->{'id'$this->id;
  96.         }
  97.         
  98.         $this->tag->{'readonly'"1";
  99.         $this->tag->show();
  100.         
  101.         TScript::create(" tslider_start( '#{$this->id}'); ");
  102.         
  103.         if (!parent::getEditable())
  104.         {
  105.             self::disableField($this->formName$this->name);
  106.         }
  107.     }
  108. }