Index: trunk/extensions/WikiBhasha/src/styles/wikiBhasha.css |
— | — | @@ -626,3 +626,11 @@ |
627 | 627 | line-height:1em; |
628 | 628 | margin-left:10px; |
629 | 629 | } |
| 630 | +#wbToggleLabel |
| 631 | +{ |
| 632 | + width:150px |
| 633 | +} |
| 634 | +#wbToggleCTFLabel |
| 635 | +{ |
| 636 | + width:150px |
| 637 | +} |
\ No newline at end of file |
Index: trunk/extensions/WikiBhasha/src/js/extern/languageServicesInterface.js |
— | — | @@ -31,7 +31,34 @@ |
32 | 32 | translationAPI: "http://www.microsofttranslator.com/ajax/v2/toolkit.ashx?siteData=Z6N2xQ1EGnakgC6d5-2bqyn8HanvRK5-lNxPYEMrEBgU1cuhJ1v6tOtshhuFOTekTtt6OcyEnzF14qob_7h35iX3x1h6x49fgbZ4gYuQvVzXufdqTVDIb_E2VYtdha3I", |
33 | 33 | // Id of button in translation toolbar clicking on which will exit the toolbar. |
34 | 34 | exitButtonElementId: "MSTTExitLink", |
35 | | - |
| 35 | + |
| 36 | + languageServiceProvider: "", |
| 37 | + |
| 38 | + //set the language service provider object in history item |
| 39 | + setLanguageServiceProviderObject: function(historyItem){ |
| 40 | + if(wbLanguageServices.languageServiceProvider && wbLanguageServices.languageServiceProvider.setTooltips){ |
| 41 | + historyItem.languageServiceProvider=wbLanguageServices.languageServiceProvider; |
| 42 | + } |
| 43 | + return; |
| 44 | + }, |
| 45 | + |
| 46 | + //retrive the language service provider object from history and use it for the current panes |
| 47 | + fetchLanguageServiceProviderObject: function(historyItem){ |
| 48 | + wbLanguageServices.languageServiceProvider = historyItem.languageServiceProvider; |
| 49 | + }, |
| 50 | + |
| 51 | + // Implement this method if CTF feature is implemented and CTF popup needed to be enabled and disabled |
| 52 | + // The value of checkbox is passed as first parameter |
| 53 | + onCTFDisplayModeChanged: function(isShowCTFPopupMode) { |
| 54 | + if (isShowCTFPopupMode) { |
| 55 | + wbLanguageServices.languageServiceProvider.setTooltips(false, false); |
| 56 | + } |
| 57 | + else { |
| 58 | + wbLanguageServices.languageServiceProvider.setTooltips(false, true); |
| 59 | + } |
| 60 | + return; |
| 61 | + }, |
| 62 | + |
36 | 63 | //translates given text using Microsoft translator API |
37 | 64 | translate: function($sourceText, sourceLanguage, targetLanguage, callback) { |
38 | 65 | var translationApi = wikiBhasha.extern.msLanguageServicesInterface.translationAPI; |
— | — | @@ -62,20 +89,23 @@ |
63 | 90 | var srcElm = sourceElement.get(0), |
64 | 91 | trgElm = targetElement.get(0), |
65 | 92 | |
66 | | - // construct BV control instance for Step #1 |
67 | | - // Bilinugal Viewer (BV) is a UI control that provides many useful features like side-by-side |
| 93 | + // construct Bilinugal Viewer (BV) control instance for Step #1 |
| 94 | + // BV is a UI control that provides many useful features like side-by-side |
68 | 95 | // display of source and translated content with synchronized scrolling and highlighting features. |
69 | | - // BE is used for Step#1 of WikiBhasha, to provide intuitive mechanism for presenting parallel material. |
| 96 | + // BV is used for Step#1 of WikiBhasha, to provide intuitive mechanism for presenting parallel material. |
70 | 97 | // BV is a published external API from Microsoft. |
71 | | - bv = new Microsoft.Translator.BilingualViewer(srcElm, trgElm, wbGlobalSettings.sourceLanguageCode, wbGlobalSettings.mtTargetLanguageCode); |
| 98 | + languageServiceProvider = new Microsoft.Translator.BilingualViewer(srcElm, trgElm, wbGlobalSettings.sourceLanguageCode, wbGlobalSettings.mtTargetLanguageCode); |
| 99 | + |
| 100 | + //set the language service provider object |
| 101 | + wbLanguageServices.languageServiceProvider = languageServiceProvider; |
72 | 102 | |
73 | | - //set whether to show tooltips (CTF) for left & right (source/target) content respectively |
| 103 | + // set whether to show tooltips (CTF) for left & right (source/target) content respectively |
74 | 104 | // The Collaborative Translation Framework (CTF) is a collaborative feature that is available as a |
75 | 105 | // tooltip in BV UI Control. Enable this feature, to provide sharing of translation knowledge. |
76 | | - bv.setTooltips(false, true); |
| 106 | + wbDisplayPaneManager.toggleCTFDisplay(); |
77 | 107 | |
78 | 108 | //initiate the translation |
79 | | - bv.translate(function() { |
| 109 | + languageServiceProvider.translate(function() { |
80 | 110 | if (onTranslationCompleted) { |
81 | 111 | onTranslationCompleted(); |
82 | 112 | } |
Index: trunk/extensions/WikiBhasha/src/js/core/mainWindow.js |
— | — | @@ -225,6 +225,11 @@ |
226 | 226 | $("#wbToggleWikiFormat").click(function() { |
227 | 227 | wbDisplayPaneManager.toggleDisplayMode(); |
228 | 228 | }); |
| 229 | + |
| 230 | + //bind click event to toggle between wiki and html formats |
| 231 | + $("#wbToggleCTF").click(function() { |
| 232 | + wbDisplayPaneManager.toggleCTFDisplay(); |
| 233 | + }); |
229 | 234 | } |
230 | 235 | |
231 | 236 | wbWorkflow.stepsArray = stepsArray; |
Index: trunk/extensions/WikiBhasha/src/js/core/paneManagement.js |
— | — | @@ -427,6 +427,11 @@ |
428 | 428 | |
429 | 429 | // Rehook events to links. Once element is removed and added back, link events disappear, so rehooking is needed. |
430 | 430 | wbDisplayPaneHelper.registerLinksForHistoryTracking(wbSourceOriginalPane.$currentChildElem); |
| 431 | + |
| 432 | + //getting the language service provider object for CTF popup |
| 433 | + if(wbLanguageServices.fetchLanguageServiceProviderObject){ |
| 434 | + wbLanguageServices.fetchLanguageServiceProviderObject(historyItem); |
| 435 | + } |
431 | 436 | } |
432 | 437 | else { |
433 | 438 | //if content not available in history item then load it from API calls |
— | — | @@ -443,6 +448,8 @@ |
444 | 449 | else { |
445 | 450 | this.$contentElem.html("<div>" + wbLocal.sourceArticleNotApplicable + "</div>"); |
446 | 451 | } |
| 452 | + //apply the CTF popup state |
| 453 | + wbDisplayPaneManager.toggleCTFDisplay(); |
447 | 454 | }, |
448 | 455 | |
449 | 456 | onShow: function() { |
— | — | @@ -532,6 +539,11 @@ |
533 | 540 | if (wbLanguageServices.exitButtonElementId && $("#" + wbMainWindow.windowId).length === 0) { |
534 | 541 | $("#" + wbLanguageServices.exitButtonElementId).get(0).onclick(); |
535 | 542 | } |
| 543 | + //create language service provider object in the history item |
| 544 | + if(wbLanguageServices.setLanguageServiceProviderObject){ |
| 545 | + wbLanguageServices.setLanguageServiceProviderObject(historyItem); |
| 546 | + } |
| 547 | + wbDisplayPaneManager.toggleCTFDisplay(); |
536 | 548 | //as soon as translation is done, enable the default Cursor |
537 | 549 | wbUIHelper.changeCursorToDefault(); |
538 | 550 | }); |
— | — | @@ -540,6 +552,10 @@ |
541 | 553 | //else updates the history item with the content |
542 | 554 | else if (historyItem) { |
543 | 555 | historyItem.content = $childElem; |
| 556 | + //create language service provider object in the history item |
| 557 | + if(wbLanguageServices.setLanguageServiceProviderObject){ |
| 558 | + wbLanguageServices.setLanguageServiceProviderObject(historyItem); |
| 559 | + } |
544 | 560 | } |
545 | 561 | }, |
546 | 562 | |
— | — | @@ -928,7 +944,16 @@ |
929 | 945 | // log the fact that user used this feature |
930 | 946 | wbLoggerService.logFeatureUsage(wbGlobalSettings.sessionId, "WikiModeSwitch", isShowWikimarkupMode); |
931 | 947 | }, |
| 948 | + //enable/disable CTF popup display |
| 949 | + toggleCTFDisplay: function() { |
| 950 | + var isShowCTFPopup = wbDisplayPaneHelper.isShowCTFPopupChecked(); |
| 951 | + if (wbLanguageServices.onCTFDisplayModeChanged) { |
| 952 | + wbLanguageServices.onCTFDisplayModeChanged(isShowCTFPopup); |
| 953 | + } |
932 | 954 | |
| 955 | + // log the fact that user used this feature |
| 956 | + wbLoggerService.logFeatureUsage(wbGlobalSettings.sessionId, "CTFPopupDisplay", isShowCTFPopup); |
| 957 | + }, |
933 | 958 | //removes content DIVs from application display. |
934 | 959 | removeContentDiv: function(parentElement) { |
935 | 960 | var previousArticleContent = parentElement.find(".articleContentDiv"); |
— | — | @@ -952,12 +977,19 @@ |
953 | 978 | |
954 | 979 | initialize: function() { |
955 | 980 | wbDisplayPaneHelper.$showWikimarkupCheckBox = $("#wbToggleWikiFormat"); |
| 981 | + wbDisplayPaneHelper.$showCTFPopup = $("#wbToggleCTF"); |
956 | 982 | }, |
957 | 983 | |
958 | 984 | //checks the value of display mode check box. |
959 | 985 | isShowWikimarkupChecked: function() { |
960 | 986 | return wbDisplayPaneHelper.$showWikimarkupCheckBox.attr("checked"); |
961 | 987 | }, |
| 988 | + |
| 989 | + //checks the value of CTF popup display check box. |
| 990 | + isShowCTFPopupChecked: function() { |
| 991 | + return wbDisplayPaneHelper.$showCTFPopup.attr("checked"); |
| 992 | + }, |
| 993 | + |
962 | 994 | //loads the content to pane and highlights it using wiki or hybrid mode appropriately |
963 | 995 | loadHighlightContent: function(childContent, displayPane, doNotParse, isSystemText) { |
964 | 996 | wbUIHelper.changeCursorToHourGlass(); |
Index: trunk/extensions/WikiBhasha/src/js/core/globalSettings.js |
— | — | @@ -421,6 +421,7 @@ |
422 | 422 | <div id="wbRightWindow">\ |
423 | 423 | <div class="wbHeader" style="height:25px;">\ |
424 | 424 | <div class="wikiModeSwitcher">\ |
| 425 | +<label id="wbToggleCTFLabel" for="wbToggleCTF"><input id="wbToggleCTF" type="checkbox" tabindex="0" />Disable Translation Popup</label>\ |
425 | 426 | <label id="wbToggleLabel" for="wbToggleWikiFormat"><input id="wbToggleWikiFormat" type="checkbox" tabindex="0" />Show Wikiformat</label>\ |
426 | 427 | </div>\ |
427 | 428 | </div>\ |