-/* jQuery */
import $ from 'jquery';
-/* eslint-disable no-unused-vars */
-/* jquery has default scope */
-import cookie from 'jquery.cookie';
-import ui from 'jquery-ui-browserify';
-/* eslint-enable no-unused-vars */
-
-/* Annotations */
-import annotator from 'annotator';
+/* Global imports */
+import '../_global/index';
/* Shortcuts */
-import './shortcuts/main';
-import './shortcuts/entry';
-import '../../_global/js/shortcuts/main';
-import '../../_global/js/shortcuts/entry';
+import './js/shortcuts/main';
+import './js/shortcuts/entry';
/* Tools */
-import { savePercent, retrievePercent } from '../../_global/js/tools';
-import toggleSaveLinkForm from './uiTools';
-
-global.jquery = $;
+import toggleSaveLinkForm from './js/uiTools';
-$.fn.ready(() => {
- const $listmode = $('#listmode');
- const $listentries = $('#list-entries');
+/* Theme style */
+import './css/index.scss';
+$(document).ready(() => {
/* ==========================================================================
Menu
========================================================================== */
}
});
- /* ==========================================================================
- List mode or Table Mode
- ========================================================================== */
-
- $listmode.click(() => {
- if ($.cookie('listmode') === 1) {
- // Cookie
- $.removeCookie('listmode');
-
- $listentries.removeClass('listmode');
- $listmode.removeClass('tablemode');
- $listmode.addClass('listmode');
- } else {
- // Cookie
- $.cookie('listmode', 1, { expires: 365 });
-
- $listentries.addClass('listmode');
- $listmode.removeClass('listmode');
- $listmode.addClass('tablemode');
- }
- });
-
- /* ==========================================================================
- Cookie listmode
- ========================================================================== */
-
- if ($.cookie('listmode') === 1) {
- $listentries.addClass('listmode');
- $listmode.removeClass('listmode');
- $listmode.addClass('tablemode');
- }
-
/* ==========================================================================
Add tag panel
========================================================================== */
-
$('#nav-btn-add-tag').on('click', () => {
- $('.nav-panel-add-tag').toggle(100);
+ $('.baggy-add-tag').toggle(100);
$('.nav-panel-menu').addClass('hidden');
$('#tag_label').focus();
return false;
});
}
- /* ==========================================================================
- Annotations & Remember position
- ========================================================================== */
-
- if ($('article').length) {
- const app = new annotator.App();
-
- app.include(annotator.ui.main, {
- element: document.querySelector('article'),
- });
-
- const x = JSON.parse($('#annotationroutes').html());
- app.include(annotator.storage.http, x);
-
- app.start().then(() => {
- app.annotations.load({ entry: x.entryId });
- });
-
- $(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(() => {
- retrievePercent(x.entryId);
- });
- }
-
/**
* Close window after adding entry if popup
*/
window.close();
}
+ /**
+ if ($('article').size() > 0) {
+ const waypoint = new Waypoint({
+ element: $('.wallabag-title').get(0),
+ handler: (direction) => {
+ console.log(direction);
+ if (direction === 'down') {
+ $('aside.tags').fadeIn('slow');
+ } else {
+ $('aside.tags').fadeOut('slow');
+ }
+ },
+ offset: 250,
+ });
+ }
+ */
+
/**
* Tags autocomplete
*/
toggleBagit();
});
- const $bagitFormForm = $('#bagit-form-form');
+ const bagitFormForm = $('#bagit-form-form');
/* ==========================================================================
bag it link and close button
========================================================================== */
// send 'bag it link' form request via ajax
- $bagitFormForm.submit((event) => {
+ bagitFormForm.submit((event) => {
$('body').css('cursor', 'wait');
$('#add-link-result').empty();
$.ajax({
- type: $bagitFormForm.attr('method'),
- url: $bagitFormForm.attr('action'),
- data: $bagitFormForm.serialize(),
+ type: bagitFormForm.attr('method'),
+ url: bagitFormForm.attr('action'),
+ data: bagitFormForm.serialize(),
success: function success() {
$('#add-link-result').html('Done!');
- $('#plainurl').val('');
- $('#plainurl').blur('');
+ $('#plainurl').val('').blur('');
$('body').css('cursor', 'auto');
},
error: function error() {
$('article a[href^="http"]').after(
() => `<a href="${$(this).attr('href')}" class="add-to-wallabag-link-after" ` +
- 'alt="add to wallabag" title="add to wallabag"></a>'
+ 'title="add to wallabag"></a>',
);
$('.add-to-wallabag-link-after').click((event) => {