[ Index ]
 

Code source de Seagull 0.6.1

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/tinyfck/plugins/insertdatetime/ -> editor_plugin_src.js (source)

   1  /**

   2   * $RCSfile: editor_plugin_src.js,v $

   3   * $Revision: 1.22 $

   4   * $Date: 2006/02/10 16:29:39 $

   5   *

   6   * @author Moxiecode

   7   * @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved.

   8   */
   9  
  10  /* Import plugin specific language pack */

  11  tinyMCE.importPluginLanguagePack('insertdatetime', 'en,tr,cs,el,fr_ca,it,ko,sv,zh_cn,fa,fr,de,pl,pt_br,nl,da,he,nb,ru,ru_KOI8-R,ru_UTF-8,nn,fi,es,cy,is,pl');
  12  
  13  var TinyMCE_InsertDateTimePlugin = {
  14      getInfo : function() {
  15          return {
  16              longname : 'Insert date/time',
  17              author : 'Moxiecode Systems',
  18              authorurl : 'http://tinymce.moxiecode.com',
  19              infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_insertdatetime.html',
  20              version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
  21          };
  22      },
  23  
  24      /**

  25       * Returns the HTML contents of the insertdate, inserttime controls.

  26       */
  27      getControlHTML : function(cn) {
  28          switch (cn) {
  29              case "insertdate":
  30                  return tinyMCE.getButtonHTML(cn, 'lang_insertdate_desc', '{$pluginurl}/images/insertdate.gif', 'mceInsertDate');
  31  
  32              case "inserttime":
  33                  return tinyMCE.getButtonHTML(cn, 'lang_inserttime_desc', '{$pluginurl}/images/inserttime.gif', 'mceInsertTime');
  34          }
  35  
  36          return "";
  37      },
  38  
  39      /**

  40       * Executes the mceInsertDate command.

  41       */
  42      execCommand : function(editor_id, element, command, user_interface, value) {
  43          /* Adds zeros infront of value */

  44  		function addZeros(value, len) {
  45              value = "" + value;
  46  
  47              if (value.length < len) {
  48                  for (var i=0; i<(len-value.length); i++)
  49                      value = "0" + value;
  50              }
  51  
  52              return value;
  53          }
  54  
  55          /* Returns the date object in the specified format */

  56  		function getDateTime(date, format) {
  57              format = tinyMCE.regexpReplace(format, "%D", "%m/%d/%y");
  58              format = tinyMCE.regexpReplace(format, "%r", "%I:%M:%S %p");
  59              format = tinyMCE.regexpReplace(format, "%Y", "" + date.getFullYear());
  60              format = tinyMCE.regexpReplace(format, "%y", "" + date.getYear());
  61              format = tinyMCE.regexpReplace(format, "%m", addZeros(date.getMonth()+1, 2));
  62              format = tinyMCE.regexpReplace(format, "%d", addZeros(date.getDate(), 2));
  63              format = tinyMCE.regexpReplace(format, "%H", "" + addZeros(date.getHours(), 2));
  64              format = tinyMCE.regexpReplace(format, "%M", "" + addZeros(date.getMinutes(), 2));
  65              format = tinyMCE.regexpReplace(format, "%S", "" + addZeros(date.getSeconds(), 2));
  66              format = tinyMCE.regexpReplace(format, "%I", "" + ((date.getHours() + 11) % 12 + 1));
  67              format = tinyMCE.regexpReplace(format, "%p", "" + (date.getHours() < 12 ? "AM" : "PM"));
  68              format = tinyMCE.regexpReplace(format, "%B", "" + tinyMCE.getLang("lang_inserttime_months_long")[date.getMonth()]);
  69              format = tinyMCE.regexpReplace(format, "%b", "" + tinyMCE.getLang("lang_inserttime_months_short")[date.getMonth()]);
  70              format = tinyMCE.regexpReplace(format, "%A", "" + tinyMCE.getLang("lang_inserttime_day_long")[date.getDay()]);
  71              format = tinyMCE.regexpReplace(format, "%a", "" + tinyMCE.getLang("lang_inserttime_day_short")[date.getDay()]);
  72              format = tinyMCE.regexpReplace(format, "%%", "%");
  73  
  74              return format;
  75          }
  76  
  77          // Handle commands

  78          switch (command) {
  79              case "mceInsertDate":
  80                  tinyMCE.execInstanceCommand(editor_id, 'mceInsertContent', false, getDateTime(new Date(), tinyMCE.getParam("plugin_insertdate_dateFormat", tinyMCE.getLang('lang_insertdate_def_fmt'))));
  81                  return true;
  82  
  83              case "mceInsertTime":
  84                  tinyMCE.execInstanceCommand(editor_id, 'mceInsertContent', false, getDateTime(new Date(), tinyMCE.getParam("plugin_insertdate_timeFormat", tinyMCE.getLang('lang_inserttime_def_fmt'))));
  85                  return true;
  86          }
  87  
  88          // Pass to next handler in chain

  89          return false;
  90      }
  91  };
  92  
  93  tinyMCE.addPlugin("insertdatetime", TinyMCE_InsertDateTimePlugin);


Généré le : Fri Mar 30 01:27:52 2007 par Balluche grâce à PHPXref 0.7