123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976 |
- require({cache:{
- 'url:dojox/widget/MultiSelectCalendar/MultiSelectCalendar.html':"<table cellspacing=\"0\" cellpadding=\"0\" class=\"dijitCalendarContainer\" role=\"grid\" dojoAttachEvent=\"onkeypress: _onKeyPress\" aria-labelledby=\"${id}_year\">\n\t<thead>\n\t\t<tr class=\"dijitReset dijitCalendarMonthContainer\" valign=\"top\">\n\t\t\t<th class='dijitReset dijitCalendarArrow' dojoAttachPoint=\"decrementMonth\">\n\t\t\t\t<img src=\"${_blankGif}\" alt=\"\" class=\"dijitCalendarIncrementControl dijitCalendarDecrease\" role=\"presentation\"/>\n\t\t\t\t<span dojoAttachPoint=\"decreaseArrowNode\" class=\"dijitA11ySideArrow\">-</span>\n\t\t\t</th>\n\t\t\t<th class='dijitReset' colspan=\"5\">\n\t\t\t\t<div dojoType=\"dijit.form.DropDownButton\" dojoAttachPoint=\"monthDropDownButton\"\n\t\t\t\t\tid=\"${id}_mddb\" tabIndex=\"-1\">\n\t\t\t\t</div>\n\t\t\t</th>\n\t\t\t<th class='dijitReset dijitCalendarArrow' dojoAttachPoint=\"incrementMonth\">\n\t\t\t\t<img src=\"${_blankGif}\" alt=\"\" class=\"dijitCalendarIncrementControl dijitCalendarIncrease\" role=\"presentation\"/>\n\t\t\t\t<span dojoAttachPoint=\"increaseArrowNode\" class=\"dijitA11ySideArrow\">+</span>\n\t\t\t</th>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<th class=\"dijitReset dijitCalendarDayLabelTemplate\" role=\"columnheader\"><span class=\"dijitCalendarDayLabel\"></span></th>\n\t\t</tr>\n\t</thead>\n\t<tbody dojoAttachEvent=\"onclick: _onDayClick, onmouseover: _onDayMouseOver, onmouseout: _onDayMouseOut, onmousedown: _onDayMouseDown, onmouseup: _onDayMouseUp\" class=\"dijitReset dijitCalendarBodyContainer\">\n\t\t<tr class=\"dijitReset dijitCalendarWeekTemplate\" role=\"row\">\n\t\t\t<td class=\"dijitReset dijitCalendarDateTemplate\" role=\"gridcell\"><span class=\"dijitCalendarDateLabel\"></span></td>\n\t\t</tr>\n\t</tbody>\n\t<tfoot class=\"dijitReset dijitCalendarYearContainer\">\n\t\t<tr>\n\t\t\t<td class='dijitReset' valign=\"top\" colspan=\"7\">\n\t\t\t\t<h3 class=\"dijitCalendarYearLabel\">\n\t\t\t\t\t<span dojoAttachPoint=\"previousYearLabelNode\" class=\"dijitInline dijitCalendarPreviousYear\"></span>\n\t\t\t\t\t<span dojoAttachPoint=\"currentYearLabelNode\" class=\"dijitInline dijitCalendarSelectedYear\" id=\"${id}_year\"></span>\n\t\t\t\t\t<span dojoAttachPoint=\"nextYearLabelNode\" class=\"dijitInline dijitCalendarNextYear\"></span>\n\t\t\t\t</h3>\n\t\t\t</td>\n\t\t</tr>\n\t</tfoot>\n</table>"}});
- define("dojox/widget/MultiSelectCalendar", [
- "dojo/main", "dijit",
- "dojo/text!./MultiSelectCalendar/MultiSelectCalendar.html",
- "dojo/cldr/supplemental",
- "dojo/date",
- "dojo/date/locale",
- "dijit/_Widget", "dijit/_Templated", "dijit/_CssStateMixin", "dijit/form/DropDownButton", "dijit/typematic"],
- function(dojo, dijit, template) {
- dojo.experimental("dojox.widget.MultiSelectCalendar");
- dojo.declare(
- "dojox.widget.MultiSelectCalendar",
- [dijit._Widget, dijit._TemplatedMixin, dijit._WidgetsInTemplateMixin, dijit._CssStateMixin],
- {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- templateString: template,
- widgetsInTemplate: true,
-
-
- value: {},
-
-
-
- datePackage: "dojo.date",
-
-
- dayWidth: "narrow",
-
-
- tabIndex: "0",
-
-
-
- returnIsoRanges : false,
-
-
-
-
-
- currentFocus: new Date(),
- baseClass:"dijitCalendar",
-
- cssStateNodes: {
- "decrementMonth": "dijitCalendarArrow",
- "incrementMonth": "dijitCalendarArrow",
- "previousYearLabelNode": "dijitCalendarPreviousYear",
- "nextYearLabelNode": "dijitCalendarNextYear"
- },
- _areValidDates: function(/*Date*/ value){
-
-
-
-
-
- for (var selDate in this.value){
- valid = (selDate && !isNaN(selDate) && typeof value == "object" && selDate.toString() != this.constructor.prototype.value.toString());
- if(!valid){ return false; }
- }
- return true;
- },
- _getValueAttr: function(){
-
- if(this.returnIsoRanges){
- datesWithRanges = this._returnDatesWithIsoRanges(this._sort());
- return datesWithRanges;
- }else{
- return this._sort();
- }
- },
-
- _setValueAttr: function(/*Date|Number|array*/ value, /*Boolean*/ priorityChange){
-
-
-
-
-
-
-
-
-
-
-
-
- this.value = {};
- if(dojo.isArray(value)) {
- dojo.forEach(value,function(element, i){
-
- var slashPosition = element.indexOf("/");
- if(slashPosition == -1){
-
- this.value[element] = 1;
- }else{
-
- var dateA=new dojo.date.stamp.fromISOString(element.substr(0,10));
- var dateB=new dojo.date.stamp.fromISOString(element.substr(11,10));
-
- this.toggleDate(dateA,[],[]);
- if((dateA - dateB) > 0){
-
- this._addToRangeRTL(dateA, dateB, [], []);
- }else{
-
- this._addToRangeLTR(dateA, dateB, [], []);
- }
- }
- },this);
- if(value.length > 0){
- this.focusOnLastDate(value[value.length-1]);
- }
- }else{
- if(value){
-
-
- value = new this.dateClassObj(value);
- }
- if(this._isValidDate(value)){
- value.setHours(1, 0, 0, 0);
-
- if(!this.isDisabledDate(value, this.lang)){
- dateIndex = dojo.date.stamp.toISOString(value).substring(0,10);
-
- this.value[dateIndex] = 1;
-
-
-
-
- this.set("currentFocus", value);
-
- if(priorityChange || typeof priorityChange == "undefined"){
- this.onChange(this.get('value'));
- this.onValueSelected(this.get('value'));
- }
- }
- }
- }
- this._populateGrid();
- },
- focusOnLastDate : function(lastElement){
-
-
- var slashPositionLastDate = lastElement.indexOf("/");
- var dateA,dateB;
- if(slashPositionLastDate == -1){
-
- lastDate = lastElement;
- }else{
- dateA=new dojo.date.stamp.fromISOString(lastElement.substr(0,10));
- dateB=new dojo.date.stamp.fromISOString(lastElement.substr(11,10));
- if((dateA - dateB) > 0){
- lastDate = dateA;
- }else{
- lastDate = dateB;
- }
- }
- this.set("currentFocus", lastDate);
- },
- _isValidDate: function(/*Date*/ value){
-
-
-
-
-
- return value && !isNaN(value) && typeof value == "object" &&
- value.toString() != this.constructor.prototype.value.toString();
- },
- _setText: function(node, text){
-
-
-
-
-
- while(node.firstChild){
- node.removeChild(node.firstChild);
- }
- node.appendChild(dojo.doc.createTextNode(text));
- },
- _populateGrid: function(){
-
-
-
-
- var month = new this.dateClassObj(this.currentFocus);
- month.setDate(1);
- var firstDay = month.getDay(),
- daysInMonth = this.dateFuncObj.getDaysInMonth(month),
- daysInPreviousMonth = this.dateFuncObj.getDaysInMonth(this.dateFuncObj.add(month, "month", -1)),
- today = new this.dateClassObj(),
- dayOffset = dojo.cldr.supplemental.getFirstDayOfWeek(this.lang);
- if(dayOffset > firstDay){ dayOffset -= 7; }
-
- this.listOfNodes = dojo.query(".dijitCalendarDateTemplate", this.domNode);
-
- this.listOfNodes.forEach(function(template, i){
- i += dayOffset;
- var date = new this.dateClassObj(month),
- number, clazz = "dijitCalendar", adj = 0;
- if(i < firstDay){
- number = daysInPreviousMonth - firstDay + i + 1;
- adj = -1;
- clazz += "Previous";
- }else if(i >= (firstDay + daysInMonth)){
- number = i - firstDay - daysInMonth + 1;
- adj = 1;
- clazz += "Next";
- }else{
- number = i - firstDay + 1;
- clazz += "Current";
- }
- if(adj){
- date = this.dateFuncObj.add(date, "month", adj);
- }
- date.setDate(number);
- if(!this.dateFuncObj.compare(date, today, "date")){
- clazz = "dijitCalendarCurrentDate " + clazz;
- }
-
- dateIndex = dojo.date.stamp.toISOString(date).substring(0,10);
-
- if(!this.isDisabledDate(date, this.lang)){
-
-
-
- if(this._isSelectedDate(date, this.lang)){
- if(this.value[dateIndex]){
- clazz = "dijitCalendarSelectedDate " + clazz;
- }else{
- clazz = clazz.replace("dijitCalendarSelectedDate ","");
- }
- }
- }
- if(this._isSelectedDate(date, this.lang)){
- clazz = "dijitCalendarBrowsingDate " + clazz;
- }
- if(this.isDisabledDate(date, this.lang)){
- clazz = "dijitCalendarDisabledDate " + clazz;
- }
- var clazz2 = this.getClassForDate(date, this.lang);
- if(clazz2){
- clazz = clazz2 + " " + clazz;
- }
- template.className = clazz + "Month dijitCalendarDateTemplate";
- template.dijitDateValue = date.valueOf();
- dojo.attr(template, "dijitDateValue", date.valueOf());
- var label = dojo.query(".dijitCalendarDateLabel", template)[0],
- text = date.getDateLocalized ? date.getDateLocalized(this.lang) : date.getDate();
- this._setText(label, text);
- }, this);
-
-
- var monthNames = this.dateLocaleModule.getNames('months', 'wide', 'standAlone', this.lang, month);
- this.monthDropDownButton.dropDown.set("months", monthNames);
-
-
-
- this.monthDropDownButton.containerNode.innerHTML =
- (dojo.isIE == 6 ? "" : "<div class='dijitSpacer'>" + this.monthDropDownButton.dropDown.domNode.innerHTML + "</div>") +
- "<div class='dijitCalendarMonthLabel dijitCalendarCurrentMonthLabel'>" + monthNames[month.getMonth()] + "</div>";
-
- var y = month.getFullYear() - 1;
- var d = new this.dateClassObj();
- dojo.forEach(["previous", "current", "next"], function(name){
- d.setFullYear(y++);
- this._setText(this[name+"YearLabelNode"],
- this.dateLocaleModule.format(d, {selector:'year', locale:this.lang}));
- }, this);
- },
- goToToday: function(){
-
-
- this.set('currentFocus', new this.dateClassObj(), false);
- },
- constructor: function(/*Object*/args){
- var dateClass = (args.datePackage && (args.datePackage != "dojo.date"))? args.datePackage + ".Date" : "Date";
- this.dateClassObj = dojo.getObject(dateClass, false);
- this.datePackage = args.datePackage || this.datePackage;
- this.dateFuncObj = dojo.getObject(this.datePackage, false);
- this.dateLocaleModule = dojo.getObject(this.datePackage + ".locale", false);
- },
- buildRendering: function(){
- this.inherited(arguments);
- dojo.setSelectable(this.domNode, false);
- var cloneClass = dojo.hitch(this, function(clazz, n){
- var template = dojo.query(clazz, this.domNode)[0];
- for(var i=0; i<n; i++){
- template.parentNode.appendChild(template.cloneNode(true));
- }
- });
-
- cloneClass(".dijitCalendarDayLabelTemplate", 6);
- cloneClass(".dijitCalendarDateTemplate", 6);
-
- cloneClass(".dijitCalendarWeekTemplate", 5);
-
- var dayNames = this.dateLocaleModule.getNames('days', this.dayWidth, 'standAlone', this.lang);
- var dayOffset = dojo.cldr.supplemental.getFirstDayOfWeek(this.lang);
- dojo.query(".dijitCalendarDayLabel", this.domNode).forEach(function(label, i){
- this._setText(label, dayNames[(i + dayOffset) % 7]);
- }, this);
- var dateObj = new this.dateClassObj(this.currentFocus);
- this.monthDropDownButton.dropDown = new dojox.widget._MonthDropDown({
- id: this.id + "_mdd",
- onChange: dojo.hitch(this, "_onMonthSelect")
- });
- this.set('currentFocus', dateObj, false);
-
- var _this = this;
- var typematic = function(nodeProp, dateProp, adj){
- _this._connects.push(
- dijit.typematic.addMouseListener(_this[nodeProp], _this, function(count){
- if(count >= 0){ _this._adjustDisplay(dateProp, adj); }
- }, 0.8, 500)
- );
- };
- typematic("incrementMonth", "month", 1);
- typematic("decrementMonth", "month", -1);
- typematic("nextYearLabelNode", "year", 1);
- typematic("previousYearLabelNode", "year", -1);
- },
- _adjustDisplay: function(/*String*/ part, /*int*/ amount){
-
-
-
-
-
-
-
-
- this._setCurrentFocusAttr(this.dateFuncObj.add(this.currentFocus, part, amount));
- },
- _setCurrentFocusAttr: function(/*Date*/ date, /*Boolean*/ forceFocus){
-
-
-
-
-
-
-
- var oldFocus = this.currentFocus,
- oldCell = oldFocus ? dojo.query("[dijitDateValue=" + oldFocus.valueOf() + "]", this.domNode)[0] : null;
-
- date = new this.dateClassObj(date);
- date.setHours(1, 0, 0, 0);
- this._set("currentFocus", date);
- var currentMonth = dojo.date.stamp.toISOString(date).substring(0,7);
-
- if(currentMonth != this.previousMonth){
- this._populateGrid();
- this.previousMonth = currentMonth;
- }
-
- var newCell = dojo.query("[dijitDateValue=" + date.valueOf() + "]", this.domNode)[0];
- newCell.setAttribute("tabIndex", this.tabIndex);
- if(this._focused || forceFocus){
- newCell.focus();
- }
-
- if(oldCell && oldCell != newCell){
- if(dojo.isWebKit){
- oldCell.setAttribute("tabIndex", "-1");
- }else{
- oldCell.removeAttribute("tabIndex");
- }
- }
- },
- focus: function(){
-
-
- this._setCurrentFocusAttr(this.currentFocus, true);
- },
- _onMonthSelect: function(/*Number*/ newMonth){
-
-
-
-
-
-
- this.currentFocus = this.dateFuncObj.add(this.currentFocus, "month",
- newMonth - this.currentFocus.getMonth());
- this._populateGrid();
- },
-
- toggleDate : function(/*date*/ dateToToggle, /*array of dates*/ selectedDates, /*array of dates*/ unselectedDates){
-
-
- var dateIndex = dojo.date.stamp.toISOString(dateToToggle).substring(0,10);
-
- if(this.value[dateIndex]){
- this.unselectDate(dateToToggle, unselectedDates);
- }else{
- this.selectDate(dateToToggle, selectedDates);
- }
- },
-
- selectDate : function(/*date*/ dateToSelect, /*array of dates*/ selectedDates){
-
- var node = this._getNodeByDate(dateToSelect);
- var clazz = node.className;
- var dateIndex = dojo.date.stamp.toISOString(dateToSelect).substring(0,10);
- this.value[dateIndex] = 1;
- selectedDates.push(dateIndex);
- clazz = "dijitCalendarSelectedDate " + clazz;
-
- node.className = clazz;
- },
-
- unselectDate : function(/*date*/ dateToUnselect, /*array of dates*/ unselectedDates){
-
- var node = this._getNodeByDate(dateToUnselect);
- var clazz = node.className;
- var dateIndex = dojo.date.stamp.toISOString(dateToUnselect).substring(0,10);
- delete(this.value[dateIndex]);
- unselectedDates.push(dateIndex);
- clazz = clazz.replace("dijitCalendarSelectedDate ","");
-
- node.className = clazz;
- },
- _getNodeByDate : function(/*ISO date*/ dateNode){
-
- var firstDate = new this.dateClassObj(this.listOfNodes[0].dijitDateValue);
- var difference = Math.abs(dojo.date.difference(firstDate, dateNode, "day"));
- return this.listOfNodes[difference];
- },
- _onDayClick: function(/*Event*/ evt){
-
-
-
-
-
-
-
-
- dojo.stopEvent(evt);
- for(var node = evt.target; node && !node.dijitDateValue; node = node.parentNode);
- if(node && !dojo.hasClass(node, "dijitCalendarDisabledDate")){
- value = new this.dateClassObj(node.dijitDateValue);
- if(!this.rangeJustSelected){
- this.toggleDate(value,[],[]);
-
-
- this.previouslySelectedDay = value;
- this.set("currentFocus", value);
- this.onValueSelected([dojo.date.stamp.toISOString(value).substring(0,10)]);
-
- }else{
- this.rangeJustSelected = false;
- this.set("currentFocus", value);
- }
- }
- },
- _onDayMouseOver: function(/*Event*/ evt){
-
-
-
-
-
-
- var node =
- dojo.hasClass(evt.target, "dijitCalendarDateLabel") ?
- evt.target.parentNode :
- evt.target;
- if(node && (node.dijitDateValue || node == this.previousYearLabelNode || node == this.nextYearLabelNode) ){
- dojo.addClass(node, "dijitCalendarHoveredDate");
- this._currentNode = node;
- }
- },
- _setEndRangeAttr: function(/*Date*/ value){
-
-
-
-
- value = new this.dateClassObj(value);
- value.setHours(1);
- this.endRange = value;
- },
- _getEndRangeAttr: function(){
-
- var value = new this.dateClassObj(this.endRange);
- value.setHours(0, 0, 0, 0);
-
-
-
- if(value.getDate() < this.endRange.getDate()){
- value = this.dateFuncObj.add(value, "hour", 1);
- }
- return value;
- },
- _onDayMouseOut: function(/*Event*/ evt){
-
-
-
-
-
- if(!this._currentNode){ return; }
-
-
- if(evt.relatedTarget && evt.relatedTarget.parentNode == this._currentNode){ return; }
- var cls = "dijitCalendarHoveredDate";
- if(dojo.hasClass(this._currentNode, "dijitCalendarActiveDate")) {
- cls += " dijitCalendarActiveDate";
- }
- dojo.removeClass(this._currentNode, cls);
- this._currentNode = null;
- },
- _onDayMouseDown: function(/*Event*/ evt){
- var node = evt.target.parentNode;
- if(node && node.dijitDateValue){
- dojo.addClass(node, "dijitCalendarActiveDate");
- this._currentNode = node;
- }
-
-
- if(evt.shiftKey && this.previouslySelectedDay){
-
- this.selectingRange = true;
- this.set('endRange', node.dijitDateValue);
- this._selectRange();
- }else{
- this.selectingRange = false;
- this.previousRangeStart = null;
- this.previousRangeEnd = null;
- }
- },
-
- _onDayMouseUp: function(/*Event*/ evt){
- var node = evt.target.parentNode;
- if(node && node.dijitDateValue){
- dojo.removeClass(node, "dijitCalendarActiveDate");
- }
- },
- handleKey: function(/*Event*/ evt){
-
-
-
-
-
-
-
-
-
-
-
- var dk = dojo.keys,
- increment = -1,
- interval,
- newValue = this.currentFocus;
- switch(evt.keyCode){
- case dk.RIGHT_ARROW:
- increment = 1;
-
- case dk.LEFT_ARROW:
- interval = "day";
- if(!this.isLeftToRight()){ increment *= -1; }
- break;
- case dk.DOWN_ARROW:
- increment = 1;
-
- case dk.UP_ARROW:
- interval = "week";
- break;
- case dk.PAGE_DOWN:
- increment = 1;
-
- case dk.PAGE_UP:
- interval = evt.ctrlKey || evt.altKey ? "year" : "month";
- break;
- case dk.END:
-
- newValue = this.dateFuncObj.add(newValue, "month", 1);
-
- interval = "day";
-
- case dk.HOME:
- newValue = new this.dateClassObj(newValue);
- newValue.setDate(1);
- break;
- case dk.ENTER:
- case dk.SPACE:
- if(evt.shiftKey && this.previouslySelectedDay){
- this.selectingRange = true;
- this.set('endRange', newValue);
- this._selectRange();
- }else{
- this.selectingRange = false;
- this.toggleDate(newValue,[],[]);
-
-
- this.previouslySelectedDay = newValue;
- this.previousRangeStart = null;
- this.previousRangeEnd = null;
- this.onValueSelected([dojo.date.stamp.toISOString(newValue).substring(0,10)]);
-
- }
- break;
- default:
- return true;
- }
- if(interval){
- newValue = this.dateFuncObj.add(newValue, interval, increment);
- }
- this.set("currentFocus", newValue);
- return false;
- },
- _onKeyPress: function(/*Event*/ evt){
-
-
- if(!this.handleKey(evt)){
- dojo.stopEvent(evt);
- }
- },
-
- _removeFromRangeLTR : function(/*date*/ beginning, /*date*/ end, /*array*/selectedDates, /*array*/unselectedDates){
-
- difference = Math.abs(dojo.date.difference(beginning, end, "day"));
- for(var i = 0; i <= difference; i++){
- var nextDay = dojo.date.add(beginning, 'day',i);
- this.toggleDate(nextDay, selectedDates, unselectedDates);
- }
- if(this.previousRangeEnd == null){
-
- this.previousRangeEnd = end;
- }else{
- if(dojo.date.compare(end, this.previousRangeEnd, 'date') > 0 )
- this.previousRangeEnd = end;
- }
- if(this.previousRangeStart == null){
-
- this.previousRangeStart = end;
- }else{
- if(dojo.date.compare(end, this.previousRangeStart, 'date') > 0 )
- this.previousRangeStart = end;
- }
- this.previouslySelectedDay = dojo.date.add(nextDay, 'day',1);
- },
- _removeFromRangeRTL : function(/*date*/ beginning, /*date*/ end, /*array*/selectedDates, /*array*/unselectedDates){
-
-
-
- difference = Math.abs(dojo.date.difference(beginning, end, "day"));
- for(var i = 0; i <= difference; i++){
- var nextDay = dojo.date.add(beginning, 'day',-i);
- this.toggleDate(nextDay, selectedDates, unselectedDates);
- }
- if(this.previousRangeEnd == null){
- this.previousRangeEnd = end;
- }else{
- if(dojo.date.compare(end, this.previousRangeEnd, 'date') < 0 ){
- this.previousRangeEnd = end;
- }
- }
- if(this.previousRangeStart == null){
- this.previousRangeStart = end;
- }else{
- if(dojo.date.compare(end, this.previousRangeStart, 'date') < 0 ){
- this.previousRangeStart = end;
- }
- }
- this.previouslySelectedDay = dojo.date.add(nextDay, 'day',-1);
- },
- _addToRangeRTL : function(/*date*/ beginning, /*date*/ end, /*array*/selectedDates, /*array*/unselectedDates){
-
- difference = Math.abs(dojo.date.difference(beginning, end, "day"));
-
-
- for(var i = 1; i <= difference; i++){
- var nextDay = dojo.date.add(beginning, 'day',-i);
- this.toggleDate(nextDay, selectedDates, unselectedDates);
- }
-
- if(this.previousRangeStart == null){
- this.previousRangeStart = end;
- }else{
- if(dojo.date.compare(end, this.previousRangeStart, 'date') < 0 ){
- this.previousRangeStart = end;
- }
- }
- if(this.previousRangeEnd == null){
- this.previousRangeEnd = beginning;
- }else{
- if(dojo.date.compare(beginning, this.previousRangeEnd, 'date') > 0 ){
- this.previousRangeEnd = beginning;
- }
- }
- this.previouslySelectedDay = nextDay;
- },
- _addToRangeLTR : function(/*date*/ beginning, /*date*/ end, /*array*/selectedDates, /*array*/unselectedDates){
-
-
- difference = Math.abs(dojo.date.difference(beginning, end, "day"));
- for(var i = 1; i <= difference; i++){
- var nextDay = dojo.date.add(beginning, 'day',i);
- this.toggleDate(nextDay, selectedDates, unselectedDates);
- }
- if(this.previousRangeStart == null){
- this.previousRangeStart = beginning;
- }else{
- if(dojo.date.compare(beginning, this.previousRangeStart, 'date') < 0 ){
- this.previousRangeStart = beginning;
- }
- }
- if(this.previousRangeEnd == null){
- this.previousRangeEnd = end;
- }else{
- if(dojo.date.compare(end, this.previousRangeEnd, 'date') > 0 ){
- this.previousRangeEnd = end;
- }
- }
- this.previouslySelectedDay = nextDay;
- },
- _selectRange : function(){
-
- var selectedDates = [];
- var unselectedDates = [];
- var beginning = this.previouslySelectedDay;
- var end = this.get('endRange');
-
- if(!this.previousRangeStart && !this.previousRangeEnd){
- removingFromRange = false;
- }else{
- if((dojo.date.compare(end, this.previousRangeStart, 'date') < 0) || (dojo.date.compare(end, this.previousRangeEnd, 'date') > 0)){
-
- removingFromRange = false;
- }else{
- removingFromRange = true;
- }
- }
- if(removingFromRange == true){
- if(dojo.date.compare(end, beginning, 'date') < 0){
-
- this._removeFromRangeRTL(beginning, end, selectedDates, unselectedDates);
- }else{
-
- this._removeFromRangeLTR(beginning, end, selectedDates, unselectedDates);
- }
- }else{
-
- if(dojo.date.compare(end, beginning, 'date') < 0){
- this._addToRangeRTL(beginning, end, selectedDates, unselectedDates);
- }else{
- this._addToRangeLTR(beginning, end, selectedDates, unselectedDates);
- }
- }
-
- if(selectedDates.length > 0){
- this.onValueSelected(selectedDates);
- }
- if(unselectedDates.length > 0){
- this.onValueUnselected(unselectedDates);
- }
- this.rangeJustSelected = true;
- },
- onValueSelected: function(/*array of ISO dates*/ dates){
-
-
-
-
-
-
- },
- onValueUnselected: function(/*array of ISO dates*/ dates){
-
-
-
-
-
-
- },
- onChange: function(/*Date*/ date){
-
-
- },
- _isSelectedDate: function(/*Date*/ dateObject, /*String?*/ locale){
-
-
-
- dateIndex = dojo.date.stamp.toISOString(dateObject).substring(0,10);
- return this.value[dateIndex];
- },
- isDisabledDate: function(/*Date*/ dateObject, /*String?*/ locale){
-
-
-
-
- },
- getClassForDate: function(/*Date*/ dateObject, /*String?*/ locale){
-
-
-
-
-
- },
- _sort : function(){
-
- if(this.value == {}){return [];}
-
- var selectedDates = [];
- for (var selDate in this.value){
- selectedDates.push(selDate);
- }
-
- selectedDates.sort(function(a, b){
- var dateA=new Date(a), dateB=new Date(b);
- return dateA-dateB;
- });
- return selectedDates;
- },
- _returnDatesWithIsoRanges : function(selectedDates /*Array of sorted ISO dates*/){
-
-
-
- var returnDates = [];
- if(selectedDates.length > 1){
-
- var weHaveRange = false,
- rangeCount = 0,
- startRange = null,
- lastDayRange = null,
- previousDate = dojo.date.stamp.fromISOString(selectedDates[0]);
-
- for(var i = 1; i < selectedDates.length+1; i++){
- currentDate = dojo.date.stamp.fromISOString(selectedDates[i]);
- if(weHaveRange){
-
- difference = Math.abs(dojo.date.difference(previousDate, currentDate, "day"));
- if(difference == 1){
-
- lastDayRange = currentDate;
- }else{
-
- range = dojo.date.stamp.toISOString(startRange).substring(0,10)
- + "/" + dojo.date.stamp.toISOString(lastDayRange).substring(0,10);
- returnDates.push(range);
- weHaveRange = false;
- }
- }else{
-
- difference = Math.abs(dojo.date.difference(previousDate, currentDate, "day"));
- if(difference == 1){
-
- weHaveRange = true;
- startRange = previousDate;
- lastDayRange = currentDate;
- }else{
-
- returnDates.push(dojo.date.stamp.toISOString(previousDate).substring(0,10));
- }
- }
- previousDate = currentDate;
- }
- return returnDates;
- }else{
-
- return selectedDates;
- }
- }
- }
- );
- dojo.declare("dojox.widget._MonthDropDown", [dijit._Widget, dijit._TemplatedMixin, dijit._WidgetsInTemplateMixin], {
-
-
-
-
-
- months: [],
- templateString: "<div class='dijitCalendarMonthMenu dijitMenu' " +
- "dojoAttachEvent='onclick:_onClick,onmouseover:_onMenuHover,onmouseout:_onMenuHover'></div>",
- _setMonthsAttr: function(/*String[]*/ months){
- this.domNode.innerHTML = dojo.map(months, function(month, idx){
- return month ? "<div class='dijitCalendarMonthLabel' month='" + idx +"'>" + month + "</div>" : "";
- }).join("");
- },
- _onClick: function(/*Event*/ evt){
- this.onChange(dojo.attr(evt.target, "month"));
- },
- onChange: function(/*Number*/ month){
-
-
- },
- _onMenuHover: function(evt){
- dojo.toggleClass(evt.target, "dijitCalendarMonthLabelHover", evt.type == "mouseover");
- }
- });
- return dojox.widget.MultiSelectCalendar;
- });
|