2 * $RCSfile: editor_plugin_src.js,v $
\r
4 * $Date: 2006/02/10 16:29:39 $
\r
7 * @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved.
\r
10 /* Import plugin specific language pack */
\r
11 tinyMCE.importPluginLanguagePack('insertdatetime', 'en,tr,cs,el,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
13 var TinyMCE_InsertDateTimePlugin = {
\r
14 getInfo : function() {
\r
16 longname : 'Insert date/time',
\r
17 author : 'Moxiecode Systems',
\r
18 authorurl : 'http://tinymce.moxiecode.com',
\r
19 infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_insertdatetime.html',
\r
20 version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
\r
25 * Returns the HTML contents of the insertdate, inserttime controls.
\r
27 getControlHTML : function(cn) {
\r
30 return tinyMCE.getButtonHTML(cn, 'lang_insertdate_desc', '{$pluginurl}/images/insertdate.gif', 'mceInsertDate');
\r
33 return tinyMCE.getButtonHTML(cn, 'lang_inserttime_desc', '{$pluginurl}/images/inserttime.gif', 'mceInsertTime');
\r
40 * Executes the mceInsertDate command.
\r
42 execCommand : function(editor_id, element, command, user_interface, value) {
\r
43 /* Adds zeros infront of value */
\r
44 function addZeros(value, len) {
\r
47 if (value.length < len) {
\r
48 for (var i=0; i<(len-value.length); i++)
\r
49 value = "0" + value;
\r
55 /* Returns the date object in the specified format */
\r
56 function getDateTime(date, format) {
\r
57 format = tinyMCE.regexpReplace(format, "%D", "%m/%d/%y");
\r
58 format = tinyMCE.regexpReplace(format, "%r", "%I:%M:%S %p");
\r
59 format = tinyMCE.regexpReplace(format, "%Y", "" + date.getFullYear());
\r
60 format = tinyMCE.regexpReplace(format, "%y", "" + date.getYear());
\r
61 format = tinyMCE.regexpReplace(format, "%m", addZeros(date.getMonth()+1, 2));
\r
62 format = tinyMCE.regexpReplace(format, "%d", addZeros(date.getDate(), 2));
\r
63 format = tinyMCE.regexpReplace(format, "%H", "" + addZeros(date.getHours(), 2));
\r
64 format = tinyMCE.regexpReplace(format, "%M", "" + addZeros(date.getMinutes(), 2));
\r
65 format = tinyMCE.regexpReplace(format, "%S", "" + addZeros(date.getSeconds(), 2));
\r
66 format = tinyMCE.regexpReplace(format, "%I", "" + ((date.getHours() + 11) % 12 + 1));
\r
67 format = tinyMCE.regexpReplace(format, "%p", "" + (date.getHours() < 12 ? "AM" : "PM"));
\r
68 format = tinyMCE.regexpReplace(format, "%B", "" + tinyMCE.getLang("lang_inserttime_months_long")[date.getMonth()]);
\r
69 format = tinyMCE.regexpReplace(format, "%b", "" + tinyMCE.getLang("lang_inserttime_months_short")[date.getMonth()]);
\r
70 format = tinyMCE.regexpReplace(format, "%A", "" + tinyMCE.getLang("lang_inserttime_day_long")[date.getDay()]);
\r
71 format = tinyMCE.regexpReplace(format, "%a", "" + tinyMCE.getLang("lang_inserttime_day_short")[date.getDay()]);
\r
72 format = tinyMCE.regexpReplace(format, "%%", "%");
\r
79 case "mceInsertDate":
\r
80 tinyMCE.execInstanceCommand(editor_id, 'mceInsertContent', false, getDateTime(new Date(), tinyMCE.getParam("plugin_insertdate_dateFormat", tinyMCE.getLang('lang_insertdate_def_fmt'))));
\r
83 case "mceInsertTime":
\r
84 tinyMCE.execInstanceCommand(editor_id, 'mceInsertContent', false, getDateTime(new Date(), tinyMCE.getParam("plugin_insertdate_timeFormat", tinyMCE.getLang('lang_inserttime_def_fmt'))));
\r
88 // Pass to next handler in chain
\r
93 tinyMCE.addPlugin("insertdatetime", TinyMCE_InsertDateTimePlugin);
\r