]>
Commit | Line | Data |
---|---|---|
a479f3ef AD |
1 | function embedOriginalArticle(id) { |
2 | try { | |
3 | var hasSandbox = "sandbox" in document.createElement("iframe"); | |
4 | ||
5 | if (!hasSandbox) { | |
6 | alert(__("Sorry, your browser does not support sandboxed iframes.")); | |
7 | return; | |
8 | } | |
9 | ||
10 | var query = "op=pluginhandler&plugin=embed_original&method=getUrl&id=" + | |
11 | param_escape(id); | |
12 | ||
13 | var c = false; | |
14 | ||
15 | if (isCdmMode()) { | |
16 | c = $$("div#RROW-" + id + " div[class=cdmContentInner]")[0]; | |
17 | } else if (id == getActiveArticleId()) { | |
18 | c = $$("div[class=postContent]")[0]; | |
19 | } | |
20 | ||
21 | if (c) { | |
44db06b6 | 22 | var iframe = c.parentNode.getElementsByClassName("embeddedContent")[0]; |
a479f3ef AD |
23 | |
24 | if (iframe) { | |
44db06b6 SS |
25 | Element.show(c); |
26 | c.parentNode.removeChild(iframe); | |
a479f3ef AD |
27 | |
28 | if (isCdmMode()) { | |
29 | cdmScrollToArticleId(id, true); | |
30 | } | |
31 | ||
32 | return; | |
33 | } | |
34 | } | |
35 | ||
36 | new Ajax.Request("backend.php", { | |
37 | parameters: query, | |
38 | onComplete: function(transport) { | |
39 | var ti = JSON.parse(transport.responseText); | |
40 | ||
41 | if (ti) { | |
42 | ||
43 | var iframe = new Element("iframe", { | |
44 | class: "embeddedContent", | |
45 | src: ti.url, | |
44db06b6 SS |
46 | width: (c.parentNode.offsetWidth-5)+'px', |
47 | height: (c.parentNode.parentNode.offsetHeight-c.parentNode.firstChild.offsetHeight-5)+'px', | |
48 | style: "overflow: auto; border: none; min-height: "+(document.body.clientHeight/2)+"px;", | |
3873151b | 49 | sandbox: 'allow-scripts', |
a479f3ef AD |
50 | }); |
51 | ||
52 | if (c) { | |
44db06b6 SS |
53 | Element.hide(c); |
54 | c.parentNode.insertBefore(iframe,c); | |
a479f3ef AD |
55 | |
56 | if (isCdmMode()) { | |
57 | cdmScrollToArticleId(id, true); | |
58 | } | |
59 | } | |
60 | } | |
61 | ||
62 | } }); | |
63 | ||
64 | ||
65 | } catch (e) { | |
66 | exception_error("embedOriginalArticle", e); | |
67 | } | |
68 | } |