MediaWiki:Mobile.js: відмінності між версіями

Матеріал з WikiLegalAid
Немає опису редагування
мНемає опису редагування
Рядок 1: Рядок 1:
/* Усі JavaScript тут будуть завантажені для користувачів мобільного сайту */
/* Усі JavaScript тут будуть завантажені для користувачів мобільного сайту */
console.log("Mobile.js script loaded");
mw.loader.using('mobile.startup', function () {
mw.loader.using('mobile.startup', function () {
     mw.hook('wikipage.content').add(function ($content) {
     mw.hook('wikipage.content').add(function ($content) {
Рядок 8: Рядок 9:
                       '</div>';
                       '</div>';


         $content.find('.section-heading').each(function () {
         $content.find('section').each(function () {
            const $section = $(this).closest('section');
      const $section = $(this);
      const $heading = $section.find('h2, h3').first();
      const $contentBlock = $section.find('.content').first();


           
            $section.removeClass('collapsed');
            $section.addClass('expanded');
            $section.find('.content-block').show();


            $section.after(adHtml);
      $section.removeClass('collapsed');
      $section.addClass('expanded');
 
 
      $contentBlock.show();
 
 
      $section.after(adHtml);
         });
         });
     });
     });
});
});

Версія за 08:55, 12 травня 2025

/* Усі JavaScript тут будуть завантажені для користувачів мобільного сайту */
console.log("Mobile.js script loaded");
mw.loader.using('mobile.startup', function () {
    mw.hook('wikipage.content').add(function ($content) {
        // HTML вміст рекламного блоку (заміни на свій код)
        const adHtml = '<div class="ad-block" style="margin: 20px 0; text-align: center;">' +
                       '<ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-9946719691242357" data-ad-format="auto"></ins>' +
                       '<script>(adsbygoogle = window.adsbygoogle || []).push({});</script>' +
                       '</div>';

        $content.find('section').each(function () {
      const $section = $(this);
      const $heading = $section.find('h2, h3').first();
      const $contentBlock = $section.find('.content').first();


      $section.removeClass('collapsed');
      $section.addClass('expanded');


      $contentBlock.show();


      $section.after(adHtml);
        });
    });
});