Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions Source/Picker.Date.Range.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ Picker.Date.Range = new Class({
}, this).join(' - '));
},
footer: true,
columns: 3
columns: 3,
disableStart: false
},

getInputDate: function(input){
Expand Down Expand Up @@ -66,8 +67,11 @@ Picker.Date.Range = new Class({
if (event.key == 'enter') self.selectRange();
}
};

var startInput = this.startInput = new Element('input', {events: events}).inject(footer);
var inputProperties = new Object();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simply use:

{
    events: events,
    readonly: readOnly
    // etc.
}

inputProperties.events = events;
inputProperties.readonly = 'readonly';
this.options.disableStart == true? inputProperties.readonly = 'readonly': '';
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use if statement for this.

var startInput = this.startInput = new Element('input', inputProperties).inject(footer);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or why not keep it like it was, but with the added properties.

new Element('span', {text: ' - '}).inject(footer);
var endInput = this.endInput = new Element('input', {events: events}).inject(footer);

Expand All @@ -90,7 +94,7 @@ Picker.Date.Range = new Class({
select: function(date){
if (this.startDate && (this.endDate == this.startDate || date > this.endDate) && date >= this.startDate) this.endDate = date;
else {
this.startDate = date;
if(!this.options.disableStart)this.startDate = date;
this.endDate = date;
}
this.updateRangeSelection();
Expand Down
12 changes: 9 additions & 3 deletions Source/Picker.Date.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ this.DatePicker = Picker.Date = new Class({
invertAvailable: false,

format: null,*/

minHour: 0, // lets the user limit the minimum hour choice
maxHour: 23, // lets the user set the maximum hour choice (i.e. office hours from 8AM to 6PM, etc...)
hourStart: '01', // lets the user initialize an hour for the timepicker (i.e. when timewheel picker opens, be 1)

timePicker: false,
timePickerOnly: false, // deprecated, use onlyView = 'time'
Expand Down Expand Up @@ -528,10 +532,12 @@ var renderers = {

if (initMinutes >= 60) initMinutes = 0;
date.set('minutes', initMinutes);

HourString = options.hourStart.toString(); //user may have entered an hours date object, and we need string
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unnecessary use of .toString(), and use camelCase.


var hoursInput = new Element('input.hour[type=text]', {
title: Locale.get('DatePicker.use_mouse_wheel'),
value: date.format('%H'),
value: date.format(HourString), //here the setting of the hour to initialize timewheel picker
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a breaking change, now it always start at 01.

I'd say simply: date.format(options.hourFormat);.

With hourFormat you give the user more options for other formats, but they can always use any other string like 01.

events: {
click: function(event){
event.target.focus();
Expand All @@ -541,8 +547,8 @@ var renderers = {
event.stop();
hoursInput.focus();
var value = hoursInput.get('value').toInt();
value = (event.wheel > 0) ? ((value < 23) ? value + 1 : 0)
: ((value > 0) ? value - 1 : 23)
value = (event.wheel > options.minHour) ? ((value < options.maxHour) ? value + 1 : 0) //here set the min and max hour variables as per options
: ((value > options.minHour) ? value - 1 : options.maxHour) //here set the min and max hour variables as per options
date.set('hours', value);
hoursInput.set('value', date.format('%H'));
}.bind(this)
Expand Down