Ticket #685: share-this.php.diff

File share-this.php.diff, 2.7 kB (added by CaptainN, 10 months ago)

Patch to remove dependancy on Prototype.js for Share This plugin

  • share-this.php

    old new  
    194194        } 
    195195} 
    196196 
    197 if (!function_exists('ak_prototype')) { 
    198         function ak_prototype() { 
    199                 if (!function_exists('wp_enqueue_script')) { 
    200                         global $ak_prototype; 
    201                         if (!isset($ak_prototype) || !$ak_prototype) { 
    202                                 print(' 
    203                 <script type="text/javascript" src="'.get_bloginfo('wpurl').'/wp-includes/js/prototype.js"></script> 
    204                                 '); 
    205                         } 
    206                         $ak_prototype = true; 
    207                 } 
    208         } 
    209 } 
    210  
    211197if (!empty($_REQUEST['akst_action'])) { 
    212198        switch ($_REQUEST['akst_action']) { 
    213199                case 'js': 
     
    214200                        header("Content-type: text/javascript"); 
    215201?> 
    216202function akst_share(id, url, title, html_id) { 
    217         var form = $('akst_form'); 
    218         var post_id = $('akst_post_id'); 
     203        var form = document.getElementById('akst_form'); 
     204        var post_id = document.getElementById('akst_post_id'); 
    219205         
    220206        if (form.style.display == 'block' && post_id.value == id) { 
    221207                form.style.display = 'none'; 
     
    222208                return; 
    223209        } 
    224210         
    225         var link = $('akst_link_' + html_id); 
    226         var offset = Position.cumulativeOffset(link); 
     211        var link = document.getElementById('akst_link_' + id); 
     212        var offset = [0,0]; 
     213         
     214        var element = link; 
     215        while (element) { 
     216                offset[0] += element.offsetLeft; 
     217                offset[1] += element.offsetTop; 
     218                element = element.offsetParent; 
     219        } 
    227220 
    228221<?php 
    229222        foreach ($social_sites as $key => $data) { 
    230                 print(' $("akst_'.$key.'").href = akst_share_url("'.$data['url'].'", url, title);'."\n"); 
     223                print(' document.getElementById("akst_'.$key.'").href = akst_share_url("'.$data['url'].'", url, title);'."\n"); 
    231224        } 
    232225?> 
    233226 
     
    402395} 
    403396add_action('init', 'akst_request_handler', 9999);                        
    404397 
    405 function akst_init() { 
    406         if (function_exists('wp_enqueue_script')) { 
    407                 wp_enqueue_script('prototype'); 
    408         } 
    409 } 
    410 add_action('init', 'akst_init');                         
    411  
    412398function akst_head() { 
    413399        $wp = get_bloginfo('wpurl'); 
    414400        $url = $wp.AKST_FILEPATH; 
    415         ak_prototype(); 
    416401        print(' 
    417402        <script type="text/javascript" src="'.$url.'?akst_action=js"></script> 
    418403        <link rel="stylesheet" type="text/css" href="'.$url.'?akst_action=css" /> 
     
    480465?> 
    481466        <!-- Share This BEGIN --> 
    482467        <div id="akst_form"> 
    483                 <a href="javascript:void($('akst_form').style.display='none');" class="akst_close"><?php _e('Close', 'share-this'); ?></a> 
     468                <a href="javascript:void(document.getElementById('akst_form').style.display='none');" class="akst_close"><?php _e('Close', 'share-this'); ?></a> 
    484469                <ul class="tabs"> 
    485470                        <li id="akst_tab1" class="selected" onclick="akst_share_tab('1');"><?php _e('Social Web', 'share-this'); ?></li> 
    486471                        <li id="akst_tab2" onclick="akst_share_tab('2');"><?php _e('E-mail', 'share-this'); ?></li>