r77421 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r77420‎ | r77421 | r77422 >
Date:12:47, 29 November 2010
Author:wikibhasha.msr
Status:deferred
Tags:
Comment:
Bug 25618 - issue fixed: Make it easy to opt out of the CTF use
Modified paths:
  • /trunk/extensions/WikiBhasha/src/js/core/globalSettings.js (modified) (history)
  • /trunk/extensions/WikiBhasha/src/js/core/mainWindow.js (modified) (history)
  • /trunk/extensions/WikiBhasha/src/js/core/paneManagement.js (modified) (history)
  • /trunk/extensions/WikiBhasha/src/js/extern/languageServicesInterface.js (modified) (history)
  • /trunk/extensions/WikiBhasha/src/styles/wikiBhasha.css (modified) (history)

Diff [purge]

Index: trunk/extensions/WikiBhasha/src/styles/wikiBhasha.css
@@ -626,3 +626,11 @@
627627 line-height:1em;
628628 margin-left:10px;
629629 }
 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 @@
3232 translationAPI: "http://www.microsofttranslator.com/ajax/v2/toolkit.ashx?siteData=Z6N2xQ1EGnakgC6d5-2bqyn8HanvRK5-lNxPYEMrEBgU1cuhJ1v6tOtshhuFOTekTtt6OcyEnzF14qob_7h35iX3x1h6x49fgbZ4gYuQvVzXufdqTVDIb_E2VYtdha3I",
3333 // Id of button in translation toolbar clicking on which will exit the toolbar.
3434 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+
3663 //translates given text using Microsoft translator API
3764 translate: function($sourceText, sourceLanguage, targetLanguage, callback) {
3865 var translationApi = wikiBhasha.extern.msLanguageServicesInterface.translationAPI;
@@ -62,20 +89,23 @@
6390 var srcElm = sourceElement.get(0),
6491 trgElm = targetElement.get(0),
6592
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
6895 // 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.
7097 // 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;
72102
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
74104 // The Collaborative Translation Framework (CTF) is a collaborative feature that is available as a
75105 // tooltip in BV UI Control. Enable this feature, to provide sharing of translation knowledge.
76 - bv.setTooltips(false, true);
 106+ wbDisplayPaneManager.toggleCTFDisplay();
77107
78108 //initiate the translation
79 - bv.translate(function() {
 109+ languageServiceProvider.translate(function() {
80110 if (onTranslationCompleted) {
81111 onTranslationCompleted();
82112 }
Index: trunk/extensions/WikiBhasha/src/js/core/mainWindow.js
@@ -225,6 +225,11 @@
226226 $("#wbToggleWikiFormat").click(function() {
227227 wbDisplayPaneManager.toggleDisplayMode();
228228 });
 229+
 230+ //bind click event to toggle between wiki and html formats
 231+ $("#wbToggleCTF").click(function() {
 232+ wbDisplayPaneManager.toggleCTFDisplay();
 233+ });
229234 }
230235
231236 wbWorkflow.stepsArray = stepsArray;
Index: trunk/extensions/WikiBhasha/src/js/core/paneManagement.js
@@ -427,6 +427,11 @@
428428
429429 // Rehook events to links. Once element is removed and added back, link events disappear, so rehooking is needed.
430430 wbDisplayPaneHelper.registerLinksForHistoryTracking(wbSourceOriginalPane.$currentChildElem);
 431+
 432+ //getting the language service provider object for CTF popup
 433+ if(wbLanguageServices.fetchLanguageServiceProviderObject){
 434+ wbLanguageServices.fetchLanguageServiceProviderObject(historyItem);
 435+ }
431436 }
432437 else {
433438 //if content not available in history item then load it from API calls
@@ -443,6 +448,8 @@
444449 else {
445450 this.$contentElem.html("<div>" + wbLocal.sourceArticleNotApplicable + "</div>");
446451 }
 452+ //apply the CTF popup state
 453+ wbDisplayPaneManager.toggleCTFDisplay();
447454 },
448455
449456 onShow: function() {
@@ -532,6 +539,11 @@
533540 if (wbLanguageServices.exitButtonElementId && $("#" + wbMainWindow.windowId).length === 0) {
534541 $("#" + wbLanguageServices.exitButtonElementId).get(0).onclick();
535542 }
 543+ //create language service provider object in the history item
 544+ if(wbLanguageServices.setLanguageServiceProviderObject){
 545+ wbLanguageServices.setLanguageServiceProviderObject(historyItem);
 546+ }
 547+ wbDisplayPaneManager.toggleCTFDisplay();
536548 //as soon as translation is done, enable the default Cursor
537549 wbUIHelper.changeCursorToDefault();
538550 });
@@ -540,6 +552,10 @@
541553 //else updates the history item with the content
542554 else if (historyItem) {
543555 historyItem.content = $childElem;
 556+ //create language service provider object in the history item
 557+ if(wbLanguageServices.setLanguageServiceProviderObject){
 558+ wbLanguageServices.setLanguageServiceProviderObject(historyItem);
 559+ }
544560 }
545561 },
546562
@@ -928,7 +944,16 @@
929945 // log the fact that user used this feature
930946 wbLoggerService.logFeatureUsage(wbGlobalSettings.sessionId, "WikiModeSwitch", isShowWikimarkupMode);
931947 },
 948+ //enable/disable CTF popup display
 949+ toggleCTFDisplay: function() {
 950+ var isShowCTFPopup = wbDisplayPaneHelper.isShowCTFPopupChecked();
 951+ if (wbLanguageServices.onCTFDisplayModeChanged) {
 952+ wbLanguageServices.onCTFDisplayModeChanged(isShowCTFPopup);
 953+ }
932954
 955+ // log the fact that user used this feature
 956+ wbLoggerService.logFeatureUsage(wbGlobalSettings.sessionId, "CTFPopupDisplay", isShowCTFPopup);
 957+ },
