From 1ccc7b4a04afc9ae2c6a7ecd2ace08b1db493556 Mon Sep 17 00:00:00 2001 From: Jan Schneider Date: Fri, 12 Feb 2010 20:32:34 +0100 Subject: [PATCH] Set default due date/time. --- kronolith/js/kronolith.js | 24 ++++++++++++++++++++++++ nag/lib/Api.php | 3 +++ 2 files changed, 27 insertions(+) diff --git a/kronolith/js/kronolith.js b/kronolith/js/kronolith.js index 353a09d16..b1d0b482b 100644 --- a/kronolith/js/kronolith.js +++ b/kronolith/js/kronolith.js @@ -1842,6 +1842,9 @@ KronolithCore = { $('kronolithTaskList').setValue(Kronolith.conf.tasks.default_tasklist); //$('kronolithTaskLocation').setValue('http://'); $('kronolithTaskPriority').setValue(3); + if (Kronolith.conf.tasks.default_due) { + this.setDefaultDue(); + } $('kronolithTaskDelete').hide(); RedBox.showHtml($('kronolithTaskDialog').show()); } @@ -1925,6 +1928,25 @@ KronolithCore = { }, /** + * Sets the default due date and time for tasks. + */ + setDefaultDue: function() + { + if ($F('kronolithTaskDueDate') || $F('kronolithTaskDueTime')) { + return; + } + $('kronolithTaskDueDate').setValue(new Date().add(Kronolith.conf.tasks.default_due_days).days().toString(Kronolith.conf.date_format)); + if (Kronolith.conf.tasks.default_due_time == 'now') { + $('kronolithTaskDueTime').setValue(new Date().toString(Kronolith.conf.time_format)); + } else { + var date = new Date(); + date.setHours(Kronolith.conf.tasks.default_due_time.replace(/:.*$/, '')); + date.setMinutes(0); + $('kronolithTaskDueTime').setValue(date.toString(Kronolith.conf.time_format)); + } + }, + + /** * Finally removes a task from the DOM and the cache. * * @param string task A task id. @@ -3810,6 +3832,8 @@ KronolithCore = { $('kronolithEventStartDate', 'kronolithEventEndDate', 'kronolithTaskDueDate').compact().invoke('observe', 'blur', this.checkDate.bind(this)); $('kronolithEventStartTime', 'kronolithEventEndTime', 'kronolithTaskDueTime').compact().invoke('observe', 'blur', this.checkTime.bind(this)); + $('kronolithTaskDueDate', 'kronolithEventDueTime').compact().invoke('observe', 'focus', this.setDefaultDue.bind(this)); + // Mouse wheel handler. [ 'kronolithEventStartDate', 'kronolithEventEndDate' ].each(function(field) { $(field).observe(Prototype.Browser.Gecko ? 'DOMMouseScroll' : 'mousewheel', function(e) { diff --git a/nag/lib/Api.php b/nag/lib/Api.php index ada54afa7..2c2774e85 100644 --- a/nag/lib/Api.php +++ b/nag/lib/Api.php @@ -27,6 +27,9 @@ class Nag_Api extends Horde_Registry_Api { return array( 'default_tasklist' => Nag::getDefaultTasklist(Horde_Perms::EDIT), + 'default_due' => (bool)$GLOBALS['prefs']->getValue('default_due'), + 'default_due_days' => (int)$GLOBALS['prefs']->getValue('default_due_days'), + 'default_due_time' => $GLOBALS['prefs']->getValue('default_due_time'), ); } -- 2.11.0