r77574 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r77573‎ | r77574 | r77575 >
Date:11:43, 2 December 2010
Author:wikibhasha.msr
Status:deferred
Tags:
Comment:
Bug 26200 - issue solved: Provide functionality to preview templates
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/core/utils.js (modified) (history)
  • /trunk/extensions/WikiBhasha/src/js/core/wikiMarkupEditWindow.js (added) (history)
  • /trunk/extensions/WikiBhasha/src/js/extern/languageServicesInterface.js (modified) (history)
  • /trunk/extensions/WikiBhasha/src/js/extern/wikipediaInterface.js (modified) (history)
  • /trunk/extensions/WikiBhasha/src/js/main.js (modified) (history)
  • /trunk/extensions/WikiBhasha/src/lang/de/strings.js (modified) (history)
  • /trunk/extensions/WikiBhasha/src/lang/en/strings.js (modified) (history)
  • /trunk/extensions/WikiBhasha/src/styles/wikiBhasha.css (modified) (history)

Diff [purge]

Index: trunk/extensions/WikiBhasha/src/lang/en/strings.js
@@ -81,6 +81,8 @@
8282 warningSaveComposeChanges: "Any changes made in this step would be lost if you move to an earlier step. Do you want to move anyway?",
8383 noTargetLanguageArticleFound: "Linked article not found in target language Wikipedia.",
8484 feedbackQuestionMessage: "Before leaving WikiBhasha, would you like to give us feedback?",
 85+ previewErrorMessage: "Unable to show the preview.",
 86+ loadingPreviewContent: "Loading Preview...",
8587
8688 //tooptip strings
8789 searchInputTooltip: "Search",
Index: trunk/extensions/WikiBhasha/src/lang/de/strings.js
@@ -80,6 +80,8 @@
8181 warningSaveComposeChanges: "Any changes made in this step would be lost if you move to an earlier step. Do you want to move anyway?",
8282 noTargetLanguageArticleFound: "Linked article not found in target language Wikipedia.",
8383 feedbackQuestionMessage: "Before leaving WikiBhasha, would you like to give us feedback?",
 84+ previewErrorMessage: "Unable to show the preview.",
 85+ loadingPreviewContent: "Loading Preview...",
8486
8587 //tooptip strings
8688 searchInputTooltip: "Search",
Index: trunk/extensions/WikiBhasha/src/styles/wikiBhasha.css
@@ -66,6 +66,19 @@
6767 color:Black;
6868 direction:ltr;
6969 }
 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+}
7083 #wbChineseLangSelectionWindow
7184 {
7285 z-index: 10000;
@@ -143,6 +156,10 @@
144157 width:539px;
145158 margin:7px 7px 0px 7px;
146159 }
 160+#wbWikiMarkupEditSubmitLink
 161+{
 162+ text-align:center;
 163+}
147164 #wbSelectionDiv {
148165 width:550px;
149166 height: 555px;
@@ -162,7 +179,6 @@
163180 float:left;
164181 width:100px;
165182 }
166 -
167183 .wbHeaderContainer {
168184 float:left;
169185 padding:0 10px 5px 15px;
@@ -175,11 +191,17 @@
176192 }
177193 .wbSearch
178194 {
179 -
180195 font-size:12px;
181196 color:Black;
182197 background-color: #ffffff;
183198 }
 199+.wbWikiMarkupEdit
 200+{
 201+ font-size:12px;
 202+ color:Black;
 203+ background-color: #ffffff;
 204+ border:1px #000000 solid;
 205+}
