X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=app%2FResources%2Fstatic%2Fthemes%2Fbaggy%2Fjs%2Finit.js;h=d7d4b166155daf3a4a2c43fb79150ee30949d343;hb=0743287f955fd19fd1a04c91f3b40a4ac2236423;hp=1721ae41ab392ffc1bd64827586733a904f64479;hpb=5ecdfcd041767c9e3244a92bb0a6cc3c3f80fea3;p=github%2Fwallabag%2Fwallabag.git diff --git a/app/Resources/static/themes/baggy/js/init.js b/app/Resources/static/themes/baggy/js/init.js index 1721ae41..d7d4b166 100755 --- a/app/Resources/static/themes/baggy/js/init.js +++ b/app/Resources/static/themes/baggy/js/init.js @@ -4,19 +4,18 @@ require('jquery-ui'); var annotator = require('annotator'); -$.fn.ready(function() { - - var $listmode = $('#listmode'), - $listentries = $("#list-entries"); +$.fn.ready(function () { + var $listmode = $('#listmode'); + var $listentries = $('#list-entries'); /* ========================================================================== Menu ========================================================================== */ - $("#menu").click(function(){ - $("#links").toggleClass('menu--open'); + $('#menu').click(function () { + $('#links').toggleClass('menu--open'); if ($('#content').hasClass('opacity03')) { - $('#content').removeClass('opacity03'); + $('#content').removeClass('opacity03'); } }); @@ -24,34 +23,32 @@ $.fn.ready(function() { List mode or Table Mode ========================================================================== */ - $listmode.click(function(){ - if ( jquery.cookie("listmode") == 1 ) { + $listmode.click(function () { + if (jquery.cookie('listmode') === 1) { // Cookie - $.removeCookie("listmode"); + $.removeCookie('listmode'); - $listentries.removeClass("listmode"); - $listmode.removeClass("tablemode"); - $listmode.addClass("listmode"); - } - else { + $listentries.removeClass('listmode'); + $listmode.removeClass('tablemode'); + $listmode.addClass('listmode'); + } else { // Cookie - jquery.cookie("listmode", 1, {expires: 365}); + jquery.cookie('listmode', 1, { expires: 365 }); - $listentries.addClass("listmode"); - $listmode.removeClass("listmode"); - $listmode.addClass("tablemode"); + $listentries.addClass('listmode'); + $listmode.removeClass('listmode'); + $listmode.addClass('tablemode'); } - }); /* ========================================================================== Cookie listmode ========================================================================== */ - if ( jquery.cookie("listmode") == 1 ) { - $listentries.addClass("listmode"); - $listmode.removeClass("listmode"); - $listmode.addClass("tablemode"); + if (jquery.cookie('listmode') === 1) { + $listentries.addClass('listmode'); + $listmode.removeClass('listmode'); + $listmode.addClass('tablemode'); } /* ========================================================================== @@ -59,43 +56,43 @@ $.fn.ready(function() { ========================================================================== */ - $('#nav-btn-add-tag').on('click', function(){ - $(".nav-panel-add-tag").toggle(100); - $(".nav-panel-menu").addClass('hidden'); - $("#tag_label").focus(); - return false; - }); + $('#nav-btn-add-tag').on('click', function () { + $('.nav-panel-add-tag').toggle(100); + $('.nav-panel-menu').addClass('hidden'); + $('#tag_label').focus(); + return false; + }); /* ========================================================================== Annotations & Remember position ========================================================================== */ - if ($("article").length) { - var app = new annotator.App(); + if ($('article').length) { + var app = new annotator.App(); - app.include(annotator.ui.main, { - element: document.querySelector('article') - }); + app.include(annotator.ui.main, { + element: document.querySelector('article'), + }); - var 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(function () { - app.annotations.load({entry: x.entryId}); - }); + app.start().then(function () { + 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; - 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); + retrievePercent(x.entryId); - $(window).resize(function(){ - retrievePercent(x.entryId); - }); + $(window).resize(function () { + retrievePercent(x.entryId); + }); } });