X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=app%2FResources%2Fstatic%2Fthemes%2Fmaterial%2Fjs%2Finit.js;h=0b2832c068fb4bcdc9d82e47f6f3a01392f18322;hb=1093e979ff49f9072c30d1d576c6adf1f8e76bdf;hp=d6a87941ee1baf89171731034869e5bf63793f05;hpb=0743287f955fd19fd1a04c91f3b40a4ac2236423;p=github%2Fwallabag%2Fwallabag.git diff --git a/app/Resources/static/themes/material/js/init.js b/app/Resources/static/themes/material/js/init.js index d6a87941..0b2832c0 100755 --- a/app/Resources/static/themes/material/js/init.js +++ b/app/Resources/static/themes/material/js/init.js @@ -1,29 +1,23 @@ -var $ = require('jquery'); -require('materialize'); -var annotator = require('annotator'); +/* jQuery */ +import $ from 'jquery'; -function initFilters() { - // no display if filters not aviable - if ($('div').is('#filters')) { - $('#button_filters').show(); - $('.button-collapse-right').sideNav({ edge: 'right' }); - $('#clear_form_filters').on('click', function () { - $('#filters input').val(''); - $('#filters :checked').removeAttr('checked'); - return false; - }); - } -} +/* Annotations */ +import annotator from 'annotator'; -function initExport() { - // no display if export not aviable - if ($('div').is('#export')) { - $('#button_export').show(); - $('.button-collapse-right').sideNav({ edge: 'right' }); - } -} +/* Tools */ +import { savePercent, retrievePercent, initFilters, initExport } from '../../_global/js/tools'; + +/* Import shortcuts */ +import './shortcuts/main'; +import './shortcuts/entry'; +import '../../_global/js/shortcuts/main'; +import '../../_global/js/shortcuts/entry'; -$(document).ready(function () { +require('materialize'); // eslint-disable-line + +global.jQuery = $; + +$(document).ready(() => { // sideNav $('.button-collapse').sideNav(); $('select').material_select(); @@ -40,13 +34,13 @@ $(document).ready(function () { initFilters(); initExport(); - $('#nav-btn-add-tag').on('click', function () { + $('#nav-btn-add-tag').on('click', () => { $('.nav-panel-add-tag').toggle(100); $('.nav-panel-menu').addClass('hidden'); $('#tag_label').focus(); return false; }); - $('#nav-btn-add').on('click', function () { + $('#nav-btn-add').on('click', () => { $('.nav-panel-buttom').hide(100); $('.nav-panel-add').show(100); $('.nav-panels .action').hide(100); @@ -55,16 +49,16 @@ $(document).ready(function () { $('#entry_url').focus(); return false; }); - $('#nav-btn-search').on('click', function () { + $('#nav-btn-search').on('click', () => { $('.nav-panel-buttom').hide(100); $('.nav-panel-search').show(100); $('.nav-panels .action').hide(100); $('.nav-panel-menu').addClass('hidden'); $('.nav-panels').css('background', 'white'); - $('#searchfield').focus(); + $('#search_entry_term').focus(); return false; }); - $('.close').on('click', function () { + $('.close').on('click', () => { $('.nav-panel-add').hide(100); $('.nav-panel-search').hide(100); $('.nav-panel-buttom').show(100); @@ -73,12 +67,12 @@ $(document).ready(function () { $('.nav-panels').css('background', 'transparent'); return false; }); - $(window).scroll(function () { - var s = $(window).scrollTop(); - var d = $(document).height(); - var c = $(window).height(); - var scrollPercent = (s / (d - c)) * 100; - $('.progress .determinate').css('width', scrollPercent + '%'); + $(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}%`); }); /* ========================================================================== @@ -86,9 +80,8 @@ $(document).ready(function () { ========================================================================== */ if ($('article').length) { - var app = new annotator.App(); - var x = JSON.parse($('#annotationroutes').html()); - + const app = new annotator.App(); + const x = JSON.parse($('#annotationroutes').html()); app.include(annotator.ui.main, { element: document.querySelector('article'), @@ -96,21 +89,21 @@ $(document).ready(function () { app.include(annotator.storage.http, x); - app.start().then(function () { + app.start().then(() => { app.annotations.load({ entry: x.entryId }); }); - $(window).scroll(function (e) { - var scrollTop = $(window).scrollTop(); - var docHeight = $(document).height(); - var scrollPercent = (scrollTop) / (docHeight); - var scrollPercentRounded = Math.round(scrollPercent * 100) / 100; + $(window).scroll(() => { + const scrollTop = $(window).scrollTop(); + const docHeight = $(document).height(); + const scrollPercent = (scrollTop) / (docHeight); + const scrollPercentRounded = Math.round(scrollPercent * 100) / 100; savePercent(x.entryId, scrollPercentRounded); }); retrievePercent(x.entryId); - $(window).resize(function () { + $(window).resize(() => { retrievePercent(x.entryId); }); }