933958 //removes content DIVs from application display.
934959 removeContentDiv: function(parentElement) {
935960 var previousArticleContent = parentElement.find(".articleContentDiv");
@@ -952,12 +977,19 @@
953978
954979 initialize: function() {
955980 wbDisplayPaneHelper.$showWikimarkupCheckBox = $("#wbToggleWikiFormat");
 981+ wbDisplayPaneHelper.$showCTFPopup = $("#wbToggleCTF");
956982 },
957983
958984 //checks the value of display mode check box.
959985 isShowWikimarkupChecked: function() {
960986 return wbDisplayPaneHelper.$showWikimarkupCheckBox.attr("checked");
961987 },
 988+
 989+ //checks the value of CTF popup display check box.
 990+ isShowCTFPopupChecked: function() {
 991+ return wbDisplayPaneHelper.$showCTFPopup.attr("checked");
 992+ },
 993+
962994 //loads the content to pane and highlights it using wiki or hybrid mode appropriately
963995 loadHighlightContent: function(childContent, displayPane, doNotParse, isSystemText) {
964996 wbUIHelper.changeCursorToHourGlass();
Index: trunk/extensions/WikiBhasha/src/js/core/globalSettings.js
@@ -421,6 +421,7 @@
422422 <div id="wbRightWindow">\
423423 <div class="wbHeader" style="height:25px;">\
424424 <div class="wikiModeSwitcher">\
 425+<label id="wbToggleCTFLabel" for="wbToggleCTF"><input id="wbToggleCTF" type="checkbox" tabindex="0" />Disable Translation Popup</label>\
425426 <label id="wbToggleLabel" for="wbToggleWikiFormat"><input id="wbToggleWikiFormat" type="checkbox" tabindex="0" />Show Wikiformat</label>\
426427 </div>\
427428 </div>\

Status & tagging log