view.php 25 KB

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