dobarkod / cookie-banner

JavaScript based cookie-info banner for complying with EU cookie law
MIT License
425 stars 85 forks source link

Refactor + tests + cookie expiration feature/option #5

Closed zytzagoo closed 10 years ago

zytzagoo commented 10 years ago

Started working on #3 and figured, wth, might as well give it the full treatment :)

The major motivator is that now we can create an instance using var banner = new Cookiebanner(opts); and call banner.run(), banner.insert(), banner.close(), banner.agree(), banner.agreed() etc. (method names not set in stone) in the exact moment we'd like to (as opposed to just having a bunch of stuff magically happen without any control over it).

The "old" mode of operation is still supported and is functioning just as it did earlier -- see/run tests.js

The few initial tests I wrote all pass, but I probably missed something somewhere...

This hopefully makes any potential further changes easier to implement (and easier to guard against breakage).

While we're on the subject of further changes, the option names are really ripe for a rewrite IMO (could now be easily done in this branch while maintaining full backwards compatibility -- just needs a small options re-writer).

It'd be awesome to get more eyes on this before moving further.

senko commented 10 years ago

Hej @zytzagoo thanks for this.

I'm looking at it but want to wait for a few more opinions from guys better than me in JS before we merge it. I'm all for improving the options as well, as long as the happy case for typical end user remains an oneliner addition in their page (edit to add: and of course if we maintain backwards compatibility, so that we don't have to start versioning stuff).

senko commented 10 years ago

Belated merge, thanks @al4n for the code review.

Thanks @zytzagoo for awesome work on this!