diff --git a/app/assets/javascripts/halfnarp.js b/app/assets/javascripts/halfnarp.js index 34a4317..bb212ac 100644 --- a/app/assets/javascripts/halfnarp.js +++ b/app/assets/javascripts/halfnarp.js @@ -1,4 +1,17 @@ (function() { + function show_status(status) { + var container = $('.status'); + var span = container.find(status ? '.success' : '.failed'); + + container.find('span').hide(); + span.show(); + container.addClass('shown'); + + setTimeout(function() { + container.removeClass('shown'); + }, 3000); + } + function toggle_grid(whichDay) { var vclasses= ['in-list', 'in-calendar onlyday1', 'in-calendar onlyday2', 'in-calendar onlyday3', 'in-calendar onlyday4', 'in-calendar alldays']; @@ -47,8 +60,6 @@ if( !myapi || !myapi.length ) { /* If we do not have resource URL, post data and get resource */ $.post( halfnarpAPI, request, function( data ) { - $('.info span').text('submitted'); - $('.info').removeClass('hidden'); try { localStorage['OpenFest-gauge-api'] = data['update_url']; localStorage['OpenFest-gauge-pid'] = mypid = data['hashed_uid']; @@ -56,8 +67,7 @@ window.location.hash = mypid; } catch(err) {} }, 'json' ).fail(function() { - $('.info span').text('failed :('); - $('.info').removeClass('hidden'); + show_stauts(false); }); } else { /* If we do have a resource URL, update resource */ @@ -71,11 +81,9 @@ if( localStorage['OpenFest-gauge-pid'] ) { window.location.hash = localStorage['OpenFest-gauge-pid']; } - $('.info span').text('updated'); - $('.info').removeClass('hidden'); - }).fail(function(msg) { - $('.info span').text('failed'); - $('.info').removeClass('hidden'); + show_status(true); + }).fail(function() { + show_stauts(false); }); } diff --git a/app/assets/stylesheets/halfnarp.css b/app/assets/stylesheets/halfnarp.css index a566599..90ccc3e 100644 --- a/app/assets/stylesheets/halfnarp.css +++ b/app/assets/stylesheets/halfnarp.css @@ -2,6 +2,29 @@ body { font-family: "HelveticaNeueLight", "HelveticaNeue-Light", "Helvetica Neue Light", "HelveticaNeue", "Helvetica Neue", 'TeXGyreHerosRegular', "Helvetica", "Tahoma", "Geneva", "Arial", sans-serif; font-weight:300; font-stretch:normal; } +.status { + position: fixed; + z-index: 1; + transition: opacity 0.6s; + top: 0; + left: 0; + right: 0; + opacity:0; + background: #fde073; + text-align: center; + line-height: 2.5; + overflow: hidden; + box-shadow: 0 0 5px black; +} + +.status.shown { + opacity: 1; +} + +.status span { + display: none; +} + .header { min-width: 640px; } diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb index 4b0ecd6..0e1d99a 100644 --- a/app/views/home/index.html.erb +++ b/app/views/home/index.html.erb @@ -1,3 +1,8 @@ +
+ <%= t 'generic.status_success' %> + <%= t 'generic.status_failed' %> +
+
diff --git a/config/locales/bg.yml b/config/locales/bg.yml index 83f10b0..d5528ca 100644 --- a/config/locales/bg.yml +++ b/config/locales/bg.yml @@ -7,3 +7,5 @@ bg: click_on_the_talks_you_would_like_to_watch: Кликнете (или натиснете два пъти, ако сте на мобилно устройство) върху лекциите, които искате да посетите. press_submit: Натиснете „Изпрати“. filter_events: Търсене + status_success: Предпочитанията Ви са запазени + status_failed: Не успахме да запазим предпочитанията Ви