From 48fb171d7a64dbd1036f9e17cbf4c14304483817 Mon Sep 17 00:00:00 2001 From: tcit Date: Wed, 15 Oct 2014 16:47:38 +0200 Subject: fix for #830 --- themes/default/js/popupForm.js | 8 ++++++++ themes/default/js/saveLink.js | 7 ++++++- 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'themes/default/js') diff --git a/themes/default/js/popupForm.js b/themes/default/js/popupForm.js index a32e6e70..eb6d1ae2 100644 --- a/themes/default/js/popupForm.js +++ b/themes/default/js/popupForm.js @@ -10,6 +10,14 @@ $(document).ready(function() { $("#search").click(function(){ closeSearch(); + // if other popup is already shown + if ($("#bagit-form").length != 0) { + $("#bagit").removeClass("active-current"); + $('#content').removeClass("opacity03"); + $("#bagit").removeClass("current"); + $("#bagit-arrow").removeClass("arrow-down"); + $("#bagit-form").hide(); + } $('#searchfield').focus(); }); diff --git a/themes/default/js/saveLink.js b/themes/default/js/saveLink.js index 6dbce97e..b52b8a2c 100755 --- a/themes/default/js/saveLink.js +++ b/themes/default/js/saveLink.js @@ -13,7 +13,7 @@ $.fn.ready(function() { $bagit.toggleClass("active-current"); - //only if bagiti link is not presented on page + //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}); @@ -23,6 +23,11 @@ $.fn.ready(function() { } } + 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) { -- cgit v1.2.3 From ff02fd8aca56a63e8caf3b9f87de8a677dd419e9 Mon Sep 17 00:00:00 2001 From: Jay Sitter Date: Sun, 2 Nov 2014 11:15:36 -0500 Subject: Improving JavaScript for popup forms --- themes/default/js/popupForm.js | 69 ++++++++++++++++++++++++++++++++++-------- themes/default/js/saveLink.js | 27 +++++++++-------- 2 files changed, 71 insertions(+), 25 deletions(-) (limited to 'themes/default/js') diff --git a/themes/default/js/popupForm.js b/themes/default/js/popupForm.js index eb6d1ae2..d233e600 100644 --- a/themes/default/js/popupForm.js +++ b/themes/default/js/popupForm.js @@ -1,29 +1,72 @@ $(document).ready(function() { $("#search-form").hide(); + $("#bagit-form").hide(); - function closeSearch() { + //--------------------------------------------------------------------------- + // 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"); + } } - $("#search").click(function(){ - closeSearch(); - // if other popup is already shown - if ($("#bagit-form").length != 0) { - $("#bagit").removeClass("active-current"); - $('#content').removeClass("opacity03"); - $("#bagit").removeClass("current"); - $("#bagit-arrow").removeClass("arrow-down"); - $("#bagit-form").hide(); + //--------------------------------------------------------------------------- + // 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"); } - $('#searchfield').focus(); + } + + //--------------------------------------------------------------------------- + // 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(){ - closeSearch(); + toggleSearch(); }); + $("#bagit-form-close").click(function(){ + toggleBagit(); + }); + + // $("#").click(function(){ + // toggleSearch(); + // }); + -}); \ No newline at end of file +}); diff --git a/themes/default/js/saveLink.js b/themes/default/js/saveLink.js index b52b8a2c..a7acd84c 100755 --- a/themes/default/js/saveLink.js +++ b/themes/default/js/saveLink.js @@ -36,18 +36,21 @@ $.fn.ready(function() { $('#plainurl').focus(); } - - $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(); - }); + //--------------------------------------------------------------------------- + // 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 -- cgit v1.2.3