PageSourceSearch

https://www.mlit.go.jp/com/13_flatheights.js

js mlit.go.jp collected 2026-10-09 21:32:52 UTC 3,832 bytes, 135 lines download raw bytes

1/*
2	jquery.flatheights.js
3	Version: 2010-09-15
4*/
5
6/*
7======================================================================
8	$.changeLetterSize.addHandler(func)
9	文字の大きさが変化した時に実行する処理を追加
10======================================================================
11*/
12
13jQuery.changeLetterSize = {
14	handlers : [],
15	interval : 1000,
16	currentSize: 0
17};
18
19(function($) {
20
21	var self = $.changeLetterSize;
22
23	/* 文字の大きさを確認するためのins要素 */
24	var ins = $('<ins>M</ins>').css({
25		display: 'block',
26		visibility: 'hidden',
27		position: 'absolute',
28		padding: '0',
29		top: '0'
30	});
31
32	/* 文字の大きさが変わったか */
33	var isChanged = function() {
34		ins.appendTo('body');
35		var size = ins[0].offsetHeight;
36		ins.remove();
37		if (self.currentSize == size) return false;
38		self.currentSize = size;
39		return true;
40	};
41
42	/* 文書を読み込んだ時点で
43	   文字の大きさを確認しておく */
44	$(isChanged);
45
46	/* 文字の大きさが変わっていたら、
47	   handlers中の関数を順に実行 */
48	var observer = function() {
49		if (!isChanged()) return;
50		$.each(self.handlers, function(i, handler) {
51			handler();
52		});
53	};
54
55	/* ハンドラを登録し、
56	   最初の登録であれば、定期処理を開始 */
57	self.addHandler = function(func) {
58		self.handlers.push(func);
59		if (self.handlers.length == 1) {
60			setInterval(observer, self.interval);
61		}
62	};
63
64})(jQuery);
65
66/*
67======================================================================
68	$(expr).flatHeights()
69	$(expr)で選択した複数の要素について、それぞれ高さを
70	一番高いものに揃える
71======================================================================
72*/
73
74(function($) {
75
76	/* 対象となる要素群の集合 */
77	var sets = [];
78
79	/* 高さ揃えの処理本体 */
80	var flatHeights = function(set) {
81		var maxHeight = 0;
82		set.each(function(){
83			var height = this.offsetHeight;
84			if (height > maxHeight) maxHeight = height;
85		});
86		set.css('height', maxHeight + 'px');
87	};
88
89	/* 要素群の高さを揃え、setsに追加 */
90	jQuery.fn.flatHeights = function() {
91		if (this.length > 1) {
92			flatHeights(this);
93			sets.push(this);
94		}
95		return this;
96	};
97
98	/* 高さ揃えを再実行する処理 */
99	var reflatting = function() {
100		$.each(sets, function() {
101			this.height('auto');
102			flatHeights(this);
103		});
104	};
105
106	/* 文字の大きさが変わった時に高さ揃えを再実行 */
107	$.changeLetterSize.addHandler(reflatting);
108
109	/* ウィンドウの大きさが変わった時に高さ揃えを再実行 */
110	$(window).resize(reflatting);
111
112})(jQuery);
113
114
115/*
116Copyright (c) 2007, KITAMURA Akatsuki
117
118Permission is hereby granted, free of charge, to any person obtaining a
119copy of this software and associated documentation files (the "Software"),
120to deal in the Software without restriction, including without limitation
121the rights to use, copy, modify, merge, publish, distribute, sublicense,
122and/or sell copies of the Software, and to permit persons to whom the
123Software is furnished to do so, subject to the following conditions:
124
125The above copyright notice and this permission notice shall be included
126in all copies or substantial portions of the Software.
127
128THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
129IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
130FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
131THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
132OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
133ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
134OTHER DEALINGS IN THE SOFTWARE.
135*/

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.