Skip to content

Commit

Permalink
first upload to GitHub
Browse files Browse the repository at this point in the history
  • Loading branch information
jeabakker committed Oct 5, 2011
0 parents commit aabfbce
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 0 deletions.
37 changes: 37 additions & 0 deletions manifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugin_manifest>
<field key="author" value="ColdTrick IT Solutions" />
<field key="version" value="1.0.3" />
<field key="description" value="Opens all external links in a new window." />
<field key="website" value="http://www.coldtrick.com/" />
<field key="copyright" value="(C) ColdTrick 2010" />
<field key="licence" value="GNU Public License version 2" />
<field key="elgg_version" value="2010040201" />
</plugin_manifest>
<!--
Todo:
- Add optional forwarding window (with "you are being redirected" info)
- Add Preview functionality
- Add new window indicator ("underline" or image)
==================
Version history
==================
1.0.3 (2011-04-22):
- changed: using jquery live function to register target blank on external links
1.0.2 (2011-04-21):
- changed: extend view functions updated for 1.7.x
- changed: moved code to js instead of metatags view
- fixed: target should not override target if it is already present
- fixed: support for https in external link
1.0.1 (2010-07-02):
- fixed: issue with href='#' (thx elggfan)
- fixed: widget content will now be handled
1.0 (2010-07-02):
- initial version
-->
9 changes: 9 additions & 0 deletions start.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

function target_blank_init(){
// extend js
elgg_extend_view("js/initialise_elgg", "target_blank/js");
}

register_elgg_event_handler('init', 'system', 'target_blank_init');
?>
18 changes: 18 additions & 0 deletions test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

require_once(dirname(dirname(dirname(__FILE__))) . '/engine/start.php');

admin_gatekeeper();

$body .= "<a href='http://www.google.nl'>1</a><br/>";
$body .= "<a href='http://www.google.nl' style='display: none;'>1</a><br/>";
$body .= "<a href='https://www.google.nl'>1</a><br/>";
$body .= "<a href='http://www.google.nl' target='_self'>1</a><br/>";
$body .= "<a href='/pg/news'>1</a><br/>";
$body .= "<a href='#'>1</a><br/>";
$body .= "<a href='javascript:void(0);'>1</a><br/>";



page_draw("", $body);
?>
10 changes: 10 additions & 0 deletions views/default/target_blank/js.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
/*$external_links = $('a[href^="http://"],a[href^="https://"]').not('[target], [href^="<?php echo $vars["url"];?>"]');*/
?>
$(document).ready(function(){
$external_links = $('a[href^="http://"]:not([target], [href^="<?php echo $vars["url"];?>"]), a[href^="https://"]:not([target], [href^="<?php echo $vars["url"];?>"])');

$external_links.live("click", function(){
$(this).attr("target", "_blank");
});
});

0 comments on commit aabfbce

Please sign in to comment.