mirror of
https://github.com/TracksApp/tracks.git
synced 2026-01-07 17:58:50 +01:00
Add additional keyboard shortcuts to date fields, per SK's suggestion in #470.
Date field shortcuts:
(t) today
(-) or (<) previous day
(+) or (>) next day
([) previous week; (]) next week
({) previous month
(}) next month
git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@519 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
parent
179d194fb2
commit
8f81f6d58a
1 changed files with 35 additions and 1 deletions
|
|
@ -220,7 +220,7 @@ DateDueKeyboardShortcutSupport.prototype = {
|
|||
this.dateFormat = dateFormat || "%Y/%m/%d";
|
||||
Event.observe(this.element,'keypress',this.onkeypress.bindAsEventListener(this));
|
||||
title = this.element.getAttributeNode("title");
|
||||
tooltip = 'Shortcuts: [t] today; [-] previous day; [+] next day; Click to show calendar';
|
||||
tooltip = 'Shortcuts: (t) today; (-) or (<) previous day; (+) or (>) next day; ([) previous week; (]) next week; ({) previous month; (}) next month; Click to show calendar';
|
||||
if (title && title.value)
|
||||
{
|
||||
this.element.setAttribute("title", title.value + ' (' + tooltip + ')');
|
||||
|
|
@ -237,12 +237,26 @@ DateDueKeyboardShortcutSupport.prototype = {
|
|||
this.setTextBoxToTodaysDate();
|
||||
break;
|
||||
case "+":
|
||||
case ">":
|
||||
case "=":
|
||||
this.setTextBoxToNextDay();
|
||||
break;
|
||||
case "-":
|
||||
case "<":
|
||||
this.setTextBoxToPreviousDay();
|
||||
break;
|
||||
case "[":
|
||||
this.setTextBoxToPreviousWeek();
|
||||
break;
|
||||
case "]":
|
||||
this.setTextBoxToNextWeek();
|
||||
break;
|
||||
case "{":
|
||||
this.setTextBoxToPreviousMonth();
|
||||
break;
|
||||
case "}":
|
||||
this.setTextBoxToNextMonth();
|
||||
break;
|
||||
default:
|
||||
handled = false;
|
||||
break;
|
||||
|
|
@ -270,12 +284,32 @@ DateDueKeyboardShortcutSupport.prototype = {
|
|||
this.addDaysToTextBoxDate(-1);
|
||||
},
|
||||
|
||||
setTextBoxToNextWeek : function() {
|
||||
this.addDaysToTextBoxDate(7);
|
||||
},
|
||||
|
||||
setTextBoxToPreviousWeek : function() {
|
||||
this.addDaysToTextBoxDate(-7);
|
||||
},
|
||||
|
||||
addDaysToTextBoxDate : function(numDays) {
|
||||
date = Date.parseDate(this.element.value, this.dateFormat);
|
||||
date.setDate(date.getDate() + numDays);
|
||||
this.setDate(date);
|
||||
},
|
||||
|
||||
setTextBoxToNextMonth : function() {
|
||||
date = Date.parseDate(this.element.value, this.dateFormat);
|
||||
date.setMonth(date.getMonth() + 1);
|
||||
this.setDate(date);
|
||||
},
|
||||
|
||||
setTextBoxToPreviousMonth : function() {
|
||||
date = Date.parseDate(this.element.value, this.dateFormat);
|
||||
date.setMonth(date.getMonth() - 1);
|
||||
this.setDate(date);
|
||||
},
|
||||
|
||||
setDate : function(date) {
|
||||
this.element.value = date.print(this.dateFormat);
|
||||
if (window.calendar) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue