--- a/includes/clientside/tinymce/plugins/insertdatetime/editor_plugin_src.js Wed Dec 26 00:37:26 2007 -0500
+++ b/includes/clientside/tinymce/plugins/insertdatetime/editor_plugin_src.js Thu Dec 27 22:09:33 2007 -0500
@@ -1,56 +1,59 @@
/**
- * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $
+ * $Id: editor_plugin_src.js 372 2007-11-11 18:38:50Z spocke $
*
* @author Moxiecode
* @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.
*/
-/* Import plugin specific language pack */
-tinyMCE.importPluginLanguagePack('insertdatetime');
+(function() {
+ tinymce.create('tinymce.plugins.InsertDateTime', {
+ init : function(ed, url) {
+ var t = this;
+
+ t.editor = ed;
+
+ ed.addCommand('mceInsertDate', function() {
+ var str = t._getDateTime(new Date(), ed.getParam("plugin_insertdate_dateFormat", ed.getLang('insertdatetime.date_fmt')));
-var TinyMCE_InsertDateTimePlugin = {
- getInfo : function() {
- return {
- longname : 'Insert date/time',
- author : 'Moxiecode Systems AB',
- authorurl : 'http://tinymce.moxiecode.com',
- infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/insertdatetime',
- version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
- };
- },
+ ed.execCommand('mceInsertContent', false, str);
+ });
+
+ ed.addCommand('mceInsertTime', function() {
+ var str = t._getDateTime(new Date(), ed.getParam("plugin_insertdate_timeFormat", ed.getLang('insertdatetime.time_fmt')));
- /**
- * Returns the HTML contents of the insertdate, inserttime controls.
- */
- getControlHTML : function(cn) {
- switch (cn) {
- case "insertdate":
- return tinyMCE.getButtonHTML(cn, 'lang_insertdate_desc', '{$pluginurl}/images/insertdate.gif', 'mceInsertDate');
+ ed.execCommand('mceInsertContent', false, str);
+ });
+
+ ed.addButton('insertdate', {title : 'insertdatetime.insertdate_desc', cmd : 'mceInsertDate'});
+ ed.addButton('inserttime', {title : 'insertdatetime.inserttime_desc', cmd : 'mceInsertTime'});
+ },
- case "inserttime":
- return tinyMCE.getButtonHTML(cn, 'lang_inserttime_desc', '{$pluginurl}/images/inserttime.gif', 'mceInsertTime');
- }
+ getInfo : function() {
+ return {
+ longname : 'Insert date/time',
+ author : 'Moxiecode Systems AB',
+ authorurl : 'http://tinymce.moxiecode.com',
+ infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/insertdatetime',
+ version : tinymce.majorVersion + "." + tinymce.minorVersion
+ };
+ },
- return "";
- },
+ // Private methods
- /**
- * Executes the mceInsertDate command.
- */
- execCommand : function(editor_id, element, command, user_interface, value) {
- /* Adds zeros infront of value */
- function addZeros(value, len) {
- value = "" + value;
+ _getDateTime : function(d, fmt) {
+ var ed = this.editor;
+
+ function addZeros(value, len) {
+ value = "" + value;
- if (value.length < len) {
- for (var i=0; i<(len-value.length); i++)
- value = "0" + value;
- }
+ if (value.length < len) {
+ for (var i=0; i<(len-value.length); i++)
+ value = "0" + value;
+ }
- return value;
- }
+ return value;
+ };
- function getDateTime(d, fmt) {
fmt = fmt.replace("%D", "%m/%d/%y");
fmt = fmt.replace("%r", "%I:%M:%S %p");
fmt = fmt.replace("%Y", "" + d.getFullYear());
@@ -62,29 +65,16 @@
fmt = fmt.replace("%S", "" + addZeros(d.getSeconds(), 2));
fmt = fmt.replace("%I", "" + ((d.getHours() + 11) % 12 + 1));
fmt = fmt.replace("%p", "" + (d.getHours() < 12 ? "AM" : "PM"));
- fmt = fmt.replace("%B", "" + tinyMCE.getLang("lang_inserttime_months_long")[d.getMonth()]);
- fmt = fmt.replace("%b", "" + tinyMCE.getLang("lang_inserttime_months_short")[d.getMonth()]);
- fmt = fmt.replace("%A", "" + tinyMCE.getLang("lang_inserttime_day_long")[d.getDay()]);
- fmt = fmt.replace("%a", "" + tinyMCE.getLang("lang_inserttime_day_short")[d.getDay()]);
+ fmt = fmt.replace("%B", "" + ed.getLang("insertdatetime.months_long").split(',')[d.getMonth()]);
+ fmt = fmt.replace("%b", "" + ed.getLang("insertdatetime.months_short").split(',')[d.getMonth()]);
+ fmt = fmt.replace("%A", "" + ed.getLang("insertdatetime.day_long").split(',')[d.getDay()]);
+ fmt = fmt.replace("%a", "" + ed.getLang("insertdatetime.day_short").split(',')[d.getDay()]);
fmt = fmt.replace("%%", "%");
return fmt;
}
-
- // 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;
- }
-};
-
-tinyMCE.addPlugin("insertdatetime", TinyMCE_InsertDateTimePlugin);
+ // Register plugin
+ tinymce.PluginManager.add('insertdatetime', tinymce.plugins.InsertDateTime);
+})();
\ No newline at end of file