view.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569
  1. <?php
  2. /**
  3. * @var $this \yii\web\View
  4. * @var $model \app\models\front\News
  5. */
  6. use yii\web\View;
  7. use yii\helpers\ArrayHelper;
  8. use app\modules\ldjson\jsonLD;
  9. use yii\web\UrlManager;
  10. use app\models\Authors;
  11. use app\models\base\Image;
  12. use \app\models\news;
  13. use yii\helpers\Url;
  14. /*
  15. $this->registerJsFile('https://platform-api.sharethis.com/js/sharethis.js#property=63ecb32f4a4876001374e328&product=inline-reaction-buttons', [
  16. 'position' => $this::POS_END,
  17. 'async' => 'async',
  18. 'defer' => 'defer'
  19. ]);
  20. */
  21. if( $model->type == 8){
  22. if( $link = trim( $model->link ) ){
  23. $link = str_replace( 'https://www.amic.ru', '', $link);
  24. if( preg_match('/\-(\d+)\/?$/',$link, $a) && isset($a[1]) ){
  25. $tildaid = $a[1];
  26. $file = file_get_contents( Yii::getAlias('@webroot').$link.'meta/inc'.$tildaid.'.json');
  27. $obj = json_decode($file);
  28. $tilda = $obj->html;
  29. echo $this->render('@app/views/news/tilda',['html'=>$tilda,'model'=>$model, 'obj'=>$obj, 'id'=>$tildaid]);
  30. }
  31. return '';
  32. }
  33. }
  34. $preview = $model->image;
  35. $retina = $preview->getUrl(Image::SIZE_1040x586,"jpg");
  36. $normal = $preview->getUrl(Image::SIZE_841x473,"webp");
  37. $bad = $preview->getUrl(Image::SIZE_680x383,'jpg');
  38. $bad = $bad?$bad:'/images/default.jpg';
  39. if( $retina === false || $normal === false ){
  40. $normal = $bad;
  41. $retina = $bad;
  42. }
  43. $normal .= "?v=".$model->rev;
  44. $retina .= "?v=".$model->rev;
  45. $bad .= "?v=".$model->rev;
  46. /*
  47. После этой даты не выводить фото до подтверждения юриста
  48. */
  49. if( isset( $model->dt_pub ) && strtotime( $model->dt_pub ) < strtotime(Yii::$app->params['delPhoto']) ){
  50. $bad = '/images/default.jpg';
  51. $normal = $bad;
  52. $retina = $bad;
  53. };
  54. $txt_date = date( "[Y-m-d] ", strtotime( $model->dt_pub ) );
  55. Yii::$app->og->title =($model->meta_title)?$model->meta_title:$model->title;
  56. Yii::$app->og->description = ($model->lid && trim($model->lid) <> '')?str_replace( '"', "&quot;", strip_tags($model->lid) ):$txt_date.trim(str_replace( '"',"'",substr(strip_tags( $model->text ),0,150)))."...";
  57. if( $model->active == 'N' || $model->dt_pub > date("Y-m-d H:i:s") || $model->noindex == 'Y' ){
  58. Yii::$app->og->noindex = 'Y';
  59. }else{
  60. \Yii::$app->og->canonical = $model->getUrl(true);
  61. \Yii::$app->og->amp = Url::base('https').'/amp/news/'.$model->id;
  62. \Yii::$app->og->og_url = $model->getUrl(true);
  63. \Yii::$app->og->og_image = $model->image->url;
  64. \Yii::$app->og->og_type = "article";
  65. \Yii::$app->og->og_title = htmlspecialchars(($model->meta_title)?strip_tags(str_replace( '"',"&quot;",$model->meta_title)):strip_tags(str_replace( '"',"&quot;",$model->title)));
  66. \Yii::$app->og->og_description = ($model->lid && trim($model->lid) <> '')?str_replace( '"',"&quot;",strip_tags($model->lid)):$txt_date.trim(str_replace( '"',"&quot;",substr(strip_tags( $model->text ),0,150)))."...";
  67. \Yii::$app->og->dtpub = date( "r", strtotime( $model->dt_pub ) );
  68. }
  69. jsonLD::addAmicORG();
  70. jsonLD::news( $model->title, preg_replace('/\s+/', ' ', str_replace( ["\n","\r"],' ',Yii::$app->og->description)), $model->image->url, $model->dt_pub, $model->getUrl(), $model->uid, $model->text, $model->meta_title);
  71. jsonLD::addfaq($model->text, $model->title);
  72. $story = new \app\models\base\Story();
  73. $this->params['breadcrumbs'] = [
  74. [
  75. "text"=>"НОВОСТИ",
  76. "url"=>"/news"
  77. ]
  78. ];
  79. $this->params['context'] = "post-view";
  80. //$topic = ArrayHelper::getValue($model->topics,0);
  81. $topic = Yii::$app->cache->getOrSet('topic-news-'.$model->id, function () use($model){
  82. return $model->getTopics()->andWhere(['show'=>"Y","active"=>1])->orderBy('order asc')->one();
  83. }, News::$keysCache['topic-news-##']);
  84. if($topic instanceof \app\models\base\NewsTopic){
  85. $this->params['breadcrumbs'][] =
  86. [
  87. "text"=>$topic->title,
  88. "url"=>"/news/".mb_strtolower($topic->url)
  89. ];
  90. }
  91. $i = 1;
  92. foreach($this->params['breadcrumbs'] as $el){
  93. jsonLD::addBreadcrumb($i, $el['url'], $el['text']);
  94. $i++;
  95. }
  96. if( $model->show_author == 'Y' )
  97. {
  98. $author = Authors::getAuthor( $model->author );
  99. $authorName = $author->name;
  100. \Yii::$app->og->author =$authorName;
  101. jsonLD::author( $authorName );
  102. }else{
  103. $authorName = 'ИА Амител';
  104. jsonLD::author( $authorName, false );
  105. }
  106. if( strstr( $model->text, 'id="widgetseting"' ) && strstr( $model->text, 'windows="100"' ) ) $model->type = 2; //старый стиль широкой страницы
  107. $GLOBALS['type_long'] = ($model->type == 6); //лонгрид
  108. ?>
  109. <?php if(!is_null($model->embed_url) && $model->embed_url!=''):?>
  110. <div class="row">
  111. <div class="col-md-12 mb-5">
  112. <div class="picture-cont-16x9">
  113. <picture class="w-100 youtube-iframe-placeholder" data-link="<?=$model->getYoutubeEmbedLink()?>">
  114. <source srcset="<?=$preview->getUrl(Image::SIZE_1040x586,"jpg")?>" media="(min-width: 600px)">
  115. <source srcset="<?=$preview->getUrl(Image::SIZE_841x473,"webp")?>" media="(min-width: 600px)">
  116. <source srcset="<?=$preview->getUrl(Image::SIZE_680x383,"webp")?>" media="(min-width: 500px)">
  117. <img src="<?=$preview->getUrl(Image::SIZE_841x473)?>" alt="<?=\yii\helpers\Html::encode($model->photo_title)?>" srcset="<?=$preview->getUrl(Image::SIZE_841x473)?> 841w, <?=$preview->getUrl(Image::SIZE_1040x586)?> 2x, <?=$preview->getUrl(Image::SIZE_680x383,"webp")?> 680w" class="w-100" loading="lazy">
  118. </picture>
  119. </div>
  120. </div>
  121. </div>
  122. <?php endif;?>
  123. <div class="row">
  124. <div class="<?=($model->type == 2 || $model->type == 6)?'col-md-12':'col-md-8'?>">
  125. <div id="post" class="post">
  126. <?
  127. if( Yii::$app->user->can('editor') ){
  128. ?>
  129. <span style="position: absolute;background-color: #a9a9a924;right: 30px;top: 10px; box-shadow: 2px 5px 5px 3px #888;"><img onclick="location='/manager/news/update?id=<?=$model['id']?>'" src="/img/edit.svg" width="25px" height="25px" style="padding:3px;cursor:pointer;"><img onclick="navigator.clipboard.writeText('https://www.amic.ru/news/<?=$model['id']?>');elementPopup(this,'Ссылка скопирована в буфер обмена');" src="/img/share-boxed.svg" width="25px" height="25px" style="padding:3px;margin-top: 2px;cursor:pointer;" ></span>
  130. <?
  131. }
  132. ?>
  133. <?=$this->render("/layouts/breadcrumbs")?>
  134. <h1><?=$model->title?></h1>
  135. <p class="lead"><?=$model->lid?></p>
  136. <p class="published_at"><?=$model->getPublishedNorm()?>, <?=$authorName?> <?= ($model->mark!="" && !is_null($model->mark)) ? \yii\helpers\Html::tag('span', 'erid: '.$model->mark,['class'=>'float-right']) : ""?></p>
  137. <p class="share_and_comment">
  138. <a href="#comments" class="comments_btn">Выскажись!</a>
  139. <a href="https://t.me/+j5mdw3j-2Q5mMWYy">
  140. <svg style="width: 22px;height: 22px; transition: transform 2s ease 3s;" class="icon icon-tg" id="btn-tg-rotate"><use xlink:href="/svg/symbol/sprite-styled.svg#tg"></use></svg>
  141. </a>
  142. <a onclick="Share.vkontakte('<?=Yii::$app->og->og_url?>','<?=addslashes(Yii::$app->og->og_title)?>','<?=Yii::$app->og->og_image?>','<?=str_replace( '"',"&quot; ",Yii::$app->og->og_description)?>')" href="#">
  143. <svg class="icon icon-vk"><use xlink:href="/svg/symbol/sprite-clear.svg#vk"></use></svg>
  144. </a>
  145. <a onclick="Share.odnoklassniki('<?=Yii::$app->og->og_url?>','<?=addslashes(Yii::$app->og->og_title)?>','<?=Yii::$app->og->og_image?>','<?=str_replace( '"',"&quot; ",Yii::$app->og->og_description)?>')" href="#">
  146. <svg class="icon icon-ok"><use xlink:href="/svg/symbol/sprite-clear.svg#ok"></use></svg>
  147. </a>
  148. <a onclick="navigator.clipboard.writeText('<?=Yii::$app->og->og_url?>'); elementPopup(this,'Ссылка скопирована в буфер обмена')" class="copy-link" href="#">
  149. <svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 8 8">
  150. <use href="/img/share-boxed.svg#share"></use>
  151. </svg>
  152. </a>
  153. </p>
  154. <p>
  155. <?php if($model->photo_include == 'Y' && $model->image instanceof \app\models\base\Image):?>
  156. <div class="picture-cont-16x9">
  157. <picture class="w-100">
  158. <source srcset="<?=$normal?>, <?=$retina?> 2x" media="(min-width: 600px)">
  159. <img src="<?=$bad?>" alt="<?=htmlentities($model->photo_title,ENT_QUOTES)?>" srcset="<?=$normal?>, <?=$retina?> x2" title="<?=htmlentities($model->photo_title,ENT_QUOTES)?>" class="w-100">
  160. </picture>
  161. </div>
  162. <div class="image-title"><?=$model->photo_title?></div>
  163. <?php endif;?>
  164. </p>
  165. <section class="text">
  166. <?=$model->renderBody()?>
  167. <?=($model->inscription == 2)?'<span class="advertisement">Реклама</span>':''?>
  168. <?=($model->inscription == 1)?'<span class="advertisement">Реклама</span><br><span class="med_advertisement">Имеются противопоказания, необходима консультация специалиста</span>':''?>
  169. <?=($model->inscription == 3)?'<span class="advertisement">Партнёр amic.ru</span>':''?>
  170. </section>
  171. <?php
  172. echo $this->render("@app/views/news/view/tags",["model"=>$model]);
  173. if(Yii::$app->deviceDetect->isMobile()){
  174. echo $this->render("@app/views/_etc/banners/BannersPostNews");
  175. }
  176. ?>
  177. <section class="share-this">
  178. <?=$this->render("@app/views/reaction-buttons/button",["id"=>$model->id,"type"=>'news']);?><div id="ok_shareWidget" style="display: inline;"></div>
  179. <div style="clear: both;"></div>
  180. </section>
  181. <?
  182. // Временно ок для конкурса
  183. ?>
  184. <script>
  185. !function (d, id, did, st, title, description, image) {
  186. function init(){
  187. OK.CONNECT.insertShareWidget(id,did,st, title, description, image);
  188. }
  189. if (!window.OK || !OK.CONNECT || !OK.CONNECT.insertShareWidget) {
  190. var js = d.createElement("script");
  191. js.src = "https://connect.ok.ru/connect.js";
  192. js.onload = js.onreadystatechange = function () {
  193. if (!this.readyState || this.readyState == "loaded" || this.readyState == "complete") {
  194. if (!this.executed) {
  195. this.executed = true;
  196. setTimeout(init, 0);
  197. }
  198. }};
  199. d.documentElement.appendChild(js);
  200. } else {
  201. init();
  202. }
  203. }(document,"ok_shareWidget",document.URL,'{"sz":30,"st":"oval","ck":1,"bgclr":"ED8207","txclr":"FFFFFF"}',"","","");
  204. </script>
  205. <?
  206. $stn = $story->getForNews($model->id);
  207. if( count($stn) > 0 ){
  208. echo $this->render("@app/views/news/view/story",["model"=>$stn, "id"=>$model->id]);
  209. foreach( $stn as $a ){
  210. jsonLD::story( trim( stripslashes( $a['title'] ) ) );
  211. }
  212. }
  213. ?>
  214. <?php if(Yii::$app->deviceDetect->isMobile()): ?>
  215. <section style="height: 300px;">
  216. <?=$this->render('@app/views/_etc/banners/bannerMobile3')?>
  217. </section>
  218. <?php else:?>
  219. <section style="height: 100px;">
  220. <?=$this->render('@app/views/_etc/banners/transparant5')?>
  221. </section>
  222. <?php endif;?>
  223. <section class="comments" id="comments">
  224. <?=$this->render("view/comments/list",["model"=>$model])?>
  225. </section>
  226. </div>
  227. </div>
  228. <script>
  229. (function (){
  230. let main_view_cont = document.getElementById('post');
  231. let height = main_view_cont.offsetHeight;
  232. console.log(height)
  233. let style = document.createElement("style");
  234. style.innerHTML = "#lenta-container{ max-height:"+height+"px;}";
  235. main_view_cont.parentNode.append(style);
  236. })()
  237. </script>
  238. <div class="<?=($model->type == 2 || $model->type == 6)?'hidden':'col-md-4'?>" id="lenta-container">
  239. <?=$this->render("/layouts/lenta/lenta_right")?>
  240. </div>
  241. <div class="col-md-12">
  242. <h3 class="mt-3" style="font-family: Helvetica,Arial,sans-serif;
  243. font-size: 20px;
  244. font-weight: 700;
  245. line-height: 24px;
  246. color: #373e44;
  247. padding-bottom: 12px;
  248. padding-top: 12px;">Новости партнеров</h3>
  249. <?//=$this->render('@app/views/_etc/banners/partnermetrics')?>
  250. <div id="ferst_partner_block"></div>
  251. <?/*
  252. <?=$this->render('@app/views/_etc/banners/partner3D')?>
  253. <?=$this->render('@app/views/_etc/banners/partner2D')?>
  254. <?=$this->render('@app/views/_etc/banners/partner1D')?>
  255. */?>
  256. <?php
  257. if(Yii::$app->deviceDetect->isMobile()){
  258. echo $this->render('@app/views/_etc/banners/moevideo');
  259. }
  260. ?>
  261. </div>
  262. <div class="col-md-12" id="infinity_newsfeed">
  263. <?=$this->render("view/infinity_newsfeed",['model'=>$model])?>
  264. </div>
  265. <div id="main-carousel" class="splide"></div>
  266. </div>
  267. <?php
  268. if( strpos( $model->text, 'class="InviewElement' ) !== false ){
  269. echo $this->render('view/inview');
  270. }
  271. ?>
  272. <?php
  273. $this->registerJsFile("/js/splide/dist/js/splide.min.js");
  274. $this->registerCssFile("/js/splide/dist/css/splide.min.css")
  275. ?>
  276. <script>
  277. var intersectionObserver = new IntersectionObserver(function(entries) {
  278. if (entries[0].intersectionRatio <= 0 || $(entries[0].target).html().length > 10 ) return;
  279. <?$code = $this->render('@app/views/_etc/banners/mytarget')?>
  280. <?$code .= $this->render('@app/views/_etc/banners/partner3D')?>
  281. <?$code .= $this->render('@app/views/_etc/banners/partner2D')?>
  282. <?$code .= $this->render('@app/views/_etc/banners/partner1D')?>
  283. <?$code .= $this->render('@app/views/_etc/banners/partner4D')?>
  284. var code = <?=json_encode($code)?>;
  285. $(entries[0].target).html(code);
  286. console.log('загрузить партнёрский блок');
  287. });
  288. (function (){
  289. var btntg = document.getElementById("btn-tg-rotate");
  290. btntg.style.transform = 'rotate(720deg)';
  291. intersectionObserver.observe(document.querySelector('#ferst_partner_block'));
  292. var gallery = document.getElementById("gallery-0");
  293. g = Array.from(document.getElementsByClassName('gallery'));
  294. g.forEach( (gallery) =>{ console.log(gallery);
  295. if(gallery!==null && !gallery.classList.contains("splide")) {
  296. var wrapper = document.createElement("div");
  297. wrapper.classList.add('gallery-wrapper')
  298. gallery.parentNode.insertBefore(wrapper, gallery)
  299. wrapper.append(gallery)
  300. var gallery_items = gallery.getElementsByTagName("img");
  301. var track = document.createElement("div");
  302. var list = document.createElement('ul');
  303. gallery.classList.add("splide")
  304. list.classList.add("splide__list")
  305. track.classList.add("splide__track")
  306. gallery.prepend(track)
  307. track.prepend(list)
  308. for (var i = 0; i < gallery_items.length; i++) {
  309. var img = gallery_items[i];
  310. var img_cont = document.createElement('li')
  311. img_cont.classList.add("splide__slide")
  312. img_cont.append(img)
  313. list.append(img_cont)
  314. }
  315. var main_view = document.createElement("div")
  316. main_view.classList.add("splide", "gallery-view");
  317. main_view.innerHTML = gallery.innerHTML;
  318. gallery.style.paddingBottom = "18px";
  319. gallery.style.marginBottom = 0;
  320. wrapper.prepend(main_view)
  321. }});
  322. document.addEventListener( 'DOMContentLoaded', function () {
  323. //return true;
  324. const galleries = document.querySelectorAll('.gallery-view');
  325. if(galleries.length>0){
  326. for (let i=0; i < galleries.length; i++){
  327. let element = galleries[i];
  328. if(element !== null){
  329. var main = new Splide(element, {
  330. type : 'fade',
  331. rewind : true,
  332. pagination: false,
  333. arrows : true,
  334. speed: 1000
  335. } );
  336. var thumbnails =new Splide( element.parentNode.querySelector('.gallery'), {
  337. fixedWidth: 100,
  338. fixedHeight: 60,
  339. gap : 10,
  340. rewind : true,
  341. pagination: false,
  342. isNavigation: true,
  343. arrows : false,
  344. } );
  345. main.sync( thumbnails );
  346. main.mount();
  347. thumbnails.mount();
  348. }
  349. }
  350. }
  351. if(document.querySelector('.gallery-view') !== null){
  352. // var main = new Splide( '.gallery-view', {
  353. // type : 'fade',
  354. // rewind : true,
  355. // pagination: false,
  356. // arrows : true,
  357. // speed: 1000
  358. // } );
  359. // var thumbnails =new Splide( '.gallery', {
  360. // fixedWidth: 100,
  361. // fixedHeight: 60,
  362. // gap : 10,
  363. // rewind : true,
  364. // pagination: false,
  365. // isNavigation: true,
  366. // arrows : false,
  367. // } );
  368. //
  369. // main.sync( thumbnails );
  370. // main.mount();
  371. // thumbnails.mount();
  372. }
  373. let fullscreenBtn = null;
  374. let gallery_wrappers = document.querySelectorAll('.gallery-wrapper');
  375. for (let i = 0; i < gallery_wrappers.length; i++) {
  376. fullscreenBtn = document.createElement('div');
  377. fullscreenBtn.classList.add('fullscreenButton');
  378. gallery_wrappers[i].append(fullscreenBtn)
  379. fullscreenBtn.onclick = function (){
  380. gallery_wrappers[i].classList.toggle('fullscreen')
  381. gallery_wrappers[i].querySelectorAll('.gallery-view img').forEach(function (elem) {
  382. elem.setAttribute('src', elem.dataset.original);
  383. })
  384. }
  385. }
  386. } );
  387. })()
  388. </script>
  389. <script>
  390. Share = {
  391. vkontakte: function(purl, ptitle, pimg, text) {
  392. url = 'https://vkontakte.ru/share.php?';
  393. url += 'url=' + encodeURIComponent(purl);
  394. url += '&title=' + encodeURIComponent(ptitle);
  395. url += '&description=' + encodeURIComponent(text);
  396. url += '&image=' + encodeURIComponent(pimg);
  397. url += '&noparse=true';
  398. Share.popup(url);
  399. },
  400. odnoklassniki: function(purl, text) {
  401. //url = 'https://www.odnoklassniki.ru/dk?st.cmd=addShare&st.s=1';
  402. url = 'https://connect.ok.ru/offer?';
  403. url += '&st.comments=' + encodeURIComponent(text);
  404. url += '&url=' + encodeURIComponent(purl);
  405. Share.popup(url);
  406. },
  407. facebook: function(purl, ptitle, pimg, text) {
  408. url = 'http://www.facebook.com/sharer.php?s=100';
  409. url += '&p[title]=' + encodeURIComponent(ptitle);
  410. url += '&p[summary]=' + encodeURIComponent(text);
  411. url += '&p[url]=' + encodeURIComponent(purl);
  412. url += '&p[images][0]=' + encodeURIComponent(pimg);
  413. Share.popup(url);
  414. },
  415. twitter: function(purl, ptitle) {
  416. url = 'https://twitter.com/share?';
  417. url += 'text=' + encodeURIComponent(ptitle);
  418. url += '&url=' + encodeURIComponent(purl);
  419. url += '&counturl=' + encodeURIComponent(purl);
  420. Share.popup(url);
  421. },
  422. mailru: function(purl, ptitle, pimg, text) {
  423. url = 'http://connect.mail.ru/share?';
  424. url += 'url=' + encodeURIComponent(purl);
  425. url += '&title=' + encodeURIComponent(ptitle);
  426. url += '&description=' + encodeURIComponent(text);
  427. url += '&imageurl=' + encodeURIComponent(pimg);
  428. Share.popup(url)
  429. },
  430. popup: function(url) {
  431. window.open(url,'','toolbar=0,status=0,width=626,height=436');
  432. }
  433. };
  434. const elementPopup = function (element, text)
  435. {
  436. console.log(element)
  437. const positionY = element.offsetTop;
  438. const positionX = element.offsetLeft;
  439. let popup = document.createElement("div")
  440. popup.style.position = 'absolute';
  441. popup.style.top = (positionY - 35) + 'px';
  442. popup.style.left = positionX + "px";
  443. popup.style.color = "white";
  444. popup.style.background = "#00000052";
  445. popup.style.borderRadius = "5px";
  446. popup.style.padding = "1px 20px";
  447. popup.style.opacity = "1";
  448. popup.style.transition = "0.3s";
  449. popup.innerHTML = text
  450. popup.classList.add('element-popup')
  451. element.parentNode.append(popup)
  452. setTimeout(function (){
  453. popup.style.opacity=0
  454. console.log(popup.style.transition)
  455. },3000)
  456. }
  457. </script>
  458. <?php if($model->mark!="" && !is_null($model->mark) && is_null(\Yii::$app->request->get('erid'))):?>
  459. <script>
  460. (function (){
  461. const url = new URL(location.href);
  462. url.searchParams.append('erid','<?=$model->mark?>')
  463. window.history.pushState({},'',url);
  464. })()
  465. </script>
  466. <?php endif;?>
  467. <script>
  468. (function (){
  469. const placeholders = document.getElementsByClassName('youtube-iframe-placeholder');
  470. if(placeholders.length>0){
  471. for(let i =0;i<placeholders.length;i++){
  472. placeholders[i].onclick = function (){
  473. const waiting = document.createElement("div");
  474. waiting.style.position = "absolute";
  475. waiting.style.width = "100%";
  476. waiting.style.height = "100%";
  477. waiting.style.background = "url('/img/loading.gif')";
  478. waiting.style.backgroundPosition = "center";
  479. waiting.style.backgroundRepeat = "no-repeat";
  480. waiting.style.backgroundSize = "contain";
  481. waiting.style.zIndex = 1;
  482. this.replaceWith(waiting);
  483. const iframe = document.createElement("iframe");
  484. iframe.src = this.dataset.link+"?autoplay=1";
  485. iframe.style.position = "absolute";
  486. iframe.style.zIndex = 2;
  487. iframe.width = "100%";
  488. iframe.height = "100%";
  489. iframe.title = "video player";
  490. iframe.frameBorder = "0";
  491. iframe.allow = "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture";
  492. iframe.allowFullscreen = true;
  493. waiting.parentNode.append(iframe);
  494. addEventListener("click", (e) => {
  495. var target = e.target || e.srcElement;
  496. if (target.tagName === 'A') {
  497. href = target.getAttribute('href');
  498. $(target).attr('target', '_blank');
  499. }
  500. });
  501. }
  502. }
  503. }
  504. })()
  505. </script>
  506. <?
  507. // загрузить fotorama.js если есть тригер
  508. $c = Yii::$app->acache;
  509. if( $c->get('fotorama') === true || 1){
  510. $this->registerJsFile(
  511. '@web/js/fotorama/fotorama.js',
  512. [
  513. 'depends' => [\yii\web\JqueryAsset::class],
  514. 'defer' =>true,
  515. 'position' => View::POS_END
  516. ],
  517. 'js-fotorama'
  518. );
  519. $this->registerCssFile("@web/js/fotorama/fotorama.css", [], 'css-fotorama');
  520. }
  521. /*
  522. if( Yii::$app->deviceDetect->isMobile() ){
  523. $this->registerJs(
  524. <<<JS
  525. $(function () {
  526. loadScript( 'https://platform-api.sharethis.com/js/sharethis.js#property=63ecb32f4a4876001374e328&product=inline-reaction-buttons', 8000 );
  527. });
  528. JS
  529. ,
  530. $this::POS_READY,
  531. 'sharethis'
  532. );
  533. }else{
  534. $this->registerJs(
  535. <<<JS
  536. $(function () {
  537. loadScript( 'https://platform-api.sharethis.com/js/sharethis.js#property=63ecb32f4a4876001374e328&product=inline-reaction-buttons', 100 );
  538. });
  539. JS
  540. ,
  541. $this::POS_READY,
  542. 'sharethis'
  543. );
  544. }
  545. */