fix datepicker not closing, linting

Added defacto JavaScript linting with eslint. I also included an editor
config file to aid common style. (http://editorconfig.org/#example-file)
This commit is contained in:
Eli Flanagan 2017-12-30 13:44:40 -05:00
parent 0c584759e1
commit e922a4aac5
3 changed files with 43 additions and 10 deletions

17
.editorconfig Normal file
View File

@ -0,0 +1,17 @@
# EditorConfig is awesome: http://EditorConfig.org
# top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
# Matches multiple files with brace expansion notation
# Set default charset
[*.js]
charset = utf-8
indent_style = space
indent_size = 2

8
hledger-web/.eslintrc.js Normal file
View File

@ -0,0 +1,8 @@
module.exports = {
"extends": "eslint:recommended",
"root": true,
"env": {
"browser": true,
"jquery": true
}
};

View File

@ -4,23 +4,30 @@
// STARTUP
$(document).ready(function() {
// cache the input element as a variable
// for minor performance benefits
var dateEl = $('#dateWrap');
// ensure add form always focusses its first field
// ensure add form always focuses its first field
$('#addmodal')
.on('shown.bs.modal', function (e) {
.on('shown.bs.modal', function() {
addformFocus();
})
.on('hidden.bs.modal', function() {
// close the date picker if open
dateEl.datepicker('hide');
});
// show add form if ?add=1
if ($.url.param('add')) { addformShow(true); }
// date picker
// http://bootstrap-datepicker.readthedocs.io/en/latest/options.html
$('#dateWrap').datepicker({
showOnFocus: false,
autoclose: true,
format: 'yyyy-mm-dd'
});
// date picker
// http://bootstrap-datepicker.readthedocs.io/en/latest/options.html
dateEl.datepicker({
showOnFocus: false,
autoclose: true,
format: 'yyyy-mm-dd'
});
// sidebar account hover handlers
$('#sidebar td a').mouseenter(function(){ $(this).parent().addClass('mouseover'); });
@ -45,7 +52,7 @@ $(document).ready(function() {
if (window.location.hash && $(window.location.hash)[0]) {
$(window.location.hash).addClass('highlighted');
}
$(window).on('hashchange', function(event) {
$(window).on('hashchange', function() {
$('.highlighted').removeClass('highlighted');
$(window.location.hash).addClass('highlighted');
});
@ -57,6 +64,7 @@ $(document).ready(function() {
//----------------------------------------------------------------------
// REGISTER CHART
//eslint-disable-next-line no-unused-vars
function registerChart($container, series) {
// https://github.com/flot/flot/blob/master/API.md
return $container.plot(