From 4766f36a4d74924f21ff329c4318ce4e069ffa04 Mon Sep 17 00:00:00 2001 From: brettp Date: Wed, 3 Mar 2010 17:53:05 +0000 Subject: Pulled in the interface changes. git-svn-id: http://code.elgg.org/elgg/trunk@5257 36083f99-b078-4883-b0ff-0f9b5a30f544 --- .../plugins/insertdatetime/editor_plugin_src.js | 80 ++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 mod/tinymce/tinymce/jscripts/tiny_mce/plugins/insertdatetime/editor_plugin_src.js (limited to 'mod/tinymce/tinymce/jscripts/tiny_mce/plugins/insertdatetime/editor_plugin_src.js') diff --git a/mod/tinymce/tinymce/jscripts/tiny_mce/plugins/insertdatetime/editor_plugin_src.js b/mod/tinymce/tinymce/jscripts/tiny_mce/plugins/insertdatetime/editor_plugin_src.js new file mode 100644 index 000000000..e80895cd3 --- /dev/null +++ b/mod/tinymce/tinymce/jscripts/tiny_mce/plugins/insertdatetime/editor_plugin_src.js @@ -0,0 +1,80 @@ +/** + * $Id: editor_plugin_src.js 520 2008-01-07 16:30:32Z spocke $ + * + * @author Moxiecode + * @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved. + */ + +(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'))); + + 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'))); + + ed.execCommand('mceInsertContent', false, str); + }); + + ed.addButton('insertdate', {title : 'insertdatetime.insertdate_desc', cmd : 'mceInsertDate'}); + ed.addButton('inserttime', {title : 'insertdatetime.inserttime_desc', cmd : '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 + }; + }, + + // Private methods + + _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; + } + + return value; + }; + + fmt = fmt.replace("%D", "%m/%d/%y"); + fmt = fmt.replace("%r", "%I:%M:%S %p"); + fmt = fmt.replace("%Y", "" + d.getFullYear()); + fmt = fmt.replace("%y", "" + d.getYear()); + fmt = fmt.replace("%m", addZeros(d.getMonth()+1, 2)); + fmt = fmt.replace("%d", addZeros(d.getDate(), 2)); + fmt = fmt.replace("%H", "" + addZeros(d.getHours(), 2)); + fmt = fmt.replace("%M", "" + addZeros(d.getMinutes(), 2)); + 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", "" + 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; + } + }); + + // Register plugin + tinymce.PluginManager.add('insertdatetime', tinymce.plugins.InsertDateTime); +})(); \ No newline at end of file -- cgit v1.2.3