mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-21 19:34:40 +08:00
69 lines
3.3 KiB
Plaintext
69 lines
3.3 KiB
Plaintext
@using Orchard.Core.Shapes.Localization
|
|
@using System.Globalization
|
|
|
|
@{
|
|
|
|
// prevent the shape from being rendered twice in a page
|
|
if (WorkContext.GetState<object>("DatePickerLocalization") != null) {
|
|
return;
|
|
}
|
|
|
|
WorkContext.SetState("DatePickerLocalization", new object());
|
|
|
|
Style.Require("jQueryUI_DatePicker");
|
|
Script.Require("jQueryUI_DatePicker");
|
|
|
|
var cultureInfo = CultureInfo.GetCultureInfo(WorkContext.CurrentCulture);
|
|
|
|
var dateTimeLocalization = WorkContext.Resolve<IDateTimeLocalization>();
|
|
var monthNames = FormatJsList(dateTimeLocalization.MonthNames.Text);
|
|
var monthNamesShort = FormatJsList(dateTimeLocalization.MonthNamesShort.Text);
|
|
var dayNames = FormatJsList(dateTimeLocalization.DayNames.Text);
|
|
var dayNamesShort = FormatJsList(dateTimeLocalization.DayNamesShort.Text);
|
|
var dayNamesMin = FormatJsList(dateTimeLocalization.DayNamesMin.Text);
|
|
|
|
// convert .NET format into jQuery format
|
|
// http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx
|
|
// http://docs.jquery.com/UI/Datepicker/formatDate
|
|
|
|
var dateFormat = cultureInfo.DateTimeFormat.ShortDatePattern
|
|
.Replace("yyyy", "YY")
|
|
.Replace("yy", "Y")
|
|
.Replace("Y", "y")
|
|
.Replace("M", "m")
|
|
;
|
|
|
|
}
|
|
|
|
@functions {
|
|
|
|
private string FormatJsList(string csv) {
|
|
return "'" + String.Join("', '", csv.Split(',').Select(x => HttpUtility.JavaScriptStringEncode(x.Trim()))) + "'";
|
|
}
|
|
|
|
}
|
|
<script type="text/javascript">
|
|
//<![CDATA[
|
|
$(function() {
|
|
$.datepicker.regional[''] = {
|
|
closeText: '@HttpUtility.JavaScriptStringEncode(T("Done").Text)', // Display text for close link
|
|
prevText: '@HttpUtility.JavaScriptStringEncode(T("Prev").Text)', // Display text for previous month link
|
|
nextText: '@HttpUtility.JavaScriptStringEncode(T("Next").Text)', // Display text for next month link
|
|
currentText: '@HttpUtility.JavaScriptStringEncode(T("Today").Text)', // Display text for current month link
|
|
monthNames: [@Html.Raw(monthNames)], // Names of months for drop-down and formatting
|
|
monthNamesShort: [@Html.Raw(monthNamesShort)], // For formatting
|
|
dayNames: [@Html.Raw(dayNames)], // For formatting
|
|
dayNamesShort: [@Html.Raw(dayNamesShort)], // For formatting
|
|
dayNamesMin: [@Html.Raw(dayNamesMin)], // Column headings for days starting at Sunday
|
|
weekHeader: '@HttpUtility.JavaScriptStringEncode(T("Wk").Text)', // Column header for week of the year
|
|
dateFormat: '@HttpUtility.JavaScriptStringEncode(dateFormat)', // See format options on parseDate
|
|
firstDay: @dateTimeLocalization.FirstDay, // The first day of the week, Sun = 0, Mon = 1, ...
|
|
isRTL: @(cultureInfo.TextInfo.IsRightToLeft ? "true" : "false"), // True if right-to-left language, false if left-to-right
|
|
showMonthAfterYear: @(dateTimeLocalization.ShowMonthAfterYear ? "true" : "false"), // True if the year select precedes month, false for month then year
|
|
yearSuffix: '@HttpUtility.JavaScriptStringEncode(dateTimeLocalization.YearSuffix)' // Additional text to append to the year in the month headers
|
|
};
|
|
|
|
$.datepicker.setDefaults($.datepicker.regional['']);
|
|
})
|
|
//]]>
|
|
</script> |