I have this example with javascript session that opens a modal in which I use the fancybox library and < a Bootstrap :
just need to create the company image: /img/logo_empresa.png
Overlay div with class: .layer_overlay
The div where the exit button will appear: <div id="session_login"></div>
And put this script in HTML:
$(document).ready(function() {
$('.layer_overlay').hide();
if (!$.prototype.fancybox) {
$('<script></script>', {
type: 'text/javascript',
src: 'https://cdnjs.cloudflare.com/ajax/libs/fancybox/2.1.5/jquery.fancybox.js'
}).appendTo('head');
$('<link/>', {
rel: 'stylesheet',
type: 'text/css',
href: 'https://cdnjs.cloudflare.com/ajax/libs/fancybox/2.1.5/jquery.fancybox.min.css'
}).appendTo('head');
}
var modalLogin = {
pagina_atual:'index',
pg_adm:'administrador',
pg_user:'usuario',
tiposLogin : {
A:'Administrador',
U:'Usuário'
},
viewModal : function() {
var content = '<div id="hello" class="col-xs-12 col-md-12 col-sm-12 login-box">\
<img src="/img/logo_empresa.png" border="0" class="text-center responsive-image">\
<h1 class="page-heading">Selecione o tipo de acesso:</h1>\
<ul class="acessos">\
<li><a href="javascript:void(0);" id="A" data-adm="'+modalLogin.tiposLogin.A+'" class="session_select">Administrador</a></li>\
<li><a href="javascript:void(0);" id="U" data-adm="'+modalLogin.tiposLogin.U+'" class="session_select">Usuário</a></li>\
</ul>\
</div>';
$.fancybox.open([
{
type: 'inline',
autoScale: true,
minHeight: 30,
content: content,
closeBtn:false
}
], {
padding: 0
});
$('.layer_overlay').show();
},
mySession : function() {
return localStorage.getItem('login')
},
setSession : function(login) {
if (login == null) {
localStorage.setItem('login', null);
localStorage.removeItem('login');
localStorage.clear();
} else {
localStorage.setItem('login', login);
$('#session_login').html('<a href="javascript:void(0)" id="reset_session">Sair ('+localStorage.getItem('login')+')</a>')
}
},
closeModal : function() {
$('.fancybox-wrap').remove();
$('.layer_overlay').fadeOut('slow');
}
}
$(document).on('click','#reset_session', function() {
$('#session_login').html('');
modalLogin.setSession(null);
window.location.reload();
});
if (localStorage.getItem('login') == 'null' || localStorage.getItem('login') == null || localStorage.getItem('login') == undefined || !localStorage.getItem('login')) {
if (!!$.prototype.fancybox) {
modalLogin.viewModal();
$(document).on('click','.session_select', function() {
var login = $(this).data('login');
modalLogin.setSession(login);
if (login == modalLogin.tiposLogin.A) {
window.location.href=modalLogin.pg_adm;
} else if (login == modalLogin.tiposLogin.U) {
window.location.href=modalLogin.pg_user;
} else {
modalLogin.closeModal();
}
});
}
} else {
$('#session_login').html('<a href="javascript:void(0)" id="reset_session">Sair (Olá '+localStorage.getItem('adm')+'!)</a>')
}
});