No regular expressions were active.
1 |
|
/**
|
|
1 |
|
/**
|
2 |
|
*
$Id:
editor_plu
gin_src.js
20
1
200
7
-0
2-
1
2
1
5:5
6:
56
Z
spocke
$
|
|
2 |
|
*
$Id:
editor_plu
gin_src.js
5
20
200
8
-0
1
-07
1
6:
30:32
Z
spocke
$
|
3 |
|
*
|
|
3 |
|
*
|
4 |
|
* @author
Moxiecode
|
|
4 |
|
* @author
Moxiecode
|
5 |
|
*
@copyright
Copyright
©
2004-200
7
,
Moxiecode
Systems
AB,
All
rights
reserved.
|
|
5 |
|
*
@copyright
Copyright
©
2004-200
8
,
Moxiecode
Systems
AB,
All
rights
reserved.
|
6 |
|
*/
|
|
6 |
|
*/
|
7 |
|
|
|
7 |
|
|
8 |
|
/* Import
plugin spe
cific lang
uage pack
*/
|
|
8 |
|
(function(
) {
|
9 |
|
tiny
MCE
.
i
m
p
ortP
lugin
LanguagePa
ck('i
nsert
d
ate
t
ime'
);
|
|
9 |
|
tiny
mce
.
create('t
i
ny
m
ce.
p
lugin
s.I
nsert
D
ate
T
ime'
,
{
|
|
|
10 |
|
in
it : funct
ion(ed, ur
l) {
|
|
|
11 |
|
var t =
this;
|
|
|
12 |
|
|
|
|
13 |
|
t.editor
= ed;
|
|
|
14 |
|
|
|
|
15 |
|
ed.addCo
mmand('mce
InsertDate
', functio
n() {
|
|
|
16 |
|
var
str = t._g
etDateTime
(new Date(
), ed.getP
aram("plug
in_insertd
ate_dateFo
rmat", ed.
getLang('i
nsertdatet
ime.date_f
mt')));
|
|
|
17 |
|
|
|
|
18 |
|
ed.e
xecCommand
('mceInser
tContent',
false, st
r);
|
|
|
19 |
|
});
|
|
|
20 |
|
|
|
|
21 |
|
ed.addCo
mmand('mce
InsertTime
', functio
n() {
|
|
|
22 |
|
var
str = t._g
etDateTime
(new Date(
), ed.getP
aram("plug
in_insertd
ate_timeFo
rmat", ed.
getLang('i
nsertdatet
ime.time_f
mt')));
|
|
|
23 |
|
|
|
|
24 |
|
ed.e
xecCommand
('mceInser
tContent',
false, st
r);
|
|
|
25 |
|
});
|
|
|
26 |
|
|
|
|
27 |
|
ed.addBu
tton('inse
rtdate', {
title : 'i
nsertdatet
ime.insert
date_desc'
, cmd : 'm
ceInsertDa
te'});
|
|
|
28 |
|
ed.addBu
tton('inse
rttime', {
title : 'i
nsertdatet
ime.insert
time_desc'
, cmd : 'm
ceInsertTi
me'});
|
|
|
29 |
|
},
|
10 |
|
|
|
30 |
|
|
11 |
|
var TinyMC
E_InsertDa
teTimePlug
in = {
|
|
|
12 |
|
getInf
o : functi
on() {
|
|
31 |
|
ge
tInfo : fu
nction() {
|
13 |
|
re
turn {
|
|
32 |
|
return {
|
14 |
|
longname
: 'Insert
date/time
',
|
|
33 |
|
long
name : 'In
sert date/
time',
|
15 |
|
author :
'Moxiecod
e Systems
AB',
|
|
34 |
|
auth
or : 'Moxi
ecode Syst
ems AB',
|
16 |
|
authorur
l : 'http:
//tinymce.
moxiecode.
com',
|
|
35 |
|
auth
orurl : 'h
ttp://tiny
mce.moxiec
ode.com',
|
17 |
|
infourl
: 'http://
wiki.moxie
code.com/i
ndex.php/T
inyMCE:Plu
gins/inser
tdatetime'
,
|
|
36 |
|
info
url : 'htt
p://wiki.m
oxiecode.c
om/index.p
hp/TinyMCE
:Plugins/i
nsertdatet
ime',
|
18 |
|
version
:
tiny
MCE
.majorVers
ion
+
"."
+
tiny
MCE
.minorVers
ion
|
|
37 |
|
version
:
tiny
mce
.majorVers
ion
+
"."
+
tiny
mce
.minorVers
ion
|
19 |
|
};
|
|
38 |
|
};
|
20 |
|
},
|
|
39 |
|
},
|
21 |
|
|
|
40 |
|
|
22 |
|
/**
|
|
41 |
|
//
Private m
ethods
|
23 |
|
* Ret
urns the H
TML conten
ts of the
insertdate
, insertti
me control
s.
|
|
|
24 |
|
*/
|
|
|
25 |
|
getCon
trolHTML :
function(
cn) {
|
|
|
26 |
|
sw
itch (cn)
{
|
|
|
27 |
|
case "in
sertdate":
|
|
|
28 |
|
retu
rn tinyMCE
.getButton
HTML(cn, '
lang_inser
tdate_desc
', '{$plug
inurl}/ima
ges/insert
date.gif',
'mceInser
tDate');
|
|
|
29 |
|
|
|
|
30 |
|
case "in
serttime":
|
|
|
31 |
|
retu
rn tinyMCE
.getButton
HTML(cn, '
lang_inser
ttime_desc
', '{$plug
inurl}/ima
ges/insert
time.gif',
'mceInser
tTime');
|
|
|
32 |
|
}
|
|
|
33 |
|
|
|
42 |
|
|
34 |
|
re
turn "";
|
|
43 |
|
_g
etDateTime
: functio
n(d, fmt)
{
|
35 |
|
},
|
|
44 |
|
var ed =
this.edit
or;
|
36 |
|
|
|
45 |
|
|
37 |
|
/**
|
|
|
38 |
|
* Exe
cutes the
mceInsertD
ate comman
d.
|
|
|
39 |
|
*/
|
|
|
40 |
|
execCo
mmand : fu
nction(edi
tor_id, el
ement, com
mand, user
_interface
, value) {
|
|
|
41 |
|
/*
Adds zero
s infront
of value *
/
|
|
|
42 |
|
fu
nction add
Zeros(valu
e, len) {
|
|
46 |
|
function
addZeros(
value, len
) {
|
43 |
|
value =
"" + value
;
|
|
47 |
|
valu
e = "" + v
alue;
|
44 |
|
|
|
48 |
|
|
45 |
|
if (valu
e.length <
len) {
|
|
49 |
|
if (
value.leng
th < len)
{
|
46 |
|
for
(var i=0;
i<(len-val
ue.length)
; i++)
|
|
50 |
|
for (var i
=0; i<(len
-value.len
gth); i++)
|
47 |
|
value = "0
" + value;
|
|
51 |
|
value
= "0" + va
lue;
|
48 |
|
}
|
|
52 |
|
}
|
49 |
|
|
|
53 |
|
|
50 |
|
return v
alue;
|
|
54 |
|
retu
rn value;
|
51 |
|
}
|
|
55 |
|
}
;
|
52 |
|
|
|
56 |
|
|
53 |
|
fu
nction get
DateTime(d
, fmt) {
|
|
|
54 |
|
fmt = fm
t.replace(
"%D", "%m/
%d/%y");
|
|
57 |
|
fmt = fm
t.replace(
"%D", "%m/
%d/%y");
|
55 |
|
fmt = fm
t.replace(
"%r", "%I:
%M:%S %p")
;
|
|
58 |
|
fmt = fm
t.replace(
"%r", "%I:
%M:%S %p")
;
|
56 |
|
fmt = fm
t.replace(
"%Y", "" +
d.getFull
Year());
|
|
59 |
|
fmt = fm
t.replace(
"%Y", "" +
d.getFull
Year());
|
57 |
|
fmt = fm
t.replace(
"%y", "" +
d.getYear
());
|
|
60 |
|
fmt = fm
t.replace(
"%y", "" +
d.getYear
());
|
58 |
|
fmt = fm
t.replace(
"%m", addZ
eros(d.get
Month()+1,
2));
|
|
61 |
|
fmt = fm
t.replace(
"%m", addZ
eros(d.get
Month()+1,
2));
|
59 |
|
fmt = fm
t.replace(
"%d", addZ
eros(d.get
Date(), 2)
);
|
|
62 |
|
fmt = fm
t.replace(
"%d", addZ
eros(d.get
Date(), 2)
);
|
60 |
|
fmt = fm
t.replace(
"%H", "" +
addZeros(
d.getHours
(), 2));
|
|
63 |
|
fmt = fm
t.replace(
"%H", "" +
addZeros(
d.getHours
(), 2));
|
61 |
|
fmt = fm
t.replace(
"%M", "" +
addZeros(
d.getMinut
es(), 2));
|
|
64 |
|
fmt = fm
t.replace(
"%M", "" +
addZeros(
d.getMinut
es(), 2));
|
62 |
|
fmt = fm
t.replace(
"%S", "" +
addZeros(
d.getSecon
ds(), 2));
|
|
65 |
|
fmt = fm
t.replace(
"%S", "" +
addZeros(
d.getSecon
ds(), 2));
|
63 |
|
fmt = fm
t.replace(
"%I", "" +
((d.getHo
urs() + 11
) % 12 + 1
));
|
|
66 |
|
fmt = fm
t.replace(
"%I", "" +
((d.getHo
urs() + 11
) % 12 + 1
));
|
64 |
|
fmt = fm
t.replace(
"%p", "" +
(d.getHou
rs() < 12
? "AM" : "
PM"));
|
|
67 |
|
fmt = fm
t.replace(
"%p", "" +
(d.getHou
rs() < 12
? "AM" : "
PM"));
|
65 |
|
fmt
=
fmt.replac
e("%B",
""
+
tinyMCE
.getLang("
lang_
insert
time
_
months_lon
g")
[d.getMont
h()]);
|
|
68 |
|
fmt
=
fmt.replac
e("%B",
""
+
ed
.getLang("
insert
date
time
.
months_lon
g")
.split(','
)
[d.getMont
h()]);
|
66 |
|
fmt
=
fmt.replac
e("%b",
""
+
tinyMCE
.getLang("
lang_
insert
time
_
months_sho
rt")
[d.getMont
h()]);
|
|
69 |
|
fmt
=
fmt.replac
e("%b",
""
+
ed
.getLang("
insert
date
time
.
months_sho
rt")
.split(','
)
[d.getMont
h()]);
|
67 |
|
fmt
=
fmt.replac
e("%A",
""
+
tinyMCE
.getLang("
lang_
insert
time
_
day_long")
[d.getDay(
)]);
|
|
70 |
|
fmt
=
fmt.replac
e("%A",
""
+
ed
.getLang("
insert
date
time
.
day_long")
.split(','
)
[d.getDay(
)]);
|
68 |
|
fmt
=
fmt.replac
e("%a",
""
+
tinyMCE
.getLang("
lang_
insert
time
_
day_short"
)
[d.getDay(
)]);
|
|
71 |
|
fmt
=
fmt.replac
e("%a",
""
+
ed
.getLang("
insert
date
time
.
day_short"
)
.split(','
)
[d.getDay(
)]);
|
69 |
|
fmt = fm
t.replace(
"%%", "%")
;
|
|
72 |
|
fmt = fm
t.replace(
"%%", "%")
;
|
70 |
|
|
|
73 |
|
|
71 |
|
return f
mt;
|
|
74 |
|
return f
mt;
|
72 |
|
}
|
|
75 |
|
}
|
|
|
76 |
|
});
|
73 |
|
|
|
77 |
|
|
74 |
|
//
Handle co
mmands
|
|
78 |
|
// Reg
ister plug
in
|
75 |
|
sw
itch (comm
and) {
|
|
79 |
|
tiny
mce
.
Plugin
Manager.ad
d
(
'
insertdate
time
'
,
t
iny
mce.plugin
s.
InsertDate
Time
);
|
76 |
|
case "mc
eInsertDat
e":
|
|
80 |
|
})();
|
77 |
|
tiny
MCE.execIn
stanceComm
and(editor
_id, 'mceI
nsertConte
nt', false
, getDateT
ime(new Da
te(), tiny
MCE.getPar
am("plugin
_insertdat
e_dateForm
at", tinyM
CE.getLang
('lang_ins
ertdate_de
f_fmt'))))
;
|
|
|
78 |
|
retu
rn true;
|
|
|
79 |
|
|
|
|
80 |
|
case "mc
eInsertTim
e":
|
|
|
81 |
|
tiny
MCE.execIn
stanceComm
and(editor
_id, 'mceI
nsertConte
nt', false
, getDateT
ime(new Da
te(), tiny
MCE.getPar
am("plugin
_insertdat
e_timeForm
at", tinyM
CE.getLang
('lang_ins
erttime_de
f_fmt'))))
;
|
|
|
82 |
|
retu
rn true;
|
|
|
83 |
|
}
|
|
|
84 |
|
|
|
|
85 |
|
//
Pass to n
ext handle
r in chain
|
|
|
86 |
|
re
turn false
;
|
|
|
87 |
|
}
|
|
|
88 |
|
};
|
|
|
89 |
|
|
|
|
90 |
|
tiny
MCE
.
add
Plugin
(
"
insertdate
time
"
,
T
iny
MCE_
InsertDate
Time
Plugin
);
|
|
|