From 2814336cc91b5fa4e01e1f699f24c71ff18cf148 Mon Sep 17 00:00:00 2001 From: IberoMedia Date: Fri, 15 Feb 2013 00:51:21 -0800 Subject: [PATCH 1/2] Update Source/Picker.Date.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I added three options to the PickerDate control. These affect the time picker specifically.  The options are: minHour: 0, maxHour: 23, hourStart: '01', If the user sets minHour and maxHour through a PickerDate object, he/she can set the time limits to choose times with timewheel, for example officehours, 8AM to 6PM. Then, the hourStart, a bit of a luxury, make it easier for the user to choose  a time. Also, when a second PickerDate object, which is destined to specify an ending  date and tie for an event, the time in the timewheel can be initialized to one hour after  the PickarDate starting event object was selected to.  Feedback? --- Source/Picker.Date.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Source/Picker.Date.js b/Source/Picker.Date.js index 8b4558e..85344f2 100644 --- a/Source/Picker.Date.js +++ b/Source/Picker.Date.js @@ -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 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 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) From eedcd4cdc90eaf60d09dfd9a971abb2d50e37896 Mon Sep 17 00:00:00 2001 From: IberoMedia Date: Sun, 24 Feb 2013 14:28:35 -0800 Subject: [PATCH 2/2] Update Source/Picker.Date.Range.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I added a new property for the Picker.Date.Range object: disableStart. The idea behind this option is to prevent users from inadvertently changing the start date field value. Without this option, in cases where the Picker.Date.Range object has been initialized to start at a certain date, and if the user clicks more than once over the Picker.Date.Range control, the start date field value is likely to change. With the implementation of the disableStart option, and when this option is set to true, the start date input from the Picker.Date.Range control is attributed readonly, i.e. disables the user from selecting this input field, and despite the number of clicks over the Picker.Date.Range control, the start date field's value will remain the initialized value.  --- Source/Picker.Date.Range.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Source/Picker.Date.Range.js b/Source/Picker.Date.Range.js index 1e31b43..2d8428f 100644 --- a/Source/Picker.Date.Range.js +++ b/Source/Picker.Date.Range.js @@ -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': ''; + var startInput = this.startInput = new Element('input', inputProperties).inject(footer); 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();