YiiWheels
  • Package
  • Class
  • Tree

Packages

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

Classes

  • WhCarousel
  • WhGallery
  • WhVideoCarousel
 1 <?php
 2 /**
 3  * WhCarousel widget class
 4  *
 5  * Renders a carousel of blueimp Gallery
 6  * @see http://blueimp.github.io/Gallery/
 7  *
 8  * @author Antonio Ramirez <amigo.cobos@gmail.com>
 9  * @copyright Copyright &copy; 2amigos.us 2013-
10  * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
11  * @package YiiWheels.widgets.gallery
12  * @uses YiiStrap.helpers.TbArray
13  * @uses YiiStrap.helpers.TbHtml
14  */
15 Yii::import('bootstrap.helpers.TbHtml');
16 Yii::import('bootstrap.helpers.TbArray');
17 Yii::import('yiiwheels.widgets.gallery.WhGallery');
18 
19 class WhCarousel extends WhGallery
20 {
21 
22     /**
23      * Widget's initialization
24      */
25     public function init()
26     {
27         parent::init();
28         $this->pluginOptions['carousel'] = true;
29         $this->pluginOptions['container'] = '#' . $this->htmlOptions['id'] . '-carousel';
30     }
31 
32     /**
33      * Renders the links
34      */
35     public function renderLinks()
36     {
37         echo CHtml::openTag('div', $this->htmlOptions);
38         foreach ($this->items as $item) {
39             $url = TbArray::getValue('url', $item, '#');
40             $src = TbArray::getValue('src', $item, '#');
41             $options = TbArray::getValue('options', $item );
42             echo CHtml::link(CHtml::image($src), $url, $options);
43         }
44         echo CHtml::closeTag('div');
45     }
46 
47     /**
48      * Renders the template
49      */
50     public function renderTemplate()
51     {
52         $options = array(
53             'id' => $this->htmlOptions['id'] . '-carousel',
54             'class' => 'blueimp-gallery blueimp-gallery-carousel'
55         );
56         if($this->displayControls) {
57             TbHtml::addCssClass('blueimp-gallery-controls', $options);
58         }
59         echo CHtml::openTag('div', $options);
60         echo '<div class="slides"></div>
61         <h3 class="title"></h3>
62         <a class="prev">‹</a>
63         <a class="next">›</a>
64         <a class="play-pause"></a>
65         <ol class="indicator"></ol>';
66         echo CHtml::closeTag('div');
67     }
68 
69     /**
70      * Registers the client script
71      */
72     public function registerClientScript()
73     {
74         $this->registerGalleryScriptFiles();
75         $selector = $this->htmlOptions['id'];
76         $options = CJavaScript::encode($this->pluginOptions);
77 
78         $js = ";$('#{$selector} a').hide();blueimp.Gallery($('#{$selector}')[0].getElementsByTagName('a'),{$options});";
79 
80         Yii::app()->clientScript->registerScript(__CLASS__.'#'.$this->getId(), $js);
81     }
82 
83 }
84 
YiiWheels API documentation generated by ApiGen 2.8.0