Skip to content

Commit

Permalink
Highstock: Fixed issue with the range selector input boxes not being …
Browse files Browse the repository at this point in the history
…able to focus after first focusing, then clicking on the chart outside the input.
  • Loading branch information
TorsteinHonsi committed Mar 27, 2015
1 parent de2c16c commit 872c94e
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 26 deletions.
40 changes: 27 additions & 13 deletions js/highstock.src.js
Original file line number Diff line number Diff line change
Expand Up @@ -22151,6 +22151,30 @@ RangeSelector.prototype = {
this[name + 'DateBox'].attr({ text: dateFormat(options.inputDateFormat || '%b %e, %Y', this[name + 'Input'].HCTime) });
},

showInput: function (name) {
var inputGroup = this.inputGroup,
dateBox = this[name + 'DateBox'];

css(this[name + 'Input'], {
left: (inputGroup.translateX + dateBox.x) + PX,
top: inputGroup.translateY + PX,
width: (dateBox.width - 2) + PX,
height: (dateBox.height - 2) + PX,
border: '2px solid silver'
});
},

hideInput: function (name) {
if (document.activeElement === this[name + 'Input']) { // Prevent running again and again
css(this[name + 'Input'], {
border: 0,
width: '1px',
height: '1px'
});
this.setInputValue(name);
}
},

/**
* Draw either the 'from' or the 'to' HTML input box of the range selector
* @param {Object} name
Expand Down Expand Up @@ -22193,6 +22217,7 @@ RangeSelector.prototype = {
color: '#444'
}, chartStyle, options.inputStyle))
.on('click', function () {
rangeSelector.showInput(name); // If it is already focused, the onfocus event doesn't fire (#3713)
rangeSelector[name + 'Input'].focus();
})
.add(inputGroup);
Expand All @@ -22219,22 +22244,11 @@ RangeSelector.prototype = {

// Blow up the input box
input.onfocus = function () {
css(this, {
left: (inputGroup.translateX + dateBox.x) + PX,
top: inputGroup.translateY + PX,
width: (dateBox.width - 2) + PX,
height: (dateBox.height - 2) + PX,
border: '2px solid silver'
});
rangeSelector.showInput(name);
};
// Hide away the input box
input.onblur = function () {
css(this, {
border: 0,
width: '1px',
height: '1px'
});
rangeSelector.setInputValue(name);
rangeSelector.hideInput(name);
};

// handle changes in the input boxes
Expand Down
40 changes: 27 additions & 13 deletions js/parts/RangeSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,30 @@ RangeSelector.prototype = {
this[name + 'DateBox'].attr({ text: dateFormat(options.inputDateFormat || '%b %e, %Y', this[name + 'Input'].HCTime) });
},

showInput: function (name) {
var inputGroup = this.inputGroup,
dateBox = this[name + 'DateBox'];

css(this[name + 'Input'], {
left: (inputGroup.translateX + dateBox.x) + PX,
top: inputGroup.translateY + PX,
width: (dateBox.width - 2) + PX,
height: (dateBox.height - 2) + PX,
border: '2px solid silver'
});
},

hideInput: function (name) {
if (document.activeElement === this[name + 'Input']) { // Prevent running again and again
css(this[name + 'Input'], {
border: 0,
width: '1px',
height: '1px'
});
this.setInputValue(name);
}
},

/**
* Draw either the 'from' or the 'to' HTML input box of the range selector
* @param {Object} name
Expand Down Expand Up @@ -404,6 +428,7 @@ RangeSelector.prototype = {
color: '#444'
}, chartStyle, options.inputStyle))
.on('click', function () {
rangeSelector.showInput(name); // If it is already focused, the onfocus event doesn't fire (#3713)
rangeSelector[name + 'Input'].focus();
})
.add(inputGroup);
Expand All @@ -430,22 +455,11 @@ RangeSelector.prototype = {

// Blow up the input box
input.onfocus = function () {
css(this, {
left: (inputGroup.translateX + dateBox.x) + PX,
top: inputGroup.translateY + PX,
width: (dateBox.width - 2) + PX,
height: (dateBox.height - 2) + PX,
border: '2px solid silver'
});
rangeSelector.showInput(name);
};
// Hide away the input box
input.onblur = function () {
css(this, {
border: 0,
width: '1px',
height: '1px'
});
rangeSelector.setInputValue(name);
rangeSelector.hideInput(name);
};

// handle changes in the input boxes
Expand Down

0 comments on commit 872c94e

Please sign in to comment.