1 |
|
tiny
MCE
.
i
m
p
ortP
lugin
La
n
g
u
a
g
e
P
a
ck
('
p
review'
);
v
a
r
T
i
nyMCE_P
review
P
lug
i
n={
getInfo:fu
nction(){r
eturn{long
name:'Prev
iew',autho
r:'Moxieco
de
Systems
AB',author
url:'http:
//tinymce.
moxiecode.
com',infou
rl:'http:/
/wiki.moxi
ecode.com/
index.php/
TinyMCE:Pl
ugins/prev
iew',versi
on:tiny
MCE
.majorVers
ion+"."+ti
ny
MCE
.minorVers
ion}
},
getControl
HTML:funct
ion(cn){sw
itch(cn){c
ase"
preview
"
:
ret
u
r
n
ti
nyMCE.getB
utt
on
HTML
(
cn,'lang_p
review_des
c','
{
$pluginurl
}/images/p
re
v
iew.gif','
mcePreview
')}retu
r
n""},
e
xecComman
d
:func
t
i
on(
editor
_id
,
eleme
n
t
,
com
m
and
,
user_inter
fa
c
e
,
value){
s
witch(c
o
mmand){ca
s
e"m
c
ePrev
i
ew":var
p
reviewP
age=
tinyMCE
.getParam(
"plugin_pr
eview_page
url",null)
;var
previe
w
Width
=
tinyMCE
.getParam(
"plugin_pr
eview_widt
h","550")
;var
previewHei
g
h
t
=
tinyMCE
.getParam(
"plugin_pr
eview_heig
ht","600")
;if(p
reviewP
age){
var
templat
e
=
n
e
w
Arr
a
y();t
e
m
p
lat
e
['
file
']=previ
e
wPa
ge
;
t
empl
a
te['width'
]=p
r
eviewWidth
;te
m
pl
ate['hei
g
ht']=
preview
Height;tin
yMCE.o
p
e
n
Window(tem
p
l
ate
,
{editor_
id
:
e
d
i
t
or_id
,
resizable:
"yes",scro
llbars:"ye
s",inline:
"yes",cont
ent:tinyMC
E.getConte
nt(),conte
nt_css:tin
yMCE.getPa
ram("conte
nt_css")
})
}else{
var
win=window
.open("","
mcePreview
","menubar
=no,toolba
r=no,scrol
lbars=yes,
resizable=
yes,left=2
0,top=20,w
idth="+
previe
w
Width
+",height=
"+
previewHei
g
h
t
);
var
html=""
,i
;
var
c=
tinyMCE
.getConten
t();
var
pos=c.inde
xOf('<body
')
,pos2,
css=
tinyMCE
.getParam(
"content_c
ss"
).split(',
');
if(pos!=-1
){pos=c.in
dexOf('>',
pos);pos2=
c.lastInde
xOf('</bod
y>');c=c.s
ubstring(p
os+1,pos2)
}html+=
tinyMCE
.getParam(
'doctype')
;html+='<h
tml
xmlns="htt
p://www.w3
.org/1999/
xhtml">';h
tml+='<hea
d>';html+=
'<title>'+
tinyMCE
.getLang('
lang_
preview_de
sc')+'</ti
tle>';html
+='<base
href="'+
tinyMCE
.
s
e
tti
n
gs['b
ase
_hr
e
f']
+'"
/>';html+=
'<meta
http-equiv
="Content-
Type"
content="t
ext/html;
charset=UT
F-8"
/>';for(i=
0;i<css.le
ngth;i++)h
tml+='<lin
k
href="'+cs
s[i]+'"
rel="style
sheet"
type="text
/css"
/>';html+=
'<
script
type="text
/
jav
a
script"
>';html+='
window.ope
ner.TinyMC
E_PreviewP
lugin._set
D
o
c(
d
ocument);'
;html+='wi
n
d
ow.opener.
T
i
nyMCE_P
r
eviewPlugi
n._setWin(
window);';
html+
=
'
writ
e
Flash
=
win
d
ow.opener
.
TinyMCE_Pr
eviewPlu
g
in._writ
e
Flash;';h
t
ml+='w
r
iteShockW
a
ve
=
win
d
ow.opener.
T
i
nyMCE_P
re
viewPlugin
._writeSho
c
kWave;';ht
ml+='wri
t
eQu
i
ckTime
=
wind
o
w.opener.T
i
n
yMCE_Previ
ewP
l
ugin._wr
it
eQuickTime
;';html
+
=
'
writeRea
l
Medi
a
=
window.ope
ner.
T
iny
MCE_Previ
e
wPlugin
.
_writeReal
Me
di
a;';h
t
ml+='write
Wind
o
ws
M
edi
a
=
window.ope
n
er.
TinyMCE_Pr
eviewPlu
g
in._writeW
indowsM
e
dia;';h
t
ml+=
'
writeEmb
ed
=
w
i
n
d
ow
.
o
p
ener.TinyM
CE_Preview
P
lugin
._writeEmb
ed;';html+
='</
s
cript>';ht
ml+='</hea
d>';html+=
'
<body
di
r
="'+tinyMC
E.g
e
tParam("d
i
r
e
ctionality
")+
'
"
on
l
oad
="
window
.
o
pener.Tiny
MCE_Previe
wPl
u
gin._o
n
Load(
);">';html
+=c;html+=
'</body>';
html+='</h
tml>';win.
document.w
rite(html)
;win.docum
ent.close(
)
}
return
true}retur
n
false
},_
setD
o
c
:function(
d){
T
i
n
yMCE_Prev
i
e
wP
l
ugi
n
._doc=d;
d
.
_emb
e
d
s
=
ne
w
Ar
r
a
y()},_
s
e
t
W
i
n:fun
c
t
i
on(d){
Ti
nyMCE
_
P
r
ev
i
e
wPl
u
g
i
n
.
_
w
i
n=d},_onLo
a
d
:funct
i
on(){v
a
r
nl,
i
,
e
l
=n
e
w
Ar
r
ay(),d=T
in
y
M
CE
_
P
r
ev
i
e
wPlug
in
._
do
c,
s
v,n
e
;nl=d.getE
lementsByT
agName("sc
ript");for
(i=0;i<nl.
length;i++
){sv=tiny
MCE
.is
MS
IE?nl[i].i
nnerHTML:n
l[i].first
Child.node
Value;if(n
ew
RegExp('wr
ite(Flash|
ShockWave|
WindowsMed
ia|QuickTi
me|RealMed
ia)\\(.*',
'g').test(
sv))el[el.
length]=nl
[i]
}for(i=0;i
<el.length
;i++){ne=d
.createEle
ment("div"
);ne.inner
HTML=d._em
beds[i];el
[i].parent
Node.inser
tBefore(ne
.firstChil
d,el[i])
}},_writeF
lash:funct
ion(p){p.s
rc=t
i
nyMCE
.
conv
e
r
t
R
e
la
t
iv
e
T
oAbsolute
URL
(
tinyMCE.se
ttings['ba
se_href'],
p.src);Tin
yMCE_Previ
ewPlugin._
writeEmbed
('D27CDB6E
-AE6D-11cf
-96B8-4445
53540000',
'http://do
wnload.mac
romedia.co
m/pub/shoc
kwave/cabs
/flash/swf
lash.cab#v
ersion=6,0
,40,0','ap
plication/
x-shockwav
e-flash',p
)
},_writeSh
ockWave:fu
nction(p){
p.src=
t
i
nyMCE
.
conv
e
r
t
R
e
la
t
iv
e
T
oAbsolute
URL
(
tinyMCE.se
ttings['ba
se_href'],
p.src);Tin
yMCE_Previ
ewPlugin._
writeEmbed
('166B1BCA
-3F9C-11CF
-8075-4445
53540000',
'http://do
wnload.mac
romedia.co
m/pub/shoc
kwave/cabs
/director/
sw.cab#ver
sion=8,5,1
,0','appli
cation/x-d
irector',p
)
},_writeQu
ickTime:fu
nction(p){
p.src=
t
i
nyMCE
.
conv
e
r
t
R
e
la
t
iv
e
T
oAbsolute
URL
(
tinyMCE.se
ttings['ba
se_href'],
p.src);Tin
yMCE_Previ
ewPlugin._
writeEmbed
('02BF25D5
-8C17-4B23
-BC80-D348
8ABDDC6B',
'http://ww
w.apple.co
m/qtactive
x/qtplugin
.cab#versi
on=6,0,2,0
','video/q
uicktime',
p)
},_writeRe
alMedia:fu
nction(p){
p.src=
t
i
nyMCE
.
conv
e
r
t
R
e
la
t
iv
e
T
oAbsolute
URL
(
tinyMCE.se
ttings['ba
se_href'],
p.src);Tin
yMCE_Previ
ewPlugin._
writeEmbed
('CFCDAA03
-8BE4-11cf
-B84B-0020
AFBBCCFA',
'http://do
wnload.mac
romedia.co
m/pub/shoc
kwave/cabs
/flash/swf
lash.cab#v
ersion=6,0
,40,0','au
dio/x-pn-r
ealaudio-p
lugin',p)
},_writeWi
ndowsMedia
:function(
p){
p.src=
t
i
nyMCE
.
conv
e
r
t
R
e
la
t
iv
e
T
oAbsolute
URL
(
tinyMCE.se
ttings['ba
se_href'],
p.src);p.u
rl=p.src;T
inyMCE_Pre
viewPlugin
._writeEmb
ed('6BF52A
52-394A-11
D3-B153-00
C04F79FAA6
','http://
activex.mi
crosoft.co
m/activex/
controls/m
player/en/
nsmp2inf.c
ab#Version
=5,1,52,70
1','applic
ation/x-mp
layer2',p)
},_writeEm
bed:functi
on(cls,cb,
mt,p){var
h='',n,d=
TinyMCE_Pr
eviewPlugi
n
._doc,ne,c
;h+='<obje
ct
classid="c
lsid:'+cls
+'"
codebase="
'+cb+'"';h
+=typeof(p
.id)!="und
efined"?'i
d="'+p.id+
'"':'';h+=
typeof(p.n
ame)!="und
efined"?'n
ame="'+p.n
ame+'"':''
;h+=typeof
(p.width)!
="undefine
d"?'width=
"'+p.width
+'"':'';h+
=typeof(p.
height)!="
undefined"
?'height="
'+p.height
+'"':'';h+
=typeof(p.
align)!="u
ndefined"?
'align="'+
p.align+'"
':'';h+='>
';for(n
in
p)h+='<par
am
name="'+n+
'"
value="'+p
[n]+'">';h
+='<embed
type="'+mt
+'"';for(n
in
p)h+=n+'="
'+p[n]+'"
';h+='></e
mbed></obj
ect>';d._e
mbeds[d._e
mbeds.leng
th]=h
}}
;tiny
MCE
.
add
Plugin
(
"
preview
"
,
T
iny
MCE_
Preview
Plugin
);
|
|
1 |
|
(function(
){
tiny
mce
.
create('t
i
ny
m
ce.
p
lugin
s.Preview'
,{i
n
it:f
u
nction(ed,
url){v
a
r
t=this;t.
e
ditor=ed;e
d.
a
ddCommand
('
mceP
review'
,t._previe
w,t
);
ed.
a
ddButton('
p
r
ev
i
ew',{title
:'preview.
p
review
_desc',cmd
:'mce
P
rev
i
ew'});},
getInfo:fu
nction(){r
eturn{long
name:'Prev
iew',autho
r:'Moxieco
de
Systems
AB',author
url:'http:
//tinymce.
moxiecode.
com',infou
rl:'http:/
/wiki.moxi
ecode.com/
index.php/
TinyMCE:Pl
ugins/prev
iew',versi
on:tiny
mce
.majorVers
ion+"."+ti
ny
mce
.minorVers
ion}
;
},
_
preview
:
f
u
n
c
ti
on
(
)
{
v
a
r
e
d
=
t
h
i
s.
editor
,
wi
n
,
ht
m
l
,
c
,
po
s
,p
o
s
2,
c
ss,
i
,
p
age=
ed
.getParam(
"plugin_pr
eview_page
url",null)
,
w
=
ed
.getParam(
"plugin_pr
eview_widt
h","550")
,
h
=
ed
.getParam(
"plugin_pr
eview_heig
ht","600")
;if(p
age){
e
d.wi
n
do
w
M
a
nag
e
r.o
p
e
n({
file
:
e
d.
ge
t
P
a
r
a
m
("
pl
u
g
in_
preview
_
p
ag
e
url",
n
u
l
l)
,
w
id
th
:
w,h
e
i
gh
t
:h}
,
{
resizable:
"yes",scro
llbars:"ye
s",inline:
1
})
;
}else{
win=window
.open("","
mcePreview
","menubar
=no,toolba
r=no,scrol
lbars=yes,
resizable=
yes,left=2
0,top=20,w
idth="+
w
+",height=
"+
h
);
html=""
;
c=
ed
.getConten
t();
pos=c.inde
xOf('<body
')
;
css=
ed
.getParam(
"content_c
ss"
,''
).split(',
');
tinymce.ma
p(css,func
tion(u){re
turn
ed.documen
tBaseURI.t
oAbsolute(
u);});
if(pos!=-1
){pos=c.in
dexOf('>',
pos);pos2=
c.lastInde
xOf('</bod
y>');c=c.s
ubstring(p
os+1,pos2)
;
}html+=
ed
.getParam(
'doctype')
;html+='<h
tml
xmlns="htt
p://www.w3
.org/1999/
xhtml">';h
tml+='<hea
d>';html+=
'<title>'+
ed
.getLang('
preview.
preview_de
sc')+'</ti
tle>';html
+='<base
href="'+
ed
.
docum
e
n
tB
ase
URI.g
e
tURI()
+'"
/>';html+=
'<meta
http-equiv
="Content-
Type"
content="t
ext/html;
charset=UT
F-8"
/>';for(i=
0;i<css.le
ngth;i++)h
tml+='<lin
k
href="'+cs
s[i]+'"
rel="style
sheet"
type="text
/css"
/>';html+=
'<
/
he
a
d
>';html+='
<b
o
d
y
d
i
r
=
"
'
+
e
d
.
g
e
t
Pa
r
a
m("
d
i
re
c
t
i
o
n
a
l
it
y")
+
'
"
on
l
o
a
d
=
"
window.ope
ner.
t
iny
mc
e
.
E
di
t
o
r
M
a
n
ag
er.
g
e
t
(\
'
'+
ed
.
i
d
+'\')
.
p
lugin
s
[\
'
p
r
e
v
i
e
w\
'
]._
on
L
oad
(
window
,d
o
c
u
me
n
t
);">';html
+=c;html+=
'</body>';
html+='</h
tml>';win.
document.w
rite(html)
;win.docum
ent.close(
)
;
}
},_
o
nLoad
:function(
w,
d){
var
t=th
i
s,
n
l,
i
,
e
l
=[],sv,
n
e;t
._doc=d;
w
.
writ
e
Fla
s
h
=
t._
w
r
iteFl
a
s
h;w.wri
t
eShock
W
ave=t._wr
i
teSho
c
kWave;w.wr
i
t
eQu
i
ck
Ti
me=t.
_
w
r
i
t
e
Q
u
i
ckTime;w
.
w
r
i
teRe
a
lMe
d
i
a
=t._w
r
i
t
e
Rea
l
M
e
dia;w.
w
r
iteW
in
dows
M
edia=t.
_
w
r
i
t
e
W
in
do
w
s
Media;w.wr
iteEmb
e
d=t._write
Embed
;nl=d.getE
lementsByT
agName("sc
ript");for
(i=0;i<nl.
length;i++
){sv=tiny
mce
.is
IE?nl[i].i
nnerHTML:n
l[i].first
Child.node
Value;if(n
ew
RegExp('wr
ite(Flash|
ShockWave|
WindowsMed
ia|QuickTi
me|RealMed
ia)\\(.*',
'g').test(
sv))el[el.
length]=nl
[i]
;
}for(i=0;i
<el.length
;i++){ne=d
.createEle
ment("div"
);ne.inner
HTML=d._em
beds[i];el
[i].parent
Node.inser
tBefore(ne
.firstChil
d,el[i])
;
}},_writeF
lash:funct
ion(p){p.s
rc=t
h
i
s
.
e
di
t
or.docum
e
n
t
Bas
e
URI.t
oAbsolute
(
p.src);Tin
yMCE_Previ
ewPlugin._
writeEmbed
('D27CDB6E
-AE6D-11cf
-96B8-4445
53540000',
'http://do
wnload.mac
romedia.co
m/pub/shoc
kwave/cabs
/flash/swf
lash.cab#v
ersion=6,0
,40,0','ap
plication/
x-shockwav
e-flash',p
)
;
},_writeSh
ockWave:fu
nction(p){
t
h
i
s
.
e
di
t
or.docum
e
n
t
Bas
e
URI.t
oAbsolute
(
p.src);Tin
yMCE_Previ
ewPlugin._
writeEmbed
('166B1BCA
-3F9C-11CF
-8075-4445
53540000',
'http://do
wnload.mac
romedia.co
m/pub/shoc
kwave/cabs
/director/
sw.cab#ver
sion=8,5,1
,0','appli
cation/x-d
irector',p
)
;
},_writeQu
ickTime:fu
nction(p){
t
h
i
s
.
e
di
t
or.docum
e
n
t
Bas
e
URI.t
oAbsolute
(
p.src);Tin
yMCE_Previ
ewPlugin._
writeEmbed
('02BF25D5
-8C17-4B23
-BC80-D348
8ABDDC6B',
'http://ww
w.apple.co
m/qtactive
x/qtplugin
.cab#versi
on=6,0,2,0
','video/q
uicktime',
p)
;
},_writeRe
alMedia:fu
nction(p){
t
h
i
s
.
e
di
t
or.docum
e
n
t
Bas
e
URI.t
oAbsolute
(
p.src);Tin
yMCE_Previ
ewPlugin._
writeEmbed
('CFCDAA03
-8BE4-11cf
-B84B-0020
AFBBCCFA',
'http://do
wnload.mac
romedia.co
m/pub/shoc
kwave/cabs
/flash/swf
lash.cab#v
ersion=6,0
,40,0','au
dio/x-pn-r
ealaudio-p
lugin',p)
;
},_writeWi
ndowsMedia
:function(
p){
t
h
i
s
.
e
di
t
or.docum
e
n
t
Bas
e
URI.t
oAbsolute
(
p.src);p.u
rl=p.src;T
inyMCE_Pre
viewPlugin
._writeEmb
ed('6BF52A
52-394A-11
D3-B153-00
C04F79FAA6
','http://
activex.mi
crosoft.co
m/activex/
controls/m
player/en/
nsmp2inf.c
ab#Version
=5,1,52,70
1','applic
ation/x-mp
layer2',p)
;
},_writeEm
bed:functi
on(cls,cb,
mt,p){var
h='',n,d=
t
._doc,ne,c
;h+='<obje
ct
classid="c
lsid:'+cls
+'"
codebase="
'+cb+'"';h
+=typeof(p
.id)!="und
efined"?'i
d="'+p.id+
'"':'';h+=
typeof(p.n
ame)!="und
efined"?'n
ame="'+p.n
ame+'"':''
;h+=typeof
(p.width)!
="undefine
d"?'width=
"'+p.width
+'"':'';h+
=typeof(p.
height)!="
undefined"
?'height="
'+p.height
+'"':'';h+
=typeof(p.
align)!="u
ndefined"?
'align="'+
p.align+'"
':'';h+='>
';for(n
in
p)h+='<par
am
name="'+n+
'"
value="'+p
[n]+'">';h
+='<embed
type="'+mt
+'"';for(n
in
p)h+=n+'="
'+p[n]+'"
';h+='></e
mbed></obj
ect>';d._e
mbeds[d._e
mbeds.leng
th]=h
;
}}
)
;tiny
mce
.
Plugin
Manager.ad
d
(
'
preview
'
,
t
iny
mce.plugin
s.
Preview
);})(
);
|