Иконка ресурса

Модуль Анимированные аватарки [RE] [gif_avatar] 1.1

Нет прав для скачивания
Немного дополненная версия модуля Анимированные аватарки [gif_avatar], которая включает в себя покупку доступа по тарифному плану. Тарифы создаются в Админ-центре.

Вывести кнопку в настройки профиля:
JavaScript:
<div id="gif_avatar_info"></div>
<script>
 $(function () {
    gif_avatar_info();
        });
    </script>

Так же код для модального окна:

HTML:
<div class="modal fade" id="tariffListModal" tabindex="-1" role="dialog" aria-labelledby="tariffListLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title" id="tariffListLabel">Выберите тариф</h4>
                <button type="button" class="close" data-dismiss="modal" aria-label="Закрыть">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <p>Выберите подходящий тариф для получения доступа к GIF-аватарам:</p>

                <div id="tariff-options" class="d-flex flex-column gap-2">
                    <?php
                    $tariffs = pdo()->query("SELECT id,title,price,duration_days,button_class FROM gif_avatar__tariffs WHERE is_active=1 ORDER BY sort_order")->fetchAll(PDO::FETCH_OBJ);
                 
                    if (!empty($tariffs)) {
                        foreach($tariffs as $t){
                            $d = $t->duration_days == 0 ? 'Навсегда' : $t->duration_days.' дн.';
                            $c = $t->button_class ?: 'btn-outline-primary';
                            $price_formatted = number_format($t->price, 2);
                            echo "<button class=\"btn $c btn-block\" onclick=\"buy_gif_avatar({$t->id})\">
                                    {$t->title} — {$price_formatted} руб. ({$d})
                                  </button>";
                        }
                    } else {
                        echo '<p class="text-danger">Тарифы пока не добавлены администратором.</p>';
                    }
                    ?>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Закрыть</button>
            </div>
        </div>
    </div>
</div>
Заменить url на этот:
../modules_extra/gif_avatar/ajax/actions.php на странице settings.tpl.

Для новой версии движка (3.683+):

Полностью замените блок "Редактирование аватара" на этот код :​

​

/templates/standart/tpl/home/settings.tpl:
            <div class="block">
    <div class="block_head">
        Редактирование аватара
    </div>
    <div class="row">
        <div class="col-4">
            <img id="avatar" src="{avatar}?v={cache}" class="w-100 mb-1">
        </div>
        <div class="col-8">
            <form enctype="multipart/form-data" id="edit_user_avatar_form">
                <input type="hidden" id="token" name="token" value="{token}">
                <input type="hidden" id="edit_user_avatar" name="edit_user_avatar" value="1">
                <input type="hidden" id="phpaction" name="phpaction" value="1">
                <input type="file" id="user_avatar" accept="image/*" name="user_avatar"/>
                <input class="btn btn-outline-primary" type="submit" value="Загрузить">
                <div id="edit_user_avatar_result"></div>
            </form>

            <div id="gif_avatar_info"></div>
            <button class="btn btn-outline-primary mt-2" onclick="showGifListModal()" id="gif_gallery_btn">
                <i class="fa fa-images"></i> Готовые GIF
            </button>
        </div>
    </div>
</div>

<script>
  function gifModuleExists() {
    try {
      var xhr = new XMLHttpRequest();
      xhr.open('HEAD', '../modules_extra/gif_avatar/ajax/actions.php', false);
      xhr.send();
      return xhr.status === 200;
    } catch(e) {
      return false;
    }
  }

  if (gifModuleExists()) {
    var scripts = [
      '../modules_extra/gif_avatar/js/ajax.js',
      '../modules_extra/gif_avatar/js/other.js'
    ];
   
    scripts.forEach(function(src) {
      var script = document.createElement('script');
      script.src = src;
      document.head.appendChild(script);
    });
   
    setTimeout(function() {
      if (typeof loadGifAvatarInfo === 'function') {
        loadGifAvatarInfo();
      }
    }, 500);
  } else {
    $('#gif_gallery_btn').hide();
  }
 
  $(document).on('submit', '#edit_user_avatar_form', function (event) {
    NProgress.start();
    event.preventDefault();
    var data = new FormData(this);
    var url = '../modules_extra/gif_avatar/ajax/actions.php';

    try {
      var xhr = new XMLHttpRequest();
      xhr.open('HEAD', url, false);
      xhr.send();
      if (xhr.status !== 200) {
        url = 'ajax/actions_a.php';
      }
    } catch(e) {
      url = 'ajax/actions_a.php';
    }
   
    $.ajax({
      type: "POST",
      url: url,
      data: data,
      contentType: false,
      processData: false,
    }).done(function (html) {
      $("#edit_user_avatar_result").empty();
      $("#edit_user_avatar_result").append(html);
      $('#edit_user_avatar_form')[0].reset();
   
      var avatarImg = document.getElementById('avatar');
      if (avatarImg) {
        var src = avatarImg.src.split('?')[0];
        avatarImg.src = src + '?v=' + new Date().getTime();
      }
     
      if (typeof loadGifAvatarInfo === 'function') {
        setTimeout(loadGifAvatarInfo, 1000);
      }
    }).always(function() {
      NProgress.done();
    });
  });
</script>


1763260408067.png

1763260433148.png

1763260542257.png

1763260567482.png

1763260621609.png

1763260642442.png

1763260760759.png

1763260785142.png

1763260812965.png
  • Лайк!
Реакции: rustickjan и Rodya
Автор
parliament
Скачивания
24
Просмотры
1 434
Первый выпуск
Обновление
Оценка
0,00 звёзд 0 оценок

Другие ресурсы пользователя parliament

Поделиться ресурсом

Последние обновления

  1. #1.1

    Исправление ошибок. Добавлена возможность загрузить свои GIF для выбора пользователям. На...
  2. #1.0

    Ресурс более недоступен. Установка модуля доступна только через модуль...
  3. #1.0 RE

    Выгрузка в ресурсы. Адаптация под новую версию движка производится индивидуально.
Сверху Снизу