6369
редагувань
Admin (обговорення | внесок) Немає опису редагування |
Admin (обговорення | внесок) Немає опису редагування |
||
| Рядок 1: | Рядок 1: | ||
// ============================================================ | // ============================================================ | ||
// MediaWiki:Common.js — Mafia Closed Circle | // MediaWiki:Common.js — Mafia Closed Circle — ФІНАЛЬНА ВЕРСІЯ | ||
// ============================================================ | // ============================================================ | ||
| Рядок 11: | Рядок 10: | ||
$.getJSON(apiUrl, { | $.getJSON(apiUrl, { | ||
action: 'query', format: 'json', list: 'random', | action: 'query', format: 'json', list: 'random', | ||
rnnamespace: '0', rnlimit: '5' | rnnamespace: '0', rnlimit: '5' | ||
}, function (data) { | }, function (data) { | ||
var html = ''; | var html = ''; | ||
$.each(data.query.random, function (i, article) { | $.each(data.query.random, function (i, article) { | ||
html += '<div class="random-article-preview"> | html += '<div class="random-article-preview"><h2><a href="/wiki/' | ||
+ encodeURIComponent(article.title) + '">' + article.title + '</a></h2></div>'; | |||
}); | }); | ||
$('#random-articles-container').html(html); | $('#random-articles-container').html(html); | ||
| Рядок 26: | Рядок 23: | ||
// ============================================================ | // ============================================================ | ||
// 2. L-BOX NAVIGATION | // 2. L-BOX NAVIGATION | ||
// document.getElementById — коректно обробляє кирилицю | |||
// ============================================================ | // ============================================================ | ||
$(function () { | $(function () { | ||
| Рядок 40: | Рядок 38: | ||
map.push({ $item: $(this), top: 0 }); | map.push({ $item: $(this), top: 0 }); | ||
} else { | } else { | ||
var | var el = document.getElementById(target); | ||
if ($el.length) | if (el) { | ||
map.push({ $item: $(this), top: $ | var $el = $(el); | ||
var $heading = $el.closest('h2, h3, h4').length | |||
? $el.closest('h2, h3, h4') : $el; | |||
map.push({ $item: $(this), top: $heading.offset().top }); | |||
} | } | ||
} | } | ||
| Рядок 51: | Рядок 52: | ||
function updateActive(map) { | function updateActive(map) { | ||
var scrollY = $(window).scrollTop() + | var scrollY = $(window).scrollTop() + 120; | ||
var current = null; | var current = null; | ||
for (var i = 0; i < map.length; i++) { | for (var i = 0; i < map.length; i++) { | ||
| Рядок 62: | Рядок 63: | ||
$items.on('click', function () { | $items.on('click', function () { | ||
var target = $(this).data('target'); | var target = $(this).data('target'); | ||
$items.removeClass('active'); | |||
$(this).addClass('active'); | |||
// Якщо активна вкладка ігор — перемикаємо на профіль спочатку | |||
var $gamesTab = $('.player-tab[data-tab="games"]'); | |||
var gamesActive = $gamesTab.length && $gamesTab.hasClass('active'); | |||
if (gamesActive && target !== 'top') { | |||
activatePlayerTab('profile'); | |||
} | } | ||
var delay = gamesActive ? 60 : 0; | |||
var | |||
setTimeout(function () { | setTimeout(function () { | ||
if (target === 'top') { | if (target === 'top') { | ||
$('html, body').animate({ scrollTop: 0 }, 280); | |||
} else { | } else { | ||
var el = document.getElementById(target); | var el = document.getElementById(target); | ||
if (el) { | if (el) { | ||
var $el = $(el); | var $el = $(el); | ||
var $heading = $el.closest('h2, h3, h4').length | var $heading = $el.closest('h2, h3, h4').length | ||
? $el.closest('h2, h3, h4') | ? $el.closest('h2, h3, h4') : $el; | ||
$('html, body').animate({ scrollTop: $heading.offset().top - 78 }, 280); | |||
} | } | ||
} | } | ||
} | }, delay); | ||
}); | }); | ||
| Рядок 547: | Рядок 112: | ||
}); | }); | ||
setTimeout(function () { | setTimeout(function () { | ||
sectionMap = buildSectionMap(); | sectionMap = buildSectionMap(); | ||
| Рядок 555: | Рядок 119: | ||
// ============================================================ | // ============================================================ | ||
// 3. PROFILE ICONS | // 3. PROFILE ICONS — клік + inactive + розгортання <p> | ||
// ============================================================ | // ============================================================ | ||
$(document).ready(function () { | $(document).ready(function () { | ||
// Розгортаємо <p> яку MediaWiki вставляє всередину grid | |||
function fixProfileGrid() { | |||
$('.profile-links-icons').each(function () { | |||
var $wrap = $(this); | |||
var $p = $wrap.find('> p'); | |||
if ($p.length) { | |||
$p.children().appendTo($wrap); | |||
$p.remove(); | |||
} | |||
$wrap.css({ display: 'grid', 'grid-template-columns': 'repeat(4, 1fr)', gap: '0' }); | |||
$wrap.find('.profile-icon').css({ | |||
display: 'flex', 'align-items': 'center', 'justify-content': 'center', | |||
padding: '13px 4px', float: 'none', width: 'auto', | |||
'min-width': '0', overflow: 'hidden', | |||
'border-right': '1px solid rgba(255,255,255,0.06)' | |||
}); | |||
$wrap.find('.profile-icon:last-child').css('border-right', 'none'); | |||
$wrap.find('.profile-icon img, .profile-icon .mw-file-element').css({ | |||
width: '22px', height: '22px', 'max-width': '22px', | |||
'object-fit': 'contain', display: 'block' | |||
}); | |||
$wrap.find('.profile-icon > span, .profile-icon .mw-default-size').css({ | |||
display: 'flex', 'align-items': 'center', | |||
'justify-content': 'center', 'line-height': '0' | |||
}); | |||
}); | |||
} | |||
fixProfileGrid(); | |||
setTimeout(fixProfileGrid, 400); | |||
// Клік + inactive | |||
$('.profile-icon').each(function () { | $('.profile-icon').each(function () { | ||
var $icon = $(this); | var $icon = $(this); | ||
| Рядок 572: | Рядок 167: | ||
// ============================================================ | // ============================================================ | ||
// 4. STATS OVERLAY НА ФОТО ГРАВЦЯ В R-BOX | // 4. STATS OVERLAY НА ФОТО ГРАВЦЯ В R-BOX | ||
// ============================================================ | // ============================================================ | ||
$(function () { | $(function () { | ||
| Рядок 578: | Рядок 172: | ||
if ($rbox.length === 0) return; | if ($rbox.length === 0) return; | ||
var wins = '', losses = '', games = ''; | |||
var | |||
$rbox.find('table tr').each(function () { | $rbox.find('table tr').each(function () { | ||
var | var label = $(this).find('th').text().trim().toLowerCase(); | ||
var val = $(this).find('td').text().trim(); | |||
var val = $td.text().trim(); | |||
if (label.indexOf('офіційних') !== -1 || label.indexOf('ігор') !== -1) { | if (label.indexOf('офіційних') !== -1 || label.indexOf('ігор') !== -1) { | ||
var m = val.match(/\((\d+)[^\d]+(\d+)\)/); | var m = val.match(/\((\d+)[^\d]+(\d+)\)/); | ||
if (m) { wins = m[1]; losses = m[2]; } | if (m) { wins = m[1]; losses = m[2]; } | ||
| Рядок 597: | Рядок 184: | ||
}); | }); | ||
if (games && wins && losses) { | if (games && wins && losses) { | ||
var $figure = $rbox.find('figure'); | var $figure = $rbox.find('figure'); | ||
if ($figure.length && !$figure.find('.rp-stats-overlay').length) { | if ($figure.length && !$figure.find('.rp-stats-overlay').length) { | ||
$figure.append( | |||
'<div class="rp-stats-overlay">' | |||
+ '<div class="rp-stat-box"><span class="rp-sv">' + games + '</span><span class="rp-sl">Ігор</span></div>' | + '<div class="rp-stat-box"><span class="rp-sv">' + games + '</span><span class="rp-sl">Ігор</span></div>' | ||
+ '<div class="rp-stat-box"><span class="rp-sv">' + wins + '</span><span class="rp-sl">Перемог</span></div>' | + '<div class="rp-stat-box"><span class="rp-sv">' + wins + '</span><span class="rp-sl">Перемог</span></div>' | ||
+ '<div class="rp-stat-box"><span class="rp-sv">' + losses + '</span><span class="rp-sl">Поразок</span></div>' | + '<div class="rp-stat-box"><span class="rp-sv">' + losses + '</span><span class="rp-sl">Поразок</span></div>' | ||
+ '</div>' | + '</div>' | ||
); | |||
} | } | ||
} | } | ||
| Рядок 617: | Рядок 204: | ||
if (!$('body').hasClass('page-Головна_сторінка')) return; | if (!$('body').hasClass('page-Головна_сторінка')) return; | ||
var | var block1 = [{ title: 'Фінал Року', url: '/index.php/Фінал_Року' }]; | ||
var | var block2 = [ | ||
{ title: 'Перша статистика', url: '/index.php/Перша_статистика' }, | { title: 'Перша статистика', url: '/index.php/Перша_статистика' }, | ||
{ title: 'Період', url: '/index.php/Період' }, | { title: 'Період', url: '/index.php/Період' }, | ||
{ title: 'Друга статистика', url: '/index.php/Статистика' } | { title: 'Друга статистика', url: '/index.php/Статистика' } | ||
]; | ]; | ||
var | var block3 = [ | ||
{ title: 'Mafia Closed Cup I', url: '/index.php/Mafia_Closed_Cup_I' }, | { title: 'Mafia Closed Cup I', url: '/index.php/Mafia_Closed_Cup_I' }, | ||
{ title: 'Mafia Closed Cup I Online', url: '/index.php/Mafia_Closed_Cup_I_Online' }, | { title: 'Mafia Closed Cup I Online', url: '/index.php/Mafia_Closed_Cup_I_Online' }, | ||
| Рядок 631: | Рядок 218: | ||
function rand(arr) { return arr[Math.floor(Math.random() * arr.length)]; } | function rand(arr) { return arr[Math.floor(Math.random() * arr.length)]; } | ||
var $ | var $b = $('.home__block-image-block p'); | ||
if ($ | if ($b.length >= 3) { | ||
[rand(block1), rand(block2), rand(block3)].forEach(function (l, i) { | |||
$b.eq(i).html('<a href="' + l.url + '">' + l.title + '</a>'); | |||
}); | |||
} | } | ||
}); | }); | ||
| Рядок 643: | Рядок 229: | ||
// 6. PLAYER TABS + LAZY LOADING | // 6. PLAYER TABS + LAZY LOADING | ||
// ============================================================ | // ============================================================ | ||
// Глобальна функція перемикання табу (використовується і в l-box) | |||
function activatePlayerTab(tabId) { | |||
var $tabs = $('.player-tab'); | var $tabs = $('.player-tab'); | ||
var $contents = $('.player-tab-content'); | var $contents = $('.player-tab-content'); | ||
var $rbox = $('.r-box'); | var $rbox = $('.r-box'); | ||
$tabs.removeClass('active'); | |||
$contents.removeClass('active'); | |||
$tabs.filter('[data-tab="' + tabId + '"]').addClass('active'); | |||
$('#tab-' + tabId).addClass('active'); | |||
if ($(window).width() <= 768) { | |||
if (tabId === 'games') $rbox.slideUp(200); | |||
else $rbox.slideDown(200); | |||
} | |||
} | |||
$(function () { | |||
var $tabs = $('.player-tab'); | |||
if ($tabs.length === 0) return; | if ($tabs.length === 0) return; | ||
$tabs.on('click', function () { | $tabs.on('click', function () { | ||
var | var tabId = $(this).data('tab'); | ||
activatePlayerTab(tabId); | |||
if (tabId === 'games') { | if (tabId === 'games') { | ||
$ | var $content = $('#tab-games'); | ||
if ($content.data('loaded')) return; | |||
$ | |||
var playerName = $content.data('player'); | var playerName = $content.data('player'); | ||
if (!playerName) return; | if (!playerName) return; | ||
| Рядок 691: | Рядок 274: | ||
success: function (response) { | success: function (response) { | ||
if (!response.expandtemplates || !response.expandtemplates.wikitext) return; | if (!response.expandtemplates || !response.expandtemplates.wikitext) return; | ||
$.ajax({ | $.ajax({ | ||
url: mw.config.get('wgScriptPath') + '/api.php', | url: mw.config.get('wgScriptPath') + '/api.php', | ||
| Рядок 702: | Рядок 284: | ||
dataType: 'json', | dataType: 'json', | ||
success: function (r) { | success: function (r) { | ||
if (r.parse | if (!r.parse || !r.parse.text) return; | ||
$content.html(r.parse.text['*']); | |||
$content.data('loaded', true); | |||
var $table = $content.find('table.sortable, table.wikitable'); | |||
$table.tablesorter(); | |||
injectGamesFilters($content, $table, playerName); | |||
applyWinrateColors($content); | |||
wrapWideTables($content); | |||
applyRolePills($content); | |||
$(document).trigger('mcc:content-loaded'); | |||
}, | }, | ||
error: function () { | error: function () { | ||
| Рядок 731: | Рядок 309: | ||
$(window).on('resize', function () { | $(window).on('resize', function () { | ||
if ( | if ($(window).width() > 768) $('.r-box').show(); | ||
}); | }); | ||
}); | }); | ||
| Рядок 738: | Рядок 316: | ||
// 7. ФІЛЬТРИ НАД ТАБЛИЦЕЮ ІГОР | // 7. ФІЛЬТРИ НАД ТАБЛИЦЕЮ ІГОР | ||
// ============================================================ | // ============================================================ | ||
function injectGamesFilters($container, $table | function injectGamesFilters($container, $table) { | ||
if (!$table.length) return; | if (!$table.length) return; | ||
if ($container.find('.mcc-games-filters').length) return; | if ($container.find('.mcc-games-filters').length) return; | ||
var events = []; | var events = []; | ||
$table.find('tbody tr').each(function () { | $table.find('tbody tr').each(function () { | ||
var | var ev = $(this).find('td').eq(0).text().trim(); | ||
if ( | if (ev && events.indexOf(ev) === -1) events.push(ev); | ||
}); | }); | ||
var | var opts = '<option value="">Всі події</option>'; | ||
events.forEach(function (e) { | events.forEach(function (e) { opts += '<option value="' + e + '">' + e + '</option>'; }); | ||
$table.before( | |||
+ '<div class="mcc-filter-group"> | '<div class="mcc-games-filters">' | ||
+ '<div class="mcc-filter-group"><span class="mcc-filter-label">Подія</span>' | |||
+ '<select class="mcc-filter-select" id="mcc-f-event">' + | + '<select class="mcc-filter-select" id="mcc-f-event">' + opts + '</select></div>' | ||
+ '<div class="mcc-filter-group"><span class="mcc-filter-label">Роль</span>' | |||
+ '<div class="mcc-filter-group"> | |||
+ '<select class="mcc-filter-select" id="mcc-f-role">' | + '<select class="mcc-filter-select" id="mcc-f-role">' | ||
+ | + '<option value="">Всі ролі</option><option value="Мир">Мирний</option>' | ||
+ '<option value="Шер">Шериф</option><option value="Маф">Мафія</option>' | |||
+ | + '<option value="Дон">Дон</option></select></div>' | ||
+ '<div class="mcc-filter-group"><span class="mcc-filter-label">Результат</span>' | |||
+ | |||
+ '<div class="mcc-filter-group"> | |||
+ '<select class="mcc-filter-select" id="mcc-f-result">' | + '<select class="mcc-filter-select" id="mcc-f-result">' | ||
+ | + '<option value="">Всі</option><option value="В">Перемога</option>' | ||
+ '<option value="П">Поразка</option></select></div>' | |||
+ | |||
+ '<div class="mcc-filter-group mcc-duration-group">' | + '<div class="mcc-filter-group mcc-duration-group">' | ||
+ '<span class="mcc-filter-label">Макс. тривалість</span>' | + '<span class="mcc-filter-label">Макс. тривалість</span>' | ||
| Рядок 782: | Рядок 347: | ||
+ '<input type="range" class="mcc-duration-range" id="mcc-f-dur" min="20" max="70" value="70" step="1">' | + '<input type="range" class="mcc-duration-range" id="mcc-f-dur" min="20" max="70" value="70" step="1">' | ||
+ '<span class="mcc-slider-val" id="mcc-dur-val">70:00</span>' | + '<span class="mcc-slider-val" id="mcc-dur-val">70:00</span>' | ||
+ '</div>' | + '</div></div>' | ||
+ '<span class="mcc-filter-count" id="mcc-games-count"></span>' | |||
+ '</div>' | + '</div>' | ||
); | |||
function toMins(s) { | |||
s = (s || '').trim(); | |||
var m1 = s.match(/^(\d+):(\d+)$/); | |||
if (m1) return +m1[1] + +m1[2] / 60; | |||
var m2 = s.match(/(\d+)\s*хв\s*(\d+)/); | |||
if (m2) return +m2[1] + +m2[2] / 60; | |||
var m1 = | |||
if (m1) return | |||
var m2 = | |||
if (m2) return | |||
return 999; | return 999; | ||
} | } | ||
function | function filter() { | ||
var ev | var ev = $('#mcc-f-event').val(); | ||
var | var rol = $('#mcc-f-role').val(); | ||
var res | var res = $('#mcc-f-result').val(); | ||
var dur | var dur = +$('#mcc-f-dur').val(); | ||
var n = 0; | |||
var | |||
$table.find('tbody tr').each(function () { | $table.find('tbody tr').each(function () { | ||
var | var td = $(this).find('td'); | ||
var show = (!ev || td.eq(0).text().trim().indexOf(ev) !== -1) | |||
var | && (!rol || td.eq(1).text().trim().indexOf(rol) !== -1) | ||
&& (!res || td.eq(3).text().trim().indexOf(res) !== -1) | |||
&& toMins(td.eq(2).text()) <= dur; | |||
$(this).toggle(show); | |||
if (show) n++; | |||
if (show) | |||
}); | }); | ||
$('#mcc-games-count').text(n + ' ігор'); | |||
$('#mcc-games-count').text( | |||
} | } | ||
$('#mcc-f-dur').on('input', function () { | $('#mcc-f-dur').on('input', function () { | ||
var v = | var v = +$(this).val(); | ||
$('#mcc-dur-val').text(v + ':00'); | $('#mcc-dur-val').text(v + ':00'); | ||
$(this).css('background-size', ((v - 20) / 50 * 100) + '% 100%'); | |||
$(this).css('background-size', | filter(); | ||
}); | }); | ||
$ | $container.find('.mcc-filter-select').on('change', filter); | ||
var total = $table.find('tbody tr').length; | var total = $table.find('tbody tr').length; | ||
$('#mcc-games-count').text(total + ' ігор'); | $('#mcc-games-count').text(total + ' ігор'); | ||
$('#mcc-f-dur').css('background-size', '100% 100%'); | |||
$('#mcc-f-dur').css('background-size', | |||
} | } | ||
// ============================================================ | // ============================================================ | ||
// 8. ROLE PILLS | // 8. ROLE PILLS | ||
// ============================================================ | // ============================================================ | ||
function applyRolePills($context) { | function applyRolePills($context) { | ||
var $root = $context || $(document); | var $root = $context || $(document); | ||
var roleMap = { | var roleMap = { | ||
'Мир': | 'Мир': { bg:'rgba(76,175,125,0.12)', color:'#7dd4a6', border:'rgba(76,175,125,0.22)' }, | ||
'Шер': | 'Шер': { bg:'rgba(91,143,255,0.12)', color:'#7da8ff', border:'rgba(91,143,255,0.22)' }, | ||
'Маф': | 'Маф': { bg:'rgba(200,76,76,0.12)', color:'#e08888', border:'rgba(200,76,76,0.22)' }, | ||
'Дон': | 'Дон': { bg:'rgba(255,215,0,0.10)', color:'#ffd700', border:'rgba(255,215,0,0.22)' } | ||
}; | }; | ||
$root.find('.wikitable tbody td').each(function () { | $root.find('.wikitable tbody td').each(function () { | ||
var $cell = $(this); | var $cell = $(this); | ||
var $span = $cell.find('span').filter(function () { | var $span = $cell.find('span').filter(function () { | ||
return ($(this).attr('style') || '').indexOf('color') !== -1; | |||
}); | }); | ||
if (!$span.length) return; | if (!$span.length) return; | ||
var text = $span.text().trim(); | |||
var text = $span.text().trim(); | |||
var style = roleMap[text]; | var style = roleMap[text]; | ||
if (!style) return; | if (!style || $span.hasClass('mcc-pill-done')) return; | ||
$span.addClass('mcc-pill-done').css({ | |||
$span.css({ | display:'inline-block', padding:'2px 10px', borderRadius:'4px', | ||
fontSize:'12.5px', fontWeight:'600', fontFamily:"'Manrope',sans-serif", | |||
background: style.bg, color: style.color, border:'1px solid '+style.border | |||
}); | }); | ||
}); | }); | ||
| Рядок 889: | Рядок 423: | ||
$(function () { applyRolePills(); }); | $(function () { applyRolePills(); }); | ||
$(document).on('mcc:content-loaded', function () { applyRolePills(); }); | |||
// ============================================================ | // ============================================================ | ||
| Рядок 912: | Рядок 447: | ||
function wrap($table) { | function wrap($table) { | ||
if ($table.closest('.mcc-scroll-inner').length) return; | if ($table.closest('.mcc-scroll-inner').length) return; | ||
$table.wrap('<div class="mcc-scroll-inner"></div>'); | $table.wrap('<div class="mcc-scroll-inner"></div>'); | ||
$table.closest('.mcc-scroll-inner').wrap('<div class="mcc-scroll-outer"></div>'); | $table.closest('.mcc-scroll-inner').wrap('<div class="mcc-scroll-outer"></div>'); | ||
var $inner = $table.closest('.mcc-scroll-inner'); | var $inner = $table.closest('.mcc-scroll-inner'); | ||
var $outer = $inner.closest('.mcc-scroll-outer'); | var $outer = $inner.closest('.mcc-scroll-outer'); | ||
function check() { | function check() { | ||
$outer.toggleClass('mcc-no-fade', | |||
$inner[0].scrollLeft + $inner[0].clientWidth >= $inner[0].scrollWidth - 4); | |||
} | } | ||
$inner.on('scroll', check); | $inner.on('scroll', check); | ||
check(); | check(); | ||
| Рядок 950: | Рядок 481: | ||
var $root = $context || $(document); | var $root = $context || $(document); | ||
$root.find('.wikitable tbody td').each(function () { | $root.find('.wikitable tbody td').each(function () { | ||
var $ | var $c = $(this); | ||
if ($ | if ($c.hasClass('wr-hi') || $c.hasClass('wr-lo')) return; | ||
var | var m = $c.text().trim().match(/^(\d+(?:\.\d+)?)%$/); | ||
if (!m) return; | |||
if (! | var v = parseFloat(m[1]); | ||
var | if (v >= 55) $c.addClass('wr-hi'); | ||
if ( | else if (v <= 33) $c.addClass('wr-lo'); | ||
else if ( | |||
}); | }); | ||
} | } | ||
| Рядок 964: | Рядок 494: | ||
// ============================================================ | // ============================================================ | ||
// 12. МОБІЛЬНИЙ ПОШУК | // 12. PLAYER TABS — "(42)" → стилізований badge | ||
// ============================================================ | |||
$(function () { | |||
$('.player-tab').each(function () { | |||
var $tab = $(this); | |||
var m = $tab.text().match(/\((\d+)\)/); | |||
if (!m) return; | |||
$tab.text($tab.text().replace(/\s*\(\d+\)/, '').trim()); | |||
$tab.append('<span class="mcc-tab-cnt">' + m[1] + '</span>'); | |||
}); | |||
}); | |||
// ============================================================ | |||
// 13. СЕЗОНИ — "Чемпіон" синього кольору | |||
// ============================================================ | |||
$(function () { | |||
function applySeasonColors($ctx) { | |||
($ctx || $(document)).find('.wikitable tbody td').each(function () { | |||
var t = $(this).text().trim(); | |||
if (t === 'Чемпіон' || t === '♔ Чемпіон') { | |||
$(this).css({ color: '#7ab8ff', fontWeight: '700' }); | |||
} | |||
}); | |||
} | |||
applySeasonColors(); | |||
$(document).on('mcc:content-loaded', function () { applySeasonColors(); }); | |||
}); | |||
// ============================================================ | |||
// 14. NAV <pre> — розгортаємо pre всередині навігації | |||
// ============================================================ | |||
$(function () { | |||
var sel = '.tournament-nav, .series-nav, .player-nav, .championship-nav'; | |||
$(sel).each(function () { | |||
var $nav = $(this); | |||
var $pre = $nav.find('pre'); | |||
if (!$pre.length) return; | |||
$pre.contents().each(function () { $nav.append($(this).clone()); }); | |||
$pre.remove(); | |||
}); | |||
}); | |||
// ============================================================ | |||
// 15. МОБІЛЬНИЙ ПОШУК | |||
// ============================================================ | // ============================================================ | ||
$(function () { | $(function () { | ||
if ($(window).width() > 768) return; | if ($(window).width() > 768) return; | ||
if ($('.mobile-search-btn').length | if ($('.mobile-search-btn').length) return; | ||
var $btn = $('<div class="mobile-search-btn">' | var $btn = $('<div class="mobile-search-btn">' | ||
| Рядок 989: | Рядок 562: | ||
setTimeout(function () { $input.focus(); }, 100); | setTimeout(function () { $input.focus(); }, 100); | ||
}); | }); | ||
$close.on('click', function () { $overlay.removeClass('active'); $input.val(''); }); | $close.on('click', function () { $overlay.removeClass('active'); $input.val(''); }); | ||
$input.on('keydown', function (e) { | $input.on('keydown', function (e) { | ||
if (e.keyCode === 13) { | if (e.keyCode === 13) { | ||
| Рядок 999: | Рядок 570: | ||
if (e.keyCode === 27) { $overlay.removeClass('active'); $input.val(''); } | if (e.keyCode === 27) { $overlay.removeClass('active'); $input.val(''); } | ||
}); | }); | ||
$overlay.on('click', function (e) { | $overlay.on('click', function (e) { | ||
if (e.target === this) { $overlay.removeClass('active'); $input.val(''); } | if (e.target === this) { $overlay.removeClass('active'); $input.val(''); } | ||
| Рядок 1006: | Рядок 576: | ||
// ============================================================ | // ============================================================ | ||
// | // 16. БЛОКУВАННЯ MINERVA SEARCH OVERLAY (ДЕСКТОП) | ||
// ============================================================ | // ============================================================ | ||
$(function () { | $(function () { | ||
| Рядок 1016: | Рядок 586: | ||
setTimeout(function () { | setTimeout(function () { | ||
$searchInput.attr('placeholder', 'Пошук...'); | $searchInput.attr('placeholder', 'Пошук...'); | ||
var $new = $searchInput.clone(false); | |||
var $ | $searchInput.replaceWith($new); | ||
$searchInput.replaceWith($ | $searchInput = $new; | ||
$searchInput = $ | |||
$searchInput.prop('readonly', false).removeAttr('readonly') | $searchInput.prop('readonly', false).removeAttr('readonly') | ||
| Рядок 1028: | Рядок 597: | ||
$('body').removeClass('overlay-enabled search-enabled'); | $('body').removeClass('overlay-enabled search-enabled'); | ||
$('.overlay, .search-overlay').hide(); | $('.overlay, .search-overlay').hide(); | ||
if (window.location.hash === '#/search') | if (window.location.hash === '#/search') | ||
history.replaceState(null, null, window.location.pathname); | history.replaceState(null, null, window.location.pathname); | ||
}); | }); | ||
| Рядок 1051: | Рядок 619: | ||
}); | }); | ||
if (window.location.hash === '#/search') | if (window.location.hash === '#/search') | ||
history.replaceState(null, null, window.location.pathname); | history.replaceState(null, null, window.location.pathname); | ||
}); | }); | ||
// ============================================================ | // ============================================================ | ||
// | // 17. BANNER SEARCH | ||
// ============================================================ | // ============================================================ | ||
$(function () { | $(function () { | ||
var $container = $('#bannerSearchContainer'); | var $container = $('#bannerSearchContainer'); | ||
if ($container.length | if (!$container.length) return; | ||
var $input = $('<input>', { type:'text', id:'bannerSearchInput', placeholder:'Пошук MCC...' }); | |||
var $btn = $('<button>', { id:'bannerSearchBtn', text:'Пошук' }); | |||
$container.append($input).append($btn); | $container.append($input).append($btn); | ||
| Рядок 1072: | Рядок 638: | ||
if (q) window.location.href = '/index.php?title=Спеціальна:Пошук&search=' + encodeURIComponent(q); | if (q) window.location.href = '/index.php?title=Спеціальна:Пошук&search=' + encodeURIComponent(q); | ||
} | } | ||
$btn.on('click', doSearch); | $btn.on('click', doSearch); | ||
$input.on('keydown', function (e) { if (e.keyCode === 13) { e.preventDefault(); doSearch(); } }); | $input.on('keydown', function (e) { if (e.keyCode === 13) { e.preventDefault(); doSearch(); } }); | ||
}); | }); | ||