1 |
|
tinyMCE.im
portPlugin
LanguagePa
ck('flash'
);var Tiny
MCE_FlashP
lugin={get
Info:funct
ion(){retu
rn{longnam
e:'Flash',
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/flash',v
ersion:tin
yMCE.major
Version+".
"+tinyMCE.
minorVersi
on}},initI
nstance:fu
nction(ins
t){if(!tin
yMCE.setti
ngs['flash
_skip_plug
in_css'])t
inyMCE.imp
ortCSS(ins
t.getDoc()
,tinyMCE.b
aseURL+"/p
lugins/fla
sh/css/con
tent.css")
},getContr
olHTML:fun
ction(cn){
switch(cn)
{case"flas
h":return
tinyMCE.ge
tButtonHTM
L(cn,'lang
_flash_des
c','{$plug
inurl}/ima
ges/flash.
gif','mceF
lash')}ret
urn""},exe
cCommand:f
unction(ed
itor_id,el
ement,comm
and,user_i
nterface,v
alue){swit
ch(command
){case"mce
Flash":var
name="",s
wffile="",
swfwidth="
",swfheigh
t="",actio
n="insert"
;var templ
ate=new Ar
ray();var
inst=tinyM
CE.getInst
anceById(e
ditor_id);
var focusE
lm=inst.ge
tFocusElem
ent();temp
late['file
']='../../
plugins/fl
ash/flash.
htm';templ
ate['width
']=430;tem
plate['hei
ght']=175;
template['
width']+=t
inyMCE.get
Lang('lang
_flash_del
ta_width',
0);templat
e['height'
]+=tinyMCE
.getLang('
lang_flash
_delta_hei
ght',0);if
(focusElm!
=null&&foc
usElm.node
Name.toLow
erCase()==
"img"){nam
e=tinyMCE.
getAttrib(
focusElm,'
class');if
(name.inde
xOf('mceIt
emFlash')=
=-1)return
true;swff
ile=tinyMC
E.getAttri
b(focusElm
,'alt');if
(tinyMCE.g
etParam('c
onvert_url
s'))swffil
e=eval(tin
yMCE.setti
ngs['urlco
nverter_ca
llback']+"
(swffile,
null, true
);");swfwi
dth=tinyMC
E.getAttri
b(focusElm
,'width');
swfheight=
tinyMCE.ge
tAttrib(fo
cusElm,'he
ight');act
ion="updat
e"}tinyMCE
.openWindo
w(template
,{editor_i
d:editor_i
d,inline:"
yes",swffi
le:swffile
,swfwidth:
swfwidth,s
wfheight:s
wfheight,a
ction:acti
on});retur
n true}ret
urn false}
,cleanup:f
unction(ty
pe,content
){switch(t
ype){case"
insert_to_
editor_dom
":if(tinyM
CE.getPara
m('convert
_urls')){v
ar imgs=co
ntent.getE
lementsByT
agName("im
g");for(va
r i=0;i<im
gs.length;
i++){if(ti
nyMCE.getA
ttrib(imgs
[i],"class
")=="mceIt
emFlash"){
var src=ti
nyMCE.getA
ttrib(imgs
[i],"alt")
;if(tinyMC
E.getParam
('convert_
urls'))src
=eval(tiny
MCE.settin
gs['urlcon
verter_cal
lback']+"(
src, null,
true);");
imgs[i].se
tAttribute
('alt',src
);imgs[i].
setAttribu
te('title'
,src)}}}br
eak;case"g
et_from_ed
itor_dom":
var imgs=c
ontent.get
ElementsBy
TagName("i
mg");for(v
ar i=0;i<i
mgs.length
;i++){if(t
inyMCE.get
Attrib(img
s[i],"clas
s")=="mceI
temFlash")
{var src=t
inyMCE.get
Attrib(img
s[i],"alt"
);if(tinyM
CE.getPara
m('convert
_urls'))sr
c=eval(tin
yMCE.setti
ngs['urlco
nverter_ca
llback']+"
(src, null
, true);")
;imgs[i].s
etAttribut
e('alt',sr
c);imgs[i]
.setAttrib
ute('title
',src)}}br
eak;case"i
nsert_to_e
ditor":var
startPos=
0;var embe
dList=new
Array();co
ntent=cont
ent.replac
e(new RegE
xp('<[ ]*e
mbed','gi'
),'<embed'
);content=
content.re
place(new
RegExp('<[
]*/embed[
]*>','gi'
),'</embed
>');conten
t=content.
replace(ne
w RegExp('
<[ ]*objec
t','gi'),'
<object');
content=co
ntent.repl
ace(new Re
gExp('<[ ]
*/object[
]*>','gi')
,'</object
>');while(
(startPos=
content.in
dexOf('<em
bed',start
Pos+1))!=-
1){var end
Pos=conten
t.indexOf(
'>',startP
os);var at
tribs=Tiny
MCE_FlashP
lugin._par
seAttribut
es(content
.substring
(startPos+
6,endPos))
;embedList
[embedList
.length]=a
ttribs}var
index=0;w
hile((star
tPos=conte
nt.indexOf
('<object'
,startPos)
)!=-1){if(
index>=emb
edList.len
gth)break;
var attrib
s=embedLis
t[index];e
ndPos=cont
ent.indexO
f('</objec
t>',startP
os);endPos
+=9;var co
ntentAfter
=content.s
ubstring(e
ndPos);con
tent=conte
nt.substri
ng(0,start
Pos);conte
nt+='<img
width="'+a
ttribs["wi
dth"]+'" h
eight="'+a
ttribs["he
ight"]+'"'
;content+=
' src="'+(
tinyMCE.ge
tParam("th
eme_href")
+'/images/
spacer.gif
')+'" titl
e="'+attri
bs["src"]+
'"';conten
t+=' alt="
'+attribs[
"src"]+'"
class="mce
ItemFlash"
/>'+conte
nt.substri
ng(endPos)
;content+=
contentAft
er;index++
;startPos+
+}var inde
x=0;while(
(startPos=
content.in
dexOf('<em
bed',start
Pos))!=-1)
{if(index>
=embedList
.length)br
eak;var at
tribs=embe
dList[inde
x];endPos=
content.in
dexOf('>',
startPos);
endPos+=9;
var conten
tAfter=con
tent.subst
ring(endPo
s);content
=content.s
ubstring(0
,startPos)
;content+=
'<img widt
h="'+attri
bs["width"
]+'" heigh
t="'+attri
bs["height
"]+'"';con
tent+=' sr
c="'+(tiny
MCE.getPar
am("theme_
href")+'/i
mages/spac
er.gif')+'
" title="'
+attribs["
src"]+'"';
content+='
alt="'+at
tribs["src
"]+'" clas
s="mceItem
Flash" />'
+content.s
ubstring(e
ndPos);con
tent+=cont
entAfter;i
ndex++;sta
rtPos++}br
eak;case"g
et_from_ed
itor":var
startPos=-
1;while((s
tartPos=co
ntent.inde
xOf('<img'
,startPos+
1))!=-1){v
ar endPos=
content.in
dexOf('/>'
,startPos)
;var attri
bs=TinyMCE
_FlashPlug
in._parseA
ttributes(
content.su
bstring(st
artPos+4,e
ndPos));if
(attribs['
class']!="
mceItemFla
sh")contin
ue;endPos+
=2;var emb
edHTML='';
var wmode=
tinyMCE.ge
tParam("fl
ash_wmode"
,"");var q
uality=tin
yMCE.getPa
ram("flash
_quality",
"high");va
r menu=tin
yMCE.getPa
ram("flash
_menu","fa
lse");embe
dHTML+='<o
bject clas
sid="clsid
:D27CDB6E-
AE6D-11cf-
96B8-44455
3540000"';
embedHTML+
=' codebas
e="http://
download.m
acromedia.
com/pub/sh
ockwave/ca
bs/flash/s
wflash.cab
#version=6
,0,29,0"';
embedHTML+
=' width="
'+attribs[
"width"]+'
" height="
'+attribs[
"height"]+
'">';embed
HTML+='<pa
ram name="
movie" val
ue="'+attr
ibs["title
"]+'" />';
embedHTML+
='<param n
ame="quali
ty" value=
"'+quality
+'" />';em
bedHTML+='
<param nam
e="menu" v
alue="'+me
nu+'" />';
embedHTML+
='<param n
ame="wmode
" value="'
+wmode+'"
/>';embedH
TML+='<emb
ed src="'+
attribs["t
itle"]+'"
wmode="'+w
mode+'" qu
ality="'+q
uality+'"
menu="'+me
nu+'" plug
inspage="h
ttp://www.
macromedia
.com/go/ge
tflashplay
er" type="
applicatio
n/x-shockw
ave-flash"
width="'+
attribs["w
idth"]+'"
height="'+
attribs["h
eight"]+'"
></embed><
/object>';
chunkBefor
e=content.
substring(
0,startPos
);chunkAft
er=content
.substring
(endPos);c
ontent=chu
nkBefore+e
mbedHTML+c
hunkAfter}
break}retu
rn content
},handleNo
deChange:f
unction(ed
itor_id,no
de,undo_in
dex,undo_l
evels,visu
al_aid,any
_selection
){if(node=
=null)retu
rn;do{if(n
ode.nodeNa
me=="IMG"&
&tinyMCE.g
etAttrib(n
ode,'class
').indexOf
('mceItemF
lash')==0)
{tinyMCE.s
witchClass
(editor_id
+'_flash',
'mceButton
Selected')
;return tr
ue}}while(
(node=node
.parentNod
e));tinyMC
E.switchCl
ass(editor
_id+'_flas
h','mceBut
tonNormal'
);return t
rue},_pars
eAttribute
s:function
(attribute
_string){v
ar attribu
teName="";
var attrib
uteValue="
";var with
InName;var
withInVal
ue;var att
ributes=ne
w Array();
var whiteS
paceRegExp
=new RegEx
p('^[ \n\r
\t]+','g')
;if(attrib
ute_string
==null||at
tribute_st
ring.lengt
h<2)return
null;with
InName=wit
hInValue=f
alse;for(v
ar i=0;i<a
ttribute_s
tring.leng
th;i++){va
r chr=attr
ibute_stri
ng.charAt(
i);if((chr
=='"'||chr
=="'")&&!w
ithInValue
)withInVal
ue=true;el
se if((chr
=='"'||chr
=="'")&&wi
thInValue)
{withInVal
ue=false;v
ar pos=att
ributeName
.lastIndex
Of(' ');if
(pos!=-1)a
ttributeNa
me=attribu
teName.sub
string(pos
+1);attrib
utes[attri
buteName.t
oLowerCase
()]=attrib
uteValue.s
ubstring(1
);attribut
eName="";a
ttributeVa
lue=""}els
e if(!whit
eSpaceRegE
xp.test(ch
r)&&!withI
nName&&!wi
thInValue)
withInName
=true;if(c
hr=='='&&w
ithInName)
withInName
=false;if(
withInName
)attribute
Name+=chr;
if(withInV
alue)attri
buteValue+
=chr}retur
n attribut
es}};tinyM
CE.addPlug
in("flash"
,TinyMCE_F
lashPlugin
);
|
|
|