-
Notifications
You must be signed in to change notification settings - Fork 0
/
FeatherlightGallery.php
37 lines (30 loc) · 972 Bytes
/
FeatherlightGallery.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
<?php
/**
* Project nv-tmn.
* User: andrew
* Date: 23.07.15
* Time: 9:43
*/
namespace andrew72ru\featherlight;
use yii\base\Widget;
use yii\helpers\Html;
use yii\helpers\ArrayHelper;
use yii\web\View;
class FeatherlightGallery extends Widget
{
public $items = [];
public $previewOptions = [];
public $sectionOptions = [];
public function init()
{
FeatherlightGalleryAsset::register($this->view);
$this->view->registerJs("$('section.flight-gallery a').featherlightGallery({previousIcon: '◀', nextIcon: '▶', galleryFadeIn: 100, galleryFadeOut: 300})", View::POS_READY);
}
public function run()
{
$innerHtml = [];
foreach ($this->items as $item)
$innerHtml[] = Html::a(Html::img($item['src'], $this->previewOptions), $item['url']);
return Html::tag('section', implode('', $innerHtml), ArrayHelper::merge(['class' => 'flight-gallery'], $this->sectionOptions));
}
}