From 89ee994f772554b035e8033ee49c389f0f7786ba Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Mon, 24 Aug 2015 20:15:57 +0200 Subject: Remove some global assets Some global assets where dedicated to baggy Remove some non-used css --- .../views/themes/baggy/public/js/autoClose.js | 6 ++ .../themes/baggy/public/js/autoCompleteTags.js | 47 +++++++++ .../views/themes/baggy/public/js/closeMessage.js | 17 ++++ .../views/themes/baggy/public/js/popupForm.js | 72 ++++++++++++++ .../views/themes/baggy/public/js/saveLink.js | 109 +++++++++++++++++++++ 5 files changed, 251 insertions(+) create mode 100644 src/Wallabag/CoreBundle/Resources/views/themes/baggy/public/js/autoClose.js create mode 100755 src/Wallabag/CoreBundle/Resources/views/themes/baggy/public/js/autoCompleteTags.js create mode 100644 src/Wallabag/CoreBundle/Resources/views/themes/baggy/public/js/closeMessage.js create mode 100644 src/Wallabag/CoreBundle/Resources/views/themes/baggy/public/js/popupForm.js create mode 100755 src/Wallabag/CoreBundle/Resources/views/themes/baggy/public/js/saveLink.js (limited to 'src/Wallabag/CoreBundle/Resources/views/themes/baggy/public') diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/public/js/autoClose.js b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/public/js/autoClose.js new file mode 100644 index 00000000..e9145b7e --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/public/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/src/Wallabag/CoreBundle/Resources/views/themes/baggy/public/js/autoCompleteTags.js b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/public/js/autoCompleteTags.js new file mode 100755 index 00000000..90bc982c --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/public/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/src/Wallabag/CoreBundle/Resources/views/themes/baggy/public/js/closeMessage.js b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/public/js/closeMessage.js new file mode 100644 index 00000000..527719d5 --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/public/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/src/Wallabag/CoreBundle/Resources/views/themes/baggy/public/js/popupForm.js b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/public/js/popupForm.js new file mode 100644 index 00000000..d233e600 --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/public/js/popupForm.js @@ -0,0 +1,72 @@ +$(document).ready(function() { + + $("#search-form").hide(); + $("#bagit-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 "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(); + }); + + $("#bagit").click(function(){ + closePopups(); + toggleBagit(); + $("#plainurl").focus(); + }); + + $("#search-form-close").click(function(){ + toggleSearch(); + }); + + $("#bagit-form-close").click(function(){ + toggleBagit(); + }); + + // $("#").click(function(){ + // toggleSearch(); + // }); + + +}); diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/public/js/saveLink.js b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/public/js/saveLink.js new file mode 100755 index 00000000..a7acd84c --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/public/js/saveLink.js @@ -0,0 +1,109 @@ +$.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(); + } + + //--------------------------------------------------------------------------- + // These two functions are now taken care of in popupForm.js + //--------------------------------------------------------------------------- + + // $bagit.click(function(){ + // $bagit.toggleClass("current"); + // $("#bagit-arrow").toggleClass("arrow-down"); + // toggleSaveLinkForm(); + // }); + + // $("#bagit-form-close").click(function(){ + // $bagit.removeClass("current"); + // $("#bagit-arrow").removeClass("arrow-down"); + // toggleSaveLinkForm(); + // }); + + + //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"); + //setTimeout( function() { toggleSaveLinkForm(); }, 1000); //close form after 1000 delay + }, + error: function(data) { + $('#add-link-result').html("Failed!"); + $("body").css("cursor", "auto"); + } + }); + + event.preventDefault(); + }); + + /* ========================================================================== + Keyboard gestion + ========================================================================== */ + + $(window).keydown(function(e){ + if ( ( e.target.tagName.toLowerCase() !== 'input' && e.keyCode == 83 ) || (e.keyCode == 27 && $bagitForm.is(':visible') ) ) { + $bagit.removeClass("current"); + $("#bagit-arrow").removeClass("arrow-down"); + toggleSaveLinkForm(); + return false; + } + }); + + /* ========================================================================== + 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