]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - app/Resources/static/themes/baggy/index.js
Adds Webpack support and removes the use for Grunt
[github/wallabag/wallabag.git] / app / Resources / static / themes / baggy / index.js
similarity index 69%
rename from app/Resources/static/themes/baggy/js/init.js
rename to app/Resources/static/themes/baggy/index.js
index 05360a287bc340c7f2d6fea724981d5e0e311b1e..5d448018325864fea55697eacbc21365edd8666b 100755 (executable)
@@ -1,31 +1,19 @@
-/* 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
      ========================================================================== */
@@ -38,45 +26,12 @@ $.fn.ready(() => {
     }
   });
 
-  /* ==========================================================================
-     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;
@@ -95,39 +50,6 @@ $.fn.ready(() => {
     });
   }
 
-  /* ==========================================================================
-     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
    */
@@ -136,6 +58,23 @@ $.fn.ready(() => {
     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
    */
@@ -283,25 +222,24 @@ $.fn.ready(() => {
     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() {
@@ -319,7 +257,7 @@ $.fn.ready(() => {
 
   $('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) => {