MediaWiki:Common.js
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
/* Any JavaScript here will be loaded for all users on every page load. */ /* function makeDraftButton() { var email=[]; $('.infobox .ibr-Email a').each( function(i,e){ email.push($(e).text()); }); $('.infobox .ibr-Email_1 a').each(function(i,e){ email.push($(e).text()); }); $('.infobox .ibr-Email_2 a').each(function(i,e){ email.push($(e).text()); }); $('.infobox .ibr-Email_3 a').each(function(i,e){ email.push($(e).text()); }); var to = encodeURIComponent(email.shift()); var cc = encodeURIComponent(email.join(', ')); var url = '/draft.php?to='+to+'&cc='+cc+'&subject='+wgTitle; if(to) { $('.track-link').html('<a href="'+url+'">SPAM !!!</a>'); } } */ function $$(id) { return document.getElementById(id); } function url_host(url) { url=url.replace(/^.*?\/\//,''); url=url.replace(/\/.*$/,''); return(url); } function windowResized() { var w=$(window).width(); if(w<922) { $('body').addClass('narrow-window'); } else { $('body').removeClass('narrow-window'); } } $(window).resize(windowResized); $(window).ready(function() { // == add SVG region map widget == // look if region is specified on a page var r=$('.infobox .ibr-Region td').text().replace(/\s+$/,''); // var minimap="/static/SI-post.svg"; var minimap="/static/SI-post.html"; if(r) { minimap+="?"+r; } $('#p-Collections .body'). append( '<iframe src="'+minimap+'" style="overflow: hidden; border: 0;" id="imagemap" width="132" height="95"></iframe>' // '<object type="image/svg+xml" data="'+minimap+'" class="svg" style="overflow: hidden" id="svg-map" width="132" height="95"></object>' ); // add embed SVG graphics $('.embed-svg').each(function (i,e) { var url=$('a.internal',e).attr('href'); $('a.internal',e).hide(); var w=640; var h=480; $(e).prepend( '<object type="image/svg+xml" data="'+url+'"'+ ' class="svg" style="overflow: visible"'+ // ' width="'+w+'" height="'+h+'"'+ '></object>' ); }); // add embedded abstracts (not used much anymore) $('.abstract').each(function (i,e) { var url=$(e).text(); if(url) { $(e).html('Querying '+url); $(e).hide(); $.get(url,{}, function(r) { $('#abstract',r).each( function(i1,e1) { $(e).html(e1); $(e).append('<p class="KU_more"><a href="'+url+'" class="more">More</a></p>'); $(e).fadeIn(); }); }, 'html'); } }); // build pretty timeline display var groupa=''; $('.timeline').each(function(i,e){ $('table',e).hide(); $('tr',e).each(function(i1,e1) { var d={}; $('td',e1).each(function(i2,e2) { var v=$(e2).html(); if(i2==1) {d.year=v;} if(i2==0) {d.label=v;} }); if(!d.year) return; $(e).append( '<div class="tl-evt">'+ ((groupa!=d.year)? ('<div class="tl-evt-bul">• '+d.year+'</div>'):'')+ '<div class="tl-evt-lbl">'+d.label+'</div>'+ '</div>'); groupa=d.year; }); }); // fix footers on semantic media wiki tables $('tr.smwfooter td a').html('<div class="more_go">More</div>'); // fix links on images for featured articles $('.featured-article-horizontal').each(function(i,e){ var newlink=$('.featured-article-horizontal-h a',e).attr('href'); $('a.image',e).attr('href',newlink); }); $('.featured-article-column').each(function(i,e){ var newlink=$('.featured-article-h a',e).attr('href'); $('a.image',e).attr('href',newlink); }); // make propery cloud $('body.page-Special_Properties').each(function(i,e) { $('#bodyContent'). append('<div id="cloud" type="category-cloud"></div>'); $('ol.special:eq(0) li'). each(function(i,e){ var t=$('a:eq(0)',e).text(); if(t=='Has improper value for') { return; } var n=$(e).text().match(/\d+/)[0]; $('#cloud').append( '<a style="font-size: '+ Math.floor(12+Math.log(n)*4)+ 'px" class="cloud-propery" title="'+n+ '" href="/en/Property:'+t+'">'+ t+ '</a> '); }); $('ol.special:eq(0)').hide(); }); // TODO: add browse RDF button to properties page $('body.mw-special-Browse').each(function(i,e) { }); // change search box to search type for extra fancyness... // $('#searchInput').attr('type','search'); // DOESN'T WORK! // focus search box, if no other inputs present and no anchor if($('input').length==4 && !window.location.hash) { $('#searchInput').focus(); } /* // display only host names for websites in infoboxen // this fixes problems with wide infoboxes on msie $('.infobox .ibr-Website a').each(function(i,e) { $(e).text(url_host($(e).attr('href'))); }); // display only host names for websites in contacts $('.contact-website a').each(function(i,e) { $(e).text(url_host($(e).attr('href'))); }); */ // display notice for articles still in progress $('.nifertik').each(function(i,e) { if(i==0) { $('#ibr-contribute .p1').html('This article is <a href="/en/Culture.si:Still_in_progress">still in progress.</a>'); } }); // hide redirected-from on new main page $('.page-Culture_of_Slovenia #contentSub').html(''); // hack-fix potentially broken MK logo $('#mklogo').html('<a href="/en/MK"><img src="/static/MK.gif" alt="Ministry of Culture of Republic of Slovenia"/></a>'); // hack-fix broken top-menu, make all links server local $('#siteNotice .buttons .internal a').each(function(i,e){ $(e).attr('href',$(e).attr('href').replace(/^http:\/\/[^\/]+\//,'/')) }); // balance h1 heights on front page var h1 = 0; $('table.twocolumns h1').each(function(i,e){var h=$(e).height(); if(h>h1) h1=h; }); $('table.twocolumns h1').each(function(i,e){$(e).height(h1);}); // fixes for EPK 2012 button var e = $('#n-Maribor-ECoC-2012 a'); e.html('<span style="display: none;">'+e.text()+'</span>'); e.css('background','url(/static/epk138x24.png)'); e.css('display','block'); e.css('height','24px'); // fixes for Festivals 2012 button var e = $('#n-Festivals-2012 a'); e.html('<span style="display: none;">'+e.text()+'</span>'); e.css('background','url(/static/festivals2012.png)'); e.css('display','block'); e.css('height','24px'); //makeDraftButton(); windowResized(); }); var distinguishedCategories = { "Academies and faculties" : 1, "Africa" : 1, "African collections" : 1, "Agencies" : 1, "Alpine folk music" : 1, "Animation" : 1, "Animation festivals" : 1, "Architecture" : 1, "Architecture archives & libraries" : 1, "Architecture awards and competitions" : 1, "Architecture course and workshop organisers" : 1, "Architecture & Design" : 1, "Architecture education and research" : 1, "Architecture exhibition organisers" : 1, "Architecture exhibition venues" : 1, "Architecture festival and event organisers" : 1, "Architecture festivals" : 1, "Architecture funding, professional and support services" : 1, "Architecture media" : 1, "Architecture museums" : 1, "Architecture overview" : 1, "Architecture publishers" : 1, "Architecture studios" : 1, "Archival funding, professional and support services" : 1, "Archival institutions" : 1, "Archival & librarian education and research" : 1, "Archival & library course and workshop organisers" : 1, "Archival & library course and workshop organisers" : 1, "Archive periodicals" : 1, "Archives" : 1, "Archives and libraries awards and competitions" : 1, "Archives & Libraries" : 1, "Archives publishers" : 1, "Archive web resources" : 1, "Ballet" : 1, "Bookshops" : 1, "Brass band music" : 1, "Broadcasting" : 1, "Cafés" : 1, "Castles" : 1, "Choral music" : 1, "Church archives" : 1, "Church collections" : 1, "Churches" : 1, "Church libraries" : 1, "Cinemas" : 1, "Clubs" : 1, "Collecting societies" : 1, "Collections" : 1, "Comic art" : 1, "Concert halls" : 1, "Contemporary dance" : 1, "Copyright" : 1, "Course and workshop organisers" : 1, "Courses and workshops" : 1, "Cultural centres" : 1, "Cultural heritage education and research" : 1, "Cultural heritage media" : 1, "Cultural management" : 1, "Cultural policy" : 1, "Dance" : 1, "Dance awards and competitions" : 1, "Dance course and workshop organisers" : 1, "Dance education and research" : 1, "Dance festival and event organisers" : 1, "Dance festivals" : 1, "Dance funding, professional and support services" : 1, "Dance groups" : 1, "Dance overview" : 1, "Dance periodicals" : 1, "Dance producers" : 1, "Dance publishers" : 1, "Dance venues" : 1, "Design" : 1, "Design awards and competitions" : 1, "Design course and workshop organisers" : 1, "Design course and workshop organisers" : 1, "Design education and research" : 1, "Design exhibition and event organisers" : 1, "Design exhibition venues" : 1, "Design festivals" : 1, "Design media" : 1, "Design museums, archives & libraries" : 1, "Design museums, archives & libraries" : 1, "Design overview" : 1, "Design publishers" : 1, "Design studios" : 1, "Development agencies" : 1, "Distributors" : 1, "Education and research" : 1, "Electronic music" : 1, "Embassies and consulates in Slovenia" : 1, "Ethno music" : 1, "EU Culture funding recipient" : 1, "EU funding of Slovene organisations (Culture and MEDIA Programmes)" : 1, "EU MEDIA funding recipient" : 1, "Event organisers" : 1, "Events" : 1, "Exhibition organisers" : 1, "Exhibition venues" : 1, "Experimental music" : 1, "Fairs" : 1, "Fashion design" : 1, "Festival organisers" : 1, "Festivals" : 1, "Film" : 1, "Film archives & libraries" : 1, "Film awards and competitions" : 1, "Film course and workshop organisers" : 1, "Film courses, workshops and residencies" : 1, "Film distributors" : 1, "Film education and research" : 1, "Film event organisers" : 1, "Film festival organisers" : 1, "Film festivals" : 1, "Film history" : 1, "Film media" : 1, "Film museums" : 1, "Film overview" : 1, "Film producers" : 1, "Film publishers" : 1, "Film studios" : 1, "Film venues" : 1, "Folkloric dance" : 1, "Funding" : 1, "Funding web resources" : 1, "Galleries" : 1, "General web resources" : 1, "Graphic design" : 1, "Groups" : 1, "Heritage organisations" : 1, "Heritage overview" : 1, "History" : 1, "History of archives" : 1, "History of dance" : 1, "History of design" : 1, "History of libraries" : 1, "History of literature" : 1, "History of museums" : 1, "History of music" : 1, "History of opera" : 1, "History of theatre" : 1, "Industrial and technical heritage" : 1, "Industrial design" : 1, "Information offices" : 1, "Intangible heritage" : 1, "Intangible heritage festivals" : 1, "Interior design" : 1, "International cultural centres" : 1, "International funding" : 1, "Jazz" : 1, "Journals" : 1, "Libraries" : 1, "Library funding" : 1, "Library funding, professional and support services" : 1, "Library institutions" : 1, "Library online media" : 1, "Library overview" : 1, "Library periodicals" : 1, "Library support services" : 1, "Library web resources" : 1, "Literature" : 1, "Literature awards and competitions" : 1, "Literature course and workshop organisers" : 1, "Literature courses, workshops and residencies" : 1, "Literature education and research" : 1, "Literature event organisers" : 1, "Literature fairs" : 1, "Literature festival organisers" : 1, "Literature festivals" : 1, "Literature funding, professional and support services" : 1, "Literature museums and archives" : 1, "Literature online media" : 1, "Literature overview" : 1, "Literature periodicals" : 1, "Literature publishers" : 1, "Literature venues" : 1, "Literature web resources" : 1, "M3C" : 1, "Magazines" : 1, "Maribor, European Capital of Culture 2012" : 1, "Media" : 1, "Media agencies" : 1, "Media awards and competitions" : 1, "Media education and research" : 1, "Media funding, professional and support services" : 1, "Media studios" : 1, "Mercury mining heritage" : 1, "Monuments and sites" : 1, "Multidisciplinary fairs" : 1, "Multidisciplinary festivals" : 1, "Multimedia centres" : 1, "Municipal archives" : 1, "Municipal cultural institutions" : 1, "Municipal funding" : 1, "Municipal libraries" : 1, "Municipal museums" : 1, "Museum awards and competitions" : 1, "Museum collections" : 1, "Museum courses and workshops" : 1, "Museum funding, professional and support services" : 1, "Museum institutions" : 1, "Museum libraries" : 1, "Museum overview" : 1, "Museum periodicals" : 1, "Museums" : 1, "Music" : 1, "Music agencies" : 1, "Music archives and libraries" : 1, "Music awards and competitions" : 1, "Music course and workshop organisers" : 1, "Music courses, workshops and residencies" : 1, "Music distributors" : 1, "Music education and research" : 1, "Music fairs" : 1, "Music festival and event organisers" : 1, "Music festivals" : 1, "Music funding, professional and support services" : 1, "Music groups, ensembles and orchestras" : 1, "Music media" : 1, "Music museums and collections" : 1, "Music overview" : 1, "Music publishers" : 1, "Music venues" : 1, "National archives" : 1, "National cultural institutions" : 1, "National funding" : 1, "National libraries" : 1, "National museums" : 1, "New media art" : 1, "New media art archives and libraries" : 1, "New media art awards and competitions" : 1, "New media art course and workshop organisers" : 1, "New media art education and research" : 1, "New media art festival and event organisers" : 1, "New media art festivals" : 1, "New media art funding, professional and support services" : 1, "New media art groups" : 1, "New media art history" : 1, "New media art overview" : 1, "New media art producers" : 1, "New media art studios" : 1, "New media art venues" : 1, "Newspapers" : 1, "Online media" : 1, "Opera and music theatre" : 1, "Opera overview" : 1, "Orchestral and chamber music" : 1, "Outdoor venues" : 1, "Overviews" : 1, "Periodicals" : 1, "Photography" : 1, "Plečnik heritage" : 1, "Pop music" : 1, "Private museum collections" : 1, "Producers" : 1, "Professional archival associations" : 1, "Professional associations" : 1, "Professional librarian associations" : 1, "Public entities" : 1, "Publishers" : 1, "Puppetry" : 1, "Puppetry event organisers" : 1, "Puppetry festival and event organisers" : 1, "Puppetry festival organisers" : 1, "Radio" : 1, "Rap and hip hop" : 1, "Recording studios" : 1, "Regional archives" : 1, "Regional libraries" : 1, "Regional museums" : 1, "Residencies" : 1, "Rock" : 1, "Roman archaeological findings" : 1, "Schools" : 1, "Šiška Cultural Quarter" : 1, "Slovene embassies and consulates" : 1, "Slovenian language" : 1, "Specialised archives" : 1, "Specialised libraries" : 1, "Specialised museums" : 1, "Sport (sk8 park, ROG)" : 1, "Street theatre" : 1, "Studios" : 1, "Support services" : 1, "Television" : 1, "Theatre" : 1, "Theatre archives" : 1, "Theatre archives and libraries" : 1, "Theatre awards and competitions" : 1, "Theatre course and workshop organisers" : 1, "Theatre courses, workshops and residencies" : 1, "Theatre education and research" : 1, "Theatre event organisers" : 1, "Theatre festival and event organisers" : 1, "Theatre festival organisers" : 1, "Theatre festivals" : 1, "Theatre funding, professional and support services" : 1, "Theatre groups" : 1, "Theatre houses" : 1, "Theatre houses" : 1, "Theatre media" : 1, "Theatre museums" : 1, "Theatre overview" : 1, "Theatre producers" : 1, "Theatre publishers" : 1, "Theatre venues" : 1, "Tourism" : 1, "Universities" : 1, "University libraries" : 1, "Venues" : 1, "Vernacular Architecture" : 1, "Video" : 1, "Visual arts" : 1, "Visual arts archives and libraries" : 1, "Visual arts awards and competitions" : 1, "Visual arts collections" : 1, "Visual arts commercial galleries" : 1, "Visual arts course and workshop organisers" : 1, "Visual arts education and research" : 1, "Visual arts festival and exhibition organisers" : 1, "Visual arts festivals" : 1, "Visual arts funding, professional and support services" : 1, "Visual arts galleries" : 1, "Visual arts history" : 1, "Visual arts media" : 1, "Visual arts museums" : 1, "Visual arts overview" : 1, "Visual arts private collections" : 1, "Visual arts producers" : 1, "Visual arts publishers" : 1, "Visual arts studios, workshops and residencies" : 1, "Visual arts venues" : 1, "War memorials" : 1, "Web resources" : 1, "World Book Capital Ljubljana 2010" : 1, "World War I" : 1, "World War II" : 1 } ; // beautify categories $('.featured-article-column .categories').each(function(i,e){ var r = ''; $('> a',e).each(function(i1,e1){ var c = $(e1).text(); if(distinguishedCategories[c]) { r += e1.outerHTML+' ' } }); $(e).html(r); // console.log(r); }); var y0; // add <h2>year</h2> to event listings $('li.event-item').each(function(i,e){ var y = $('.year:first',e).text(); if(y0!=y) { y0=y; $(e).before('<h2>'+y+'</h2>'); // $(e).prepend(`<h2>${y}</h2>`); console.log('y',y); } }); /////////////////////////////////////// // stuff moved over from script.js // /////////////////////////////////////// // Velikost seznamov na kategorijah var SEZNAM_LIMIT = 30; // Segment slik na kategoriji var GALLERY_IMAGES = 30; // Sticky header! var headerOffset = 70; window.onscroll = function () { if (window.pageYOffset > headerOffset) { document.body.classList.add('stickyhead'); } else { document.body.classList.remove('stickyhead'); } } // Dostopnost vklopiAccessibility(); // Anchor jump fix window.addEventListener('hashchange', function () { window.scrollTo(window.pageXOffset, window.pageYOffset - headerOffset - 10); }); window.addEventListener('DOMContentLoaded', function () { // Search bar toggle in te scene var nav = document.getElementById('mw-navigation'); var searchInput = document.getElementById('searchInput'); var searchGo = document.getElementById('searchGoButton'); searchInput.onblur = function (ev) { if (ev.relatedTarget !== searchGo) { nav.classList.toggle('search-open', false); } }; searchGo.onclick = function (ev) { if (!nav.classList.contains('search-open')) { ev.preventDefault(); nav.classList.toggle('search-open', true); searchInput.focus(); } else if (searchInput.value === '') { ev.preventDefault(); nav.classList.toggle('search-open', false); } }; // Gumbek za prikaz vec eventov document.querySelectorAll('.show-more-events').forEach(function (moreLink) { moreLink.onclick = showMoreClick; }); // Gumbek za prikaz vec EU projektov document.querySelectorAll('.show-more-projects').forEach(function (moreLink) { moreLink.onclick = showMoreClick; }); // Menu toggle /* var menuToggle = document.getElementsByClassName('dropdown-toggle'); [].forEach.call(menuToggle, function (toggleBtn) { toggleBtn.addEventListener('click', function (ev) { var expanded = ev.currentTarget.getAttribute('aria-expanded'); var odprt = expanded !== 'true'; }); }); */ // Kategorije v clanku vrzi pod contact info! var teaser = document.getElementById('teaser'); var cat = document.getElementById('catlinks'); var catPage = document.getElementsByClassName('ns-14'); var header = document.getElementsByClassName('contentHeader'); // Kategorija - kategorije pod naslovom if (cat && catPage.length && header.length) { header[0].insertAdjacentElement('afterend', cat); // Clanek - kategorije kazi pod teaserjem } else if (cat && teaser) { teaser.insertAdjacentElement('beforeend', cat); } // Category page - "skrci" podkategorije v sekcije if (catPage) { var seznamiKategorij = document.querySelectorAll('.mw-category'); seznamiKategorij.forEach(segmentirajSeznam); // Skrij "Latest Entries" var latest = document.getElementById('Latest_Entries'); if (latest) { latest.parentElement.classList.add('hide_latest'); } // Preoblikuj naslov (skrij "Category:") /* var naslov = document.getElementById('firstHeading'); var naslovTekst = naslov.innerHTML; var popravljenNaslov = naslovTekst.substr(naslovTekst.indexOf(':') + 1); naslov.innerHTML = popravljenNaslov; */ // Show more for category pictures galleryShowMore(); } var dogodki = document.querySelector('section.events-archive'); if (dogodki) { var letaSection = dogodki.querySelector('.filter-years'); var leta = dogodki.querySelectorAll('.filter-years a'); sestaviSelectFilter('ev_years', 'Year:', letaSection, leta); var drzaveSection = dogodki.querySelector('.filter-countries'); var drzave = dogodki.querySelectorAll('.filter-countries a'); sestaviSelectFilter('ev_countries', 'Country:', drzaveSection, drzave); var kategorijeSection = dogodki.querySelector('.filter-categories'); var kategorije = dogodki.querySelectorAll('.filter-categories a'); sestaviSelectFilter('ev_categories', 'Category:', kategorijeSection, kategorije); } var infobox = document.querySelector('div.infobox'); if (infobox) { nastaviIkone(infobox); } // Galerija cez celo var galerije = document.querySelectorAll('.gallery'); if (galerije) { galerije.forEach(function (gallery) { console.log('gallery', gallery); gallery.parentNode.classList.add('gallery-fullwidth'); }); } popraviPrazneProstore(); accessibilityGumbi(); }); function sestaviSelectFilter(id, label, section, entries) { var s = document.createElement('select'); var l = document.createElement('label'); l.setAttribute('for', id); l.innerHTML = label; s.setAttribute('name', id); entries.forEach(function (e) { var o = document.createElement('option'); var link = e.getAttribute('href'); o.setAttribute('value', link); o.innerHTML = e.innerHTML; if (location.pathname == link) { o.setAttribute('selected', 'selected'); } s.appendChild(o); }); s.addEventListener('change', function (ev) { window.location = ev.currentTarget.value; }); section.innerHTML = ''; section.appendChild(l); section.appendChild(s); } function togglePodseznam(st, ev) { var podseznami = document.querySelectorAll('.podseznam_' + st); // Skrij prikazane podsezname podseznami[0].parentElement.childNodes.forEach(function (el) { el.classList.toggle('open', false); }); // Prikazi primerne podsezname podseznami.forEach(function (podseznam) { podseznam.classList.toggle('open', true); podseznam.classList.toggle('wtf', true); }); // Obarvaj izbor? if (ev) { knof = ev.currentTarget; knof.parentElement.childNodes.forEach(function (knof) { knof.classList.toggle('chosen', false); }); knof.classList.toggle('chosen', true); } } // Deblur images function deblurGallery(container) { console.log('deblur', container); var slike = container.querySelectorAll('img'); var thumbWidth = 300; slike.forEach(function (s) { if (s.getAttribute('data-file-width') < thumbWidth) { return; } s.setAttribute('loading', 'lazy'); var link = s.getAttribute('src'); var parts = link.split('/'); var filename = parts[parts.length - 1]; // Cleanup prepend of thumb filename = filename.split('px-')[1]; // Fix svg filename = filename.replace('.svg.png', '.svg'); s.setAttribute('src', '/w/thumb.php?w=' + thumbWidth + '&f=' + filename); }); } function galleryShowMore() { var catGallery = document.querySelector('#mw-category-media > .gallery'); if (!catGallery) { return; } var catImages = catGallery.querySelectorAll('.gallerybox'); var sections = Array.from(catImages).reduce(function (images, img) { var idx = images.length - 1; if (images[idx].length < GALLERY_IMAGES) { images[idx].push(img); } else { images.push([img]); } return images; }, [[]]); var p = catGallery.parentNode; catGallery.remove(); sections.forEach(function (sec, i) { var s = document.createElement('ul'); s.className = 'gallery'; sec.forEach(function (img) { s.append(img); }) p.append(s); if (i == 0) { // Deblur first deblurGallery(s); } }); // Load more btn if (sections.length > 1) { var b = document.createElement('button'); b.innerHTML = 'See more'; b.onclick = function () { try { var gals = p.querySelectorAll('ul.gallery'); gals.forEach(function (g, i) { var s = window.getComputedStyle(g); var d = s.getPropertyValue('display'); if (d == 'none') { g.style.display = "block"; deblurGallery(g); if (i == gals.length - 1) { b.remove(); } throw 'ok'; } }); } catch (e) { return; } } p.append(b); } } function nastaviIkone(infobox) { var zamenjave = { 'tw': /https?:\/\/(www\.)?twitter\.com/, 'facebook': /https?:\/\/(www\.)?(sl-si\.)?facebook\.com/, 'instagram': /https?:\/\/(www\.)?instagram\.com/, 'youtube': /https?:\/\/(www\.)?youtube\.com/, 'issuu': /https?:\/\/(www\.)?issuu\.com/, 'vimeo': /https?:\/\/(www\.)?vimeo\.com/, 'soundcloud': /https?:\/\/(www\.)?soundcloud\.com/, 'bandcamp': /https?:\/\/(www\.)?bandcamp\.com/, 'flickr': /https?:\/\/(www\.)?flickr\.com/, 'pinterest': /https?:\/\/(www\.)?pinterest\.com/ }; infobox.querySelectorAll('a.external').forEach(function (link) { var href = link.getAttribute('href'); // Email? if (href.search('mailto:') === 0) { link.classList.add('ico-email'); return; } // Social icon? Object.keys(zamenjave).forEach(function (z) { if (href.match(zamenjave[z])) { link.classList.add('icon-social'); link.innerHTML = '<i class="icon icon-' + z + '"></i>'; var p = link.parentNode; if (p.tagName === 'P') { p.parentNode.appendChild(link); p.remove(); } return; } }); }); } function segmentirajSeznam(seznam) { var stevec = 0; var limit = SEZNAM_LIMIT; var pID = seznam.parentNode.parentNode.id; var gumbi = document.createElement('div'); gumbi.classList.add('subcategory-select'); var crka = null; var gumb = null; var vnosi = 0; stevec += 1; Array.from(seznam.children).forEach(function (podseznam) { // Ce je dovolj vnosov, dodaj nov gumb if (vnosi >= limit && !(pID === 'mw-subcategories')) { if (gumb.innerHTML != crka) { gumb.innerHTML += "-" + crka; } gumbi.appendChild(gumb); stevec += 1; gumb = null; vnosi = 0; } crka = podseznam.children[0].innerHTML; if (!gumb) { gumb = document.createElement('a'); gumb.innerHTML = crka; (function (s) { gumb.onclick = function (ev) { togglePodseznam(s, ev); }; })(stevec); } podseznam.classList.add('podseznam_' + stevec); vnosi += podseznam.children[1].children.length; }); // Dodam zadnji gumb? if (gumbi.children.length > 0) { if (gumb.innerHTML != crka) { gumb.innerHTML += "-" + crka; } gumbi.appendChild(gumb); // Dodaj seznam gumbov za navigacijo pred seznam seznam.insertAdjacentElement('beforebegin', gumbi); // Izberi prvo //gumbi.children[Math.floor(Math.random() * gumbi.children.length)].click(); gumbi.children[0].click(); } else { gumb.onclick(); } } function showMoreClick(ev) { ev.preventDefault(); var seznam = ev.currentTarget.parentElement.getElementsByTagName('li'); var stNaslednjih = 3; for (var i = 0; i < seznam.length; i++) { var dogodek = seznam[i]; var display = window.getComputedStyle(dogodek).display; if (display === 'none') { if (dogodek.classList.contains('event-item')) { dogodek.style.display = 'flex'; } else { dogodek.style.display = 'block'; } stNaslednjih -= 1; if (i == seznam.length - 1) { ev.currentTarget.style.display = 'none'; } if (stNaslednjih === 0) { return; } } } ev.currentTarget.style.display = 'none'; } function popraviPrazneProstore() { document.querySelectorAll('p').forEach(function (paragraph) { if (paragraph.childNodes.length === 1 && paragraph.childNodes[0].tagName === 'br') { paragraph.style.display = 'none'; } }); } // Ponastavi header ob spremembi velikosti okna window.addEventListener('resize', function () { document.getElementsByClassName('navbar-collapse')[0].classList.remove('show'); document.getElementsByClassName('navbar-toggler')[0].setAttribute('aria-show', false); }); // Upostevaj accessibility nastavitev function brezKontrasta() { document.body.classList.remove('kontrast-svetel', 'kontrast-temen'); } function vklopiAccessibility() { // Upostevaj kontrast brezKontrasta(); console.log(localStorage.kontrast, 'KONTRAST'); switch (localStorage.kontrast) { case 'svetel': document.body.classList.add('kontrast-svetel'); break; case 'temen': document.body.classList.add('kontrast-temen'); break; } } function accessibilityGumbi() { var ks = document.getElementById('accessibility-kontrast-svetel'); if (ks) { ks.onclick = function () { localStorage.kontrast = 'svetel'; vklopiAccessibility(); } } var kt = document.getElementById('accessibility-kontrast-temen'); if (kt) { kt.onclick = function () { localStorage.kontrast = 'temen'; vklopiAccessibility(); } } var kn = document.getElementById('accessibility-kontrast-navaden'); if (kn) { kn.onclick = function () { localStorage.kontrast = null; vklopiAccessibility(); } } }