1 |
|
tinyMCE.im
portPlugin
LanguagePa
ck('search
replace');
var TinyMC
E_SearchRe
placePlugi
n={getInfo
:function(
){return{l
ongname:'S
earch/Repl
ace',autho
r:'Moxieco
de Systems
AB',autho
rurl:'http
://tinymce
.moxiecode
.com',info
url:'http:
//wiki.mox
iecode.com
/index.php
/TinyMCE:P
lugins/sea
rchreplace
',version:
tinyMCE.ma
jorVersion
+"."+tinyM
CE.minorVe
rsion}},in
itInstance
:function(
inst){inst
.addShortc
ut('ctrl',
'f','lang_
searchrepl
ace_search
_desc','mc
eSearch',t
rue);},get
ControlHTM
L:function
(cn){switc
h(cn){case
"search":r
eturn tiny
MCE.getBut
tonHTML(cn
,'lang_sea
rchreplace
_search_de
sc','{$plu
ginurl}/im
ages/searc
h.gif','mc
eSearch',t
rue);case"
replace":r
eturn tiny
MCE.getBut
tonHTML(cn
,'lang_sea
rchreplace
_replace_d
esc','{$pl
uginurl}/i
mages/repl
ace.gif','
mceSearchR
eplace',tr
ue)}return
""},execCo
mmand:func
tion(edito
r_id,eleme
nt,command
,user_inte
rface,valu
e){var ins
t=tinyMCE.
getInstanc
eById(edit
or_id),sel
ectedText=
inst.selec
tion.getSe
lectedText
(),rng;fun
ction defV
alue(key,d
efault_val
ue){value[
key]=typeo
f(value[ke
y])=="unde
fined"?def
ault_value
:value[key
]}function
replaceSe
l(search_s
tr,str,bac
k){if(!ins
t.selectio
n.isCollap
sed()){if(
tinyMCE.is
RealIE)ins
t.selectio
n.getRng()
.duplicate
().pasteHT
ML(str);el
se inst.ex
ecCommand(
'mceInsert
Content',f
alse,str)}
}if(!value
)value=[];
defValue("
editor_id"
,editor_id
);defValue
("searchst
ring",sele
ctedText);
defValue("
replacestr
ing",null)
;defValue(
"replacemo
de","none"
);defValue
("casesens
itive",fal
se);defVal
ue("backwa
rds",false
);defValue
("wrap",fa
lse);defVa
lue("whole
word",fals
e);defValu
e("inline"
,"yes");de
fValue("re
sizable","
no");switc
h(command)
{case"mceS
earch":if(
user_inter
face){var
template=n
ew Array()
;template[
'file']='.
./../plugi
ns/searchr
eplace/sea
rchreplace
.htm';temp
late['widt
h']=380;te
mplate['he
ight']=155
+(tinyMCE.
isNS7?20:0
)+(tinyMCE
.isMSIE?15
:0);templa
te['width'
]+=tinyMCE
.getLang('
lang_searc
hreplace_d
elta_width
',0);templ
ate['heigh
t']+=tinyM
CE.getLang
('lang_sea
rchreplace
_delta_hei
ght',0);in
st.selecti
on.collaps
e(true);ti
nyMCE.open
Window(tem
plate,valu
e)}else{va
r win=tiny
MCE.getIns
tanceById(
editor_id)
.contentWi
ndow;var d
oc=tinyMCE
.getInstan
ceById(edi
tor_id).co
ntentWindo
w.document
;var body=
tinyMCE.ge
tInstanceB
yId(editor
_id).conte
ntWindow.d
ocument.bo
dy;var awi
n=value.wi
n,found;if
(body.inne
rHTML=="")
{awin.aler
t(tinyMCE.
getLang('l
ang_search
replace_no
tfound'));
return tru
e}if(value
['replacem
ode']=="cu
rrent"){re
placeSel(v
alue['stri
ng'],value
['replaces
tring'],va
lue['backw
ards']);va
lue['repla
cemode']="
none";}ins
t.selectio
n.collapse
(value['ba
ckwards'])
;if(tinyMC
E.isMSIE){
var rng=in
st.selecti
on.getRng(
);var flag
s=0;if(val
ue['wholew
ord'])flag
s=flags|2;
if(value['
casesensit
ive'])flag
s=flags|4;
if(!rng.fi
ndText){aw
in.alert('
This opera
tion is cu
rrently no
t supporte
d by this
browser.')
;return tr
ue}if(valu
e['replace
mode']=="a
ll"){found
=false;whi
le(rng.fin
dText(valu
e['string'
],value['b
ackwards']
?-1:1,flag
s)){found=
true;rng.s
crollIntoV
iew();rng.
select();r
eplaceSel(
value['str
ing'],valu
e['replace
string'],v
alue['back
wards'])}i
f(found)aw
in.alert(t
inyMCE.get
Lang('lang
_searchrep
lace_allre
placed'));
else awin.
alert(tiny
MCE.getLan
g('lang_se
archreplac
e_notfound
'));return
true}if(r
ng.findTex
t(value['s
tring'],va
lue['backw
ards']?-1:
1,flags)){
rng.scroll
IntoView()
;rng.selec
t()}else a
win.alert(
tinyMCE.ge
tLang('lan
g_searchre
place_notf
ound'))}el
se{if(valu
e['replace
mode']=="a
ll"){found
=false;whi
le(win.fin
d(value['s
tring'],va
lue['cases
ensitive']
,value['ba
ckwards'],
value['wra
p'],value[
'wholeword
'],false,f
alse)){fou
nd=true;re
placeSel(v
alue['stri
ng'],value
['replaces
tring'],va
lue['backw
ards'])}if
(found)awi
n.alert(ti
nyMCE.getL
ang('lang_
searchrepl
ace_allrep
laced'));e
lse awin.a
lert(tinyM
CE.getLang
('lang_sea
rchreplace
_notfound'
));return
true}if(!w
in.find(va
lue['strin
g'],value[
'casesensi
tive'],val
ue['backwa
rds'],valu
e['wrap'],
value['who
leword'],f
alse,false
))awin.ale
rt(tinyMCE
.getLang('
lang_searc
hreplace_n
otfound'))
}}return t
rue;case"m
ceSearchRe
place":val
ue['replac
estring']=
"";tinyMCE
.execInsta
nceCommand
(editor_id
,'mceSearc
h',user_in
terface,va
lue,false)
;return tr
ue}return
false}};ti
nyMCE.addP
lugin("sea
rchreplace
",TinyMCE_
SearchRepl
acePlugin)
;
|
|
1 |
|
(function(
){tinymce.
create('ti
nymce.plug
ins.Search
ReplacePlu
gin',{init
:function(
ed,url){fu
nction ope
n(m){ed.wi
ndowManage
r.open({fi
le:url+'/s
earchrepla
ce.htm',wi
dth:420+pa
rseInt(ed.
getLang('s
earchrepla
ce.delta_w
idth',0)),
height:160
+parseInt(
ed.getLang
('searchre
place.delt
a_height',
0)),inline
:1,auto_fo
cus:0},{mo
de:m,searc
h_string:e
d.selectio
n.getConte
nt({format
:'text'}),
plugin_url
:url});};e
d.addComma
nd('mceSea
rch',funct
ion(){open
('search')
;});ed.add
Command('m
ceReplace'
,function(
){open('re
place');})
;ed.addBut
ton('searc
h',{title:
'searchrep
lace.searc
h_desc',cm
d:'mceSear
ch'});ed.a
ddButton('
replace',{
title:'sea
rchreplace
.replace_d
esc',cmd:'
mceReplace
'});ed.add
Shortcut('
ctrl+f','s
earchrepla
ce.search_
desc','mce
Search');}
,getInfo:f
unction(){
return{lon
gname:'Sea
rch/Replac
e',author:
'Moxiecode
Systems A
B',authoru
rl:'http:/
/tinymce.m
oxiecode.c
om',infour
l:'http://
wiki.moxie
code.com/i
ndex.php/T
inyMCE:Plu
gins/searc
hreplace',
version:ti
nymce.majo
rVersion+"
."+tinymce
.minorVers
ion};}});t
inymce.Plu
ginManager
.add('sear
chreplace'
,tinymce.p
lugins.Sea
rchReplace
Plugin);})
();
|