184206 .wbTargetSearch
185207 {
186208 background-color:#F1F1F1;
@@ -633,4 +655,68 @@
634656 #wbToggleCTFLabel
635657 {
636658 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;
637723 }
\ No newline at end of file
Index: trunk/extensions/WikiBhasha/src/js/main.js
@@ -237,6 +237,7 @@
238238 "js/core/scratchpadWindow.js",
239239 "js/core/feedbackWindow.js",
240240 "js/core/searchWindow.js",
 241+ "js/core/wikiMarkupEditWindow.js",
241242 "js/core/templateAndLinkTranslator.js",
242243 "js/core/themes.js",
243244 "js/core/utils.js",
Index: trunk/extensions/WikiBhasha/src/js/extern/wikipediaInterface.js
@@ -38,6 +38,9 @@
3939 //API to search wikipedia article
4040 wikiSearchAPI: "http://{0}.wikipedia.org/w/api.php?action=query&list=search&srsearch={1}&format=json",
4141
 42+ //API to search wikipedia article
 43+ wikiPreviewAPI: "http://{0}.wikipedia.org/w/api.php?action=parse&text={1}&format=json",
 44+
4245 //API to get wikipedia language links
4346 wikiLangLinksAPI: "http://{0}.wikipedia.org/w/api.php?action=query&prop=langlinks&format=json&redirects=1&titles={1}&lllimit=5000",
4447
@@ -300,7 +303,17 @@
301304 //checks whether current domain is wikipedia or not
302305 isWikiDomain: function(url) {
303306 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+ });
304318 }
305 -
306319 };
307320 })();
\ No newline at end of file
Index: trunk/extensions/WikiBhasha/src/js/extern/languageServicesInterface.js
@@ -31,7 +31,7 @@
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+
3636 languageServiceProvider: "",
3737
3838 //set the language service provider object in history item
@@ -110,6 +110,7 @@
111111 onTranslationCompleted();
112112 }
113113 });
 114+
114115 });
115116 }
116117 }
Index: trunk/extensions/WikiBhasha/src/js/core/mainWindow.js
@@ -226,7 +226,7 @@
227227 wbDisplayPaneManager.toggleDisplayMode();
228228 });
229229
230 - //bind click event to toggle between wiki and html formats
 230+ //bind click event to toggle between wiki and html formats
231231 $("#wbToggleCTF").click(function() {
232232 wbDisplayPaneManager.toggleCTFDisplay();
233233 });
@@ -322,6 +322,7 @@
323323 //Unload the context menu and search window for the application
324324 wbContextMenuHandler.unload();
325325 wbSearch.unload();
 326+ wbWikiMarkupEdit.unload();
326327 wbSplash.close();
327328
328329 wbTransliterationServices.disableTransliteration(wbGlobalSettings.mtTargetLanguageCode);
@@ -382,6 +383,7 @@
383384 "wbWikiSite",
384385 "wbWorkflow",
385386 "wbChineseLangSelection",
 387+ "wbWikiMarkupEditWindow",
