summaryrefslogtreecommitdiff
path: root/public/javascripts/tiny_mce/plugins/insertdatetime
diff options
context:
space:
mode:
authorhukl <contact@smyck.org>2009-02-17 21:54:39 +0100
committerhukl <contact@smyck.org>2009-02-17 21:54:39 +0100
commitf61b5b0597e0c25f084ee67d402f12a43a7a9947 (patch)
tree3b4c3f9f38637f1a7ecf703ece4fd3bc4c6e2934 /public/javascripts/tiny_mce/plugins/insertdatetime
parent3d3b786cc43266f6292f5edd25733dbb9bd6ed06 (diff)
added tinymce editor for body area of pages
Diffstat (limited to 'public/javascripts/tiny_mce/plugins/insertdatetime')
-rwxr-xr-xpublic/javascripts/tiny_mce/plugins/insertdatetime/editor_plugin.js1
-rwxr-xr-xpublic/javascripts/tiny_mce/plugins/insertdatetime/editor_plugin_src.js80
2 files changed, 81 insertions, 0 deletions
diff --git a/public/javascripts/tiny_mce/plugins/insertdatetime/editor_plugin.js b/public/javascripts/tiny_mce/plugins/insertdatetime/editor_plugin.js
new file mode 100755
index 0000000..34d4cec
--- /dev/null
+++ b/public/javascripts/tiny_mce/plugins/insertdatetime/editor_plugin.js
@@ -0,0 +1 @@
(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};},_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;}});tinymce.PluginManager.add('insertdatetime',tinymce.plugins.InsertDateTime);})(); \ No newline at end of file
diff --git a/public/javascripts/tiny_mce/plugins/insertdatetime/editor_plugin_src.js b/public/javascripts/tiny_mce/plugins/insertdatetime/editor_plugin_src.js
new file mode 100755
index 0000000..9ab3135
--- /dev/null
+++ b/public/javascripts/tiny_mce/plugins/insertdatetime/editor_plugin_src.js
@@ -0,0 +1,80 @@
1/**
2 * $Id: editor_plugin_src.js 520 2008-01-07 16:30:32Z spocke $
3 *
4 * @author Moxiecode
5 * @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved.
6 */
7
8(function() {
9 tinymce.create('tinymce.plugins.InsertDateTime', {
10 init : function(ed, url) {
11 var t = this;
12
13 t.editor = ed;
14
15 ed.addCommand('mceInsertDate', function() {
16 var str = t._getDateTime(new Date(), ed.getParam("plugin_insertdate_dateFormat", ed.getLang('insertdatetime.date_fmt')));
17
18 ed.execCommand('mceInsertContent', false, str);
19 });
20
21 ed.addCommand('mceInsertTime', function() {
22 var str = t._getDateTime(new Date(), ed.getParam("plugin_insertdate_timeFormat", ed.getLang('insertdatetime.time_fmt')));
23
24 ed.execCommand('mceInsertContent', false, str);
25 });
26
27 ed.addButton('insertdate', {title : 'insertdatetime.insertdate_desc', cmd : 'mceInsertDate'});
28 ed.addButton('inserttime', {title : 'insertdatetime.inserttime_desc', cmd : 'mceInsertTime'});
29 },
30
31 getInfo : function() {
32 return {
33 longname : 'Insert date/time',
34 author : 'Moxiecode Systems AB',
35 authorurl : 'http://tinymce.moxiecode.com',
36 infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/insertdatetime',
37 version : tinymce.majorVersion + "." + tinymce.minorVersion
38 };
39 },
40
41 // Private methods
42
43 _getDateTime : function(d, fmt) {
44 var ed = this.editor;
45
46 function addZeros(value, len) {
47 value = "" + value;
48
49 if (value.length < len) {
50 for (var i=0; i<(len-value.length); i++)
51 value = "0" + value;
52 }
53
54 return value;
55 };
56
57 fmt = fmt.replace("%D", "%m/%d/%y");
58 fmt = fmt.replace("%r", "%I:%M:%S %p");
59 fmt = fmt.replace("%Y", "" + d.getFullYear());
60 fmt = fmt.replace("%y", "" + d.getYear());
61 fmt = fmt.replace("%m", addZeros(d.getMonth()+1, 2));
62 fmt = fmt.replace("%d", addZeros(d.getDate(), 2));
63 fmt = fmt.replace("%H", "" + addZeros(d.getHours(), 2));
64 fmt = fmt.replace("%M", "" + addZeros(d.getMinutes(), 2));
65 fmt = fmt.replace("%S", "" + addZeros(d.getSeconds(), 2));
66 fmt = fmt.replace("%I", "" + ((d.getHours() + 11) % 12 + 1));
67 fmt = fmt.replace("%p", "" + (d.getHours() < 12 ? "AM" : "PM"));
68 fmt = fmt.replace("%B", "" + ed.getLang("insertdatetime.months_long").split(',')[d.getMonth()]);
69 fmt = fmt.replace("%b", "" + ed.getLang("insertdatetime.months_short").split(',')[d.getMonth()]);
70 fmt = fmt.replace("%A", "" + ed.getLang("insertdatetime.day_long").split(',')[d.getDay()]);
71 fmt = fmt.replace("%a", "" + ed.getLang("insertdatetime.day_short").split(',')[d.getDay()]);
72 fmt = fmt.replace("%%", "%");
73
74 return fmt;
75 }
76 });
77
78 // Register plugin
79 tinymce.PluginManager.add('insertdatetime', tinymce.plugins.InsertDateTime);
80})(); \ No newline at end of file