2 * $Id: editor_plugin_src.js 126 2006-10-22 16:19:55Z spocke $
5 * @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved.
8 /* Import plugin specific language pack */
9 tinyMCE
.importPluginLanguagePack('insertdatetime');
11 var TinyMCE_InsertDateTimePlugin
= {
12 getInfo : function() {
14 longname
: 'Insert date/time',
15 author
: 'Moxiecode Systems AB',
16 authorurl
: 'http://tinymce.moxiecode.com',
17 infourl
: 'http://tinymce.moxiecode.com/tinymce/docs/plugin_insertdatetime.html',
18 version
: tinyMCE
.majorVersion
+ "." + tinyMCE
.minorVersion
23 * Returns the HTML contents of the insertdate, inserttime controls.
25 getControlHTML : function(cn
) {
28 return tinyMCE
.getButtonHTML(cn
, 'lang_insertdate_desc', '{$pluginurl}/images/insertdate.gif', 'mceInsertDate');
31 return tinyMCE
.getButtonHTML(cn
, 'lang_inserttime_desc', '{$pluginurl}/images/inserttime.gif', 'mceInsertTime');
38 * Executes the mceInsertDate command.
40 execCommand : function(editor_id
, element
, command
, user_interface
, value
) {
41 /* Adds zeros infront of value */
42 function addZeros(value
, len
) {
45 if (value
.length
< len
) {
46 for (var i
=0; i
<(len
-value
.length
); i
++)
53 function getDateTime(d
, fmt
) {
54 fmt
= fmt
.replace("%D", "%m/%d/%y");
55 fmt
= fmt
.replace("%r", "%I:%M:%S %p");
56 fmt
= fmt
.replace("%Y", "" + d
.getFullYear());
57 fmt
= fmt
.replace("%y", "" + d
.getYear());
58 fmt
= fmt
.replace("%m", addZeros(d
.getMonth()+1, 2));
59 fmt
= fmt
.replace("%d", addZeros(d
.getDate(), 2));
60 fmt
= fmt
.replace("%H", "" + addZeros(d
.getHours(), 2));
61 fmt
= fmt
.replace("%M", "" + addZeros(d
.getMinutes(), 2));
62 fmt
= fmt
.replace("%S", "" + addZeros(d
.getSeconds(), 2));
63 fmt
= fmt
.replace("%I", "" + ((d
.getHours() + 11) % 12 + 1));
64 fmt
= fmt
.replace("%p", "" + (d
.getHours() < 12 ? "AM" : "PM"));
65 fmt
= fmt
.replace("%B", "" + tinyMCE
.getLang("lang_inserttime_months_long")[d
.getMonth()]);
66 fmt
= fmt
.replace("%b", "" + tinyMCE
.getLang("lang_inserttime_months_short")[d
.getMonth()]);
67 fmt
= fmt
.replace("%A", "" + tinyMCE
.getLang("lang_inserttime_day_long")[d
.getDay()]);
68 fmt
= fmt
.replace("%a", "" + tinyMCE
.getLang("lang_inserttime_day_short")[d
.getDay()]);
69 fmt
= fmt
.replace("%%", "%");
77 tinyMCE
.execInstanceCommand(editor_id
, 'mceInsertContent', false, getDateTime(new Date(), tinyMCE
.getParam("plugin_insertdate_dateFormat", tinyMCE
.getLang('lang_insertdate_def_fmt'))));
81 tinyMCE
.execInstanceCommand(editor_id
, 'mceInsertContent', false, getDateTime(new Date(), tinyMCE
.getParam("plugin_insertdate_timeFormat", tinyMCE
.getLang('lang_inserttime_def_fmt'))));
85 // Pass to next handler in chain
90 tinyMCE
.addPlugin("insertdatetime", TinyMCE_InsertDateTimePlugin
);