Ensure that Date and DateTime widget uses the same keybindings as the GTk client
issue7176 review44071002
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
* Add shortcuts to Date and DateTime widgets
|
||||
* Use limit to expand tree
|
||||
* Use spellcheck and lang attributes for textbox widget
|
||||
* Support icon on page
|
||||
|
||||
@@ -185,6 +185,23 @@
|
||||
;
|
||||
};
|
||||
|
||||
Sao.common.DATE_OPERATORS = [
|
||||
['S', moment.duration(-1, 'seconds')],
|
||||
['s', moment.duration(1, 'seconds')],
|
||||
['I', moment.duration(-1, 'minutes')],
|
||||
['i', moment.duration(1, 'minutes')],
|
||||
['H', moment.duration(-1, 'hours')],
|
||||
['h', moment.duration(1, 'hours')],
|
||||
['D', moment.duration(-1, 'days')],
|
||||
['d', moment.duration(1, 'days')],
|
||||
['W', moment.duration(-1, 'weeks')],
|
||||
['w', moment.duration(1, 'weeks')],
|
||||
['M', moment.duration(-1, 'months')],
|
||||
['m', moment.duration(1, 'months')],
|
||||
['Y', moment.duration(-1, 'years')],
|
||||
['y', moment.duration(1, 'years')],
|
||||
];
|
||||
|
||||
Sao.common.date_format = function(format) {
|
||||
if (jQuery.isEmptyObject(format)) {
|
||||
format = '%Y-%m-%d';
|
||||
|
||||
+28
-1
@@ -1401,11 +1401,38 @@ function eval_pyson(value){
|
||||
}).append(jQuery('<span/>', {
|
||||
'class': 'glyphicon glyphicon-calendar'
|
||||
}))).appendTo(this.date);
|
||||
var noop = function () {};
|
||||
var reset_keyBinds = {};
|
||||
var default_keyBinds = this.date.datetimepicker.defaults.keyBinds;
|
||||
for (var key in default_keyBinds) {
|
||||
if (default_keyBinds.hasOwnProperty(key)) {
|
||||
reset_keyBinds[key] = noop;
|
||||
}
|
||||
}
|
||||
this.date.datetimepicker({
|
||||
'locale': moment.locale()
|
||||
'locale': moment.locale(),
|
||||
'keyBinds': reset_keyBinds,
|
||||
});
|
||||
this.date.css('width', this._width);
|
||||
this.date.on('dp.change', this.focus_out.bind(this));
|
||||
var mousetrap = new Mousetrap(this.el[0]);
|
||||
|
||||
mousetrap.bind(['enter', '='], function(e, combo) {
|
||||
if (e.which != Sao.common.RETURN_KEYCODE) {
|
||||
e.preventDefault();
|
||||
}
|
||||
this.date.data('DateTimePicker').date(moment());
|
||||
}.bind(this));
|
||||
|
||||
Sao.common.DATE_OPERATORS.forEach(function(operator) {
|
||||
mousetrap.bind(operator[0], function(e, combo) {
|
||||
e.preventDefault();
|
||||
var dp = this.date.data('DateTimePicker');
|
||||
var date = dp.date();
|
||||
date.add(operator[1]);
|
||||
dp.date(date);
|
||||
}.bind(this));
|
||||
}.bind(this));
|
||||
},
|
||||
get_format: function(record, field) {
|
||||
return field.date_format(record);
|
||||
|
||||
Reference in New Issue
Block a user