Last active
August 31, 2017 20:38
-
-
Save kazzkiq/5b2d6cfa83ccdf9e874194d36c93c26d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Roda a função apenas após todo o HTML carregar | |
document.addEventListener('DOMContentLoaded', addMobileLinks); | |
function addMobileLinks() { | |
// Elementos que já existem na tela atualmente | |
var social_links = document.querySelectorAll('#menu-social-links-menu li'); | |
var nav_mobile = document.getElementById('nav-mobile'); | |
var nav_mobile_logo = document.querySelector('#nav-mobile .mobile-title-logo-in-header'); | |
// Clona os links do desktop para replicá-los no mobile | |
var link_ssg = social_links[social_links.length - 2].cloneNode(true); | |
var link_sysmap = social_links[social_links.length - 1].cloneNode(true); | |
// Estilo que adapta os clones para mobile | |
var links_style = 'position: absolute;left: 140px;top: 13px;list-style: none;padding: 0;color: #fff;'; | |
// Remove ids dos clones para evitar conflito com desktop | |
link_ssg.id = ''; | |
link_sysmap.id = ''; | |
// Aplica estilos nos clones | |
link_ssg.setAttribute('style', links_style); | |
link_sysmap.setAttribute('style', links_style); | |
link_sysmap.style.left = '200px'; | |
// Aplica estilo no topbar mobile para liberar espaço para os clones | |
nav_mobile_logo.style.width = '130px'; | |
// Adiciona os clones no DOM. | |
nav_mobile.insertBefore(link_ssg, nav_mobile_logo.nextSibling); | |
nav_mobile.appendChild(link_sysmap, nav_mobile_logo.nextSibling); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment