1 |
|
tiny
MCE
.
i
m
p
o
rt
P
lugin
Lang
u
a
ge
Pa
ck
('insertda
tetime
')
;
v
a
r
T
in
yMCE
_
InsertDate
T
ime
P
l
ug
in
={
getInfo:fu
nction(){r
eturn{long
name:'Inse
rt
date/time'
,author:'M
oxiecode
Systems
AB',author
url:'http:
//tinymce.
moxiecode.
com',infou
rl:'http:/
/wiki.moxi
ecode.com/
index.php/
TinyMCE:Pl
ugins/inse
rtdatetime
',version:
tiny
MCE
.majorVers
ion+"."+ti
ny
MCE
.minorVers
ion}
},
getControl
HTML:funct
ion(cn){sw
itch(cn){c
ase"insert
date":retu
rn
tinyMCE.ge
tButtonHTM
L(cn,'lang
_insertdat
e
_
desc','{$p
luginurl}/
ima
ge
s/insertda
te.gif','m
ceInser
tDate
');case"in
sertt
ime
"
:
ret
u
r
n
ti
nyMCE.getB
utt
on
HTML
(
cn,'lang_i
nserttime_
d
esc'
,
'{$pluginu
rl}/images
/inserttim
e.gi
f
','
m
ceInser
t
Time'
)
}retu
r
n""},
e
xecComman
d
:func
t
i
on(
editor
_id,elemen
t,command,
user_inter
face,value
){
function
addZeros(v
alue,len){
value=""+v
alue;if(va
lue.length
<len){for(
var
i=0;i<(len
-value.len
gth);i++)v
alue="0"+v
alue
}return
value
}
function
getDateTim
e(d,fmt){
fmt=fmt.re
place("%D"
,"%m/%d/%y
");fmt=fmt
.replace("
%r","%I:%M
:%S
%p");fmt=f
mt.replace
("%Y",""+d
.getFullYe
ar());fmt=
fmt.replac
e("%y",""+
d.getYear(
));fmt=fmt
.replace("
%m",addZer
os(d.getMo
nth()+1,2)
);fmt=fmt.
replace("%
d",addZero
s(d.getDat
e(),2));fm
t=fmt.repl
ace("%H","
"+addZeros
(d.getHour
s(),2));fm
t=fmt.repl
ace("%M","
"+addZeros
(d.getMinu
tes(),2));
fmt=fmt.re
place("%S"
,""+addZer
os(d.getSe
conds(),2)
);fmt=fmt.
replace("%
I",""+((d.
getHours()
+11)%12+1)
);fmt=fmt.
replace("%
p",""+(d.g
etHours()<
12?"AM":"P
M"));fmt=f
mt.replace
("%B",""+
tinyMCE
.getLang("
lang_
insert
time
_
months_lon
g")
[d.getMont
h()]);fmt=
fmt.replac
e("%b",""+
tinyMCE
.getLang("
lang_
insert
time
_
months_sho
rt")
[d.getMont
h()]);fmt=
fmt.replac
e("%A",""+
tinyMCE
.getLang("
lang_
insert
time
_
day_long")
[d.getDay(
)]);fmt=fm
t.replace(
"%a",""+
tinyMCE
.getLang("
lang_
insert
time
_
day_short"
)
[d.getDay(
)]);fmt=fm
t.replace(
"%%","%");
return
fmt
}
switch(com
mand
)
{case"mceI
nsertDate"
:
tiny
MCE.execIn
stanceComm
and(editor
_id,'
mce
InsertCont
ent',false
,getDateTi
me(new
Date(),tin
yMCE
.
get
P
aram("p
lugin
_insertdat
e_dateForm
at",tiny
M
CE.getL
an
g('l
a
n
g
_insertdat
e_def_fmt'
))));retur
n
true;case"
mceIns
er
tTime":tin
yMCE
.
execInst
a
nceCommand
(e
d
itor_i
d
,'mceInser
tContent',
false,getD
ateTime(ne
w
Date
(
),tinyMCE.
getParam("
plugin_
insertdate
_
time
Format"
,tiny
MCE.getLan
g('lang_in
sertti
m
e
_def_fmt')
)));return
true}retur
n
false}};ti
nyMCE
.
addP
lugin
("in
s
ertdatetim
e",TinyMCE
_
InsertDate
Time
Plugin
);
|
|
1 |
|
(function(
){
tiny
mce
.
create('t
i
ny
m
ce.
p
lugins.Ins
ertDateTim
e',{init:f
uncti
o
n(ed,url){
va
r
t
=this;t.ed
itor=ed;ed
.addComman
d('mceInse
rtDate',fu
nction(){v
ar
str=t._get
DateTime(n
ew
Date(),ed.
get
P
aram("p
lugin
_insertdat
e_dateForm
at",ed.get
Lang
('insertda
tetime.dat
e_fmt')));
ed.execCom
mand('mceI
nsertConte
nt',false,
str);});ed
.addComman
d('mceInse
rtTime',f
u
nction(){v
ar
str=t._get
DateTime(n
ew
D
a
te(),ed.
ge
t
Pa
ram("plugi
n_insertda
te_timeFor
mat",ed.ge
tLang
('insertda
tetime
.time_fmt
')
))
;
ed.execCom
m
a
nd('mceIns
e
r
tContent',
false,str)
;});ed.add
Button('
in
sertdate',
{title:'in
sertdateti
me.insertd
ate
_
desc',cmd:
'mce
InsertDate
'});ed.add
Button('in
sertt
ime
',{tit
l
e:'
in
sertdateti
me.insertt
ime_desc',
cmd:'mceIn
sertTime'}
);},
getInfo:fu
nction(){r
eturn{long
name:'Inse
rt
date/time'
,author:'M
oxiecode
Systems
AB',author
url:'http:
//tinymce.
moxiecode.
com',infou
rl:'http:/
/wiki.moxi
ecode.com/
index.php/
TinyMCE:Pl
ugins/inse
rtdatetime
',version:
tiny
mce
.majorVers
ion+"."+ti
ny
mce
.minorVers
ion}
;
},
_
ge
tDate
T
ime
:
f
u
n
c
ti
on
(
d
,
f
m
t
)
{va
r
e
d
=
t
h
i
s.
editor
;
function
addZeros(v
alue,len){
value=""+v
alue;if(va
lue.length
<len){for(
var
i=0;i<(len
-value.len
gth);i++)v
alue="0"+v
alue
;
}return
value
;
}
;
fmt=fmt.re
place("%D"
,"%m/%d/%y
");fmt=fmt
.replace("
%r","%I:%M
:%S
%p");fmt=f
mt.replace
("%Y",""+d
.getFullYe
ar());fmt=
fmt.replac
e("%y",""+
d.getYear(
));fmt=fmt
.replace("
%m",addZer
os(d.getMo
nth()+1,2)
);fmt=fmt.
replace("%
d",addZero
s(d.getDat
e(),2));fm
t=fmt.repl
ace("%H","
"+addZeros
(d.getHour
s(),2));fm
t=fmt.repl
ace("%M","
"+addZeros
(d.getMinu
tes(),2));
fmt=fmt.re
place("%S"
,""+addZer
os(d.getSe
conds(),2)
);fmt=fmt.
replace("%
I",""+((d.
getHours()
+11)%12+1)
);fmt=fmt.
replace("%
p",""+(d.g
etHours()<
12?"AM":"P
M"));fmt=f
mt.replace
("%B",""+
ed
.getLang("
insert
date
time
.
months_lon
g")
.split(','
)
[d.getMont
h()]);fmt=
fmt.replac
e("%b",""+
ed
.getLang("
insert
date
time
.
months_sho
rt")
.split(','
)
[d.getMont
h()]);fmt=
fmt.replac
e("%A",""+
ed
.getLang("
insert
date
time
.
day_long")
.split(','
)
[d.getDay(
)]);fmt=fm
t.replace(
"%a",""+
ed
.getLang("
insert
date
time
.
day_short"
)
.split(','
)
[d.getDay(
)]);fmt=fm
t.replace(
"%%","%");
return
fmt
;}
}
)
;
tiny
mce
.
P
lugin
M
an
a
g
er
.
a
d
d
(
'
insertdate
time
'
,tiny
m
c
e
.
p
lugin
s
.
InsertDate
Time
);})(
);
|