Explorar el Código

added hash nav for iframe embeding

Bachir Soussi Chiadmi hace 9 años
padre
commit
61b744fb00
Se han modificado 1 ficheros con 51 adiciones y 2 borrados
  1. 51 2
      sites/all/themes/gui/jee/js/jee.js

+ 51 - 2
sites/all/themes/gui/jee/js/jee.js

@@ -19,7 +19,9 @@ jQuery(document).ready(function($) {
       _avgDelay = 1,
       _lastDraw = new Date,
       _fps,
-      _$nav_cursor;
+      _$nav_cursor,
+      _History = window.History;
+
 
   var _$body = $('body'),
       _is_mobile = $('html').is('.mobile'),
@@ -62,6 +64,9 @@ jQuery(document).ready(function($) {
     initChapterWrapper();
     initChapters();
     initStaticLinks();
+
+    // initHistoryNav();
+
     launchNav();
 
     // FULL SCREEN
@@ -86,6 +91,8 @@ jQuery(document).ready(function($) {
     //       .prependTo(_$container)
     //   );
     // };
+
+    initHashNav();
   };
 
   function initDebug(){
@@ -128,6 +135,7 @@ jQuery(document).ready(function($) {
     setTimeout(function(){
       _$chapter_wrapper.find('.node').remove();
     }, 2000);
+    updateHash('');
   };
 
   function initChapters(){
@@ -321,6 +329,38 @@ jQuery(document).ready(function($) {
       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();
     _$static_wrapper.removeClass('visible');
     loadStaticContent($(this).attr("href"));
+
     _$body.addClass('loading');
     _loaded_static = true;
     return false;
   };
 
   function loadStaticContent(h){
+    // change hash address bar
+    updateHash(h);
+
     $.getJSON(
       '/jee/static',
       {"href":h},
@@ -361,6 +405,7 @@ jQuery(document).ready(function($) {
   };
 
   function onCloseStatic(e){
+    updateHash('');
     _$static_wrapper.removeClass('visible');
     _loaded_static = false;
   };
@@ -743,6 +788,10 @@ jQuery(document).ready(function($) {
 
       Chapter.prototype.loadNode = function(e){
         console.log("Chapter :: open : nid", this.nid);
+
+        // change hash address bar
+        updateHash("principe-"+this.nid);
+
         _$body.addClass('loading');
 
         $.getJSON(
@@ -942,7 +991,7 @@ jQuery(document).ready(function($) {
         this.$vids.eq(this.cur_vid_playing).vimeo('unload');
       };
 
-      Node.initialized = true;
+      Chapter.initialized = true;
     };
 
     this.init();