| |||||||||||||||||
| Source File | Conditionals | Statements | Methods | TOTAL | |||||||||||||
| Web\Scripts\JSCalendarSetupScriptBlock.cs | - | 100,0 % | 100,0 % | 100,0 % |
|
||||||||||||
| 1 | #region Copyright | |
| 2 | /* | |
| 3 | ShowX. Maps business objects into presentation layer. | |
| 4 | Copyright (C) 2005 Jesus Diaz. | |
| 5 | ||
| 6 | This library is free software; you can redistribute it and/or | |
| 7 | modify it under the terms of the GNU Lesser General Public | |
| 8 | License as published by the Free Software Foundation; either | |
| 9 | version 2.1 of the License, or (at your option) any later version. | |
| 10 | ||
| 11 | This library is distributed in the hope that it will be useful, | |
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 14 | Lesser General Public License for more details. | |
| 15 | ||
| 16 | You should have received a copy of the GNU Lesser General Public | |
| 17 | License along with this library; if not, write to the Free Software | |
| 18 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. | |
| 19 | ||
| 20 | For project details see: http://showx.sourceforge.net | |
| 21 | */ | |
| 22 | #endregion | |
| 23 | ||
| 24 | using System; | |
| 25 | using System.Text; | |
| 26 | using log4net; | |
| 27 | ||
| 28 | namespace ShowX.Web.Scripts | |
| 29 | { | |
| 30 | /// <summary> | |
| 31 | /// Generates the necessary includes in order to use | |
| 32 | /// the jsCalendar control. | |
| 33 | /// The script code looks somehow like: | |
| 34 | /// <code> | |
| 35 | /// <script type="text/javascript"> | |
| 36 | /// Calendar.setup( | |
| 37 | /// { | |
| 38 | /// inputField : "f_date_b", | |
| 39 | /// ifFormat : "%m/%d/%Y", | |
| 40 | /// showsTime : false, | |
| 41 | /// button : "f_trigger_b", | |
| 42 | /// singleClick : true, | |
| 43 | /// step : 1 | |
| 44 | /// }); | |
| 45 | /// </script> | |
| 46 | /// </code> | |
| 47 | /// | |
| 48 | /// </summary> | |
| 49 | public class JSCalendarSetupScriptBlock : ScriptBaseClass | |
| 50 | { | |
| 51 | private static readonly ILog log = LogManager.GetLogger( | |
| 52 | typeof( JSCalendarSetupScriptBlock)); | |
| 53 | ||
| 54 | /// <summary> | |
| 55 | /// Constructor, to build script block. | |
| 56 | /// </summary> | |
| 57 | 25 | public JSCalendarSetupScriptBlock(string inputFieldId, string triggerId) |
| 58 | : base ("JSCalendarSetupScriptBlock:" + Guid.NewGuid().ToString()) | |
| 59 | { | |
| 60 | 25 | log.Info("Building calendar setup script."); |
| 61 | ||
| 62 | 25 | StringBuilder strBuilder = new StringBuilder(); |
| 63 | ||
| 64 | 25 | strBuilder.Append("<script type='text/javascript'>") |
| 65 | .Append("Calendar.setup({") | |
| 66 | .Append("inputField : '" + inputFieldId + "',") // id of the input field | |
| 67 | .Append("ifFormat : '%d/%m/%Y',") // format of the input field | |
| 68 | .Append("showsTime : false,") // will display a time selector | |
| 69 | .Append("button : '" + triggerId + "',") // trigger for the calendar | |
| 70 | .Append("singleClick : true,") // double-click mode | |
| 71 | .Append("step : 1});</script>"); // show all years in drop-down boxes (instead of every other year as default) | |
| 72 | ||
| 73 | ||
| 74 | 25 | script = strBuilder.ToString(); |
| 75 | } | |
| 76 | } | |
| 77 | } | |
| 78 |
|
||||||||