1 |
|
tinyMCE.im
portPlugin
LanguagePa
ck('fullpa
ge');var T
inyMCE_Ful
lPagePlugi
n={getInfo
:function(
){return{l
ongname:'F
ullpage',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
/fullpage'
,version:t
inyMCE.maj
orVersion+
"."+tinyMC
E.minorVer
sion}},get
ControlHTM
L:function
(cn){switc
h(cn){case
"fullpage"
:return ti
nyMCE.getB
uttonHTML(
cn,'lang_f
ullpage_de
sc','{$plu
ginurl}/im
ages/fullp
age.gif','
mceFullPag
ePropertie
s')}return
""},execCo
mmand:func
tion(edito
r_id,eleme
nt,command
,user_inte
rface,valu
e){switch(
command){c
ase"mceFul
lPagePrope
rties":var
template=
new Array(
);template
['file']='
../../plug
ins/fullpa
ge/fullpag
e.htm';tem
plate['wid
th']=430;t
emplate['h
eight']=48
5+(tinyMCE
.isOpera?5
:0);templa
te['width'
]+=tinyMCE
.getLang('
lang_fullp
age_delta_
width',0);
template['
height']+=
tinyMCE.ge
tLang('lan
g_fullpage
_delta_hei
ght',0);ti
nyMCE.open
Window(tem
plate,{edi
tor_id:edi
tor_id,inl
ine:"yes"}
);return t
rue;case"m
ceFullPage
Update":Ti
nyMCE_Full
PagePlugin
._addToHea
d(tinyMCE.
getInstanc
eById(edit
or_id));re
turn true}
return fal
se},cleanu
p:function
(type,cont
ent,inst){
switch(typ
e){case"in
sert_to_ed
itor":var
tmp=conten
t.toLowerC
ase();var
pos=tmp.in
dexOf('<bo
dy'),pos2;
if(pos!=-1
){pos=tmp.
indexOf('>
',pos);pos
2=tmp.last
IndexOf('<
/body>');i
nst.fullpa
geTopConte
nt=content
.substring
(0,pos+1);
content=co
ntent.subs
tring(pos+
1,pos2);}e
lse{if(!in
st.fullpag
eTopConten
t){var doc
Type=tinyM
CE.getPara
m("fullpag
e_default_
doctype",'
<!DOCTYPE
html PUBLI
C "-/'+'/W
3C//DTD XH
TML 1.0 Tr
ansitional
/'+'/EN" "
http:/'+'/
www.w3.org
/TR/xhtml1
/DTD/xhtml
1-transiti
onal.dtd">
');var enc
=tinyMCE.g
etParam("f
ullpage_de
fault_enco
ding",'utf
-8');var t
itle=tinyM
CE.getPara
m("fullpag
e_default_
title",'Un
titled doc
ument');va
r lang=tin
yMCE.getPa
ram("fullp
age_defaul
t_langcode
",'en');va
r pi=tinyM
CE.getPara
m("fullpag
e_default_
xml_pi",tr
ue);var ff
=tinyMCE.g
etParam("f
ullpage_de
fault_font
_family","
");var fz=
tinyMCE.ge
tParam("fu
llpage_def
ault_font_
size","");
var ds=tin
yMCE.getPa
ram("fullp
age_defaul
t_style","
");var dtc
=tinyMCE.g
etParam("f
ullpage_de
fault_text
_color",""
);title=ti
tle.replac
e(/&/g,'&a
mp;');titl
e=title.re
place(/\"/
g,'"'
);title=ti
tle.replac
e(/</g,'&l
t;');title
=title.rep
lace(/>/g,
'>');tm
p='';if(pi
)tmp+='<?x
ml version
="1.0" enc
oding="'+e
nc+'"?>\n'
;tmp+=docT
ype+'\n';t
mp+='<html
xmlns="ht
tp:/'+'/ww
w.w3.org/1
999/xhtml"
lang="'+l
ang+'" xml
:lang="'+l
ang+'">\n'
;tmp+='<he
ad>\n';tmp
+='\t<titl
e>'+title+
'</title>\
n';tmp+='\
t<meta htt
p-equiv="C
ontent-Typ
e" content
="text/htm
l; charset
='+enc+'"
/>\n';tmp+
='</head>\
n';tmp+='<
body';if(f
f!=''||fz!
=''){tmp+=
' style="'
;if(ds!=''
)tmp+=ds+"
;";if(ff!=
'')tmp+='f
ont-family
: '+ff+";"
;if(fz!=''
)tmp+='fon
t-size: '+
fz+";";tmp
+='"'}if(d
tc!='')tmp
+=' text="
'+dtc+'"';
tmp+='>\n'
;inst.full
pageTopCon
tent=tmp}}
this._addT
oHead(inst
);break;ca
se"get_fro
m_editor":
if(inst.fu
llpageTopC
ontent&&!t
inyMCE.get
Param("ful
lpage_hide
_in_source
_view",fal
se)){conte
nt=content
.replace(/
(\s)?mce\_
[a-z_]+\=[
^\s>]+(\s|
\>)/i,'');
content=in
st.fullpag
eTopConten
t+content+
"\n</body>
\n</html>"
}break;cas
e"submit_c
ontent":if
(inst.full
pageTopCon
tent&&tiny
MCE.getPar
am("fullpa
ge_hide_in
_source_vi
ew",false)
)content=i
nst.fullpa
geTopConte
nt+content
+"\n</body
>\n</html>
";break}re
turn conte
nt},_addTo
Head:funct
ion(inst){
var doc=in
st.getDoc(
);var head
=doc.getEl
ementsByTa
gName("hea
d")[0];var
body=doc.
body;var h
=inst.full
pageTopCon
tent;var e
=doc.creat
eElement("
body");var
nl,i,le,t
mp;h=h.rep
lace(/(\r|
\n)/gi,'')
;h=h.repla
ce(/<\?[^\
>]*\>/gi,'
');h=h.rep
lace(/<\/?
(!DOCTYPE|
head|html)
[^\>]*\>/g
i,'');h=h.
replace(/<
script(.*?
)<\/script
>/gi,'');h
=h.replace
(/<title(.
*?)<\/titl
e>/gi,'');
h=h.replac
e(/<(meta|
base)[^>]*
>/gi,'');h
=h.replace
(/<link([^
>]*)\/>/gi
,'<pre mce
_type="lin
k" $1></pr
e>');h=h.r
eplace(/<b
ody/gi,'<d
iv mce_typ
e="body"')
;h+='</div
>';e.inner
HTML=h;bod
y.vLink=bo
dy.aLink=b
ody.link=b
ody.text='
';body.sty
le.cssText
='';nl=hea
d.getEleme
ntsByTagNa
me('link')
;for(i=0;i
<nl.length
;i++){if(t
inyMCE.get
Attrib(nl[
i],'mce_he
ad')=="tru
e")nl[i].p
arentNode.
removeChil
d(nl[i])}n
l=e.getEle
mentsByTag
Name('pre'
);for(i=0;
i<nl.lengt
h;i++){tmp
=tinyMCE.g
etAttrib(n
l[i],'medi
a');if(tin
yMCE.getAt
trib(nl[i]
,'mce_type
')=="link"
&&(tmp==""
||tmp=="sc
reen"||tmp
=="all")&&
tinyMCE.ge
tAttrib(nl
[i],'rel')
=="stylesh
eet"){le=d
oc.createE
lement("li
nk");le.re
l="stylesh
eet";le.hr
ef=tinyMCE
.getAttrib
(nl[i],'hr
ef');le.se
tAttribute
("mce_head
","true");
head.appen
dChild(le)
}}nl=e.get
ElementsBy
TagName('d
iv');if(nl
.length>0)
{body.styl
e.cssText=
tinyMCE.ge
tAttrib(nl
[0],'style
');if((tmp
=tinyMCE.g
etAttrib(n
l[0],'left
margin'))!
=''&&body.
style.marg
inLeft==''
)body.styl
e.marginLe
ft=tmp+"px
";if((tmp=
tinyMCE.ge
tAttrib(nl
[0],'right
margin'))!
=''&&body.
style.marg
inRight=='
')body.sty
le.marginR
ight=tmp+"
px";if((tm
p=tinyMCE.
getAttrib(
nl[0],'top
margin'))!
=''&&body.
style.marg
inTop=='')
body.style
.marginTop
=tmp+"px";
if((tmp=ti
nyMCE.getA
ttrib(nl[0
],'bottomm
argin'))!=
''&&body.s
tyle.margi
nBottom=='
')body.sty
le.marginB
ottom=tmp+
"px";body.
dir=tinyMC
E.getAttri
b(nl[0],'d
ir');body.
vLink=tiny
MCE.getAtt
rib(nl[0],
'vlink');b
ody.aLink=
tinyMCE.ge
tAttrib(nl
[0],'alink
');body.li
nk=tinyMCE
.getAttrib
(nl[0],'li
nk');body.
text=tinyM
CE.getAttr
ib(nl[0],'
text');if(
(tmp=tinyM
CE.getAttr
ib(nl[0],'
background
'))!='')bo
dy.style.b
ackgroundI
mage="url(
'"+tmp+"')
";if((tmp=
tinyMCE.ge
tAttrib(nl
[0],'bgcol
or'))!='')
body.style
.backgroun
dColor=tmp
}}};tinyMC
E.addPlugi
n("fullpag
e",TinyMCE
_FullPageP
lugin);
|
|
1 |
|
(function(
){tinymce.
create('ti
nymce.plug
ins.FullPa
gePlugin',
{init:func
tion(ed,ur
l){var t=t
his;t.edit
or=ed;ed.a
ddCommand(
'mceFullPa
geProperti
es',functi
on(){ed.wi
ndowManage
r.open({fi
le:url+'/f
ullpage.ht
m',width:4
30+parseIn
t(ed.getLa
ng('fullpa
ge.delta_w
idth',0)),
height:495
+parseInt(
ed.getLang
('fullpage
.delta_hei
ght',0)),i
nline:1},{
plugin_url
:url,head_
html:t.hea
d});});ed.
addButton(
'fullpage'
,{title:'f
ullpage.de
sc',cmd:'m
ceFullPage
Properties
'});ed.onB
eforeSetCo
ntent.add(
t._setCont
ent,t);ed.
onSetConte
nt.add(t._
setBodyAtt
ribs,t);ed
.onGetCont
ent.add(t.
_getConten
t,t);},get
Info:funct
ion(){retu
rn{longnam
e:'Fullpag
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/fullp
age',versi
on:tinymce
.majorVers
ion+"."+ti
nymce.mino
rVersion};
},_setBody
Attribs:fu
nction(ed,
o){var bda
ttr,i,len,
kv,k,v,t,a
ttr=this.h
ead.match(
/body(.*?)
>/i);if(at
tr&&attr[1
]){bdattr=
attr[1].ma
tch(/\s*(\
w+\s*=\s*"
.*?"|\w+\s
*=\s*'.*?'
|\w+\s*=\s
*\w+|\w+)\
s*/g);for(
i=0,len=bd
attr.lengt
h;i<len;i+
+){kv=bdat
tr[i].spli
t('=');k=k
v[0].repla
ce(/\s/,''
);v=kv[1];
if(v){v=v.
replace(/^
\s+/,'').r
eplace(/\s
+$/,'');t=
v.match(/^
["'](.*)["
']$/);if(t
)v=t[1];}e
lse v=k;ed
.dom.setAt
trib(ed.ge
tBody(),'s
tyle',v);}
}},_create
Serializer
:function(
){return n
ew tinymce
.dom.Seria
lizer({dom
:this.edit
or.dom,app
ly_source_
formatting
:true});},
_setConten
t:function
(ed,o){var
t=this,sp
,ep,c=o.co
ntent;c=c.
replace(/<
(\/?)BODY/
gi,'<$1bod
y');sp=c.i
ndexOf('<b
ody');if(s
p!=-1){sp=
c.indexOf(
'>',sp);t.
head=c.sub
string(0,s
p+1);ep=c.
indexOf('<
/body',sp)
;if(ep==-1
)ep=c.inde
xOf('</bod
y',ep);o.c
ontent=c.s
ubstring(s
p+1,ep);t.
foot=c.sub
string(ep)
;function
low(s){ret
urn s.repl
ace(/<\/?[
A-Z]+/g,fu
nction(a){
return a.t
oLowerCase
();})};t.h
ead=low(t.
head);t.fo
ot=low(t.f
oot);}else
{t.head='<
!DOCTYPE h
tml PUBLIC
"-//W3C//
DTD XHTML
1.0 Transi
tional//EN
" "http://
www.w3.org
/TR/xhtml1
/DTD/xhtml
1-transiti
onal.dtd">
';t.head+=
'\n<html>\
n<head>\n<
title>Unti
tled docum
ent</title
>\n</head>
\n<body>\n
';t.foot='
\n</body>\
n</html>';
}},_getCon
tent:funct
ion(ed,o){
var t=this
;o.content
=tinymce.t
rim(t.head
)+'\n'+tin
ymce.trim(
o.content)
+'\n'+tiny
mce.trim(t
.foot);}})
;tinymce.P
luginManag
er.add('fu
llpage',ti
nymce.plug
ins.FullPa
gePlugin);
})();
|