itip-formatter: Move JavaScript code from C to e-web-view.js
This is cleaner than having the code in the C and recompile the project for any simple change. There is also added a call to window.webkit.messageHandlers.scheduleIFramesHeightUpdate.postMessage(0); at the end, which caused trouble when being in the C code (there had been issued an "Unsupported return type" error).
This commit is contained in:
@ -1852,3 +1852,24 @@ EvoItip.GetState = function(iframe_id)
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
EvoItip.FlipAlternativeHTMLPart = function(iframe_id, element_value, img_id, span_id)
|
||||
{
|
||||
var elem = Evo.FindElement(iframe_id, element_value);
|
||||
if (elem) {
|
||||
elem.hidden = !elem.hidden;
|
||||
}
|
||||
elem = Evo.FindElement(iframe_id, img_id);
|
||||
if (elem) {
|
||||
var tmp = elem.src;
|
||||
elem.src = elem.getAttribute("othersrc");
|
||||
elem.setAttribute("othersrc", tmp);
|
||||
}
|
||||
elem = Evo.FindElement(iframe_id, span_id);
|
||||
if (elem) {
|
||||
var tmp = elem.innerText;
|
||||
elem.innerText = elem.getAttribute("othertext");
|
||||
elem.setAttribute("othertext", tmp);
|
||||
}
|
||||
window.webkit.messageHandlers.scheduleIFramesHeightUpdate.postMessage(0);
|
||||
}
|
||||
|
||||
@ -93,25 +93,7 @@ itip_view_alternative_html_clicked_cb (EWebView *web_view,
|
||||
g_return_if_fail (g_snprintf (tmp, sizeof (tmp), "%s-img", element_value) < sizeof (tmp));
|
||||
|
||||
e_web_view_jsc_run_script (WEBKIT_WEB_VIEW (web_view), e_web_view_get_cancellable (web_view),
|
||||
"var elem = Evo.FindElement(%s, %s);\n"
|
||||
"if (elem) {\n"
|
||||
" elem.hidden = !elem.hidden;\n"
|
||||
"}\n"
|
||||
"elem = Evo.FindElement(%s, %s);\n"
|
||||
"if (elem) {\n"
|
||||
" var tmp = elem.src;\n"
|
||||
" elem.src = elem.getAttribute(\"othersrc\");\n"
|
||||
" elem.setAttribute(\"othersrc\", tmp);\n"
|
||||
"}\n"
|
||||
"elem = Evo.FindElement(%s, %s);\n"
|
||||
"if (elem) {\n"
|
||||
" var tmp = elem.innerText;\n"
|
||||
" elem.innerText = elem.getAttribute(\"othertext\");\n"
|
||||
" elem.setAttribute(\"othertext\", tmp);\n"
|
||||
"}\n",
|
||||
iframe_id, element_value,
|
||||
iframe_id, tmp,
|
||||
iframe_id, spn);
|
||||
"EvoItip.FlipAlternativeHTMLPart(%s,%s,%s,%s);", iframe_id, element_value, tmp, spn);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user