Changeset 637
- Timestamp:
- 06/11/2011 02:34:58 AM (12 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WordPress/plugin/transposh/js/transposhedit.js
r624 r637 151 151 tr0: translation 152 152 }; 153 // We are pre-accounting the progress bar here - which is not very nice 154 /*TODO think!!!! if (source > 0) { 155 done_p += $("*[token='" + token + "']").size(); 156 }*/ 153 157 154 $.ajax({ 158 155 type: "POST", 159 156 url: t_jp.post_url, 160 157 data: data, 161 success: function () { 162 // Success now only updates the save progress bar (green) 163 /* THINK if (t_jp.progress) { 164 if (togo > 4 && source > 0) { 165 $("#progress_bar2").progressbar('value', done_p / togo * 100); 166 } 167 168 }*/ 169 }, 170 158 // In the past we used this to make progress bar status, not really needed, but keeping for future reference 159 // success: function () {}, 160 // TODO: This probably needs a revision! 171 161 error: function (req) { 172 162 alert("Error !!! failed to translate.\n\nServer's message: " + req.statusText); … … 185 175 } 186 176 177 // fetch translation from google translate... 187 178 function getgt() 188 179 { … … 208 199 function getbt() 209 200 { 210 ms_trans($(idprefix + "original").val(), function ( translation) {211 $(idprefix + "translation").val($("<div>" + $.trim( translation) + "</div>").text())201 ms_trans($(idprefix + "original").val(), function (result) { 202 $(idprefix + "translation").val($("<div>" + $.trim(result) + "</div>").text()) 212 203 .keyup(); 213 204 }); … … 308 299 function history_dialog(segment_id){ 309 300 var dialog = idprefix + "historydialog"; 310 /*if ($(dialog).length) {311 $(dialog).dialog('open');312 return;313 }*/314 301 315 302 $(dialog).remove(); 316 //$(idprefix+'historydialog').remove();317 303 318 304 $('<div id="' + prefix + 'historydialog" title="' + __('History') + '">'+__('Loading...')+'</div>').appendTo("body"); … … 321 307 // dialogClass: 'ui-widget-shadow', 322 308 show: 'slide'//, 323 //stack: true324 309 }); 325 310 if ($("html").attr("dir") === 'rtl') { … … 414 399 415 400 } 401 402 // load data to translate dialog 403 function set_translate_dialog_values(segment_id) { 404 // the field values 405 $(idprefix + "original").val($(idprefix + segment_id).attr('data-orig')); 406 $(idprefix + "translation").val($(idprefix + segment_id).html()); 407 408 if ($(idprefix + segment_id).attr('data-trans')) { 409 $(idprefix + "translation").val($(idprefix + segment_id).attr('data-trans')); 410 } 411 // init data vars 412 $(idprefix + "translation").data("origval", $(idprefix + "translation").val()); 413 414 // need to set approve button to enabled by default 415 $(idprefix + 'approve').button("enable"); 416 417 // make sure the next and prev buttons are in order 418 $(idprefix + 'prev').button("enable"); 419 $(idprefix + 'next').button("enable"); 420 if (!$(idprefix + (Number(segment_id) - 1)).length) { 421 $(idprefix + 'prev').button("disable"); 422 } 423 if (!$(idprefix + (Number(segment_id) + 1)).length) { 424 $(idprefix + 'next').button("disable"); 425 } 426 427 // set the original language part 428 var segmentlang = $(idprefix + segment_id).attr('data-srclang'); 429 if (segmentlang === undefined ) { 430 segmentlang = t_jp.olang; 431 } 432 $(idprefix + "orglang").text(l[segmentlang]); 433 // old history is history 434 $(idprefix+'historydialog').remove(); 435 // This line makes sure that the approval button is correct on creation 436 // at the end of the chain, a keyup event will make sure everything is ok 437 $(idprefix + "translation").keyup(); 438 439 440 } 441 416 442 //Open translation dialog 417 443 function translate_dialog(segment_id) { … … 434 460 $('<div id="' + prefix + 'dialog" title="' + __('Edit Translation') + '"/>').appendTo("body"); 435 461 436 var segmentlang = $(idprefix + segment_id).attr('data-srclang');437 if (segmentlang === undefined ) {438 segmentlang = t_jp.olang;439 }440 441 462 $(dialog).css("padding", "1px").append( 442 463 '<div style="width: 100%">' + 443 '<label for="original">' + __('Original text') +' (<a href="#" title="'+__('read alternate translations')+'" id="'+prefix+'orglang"> '+l[segmentlang]+'</a>)'+ '</label>' +464 '<label for="original">' + __('Original text') +' (<a href="#" title="'+__('read alternate translations')+'" id="'+prefix+'orglang"></a>)'+ '</label>' + 444 465 '<textarea cols="80" row="3" name="original" id="' + prefix + 'original" readonly="y"/>' + 445 466 '<span id="' + prefix + 'utlbar">' + … … 552 573 text: false 553 574 }); 575 554 576 // prev button click 555 if ($(idprefix + (Number(segment_id) - 1)).length) { 556 $(idprefix + 'prev').click(function () { 557 translate_dialog(Number(segment_id) - 1); 558 }); 559 } else { 560 $(idprefix + 'prev').button("disable"); 561 } 577 $(idprefix + 'prev').click(function () { 578 // save data if changed 579 if ($(idprefix + 'translation').data("changed")) { 580 var translation = $(idprefix + 'translation').val(), 581 token = $(idprefix + segment_id).attr('data-token'); 582 ajax_translate_human(token, translation); 583 } 584 // dec counter, reload fields 585 segment_id = Number(segment_id) - 1; 586 set_translate_dialog_values(segment_id); 587 }); 588 // next button click 589 $(idprefix + 'next').click(function () { 590 // save data if changed 591 if ($(idprefix + 'translation').data("changed")) { 592 var translation = $(idprefix + 'translation').val(), 593 token = $(idprefix + segment_id).attr('data-token'); 594 ajax_translate_human(token, translation); 595 } 596 // inc counterm reload fields 597 segment_id = Number(segment_id) + 1; 598 set_translate_dialog_values(segment_id); 599 }); 600 562 601 // zoom button click 563 602 $(idprefix + 'zoom').click(function () { … … 592 631 }); 593 632 594 // next button click595 if ($(idprefix + (Number(segment_id) + 1)).length) {596 $(idprefix + 'next').click(function () {597 translate_dialog(Number(segment_id) + 1);598 });599 } else {600 $(idprefix + 'next').button("disable");601 }602 603 633 $(idprefix + 'history').button({ 604 634 icons: { … … 636 666 $(this).button("disable"); 637 667 }); 668 638 669 $(idprefix + 'bing').button({ 639 670 icons: { … … 646 677 $(this).button("disable"); 647 678 }); 679 648 680 $(idprefix + 'apertium').button({ 649 681 icons: { … … 656 688 $(this).button("disable"); 657 689 }); 690 691 // approval button 658 692 $(idprefix + 'approve').button({ 659 693 icons: { … … 670 704 } 671 705 }); 672 673 // setting textarea values674 $(idprefix + "original").val($(idprefix + segment_id).attr('data-orig'));675 676 $(idprefix + "translation").val($(idprefix + segment_id).html());677 678 if ($(idprefix + segment_id).attr('data-trans')) {679 $(idprefix + "translation").val($(idprefix + segment_id).attr('data-trans'));680 }681 // init data vars682 $(idprefix + "translation")683 //.data("changed",false)684 .data("origval", $(idprefix + "translation").val());685 706 686 707 $(idprefix + "translation").keyup(function (e) { … … 697 718 } 698 719 }); 699 700 // This line makes sure that the approval button is correct on creation 701 $(idprefix + "translation").keyup(); 720 // load field values 721 set_translate_dialog_values(segment_id); 702 722 703 723 // time to create the dialog 704 724 $(dialog).dialog({ 705 //modal: true,706 //width: 'auto',707 //autoopen: false,708 725 resizable: false, 709 726 width: 500//, 710 // buttons: tButtons711 727 }); 712 728 … … 715 731 fix_dialog_header_rtl(dialog); 716 732 var uicorner = 'ui-corner-'; 733 // to remove with jqueryui-1.8.14 717 734 $(idprefix + 'utlbar button:first').addClass(uicorner + left).removeClass(uicorner + right); 718 735 $(idprefix + 'utlbar button:last').addClass(uicorner + right).removeClass(uicorner + left); … … 742 759 743 760 } 744 745 761 746 762 // lets add the images
Note: See TracChangeset
for help on using the changeset viewer.
