PageSourceSearch

https://peppermintridgefarm.au/wp-content/plugins/woopack/assets/js/modal.js?ver=1.5.11

js peppermintridgefarm.au collected 2026-10-10 00:08:10 UTC 7,303 bytes, 224 lines download raw bytes

1;(function($) {
2
3    WooPackModal = function( settings )
4    {
5        this.wrapper        = $('.woopack-modal');
6        this.contentWrap    = $('.woopack-modal .woopack-modal-content');
7        this.settings       = settings;
8        this.breakpoint     = this.settings.breakpoint;
9        this.animationSpeed = this.settings.animationSpeed;
10        this.isActive       = false;
11
12        if ( 'undefined' === typeof this.settings.source ) {
13            console.error( 'Error initiating modal. Source is missing!' );
14            return;
15        }
16        if ( 'html' === this.settings.source && 'undefined' === typeof this.settings.content ) {
17            console.error( 'Error initiating modal. Content is missing!' );
18            return;
19        }
20        if ( 'url' === this.settings.source && 'undefined' === typeof this.settings.url ) {
21            console.error( 'Error initiating modal. URL is missing!' );
22            return;
23        }
24        if ( 'ajax' === this.settings.source ) {
25            if ( 'undefined' === typeof this.settings.ajaxUrl ) {
26                console.error( 'Error initiating modal. AJAX URL is missing!' );
27                return;
28            }
29            if ( 'object' !== typeof this.settings.ajaxData ) {
30                console.error( 'Error initiating modal. AJAX data is missing!' );
31                return;
32            }
33        }
34
35        this._init();
36    };
37
38    WooPackModal.prototype = {
39        wrapper: '',
40        contentWrap: '',
41        settings: {},
42        isActive: '',
43        breakpoint: 767,
44        animationSpeed: 100,
45
46        _init: function()
47        {
48            this._initModal();
49            this._bindEvents();
50            this._resize();
51            this._resetHeight();
52            this._show();
53        },
54
55        _initModal: function()
56        {
57            this.wrapper.removeClass( 'woopack-modal-fullscreen' );
58            this.wrapper.removeClass('woopack-modal-has-iframe');
59
60            if ( 'string' === typeof this.settings.cssClass ) {
61                this.wrapper.addClass(this.settings.cssClass);
62            }
63
64            if ( this.settings.fullscreen ) {
65                this.wrapper.addClass( 'woopack-modal-fullscreen' );
66            }
67            if ( 'undefined' !== typeof this.settings.closeButton && ! this.settings.closeButton ) {
68                this.wrapper.addClass('woopack-modal-hide-close');
69            }
70
71            if ( 'html' == this.settings.source ) {
72                this._initContent();
73            }
74            if ( 'url' == this.settings.source ) {
75                this.wrapper.addClass('woopack-modal-has-iframe');
76                this._initIframe();
77            }
78            if ( 'ajax' === this.settings.source ) {
79                this._initAjax();
80            }
81        },
82
83        _initContent: function()
84        {
85            this.contentWrap.html(this.settings.content);
86        },
87
88        _initIframe: function()
89        {
90            var iframe = '<iframe src="'+this.settings.url+'" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>';
91            this.contentWrap.html(iframe);
92        },
93
94        _initAjax: function()
95        {
96            var ajaxUrl     = this.settings.ajaxUrl,
97                ajaxData    = this.settings.ajaxData,
98				self        = this;
99				
100			if ( 'undefined' !== typeof this.settings.processAjax && ! this.settings.processAjax ) {
101				if ( 'function' === typeof self.settings.responseHandler ) {
102					self.settings.responseHandler( {}, self );
103				}
104				self.wrapper.addClass('woopack-content-loaded');
105				if ( 'function' === typeof self.settings.onAjaxLoad ) {
106					self.settings.onAjaxLoad( self );
107				}
108				return;
109			}
110
111            $.ajax({
112                type: 'post',
113                url: ajaxUrl,
114                data: ajaxData,
115                success: function(response) {
116					if ( 'function' === typeof self.settings.responseHandler ) {
117						self.settings.responseHandler( response, self );
118					} else {
119						self.contentWrap.html(response);
120					}
121					setTimeout(function() {
122						self.wrapper.addClass('woopack-content-loaded');
123						if ( 'function' === typeof self.settings.onAjaxLoad ) {
124							self.settings.onAjaxLoad(self);
125						}
126					}, 100);
127                }
128            });
129        },
130
131        _bindEvents: function()
132        {
133            var self = this;
134
135            $('.woopack-modal-close, .woopack-modal-close a, .woopack-modal-overlay').on('click', function(e) {
136                e.preventDefault();
137                self._hide();
138            });
139
140            if ( 'undefined' !== typeof this.settings.closeButtonEl && $(this.settings.closeButtonEl).length > 0 ) {
141                $('body').on('click', this.settings.closeButtonEl, function(e) {
142                    e.preventDefault();
143                    self._hide();
144                });
145            }
146
147            $(document).keyup(function(e) {
148                if ( 27 == e.which && self.isActive ) {
149                    self._hide();
150                }
151			});
152			
153			this.wrapper.find( '.woopack-modal-inner' ).on( 'click', $.proxy( this._resetHeight, this ) )
154        },
155
156        _show: function()
157        {
158            if ( this.isActive ) {
159                return;
160            }
161
162            var speed = this.animationSpeed;
163
164            $('body').trigger('woopack-modal-before-trigger');
165
166            this.wrapper.fadeIn(speed).addClass('woopack-modal-active');
167            this.isActive = true;
168
169            if ( 'function' === typeof this.settings.onLoad ) {
170                this.settings.onLoad(this.wrapper);
171            }
172
173            $('body').trigger('woopack-modal-after-trigger');
174        },
175
176        _hide: function()
177        {
178            var speed = this.animationSpeed;
179            var wrapper = this.wrapper;
180            var contentWrap = this.contentWrap;
181            var self = this;
182
183            $('body').trigger('woopack-modal-before-close');
184
185            wrapper.fadeOut(speed, function() {
186                contentWrap.html('');
187                wrapper.removeClass('woopack-content-loaded');
188                if ( 'function' === typeof self.settings.onClose ) {
189                    self.settings.onClose(wrapper);
190                }
191            }).removeClass('woopack-modal-active');
192
193            $('body').trigger('woopack-modal-after-close');
194
195            this.isActive = false;
196        },
197
198        _resize: function()
199        {	
200            if ( 'object' === typeof this.settings.style ) {
201                this.wrapper.find('.woopack-modal-inner').css(this.settings.style);
202            }
203            if ( window.innerWidth <= this.settings.breakpoint ) {
204                this.wrapper.addClass('woopack-responsive-modal');
205                this.wrapper.find('.woopack-modal-inner').css({
206                    height: ( window.innerHeight ) + 'px',
207                });
208            }
209		},
210		
211		_resetHeight: function() {
212			var wrapper = this.wrapper;
213			if ( wrapper.find('.woopack-modal-inner').height() >= window.innerHeight ) {
214				wrapper.find('.woopack-modal-inner').css({
215					'max-height': ( window.innerHeight - 60 ) + 'px',
216				});
217				wrapper.find('.woopack-modal-inner .woopack-modal-content').css({
218					'max-height': ( window.innerHeight - 80 ) + 'px',
219				});
220			}
221		}
222    };
223
224})(jQuery);

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.