From 61a6e1ba091442fa5051ec7e49f3f60496195ae2 Mon Sep 17 00:00:00 2001 From: Silvio Date: Wed, 6 Nov 2013 18:09:17 -0200 Subject: Use MakeMenuLinksOpenInNewWindow() just on widget mode --- timelinejs.js | 2 +- timelinejs.module | 1 + timelinejs.tpl.php | 21 ++++++++++++++------- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/timelinejs.js b/timelinejs.js index b7bb186..eb4d6b4 100644 --- a/timelinejs.js +++ b/timelinejs.js @@ -12,7 +12,7 @@ css: timelineCss, js: timelineJs, lang: timelineLang, - } + } }); } }; diff --git a/timelinejs.module b/timelinejs.module index 19cc0cb..ce48632 100644 --- a/timelinejs.module +++ b/timelinejs.module @@ -184,6 +184,7 @@ function timelinejs_widget($nid = NULL, $width = '960px', $height = '500px') { $output .= ''; $output .= ''; $output .= ''. t('Timeline: @title', array('@title' => $node->title)) .''; + $output .= ''; $output .= ''; $output .= timelinejs($nid, $width, $height); $output .= ''; diff --git a/timelinejs.tpl.php b/timelinejs.tpl.php index e3e1175..7fef98d 100644 --- a/timelinejs.tpl.php +++ b/timelinejs.tpl.php @@ -13,14 +13,21 @@ lang: "" } -function MakeMenuLinksOpenInNewWindow() { - var links = document.getElementsByTagName("a"); - for (var i = 0; i < links.length; i++) { - if (links[i].href != "http://widgets.socioambiental.org/") + // Used to open links in the parent iframe when showing as a widget + function MakeMenuLinksOpenInNewWindow() { + var links = document.getElementsByTagName("a"); + for (var i = 0; i < links.length; i++) { + if (links[i].protocol + '//' + links[i].hostname != "") { links[i].target = "_parent"; - } -} -MakeMenuLinksOpenInNewWindow(); + } + // FIXME + //console.log(links[i].protocol + '//' + links[i].hostname + ' '); + } + } + + if (typeof(timelineWidget) != "undefined" && timelineWidget == true) { + MakeMenuLinksOpenInNewWindow(); + } -- cgit v1.2.3