view.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <?php
  2. /**
  3. * @var $this \yii\web\View
  4. * @var $model \app\models\News
  5. */
  6. use yii\helpers\ArrayHelper;
  7. $this->params['breadcrumbs'] = [
  8. [
  9. "text"=>"НОВОСТИ",
  10. "url"=>"/news"
  11. ]
  12. ];
  13. $topic = ArrayHelper::getValue($model->topics,0);
  14. if($topic instanceof \app\models\base\NewsTopic){
  15. $this->params['breadcrumbs'][] =
  16. [
  17. "text"=>$topic->title,
  18. "url"=>mb_strtoupper($topic->url)
  19. ];
  20. }
  21. ?>
  22. <div class="row">
  23. <div class="col-md-8">
  24. <div id="post" class="post">
  25. <?=$this->render("/layouts/breadcrumbs")?>
  26. <h1><?=$model->title?></h1>
  27. <p class="lead"><?=$model->lid?></p>
  28. <p class="published_at"><?=$model->publishedAt?> <?=date("Y, H:m")?></p>
  29. <p>
  30. <?php if($model->image instanceof \app\models\base\Image):?>
  31. <div class="picture-cont-16x9">
  32. <picture class="w-100">
  33. <source srcset="<?=$model->image->url?>" media="(min-width: 600px)">
  34. <img src="<?=$model->image->url?>" alt="<?=$model->photo_title?>" class="w-100">
  35. </picture>
  36. </div>
  37. <div class="image-title"><?=$model->photo_title?></div>
  38. <?php endif;?>
  39. </p>
  40. <section class="text">
  41. <?=$model->renderBody()?>
  42. </section>
  43. </div>
  44. </div>
  45. <script>
  46. (function (){
  47. let main_view_cont = document.getElementById('post');
  48. let height = main_view_cont.offsetHeight;
  49. console.log(height)
  50. let style = document.createElement("style");
  51. style.innerHTML = "#lenta-container{ max-height:"+height+"px;}";
  52. main_view_cont.parentNode.append(style);
  53. })()
  54. </script>
  55. <div class="col-md-4" id="lenta-container">
  56. <?=$this->render("/layouts/lenta/lenta")?>
  57. </div>
  58. <div id="main-carousel" class="splide"></div>
  59. </div>
  60. <?php
  61. $this->registerJsFile("/js/splide/dist/js/splide.min.js");
  62. $this->registerCssFile("/js/splide/dist/css/splide.min.css")
  63. ?>
  64. <script>
  65. var gallery = document.getElementById("gallery-0");
  66. var wrapper = document.createElement("div");
  67. wrapper.classList.add('gallery-wrapper')
  68. gallery.parentNode.insertBefore(wrapper,gallery)
  69. wrapper.append(gallery)
  70. var gallery_items = gallery.getElementsByTagName("img");
  71. var track = document.createElement("div");
  72. var list = document.createElement('ul');
  73. gallery.classList.add("splide")
  74. list.classList.add("splide__list")
  75. track.classList.add("splide__track")
  76. gallery.prepend(track)
  77. track.prepend(list)
  78. for(var i =0; i<gallery_items.length;i++){
  79. var img = gallery_items[i];
  80. var img_cont = document.createElement('li')
  81. img_cont.classList.add("splide__slide")
  82. img_cont.append(img)
  83. list.append(img_cont)
  84. }
  85. var main_view = document.createElement("div")
  86. main_view.classList.add("splide","gallery-view");
  87. main_view.innerHTML=gallery.innerHTML;
  88. wrapper.prepend(main_view)
  89. document.addEventListener( 'DOMContentLoaded', function () {
  90. var main = new Splide( '.gallery-view', {
  91. type : 'fade',
  92. rewind : true,
  93. pagination: false,
  94. arrows : false,
  95. } );
  96. var thumbnails =new Splide( '.gallery', {
  97. fixedWidth: 100,
  98. fixedHeight: 60,
  99. gap : 10,
  100. rewind : true,
  101. pagination: false,
  102. isNavigation: true,
  103. } );
  104. main.sync( thumbnails );
  105. main.mount();
  106. thumbnails.mount();
  107. } );
  108. </script>