From ba7d7ff3c33f571690d8e04d22ffa274065479bd Mon Sep 17 00:00:00 2001 From: Bachir Soussi Chiadmi Date: Tue, 12 May 2015 16:44:34 +0200 Subject: [PATCH] fixed bad hash nav implementation --- .../admin/token/tests/token_test.tokens.inc | 13 +++++++ sites/all/modules/gui/jeemod/jeemod.module | 2 +- sites/all/themes/gui/jee/js/jee.js | 37 +++++++++++++------ .../all/themes/gui/jee/templates/html.tpl.php | 11 ++++++ 4 files changed, 50 insertions(+), 13 deletions(-) create mode 100644 sites/all/modules/contrib/admin/token/tests/token_test.tokens.inc diff --git a/sites/all/modules/contrib/admin/token/tests/token_test.tokens.inc b/sites/all/modules/contrib/admin/token/tests/token_test.tokens.inc new file mode 100644 index 0000000..19cbbb0 --- /dev/null +++ b/sites/all/modules/contrib/admin/token/tests/token_test.tokens.inc @@ -0,0 +1,13 @@ + t('A test token with colons in the name'), + 'description' => NULL, + ); + + return $info; +} diff --git a/sites/all/modules/gui/jeemod/jeemod.module b/sites/all/modules/gui/jeemod/jeemod.module index d6b96b2..ae9906d 100644 --- a/sites/all/modules/gui/jeemod/jeemod.module +++ b/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; diff --git a/sites/all/themes/gui/jee/js/jee.js b/sites/all/themes/gui/jee/js/jee.js index 932ecf4..dc2caf2 100755 --- a/sites/all/themes/gui/jee/js/jee.js +++ b/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); - setTimeout((function(href){ - $('a[href="'+href+'"]', '#block-menu-menu-footer-menu').trigger('click'); - }(h[1])), 500); + 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])), 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'); diff --git a/sites/all/themes/gui/jee/templates/html.tpl.php b/sites/all/themes/gui/jee/templates/html.tpl.php index ff3968a..801d55a 100755 --- a/sites/all/themes/gui/jee/templates/html.tpl.php +++ b/sites/all/themes/gui/jee/templates/html.tpl.php @@ -55,6 +55,17 @@ +