To participate you must create an account on apostrophenow.org. If you have already done so, click Login.

Changeset 4501

Show
Ignore:
Timestamp:
01/23/12 15:53:56 (4 months ago)
Author:
johnnyoffline
Message:

added an app.yml option to return email links in a different format that allows apostrophe.unobfuscateEmailInline to be called outside of the a_js spool

app.yml flag is:

a:

inline_obfuscate_mailto: true

Location:
plugins/apostrophePlugin/branches/1.5
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • plugins/apostrophePlugin/branches/1.5/lib/toolkit/aHtml.class.php

    r4376 r4501  
    673673    // This is worth it to produce cacheable content though 
    674674    $class = 'a-email-' . sprintf("%u", crc32($user . '@' . $domain . ':' . $label)); 
    675     $href = rawurlencode("mailto:$user@$domain"); 
    676     $label = rawurlencode(trim($label)); 
    677     // This is an acceptable way to stub in a js call for now, since it's the 
    678     // way the helper has to do it too 
    679     aTools::$jsCalls[] = array('callable' => 'apostrophe.unobfuscateEmail(?, ?, ?)', 'args' => array($class, $href, $label)); 
    680     return "<a href='#' class='$class'></a>"; 
     675    $href = "mailto:$user@$domain"; 
     676    if (sfConfig::get('app_a_inline_obfuscate_mailto')) 
     677    { 
     678      $result = '<a href="#" class="a-obs-email ' . $class . '" data-prefix="' . $user . '" data-suffix="' . $domain . '" data-label="' . $label . '"></a>'; 
     679    } 
     680    else 
     681    { 
     682      // This is an acceptable way to stub in a js call for now, since it's the 
     683      // way the helper has to do it too 
     684      $result = "<a href='#' class='$class'></a>";   
     685      $label = rawurlencode(trim($label));           
     686      $href = rawurlencode($href);       
     687      aTools::$jsCalls[] = array('callable' => 'apostrophe.unobfuscateEmail(?, ?, ?)', 'args' => array($class, $href, $label)); 
     688    } 
     689    return $result; 
    681690  } 
    682691 
  • plugins/apostrophePlugin/branches/1.5/web/js/a.js

    r4490 r4501  
    340340        this.unobfuscateEmail = function(aClass, email, label) 
    341341        { 
     342          aLog('apostrophe.unobfuscateEmail -- ' + aClass + ', ' + email + ', ' + label); 
    342343                $('.' + aClass).attr('href', unescape(email)).html(unescape(label)); 
    343344        }; 
     345 
     346 
     347  /** 
     348    apostrophe.unobfuscateEmailInline -- works in conjunction with an app.yml flag: 
     349    //  a: 
     350    //    inline_obfuscate_mailto: true 
     351    To unobfuscate all emails loaded on a page after a_js has fired. 
     352  */ 
     353  this.unobfuscateEmailInline = function() { 
     354    var links = $('.a-obs-email'); 
     355    if (links.length)  
     356    { 
     357      links.each(function(){ 
     358        $self = $(this); 
     359        $self.attr('href', 'mailto:' + $self.attr('data-prefix') + '@' + $self.attr('data-suffix')).html($self.attr('data-label')); 
     360      }); 
     361    }; 
     362  }; 
    344363 
    345364        // Turns a form into an AJAX form that updates the element