Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions Src/LexText/ParserUI/TryAWordDlg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
using XCore;
using SIL.FieldWorks.Common.FwUtils;
using SIL.Utils;
using SIL.FieldWorks.XWorks;
using Gecko;
using static SIL.FieldWorks.XWorks.GeneratedHtmlViewer;

namespace SIL.FieldWorks.LexText.Controls
{
Expand Down Expand Up @@ -66,6 +69,8 @@ public class TryAWordDlg : Form, IMediatorProvider, IPropertyTableProvider
private WebPageInteractor m_webPageInteractor;
private IParserTrace m_trace;

private GeneratedHtmlViewer.FindDialog findDialog;

#endregion Data members

/// <summary>
Expand Down Expand Up @@ -153,6 +158,7 @@ private void InitHtmlControl()
Size = new Size(m_resultsPanel.Width, m_resultsPanel.Height - (m_resultsLabel.Height + 1)),
Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right
};
m_htmlControl.Browser.DomKeyPress += new EventHandler<DomKeyEventArgs>(OnDomKeyPress);
// Setting the Dock to fill doesn't work, as we lose the top of the HtmlControl to the
// label control at the top of the panel. See LT-7446 for the worst case scenario (120dpi).
// So, set the location and size of the HTML control, and anchor it to all four sides of the
Expand Down Expand Up @@ -359,6 +365,30 @@ private void InitializeComponent()
}

#endregion
private void OnDomKeyPress(object sender, DomKeyEventArgs e)
{
var ctrl = e.CtrlKey;
if (ctrl && (char)e.KeyChar == 'f')
{
findDialog = new FindDialog(m_htmlControl.Browser);
findDialog.FormClosing += new FormClosingEventHandler(FindDialog_FormClosing);
findDialog.Show(this);
}
else if (e.KeyCode == (uint)Keys.Escape)
{
// we use escape to close the find dialog
findDialog?.Close();
}
}
private void FindDialog_FormClosing(object sender, FormClosingEventArgs e)
{
using (var executor = new AutoJSContext(m_htmlControl.Browser.Window))
{
// Javascript query to execute in the browser
var browserJsQuery = "cleanUpHighlights()";
executor.EvaluateScript(browserJsQuery);
}
}

protected override void OnClosed(EventArgs ea)
{
Expand Down
12 changes: 11 additions & 1 deletion Src/LexText/ParserUI/WebPageInteractor.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2015 SIL International
// Copyright (c) 2015 SIL International
// This software is licensed under the LGPL, version 2.1 or later
// (http://www.gnu.org/licenses/lgpl-2.1.html)

Expand All @@ -9,6 +9,7 @@
using SIL.FieldWorks.FdoUi;
using SIL.LCModel;
using XCore;
using static SIL.FieldWorks.XWorks.GeneratedHtmlViewer;

namespace SIL.FieldWorks.LexText.Controls
{
Expand Down Expand Up @@ -78,6 +79,15 @@ protected void HandleDomClick(object sender, DomMouseEventArgs e)
break;
}
}
if (elem.TagName.Equals("IMG", StringComparison.InvariantCultureIgnoreCase)
&& m_htmlControl.ParentForm != null && m_htmlControl.ParentForm.OwnedForms.Length > 0)
{
// Try a Word tracing items:
// close any instance of the find dialog when a section is opened or closed because the matches are
// no longer valid or needed.
FindDialog findDlg = (FindDialog)m_htmlControl.ParentForm.OwnedForms[0];
findDlg?.Close();
}
}

/// <summary>
Expand Down
181 changes: 2 additions & 179 deletions Src/Transforms/Presentation/FormatHCTrace.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="4.0" encoding="UTF-8" indent="yes" media-type="text/html; charset=utf-8"/>
<xsl:include href="FormatCommon.xsl"/>
<xsl:include href="JSFunctions.xsl"/>
<!--
================================================================
Format the xml returned from XAmple parse for user display.
Expand Down Expand Up @@ -57,13 +58,7 @@ Main template
<html>
<head>
<meta charset="UTF-8" />
<xsl:call-template name="Script"/>
<style type="text/css">
.interblock {
display: -moz-inline-box;
display: inline-block;
vertical-align: top;
}</style>
<xsl:call-template name="TraceScript"/>
</head>
<body style="font-family:Times New Roman">
<h1>
Expand Down Expand Up @@ -420,178 +415,6 @@ ShowMsaInfo
</span>
</xsl:for-each>
</xsl:template>
<!--
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Script
Output the JavaScript script to handle dynamic "tree"
Parameters: none
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-->
<xsl:template name="Script">
<script language="JavaScript" id="clientEventHandlersJS">
<xsl:text disable-output-escaping="yes">
function ButtonShowDetails()
{
if (TraceSection.style.display == 'none')
{
TraceSection.style.display = 'block';
ShowDetailsButton.value = "Hide Details";
}
else
{
TraceSection.style.display = 'none';
ShowDetailsButton.value = "Show Details";
}
}
// Center the mouse position in the browser
function CenterNodeInBrowser(node)
{
var posx = 0;
var posy = 0;
if (!e) var e = window.event;
if (e.pageX || e.pageY)
{
posx = e.pageX;
posy = e.pageY;
}
else if (e.clientX || e.clientY)
{
posx = e.clientX + document.body.scrollLeft;
posy = e.clientY + document.body.scrollTop;
}
// posx and posy contain the mouse position relative to the document
curY = findPosY(node);
offset = document.body.clientHeight/2;
window.scrollTo(0, curY-offset); // scroll to about the middle if possible
}
// findPosX() and findPosY() are from http://www.quirksmode.org/js/findpos.html
function findPosX(obj)
{
var curleft = 0;
if (obj.offsetParent)
{
while (obj.offsetParent)
{
curleft += obj.offsetLeft
obj = obj.offsetParent;
}
}
else if (obj.x)
curleft += obj.x;
return curleft;
}

