historia-de-zainab/js/main.js

89 lines
2.4 KiB
JavaScript
Raw Normal View History

2017-09-26 11:17:09 +02:00
viewStatus= "story" /* data story */
2017-09-26 13:35:51 +02:00
pagesLoaded= 0
totalPages=7;
2017-09-25 14:03:53 +02:00
window.onload = function() {
width = 1000,
height = 1000;
loadPageTemplates()
$('#pagepiling').pagepiling({
menu: null,
2017-09-29 11:53:26 +02:00
anchors: ["portada","page1","page2","page3","page4","page5","page6","page7"],
2017-09-25 14:03:53 +02:00
direction: 'horizontal',
verticalCentered: true,
scrollingSpeed: 800,
easing: 'swing',
2017-09-29 11:53:26 +02:00
normalScrollElements:'div',
2017-09-25 14:03:53 +02:00
afterLoad: function(anchorLink, index){
//using index
2017-09-29 11:53:26 +02:00
index-=1;
console.log(index)
if(index<=0){
$('#timeline').fadeOut();
}else{
$('#timeline').fadeIn();
}
2017-09-25 14:03:53 +02:00
$('.btn-navigation.active').removeClass('active')
$('#nav-btn-page'+index + " a").addClass('active')
}
});
//turnEventsOn();
}
function loadPageTemplates(){
2017-09-25 15:15:33 +02:00
2017-09-29 11:53:26 +02:00
$('#portada').load("templates/portada.html")
2017-09-26 13:35:51 +02:00
for (var i=1; i<= totalPages; i++){
(function (n) {
$('#page-'+n).load("templates/page"+n+".html",function(){
counterLoading();
loadModalEvent(n);
})
})(i)
}
2017-09-29 11:53:26 +02:00
2017-09-26 13:35:51 +02:00
//turnEventsOn();
2017-09-26 11:17:09 +02:00
}
2017-09-26 13:35:51 +02:00
function loadModalEvent(j){
2017-09-26 11:17:09 +02:00
var modal = new jBox('Modal', {
2017-09-26 13:35:51 +02:00
attach: '#map-btn-page-'+j,
content: $('#map-page-'+j),
2017-09-26 11:17:09 +02:00
closeButton: 'box'
});
}
function counterLoading(){
2017-09-26 13:35:51 +02:00
pagesLoaded++;
if(pagesLoaded >= totalPages){
//Todas las plantillas cargadas
2017-09-26 11:17:09 +02:00
$('.menu-content').on("click",'.switchMode', function(e){
if(viewStatus=="story") viewStatus="data"
else{
viewStatus="story"
}
if(viewStatus=="story"){
2017-09-27 13:00:50 +02:00
$('.story-content, .menu-story-content').show();
$('.data-content, .menu-data-content').hide();
//$('.menu-content .switchMode').empty().html("ver datos")
2017-09-26 11:17:09 +02:00
}
else{
2017-09-27 13:00:50 +02:00
$('.story-content, .menu-story-content').hide();
$('.data-content, .menu-data-content').show();
//$('.menu-content .switchMode').empty().html("ver historia")
2017-09-26 11:17:09 +02:00
}
})
}
2017-09-25 14:03:53 +02:00
}
function turnEventsOn(){
2017-09-25 15:15:33 +02:00
/*$('#timeline').on("click",'.btn-navigation', function(e){
2017-09-25 14:03:53 +02:00
$('.btn-navigation.active').removeClass('active')
$(this).addClass('active')
2017-09-25 15:15:33 +02:00
})*/
2017-09-26 11:17:09 +02:00
}