PageSourceSearch

https://www.jhrl.com/sites/all/themes/custom/vrweb_foundation/js/vendor/foundation/foundation.reveal.js?tlse4v

js jhrl.com collected 2026-10-06 13:18:46 UTC 9,639 bytes, 330 lines download raw bytes

1/*jslint unparam: true, browser: true, indent: 2 */
2
3;(function ($, window, document, undefined) {
4  'use strict';
5
6  Foundation.libs.reveal = {
7    name : 'reveal',
8
9    version : '4.2.2',
10
11    locked : false,
12
13    settings : {
14      animation: 'fadeAndPop',
15      animationSpeed: 250,
16      closeOnBackgroundClick: true,
17      closeOnEsc: true,
18      dismissModalClass: 'close-reveal-modal',
19      bgClass: 'reveal-modal-bg',
20      open: function(){},
21      opened: function(){},
22      close: function(){},
23      closed: function(){},
24      bg : $('.reveal-modal-bg'),
25      css : {
26        open : {
27          'opacity': 0,
28          'visibility': 'visible',
29          'display' : 'block'
30        },
31        close : {
32          'opacity': 1,
33          'visibility': 'hidden',
34          'display': 'none'
35        }
36      }
37    },
38
39    init : function (scope, method, options) {
40      Foundation.inherit(this, 'data_options delay');
41
42      if (typeof method === 'object') {
43        $.extend(true, this.settings, method);
44      } else if (typeof options !== 'undefined') {
45        $.extend(true, this.settings, options);
46      }
47
48      if (typeof method !== 'string') {
49        this.events();
50
51        return this.settings.init;
52      } else {
53        return this[method].call(this, options);
54      }
55    },
56
57    events : function () {
58      var self = this;
59
60      $(this.scope)
61        .off('.fndtn.reveal')
62        .on('click.fndtn.reveal', '[data-reveal-id]', function (e) {
63          e.preventDefault();
64
65          if (!self.locked) {
66            var element = $(this),
67                ajax = element.data('reveal-ajax');
68
69            self.locked = true;
70
71            if (typeof ajax === 'undefined') {
72              self.open.call(self, element);
73            } else {
74              var url = ajax === true ? element.attr('href') : ajax;
75
76              self.open.call(self, element, {url: url});
77            }
78          }
79        })
80        .on('click.fndtn.reveal', this.close_targets(), function (e) {
81          e.preventDefault();
82          if (!self.locked) {
83            var settings = $.extend({}, self.settings, self.data_options($('.reveal-modal.open')));
84            if ($(e.target)[0] === $('.' + settings.bgClass)[0] && !sett
84ings.closeOnBackgroundClick) {
85              return;
86            }
87
88            self.locked = true;
89            self.close.call(self, $(this).closest('.reveal-modal'));
90          }
91        })
92        .on('open.fndtn.reveal', '.reveal-modal', this.settings.open)
93        .on('opened.fndtn.reveal', '.reveal-modal', this.settings.opened)
94        .on('opened.fndtn.reveal', '.reveal-modal', this.open_video)
95        .on('close.fndtn.reveal', '.reveal-modal', this.settings.close)
96        .on('closed.fndtn.reveal', '.reveal-modal', this.settings.closed)
97        .on('closed.fndtn.reveal', '.reveal-modal', this.close_video);
98
99      $( 'body' ).bind( 'keyup.reveal', function ( event ) {
100        var open_modal = $('.reveal-modal.open'),
101            settings = $.extend({}, self.settings, self.data_options(open_modal));
102        if ( event.which === 27  && settings.closeOnEsc) { // 27 is the keycode for the Escape key
103          open_modal.foundation('reveal', 'close');
104        }
105      });
106
107      return true;
108    },
109
110    open : function (target, ajax_settings) {
111      if (target) {
112        if (typeof target.selector !== 'undefined') {
113          var modal = $('#' + target.data('reveal-id'));
114        } else {
115          var modal = $(this.scope);
116
117          ajax_settings = target;
118        }
119      } else {
120        var modal = $(this.scope);
121      }
122
123      if (!modal.hasClass('open')) {
124        var open_modal = $('.reveal-modal.open');
125
126        if (typeof modal.data('css-top') === 'undefined') {
127          modal.data('css-top', parseInt(modal.css('top'), 10))
128            .data('offset', this.cache_offset(modal));
129        }
130
131        modal.trigger('open');
132
133        if (open_modal.length < 1) {
134          this.toggle_bg(modal);
135        }
136
137        if (typeof ajax_settings === 'undefined' || !ajax_settings.url) {
138          this.hide(open_modal, this.settings.css.close);
139          this.show(modal, this.settings.css.open);
140        } else {
141          var self = this,
142              old_success = typeof ajax_settings.success !== 'undefined' ? ajax_settings.success : null;
143
144          $.extend(ajax_settings, {
145            success: function (data, textStatus, jqXHR) {
146              if ( $.isFunction(old_success) ) {
147                old_success(data, textStatus, jqXHR);
148              }
149
150              modal.html(data);
151              $(modal).foundation('section', 'reflow');
152
153              self.hide(open_modal, self.settings.css.close);
154              self.show(modal, self.settings.css.open);
155            }
156          });
157
158          $.ajax(ajax_settings);
159        }
160      }
161    },
162
163    close : function (modal) {
164
165      var modal = modal && modal.length ? modal : $(this.scope),
166          open_modals = $('.reveal-modal.open');
167
168      if (open_modals.length > 0) {
169        this.locked = true;
170        modal.trigger('close');
171        this.toggle_bg(modal);
172        this.hide(open_modals, this.settings.css.close);
173      }
174    },
175
176    close_targets : function () {
177      var base = '.' + this.settings.dismissModalClass;
178
179      if (this.settings.closeOnBackgroundClick) {
180        return base + ', .' + this.settings.bgClass;
181      }
182
183      return base;
184    },
185
186    toggle_bg : function (modal) {
187      if ($('.reveal-modal-bg').length === 0) {
188        this.settings.bg = $('<div />', {'class': this.settings.bgClass})
189          .appendTo('body');
190      }
191
192      if (this.settings.bg.filter(':visible').length > 0) {
193        this.hide(this.settings.bg);
194      } else {
195        this.show(this.settings.bg);
196      }
197    },
198
199    show : function (el, css) {
200      // is modal
201      if (css) {
202        if (/pop/i.test(this.settings.animation)) {
203          css.top = $(window).scrollTop() - el.data('offset') + 'px';
204          var end_css = {
205            top: $(window).scrollTop() + el.data('css-top') + 'px',
206            opacity: 1
207          };
208
209          return this.delay(function () {
210            return el
211              .css(css)
212              .animate(end_css, this.settings.animationSpeed, 'linear', function () {
213                this.locked = false;
214                el.trigger('opened');
215              }.bind(this))
216              .addClass('open');
217          }.bind(this), this.settings.animationSpeed / 2);
218        }
219
220        if (/fade/i.test(this.settings.animation)) {
221          var end_css = {opacity: 1};
222
223          return this.delay(function () {
224            return el
225              .css(css)
226              .animate(end_css, this.settings.animationSpeed, 'linear', function () {
227                this.locked = false;
228                el.trigger('opened');
229              }.bind(this))
230              .addClass('open');
231          }.bind(this), this.settings.animationSpeed / 2);
232        }
233
234        return el.css(css).show().css({opacity: 1}).addClass('open').trigger('opened');
235      }
236
237      // should we animate the background?
238      if (/fade/i.test(this.settings.animation)) {
239        return el.fadeIn(this.settings.animationSpeed / 2);
240      }
241
242      return el.show();
243    },
244
245    hide : function (el, css) {
246      // is modal
247      if (css) {
248        if (/pop/i.test(this.settings.animation)) {
249          var end_css = {
250            top: - $(window).scrollTop() - el.data('offset') + 'px',
251            opacity: 0
252          };
253
254          return this.delay(function () {
255            return el
256              .animate(end_css, this.settings.animationSpeed, 'linear', function () {
257                this.locked = false;
258                el.css(css).trigger('closed');
259              }.bind(this))
260              .removeClass('open');
261          }.bind(this), this.settings.animationSpeed / 2);
262        }
263
264        if (/fade/i.test(this.settings.animation)) {
265          var end_css = {opacity: 0};
266
267          return this.delay(function () {
268            return el
269              .animate(end_css, this.settings.animationSpeed, 'linear', function () {
270                this.locked = false;
271                el.css(css).trigger('closed');
272              }.bind(this))
273              .removeClass('open');
274          }.bind(this), this.settings.animationSpeed / 2);
275        }
276
277        return el.hide().css(css).removeClass('open').trigger('closed');
278      }
279
280      // should we animate the background?
281      if (/fade/i.test(this.settings.animation)) {
282        return el.fadeOut(this.settings.animationSpeed / 2);
283      }
284
285      return el.hide();
286    },
287
288    close_video : function (e) {
289      var video = $(this).find('.flex-video'),
290          iframe = video.find('iframe');
291
292      if (iframe.length > 0) {
293        iframe.attr('data-src', iframe[0].src);
294        iframe.attr('src', 'about:blank');
295        video.hide();
296      }
297    },
298
299    open_video : function (e) {
300      var video = $(this).find('.flex-video'),
301          iframe = video.find('iframe');
302
303      if (iframe.length > 0) {
304        var data_src = iframe.attr('data-src');
305        if (typeof data_src === 'string') {
306          iframe[0].src = iframe.attr('data-src');
307        } else {
308          var src = iframe[0].src;
309          iframe[0].src = undefined;
310          iframe[0].src = src;
311        }
312        video.show();
313      }
314    },
315
316    cache_offset : function (modal) {
317      var offset = modal.show().height() + parseInt(modal.css('top'), 10);
318
319      modal.hide();
320
321      return offset;
322    },
323
324    off : function () {
325      $(this.scope).off('.fndtn.reveal');
326    },
327
328    reflow : function () {}
329  };
330}(Foundation.zj, this, this.document));

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.