Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
90 lines (71 sloc) 2.16 KB
<!-- Heading for a 7 day week calendar, globalized. -->
<Control className="DaysOfWeek" generic="true">
<content>
<div class="dayOfWeek"/>
<div class="dayOfWeek"/>
<div class="dayOfWeek"/>
<div class="dayOfWeek"/>
<div class="dayOfWeek"/>
<div class="dayOfWeek"/>
<div class="dayOfWeek"/>
</content>
<style>
.dayOfWeek {
display: table-cell;
}
/* Generic appearance */
.DaysOfWeek.generic .dayOfWeek {
text-align: center;
}
</style>
<script>
DaysOfWeek.prototype.extend({
/*
* The control's current culture.
*/
culture: function( culture ) {
var result = this._super( culture );
if ( culture !== undefined ) {
this.format( this.format() );
}
return result;
},
/*
* The format used to show the names of the day. These are defined by
* the Globalize library:
*
* "names": the full name, e.g. "Sunday".
* "namesAbbreviated": an abbreviated name, e.g., "Sun".
* "namesShort": an even shorter name, e.g., "Su".
*/
format: Control.property( function( format ) {
var culture = this.culture();
var dayNameEnum = culture ? culture.calendar.days : DaysOfWeek.days;
var dayNames = dayNameEnum[ format ];
var firstDay = culture ? culture.calendar.firstDay : 0;
var $children = this.children();
for ( var i = 0; i < dayNames.length; i++ ) {
var day = (i + firstDay) % 7;
var dayName = dayNames[ day ];
$children.eq(i).content( dayName );
}
}),
initialize: function() {
if ( !this.format() ) {
this.format( "namesAbbr" );
}
}
});
DaysOfWeek.extend({
// Default names; used if Globalize is not loaded.
days: {
// full day names
names: [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ],
// abbreviated day names
namesAbbr: [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ],
// shortest day names
namesShort: [ "Su", "Mo", "Tu", "We", "Th", "Fr", "Sa" ]
}
})
</script>
</Control>
Jump to Line
Something went wrong with that request. Please try again.