]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Assets work
authorThomas Citharel <tcit@tcit.fr>
Wed, 28 Sep 2016 08:30:18 +0000 (10:30 +0200)
committerThomas Citharel <tcit@tcit.fr>
Wed, 28 Sep 2016 08:30:18 +0000 (10:30 +0200)
* ES6 all the things !

* ESLint checks everything

* CSS fixes (use stylelint)

* Fix #2231

23 files changed:
.eslintrc.json
.gitignore
.stylelintrc [new file with mode: 0644]
Gruntfile.js
app/Resources/static/themes/_global/js/bookmarklet.js
app/Resources/static/themes/_global/js/restoreScroll.js [deleted file]
app/Resources/static/themes/_global/js/tools.js [new file with mode: 0644]
app/Resources/static/themes/baggy/css/main.css
app/Resources/static/themes/baggy/css/ratatouille.css
app/Resources/static/themes/baggy/js/autoClose.js [deleted file]
app/Resources/static/themes/baggy/js/autoCompleteTags.js
app/Resources/static/themes/baggy/js/closeMessage.js [deleted file]
app/Resources/static/themes/baggy/js/init.js
app/Resources/static/themes/baggy/js/popupForm.js [deleted file]
app/Resources/static/themes/baggy/js/saveLink.js [deleted file]
app/Resources/static/themes/baggy/js/uiTools.js [new file with mode: 0644]
app/Resources/static/themes/material/css/main.css
app/Resources/static/themes/material/css/print.css
app/Resources/static/themes/material/js/init.js
package.json
src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entries.html.twig
src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entry.html.twig
src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig

index 976a9eb59996bdb5cb000afd5f478e2f424928ad..d6279c641624501550e75ab9a84e90fbfcea5ec1 100644 (file)
@@ -1,4 +1,4 @@
 {
     "extends": "airbnb",
-    "installedESLint": true,
+    "parser": "babel-eslint"
 }