386388 "wb"];
387389
388390 for (var i = 0; i < wbGloablVariables.length; i++) {
@@ -456,7 +458,7 @@
457459
458460 //removes cloned HTML elements(during Drag-Drop or Copy-Paste) from the element"#wbRightWindowContentDiv"
459461 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"));
461463 var removeCloneNodes = function() {
462464 //jQuery '.remove()' method actually removes the events on original elements
463465 //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 @@
4646 // Typically, this element is created and initialized in this class's 'initialize()' call.
4747 $contentElem: null,
4848
 49+ // language of the content the pane contains
 50+ contentLang: null,
 51+
4952 // Required Member. This is called only once per WikiBhasha session before this pane is used or displayed.
5053 initialize: function() {
5154 // Create necessary elements and initializations here and append item to 'this.$contentElem'. The '$contentElem'
@@ -69,7 +72,6 @@
7073 onDisplayModeChanged: function(isShowWikimarkupMode) {
7174 },
7275
73 -
7476 // Optional Member. This function gets called just before the pane is to be hidden, for example, when user
7577 // changes steps. Return false to cancel the hide operation and be in the current step.
7678 canHide: function() {
@@ -110,7 +112,7 @@
111113 //get wikipedia article compose url
112114 var urlData = wbWikiSite.getEditPageUrl(wbGlobalSettings.targetLanguageCode, wbGlobalSettings.targetLanguageArticleTitle),
113115 //iframe object
114 - composeFrameObject = document.getElementById("wbComposeIFrame");
 116+ composeFrameObject = document.getElementById("wbComposeIFrame");
115117
116118 this.$contentElem = $("#" + this.contentDivId);
117119
@@ -228,7 +230,6 @@
229231 });
230232 });
231233 }
232 -
233234 },
234235
235236 onShow: function() {
@@ -322,6 +323,7 @@
323324
324325 initialize: function() {
325326 wbUIHelper.changeCursorToHourGlass();
 327+ wbSourceOriginalPane.contentLang = wbGlobalSettings.sourceLanguageCode;
326328 this.$contentElem = $("<div>" + wbLocal.loadingElementContent + "</div>").attr("id", this.contentDivId);
327329 if (!wbGlobalSettings.sourceLanguageArticleTitle) {
328330
@@ -418,6 +420,7 @@
419421
420422 onHistoryChanged: function(historyItem) {
421423 var title = historyItem.title;
 424+
422425 if (historyItem.langId === wbGlobalSettings.sourceLanguageCode) {
423426 //If content available in history item
424427 if (historyItem.content) {
@@ -427,8 +430,7 @@
428431
429432 // Rehook events to links. Once element is removed and added back, link events disappear, so rehooking is needed.
430433 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
433435 if(wbLanguageServices.fetchLanguageServiceProviderObject){
434436 wbLanguageServices.fetchLanguageServiceProviderObject(historyItem);
435437 }
@@ -448,7 +450,7 @@
449451 else {
450452 this.$contentElem.html("<div>" + wbLocal.sourceArticleNotApplicable + "</div>");
451453 }
452 - //apply the CTF popup state
 454+ //apply the CTF popup state
453455 wbDisplayPaneManager.toggleCTFDisplay();
454456 },
455457
@@ -482,6 +484,7 @@
483485
484486 initialize: function() {
485487 wbUIHelper.changeCursorToHourGlass();
 488+ wbSourceTranslatedPane.contentLang = wbGlobalSettings.targetLanguageCode;
486489 this.$contentElem = $("<div>" + wbLocal.loadingElementContent + "</div>").attr("id", this.contentDivId);
487490
488491 // set the orientation of the content based on the language
@@ -529,7 +532,7 @@
530533 wbDisplayPaneHelper.$showWikimarkupCheckBox.attr("disabled", "true").attr("title", wbLocal.waitUntilTranslationComplete);
531534
532535 wbUIHelper.changeCursorToHourGlass();
533 -
 536+
534537 wbLanguageServices.translateParallelElements(sourceElem, $childElem, function() {
535538 //as soon as translation is done, enable the toggle mode check box.
536539 wbDisplayPaneHelper.$showWikimarkupCheckBox.removeAttr("disabled").removeAttr("title");
@@ -539,7 +542,7 @@
540543 if (wbLanguageServices.exitButtonElementId && $("#" + wbMainWindow.windowId).length === 0) {
541544 $("#" + wbLanguageServices.exitButtonElementId).get(0).onclick();
542545 }
543 - //create language service provider object in the history item
 546+ //create language service provider object in the history item
544547 if(wbLanguageServices.setLanguageServiceProviderObject){
545548 wbLanguageServices.setLanguageServiceProviderObject(historyItem);
546549 }
@@ -547,12 +550,13 @@
548551 //as soon as translation is done, enable the default Cursor
549552 wbUIHelper.changeCursorToDefault();
550553 });
 554+
551555 }
552556 }
553557 //else updates the history item with the content
554558 else if (historyItem) {
555559 historyItem.content = $childElem;
556 - //create language service provider object in the history item
 560+ //create language service provider object in the history item
557561 if(wbLanguageServices.setLanguageServiceProviderObject){
558562 wbLanguageServices.setLanguageServiceProviderObject(historyItem);
559563 }
@@ -572,6 +576,7 @@
573577 // Show "loading..." message till then
574578 wbUIHelper.changeCursorToHourGlass();
575579 wbDisplayPaneHelper.loadHighlightContent(wbLocal.loadingElementContent, wbSourceTranslatedPane);
 580+
576581 }
577582 }
578583 else if (historyItem.langId === wbGlobalSettings.targetLanguageCode && historyItem.content !== null) {
@@ -590,6 +595,7 @@
591596 function(data) {
592597 wbSourceTranslatedPane.loadAndTranslateContent(data, null, historyItem);
593598 });
 599+
594600 }
595601 },
596602
@@ -628,6 +634,7 @@
629635
630636 initialize: function() {
631637 wbUIHelper.changeCursorToHourGlass();
 638+ wbTargetContentPane.contentLang = wbGlobalSettings.targetLanguageCode;
632639 wbTargetContentPane.$contentElem = $("<div>" + wbLocal.loadingElementContent + "</div>").attr("id", this.contentDivId);
633640
634641 // set the orientation of the content based on the language
@@ -944,7 +951,8 @@
945952 // log the fact that user used this feature
946953 wbLoggerService.logFeatureUsage(wbGlobalSettings.sessionId, "WikiModeSwitch", isShowWikimarkupMode);
947954 },
948 - //enable/disable CTF popup display
 955+
 956+ //enable/disable CTF popup display
949957 toggleCTFDisplay: function() {
950958 var isShowCTFPopup = wbDisplayPaneHelper.isShowCTFPopupChecked();
951959 if (wbLanguageServices.onCTFDisplayModeChanged) {
@@ -954,6 +962,7 @@
955963 // log the fact that user used this feature
956964 wbLoggerService.logFeatureUsage(wbGlobalSettings.sessionId, "CTFPopupDisplay", isShowCTFPopup);
957965 },
 966+
958967 //removes content DIVs from application display.
959968 removeContentDiv: function(parentElement) {
960969 var previousArticleContent = parentElement.find(".articleContentDiv");
@@ -977,7 +986,10 @@
978987
979988 initialize: function() {
980989 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); });
982994 },
983995
984996 //checks the value of display mode check box.
@@ -985,7 +997,7 @@
986998 return wbDisplayPaneHelper.$showWikimarkupCheckBox.attr("checked");
987999 },
9881000
989 - //checks the value of CTF popup display check box.
 1001+ //checks the value of CTF popup display check box.
