Changeset 670


Ignore:
Timestamp:
11/22/2011 01:15:23 AM (6 months ago)
Author:
ofer
Message:

Fix some errors in edit mode, including adapting to new translation functions and rid of the lazyloader error which was in our system for quite long, however this is just delayed for now for some other places such as keyboard and other original language loadings

File:
1 edited

Legend:

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

    r667 r670  
    8383    prefix = t_jp.prefix, 
    8484    idprefix = "#" + prefix, 
     85    localeloaded = false, 
    8586    previcon = 'prev', 
    8687    nexticon = 'next', 
     
    154155                tr0: translation 
    155156            }, 
    156             // TODO: This probably needs a revision! 
    157157            error: function (req) { 
     158                fix_page_human(token, '', 1); // Will turn things back, almost 
    158159                alert("Problem saving translation, contact support.\n\nServer's message: " + req.statusText); 
    159160            } 
     
    184185                $(idprefix + "translation").val($("<div>" + $.trim(result.data.translations[0].translatedText) + "</div>").text()) 
    185186                .keyup(); 
    186             }); 
     187            }, t_jp.lang); 
    187188        } 
    188189    } 
     
    194195            $(idprefix + "translation").val($("<div>" + $.trim(result[0].TranslatedText) + "</div>").text()) 
    195196            .keyup(); 
    196         }); 
    197     } 
    198  
    199     // perform apertium translate of single phrase via jsonp 
    200     function apertium_trans(to_trans, callback) { 
    201         $.ajax({ 
    202             url: 'http://api.apertium.org/json/translate?q=' + encodeURIComponent(to_trans) + '&langpair=en%7C' + t_jp.lang, // || &key=YOURAPIKEY&markUnknown=yes 
    203             dataType: "jsonp", 
    204             success: callback 
    205         }); 
     197        }, t_jp.binglang); 
    206198    } 
    207199 
     
    209201    function getat() 
    210202    { 
    211         apertium_trans($(idprefix + "original").val(), function (result) { 
     203        t_jp.dat($(idprefix + "original").val(), function (result) { 
    212204            $(idprefix + "translation").val($("<div>" + $.trim(result.responseData.translatedText) + "</div>").text()) 
    213205            .keyup(); 
    214         }); 
     206        }, t_jp.lang); 
    215207    } 
    216208 
     
    753745        $(this).after('<span id="' + prefix + 'img_' + translated_id + '" class="tr-icon" title="' + $(this).attr('data-orig') + '"></span>'); 
    754746        img = $(idprefix + 'img_' + translated_id); 
     747        // internal function used to load locale in two needed cases (where we load jQueryui and not...) 
     748        var loadlocaleandrundialog = function() { 
     749                if (t_jp.locale && !localeloaded) { 
     750                    $.getScript(t_jp.plugin_url + '/js/l/'+t_jp.lang+'.js', function () { 
     751                        localeloaded = true; 
     752                        translate_dialog(translated_id); 
     753                    }); 
     754                } else { 
     755                    translate_dialog(translated_id); 
     756                } 
     757        } 
    755758        img.click(function () { 
    756759            //  if we detect that $.ui is missing (TODO - check tabs - etal) we load it first, the added or solves a jquery tools conflict !!!!!!!!!!! 
     
    763766                        js: t_jp.jQueryUI + 'jquery-ui.min.js', 
    764767                        css: t_jp.jQueryUI + 'themes/'+ t_jp.theme + '/jquery-ui.css', 
    765                         success: function () { 
    766                             // Load locale - todo - better... 
    767                             if (t_jp.locale) { 
    768                                 $.xLazyLoader({ 
    769                                     js: [t_jp.plugin_url + '/js/l/'+t_jp.lang+'.js'], 
    770                                     success: function () { 
    771                                         translate_dialog(translated_id); 
    772                                     } 
    773                                 }); 
    774                             } else { 
    775                                 translate_dialog(translated_id); 
    776                             } 
    777                         } 
     768                        success: loadlocaleandrundialog 
    778769                    }); 
    779770                }); 
    780771            } else { 
    781                 if (t_jp.locale) { 
    782                     $.xLazyLoader({ 
    783                         js: [t_jp.plugin_url + '/js/l/'+t_jp.lang+'.js'], 
    784                         success: function () { 
    785                             translate_dialog(translated_id); 
    786                         } 
    787                     }); 
    788                 } else { 
    789                     translate_dialog(translated_id); 
    790                 } 
     772                loadlocaleandrundialog(); 
    791773            } 
    792774            return false; 
Note: See TracChangeset for help on using the changeset viewer.