[Rt-commit] rt branch, 4.0/datetimepicker-ui, created. rt-4.0.2-111-g504642f
Thomas Sibley
trs at bestpractical.com
Mon Sep 19 16:32:36 EDT 2011
The branch, 4.0/datetimepicker-ui has been created
at 504642f4f4cf0a16a5c8ea3eac3fd4e0dbd445b0 (commit)
- Log -----------------------------------------------------------------
commit d772292a40d661b493e115756025d38a7619d137
Author: Thomas Sibley <trs at bestpractical.com>
Date: Mon Sep 19 16:26:01 2011 -0400
Refactor common datepicker options
diff --git a/share/html/NoAuth/js/util.js b/share/html/NoAuth/js/util.js
index b1a4a0b..87cb3f5 100644
--- a/share/html/NoAuth/js/util.js
+++ b/share/html/NoAuth/js/util.js
@@ -222,14 +222,12 @@ function doOnLoad( js ) {
}
jQuery(function() {
- jQuery(".ui-datepicker:not(.withtime)").datepicker( {
- dateFormat: 'yy-mm-dd',
- constrainInput: false
- } );
-
- jQuery(".ui-datepicker.withtime").datepicker( {
+ var opts = {
dateFormat: 'yy-mm-dd',
constrainInput: false,
+ };
+ jQuery(".ui-datepicker:not(.withtime)").datepicker(opts);
+ jQuery(".ui-datepicker.withtime").datepicker( jQuery.extend({}, opts, {
onSelect: function( dateText, inst ) {
// trigger timepicker to get time
var button = document.createElement('input');
@@ -250,7 +248,7 @@ jQuery(function() {
jQuery(button).focus();
}
- } );
+ }) );
});
function textToHTML(value) {
commit b82fc5988f44264ea65bafd56751aacdd4a9539d
Author: Thomas Sibley <trs at bestpractical.com>
Date: Mon Sep 19 16:26:45 2011 -0400
Easier date selection through datepicker options
This enables selection of dates outside the current month, adds a
shortcut for "today", and provides dropdowns for quickly changing the
month or year.
diff --git a/share/html/NoAuth/js/util.js b/share/html/NoAuth/js/util.js
index 87cb3f5..346d457 100644
--- a/share/html/NoAuth/js/util.js
+++ b/share/html/NoAuth/js/util.js
@@ -225,6 +225,11 @@ jQuery(function() {
var opts = {
dateFormat: 'yy-mm-dd',
constrainInput: false,
+ showButtonPanel: true,
+ changeMonth: true,
+ changeYear: true,
+ showOtherMonths: true,
+ selectOtherMonths: true
};
jQuery(".ui-datepicker:not(.withtime)").datepicker(opts);
jQuery(".ui-datepicker.withtime").datepicker( jQuery.extend({}, opts, {
commit 504642f4f4cf0a16a5c8ea3eac3fd4e0dbd445b0
Author: Thomas Sibley <trs at bestpractical.com>
Date: Mon Sep 19 16:29:40 2011 -0400
Hook the timepicker on the actual input rather than a new button
Overall this is less jumpy and makes the timepicker appear directly
under the input being edited. It also solves 80% of the problems with
spilling over the right side of the page by naturally moving the top
left origin of the timepicker further left.
diff --git a/share/html/NoAuth/js/util.js b/share/html/NoAuth/js/util.js
index 346d457..260cdea 100644
--- a/share/html/NoAuth/js/util.js
+++ b/share/html/NoAuth/js/util.js
@@ -234,24 +234,15 @@ jQuery(function() {
jQuery(".ui-datepicker:not(.withtime)").datepicker(opts);
jQuery(".ui-datepicker.withtime").datepicker( jQuery.extend({}, opts, {
onSelect: function( dateText, inst ) {
- // trigger timepicker to get time
- var button = document.createElement('input');
- button.setAttribute('type', 'button');
- jQuery(button).width('5em');
- jQuery(button).insertAfter(this);
- jQuery(button).timepickr({val: '00:00'});
- var date_input = this;
-
- jQuery(button).blur( function() {
- var time = jQuery(button).val();
+ // trigger timepicker to get time, closing over dateText
+ jQuery(this).timepickr({ trigger: 'timepickr.show', updateLive: false }).bind('change.timepickr', function() {
+ jQuery(this).unbind('change.timepickr');
+ var time = jQuery(this).val();
if ( ! time.match(/\d\d:\d\d/) ) {
time = '00:00';
}
- jQuery(date_input).val( dateText + ' ' + time + ':00' );
- jQuery(button).remove();
- } );
-
- jQuery(button).focus();
+ jQuery(this).val( dateText + ' ' + time + ':00' );
+ }).trigger('timepickr.show');
}
}) );
});
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list