Changeset 354


Ignore:
Timestamp:
01/12/2010 10:31:32 PM (2 years ago)
Author:
ofer
Message:

Cleaned up script generated for header.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/WordPress/plugin/transposh/transposh.php

    r349 r354  
    487487            // toying around - for later... 
    488488            //wp_enqueue_script("jquery","http://code.jquery.com/jquery-1.4a2.min.js",array(),'1.4a2'); 
    489         } 
    490     } 
    491  
    492  
     489            //wp_enqueue_script("jquery","http://api.jquery.com/scripts/jquery-1.4.js",array(),'1.4b'); 
     490        } 
     491    } 
     492 
     493    /** 
     494     * Inserts the transposh async loading in the head. 
     495     * @return nothing 
     496     */ 
    493497    function add_transposh_async() { 
    494498        if (!$this->edit_mode && !$this->is_auto_translate_permitted()) { 
     
    496500        } 
    497501 
    498         echo "<script type=\"text/javascript\"> 
    499  
    500         var _tr_p=_tr_p || []; 
    501         _tr_p.post_url='{$this->post_url}'; 
    502         _tr_p.plugin_url='{$this->transposh_plugin_url}'; 
    503         _tr_p.edit=".($this->edit_mode? 'true' : 'false')."; 
    504         _tr_p.lang='{$this->target_language}'; 
    505         _tr_p.prefix='".SPAN_PREFIX."'; 
    506         _tr_p.msnkey='{$this->options->get_msn_key()}'; 
    507         _tr_p.progress=".($this->edit_mode || $this->options->get_widget_progressbar() ? 'true' : 'false')."; 
    508  
    509   (function() { 
    510     var tp = document.createElement('script'); tp.type = 'text/javascript'; tp.async = true; 
    511     tp.src = '{$this->transposh_plugin_url}/js/transposh.js?ver=".TRANSPOSH_PLUGIN_VER."'; 
    512     (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(tp); 
    513   })(); 
    514  
    515 </script>"; 
     502        echo "<script type=\"text/javascript\">"; 
     503        echo "var t_jp=t_jp || [];"; 
     504        echo "t_jp.post_url='{$this->post_url}';"; 
     505        echo "t_jp.plugin_url='{$this->transposh_plugin_url}';"; 
     506        echo "t_jp.edit=".($this->edit_mode? 'true' : 'false').";"; 
     507        //echo "t_jp.rtl=".(in_array ($this->target_language, $GLOBALS['rtl_languages'])? 'true' : 'false').";"; 
     508        echo "t_jp.lang='{$this->target_language}';"; 
     509        echo "t_jp.prefix='".SPAN_PREFIX."';"; 
     510        echo "t_jp.msnkey='{$this->options->get_msn_key()}';"; 
     511        echo "t_jp.progress=".($this->edit_mode || $this->options->get_widget_progressbar() ? 'true' : 'false').";"; 
     512 
     513        /* 
     514         *         // let's lazy load! (worked, didn't make sense) 
     515//                jQuery(document).ready( 
     516                jQuery(window).load( 
     517    function() { 
     518                jQuery.ajax({ 
     519                        type: 'GET', 
     520                        url: '{$this->transposh_plugin_url}/js/transposh.js?ver=".TRANSPOSH_PLUGIN_VER."', 
     521                        dataType: 'script', 
     522                        cache: true 
     523                }); 
     524  }); 
     525        */ 
     526        echo "var tp = document.createElement('script'); tp.type = 'text/javascript'; tp.async = true;"; 
     527        echo "tp.src = '{$this->transposh_plugin_url}/js/transposh.js?ver=".TRANSPOSH_PLUGIN_VER."';"; 
     528        echo "(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(tp);"; 
     529        echo"</script>"; 
    516530    } 
    517531 
Note: See TracChangeset for help on using the changeset viewer.