Better save notifications

This commit is contained in:
Yordan Ivanov 2017-10-04 22:36:55 +03:00
parent fe365b46bf
commit 091b442364
No known key found for this signature in database
GPG Key ID: 0621C9F3657425C0
4 changed files with 47 additions and 9 deletions

View File

@ -1,4 +1,17 @@
(function() { (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) { function toggle_grid(whichDay) {
var vclasses= ['in-list', 'in-calendar onlyday1', 'in-calendar onlyday2', 'in-calendar onlyday3', var vclasses= ['in-list', 'in-calendar onlyday1', 'in-calendar onlyday2', 'in-calendar onlyday3',
'in-calendar onlyday4', 'in-calendar alldays']; 'in-calendar onlyday4', 'in-calendar alldays'];
@ -47,8 +60,6 @@
if( !myapi || !myapi.length ) { if( !myapi || !myapi.length ) {
/* If we do not have resource URL, post data and get resource */ /* If we do not have resource URL, post data and get resource */
$.post( halfnarpAPI, request, function( data ) { $.post( halfnarpAPI, request, function( data ) {
$('.info span').text('submitted');
$('.info').removeClass('hidden');
try { try {
localStorage['OpenFest-gauge-api'] = data['update_url']; localStorage['OpenFest-gauge-api'] = data['update_url'];
localStorage['OpenFest-gauge-pid'] = mypid = data['hashed_uid']; localStorage['OpenFest-gauge-pid'] = mypid = data['hashed_uid'];
@ -56,8 +67,7 @@
window.location.hash = mypid; window.location.hash = mypid;
} catch(err) {} } catch(err) {}
}, 'json' ).fail(function() { }, 'json' ).fail(function() {
$('.info span').text('failed :('); show_stauts(false);
$('.info').removeClass('hidden');
}); });
} else { } else {
/* If we do have a resource URL, update resource */ /* If we do have a resource URL, update resource */
@ -71,11 +81,9 @@
if( localStorage['OpenFest-gauge-pid'] ) { if( localStorage['OpenFest-gauge-pid'] ) {
window.location.hash = localStorage['OpenFest-gauge-pid']; window.location.hash = localStorage['OpenFest-gauge-pid'];
} }
$('.info span').text('updated'); show_status(true);
$('.info').removeClass('hidden'); }).fail(function() {
}).fail(function(msg) { show_stauts(false);
$('.info span').text('failed');
$('.info').removeClass('hidden');
}); });
} }

View File

@ -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; 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 { .header {
min-width: 640px; min-width: 640px;
} }

View File

@ -1,3 +1,8 @@
<div class="status">
<span class="success"><%= t 'generic.status_success' %></span>
<span class="failed"><%= t 'generic.status_failed' %></span>
</div>
<div style="display:none"> <div style="display:none">
<div id="template"> <div id="template">
<div class="title"></div> <div class="title"></div>

View File

@ -7,3 +7,5 @@ bg:
click_on_the_talks_you_would_like_to_watch: Кликнете (или натиснете два пъти, ако сте на мобилно устройство) върху лекциите, които искате да посетите. click_on_the_talks_you_would_like_to_watch: Кликнете (или натиснете два пъти, ако сте на мобилно устройство) върху лекциите, които искате да посетите.
press_submit: Натиснете „Изпрати“. press_submit: Натиснете „Изпрати“.
filter_events: Търсене filter_events: Търсене
status_success: Предпочитанията Ви са запазени
status_failed: Не успахме да запазим предпочитанията Ви