1 |
|
tinyMCE.im
portPlugin
LanguagePa
ck('media'
);var Tiny
MCE_MediaP
lugin={get
Info:funct
ion(){retu
rn{longnam
e:'Media',
author:'Mo
xiecode Sy
stems AB',
authorurl:
'http://ti
nymce.moxi
ecode.com'
,infourl:'
http://wik
i.moxiecod
e.com/inde
x.php/Tiny
MCE:Plugin
s/media',v
ersion:tin
yMCE.major
Version+".
"+tinyMCE.
minorVersi
on}},initI
nstance:fu
nction(ins
t){if(inst
.hasPlugin
('flash')&
&!tinyMCE.
flashWarn)
{alert('Fl
ash plugin
is deprec
ated and s
hould not
be used to
gether wit
h the medi
a plugin.'
);tinyMCE.
flashWarn=
true}if(!t
inyMCE.set
tings['med
ia_skip_pl
ugin_css']
)tinyMCE.i
mportCSS(i
nst.getDoc
(),tinyMCE
.baseURL+"
/plugins/m
edia/css/c
ontent.css
")},getCon
trolHTML:f
unction(cn
){switch(c
n){case"me
dia":retur
n tinyMCE.
getButtonH
TML(cn,'la
ng_media_d
esc','{$pl
uginurl}/i
mages/medi
a.gif','mc
eMedia')}r
eturn""},e
xecCommand
:function(
editor_id,
element,co
mmand,user
_interface
,value){sw
itch(comma
nd){case"m
ceMedia":t
inyMCE.ope
nWindow({f
ile:'../..
/plugins/m
edia/media
.htm',widt
h:430+tiny
MCE.getLan
g('lang_me
dia_delta_
width',0),
height:470
+tinyMCE.g
etLang('la
ng_media_d
elta_heigh
t',0)},{ed
itor_id:ed
itor_id,in
line:"yes"
});return
true}retur
n false},c
leanup:fun
ction(type
,content,i
nst){var n
l,img,i,ne
,d,s,ci;sw
itch(type)
{case"inse
rt_to_edit
or":img=ti
nyMCE.getP
aram("them
e_href")+'
/images/sp
acer.gif';
content=co
ntent.repl
ace(/<scri
pt[^>]*>\s
*write(Fla
sh|ShockWa
ve|Windows
Media|Quic
kTime|Real
Media)\(\{
([^\)]*)\}
\);\s*<\/s
cript>/gi,
'<img clas
s="mceItem
$1" title=
"$2" src="
'+img+'" /
>');conten
t=content.
replace(/<
object([^>
]*)>/gi,'<
div class=
"mceItemOb
ject" $1>'
);content=
content.re
place(/<em
bed([^>]*)
>/gi,'<div
class="mc
eItemObjec
tEmbed" $1
>');conten
t=content.
replace(/<
\/(object|
embed)([^>
]*)>/gi,'<
/div>');co
ntent=cont
ent.replac
e(/<param(
[^>]*)>/gi
,'<div $1
class="mce
ItemParam"
></div>');
content=co
ntent.repl
ace(new Re
gExp('\\/
class="mce
ItemParam"
><\\/div>'
,'gi'),'cl
ass="mceIt
emParam"><
/div>');br
eak;case"i
nsert_to_e
ditor_dom"
:d=inst.ge
tDoc();nl=
content.ge
tElementsB
yTagName("
img");for(
i=0;i<nl.l
ength;i++)
{if(/mceIt
em(Flash|S
hockWave|W
indowsMedi
a|QuickTim
e|RealMedi
a)/.test(n
l[i].class
Name)){nl[
i].width=n
l[i].title
.replace(/
.*width:[^
0-9]?([0-9
]+)%?.*/g,
'$1');nl[i
].height=n
l[i].title
.replace(/
.*height:[
^0-9]?([0-
9]+)%?.*/g
,'$1');}}n
l=tinyMCE.
selectElem
ents(conte
nt,'DIV',f
unction(n)
{return ti
nyMCE.hasC
SSClass(n,
'mceItemOb
ject')});f
or(i=0;i<n
l.length;i
++){ci=tin
yMCE.getAt
trib(nl[i]
,"classid"
).toLowerC
ase().repl
ace(/\s+/g
,'');switc
h(ci){case
'clsid:d27
cdb6e-ae6d
-11cf-96b8
-444553540
000':nl[i]
.parentNod
e.replaceC
hild(TinyM
CE_MediaPl
ugin._crea
teImg('mce
ItemFlash'
,d,nl[i]),
nl[i]);bre
ak;case'cl
sid:166b1b
ca-3f9c-11
cf-8075-44
4553540000
':nl[i].pa
rentNode.r
eplaceChil
d(TinyMCE_
MediaPlugi
n._createI
mg('mceIte
mShockWave
',d,nl[i])
,nl[i]);br
eak;case'c
lsid:6bf52
a52-394a-1
1d3-b153-0
0c04f79faa
6':case'cl
sid:22d6f3
12-b0f6-11
d0-94ab-00
80c74c7e95
':case'cls
id:05589fa
1-c356-11c
e-bf01-00a
a0055595a'
:nl[i].par
entNode.re
placeChild
(TinyMCE_M
ediaPlugin
._createIm
g('mceItem
WindowsMed
ia',d,nl[i
]),nl[i]);
break;case
'clsid:02b
f25d5-8c17
-4b23-bc80
-d3488abdd
c6b':nl[i]
.parentNod
e.replaceC
hild(TinyM
CE_MediaPl
ugin._crea
teImg('mce
ItemQuickT
ime',d,nl[
i]),nl[i])
;break;cas
e'clsid:cf
cdaa03-8be
4-11cf-b84
b-0020afbb
ccfa':nl[i
].parentNo
de.replace
Child(Tiny
MCE_MediaP
lugin._cre
ateImg('mc
eItemRealM
edia',d,nl
[i]),nl[i]
);break}}n
l=tinyMCE.
selectNode
s(content,
function(n
){return n
.className
=='mceItem
ObjectEmbe
d'});for(i
=0;i<nl.le
ngth;i++){
switch(tin
yMCE.getAt
trib(nl[i]
,'type')){
case'appli
cation/x-s
hockwave-f
lash':Tiny
MCE_MediaP
lugin._cre
ateImgFrom
Embed(nl[i
],d,'mceIt
emFlash');
break;case
'applicati
on/x-direc
tor':TinyM
CE_MediaPl
ugin._crea
teImgFromE
mbed(nl[i]
,d,'mceIte
mShockWave
');break;c
ase'applic
ation/x-mp
layer2':Ti
nyMCE_Medi
aPlugin._c
reateImgFr
omEmbed(nl
[i],d,'mce
ItemWindow
sMedia');b
reak;case'
video/quic
ktime':Tin
yMCE_Media
Plugin._cr
eateImgFro
mEmbed(nl[
i],d,'mceI
temQuickTi
me');break
;case'audi
o/x-pn-rea
laudio-plu
gin':TinyM
CE_MediaPl
ugin._crea
teImgFromE
mbed(nl[i]
,d,'mceIte
mRealMedia
');break}}
break;case
"get_from_
editor":va
r startPos
=-1,endPos
,attribs,c
hunkBefore
,chunkAfte
r,embedHTM
L,at,pl,cb
,mt,ex;whi
le((startP
os=content
.indexOf('
<img',star
tPos+1))!=
-1){endPos
=content.i
ndexOf('/>
',startPos
);attribs=
TinyMCE_Me
diaPlugin.
_parseAttr
ibutes(con
tent.subst
ring(start
Pos+4,endP
os));if(!/
mceItem(Fl
ash|ShockW
ave|Window
sMedia|Qui
ckTime|Rea
lMedia)/.t
est(attrib
s['class']
))continue
;endPos+=2
;at=attrib
s['title']
;if(at){at
=at.replac
e(/&(#39|a
pos);/g,"'
");at=at.r
eplace(/&#
quot;/g,'"
');try{pl=
eval('x={'
+at+'};')}
catch(ex){
pl={}}}if(
!tinyMCE.g
etParam('m
edia_use_s
cript',fal
se)){switc
h(attribs[
'class']){
case'mceIt
emFlash':c
i='d27cdb6
e-ae6d-11c
f-96b8-444
553540000'
;cb='http:
//download
.macromedi
a.com/pub/
shockwave/
cabs/flash
/swflash.c
ab#version
=6,0,40,0'
;mt='appli
cation/x-s
hockwave-f
lash';brea
k;case'mce
ItemShockW
ave':ci='1
66B1BCA-3F
9C-11CF-80
75-4445535
40000';cb=
'http://do
wnload.mac
romedia.co
m/pub/shoc
kwave/cabs
/director/
sw.cab#ver
sion=8,5,1
,0';mt='ap
plication/
x-director
';break;ca
se'mceItem
WindowsMed
ia':ci=tin
yMCE.getPa
ram('media
_wmp6_comp
atible')?'
05589FA1-C
356-11CE-B
F01-00AA00
55595A':'6
BF52A52-39
4A-11D3-B1
53-00C04F7
9FAA6';cb=
'http://ac
tivex.micr
osoft.com/
activex/co
ntrols/mpl
ayer/en/ns
mp2inf.cab
#Version=5
,1,52,701'
;mt='appli
cation/x-m
player2';b
reak;case'
mceItemQui
ckTime':ci
='02BF25D5
-8C17-4B23
-BC80-D348
8ABDDC6B';
cb='http:/
/www.apple
.com/qtact
ivex/qtplu
gin.cab#ve
rsion=6,0,
2,0';mt='v
ideo/quick
time';brea
k;case'mce
ItemRealMe
dia':ci='C
FCDAA03-8B
E4-11cf-B8
4B-0020AFB
BCCFA';cb=
'http://do
wnload.mac
romedia.co
m/pub/shoc
kwave/cabs
/flash/swf
lash.cab#v
ersion=6,0
,40,0';mt=
'audio/x-p
n-realaudi
o-plugin';
break}if(!
tinyMCE.ge
tParam("re
lative_url
s"))pl.src
=tinyMCE.c
onvertRela
tiveToAbso
luteURL(ti
nyMCE.sett
ings['base
_href'],pl
.src);embe
dHTML=Tiny
MCE_MediaP
lugin._get
Embed(ci,c
b,mt,pl,at
tribs)}els
e{switch(a
ttribs['cl
ass']){cas
e'mceItemF
lash':s='w
riteFlash'
;break;cas
e'mceItemS
hockWave':
s='writeSh
ockWave';b
reak;case'
mceItemWin
dowsMedia'
:s='writeW
indowsMedi
a';break;c
ase'mceIte
mQuickTime
':s='write
QuickTime'
;break;cas
e'mceItemR
ealMedia':
s='writeRe
alMedia';b
reak}if(at
tribs.widt
h)at=at.re
place(/wid
th:[^0-9]?
[0-9]+%?[^
0-9]?/g,"w
idth:'"+at
tribs.widt
h+"'");if(
attribs.he
ight)at=at
.replace(/
height:[^0
-9]?[0-9]+
%?[^0-9]?/
g,"height:
'"+attribs
.height+"'
");if(!tin
yMCE.getPa
ram("relat
ive_urls")
){pl.src=t
inyMCE.con
vertRelati
veToAbsolu
teURL(tiny
MCE.settin
gs['base_h
ref'],pl.s
rc);at=at.
replace(ne
w RegExp("
src:'[^']*
'","g"),"s
rc:'"+pl.s
rc+"'")}em
bedHTML='<
script typ
e="text/ja
vascript">
'+s+'({'+a
t+'});</sc
ript>'}chu
nkBefore=c
ontent.sub
string(0,s
tartPos);c
hunkAfter=
content.su
bstring(en
dPos);cont
ent=chunkB
efore+embe
dHTML+chun
kAfter}bre
ak}return
content},h
andleNodeC
hange:func
tion(edito
r_id,node,
undo_index
,undo_leve
ls,visual_
aid,any_se
lection){i
f(node==nu
ll)return;
do{if(node
.nodeName=
="IMG"&&/m
ceItem(Fla
sh|ShockWa
ve|Windows
Media|Quic
kTime|Real
Media)/.te
st(tinyMCE
.getAttrib
(node,'cla
ss'))){tin
yMCE.switc
hClass(edi
tor_id+'_m
edia','mce
ButtonSele
cted');ret
urn true}}
while((nod
e=node.par
entNode));
tinyMCE.sw
itchClass(
editor_id+
'_media','
mceButtonN
ormal');re
turn true}
,_createIm
gFromEmbed
:function(
n,d,cl){va
r ne,at,i,
ti='',an;n
e=d.create
Element('i
mg');ne.sr
c=tinyMCE.
getParam("
theme_href
")+'/image
s/spacer.g
if';ne.wid
th=tinyMCE
.getAttrib
(n,'width'
);ne.heigh
t=tinyMCE.
getAttrib(
n,'height'
);ne.class
Name=cl;at
=n.attribu
tes;for(i=
0;i<at.len
gth;i++){i
f(at[i].sp
ecified&&a
t[i].nodeV
alue){an=a
t[i].nodeN
ame.toLowe
rCase();if
(an=='src'
)continue;
if(an=='mc
e_src')an=
'src';if(a
n.indexOf(
'mce_')==-
1&&!new Re
gExp('^(cl
ass|type)$
').test(an
))ti+=an.t
oLowerCase
()+':\''+a
t[i].nodeV
alue+"',"}
}ti=ti.len
gth>0?ti.s
ubstring(0
,ti.length
-1):ti;ne.
title=ti;n
.parentNod
e.replaceC
hild(ne,n)
},_createI
mg:functio
n(cl,d,n){
var i,nl,t
i="",an,av
,al=new Ar
ray();ne=d
.createEle
ment('img'
);ne.src=t
inyMCE.get
Param("the
me_href")+
'/images/s
pacer.gif'
;ne.width=
tinyMCE.ge
tAttrib(n,
'width');n
e.height=t
inyMCE.get
Attrib(n,'
height');n
e.classNam
e=cl;al.id
=tinyMCE.g
etAttrib(n
,'id');al.
name=tinyM
CE.getAttr
ib(n,'name
');al.widt
h=tinyMCE.
getAttrib(
n,'width')
;al.height
=tinyMCE.g
etAttrib(n
,'height')
;al.bgcolo
r=tinyMCE.
getAttrib(
n,'bgcolor
');al.alig
n=tinyMCE.
getAttrib(
n,'align')
;al.class_
name=tinyM
CE.getAttr
ib(n,'mce_
class');nl
=n.getElem
entsByTagN
ame('div')
;for(i=0;i
<nl.length
;i++){av=t
inyMCE.get
Attrib(nl[
i],'value'
);av=av.re
place(new
RegExp('\\
\\','g'),'
\\\\');av=
av.replace
(new RegEx
p('"','g')
,'\\"');av
=av.replac
e(new RegE
xp("'",'g'
),"\\'");a
n=tinyMCE.
getAttrib(
nl[i],'nam
e');al[an]
=av}if(al.
movie){al.
src=al.mov
ie;al.movi
e=null}for
(an in al)
{if(al[an]
!=null&&ty
peof(al[an
])!="funct
ion"&&al[a
n]!='')ti+
=an.toLowe
rCase()+':
\''+al[an]
+"',"}ti=t
i.length>0
?ti.substr
ing(0,ti.l
ength-1):t
i;ne.title
=ti;return
ne},_getE
mbed:funct
ion(cls,cb
,mt,p,at){
var h='',n
;p.width=a
t.width?at
.width:p.w
idth;p.hei
ght=at.hei
ght?at.hei
ght:p.heig
ht;h+='<ob
ject class
id="clsid:
'+cls+'" c
odebase="'
+cb+'"';h+
=typeof(p.
id)!="unde
fined"?' i
d="'+p.id+
'"':'';h+=
typeof(p.n
ame)!="und
efined"?'
name="'+p.
name+'"':'
';h+=typeo
f(p.width)
!="undefin
ed"?' widt
h="'+p.wid
th+'"':'';
h+=typeof(
p.height)!
="undefine
d"?' heigh
t="'+p.hei
ght+'"':''
;h+=typeof
(p.align)!
="undefine
d"?' align
="'+p.alig
n+'"':'';h
+='>';for(
n in p){if
(typeof(p[
n])!="unde
fined"&&ty
peof(p[n])
!="functio
n"){h+='<p
aram name=
"'+n+'" va
lue="'+p[n
]+'" />';i
f(n=='src'
&&p[n].ind
exOf('://'
)!=-1&&mt=
='applicat
ion/x-mpla
yer2')h+='
<param nam
e="url" va
lue="'+p[n
]+'" />'}}
h+='<embed
type="'+m
t+'"';for(
n in p){if
(typeof(p[
n])=="func
tion")cont
inue;if(!(
n=='url'&&
mt=='appli
cation/x-m
player2'))
h+=' '+n+'
="'+p[n]+'
"'}h+='></
embed></ob
ject>';ret
urn h},_pa
rseAttribu
tes:functi
on(attribu
te_string)
{var attri
buteName="
",endChr='
"';var att
ributeValu
e="";var w
ithInName;
var withIn
Value;var
attributes
=new Array
();var whi
teSpaceReg
Exp=new Re
gExp('^[ \
n\r\t]+','
g');if(att
ribute_str
ing==null|
|attribute
_string.le
ngth<2)ret
urn null;w
ithInName=
withInValu
e=false;fo
r(var i=0;
i<attribut
e_string.l
ength;i++)
{var chr=a
ttribute_s
tring.char
At(i);if((
chr=='"'||
chr=="'")&
&!withInVa
lue){withI
nValue=tru
e;endChr=c
hr}else if
(chr==endC
hr&&withIn
Value){wit
hInValue=f
alse;var p
os=attribu
teName.las
tIndexOf('
');if(pos
!=-1)attri
buteName=a
ttributeNa
me.substri
ng(pos+1);
attributes
[attribute
Name.toLow
erCase()]=
attributeV
alue.subst
ring(1);at
tributeNam
e="";attri
buteValue=
""}else if
(!whiteSpa
ceRegExp.t
est(chr)&&
!withInNam
e&&!withIn
Value)with
InName=tru
e;if(chr==
'='&&withI
nName)with
InName=fal
se;if(with
InName)att
ributeName
+=chr;if(w
ithInValue
)attribute
Value+=chr
}return at
tributes}}
;tinyMCE.a
ddPlugin("
media",Tin
yMCE_Media
Plugin);
|
|
1 |
|
(function(
){var each
=tinymce.e
ach;tinymc
e.create('
tinymce.pl
ugins.Medi
aPlugin',{
init:funct
ion(ed,url
){var t=th
is;t.edito
r=ed;t.url
=url;funct
ion isMedi
aElm(n){re
turn/^(mce
ItemFlash|
mceItemSho
ckWave|mce
ItemWindow
sMedia|mce
ItemQuickT
ime|mceIte
mRealMedia
)$/.test(n
.className
);};ed.add
Command('m
ceMedia',f
unction(){
ed.windowM
anager.ope
n({file:ur
l+'/media.
htm',width
:430+parse
Int(ed.get
Lang('medi
a.delta_wi
dth',0)),h
eight:470+
parseInt(e
d.getLang(
'media.del
ta_height'
,0)),inlin
e:1},{plug
in_url:url
});});ed.a
ddButton('
media',{ti
tle:'media
.desc',cmd
:'mceMedia
'});ed.onN
odeChange.
add(functi
on(ed,cm,n
){cm.setAc
tive('medi
a',n.nodeN
ame=='IMG'
&&isMediaE
lm(n));});
ed.onInit.
add(functi
on(){var l
o={mceItem
Flash:'fla
sh',mceIte
mShockWave
:'shockwav
e',mceItem
WindowsMed
ia:'window
smedia',mc
eItemQuick
Time:'quic
ktime',mce
ItemRealMe
dia:'realm
edia'};ed.
dom.loadCS
S(url+"/cs
s/content.
css");if(e
d.theme.on
ResolveNam
e){ed.them
e.onResolv
eName.add(
function(t
h,o){if(o.
name=='img
'){each(lo
,function(
v,k){if(ed
.dom.hasCl
ass(o.node
,k)){o.nam
e=v;o.titl
e=ed.dom.g
etAttrib(o
.node,'tit
le');retur
n false;}}
);}});}if(
ed&&ed.plu
gins.conte
xtmenu){ed
.plugins.c
ontextmenu
.onContext
Menu.add(f
unction(th
,m,e){if(e
.nodeName=
='IMG'&&/m
ceItem(Fla
sh|ShockWa
ve|Windows
Media|Quic
kTime|Real
Media)/.te
st(e.class
Name)){m.a
dd({title:
'media.edi
t',icon:'m
edia',cmd:
'mceMedia'
});}});}})
;ed.onBefo
reSetConte
nt.add(fun
ction(ed,o
){var h=o.
content;h=
h.replace(
/<script[^
>]*>\s*wri
te(Flash|S
hockWave|W
indowsMedi
a|QuickTim
e|RealMedi
a)\(\{([^\
)]*)\}\);\
s*<\/scrip
t>/gi,func
tion(a,b,c
){var o=t.
_parse(c);
return'<im
g class="m
ceItem'+b+
'" title="
'+ed.dom.e
ncode(c)+'
" src="'+u
rl+'/img/t
rans.gif"
width="'+o
.width+'"
height="'+
o.height+'
" />'});h=
h.replace(
/<object([
^>]*)>/gi,
'<span cla
ss="mceIte
mObject" $
1>');h=h.r
eplace(/<e
mbed([^>]*
)>/gi,'<sp
an class="
mceItemEmb
ed" $1>');
h=h.replac
e(/<\/(obj
ect|embed)
([^>]*)>/g
i,'</span>
');h=h.rep
lace(/<par
am([^>]*)>
/gi,functi
on(a,b){re
turn'<span
'+b.repla
ce(/value=
/gi,'_valu
e=')+' cla
ss="mceIte
mParam"></
span>'});h
=h.replace
(/\/ class
=\"mceItem
Param\"><\
/span>/gi,
'class="mc
eItemParam
"></span>'
);o.conten
t=h;});ed.
onSetConte
nt.add(fun
ction(){t.
_spansToIm
gs(ed.getB
ody());});
ed.onPrePr
ocess.add(
function(e
d,o){var d
om=ed.dom;
if(o.set){
t._spansTo
Imgs(o.nod
e);each(do
m.select('
IMG',o.nod
e),functio
n(n){var p
;if(isMedi
aElm(n)){p
=t._parse(
n.title);d
om.setAttr
ib(n,'widt
h',dom.get
Attrib(n,'
width',p.w
idth||100)
);dom.setA
ttrib(n,'h
eight',dom
.getAttrib
(n,'height
',p.height
||100));}}
);}if(o.ge
t){each(do
m.select('
IMG',o.nod
e),functio
n(n){var c
i,cb,mt;if
(ed.getPar
am('media_
use_script
')){if(isM
ediaElm(n)
)n.classNa
me=n.class
Name.repla
ce(/mceIte
m/g,'mceTe
mp');retur
n;}switch(
n.classNam
e){case'mc
eItemFlash
':ci='d27c
db6e-ae6d-
11cf-96b8-
4445535400
00';cb='ht
tp://downl
oad.macrom
edia.com/p
ub/shockwa
ve/cabs/fl
ash/swflas
h.cab#vers
ion=6,0,40
,0';mt='ap
plication/
x-shockwav
e-flash';b
reak;case'
mceItemSho
ckWave':ci
='166b1bca
-3f9c-11cf
-8075-4445
53540000';
cb='http:/
/download.
macromedia
.com/pub/s
hockwave/c
abs/direct
or/sw.cab#
version=8,
5,1,0';mt=
'applicati
on/x-direc
tor';break
;case'mceI
temWindows
Media':ci=
ed.getPara
m('media_w
mp6_compat
ible')?'05
589fa1-c35
6-11ce-bf0
1-00aa0055
595a':'6bf
52a52-394a
-11d3-b153
-00c04f79f
aa6';cb='h
ttp://acti
vex.micros
oft.com/ac
tivex/cont
rols/mplay
er/en/nsmp
2inf.cab#V
ersion=5,1
,52,701';m
t='applica
tion/x-mpl
ayer2';bre
ak;case'mc
eItemQuick
Time':ci='
02bf25d5-8
c17-4b23-b
c80-d3488a
bddc6b';cb
='http://w
ww.apple.c
om/qtactiv
ex/qtplugi
n.cab#vers
ion=6,0,2,
0';mt='vid
eo/quickti
me';break;
case'mceIt
emRealMedi
a':ci='cfc
daa03-8be4
-11cf-b84b
-0020afbbc
cfa';cb='h
ttp://down
load.macro
media.com/
pub/shockw
ave/cabs/f
lash/swfla
sh.cab#ver
sion=6,0,4
0,0';mt='a
udio/x-pn-
realaudio-
plugin';br
eak;}if(ci
){dom.repl
ace(t._bui
ldObj({cla
ssid:ci,co
debase:cb,
type:mt},n
),n);}});}
});ed.onPo
stProcess.
add(functi
on(ed,o){o
.content=o
.content.r
eplace(/_v
alue=/g,'v
alue=');})
;if(ed.get
Param('med
ia_use_scr
ipt')){fun
ction getA
ttr(s,n){n
=new RegEx
p(n+'=\"([
^\"]+)\"',
'g').exec(
s);return
n?ed.dom.d
ecode(n[1]
):'';};ed.
onPostProc
ess.add(fu
nction(ed,
o){o.conte
nt=o.conte
nt.replace
(/<img[^>]
+>/g,funct
ion(im){va
r cl=getAt
tr(im,'cla
ss');if(/^
(mceTempFl
ash|mceTem
pShockWave
|mceTempWi
ndowsMedia
|mceTempQu
ickTime|mc
eTempRealM
edia)$/.te
st(cl)){at
=t._parse(
getAttr(im
,'title'))
;at.width=
getAttr(im
,'width');
at.height=
getAttr(im
,'height')
;im='<scri
pt type="t
ext/javasc
ript">writ
e'+cl.subs
tring(7)+'
({'+t._ser
ialize(at)
+'});</scr
ipt>';}ret
urn im;});
});}},getI
nfo:functi
on(){retur
n{longname
:'Media',a
uthor:'Mox
iecode Sys
tems AB',a
uthorurl:'
http://tin
ymce.moxie
code.com',
infourl:'h
ttp://wiki
.moxiecode
.com/index
.php/TinyM
CE:Plugins
/media',ve
rsion:tiny
mce.majorV
ersion+"."
+tinymce.m
inorVersio
n};},_buil
dObj:funct
ion(o,n){v
ar ob,ed=t
his.editor
,dom=ed.do
m,p=this._
parse(n.ti
tle);p.wid
th=o.width
=dom.getAt
trib(n,'wi
dth')||100
;p.height=
o.height=d
om.getAttr
ib(n,'heig
ht')||100;
ob=dom.cre
ate('span'
,{mce_name
:'object',
classid:"c
lsid:"+o.c
lassid,cod
ebase:o.co
debase,wid
th:o.width
,height:o.
height});i
f(p.src)p.
src=ed.con
vertURL(p.
src,'src',
n);each(p,
function(v
,k){if(!/^
(width|hei
ght|codeba
se|classid
)$/.test(k
))dom.add(
ob,'span',
{mce_name:
'param',na
me:k,'_val
ue':v});})
;dom.add(o
b,'span',t
inymce.ext
end({mce_n
ame:'embed
',type:o.t
ype},p));r
eturn ob;}
,_spansToI
mgs:functi
on(p){var
t=this,dom
=t.editor.
dom,im,ci;
each(dom.s
elect('spa
n',p),func
tion(n){if
(dom.getAt
trib(n,'cl
ass')=='mc
eItemObjec
t'){ci=dom
.getAttrib
(n,"classi
d").toLowe
rCase().re
place(/\s+
/g,'');swi
tch(ci){ca
se'clsid:d
27cdb6e-ae
6d-11cf-96
b8-4445535
40000':dom
.replace(t
._createIm
g('mceItem
Flash',n),
n);break;c
ase'clsid:
166b1bca-3
f9c-11cf-8
075-444553
540000':do
m.replace(
t._createI
mg('mceIte
mShockWave
',n),n);br
eak;case'c
lsid:6bf52
a52-394a-1
1d3-b153-0
0c04f79faa
6':case'cl
sid:22d6f3
12-b0f6-11
d0-94ab-00
80c74c7e95
':case'cls
id:05589fa
1-c356-11c
e-bf01-00a
a0055595a'
:dom.repla
ce(t._crea
teImg('mce
ItemWindow
sMedia',n)
,n);break;
case'clsid
:02bf25d5-
8c17-4b23-
bc80-d3488
abddc6b':d
om.replace
(t._create
Img('mceIt
emQuickTim
e',n),n);b
reak;case'
clsid:cfcd
aa03-8be4-
11cf-b84b-
0020afbbcc
fa':dom.re
place(t._c
reateImg('
mceItemRea
lMedia',n)
,n);break;
default:do
m.replace(
t._createI
mg('mceIte
mFlash',n)
,n);}retur
n;}if(dom.
getAttrib(
n,'class')
=='mceItem
Embed'){sw
itch(dom.g
etAttrib(n
,'type')){
case'appli
cation/x-s
hockwave-f
lash':dom.
replace(t.
_createImg
('mceItemF
lash',n),n
);break;ca
se'applica
tion/x-dir
ector':dom
.replace(t
._createIm
g('mceItem
ShockWave'
,n),n);bre
ak;case'ap
plication/
x-mplayer2
':dom.repl
ace(t._cre
ateImg('mc
eItemWindo
wsMedia',n
),n);break
;case'vide
o/quicktim
e':dom.rep
lace(t._cr
eateImg('m
ceItemQuic
kTime',n),
n);break;c
ase'audio/
x-pn-reala
udio-plugi
n':dom.rep
lace(t._cr
eateImg('m
ceItemReal
Media',n),
n);break;d
efault:dom
.replace(t
._createIm
g('mceItem
Flash',n),
n);}}});},
_createImg
:function(
cl,n){var
im,dom=thi
s.editor.d
om,pa={},t
i='';im=do
m.create('
img',{src:
this.url+'
/img/trans
.gif',widt
h:dom.getA
ttrib(n,'w
idth')||10
0,height:d
om.getAttr
ib(n,'heig
ht')||100,
'class':cl
});each(['
id','name'
,'width','
height','b
gcolor','a
lign','fla
shvars','s
rc','wmode
'],functio
n(na){var
v=dom.getA
ttrib(n,na
);if(v)pa[
na]=v;});e
ach(dom.se
lect('span
',n),funct
ion(n){if(
dom.hasCla
ss(n,'mceI
temParam')
)pa[dom.ge
tAttrib(n,
'name')]=d
om.getAttr
ib(n,'_val
ue');});if
(pa.movie)
{pa.src=pa
.movie;del
ete pa.mov
ie;}delete
pa.width;
delete pa.
height;im.
title=this
._serializ
e(pa);retu
rn im;},_p
arse:funct
ion(s){ret
urn tinymc
e.util.JSO
N.parse('{
'+s+'}');}
,_serializ
e:function
(o){return
tinymce.u
til.JSON.s
erialize(o
).replace(
/[{}]/g,''
);}});tiny
mce.Plugin
Manager.ad
d('media',
tinymce.pl
ugins.Medi
aPlugin);}
)();
|