').
appendTo($('body')).
delay(2000).
animate({opacity:0}, 500, function() {
$(this).remove();
});
}
},
zoomOut: function () {
$('#slider-bar').fadeIn();
//$('.magazine-goto').fadeIn();
$('.exit-message').hide();
$('.made').fadeIn();
$('.toolbar-zoom').removeClass('zoom-out').addClass('zoom-in');
setTimeout(function(){
$('.magazine').addClass('animated').removeClass('zoom-in');
resizeViewport();
}, 0);
}
}
});
// Zoom event
if ($.isTouch)
$('.magazine-viewport').bind('zoom.doubleTap', zoomTo);
else
$('.magazine-viewport').bind('zoom.tap', zoomTo);
// Using arrow keys to turn the page
$(document).keydown(function(e){
var previous = 37, next = 39, esc = 27;
switch (e.keyCode) {
case previous:
// left arrow
$('.magazine').turn('previous');
e.preventDefault();
break;
case next:
//right arrow
$('.magazine').turn('next');
e.preventDefault();
break;
case esc:
$('.magazine-viewport').zoom('zoomOut');
e.preventDefault();
break;
}
});
// URIs - Format #/page/1
Hash.on('^page\/([0-9]*)$', {
yep: function(path, parts) {
var page = parts[1];
if (page!==undefined) {
if ($('.magazine').turn('is'))
$('.magazine').turn('page', page);
}
},
nop: function(path) {
if ($('.magazine').turn('is'))
$('.magazine').turn('page', 1);
}
});
$(window).resize(function() {
resizeViewport();
}).bind('orientationchange', function() {
resizeViewport();
});
// Regions
if ($.isTouch) {
$('.magazine').bind('touchstart', regionClick);
} else {
$('.magazine').click(regionClick);
}
// Events for the next button
$('.next-button').bind($.mouseEvents.over, function() {
$(this).addClass('next-button-hover');
}).bind($.mouseEvents.out, function() {
$(this).removeClass('next-button-hover');
}).bind($.mouseEvents.down, function() {
$(this).addClass('next-button-down');
}).bind($.mouseEvents.up, function() {
$(this).removeClass('next-button-down');
}).click(function() {
$('.magazine').turn('next');
});
// Events for the next button
$('.previous-button').bind($.mouseEvents.over, function() {
$(this).addClass('previous-button-hover');
}).bind($.mouseEvents.out, function() {
$(this).removeClass('previous-button-hover');
}).bind($.mouseEvents.down, function() {
$(this).addClass('previous-button-down');
}).bind($.mouseEvents.up, function() {
$(this).removeClass('previous-button-down');
}).click(function() {
$('.magazine').turn('previous');
});
// Slider
$( "#slider" ).slider({
min: 1,
max: numberOfViews(flipbook),
start: function(event, ui) {
if (!window._thumbPreview) {
_thumbPreview = $('', {'class': 'thumbnail'}).html('');
setPreview(ui.value);
_thumbPreview.appendTo($(ui.handle));
} else
setPreview(ui.value);
moveBar(false);
},
slide: function(event, ui) {
setPreview(ui.value);
},
stop: function() {
if (window._thumbPreview)
_thumbPreview.removeClass('show');
$('.magazine').turn('page', Math.max(1, $(this).slider('value')*2 - 2));
}
});
resizeViewport();
$('.magazine').addClass('animated');
}
// Zoom icon
$('.toolbar-zoom').bind('mouseover', function() {
if ($(this).hasClass('zoom-in'))
$(this).addClass('zoom-in-hover');
if ($(this).hasClass('zoom-out'))
$(this).addClass('zoom-out-hover');
}).bind('mouseout', function() {
if ($(this).hasClass('zoom-in'))
$(this).removeClass('zoom-in-hover');
if ($(this).hasClass('zoom-out'))
$(this).removeClass('zoom-out-hover');
}).bind('click', function() {
if ($(this).hasClass('zoom-in'))
$('.magazine-viewport').zoom('zoomIn');
else if ($(this).hasClass('zoom-out'))
$('.magazine-viewport').zoom('zoomOut');
return false;
});
$('#canvas').hide();
$('#magazine-goto').blur(function() {
$('.magazine').turn('page', $(this).val());
});
$('#magazine-goto').keypress(function(e) {
if(e.which == 13) {
$('.magazine').turn('page', $(this).val());
}
});
// Load the HTML4 version if there's not CSS transform
yepnope({
test : Modernizr.csstransforms,
yep: ['/js/turnjs4/lib/turn.min.js'],
nope: ['/js/turnjs4/lib/turn.html4.min.js', '/js/turnjs4/lib/jquery.ui.html4.css'],
both: ['/js/turnjs4/lib/zoom.min.js', '/js/turnjs4/lib/jquery.ui.css', '/js/turnjs4/lib/magazine.js', '/js/turnjs4/lib/magazine.css'],
complete: loadApp
});