-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFlexSlider.php
51 lines (33 loc) · 1.03 KB
/
FlexSlider.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
/**
* Created by PhpStorm.
* User: joels
* Date: 21/04/2017
* Time: 12:49 PM
*/
namespace enigmatix\flexSlider;
use yii\base\Widget;
use yii\bootstrap\Html;
class FlexSlider extends Widget
{
public $items = [];
public $item;
public function init() {
parent::init(); // TODO: Change the autogenerated stub
$this->view->registerAssetBundle(FlexSliderAsset::className());
}
public function run() {
$this->view->registerJs('$("#' . $this->id . '").flexslider({controlNav: "thumbnails"})');
return Html::tag('div',$this->slides,['id' => $this->id, 'class' => 'col-sm-12 flexslider']);
}
public function getSlides() {
if($this->item === null){
$item = function($item, $index){
return Html::tag('li', Html::img($item->getViewLink()), ['data-thumb' => $item->getViewLink()]);
};
} else {
$item = $this->item;
}
return Html::ul($this->items, ['class' => 'slides', 'item' => $item]);
}
}