1 |
|
var TinyMC
E_NonEdita
blePlugin=
{getInfo:f
unction(){
return{lon
gname:'Non
editable
elements',
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/nonedita
ble',versi
on:tinyMCE
.majorVers
ion+"."+ti
nyMCE.mino
rVersion}}
,initInsta
nce:functi
on(inst){t
inyMCE.imp
ortCSS(ins
t.getDoc()
,tinyMCE.b
aseURL+"/p
lugins/non
editable/c
ss/nonedit
able.css")
;if(tinyMC
E.isMSIE5_
0)tinyMCE.
settings['
plugins']=
tinyMCE.se
ttings['pl
ugins'].re
place(/non
editable/g
i,'Nonedit
able')},ha
ndleEvent:
function(e
){return t
his._moveS
election(e
,tinyMCE.s
electedIns
tance)},cl
eanup:func
tion(type,
content,in
st){switch
(type){cas
e"insert_t
o_editor_d
om":var no
des,i,edit
Class,nonE
ditClass,e
ditable,el
m;if(tinyM
CE.isGecko
)return co
ntent;node
s=tinyMCE.
getNodeTre
e(content,
[],1);edit
Class=tiny
MCE.getPar
am("nonedi
table_edit
able_class
","mceEdit
able");non
EditClass=
tinyMCE.ge
tParam("no
neditable_
noneditabl
e_class","
mceNonEdit
able");for
(i=0;i<nod
es.length;
i++){elm=n
odes[i];ed
itable=tin
yMCE.getAt
trib(elm,"
contentedi
table");if
(new RegEx
p("true|fa
lse","gi")
.test(edit
able))Tiny
MCE_NonEdi
tablePlugi
n._setEdit
able(elm,e
ditable=="
true");if(
tinyMCE.is
IE){if(tin
yMCE.hasCS
SClass(elm
,editClass
))elm.cont
entEditabl
e=true;if(
tinyMCE.ha
sCSSClass(
elm,nonEdi
tClass))el
m.contentE
ditable=fa
lse}}break
;case"inse
rt_to_edit
or":var ed
itClass=ti
nyMCE.getP
aram("none
ditable_ed
itable_cla
ss","mceEd
itable");v
ar nonEdit
Class=tiny
MCE.getPar
am("nonedi
table_none
ditable_cl
ass","mceN
onEditable
");content
=content.r
eplace(/mc
eItemEdita
ble/g,edit
Class);con
tent=conte
nt.replace
(/mceItemN
onEditable
/g,nonEdit
Class);if(
tinyMCE.is
IE&&(conte
nt.indexOf
(editClass
)!=-1||con
tent.index
Of(nonEdit
Class)!=-1
)){content
=content.r
eplace(new
RegExp("c
lass=\"(.+
)("+editCl
ass+")\"",
"gi"),'cla
ss="$1$2"
contentedi
table="tru
e"');conte
nt=content
.replace(n
ew RegExp(
"class=\"(
.+)("+nonE
ditClass+"
)\"","gi")
,'class="$
1$2" conte
nteditable
="false"')
;content=c
ontent.rep
lace(new R
egExp("cla
ss=\"("+ed
itClass+")
([^\"]*)\"
","gi"),'c
lass="$1$2
" contente
ditable="t
rue"');con
tent=conte
nt.replace
(new RegEx
p("class=\
"("+nonEdi
tClass+")(
[^\"]*)\""
,"gi"),'cl
ass="$1$2"
contented
itable="fa
lse"');con
tent=conte
nt.replace
(new RegEx
p("class=\
"(.+)("+ed
itClass+")
([^\"]*)\"
","gi"),'c
lass="$1$2
$3" conten
teditable=
"true"');c
ontent=con
tent.repla
ce(new Reg
Exp("class
=\"(.+)("+
nonEditCla
ss+")([^\"
]*)\"","gi
"),'class=
"$1$2$3" c
ontentedit
able="fals
e"')}break
;case"get_
from_edito
r_dom":if(
tinyMCE.is
Gecko)retu
rn content
;if(tinyMC
E.getParam
("nonedita
ble_leave_
contentedi
table",fal
se)){var n
odes=tinyM
CE.getNode
Tree(conte
nt,new Arr
ay(),1);fo
r(var i=0;
i<nodes.le
ngth;i++)n
odes[i].re
moveAttrib
ute("conte
nteditable
")}break}r
eturn cont
ent},_move
Selection:
function(e
,inst){var
s,r,sc,ec
,el,c=tiny
MCE.getPar
am('nonedi
table_edit
able_class
','mceNonE
ditable');
if(!inst)r
eturn true
;if(tinyMC
E.isGecko)
{s=inst.se
lection.ge
tSel();r=s
.getRangeA
t(0);sc=ti
nyMCE.getP
arentNode(
r.startCon
tainer,fun
ction(n){r
eturn tiny
MCE.hasCSS
Class(n,c)
});ec=tiny
MCE.getPar
entNode(r.
endContain
er,functio
n(n){retur
n tinyMCE.
hasCSSClas
s(n,c)});s
c&&r.setSt
artBefore(
sc);ec&&r.
setEndAfte
r(ec);if(s
c||ec){if(
e.type=='k
eypress'&&
e.keyCode=
=39){el=sc
||ec;}s.re
moveAllRan
ges();s.ad
dRange(r);
return tin
yMCE.cance
lEvent(e)}
}return tr
ue},_setEd
itable:fun
ction(elm,
state){var
editClass
=tinyMCE.g
etParam("n
oneditable
_editable_
class","mc
eEditable"
);var nonE
ditClass=t
inyMCE.get
Param("non
editable_n
oneditable
_class","m
ceNonEdita
ble");var
className=
elm.classN
ame?elm.cl
assName:""
;if(classN
ame.indexO
f(editClas
s)!=-1||cl
assName.in
dexOf(nonE
ditClass)!
=-1)return
;if((class
Name=tinyM
CE.getAttr
ib(elm,"cl
ass"))!=""
)className
+=" ";clas
sName+=sta
te?editCla
ss:nonEdit
Class;elm.
setAttribu
te("class"
,className
);elm.clas
sName=clas
sName}};ti
nyMCE.addP
lugin("non
editable",
TinyMCE_No
nEditableP
lugin);
|
|
1 |
|
(function(
){var Even
t=tinymce.
dom.Event;
tinymce.cr
eate('tiny
mce.plugin
s.NonEdita
blePlugin'
,{init:fun
ction(ed,u
rl){var t=
this,editC
lass,nonEd
itClass;t.
editor=ed;
editClass=
ed.getPara
m("nonedit
able_edita
ble_class"
,"mceEdita
ble");nonE
ditClass=e
d.getParam
("nonedita
ble_nonedi
table_clas
s","mceNon
Editable")
;ed.onNode
Change.add
ToTop(func
tion(ed,cm
,n){var sc
,ec;sc=ed.
dom.getPar
ent(ed.sel
ection.get
Start(),fu
nction(n){
return ed.
dom.hasCla
ss(n,nonEd
itClass);}
);ec=ed.do
m.getParen
t(ed.selec
tion.getEn
d(),functi
on(n){retu
rn ed.dom.
hasClass(n
,nonEditCl
ass);});if
(sc||ec){t
._setDisab
led(1);ret
urn false;
}else t._s
etDisabled
(0);});},g
etInfo:fun
ction(){re
turn{longn
ame:'Non e
ditable el
ements',au
thor:'Moxi
ecode Syst
ems AB',au
thorurl:'h
ttp://tiny
mce.moxiec
ode.com',i
nfourl:'ht
tp://wiki.
moxiecode.
com/index.
php/TinyMC
E:Plugins/
noneditabl
e',version
:tinymce.m
ajorVersio
n+"."+tiny
mce.minorV
ersion};},
_block:fun
ction(ed,e
){return E
vent.cance
l(e);},_se
tDisabled:
function(s
){var t=th
is,ed=t.ed
itor;tinym
ce.each(ed
.controlMa
nager.cont
rols,funct
ion(c){c.s
etDisabled
(s);});if(
s!==t.disa
bled){if(s
){ed.onKey
Down.addTo
Top(t._blo
ck);ed.onK
eyPress.ad
dToTop(t._
block);ed.
onKeyUp.ad
dToTop(t._
block);ed.
onPaste.ad
dToTop(t._
block);}el
se{ed.onKe
yDown.remo
ve(t._bloc
k);ed.onKe
yPress.rem
ove(t._blo
ck);ed.onK
eyUp.remov
e(t._block
);ed.onPas
te.remove(
t._block);
}t.disable
d=s;}}});t
inymce.Plu
ginManager
.add('none
ditable',t
inymce.plu
gins.NonEd
itablePlug
in);})();
|