Blame view

common/widgets/views/youtube_field.php 2.87 KB
eb7e82fb   Administrator   29.02.16
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
  <?php

      use yii\helpers\Html;

  

  ?>

  <fieldset>

  

  

      <div class="field_list">

  

  

      <?php $t = 0;

      $label = 0; // add this var

          for($i = 1; $i <= count($model); $i++):

              $row = $i;

  

              ?>

  

              <?= Html::beginTag('div', [

              'class' => 'form-group',

              'id'    => isset( $model[ $i ][ 'parent_key' ] ) ? $model[ $i ][ 'parent_key' ] : 0,

          ]) ?>

          <div class="input-blocks">

              <label for="iframe_youtube-<?= ++$label ?>">Youtube</label>

9fd076e8   Administrator   01.03.16
24
              <input id="iframe_youtube-<?= $label  ?>" type="text" placeholder="iframe" class="form-control custom-input-2" value='<?= isset( $model[ $t ][ 'value' ] ) ? '<iframe width="560" height="315" src="'.$model[ $t ][ 'value' ].'" frameborder="0" allowfullscreen></iframe>' : '' ?>' name="Fields[youtube][<?= $row ?>][0][youtube]"/>

eb7e82fb   Administrator   29.02.16
25
          </div>

06ec2844   Administrator   28.03.16
26
              <span data-id="<?= isset( $model[ $i ][ 'parent_key' ] ) ? $model[ $i ][ 'parent_key' ] : 0 ?>" title="<?= Yii::t('app','add') ?>" class="glyphicon glyphicon-trash delete-field-item"></span>

eb7e82fb   Administrator   29.02.16
27
28
29
30
              <?= Html::endTag('div') ?>

              <?php $i = ++$t; ?>

          <?php endfor; ?>

      </div>

c7dc4dbd   Administrator   28.03.16
31
      <p class="btn btn-success add_field_<?= $this->context->id ?>"><?= Yii::t('app', 'add_field') ?></p>

eb7e82fb   Administrator   29.02.16
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
  

  </fieldset>

  <script>

      var start_i_<?=$this->context->id?> = <?=$i?>;

      var start_label_<?=$this->context->id?> = <?=$label?>; // add this var

      $ (document)

          .ready (

              function ()

              {

                  $ ('.add_field_<?=$this->context->id?>')

                      .click (

                          function ()

                          {

                              var block     = $ (this)

                                  .siblings('.field_list');

                              var block_id  = $ (this)

                                  .parent ('fieldset');

                              var sub_block = '<div class="form-group" >' +

                                              '<div class="input-blocks">'+

                                              '<label for="iframe_youtube-' + ++start_label_<?=$this->context->id?> +'">Youtube</label>'+

                                              '<input id="iframe_youtube-' + start_label_<?=$this->context->id?> +'" type="text" placeholder="iframe" class="form-control custom-input-2" value="" name="Fields[youtube][' + start_i_<?=$this->context->id?>++ + '][0][youtube]" />' +

                                              '</div>'+

06ec2844   Administrator   28.03.16
54
                                              '<span title="<?= Yii::t('app','add') ?>" class="glyphicon glyphicon-trash delete-field-item"></span>' +

eb7e82fb   Administrator   29.02.16
55
56
57
58
59
60
61
62
63
64
                                              '<div>';

  //                            console.log (block);

                              block.append (sub_block);

                          }

                      );

              }

          );

  </script>