No regular expressions were active.
1 |
|
/**
|
|
|
2 |
|
* $Id: ed
itor_plugi
n_src.js 2
01 2007-02
-12 15:56:
56Z spocke
$
|
|
|
3 |
|
*
|
|
|
4 |
|
* @author
Moxiecode
|
|
|
5 |
|
* @copyri
ght Copyri
ght © 2004
-2007, Mox
iecode Sys
tems AB, A
ll rights
reserved.
|
|
|
6 |
|
*/
|
|
|
7 |
|
|
|
|
8 |
|
/* Import
plugin spe
cific lang
uage pack
*/
|
|
|
9 |
|
tinyMCE.im
portPlugin
LanguagePa
ck('flash'
);
|
|
|
10 |
|
|
|
|
11 |
|
var TinyMC
E_FlashPlu
gin = {
|
|
|
12 |
|
getInf
o : functi
on() {
|
|
|
13 |
|
re
turn {
|
|
|
14 |
|
longname
: 'Flash'
,
|
|
|
15 |
|
author :
'Moxiecod
e Systems
AB',
|
|
|
16 |
|
authorur
l : 'http:
//tinymce.
moxiecode.
com',
|
|
|
17 |
|
infourl
: 'http://
wiki.moxie
code.com/i
ndex.php/T
inyMCE:Plu
gins/flash
',
|
|
|
18 |
|
version
: tinyMCE.
majorVersi
on + "." +
tinyMCE.m
inorVersio
n
|
|
|
19 |
|
};
|
|
|
20 |
|
},
|
|
|
21 |
|
|
|
|
22 |
|
initIn
stance : f
unction(in
st) {
|
|
|
23 |
|
if
(!tinyMCE
.settings[
'flash_ski
p_plugin_c
ss'])
|
|
|
24 |
|
tinyMCE.
importCSS(
inst.getDo
c(), tinyM
CE.baseURL
+ "/plugi
ns/flash/c
ss/content
.css");
|
|
|
25 |
|
},
|
|
|
26 |
|
|
|
|
27 |
|
getCon
trolHTML :
function(
cn) {
|
|
|
28 |
|
sw
itch (cn)
{
|
|
|
29 |
|
case "fl
ash":
|
|
|
30 |
|
retu
rn tinyMCE
.getButton
HTML(cn, '
lang_flash
_desc', '{
$pluginurl
}/images/f
lash.gif',
'mceFlash
');
|
|
|
31 |
|
}
|
|
|
32 |
|
|
|
|
33 |
|
re
turn "";
|
|
|
34 |
|
},
|
|
|
35 |
|
|
|
|
36 |
|
execCo
mmand : fu
nction(edi
tor_id, el
ement, com
mand, user
_interface
, value) {
|
|
|
37 |
|
//
Handle co
mmands
|
|
|
38 |
|
sw
itch (comm
and) {
|
|
|
39 |
|
case "mc
eFlash":
|
|
|
40 |
|
var
name = "",
swffile =
"", swfwi
dth = "",
swfheight
= "", acti
on = "inse
rt";
|
|
|
41 |
|
var
template =
new Array
();
|
|
|
42 |
|
var
inst = tin
yMCE.getIn
stanceById
(editor_id
);
|
|
|
43 |
|
var
focusElm =
inst.getF
ocusElemen
t();
|
|
|
44 |
|
|
|
|
45 |
|
temp
late['file
'] = '..
/../plugin
s/flash/fl
ash.htm';
// Relativ
e to theme
|
|
|
46 |
|
temp
late['widt
h'] = 430
;
|
|
|
47 |
|
temp
late['heig
ht'] = 175
;
|
|
|
48 |
|
|
|
|
49 |
|
temp
late['widt
h'] += tin
yMCE.getLa
ng('lang_f
lash_delta
_width', 0
);
|
|
|
50 |
|
temp
late['heig
ht'] += ti
nyMCE.getL
ang('lang_
flash_delt
a_height',
0);
|
|
|
51 |
|
|
|
|
52 |
|
// I
s selectio
n a image
|
|
|
53 |
|
if (
focusElm !
= null &&
focusElm.n
odeName.to
LowerCase(
) == "img"
) {
|
|
|
54 |
|
name = tin
yMCE.getAt
trib(focus
Elm, 'clas
s');
|
|
|
55 |
|
|
|
|
56 |
|
if (name.i
ndexOf('mc
eItemFlash
') == -1)
// Not a F
lash
|
|
|
57 |
|
return
true;
|
|
|
58 |
|
|
|
|
59 |
|
// Get res
t of Flash
items
|
|
|
60 |
|
swffile =
tinyMCE.ge
tAttrib(fo
cusElm, 'a
lt');
|
|
|
61 |
|
|
|
|
62 |
|
if (tinyMC
E.getParam
('convert_
urls'))
|
|
|
63 |
|
swffil
e = eval(t
inyMCE.set
tings['url
converter_
callback']
+ "(swffi
le, null,
true);");
|
|
|
64 |
|
|
|
|
65 |
|
swfwidth =
tinyMCE.g
etAttrib(f
ocusElm, '
width');
|
|
|
66 |
|
swfheight
= tinyMCE.
getAttrib(
focusElm,
'height');
|
|
|
67 |
|
action = "
update";
|
|
|
68 |
|
}
|
|
|
69 |
|
|
|
|
70 |
|
tiny
MCE.openWi
ndow(templ
ate, {edit
or_id : ed
itor_id, i
nline : "y
es", swffi
le : swffi
le, swfwid
th : swfwi
dth, swfhe
ight : swf
height, ac
tion : act
ion});
|
|
|
71 |
|
return t
rue;
|
|
|
72 |
|
}
|
|
|
73 |
|
|
|
|
74 |
|
//
Pass to ne
xt handler
in chain
|
|
|
75 |
|
ret
urn false;
|
|
|
76 |
|
},
|
|
|
77 |
|
|
|
|
78 |
|
cleanu
p : functi
on(type, c
ontent) {
|
|
|
79 |
|
sw
itch (type
) {
|
|
|
80 |
|
case "in
sert_to_ed
itor_dom":
|
|
|
81 |
|
// F
orce relat
ive/absolu
te
|
|
|
82 |
|
if (
tinyMCE.ge
tParam('co
nvert_urls
')) {
|
|
|
83 |
|
var imgs =
content.g
etElements
ByTagName(
"img");
|
|
|
84 |
|
for (var i
=0; i<imgs
.length; i
++) {
|
|
|
85 |
|
if (ti
nyMCE.getA
ttrib(imgs
[i], "clas
s") == "mc
eItemFlash
") {
|
|
|
86 |
|
va
r src = ti
nyMCE.getA
ttrib(imgs
[i], "alt"
);
|
|
|
87 |
|
|
|
|
88 |
|
if
(tinyMCE.
getParam('
convert_ur
ls'))
|
|
|
89 |
|
src = ev
al(tinyMCE
.settings[
'urlconver
ter_callba
ck'] + "(s
rc, null,
true);");
|
|
|
90 |
|
|
|
|
91 |
|
im
gs[i].setA
ttribute('
alt', src)
;
|
|
|
92 |
|
im
gs[i].setA
ttribute('
title', sr
c);
|
|
|
93 |
|
}
|
|
|
94 |
|
}
|
|
|
95 |
|
}
|
|
|
96 |
|
brea
k;
|
|
|
97 |
|
|
|
|
98 |
|
case "ge
t_from_edi
tor_dom":
|
|
|
99 |
|
var
imgs = con
tent.getEl
ementsByTa
gName("img
");
|
|
|
100 |
|
for
(var i=0;
i<imgs.len
gth; i++)
{
|
|
|
101 |
|
if (tinyMC
E.getAttri
b(imgs[i],
"class")
== "mceIte
mFlash") {
|
|
|
102 |
|
var sr
c = tinyMC
E.getAttri
b(imgs[i],
"alt");
|
|
|
103 |
|
|
|
|
104 |
|
if (ti
nyMCE.getP
aram('conv
ert_urls')
)
|
|
|
105 |
|
sr
c = eval(t
inyMCE.set
tings['url
converter_
callback']
+ "(src,
null, true
);");
|
|
|
106 |
|
|
|
|
107 |
|
imgs[i
].setAttri
bute('alt'
, src);
|
|
|
108 |
|
imgs[i
].setAttri
bute('titl
e', src);
|
|
|
109 |
|
}
|
|
|
110 |
|
}
|
|
|
111 |
|
brea
k;
|
|
|
112 |
|
|
|
|
113 |
|
case "in
sert_to_ed
itor":
|
|
|
114 |
|
var
startPos =
0;
|
|
|
115 |
|
var
embedList
= new Arra
y();
|
|
|
116 |
|
|
|
|
117 |
|
// F
ix the emb
ed and obj
ect elemen
ts
|
|
|
118 |
|
cont
ent = cont
ent.replac
e(new RegE
xp('<[ ]*e
mbed','gi'
),'<embed'
);
|
|
|
119 |
|
cont
ent = cont
ent.replac
e(new RegE
xp('<[ ]*/
embed[ ]*>
','gi'),'<
/embed>');
|
|
|
120 |
|
cont
ent = cont
ent.replac
e(new RegE
xp('<[ ]*o
bject','gi
'),'<objec
t');
|
|
|
121 |
|
cont
ent = cont
ent.replac
e(new RegE
xp('<[ ]*/
object[ ]*
>','gi'),'
</object>'
);
|
|
|
122 |
|
|
|
|
123 |
|
// P
arse all e
mbed tags
|
|
|
124 |
|
whil
e ((startP
os = conte
nt.indexOf
('<embed',
startPos+
1)) != -1)
{
|
|
|
125 |
|
var endPos
= content
.indexOf('
>', startP
os);
|
|
|
126 |
|
var attrib
s = TinyMC
E_FlashPlu
gin._parse
Attributes
(content.s
ubstring(s
tartPos +
6, endPos)
);
|
|
|
127 |
|
embedList[
embedList.
length] =
attribs;
|
|
|
128 |
|
}
|
|
|
129 |
|
|
|
|
130 |
|
// P
arse all o
bject tags
and repla
ce them wi
th images
from the e
mbed data
|
|
|
131 |
|
var
index = 0;
|
|
|
132 |
|
whil
e ((startP
os = conte
nt.indexOf
('<object'
, startPos
)) != -1)
{
|
|
|
133 |
|
if (index
>= embedLi
st.length)
|
|
|
134 |
|
break;
|
|
|
135 |
|
|
|
|
136 |
|
var attrib
s = embedL
ist[index]
;
|
|
|
137 |
|
|
|
|
138 |
|
// Find en
d of objec
t
|
|
|
139 |
|
endPos = c
ontent.ind
exOf('</ob
ject>', st
artPos);
|
|
|
140 |
|
endPos +=
9;
|
|
|
141 |
|
|
|
|
142 |
|
// Insert
image
|
|
|
143 |
|
var conten
tAfter = c
ontent.sub
string(end
Pos);
|
|
|
144 |
|
content =
content.su
bstring(0,
startPos)
;
|
|
|
145 |
|
content +=
'<img wid
th="' + at
tribs["wid
th"] + '"
height="'
+ attribs[
"height"]
+ '"';
|
|
|
146 |
|
content +=
' src="'
+ (tinyMCE
.getParam(
"theme_hre
f") + '/im
ages/space
r.gif') +
'" title="
' + attrib
s["src"] +
'"';
|
|
|
147 |
|
content +=
' alt="'
+ attribs[
"src"] + '
" class="m
ceItemFlas
h" />' + c
ontent.sub
string(end
Pos);
|
|
|
148 |
|
content +=
contentAf
ter;
|
|
|
149 |
|
index++;
|
|
|
150 |
|
|
|
|
151 |
|
startPos++
;
|
|
|
152 |
|
}
|
|
|
153 |
|
|
|
|
154 |
|
// P
arse all e
mbed tags
and replac
e them wit
h images f
rom the em
bed data
|
|
|
155 |
|
var
index = 0;
|
|
|
156 |
|
whil
e ((startP
os = conte
nt.indexOf
('<embed',
startPos)
) != -1) {
|
|
|
157 |
|
if (index
>= embedLi
st.length)
|
|
|
158 |
|
break;
|
|
|
159 |
|
|
|
|
160 |
|
var attrib
s = embedL
ist[index]
;
|
|
|
161 |
|
|
|
|
162 |
|
// Find en
d of embed
|
|
|
163 |
|
endPos = c
ontent.ind
exOf('>',
startPos);
|
|
|
164 |
|
endPos +=
9;
|
|
|
165 |
|
|
|
|
166 |
|
// Insert
image
|
|
|
167 |
|
var conten
tAfter = c
ontent.sub
string(end
Pos);
|
|
|
168 |
|
content =
content.su
bstring(0,
startPos)
;
|
|
|
169 |
|
content +=
'<img wid
th="' + at
tribs["wid
th"] + '"
height="'
+ attribs[
"height"]
+ '"';
|
|
|
170 |
|
content +=
' src="'
+ (tinyMCE
.getParam(
"theme_hre
f") + '/im
ages/space
r.gif') +
'" title="
' + attrib
s["src"] +
'"';
|
|
|
171 |
|
content +=
' alt="'
+ attribs[
"src"] + '
" class="m
ceItemFlas
h" />' + c
ontent.sub
string(end
Pos);
|
|
|
172 |
|
content +=
contentAf
ter;
|
|
|
173 |
|
index++;
|
|
|
174 |
|
|
|
|
175 |
|
startPos++
;
|
|
|
176 |
|
}
|
|
|
177 |
|
|
|
|
178 |
|
brea
k;
|
|
|
179 |
|
|
|
|
180 |
|
case "ge
t_from_edi
tor":
|
|
|
181 |
|
// P
arse all i
mg tags an
d replace
them with
object+emb
ed
|
|
|
182 |
|
var
startPos =
-1;
|
|
|
183 |
|
|
|
|
184 |
|
whil
e ((startP
os = conte
nt.indexOf
('<img', s
tartPos+1)
) != -1) {
|
|
|
185 |
|
var endPos
= content
.indexOf('
/>', start
Pos);
|
|
|
186 |
|
var attrib
s = TinyMC
E_FlashPlu
gin._parse
Attributes
(content.s
ubstring(s
tartPos +
4, endPos)
);
|
|
|
187 |
|
|
|
|
188 |
|
// Is not
flash, ski
p it
|
|
|
189 |
|
if (attrib
s['class']
!= "mceIt
emFlash")
|
|
|
190 |
|
contin
ue;
|
|
|
191 |
|
|
|
|
192 |
|
endPos +=
2;
|
|
|
193 |
|
|
|
|
194 |
|
var embedH
TML = '';
|
|
|
195 |
|
var wmode
= tinyMCE.
getParam("
flash_wmod
e", "");
|
|
|
196 |
|
var qualit
y = tinyMC
E.getParam
("flash_qu
ality", "h
igh");
|
|
|
197 |
|
var menu =
tinyMCE.g
etParam("f
lash_menu"
, "false")
;
|
|
|
198 |
|
|
|
|
199 |
|
// Insert
object + e
mbed
|
|
|
200 |
|
embedHTML
+= '<objec
t classid=
"clsid:D27
CDB6E-AE6D
-11cf-96B8
-444553540
000"';
|
|
|
201 |
|
embedHTML
+= ' codeb
ase="http:
//download
.macromedi
a.com/pub/
shockwave/
cabs/flash
/swflash.c
ab#version
=6,0,29,0"
';
|
|
|
202 |
|
embedHTML
+= ' width
="' + attr
ibs["width
"] + '" he
ight="' +
attribs["h
eight"] +
'">';
|
|
|
203 |
|
embedHTML
+= '<param
name="mov
ie" value=
"' + attri
bs["title"
] + '" />'
;
|
|
|
204 |
|
embedHTML
+= '<param
name="qua
lity" valu
e="' + qua
lity + '"
/>';
|
|
|
205 |
|
embedHTML
+= '<param
name="men
u" value="
' + menu +
'" />';
|
|
|
206 |
|
embedHTML
+= '<param
name="wmo
de" value=
"' + wmode
+ '" />';
|
|
|
207 |
|
embedHTML
+= '<embed
src="' +
attribs["t
itle"] + '
" wmode="'
+ wmode +
'" qualit
y="' + qua
lity + '"
menu="' +
menu + '"
pluginspag
e="http://
www.macrom
edia.com/g
o/getflash
player" ty
pe="applic
ation/x-sh
ockwave-fl
ash" width
="' + attr
ibs["width
"] + '" he
ight="' +
attribs["h
eight"] +
'"></embed
></object>
';
|
|
|
208 |
|
|
|
|
209 |
|
// Insert
embed/obje
ct chunk
|
|
|
210 |
|
chunkBefor
e = conten
t.substrin
g(0, start
Pos);
|
|
|
211 |
|
chunkAfter
= content
.substring
(endPos);
|
|
|
212 |
|
content =
chunkBefor
e + embedH
TML + chun
kAfter;
|
|
|
213 |
|
}
|
|
|
214 |
|
brea
k;
|
|
|
215 |
|
}
|
|
|
216 |
|
|
|
|
217 |
|
//
Pass thro
ugh to nex
t handler
in chain
|
|
|
218 |
|
re
turn conte
nt;
|
|
|
219 |
|
},
|
|
|
220 |
|
|
|
|
221 |
|
handle
NodeChange
: functio
n(editor_i
d, node, u
ndo_index,
undo_leve
ls, visual
_aid, any_
selection)
{
|
|
|
222 |
|
if
(node ==
null)
|
|
|
223 |
|
return;
|
|
|
224 |
|
|
|
|
225 |
|
do
{
|
|
|
226 |
|
if (node
.nodeName
== "IMG" &
& tinyMCE.
getAttrib(
node, 'cla
ss').index
Of('mceIte
mFlash') =
= 0) {
|
|
|
227 |
|
tiny
MCE.switch
Class(edit
or_id + '_
flash', 'm
ceButtonSe
lected');
|
|
|
228 |
|
retu
rn true;
|
|
|
229 |
|
}
|
|
|
230 |
|
}
while ((no
de = node.
parentNode
));
|
|
|
231 |
|
|
|
|
232 |
|
ti
nyMCE.swit
chClass(ed
itor_id +
'_flash',
'mceButton
Normal');
|
|
|
233 |
|
|
|
|
234 |
|
re
turn true;
|
|
|
235 |
|
},
|
|
|
236 |
|
|
|
|
237 |
|
// Pri
vate plugi
n internal
functions
|
|
|
238 |
|
|
|
|
239 |
|
_parse
Attributes
: functio
n(attribut
e_string)
{
|
|
|
240 |
|
va
r attribut
eName = ""
;
|
|
|
241 |
|
va
r attribut
eValue = "
";
|
|
|
242 |
|
va
r withInNa
me;
|
|
|
243 |
|
va
r withInVa
lue;
|
|
|
244 |
|
va
r attribut
es = new A
rray();
|
|
|
245 |
|
va
r whiteSpa
ceRegExp =
new RegEx
p('^[ \n\r
\t]+', 'g'
);
|
|
|
246 |
|
|
|
|
247 |
|
if
(attribut
e_string =
= null ||
attribute_
string.len
gth < 2)
|
|
|
248 |
|
return n
ull;
|
|
|
249 |
|
|
|
|
250 |
|
wi
thInName =
withInVal
ue = false
;
|
|
|
251 |
|
|
|
|
252 |
|
fo
r (var i=0
; i<attrib
ute_string
.length; i
++) {
|
|
|
253 |
|
var chr
= attribut
e_string.c
harAt(i);
|
|
|
254 |
|
|
|
|
255 |
|
if ((chr
== '"' ||
chr == "'
") && !wit
hInValue)
|
|
|
256 |
|
with
InValue =
true;
|
|
|
257 |
|
else if
((chr == '
"' || chr
== "'") &&
withInVal
ue) {
|
|
|
258 |
|
with
InValue =
false;
|
|
|
259 |
|
|
|
|
260 |
|
var
pos = attr
ibuteName.
lastIndexO
f(' ');
|
|
|
261 |
|
if (
pos != -1)
|
|
|
262 |
|
attributeN
ame = attr
ibuteName.
substring(
pos+1);
|
|
|
263 |
|
|
|
|
264 |
|
attr
ibutes[att
ributeName
.toLowerCa
se()] = at
tributeVal
ue.substri
ng(1);
|
|
|
265 |
|
|
|
|
266 |
|
attr
ibuteName
= "";
|
|
|
267 |
|
attr
ibuteValue
= "";
|
|
|
268 |
|
} else i
f (!whiteS
paceRegExp
.test(chr)
&& !withI
nName && !
withInValu
e)
|
|
|
269 |
|
with
InName = t
rue;
|
|
|
270 |
|
|
|
|
271 |
|
if (chr
== '=' &&
withInName
)
|
|
|
272 |
|
with
InName = f
alse;
|
|
|
273 |
|
|
|
|
274 |
|
if (with
InName)
|
|
|
275 |
|
attr
ibuteName
+= chr;
|
|
|
276 |
|
|
|
|
277 |
|
if (with
InValue)
|
|
|
278 |
|
attr
ibuteValue
+= chr;
|
|
|
279 |
|
}
|
|
|
280 |
|
|
|
|
281 |
|
re
turn attri
butes;
|
|
|
282 |
|
}
|
|
|
283 |
|
};
|
|
|
284 |
|
|
|
|
285 |
|
tinyMCE.ad
dPlugin("f
lash", Tin
yMCE_Flash
Plugin);
|
|
|