1 |
|
tinyMCE.im
portPlugin
LanguagePa
ck
(
'layer');v
ar
TinyMCE_La
yerPlugin=
{getInfo:
function()
{
return{lon
gname:'Lay
er',author
:'Moxiecod
e
Systems
AB',author
url:'http:
//
tinymce.
moxie
c
ode.com',i
nfou
r
l:'h
t
t
p://w
i
ki.
m
oxie
c
od
e.
com/index.
ph
p
/TinyMCE:P
lugins
/layer',ve
rsion:tiny
MCE
.
m
a
jorVersion
+"."+tin
y
MCE.minorV
er
sion}}
,
init
Instance
:function(
inst
){
if(
t
inyMCE.isM
SIE&&!
t
i
nyMCE.isOp
era)in
s
t.
g
e
t
D
o
c().
e
x
e
c
Command('
2D-Positio
n')},handl
eEvent:fun
ction(e){v
ar
inst=tinyM
CE.sele
c
t
e
d
Ins
tanc
e
;va
r
w=inst.ge
t
Win(),le=i
nst._l
a
stSt
y
l
e
Elm
,
e;if(
t
inyMCE
.
i
s
Gecko){e=t
his._g
e
tPa
r
en
tLayer
(inst.getF
ocusElemen
t
()
);
if(
e
){if(!inst
.
_l
a
stStyleEl
m
){e.styl
e
.
ove
rfl
o
w
='
a
uto
'
;i
n
st._lastS
t
yleElm=e}}
else
i
f
(
le
){
le=ins
t._
lastStyleE
l
m
;l
e
.styl
e
.wi
d
th=le
.
scr
o
llWi
d
th+'px
'
;le.style.
height=le.
s
c
rollHeight
+'px';le.s
tyl
e
.
ove
rflo
w
='';inst._
l
a
stStyleElm
=null}}ret
urn
t
r
ue},han
d
leVisualAi
d:
function(
el,deep,st
ate,inst
){
var
nl=ins
t.
getDoc().g
etElements
ByTagNa
m
e(
"div"
)
,i
;
for(i=0
;
i<nl.l
e
n
gth;i++){i
f(new
RegExp
('
a
bsolute
|relative|
static
',
'gi').test
(
n
l[i].style
.posi
tion
)){if
(
state
)
t
inyMCE
.
addCSSClas
s(n
l
[i],'mc
e
Visual
A
id');el
s
e
tinyMCE.re
m
o
veCSSClass
(n
l
[i],'mceVi
s
u
alAid'
)
}
}},g
e
tControlHT
ML:f
u
nc
t
i
on(
cn){switch
(cn){case"
moveforwar
d
":return
ti
nyMCE.ge
t
ButtonHTML
(cn,'
l
ang_
layer
_
forward_de
sc',
'{$pluginu
rl}/images
/
m
oveforwar
d
.gif',
'mceMoveFo
rward'
,true
);
cas
e
"
movebackwa
rd
":return
ti
nyMCE.getB
u
t
tonHTML(cn
,'
l
ang_
layer
_
backward_d
esc',
'{$pluginu
rl}/images
/moveba
c
kwar
d
.gif',
'mceMoveBa
ckward'
,true
);
cas
e
"absolute"
:return
tinyMCE
.
get
Button
HTML
(
cn,
'
lang_layer
_
absolute
_desc
',
'
{
$plug
i
nur
l
}/im
a
g
e
s/
absolute
.gif
',
'mceMakeAb
solute'
,true
);
case"inser
tlayer":r
e
turn
tinyMCE
.
get
Button
HTML
(
cn,
'
lang_layer
_
insertlaye
r
_desc
',
'
{
$plug
i
nur
l
}/im
a
g
e
s/
insertlaye
r
.gif
',
'mceInsert
Layer'
,true)}ret
urn""
}
,ex
e
cC
o
mma
n
d
:
function(
ed
i
t
or_
i
d,
e
l
e
m
e
n
t
,
c
ommand
,u
s
er_
i
n
t
er
fa
c
e,
val
ue)
{switch(c
o
mma
n
d
){case"mc
e
I
n
s
e
rtL
a
yer":
t
his
._
i
n
s
e
rtL
a
y
e
r(
);
r
e
tur
n
tr
u
e;c
a
se"mceMove
Forw
a
r
d
":
t
his
._
mo
v
e(1
);
r
et
ur
n
true;case"
mceM
o
veBackward
"
:
t
h
i
s._m
o
ve
(
-1
)
;
return
true;c
a
se"
m
c
e
M
a
k
e
Absol
ut
e":t
h
i
s._t
o
ggl
e
Ab
s
olu
te
();ret
u
rn
t
ru
e}retu
r
n
fa
l
se},
h
a
n
dl
e
N
ode
Cha
n
ge:
f
u
nc
t
i
on(ed
i
t
o
r_
i
d,n
ode
,und
o
_
index
,
u
n
do_
l
e
ve
l
s
,v
i
sual_a
i
d,a
ny
_s
e
l
e
ct
ion
){var
in
s
t=t
i
n
yM
C
E.
ge
tI
n
s
t
a
n
ceById
(ed
itor_id
)
;
var
le
=this._get
ParentLaye
r(
inst.getFo
cusEleme
n
t()
);
var
p=
tinyMCE
.getParent
Element
(
inst.getFo
cusEleme
n
t()
,'
div
,
p
,
img
');
t
i
nyMCE.swit
c
hClas
s
(
e
di
t
or_
i
d
+
'
_
absolute',
'm
c
e
But
t
on
Disabled
');tinyMCE
.switchCla
ss
(
editor_id+
'
_
moveforwar
d',
'm
c
e
But
t
on
Disabled
'
);
tinyMCE
.s
wi
t
chC
l
a
s
s
(
e
di
t
or_
i
d
+
'
_
move
back
ward',
'm
c
e
But
t
on
Disabled
'
);
if(p)tinyM
CE
.s
wi
t
c
hClass(edi
t
or_
i
d+
'
_
absolute',
'mceButton
Normal');i
f(
le&&le.sty
le.positio
n.toLowerC
ase()=="ab
solute")
{
tiny
MCE
.
swit
ch
Class
(
e
di
t
o
r_
i
d+'_
absolute
','mceButt
onS
el
e
c
te
d');
t
inyMCE
.s
wi
t
chC
l
ass(
e
d
it
or_
i
d+'_m
o
ve
f
o
rw
a
r
d
'
,'mce
But
t
onNor
m
al
');
tinyMCE.sw
itchC
l
a
s
s(
ed
it
o
r
_id+'_
move
backw
a
rd'
,'mce
But
t
onNor
m
al
')
}}
,_move:fun
ction(d){v
ar
inst
=t
i
nyMCE.
s
elect
ed
Ins
t
ance
,i,z=
new
Array();va
r
le=this._g
etParentLa
yer(
in
s
t
.get
F
o
cusElem
e
nt
()),ci=-1,
fi=-1
;
var
nl=
tiny
MCE.s
e
l
e
ctNo
d
es(inst
.getBody()
,function(
n){
return
n.nodeType
==1&&
new
RegExp
(
'
absolute|r
elative|st
atic
','gi'
)
.test(n.st
yle.positi
on)
}
);for(i=0;
i<nl.lengt
h;i++){z[i
]=nl[i].st
yle.zIndex
?parseInt(
nl[i].styl
e.zIndex):
0;if(ci<0&
&nl[i]==le
)ci=i
}if(d<0){f
or(i=0;i<z
.length;i+
+){if(z[i]
<z[ci]){fi
=i;break
}}if(fi>-1
){nl[ci].s
tyle.zInde
x=z[fi];nl
[fi].style
.zIndex=z[
ci]
}else{if(z
[ci]>0)nl[
ci].style.
zIndex=z[c
i]-1
}}else{for
(i=0;i<z.l
ength;i++)
{if(z[i]>z
[ci]){fi=i
;break
}}if(fi>-1
){nl[ci].s
tyle.zInde
x=z[fi];nl
[fi].style
.zIndex=z[
ci]
}else
nl[ci].sty
le.zIndex=
z[ci]+1
}
inst
.
r
epaint
(
)
},_getPare
ntLayer:fu
nction(n){
return
t
i
nyMCE
.getParent
Node
(n,functio
n(n){retur
n
n.nodeType
==1&&
new
RegExp
(
'
absolute|r
elative|st
atic
','gi'
)
.test(n.st
yle.positi
on)
})
},_insertL
ayer:funct
ion(){var
inst=tinyM
CE.select
ed
Instance;v
ar
e
=t
i
nyMCE.getP
arentEleme
nt(in
s
t
.
g
e
t
F
o
cusElement
());va
r
p=
tinyMCE
.get
Abs
Pos
ition
(e
);var
d
=inst
.get
Doc();v
ar
ne=d.creat
eElem
ent(
'
d
iv');var
h=inst
.selection
.get
Selecte
d
HTML
()
;
n
e
.
style
.
position
=
'absolute'
;ne.style.
left
=
p.
absLeft+'p
x
';ne.style
.
top
=
(p.
absTop
>20?p.
absTop
:20)
+'px';ne.s
tyle.
width
='
100
px';ne.sty
le.
height
='
100
px
'
;ne.
class
Name=
'mce
VisualAid'
;if(!h)h=
ti
n
yM
C
E
.getLang('
la
ng_la
yer
_
content')
;ne.innerH
TML=h;d.bo
dy.appendC
hild(ne
)
},_toggleA
bsolute:fu
nction(){v
ar
inst
=t
i
nyMCE.
s
elect
ed
Ins
t
ance;va
r
le=this._g
etParentLa
yer(
in
s
t
.get
F
o
cusElem
e
nt
());if(
le
==null
)le=
tinyMCE
.getParent
El
e
m
e
n
t
(
i
n
st
.get
F
o
cusElem
e
nt
(),'
div
,
p
,
img
');if(le){
if(le.styl
e.position
.toLowerCa
se()=="abs
olute"){
l
e
.s
tyle
.
position
="";
le
.s
t
yle.l
e
f
t
=""
;
l
e
.
style
.
t
o
p=""}
e
l
s
e{le.
s
ty
le
.posi
t
i
on="ab
s
ol
u
te"
;
if(le.styl
e.left==""
)le.style.
left=20+'p
x';if(le.s
tyle.top==
"")le.styl
e.top=20+'
px';if(le.
style.widt
h=="")le.s
tyle.width
=le.width?
(le.width+
'px'):'100
px';if(le.
style.heig
ht=="")le.
style.heig
ht=le.heig
ht?(le.hei
ght+'px'):
'100px';
t
in
y
MCE
.
ha
n
d
l
e
Visual
Aid
(
inst
.getBody()
,tru
e
,inst
.
visu
a
lAid,i
n
st)}inst.r
epaint
(
);
tinyMCE.tr
igg
e
rN
odeChange
()
}}}
;tiny
MCE
.
add
Plugin
(
"
layer
"
,
T
iny
MCE_Lay
e
rP
lugin
);
|
|
1 |
|
(
function()
{
tinymce.
c
r
ea
t
e('
t
i
ny
m
c
e.
p
lugins
.
L
a
y
er
'
,
{
init
:function(
ed,url
){
var
t
=
t
h
i
s
;
t.
e
di
t
o
r=
e
d;
e
d.add
Command('
m
c
e
Ins
e
r
t
L
a
y
e
r'
,
t
.
_
i
n
s
e
r
tLayer
,
t
);
e
d
.
a
ddCo
m
mand('mc
e
M
ove
F
o
r
w
a
rd
'
,fu
n
c
t
i
on
(
){
t._
m
ov
e
(1);});
e
d
.
addC
o
mman
d
(
'
m
c
e
M
ove
Back
w
a
r
d
',
function(
){
t.
_
m
ov
e(
-1
)
;
})
;
e
d.addComma
n
d
('
mceM
a
keA
bsolute
',
fu
n
c
tion
(
)
{
t
.
_togg
l
e
A
b
s
o
l
u
te(
)
;
}
);
e
d.addB
u
t
t
on(
'
moveforwar
d
',{
ti
t
l
e:'
layer
.
forward_de
sc',
c
m
d
:
'mceMoveFo
rward'
}
);
e
d.addButto
n('
movebackwa
rd
',{
ti
t
l
e:'
layer
.
backward_d
esc',
c
m
d
:
'mceMoveBa
ckward'
}
);
e
d
.
add
Button
(
'
absolute
',
{
t
i
tle:'
l
a
y
e
r.
absolute
_desc
',
cmd:
'mceMakeAb
solute'
}
);
e
d
.
add
Button
(
'
insertlaye
r
',
{
t
i
tle:'
l
a
y
e
r.
insertlaye
r
_desc
',
cmd:
'mceInsert
Layer'
}
);
e
d.
o
n
Init.a
d
d(
function(
){
i
f(
t
i
nymc
e
.isIE)
e
d.g
e
t
Do
c
().execC
ommand
('2D-Po
s
i
t
ion',
fa
ls
e,
tr
ue)
;});ed.
o
n
No
d
e
Cha
n
g
e
.
a
dd(
t
._
n
od
e
Ch
a
ng
e
,t
);
e
d.o
n
Vis
u
a
lAid.
a
d
d(
t
._
v
isualAid,t
);
},g
et
I
n
f
o
:
func
t
i
o
n
(
)
{
return
{longn
a
m
e
:'L
a
y
e
r',a
ut
h
or:'Mox
i
ec
o
d
e
Sy
s
te
ms
AB',a
u
t
ho
ru
r
l
:'
h
ttp://ti
n
ymc
e
.moxiec
ode
.com',i
n
f
o
u
rl:'h
t
tp://w
i
k
i
.m
o
x
i
ec
ode
.c
o
m/
index
.php/TinyM
CE:Pl
u
gi
n
s/
l
ay
e
r',
ve
r
s
i
on:t
i
ny
mc
e
.majorV
e
rs
ion
+"."+tinym
ce.m
in
orVer
s
i
o
n
};},_node
C
han
ge
:fu
n
c
t
io
n
(ed
,cm,n
)
{
var
le
,p;le
=this._get
ParentLaye
r(
n
);
p=
ed.dom
.getParent
(
n
,'
DIV
,
P
,
IMG
');
i
f(!p){
c
m.
s
e
t
D
i
sable
d
(
'
absolute',
1);
c
m.s
e
t
Disabled
(
'
moveforwar
d',
1);
c
m.s
e
t
Disabled
(
'
movebackwa
rd',1
);
}else{cm
.s
e
t
Disab
l
ed('
a
b
s
olute',0);
cm.
s
e
t
D
i
sable
d
(
'
move
for
ward',
!le);
c
m.s
e
t
Disabled
('moveback
ward
'
,!le
);
cm
.s
e
t
A
c
t
i
ve(
'
absolute',
le&&le.sty
le.positio
n.toLowerC
ase()=="ab
solute")
;}},_visua
lAid:funct
ion(ed,e,s
)
{
var
dom=ed.dom
;
tiny
mce
.
ea
ch
(
dom.s
e
lect('
di
v,p',e),fu
nc
t
i
o
n(e){
i
f(/^(
absolute
|r
el
ativ
e
|stati
c
)$/i.
te
s
t
(e
.s
t
y
l
e
.pos
it
i
o
n)){i
f
(s)d
o
m.
a
d
dClass(e
,'mce
I
t
e
m
Visu
al
Aid
');
e
l
s
e
d
o
m.
r
e
move
Cl
a
ss(e
,'mce
I
t
e
m
Visu
al
Aid
')
;
}}
);}
,_move:fun
ction(d){v
ar
ed
=t
h
i
s
.
ed
i
t
or
,i,z=
[],
le=this._g
etParentLa
yer(
ed.
s
elec
t
ion
.get
N
o
d
e
()),ci=-1,
fi=-1
,nl
;
nl=
[];
tiny
mc
e
.wa
l
k(
e
d
.getBody()
,function(
n){
if(
n.nodeType
==1&&
/^
(
absolute|r
elative|st
atic
)
$/i
.test(n.st
yle.positi
on)
)nl.push(n
);
}
,'childNod
es'
);for(i=0;
i<nl.lengt
h;i++){z[i
]=nl[i].st
yle.zIndex
?parseInt(
nl[i].styl
e.zIndex):
0;if(ci<0&
&nl[i]==le
)ci=i
;
}if(d<0){f
or(i=0;i<z
.length;i+
+){if(z[i]
<z[ci]){fi
=i;break
;
}}if(fi>-1
){nl[ci].s
tyle.zInde
x=z[fi];nl
[fi].style
.zIndex=z[
ci]
;
}else{if(z
[ci]>0)nl[
ci].style.
zIndex=z[c
i]-1
;
}}else{for
(i=0;i<z.l
ength;i++)
{if(z[i]>z
[ci]){fi=i
;break
;
}}if(fi>-1
){nl[ci].s
tyle.zInde
x=z[fi];nl
[fi].style
.zIndex=z[
ci]
;
}else
nl[ci].sty
le.zIndex=
z[ci]+1
;
}
ed
.
execComman
d('mceR
epaint
'
)
;
},_getPare
ntLayer:fu
nction(n){
return
t
h
i
s.editor.d
om
.getParent
(n,functio
n(n){retur
n
n.nodeType
==1&&
/^
(
absolute|r
elative|st
atic
)
$/i
.test(n.st
yle.positi
on)
;
})
;
},_insertL
ayer:funct
ion(){var
ed
=t
h
i
s
.
e
di
t
o
r
,
p=
ed.dom
.get
Pos
(e
d
.dom
.get
P
ar
ent(
e
d
.selection
.get
No
d
e
()
,'*'))
;
e
d.dom
.
add(ed.get
Body(),'di
v',{
style
:{
position
:
'absolute'
,
left
:
p.
x
,
top
:
(p.
y
>20?p.
y
:20)
,
width
:
100
,
height
:
100
},
'
class
':
'mce
Item
VisualAid'
},ed.selec
ti
o
n
.get
C
ontent()||
ed
.getLang('
la
yer
.
content')
)
;
},_toggleA
bsolute:fu
nction(){v
ar
ed
=t
h
i
s
.
ed
i
t
o
r
,
le=this._g
etParentLa
yer(
ed.
s
elec
t
ion
.get
N
o
d
e
());if(
!
le
)le=
ed.dom
.getParent
(
e
d.s
e
lec
t
i
o
n
.get
N
o
d
e
(),'
DIV
,
P
,
IMG
');if(le){
if(le.styl
e.position
.toLowerCa
se()=="abs
olute"){
e
d.dom
.s
etS
tyle
s(le,{
position
:'',
le
f
t
:'',top:''
,width:'',
h
e
igh
t
:''})
;
e
d
.
dom
.
rem
o
v
e
C
l
a
s
s
(
le
,'mceI
t
emV
i
s
u
alAid')
;
}else{
if(le.styl
e.left==""
)le.style.
left=20+'p
x';if(le.s
tyle.top==
"")le.styl
e.top=20+'
px';if(le.
style.widt
h=="")le.s
tyle.width
=le.width?
(le.width+
'px'):'100
px';if(le.
style.heig
ht=="")le.
style.heig
ht=le.heig
ht?(le.hei
ght+'px'):
'100px';
le.s
t
y
le
.
positio
n
="abso
l
ut
e
";ed.add
Visual
(
ed
.getBody()
);}
e
d
.
execComm
a
n
d('mceR
epaint
'
);
e
d.n
odeChange
d
()
;
}}}
)
;tiny
mce
.
Plugin
Manager.ad
d
(
'
layer
'
,
t
iny
mc
e
.p
lugin
s.Layer);}
)(
);
|