- Timestamp:
- 11/22/2011 04:25:25 PM (6 months ago)
- Location:
- trunk/WordPress/plugin/transposh/js
- Files:
-
- 2 edited
-
transposh.js (modified) (3 diffs)
-
transposhedit.js (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/WordPress/plugin/transposh/js/transposh.js
r667 r671 274 274 } 275 275 276 // helper function for lazy running277 function lazyrun(func) {278 if (typeof $.xLazyLoader === 'function') {279 func();280 } else {281 $.getScript(t_jp.plugin_url + '/js/lazy.js', func);282 }283 }284 285 276 // invokes the correct mass translatot based on the prefered one... 286 277 function do_mass_invoke(batchtokens, batchtrans) { … … 325 316 } 326 317 318 // helper function for lazy running 319 function test_for_lazyrun(callback) { 320 if (typeof $.xLazyLoader === 'function') { 321 callback(); 322 } else { 323 $.getScript(t_jp.plugin_url + '/js/lazy.js', callback); 324 } 325 } 326 327 t_jp.tfl = test_for_lazyrun; 328 329 function test_for_jqueryui(callback) { 330 if (test_for_jqueryui.hit /* might be needed? - && typeof $.fn.dialog !== 'function' */) { 331 callback(); 332 } else { 333 test_for_jqueryui.hit = true; 334 test_for_lazyrun(function() { 335 $.xLazyLoader({ 336 js: t_jp.jQueryUI + 'jquery-ui.min.js', 337 css: t_jp.jQueryUI + 'themes/'+ t_jp.theme + '/jquery-ui.css', 338 success: callback 339 }); 340 }); 341 } 342 } 343 344 t_jp.tfju = test_for_jqueryui; 345 327 346 $(document).ready( 328 347 function () { … … 365 384 // 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 366 385 if (t_jp.progress) { 367 var loaduiandtranslate = function () { 368 $.xLazyLoader({ 369 js: t_jp.jQueryUI + 'jquery-ui.min.js', 370 css: t_jp.jQueryUI + 'themes/'+ t_jp.theme + '/jquery-ui.css', 371 success: function () { 372 create_progress_bar(); 373 do_auto_translate(); 374 } 375 }); 376 }; 377 lazyrun(loaduiandtranslate); 386 test_for_jqueryui(function () { 387 create_progress_bar(); 388 do_auto_translate(); 389 }); 378 390 } else { 379 391 do_auto_translate(); -
trunk/WordPress/plugin/transposh/js/transposhedit.js
r670 r671 491 491 } else { 492 492 // We will show languages that have a human translation on the server 493 $.xLazyLoader({ 494 js: [t_jp.plugin_url + '/js/jquery.ui.menu.js'], 495 success: function () { 496 $.ajax({ 497 url: t_jp.ajaxurl, 498 data: { 499 action: 'tp_trans_alts', 500 token: $(idprefix + segment_id).attr('data-token') 501 }, 502 dataType: "json", 503 cache: false, 504 success: function(data) { 505 var itemlang 506 if (!(itemlang = $(idprefix + segment_id).attr('data-srclang'))) { 507 itemlang = t_jp.olang; 493 t_jp.tfl(function() { 494 $.xLazyLoader({ 495 js: [t_jp.plugin_url + '/js/jquery.ui.menu.js'], 496 success: function () { 497 $.ajax({ 498 url: t_jp.ajaxurl, 499 data: { 500 action: 'tp_trans_alts', 501 token: $(idprefix + segment_id).attr('data-token') 502 }, 503 dataType: "json", 504 cache: false, 505 success: function(data) { 506 var itemlang 507 if (!(itemlang = $(idprefix + segment_id).attr('data-srclang'))) { 508 itemlang = t_jp.olang; 509 } 510 var liflag = '<li data-translated="' + $(idprefix + segment_id).attr('data-orig') + '"><a href="#">' + l[itemlang] + '</a></li>' 511 $(data).each(function(index, item) { 512 if (item.lang !== t_jp.lang) { 513 liflag = liflag + '<li data-translated="' + item.translated + '"><a href="#">' + l[item.lang] + '</a></li>' 514 } 515 }); 516 $('<ul style="position: absolute; top: 0px" id="' + prefix + 'langmenu">' + liflag).appendTo(dialog); 517 518 $(idprefix + "langmenu").menu({ 519 select: function(event, ui) { 520 $(this).hide(); 521 $(idprefix + "original").val(ui.item.attr('data-translated')); 522 $(idprefix + "orglang").text(ui.item.text()).addClass('ui-state-highlight'); 523 if (l[itemlang] === ui.item.text()) { 524 $(idprefix + "orglang").removeClass('ui-state-highlight'); 525 } 526 }, 527 input: $(this) 528 }).show().css({ 529 top:0, 530 left:0 531 }).position({ 532 my: left + ' top', 533 at: left +' bottom', 534 of: $(idprefix + 'orglang') 535 }); 508 536 } 509 var liflag = '<li data-translated="' + $(idprefix + segment_id).attr('data-orig') + '"><a href="#">' + l[itemlang] + '</a></li>' 510 $(data).each(function(index, item) { 511 if (item.lang !== t_jp.lang) { 512 liflag = liflag + '<li data-translated="' + item.translated + '"><a href="#">' + l[item.lang] + '</a></li>' 513 } 514 }); 515 $('<ul style="position: absolute; top: 0px" id="' + prefix + 'langmenu">' + liflag).appendTo(dialog); 516 517 $(idprefix + "langmenu").menu({ 518 select: function(event, ui) { 519 $(this).hide(); 520 $(idprefix + "original").val(ui.item.attr('data-translated')); 521 $(idprefix + "orglang").text(ui.item.text()).addClass('ui-state-highlight'); 522 if (l[itemlang] === ui.item.text()) { 523 $(idprefix + "orglang").removeClass('ui-state-highlight'); 524 } 525 }, 526 input: $(this) 527 }).show().css({ 528 top:0, 529 left:0 530 }).position({ 531 my: left + ' top', 532 at: left +' bottom', 533 of: $(idprefix + 'orglang') 534 }); 535 } 536 }); 537 } 537 }); 538 } 539 }); 538 540 }); 539 541 } … … 632 634 text: false 633 635 }).click(function () { 634 $.xLazyLoader({ 635 js: [t_jp.plugin_url + '/js/keyboard.js'], 636 css: [t_jp.plugin_url + '/css/keyboard.css'], 637 success: function () { 638 VKI_attach($(idprefix + "translation").get(0)); 639 VKI_show($(idprefix + "translation").get(0)); 640 } 636 t_jp.tfl(function() { 637 $.xLazyLoader({ 638 js: [t_jp.plugin_url + '/js/keyboard.js'], 639 css: [t_jp.plugin_url + '/css/keyboard.css'], 640 success: function () { 641 VKI_attach($(idprefix + "translation").get(0)); 642 VKI_show($(idprefix + "translation").get(0)); 643 } 644 }); 641 645 }); 642 646 }); … … 747 751 // internal function used to load locale in two needed cases (where we load jQueryui and not...) 748 752 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 { 753 if (t_jp.locale && !localeloaded) { 754 $.getScript(t_jp.plugin_url + '/js/l/'+t_jp.lang+'.js', function () { 755 localeloaded = true; 755 756 translate_dialog(translated_id); 756 } 757 }); 758 } else { 759 translate_dialog(translated_id); 760 } 757 761 } 758 762 img.click(function () { 759 763 // if we detect that $.ui is missing (TODO - check tabs - etal) we load it first, the added or solves a jquery tools conflict !!!!!!!!!!! 760 if (typeof $.fn.tabs !== 'function' || typeof $.fn.buttonset !== 'function' || typeof $.fn.dialog !== 'function') { 761 $.ajaxSetup({ 762 cache: true 763 }); 764 $.getScript(t_jp.plugin_url + '/js/lazy.js', function () { 765 $.xLazyLoader({ 766 js: t_jp.jQueryUI + 'jquery-ui.min.js', 767 css: t_jp.jQueryUI + 'themes/'+ t_jp.theme + '/jquery-ui.css', 768 success: loadlocaleandrundialog 769 }); 770 }); 771 } else { 764 t_jp.tfju(function() { 772 765 loadlocaleandrundialog(); 773 } 766 }) 774 767 return false; 775 768 }).css({
Note: See TracChangeset
for help on using the changeset viewer.
