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/_pocheit-form.twig | 3 ++- themes/baggy/css/main.css | 6 ++++++ themes/baggy/js/init.js | 31 ++++++++++++++++++++++++++----- 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/themes/baggy/_pocheit-form.twig b/themes/baggy/_pocheit-form.twig index ff911515..505ec368 100755 --- a/themes/baggy/_pocheit-form.twig +++ b/themes/baggy/_pocheit-form.twig @@ -1,9 +1,10 @@
-
+

X {% trans "Save a link" %}

+
diff --git a/themes/baggy/css/main.css b/themes/baggy/css/main.css index ba4b7c7f..61e0b47e 100755 --- a/themes/baggy/css/main.css +++ b/themes/baggy/css/main.css @@ -607,6 +607,11 @@ a#bagit-form-close:hover { padding: 0 3px 2px 3px; } +#add-link-result { + font-weight: bold; + margin-top: 10px; +} + /* ========================================================================== 3 = Pictos ========================================================================== */ @@ -741,6 +746,7 @@ a#bagit-form-close:hover { #article { width: 70%; margin-bottom: 3em; + text-align: justify; } #article .tags { 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