activated overlays, commented page.js
This commit is contained in:
+109
-58
@@ -31,6 +31,7 @@ $(document).ready(function() {
|
||||
initRailway();
|
||||
initkeyboard();
|
||||
initPagination();
|
||||
initHashNav();
|
||||
changePages();
|
||||
};
|
||||
|
||||
@@ -147,50 +148,40 @@ $(document).ready(function() {
|
||||
if(typeof _ACTIVE_PAGES[_current_dp_key] !== "undefined"){
|
||||
_current_dp_ob = _ACTIVE_PAGES[_current_dp_key];
|
||||
|
||||
if (typeof _current_dp_ob[0].bg !== "undefined") {
|
||||
var pl = _current_dp_ob[0];
|
||||
// change display of main page left
|
||||
_$page_left
|
||||
.css({'background-image': "url("+_bgs_prefix+pl.bg+")"})
|
||||
.removeClass(pageClassToRemove)
|
||||
.addClass('page-'+pl.page);
|
||||
// change pagination
|
||||
_$pagi_l_txt.text(pl.page);
|
||||
}else{
|
||||
_$page_left.css({'background-image': "none"});
|
||||
_$pagi_l_txt.text("");
|
||||
}
|
||||
|
||||
if (typeof _current_dp_ob[1].bg !== "undefined") {
|
||||
var pr = _current_dp_ob[1];
|
||||
_$page_right
|
||||
.css({'background-image': "url("+_bgs_prefix+pr.bg+")"})
|
||||
.removeClass(pageClassToRemove)
|
||||
.addClass('page-'+pr.page);
|
||||
_$pagi_r_txt.text(pr.page);
|
||||
}else{
|
||||
_$page_right.css({'background-image': "none"});
|
||||
_$pagi_r_txt.text("");
|
||||
}
|
||||
|
||||
// hide or show nav arrows for first annd last double page
|
||||
var i = _active_pages_keys.indexOf(_current_dp_key);
|
||||
if( i == 0){
|
||||
_$pagi_l_arrow.addClass('hidden');
|
||||
}else{
|
||||
_$pagi_l_arrow.removeClass('hidden')
|
||||
}
|
||||
if(i == _active_pages_keys.length-1){
|
||||
_$pagi_r_arrow.addClass('hidden');
|
||||
}else{
|
||||
_$pagi_r_arrow.removeClass('hidden')
|
||||
}
|
||||
|
||||
|
||||
// make railway db thumb current
|
||||
$('li.double-page-'+_current_dp_key).addClass('current');
|
||||
updatePagesDisplay();
|
||||
updatePaginationDisplay();
|
||||
updateRailwayDisplay();
|
||||
updateHash();
|
||||
updatePagesOverlays();
|
||||
}
|
||||
};
|
||||
|
||||
function updatePagesDisplay(){
|
||||
if (typeof _current_dp_ob[0].bg !== "undefined") {
|
||||
var pl = _current_dp_ob[0];
|
||||
// change display of main page left
|
||||
_$page_left
|
||||
.css({'background-image': "url("+_bgs_prefix+pl.bg+")"})
|
||||
.removeClass(pageClassToRemove)
|
||||
.addClass('page-'+pl.page);
|
||||
// change pagination
|
||||
_$pagi_l_txt.text(pl.page);
|
||||
}else{
|
||||
_$page_left.css({'background-image': "none"});
|
||||
_$pagi_l_txt.text("");
|
||||
}
|
||||
|
||||
if (typeof _current_dp_ob[1].bg !== "undefined") {
|
||||
var pr = _current_dp_ob[1];
|
||||
_$page_right
|
||||
.css({'background-image': "url("+_bgs_prefix+pr.bg+")"})
|
||||
.removeClass(pageClassToRemove)
|
||||
.addClass('page-'+pr.page);
|
||||
_$pagi_r_txt.text(pr.page);
|
||||
}else{
|
||||
_$page_right.css({'background-image': "none"});
|
||||
_$pagi_r_txt.text("");
|
||||
}
|
||||
// updatePagesOverlays();
|
||||
};
|
||||
|
||||
function pageClassToRemove(){
|
||||
@@ -199,40 +190,100 @@ $(document).ready(function() {
|
||||
return c[0];
|
||||
};
|
||||
|
||||
function updatePaginationDisplay(){
|
||||
// hide or show nav arrows for first annd last double page
|
||||
var i = _active_pages_keys.indexOf(_current_dp_key);
|
||||
if( i == 0){
|
||||
_$pagi_l_arrow.addClass('hidden');
|
||||
}else{
|
||||
_$pagi_l_arrow.removeClass('hidden')
|
||||
}
|
||||
if(i == _active_pages_keys.length-1){
|
||||
_$pagi_r_arrow.addClass('hidden');
|
||||
}else{
|
||||
_$pagi_r_arrow.removeClass('hidden')
|
||||
}
|
||||
};
|
||||
|
||||
function updateRailwayDisplay(){
|
||||
// make railway db thumb current
|
||||
$('li.double-page-'+_current_dp_key).addClass('current');
|
||||
};
|
||||
|
||||
// ____ __
|
||||
// / __ \_ _____ _____/ /___ ___ _______
|
||||
// / / / / | / / _ \/ ___/ / __ `/ / / / ___/
|
||||
// / /_/ /| |/ / __/ / / / /_/ / /_/ (__ )
|
||||
// \____/ |___/\___/_/ /_/\__,_/\__, /____/
|
||||
// /____/
|
||||
|
||||
function updatePagesOverlays(){
|
||||
console.log("updatePagesOverlays");
|
||||
|
||||
// remove all pages overlays
|
||||
$('.overlay, .maps',_$page_left).children().remove();
|
||||
$('.overlay, .maps',_$page_right).children().remove();
|
||||
resetOverlays();
|
||||
|
||||
console.log("Overlays", _ACTIVE_PAGES[_current_dp_key].overlays);
|
||||
// build page_left overlays
|
||||
for (var map in _ACTIVE_PAGES[_current_dp_key].overlays) {
|
||||
if (_ACTIVE_PAGES[_current_dp_key].overlays.hasOwnProperty(map)) {
|
||||
map = _ACTIVE_PAGES[_current_dp_key].overlays[map];
|
||||
console.log("Map",map);
|
||||
_$maps_left.append(
|
||||
// loop through left and right pages from the current double page
|
||||
var lr = 0,
|
||||
p_ob,
|
||||
$p,
|
||||
map;
|
||||
for(var i in _current_dp_ob){
|
||||
p_ob = _current_dp_ob[i];
|
||||
console.log("p_ob", p_ob);
|
||||
// first left, then right
|
||||
$p = lr == 0 ? _$maps_left : _$maps_right;
|
||||
// loop through overlays from each page
|
||||
for(var m in p_ob.overlays){
|
||||
map = p_ob.overlays[m];
|
||||
console.log('map', map);
|
||||
$p.append(
|
||||
$('<div>')
|
||||
.addClass("map")
|
||||
.attr('overlay', map.over)
|
||||
.attr('debug', map.debug)
|
||||
.css({
|
||||
"left":map.x,
|
||||
"top":map.y,
|
||||
"width":map.w,
|
||||
"height":map.h
|
||||
"left":map.x+"mm",
|
||||
"top":map.y+"mm",
|
||||
"width":map.w+"mm",
|
||||
"height":map.h+"mm"
|
||||
})
|
||||
.bind("mouseover", function(e){
|
||||
$(this)
|
||||
.parents('.page').find('.overlay')
|
||||
.css({
|
||||
// 'background-color':"red",
|
||||
'background-image':'url(images/vectos/'+$(this).attr('overlay')+')'
|
||||
'background-image':'url(images/overlays/'+$(this).attr('overlay')+')'
|
||||
});
|
||||
})
|
||||
.bind("mouseout", function(e){
|
||||
$(this)
|
||||
.parents('.page').find('.overlay')
|
||||
.css({'background-image':'none'});
|
||||
})
|
||||
);
|
||||
}
|
||||
lr++;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
function resetOverlays(){
|
||||
$('.overlay, .maps','.page').css({'background-image':'none'}).children().remove();
|
||||
}
|
||||
// ___ __
|
||||
// / | ____ _____/ /_ ____ __________
|
||||
// / /| | / __ \/ ___/ __ \/ __ \/ ___/ ___/
|
||||
// / ___ |/ / / / /__/ / / / /_/ / / (__ )
|
||||
// /_/ |_/_/ /_/\___/_/ /_/\____/_/ /____/
|
||||
|
||||
function initHashNav(){
|
||||
h = window.location.hash;
|
||||
console.log('hash',h);
|
||||
_current_dp_key = h.match(/^#(\d+)$/)[1];
|
||||
}
|
||||
|
||||
function updateHash(){
|
||||
window.location.hash = _current_dp_key;
|
||||
};
|
||||
|
||||
// __ __ __ __
|
||||
|
||||
Reference in New Issue
Block a user