PageSourceSearch

https://www.xanax.com/-/media/Base-Themes/Components-Theme/Scripts/component-flash.js

js xanax.com collected 2026-09-24 22:55:17 UTC 3,003 bytes, 100 lines download raw bytes

1/**
2 * Component Flash
3 * @module Flash
4 * @param  {jQuery} $ Instance of jQuery
5 * @return {Object} List of flash methods
6 */
7XA.component.flash = (function($) {
8    /**
9     * This object stores all public api methods
10     * @type {Object.<Methods>}
11     * @memberOf module:Flash
12     * */
13    var api = {};
14    /**
15     * Sets size of embeded element
16     * @memberOf module:Flash
17     * @method
18     * @param {jQuery.<Element>} object Embed element
19     * @private
20     */
21    function setSize(object) {
22        var oldHeight = object.attr("height");
23        var oldWidth = object.attr("width");
24        var newWidth = object.width();
25        var newHeight = (oldHeight * newWidth) / oldWidth;
26        object.height(newHeight);
27    }
28    /**
29     * Initialize flash component
30     * @memberOf module:Flash
31     * @method
32     * @param {jQuery} component Root DOM element of flash component wrapped by jQuery
33     * @param {Object} properties Properties set in data attribute
34     * @private
35     */
36    function initFlash(component, properties) {
37        var content = component.find(".component-content > div");
38        content.flash(properties);
39    }
40    /**
41     * Calls ["setSize"]{@link module:Flash.setSize} method
42     * and binds it to resize event
43     * @memberOf module:Flash
44     * @method
45     * @param {jQuery} component Root DOM element of flash component wrapped by jQuery
46     * @param {Object} prop Properties set in data attribute
47     * @private
48     */
49    function attachEvents(component) {
50        $(document).ready(function() {
51            var object = component.find("embed");
52            object.css("width", "100%");
53            setSize(object);
54
55            $(window).resize(function() {
56                setSize(object);
57            });
58        });
59    }
60
61    /**
62     * Call
63     * ["initFlash"]{@link  module:Flash.initFlash} and
64     * ["attachEvents"]{@link  module:Flash.attachEvents}
65     * methods
66     * @memberOf module:Flash
67     * @method
68     * @param {jQuery} component Root DOM element of flash component wrapped by jQuery
69     * @param {Object} prop Properties set in data attribute
70     *  of flash component
71     * @alias module:Flash.initInstance
72     */
73    api.initInstance = function(component, prop) {
74        initFlash(component, prop);
75        attachEvents(component);
76    };
77    /**
78     * Finds all not-initialized 
79     * Flash components and runs in a loop 
80     * Flash's 
81     * ["initInstance"]{@link module:Flash.initInstance}
82     * method.
83     * @memberOf module:Flash
84     * @alias module:Flash.init
85     */
86    api.init = function() {
87        var flash = $(".flash:not(.initialized)");
88        if (flash.length > 0) {
89            flash.each(function() {
90                var properties = $(this).data("properties");
91                api.initInstance($(this), properties);
92                $(this).addClass("initialized");
93            });
94        }
95    };
96
97    return api;
98})(jQuery, document);
99
100XA.register("flash", XA.component.flash);

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.