function findPosY(obj)
{
var curtop = 0;
if (obj.offsetParent)
{
while (obj.offsetParent)
{
curtop += obj.offsetTop
obj = obj.offsetParent;
}
}
else if (obj.y)
curtop += obj.y;
return curtop;
}

// nextSibling function that skips over textNodes.
function NextNonTextSibling(node)
{
while(node.nextSibling.nodeName == "#text")
node = node.nextSibling;

return node.nextSibling;
}

// This script based on the one given in http://www.codeproject.com/jscript/dhtml_treeview.asp.
function Toggle(node, path, imgOffset)
{

Images = new Array('beginminus.gif', 'beginplus.gif', 'lastminus.gif', 'lastplus.gif', 'minus.gif', 'plus.gif', 'singleminus.gif', 'singleplus.gif',
'beginminusRTL.gif', 'beginplusRTL.gif', 'lastminusRTL.gif', 'lastplusRTL.gif', 'minusRTL.gif', 'plusRTL.gif', 'singleminusRTL.gif', 'singleplusRTL.gif');
// Unfold the branch if it isn't visible

if (NextNonTextSibling(node).style.display == 'none')
{
// Change the image (if there is an image)
if (node.childNodes.length > 0)
{
if (node.childNodes.item(0).nodeName == "IMG")
{
var str = node.childNodes.item(0).src;
var pos = str.indexOf(Images[1 + imgOffset]); // beginplus.gif
if (pos >= 0)
{
node.childNodes.item(0).src = path + Images[0 + imgOffset]; // "beginminus.gif";
}
else
{
pos = str.indexOf(Images[7 + imgOffset]); // "singleplus.gif");
if (pos >= 0)
{
node.childNodes.item(0).src = path + Images[6 + imgOffset]; // "singleminus.gif";
}
else
{
pos = str.indexOf(Images[3 + imgOffset]); // "lastplus.gif");
if (pos >= 0)
{
node.childNodes.item(0).src = path + Images[2 + imgOffset]; // "lastminus.gif";
}
else
{
node.childNodes.item(0).src = path + Images[4 + imgOffset]; // "minus.gif";
}
}
}
}
}
NextNonTextSibling(node).style.display = 'block';
CenterNodeInBrowser(node);
}
// Collapse the branch if it IS visible
else
{
// Change the image (if there is an image)
if (node.childNodes.length > 0)
{
if (node.childNodes.item(0).nodeName == "IMG")
var str = node.childNodes.item(0).src;
var pos = str.indexOf(Images[0 + imgOffset]); // "beginminus.gif");
if (pos >= 0)
{
node.childNodes.item(0).src = path + Images[1 + imgOffset]; // "beginplus.gif";
}
else
{
pos = str.indexOf(Images[6 + imgOffset]); // "singleminus.gif");
if (pos >= 0)
{
node.childNodes.item(0).src = path + Images[7 + imgOffset]; // "singleplus.gif";
}
else
{
pos = str.indexOf(Images[2 + imgOffset]); // "lastminus.gif");
if (pos >= 0)
{
node.childNodes.item(0).src = path + Images[3 + imgOffset]; // "lastplus.gif";
}
else
{
node.childNodes.item(0).src = path + Images[5 + imgOffset]; // "plus.gif";
}
}
}
}
NextNonTextSibling(node).style.display = 'none';
}
}
</xsl:text>
</script>
</xsl:template>
<!--
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ShowAnyFailure
Expand Down
10 changes: 2 additions & 8 deletions Src/Transforms/Presentation/FormatXAmpleParse.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="4.0" encoding="UTF-8" indent="yes" media-type="text/html; charset=utf-8"/>
<xsl:include href="FormatCommon.xsl"/>
<xsl:include href="JSFunctions.xsl"/>
<!--
================================================================
Format the xml returned from XAmple parse for user display.
Expand Down Expand Up @@ -51,14 +52,7 @@ Main template
<html>
<head>
<meta charset="UTF-8" />
<style type="text/css">
.interblock {
display: -moz-inline-box;
display:
inline-block;
vertical-align: top;

}</style>
<xsl:call-template name="FindScript"/>
</head>
<body style="font-family:Times New Roman">
<h1>
Expand Down
Loading
Loading