YiiWheels
  • Package
  • Class
  • Tree

Packages

  • yiiwheels
    • behaviors
    • widgets
    • widgets
      • ace
      • box
      • datepicker
      • daterangepicker
      • datetimepicker
      • detail
      • editable
      • fileupload
      • fileuploader
      • formhelpers
      • gallery
      • google
      • grid
        • behaviors
        • operations
      • highcharts
      • maskInput
      • maskmoney
      • modal
      • multiselect
      • rangeslider
      • redactor
      • select2
      • sparklines
      • switch
      • timeago
      • timepicker
      • toggle
      • typeahead

Classes

  • WhCountries
  • WhDatePickerHelper
  • WhFonts
  • WhFontSizes
  • WhGoogleFonts
  • WhLanguages
  • WhPhone
  • WhSelectBox
  • WhStates
  • WhTimePickerHelper
  • WhTimezones
  1 <?php
  2 /**
  3  * WhTimePickerHelper widget class
  4  *
  5  * @author Antonio Ramirez <amigo.cobos@gmail.com>
  6  * @copyright Copyright &copy; 2amigos.us 2013-
  7  * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
  8  * @package YiiWheels.widgets.formhelpers
  9  * @uses YiiStrap.helpers.TbArray
 10  * @uses YiiStrap.helpers.TbHtml
 11  */
 12 Yii::import('bootstrap.helpers.TbArray');
 13 Yii::import('bootstrap.helpers.TbHtml');
 14 
 15 class WhTimePickerHelper extends CInputWidget
 16 {
 17 
 18     /**
 19      * @var array options of the input
 20      */
 21     public $inputOptions = array();
 22 
 23     /**
 24      * @var array
 25      */
 26     public $pluginOptions = array();
 27 
 28 
 29     /**
 30      * Widget's initialization method
 31      * @throws CException
 32      */
 33     public function init()
 34     {
 35 
 36         $this->attachBehavior('ywplugin', array('class' => 'yiiwheels.behaviors.WhPlugin'));
 37 
 38         TbHtml::addCssClass('bfh-timepicker', $this->htmlOptions);
 39         $this->htmlOptions['data-time'] = $this->hasModel()
 40             ? $this->model->{$this->attribute}
 41             : $this->value;
 42 
 43         $this->inputOptions['readonly'] = true;
 44     }
 45 
 46     /**
 47      * Runs the widget.
 48      */
 49     public function run()
 50     {
 51         $this->renderField();
 52         $this->registerClientScript();
 53     }
 54 
 55     /**
 56      * Renders the input file field
 57      */
 58     public function renderField()
 59     {
 60 
 61         list($name, $id) = $this->resolveNameID();
 62 
 63         TbArray::defaultValue('id', $id, $this->htmlOptions);
 64         TbArray::defaultValue('name', $name, $this->htmlOptions);
 65 
 66         echo CHtml::openTag('div', $this->htmlOptions);
 67         echo CHtml::openTag('div', array(
 68             'class' => 'input-prepend bfh-timepicker-toggle',
 69             'data-toggle' => 'bfh-timepicker'
 70         ));
 71         echo CHtml::tag('span', array('class' => 'add-on'), TbHtml::icon(TbHtml::ICON_TIME));
 72         if ($this->hasModel()) {
 73             echo CHtml::activeTextField($this->model, $this->attribute, $this->inputOptions);
 74         } else {
 75             echo CHtml::textField($name, $this->value, $this->inputOptions);
 76         }
 77         echo CHtml::closeTag('div');
 78 
 79         echo '<div class="bfh-timepicker-popover">
 80                 <table class="table">
 81                 <tbody>
 82                     <tr>
 83                         <td class="hour">
 84                         <a class="next" href="#"><i class="icon-chevron-up"></i></a><br>
 85                         <input type="text" class="input-mini" readonly><br>
 86                         <a class="previous" href="#"><i class="icon-chevron-down"></i></a>
 87                         </td>
 88                         <td class="separator">:</td>
 89                         <td class="minute">
 90                         <a class="next" href="#"><i class="icon-chevron-up"></i></a><br>
 91                         <input type="text" class="input-mini" readonly><br>
 92                         <a class="previous" href="#"><i class="icon-chevron-down"></i></a>
 93                         </td>
 94                     </tr>
 95                 </tbody>
 96                 </table>
 97             </div>';
 98         echo CHtml::closeTag('div');
 99     }
100 
101     /**
102      * Registers client script
103      */
104     public function registerClientScript()
105     {
106         /* publish assets dir */
107         $path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets';
108         $assetsUrl = $this->getAssetsUrl($path);
109 
110         /* @var $cs CClientScript */
111         $cs = Yii::app()->getClientScript();
112 
113         $cs->registerCssFile($assetsUrl . '/css/bootstrap-formhelpers.css');
114         $cs->registerScriptFile($assetsUrl . '/js/bootstrap-formhelpers-timepicker.js');
115 
116         /* initialize plugin */
117         // $selector = '#' . TbArray::getValue('id', $this->htmlOptions, $this->getId());
118         // $this->getApi()->registerPlugin('bfhdatepicker', $selector, $this->pluginOptions);
119 
120     }
121 }
YiiWheels API documentation generated by ApiGen 2.8.0