1 /* Import plugin specific language pack */
2 tinyMCE.importPluginLanguagePack('insertdatetime', 'cs,el,en,fr_ca,it,ko,sv,zh_cn,fa,fr,de,pl,pt_br,nl');
4 function TinyMCE_insertdatetime_getInfo() {
6 longname : 'Insert date/time',
7 author : 'Moxiecode Systems',
8 authorurl : 'http://tinymce.moxiecode.com',
9 infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_insertdatetime.html',
10 version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
15 * Returns the HTML contents of the insertdate, inserttime controls.
17 function TinyMCE_insertdatetime_getControlHTML(control_name) {
18 switch (control_name) {
20 return '<a href="javascript:tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceInsertDate\');" onmousedown="return false;"><img id="{$editor_id}_insertdate" src="{$pluginurl}/images/insertdate.gif" title="{$lang_insertdate_desc}" width="20" height="20" class="mceButtonNormal" onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');" onmouseout="tinyMCE.restoreClass(this);" onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');" /></a>';
23 return '<a href="javascript:tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceInsertTime\');" onmousedown="return false;"><img id="{$editor_id}_inserttime" src="{$pluginurl}/images/inserttime.gif" title="{$lang_inserttime_desc}" width="20" height="20" class="mceButtonNormal" onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');" onmouseout="tinyMCE.restoreClass(this);" onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');" /></a>';
30 * Executes the mceInsertDate command.
32 function TinyMCE_insertdatetime_execCommand(editor_id, element, command, user_interface, value) {
33 /* Adds zeros infront of value */
34 function addZeros(value, len) {
37 if (value.length < len) {
38 for (var i=0; i<(len-value.length); i++)
45 /* Returns the date object in the specified format */
46 function getDateTime(date, format) {
47 format = tinyMCE.regexpReplace(format, "%D", "%m/%d/%y");
48 format = tinyMCE.regexpReplace(format, "%r", "%I:%M:%S %p");
49 format = tinyMCE.regexpReplace(format, "%Y", "" + date.getFullYear());
50 format = tinyMCE.regexpReplace(format, "%y", "" + date.getYear());
51 format = tinyMCE.regexpReplace(format, "%m", addZeros(date.getMonth()+1, 2));
52 format = tinyMCE.regexpReplace(format, "%d", addZeros(date.getDate(), 2));
53 format = tinyMCE.regexpReplace(format, "%H", "" + addZeros(date.getHours(), 2));
54 format = tinyMCE.regexpReplace(format, "%M", "" + addZeros(date.getMinutes(), 2));
55 format = tinyMCE.regexpReplace(format, "%S", "" + addZeros(date.getSeconds(), 2));
56 format = tinyMCE.regexpReplace(format, "%I", "" + (date.getHours() < 12 ? (date.getHours()+1) : 24-date.getHours()));
57 format = tinyMCE.regexpReplace(format, "%p", "" + (date.getHours() < 12 ? "AM" : "PM"));
58 format = tinyMCE.regexpReplace(format, "%B", "" + tinyMCE.getLang("lang_inserttime_months_long")[date.getMonth()]);
59 format = tinyMCE.regexpReplace(format, "%b", "" + tinyMCE.getLang("lang_inserttime_months_short")[date.getMonth()]);
60 format = tinyMCE.regexpReplace(format, "%A", "" + tinyMCE.getLang("lang_inserttime_day_long")[date.getDay()]);
61 format = tinyMCE.regexpReplace(format, "%a", "" + tinyMCE.getLang("lang_inserttime_day_short")[date.getDay()]);
62 format = tinyMCE.regexpReplace(format, "%%", "%");
70 tinyMCE.execInstanceCommand(editor_id, 'mceInsertContent', false, getDateTime(new Date(), tinyMCE.getParam("plugin_insertdate_dateFormat", tinyMCE.getLang('lang_insertdate_def_fmt'))));
74 tinyMCE.execInstanceCommand(editor_id, 'mceInsertContent', false, getDateTime(new Date(), tinyMCE.getParam("plugin_insertdate_timeFormat", tinyMCE.getLang('lang_inserttime_def_fmt'))));
78 // Pass to next handler in chain