From 2926ee877bcf8974c529e1271ded42971fe0d632 Mon Sep 17 00:00:00 2001 From: Seb Bacon Date: Mon, 5 Sep 2011 12:17:02 +0100 Subject: Flash a message to users from outside the deployed country, telling them about either (a) a website in their country, or (b) the existence of Alaveteli to help them make one themselves. Closes #124. --- public/javascripts/general.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 public/javascripts/general.js (limited to 'public/javascripts/general.js') diff --git a/public/javascripts/general.js b/public/javascripts/general.js new file mode 100644 index 000000000..ed5095f82 --- /dev/null +++ b/public/javascripts/general.js @@ -0,0 +1,22 @@ +$(document).ready(function() { + if(window.location.search.substring(1).search("country_name") == -1) { + if (!$.cookie('has_seen_country_message')) { + $.ajax({ + url: "/country_message", + dataType: 'html', + success: function(country_message){ + if (country_message != ''){ + $('#other-country-notice').html(country_message); + $('body:not(.front) #other-country-notice').show() + } + } + }) + + } + } + + $('#other-country-notice').click(function() { + $('#other-country-notice').hide(); + $.cookie('has_seen_country_message', 1, {expires: 365, path: '/'}); + }) +}) \ No newline at end of file -- cgit v1.2.3 From ec621a8a56ca04f4f8e5cf4566c7c66daf808b74 Mon Sep 17 00:00:00 2001 From: Seb Bacon Date: Mon, 12 Sep 2011 10:46:10 +0100 Subject: Modify "link to this" behaviour: make it pop up a box with an input prefilled with the URL, and display it with an icon rather than text. Fixes #172. --- public/javascripts/general.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'public/javascripts/general.js') diff --git a/public/javascripts/general.js b/public/javascripts/general.js index ed5095f82..3d6aae0d8 100644 --- a/public/javascripts/general.js +++ b/public/javascripts/general.js @@ -1,4 +1,5 @@ $(document).ready(function() { + // flash message for people coming from other countries if(window.location.search.substring(1).search("country_name") == -1) { if (!$.cookie('has_seen_country_message')) { $.ajax({ @@ -18,5 +19,21 @@ $(document).ready(function() { $('#other-country-notice').click(function() { $('#other-country-notice').hide(); $.cookie('has_seen_country_message', 1, {expires: 365, path: '/'}); - }) + }); + // "link to this" widget + $('a.link_to_this').click(function() { + var box = $('div#link_box'); + var location = window.location.protocol + "//" + window.location.hostname + $(this).attr('href'); + box.width(location.length + " em"); + box.find('input').val(location).attr('size', location.length + " em"); + box.show(); + box.find('input').select(); + box.position({ + my: "left top", + at: "left bottom", + of: this, + collision: "fit" }); + + }); + $('.close-button').click(function() { $(this).parent().hide() }); }) \ No newline at end of file -- cgit v1.2.3 From c13c5a717ad2ede8f51cc90c66daf8f573bf2ea4 Mon Sep 17 00:00:00 2001 From: Seb Bacon Date: Fri, 16 Sep 2011 09:26:34 +0100 Subject: Preserve search text when flipping between result types. Fixes #187. --- public/javascripts/general.js | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'public/javascripts/general.js') diff --git a/public/javascripts/general.js b/public/javascripts/general.js index 3d6aae0d8..ab74cf318 100644 --- a/public/javascripts/general.js +++ b/public/javascripts/general.js @@ -36,4 +36,12 @@ $(document).ready(function() { }); $('.close-button').click(function() { $(this).parent().hide() }); + $('div#variety-filter a').each(function() { + $(this).click(function() { + var form = $('form#search_form'); + form.attr('action', $(this).attr('href')); + form.submit(); + return false; + }) + }) }) \ No newline at end of file -- cgit v1.2.3