This repository has been archived by the owner on Jul 21, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework templates for link replacement (GH #25)
To make it easier to change the link replacement javascript, it has been moved into overridable templates default_convertlinks.php. The links are also now placed in a span of class 'wordbridge_link_set' which will make it easier to CSS style the replaced links.
- Loading branch information
Vittal Aithal
committed
Apr 16, 2012
1 parent
d92bb77
commit 92ab937
Showing
8 changed files
with
92 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
joomla_1.6/com_wordbridge/site/views/entries/tmpl/default_convertlinks.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<script type="text/javascript"> | ||
<!-- | ||
window.addEvent('domready',function() { | ||
var wp_link_class = 'wordbridge_wp_link'; | ||
var wp_link_map = { 'comments' : '<?php echo JText::_( 'COM_WORDBRIDGE_LINK_ADD_COMMENT' ); ?>', 'facebook' : '<?php echo JText::_( 'COM_WORDBRIDGE_LINK_ADD_FACEBOOK' ); ?>', | ||
'twitter' : '<?php echo JText::_( 'COM_WORDBRIDGE_LINK_ADD_TWEET' ); ?>', 'stumble' : '<?php echo JText::_( 'COM_WORDBRIDGE_LINK_ADD_STUMBLE' ); ?>', 'digg' : '<?php echo JText::_( 'COM_WORDBRIDGE_LINK_ADD_DIGG' ); ?>', | ||
'reddit': '<?php echo JText::_( 'COM_WORDBRIDGE_LINK_ADD_REDDIT' ); ?>' }; | ||
var wp_link_str = 'https?://feeds.wordpress.com/1.0/('; | ||
for (var k in wp_link_map) { wp_link_str += k + '|'; } | ||
var wp_link_re = new RegExp(wp_link_str.substr(0, wp_link_str.length - 1) + ')/'); | ||
var wp_link_set_idx = 0; | ||
$$('div.wordbridge_content img').each(function(img){ | ||
var wp_link_match = img.src.match(wp_link_re); | ||
if (wp_link_match != null) { | ||
var el = new Element('span', { html: wp_link_map[wp_link_match[1]] }); | ||
el.replaces(img); | ||
var link = el.getParent(); | ||
link.addClass(wp_link_class); | ||
if (!link.getParent().hasClass('wordbridge_converted_links')) { | ||
link.getParent().addClass('wordbridge_converted_links'); | ||
wp_link_set_idx++; | ||
var container = new Element("span", { id: 'wordbridge_wp_link_set_' + wp_link_set_idx, class: 'wordbridge_link_set' }).inject(link, "before"); | ||
link.inject(container, 'bottom'); | ||
} else { | ||
$('wordbridge_wp_link_set_' + wp_link_set_idx).grab(link, 'bottom'); | ||
} | ||
} | ||
}); | ||
}); | ||
// --> | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
joomla_1.6/com_wordbridge/site/views/entry/tmpl/default_convertlinks.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<script type="text/javascript"> | ||
<!-- | ||
window.addEvent('domready',function() { | ||
var wp_link_class = 'wordbridge_wp_link'; | ||
var wp_link_map = { 'comments' : '<?php echo JText::_( 'COM_WORDBRIDGE_LINK_ADD_COMMENT' ); ?>', 'facebook' : '<?php echo JText::_( 'COM_WORDBRIDGE_LINK_ADD_FACEBOOK' ); ?>', | ||
'twitter' : '<?php echo JText::_( 'COM_WORDBRIDGE_LINK_ADD_TWEET' ); ?>', 'stumble' : '<?php echo JText::_( 'COM_WORDBRIDGE_LINK_ADD_STUMBLE' ); ?>', 'digg' : '<?php echo JText::_( 'COM_WORDBRIDGE_LINK_ADD_DIGG' ); ?>', | ||
'reddit': '<?php echo JText::_( 'COM_WORDBRIDGE_LINK_ADD_REDDIT' ); ?>' }; | ||
var wp_link_str = 'https?://feeds.wordpress.com/1.0/('; | ||
for (var k in wp_link_map) { wp_link_str += k + '|'; } | ||
var wp_link_re = new RegExp(wp_link_str.substr(0, wp_link_str.length - 1) + ')/'); | ||
var wp_link_set_idx = 0; | ||
$$('div.wordbridge_content img').each(function(img){ | ||
var wp_link_match = img.src.match(wp_link_re); | ||
if (wp_link_match != null) { | ||
var el = new Element('span', { html: wp_link_map[wp_link_match[1]] }); | ||
el.replaces(img); | ||
var link = el.getParent(); | ||
link.addClass(wp_link_class); | ||
if (!link.getParent().hasClass('wordbridge_converted_links')) { | ||
link.getParent().addClass('wordbridge_converted_links'); | ||
wp_link_set_idx++; | ||
var container = new Element("span", { id: 'wordbridge_wp_link_set_' + wp_link_set_idx, class: 'wordbridge_link_set' }).inject(link, "before"); | ||
link.inject(container, 'bottom'); | ||
} else { | ||
$('wordbridge_wp_link_set_' + wp_link_set_idx).grab(link, 'bottom'); | ||
} | ||
} | ||
}); | ||
}); | ||
// --> | ||
</script> |