Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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...
commit 92ab937121b0476e777b93165c8e8f61131c1ef4 1 parent d92bb77
Vittal Aithal authored
View
3  joomla_1.5/com_wordbridge/site/views/entries/tmpl/default.php
@@ -156,5 +156,6 @@
<?php
if ( $this->convertLinks )
{
- include_once( JPATH_COMPONENT.DS.'views'.DS.'entries'.DS.'tmpl'.DS.'convert_links.php' );
+ JHTML::_( 'behavior.mootools' );
+ echo $this->loadTemplate( 'convertlinks' );
}
View
15 ...site/views/entries/tmpl/convert_links.php → ...ews/entries/tmpl/default_convertlinks.php
@@ -1,6 +1,3 @@
-<?php
- JHTML::_('behavior.mootools');
-?>
<script type="text/javascript">
<!--
window.addEvent('domready',function() {
@@ -11,12 +8,22 @@
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);
- el.getParent().addClass(wp_link_class);
+ 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');
+ }
}
});
});
View
3  joomla_1.5/com_wordbridge/site/views/entry/tmpl/default.php
@@ -71,5 +71,6 @@
<?php
if ( $this->convertLinks )
{
- include_once( JPATH_COMPONENT.DS.'views'.DS.'entries'.DS.'tmpl'.DS.'convert_links.php' );
+ JHTML::_( 'behavior.mootools' );
+ echo $this->loadTemplate( 'convertlinks' );
}
View
15 ...site/views/entries/tmpl/convert_links.php → ...views/entry/tmpl/default_convertlinks.php
@@ -1,6 +1,3 @@
-<?php
- JHTML::_('behavior.mootools');
-?>
<script type="text/javascript">
<!--
window.addEvent('domready',function() {
@@ -11,12 +8,22 @@
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);
- el.getParent().addClass(wp_link_class);
+ 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');
+ }
}
});
});
View
3  joomla_1.6/com_wordbridge/site/views/entries/tmpl/default.php
@@ -157,5 +157,6 @@
<?php
if ( $this->convertLinks )
{
- include_once( JPATH_COMPONENT.DS.'views'.DS.'entries'.DS.'tmpl'.DS.'convert_links.php' );
+ JHTML::_( 'behavior.mootools' );
+ echo $this->loadTemplate( 'convertlinks' );
}
View
31 joomla_1.6/com_wordbridge/site/views/entries/tmpl/default_convertlinks.php
@@ -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>
View
3  joomla_1.6/com_wordbridge/site/views/entry/tmpl/default.php
@@ -71,5 +71,6 @@
<?php
if ( $this->convertLinks )
{
- include_once( JPATH_COMPONENT.DS.'views'.DS.'entries'.DS.'tmpl'.DS.'convert_links.php' );
+ JHTML::_( 'behavior.mootools' );
+ echo $this->loadTemplate( 'convertlinks' );
}
View
31 joomla_1.6/com_wordbridge/site/views/entry/tmpl/default_convertlinks.php
@@ -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>
Please sign in to comment.
Something went wrong with that request. Please try again.