Permalink
Browse files

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)
  • Loading branch information...
efx committed Dec 30, 2017
1 parent 0c58475 commit e922a4aac594df86972787c3700ba3f0c5b26523
Showing with 43 additions and 10 deletions.
  1. +17 −0 .editorconfig
  2. +8 −0 hledger-web/.eslintrc.js
  3. +18 −10 hledger-web/static/hledger.js
@@ -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
@@ -0,0 +1,8 @@
module.exports = {
"extends": "eslint:recommended",
"root": true,
"env": {
"browser": true,
"jquery": true
}
};
@@ -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(

0 comments on commit e922a4a

Please sign in to comment.