Commit 1b06762d353879efe754d967d5f64454db0531f2

Authored by Anastasia
1 parent 5f694714

- events

- background in slider
common/models/event/Tag.php
@@ -116,7 +116,7 @@ @@ -116,7 +116,7 @@
116 /** 116 /**
117 * @return \yii\db\ActiveQuery 117 * @return \yii\db\ActiveQuery
118 */ 118 */
119 - public function getArticles() 119 + public function getEvents()
120 { 120 {
121 return $this->hasMany(Event::className(), [ 'id' => 'event_id' ]) 121 return $this->hasMany(Event::className(), [ 'id' => 'event_id' ])
122 ->viaTable('event_to_tag', [ 'event_tag_id' => 'id' ]); 122 ->viaTable('event_to_tag', [ 'event_tag_id' => 'id' ]);
frontend/controllers/EventController.php
@@ -98,7 +98,7 @@ @@ -98,7 +98,7 @@
98 ) 98 )
99 ->with( 99 ->with(
100 [ 100 [
101 - 'articles', 101 + 'events',
102 ] 102 ]
103 ) 103 )
104 ->one(); 104 ->one();
frontend/views/site/index.php
@@ -16,7 +16,7 @@ @@ -16,7 +16,7 @@
16 <!-- *** HOMEPAGE CAROUSEL *** 16 <!-- *** HOMEPAGE CAROUSEL ***
17 _________________________________________________________ --> 17 _________________________________________________________ -->
18 18
19 - <div class="home-carousel"> 19 + <div class="home-carousel" <?=$slides[0]->background !== null ? ' style="background: url('.$slides[0]->background->getUrl().') center center repeat;"' : ''?>>
20 20
21 <div class="dark-mask"></div> 21 <div class="dark-mask"></div>
22 22
@@ -25,7 +25,7 @@ _________________________________________________________ --&gt; @@ -25,7 +25,7 @@ _________________________________________________________ --&gt;
25 25
26 <?php foreach ($slides as $key => $slide){?> 26 <?php foreach ($slides as $key => $slide){?>
27 27
28 - <div class="item"> 28 + <div class="item" data-bg=<?=($slide->background !== null) ? $slide->background->getUrl() : ''?>>
29 <div class="row"> 29 <div class="row">
30 <div class="col-sm-5 <?=($key%2 == 0) ? 'right' : ''?>"> 30 <div class="col-sm-5 <?=($key%2 == 0) ? 'right' : ''?>">
31 <h1><?=$slide->title?></h1> 31 <h1><?=$slide->title?></h1>
frontend/web/js/front.js
@@ -119,8 +119,14 @@ function sliders() { @@ -119,8 +119,14 @@ function sliders() {
119 //animationsSlider(); 119 //animationsSlider();
120 console.log('init'); 120 console.log('init');
121 }, 121 },
122 - afterMove: function () { 122 + afterMove: function (elem) {
123 //animationsSlider(); 123 //animationsSlider();
  124 + var bg = $(elem).children('.owl-wrapper-outer').children().find('.active').find('.item').data('bg');
  125 + if (bg != ''){
  126 + $(elem).parent().parent().css("background", 'url('+bg+') center center repeat');
  127 + }else{
  128 + $(elem).parent().parent().css('background', 'url(../img/photogrid.jpg) center center repeat');
  129 + }
124 console.log('move'); 130 console.log('move');
125 } 131 }
126 }); 132 });