/* Funcoes comuns a todas as paginas */
/* Incluir sempre depois do jquery e jqueryui*/
var deviceWidth = (window.innerWidth > 0) ? window.innerWidth : screen.width;
//window.load padrão:
$(window).load(function() {
fb_test_status(false);
$('#cor_liturgia').click(function(e){
e.stopPropagation();
window.open('http://www.cnbb.org.br/liturgia');
});
$('.slider_ad').show('slide');
});
function adjustStyleCommon(width) {
width = parseInt(width);
if (width < 960) {
$("#common_stylesheet").attr("href", "/css/common-mobile.css");
$( document ).tooltip({ disabled: true });
$('#cor_liturgia').tooltip({ disabled: true });
} else {
$("#common_stylesheet").attr("href", "/css/common.css.php");
$( document ).tooltip({
position: {
my: "center bottom-20",
at: "center top",
using: function(position, feedback) {
$(this).css( position );
}
}
});
$('#cor_liturgia').tooltip({
position: {
my: "center bottom-10",
at: "center top",
using: function(position, feedback) {
$(this).css( position );
}
},
tooltipClass: "tooltip-leituras"
});
}
}
//window.resize padrão:
$(window).resize(function() {
adjustStyleCommon($(window).width());
});
function alertDialog(title, message, cb){
$("#dialog").html(message);
$("#dialog").dialog({
autoOpen: true,
height: 210,
width: 300,
modal: true,
closeOnEscape: true,
draggable : false,
resizable: false,
title: title,
buttons:{"ok": function(){
$(this).dialog("close");
if (typeof cb == 'function'){
cb.call(this);
}
}}
});
}
/* **************************FACEBOOK*********************** */
var fb_user = undefined;
var fb_status = undefined;
function fb_test_status(showlogin){
try {
FB.getLoginStatus(function(response) {
window.fb_status = response.status;
if (response.status === 'connected') {
FB.api('/me', function(response) {
window.fb_user = response;
fb_display_user();
});
} else if (response.status === 'not_authorized') {
// not_authorized
window.fb_user = undefined;
if (showlogin){
$('#modal').show(0);
$('#fb-login-panel').show(0);
}
fb_display_user();
} else {
// not_logged_in
window.fb_user = undefined;
if (showlogin){
$('#modal').show(0);
$('#fb-login-panel').show(0);
}
fb_display_user();
}
});
} catch (err){
console.log(err);
}
}
function fb_display_user(){
try{
if (window.fb_user != undefined){
$('#fb-top-wrapper').html('Você entrou como ' + window.fb_user.name + '. Caso não seja você, clique aqui.');
} else {
//$('#fb-top-wrapper').html('Para entrar com sua conta do Facebook, clique aqui.');
}
} catch (err){
console.log(err);
}
}
function fb_login(){
try{
FB.login(function(response) {
if (response.authResponse) {
fb_test_status(false);
$('#modal').hide(0);
$('#fb-login-panel').hide(0);
} else {
cancelLogin();
}
}, {scope: 'email'});
} catch (err){
console.log(err);
}
}
function fb_serialize_user_data(){
}
function fb_logout(){
try{
FB.logout(function(response) {
window.location = '/formcolabore.php?cancel_login=1';
});
} catch (err){
console.log(err);
}
}
function fb_cancel_login(){
window.location = '/formcolabore.php?cancel_login=1';
}