annotate media/js/tiny_mce/plugins/insertdatetime/editor_plugin_src.js @ 64:58bc950c6d8b

Added breadcrumb navigation to the donations thanks page.
author Brian Neal <bgneal@gmail.com>
date Sat, 27 Jun 2009 21:44:52 +0000
parents a5b4c5ce0658
children 149c3567fec1
rev   line source
bgneal@45 1 /**
bgneal@45 2 * $Id: editor_plugin_src.js 520 2008-01-07 16:30:32Z spocke $
bgneal@45 3 *
bgneal@45 4 * @author Moxiecode
bgneal@45 5 * @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved.
bgneal@45 6 */
bgneal@45 7
bgneal@45 8 (function() {
bgneal@45 9 tinymce.create('tinymce.plugins.InsertDateTime', {
bgneal@45 10 init : function(ed, url) {
bgneal@45 11 var t = this;
bgneal@45 12
bgneal@45 13 t.editor = ed;
bgneal@45 14
bgneal@45 15 ed.addCommand('mceInsertDate', function() {
bgneal@45 16 var str = t._getDateTime(new Date(), ed.getParam("plugin_insertdate_dateFormat", ed.getLang('insertdatetime.date_fmt')));
bgneal@45 17
bgneal@45 18 ed.execCommand('mceInsertContent', false, str);
bgneal@45 19 });
bgneal@45 20
bgneal@45 21 ed.addCommand('mceInsertTime', function() {
bgneal@45 22 var str = t._getDateTime(new Date(), ed.getParam("plugin_insertdate_timeFormat", ed.getLang('insertdatetime.time_fmt')));
bgneal@45 23
bgneal@45 24 ed.execCommand('mceInsertContent', false, str);
bgneal@45 25 });
bgneal@45 26
bgneal@45 27 ed.addButton('insertdate', {title : 'insertdatetime.insertdate_desc', cmd : 'mceInsertDate'});
bgneal@45 28 ed.addButton('inserttime', {title : 'insertdatetime.inserttime_desc', cmd : 'mceInsertTime'});
bgneal@45 29 },
bgneal@45 30
bgneal@45 31 getInfo : function() {
bgneal@45 32 return {
bgneal@45 33 longname : 'Insert date/time',
bgneal@45 34 author : 'Moxiecode Systems AB',
bgneal@45 35 authorurl : 'http://tinymce.moxiecode.com',
bgneal@45 36 infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/insertdatetime',
bgneal@45 37 version : tinymce.majorVersion + "." + tinymce.minorVersion
bgneal@45 38 };
bgneal@45 39 },
bgneal@45 40
bgneal@45 41 // Private methods
bgneal@45 42
bgneal@45 43 _getDateTime : function(d, fmt) {
bgneal@45 44 var ed = this.editor;
bgneal@45 45
bgneal@45 46 function addZeros(value, len) {
bgneal@45 47 value = "" + value;
bgneal@45 48
bgneal@45 49 if (value.length < len) {
bgneal@45 50 for (var i=0; i<(len-value.length); i++)
bgneal@45 51 value = "0" + value;
bgneal@45 52 }
bgneal@45 53
bgneal@45 54 return value;
bgneal@45 55 };
bgneal@45 56
bgneal@45 57 fmt = fmt.replace("%D", "%m/%d/%y");
bgneal@45 58 fmt = fmt.replace("%r", "%I:%M:%S %p");
bgneal@45 59 fmt = fmt.replace("%Y", "" + d.getFullYear());
bgneal@45 60 fmt = fmt.replace("%y", "" + d.getYear());
bgneal@45 61 fmt = fmt.replace("%m", addZeros(d.getMonth()+1, 2));
bgneal@45 62 fmt = fmt.replace("%d", addZeros(d.getDate(), 2));
bgneal@45 63 fmt = fmt.replace("%H", "" + addZeros(d.getHours(), 2));
bgneal@45 64 fmt = fmt.replace("%M", "" + addZeros(d.getMinutes(), 2));
bgneal@45 65 fmt = fmt.replace("%S", "" + addZeros(d.getSeconds(), 2));
bgneal@45 66 fmt = fmt.replace("%I", "" + ((d.getHours() + 11) % 12 + 1));
bgneal@45 67 fmt = fmt.replace("%p", "" + (d.getHours() < 12 ? "AM" : "PM"));
bgneal@45 68 fmt = fmt.replace("%B", "" + ed.getLang("insertdatetime.months_long").split(',')[d.getMonth()]);
bgneal@45 69 fmt = fmt.replace("%b", "" + ed.getLang("insertdatetime.months_short").split(',')[d.getMonth()]);
bgneal@45 70 fmt = fmt.replace("%A", "" + ed.getLang("insertdatetime.day_long").split(',')[d.getDay()]);
bgneal@45 71 fmt = fmt.replace("%a", "" + ed.getLang("insertdatetime.day_short").split(',')[d.getDay()]);
bgneal@45 72 fmt = fmt.replace("%%", "%");
bgneal@45 73
bgneal@45 74 return fmt;
bgneal@45 75 }
bgneal@45 76 });
bgneal@45 77
bgneal@45 78 // Register plugin
bgneal@45 79 tinymce.PluginManager.add('insertdatetime', tinymce.plugins.InsertDateTime);
bgneal@45 80 })();