Changeset 373 for trunk


Ignore:
Timestamp:
01/30/2010 01:52:55 AM (2 years ago)
Author:
ofer
Message:

Canned async loading, footer scripts, remote jQuery in the sake of simplicity and compatability, will probably add some when jQuery ui is fixed and out

Location:
trunk/WordPress/plugin/transposh
Files:
2 edited

Legend:

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

    r372 r373  
    1717// source - 0 is human, 1 is google translate - 2 is msn translate , and higher reserved for future engines 
    1818/*global Date, Math, Microsoft, alert, clearTimeout, document, google, jQuery, setTimeout, t_jp, window */ 
    19 // fetch translation from google translate... 
    20 // We first try to avoid conflict with other frameworks 
    21 jQuery.noConflict(); 
    22  
    2319(function ($) { // closure 
    2420    var langLoaded, loadLang, getMSN, 
  • trunk/WordPress/plugin/transposh/transposh.php

    r370 r373  
    116116        add_action('wp_print_styles', array(&$this,'add_transposh_css')); 
    117117        add_action('wp_print_scripts', array(&$this,'add_transposh_js')); 
    118         add_action('wp_head', array(&$this,'add_transposh_async')); 
     118//        add_action('wp_head', array(&$this,'add_transposh_async')); 
    119119        add_action("sm_addurl",array(&$this,'add_sm_transposh_urls')); 
    120120        register_activation_hook(__FILE__, array(&$this,'plugin_activate')); 
     
    461461    function add_transposh_css() { 
    462462        //translation not allowed - no need for the transposh.css 
    463         if(!$this->is_editing_permitted() && !$this->is_auto_translate_permitted()) return;         
     463        if(!$this->is_editing_permitted() && !$this->is_auto_translate_permitted()) return; 
    464464        // actually - this is only needed when editing 
    465465        if (!$this->edit_mode) return; 
     
    484484        if($this->edit_mode || $this->is_auto_translate_permitted()) { 
    485485            //TODO - fix (onetime var) 
    486             wp_deregister_script('jquery'); 
    487             wp_enqueue_script("jquery","http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js",array(),'1.3.2'); 
     486            //  wp_deregister_script('jquery'); 
     487            //wp_enqueue_script("jquery"); 
     488            //wp_enqueue_script("transposh","{$this->transposh_plugin_url}/js/transposh.js",array("jquery"),TRANSPOSH_PLUGIN_VER,true) 
     489            wp_enqueue_script("transposh","{$this->transposh_plugin_url}/js/transposh.js",array("jquery"),TRANSPOSH_PLUGIN_VER); 
     490            // true -> 1, false -> nothing 
     491            wp_localize_script("transposh","t_jp",array( 
     492                    'url' => $this->post_url, 
     493                    'plugin_url' => $this->transposh_plugin_url, 
     494                    'edit' => ($this->edit_mode? '1' : ''), 
     495                    //'rtl' => (in_array ($this->target_language, $GLOBALS['rtl_languages'])? 'true' : ''), 
     496                    'lang' => $this->target_language, 
     497                    // those two options show if the script can support said engines 
     498                    'msn' => (in_array($this->target_language,$GLOBALS['bing_languages']) && $this->options->get_msn_key()  ? '1' : ''), 
     499                    'google' => (in_array($this->target_language,$GLOBALS['google_languages']) ? '1' : ''), 
     500                    'prefix' => SPAN_PREFIX, 
     501                    'msnkey'=>$this->options->get_msn_key(), 
     502                    'preferred'=> $this->options->get_preferred_translator(), 
     503                    'progress'=>$this->edit_mode || $this->options->get_widget_progressbar() ? '1' : '') 
     504//                      'l10n_print_after' => 'try{convertEntities(inlineEditL10n);}catch(e){};' 
     505            ); 
     506            /*wp_enqueue_script("jquery","http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js",array(),'1.3.2');*/ 
    488507            // toying around - for later... 
    489508//            wp_enqueue_script("jquery","http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js",array(),'1.4.1'); 
     
    495514     * @return nothing 
    496515     */ 
    497     function add_transposh_async() { 
     516    // lost in compatability 
     517/*    function add_transposh_async() { 
    498518        if (!$this->edit_mode && !$this->is_auto_translate_permitted()) { 
    499519            return; 
     
    515535        echo "t_jp.progress=".($this->edit_mode || $this->options->get_widget_progressbar() ? 'true' : 'false').";"; 
    516536 
    517         /* 
    518          *         // let's lazy load! (worked, didn't make sense) 
    519 //                jQuery(document).ready( 
    520                 jQuery(window).load( 
    521     function() { 
    522                 jQuery.ajax({ 
    523                         type: 'GET', 
    524                         url: '{$this->transposh_plugin_url}/js/transposh.js?ver=".TRANSPOSH_PLUGIN_VER."', 
    525                         dataType: 'script', 
    526                         cache: true 
    527                 }); 
    528   }); 
    529         */ 
    530537        echo "var tp = document.createElement('script'); tp.type = 'text/javascript'; tp.async = true;"; 
    531538        echo "tp.src = '{$this->transposh_plugin_url}/js/transposh.js?ver=".TRANSPOSH_PLUGIN_VER."';"; 
    532539        echo "(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(tp);"; 
    533540        echo"</script>"; 
    534     } 
     541    }*/ 
    535542 
    536543    /** 
Note: See TracChangeset for help on using the changeset viewer.