[Jifty-commit] r6678 - in jifty/trunk: share/web/static/js
Jifty commits
jifty-commit at lists.jifty.org
Thu Mar 19 11:23:56 EDT 2009
Author: sartak
Date: Thu Mar 19 11:23:54 2009
New Revision: 6678
Modified:
jifty/trunk/lib/Jifty/Web/Form/Field/Date.pm
jifty/trunk/share/web/static/js/calendar.js
Log:
Add an respect the calendar-starts-monday element class
Modified: jifty/trunk/lib/Jifty/Web/Form/Field/Date.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Web/Form/Field/Date.pm (original)
+++ jifty/trunk/lib/Jifty/Web/Form/Field/Date.pm Thu Mar 19 11:23:54 2009
@@ -13,13 +13,24 @@
=head2 classes
-Output date fields with the class 'date'
+Output date fields with the class 'date'. If the current user's user object has
+a C<calendar_starts_monday> method, and it returns true, the
+'calendar-starts-monday' class is added as well.
=cut
sub classes {
my $self = shift;
- return join(' ', 'date', ($self->SUPER::classes));
+ my $classes = join ' ', $self->SUPER::classes;
+ $classes .= ' date';
+
+ if (my $user = Jifty->web->current_user->user_object) {
+ $classes .= ' calendar-starts-monday'
+ if $user->can('calendar_starts_monday')
+ && $user->calendar_starts_monday;
+ }
+
+ return $classes;
}
=head2 canonicalize_value
Modified: jifty/trunk/share/web/static/js/calendar.js
==============================================================================
--- jifty/trunk/share/web/static/js/calendar.js (original)
+++ jifty/trunk/share/web/static/js/calendar.js Thu Mar 19 11:23:54 2009
@@ -42,19 +42,29 @@
this.parentNode.insertBefore( wrap, this.nextSibling );
var cal;
-
+
+ var start_weekday = jQuery(this).hasClass('calendar-starts-monday') ? 1 : 0;
+
if (Jifty.Calendar.dateRegex.test(this.value) ) {
var bits = this.value.match(Jifty.Calendar.dateRegex);
- cal = new YAHOO.widget.Calendar( calId,
- wrapId,
- { pagedate: bits[2]+"/"+bits[1],
- selected: bits[2]+"/"+bits[3]+"/"+bits[1] }
- );
+ cal = new YAHOO.widget.Calendar(
+ calId,
+ wrapId,
+ {
+ pagedate: bits[2]+"/"+bits[1],
+ selected: bits[2]+"/"+bits[3]+"/"+bits[1],
+ start_weekday: start_weekday
+ }
+ );
}
else {
- cal = new YAHOO.widget.Calendar( calId, wrapId);
+ cal = new YAHOO.widget.Calendar(
+ calId,
+ wrapId,
+ { start_weekday: start_weekday }
+ );
}
-
+
cal.cfg.applyConfig( Jifty.Calendar.Options );
cal.cfg.fireQueue();
More information about the Jifty-commit
mailing list