diff options
-rw-r--r-- | timelinejs.js | 2 | ||||
-rw-r--r-- | timelinejs.module | 1 | ||||
-rw-r--r-- | 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 .= '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">'; $output .= '<html style="height: 100%;"><head>'; $output .= '<title>'. t('Timeline: @title', array('@title' => $node->title)) .'</title>'; + $output .= '<script type="text/javascript">timelineWidget = true;</script>'; $output .= '</head><body class="widget timeline-widget" style="height: 100%; margin: 0px;">'; $output .= timelinejs($nid, $width, $height); $output .= '</body></html>'; 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: "<?php print $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 != "<?php global $base_url; print $base_url; ?>") { links[i].target = "_parent"; - } -} -MakeMenuLinksOpenInNewWindow(); + } + // FIXME + //console.log(links[i].protocol + '//' + links[i].hostname + ' <?php print $base_url; ?>'); + } + } + + if (typeof(timelineWidget) != "undefined" && timelineWidget == true) { + MakeMenuLinksOpenInNewWindow(); + } </script> <script type="text/javascript" src="/<?php print $library_path; ?>/compiled/js/storyjs-embed.js"></script> <!-- END Timeline Embed --> |