PageSourceSearch

https://www.village-justice.com/articles/squelettes/js/animatedModal.js

js village-justice.com collected 2026-10-01 10:38:09 UTC 3,966 bytes, 126 lines download raw bytes

1/*=========================================
2 * animatedModal.js: Version 1.0
3 * author: João Pereira
4 * website: https://www.joaopereira.pt
5 * email: [email protected]
6 * Licensed MIT
7=========================================*/
8
9(function ($) {
10
11    $.fn.animatedModal = function(options) {
12        var modal = $(this);
13
14        //Defaults
15        var settings = $.extend({
16            modalTarget:'animatedModal',
17            position:'fixed',
18            width:'100%',
19            height:'100%',
20            top:'0px',
21            left:'0px',
22            zIndexIn: '9999',
23            zIndexOut: '-9999',
24            color: '#39BEB9',
25            opacityIn:'1',
26            opacityOut:'0',
27            animatedIn:'zoomIn',
28            animatedOut:'zoomOut',
29            animationDuration:'.6s',
30            overflow:'auto',
31            // Callbacks
32            beforeOpen: function() {},
33            afterOpen: function() {},
34            beforeClose: function() {},
35            afterClose: function() {}
36
37
38
39        }, options);
40
vendor: 2,928 bytes, lines 41-126
41        var closeBt = $('.close-'+settings.modalTarget);
42
43        //console.log(closeBt)
44
45        var href = $(modal).attr('href'),
46            id = $('body').find('#'+settings.modalTarget),
47            idConc = '#'+id.attr('id');
48            //console.log(idConc);
49            // Default Classes
50            id.addClass('animated');
51            id.addClass(settings.modalTarget+'-off');
52
53        //Init styles
54        var initStyles = {
55            'position':settings.position,
56            'width':settings.width,
57            'height':settings.height,
58            'top':settings.top,
59            'left':settings.left,
60            'background-color':settings.color,
61            'overflow-y':settings.overflow,
62            'z-index':settings.zIndexOut,
63            'opacity':settings.opacityOut,
64            '-webkit-animation-duration':settings.animationDuration,
65            '-moz-animation-duration':settings.animationDuration,
66            '-ms-animation-duration':settings.animationDuration,
67            'animation-duration':settings.animationDuration
68        };
69        //Apply stles
70        id.css(initStyles);
71
72        modal.click(function(event) {
73            event.preventDefault();
74            $('body, html').css({'overflow':'hidden'});
75            if (href == idConc) {
76                if (id.hasClass(settings.modalTarget+'-off')) {
77                    id.removeClass(settings.animatedOut);
78                    id.removeClass(settings.modalTarget+'-off');
79                    id.addClass(settings.modalTarget+'-on');
80                }
81
82                 if (id.hasClass(settings.modalTarget+'-on')) {
83                    settings.beforeOpen();
84                    id.css({'opacity':settings.opacityIn,'z-index':settings.zIndexIn});
85                    id.addClass(settings.animatedIn);
86                    id.one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', afterOpen);
87                };
88            }
89        });
90
91
92
93        closeBt.click(function(event) {
94            event.preventDefault();
95            $('body, html').css({'overflow':'auto'});
96
97            settings.beforeClose(); //beforeClose
98            if (id.hasClass(settings.modalTarget+'-on')) {
99                id.removeClass(settings.modalTarget+'-on');
100                id.addClass(settings.modalTarget+'-off');
101            }
102
103            if (id.hasClass(settings.modalTarget+'-off')) {
104                id.removeClass(settings.animatedIn);
105                id.addClass(settings.animatedOut);
106                id.one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', afterClose);
107            };
108
109        });
110
111        function afterClose () {
112            id.css({'z-index':settings.zIndexOut});
113            settings.afterClose(); //afterClose
114        }
115
116        function afterOpen () {
117            settings.afterOpen(); //afterOpen
118        }
119
120    }; // End animatedModal.js
121
122}(jQuery));
123
124
125
126

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.