2016-10-26 23:57:27 +00:00
|
|
|
import $ from 'jquery';
|
2016-11-03 09:02:16 +00:00
|
|
|
|
2017-03-31 18:21:41 +00:00
|
|
|
/* Materialize imports */
|
|
|
|
import 'materialize-css/dist/css/materialize.css';
|
|
|
|
import 'materialize-css/dist/js/materialize';
|
|
|
|
|
|
|
|
/* Global imports */
|
|
|
|
import '../_global/index';
|
2016-11-03 09:02:16 +00:00
|
|
|
|
|
|
|
/* Tools */
|
2017-03-31 18:21:41 +00:00
|
|
|
import { initExport, initFilters } from './js/tools';
|
2016-11-03 09:02:16 +00:00
|
|
|
|
|
|
|
/* Import shortcuts */
|
2017-03-31 18:21:41 +00:00
|
|
|
import './js/shortcuts/main';
|
|
|
|
import './js/shortcuts/entry';
|
2016-10-04 13:30:05 +00:00
|
|
|
|
2017-03-31 18:21:41 +00:00
|
|
|
/* Theme style */
|
|
|
|
import './css/index.scss';
|
2016-03-08 16:02:34 +00:00
|
|
|
|
2016-09-28 08:30:18 +00:00
|
|
|
$(document).ready(() => {
|
2016-06-09 17:02:38 +00:00
|
|
|
// sideNav
|
|
|
|
$('.button-collapse').sideNav();
|
|
|
|
$('select').material_select();
|
|
|
|
$('.collapsible').collapsible({
|
|
|
|
accordion: false,
|
|
|
|
});
|
|
|
|
$('.datepicker').pickadate({
|
|
|
|
selectMonths: true,
|
|
|
|
selectYears: 15,
|
|
|
|
formatSubmit: 'dd/mm/yyyy',
|
|
|
|
hiddenName: true,
|
|
|
|
format: 'dd/mm/yyyy',
|
2017-03-31 18:21:41 +00:00
|
|
|
container: 'body',
|
2016-06-09 17:02:38 +00:00
|
|
|
});
|
|
|
|
initFilters();
|
|
|
|
initExport();
|
2015-08-04 16:39:26 +00:00
|
|
|
|
2017-12-28 22:27:45 +00:00
|
|
|
const toggleNav = (toShow, toFocus) => {
|
|
|
|
$('.nav-panel-actions').hide(100);
|
|
|
|
$(toShow).show(100);
|
|
|
|
$('.nav-panels').css('background', 'white');
|
|
|
|
$(toFocus).focus();
|
|
|
|
};
|
|
|
|
|
2016-09-28 08:30:18 +00:00
|
|
|
$('#nav-btn-add-tag').on('click', () => {
|
2016-06-09 17:02:38 +00:00
|
|
|
$('.nav-panel-add-tag').toggle(100);
|
|
|
|
$('.nav-panel-menu').addClass('hidden');
|
|
|
|
$('#tag_label').focus();
|
|
|
|
return false;
|
|
|
|
});
|
2016-09-28 08:30:18 +00:00
|
|
|
$('#nav-btn-add').on('click', () => {
|
2017-12-28 22:27:45 +00:00
|
|
|
toggleNav('.nav-panel-add', '#entry_url');
|
2016-06-09 17:02:38 +00:00
|
|
|
return false;
|
|
|
|
});
|
2017-12-28 21:54:42 +00:00
|
|
|
const materialAddForm = $('.nav-panel-add');
|
2017-11-01 11:32:14 +00:00
|
|
|
materialAddForm.on('submit', () => {
|
|
|
|
materialAddForm.addClass('disabled');
|
|
|
|
$('input#entry_url', materialAddForm).prop('readonly', true).trigger('blur');
|
|
|
|
});
|
2016-09-28 08:30:18 +00:00
|
|
|
$('#nav-btn-search').on('click', () => {
|
2017-12-28 22:27:45 +00:00
|
|
|
toggleNav('.nav-panel-search', '#search_entry_term');
|
2016-06-09 17:02:38 +00:00
|
|
|
return false;
|
|
|
|
});
|
2017-12-28 22:27:45 +00:00
|
|
|
$('.close').on('click', (e) => {
|
|
|
|
$(e.target).parent('.nav-panel-item').hide(100);
|
2017-12-28 21:54:42 +00:00
|
|
|
$('.nav-panel-actions').show(100);
|
2016-06-09 17:02:38 +00:00
|
|
|
$('.nav-panels').css('background', 'transparent');
|
|
|
|
return false;
|
|
|
|
});
|
2016-09-28 08:30:18 +00:00
|
|
|
$(window).scroll(() => {
|
|
|
|
const s = $(window).scrollTop();
|
|
|
|
const d = $(document).height();
|
|
|
|
const c = $(window).height();
|
|
|
|
const scrollPercent = (s / (d - c)) * 100;
|
|
|
|
$('.progress .determinate').css('width', `${scrollPercent}%`);
|
2016-06-09 17:02:38 +00:00
|
|
|
});
|
2015-08-11 16:07:02 +00:00
|
|
|
});
|