9901002 isShowCTFPopupChecked: function() {
9911003 return wbDisplayPaneHelper.$showCTFPopup.attr("checked");
9921004 },
@@ -1184,6 +1196,11 @@
11851197 }
11861198 },
11871199
 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+
11881205 //sets pane title according to the format given in configuration.
11891206 setPaneTitleFromConfig: function($contentElem, paneConfigInfo) {
11901207 var paneTitle = paneConfigInfo.title;
Index: trunk/extensions/WikiBhasha/src/js/core/globalSettings.js
@@ -847,6 +847,25 @@
848848 </tr>\
849849 </table>',
850850
 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"/>&nbsp;&nbsp;&nbsp;&nbsp;\
 866+<input type="button" id="wbWikiMarkupEditCancelLink" value="Cancel"/>\
 867+</div>\
 868+</div>\
 869+</div>',
851870
852871 tutorialWindowHTML:'<div id="wbTutorialDiv" class="wbTutorialBgContentArea" >\
853872 <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
1232 + native
Index: trunk/extensions/WikiBhasha/src/js/core/utils.js
@@ -371,9 +371,37 @@
372372 });
373373 }
374374 },
 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
375402 changeCursorToHourGlass: function () {
376403 $("body").css("cursor", "progress");
377404 },
 405+ // changed the mouse pointer to default pointer
378406 changeCursorToDefault: function () {
379407 $("body").css("cursor", "auto");
380408 }

Status & tagging log