Commit 265b8b8e authored by Laurent Montel's avatar Laurent Montel 😁

Look at to execute javascript in specific wordid

parent cea1557b
......@@ -108,6 +108,11 @@ MailWebEngineView::~MailWebEngineView()
}
void MailWebEngineView::runJavaScriptInWordId(const QString &script)
{
page()->runJavaScript(script);
}
void MailWebEngineView::initializeScripts()
{
initializeJQueryScript();
......@@ -130,12 +135,12 @@ void MailWebEngineView::slotWebHitFinished(const WebEngineViewer::WebHitTestResu
void MailWebEngineView::scrollUp(int pixels)
{
page()->runJavaScript(WebEngineViewer::WebEngineScript::scrollUp(pixels));
runJavaScriptInWordId(WebEngineViewer::WebEngineScript::scrollUp(pixels));
}
void MailWebEngineView::scrollDown(int pixels)
{
page()->runJavaScript(WebEngineViewer::WebEngineScript::scrollDown(pixels));
runJavaScriptInWordId(WebEngineViewer::WebEngineScript::scrollDown(pixels));
}
void MailWebEngineView::selectAll()
......@@ -248,22 +253,23 @@ bool MailWebEngineView::isScrolledToBottom() const
void MailWebEngineView::setElementByIdVisible(const QString &id, bool visible)
{
page()->runJavaScript(WebEngineViewer::WebEngineScript::setElementByIdVisible(id, visible));
runJavaScriptInWordId(WebEngineViewer::WebEngineScript::setElementByIdVisible(id, visible));
}
void MailWebEngineView::removeAttachmentMarking(const QString &id)
{
page()->runJavaScript(WebEngineViewer::WebEngineScript::removeStyleToElement(QLatin1String("*#") + id));
runJavaScriptInWordId(WebEngineViewer::WebEngineScript::removeStyleToElement(QLatin1String("*#") + id));
}
void MailWebEngineView::markAttachment(const QString &id, const QString &style)
{
//TODO verify "*#" + id
page()->runJavaScript(WebEngineViewer::WebEngineScript::setStyleToElement(QLatin1String("*#") + id, style));
runJavaScriptInWordId(WebEngineViewer::WebEngineScript::setStyleToElement(QLatin1String("*#") + id, style));
}
void MailWebEngineView::scrollToAnchor(const QString &anchor)
{
//TODO add wordid here too
page()->runJavaScript(WebEngineViewer::WebEngineScript::searchElementPosition(anchor), invoke(this, &MailWebEngineView::handleScrollToAnchor));
}
......@@ -273,14 +279,14 @@ void MailWebEngineView::handleScrollToAnchor(const QVariant &result)
const QList<QVariant> lst = result.toList();
if (lst.count() == 2) {
const QPoint pos(lst.at(0).toInt(), lst.at(1).toInt());
page()->runJavaScript(WebEngineViewer::WebEngineScript::scrollToPosition(pos));
runJavaScriptInWordId(WebEngineViewer::WebEngineScript::scrollToPosition(pos));
}
}
}
void MailWebEngineView::scrollPageDown(int percent)
{
page()->runJavaScript(WebEngineViewer::WebEngineScript::scrollPercentage(percent));
runJavaScriptInWordId(WebEngineViewer::WebEngineScript::scrollPercentage(percent));
}
void MailWebEngineView::scrollPageUp(int percent)
......@@ -293,7 +299,7 @@ void MailWebEngineView::executeCustomRenderingScripts()
const QString scripts = MessageViewer::MailWebEngineScript::manageShowHideAttachments() +
MessageViewer::MailWebEngineScript::manageExpandAddresses(QStringLiteral("To")) +
MessageViewer::MailWebEngineScript::manageExpandAddresses(QStringLiteral("Cc"));
page()->runJavaScript(scripts);
runJavaScriptInWordId(scripts);
}
void MailWebEngineView::injectAttachments(const boost::function<QString()> &delayedHtml)
......@@ -302,7 +308,7 @@ void MailWebEngineView::injectAttachments(const boost::function<QString()> &dela
if (html.isEmpty()) {
return;
}
page()->runJavaScript(MessageViewer::MailWebEngineScript::injectAttachments(html, QStringLiteral("attachmentInjectionPoint")));
runJavaScriptInWordId(MessageViewer::MailWebEngineScript::injectAttachments(html, QStringLiteral("attachmentInjectionPoint")));
}
void MailWebEngineView::toggleFullAddressList(const QString &field, const boost::function<QString()> &delayedHtml)
......@@ -313,7 +319,7 @@ void MailWebEngineView::toggleFullAddressList(const QString &field, const boost:
}
//qDebug() << "void MailWebEngineView::toggleFullAddressList(const QString &field, const boost::function<QString()> &delayedHtml, bool doShow)" << html << " fields " << field;
page()->runJavaScript(MessageViewer::MailWebEngineScript::replaceInnerHtml(field, html));
runJavaScriptInWordId(MessageViewer::MailWebEngineScript::replaceInnerHtml(field, html));
}
bool MailWebEngineView::hasVerticalScrollBar() const
......@@ -333,7 +339,7 @@ bool MailWebEngineView::isAttachmentInjectionPoint(const QPoint &globalPos) cons
void MailWebEngineView::scrollToRelativePosition(qreal pos)
{
page()->runJavaScript(WebEngineViewer::WebEngineScript::scrollToRelativePosition(pos));
runJavaScriptInWordId(WebEngineViewer::WebEngineScript::scrollToRelativePosition(pos));
}
QUrl MailWebEngineView::linkOrImageUrlAt(const QPoint &global) const
......@@ -379,3 +385,4 @@ void MailWebEngineView::dropEvent(QDropEvent *e)
Q_UNUSED(e);
qDebug() << " MailWebEngineView::dropEvent";
}
......@@ -101,6 +101,7 @@ private Q_SLOTS:
void slotLoadFinished();
private:
void initializeScripts();
void runJavaScriptInWordId(const QString &script);
MailWebEngineViewPrivate *const d;
};
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment