Changeset 362
- Timestamp:
- 01/25/2010 09:27:13 AM (2 years ago)
- Location:
- trunk/WordPress/plugin/transposh/js
- Files:
-
- 1 added
- 2 edited
-
transposh.js (modified) (6 diffs)
-
transposhadmin.js (modified) (1 diff)
-
transposhedit.js (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/WordPress/plugin/transposh/js/transposh.js
r358 r362 20 20 (function () { // closure 21 21 var langLoaded, loadLang, 22 // number of phrases that might be translated 23 possibly_translateable, 24 // ids of progress bars 25 progressbar_id = t_jp.prefix + "pbar", 26 progressbar_posted_id = progressbar_id + "_s", 22 27 //Ajax translation 23 done_p = 0, togo= 0, /*Timer for translation aggregation*/ timer, tokens = [], translations = [],28 done_posted = 0, /*Timer for translation aggregation*/ timer, tokens = [], translations = [], 24 29 // the languages supported externally 25 30 // extracted using function above + he|zh-tw|pt that we know 26 google_langs = 'af|sq|ar|be|bg|ca|zh|zh-CN|zh-TW|hr|cs|da|nl|en|et|tl|fi|fr|gl|de|el|iw|hi|hu|is|id|ga|it|ja|ko|lv|lt|mk|ms|mt|no|fa|pl|pt-PT|ro|ru|sr|sk|sl|es|sw|sv|tl|th|tr|uk|vi|cy|yi|he|zh-tw|pt' ,31 google_langs = 'af|sq|ar|be|bg|ca|zh|zh-CN|zh-TW|hr|cs|da|nl|en|et|tl|fi|fr|gl|de|el|iw|hi|hu|is|id|ga|it|ja|ko|lv|lt|mk|ms|mt|no|fa|pl|pt-PT|ro|ru|sr|sk|sl|es|sw|sv|tl|th|tr|uk|vi|cy|yi|he|zh-tw|pt'; 27 32 // got this using Microsoft.Translator.GetLanguages() with added zh and zh-tw for our needs 28 bing_langs = 'ar,bg,zh-chs,zh-cht,cs,da,nl,en,fi,fr,de,el,he,it,ja,ko,pl,pt,ru,es,sv,th,zh,zh-tw'; 29 30 function getgt() 31 { 32 if (typeof google === 'undefined') { 33 langLoaded = function () { 34 getgt(); 35 }; 36 jQuery.xLazyLoader({ 37 // js: 'http://www.google.com/jsapi?callback=loadLang' 38 js: 'http://www.google.com/jsapi', 39 success: loadLang 40 }); 41 } else { 42 jQuery(":button:contains('Suggest - Google')").attr("disabled", "disabled").addClass("ui-state-disabled"); 43 google.language.translate(jQuery("#" + t_jp.prefix + "original").val(), "", t_jp.lang, function (result) { 44 if (!result.error) { 45 jQuery("#" + t_jp.prefix + "translation").val(jQuery("<div>" + result.translation + "</div>").text()) 46 .keyup(); 47 } 48 }); 33 34 // This function fixes the page, it gets a token and translation and fixes this, 35 // since here we only get the automated source, we use this to reduce the code size 36 function fix_page(token, translation) { 37 // Todo - Probably not needed, but in case we get bad stuff 38 if (jQuery.trim(translation).length === 0) { 39 return; 49 40 } 50 } 51 52 // fetch translation from bing translate... 53 function getbt() 54 { 55 if (typeof Microsoft === 'undefined') { 56 jQuery.xLazyLoader({ 57 js: 'http://api.microsofttranslator.com/V1/Ajax.svc/Embed?appId=' + t_jp.msnkey, 58 success: function () { 59 getbt(); 60 } 61 }); 62 63 } else { 64 jQuery(":button:contains('Suggest - Bing')").attr("disabled", "disabled").addClass("ui-state-disabled"); 65 var binglang = t_jp.lang; 66 if (binglang === 'zh') { 67 binglang = 'zh-chs'; 68 } 69 if (binglang === 'zh-tw') { 70 binglang = 'zh-cht'; 71 } 72 try { 73 Microsoft.Translator.translate(jQuery("#" + t_jp.prefix + "original").val(), "", binglang, function (translation) { 74 jQuery("#" + t_jp.prefix + "translation").val(jQuery("<div>" + translation + "</div>").text()) 75 .keyup(); 76 }); 77 } 78 catch (err) { 79 alert("There was an error using Microsoft.Translator - probably a bad key or URL used in key. (" + err + ")"); 80 } 81 } 82 } 83 84 function fix_page(translation, source, segment_id) { 85 var token = jQuery("#" + t_jp.prefix + segment_id).attr('token'), 86 new_text = translation; 87 //reset to the original content - the unescaped version if translation is empty 88 if (jQuery.trim(translation).length === 0) { 89 new_text = jQuery("#" + t_jp.prefix + segment_id).attr('orig'); 90 } 41 // this is an inner function used to fix the images in the case of being inside the edit mode. 42 // if we are not editing, no images will be found and nothing will happen. 43 // even if this happens before the edit scripts adds the images, it won't matter as source is changed too and the 44 // edit script will fix this 45 var fix_image = function () { // handle the image changes 46 var img_segment_id = jQuery(this).attr('id').substr(jQuery(this).attr('id').lastIndexOf('_') + 1), 47 img = jQuery("#" + t_jp.prefix + "img_" + img_segment_id); 48 jQuery("#" + t_jp.prefix + img_segment_id).attr('source', 1); // source is 1 49 img.removeClass('tr-icon-yellow').removeClass('tr-icon-green').addClass('tr-icon-yellow'); 50 }; 51 91 52 // rewrite text for all matching items at once 92 53 jQuery("*[token='" + token + "'][hidden!='y']") 93 .html(new_text) 94 .each(function (i) { // handle the image changes 95 var img_segment_id = jQuery(this).attr('id').substr(jQuery(this).attr('id').lastIndexOf('_') + 1), 96 img = jQuery("#" + t_jp.prefix + "img_" + img_segment_id); 97 jQuery("#" + t_jp.prefix + img_segment_id).attr('source', source); 98 img.removeClass('tr-icon-yellow').removeClass('tr-icon-green'); 99 if (jQuery.trim(translation).length !== 0) { 100 if (source === 1) { 101 //switch to the auto img 102 img.addClass('tr-icon-yellow'); 103 } else { 104 // switch to the fix img 105 img.addClass('tr-icon-green'); 106 } 107 } 108 }); 109 110 // FIX hidden elements too (need to update father's title) 54 .html(translation) 55 .each(fix_image); 56 57 // TODO - FIX hidden elements too (need to update father's title) 111 58 jQuery("*[token='" + token + "'][hidden='y']") 112 .attr('trans', new_text) 113 .each(function (i) { // handle the image changes 114 var img_segment_id = jQuery(this).attr('id').substr(jQuery(this).attr('id').lastIndexOf('_') + 1), 115 img = jQuery("#" + t_jp.prefix + "img_" + img_segment_id); 116 jQuery("#" + t_jp.prefix + img_segment_id).attr('source', source); 117 img.removeClass('tr-icon-yellow').removeClass('tr-icon-green'); 118 if (jQuery.trim(translation).length !== 0) { 119 if (source === 1) { 120 //switch to the auto img 121 img.addClass('tr-icon-yellow'); 122 } else { 123 // switch to the fix img 124 img.addClass('tr-icon-green'); 125 } 126 } 127 }); 128 129 } 130 131 function ajax_translate(translation, source, segment_id) { 59 .attr('trans', translation) 60 .each(fix_image); 61 } 62 63 // we have four params, here two are implicit (source =1 auto translate, lang = target language) 64 function ajax_translate(token, translation) { 132 65 // we aggregate translations together, 200ms from the last translation we will send the timer 133 66 // so here we remove it so nothing unexpected happens 134 67 clearTimeout(timer); 135 68 // push translations 136 tokens.push( jQuery("#" + t_jp.prefix + segment_id).attr('token'));69 tokens.push(token); 137 70 translations.push(translation); 138 71 // This is a change - as we fix the pages before we got actual confirmation (worked well for auto-translation) 139 fix_page(t ranslation, source, segment_id);72 fix_page(token, translation); 140 73 timer = setTimeout(function () { 141 74 var data = { 142 l ang: t_jp.lang,143 s ource: source,144 translation_posted: " 1",145 items: tokens.length 75 ln0: t_jp.lang, // implicit 76 sr0: 1, // implicit auto translate... 77 translation_posted: "2", 78 items: tokens.length // we can do this here because all tokens will be different 146 79 }, i; 147 80 for (i = 0; i < tokens.length; i += 1) { … … 149 82 data["tr" + i] = translations[i]; 150 83 // We are pre-accounting the progress bar here - which is not very nice 151 if (source > 0) {152 done_p+= jQuery("*[token='" + tokens[i] + "']").size();153 }84 //if (source > 0) { 85 done_posted += jQuery("*[token='" + tokens[i] + "']").size(); 86 //} 154 87 } 155 88 jQuery.ajax({ … … 159 92 success: function () { 160 93 // Success now only updates the save progress bar (green) 161 if (t_jp.progress) { 162 if (togo > 4 && source > 0) { 163 jQuery("#progress_bar2").progressbar('value', done_p / togo * 100); 164 } 165 166 } 167 }, 168 169 error: function (req) { 170 if (source === 0) { 171 alert("Error !!! failed to translate.\n\nServer's message: " + req.statusText); 172 } 94 jQuery('#' + progressbar_posted_id).progressbar('value', done_posted / possibly_translateable * 100); 173 95 } 96 // we removed the error function, as there is no alert for automated thing, this will silently fail 97 // which although bad, is what we can do for now 174 98 }); 175 99 translations = []; 176 100 tokens = []; 177 }, 200); // wait 200 ms... 178 } 179 101 }, 200); // wait 200 ms... -- TODO, maybe do - items*3 102 } 103 104 105 // function that creates the progress bar html 106 // TODO: change the id 107 function create_progress_bar() { 108 // progress bar is for alteast 5 items 109 jQuery("#" + t_jp.prefix + "credit").css({ 110 'overflow': 'auto' 111 }).append('<div style="float: left;width: 90%;height: 10px" id="' + progressbar_id + '"/><div style="margin-bottom:10px;float:left;width: 90%;height: 10px" id="' + progressbar_posted_id + '"/>'); 112 jQuery('#' + progressbar_id).progressbar({ 113 value: 0 114 }); 115 jQuery('#' + progressbar_posted_id).progressbar({ 116 value: 0 117 }); 118 // color the "save" bar 119 jQuery('#' + progressbar_posted_id + " > div").css({ 120 'background': '#28F828', 121 'border' : "#08A908 1px solid" 122 }); 123 } 180 124 181 125 //function for auto translation 182 126 function do_auto_translate() { 183 127 // auto_translated_previously... 184 var auto_t_p = [], done; 185 if (t_jp.progress) { 186 togo = jQuery("." + t_jp.prefix + '[source=""]').size(); 187 //alert(togo); 188 // progress bar is for alteast 5 items 189 if (togo > 4) { 190 jQuery("#" + t_jp.prefix + "credit").append('<div style="float: left;width: 90%;height: 10px" id="progress_bar"/><div style="margin-bottom:10px;float:left;width: 90%;height: 10px" id="progress_bar2"/>'); 191 jQuery("#progress_bar").progressbar({ 192 value: 0 193 }); 194 jQuery("#progress_bar2").progressbar({ 195 value: 0 196 }); 197 // color the "save" bar 198 jQuery("#progress_bar2 > div").css({ 199 'background': '#28F828', 200 'border' : "#08A908 1px solid" 201 }); 202 } 203 done = 0; 204 } 128 var auto_translated_phrases = []; 205 129 jQuery("." + t_jp.prefix + '[source=""]').each(function (i) { 206 var translated_id = jQuery(this).attr('id'), 130 // not needed! 131 //var translated_id = jQuery(this).attr('id'), 132 var token = jQuery(this).attr('token'), 207 133 //alert(translated_id); 134 // we only have orig if we have some translation,? 208 135 to_trans = jQuery(this).attr('orig'); 209 136 if (to_trans === undefined) { 210 137 to_trans = jQuery(this).html(); 211 138 } 212 if (auto_t _p[to_trans] !== 1) {213 auto_t _p[to_trans] = 1;139 if (auto_translated_phrases[to_trans] !== 1) { 140 auto_translated_phrases[to_trans] = 1; 214 141 google.language.translate(to_trans, "", t_jp.lang, function (result) { 215 142 if (!result.error) { 216 var segment_id = translated_id.substr(translated_id.lastIndexOf('_') + 1); 143 // we no longer refer to segment IDs, just tokens 144 //var segment_id = translated_id.substr(translated_id.lastIndexOf('_') + 1); 217 145 // No longer need because now included in the ajax translate 218 146 //fix_page(jQuery("<div>" + result.translation + "</div>").text(), 1, segment_id); 219 ajax_translate(jQuery("<div>" + result.translation + "</div>").text(), 1, segment_id); 220 if (t_jp.progress) { 221 done = togo - jQuery("." + t_jp.prefix + '[source=""]').size(); 222 if (togo > 4) { 223 jQuery("#progress_bar").progressbar('value', done / togo * 100); 224 } 225 } 147 to_trans = jQuery(this).attr('orig'); 148 ajax_translate(token, jQuery("<div>" + result.translation + "</div>").text()); 149 // update the regular progress bar 150 // done = possibly_translateable - jQuery("." + t_jp.prefix + '[source=""]').size(); 151 jQuery('#' + progressbar_id).progressbar('value', (possibly_translateable - jQuery("." + t_jp.prefix + '[source=""]').size()) / possibly_translateable * 100); 226 152 } 227 153 }); 228 154 } 229 });230 }231 232 function confirm_close() {233 jQuery('<div id="dial" title="Close without saving?"><p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>You have made a change to the translation. Are you sure you want to discard it?</p></div>').appendTo("body").dialog({234 bgiframe: true,235 resizable: false,236 height: 140,237 modal: true,238 overlay: {239 backgroundColor: '#000',240 opacity: 0.5241 },242 buttons: {243 'Discard': function () {244 jQuery("#" + t_jp.prefix + "translation").data("edit", {245 changed: false246 });247 jQuery(this).dialog('close');248 jQuery("#" + t_jp.prefix + "d-tabs").dialog('close');249 },250 Cancel: function () {251 jQuery(this).dialog('close');252 }253 }254 });255 }256 257 //Open translation dialog258 function translate_dialog(segment_id) {259 var tButtons = {}, hButtons = {};260 //only add button is bing support is defined for the language (and we got some key)261 if (bing_langs.indexOf(t_jp.lang) > -1 && t_jp.msnkey !== '') {262 //ar,zh-chs,zh-cht,nl,en,fr,de,he,it,ja,ko,pl,pt,ru,es263 tButtons['Suggest - Bing'] = function () {264 getbt();265 };266 }267 268 // Only add button if google supports said language269 if (google_langs.indexOf(t_jp.lang) > -1) {270 tButtons['Suggest - Google'] = function () {271 getgt();272 };273 }274 /* 'Next': function () {275 alert(parseInt(segment_id) + 1);276 translate_dialog(parseInt(segment_id) + 1);277 },278 'Combine - Next': function () {279 something?();280 //.next? .next all?281 },*/282 tButtons.Ok = function () {283 var translation = jQuery('#' + t_jp.prefix + 'translation').val();284 if (jQuery('#' + t_jp.prefix + 'translation').data("edit").changed) {285 ajax_translate(translation, 0, segment_id);286 jQuery("#" + t_jp.prefix + "translation").data("edit", {287 changed: false288 });289 }290 jQuery(this).dialog('close');291 };292 //tButtons["beep"] = function () {alert(Microsoft.Translator.GetLanguages())};293 hButtons = {294 Close: function () {295 jQuery(this).dialog('close');296 }297 };298 299 jQuery("#" + t_jp.prefix + "d-tabs").remove();300 jQuery('<div id="' + t_jp.prefix + 'd-tabs" title="Edit Translation"/>').appendTo("body");301 jQuery("#" + t_jp.prefix + "d-tabs").append('<ul/>').tabs({302 cache: true303 })304 .tabs('add', "#" + t_jp.prefix + "d-tabs-1", 'Translate')305 .tabs('add', t_jp.post_url + '?tr_token_hist=' + jQuery("#" + t_jp.prefix + segment_id).attr('token') + '&lang=' + t_jp.lang, 'History')306 .css("text-align", "left")307 .css("padding", 0)308 .bind('tabsload', function (event, ui) {309 //TODO, formatting here, not server side310 jQuery("table", ui.panel).addClass("ui-widget ui-widget-content").css({311 'width' : '95%',312 'padding' : '0'313 });314 //jQuery("table thead th:last",ui.panel).after("<th/>");315 jQuery("table thead tr", ui.panel).addClass("ui-widget-header");316 //jQuery("table tbody tr", ui.panel).append('<td/>');317 jQuery("table tbody td[source='1']", ui.panel).append('<span title="computer" style="display: inline-block; margin-right: 0.3em;" class="ui-icon ui-icon-gear"></span>');318 jQuery("table tbody td[source='0']", ui.panel).append('<span title="human" style="display: inline-block; margin-right: 0.3em;" class="ui-icon ui-icon-person"></span>');319 //jQuery("table tbody tr:first td:last", ui.panel).append('<span title="remove this translation" id="' + t_jp.prefix + 'revert" style="float: left; margin-right: 0.3em;" class="ui-icon ui-icon-scissors"/>');320 //jQuery("#" + t_jp.prefix + "revert").click(function () {321 //alert ('hi');322 //});323 })324 .bind('tabsselect', function (event, ui) {325 // Change buttons326 if (jQuery(ui.tab).text() === 'Translate') {327 jQuery("#" + t_jp.prefix + "d-tabs").dialog('option', 'buttons', tButtons);328 } else {329 jQuery("#" + t_jp.prefix + "d-tabs").dialog('option', 'buttons', hButtons);330 }331 })332 .bind('dialogbeforeclose', function (event, ui) {333 if (jQuery("#" + t_jp.prefix + "translation").data("edit").changed) {334 confirm_close();335 return false;336 }337 return true;338 });339 // fix for templates messing with li340 jQuery("#" + t_jp.prefix + "d-tabs li").css("list-style-type", "none").css("list-style-position", "outside");341 jQuery("#" + t_jp.prefix + "d-tabs-1").css("padding", "1px").append(342 /*'<table><tr><td>'+*/343 '<form id="' + t_jp.prefix + 'form">' +344 '<fieldset>' +345 '<label for="original">Original Text</label>' +346 '<textarea cols="80" row="3" name="original" id="' + t_jp.prefix + 'original" class="text ui-widget-content ui-corner-all" readonly="y"/>' +347 '<label for="translation">Translate To</label>' +348 '<textarea cols="80" row="3" name="translation" id="' + t_jp.prefix + 'translation" value="" class="text ui-widget-content ui-corner-all"/>' +349 '</fieldset>' +350 '</form>'/* +351 '</td><td style="width:32px">' +352 '<img src="/wp-content/plugins/transposh/img/knob/knobs/left.png"/>' +353 '<img src="/wp-content/plugins/transposh/img/knob/knobs/right.png"/>' +354 '<img id="smart" src="/wp-content/plugins/transposh/img/knob/knobs/smart.png"/>'+355 '<img src="/wp-content/plugins/transposh/img/knob/knobs/merge.png"/>'+356 '</td></tr></table>'*/);357 /*jQuery("#smart").click(function () {358 grabnext(segment_id);359 });*/360 jQuery("#" + t_jp.prefix + "d-tabs-1 label").css("display", "block");361 jQuery("#" + t_jp.prefix + "d-tabs-1 textarea.text").css({362 'margin-bottom': '12px',363 'width' : '95%',364 'padding' : '.4em'365 });366 jQuery("#" + t_jp.prefix + "original").val(jQuery("#" + t_jp.prefix + segment_id).attr('orig'));367 jQuery("#" + t_jp.prefix + "translation").val(jQuery("#" + t_jp.prefix + segment_id).html());368 if (jQuery("#" + t_jp.prefix + segment_id).attr('trans')) {369 jQuery("#" + t_jp.prefix + "translation").val(jQuery("#" + t_jp.prefix + segment_id).attr('trans'));370 }371 jQuery("#" + t_jp.prefix + "translation").data("edit", {372 changed: false373 });374 jQuery("#" + t_jp.prefix + "translation").keyup(function (e) {375 if (jQuery("#" + t_jp.prefix + segment_id).text() !== jQuery(this).val()) {376 jQuery(this).css("background", "yellow");377 jQuery(this).data("edit", {378 changed: true379 });380 } else {381 jQuery(this).css("background", "");382 jQuery(this).data("edit", {383 changed: false384 });385 }386 });387 jQuery("#" + t_jp.prefix + "d-tabs").dialog({388 bgiframe: true,389 modal: true,390 //width: 'auto',391 width: 500,392 buttons: tButtons393 155 }); 394 156 } … … 413 175 }); 414 176 415 var translationstats, possibly_translateable, now; 177 var now; 178 // translationstats not used yet 179 //var translationstats, possibly_translateable, now; 416 180 // now lets check if auto translate is needed 417 translationstats = jQuery("meta[name=translation-stats]").attr("content");181 //translationstats = jQuery("meta[name=translation-stats]").attr("content"); 418 182 // Logic borrowed from jquery and http://json.org/json2.js - Didn't see the reason for that, if someone can modify the html, he can probably do any script he wants too... 419 183 /*if (/^[\],:{}\s]*$/.test(translationstats.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, "@") … … 422 186 423 187 // Try to use the native JSON parser first 424 if (window.JSON && window.JSON.parse) {188 /*if (window.JSON && window.JSON.parse) { 425 189 translationstats = window.JSON.parse(translationstats); 426 190 427 191 } else { 428 192 translationstats = (new Function("return " + translationstats))(); 429 } 193 }*/ 430 194 431 195 /*} else { … … 434 198 435 199 // var translationstats = window["eval"]("(" + jQuery("meta[name=translation-stats]").attr("content") + ")"), possibly_translateable, now; 436 if (translationstats !== undefined) { 437 possibly_translateable = (translationstats.total_phrases - translationstats.translated_phrases - (translationstats.meta_phrases - translationstats.meta_translated_phrases)); 438 now = new Date(); 439 // we'll only auto-translate and load the stuff if we either have more than 5 candidate translations, or more than one at 4am, and this language is supported... 440 if ((possibly_translateable > 5 || (now.getHours() === 4 && possibly_translateable > 0)) && google_langs.indexOf(t_jp.lang) > -1) { 441 // TODO - FIX ME! (islands) 442 jQuery.ajaxSetup({ 443 cache: true 444 }); 445 // if we have a progress bar, we need to load the jqueryui before the auto translate, after the google was loaded, otherwise we can just go ahead 446 langLoaded = function () { 447 if (t_jp.progress) { 448 jQuery.getScript(t_jp.plugin_url + '/js/lazy.js', function () { 449 jQuery.xLazyLoader({ 450 js: 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js', 451 css: 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/ui-lightness/jquery-ui.css', 452 success: function () { 453 do_auto_translate(); 454 } 455 }); 200 //if (translationstats !== undefined) { 201 //possibly_translateable = (translationstats.total_phrases - translationstats.translated_phrases - (translationstats.meta_phrases - translationstats.meta_translated_phrases)); 202 possibly_translateable = jQuery("." + t_jp.prefix + '[source=""]').size(); 203 204 now = new Date(); 205 // we'll only auto-translate and load the stuff if we either have more than 5 candidate translations, or more than one at 4am, and this language is supported... 206 if ((possibly_translateable > 5 || (now.getHours() === 4 && possibly_translateable > 0)) && google_langs.indexOf(t_jp.lang) > -1) { 207 // TODO - FIX ME! (islands) 208 jQuery.ajaxSetup({ 209 cache: true 210 }); 211 // if we have a progress bar, we need to load the jqueryui before the auto translate, after the google was loaded, otherwise we can just go ahead 212 langLoaded = function () { 213 if (t_jp.progress) { 214 jQuery.getScript(t_jp.plugin_url + '/js/lazy.js', function () { 215 jQuery.xLazyLoader({ 216 js: 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js', 217 css: 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/ui-lightness/jquery-ui.css', 218 success: function () { 219 create_progress_bar(); 220 do_auto_translate(); 221 } 456 222 }); 457 } else { 458 do_auto_translate(); 459 } 460 }; 461 // we now start the chain that leads to auto-translate (with or without progress) 462 jQuery.getScript('http://www.google.com/jsapi', loadLang); 463 } 464 } 223 }); 224 } else { 225 do_auto_translate(); 226 } 227 }; 228 // we now start the chain that leads to auto-translate (with or without progress) 229 jQuery.getScript('http://www.google.com/jsapi', loadLang); 230 } 231 //} 465 232 466 233 // this is the part when we have editor support 467 234 if (t_jp.edit) { 468 // lets add the images 469 jQuery("." + t_jp.prefix).each(function (i) { 470 var translated_id = jQuery(this).attr('id').substr(jQuery(this).attr('id').lastIndexOf('_') + 1), img; 471 jQuery(this).after('<span id="' + t_jp.prefix + 'img_' + translated_id + '" class="tr-icon" title="' + jQuery(this).attr('orig') + '"></span>'); 472 img = jQuery('#' + t_jp.prefix + 'img_' + translated_id); 473 img.click(function () { 474 // if we detect that jQuery.ui is missing (TODO - check tabs - etal) we load it first 475 if (typeof jQuery.fn.tabs !== 'function') { 476 jQuery.ajaxSetup({ 477 cache: true 478 }); 479 jQuery.getScript(t_jp.plugin_url + '/js/lazy.js', function () { 480 jQuery.xLazyLoader({ 481 js: 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js', 482 css: 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/ui-lightness/jquery-ui.css', 483 success: function () { 484 translate_dialog(translated_id); 485 } 486 }); 487 }); 488 } else { 489 translate_dialog(translated_id); 490 } 491 return false; 492 }).css({ 493 'border': '0px', 494 'margin': '1px', 495 'padding': '0px' 496 }); 497 if (jQuery(this).attr('source') === '1') { 498 img.addClass('tr-icon-yellow'); 499 } 500 else if (jQuery(this).attr('source') === '0') { 501 img.addClass('tr-icon-green'); 502 } 503 // if the image is sourced from a hidden element - kindly "show" this 504 if (jQuery(this).attr('hidden') === 'y') { 505 img.css({ 506 'opacity': '0.6' 507 }); 508 } 509 }); 235 jQuery.getScript(t_jp.plugin_url + '/js/transposhedit.js');// , loadLang); // TODO!!! 510 236 } 511 237 }); -
trunk/WordPress/plugin/transposh/js/transposhadmin.js
r360 r362 41 41 }, 42 42 43 error: function( req) {43 error: function() { 44 44 } 45 45 });
Note: See TracChangeset
for help on using the changeset viewer.
