var w=window,d=document,e=d.documentElement,g=d.getElementsByTagName('body')[0],x=w.innerWidth||e.clientWidth||g.clientWidth,y=w.innerHeight||e.clientHeight||g.clientHeight;
//calcolo la proporzione del viewport
var proporzioneViewport = x / y;
var larghezzaMinimaViewport = 0;
//se il viewport � pi� stretto di 640 lo imposto a 640
if (x < larghezzaMinimaViewport) {
//alert('schermo troppo piccolo (' + x + ' x ' + y + ')');
y = (larghezzaMinimaViewport * y) / x;
x = larghezzaMinimaViewport;
//alert('reimpostato a ' + x + ' x ' + y);
}
// imposto i margini attorno allo sfogliabile
var margineX = 35;
var margineY = 25;
//console.log(proporzioneViewport);
if(proporzioneViewport<1){
var sfogliabileX = 1038.00;
//console.log('vertical mobile' );
} else {
var sfogliabileX = 2076.00;
//console.log('horizontal mobile' );
}
var sfogliabileY = 587.00;
//calcolo la proporzione dello sfogliabile
var proporzioneSfogliabile = sfogliabileX / sfogliabileY;
//se la proporzione dello sfogliabile � maggiore della proporzione del viewport tengo fissa l'altezza
if (proporzioneSfogliabile < proporzioneViewport){
altezzaEffettiva = y - margineY;
larghezzaEffettiva = (altezzaEffettiva * (proporzioneSfogliabile));
} else {
larghezzaEffettiva = x - margineX;
altezzaEffettiva = ((larghezzaEffettiva) / proporzioneSfogliabile);
}
jQuery(function () {
$('.close-icon').click(function () {
$('#flipbook', window.parent.document).hide();
$('#flipbook', window.parent.document).attr("src", "");
});
applyConfig();
});
function applyConfig()
{
$('.logo-backs2').hide();
$('#slider-bar').show();
$('#at-expanding-share-button').show();
$('.down-pdf').show();
$('.flipbook-title').hide();
$('.flipbook-title p').html("");
$('.flipbook-title h2').html("");
$('.flipbook-title h1').html("");
if (flipbookcfg.cover > 0) {
$('#slider-bar').hide();
}
if (flipbookcfg.background!=null && $.trim(flipbookcfg.background)!='') {
$('.logo-backs').css('background-image', "url('"+flipbookcfg.background+"')");
}
if (flipbookcfg.showSlider!=null && $.trim(flipbookcfg.showSlider)==0) {
$('#slider-bar').hide();
}
if (flipbookcfg.showSocial!=null && $.trim(flipbookcfg.showSocial)==0) {
$('#at-expanding-share-button').hide();
}
if (flipbookcfg.companyLogo!=null && $.trim(flipbookcfg.companyLogo)!='') {
// $('.logo-backs2').attr('src', flipbookcfg.companyLogo);
$('.logo-backs2').show();
} else {
// $('.logo-backs2').attr('src', '');
$('.logo-backs2').hide();
}
if (flipbookcfg.title!=null && $.trim(flipbookcfg.title)!='') {
$('.flipbook-title h1').html(flipbookcfg.title);
$('.flipbook-title').show();
}
if (flipbookcfg.subtitle!=null && $.trim(flipbookcfg.subtitle)!='') {
$('.flipbook-title h2').html(flipbookcfg.subtitle);
$('.flipbook-title').show();
}
if (flipbookcfg.description!=null && $.trim(flipbookcfg.description)!='') {
$('.flipbook-title p').html(flipbookcfg.description);
$('.flipbook-title').show();
}
if (flipbookcfg.showDownload!=null && $.trim(flipbookcfg.showDownload)==0) {
$('.down-pdf').hide();
}
}
//Load normal page
function loadPage(page, pageElement) {
var img = $('');
img.mousedown(function (e) {
e.preventDefault();
});
img.load(function () {
$(this).css({width: '100%', height: '100%'});
$(this).appendTo(pageElement);
pageElement.find('.loader').remove();
});
img.attr('src', flipbookcfg.url + (page - flipbookcfg.cover) + '.jpg');
loadRegions(page, pageElement);
}
//Load large page
function loadLargePage(page, pageElement) {
var img = $('
');
img.load(function () {
var prevImg = pageElement.find('img');
$(this).css({width: '100%', height: '100%'});
$(this).appendTo(pageElement);
prevImg.remove();
});
img.attr('src', flipbookcfg.url + (page - flipbookcfg.cover) + '.jpg');
}
//Load small page
function loadSmallPage(page, pageElement) {
var img = pageElement.find('img');
img.css({width: '100%', height: '100%'});
img.unbind('load');
img.attr('src', flipbookcfg.url + (page - flipbookcfg.cover) + '.jpg');
}
function requestFullScreen(element) {
var requestMethod = element.requestFullScreen || element.webkitRequestFullScreen || element.mozRequestFullScreen || element.msRequestFullscreen;
if (requestMethod) { // Native full screen.
requestMethod.call(element);
} else if (typeof window.ActiveXObject !== "undefined") { // Older IE.
var wscript = new ActiveXObject("WScript.Shell");
if (wscript !== null) {
wscript.SendKeys("{F11}");
}
}
}
function loadApp()
{
$('#canvas').fadeIn(1000);
var flipbook = $('.magazine');
// Check if the CSS was already loaded
if (flipbook.width() == 0 || flipbook.height() == 0) {
setTimeout(loadApp, 10);
return;
}
// $('.logo-backs2').show();
if(proporzioneViewport<1){
width_new = larghezzaEffettiva;
height_new = altezzaEffettiva;
} else {
width_new = 1258;
height_new = 687;
}
flipbook.turn({
width: width_new,
height: height_new,
display: 'single',
duration: 1000,
cornerSize: 200,
gradients: true,
autoCenter: true,
elevation: 50,
acceleration: !isChrome(),
pages: flipbookcfg.numPages,
direction: flipbookcfg.direction,
// Events
when: {
turning: function (event, page, view)
{
var book = $(this),
currentPage = book.turn('page'),
pages = book.turn('pages');
Hash.go('page/' + page).update();
disableControls(page);
var audio = document.getElementById("audio");
audio.play();
},
turned: function (event, page, view)
{
disableControls(page);
$(this).turn('center');
$('#slider').slider('value', getViewNumber($(this), page));
if (page == 1) {
$(this).turn('peel', 'br');
}
},
missing: function (event, pages)
{
for (var i = 0; i < pages.length; i++)
addPage(pages[i], $(this));
}
}
});
$("#prev").click(function(e){
e.preventDefault();
if (flipbookcfg.direction == 'rtl') {
flipbook.turn("next"); } else {
flipbook.turn("previous"); }
});
$("#next").click(function(e){
e.preventDefault();
if (flipbookcfg.direction == 'rtl') {
flipbook.turn("previous"); } else {
flipbook.turn("next"); }
});
$('.magazine-viewport').zoom({
flipbook: $('.magazine'),
max: function () {
// return largeMagazineWidth() / $('.magazine').width();
return 3600/ $('.magazine').width();
},
when: {
swipeLeft: function () {
$(this).zoom('flipbook').turn('next');
},
swipeRight: function () {
$(this).zoom('flipbook').turn('previous');
},
resize: function (event, scale, page, pageElement) {
if (scale == 1)
loadSmallPage(page, pageElement);
else
loadLargePage(page, pageElement);
},
zoomIn: function () {
$('#slider-bar').hide();
$('.made').hide();
$('.magazine').removeClass('animated').addClass('zoom-in');
$('.zoom-icon').removeClass('zoom-icon-in').addClass('zoom-icon-out');
$('.controlzoom').show();
if (!window.escTip && !$.isTouch) {
escTip = true;
$('