Skip to content

Commit e955962

Browse files
committed
carousel block: added Ace editor widget
1 parent 1ea00e7 commit e955962

File tree

4 files changed

+23
-16
lines changed

4 files changed

+23
-16
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"nullref/yii2-useful": "dev-master",
1515
"nullref/yii2-core": "dev-master",
1616
"nullref/yii2-admin": "dev-master",
17-
"bower-asset/owl.carousel": "2.*"
17+
"bower-asset/owl.carousel": "2.*",
18+
"trntv/yii2-aceeditor": "*"
1819
},
1920
"autoload": {
2021
"psr-4": {

src/blocks/carousel/Block.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
class Block extends BaseBlock
1010
{
1111
public $content;
12-
public $tag = 'div';
13-
public $tagClass = 'container';
14-
public $carouselName = 'cms-slider carousel-slider';
12+
public $sliderWrapperName = 'cms-slider-wrapper';
13+
public $defaultSliderName = 'cms-slider';
14+
public $carouselId = 'carousel-slider';
1515

1616
public function getName()
1717
{
@@ -21,7 +21,7 @@ public function getName()
2121
public function rules()
2222
{
2323
return [
24-
[['content','tag','tagClass', 'carouselName'],'required'],
24+
[['content','sliderWrapperName', 'defaultSliderName', 'carouselId'],'required'],
2525
];
2626
}
2727

src/blocks/carousel/Widget.php

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,21 @@
77

88
use nullref\cms\blocks\text\Widget as BaseWidget;
99
use yii\helpers\Html;
10-
use sersid\owlcarousel\Asset;
10+
use nullref\cms\assets\owlCarousel\OwlCarousel2;
1111

1212

1313
class Widget extends BaseWidget
1414
{
15-
public $carouselName;
15+
public $sliderWrapperName;
16+
public $defaultSliderName;
17+
public $carouselId;
18+
1619
public function run()
1720
{
18-
Asset::register($this->view);
21+
OwlCarousel2::register($this->view);
1922
$this->view->registerJs(<<<JS
2023
jQuery(function(){
21-
var selector = "."+"$this->carouselName";
24+
var selector = "#"+"$this->carouselId";
2225
jQuery(selector).owlCarousel({
2326
loop:true,
2427
center: true,
@@ -28,12 +31,15 @@ public function run()
2831
});
2932
});
3033
JS
31-
);
34+
);
3235

3336
return
34-
Html::beginTag($this->tag, ['class' => $this->tagClass]) .
35-
Html::beginTag('div', ['class' => $this->carouselName]) .
36-
$this->content.
37+
Html::beginTag($this->tag, ['class' => $this->sliderWrapperName]) .
38+
Html::beginTag('div', [
39+
'class' => $this->defaultSliderName . ' owl-carousel',
40+
'id' => $this->carouselId
41+
]) .
42+
$this->content .
3743
Html::endTag('div') .
3844
Html::endTag($this->tag);
3945
}

src/blocks/carousel/_form.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,6 @@
4545
],
4646
],
4747
]);
48-
echo $form->field($block, 'tag')->textInput();
49-
echo $form->field($block, 'tagClass')->textInput();
50-
echo $form->field($block, 'carouselName')->textInput();
48+
echo $form->field($block, 'sliderWrapperName')->textInput();
49+
echo $form->field($block, 'defaultSliderName')->textInput();
50+
echo $form->field($block, 'carouselId')->textInput();

0 commit comments

Comments
 (0)