Commit 261e7ea5 authored by Sacred Seven's avatar Sacred Seven

JalaliCalendar in broadcast messages

parent 3383383c
= stylesheet_link_tag "JalaliJSCalendar-1.4/calendar-blue"
= javascript_include_tag "JalaliJSCalendar-1.4/jalali"
= javascript_include_tag "JalaliJSCalendar-1.4/calendar"
= javascript_include_tag "JalaliJSCalendar-1.4/calendar-setup"
= javascript_include_tag "JalaliJSCalendar-1.4/lang/calendar-fa"
%h3.page-title
Broadcast Messages
%p.light
......@@ -30,12 +35,14 @@
.light 6 character hex values starting with a # sign.
.form-group
= f.label :starts_at, class: 'control-label'
.col-sm-10.datetime-controls
= f.datetime_select :starts_at
.col-sm-10.datetime-controls{ style: 'width: auto' }
= f.hidden_field :starts_at
#datepicker1
.form-group
= f.label :ends_at, class: 'control-label'
.col-sm-10.datetime-controls
= f.datetime_select :ends_at
.col-sm-10.datetime-controls{ style: 'width: auto' }
= f.hidden_field :ends_at
#datepicker2
.form-actions
= f.submit "Add broadcast message", class: "btn btn-create"
......@@ -46,11 +53,11 @@
.pull-right
- if broadcast_message.starts_at
%strong
#{broadcast_message.starts_at.to_s(:short)}
#{JalaliDate.new(broadcast_message.starts_at).strftime("%A %d %b %Y %H:%M")}
\...
- if broadcast_message.ends_at
%strong
#{broadcast_message.ends_at.to_s(:short)}
#{JalaliDate.new(broadcast_message.ends_at).strftime("%A %d %b %Y %H:%M")}
 
= link_to [:admin, broadcast_message], method: :delete, remote: true, class: 'remove-row btn btn-tiny' do
%i.fa.fa-times.cred
......@@ -59,3 +66,31 @@
= paginate @broadcast_messages
:javascript
function utcString(date) {
var utc = new Date(date.getTime() + date.getTimezoneOffset() * 60000);
return utc.toLocaleFormat("%Y/%m/%d %H:%M");
}
var now = new Date();
var nowCounterUTC = new Date(now.getTime() - now.getTimezoneOffset() * 60000);
Calendar.setup({
inputField : "broadcast_message_starts_at",
flat : "datepicker1", // id of the input field
flatCallback : function(calendar) {$('#broadcast_message_starts_at').val(utcString(calendar.date))},
ifFormat : "%Y/%m/%d %H:%M", // format of the input field
dateType : 'jalali',
timeFormat : '24',
showsTime : true,
weekNumbers : false
}).setDate(nowCounterUTC);
Calendar.setup({
inputField : "broadcast_message_ends_at",
flat : "datepicker2", // id of the input field
flatCallback : function(calendar) {$('#broadcast_message_ends_at').val(utcString(calendar.date))},
ifFormat : "%Y/%m/%d %H:%M", // format of the input field
dateType : 'jalali',
timeFormat : '24',
showsTime : true,
weekNumbers : false
}).setDate(nowCounterUTC);
......@@ -51,6 +51,7 @@
:javascript
disableButtonIfEmptyField("#milestone_title", ".btn-save");
Calendar.setup({
inputField : "milestone_due_date",
flat : "datepicker", // id of the input field
flatCallback : function(calendar) {$('#milestone_due_date').val(calendar.date.toLocaleFormat("%Y/%m/%d"))},
ifFormat : "%Y/%m/%d", // format of the input field
......
......@@ -25,7 +25,7 @@ module Gitlab
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'
config.time_zone = 'Tehran'
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment