1 |
|
if(!tinyMC
E.settings
['contextm
enu_skip_p
lugin_css'
]){tinyMCE
.loadCSS(t
inyMCE.bas
eURL+"/plu
gins/conte
xtmenu/css
/contextme
nu.css")}v
ar TinyMCE
_ContextMe
nuPlugin={
_contextMe
nu:null,ge
tInfo:func
tion(){ret
urn{longna
me:'Contex
t menus',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
/contextme
nu',versio
n:tinyMCE.
majorVersi
on+"."+tin
yMCE.minor
Version}},
initInstan
ce:functio
n(inst){if
(tinyMCE.i
sMSIE5_0&&
tinyMCE.is
Opera)retu
rn;TinyMCE
_ContextMe
nuPlugin._
contextMen
u=new Tiny
MCE_Contex
tMenu({com
mandhandle
r:"TinyMCE
_ContextMe
nuPlugin._
commandHan
dler",spac
er_image:t
inyMCE.bas
eURL+"/plu
gins/conte
xtmenu/ima
ges/spacer
.gif"});ti
nyMCE.addE
vent(inst.
getDoc(),"
click",Tin
yMCE_Conte
xtMenuPlug
in._hideCo
ntextMenu)
;tinyMCE.a
ddEvent(in
st.getDoc(
),"keypres
s",TinyMCE
_ContextMe
nuPlugin._
hideContex
tMenu);tin
yMCE.addEv
ent(inst.g
etDoc(),"k
eydown",Ti
nyMCE_Cont
extMenuPlu
gin._hideC
ontextMenu
);tinyMCE.
addEvent(d
ocument,"c
lick",Tiny
MCE_Contex
tMenuPlugi
n._hideCon
textMenu);
tinyMCE.ad
dEvent(doc
ument,"key
press",Tin
yMCE_Conte
xtMenuPlug
in._hideCo
ntextMenu)
;tinyMCE.a
ddEvent(do
cument,"ke
ydown",Tin
yMCE_Conte
xtMenuPlug
in._hideCo
ntextMenu)
;if(tinyMC
E.isGecko)
{tinyMCE.a
ddEvent(in
st.getDoc(
),"context
menu",func
tion(e){Ti
nyMCE_Cont
extMenuPlu
gin._showC
ontextMenu
(tinyMCE.i
sMSIE?inst
.contentWi
ndow.event
:e,inst)})
}else tiny
MCE.addEve
nt(inst.ge
tDoc(),"co
ntextmenu"
,TinyMCE_C
ontextMenu
Plugin._on
ContextMen
u)},_onCon
textMenu:f
unction(e)
{var elm=t
inyMCE.isM
SIE?e.srcE
lement:e.t
arget;var
targetInst
,body;if((
body=tinyM
CE.getPare
ntElement(
elm,"body"
))!=null){
for(var n
in tinyMCE
.instances
){var inst
=tinyMCE.i
nstances[n
];if(!tiny
MCE.isInst
ance(inst)
)continue;
if(body==i
nst.getBod
y()){targe
tInst=inst
;break}}re
turn TinyM
CE_Context
MenuPlugin
._showCont
extMenu(ti
nyMCE.isMS
IE?targetI
nst.conten
tWindow.ev
ent:e,targ
etInst)}},
_showConte
xtMenu:fun
ction(e,in
st){if(e.c
trlKey)ret
urn true;f
unction ge
tAttrib(el
m,name){re
turn elm.g
etAttribut
e(name)?el
m.getAttri
bute(name)
:""}var x,
y,elm,cont
extMenu;va
r pos=tiny
MCE.getAbs
Position(i
nst.iframe
Element);x
=tinyMCE.i
sMSIE?e.sc
reenX:pos.
absLeft+(e
.pageX-ins
t.getBody(
).scrollLe
ft);y=tiny
MCE.isMSIE
?e.screenY
:pos.absTo
p+(e.pageY
-inst.getB
ody().scro
llTop);elm
=tinyMCE.i
sMSIE?e.sr
cElement:e
.target;co
ntextMenu=
this._cont
extMenu;co
ntextMenu.
inst=inst;
window.set
Timeout(fu
nction(){v
ar theme=t
inyMCE.get
Param("the
me");conte
xtMenu.cle
arAll();va
r sel=inst
.selection
.getSelect
edText().l
ength!=0||
elm.nodeNa
me=="IMG";
contextMen
u.addItem(
tinyMCE.ba
seURL+"/th
emes/"+the
me+"/image
s/cut.gif"
,"$lang_cu
t_desc","C
ut","",!se
l);context
Menu.addIt
em(tinyMCE
.baseURL+"
/themes/"+
theme+"/im
ages/copy.
gif","$lan
g_copy_des
c","Copy",
"",!sel);c
ontextMenu
.addItem(t
inyMCE.bas
eURL+"/the
mes/"+them
e+"/images
/paste.gif
","$lang_p
aste_desc"
,"Paste","
",false);i
f(sel||(el
m?(elm.nod
eName=='A'
&&tinyMCE.
getAttrib(
elm,'name'
)=='')||(e
lm.nodeNam
e=='IMG'):
false)){co
ntextMenu.
addSeparat
or();conte
xtMenu.add
Item(tinyM
CE.baseURL
+"/themes/
advanced/i
mages/link
.gif","$la
ng_link_de
sc",inst.h
asPlugin("
advlink")?
"mceAdvLin
k":"mceLin
k");contex
tMenu.addI
tem(tinyMC
E.baseURL+
"/themes/a
dvanced/im
ages/unlin
k.gif","$l
ang_unlink
_desc","un
link","",(
elm?(elm.n
odeName!='
A')&&(elm.
nodeName!=
'IMG'):tru
e))}elm=ti
nyMCE.getP
arentEleme
nt(elm,"im
g,table,td
"+(inst.ha
sPlugin("a
dvhr")?',h
r':''));if
(elm){swit
ch(elm.nod
eName){cas
e"IMG":con
textMenu.a
ddSeparato
r();if(tin
yMCE.hasPl
ugin('flas
h')&&tinyM
CE.getAttr
ib(elm,'cl
ass').inde
xOf('mceIt
emFlash')!
=-1)contex
tMenu.addI
tem(tinyMC
E.baseURL+
"/plugins/
flash/imag
es/flash.g
if","$lang
_flash_pro
ps","mceFl
ash");else
if(tinyMC
E.hasPlugi
n('media')
&&/mceItem
(Flash|Sho
ckWave|Win
dowsMedia|
QuickTime|
RealMedia)
/.test(tin
yMCE.getAt
trib(elm,'
class')))c
ontextMenu
.addItem(t
inyMCE.bas
eURL+"/plu
gins/flash
/images/fl
ash.gif","
$lang_medi
a_title","
mceMedia")
;else cont
extMenu.ad
dItem(tiny
MCE.baseUR
L+"/themes
/"+theme+"
/images/im
age.gif","
$lang_imag
e_props_de
sc",inst.h
asPlugin("
advimage")
?"mceAdvIm
age":"mceI
mage");bre
ak;case"HR
":contextM
enu.addSep
arator();c
ontextMenu
.addItem(t
inyMCE.bas
eURL+"/plu
gins/advhr
/images/ad
vhr.gif","
$lang_inse
rt_advhr_d
esc","mceA
dvancedHr"
);break;ca
se"TABLE":
case"TD":i
f(inst.has
Plugin("ta
ble")){var
colspan=(
elm.nodeNa
me=="TABLE
")?"":getA
ttrib(elm,
"colspan")
;var rowsp
an=(elm.no
deName=="T
ABLE")?"":
getAttrib(
elm,"rowsp
an");colsp
an=colspan
==""?"1":c
olspan;row
span=rowsp
an==""?"1"
:rowspan;c
ontextMenu
.addSepara
tor();cont
extMenu.ad
dItem(tiny
MCE.baseUR
L+"/themes
/"+theme+"
/images/cu
t.gif","$l
ang_table_
cut_row_de
sc","mceTa
bleCutRow"
);contextM
enu.addIte
m(tinyMCE.
baseURL+"/
themes/"+t
heme+"/ima
ges/copy.g
if","$lang
_table_cop
y_row_desc
","mceTabl
eCopyRow")
;contextMe
nu.addItem
(tinyMCE.b
aseURL+"/t
hemes/"+th
eme+"/imag
es/paste.g
if","$lang
_table_pas
te_row_bef
ore_desc",
"mceTableP
asteRowBef
ore","",in
st.tableRo
wClipboard
==null);co
ntextMenu.
addItem(ti
nyMCE.base
URL+"/them
es/"+theme
+"/images/
paste.gif"
,"$lang_ta
ble_paste_
row_after_
desc","mce
TablePaste
RowAfter",
"",inst.ta
bleRowClip
board==nul
l);context
Menu.addSe
parator();
contextMen
u.addItem(
tinyMCE.ba
seURL+"/pl
ugins/tabl
e/images/t
able.gif",
"$lang_tab
le_desc","
mceInsertT
able","ins
ert");cont
extMenu.ad
dItem(tiny
MCE.baseUR
L+"/plugin
s/table/im
ages/table
.gif","$la
ng_table_p
rops_desc"
,"mceInser
tTable");c
ontextMenu
.addItem(t
inyMCE.bas
eURL+"/plu
gins/table
/images/ta
ble_cell_p
rops.gif",
"$lang_tab
le_cell_de
sc","mceTa
bleCellPro
ps");conte
xtMenu.add
Item(tinyM
CE.baseURL
+"/plugins
/table/ima
ges/table_
delete.gif
","$lang_t
able_del",
"mceTableD
elete");co
ntextMenu.
addSeparat
or();conte
xtMenu.add
Item(tinyM
CE.baseURL
+"/plugins
/table/ima
ges/table_
row_props.
gif","$lan
g_table_ro
w_desc","m
ceTableRow
Props");co
ntextMenu.
addItem(ti
nyMCE.base
URL+"/plug
ins/table/
images/tab
le_insert_
row_before
.gif","$la
ng_table_r
ow_before_
desc","mce
TableInser
tRowBefore
");context
Menu.addIt
em(tinyMCE
.baseURL+"
/plugins/t
able/image
s/table_in
sert_row_a
fter.gif",
"$lang_tab
le_row_aft
er_desc","
mceTableIn
sertRowAft
er");conte
xtMenu.add
Item(tinyM
CE.baseURL
+"/plugins
/table/ima
ges/table_
delete_row
.gif","$la
ng_table_d
elete_row_
desc","mce
TableDelet
eRow");con
textMenu.a
ddSeparato
r();contex
tMenu.addI
tem(tinyMC
E.baseURL+
"/plugins/
table/imag
es/table_i
nsert_col_
before.gif
","$lang_t
able_col_b
efore_desc
","mceTabl
eInsertCol
Before");c
ontextMenu
.addItem(t
inyMCE.bas
eURL+"/plu
gins/table
/images/ta
ble_insert
_col_after
.gif","$la
ng_table_c
ol_after_d
esc","mceT
ableInsert
ColAfter")
;contextMe
nu.addItem
(tinyMCE.b
aseURL+"/p
lugins/tab
le/images/
table_dele
te_col.gif
","$lang_t
able_delet
e_col_desc
","mceTabl
eDeleteCol
");context
Menu.addSe
parator();
contextMen
u.addItem(
tinyMCE.ba
seURL+"/pl
ugins/tabl
e/images/t
able_split
_cells.gif
","$lang_t
able_split
_cells_des
c","mceTab
leSplitCel
ls","",(co
lspan=="1"
&&rowspan=
="1"));con
textMenu.a
ddItem(tin
yMCE.baseU
RL+"/plugi
ns/table/i
mages/tabl
e_merge_ce
lls.gif","
$lang_tabl
e_merge_ce
lls_desc",
"mceTableM
ergeCells"
,"",false)
}break}}el
se{if(inst
.hasPlugin
("table"))
{contextMe
nu.addSepa
rator();co
ntextMenu.
addItem(ti
nyMCE.base
URL+"/plug
ins/table/
images/tab
le.gif","$
lang_table
_desc","mc
eInsertTab
le","inser
t")}}conte
xtMenu.sho
w(x,y)},10
);tinyMCE.
cancelEven
t(e);retur
n false},_
hideContex
tMenu:func
tion(){if(
TinyMCE_Co
ntextMenuP
lugin._con
textMenu)T
inyMCE_Con
textMenuPl
ugin._cont
extMenu.hi
de()},_com
mandHandle
r:function
(command,v
alue){var
cm=TinyMCE
_ContextMe
nuPlugin._
contextMen
u;cm.hide(
);var ui=f
alse;if(co
mmand=="mc
eInsertTab
le"||comma
nd=="mceTa
bleCellPro
ps"||comma
nd=="mceTa
bleRowProp
s"||comman
d=="mceTab
leMergeCel
ls")ui=tru
e;if(comma
nd=="Paste
")value=nu
ll;if(tiny
MCE.getPar
am("dialog
_type")=="
modal"&&ti
nyMCE.isMS
IE){window
.setTimeou
t(function
(){cm.inst
.execComma
nd(command
,ui,value)
},100)}els
e cm.inst.
execComman
d(command,
ui,value)}
};tinyMCE.
addPlugin(
"contextme
nu",TinyMC
E_ContextM
enuPlugin)
;function
TinyMCE_Co
ntextMenu(
settings){
var doc,se
lf=this;fu
nction def
Param(key,
def_val){s
ettings[ke
y]=typeof(
settings[k
ey])!="und
efined"?se
ttings[key
]:def_val}
this.isMSI
E=(navigat
or.appName
=="Microso
ft Interne
t Explorer
");this.co
ntextMenuD
iv=documen
t.createEl
ement("div
");this.co
ntextMenuD
iv.classNa
me="contex
tMenu";thi
s.contextM
enuDiv.set
Attribute(
"class","c
ontextMenu
");this.co
ntextMenuD
iv.style.d
isplay="no
ne";this.c
ontextMenu
Div.style.
position='
absolute';
this.conte
xtMenuDiv.
style.zind
ex=1000;th
is.context
MenuDiv.st
yle.left='
0';this.co
ntextMenuD
iv.style.t
op='0';thi
s.contextM
enuDiv.uns
electable=
"on";docum
ent.body.a
ppendChild
(this.cont
extMenuDiv
);defParam
("commandh
andler",""
);defParam
("spacer_i
mage","ima
ges/spacer
.gif");thi
s.items=ne
w Array();
this.setti
ngs=settin
gs;this.ht
ml="";if(t
inyMCE.isM
SIE&&!tiny
MCE.isMSIE
5_0&&!tiny
MCE.isOper
a){this.po
p=window.c
reatePopup
();doc=thi
s.pop.docu
ment;doc.o
pen();doc.
write('<ht
ml><head><
link href=
"'+tinyMCE
.baseURL+'
/plugins/c
ontextmenu
/css/conte
xtmenu.css
" rel="sty
lesheet" t
ype="text/
css" /></h
ead><body
unselectab
le="yes" c
lass="cont
extMenuIEP
opup"></bo
dy></html>
');doc.clo
se()}};Tin
yMCE_Conte
xtMenu.pro
totype={cl
earAll:fun
ction(){th
is.html=""
;this.cont
extMenuDiv
.innerHTML
=""},addSe
parator:fu
nction(){t
his.html+=
'<tr class
="contextM
enuItem"><
td class="
contextMen
uIcon"><im
g src="'+t
his.settin
gs['spacer
_image']+'
" width="2
0" height=
"1" class=
"contextMe
nuImage" /
></td><td>
<img class
="contextM
enuSeparat
or" width=
"1" height
="1" src="
'+this.set
tings['spa
cer_image'
]+'" /></t
d></tr>'},
addItem:fu
nction(ico
n,title,co
mmand,valu
e,disabled
){if(title
.charAt(0)
=='$')titl
e=tinyMCE.
getLang(ti
tle.substr
ing(1));va
r onMouseD
own='';var
html='';i
f(tinyMCE.
isMSIE&&!t
inyMCE.isM
SIE5_0)onM
ouseDown='
contextMen
u.execComm
and(\''+co
mmand+'\',
\''+value
+'\');retu
rn false;'
;else onMo
useDown=th
is.setting
s['command
handler']+
'(\''+comm
and+'\', \
''+value+'
\');return
false;';i
f(icon==""
)icon=this
.settings[
'spacer_im
age'];if(!
disabled)h
tml+='<tr
class="con
textMenuIt
em">';else
html+='<t
r class="c
ontextMenu
ItemDisabl
ed">';html
+='<td cla
ss="contex
tMenuIcon"
><img src=
"'+icon+'"
width="20
" height="
20" class=
"contextMe
nuImage" /
></td>';ht
ml+='<td><
div class=
"contextMe
nuText">';
html+='<a
href="java
script:voi
d(0);" onc
lick="'+on
MouseDown+
'" onmouse
down="retu
rn false;"
> ';h
tml+=title
;html+='&#
160;</a>';
html+='</d
iv></td>';
html+='</t
r>';this.h
tml+=html}
,show:func
tion(x,y){
var vp,wid
th,height,
yo;if(this
.html=="")
return;var
html='';h
tml+='<a h
ref="#"></
a><table b
order="0"
cellpaddin
g="0" cell
spacing="0
">';html+=
this.html;
html+='</t
able>';thi
s.contextM
enuDiv.inn
erHTML=htm
l;this.con
textMenuDi
v.style.di
splay="blo
ck";width=
this.conte
xtMenuDiv.
offsetWidt
h;height=t
his.contex
tMenuDiv.o
ffsetHeigh
t;this.con
textMenuDi
v.style.di
splay="non
e";if(tiny
MCE.isMSIE
&&!tinyMCE
.isMSIE5_0
&&!tinyMCE
.isOpera){
this.pop.d
ocument.bo
dy.innerHT
ML='<div c
lass="cont
extMenu">'
+html+"</d
iv>";this.
pop.docume
nt.tinyMCE
=tinyMCE;t
his.pop.do
cument.con
textMenu=t
his;this.p
op.show(x,
y,width,he
ight)}else
{vp=this.g
etViewPort
();yo=tiny
MCE.isMSIE
5_0?docume
nt.body.sc
rollTop:se
lf.pageYOf
fset;this.
contextMen
uDiv.style
.left=(x>v
p.left+vp.
width-widt
h?vp.left+
vp.width-w
idth:x)+'p
x';this.co
ntextMenuD
iv.style.t
op=(y>vp.t
op+vp.heig
ht-height?
vp.top+vp.
height-hei
ght:y)+'px
';this.con
textMenuDi
v.style.di
splay="blo
ck"}},getV
iewPort:fu
nction(){r
eturn{left
:self.page
XOffset||s
elf.docume
nt.documen
tElement.s
crollLeft|
|self.docu
ment.body.
scrollLeft
,top:self.
pageYOffse
t||self.do
cument.doc
umentEleme
nt.scrollT
op||self.d
ocument.bo
dy.scrollT
op,width:d
ocument.do
cumentElem
ent.offset
Width||doc
ument.body
.offsetWid
th,height:
self.inner
Height||do
cument.doc
umentEleme
nt.clientH
eight||doc
ument.body
.clientHei
ght}},hide
:function(
){if(tinyM
CE.isMSIE&
&!tinyMCE.
isMSIE5_0&
&!tinyMCE.
isOpera)th
is.pop.hid
e();else t
his.contex
tMenuDiv.s
tyle.displ
ay="none"}
,execComma
nd:functio
n(command,
value){eva
l(this.set
tings['com
mandhandle
r']+"(comm
and, value
);")}};
|
|
1 |
|
(function(
){var Even
t=tinymce.
dom.Event,
each=tinym
ce.each,DO
M=tinymce.
DOM;tinymc
e.create('
tinymce.pl
ugins.Cont
extMenu',{
init:funct
ion(ed){va
r t=this;t
.editor=ed
;t.onConte
xtMenu=new
tinymce.u
til.Dispat
cher(this)
;ed.onCont
extMenu.ad
d(function
(ed,e){if(
!e.ctrlKey
){t._getMe
nu(ed).sho
wMenu(e.cl
ientX,e.cl
ientY);Eve
nt.cancel(
e);}});fun
ction hide
(){if(t._m
enu){t._me
nu.removeA
ll();t._me
nu.destroy
();}};ed.o
nMouseDown
.add(hide)
;ed.onKeyD
own.add(hi
de);Event.
add(docume
nt,'click'
,hide);},_
getMenu:fu
nction(ed)
{var t=thi
s,m=t._men
u,se=ed.se
lection,co
l=se.isCol
lapsed(),e
l=se.getNo
de()||ed.g
etBody(),a
m,p1,p2;if
(m){m.remo
veAll();m.
destroy();
}p1=DOM.ge
tPos(ed.ge
tContentAr
eaContaine
r());p2=DO
M.getPos(e
d.getConta
iner());m=
ed.control
Manager.cr
eateDropMe
nu('contex
tmenu',{of
fset_x:p1.
x,offset_y
:p1.y,cons
train:1});
t._menu=m;
m.add({tit
le:'advanc
ed.cut_des
c',icon:'c
ut',cmd:'C
ut'}).setD
isabled(co
l);m.add({
title:'adv
anced.copy
_desc',ico
n:'copy',c
md:'Copy'}
).setDisab
led(col);m
.add({titl
e:'advance
d.paste_de
sc',icon:'
paste',cmd
:'Paste'})
;if((el.no
deName=='A
'&&!ed.dom
.getAttrib
(el,'name'
))||!col){
m.addSepar
ator();m.a
dd({title:
'advanced.
link_desc'
,icon:'lin
k',cmd:ed.
plugins.ad
vlink?'mce
AdvLink':'
mceLink',u
i:true});m
.add({titl
e:'advance
d.unlink_d
esc',icon:
'unlink',c
md:'UnLink
'});}m.add
Separator(
);m.add({t
itle:'adva
nced.image
_desc',ico
n:'image',
cmd:ed.plu
gins.advim
age?'mceAd
vImage':'m
ceImage',u
i:true});m
.addSepara
tor();am=m
.addMenu({
title:'con
textmenu.a
lign'});am
.add({titl
e:'context
menu.left'
,icon:'jus
tifyleft',
cmd:'Justi
fyLeft'});
am.add({ti
tle:'conte
xtmenu.cen
ter',icon:
'justifyce
nter',cmd:
'JustifyCe
nter'});am
.add({titl
e:'context
menu.right
',icon:'ju
stifyright
',cmd:'Jus
tifyRight'
});am.add(
{title:'co
ntextmenu.
full',icon
:'justifyf
ull',cmd:'
JustifyFul
l'});t.onC
ontextMenu
.dispatch(
t,m,el,col
);return m
;}});tinym
ce.PluginM
anager.add
('contextm
enu',tinym
ce.plugins
.ContextMe
nu);})();
|