-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
adding disableStart option for Picker.Date.Range #135
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,8 @@ Picker.Date.Range = new Class({ | |
}, this).join(' - ')); | ||
}, | ||
footer: true, | ||
columns: 3 | ||
columns: 3, | ||
disableStart: false | ||
}, | ||
|
||
getInputDate: function(input){ | ||
|
@@ -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(); | ||
inputProperties.events = events; | ||
inputProperties.readonly = 'readonly'; | ||
this.options.disableStart == true? inputProperties.readonly = 'readonly': ''; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use |
||
var startInput = this.startInput = new Element('input', inputProperties).inject(footer); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
|
||
|
@@ -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(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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' | ||
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unnecessary use of |
||
|
||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a breaking change, now it always start at I'd say simply: With hourFormat you give the user more options for other formats, but they can always use any other string like |
||
events: { | ||
click: function(event){ | ||
event.target.focus(); | ||
|
@@ -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) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simply use: