clean & lint stuff

This commit is contained in:
Thomas Citharel 2016-06-09 19:02:38 +02:00
parent 5ecdfcd041
commit 0743287f95
11 changed files with 395 additions and 394 deletions

4
.eslintrc.json Normal file
View file

@ -0,0 +1,4 @@
{
"extends": "airbnb",
"installedESLint": true,
}

View file

@ -9,85 +9,81 @@ module.exports = function (grunt) {
material: { material: {
options: { options: {
map: { map: {
inline: false inline: false,
}, },
processors: [ processors: [
require('pixrem')(), require('pixrem')(),
require('autoprefixer')({browsers: 'last 2 versions'}), require('autoprefixer')({ browsers: 'last 2 versions' }),
require('cssnano')() require('cssnano')(),
] ],
}, },
src: '<%= buildDir %>/material.css', src: '<%= buildDir %>/material.css',
dest: '<%= buildDir %>/themes/material/css/style.min.css' dest: '<%= buildDir %>/themes/material/css/style.min.css',
}, },
baggy: { baggy: {
options: { options: {
map: { map: {
inline: false inline: false,
}, },
processors: [ processors: [
require('pixrem')(), require('pixrem')(),
require('autoprefixer')({browsers: 'last 2 versions'}), require('autoprefixer')({ browsers: 'last 2 versions' }),
require('cssnano')() require('cssnano')(),
] ],
}, },
src: '<%= buildDir %>/baggy.css', src: '<%= buildDir %>/baggy.css',
dest: '<%= buildDir %>/themes/baggy/css/style.min.css' dest: '<%= buildDir %>/themes/baggy/css/style.min.css',
} },
}, },
concat: { concat: {
options: { options: {
separator: ';' separator: ';',
}, },
jsMaterial: { jsMaterial: {
src: [ src: [
'node_modules/jquery/dist/jquery.js', '<%= appDir %>/themes/material/js/init.js',
'node_modules/jquery-ui/jquery-ui.js',
'node_modules/materialize-css/bin/materialize.js',
'<%= appDir %>/themes/_global/js/restoreScroll.js', '<%= appDir %>/themes/_global/js/restoreScroll.js',
'<%= appDir %>/themes/material/js/init.js'
], ],
dest: '<%= buildDir %>/material.js' dest: '<%= buildDir %>/material.js',
}, },
jsBaggy: { jsBaggy: {
src: [ src: [
'node_modules/jquery/dist/jquery.js',
'node_modules/jquery-ui/jquery-ui.js',
'<%= appDir %>/themes/baggy/js/init.js', '<%= appDir %>/themes/baggy/js/init.js',
'<%= appDir %>/themes/_global/js/restoreScroll.js', '<%= appDir %>/themes/_global/js/restoreScroll.js',
'<%= appDir %>/themes/baggy/js/autoClose.js', '<%= appDir %>/themes/baggy/js/autoClose.js',
'<%= appDir %>/themes/baggy/js/autoCompleteTags.js', '<%= appDir %>/themes/baggy/js/autoCompleteTags.js',
'<%= appDir %>/themes/baggy/js/closeMessage.js', '<%= appDir %>/themes/baggy/js/closeMessage.js',
'<%= appDir %>/themes/baggy/js/popupForm.js', '<%= appDir %>/themes/baggy/js/popupForm.js',
'<%= appDir %>/themes/baggy/js/saveLink.js' // Save link is no more used for now
// '<%= appDir %>/themes/baggy/js/saveLink.js',
], ],
dest: '<%= buildDir %>/baggy.js' dest: '<%= buildDir %>/baggy.js',
}, },
cssMaterial: { cssMaterial: {
src: [ src: [
'node_modules/materialize-css/bin/materialize.css', 'node_modules/materialize-css/bin/materialize.css',
'<%= appDir %>/themes/material/css/*.css' '<%= appDir %>/themes/material/css/*.css',
], ],
dest: '<%= buildDir %>/material.css' dest: '<%= buildDir %>/material.css',
}, },
cssBaggy: { cssBaggy: {
src: [ src: [
'<%= appDir %>/themes/baggy/css/*.css' '<%= appDir %>/themes/baggy/css/*.css',
], ],
dest: '<%= buildDir %>/baggy.css' dest: '<%= buildDir %>/baggy.css',
} },
}, },
browserify: { browserify: {
'<%= buildDir %>/material.browser.js': ['<%= buildDir %>/material.js'], '<%= buildDir %>/material.browser.js': ['<%= buildDir %>/material.js'],
'<%= buildDir %>/baggy.browser.js': ['<%= buildDir %>/baggy.js'] '<%= buildDir %>/baggy.browser.js': ['<%= buildDir %>/baggy.js'],
}, },
uglify: { uglify: {
material: { material: {
files: { files: {
'<%= buildDir %>/themes/material/js/material.min.js': '<%= buildDir %>/themes/material/js/material.min.js':
['<%= buildDir %>/material.browser.js'] ['<%= buildDir %>/material.browser.js'],
}, },
options: { options: {
sourceMap: true, sourceMap: true,
@ -96,7 +92,7 @@ module.exports = function (grunt) {
baggy: { baggy: {
files: { files: {
'<%= buildDir %>/themes/baggy/js/baggy.min.js': '<%= buildDir %>/themes/baggy/js/baggy.min.js':
['<%= buildDir %>/baggy.browser.js'] ['<%= buildDir %>/baggy.browser.js'],
}, },
options: { options: {
sourceMap: true, sourceMap: true,
@ -108,14 +104,14 @@ module.exports = function (grunt) {
expand: true, expand: true,
cwd: 'node_modules/pickadate/lib', cwd: 'node_modules/pickadate/lib',
src: 'picker.js', src: 'picker.js',
dest: '<%= buildDir %>' dest: '<%= buildDir %>',
}, },
annotator: { annotator: {
expand: true, expand: true,
cwd: 'node_modules/annotator/pkg', cwd: 'node_modules/annotator/pkg',
src: 'annotator.min.js', src: 'annotator.min.js',
dest: '<%= buildDir %>/themes/_global/js/' dest: '<%= buildDir %>/themes/_global/js/',
} },
}, },
symlink: { symlink: {
baggyfonts: { baggyfonts: {
@ -123,50 +119,50 @@ module.exports = function (grunt) {
{ {
expand: true, expand: true,
overwrite: true, overwrite: true,
cwd: "<%= appDir %>/lib/icomoon-bower/", cwd: '<%= appDir %>/lib/icomoon-bower/',
src: "fonts", src: 'fonts',
dest: "<%= buildDir %>/themes/baggy/" dest: '<%= buildDir %>/themes/baggy/',
}, },
{ {
expand: true, expand: true,
overwrite: true, overwrite: true,
cwd: "<%= appDir %>/lib/bower-pt-sans/fonts", cwd: '<%= appDir %>/lib/bower-pt-sans/fonts',
src: "*", src: '*',
dest: "<%= buildDir %>/themes/baggy/fonts/" dest: '<%= buildDir %>/themes/baggy/fonts/',
} },
] ],
}, },
materialfonts: { materialfonts: {
files: [ files: [
{ {
expand: true, expand: true,
overwrite: true, overwrite: true,
cwd: "<%= appDir %>/lib/icomoon-bower/", cwd: '<%= appDir %>/lib/icomoon-bower/',
src: "fonts", src: 'fonts',
dest: "<%= buildDir %>/themes/material/" dest: '<%= buildDir %>/themes/material/',
}, },
{ {
expand: true, expand: true,
overwrite: true, overwrite: true,
cwd: "node_modules/materialize-css/", cwd: 'node_modules/materialize-css/',
src: "font", src: 'font',
dest: "<%= buildDir %>/themes/material" dest: '<%= buildDir %>/themes/material',
}, },
{ {
expand: true, expand: true,
overwrite: true, overwrite: true,
cwd: "<%= appDir %>/lib/roboto-fontface/fonts/", cwd: '<%= appDir %>/lib/roboto-fontface/fonts/',
src: "*", src: '*',
dest: "<%= buildDir %>/themes/material/fonts/roboto/" dest: '<%= buildDir %>/themes/material/fonts/roboto/',
}, },
{ {
expand: true, expand: true,
overwrite: true, overwrite: true,
cwd: "<%= appDir %>/lib/material-design-icons/iconfont/", cwd: '<%= appDir %>/lib/material-design-icons/iconfont/',
src: "*", src: '*',
dest: "<%= buildDir %>/themes/material/fonts/" dest: '<%= buildDir %>/themes/material/fonts/',
} },
] ],
}, },
pics: { pics: {
files: [ files: [
@ -175,22 +171,22 @@ module.exports = function (grunt) {
overwrite: true, overwrite: true,
cwd: '<%= appDir %>/themes/_global/', cwd: '<%= appDir %>/themes/_global/',
src: 'img', src: 'img',
dest: '<%= buildDir %>/themes/_global/' dest: '<%= buildDir %>/themes/_global/',
} },
] ],
} },
}, },
clean: { clean: {
css: { css: {
src: [ '<%= buildDir %>/**/*.css' ] src: ['<%= buildDir %>/**/*.css'],
}, },
js: { js: {
src: ['<%= buildDir %>/**/*.js', '<%= buildDir %>/**/*.map'] src: ['<%= buildDir %>/**/*.js', '<%= buildDir %>/**/*.map'],
}, },
all: { all: {
src: ['./<%= buildDir %>'] src: ['./<%= buildDir %>'],
} },
} },
}); });
grunt.registerTask( grunt.registerTask(
@ -216,4 +212,4 @@ module.exports = function (grunt) {
'Compiles the stylesheets.', 'Compiles the stylesheets.',
['clean:css', 'concat:cssMaterial', 'concat:cssBaggy', 'postcss'] ['clean:css', 'concat:cssMaterial', 'concat:cssBaggy', 'postcss']
); );
} };

View file

@ -1,25 +1,25 @@
function supportsLocalStorage() { function supportsLocalStorage() {
try { try {
return 'localStorage' in window && window['localStorage'] !== null; return 'localStorage' in window && window.localStorage !== null;
} catch (e) { } catch (e) {
return false; return false;
} }
} }
function savePercent(id, percent) { function savePercent(id, percent) {
if (!supportsLocalStorage()) { return false; } if (!supportsLocalStorage()) { return false; }
localStorage["wallabag.article." + id + ".percent"] = percent; localStorage['wallabag.article.' + id + '.percent'] = percent;
return true; return true;
} }
function retrievePercent(id) { function retrievePercent(id) {
if (!supportsLocalStorage()) { return false; } if (!supportsLocalStorage()) { return false; }
var bheight = $(document).height(); var bheight = $(document).height();
var percent = localStorage["wallabag.article." + id + ".percent"]; var percent = localStorage['wallabag.article.' + id + '.percent'];
var scroll = bheight * percent; var scroll = bheight * percent;
$('html,body').animate({scrollTop: scroll}, 'fast'); $('html,body').animate({ scrollTop: scroll }, 'fast');
return true; return true;
} }

View file

@ -1,6 +1,8 @@
$(document).ready(function() { var $ = global.jquery = require('jquery');
current_url = window.location.href
if (current_url.match("&closewin=true")) { $(document).ready(function () {
window.close(); var currentUrl = window.location.href;
} if (currentUrl.match('&closewin=true')) {
window.close();
}
}); });

View file

@ -1,47 +1,46 @@
jQuery(function($) { var $ = global.jquery = require('jquery');
function split( val ) { jQuery(function ($) {
return val.split( /,\s*/ ); function split(val) {
return val.split(/,\s*/);
} }
function extractLast( term ) { function extractLast(term) {
return split( term ).pop(); return split(term).pop();
} }
$("#value").bind("keydown", function(event) { $('#value').bind('keydown', function (event) {
if (event.keyCode === $.ui.keyCode.TAB && $(this).data("ui-autocomplete").menu.active) { if (event.keyCode === $.ui.keyCode.TAB && $(this).data('ui-autocomplete').menu.active) {
event.preventDefault(); event.preventDefault();
} }
}).autocomplete({ }).autocomplete({
source : function(request, response) { source: function (request, response) {
$.getJSON("./?view=tags", { $.getJSON('./?view=tags', {
term : extractLast(request.term), term: extractLast(request.term),
//id: $(':hidden#entry_id').val() //id: $(':hidden#entry_id').val()
}, response); }, response);
}, },
search : function() { search: function () {
// custom minLength // custom minLength
var term = extractLast(this.value); var term = extractLast(this.value);
if (term.length < 1) { if (term.length < 1) {
return false; return false;
} }
}, },
focus : function() { focus: function () {
// prevent value inserted on focus // prevent value inserted on focus
return false; return false;
}, },
select : function(event, ui) { select: function (event, ui) {
var terms = split(this.value); var terms = split(this.value);
// remove the current input // remove the current input
terms.pop(); terms.pop();
// add the selected item // add the selected item
terms.push(ui.item.value); terms.push(ui.item.value);
// add placeholder to get the comma-and-space at the end // add placeholder to get the comma-and-space at the end
terms.push(""); terms.push('');
this.value = terms.join(", "); this.value = terms.join(', ');
return false; return false;
} },
}); });
}); });

View file

@ -1,17 +1,19 @@
$(function(){ var $ = global.jquery = require('jquery');
//---------------------------------------------------------------------------
// Show the close icon when the user hover over a message $(function () {
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// $('.messages').on('mouseenter', function(){ // Show the close icon when the user hover over a message
// $(this).find('a.closeMessage').stop(true, true).show(); //---------------------------------------------------------------------------
// }).on('mouseleave', function(){ // $('.messages').on('mouseenter', function(){
// $(this).find('a.closeMessage').stop(true, true).hide(); // $(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(){ // Close the message box when the user clicks the close icon
$(this).parents('div.messages').slideUp(300, function(){ $(this).remove(); }); //---------------------------------------------------------------------------
return false; $('a.closeMessage').on('click', function () {
}); $(this).parents('div.messages').slideUp(300, function () { $(this).remove(); });
}); return false;
});
});

View file

@ -4,19 +4,18 @@ require('jquery-ui');
var annotator = require('annotator'); var annotator = require('annotator');
$.fn.ready(function() { $.fn.ready(function () {
var $listmode = $('#listmode');
var $listmode = $('#listmode'), var $listentries = $('#list-entries');
$listentries = $("#list-entries");
/* ========================================================================== /* ==========================================================================
Menu Menu
========================================================================== */ ========================================================================== */
$("#menu").click(function(){ $('#menu').click(function () {
$("#links").toggleClass('menu--open'); $('#links').toggleClass('menu--open');
if ($('#content').hasClass('opacity03')) { if ($('#content').hasClass('opacity03')) {
$('#content').removeClass('opacity03'); $('#content').removeClass('opacity03');
} }
}); });
@ -24,34 +23,32 @@ $.fn.ready(function() {
List mode or Table Mode List mode or Table Mode
========================================================================== */ ========================================================================== */
$listmode.click(function(){ $listmode.click(function () {
if ( jquery.cookie("listmode") == 1 ) { if (jquery.cookie('listmode') === 1) {
// Cookie // Cookie
$.removeCookie("listmode"); $.removeCookie('listmode');
$listentries.removeClass("listmode"); $listentries.removeClass('listmode');
$listmode.removeClass("tablemode"); $listmode.removeClass('tablemode');
$listmode.addClass("listmode"); $listmode.addClass('listmode');
} } else {
else {
// Cookie // Cookie
jquery.cookie("listmode", 1, {expires: 365}); jquery.cookie('listmode', 1, { expires: 365 });
$listentries.addClass("listmode"); $listentries.addClass('listmode');
$listmode.removeClass("listmode"); $listmode.removeClass('listmode');
$listmode.addClass("tablemode"); $listmode.addClass('tablemode');
} }
}); });
/* ========================================================================== /* ==========================================================================
Cookie listmode Cookie listmode
========================================================================== */ ========================================================================== */
if ( jquery.cookie("listmode") == 1 ) { if (jquery.cookie('listmode') === 1) {
$listentries.addClass("listmode"); $listentries.addClass('listmode');
$listmode.removeClass("listmode"); $listmode.removeClass('listmode');
$listmode.addClass("tablemode"); $listmode.addClass('tablemode');
} }
/* ========================================================================== /* ==========================================================================
@ -59,43 +56,43 @@ $.fn.ready(function() {
========================================================================== */ ========================================================================== */
$('#nav-btn-add-tag').on('click', function(){ $('#nav-btn-add-tag').on('click', function () {
$(".nav-panel-add-tag").toggle(100); $('.nav-panel-add-tag').toggle(100);
$(".nav-panel-menu").addClass('hidden'); $('.nav-panel-menu').addClass('hidden');
$("#tag_label").focus(); $('#tag_label').focus();
return false; return false;
}); });
/* ========================================================================== /* ==========================================================================
Annotations & Remember position Annotations & Remember position
========================================================================== */ ========================================================================== */
if ($("article").length) { if ($('article').length) {
var app = new annotator.App(); var app = new annotator.App();
app.include(annotator.ui.main, { app.include(annotator.ui.main, {
element: document.querySelector('article') element: document.querySelector('article'),
}); });
var x = JSON.parse($('#annotationroutes').html()); var x = JSON.parse($('#annotationroutes').html());
app.include(annotator.storage.http, x); app.include(annotator.storage.http, x);
app.start().then(function () { app.start().then(function () {
app.annotations.load({entry: x.entryId}); app.annotations.load({ entry: x.entryId });
}); });
$(window).scroll(function(e){ $(window).scroll(function (e) {
var scrollTop = $(window).scrollTop(); var scrollTop = $(window).scrollTop();
var docHeight = $(document).height(); var docHeight = $(document).height();
var scrollPercent = (scrollTop) / (docHeight); var scrollPercent = (scrollTop) / (docHeight);
var scrollPercentRounded = Math.round(scrollPercent*100)/100; var scrollPercentRounded = Math.round(scrollPercent * 100) / 100;
savePercent(x.entryId, scrollPercentRounded); savePercent(x.entryId, scrollPercentRounded);
}); });
retrievePercent(x.entryId); retrievePercent(x.entryId);
$(window).resize(function(){ $(window).resize(function () {
retrievePercent(x.entryId); retrievePercent(x.entryId);
}); });
} }
}); });

View file

@ -1,100 +1,101 @@
$(document).ready(function() { var $ = global.jquery = require('jquery');
$("#search-form").hide(); $(document).ready(function () {
$("#bagit-form").hide(); $('#search-form').hide();
$("#filter-form").hide(); $('#bagit-form').hide();
$("#download-form").hide(); $('#filter-form').hide();
$('#download-form').hide();
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// Toggle the "Search" popup in the sidebar // Toggle the 'Search' popup in the sidebar
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
function toggleSearch() { function toggleSearch() {
$("#search-form").toggle(); $('#search-form').toggle();
$("#search").toggleClass("current"); $('#search').toggleClass('current');
$("#search").toggleClass("active-current"); $('#search').toggleClass('active-current');
$("#search-arrow").toggleClass("arrow-down"); $('#search-arrow').toggleClass('arrow-down');
if ($("#search").hasClass("current")) { if ($('#search').hasClass('current')) {
$("#content").addClass("opacity03"); $('#content').addClass('opacity03');
} else { } else {
$("#content").removeClass("opacity03"); $('#content').removeClass('opacity03');
}
} }
}
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// Toggle the "Filter" popup on entries list // Toggle the 'Filter' popup on entries list
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
function toggleFilter() { function toggleFilter() {
$("#filter-form").toggle(); $('#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');
} }
}
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// Toggle the "Download" popup on entries list // Close all #links popups in the sidebar
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
function toggleDownload() { function closePopups() {
$("#download-form").toggle(); $('#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 () {
// Toggle the "Save a Link" popup in the sidebar closePopups();
//--------------------------------------------------------------------------- toggleSearch();
function toggleBagit() { $('#searchfield').focus();
$("#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");
}
}
//--------------------------------------------------------------------------- $('.filter-btn').click(function () {
// Close all #links popups in the sidebar closePopups();
//--------------------------------------------------------------------------- toggleFilter();
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(){ $('.download-btn').click(function () {
closePopups(); closePopups();
toggleSearch(); toggleDownload();
$("#searchfield").focus(); });
});
$(".filter-btn").click(function(){ $('#bagit').click(function () {
closePopups(); closePopups();
toggleFilter(); toggleBagit();
}); $('#plainurl').focus();
});
$(".download-btn").click(function(){ $('#search-form-close').click(function () {
closePopups(); toggleSearch();
toggleDownload(); });
});
$("#bagit").click(function(){ $('#filter-form-close').click(function () {
closePopups(); toggleFilter();
toggleBagit(); });
$("#plainurl").focus();
});
$("#search-form-close").click(function(){ $('#download-form-close').click(function () {
toggleSearch(); toggleDownload();
}); });
$("#filter-form-close").click(function(){ $('#bagit-form-close').click(function () {
toggleFilter(); toggleBagit();
}); });
$("#download-form-close").click(function(){
toggleDownload();
});
$("#bagit-form-close").click(function(){
toggleBagit();
});
}); });

View file

@ -1,60 +1,60 @@
$.fn.ready(function() { var $ = global.jquery = require('jquery');
var $bagit = $('#bagit'), $.fn.ready(function () {
$bagitForm = $('#bagit-form'), var $bagit = $('#bagit');
$bagitFormForm = $('#bagit-form-form'); var $bagitForm = $('#bagit-form');
var $bagitFormForm = $('#bagit-form-form');
/* ========================================================================== /* ==========================================================================
bag it link and close button bag it link and close button
========================================================================== */ ========================================================================== */
function toggleSaveLinkForm(url, event) { function toggleSaveLinkForm(url, event) {
$("#add-link-result").empty(); $('#add-link-result').empty();
$bagit.toggleClass("active-current"); $bagit.toggleClass('active-current');
//only if bag-it link is not presented on page // only if bag-it link is not presented on page
if ( $bagit.length === 0 ) { if ($bagit.length === 0) {
if ( event !== 'undefined' && event ) { if (event !== 'undefined' && event) {
$bagitForm.css( {position:"absolute", top:event.pageY, left:event.pageX-200}); $bagitForm.css({ position: 'absolute', top: event.pageY, left: event.pageX - 200 });
} } else {
else { $bagitForm.css({ position: 'relative', top: 'auto', left: 'auto' });
$bagitForm.css( {position:"relative", top:"auto", left:"auto"});
} }
} }
if ($("#search-form").length != 0) { if ($('#search-form').length !== 0) {
$("#search").removeClass("current"); $('#search').removeClass('current');
$("#search-arrow").removeClass("arrow-down"); $('#search-arrow').removeClass('arrow-down');
$("#search-form").hide(); $('#search-form').hide();
} }
$bagitForm.toggle(); $bagitForm.toggle();
$('#content').toggleClass("opacity03"); $('#content').toggleClass('opacity03');
if (url !== 'undefined' && url) { if (url !== 'undefined' && url) {
$('#plainurl').val(url); $('#plainurl').val(url);
} }
$('#plainurl').focus(); $('#plainurl').focus();
} }
//send "bag it link" form request via ajax // send 'bag it link' form request via ajax
$bagitFormForm.submit( function(event) { $bagitFormForm.submit(function (event) {
$("body").css("cursor", "wait"); $('body').css('cursor', 'wait');
$("#add-link-result").empty(); $('#add-link-result').empty();
$.ajax({ $.ajax({
type: $bagitFormForm.attr('method'), type: $bagitFormForm.attr('method'),
url: $bagitFormForm.attr('action'), url: $bagitFormForm.attr('action'),
data: $bagitFormForm.serialize(), data: $bagitFormForm.serialize(),
success: function(data) { success: function (data) {
$('#add-link-result').html("Done!"); $('#add-link-result').html('Done!');
$('#plainurl').val(''); $('#plainurl').val('');
$('#plainurl').blur(''); $('#plainurl').blur('');
$("body").css("cursor", "auto"); $('body').css('cursor', 'auto');
},
error: function (data) {
$('#add-link-result').html('Failed!');
$('body').css('cursor', 'auto');
}, },
error: function(data) {
$('#add-link-result').html("Failed!");
$("body").css("cursor", "auto");
}
}); });
event.preventDefault(); event.preventDefault();
@ -64,15 +64,12 @@ $.fn.ready(function() {
Process all links inside an article Process all links inside an article
========================================================================== */ ========================================================================== */
$("article a[href^='http']").after(function() { $('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> "; 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){ $('.add-to-wallabag-link-after').click(function (event) {
toggleSaveLinkForm($(this).attr('href'), event); toggleSaveLinkForm($(this).attr('href'), event);
event.preventDefault(); event.preventDefault();
}); });
}); });

View file

@ -1,116 +1,117 @@
var $ = require("jquery"), var $ = require('jquery');
materialize = require("materialize"); require('materialize');
var annotator = require('annotator'); var annotator = require('annotator');
function init_filters() { function initFilters() {
// no display if filters not aviable // no display if filters not aviable
if ($("div").is("#filters")) { if ($('div').is('#filters')) {
$('#button_filters').show(); $('#button_filters').show();
$('.button-collapse-right').sideNav({ edge: 'right' }); $('.button-collapse-right').sideNav({ edge: 'right' });
$('#clear_form_filters').on('click', function(){ $('#clear_form_filters').on('click', function () {
$('#filters input').val(''); $('#filters input').val('');
$('#filters :checked').removeAttr('checked'); $('#filters :checked').removeAttr('checked');
return false; return false;
}); });
} }
} }
function init_export() { function initExport() {
// no display if export not aviable // no display if export not aviable
if ($("div").is("#export")) { if ($('div').is('#export')) {
$('#button_export').show(); $('#button_export').show();
$('.button-collapse-right').sideNav({ edge: 'right' }); $('.button-collapse-right').sideNav({ edge: 'right' });
} }
} }
$(document).ready(function(){ $(document).ready(function () {
// sideNav // sideNav
$('.button-collapse').sideNav(); $('.button-collapse').sideNav();
$('select').material_select(); $('select').material_select();
$('.collapsible').collapsible({ $('.collapsible').collapsible({
accordion : false accordion: false,
}); });
$('.datepicker').pickadate({ $('.datepicker').pickadate({
selectMonths: true, selectMonths: true,
selectYears: 15, selectYears: 15,
formatSubmit: 'dd/mm/yyyy', formatSubmit: 'dd/mm/yyyy',
hiddenName: true, hiddenName: true,
format: 'dd/mm/yyyy', format: 'dd/mm/yyyy',
}); });
init_filters(); initFilters();
init_export(); initExport();
$('#nav-btn-add-tag').on('click', function(){ $('#nav-btn-add-tag').on('click', function () {
$(".nav-panel-add-tag").toggle(100); $('.nav-panel-add-tag').toggle(100);
$(".nav-panel-menu").addClass('hidden'); $('.nav-panel-menu').addClass('hidden');
$("#tag_label").focus(); $('#tag_label').focus();
return false; return false;
}); });
$('#nav-btn-add').on('click', function(){ $('#nav-btn-add').on('click', function () {
$(".nav-panel-buttom").hide(100); $('.nav-panel-buttom').hide(100);
$(".nav-panel-add").show(100); $('.nav-panel-add').show(100);
$(".nav-panels .action").hide(100); $('.nav-panels .action').hide(100);
$(".nav-panel-menu").addClass('hidden'); $('.nav-panel-menu').addClass('hidden');
$(".nav-panels").css('background', 'white'); $('.nav-panels').css('background', 'white');
$("#entry_url").focus(); $('#entry_url').focus();
return false; return false;
}); });
$('#nav-btn-search').on('click', function(){ $('#nav-btn-search').on('click', function () {
$(".nav-panel-buttom").hide(100); $('.nav-panel-buttom').hide(100);
$(".nav-panel-search").show(100); $('.nav-panel-search').show(100);
$(".nav-panels .action").hide(100); $('.nav-panels .action').hide(100);
$(".nav-panel-menu").addClass('hidden'); $('.nav-panel-menu').addClass('hidden');
$(".nav-panels").css('background', 'white'); $('.nav-panels').css('background', 'white');
$("#searchfield").focus(); $('#searchfield').focus();
return false; return false;
}); });
$('.close').on('click', function(){ $('.close').on('click', function () {
$(".nav-panel-add").hide(100); $('.nav-panel-add').hide(100);
$(".nav-panel-search").hide(100); $('.nav-panel-search').hide(100);
$(".nav-panel-buttom").show(100); $('.nav-panel-buttom').show(100);
$(".nav-panels .action").show(100); $('.nav-panels .action').show(100);
$(".nav-panel-menu").removeClass('hidden'); $('.nav-panel-menu').removeClass('hidden');
$(".nav-panels").css('background', 'transparent'); $('.nav-panels').css('background', 'transparent');
return false; return false;
}); });
$(window).scroll(function () { $(window).scroll(function () {
var s = $(window).scrollTop(), var s = $(window).scrollTop();
d = $(document).height(), var d = $(document).height();
c = $(window).height(); var c = $(window).height();
var scrollPercent = (s / (d-c)) * 100; var scrollPercent = (s / (d - c)) * 100;
$(".progress .determinate").css('width', scrollPercent+'%'); $('.progress .determinate').css('width', scrollPercent + '%');
});
/* ==========================================================================
Annotations & Remember position
========================================================================== */
if ($('article').length) {
var app = new annotator.App();
var x = JSON.parse($('#annotationroutes').html());
app.include(annotator.ui.main, {
element: document.querySelector('article'),
}); });
/* ========================================================================== app.include(annotator.storage.http, x);
Annotations & Remember position
========================================================================== */
if ($("article").length) { app.start().then(function () {
var app = new annotator.App(); app.annotations.load({ entry: x.entryId });
});
app.include(annotator.ui.main, { $(window).scroll(function (e) {
element: document.querySelector('article') var scrollTop = $(window).scrollTop();
}); var docHeight = $(document).height();
var scrollPercent = (scrollTop) / (docHeight);
var scrollPercentRounded = Math.round(scrollPercent * 100) / 100;
savePercent(x.entryId, scrollPercentRounded);
});
var x = JSON.parse($('#annotationroutes').html()); retrievePercent(x.entryId);
app.include(annotator.storage.http, x);
app.start().then(function () { $(window).resize(function () {
app.annotations.load({entry: x.entryId}); retrievePercent(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;
savePercent(x.entryId, scrollPercentRounded);
});
retrievePercent(x.entryId);
$(window).resize(function(){
retrievePercent(x.entryId);
});
}
}); });

View file

@ -1,6 +1,6 @@
{ {
"name": "wallabag", "name": "wallabag",
"version": "2.0.0", "version": "2.1.0",
"description": "wallabag is a self hostable application for saving web pages", "description": "wallabag is a self hostable application for saving web pages",
"main": "index.js", "main": "index.js",
"private": true, "private": true,
@ -20,11 +20,9 @@
"grunt-contrib-clean": "^1.0.0", "grunt-contrib-clean": "^1.0.0",
"grunt-contrib-concat": "^1.0.0", "grunt-contrib-concat": "^1.0.0",
"grunt-contrib-copy": "^1.0.0", "grunt-contrib-copy": "^1.0.0",
"grunt-contrib-cssmin": "^1.0.0",
"grunt-contrib-symlink": "^1.0.0", "grunt-contrib-symlink": "^1.0.0",
"grunt-contrib-uglify": "^1.0.0", "grunt-contrib-uglify": "^1.0.0",
"grunt-postcss": "^0.8.0", "grunt-postcss": "^0.8.0",
"grunt-shell": "^1.2.1",
"hammerjs": "^2.0.6", "hammerjs": "^2.0.6",
"jquery": "^2.2.1", "jquery": "^2.2.1",
"jquery-ui": "^1.10.5", "jquery-ui": "^1.10.5",
@ -80,5 +78,9 @@
"license": "MIT", "license": "MIT",
"bugs": { "bugs": {
"url": "https://github.com/wallabag/wallabag/issues" "url": "https://github.com/wallabag/wallabag/issues"
},
"devDependencies": {
"eslint": "^2.11.1",
"eslint-config-airbnb": "^9.0.1",
} }
} }