Changeset 160


Ignore:
Timestamp:
04/21/2009 02:16:42 PM (3 years ago)
Author:
ofer
Message:

Lots of work into removal of the image tag from the parser and into the javascript

Location:
trunk/WordPress/plugin/transposh
Files:
1 added
4 edited

Legend:

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

    r157 r160  
    800800        if(($is_edit_mode || ($enable_auto_translate && $translated_text == NULL)) && in_array('body', $tags_list)) 
    801801        { 
    802                 $span_prefix = SPAN_PREFIX; 
    803                 // We will mark translated text with tr_t class and untranslated with tr_u 
    804                 $span = "<span class=\"$span_prefix"; 
    805  
    806802                //Use base64 encoding to make that when the page is translated (i.e. update_translation) we 
    807803                //get back exactlly the same string without having the client decode/encode it in anyway. 
    808                 $token = "token=\"" . base64_url_encode($original_text) . "\""; 
     804                $token = 'token="' . base64_url_encode($original_text) . '"'; 
     805 
     806                // We will mark translated text with tr_t class and untranslated with tr_u 
     807                $span = '<span id="'.SPAN_PREFIX."{$segment_id}\" $token "; 
     808                // those are needed for on the fly image creation 
     809                if ($is_edit_mode) { 
     810                        $span .= "source=\"$source\" "; 
     811                        if($translated_text != NULL) 
     812                          $span .= "orig=\"$original_text\" "; 
     813                } 
     814                $span .= 'class="'.SPAN_PREFIX; 
    809815 
    810816                if($translated_text == NULL) 
    811817                { 
    812                         $span .= "u\" id=\"{$span_prefix}{$segment_id}\" $token>"; 
    813                         $span .= $original_text . '</span>'; 
     818                        $span .= 'u">'; 
     819                        $span .= $original_text; 
    814820                } 
    815821                else 
    816822                { 
    817                         $span .= "t\" id=\"{$span_prefix}{$segment_id}\" $token>"; 
    818                         $span .= $translated_text . "</span>"; 
    819                         $is_translated = TRUE; 
    820                 } 
     823                        $span .= 't">'; 
     824                        $span .= $translated_text; 
     825                ////    $is_translated = TRUE; 
     826                } 
     827                $span .= '</span>'; 
    821828 
    822829                //Insert text (either original or translated) marked by a <span> 
     
    825832 
    826833                //Insert image to allow editing this segment (only in explicit edit) 
    827                 if($is_edit_mode) { 
     834                // TODO: check removal 
     835                /*if($is_edit_mode) { 
    828836                        $img = get_img_tag($original_text, $translated_text, $source, $segment_id, $is_translated); 
    829837                        update_translated_page($end + 1, - 1, $img); 
    830                 } 
     838                }*/ 
    831839                //Increment only after both text and image are generated so they 
    832840                //will be the same for each translated segement 
     
    939947 * placed within the img tag for use on client side operation (jquery) 
    940948 */ 
    941 function get_img_tag($original, $translation, $source, $segment_id, $is_translated = FALSE) 
     949/*function get_img_tag($original, $translation, $source, $segment_id, $is_translated = FALSE) 
    942950{ 
    943951        global $plugin_url, $lang, $home_url; 
     
    969977 
    970978        return $img; 
    971 } 
     979}*/ 
    972980 
    973981?> 
  • trunk/WordPress/plugin/transposh/css/transposh.css

    r155 r160  
    3232    border: 0px;  
    3333    margin: 0px; 
     34} 
     35 
     36.tr-icon { 
     37        background-image:url(../img/tr_imgs.png); 
     38        height:12px; 
     39        width:12px; 
     40        background-repeat:no-repeat; 
     41        overflow:hidden; 
     42        text-indent:-99999px; 
     43} 
     44.tr-icon-yellow { 
     45        background-position:-12px -0px; 
     46} 
     47.tr-icon-green { 
     48        background-position:-24px -0px; 
    3449} 
    3550 
  • trunk/WordPress/plugin/transposh/js/transposh.js

    r159 r160  
    137137} 
    138138 
    139 //to run at start 
    140 jQuery.noConflict(); 
    141 //read parameters 
    142 var transposh_params = new Array();  
    143 jQuery("script[src*='transposh.js']").each(function (i) { 
    144         var query_string = unescape(this.src.substring(this.src.indexOf('?')+1)); 
    145         var parms = query_string.split('&'); 
    146         for (var i=0; i<parms.length; i++) { 
    147                 var pos = parms[i].indexOf('='); 
    148                 if (pos > 0) { 
    149                         var key = parms[i].substring(0,pos); 
    150                         var val = parms[i].substring(pos+1); 
    151                         transposh_params[key] = val;     
    152                 } 
    153         } 
    154 }); 
    155  
    156139//Open translation dialog  
    157140/*function translate_dialog(original, trans, segment_id) 
     
    217200                        //TODO, formatting here, not server side 
    218201                        jQuery("table",ui.panel).addClass("ui-widget ui-widget-content").css({'width' : '95%', 'padding' : '0'}); 
     202                        jQuery("table thead th:last",ui.panel).after("<th/>"); 
    219203                        jQuery("table thead tr",ui.panel).addClass("ui-widget-header"); 
     204                        jQuery("table tbody tr",ui.panel).append('<td/>'); 
     205                        jQuery("table tbody tr:first td:last",ui.panel).append('<span id="tr_revert" style="float: left; margin-right: 0.3em;" class="ui-icon ui-icon-scissors"/>'); 
     206                        jQuery("#tr_revert").click(function () {  
     207                      alert ('hi');  
     208                        }); 
    220209                }) 
    221210                .bind('tabsselect', function(event, ui) { 
     
    246235        jQuery("#trd-tabs-1 label").css("display","block"); 
    247236        jQuery("#trd-tabs-1 textarea.text").css({'margin-bottom':'12px', 'width' : '95%', 'padding' : '.4em'}); 
    248         jQuery("#tr_original").val(jQuery("#tr_img_" + segment_id).attr('title')); 
     237        jQuery("#tr_original").val(jQuery("#tr_" + segment_id).attr('orig')); 
    249238        jQuery("#tr_translation").val(jQuery("#tr_" + segment_id).html()); 
    250239        jQuery("#tr_translation").data("edit", { changed: false}); 
     
    285274} 
    286275 
     276//to run at start 
     277jQuery.noConflict(); 
     278//read parameters 
     279var transposh_params = new Array();  
     280jQuery("script[src*='transposh.js']").each(function (i) { 
     281        var query_string = unescape(this.src.substring(this.src.indexOf('?')+1)); 
     282        var parms = query_string.split('&'); 
     283        for (var i=0; i<parms.length; i++) { 
     284                var pos = parms[i].indexOf('='); 
     285                if (pos > 0) { 
     286                        var key = parms[i].substring(0,pos); 
     287                        var val = parms[i].substring(pos+1); 
     288                        transposh_params[key] = val;     
     289                } 
     290        } 
     291}); 
     292 
    287293google.load("language", "1"); 
    288294jQuery(document).ready( 
    289295        function() { 
    290296                do_auto_translate(); 
     297                if (transposh_params['edit']) { 
     298                        // lets add the images 
     299                        jQuery(".tr_t,.tr_u").each(function (i) { 
     300                                var translated_id = jQuery(this).attr('id').substr(jQuery(this).attr('id').lastIndexOf('_')+1); 
     301                                jQuery(this).after('<img id="tr_img_'+translated_id+'" class="tr-icon" size="12x12" title="'+jQuery(this).attr('orig')+'" src="'+transposh_params['post_url']+'?tp_gif=y"/>'); 
     302                                jQuery('#tr_img_'+translated_id).click(function () { 
     303                                      translate_dialog(translated_id); 
     304                                      }); 
     305                                if (jQuery(this).hasClass('tr_t')) { 
     306                                if (jQuery(this).attr('source') == '1') 
     307                                        jQuery('#tr_img_'+translated_id).addClass('tr-icon-yellow'); 
     308                                else 
     309                                        jQuery('#tr_img_'+translated_id).addClass('tr-icon-green'); 
     310                                } 
     311                        }); 
     312                } 
    291313        } 
    292314); 
  • trunk/WordPress/plugin/transposh/transposh.php

    r155 r160  
    138138                get_translation_history($_GET['tr_token_hist'], $_GET['lang']); 
    139139        } 
     140        elseif ($_GET['tp_gif']) { 
     141                $trans_gif_64 = "R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="; 
     142                header("Content-type: image/gif"); 
     143                print(base64_decode($trans_gif_64)); 
     144                exit; 
     145        } 
    140146        else 
    141147        { 
     
    374380        } 
    375381 
    376         $overlib_dir = "$plugin_url/js/overlibmws"; 
     382        //$overlib_dir = "$plugin_url/js/overlibmws"; 
    377383 
    378384        if($is_edit_param_enabled) 
     
    385391                wp_enqueue_script("overlibmws5","$overlib_dir/overlibmws_shadow.js",array("overlibmws4"),'1.0');*/ 
    386392                wp_enqueue_script("jqueryui","http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.1/jquery-ui.min.js",array("jquery"),'1.7.1'); 
     393                $edit_mode = "&edit=y"; 
    387394        } 
    388395 
     
    393400                wp_enqueue_script("jquery","http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js",array(),'1.3.2'); 
    394401                wp_enqueue_script("google","http://www.google.com/jsapi",array(),'1'); 
    395                 wp_enqueue_script("transposh","$plugin_url/js/transposh.js?post_url=$post_url&lang={$lang}",array("jquery"),'1.0'); 
     402                wp_enqueue_script("transposh","$plugin_url/js/transposh.js?post_url=$post_url{$edit_mode}&lang={$lang}&prefix=".SPAN_PREFIX,array("jquery"),'1.0'); 
    396403        } 
    397404} 
Note: See TracChangeset for help on using the changeset viewer.