Commit 6841f7f2db86136a79e377bf4dd05184f0c6146b
1 parent
635fcd62
Exists in
master
and in
5 other branches
add contrast into cookie (now, it is not removed on page reload)
Showing
1 changed file
with
27 additions
and
10 deletions
Show diff stats
js/main.js
| ... | ... | @@ -936,6 +936,11 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun |
| 936 | 936 | $( '#display-contrast' ).on('click', function(e){ |
| 937 | 937 | e.preventDefault(); |
| 938 | 938 | $('body').toggleClass('contrast'); |
| 939 | + | |
| 940 | + if($.cookie){ | |
| 941 | + var isContrasted = $('body').hasClass('contrast'); | |
| 942 | + $.cookie('dialoga_contraste', isContrasted); | |
| 943 | + } | |
| 939 | 944 | }); |
| 940 | 945 | |
| 941 | 946 | $( '.show_body' ).on('click', function(e){ |
| ... | ... | @@ -1020,17 +1025,29 @@ define(['jquery', 'handlebars', 'fastclick', 'handlebars_helpers', 'piwik'], fun |
| 1020 | 1025 | |
| 1021 | 1026 | FastClick.attach(document.body); |
| 1022 | 1027 | |
| 1023 | - if($.cookie('_dialoga_session')) { | |
| 1024 | - var url = host + '/api/v1/users/me?private_token=' + $.cookie('_dialoga_session'); | |
| 1025 | - $.getJSON(url).done(function( data ) { | |
| 1026 | - logged_in = true; | |
| 1027 | - Main.private_token = $.cookie('_dialoga_session'); | |
| 1028 | + if($.cookie) { | |
| 1028 | 1029 | |
| 1029 | - if(data && data.user){ | |
| 1030 | - Main.setUser(data.user); | |
| 1031 | - Main.showLogout(); | |
| 1032 | - } | |
| 1033 | - }); | |
| 1030 | + // session | |
| 1031 | + if($.cookie('_dialoga_session')){ | |
| 1032 | + var url = host + '/api/v1/users/me?private_token=' + $.cookie('_dialoga_session'); | |
| 1033 | + $.getJSON(url).done(function( data ) { | |
| 1034 | + logged_in = true; | |
| 1035 | + Main.private_token = $.cookie('_dialoga_session'); | |
| 1036 | + | |
| 1037 | + if(data && data.user){ | |
| 1038 | + Main.setUser(data.user); | |
| 1039 | + Main.showLogout(); | |
| 1040 | + } | |
| 1041 | + }); | |
| 1042 | + } | |
| 1043 | + | |
| 1044 | + // contrast | |
| 1045 | + var isContrasted = $.cookie('dialoga_contraste'); | |
| 1046 | + console.log('isContrasted', isContrasted); | |
| 1047 | + if(isContrasted){ | |
| 1048 | + // remove all classes 'contrast' and add only one 'contrast' | |
| 1049 | + $('body').addClass('contrast'); | |
| 1050 | + } | |
| 1034 | 1051 | } |
| 1035 | 1052 | |
| 1036 | 1053 | $(document).on('login:success', Main.handleLoginSuccess); | ... | ... |