From 5ecdfcd041767c9e3244a92bb0a6cc3c3f80fea3 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Tue, 8 Mar 2016 17:02:34 +0100 Subject: manage assets through npm first draft remote assetic totally work nearly there use at least nodejs > 0.12 use proper version of grunt bump nodejs version for travis update npm workaround for materialize install node 5.0 add grunt-cli baggy theme & cache node modules cache bower & npm make travis build assets on php7 only exclude installing node & npm if not needed & use bash clean & try to make icomoon work on baggy ready config for travis rebase make travis work more travis work impove travis & update deps add missing pixrem deps add module through oddly lost ui updates install latest nodejs add install_dev.sh, link local binaries for npm/bower/grunt ui improvements (mostly baggy) fix travis build no need to install on travis Add unread filter to entries pages Add the ability to filter for unread pages in the filters menu. Add unread filter test to EntryControllerTest Add a new test to the EntryControllerTest collection which checks that only entries which have not been archived (and are treated as "unread") are retrieved. Improve English translation Update FAQ -Fix grammar -Add notes about MTA, firewall, and SELinux Update installation instructions -Fix grammar -Add SELinux section add screenshots of android docu in English Fix the deletion of Tags/Entries relation when delete an entry Fix #2121 Move fixtures to the right place Display a message when saving an entry failed When saving an entry fail because of database error we previously just returned `false`. Now we got an error in the log and the displayed notice to the user is updated too. Change ManyToMany between entry & tag Following https://gist.github.com/Ocramius/3121916 Be sure to remove the related entity when removing an entity. Let say you have Entry -> EntryTag -> Tag. If you remove the entry: - before that commit, the EntryTag will stay (at least using SQLite). - with that commit, the related entity is removed Prepare wallabag 2.0.5 enforce older materialize version --- app/Resources/static/themes/baggy/js/autoClose.js | 6 ++ .../static/themes/baggy/js/autoCompleteTags.js | 47 ++++++++++ .../static/themes/baggy/js/closeMessage.js | 17 ++++ app/Resources/static/themes/baggy/js/init.js | 101 +++++++++++++++++++++ app/Resources/static/themes/baggy/js/popupForm.js | 100 ++++++++++++++++++++ app/Resources/static/themes/baggy/js/saveLink.js | 78 ++++++++++++++++ 6 files changed, 349 insertions(+) create mode 100644 app/Resources/static/themes/baggy/js/autoClose.js create mode 100755 app/Resources/static/themes/baggy/js/autoCompleteTags.js create mode 100644 app/Resources/static/themes/baggy/js/closeMessage.js create mode 100755 app/Resources/static/themes/baggy/js/init.js create mode 100644 app/Resources/static/themes/baggy/js/popupForm.js create mode 100755 app/Resources/static/themes/baggy/js/saveLink.js (limited to 'app/Resources/static/themes/baggy/js') diff --git a/app/Resources/static/themes/baggy/js/autoClose.js b/app/Resources/static/themes/baggy/js/autoClose.js new file mode 100644 index 00000000..e9145b7e --- /dev/null +++ b/app/Resources/static/themes/baggy/js/autoClose.js @@ -0,0 +1,6 @@ +$(document).ready(function() { + current_url = window.location.href + if (current_url.match("&closewin=true")) { + window.close(); + } +}); diff --git a/app/Resources/static/themes/baggy/js/autoCompleteTags.js b/app/Resources/static/themes/baggy/js/autoCompleteTags.js new file mode 100755 index 00000000..90bc982c --- /dev/null +++ b/app/Resources/static/themes/baggy/js/autoCompleteTags.js @@ -0,0 +1,47 @@ +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; + } + }); + + +}); diff --git a/app/Resources/static/themes/baggy/js/closeMessage.js b/app/Resources/static/themes/baggy/js/closeMessage.js new file mode 100644 index 00000000..527719d5 --- /dev/null +++ b/app/Resources/static/themes/baggy/js/closeMessage.js @@ -0,0 +1,17 @@ +$(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; + }); +}); \ No newline at end of file diff --git a/app/Resources/static/themes/baggy/js/init.js b/app/Resources/static/themes/baggy/js/init.js new file mode 100755 index 00000000..1721ae41 --- /dev/null +++ b/app/Resources/static/themes/baggy/js/init.js @@ -0,0 +1,101 @@ +var $ = global.jquery = require('jquery'); +require('jquery.cookie'); +require('jquery-ui'); +var annotator = require('annotator'); + + +$.fn.ready(function() { + + var $listmode = $('#listmode'), + $listentries = $("#list-entries"); + + /* ========================================================================== + Menu + ========================================================================== */ + + $("#menu").click(function(){ + $("#links").toggleClass('menu--open'); + if ($('#content').hasClass('opacity03')) { + $('#content').removeClass('opacity03'); + } + }); + + /* ========================================================================== + List mode or Table Mode + ========================================================================== */ + + $listmode.click(function(){ + if ( jquery.cookie("listmode") == 1 ) { + // Cookie + $.removeCookie("listmode"); + + $listentries.removeClass("listmode"); + $listmode.removeClass("tablemode"); + $listmode.addClass("listmode"); + } + else { + // Cookie + jquery.cookie("listmode", 1, {expires: 365}); + + $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"); + } + + /* ========================================================================== + Add tag panel + ========================================================================== */ + + + $('#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(); + + app.include(annotator.ui.main, { + element: document.querySelector('article') + }); + + var x = JSON.parse($('#annotationroutes').html()); + app.include(annotator.storage.http, x); + + 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); + }); + + retrievePercent(x.entryId); + + $(window).resize(function(){ + retrievePercent(x.entryId); + }); + } +}); diff --git a/app/Resources/static/themes/baggy/js/popupForm.js b/app/Resources/static/themes/baggy/js/popupForm.js new file mode 100644 index 00000000..0b478fad --- /dev/null +++ b/app/Resources/static/themes/baggy/js/popupForm.js @@ -0,0 +1,100 @@ +$(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 new file mode 100755 index 00000000..91cc2c3f --- /dev/null +++ b/app/Resources/static/themes/baggy/js/saveLink.js @@ -0,0 +1,78 @@ +$.fn.ready(function() { + + var $bagit = $('#bagit'), + $bagitForm = $('#bagit-form'), + $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 " "; + }); + + $(".add-to-wallabag-link-after").click(function(event){ + toggleSaveLinkForm($(this).attr('href'), event); + event.preventDefault(); + }); + +}); + + -- cgit v1.2.3 From 0743287f955fd19fd1a04c91f3b40a4ac2236423 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Thu, 9 Jun 2016 19:02:38 +0200 Subject: clean & lint stuff --- app/Resources/static/themes/baggy/js/autoClose.js | 12 +- .../static/themes/baggy/js/autoCompleteTags.js | 35 +++-- .../static/themes/baggy/js/closeMessage.js | 36 ++--- app/Resources/static/themes/baggy/js/init.js | 99 ++++++------ app/Resources/static/themes/baggy/js/popupForm.js | 167 +++++++++++---------- app/Resources/static/themes/baggy/js/saveLink.js | 67 ++++----- 6 files changed, 207 insertions(+), 209 deletions(-) (limited to 'app/Resources/static/themes/baggy/js') diff --git a/app/Resources/static/themes/baggy/js/autoClose.js b/app/Resources/static/themes/baggy/js/autoClose.js index e9145b7e..b0dafab2 100644 --- a/app/Resources/static/themes/baggy/js/autoClose.js +++ b/app/Resources/static/themes/baggy/js/autoClose.js @@ -1,6 +1,8 @@ -$(document).ready(function() { - current_url = window.location.href - if (current_url.match("&closewin=true")) { - window.close(); - } +var $ = global.jquery = require('jquery'); + +$(document).ready(function () { + var currentUrl = window.location.href; + if (currentUrl.match('&closewin=true')) { + window.close(); + } }); diff --git a/app/Resources/static/themes/baggy/js/autoCompleteTags.js b/app/Resources/static/themes/baggy/js/autoCompleteTags.js index 90bc982c..edd0a421 100755 --- a/app/Resources/static/themes/baggy/js/autoCompleteTags.js +++ b/app/Resources/static/themes/baggy/js/autoCompleteTags.js @@ -1,47 +1,46 @@ -jQuery(function($) { +var $ = global.jquery = require('jquery'); - function split( val ) { - return val.split( /,\s*/ ); +jQuery(function ($) { + function split(val) { + return val.split(/,\s*/); } - function extractLast( term ) { - return split( term ).pop(); + function extractLast(term) { + return split(term).pop(); } - $("#value").bind("keydown", function(event) { - if (event.keyCode === $.ui.keyCode.TAB && $(this).data("ui-autocomplete").menu.active) { + $('#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), + source: function (request, response) { + $.getJSON('./?view=tags', { + term: extractLast(request.term), //id: $(':hidden#entry_id').val() }, response); }, - search : function() { + search: function () { // custom minLength var term = extractLast(this.value); if (term.length < 1) { return false; } }, - focus : function() { + focus: function () { // prevent value inserted on focus return false; }, - select : function(event, ui) { + 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(", "); + terms.push(''); + this.value = terms.join(', '); return false; - } + }, }); - - }); diff --git a/app/Resources/static/themes/baggy/js/closeMessage.js b/app/Resources/static/themes/baggy/js/closeMessage.js index 527719d5..ae4b1791 100644 --- a/app/Resources/static/themes/baggy/js/closeMessage.js +++ b/app/Resources/static/themes/baggy/js/closeMessage.js @@ -1,17 +1,19 @@ -$(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; - }); -}); \ No newline at end of file +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; + }); +}); 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); + }); } }); diff --git a/app/Resources/static/themes/baggy/js/popupForm.js b/app/Resources/static/themes/baggy/js/popupForm.js index 0b478fad..95ba60ee 100644 --- a/app/Resources/static/themes/baggy/js/popupForm.js +++ b/app/Resources/static/themes/baggy/js/popupForm.js @@ -1,100 +1,101 @@ -$(document).ready(function() { +var $ = global.jquery = require('jquery'); - $("#search-form").hide(); - $("#bagit-form").hide(); - $("#filter-form").hide(); - $("#download-form").hide(); +$(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 '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 'Filter' popup on entries list + //--------------------------------------------------------------------------- + function toggleFilter() { + $('#filter-form').toggle(); + } - //--------------------------------------------------------------------------- - // Toggle the "Download" popup on entries list - //--------------------------------------------------------------------------- - function toggleDownload() { - $("#download-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 '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"); - } + //--------------------------------------------------------------------------- + // 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(); - }); + $('#search').click(function () { + closePopups(); + toggleSearch(); + $('#searchfield').focus(); + }); - $(".filter-btn").click(function(){ - closePopups(); - toggleFilter(); - }); + $('.filter-btn').click(function () { + closePopups(); + toggleFilter(); + }); - $(".download-btn").click(function(){ - closePopups(); - toggleDownload(); - }); + $('.download-btn').click(function () { + closePopups(); + toggleDownload(); + }); - $("#bagit").click(function(){ - closePopups(); - toggleBagit(); - $("#plainurl").focus(); - }); + $('#bagit').click(function () { + closePopups(); + toggleBagit(); + $('#plainurl').focus(); + }); - $("#search-form-close").click(function(){ - toggleSearch(); - }); + $('#search-form-close').click(function () { + toggleSearch(); + }); - $("#filter-form-close").click(function(){ - toggleFilter(); - }); + $('#filter-form-close').click(function () { + toggleFilter(); + }); - $("#download-form-close").click(function(){ - toggleDownload(); - }); + $('#download-form-close').click(function () { + toggleDownload(); + }); - $("#bagit-form-close").click(function(){ - toggleBagit(); - }); + $('#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 index 91cc2c3f..5c720886 100755 --- a/app/Resources/static/themes/baggy/js/saveLink.js +++ b/app/Resources/static/themes/baggy/js/saveLink.js @@ -1,60 +1,60 @@ -$.fn.ready(function() { +var $ = global.jquery = require('jquery'); - var $bagit = $('#bagit'), - $bagitForm = $('#bagit-form'), - $bagitFormForm = $('#bagit-form-form'); +$.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(); + $('#add-link-result').empty(); - $bagit.toggleClass("active-current"); + $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"}); + // 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(); + if ($('#search-form').length !== 0) { + $('#search').removeClass('current'); + $('#search-arrow').removeClass('arrow-down'); + $('#search-form').hide(); } $bagitForm.toggle(); - $('#content').toggleClass("opacity03"); + $('#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(); + // 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!"); + success: function (data) { + $('#add-link-result').html('Done!'); $('#plainurl').val(''); $('#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(); @@ -64,15 +64,12 @@ $.fn.ready(function() { Process all links inside an article ========================================================================== */ - $("article a[href^='http']").after(function() { - return " "; + $('article a[href^="http"]').after(function () { + return ' '; }); - $(".add-to-wallabag-link-after").click(function(event){ + $('.add-to-wallabag-link-after').click(function (event) { toggleSaveLinkForm($(this).attr('href'), event); event.preventDefault(); }); - }); - - -- cgit v1.2.3 From c146f6940a176142084b4fc3c610d13aca60d90e Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Wed, 28 Sep 2016 10:30:18 +0200 Subject: Assets work * ES6 all the things ! * ESLint checks everything * CSS fixes (use stylelint) * Fix #2231 --- app/Resources/static/themes/baggy/js/autoClose.js | 8 - .../static/themes/baggy/js/autoCompleteTags.js | 52 +--- .../static/themes/baggy/js/closeMessage.js | 19 -- app/Resources/static/themes/baggy/js/init.js | 277 ++++++++++++++++++--- app/Resources/static/themes/baggy/js/popupForm.js | 101 -------- app/Resources/static/themes/baggy/js/saveLink.js | 75 ------ app/Resources/static/themes/baggy/js/uiTools.js | 35 +++ 7 files changed, 286 insertions(+), 281 deletions(-) delete mode 100644 app/Resources/static/themes/baggy/js/autoClose.js delete mode 100644 app/Resources/static/themes/baggy/js/closeMessage.js delete mode 100644 app/Resources/static/themes/baggy/js/popupForm.js delete mode 100755 app/Resources/static/themes/baggy/js/saveLink.js create mode 100644 app/Resources/static/themes/baggy/js/uiTools.js (limited to 'app/Resources/static/themes/baggy/js') diff --git a/app/Resources/static/themes/baggy/js/autoClose.js b/app/Resources/static/themes/baggy/js/autoClose.js deleted file mode 100644 index b0dafab2..00000000 --- a/app/Resources/static/themes/baggy/js/autoClose.js +++ /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(); - } -}); diff --git a/app/Resources/static/themes/baggy/js/autoCompleteTags.js b/app/Resources/static/themes/baggy/js/autoCompleteTags.js index edd0a421..f287ebfa 100755 --- a/app/Resources/static/themes/baggy/js/autoCompleteTags.js +++ b/app/Resources/static/themes/baggy/js/autoCompleteTags.js @@ -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 index ae4b1791..00000000 --- a/app/Resources/static/themes/baggy/js/closeMessage.js +++ /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; - }); -}); diff --git a/app/Resources/static/themes/baggy/js/init.js b/app/Resources/static/themes/baggy/js/init.js index d7d4b166..c6a54f6f 100755 --- a/app/Resources/static/themes/baggy/js/init.js +++ b/app/Resources/static/themes/baggy/js/init.js @@ -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( + () => `' + ); + + $('.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 index 95ba60ee..00000000 --- a/app/Resources/static/themes/baggy/js/popupForm.js +++ /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 index 5c720886..00000000 --- a/app/Resources/static/themes/baggy/js/saveLink.js +++ /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 ' '; - }); - - $('.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 index 00000000..900b2707 --- /dev/null +++ b/app/Resources/static/themes/baggy/js/uiTools.js @@ -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 }; -- cgit v1.2.3 From 8f234d0156cc6f2eb6e3c9f692e4633b35fafc41 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Wed, 28 Sep 2016 18:59:15 +0200 Subject: remove autocomplete and bring fonts through npm --- app/Resources/static/themes/baggy/js/init.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'app/Resources/static/themes/baggy/js') diff --git a/app/Resources/static/themes/baggy/js/init.js b/app/Resources/static/themes/baggy/js/init.js index c6a54f6f..8da9a859 100755 --- a/app/Resources/static/themes/baggy/js/init.js +++ b/app/Resources/static/themes/baggy/js/init.js @@ -1,6 +1,6 @@ const $ = global.jquery = require('jquery'); require('jquery.cookie'); -require('jquery-ui'); +require('jquery-ui-browserify'); const annotator = require('annotator'); import { savePercent, retrievePercent } from '../../_global/js/tools.js'; import { split, extractLast } from './autoCompleteTags.js'; @@ -124,6 +124,10 @@ $.fn.ready(() => { /** * Tags autocomplete */ + /** + * Not working on v2 + * + $('#value').bind('keydown', (event) => { if (event.keyCode === $.ui.keyCode.TAB && $(this).data('ui-autocomplete').menu.active) { event.preventDefault(); @@ -156,6 +160,7 @@ $.fn.ready(() => { return false; }, }); + */ //--------------------------------------------------------------------------- // Close the message box when the user clicks the close icon -- cgit v1.2.3 From 9f7d154e3451f1ccc1d69f0013e98acf4639c63b Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Tue, 4 Oct 2016 12:14:28 +0200 Subject: Add eslint & stylelint tests (fix a few things) and move dependencies to dev --- app/Resources/static/themes/baggy/js/init.js | 1 - 1 file changed, 1 deletion(-) (limited to 'app/Resources/static/themes/baggy/js') diff --git a/app/Resources/static/themes/baggy/js/init.js b/app/Resources/static/themes/baggy/js/init.js index 8da9a859..07afd311 100755 --- a/app/Resources/static/themes/baggy/js/init.js +++ b/app/Resources/static/themes/baggy/js/init.js @@ -3,7 +3,6 @@ require('jquery.cookie'); require('jquery-ui-browserify'); const annotator = require('annotator'); import { savePercent, retrievePercent } from '../../_global/js/tools.js'; -import { split, extractLast } from './autoCompleteTags.js'; import { toggleSaveLinkForm } from './uiTools.js'; -- cgit v1.2.3 From 6cb364a2c123b96d245b1ca3c330fd0042c74cd1 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Tue, 4 Oct 2016 15:30:05 +0200 Subject: use airbnb base rules and update eslint --- app/Resources/static/themes/baggy/js/init.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'app/Resources/static/themes/baggy/js') diff --git a/app/Resources/static/themes/baggy/js/init.js b/app/Resources/static/themes/baggy/js/init.js index 07afd311..dc11043a 100755 --- a/app/Resources/static/themes/baggy/js/init.js +++ b/app/Resources/static/themes/baggy/js/init.js @@ -1,9 +1,10 @@ +import { savePercent, retrievePercent } from '../../_global/js/tools'; +import { toggleSaveLinkForm } from './uiTools'; + const $ = global.jquery = require('jquery'); require('jquery.cookie'); require('jquery-ui-browserify'); const annotator = require('annotator'); -import { savePercent, retrievePercent } from '../../_global/js/tools.js'; -import { toggleSaveLinkForm } from './uiTools.js'; $.fn.ready(() => { -- cgit v1.2.3