Last active
April 11, 2018 09:15
-
-
Save sosroInSpace/5e476ec8ff4702fdc1fdcbf5c0259be1 to your computer and use it in GitHub Desktop.
Code for use with local storage - display modal once and then hide after submission with different css classes applied dependent on selected options.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ($(window).width() < 768) { | |
//* if local storage is supported or not --> | |
if (typeof Storage !== "undefined") { | |
/* update variable -->*/ | |
var keyName = 'hulc_hand'; | |
/* store local storage item into variable -->*/ | |
var hand = localStorage.getItem(keyName); | |
/* if hand is not there do this function --> */ | |
function showForm () { | |
$('.mobileLeftRight').removeClass('hidden'); | |
}; | |
/* if left button clicked function */ | |
function makeLeft () { | |
localStorage.setItem(keyName, 'left'); | |
$('.mobileLeftRight').addClass('hidden'); | |
$('.mobileButton').addClass('mobile-button-left') | |
$('.hulcLogo').addClass('hulc-logo-right'); | |
}; | |
/* if right button clicked function */ | |
function makeRight () { | |
localStorage.setItem(keyName, 'right'); | |
$('.mobileLeftRight').addClass('hidden'); | |
}; | |
/* if local storage same as item left run function makeLeft */ | |
if (hand === 'left') { | |
makeLeft(); | |
} else if (hand === 'right') {/* if local storage same as item left run function makeLeft */ | |
makeRight(); | |
} else { /* else show form */ | |
showForm(); | |
} | |
$('#handLeftButton').click(makeLeft); | |
$('#handRightButton').click(makeRight); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment