Index: trunk/extensions/WikiBhasha/src/lang/en/strings.js |
— | — | @@ -81,6 +81,8 @@ |
82 | 82 | warningSaveComposeChanges: "Any changes made in this step would be lost if you move to an earlier step. Do you want to move anyway?", |
83 | 83 | noTargetLanguageArticleFound: "Linked article not found in target language Wikipedia.", |
84 | 84 | feedbackQuestionMessage: "Before leaving WikiBhasha, would you like to give us feedback?", |
| 85 | + previewErrorMessage: "Unable to show the preview.", |
| 86 | + loadingPreviewContent: "Loading Preview...", |
85 | 87 | |
86 | 88 | //tooptip strings |
87 | 89 | searchInputTooltip: "Search", |
Index: trunk/extensions/WikiBhasha/src/lang/de/strings.js |
— | — | @@ -80,6 +80,8 @@ |
81 | 81 | warningSaveComposeChanges: "Any changes made in this step would be lost if you move to an earlier step. Do you want to move anyway?", |
82 | 82 | noTargetLanguageArticleFound: "Linked article not found in target language Wikipedia.", |
83 | 83 | feedbackQuestionMessage: "Before leaving WikiBhasha, would you like to give us feedback?", |
| 84 | + previewErrorMessage: "Unable to show the preview.", |
| 85 | + loadingPreviewContent: "Loading Preview...", |
84 | 86 | |
85 | 87 | //tooptip strings |
86 | 88 | searchInputTooltip: "Search", |
Index: trunk/extensions/WikiBhasha/src/styles/wikiBhasha.css |
— | — | @@ -66,6 +66,19 @@ |
67 | 67 | color:Black; |
68 | 68 | direction:ltr; |
69 | 69 | } |
| 70 | +#wbWikiMarkupEditWindow |
| 71 | +{ |
| 72 | + z-index: 10000; |
| 73 | + position: absolute; |
| 74 | + margin:0 auto; |
| 75 | + text-align:left; |
| 76 | + font-size:12px; |
| 77 | + font-weight:normal; |
| 78 | + color:Black; |
| 79 | + direction:ltr; |
| 80 | + width: 370px; |
| 81 | + height:30px; |
| 82 | +} |
70 | 83 | #wbChineseLangSelectionWindow |
71 | 84 | { |
72 | 85 | z-index: 10000; |
— | — | @@ -143,6 +156,10 @@ |
144 | 157 | width:539px; |
145 | 158 | margin:7px 7px 0px 7px; |
146 | 159 | } |
| 160 | +#wbWikiMarkupEditSubmitLink |
| 161 | +{ |
| 162 | + text-align:center; |
| 163 | +} |
147 | 164 | #wbSelectionDiv { |
148 | 165 | width:550px; |
149 | 166 | height: 555px; |
— | — | @@ -162,7 +179,6 @@ |
163 | 180 | float:left; |
164 | 181 | width:100px; |
165 | 182 | } |
166 | | - |
167 | 183 | .wbHeaderContainer { |
168 | 184 | float:left; |
169 | 185 | padding:0 10px 5px 15px; |
— | — | @@ -175,11 +191,17 @@ |
176 | 192 | } |
177 | 193 | .wbSearch |
178 | 194 | { |
179 | | - |
180 | 195 | font-size:12px; |
181 | 196 | color:Black; |
182 | 197 | background-color: #ffffff; |
183 | 198 | } |
| 199 | +.wbWikiMarkupEdit |
| 200 | +{ |
| 201 | + font-size:12px; |
| 202 | + color:Black; |
| 203 | + background-color: #ffffff; |
| 204 | + border:1px #000000 solid; |
| 205 | +} |
184 | 206 | .wbTargetSearch |
185 | 207 | { |
186 | 208 | background-color:#F1F1F1; |
— | — | @@ -633,4 +655,68 @@ |
634 | 656 | #wbToggleCTFLabel |
635 | 657 | { |
636 | 658 | width:150px |
| 659 | +} |
| 660 | +#wbWikiMarkupEditDraggableHandle |
| 661 | +{ |
| 662 | + background: #E9F1F5; |
| 663 | + cursor:move; |
| 664 | + width:352px; |
| 665 | + height:30px; |
| 666 | + border: 1px solid #999; |
| 667 | + padding-left:5px; |
| 668 | + padding-right:5px; |
| 669 | +} |
| 670 | +ul.tabs { |
| 671 | + margin: 0; |
| 672 | + padding: 0; |
| 673 | + float: left; |
| 674 | + list-style: none; |
| 675 | + font-size:16px; |
| 676 | + border-bottom: none; |
| 677 | +} |
| 678 | +ul.tabs li |
| 679 | +{ |
| 680 | + text-decoration: none; |
| 681 | + float: left; |
| 682 | + height: 28px; |
| 683 | + position: relative; |
| 684 | + border-right: 1px solid #999; |
| 685 | + background: #E9F1F5; |
| 686 | + padding-left:5px; |
| 687 | + padding-right:5px; |
| 688 | +} |
| 689 | +ul.tabs li a |
| 690 | +{ |
| 691 | + height:30px; |
| 692 | + color:#000000; |
| 693 | + font-weight:bold; |
| 694 | + text-decoration: none; |
| 695 | +} |
| 696 | +ul.tabs li.active, ul.tabs li:hover { |
| 697 | + background-color: #D0E1EA; |
| 698 | +} |
| 699 | +.tab_container |
| 700 | +{ |
| 701 | + padding:0; |
| 702 | + border-left: 1px solid #999; |
| 703 | + border-bottom: 1px solid #999; |
| 704 | + border-right: 1px solid #999; |
| 705 | + clear: both; |
| 706 | + float: left; |
| 707 | + background: #fff; |
| 708 | +} |
| 709 | +#wbWikiMarkupEditTab, #wbWikiMarkupEditPreviewTab { |
| 710 | + height:300px; |
| 711 | + width:352px; |
| 712 | + overflow:auto; |
| 713 | + padding-left:5px; |
| 714 | + padding-right:5px; |
| 715 | +} |
| 716 | +.wbWikiMarkupEditBottomLinks |
| 717 | +{ |
| 718 | + width:360px; |
| 719 | + background-color:#D0E1EA; |
| 720 | + text-align:center; |
| 721 | + border-top: 1px solid #999; |
| 722 | + padding:2px; |
637 | 723 | } |
\ No newline at end of file |
Index: trunk/extensions/WikiBhasha/src/js/main.js |
— | — | @@ -237,6 +237,7 @@ |
238 | 238 | "js/core/scratchpadWindow.js", |
239 | 239 | "js/core/feedbackWindow.js", |
240 | 240 | "js/core/searchWindow.js", |
| 241 | + "js/core/wikiMarkupEditWindow.js", |
241 | 242 | "js/core/templateAndLinkTranslator.js", |
242 | 243 | "js/core/themes.js", |
243 | 244 | "js/core/utils.js", |
Index: trunk/extensions/WikiBhasha/src/js/extern/wikipediaInterface.js |
— | — | @@ -38,6 +38,9 @@ |
39 | 39 | //API to search wikipedia article |
40 | 40 | wikiSearchAPI: "http://{0}.wikipedia.org/w/api.php?action=query&list=search&srsearch={1}&format=json", |
41 | 41 | |
| 42 | + //API to search wikipedia article |
| 43 | + wikiPreviewAPI: "http://{0}.wikipedia.org/w/api.php?action=parse&text={1}&format=json", |
| 44 | + |
42 | 45 | //API to get wikipedia language links |
43 | 46 | wikiLangLinksAPI: "http://{0}.wikipedia.org/w/api.php?action=query&prop=langlinks&format=json&redirects=1&titles={1}&lllimit=5000", |
44 | 47 | |
— | — | @@ -300,7 +303,17 @@ |
301 | 304 | //checks whether current domain is wikipedia or not |
302 | 305 | isWikiDomain: function(url) { |
303 | 306 | return (url.match(this.wikiPageUrlRegex) === null) ? false : true; |
| 307 | + }, |
| 308 | + //function to view the preview of the edited article |
| 309 | + getPreviewContent: function(lang, composeText, callback) { |
| 310 | + urlData = wbUtil.stringFormat(wbWikiSite.wikiPreviewAPI, lang, encodeURIComponent(composeText.replace(/<br>/gi, '').replace(/<br\/>/ig, '').replace('\'\'', '\'')).replace(/'/g, '%27')); |
| 311 | + $.getJSON(urlData, 'callback=?', function(data) { |
| 312 | + if (data && data.parse && data.parse.text) { |
| 313 | + callback(data.parse.text['*']); |
| 314 | + }else{ |
| 315 | + callback(false); |
| 316 | + } |
| 317 | + }); |
304 | 318 | } |
305 | | - |
306 | 319 | }; |
307 | 320 | })(); |
\ No newline at end of file |
Index: trunk/extensions/WikiBhasha/src/js/extern/languageServicesInterface.js |
— | — | @@ -31,7 +31,7 @@ |
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 | 36 | languageServiceProvider: "", |
37 | 37 | |
38 | 38 | //set the language service provider object in history item |
— | — | @@ -110,6 +110,7 @@ |
111 | 111 | onTranslationCompleted(); |
112 | 112 | } |
113 | 113 | }); |
| 114 | + |
114 | 115 | }); |
115 | 116 | } |
116 | 117 | } |
Index: trunk/extensions/WikiBhasha/src/js/core/mainWindow.js |
— | — | @@ -226,7 +226,7 @@ |
227 | 227 | wbDisplayPaneManager.toggleDisplayMode(); |
228 | 228 | }); |
229 | 229 | |
230 | | - //bind click event to toggle between wiki and html formats |
| 230 | + //bind click event to toggle between wiki and html formats |
231 | 231 | $("#wbToggleCTF").click(function() { |
232 | 232 | wbDisplayPaneManager.toggleCTFDisplay(); |
233 | 233 | }); |
— | — | @@ -322,6 +322,7 @@ |
323 | 323 | //Unload the context menu and search window for the application |
324 | 324 | wbContextMenuHandler.unload(); |
325 | 325 | wbSearch.unload(); |
| 326 | + wbWikiMarkupEdit.unload(); |
326 | 327 | wbSplash.close(); |
327 | 328 | |
328 | 329 | wbTransliterationServices.disableTransliteration(wbGlobalSettings.mtTargetLanguageCode); |
— | — | @@ -382,6 +383,7 @@ |
383 | 384 | "wbWikiSite", |
384 | 385 | "wbWorkflow", |
385 | 386 | "wbChineseLangSelection", |
| 387 | + "wbWikiMarkupEditWindow", |
386 | 388 | "wb"]; |
387 | 389 | |
388 | 390 | for (var i = 0; i < wbGloablVariables.length; i++) { |
— | — | @@ -456,7 +458,7 @@ |
457 | 459 | |
458 | 460 | //removes cloned HTML elements(during Drag-Drop or Copy-Paste) from the element"#wbRightWindowContentDiv" |
459 | 461 | removeNonContentElements: function() { |
460 | | - var $elementsToBeRemoved = $("#wbTranslationTable, .wbLeftWindowContent, .wbLogoContainer, .wbContentContainer, #wbTwoPaneOuterWrapper, #wbLeftWindow, .wbTableBackground, .wbTopButtonsDiv, #wbTopIcons, #wbHistoryInfo, .workflowNavigationBtns, #workFlowStepBtns, .wbTable, .wbHeader, #wbWorkingArticleLabel", $("#wbRightWindowContentDiv")); |
| 462 | + var $elementsToBeRemoved = $("#wbTranslationTable, .wbExit, .wbLeftWindowContent, .wbLogoContainer, .wbContentContainer, #wbTwoPaneOuterWrapper, #wbLeftWindow, .wbTableBackground, .wbTopButtonsDiv, #wbTopIcons, #wbHistoryInfo, .workflowNavigationBtns, #workFlowStepBtns, .wbTable, .wbHeader, #wbWorkingArticleLabel, .tabs_li, .wbWikiMarkupEditBottomLinks, .tab_content", $("#wbRightWindowContentDiv")); |
461 | 463 | var removeCloneNodes = function() { |
462 | 464 | //jQuery '.remove()' method actually removes the events on original elements |
463 | 465 | //to avoid this we need to use native DOM method to remove only the cloned elements |
Index: trunk/extensions/WikiBhasha/src/js/core/paneManagement.js |
— | — | @@ -45,6 +45,9 @@ |
46 | 46 | // Typically, this element is created and initialized in this class's 'initialize()' call. |
47 | 47 | $contentElem: null, |
48 | 48 | |
| 49 | + // language of the content the pane contains |
| 50 | + contentLang: null, |
| 51 | + |
49 | 52 | // Required Member. This is called only once per WikiBhasha session before this pane is used or displayed. |
50 | 53 | initialize: function() { |
51 | 54 | // Create necessary elements and initializations here and append item to 'this.$contentElem'. The '$contentElem' |
— | — | @@ -69,7 +72,6 @@ |
70 | 73 | onDisplayModeChanged: function(isShowWikimarkupMode) { |
71 | 74 | }, |
72 | 75 | |
73 | | - |
74 | 76 | // Optional Member. This function gets called just before the pane is to be hidden, for example, when user |
75 | 77 | // changes steps. Return false to cancel the hide operation and be in the current step. |
76 | 78 | canHide: function() { |
— | — | @@ -110,7 +112,7 @@ |
111 | 113 | //get wikipedia article compose url |
112 | 114 | var urlData = wbWikiSite.getEditPageUrl(wbGlobalSettings.targetLanguageCode, wbGlobalSettings.targetLanguageArticleTitle), |
113 | 115 | //iframe object |
114 | | - composeFrameObject = document.getElementById("wbComposeIFrame"); |
| 116 | + composeFrameObject = document.getElementById("wbComposeIFrame"); |
115 | 117 | |
116 | 118 | this.$contentElem = $("#" + this.contentDivId); |
117 | 119 | |
— | — | @@ -228,7 +230,6 @@ |
229 | 231 | }); |
230 | 232 | }); |
231 | 233 | } |
232 | | - |
233 | 234 | }, |
234 | 235 | |
235 | 236 | onShow: function() { |
— | — | @@ -322,6 +323,7 @@ |
323 | 324 | |
324 | 325 | initialize: function() { |
325 | 326 | wbUIHelper.changeCursorToHourGlass(); |
| 327 | + wbSourceOriginalPane.contentLang = wbGlobalSettings.sourceLanguageCode; |
326 | 328 | this.$contentElem = $("<div>" + wbLocal.loadingElementContent + "</div>").attr("id", this.contentDivId); |
327 | 329 | if (!wbGlobalSettings.sourceLanguageArticleTitle) { |
328 | 330 | |
— | — | @@ -418,6 +420,7 @@ |
419 | 421 | |
420 | 422 | onHistoryChanged: function(historyItem) { |
421 | 423 | var title = historyItem.title; |
| 424 | + |
422 | 425 | if (historyItem.langId === wbGlobalSettings.sourceLanguageCode) { |
423 | 426 | //If content available in history item |
424 | 427 | if (historyItem.content) { |
— | — | @@ -427,8 +430,7 @@ |
428 | 431 | |
429 | 432 | // Rehook events to links. Once element is removed and added back, link events disappear, so rehooking is needed. |
430 | 433 | wbDisplayPaneHelper.registerLinksForHistoryTracking(wbSourceOriginalPane.$currentChildElem); |
431 | | - |
432 | | - //getting the language service provider object for CTF popup |
| 434 | + //getting the language service provider object for CTF popup |
433 | 435 | if(wbLanguageServices.fetchLanguageServiceProviderObject){ |
434 | 436 | wbLanguageServices.fetchLanguageServiceProviderObject(historyItem); |
435 | 437 | } |
— | — | @@ -448,7 +450,7 @@ |
449 | 451 | else { |
450 | 452 | this.$contentElem.html("<div>" + wbLocal.sourceArticleNotApplicable + "</div>"); |
451 | 453 | } |
452 | | - //apply the CTF popup state |
| 454 | + //apply the CTF popup state |
453 | 455 | wbDisplayPaneManager.toggleCTFDisplay(); |
454 | 456 | }, |
455 | 457 | |
— | — | @@ -482,6 +484,7 @@ |
483 | 485 | |
484 | 486 | initialize: function() { |
485 | 487 | wbUIHelper.changeCursorToHourGlass(); |
| 488 | + wbSourceTranslatedPane.contentLang = wbGlobalSettings.targetLanguageCode; |
486 | 489 | this.$contentElem = $("<div>" + wbLocal.loadingElementContent + "</div>").attr("id", this.contentDivId); |
487 | 490 | |
488 | 491 | // set the orientation of the content based on the language |
— | — | @@ -529,7 +532,7 @@ |
530 | 533 | wbDisplayPaneHelper.$showWikimarkupCheckBox.attr("disabled", "true").attr("title", wbLocal.waitUntilTranslationComplete); |
531 | 534 | |
532 | 535 | wbUIHelper.changeCursorToHourGlass(); |
533 | | - |
| 536 | + |
534 | 537 | wbLanguageServices.translateParallelElements(sourceElem, $childElem, function() { |
535 | 538 | //as soon as translation is done, enable the toggle mode check box. |
536 | 539 | wbDisplayPaneHelper.$showWikimarkupCheckBox.removeAttr("disabled").removeAttr("title"); |
— | — | @@ -539,7 +542,7 @@ |
540 | 543 | if (wbLanguageServices.exitButtonElementId && $("#" + wbMainWindow.windowId).length === 0) { |
541 | 544 | $("#" + wbLanguageServices.exitButtonElementId).get(0).onclick(); |
542 | 545 | } |
543 | | - //create language service provider object in the history item |
| 546 | + //create language service provider object in the history item |
544 | 547 | if(wbLanguageServices.setLanguageServiceProviderObject){ |
545 | 548 | wbLanguageServices.setLanguageServiceProviderObject(historyItem); |
546 | 549 | } |
— | — | @@ -547,12 +550,13 @@ |
548 | 551 | //as soon as translation is done, enable the default Cursor |
549 | 552 | wbUIHelper.changeCursorToDefault(); |
550 | 553 | }); |
| 554 | + |
551 | 555 | } |
552 | 556 | } |
553 | 557 | //else updates the history item with the content |
554 | 558 | else if (historyItem) { |
555 | 559 | historyItem.content = $childElem; |
556 | | - //create language service provider object in the history item |
| 560 | + //create language service provider object in the history item |
557 | 561 | if(wbLanguageServices.setLanguageServiceProviderObject){ |
558 | 562 | wbLanguageServices.setLanguageServiceProviderObject(historyItem); |
559 | 563 | } |
— | — | @@ -572,6 +576,7 @@ |
573 | 577 | // Show "loading..." message till then |
574 | 578 | wbUIHelper.changeCursorToHourGlass(); |
575 | 579 | wbDisplayPaneHelper.loadHighlightContent(wbLocal.loadingElementContent, wbSourceTranslatedPane); |
| 580 | + |
576 | 581 | } |
577 | 582 | } |
578 | 583 | else if (historyItem.langId === wbGlobalSettings.targetLanguageCode && historyItem.content !== null) { |
— | — | @@ -590,6 +595,7 @@ |
591 | 596 | function(data) { |
592 | 597 | wbSourceTranslatedPane.loadAndTranslateContent(data, null, historyItem); |
593 | 598 | }); |
| 599 | + |
594 | 600 | } |
595 | 601 | }, |
596 | 602 | |
— | — | @@ -628,6 +634,7 @@ |
629 | 635 | |
630 | 636 | initialize: function() { |
631 | 637 | wbUIHelper.changeCursorToHourGlass(); |
| 638 | + wbTargetContentPane.contentLang = wbGlobalSettings.targetLanguageCode; |
632 | 639 | wbTargetContentPane.$contentElem = $("<div>" + wbLocal.loadingElementContent + "</div>").attr("id", this.contentDivId); |
633 | 640 | |
634 | 641 | // set the orientation of the content based on the language |
— | — | @@ -944,7 +951,8 @@ |
945 | 952 | // log the fact that user used this feature |
946 | 953 | wbLoggerService.logFeatureUsage(wbGlobalSettings.sessionId, "WikiModeSwitch", isShowWikimarkupMode); |
947 | 954 | }, |
948 | | - //enable/disable CTF popup display |
| 955 | + |
| 956 | + //enable/disable CTF popup display |
949 | 957 | toggleCTFDisplay: function() { |
950 | 958 | var isShowCTFPopup = wbDisplayPaneHelper.isShowCTFPopupChecked(); |
951 | 959 | if (wbLanguageServices.onCTFDisplayModeChanged) { |
— | — | @@ -954,6 +962,7 @@ |
955 | 963 | // log the fact that user used this feature |
956 | 964 | wbLoggerService.logFeatureUsage(wbGlobalSettings.sessionId, "CTFPopupDisplay", isShowCTFPopup); |
957 | 965 | }, |
| 966 | + |
958 | 967 | //removes content DIVs from application display. |
959 | 968 | removeContentDiv: function(parentElement) { |
960 | 969 | var previousArticleContent = parentElement.find(".articleContentDiv"); |
— | — | @@ -977,7 +986,10 @@ |
978 | 987 | |
979 | 988 | initialize: function() { |
980 | 989 | wbDisplayPaneHelper.$showWikimarkupCheckBox = $("#wbToggleWikiFormat"); |
981 | | - wbDisplayPaneHelper.$showCTFPopup = $("#wbToggleCTF"); |
| 990 | + wbDisplayPaneHelper.$showCTFPopup = $("#wbToggleCTF"); |
| 991 | + $('.wbHybridTemplate').live('mouseover', function () { wbWikiMarkupEdit.showMenu(this); }); |
| 992 | + //TODO: uncomment this to implement the template preview popup for wikimarkup preview |
| 993 | + //$('.wbHybridTag').live('mouseover', function () { wbWikiMarkupEdit.showMenu(this); }); |
982 | 994 | }, |
983 | 995 | |
984 | 996 | //checks the value of display mode check box. |
— | — | @@ -985,7 +997,7 @@ |
986 | 998 | return wbDisplayPaneHelper.$showWikimarkupCheckBox.attr("checked"); |
987 | 999 | }, |
988 | 1000 | |
989 | | - //checks the value of CTF popup display check box. |
| 1001 | + //checks the value of CTF popup display check box. |
990 | 1002 | isShowCTFPopupChecked: function() { |
991 | 1003 | return wbDisplayPaneHelper.$showCTFPopup.attr("checked"); |
992 | 1004 | }, |
— | — | @@ -1184,6 +1196,11 @@ |
1185 | 1197 | } |
1186 | 1198 | }, |
1187 | 1199 | |
| 1200 | + //get the pane id of the pane in which the element exists |
| 1201 | + getElementsPaneDivId: function (elem) { |
| 1202 | + return $(elem).closest('.articleContentDiv').parent().attr('id'); |
| 1203 | + }, |
| 1204 | + |
1188 | 1205 | //sets pane title according to the format given in configuration. |
1189 | 1206 | setPaneTitleFromConfig: function($contentElem, paneConfigInfo) { |
1190 | 1207 | var paneTitle = paneConfigInfo.title; |
Index: trunk/extensions/WikiBhasha/src/js/core/globalSettings.js |
— | — | @@ -847,6 +847,25 @@ |
848 | 848 | </tr>\ |
849 | 849 | </table>', |
850 | 850 | |
| 851 | +wikiMarkupEditWindowHTML:'<div id="wbWikiMarkupEditDiv">\ |
| 852 | +<div id="wbWikiMarkupEditDraggableHandle">\ |
| 853 | +<div style="float:left;height:25px;"><ul class="tabs" id="wbWikiMarkupEditDivTab">\ |
| 854 | +<li id="wbWikiMarkupEditLi"><a href="#" id="wbWikiMarkupEditLink" class="tabs_li">Edit Text</a></li>\ |
| 855 | +<li id="wbWikiMarkupEditPreviewLi"><a href="#" id="wbWikiMarkupEditPreviewLink" class="tabs_li">Preview</a></li>\ |
| 856 | +</ul></div>\ |
| 857 | +<div style="float:right"><a id="wbWikiMarkupEditExit" class="wbExit" href="#" title="Close" oncontextmenu="return false;" style="margin:4px;padding:0;"></a></div>\ |
| 858 | +</div>\ |
| 859 | +<div id="wbWikiMarkupEditTabsContainer" class="tab_container">\ |
| 860 | +<textarea id="wbWikiMarkupEditTab" class="tab_content">\ |
| 861 | +</textarea>\ |
| 862 | +<div id="wbWikiMarkupEditPreviewTab" class="tab_content">\ |
| 863 | +Loading Preview</div>\ |
| 864 | +<div id="wbWikiMarkupEditSubmitLinks" class="wbWikiMarkupEditBottomLinks">\ |
| 865 | +<input type="button" id="wbWikiMarkupEditSaveLink" value="Save"/> \ |
| 866 | +<input type="button" id="wbWikiMarkupEditCancelLink" value="Cancel"/>\ |
| 867 | +</div>\ |
| 868 | +</div>\ |
| 869 | +</div>', |
851 | 870 | |
852 | 871 | tutorialWindowHTML:'<div id="wbTutorialDiv" class="wbTutorialBgContentArea" >\ |
853 | 872 | <div id="wbTutorialContent">\ |
Index: trunk/extensions/WikiBhasha/src/js/core/wikiMarkupEditWindow.js |
— | — | @@ -0,0 +1,230 @@ |
| 2 | +/* |
| 3 | +* |
| 4 | +* Copyright (c) Microsoft. All rights reserved. |
| 5 | +* |
| 6 | +* This code is licensed under the Apache License, Version 2.0. |
| 7 | +* THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF |
| 8 | +* ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY |
| 9 | +* IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR |
| 10 | +* PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. |
| 11 | +* |
| 12 | +* The apache license details from |
| 13 | +* ‘http://www.apache.org/licenses/’ are reproduced |
| 14 | +* in ‘Apache2_license.txt’ |
| 15 | +* |
| 16 | +*/ |
| 17 | + |
| 18 | +/* |
| 19 | +* |
| 20 | +* Available Classes: |
| 21 | +* 1) wikiMarkupEditWindow - Describes the wiki markup edit window, which enables user to edit the wiki markup and privew the same and save the same to the target language article |
| 22 | +* |
| 23 | +*/ |
| 24 | + |
| 25 | +//make sure the namespace exists. |
| 26 | +if (typeof (wikiBhasha.windowManagement) === "undefined") { |
| 27 | + wikiBhasha.windowManagement = {}; |
| 28 | +} |
| 29 | + |
| 30 | +(function() { |
| 31 | + //describes the search window, which enables user to search various articles in wikipedia |
| 32 | + //for contributing to the target language article |
| 33 | + wikiBhasha.windowManagement.wikiMarkupEditWindow = { |
| 34 | + |
| 35 | + //search window div Id. |
| 36 | + windowId: "wbWikiMarkupEditWindow", |
| 37 | + |
| 38 | + wikiMarkupEditWindowHTML: "", |
| 39 | + |
| 40 | + wikiMarkupEditObject:'', |
| 41 | + |
| 42 | + lang:'', |
| 43 | + |
| 44 | + timer:'', |
| 45 | + |
| 46 | + hasChanged:false, |
| 47 | + |
| 48 | + pane:null, |
| 49 | + |
| 50 | + showMenu: function(elem) { |
| 51 | + if(wbWikiMarkupEdit.hasChanged == true) |
| 52 | + { |
| 53 | + return; |
| 54 | + } |
| 55 | + var $wikiMarkupEditWindowElem = $("#" + wbWikiMarkupEdit.windowId), |
| 56 | + wikiMarkupText = elem ? wbUtil.getDataAttribute(elem) : null; |
| 57 | + |
| 58 | + //store the mouse hover element reference |
| 59 | + wbWikiMarkupEdit.wikiMarkupEditObject = elem; |
| 60 | + // normalize the <br> tags as new line chars |
| 61 | + wikiMarkupText=wikiMarkupText.replace(/<br\s*\/?>/gi, "\n"); |
| 62 | + //check if the window was created already |
| 63 | + if ($wikiMarkupEditWindowElem.length === 0) { |
| 64 | + wbUIHelper.createWindow(wbWikiMarkupEdit.windowId, wbGlobalSettings.wikiMarkupEditWindowHTML); |
| 65 | + $wikiMarkupEditWindowElem = $("#" + wbWikiMarkupEdit.windowId); |
| 66 | + //preview $link |
| 67 | + $("#wbWikiMarkupEditPreviewLi").click(function(){ wbWikiMarkupEdit.preview(); }); |
| 68 | + //markup content $link |
| 69 | + $("#wbWikiMarkupEditLi").click(function(){ wbWikiMarkupEdit.show(); }); |
| 70 | + //save link |
| 71 | + $("#wbWikiMarkupEditSaveLink").click(function(){ wbWikiMarkupEdit.submit();}); |
| 72 | + //cancel link |
| 73 | + $("#wbWikiMarkupEditCancelLink").click(function(){ wbWikiMarkupEdit.hide(); }); |
| 74 | + // prevent drag drop of UI elements |
| 75 | + $("#wbWikiMarkupEditPreviewTab, .wbExit, .tabs_li, .wbWikiMarkupEditBottomLinks").each( function(){ |
| 76 | + $(this).mousedown( |
| 77 | + function(event){ |
| 78 | + if ($.browser.msie) { |
| 79 | + this.onselectstart = function() { return false; }; |
| 80 | + }else{ |
| 81 | + event.stopPropagation(); |
| 82 | + event.preventDefault(); |
| 83 | + } |
| 84 | + return false; |
| 85 | + }); |
| 86 | + }); |
| 87 | + $('#wbTranslationWindow').click(function() { |
| 88 | + if(wbWikiMarkupEdit.hasChanged == false) |
| 89 | + { |
| 90 | + wbWikiMarkupEdit.hide(); |
| 91 | + } |
| 92 | + return; |
| 93 | + }); |
| 94 | + //clicking inside the div, should not hide the wiki markup edit popup |
| 95 | + $('#wbWikiMarkupEditDiv').click(function(event){ event.stopPropagation(); }); |
| 96 | + //closes the window on click of exit link |
| 97 | + $("#wbWikiMarkupEditExit").click(function() { wbWikiMarkupEdit.hide(); }); |
| 98 | + wbUIHelper.makeDraggable(wbWikiMarkupEdit.windowId, "wbWikiMarkupEditDraggableHandle"); |
| 99 | + } |
| 100 | + |
| 101 | + wbWikiMarkupEdit.hide(); |
| 102 | + $('#'+wbWikiMarkupEdit.windowId).height($('#wbWikiMarkupEditDraggableHandle').height()); |
| 103 | + |
| 104 | + // get the present pane object |
| 105 | + wbWikiMarkupEdit.pane = wbDisplayPaneManager.getPaneForId(wbDisplayPaneHelper.getElementsPaneDivId(elem)); |
| 106 | + |
| 107 | + // set the language of the popup according to the pane |
| 108 | + wbWikiMarkupEdit.lang = wbWikiMarkupEdit.pane.contentLang; |
| 109 | + |
| 110 | + // get if the present pane is editable |
| 111 | + wbWikiMarkupEdit.isEditable = wbWikiMarkupEdit.pane.paneConfigInfo.isContentEditable; |
| 112 | + |
| 113 | + //populate the $content |
| 114 | + $("#wbWikiMarkupEditTab").val(wikiMarkupText); |
| 115 | + $("#wbWikiMarkupEditPreviewTab").html(wbLocal.loadingPreviewContent); |
| 116 | + |
| 117 | + wbUIHelper.setWindowOnContext(wbWikiMarkupEdit.windowId, elem); |
| 118 | + // bring the window always on top. |
| 119 | + $wikiMarkupEditWindowElem.maxZIndex({ inc: 5 }); |
| 120 | + |
| 121 | + //hide the content divs |
| 122 | + $('#wbWikiMarkupEditPreviewTab').hide(); |
| 123 | + $('#wbWikiMarkupEditTab').hide(); |
| 124 | + $("#wbWikiMarkupEditTabsContainer").hide(); |
| 125 | + |
| 126 | + $('#wbWikiMarkupEditLi').removeClass('active'); |
| 127 | + $('#wbWikiMarkupEditPreviewLi').removeClass('active'); |
| 128 | + |
| 129 | + // show / hide save cancel buttons |
| 130 | + if(wbWikiMarkupEdit.isEditable == true){ |
| 131 | + $('#wbWikiMarkupEditSubmitLinks').show(); |
| 132 | + $("#wbWikiMarkupEditTab").attr("readonly", false); |
| 133 | + $('#wbWikiMarkupEditLink').html('Edit Text'); |
| 134 | + }else{ |
| 135 | + $('#wbWikiMarkupEditSubmitLinks').hide(); |
| 136 | + $("#wbWikiMarkupEditTab").attr("readonly", true); |
| 137 | + $('#wbWikiMarkupEditLink').html('View Text'); |
| 138 | + } |
| 139 | + |
| 140 | + $wikiMarkupEditWindowElem.show(); |
| 141 | + |
| 142 | + // log the usage of search window. |
| 143 | + wbLoggerService.logFeatureUsage(wbGlobalSettings.sessionId, "WikiMarkupEditWindowInvoked"); |
| 144 | + |
| 145 | + //clear the previous timeout |
| 146 | + if(wbWikiMarkupEdit.timer){ |
| 147 | + clearTimeout(wbWikiMarkupEdit.timer); |
| 148 | + } |
| 149 | + //set timeout to hide the popup |
| 150 | + wbWikiMarkupEdit.timer = setTimeout(function(){ |
| 151 | + if($("#wbWikiMarkupEditTab").css("display") == "none" && $("#wbWikiMarkupEditPreviewTab").css("display") == "none"){ |
| 152 | + wbWikiMarkupEdit.hide(); |
| 153 | + } |
| 154 | + },2500); |
| 155 | + }, |
| 156 | + //displays search window on application UI |
| 157 | + show: function() { |
| 158 | + // reset the preview tab |
| 159 | + $("#wbWikiMarkupEditPreviewTab").html(wbLocal.loadingPreviewContent); |
| 160 | + //unhide the content div |
| 161 | + $("#wbWikiMarkupEditTabsContainer").show(); |
| 162 | + if($("#wbWikiMarkupEditTab").css("display") == "none" && $("#wbWikiMarkupEditPreviewTab").css("display") == "none"){ |
| 163 | + $(".tab_content").hide(); |
| 164 | + $('#wbWikiMarkupEditTab').slideToggle("slow", function(){ |
| 165 | + $('#'+wbWikiMarkupEdit.windowId).height($('#wbWikiMarkupEditTab').height()); |
| 166 | + wbUIHelper.setWindowOnContext(wbWikiMarkupEdit.windowId, wbWikiMarkupEdit.wikiMarkupEditObject); |
| 167 | + }); |
| 168 | + }else{ |
| 169 | + $('#wbWikiMarkupEditPreviewTab').hide(); |
| 170 | + $('#wbWikiMarkupEditTab').show(); |
| 171 | + } |
| 172 | + // set property to disable/enable show / hide popup |
| 173 | + if(wbWikiMarkupEdit.isEditable == true){ |
| 174 | + wbWikiMarkupEdit.hasChanged=true; |
| 175 | + }else{ |
| 176 | + wbWikiMarkupEdit.hasChanged=false; |
| 177 | + } |
| 178 | + $('#wbWikiMarkupEditLi').addClass('active'); |
| 179 | + $('#wbWikiMarkupEditPreviewLi').removeClass('active'); |
| 180 | + return true; |
| 181 | + }, |
| 182 | + |
| 183 | + preview : function(){ |
| 184 | + wbWikiSite.getPreviewContent(wbWikiMarkupEdit.lang, $("#wbWikiMarkupEditTab").val(), function(previewData){ |
| 185 | + if(previewData){ |
| 186 | + $("#wbWikiMarkupEditPreviewTab").html(previewData); |
| 187 | + }else{ |
| 188 | + $("#wbWikiMarkupEditPreviewTab").html(wbLocal.previewErrorMessage); |
| 189 | + } |
| 190 | + }); |
| 191 | + |
| 192 | + //unhide the preview tab |
| 193 | + $("#wbWikiMarkupEditTabsContainer").show(); |
| 194 | + if($("#wbWikiMarkupEditPreviewTab").css("display") == "none" && $("#wbWikiMarkupEditTab").css("display") == "none"){ |
| 195 | + $(".tab_content").hide(); |
| 196 | + $('#wbWikiMarkupEditPreviewTab').slideToggle("slow", function(){ |
| 197 | + $('#'+wbWikiMarkupEdit.windowId).height($('#wbWikiMarkupEditPreviewTab').height()); |
| 198 | + wbUIHelper.setWindowOnContext(wbWikiMarkupEdit.windowId, wbWikiMarkupEdit.wikiMarkupEditObject); |
| 199 | + }); |
| 200 | + }else{ |
| 201 | + $('#wbWikiMarkupEditPreviewTab').show(); |
| 202 | + $('#wbWikiMarkupEditTab').hide(); |
| 203 | + } |
| 204 | + $('#wbWikiMarkupEditLi').removeClass('active'); |
| 205 | + $('#wbWikiMarkupEditPreviewLi').addClass('active'); |
| 206 | + return true; |
| 207 | + }, |
| 208 | + |
| 209 | + submit : function(){ |
| 210 | + wbUtil.setDataAttribute(wbWikiMarkupEdit.wikiMarkupEditObject, $("#wbWikiMarkupEditTab").val()); |
| 211 | + wbWikiMarkupEdit.hide(); |
| 212 | + }, |
| 213 | + |
| 214 | + //removes the window from the application window |
| 215 | + unload: function() { |
| 216 | + wbUIHelper.removeWindow(this.windowId); |
| 217 | + }, |
| 218 | + |
| 219 | + //hides the window from application UI |
| 220 | + hide: function() { |
| 221 | + $("#wbWikiMarkupEditTab").html(""); |
| 222 | + // reset the preview tab |
| 223 | + $("#wbWikiMarkupEditPreviewTab").html(wbLocal.loadingPreviewContent); |
| 224 | + wbWikiMarkupEdit.hasChanged=false; |
| 225 | + $("#" + this.windowId).hide(); |
| 226 | + } |
| 227 | + }; |
| 228 | + |
| 229 | + //shortcut to call wikiBhasha.windowManagement.wikiMarkupEditWindow |
| 230 | + wbWikiMarkupEdit = wikiBhasha.windowManagement.wikiMarkupEditWindow; |
| 231 | +})(); |
\ No newline at end of file |
Property changes on: trunk/extensions/WikiBhasha/src/js/core/wikiMarkupEditWindow.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 232 | + native |
Index: trunk/extensions/WikiBhasha/src/js/core/utils.js |
— | — | @@ -371,9 +371,37 @@ |
372 | 372 | }); |
373 | 373 | } |
374 | 374 | }, |
| 375 | + //sets the given window position to the context of the mouse pointer hovered element. |
| 376 | + setWindowOnContext: function (windowId, elem) { |
| 377 | + var $windowElement = $("#" + windowId), |
| 378 | + $browserWindowElement = $(window), |
| 379 | + pos = $(elem).offset(), |
| 380 | + left = pos.left, |
| 381 | + top = pos.top, |
| 382 | + wHeight = $windowElement.height(), |
| 383 | + wWidth = $windowElement.width(); |
| 384 | + |
| 385 | + if ((top + wHeight + 30) > $(window).height()) { |
| 386 | + top = top - wHeight; |
| 387 | + } |
| 388 | + |
| 389 | + if ((left + wWidth + 30) > $(window).width()) { |
| 390 | + left = left - wWidth; |
| 391 | + } else { |
| 392 | + left = left + $(elem).width(); |
| 393 | + } |
| 394 | + |
| 395 | + //set top and left to the window |
| 396 | + $windowElement.css({ |
| 397 | + top: top + 'px', |
| 398 | + left: left + 'px' |
| 399 | + }); |
| 400 | + }, |
| 401 | + // changed the mouse pointer to hourglass pointer |
375 | 402 | changeCursorToHourGlass: function () { |
376 | 403 | $("body").css("cursor", "progress"); |
377 | 404 | }, |
| 405 | + // changed the mouse pointer to default pointer |
378 | 406 | changeCursorToDefault: function () { |
379 | 407 | $("body").css("cursor", "auto"); |
380 | 408 | } |