Created
March 30, 2012 12:50
-
-
Save Mikke/2251309 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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