-/* Import plugin specific language pack */
-tinyMCE.importPluginLanguagePack('insertdatetime', 'cs,el,en,fr_ca,it,ko,sv,zh_cn,fa,fr,de,pl,pt_br,nl,da,he,no');
-
-function TinyMCE_insertdatetime_getInfo() {
- return {
- longname : 'Insert date/time',
- author : 'Moxiecode Systems',
- authorurl : 'http://tinymce.moxiecode.com',
- infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_insertdatetime.html',
- version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
- };
-};
-
-/**
- * Returns the HTML contents of the insertdate, inserttime controls.
- */
-function TinyMCE_insertdatetime_getControlHTML(control_name) {
- switch (control_name) {
- case "insertdate":
- return '<a href="javascript:tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceInsertDate\');" 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>';
-
- case "inserttime":
- return '<a href="javascript:tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceInsertTime\');" 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>';
- }
-
- return "";
-}
-
-/**
- * Executes the mceInsertDate command.
- */
-function TinyMCE_insertdatetime_execCommand(editor_id, element, command, user_interface, value) {
- /* Adds zeros infront of value */
- function addZeros(value, len) {
- value = "" + value;
-
- if (value.length < len) {
- for (var i=0; i<(len-value.length); i++)
- value = "0" + value;
- }
-
- return value;
- }
-
- /* Returns the date object in the specified format */
- function getDateTime(date, format) {
- format = tinyMCE.regexpReplace(format, "%D", "%m/%d/%y");
- format = tinyMCE.regexpReplace(format, "%r", "%I:%M:%S %p");
- format = tinyMCE.regexpReplace(format, "%Y", "" + date.getFullYear());
- format = tinyMCE.regexpReplace(format, "%y", "" + date.getYear());
- format = tinyMCE.regexpReplace(format, "%m", addZeros(date.getMonth()+1, 2));
- format = tinyMCE.regexpReplace(format, "%d", addZeros(date.getDate(), 2));
- format = tinyMCE.regexpReplace(format, "%H", "" + addZeros(date.getHours(), 2));
- format = tinyMCE.regexpReplace(format, "%M", "" + addZeros(date.getMinutes(), 2));
- format = tinyMCE.regexpReplace(format, "%S", "" + addZeros(date.getSeconds(), 2));
- format = tinyMCE.regexpReplace(format, "%I", "" + ((date.getHours() + 11) % 12 + 1));
- format = tinyMCE.regexpReplace(format, "%p", "" + (date.getHours() < 12 ? "AM" : "PM"));
- format = tinyMCE.regexpReplace(format, "%B", "" + tinyMCE.getLang("lang_inserttime_months_long")[date.getMonth()]);
- format = tinyMCE.regexpReplace(format, "%b", "" + tinyMCE.getLang("lang_inserttime_months_short")[date.getMonth()]);
- format = tinyMCE.regexpReplace(format, "%A", "" + tinyMCE.getLang("lang_inserttime_day_long")[date.getDay()]);
- format = tinyMCE.regexpReplace(format, "%a", "" + tinyMCE.getLang("lang_inserttime_day_short")[date.getDay()]);
- format = tinyMCE.regexpReplace(format, "%%", "%");
-
- return format;
- }
-
- // Handle commands
- switch (command) {
- case "mceInsertDate":
- tinyMCE.execInstanceCommand(editor_id, 'mceInsertContent', false, getDateTime(new Date(), tinyMCE.getParam("plugin_insertdate_dateFormat", tinyMCE.getLang('lang_insertdate_def_fmt'))));
- return true;
-
- case "mceInsertTime":
- tinyMCE.execInstanceCommand(editor_id, 'mceInsertContent', false, getDateTime(new Date(), tinyMCE.getParam("plugin_insertdate_timeFormat", tinyMCE.getLang('lang_inserttime_def_fmt'))));
- return true;
- }
-
- // Pass to next handler in chain
- return false;
-}
+/*\r
+ * Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved.\r
+ */\r
+\r
+(function() {\r
+ tinymce.create('tinymce.plugins.InsertDateTime', {\r
+ init : function(ed, url) {\r
+ var t = this;\r
+\r
+ t.editor = ed;\r
+\r
+ ed.addCommand('mceInsertDate', function() {\r
+ var str = t._getDateTime(new Date(), ed.getParam("plugin_insertdate_dateFormat", ed.getLang('insertdatetime.date_fmt')));\r
+\r
+ ed.execCommand('mceInsertContent', false, str);\r
+ });\r
+\r
+ ed.addCommand('mceInsertTime', function() {\r
+ var str = t._getDateTime(new Date(), ed.getParam("plugin_insertdate_timeFormat", ed.getLang('insertdatetime.time_fmt')));\r
+\r
+ ed.execCommand('mceInsertContent', false, str);\r
+ });\r
+\r
+ ed.addButton('insertdate', {title : 'insertdatetime.insertdate_desc', cmd : 'mceInsertDate'});\r
+ ed.addButton('inserttime', {title : 'insertdatetime.inserttime_desc', cmd : 'mceInsertTime'});\r
+ },\r
+\r
+ getInfo : function() {\r
+ return {\r
+ longname : 'Insert date/time',\r
+ author : 'Moxiecode Systems AB',\r
+ authorurl : 'http://tinymce.moxiecode.com',\r
+ infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/insertdatetime',\r
+ version : tinymce.majorVersion + "." + tinymce.minorVersion\r
+ };\r
+ },\r
+\r
+ // Private methods\r
+\r
+ _getDateTime : function(d, fmt) {\r
+ var ed = this.editor;\r
+\r
+ function addZeros(value, len) {\r
+ value = "" + value;\r
+\r
+ if (value.length < len) {\r
+ for (var i=0; i<(len-value.length); i++)\r
+ value = "0" + value;\r
+ }\r
+\r
+ return value;\r
+ };\r
+\r
+ fmt = fmt.replace("%D", "%m/%d/%y");\r
+ fmt = fmt.replace("%r", "%I:%M:%S %p");\r
+ fmt = fmt.replace("%Y", "" + d.getFullYear());\r
+ fmt = fmt.replace("%y", "" + d.getYear());\r
+ fmt = fmt.replace("%m", addZeros(d.getMonth()+1, 2));\r
+ fmt = fmt.replace("%d", addZeros(d.getDate(), 2));\r
+ fmt = fmt.replace("%H", "" + addZeros(d.getHours(), 2));\r
+ fmt = fmt.replace("%M", "" + addZeros(d.getMinutes(), 2));\r
+ fmt = fmt.replace("%S", "" + addZeros(d.getSeconds(), 2));\r
+ fmt = fmt.replace("%I", "" + ((d.getHours() + 11) % 12 + 1));\r
+ fmt = fmt.replace("%p", "" + (d.getHours() < 12 ? "AM" : "PM"));\r
+ fmt = fmt.replace("%B", "" + ed.getLang("insertdatetime.months_long").split(',')[d.getMonth()]);\r
+ fmt = fmt.replace("%b", "" + ed.getLang("insertdatetime.months_short").split(',')[d.getMonth()]);\r
+ fmt = fmt.replace("%A", "" + ed.getLang("insertdatetime.day_long").split(',')[d.getDay()]);\r
+ fmt = fmt.replace("%a", "" + ed.getLang("insertdatetime.day_short").split(',')[d.getDay()]);\r
+ fmt = fmt.replace("%%", "%");\r
+\r
+ return fmt;\r
+ }\r
+ });\r
+\r
+ // Register plugin\r
+ tinymce.PluginManager.add('insertdatetime', tinymce.plugins.InsertDateTime);\r
+})();\r