added hash nav for iframe embeding

This commit is contained in:
Bachir Soussi Chiadmi
2015-05-08 18:44:23 +02:00
parent df063fc463
commit 61b744fb00
+51 -2
View File
@@ -19,7 +19,9 @@ jQuery(document).ready(function($) {
_avgDelay = 1, _avgDelay = 1,
_lastDraw = new Date, _lastDraw = new Date,
_fps, _fps,
_$nav_cursor; _$nav_cursor,
_History = window.History;
var _$body = $('body'), var _$body = $('body'),
_is_mobile = $('html').is('.mobile'), _is_mobile = $('html').is('.mobile'),
@@ -62,6 +64,9 @@ jQuery(document).ready(function($) {
initChapterWrapper(); initChapterWrapper();
initChapters(); initChapters();
initStaticLinks(); initStaticLinks();
// initHistoryNav();
launchNav(); launchNav();
// FULL SCREEN // FULL SCREEN
@@ -86,6 +91,8 @@ jQuery(document).ready(function($) {
// .prependTo(_$container) // .prependTo(_$container)
// ); // );
// }; // };
initHashNav();
}; };
function initDebug(){ function initDebug(){
@@ -128,6 +135,7 @@ jQuery(document).ready(function($) {
setTimeout(function(){ setTimeout(function(){
_$chapter_wrapper.find('.node').remove(); _$chapter_wrapper.find('.node').remove();
}, 2000); }, 2000);
updateHash('');
}; };
function initChapters(){ function initChapters(){
@@ -321,6 +329,38 @@ jQuery(document).ready(function($) {
setTimeout(_loaded_chapter.buildVideos(), 100); setTimeout(_loaded_chapter.buildVideos(), 100);
}; };
/*
__ __
/ /_ ____ ______/ /_ ____ ____ __ __
/ __ \/ __ `/ ___/ __ \ / __ \/ __ `/ | / /
/ / / / /_/ (__ ) / / / / / / / /_/ /| |/ /
/_/ /_/\__,_/____/_/ /_/ /_/ /_/\__,_/ |___/
*/
function updateHash(h){
window.location.hash = h;
};
function initHashNav(){
if(window.location.hash !== ''){
// console.log("hash = "+window.location.hash);
var p = window.location.hash.match('^#principe-([0-9]+)$');
// console.log("p :", p);
if(p){
// console.log($('li.node-readmore a[href="/node/'+p[1]+'"]', 'section#node-'+p[1]));
setTimeout((function(nid){
$('li.node-readmore a[href="/node/'+nid+'"]', 'section#node-'+nid).trigger('click').delay(1000).trigger('click');
}(p[1])), 500);
}else{
var h = window.location.hash.match('^#(.+)$');
// console.log("h :", h);
setTimeout((function(href){
$('a[href="'+href+'"]', '#block-menu-menu-footer-menu').trigger('click');
}(h[1])), 500);
}
}
};
/* /*
_____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____
| __|_ _| _ |_ _| | | __| | __|_ _| _ |_ _| | | __|
@@ -337,12 +377,16 @@ jQuery(document).ready(function($) {
e.preventDefault(); e.preventDefault();
_$static_wrapper.removeClass('visible'); _$static_wrapper.removeClass('visible');
loadStaticContent($(this).attr("href")); loadStaticContent($(this).attr("href"));
_$body.addClass('loading'); _$body.addClass('loading');
_loaded_static = true; _loaded_static = true;
return false; return false;
}; };
function loadStaticContent(h){ function loadStaticContent(h){
// change hash address bar
updateHash(h);
$.getJSON( $.getJSON(
'/jee/static', '/jee/static',
{"href":h}, {"href":h},
@@ -361,6 +405,7 @@ jQuery(document).ready(function($) {
}; };
function onCloseStatic(e){ function onCloseStatic(e){
updateHash('');
_$static_wrapper.removeClass('visible'); _$static_wrapper.removeClass('visible');
_loaded_static = false; _loaded_static = false;
}; };
@@ -743,6 +788,10 @@ jQuery(document).ready(function($) {
Chapter.prototype.loadNode = function(e){ Chapter.prototype.loadNode = function(e){
console.log("Chapter :: open : nid", this.nid); console.log("Chapter :: open : nid", this.nid);
// change hash address bar
updateHash("principe-"+this.nid);
_$body.addClass('loading'); _$body.addClass('loading');
$.getJSON( $.getJSON(
@@ -942,7 +991,7 @@ jQuery(document).ready(function($) {
this.$vids.eq(this.cur_vid_playing).vimeo('unload'); this.$vids.eq(this.cur_vid_playing).vimeo('unload');
}; };
Node.initialized = true; Chapter.initialized = true;
}; };
this.init(); this.init();