44a1d02231394abd99bd7c301c0951ccc8196934
[wolnelektury.git] / src / annoy / static / annoy / banner.js
1 (function($) {
2     $(function() {
3
4         $(".annoy-banner-on").each(function() {
5             var $on = $(this);
6             var tag = 'annoyed' + $on.attr('data-target');
7             var $target = $($on.attr('data-target'));
8             var $off = $('.annoy-banner-off', $target);
9
10             $on.click(function(e) {
11                 e.preventDefault();
12                 $target.slideDown('fast');
13                 $on.hide();
14                 if (Modernizr.localstorage) localStorage.removeItem(tag);
15                 _paq.push(['trackEvent', 'banner', 'banner-unhide', $target.attr('id')]);
16             });
17
18             $off.click(function() {
19                 $target.slideUp('fast');
20                 $on.show();
21                 if (Modernizr.localstorage) localStorage[tag] = true;
22                 _paq.push(['trackEvent', 'banner', 'banner-hide', $target.attr('id')]);
23             });
24
25             if (Modernizr.localstorage) {
26                 if (!localStorage[tag]) {
27                     $on.hide();
28                     $target.show();
29                     _paq.push(['trackEvent', 'banner', 'banner-show', $target.attr('id')]);
30                 }
31             }
32         });
33
34         $(document).on('click', ".annoy-banner a", function() {
35             banner = $(this).closest('.annoy-banner');
36             _paq.push(['trackEvent', 'banner', 'banner-click', banner.attr('id')]);
37         });
38         $(document).on('click', ".dynamic-insert a", function() {
39             banner = $(this).closest('.dynamic-insert');
40             _paq.push(['trackEvent', 'dynamic-insert', 'dynamic-insert-click', 'insert-' + banner.attr('data-paragraphs') + '-pars-text-' + banner.attr('data-textid')]);
41         });
42
43     });
44 })(jQuery);