Mercurial > public > sg101
comparison static/js/tiny_mce/plugins/insertdatetime/editor_plugin_src.js @ 312:88b2b9cb8c1f
Fixing #142; cut over to the django.contrib.staticfiles app.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Thu, 27 Jan 2011 02:56:10 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
311:b1c39788e511 | 312:88b2b9cb8c1f |
---|---|
1 /** | |
2 * editor_plugin_src.js | |
3 * | |
4 * Copyright 2009, Moxiecode Systems AB | |
5 * Released under LGPL License. | |
6 * | |
7 * License: http://tinymce.moxiecode.com/license | |
8 * Contributing: http://tinymce.moxiecode.com/contributing | |
9 */ | |
10 | |
11 (function() { | |
12 tinymce.create('tinymce.plugins.InsertDateTime', { | |
13 init : function(ed, url) { | |
14 var t = this; | |
15 | |
16 t.editor = ed; | |
17 | |
18 ed.addCommand('mceInsertDate', function() { | |
19 var str = t._getDateTime(new Date(), ed.getParam("plugin_insertdate_dateFormat", ed.getLang('insertdatetime.date_fmt'))); | |
20 | |
21 ed.execCommand('mceInsertContent', false, str); | |
22 }); | |
23 | |
24 ed.addCommand('mceInsertTime', function() { | |
25 var str = t._getDateTime(new Date(), ed.getParam("plugin_insertdate_timeFormat", ed.getLang('insertdatetime.time_fmt'))); | |
26 | |
27 ed.execCommand('mceInsertContent', false, str); | |
28 }); | |
29 | |
30 ed.addButton('insertdate', {title : 'insertdatetime.insertdate_desc', cmd : 'mceInsertDate'}); | |
31 ed.addButton('inserttime', {title : 'insertdatetime.inserttime_desc', cmd : 'mceInsertTime'}); | |
32 }, | |
33 | |
34 getInfo : function() { | |
35 return { | |
36 longname : 'Insert date/time', | |
37 author : 'Moxiecode Systems AB', | |
38 authorurl : 'http://tinymce.moxiecode.com', | |
39 infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/insertdatetime', | |
40 version : tinymce.majorVersion + "." + tinymce.minorVersion | |
41 }; | |
42 }, | |
43 | |
44 // Private methods | |
45 | |
46 _getDateTime : function(d, fmt) { | |
47 var ed = this.editor; | |
48 | |
49 function addZeros(value, len) { | |
50 value = "" + value; | |
51 | |
52 if (value.length < len) { | |
53 for (var i=0; i<(len-value.length); i++) | |
54 value = "0" + value; | |
55 } | |
56 | |
57 return value; | |
58 }; | |
59 | |
60 fmt = fmt.replace("%D", "%m/%d/%y"); | |
61 fmt = fmt.replace("%r", "%I:%M:%S %p"); | |
62 fmt = fmt.replace("%Y", "" + d.getFullYear()); | |
63 fmt = fmt.replace("%y", "" + d.getYear()); | |
64 fmt = fmt.replace("%m", addZeros(d.getMonth()+1, 2)); | |
65 fmt = fmt.replace("%d", addZeros(d.getDate(), 2)); | |
66 fmt = fmt.replace("%H", "" + addZeros(d.getHours(), 2)); | |
67 fmt = fmt.replace("%M", "" + addZeros(d.getMinutes(), 2)); | |
68 fmt = fmt.replace("%S", "" + addZeros(d.getSeconds(), 2)); | |
69 fmt = fmt.replace("%I", "" + ((d.getHours() + 11) % 12 + 1)); | |
70 fmt = fmt.replace("%p", "" + (d.getHours() < 12 ? "AM" : "PM")); | |
71 fmt = fmt.replace("%B", "" + ed.getLang("insertdatetime.months_long").split(',')[d.getMonth()]); | |
72 fmt = fmt.replace("%b", "" + ed.getLang("insertdatetime.months_short").split(',')[d.getMonth()]); | |
73 fmt = fmt.replace("%A", "" + ed.getLang("insertdatetime.day_long").split(',')[d.getDay()]); | |
74 fmt = fmt.replace("%a", "" + ed.getLang("insertdatetime.day_short").split(',')[d.getDay()]); | |
75 fmt = fmt.replace("%%", "%"); | |
76 | |
77 return fmt; | |
78 } | |
79 }); | |
80 | |
81 // Register plugin | |
82 tinymce.PluginManager.add('insertdatetime', tinymce.plugins.InsertDateTime); | |
83 })(); |