index fb51034e28110d62921deddf00cbacaf6eb85358..9e793a54f1455b3ba4efdf2a2073ed6c879a4840 100644 (file)
@@ -49,3 +49,7 @@ app/Resources/static/lib/*
 /bin
 !/src/Wallabag/CoreBundle/Resources/public
 /src/Wallabag/CoreBundle/Resources/public/*
+
+# PHPStorm
+.idea/
+
diff --git a/.stylelintrc b/.stylelintrc
new file mode 100644 (file)
index 0000000..40db42c
--- /dev/null
@@ -0,0 +1,3 @@
+{
+  "extends": "stylelint-config-standard"
+}
index 8dc5b83bdb3a8fd74d9298c6064085d7338687e4..9277408110f28daac3fe6dfc3759eb1429f2ad85 100644 (file)
@@ -41,27 +41,6 @@ module.exports = function (grunt) {
       options: {
         separator: ';',
       },
-      jsMaterial: {
-        src: [
-          '<%= appDir %>/themes/material/js/init.js',
-          '<%= appDir %>/themes/_global/js/restoreScroll.js',
-          'node_modules/jquery.tinydot/src/jquery.tinydot.js',
-        ],
-        dest: '<%= buildDir %>/material.js',
-      },
-      jsBaggy: {
-        src: [
-          '<%= appDir %>/themes/baggy/js/init.js',
-          '<%= appDir %>/themes/_global/js/restoreScroll.js',
-          '<%= appDir %>/themes/baggy/js/autoClose.js',
-          '<%= appDir %>/themes/baggy/js/autoCompleteTags.js',
-          '<%= appDir %>/themes/baggy/js/closeMessage.js',
-          '<%= appDir %>/themes/baggy/js/popupForm.js',
-          // Save link is no more used for now
-          // '<%= appDir %>/themes/baggy/js/saveLink.js',
-        ],
-        dest: '<%= buildDir %>/baggy.js',
-      },
       cssMaterial: {
         src: [
           'node_modules/materialize-css/bin/materialize.css',
@@ -77,8 +56,27 @@ module.exports = function (grunt) {
       },
     },
     browserify: {
-      '<%= buildDir %>/material.browser.js': ['<%= buildDir %>/material.js'],
-      '<%= buildDir %>/baggy.browser.js': ['<%= buildDir %>/baggy.js'],
+      dist: {
+        files: {
+          '<%= buildDir %>/material.browser.js': ['<%= appDir %>/themes/material/js/init.js'],
+          '<%= buildDir %>/baggy.browser.js': ['<%= appDir %>/themes/baggy/js/init.js']
+        }
+      },
+      options: {
+        sourceType: "module",
+        transform: [
+          ["babelify", {
+          presets: ["es2015"]
+        }], "browserify-shim"
+        ],
+        browserifyOptions: {
+          browser: {
+            "jQuery": "./node_modules/jquery/dist/jquery.js",
+            "jquery.tinydot": "./nodes_modules/jquery.tinydot/src/jquery.tinydot.js"
+          }
+        }
+      }
+
     },
     uglify: {
       material: {
@@ -199,7 +197,7 @@ module.exports = function (grunt) {
   grunt.registerTask(
     'js',
     'Build and install js files',
-    ['clean:js', 'copy:pickerjs', 'concat:jsMaterial', 'concat:jsBaggy', 'browserify', 'uglify']
+    ['clean:js', 'copy:pickerjs', 'browserify', 'uglify']
     );
 
   grunt.registerTask(
index 2afdfc3cb1d07b5146d327ee3f98c9f04a2bce32..5174ff472e54e055067fcddb669eae6c930f5d01 100644 (file)
@@ -1,2 +1,6 @@
 
-top["bookmarklet-url@wallabag.org"]=""+"<!DOCTYPE html>"+"<html>"+"<head>"+"<title>bag it!</title>"+'<link rel="icon" href="tpl/img/favicon.ico" />'+"</head>"+"<body>"+"<script>"+"window.onload=function(){"+"window.setTimeout(function(){"+"history.back();"+"},250);"+"};"+"</scr"+"ipt>"+"</body>"+"</html>"
+top['bookmarklet-url@wallabag.org'] =
+    '<!DOCTYPE html><html><head><title>bag it!</title>' +
+    '<link rel="icon" href="tpl/img/favicon.ico" />' +
+    '</head><body><script>window.onload=function(){window.setTimeout' +
+    '(function(){history.back();},250);};</script></body></html>';
diff --git a/app/Resources/static/themes/_global/js/restoreScroll.js b/app/Resources/static/themes/_global/js/restoreScroll.js
deleted file mode 100644 (file)
index 9c4d7e2..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-function supportsLocalStorage() {
-  try {
-    return 'localStorage' in window && window.localStorage !== null;
-  } catch (e) {
-    return false;
-  }
-}
-
-function savePercent(id, percent) {
-  if (!supportsLocalStorage()) { return false; }
-  localStorage['wallabag.article.' + id + '.percent'] = percent;
-  return true;
-}
-
-function retrievePercent(id) {
-  if (!supportsLocalStorage()) { return false; }
-
-  var bheight = $(document).height();
-  var percent = localStorage['wallabag.article.' + id + '.percent'];
-  var scroll = bheight * percent;
-
-  $('html,body').animate({ scrollTop: scroll }, 'fast');
-
-  return true;
-}
diff --git a/app/Resources/static/themes/_global/js/tools.js b/app/Resources/static/themes/_global/js/tools.js
new file mode 100644 (file)
index 0000000..ab30deb
--- /dev/null
@@ -0,0 +1,50 @@
+const $ = require('jquery');
+
+function supportsLocalStorage() {
+  try {
+    return 'localStorage' in window && window.localStorage !== null;
+  } catch (e) {
+    return false;
+  }
+}
+
+function savePercent(id, percent) {
+  if (!supportsLocalStorage()) { return false; }
+  localStorage[`wallabag.article.${id}.percent`] = percent;
+  return true;
+}
+
+function retrievePercent(id) {
+  if (!supportsLocalStorage()) { return false; }
+
+  const bheight = $(document).height();
+  const percent = localStorage[`wallabag.article.${id}.percent`];
+  const scroll = bheight * percent;
+
+  $('html,body').animate({ scrollTop: scroll }, 'fast');
+
+  return true;
+}
+
+function initFilters() {
+  // no display if filters not available
+  if ($('div').is('#filters')) {
+    $('#button_filters').show();
+    $('.button-collapse-right').sideNav({ edge: 'right' });
+    $('#clear_form_filters').on('click', () => {
+      $('#filters input').val('');
+      $('#filters :checked').removeAttr('checked');
+      return false;
+    });
+  }
+}
+
+function initExport() {
+  // no display if export not available
+  if ($('div').is('#export')) {
+    $('#button_export').show();
+    $('.button-collapse-right').sideNav({ edge: 'right' });
+  }
+}
+
+export { savePercent, retrievePercent, initFilters, initExport };
index 7ffaa12cebc894eeda2e04c7f252f7271948870d..58f0eb82a7351b56e9292a286bc6f64da73eeeca 100755 (executable)
@@ -481,9 +481,6 @@ footer a {
   text-transform: none;
   margin-bottom: 0;
   line-height: 1.2;
-  text-align: justify;
-  -moz-text-align-last: center;
-  text-align-last: center;
 }
 
 .entry h2::after {
@@ -1071,7 +1068,7 @@ pre code {
   font-family: "Courier New", Courier, monospace;
 }
 
-#filter-form {
+#filters {
   position: fixed;
   width: 20%;
   height: 100%;
@@ -1086,7 +1083,7 @@ pre code {
   min-width: 300px;
 }
 
-#filter-form form .filter-group {
+#filters form .filter-group {
   margin: 5px;
 }
 
@@ -1125,9 +1122,11 @@ pre code {
   .entry {
     width: 49%;
   }
+
   .entry:nth-child(3n+1) {
     margin-left: 1.5%;
   }
+
   .entry:nth-child(2n+1) {
     margin-left: 0;
   }
@@ -1137,6 +1136,7 @@ pre code {
   #article {
     width: 80%;
   }
+
   .topPosF {
     right: 2.5em;
   }
@@ -1147,6 +1147,7 @@ pre code {
     width: 100%;
     margin-left: 0;
   }
+
   #display-mode {
     display: none;
   }
@@ -1197,7 +1198,6 @@ pre code {
     height: auto;
     top: 0.5em;
     width: 75px;
-    height: 75px;
     margin-left: -37.5px;
   }
 
@@ -1214,6 +1214,7 @@ pre code {
     background-color: #999;
     font-size: 1.2em;
   }
+
   .desktopHide:hover,
   .desktopHide:focus {
     background-color: #fff;
index b5aeb54e415352e81898c01e1fdaecdee27f607b..a6167f34436d93186bad1e182cdaa8df502d1c6b 100644 (file)
@@ -63,7 +63,9 @@ pre {
   max-width: 61.25em; /* 980px */
 }
 
