No regular expressions were active.
1 |
|
/**
|
|
1 |
|
/**
|
2 |
|
*
$Id:
editor_plu
gin_src.js
20
1
200
7
-0
2-
1
2
1
5:5
6:
56
Z
spocke
$
|
|
2 |
|
*
$Id:
editor_plu
gin_src.js
5
20
200
8
-0
1
-07
1
6:
30:32
Z
spocke
$
|
3 |
|
*
|
|
3 |
|
*
|
4 |
|
* @author
Moxiecode
|
|
4 |
|
* @author
Moxiecode
|
5 |
|
*
@copyright
Copyright
©
2004-200
7
,
Moxiecode
Systems
AB,
All
rights
reserved.
|
|
5 |
|
*
@copyright
Copyright
©
2004-200
8
,
Moxiecode
Systems
AB,
All
rights
reserved.
|
6 |
|
*/
|
|
6 |
|
*/
|
7 |
|
|
|
7 |
|
|
8 |
|
/* Import
plugin spe
cific lang
uage pack
*/
|
|
8 |
|
(function(
) {
|
9 |
|
tiny
MCE
.
i
m
p
ortP
lugin
LanguagePa
ck('d
irectional
ity'
);
|
|
9 |
|
tiny
mce
.
create('t
i
ny
m
ce.
p
lugin
s.D
irectional
ity'
,
{
|
|
|
10 |
|
in
it : funct
ion(ed, ur
l) {
|
|
|
11 |
|
var t =
this;
|
10 |
|
|
|
12 |
|
|
11 |
|
var TinyMC
E_Directio
nalityPlug
in = {
|
|
13 |
|
t.editor
= ed;
|
12 |
|
getInf
o : functi
on() {
|
|
|
13 |
|
re
turn {
|
|
|
14 |
|
longname
: 'Direct
ionality',
|
|
|
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/direc
tionality'
,
|
|
|
18 |
|
version
: tinyMCE.
majorVersi
on + "." +
tinyMCE.m
inorVersio
n
|
|
|
19 |
|
};
|
|
|
20 |
|
},
|
|
|
21 |
|
|
|
14 |
|
|
22 |
|
g
e
t
Co
n
t
r
o
lHTM
L
:
function(
cn
)
{
|
|
15 |
|
e
d.add
Co
mma
n
d('mceDi
r
ecti
o
n
L
TR',
function(
)
{
|
23 |
|
sw
itch (cn)
{
|
|
16 |
|
var
e = ed.dom
.getParent
(ed.select
ion.getNod
e(), ed.do
m.isBlock)
;
|
24 |
|
case "lt
r":
|
|
|
25 |
|
retu
rn tinyMCE
.getButton
HTML(cn, '
lang_direc
tionality_
ltr_desc',
'{$plugin
url}/image
s/ltr.gif'
, 'mceDire
ctionLTR')
;
|
|
|
26 |
|
|
|
17 |
|
|
27 |
|
case "rt
l":
|
|
18 |
|
if (
e) {
|
28 |
|
retu
rn tinyMCE
.getButton
HTML(cn, '
lang_direc
tionality_
rtl_desc',
'{$plugin
url}/image
s/rtl.gif'
, 'mceDire
ctionRTL')
;
|
|
19 |
|
if (ed.dom
.getAttrib
(e, "dir")
!= "ltr")
|
|
|
20 |
|
ed.dom
.setAttrib
(e, "dir",
"ltr");
|
|
|
21 |
|
else
|
|
|
22 |
|
ed.dom
.setAttrib
(e, "dir",
"");
|
29 |
|
}
|
|
23 |
|
}
|
30 |
|
|
|
24 |
|
|
31 |
|
re
turn "";
|
|
25 |
|
ed.n
odeChanged
();
|
32 |
|
},
|
|
26 |
|
});
|
33 |
|
|
|
|
34 |
|
execCo
mmand : fu
nction(edi
tor_id, el
ement, com
mand, user
_interface
, value) {
|
|
|
35 |
|
//
Handle co
mmands
|
|
|
36 |
|
sw
itch (comm
and) {
|
|
|
37 |
|
case "mc
eDirection
LTR":
|
|
|
38 |
|
var
inst = tin
yMCE.getIn
stanceById
(editor_id
);
|
|
|
39 |
|
var
elm = tiny
MCE.getPar
entElement
(inst.getF
ocusElemen
t(), "p,di
v,td,h1,h2
,h3,h4,h5,
h6,pre,add
ress");
|
|
|
40 |
|
|
|
27 |
|
|
41 |
|
if (
elm)
|
|
28 |
|
ed.addCo
mmand('mce
DirectionR
TL', funct
ion() {
|
42 |
|
elm.setAtt
ribute("di
r", "ltr")
;
|
|
29 |
|
var
e = ed.dom
.getParent
(ed.select
ion.getNod
e(), ed.do
m.isBlock)
;
|
43 |
|
|
|
30 |
|
|
44 |
|
tiny
MCE.trigge
rNodeChang
e(false);
|
|
31 |
|
if (
e) {
|
45 |
|
retu
rn true;
|
|
32 |
|
if (ed.dom
.getAttrib
(e, "dir")
!= "rtl")
|
|
|
33 |
|
ed.dom
.setAttrib
(e, "dir",
"rtl");
|
|
|
34 |
|
else
|
|
|
35 |
|
ed.dom
.setAttrib
(e, "dir",
"");
|
|
|
36 |
|
}
|
46 |
|
|
|
37 |
|
|
47 |
|
case "mc
eDirection
RTL":
|
|
38 |
|
ed.n
odeChanged
();
|
48 |
|
var
inst = tin
yMCE.getIn
stanceById
(editor_id
);
|
|
39 |
|
});
|
49 |
|
var
elm = tiny
MCE.getPar
entElement
(inst.getF
ocusElemen
t(), "p,di
v,td,h1,h2
,h3,h4,h5,
h6,pre,add
ress");
|
|
|
50 |
|
|
|
40 |
|
|
51 |
|
if (
elm)
|
|
41 |
|
ed.addBu
tton('ltr'
, {title :
'directio
nality.ltr
_desc', cm
d : 'mceDi
rectionLTR
'});
|
52 |
|
elm.setAtt
ribute("di
r", "rtl")
;
|
|
42 |
|
ed.addBu
tton('rtl'
, {title :
'directio
nality.rtl
_desc', cm
d : 'mceDi
rectionRTL
'});
|
53 |
|
|
|
43 |
|
|
54 |
|
tiny
MCE.trigge
rNodeChang
e(false);
|
|
44 |
|
ed.onNod
eChange.ad
d(t._nodeC
hange, t);
|
55 |
|
retu
rn true;
|
|
45 |
|
}
,
|
56 |
|
}
|
|
|
57 |
|
|
|
46 |
|
|
58 |
|
//
Pass to n
ext handle
r in chain
|
|
47 |
|
ge
tInfo : fu
nction() {
|
59 |
|
return
false;
|
|
48 |
|
return
{
|
|
|
49 |
|
long
name : 'Di
rectionali
ty',
|
|
|
50 |
|
auth
or : 'Moxi
ecode Syst
ems AB',
|
|
|
51 |
|
auth
orurl : 'h
ttp://tiny
mce.moxiec
ode.com',
|
|
|
52 |
|
info
url : 'htt
p://wiki.m
oxiecode.c
om/index.p
hp/TinyMCE
:Plugins/d
irectional
ity',
|
|
|
53 |
|
vers
ion : tiny
mce.majorV
ersion + "
." + tinym
ce.minorVe
rsion
|
|
|
54 |
|
};
|
60 |
|
},
|
|
55 |
|
},
|
61 |
|
|
|
56 |
|
|
62 |
|
handle
NodeChange
: functio
n(editor_i
d, node, u
ndo_index,
undo_leve
ls, visual
_aid, any_
selection)
{
|
|
57 |
|
//
Private m
ethods
|
63 |
|
fu
nction get
Attrib(elm
, name) {
|
|
|
64 |
|
return e
lm.getAttr
ibute(name
) ? elm.ge
tAttribute
(name) : "
";
|
|
|
65 |
|
}
|
|
|
66 |
|
|
|
58 |
|
|
67 |
|
if
(node ==
null)
|
|
59 |
|
_n
odeChange
: function
(ed, cm, n
) {
|
68 |
|
return;
|
|
60 |
|
var dom
= ed.dom,
dir;
|
69 |
|
|
|
61 |
|
|
70 |
|
va
r elm = ti
nyMCE.getP
arentEleme
nt(node, "
p,div,td,h
1,h2,h3,h4
,h5,h6,pre
,address")
;
|
|
62 |
|
n = dom.
getParent(
n, dom.isB
lock);
|
71 |
|
if
(!
elm
)
{
|
|
63 |
|
if
(!
n
)
{
|
72 |
|
tinyMCE.
switchClas
s(editor_i
d + '_ltr'
, 'mceButt
onDisabled
');
|
|
64 |
|
cm.s
etDisabled
('ltr', 1)
;
|
73 |
|
tinyMCE.
switchClas
s(editor_i
d + '_rtl'
, 'mceButt
onDisabled
');
|
|
65 |
|
cm.s
etDisabled
('rtl', 1)
;
|
74 |
|
return
true
;
|
|
66 |
|
return
;
|
75 |
|
}
|
|
67 |
|
}
|
76 |
|
|
|
68 |
|
|
77 |
|
ti
nyMCE.swit
chClass(ed
itor_id +
'_ltr', 'm
ceButtonNo
rmal');
|
|
69 |
|
dir
=
dom.
getAttrib(
n
,
'
dir
'
);
|
78 |
|
ti
nyMCE.swit
chClass(ed
itor_id +
'_rtl', 'm
ceButtonNo
rmal');
|
|
70 |
|
cm.setAc
tive('ltr'
, dir == "
ltr");
|
79 |
|
|
|
71 |
|
cm.setDi
sabled('lt
r', 0);
|
80 |
|
var
dir
=
getAttrib(
elm
,
"
dir
"
);
|
|
72 |
|
cm.setAc
tive('rtl'
, dir == "
rtl");
|
81 |
|
if
(dir == "
ltr" || di
r == "")
|
|
73 |
|
cm.setDi
sabled('rt
l', 0);
|
82 |
|
tinyMCE.
switchClas
s(editor_i
d + '_ltr'
, 'mceButt
onSelected
');
|
|
|
83 |
|
el
se
|
|
|
84 |
|
tinyMCE.
switchClas
s(editor_i
d + '_rtl'
, 'mceButt
onSelected
');
|
|
|
85 |
|
|
|
|
86 |
|
re
turn true;
|
|
|
87 |
|
}
|
|
74 |
|
}
|
88 |
|
}
;
|
|
75 |
|
}
)
;
|
89 |
|
|
|
76 |
|
|
90 |
|
tiny
MCE
.
add
Plugin
(
"
directiona
lity
"
,
T
iny
MCE_
Directiona
lity
Plugin
);
|
|
77 |
|
// Reg
ister plug
in
|
|
|
78 |
|
tiny
mce
.
Plugin
Manager.ad
d
(
'
directiona
lity
'
,
t
iny
mce.plugin
s.
Directiona
lity
);
|
|
|
79 |
|
})();
|