瀏覽代碼

fixed bad hash nav implementation

Bachir Soussi Chiadmi 9 年之前
父節點
當前提交
ba7d7ff3c3

+ 13 - 0
sites/all/modules/contrib/admin/token/tests/token_test.tokens.inc

@@ -0,0 +1,13 @@
+<?php
+
+/**
+ * Implements hook_token_info()
+ */
+function token_test_token_info() {
+  $info['tokens']['node']['colons:in:name'] = array(
+    'name' => t('A test token with colons in the name'),
+    'description' => NULL,
+  );
+
+  return $info;
+}

+ 1 - 1
sites/all/modules/gui/jeemod/jeemod.module

@@ -155,7 +155,7 @@ function jeemod_preprocess_jeemod_share_links(&$vars){
 
   $sitetitle = variable_get('site_name', '');
   $nodetitle = $entity->title;
-  $nodeurl = $base_url . base_path() . "#principe-" . $entity->nid;
+  $nodeurl = $base_url . url('node/'.$entity->nid);//$base_url . base_path() . "#principe-" . $entity->nid;
 
   $text = $nodetitle ." | ". $sitetitle . " - " . $nodeurl;
 

+ 23 - 10
sites/all/themes/gui/jee/js/jee.js

@@ -9,12 +9,15 @@
      2015
 */
 
+
 jQuery(document).ready(function($) {
   // console.log('Hello Jee');
 
   // http://stackoverflow.com/questions/2890898/preventing-mouse-emulation-events-ie-click-from-touch-events-in-mobile-safari
   // FastClick.attach(document.body);
 
+
+
   var _debug = false,
       _avgDelay = 1,
       _lastDraw = new Date,
@@ -344,24 +347,33 @@ jQuery(document).ready(function($) {
   };
 
   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);
+        var hash = $('li.node-readmore a', 'section#node-'+p[1]).attr('href');
+        updateHash(hash);
+      }
+
+      var page = window.location.hash.match('^#/page/.+$');
+      var h = window.location.hash.match('^#(.+)$');
+      // console.log("h :", h);
+      if(page){
         setTimeout((function(href){
           $('a[href="'+href+'"]', '#block-menu-menu-footer-menu').trigger('click');
-        }(h[1])), 500);
+        }(h[1])), 100);
+      }else{
+        setTimeout((function(href){
+          $('li.node-readmore a[href="'+href+'"]', 'section.node-chapitre').trigger('click').delay(1000).trigger('click');
+        }(h[1])), 100);
       }
 
+
+
     }
+
   };
   /*
    _____ _____ _____ _____ _____ _____ _____
@@ -427,6 +439,7 @@ jQuery(document).ready(function($) {
     this.e = e;
     this.$e = $(e);
     this.nid = this.$e.attr("id").match(/^node-(\d+)/)[1];
+    this.hashref = $('li.node-readmore a', e).attr('href');
     this.geom = {
       base_a:base_a,
       a:0,
@@ -789,10 +802,10 @@ jQuery(document).ready(function($) {
       // |_____|__|  |_____|_|___|  |_____|__|__|__|__|__|    |_| |_____|__|__|
 
       Chapter.prototype.loadNode = function(e){
-        console.log("Chapter :: open : nid", this.nid);
+        console.log("Chapter :: open : e", e);
 
         // change hash address bar
-        updateHash("principe-"+this.nid);
+        updateHash(this.hashref);
 
         _$body.addClass('loading');
 

+ 11 - 0
sites/all/themes/gui/jee/templates/html.tpl.php

@@ -55,6 +55,17 @@
 		<!-- remove the no-js as fast as possible -->
 		<script>(function(H){H.className=H.className.replace(/\bno-js\b/,'js')})(document.documentElement)</script>
 
+    <script type="text/javascript">
+      /* redirect sub page to ajax loaded with hash */
+      function checkRedirect(){
+        var loc = window.location;
+        console.log(loc);
+        if(loc.pathname !== "/"){
+          window.location = loc.origin + "/#" + loc.pathname;
+        }
+      };
+      checkRedirect();
+    </script>
 		<!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame
 		     Remove this if you use the .htaccess -->
 		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />