From 4744cb0e1df8ee7c1cd10c9fbd67caec73051024 Mon Sep 17 00:00:00 2001 From: Thomas LEBEAU Date: Sat, 8 Mar 2014 13:47:15 +0100 Subject: bagit link + overlay save link + listmode --- themes/baggy/js/init.js | 71 ++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 55 insertions(+), 16 deletions(-) (limited to 'themes/baggy/js') diff --git a/themes/baggy/js/init.js b/themes/baggy/js/init.js index 4a843548..99bffd09 100755 --- a/themes/baggy/js/init.js +++ b/themes/baggy/js/init.js @@ -1,36 +1,75 @@ -$(document).ready(function() { +$.fn.ready(function() { + + var $listmode = $('#listmode'), + $listentries = $("#list-entries"), + $bagit = $('#bagit'), + $bagitForm = $('#bagit-form'); + + /* ========================================================================== + Menu + ========================================================================== */ $("#menu").click(function(){ $("#links").toggle(); }); + /* ========================================================================== + List mode or Table Mode + ========================================================================== */ - $("#listmode").click(function(){ + $listmode.click(function(){ if ( $.cookie("listmode") == 1 ) { - $(".entrie").css("width", ""); - $(".entrie").css("margin-left", ""); - + // Cookie $.removeCookie("listmode"); - $("#listmode").removeClass("tablemode"); - $("#listmode").addClass("listmode"); + + $listentries.removeClass("listmode"); + $listmode.removeClass("tablemode"); + $listmode.addClass("listmode"); } else { + // Cookie $.cookie("listmode", 1, {expires: 365}); - $(".entrie").css("width", "100%"); - $(".entrie").css("margin-left", "0"); - $("#listmode").removeClass("listmode"); - $("#listmode").addClass("tablemode"); + $listentries.addClass("listmode"); + $listmode.removeClass("listmode"); + $listmode.addClass("tablemode"); } }); + /* ========================================================================== + Cookie listmode + ========================================================================== */ + if ( $.cookie("listmode") == 1 ) { - $(".entrie").css("width", "100%"); - $(".entrie").css("margin-left", "0"); - $("#listmode").removeClass("listmode"); - $("#listmode").addClass("tablemode"); + $listentries.addClass("listmode"); + $listmode.removeClass("listmode"); + $listmode.addClass("tablemode"); } + /* ========================================================================== + bag it link + ========================================================================== */ + + $bagit.click(function(){ + $bagitForm.toggle(); + }); + + /* ========================================================================== + Keyboard gestion + ========================================================================== */ + + $(window).keydown(function(e){ + switch (e.keyCode) { + // s letter + case 83: + $bagitForm.toggle(); + break; + case 27: + $bagitForm.hide(); + break; + } + }) + -}); +}); \ No newline at end of file -- cgit v1.2.3 From 7339b0b08dc5cd97c478981a431829bf587256f2 Mon Sep 17 00:00:00 2001 From: Maryana Rozhankivska Date: Wed, 12 Mar 2014 13:00:37 +0200 Subject: fix of conflict of s shortcat and entering s in input fields --- themes/baggy/js/init.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'themes/baggy/js') diff --git a/themes/baggy/js/init.js b/themes/baggy/js/init.js index 99bffd09..4e85beaa 100755 --- a/themes/baggy/js/init.js +++ b/themes/baggy/js/init.js @@ -60,16 +60,19 @@ $.fn.ready(function() { ========================================================================== */ $(window).keydown(function(e){ - switch (e.keyCode) { - // s letter - case 83: - $bagitForm.toggle(); - break; - case 27: - $bagitForm.hide(); - break; + if ( e.target.tagName.toLowerCase() !== 'input' ) { + switch (e.keyCode) { + // s letter + case 83: + $bagitForm.toggle(); + return false; + break; + case 27: + $bagitForm.hide(); + break; + } } }) -}); \ No newline at end of file +}); -- cgit v1.2.3 From 6775da70a845a7fa8364dd3bc1a8e7702e9789bf Mon Sep 17 00:00:00 2001 From: Maryana Rozhankivska Date: Wed, 12 Mar 2014 17:36:04 +0200 Subject: feature #505 - it is now possible to add link from bagged article (TODO: redev it to ajax action). Some enhancements to "save a link" popup div --- themes/baggy/js/init.js | 61 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 44 insertions(+), 17 deletions(-) (limited to 'themes/baggy/js') diff --git a/themes/baggy/js/init.js b/themes/baggy/js/init.js index 4e85beaa..4830bd25 100755 --- a/themes/baggy/js/init.js +++ b/themes/baggy/js/init.js @@ -48,31 +48,58 @@ $.fn.ready(function() { } /* ========================================================================== - bag it link - ========================================================================== */ + bag it link and close button + ========================================================================== */ - $bagit.click(function(){ + function toggleSaveLinkForm(url) { + $bagit.toggleClass("active-current"); $bagitForm.toggle(); + $('#content').toggleClass("opacity03"); + if (url !== 'undefined' && url) { + $('#plainurl').val(url); + } + $('#plainurl').focus(); + } + + $bagit.click(function(){ + toggleSaveLinkForm(); + }); + + $("#bagit-form-close").click(function(){ + toggleSaveLinkForm(); + }); + + $('#bagit-form form').submit(function(){ + toggleSaveLinkForm(); + return true; }); /* ========================================================================== - Keyboard gestion - ========================================================================== */ + Keyboard gestion + ========================================================================== */ $(window).keydown(function(e){ - if ( e.target.tagName.toLowerCase() !== 'input' ) { - switch (e.keyCode) { - // s letter - case 83: - $bagitForm.toggle(); - return false; - break; - case 27: - $bagitForm.hide(); - break; - } + if ( ( e.target.tagName.toLowerCase() !== 'input' && e.keyCode == 83 ) || e.keyCode == 27 ) { + toggleSaveLinkForm(); + return false; } - }) + }); + + /* ========================================================================== + Process all links inside an article + ========================================================================== */ + + $("article a[href^='http']").after(function() { + return " w "; + }); + + $(".add-to-wallabag-link-after").click(function(event){ + event.preventDefault(); + toggleSaveLinkForm($(this).attr('href')); + return false; + }); + + }); -- cgit v1.2.3 From 3ee27ee6ba8d44182ddeac7b54d75cc54affeec7 Mon Sep 17 00:00:00 2001 From: Maryana Rozhankivska Date: Thu, 13 Mar 2014 18:37:08 +0200 Subject: saving link form now sends ajax request, article view is now justified --- themes/baggy/js/init.js | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'themes/baggy/js') diff --git a/themes/baggy/js/init.js b/themes/baggy/js/init.js index 4830bd25..da644fbe 100755 --- a/themes/baggy/js/init.js +++ b/themes/baggy/js/init.js @@ -4,6 +4,7 @@ $.fn.ready(function() { $listentries = $("#list-entries"), $bagit = $('#bagit'), $bagitForm = $('#bagit-form'); + $bagitFormForm = $('#bagit-form-form'); /* ========================================================================== Menu @@ -69,9 +70,30 @@ $.fn.ready(function() { toggleSaveLinkForm(); }); - $('#bagit-form form').submit(function(){ - toggleSaveLinkForm(); - return true; + + //send "bag it link" form request via ajax + $bagitFormForm.submit( function(event) { + $bagitFormForm.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(''); + $bagitFormForm.css("cursor", "auto"); + //setTimeout( function() { toggleSaveLinkForm(); }, 1000); //close form after 1000 delay + }, + error: function(data) { + $('#add-link-result').html("Failed!"); + $bagitFormForm.css("cursor", "auto"); + } + }); + + event.preventDefault(); }); /* ========================================================================== @@ -94,9 +116,8 @@ $.fn.ready(function() { }); $(".add-to-wallabag-link-after").click(function(event){ - event.preventDefault(); toggleSaveLinkForm($(this).attr('href')); - return false; + event.preventDefault(); }); -- cgit v1.2.3