-table, img, figure {
+table,
+img,
+figure {
   max-width: 100%;
   height: auto;
 }
diff --git a/app/Resources/static/themes/baggy/js/autoClose.js b/app/Resources/static/themes/baggy/js/autoClose.js
deleted file mode 100644 (file)
index b0dafab..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-var $ = global.jquery = require('jquery');
-
-$(document).ready(function () {
-  var currentUrl = window.location.href;
-  if (currentUrl.match('&closewin=true')) {
-    window.close();
-  }
-});
index edd0a421e27be5d16f76b188bf1fdbc6bd852386..f287ebfa9168dcf127f2f20f207560af8571263b 100755 (executable)
@@ -1,46 +1,8 @@
-var $ = global.jquery = require('jquery');
+function split(val) {
+  return val.split(/,\s*/);
+}
+function extractLast(term) {
+  return split(term).pop();
+}
 
-jQuery(function ($) {
-  function split(val) {
-    return val.split(/,\s*/);
-  }
-  function extractLast(term) {
-    return split(term).pop();
-  }
-
-
-  $('#value').bind('keydown', function (event) {
-    if (event.keyCode === $.ui.keyCode.TAB && $(this).data('ui-autocomplete').menu.active) {
-      event.preventDefault();
-    }
-  }).autocomplete({
-    source: function (request, response) {
-      $.getJSON('./?view=tags', {
-        term: extractLast(request.term),
-        //id: $(':hidden#entry_id').val()
-      }, response);
-    },
-    search: function () {
-      // custom minLength
-      var term = extractLast(this.value);
-      if (term.length < 1) {
-        return false;
-      }
-    },
-    focus: function () {
-      // prevent value inserted on focus
-      return false;
-    },
-    select: function (event, ui) {
-      var terms = split(this.value);
-      // remove the current input
-      terms.pop();
-      // add the selected item
-      terms.push(ui.item.value);
-      // add placeholder to get the comma-and-space at the end
-      terms.push('');
-      this.value = terms.join(', ');
-      return false;
-    },
-  });
-});
+export { split, extractLast };
diff --git a/app/Resources/static/themes/baggy/js/closeMessage.js b/app/Resources/static/themes/baggy/js/closeMessage.js
deleted file mode 100644 (file)
index ae4b179..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-var $ = global.jquery = require('jquery');
-
-$(function () {
-  //---------------------------------------------------------------------------
-  // Show the close icon when the user hover over a message
-  //---------------------------------------------------------------------------
-  // $('.messages').on('mouseenter', function(){
-  //      $(this).find('a.closeMessage').stop(true, true).show();
-  // }).on('mouseleave', function(){
-  //      $(this).find('a.closeMessage').stop(true, true).hide();
-  // });
-  //---------------------------------------------------------------------------
-  // Close the message box when the user clicks the close icon
-  //---------------------------------------------------------------------------
-  $('a.closeMessage').on('click', function () {
-    $(this).parents('div.messages').slideUp(300, function () { $(this).remove(); });
-    return false;
-  });
-});
index d7d4b166155daf3a4a2c43fb79150ee30949d343..c6a54f6fa696fc75c858d8a4ee327a3455aa89fa 100755 (executable)
@@ -1,21 +1,25 @@
-var $ = global.jquery = require('jquery');
+const $ = global.jquery = require('jquery');
 require('jquery.cookie');
 require('jquery-ui');
-var annotator = require('annotator');
+const annotator = require('annotator');
+import { savePercent, retrievePercent } from '../../_global/js/tools.js';
+import { split, extractLast } from './autoCompleteTags.js';
+import { toggleSaveLinkForm } from './uiTools.js';
 
 
-$.fn.ready(function () {
-  var $listmode = $('#listmode');
-  var $listentries = $('#list-entries');
+$.fn.ready(() => {
+  const $listmode = $('#listmode');
+  const $listentries = $('#list-entries');
 
   /* ==========================================================================
      Menu
      ========================================================================== */
 
-  $('#menu').click(function () {
+  $('#menu').click(() => {
     $('#links').toggleClass('menu--open');
-    if ($('#content').hasClass('opacity03')) {
-      $('#content').removeClass('opacity03');
+    const content = $('#content');
+    if (content.hasClass('opacity03')) {
+      content.removeClass('opacity03');
     }
   });
 
@@ -23,8 +27,8 @@ $.fn.ready(function () {
      List mode or Table Mode
      ========================================================================== */
 
-  $listmode.click(function () {
-    if (jquery.cookie('listmode') === 1) {
+  $listmode.click(() => {
+    if ($.cookie('listmode') === 1) {
       // Cookie
       $.removeCookie('listmode');
 
@@ -33,7 +37,7 @@ $.fn.ready(function () {
       $listmode.addClass('listmode');
     } else {
       // Cookie
-      jquery.cookie('listmode', 1, { expires: 365 });
+      $.cookie('listmode', 1, { expires: 365 });
 
       $listentries.addClass('listmode');
       $listmode.removeClass('listmode');
@@ -45,7 +49,7 @@ $.fn.ready(function () {
      Cookie listmode
      ========================================================================== */
 
-  if (jquery.cookie('listmode') === 1) {
+  if ($.cookie('listmode') === 1) {
     $listentries.addClass('listmode');
     $listmode.removeClass('listmode');
     $listmode.addClass('tablemode');
@@ -56,43 +60,250 @@ $.fn.ready(function () {
      ========================================================================== */
 
 
-  $('#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;
   });
 
+  /**
+   * Filters & Export
+   */
+  // no display if filters not available
+  if ($('div').is('#filters')) {
+    $('#button_filters').show();
+    $('#clear_form_filters').on('click', () => {
+      $('#filters input').val('');
+      $('#filters :checked').removeAttr('checked');
+      return false;
+    });
+  }
+
   /* ==========================================================================
      Annotations & Remember position
      ========================================================================== */
 
-    if ($('article').length) {
-      var app = new annotator.App();
+  if ($('article').length) {
+    const app = new annotator.App();
+
+    app.include(annotator.ui.main, {
+      element: document.querySelector('article'),
+    });
 
-      app.include(annotator.ui.main, {
-        element: document.querySelector('article'),
-      });
+    const x = JSON.parse($('#annotationroutes').html());
+    app.include(annotator.storage.http, x);
 
-      var x = JSON.parse($('#annotationroutes').html());
-      app.include(annotator.storage.http, x);
+    app.start().then(() => {
+      app.annotations.load({ entry: x.entryId });
+    });
 
-      app.start().then(function () {
-        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);
+    });
 
-      $(window).scroll(function (e) {
-        var scrollTop = $(window).scrollTop();
-        var docHeight = $(document).height();
-        var scrollPercent = (scrollTop) / (docHeight);
-        var 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
+   */
+  const currentUrl = window.location.href;
+  if (currentUrl.match('&closewin=true')) {
+    window.close();
+  }
+
+  /**
+   * Tags autocomplete
+   */
+  $('#value').bind('keydown', (event) => {
+    if (event.keyCode === $.ui.keyCode.TAB && $(this).data('ui-autocomplete').menu.active) {
+      event.preventDefault();
+    }
+  }).autocomplete({
+    source: function source(request, response) {
+      $.getJSON('./?view=tags', {
+        term: extractLast(request.term),
+        //id: $(':hidden#entry_id').val()
+      }, response);
+    },
+    search: function search() {
+      // custom minLength
+      const term = extractLast(this.value);
+      return term.length >= 1;
+    },
+    focus: function focus() {
+      // prevent value inserted on focus
+      return false;
+    },
+    select: function select(event, ui) {
+      const terms = split(this.value);
+      // remove the current input
+      terms.pop();
+      // add the selected item
+      terms.push(ui.item.value);
+      // add placeholder to get the comma-and-space at the end
+      terms.push('');
+      this.value = terms.join(', ');
+      return false;
+    },
+  });
+
+  //---------------------------------------------------------------------------
+  // Close the message box when the user clicks the close icon
+  //---------------------------------------------------------------------------
+  $('a.closeMessage').on('click', () => {
+    $(this).parents('div.messages').slideUp(300, () => { $(this).remove(); });
+    return false;
+  });
+
+  $('#search-form').hide();
+  $('#bagit-form').hide();
+  $('#filters').hide();
+  $('#download-form').hide();
 
-      $(window).resize(function () {
-          retrievePercent(x.entryId);
-      });
+  //---------------------------------------------------------------------------
+  // Toggle the 'Search' popup in the sidebar
+  //---------------------------------------------------------------------------
+  function toggleSearch() {
+    $('#search-form').toggle();
+    $('#search').toggleClass('current');
+    $('#search').toggleClass('active-current');
+    $('#search-arrow').toggleClass('arrow-down');
+    if ($('#search').hasClass('current')) {
+      $('#content').addClass('opacity03');
+    } else {
+      $('#content').removeClass('opacity03');
+    }
+  }
+
+  //---------------------------------------------------------------------------
+  // Toggle the 'Filter' popup on entries list
+  //---------------------------------------------------------------------------
+  function toggleFilter() {
+    $('#filters').toggle();
+  }
+
+  //---------------------------------------------------------------------------
+  // Toggle the 'Download' popup on entries list
+  //---------------------------------------------------------------------------
+  function toggleDownload() {
+    $('#download-form').toggle();
+  }
+
+  //---------------------------------------------------------------------------
+  // Toggle the 'Save a Link' popup in the sidebar
+  //---------------------------------------------------------------------------
+  function toggleBagit() {
+    $('#bagit-form').toggle();
+    $('#bagit').toggleClass('current');
+    $('#bagit').toggleClass('active-current');
+    $('#bagit-arrow').toggleClass('arrow-down');
+    if ($('#bagit').hasClass('current')) {
+      $('#content').addClass('opacity03');
+    } else {
+      $('#content').removeClass('opacity03');
     }
+  }
+
+  //---------------------------------------------------------------------------
+  // Close all #links popups in the sidebar
+  //---------------------------------------------------------------------------
+  function closePopups() {
+    $('#links .messages').hide();
+    $('#links > li > a').removeClass('active-current');
+    $('#links > li > a').removeClass('current');
+    $('[id$=-arrow]').removeClass('arrow-down');
+    $('#content').removeClass('opacity03');
+  }
+
+  $('#search').click(() => {
+    closePopups();
+    toggleSearch();
+    $('#searchfield').focus();
+  });
+
+  $('.filter-btn').click(() => {
+    closePopups();
+    toggleFilter();
+  });
+
+  $('.download-btn').click(() => {
+    closePopups();
+    toggleDownload();
+  });
+
+  $('#bagit').click(() => {
+    closePopups();
+    toggleBagit();
+    $('#plainurl').focus();
+  });
+
+  $('#search-form-close').click(() => {
+    toggleSearch();
+  });
+
+  $('#filter-form-close').click(() => {
+    toggleFilter();
+  });
+
+  $('#download-form-close').click(() => {
+    toggleDownload();
+  });
+
+  $('#bagit-form-close').click(() => {
+    toggleBagit();
+  });
+
+  const $bagitFormForm = $('#bagit-form-form');
+
+  /* ==========================================================================
+   bag it link and close button
+   ========================================================================== */
+
+  // send 'bag it link' form request via ajax
+  $bagitFormForm.submit((event) => {
+    $('body').css('cursor', 'wait');
+    $('#add-link-result').empty();
+
+    $.ajax({
+      type: $bagitFormForm.attr('method'),
+      url: $bagitFormForm.attr('action'),
+      data: $bagitFormForm.serialize(),
+      success: function success() {
+        $('#add-link-result').html('Done!');
+        $('#plainurl').val('');
+        $('#plainurl').blur('');
+        $('body').css('cursor', 'auto');
+      },
+      error: function error() {
+        $('#add-link-result').html('Failed!');
+        $('body').css('cursor', 'auto');
+      },
+    });
+
+    event.preventDefault();
+  });
+
+  /* ==========================================================================
+   Process all links inside an article
+   ========================================================================== */
+
+  $('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>'
+  );
+
+  $('.add-to-wallabag-link-after').click((event) => {
+    toggleSaveLinkForm($(this).attr('href'), event);
+    event.preventDefault();
+  });
 });
diff --git a/app/Resources/static/themes/baggy/js/popupForm.js b/app/Resources/static/themes/baggy/js/popupForm.js
deleted file mode 100644 (file)
index 95ba60e..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-var $ = global.jquery = require('jquery');
-
-$(document).ready(function () {
-  $('#search-form').hide();
-  $('#bagit-form').hide();
-  $('#filter-form').hide();
-  $('#download-form').hide();
-
-  //---------------------------------------------------------------------------
-  // Toggle the 'Search' popup in the sidebar
-  //---------------------------------------------------------------------------
-  function toggleSearch() {
-    $('#search-form').toggle();
-    $('#search').toggleClass('current');
-    $('#search').toggleClass('active-current');
-    $('#search-arrow').toggleClass('arrow-down');
-    if ($('#search').hasClass('current')) {
-      $('#content').addClass('opacity03');
-    } else {
-      $('#content').removeClass('opacity03');
-    }
-  }
-
-  //---------------------------------------------------------------------------
-  // Toggle the 'Filter' popup on entries list
-  //---------------------------------------------------------------------------
-  function toggleFilter() {
-    $('#filter-form').toggle();
-  }
-
-  //---------------------------------------------------------------------------
-  // Toggle the 'Download' popup on entries list
-  //---------------------------------------------------------------------------
-  function toggleDownload() {
-    $('#download-form').toggle();
-  }
-
-  //---------------------------------------------------------------------------
-  // Toggle the 'Save a Link' popup in the sidebar
-  //---------------------------------------------------------------------------
-  function toggleBagit() {
-    $('#bagit-form').toggle();
-    $('#bagit').toggleClass('current');
-    $('#bagit').toggleClass('active-current');
-    $('#bagit-arrow').toggleClass('arrow-down');
-    if ($('#bagit').hasClass('current')) {
-      $('#content').addClass('opacity03');
-    } else {
-      $('#content').removeClass('opacity03');
-    }
-  }
-
-  //---------------------------------------------------------------------------
-  // Close all #links popups in the sidebar
-  //---------------------------------------------------------------------------
-  function closePopups() {
-    $('#links .messages').hide();
-    $('#links > li > a').removeClass('active-current');
-    $('#links > li > a').removeClass('current');
-    $('[id$=-arrow]').removeClass('arrow-down');
-    $('#content').removeClass('opacity03');
-  }
-
-  $('#search').click(function () {
-    closePopups();
-    toggleSearch();
-    $('#searchfield').focus();
-  });
-
-  $('.filter-btn').click(function () {
-    closePopups();
-    toggleFilter();
-  });
-
-  $('.download-btn').click(function () {
-    closePopups();
-    toggleDownload();
-  });
-
-  $('#bagit').click(function () {
-    closePopups();
-    toggleBagit();
-    $('#plainurl').focus();
-  });
-
-  $('#search-form-close').click(function () {
-    toggleSearch();
-  });
-
-  $('#filter-form-close').click(function () {
-    toggleFilter();
-  });
-
-  $('#download-form-close').click(function () {
-    toggleDownload();
-  });
-
-  $('#bagit-form-close').click(function () {
-    toggleBagit();
-  });
-});
diff --git a/app/Resources/static/themes/baggy/js/saveLink.js b/app/Resources/static/themes/baggy/js/saveLink.js
deleted file mode 100755 (executable)
index 5c72088..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-var $ = global.jquery = require('jquery');
-
-$.fn.ready(function () {
-  var $bagit = $('#bagit');
-  var $bagitForm = $('#bagit-form');
-  var $bagitFormForm = $('#bagit-form-form');
-
-  /* ==========================================================================
-   bag it link and close button
-   ========================================================================== */
-
-  function toggleSaveLinkForm(url, event) {
-    $('#add-link-result').empty();
-
-    $bagit.toggleClass('active-current');
-
-    // only if bag-it link is not presented on page
-    if ($bagit.length === 0) {
-      if (event !== 'undefined' && event) {
-        $bagitForm.css({ position: 'absolute', top: event.pageY, left: event.pageX - 200 });
-      } else {
-        $bagitForm.css({ position: 'relative', top: 'auto', left: 'auto' });
-      }
-    }
-
-    if ($('#search-form').length !== 0) {
-      $('#search').removeClass('current');
-      $('#search-arrow').removeClass('arrow-down');
-      $('#search-form').hide();
-    }
-    $bagitForm.toggle();
-    $('#content').toggleClass('opacity03');
-    if (url !== 'undefined' && url) {
-      $('#plainurl').val(url);
-    }
-    $('#plainurl').focus();
-  }
-
-  // send 'bag it link' form request via ajax
-  $bagitFormForm.submit(function (event) {
-    $('body').css('cursor', 'wait');
-    $('#add-link-result').empty();
-
-    $.ajax({
-      type: $bagitFormForm.attr('method'),
-      url: $bagitFormForm.attr('action'),
-      data: $bagitFormForm.serialize(),
-      success: function (data) {
-        $('#add-link-result').html('Done!');
-        $('#plainurl').val('');
-        $('#plainurl').blur('');
-        $('body').css('cursor', 'auto');
-      },
-      error: function (data) {
-        $('#add-link-result').html('Failed!');
-        $('body').css('cursor', 'auto');
-      },
-    });
-
-    event.preventDefault();
-  });
-
-  /* ==========================================================================
-   Process all links inside an article
-   ========================================================================== */
-
-  $('article a[href^="http"]').after(function () {
-    return ' <a href="' + $(this).attr('href') + '" class="add-to-wallabag-link-after" alt="add to wallabag" title="add to wallabag"></a> ';
-  });
-
-  $('.add-to-wallabag-link-after').click(function (event) {
-    toggleSaveLinkForm($(this).attr('href'), event);
-    event.preventDefault();
-  });
-});
diff --git a/app/Resources/static/themes/baggy/js/uiTools.js b/app/Resources/static/themes/baggy/js/uiTools.js
new file mode 100644 (file)
index 0000000..900b270
--- /dev/null
@@ -0,0 +1,35 @@
+const $ = require('jquery');
+
+function toggleSaveLinkForm(url, event) {
+  $('#add-link-result').empty();
+
+  const $bagit = $('#bagit');
+  const $bagitForm = $('#bagit-form');
+
+  $bagit.toggleClass('active-current');
+
+  // only if bag-it link is not presented on page
+  if ($bagit.length === 0) {
+    if (event !== 'undefined' && event) {
+      $bagitForm.css({ position: 'absolute', top: event.pageY, left: event.pageX - 200 });
+    } else {
+      $bagitForm.css({ position: 'relative', top: 'auto', left: 'auto' });
+    }
+  }
+
+  const searchForm = $('#search-form');
+  const plainUrl = $('#plainurl');
+  if (searchForm.length !== 0) {
+    $('#search').removeClass('current');
+    $('#search-arrow').removeClass('arrow-down');
+    searchForm.hide();
+  }
+  $bagitForm.toggle();
+  $('#content').toggleClass('opacity03');
+  if (url !== 'undefined' && url) {
+    plainUrl.val(url);
+  }
+  plainUrl.focus();
+}
+
+export { toggleSaveLinkForm };
index 65b708c77c262e2ca4d9f6c693e2d12d8f7f9032..1d14448f9344b4d9b4bb62804e91fd828efb0dd7 100755 (executable)
@@ -174,7 +174,7 @@ div.pagination ul .next.disabled {
 
 footer.page-footer {
   margin-top: 10px;
-  padding-top: 0px;
+  padding-top: 0;
 }
 
 footer .row {
@@ -257,8 +257,9 @@ nav input {
   display: none;
 }
 
-.input-field.nav-panel-add, .input-field.nav-panel-add form {
-    height: 100%;
+.input-field.nav-panel-add,
+.input-field.nav-panel-add form {
+  height: 100%;
 }
 
 /* ==========================================================================
@@ -355,8 +356,9 @@ main ul.row {
   display: block;
 }
 
-.card .card-content i.right, .card .card-reveal i.right {
-    margin-left: 0;
+.card .card-content i.right,
+.card .card-reveal i.right {
+  margin-left: 0;
 }
 
 .card .card-entry-labels {
@@ -528,30 +530,38 @@ main ul.row {
   footer {
     padding-left: 0;
   }
+
   nav,
   main,
   footer {
     padding-left: 0;
   }
+
   .pagination {
     width: auto;
   }
+
   .reader-mode {
     width: 240px !important;
   }
+
   .reader-mode span {
     opacity: 1;
   }
+
   .tabs {
     display: inline-block;
     height: auto;
   }
+
   .tab {
     min-width: 100%;
   }
+
   .indicator {
     display: none;
   }
+
   .pagination li.prev,
   .pagination li.next {
     width: auto;
@@ -569,38 +579,47 @@ main ul.row {
     width: 25%;
     margin-left: 0;
   }
+
   .row .col.l2 {
     width: 33.33333%;
     margin-left: 0;
   }
+
   .row .col.l3 {
     width: 41.66667%;
     margin-left: 0;
   }
+
   .row .col.l4 {
     width: 50%;
     margin-left: 0;
   }
+
   .row .col.l5 {
     width: 58.33333%;
     margin-left: 0;
   }
+
   .row .col.l6 {
     width: 66.66667%;
     margin-left: 0;
   }
+
   .row .col.l7 {
     width: 75%;
     margin-left: 0;
   }
+
   .row .col.l8 {
     width: 83.33333%;
     margin-left: 0;
   }
+
   .row .col.l9 {
     width: 91.66667%;
     margin-left: 0;
   }
+
   .row .col.l10 {
     width: 100%;
     margin-left: 0;
@@ -646,7 +665,7 @@ main ul.row {
 }
 
 .icon-link::before {
-    content: "\e9cb";
+  content: "\e9cb";
 }
 
 footer [class^="icon-"],
@@ -677,5 +696,5 @@ div.settings div.file-field div {
 }
 
 .input-field label.active {
-    font-size: 1rem;
+  font-size: 1rem;
 }
index 1eb96735aadcf5a27119eccddd1df78e5432b347..98505aae0434b4dc1f874656308b8da224138824 100755 (executable)
   .messages,
   .entry + .results,
   #slide-out,
-  .progress, .hide-on-large-only,
+  .progress,
+  .hide-on-large-only,
   #article > aside,
-  #article .mbm a
-  {
+  #article .mbm a {
     display: none !important;
   }
 
index d6a87941ee1baf89171731034869e5bf63793f05..18f7b40affc65f6d93266427d72e244313eae4aa 100755 (executable)
@@ -1,29 +1,10 @@
-var $ = require('jquery');
-require('materialize');
-var annotator = require('annotator');
+const $ = require('jquery');
+global.jQuery = $;
+require('materialize'); // eslint-disable-line
+const annotator = require('annotator');
+import { savePercent, retrievePercent, initFilters, initExport } from '../../_global/js/tools.js';
 
-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;
-    });
-  }
-}
-
-function initExport() {
-  // no display if export not aviable
-  if ($('div').is('#export')) {
-    $('#button_export').show();
-    $('.button-collapse-right').sideNav({ edge: 'right' });
-  }
-}
-
-$(document).ready(function () {
+$(document).ready(() => {
   // sideNav
   $('.button-collapse').sideNav();
   $('select').material_select();
@@ -40,13 +21,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,7 +36,7 @@ $(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);
@@ -64,7 +45,7 @@ $(document).ready(function () {
     $('#searchfield').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 +54,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 +67,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 +76,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);
     });
   }
index 39a10e9c949f868d1b65ea97a18cc6680d6038ec..78970f8f29e1631f9bfcc6077f0efc27779d32ae 100644 (file)
@@ -10,6 +10,8 @@
   "dependencies": {
     "annotator": "git://github.com/wallabag/annotator.git#0f076c7d371ed25eb0793346f46982d90f2c4c85",
     "autoprefixer": "^6.3.6",
+    "babel-preset-es2015": "^6.14.0",
+    "babelify": "^7.3.0",
     "bower": "^1.7.7",
     "browserify": "^13.0.0",
     "browserify-shim": "^3.8.12",
     "url": "https://github.com/wallabag/wallabag/issues"
   },
   "devDependencies": {
-    "eslint": "^2.11.1",
-    "eslint-config-airbnb": "^9.0.1"
+    "babel-eslint": "^6.1.2",
+    "eslint": "^2.13.1",
+    "eslint-config-airbnb": "^9.0.1",
+    "stylelint": "^7.3.1",
+    "stylelint-config-standard": "^13.0.2"
   }
 }
index 1554cce4789b33c9cebaee7f3394e5573feadd5f..8d841b4cf477cb02c95c7f01c0b4e5e32471364b 100644 (file)
@@ -67,7 +67,7 @@
 
     <!-- Filter -->
     {% if form is not null %}
-    <aside id="filter-form" class="">
+    <div id="filters" class="">
         <form method="get" action="{{ path('all') }}">
             <h2>{{ 'entry.filters.title'|trans }}</h2>
             <a href="javascript: void(null);" id="filter-form-close" class="close-button--popup close-button">&times;</a>
                 <button class="btn waves-effect waves-light" type="submit" id="submit-filter" value="filter">{{ 'entry.filters.action.filter'|trans }}</button>
             </div>
         </form>
-    </aside>
+    </div>
     {% endif %}
 {% endblock %}
index bec4b70fb318e3b3f5cffcea432aa57e9d7089c2..be1e3647620e42f3d383cf63ce7edb2f25b0efdd 100644 (file)
         "entryId": "{{ entry.id }}"
     }
     </script>
-    <script src="{{ asset('bundles/wallabagcore/themes/_global/js/restoreScroll.js')}}"></script>
-    <script type="text/javascript">
-        $(document).ready(function() {
-            $(window).scroll(function(e){
-                var scrollTop = $(window).scrollTop();
-                var docHeight = $(document).height();
-                var scrollPercent = (scrollTop) / (docHeight);
-                var scrollPercentRounded = Math.round(scrollPercent*100)/100;
-                savePercent({{ entry.id }}, scrollPercentRounded);
-            });
-
-            retrievePercent({{ entry.id }});
-
-            $(window).resize(function(){
-                retrievePercent({{ entry.id }});
-            });
-        });
-    </script>
 {% endblock %}
index 806a4eefe795473bb3d882c06c20d524efd9a443..1c5057ddd102784366ca99c1f4913b1f23eb31fc 100644 (file)
@@ -66,7 +66,7 @@
 
                             <p>{{ entry.content|striptags|slice(0, 300)|raw }}&hellip;</p>
 
-                            <ul class="card-entry-tags">
+                            <ul class="card-entry-labels-hidden">
                                 {% for tag in entry.tags %}
                                     <li>{{ tag.label }}</li>
                                 {% endfor %}