2 ms·
I'd default the notice invisible and show it when it hasn't been accepted, rather than vice versa as you do here. That way, in the more common case, nothing nee
by throwanem 10y ago
I'd default the notice invisible and show it when it hasn't been accepted, rather than vice versa as you do here. That way, in the more common case, nothing needs doing. (Maybe there's a regulatory reason that won't fly? I don't know or care much beyond the obvious about the EU cookie rule.) I'd also break out some of the inlining, just to make it read more easily, if this were destined for production.
But the functionality looks good! I mean, document.cookie can be a huge pain to deal with if you actually have to deal with it, and jQuery has a plugin for that - but this doesn't take any kind of parsing, just a cheap substring check, and the class list manipulation is equally trivial. Even animation could be handled in CSS.
Perhaps OP's use case is much more complex than it sounds, in a way that's far from obvious?
- lucideer 10y agoI'm not sure what the regulation would say, but if I'm choosing to comply, I'm going to default to visible as absence of JS doesn't equal absence of cookies. It maybe annoying that the accept button won't work, but at least the user is informed, which I guess was the intent of the (tbh misguided) regulation.