PageSourceSearch

https://sunmusic-gp.co.jp/js/jquery.equalheight.js

js sunmusic-gp.co.jp collected 2026-09-24 21:14:01 UTC 3,016 bytes, 110 lines download raw bytes

1;(function ($, window, document, undefined) {
2
3    var pluginName = "equalHeight",
4        defaults = {
5            wait: false,
6            responsive: true
7        };
8
9    function Plugin(elements, options) {
10        this.elements = elements;
11
12        this.options = $.extend({}, defaults, options);
13
14        this._defaults = defaults;
15        this._name = pluginName;
16
17        this.active = false;
18
19        this.init();
20    }
21
22    Plugin.prototype = {
23
24        init: function () {
25            if (!this.options.wait) {
26                this.start();
27            }
28
29            if (this.options.responsive) {
30                $(window).on("resize", $.proxy(this.onWindowResize, this));
31            }
32        },
33
34        /**
35         * Set the height of each element to the height of the highest element.
36         */
37        magic: function () {
38            // Store the height of the highest element.
39            var topHeight = 0;
40
41            // Reset min-height and height. Otherwise we will run in trouble if
42            // we execute this function a second time (on resize for instance).
43            this.reset();
44
45            // Find highest element and store the height.
46            for (var i = 0; i < this.elements.length; i++) {
47                var height = $(this.elements[i]).height();
48                topHeight = height > topHeight ? height : topHeight;
49            }
50
51            // If this.stop was called during execution of this function, abort
52            if (!this.active) return;
53
54            // Set min-height on elements.
55            for (var j = 0; j < this.elements.length; j++) {
56                var element = $(this.elements[j]);
57
58                // Height behaves like min-height when display is table-cell.
59                if (element.css("display") === "table-cell") {
60                    element.css("height", topHeight + 2);
61                } else {
62                    element.css("min-height", topHeight + 2);
63                }
64            }
65
66            // If this.stop was called during executing of this function, reset
67            if (!this.active) this.reset();
68        },
69
70        /**
71         * Remove all styles added by this plugin.
72         */
73        reset: function () {
74            this.elements.css("min-height", "");
75            this.elements.css("height", "");
76        },
77
78        /**
79         * Start the plugin.
80         */
81        start: function () {
82            this.active = true;
83            this.magic();
84        },
85
86        /**
87         * Stop the plugin and reset the elements.
88         */
89        stop: function () {
90            this.active = false;
91            this.reset();
92        },
93
94        /**
95         * Call the magic method on window resize, if allowed.
96         */
97        onWindowResize: function () {
98            if (this.active) {
99                this.magic();
100            }
101        }
102
103    };
104
105    // Release the beast
106    $.fn[pluginName] = function (options) {
107        return new Plugin(this, options);
108    };
109
110})(jQuery, window, 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.