Skip to content

Instantly share code, notes, and snippets.

@Mikke
Created March 30, 2012 12:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mikke/2251309 to your computer and use it in GitHub Desktop.
Save Mikke/2251309 to your computer and use it in GitHub Desktop.
define(["dojo/_base/declare", "dijit/Calendar", "dojo/cldr/supplemental", "dojo/string", "dojo/dom"],
function(declare, Calendar, cldrSupplemental, string, dom){
return declare([Calendar], {
buildRendering: function(){
// Markup for days of the week (referenced from template)
var d = this.dowTemplateString,
dayNames = this.dateLocaleModule.getNames('days', this.dayWidth, 'standAlone', this.lang),
dayOffset = cldrSupplemental.getFirstDayOfWeek(this.lang);
this.dayCellsHtml = string.substitute([d,d,d,d,d,d,d].join(""), {d: ""}, function(){
return dayNames[dayOffset++ % 7]
});
// Markup for dates of the month (referenced from template), but without numbers filled in
var r = string.substitute(this.weekTemplateString, {d: this.dateTemplateString});
this.dateRowsHtml = [r,r,r,r,r,r].join("");
// Instantiate from template.
// dateCells and dateLabels arrays filled when _Templated parses my template.
this.dateCells = [];
this.dateLabels = [];
this.inherited(arguments);
dom.setSelectable(this.domNode, false);
var dateObj = new this.dateClassObj(this.currentFocus);
this._supportingWidgets.push(this.monthWidget = this._createMonthWidget());
this.set('currentFocus', dateObj, false); // draw the grid to the month specified by currentFocus
// Set up connects for increment/decrement of months/years
var connect = lang.hitch(this, function(nodeProp, part, amount){
this.connect(this[nodeProp], "onclick", function(){
this._setCurrentFocusAttr(this.dateFuncObj.add(this.currentFocus, part, amount));
});
});
connect("incrementMonth", "month", 1);
connect("decrementMonth", "month", -1);
connect("nextYearLabelNode", "year", 1);
connect("previousYearLabelNode", "year", -1);
},
postCreate: function(){
this.inherited(arguments);
console.log(this);
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment