1 /* Import plugin specific language pack */
\r
2 tinyMCE.importPluginLanguagePack('insertdatetime', 'cs,el,en,fr_ca,it,ko,sv,zh_cn,fa,fr,de,pl,pt_br,nl,da,he,nb,ru,ru_KOI8-R,ru_UTF-8,nn,fi,es,cy,is,pl');
\r
4 function TinyMCE_insertdatetime_getInfo() {
\r
6 longname : 'Insert date/time',
\r
7 author : 'Moxiecode Systems',
\r
8 authorurl : 'http://tinymce.moxiecode.com',
\r
9 infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_insertdatetime.html',
\r
10 version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
\r
15 * Returns the HTML contents of the insertdate, inserttime controls.
\r
17 function TinyMCE_insertdatetime_getControlHTML(control_name) {
\r
18 switch (control_name) {
\r
20 var cmd = 'tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceInsertDate\');return false;';
\r
21 return '<a href="javascript:' + cmd + '" onclick="' + cmd + '" target="_self" 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>';
\r
24 var cmd = 'tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceInsertTime\');return false;';
\r
25 return '<a href="javascript:' + cmd + '" onclick="' + cmd + '" target="_self" 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>';
\r
32 * Executes the mceInsertDate command.
\r
34 function TinyMCE_insertdatetime_execCommand(editor_id, element, command, user_interface, value) {
\r
35 /* Adds zeros infront of value */
\r
36 function addZeros(value, len) {
\r
39 if (value.length < len) {
\r
40 for (var i=0; i<(len-value.length); i++)
\r
41 value = "0" + value;
\r
47 /* Returns the date object in the specified format */
\r
48 function getDateTime(date, format) {
\r
49 format = tinyMCE.regexpReplace(format, "%D", "%m/%d/%y");
\r
50 format = tinyMCE.regexpReplace(format, "%r", "%I:%M:%S %p");
\r
51 format = tinyMCE.regexpReplace(format, "%Y", "" + date.getFullYear());
\r
52 format = tinyMCE.regexpReplace(format, "%y", "" + date.getYear());
\r
53 format = tinyMCE.regexpReplace(format, "%m", addZeros(date.getMonth()+1, 2));
\r
54 format = tinyMCE.regexpReplace(format, "%d", addZeros(date.getDate(), 2));
\r
55 format = tinyMCE.regexpReplace(format, "%H", "" + addZeros(date.getHours(), 2));
\r
56 format = tinyMCE.regexpReplace(format, "%M", "" + addZeros(date.getMinutes(), 2));
\r
57 format = tinyMCE.regexpReplace(format, "%S", "" + addZeros(date.getSeconds(), 2));
\r
58 format = tinyMCE.regexpReplace(format, "%I", "" + ((date.getHours() + 11) % 12 + 1));
\r
59 format = tinyMCE.regexpReplace(format, "%p", "" + (date.getHours() < 12 ? "AM" : "PM"));
\r
60 format = tinyMCE.regexpReplace(format, "%B", "" + tinyMCE.getLang("lang_inserttime_months_long")[date.getMonth()]);
\r
61 format = tinyMCE.regexpReplace(format, "%b", "" + tinyMCE.getLang("lang_inserttime_months_short")[date.getMonth()]);
\r
62 format = tinyMCE.regexpReplace(format, "%A", "" + tinyMCE.getLang("lang_inserttime_day_long")[date.getDay()]);
\r
63 format = tinyMCE.regexpReplace(format, "%a", "" + tinyMCE.getLang("lang_inserttime_day_short")[date.getDay()]);
\r
64 format = tinyMCE.regexpReplace(format, "%%", "%");
\r
71 case "mceInsertDate":
\r
72 tinyMCE.execInstanceCommand(editor_id, 'mceInsertContent', false, getDateTime(new Date(), tinyMCE.getParam("plugin_insertdate_dateFormat", tinyMCE.getLang('lang_insertdate_def_fmt'))));
\r
75 case "mceInsertTime":
\r
76 tinyMCE.execInstanceCommand(editor_id, 'mceInsertContent', false, getDateTime(new Date(), tinyMCE.getParam("plugin_insertdate_timeFormat", tinyMCE.getLang('lang_inserttime_def_fmt'))));
\r
80 // Pass to next handler in chain
\r