PageSourceSearch

https://www.healthychildren.org/_layouts/15/AAP.HealthyChildren/js/jquery.simplemodal.js?v=7.0

js healthychildren.org collected 2026-10-01 08:32:51 UTC 31,537 bytes, 716 lines download raw bytes

1/*
2 * SimpleModal @VERSION - jQuery Plugin
3 * http://simplemodal.com/
4 * Copyright (c) 2014 Eric Martin
5 * Licensed under MIT and GPL
6 * Date:
7 */
8
9/**
10 * SimpleModal is a lightweight jQuery plugin that provides a simple
11 * interface to create a modal dialog.
12 *
13 * The goal of SimpleModal is to provide developers with a cross-browser
14 * overlay and container that will be populated with data provided to
15 * SimpleModal.
16 *
17 * There are two ways to call SimpleModal:
18 * 1) As a chained function on a jQuery object, like $('#myDiv').modal();.
19 * This call would place the DOM object, #myDiv, inside a modal dialog.
20 * Chaining requires a jQuery object. An optional options object can be
21 * passed as a parameter.
22 *
23 * @example $('<div>my data</div>').modal({options});
24 * @example $('#myDiv').modal({options});
25 * @example jQueryObject.modal({options});
26 *
27 * 2) As a stand-alone function, like $.modal(data). The data parameter
28 * is required and an optional options object can be passed as a second
29 * parameter. This method provides more flexibility in the types of data
30 * that are allowed. The data could be a DOM object, a jQuery object, HTML
31 * or a string.
32 *
33 * @example $.modal('<div>my data</div>', {options});
34 * @example $.modal('my data', {options});
35 * @example $.modal($('#myDiv'), {options});
36 * @example $.modal(jQueryObject, {options});
37 * @example $.modal(document.getElementById('myDiv'), {options});
38 *
39 * A SimpleModal call can contain multiple elements, but only one modal
40 * dialog can be created at a time. Which means that all of the matched
41 * elements will be displayed within the modal container.
42 *
43 * SimpleModal internally sets the CSS needed to display the modal dialog
44 * properly in all browsers, yet provides the developer with the flexibility
45 * to easily control the look and feel. The styling for SimpleModal can be
46 * done through external stylesheets, or through SimpleModal, using the
47 * overlayCss, containerCss, and dataCss options.
48 *
49 * SimpleModal has been tested in the following browsers:
50 * - IE 6+
51 * - Firefox 2+
52 * - Opera 9+
53 * - Safari 3+
54 * - Chrome 1+
55 *
56 * @name SimpleModal
57 * @type jQuery
58 * @requires jQuery v1.3
59 * @cat Plugins/Windows and Overlays
60 * @author Eric Martin (http://ericmmartin.com)
61 * @version @VERSION
62 */
63
64; (function (factory) {
65    if (typeof define === 'function' && define.amd) {
66        // AMD. Register as an anonymous module.
67        define(['jquery'], factory);
68    } else {
69        // Browser globals
70        factory(jQuery);
71    }
72}
73    (function ($) {
74        var d = [],
75            doc = $(document),
76            ua = navigator.userAgent.toLowerCase(),
77            wndw = $(window),
78            w = [];
79
80        var browser = {
81            ieQuirks: null,
82            msie: /msie/.test(ua) && !/opera/.test(ua),
83            opera: /opera/.test(ua)
84        };
85        browser.ie6 = browser.msie && /msie 6./.test(ua) && typeof window['XMLHttpRequest'] !== 'object';
86        browser.ie7 = browser.msie && /msie 7.0/.test(ua);
87        browser.boxModel = (document.compatMode === "CSS1Compat");
88
89        /*
90         * Create and display a modal dialog.
91         *
92         * @param {string, object} data A string, jQuery object or DOM object
93         * @param {object} [options] An optional object containing options overrides
94         */
95        $.modal = function (data, options) {
96            return $.modal.impl.init(data, options);
97        };
98
99        /*
100         * Close the modal dialog.
101         */
102        $.modal.close = function () {
103            $.modal.impl.close();
104        };
105
106        /*
107         * Set focus on first or last visible input in the modal dialog. To focus on the last
108         * element, call $.modal.focus('last'). If no input elements are found, focus is placed
109         * on the data wrapper element.
110         */
111        $.modal.focus = function (pos) {
112            $.modal.impl.focus(pos);
113        };
114
115        /*
116         * Determine and set the dimensions of the modal dialog container.
117         * setPosition() is called if the autoPosition option is true.
118         */
119        $.modal.setContainerDimensions = function () {
120            $.modal.impl.setContainerDimensions();
121        };
122
123        /*
124         * Re-position the modal dialog.
125         */
126        $.modal.setPosition = function () {
127            $.modal.impl.setPosition();
128        };
129
130        /*
131         * Update the modal dialog. If new dimensions are passed, they will be used to determine
132         * the dimensions of the container.
133         *
134         * setContainerDimensions() is called, which in turn calls setPosition(), if enabled.
135         * Lastly, focus() is called is the focus option is true.
136         */
137        $.modal.update = function (height, width) {
138            $.modal.impl.update(height, width);
139        };
140
141        /*
142         * Chained function to create a modal dialog.
143         *
144         * @param {object} [options] An optional object containing options overrides
145         */
146        $.fn.modal = function (options) {
147            return $.modal.impl.init(this, options);
148        };
149
150        /*
151         * SimpleModal default options
152         *
153         * appendTo:		(String:'body') The jQuery selector to append the elements to. For .NET, use 'form'.
154         * focus:			(Boolean:true) Focus in the first visible, enabled element?
155         * opacity:			(Number:50) The opacity value for the overlay div, from 0 - 100
156         * overlayId:		(String:'simplemodal-overlay') The DOM element id for the overlay div
157         * overlayCss:		(Object:{}) The CSS styling for the overlay div
158         * containerId:		(String:'simplemodal-container') The DOM element id for the container div
159         * containerCss:	(Object:{}) The CSS styling for the container div
160         * dataId:			(String:'simplemodal-data') The DOM element id for the data div
161         * dataCss:			(Object:{}) The CSS styling for the data div
162         * minHeight:		(Number:null) The minimum height for the container
163         * minWidth:		(Number:null) The minimum width for the container
164         * maxHeight:		(Number:null) The maximum height for the container. If not specified, the window height is used.
165         * maxWidth:		(Number:null) The maximum width for the container. If not specified, the window width is used.
166         * autoResize:		(Boolean:false) Automatically resize the container if it exceeds the browser window dimensions?
167         * autoPosition:	(Boolean:true) Automatically position the container upon creation and on window resize?
168         * zIndex:			(Number: 1000) Starting z-index value
169         * close:			(Boolean:true) If true, closeHTML, escClose and overClose will be used if set.
170                                        If false, none of them will be used.
171         * closeHTML:		(String:'<a class="modalCloseImg" title="Close"></a>') The HTML for the default close link.
172                                    SimpleModal will automatically add the closeClass to this element.
173         * closeClass:		(String:'simplemodal-close') The CSS class used to bind to the close event
174         * escClose:		(Boolean:true) Allow Esc keypress to close the dialog?
175         * overlayClose:	(Boolean:false) Allow click on overlay to close the dialog?
176         * fixed:			(Boolean:true) If true, the container will use a fixed position. If false, it will use a
177                                    absolute position (the dialog will scroll with the page)
178         * position:		(Array:null) Position of container [top, left]. Can be number of pixels or percentage
179         * persist:			(Boolean:false) Persist the data across modal calls? Only used for existing
180                                    DOM elements. If true, the data will be maintained across modal calls, if false,
181                                    the data will be reverted to its original state.
182         * modal:			(Boolean:true) User will be unable to interact with the page below the modal or tab away from the dialog.
183                                    If false, the overlay, iframe, and certain events will be disabled allowing the user to interact
184                                    with the page below the dialog.
185         * onOpen:			(Function:null) The callback function used in place of SimpleModal's open
186         * onShow:			(Function:null) The callback function used after the modal dialog has opened
187         * onClose:			(Function:null) The callback function used in place of SimpleModal's close
188         */
189        $.modal.defaults = {
190            appendTo: 'body',
191            focus: true,
192            opacity: 50,
193            overlayId: 'simplemodal-overlay',
194            overlayCss: {},
195            containerId: 'simplemodal-container',
196            containerCss: {},
197            dataId: 'simplemodal-data',
198            dataCss: {},
199            minHeight: null,
200            minWidth: null,
201            maxHeight: null,
202            maxWidth: null,
203            autoResize: false,
204            autoPosition: true,
205            zIndex: 1000,
206            close: true,
207            closeHTML: '<a class="modalCloseImg" title="Close"></a>',
208            closeClass: 'simplemodal-close',
209            escClose: true,
210            overlayClose: false,
211            fixed: true,
212            position: null,
213            persist: false,
214            modal: true,
215            onOpen: null,
216            onShow: null,
217            onClose: null
218        };
219
220        /*
221         * Main modal object
222         * o = options
223         */
224        $.modal.impl = {
225            /*
226             * Contains the modal dialog elements and is the object passed
227             * back to the callback (onOpen, onShow, onClose) functions
228             */
229            d: {},
230            /*
231             * Initialize the modal dialog
232             */
233            init: function (data, options) {
234                var s = this;
235
236                // don't allow multiple calls
237                if (s.d.data) {
238                    return false;
239                }
240
241                browser.ieQuirks = browser.msie && !browser.boxModel;
242
243                // merge defaults and user options
244                s.o = $.extend({}, $.modal.defaults, options);
245
246                // keep track of z-index
247                s.zIndex = s.o.zIndex;
248
249                // set the onClose callback flag
250                s.occb = false;
251
252                // determine how to handle the data based on its type
253                if (typeof data === 'object') {
254                    // convert DOM object to a jQuery object
255                    data = data instanceof $ ? data : $(data);
256                    s.d.placeholder = false;
257
258                    // if the object came from the DOM, keep track of its parent
259                    if (data.parent().parent().size() > 0) {
260                        data.before($('<span></span>')
261                            .attr('id', 'simplemodal-placeholder')
262                            .css({ display: 'none' }));
263
264                        s.d.placeholder = true;
265                        s.display = data.css('display');
266
267                        // persist changes? if not, make a clone of the element
268                        if (!s.o.persist) {
269                            s.d.orig = data.clone(true);
270                        }
271                    }
272                }
273                else if (typeof data === 'string' || typeof data === 'number') {
274                    // just insert the data as innerHTML
275                    data = $('<div></div>').html(data);
276                }
277                else {
278                    // unsupported data type!
279                    alert('SimpleModal Error: Unsupported data type: ' + typeof data);
280                    return s;
281                }
282
283                // create the modal overlay, container and, if necessary, iframe
284                s.create(data);
285                data = null;
286
287                // display the modal dialog
288                s.open();
289
290                // useful for adding events/manipulating data in the modal dialog
291                if ($.isFunction(s.o.onShow)) {
292                    s.o.onShow.apply(s, [s.d]);
293                }
294
295                // don't break the chain =)
296                return s;
297            },
298            /*
299             * Create and add the modal overlay and container to the page
300             */
301            create: function (data) {
302                var s = this;
303
304                // get the window properties
305                s.getDimensions();
306
307                // add an iframe to prevent select options from bleeding through
308                if (s.o.modal && browser.ie6) {
309                    s.d.iframe = $('<iframe src="javascript:false;"></iframe>')
310                        .css($.extend(s.o.iframeCss, {
311                            display: 'none',
312                            opacity: 0,
313                            position: 'fixed',
314                            height: w[0],
315                            width: w[1],
316                            zIndex: s.o.zIndex,
317                            top: 0,
318                            left: 0
319                        }))
320                        .appendTo(s.o.appendTo);
321                }
322
323                // create the overlay
324                s.d.overlay = $('<div></div>')
325                    .attr('id', s.o.overlayId)
326                    .addClass('simplemodal-overlay')
327                    .css($.extend(s.o.overlayCss, {
328                        display: 'none',
329                        opacity: s.o.opacity / 100,
330                        height: s.o.modal ? d[0] : 0,
331                        width: s.o.modal ? d[1] : 0,
332                        position: 'fixed',
333                        left: 0,
334                        top: 0,
335                        zIndex: s.o.zIndex + 1
336                    }))
337                    .appendTo(s.o.appendTo);
338
339                // create the container
340                s.d.container = $('<div></div>')
341                    .attr('id', s.o.containerId)
342                    .addClass('simplemodal-container')
343                    .css($.extend(
344                        { position: s.o.fixed ? 'fixed' : 'absolute' },
345                        s.o.containerCss,
346                        { display: 'none', zIndex: s.o.zIndex + 2 }
347                    ))
348                    .append(s.o.close && s.o.closeHTML
349                        ? $(s.o.closeHTML).addClass(s.o.closeClass)
350                        : '')
351                    .appendTo(s.o.appendTo);
352
353                s.d.wrap = $('<div></div>')
354                    .attr('tabIndex', -1)
355                    .addClass('simplemodal-wrap')
356                    .css({ height: '100%', outline: 0, width: '100%' })
357                    .appendTo(s.d.container);
358
359                // add styling and attributes to the data
360                // append to body to get correct dimensions, then move to wrap
361                s.d.data = data
362                    .attr('id', data.attr('id') || s.o.dataId)
363                    .addClass('simplemodal-data')
364                    .css($.extend(s.o.dataCss, {
365                        display: 'none'
366                    }))
367                    .appendTo('body');
368                data = null;
369
370                s.setContainerDimensions();
371                s.d.data.appendTo(s.d.wrap);
372
373                // fix issues with IE
374                if (browser.ie6 || browser.ieQuirks) {
375                    s.fixIE();
376                }
377            },
378            /*
379             * Bind events
380             */
381            bindEvents: function () {
382                var s = this;
383
384                // bind the close event to any element with the closeClass class
385                $('.' + s.o.closeClass).bind('click.simplemodal', function (e) {
386                    e.preventDefault();
387                    s.close();
388                });
389
390                // bind the overlay click to the close function, if enabled
391                if (s.o.modal && s.o.close && s.o.overlayClose) {
392                    s.d.overlay.bind('click.simplemodal', function (e) {
393                        e.preventDefault();
394                        s.close();
395                    });
396                }
397
398                // bind keydown events
399                doc.bind('keydown.simplemodal', function (e) {
400                    if (s.o.modal && e.keyCode === 9) { // TAB
401                        s.watchTab(e);
402                    }
403                    else if ((s.o.close && s.o.escClose) && e.keyCode === 27) { // ESC
404                        e.preventDefault();
405                        s.close();
406                    }
407                });
408
409                // update window size
410                wndw.bind('resize.simplemodal orientationchange.simplemodal', function () {
411                    // redetermine the window width/height
412                    s.getDimensions();
413
414                    // reposition the dialog
415                    s.o.autoResize ? s.setContainerDimensions() : s.o.autoPosition && s.setPosition();
416
417                    if (browser.ie6 || browser.ieQuirks) {
418                        s.fixIE();
419                    }
420                    else if (s.o.modal) {
421                        // update the iframe & overlay
422                        s.d.iframe && s.d.iframe.css({ height: w[0], width: w[1] });
423                        s.d.overlay.css({ height: d[0], width: d[1] });
424                    }
425                });
426            },
427            /*
428             * Unbind events
429             */
430            unbindEvents: function () {
431                $('.' + this.o.closeClass).unbind('click.simplemodal');
432                doc.unbind('keydown.simplemodal');
433                wndw.unbind('.simplemodal');
434                this.d.overlay.unbind('click.simplemodal');
435            },
436            /*
437             * Fix issues in IE6 and IE7 in quirks mode
438             */
439            fixIE: function () {
440                var s = this, p = s.o.position;
441
442                // simulate fixed position - adapted from BlockUI
443                $.each([s.d.iframe || null, !s.o.modal ? null : s.d.overlay, s.d.container.css('position') === 'fixed' ? s.d.container : null], function (i, el) {
444                    if (el) {
445                        var bch = 'document.body.clientHeight', bcw = 'document.body.clientWidth',
446                            bsh = 'document.body.scrollHeight', bsl = 'document.body.scrollLeft',
447                            bst = 'document.body.scrollTop', bsw = 'document.body.scrollWidth',
448                            ch = 'document.documentElement.clientHeight', cw = 'document.documentElement.clientWidth',
449                            sl = 'document.documentElement.scrollLeft', st = 'document.documentElement.scrollTop',
450                            s = el[0].style;
451
452                        s.position = 'absolute';
453                        if (i < 2) {
454                            s.removeExpression('height');
455                            s.removeExpression('width');
456                            s.setExpression('height', '' + bsh + ' > ' + bch + ' ? ' + bsh + ' : ' + bch + ' + "px"');
457                            s.setExpression('width', '' + bsw + ' > ' + bcw + ' ? ' + bsw + ' : ' + bcw + ' + "px"');
458                        }
459                        else {
460                            var te, le;
461                            if (p && p.constructor === Array) {
462                                var top = p[0]
463                                    ? typeof p[0] === 'number' ? p[0].toString() : p[0].replace(/px/, '')
464                                    : el.css('top').replace(/px/, '');
465                                te = top.indexOf('%') === -1
466                                    ? top + ' + (t = ' + st + ' ? ' + st + ' : ' + bst + ') + "px"'
467                                    : parseInt(top.replace(/%/, '')) + ' * ((' + ch + ' || ' + bch + ') / 100) + (t = ' + st + ' ? ' + st + ' : ' + bst + ') + "px"';
468
469                                if (p[1]) {
470                                    var left = typeof p[1] === 'number' ? p[1].toString() : p[1].replace(/px/, '');
471                                    le = left.indexOf('%') === -1
472                                        ? left + ' + (t = ' + sl + ' ? ' + sl + ' : ' + bsl + ') + "px"'
473                                        : parseInt(left.replace(/%/, '')) + ' * ((' + cw + ' || ' + bcw + ') / 100) + (t = ' + sl + ' ? ' + sl + ' : ' + bsl + ') + "px"';
474                                }
475                            }
476                            else {
477                                te = '(' + ch + ' || ' + bch + ') / 2 - (this.offsetHeight / 2) + (t = ' + st + ' ? ' + st + ' : ' + bst + ') + "px"';
478                                le = '(' + cw + ' || ' + bcw + ') / 2 - (this.offsetWidth / 2) + (t = ' + sl + ' ? ' + sl + ' : ' + bsl + ') + "px"';
479                            }
480                            s.removeExpression('top');
481                            s.removeExpression('left');
482                            s.setExpression('top', te);
483                            s.setExpression('left', le);
484                        }
485                    }
486                });
487            },
488            /*
489             * Place focus on the first or last visible input
490             */
491            focus: function (pos) {
492                var s = this, p = pos && $.inArray(pos, ['first', 'last']) !== -1 ? pos : 'first';
493
494                // focus on dialog or the first visible/enabled input element
495                var input = $(':input:enabled:visible:' + p, s.d.wrap);
496                setTimeout(function () {
497                    input.length > 0 ? input.focus() : s.d.wrap.focus();
498                }, 10);
499            },
500            getDimensions: function () {
501                // fix a jQuery bug with determining the window height - use innerHeight if available
502                var s = this,
503                    h = typeof window.innerHeight === 'undefined' ? wndw.height() : window.innerHeight;
504
505                d = [doc.height(), doc.width()];
506                w = [h, wndw.width()];
507            },
508            getVal: function (v, d) {
509                return v ? (typeof v === 'number' ? v
510                    : v === 'auto' ? 0
511                        : v.indexOf('%') > 0 ? ((parseInt(v.replace(/%/, '')) / 100) * (d === 'h' ? w[0] : w[1]))
512                            : parseInt(v.replace(/px/, '')))
513                    : null;
514            },
515            /*
516             * Update the container. Set new dimensions, if provided.
517             * Focus, if enabled. Re-bind events.
518             */
519            update: function (height, width) {
520                var s = this;
521
522                // prevent update if dialog does not exist
523                if (!s.d.data) {
524                    return false;
525                }
526
527                // reset orig values
528                s.d.origHeight = s.getVal(height, 'h');
529                s.d.origWidth = s.getVal(width, 'w');
530
531                // hide data to prevent screen flicker
532                s.d.data.hide();
533                height && s.d.container.css('height', height);
534                width && s.d.container.css('width', width);
535                s.setContainerDimensions();
536                s.d.data.show();
537                s.o.focus && s.focus();
538
539                // rebind events
540                s.unbindEvents();
541                s.bindEvents();
542            },
543            setContainerDimensions: function () {
544                var s = this,
545                    badIE = browser.ie6 || browser.ie7;
546
547                // get the dimensions for the container and data
548                var ch = s.d.origHeight ? s.d.origHeight : browser.opera ? s.d.container.height() : s.getVal(badIE ? s.d.container[0].currentStyle['height'] : s.d.container.css('height'), 'h'),
549                    cw = s.d.origWidth ? s.d.origWidth : browser.opera ? s.d.container.width() : s.getVal(badIE ? s.d.container[0].currentStyle['width'] : s.d.container.css('width'), 'w'),
550                    dh = s.d.data.outerHeight(true), dw = s.d.data.outerWidth(true);
551
552                s.d.origHeight = s.d.origHeight || ch;
553                s.d.origWidth = s.d.origWidth || cw;
554
555                // mxoh = max option height, mxow = max option width
556                var mxoh = s.o.maxHeight ? s.getVal(s.o.maxHeight, 'h') : null,
557                    mxow = s.o.maxWidth ? s.getVal(s.o.maxWidth, 'w') : null,
558                    mh = mxoh && mxoh < w[0] ? mxoh : w[0],
559                    mw = mxow && mxow < w[1] ? mxow : w[1];
560
561                // moh = min option height
562                var moh = s.o.minHeight ? s.getVal(s.o.minHeight, 'h') : 'auto';
563                if (!ch) {
564                    if (!dh) { ch = moh; }
565                    else {
566                        if (dh > mh) { ch = mh; }
567                        else if (s.o.minHeight && moh !== 'auto' && dh < moh) { ch = moh; }
568                        else { ch = dh; }
569                    }
570                }
571                else {
572                    ch = s.o.autoResize && ch > mh ? mh : ch < moh ? moh : ch;
573                }
574
575                // mow = min option width
576                var mow = s.o.minWidth ? s.getVal(s.o.minWidth, 'w') : 'auto';
577                if (!cw) {
578                    if (!dw) { cw = mow; }
579                    else {
580                        if (dw > mw) { cw = mw; }
581                        else if (s.o.minWidth && mow !== 'auto' && dw < mow) { cw = mow; }
582                        else { cw = dw; }
583                    }
584                }
585                else {
586                    cw = s.o.autoResize && cw > mw ? mw : cw < mow ? mow : cw;
587                }
588
589                s.d.container.css({ height: ch, width: cw });
590                s.d.wrap.css({ overflow: (dh > ch || dw > cw) ? 'auto' : 'visible' });
591                s.o.autoPosition && s.setPosition();
592            },
593            setPosition: function () {
594                var s = this, top, left,
595                    hc = (w[0] / 2) - (s.d.container.outerHeight(true) / 2),
596                    vc = (w[1] / 2) - (s.d.container.outerWidth(true) / 2),
597                    st = s.d.container.css('position') !== 'fixed' ? wndw.scrollTop() : 0;
598
599                if (s.o.position && Object.prototype.toString.call(s.o.position) === '[object Array]') {
600                    top = st + (s.o.position[0] || hc);
601                    left = s.o.position[1] || vc;
602                } else {
603                    top = st + hc;
604                    left = vc;
605                }
606                s.d.container.css({ left: left, top: top });
607            },
608            watchTab: function (e) {
609                var s = this;
610
611                if ($(e.target).parents('.simplemodal-container').length > 0) {
612                    // save the list of inputs
613                    s.inputs = $(':input:enabled:visible:first, :input:enabled:visible:last', s.d.data[0]);
614
615                    // if it's the first or last tabbable element, refocus
616                    if ((!e.shiftKey && e.target === s.inputs[s.inputs.length - 1]) ||
617                        (e.shiftKey && e.target === s.inputs[0]) ||
618                        s.inputs.length === 0) {
619                        e.preventDefault();
620                        var pos = e.shiftKey ? 'last' : 'first';
621                        s.focus(pos);
622                    }
623                }
624                else {
625                    // might be necessary when custom onShow callback is used
626                    e.preventDefault();
627                    s.focus();
628                }
629            },
630            /*
631             * Open the modal dialog elements
632             * - Note: If you use the onOpen callback, you must "show" the
633             *         overlay and container elements manually
634             *         (the iframe will be handled by SimpleModal)
635             */
636            open: function () {
637                var s = this;
638                // display the iframe
639                s.d.iframe && s.d.iframe.show();
640
641                if ($.isFunction(s.o.onOpen)) {
642                    // execute the onOpen callback
643                    s.o.onOpen.apply(s, [s.d]);
644                }
645                else {
646                    // display the remaining elements
647                    s.d.overlay.show();
648                    s.d.container.show();
649                    s.d.data.show();
650                }
651
652                s.o.focus && s.focus();
653
654                // bind default events
655                s.bindEvents();
656            },
657            /*
658             * Close the modal dialog
659             * - Note: If you use an onClose callback, you must remove the
660             *         overlay, container and iframe elements manually
661             *
662             * @param {boolean} external Indicates whether the call to this
663             *     function was internal or external. If it was external, the
664             *     onClose callback will be ignored
665             */
666            close: function () {
667                var s = this;
668
669                // prevent close when dialog does not exist
670                if (!s.d.data) {
671                    return false;
672                }
673
674                // remove the default events
675                s.unbindEvents();
676
677                if ($.isFunction(s.o.onClose) && !s.occb) {
678                    // set the onClose callback flag
679                    s.occb = true;
680
681                    // execute the onClose callback
682                    s.o.onClose.apply(s, [s.d]);
683                }
684                else {
685                    // if the data came from the DOM, put it back
686                    if (s.d.placeholder) {
687                        var ph = $('#simplemodal-placeholder');
688                        // save changes to the data?
689                        if (s.o.persist) {
690                            // insert the (possibly) modified data back into the DOM
691                            ph.replaceWith(s.d.data.removeClass('simplemodal-data').css('display', s.display));
692                        }
693                        else {
694                            // remove the current and insert the original,
695                            // unmodified data back into the DOM
696                            s.d.data.hide().remove();
697                            ph.replaceWith(s.d.orig);
698                        }
699                    }
700                    else {
701                        // otherwise, remove it
702                        s.d.data.hide().remove();
703                    }
704
705                    // remove the remaining elements
706                    s.d.container.hide().remove();
707                    s.d.overlay.hide();
708                    s.d.iframe && s.d.iframe.hide().remove();
709                    s.d.overlay.remove();
710
711                    // reset the dialog object
712                    s.d = {};
713                }
714            }
715        };
716    }));

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.