Commit 3930107cab10f55a88e4c2d2d402249af3bd638c

Authored by Anastasia
1 parent 44ac74b7

- social button

Showing 1 changed file with 27 additions and 3 deletions   Show diff stats
frontend/views/book/view.php
... ... @@ -5,6 +5,7 @@
5 5 */
6 6 use artbox\core\helpers\ImageHelper;
7 7 use yii\helpers\Url;
  8 + use yii\web\View;
8 9  
9 10 $this->params[ 'breadrumbs'][] = [
10 11 'label' => 'Книги',
... ... @@ -40,6 +41,29 @@
40 41 'type' => 'hiddenInput',
41 42 'options' => ['value' => ''],
42 43 ]];
  44 + $link = \Yii::$app->request->absoluteUrl;
  45 + $js = <<<JS
  46 + var link = "{$link}";
  47 + var title = "{$model->title}";
  48 + $(document).on('click','.facebook_link', function(e) {
  49 + e.preventDefault();
  50 + window.open('http://www.facebook.com/sharer/sharer.php?u='+link);
  51 + });
  52 +
  53 + $(document).on('click','.twitter_link', function(e) {
  54 + e.preventDefault();
  55 + window.open('https://twitter.com/intent/tweet?text='+title+'&url='+link);
  56 + });
  57 +
  58 + $(document).on('click','.google_link', function(e) {
  59 + e.preventDefault();
  60 + window.open('https://plus.google.com/share?url='+link);
  61 + });
  62 +
  63 +JS;
  64 +
  65 +$this->registerJs($js, View::POS_READY);
  66 +
43 67 ?>
44 68  
45 69 <section class="section-card">
... ... @@ -101,9 +125,9 @@
101 125 <p>поділитися в соціальних мережах</p>
102 126 <!--вставлять ссылку на эту страницу сюда {link-this-page}-->
103 127 <ul>
104   - <li class="card-s1"><a target="_blank" rel="nofollow" href="http://www.facebook.com/sharer/sharer.php?u=<?=\Yii::$app->request->absoluteUrl?>"></a></li>
105   - <li class="card-s2"><a target="_blank" rel="nofollow" href="https://twitter.com/intent/tweet?text=Hello%20world&url=<?=\Yii::$app->request->absoluteUrl?>"></a></li>
106   - <li class="card-s3"><a target="_blank" rel="nofollow" href="https://plus.google.com/share?url=<?=\Yii::$app->request->absoluteUrl?>"></a></li>
  128 + <li class="card-s1"><a class="facebook_link" target="_blank" rel="nofollow" href="#"></a></li>
  129 + <li class="card-s2"><a class="twitter_link" target="_blank" rel="nofollow" href="#"></a></li>
  130 + <li class="card-s3"><a class="google_link" target="_blank" rel="nofollow" href="#"></a></li>
107 131 </ul>
108 132 </div>
109 133 </div>
... ...