PageSourceSearch

http://gis.pref.okinawa.jp/v/common/Scripts/pages/top/fixHeight.js

js pref.okinawa.jp collected 2026-09-24 09:04:26 UTC 2,613 bytes, 99 lines download raw bytes

1/*
2 * fixHeight - jQuery Plugin
3 *
4 * Author Koji Kimura @ STARRYWORKS inc.
5 * http://www.starryworks.co.jp/
6 *
7 * Licensed under the MIT License
8 *
9 */
10
11
12(function($){
13	
14	var isInitialized = false;
15	var parents = [];
16	var textHeight = 0;
17	var $fontSizeDiv;
18	
19	$.fn.fixHeight = function() {
20		this.each(function(){
21			var childrenGroups = getChildren( this );
22			$.each( childrenGroups, function(){
23				
24				var $children = $(this);
25				if ( !$children.filter(":visible").length ) return;
26				
27				var row = [];
28				var top = 0;
29				$children.each(function(){
30					if ( top != $(this).position().top ) {
31						$(row).sameHeight();
32						row = [];
33						top = $(this).position().top;
34					}
35					row.push(this);
36				});
37				if ( row.length ) $(row).sameHeight();
38			});
39		});
40		init();
41		return this;
42	}
43	
44	$.checkFixHeight = function( i_force ) {
45		if ( $fontSizeDiv.height() == textHeight && i_force !== true ) return;
46		textHeight = $fontSizeDiv.height();
47		$(parents).fixHeight();
48	}
49	
50	$.fn.sameHeight = function() {
51		var maxHeight = 0;
52		this.css("height","auto");
53		this.each(function(){
54			if ( $(this).height() > maxHeight ) maxHeight = $(this).height();
55		});
56		return this.height(maxHeight);
57	}
58	
59	function getChildren( i_parent ) {
60		var $parent = $( i_parent );
61		if ( $parent.data("fixHeightChildrenGroups") ) return $parent.data("fixHeightChildrenGroups");
62		var childrenGroups = [];
63		var $children = $parent.find(".fixHeightChild");
64		if ( $children.length ) childrenGroups.push( $children );
65		var $groupedChildren = $parent.find("*[class^='fixHeightChild']:not(.fixHeightChild)");
66		if ( $groupedChildren.length ) {
67			var classNames = {};
68			$groupedChildren.each(function(){
69				var c = $(this).attr("class");
70				classNames[c] = c;
71			});
72			for ( var c in classNames ) childrenGroups.push( $parent.find("."+c) );
73		}
74		if ( !childrenGroups.length ) {
75			$children = $parent.children();
76			if ( $children.length ) childrenGroups.push( $children );
77		}
78		$parent.data("fixHeightChildrenGroups", childrenGroups );
79		parents.push( $parent );
80		return childrenGroups;
81	}
82	
83	
84	function init() {
85		if ( isInitialized ) return;
86		isInitialized = true;
87		$fontSizeDiv = $('body').append('<div style="position:absolute;left:-9999px;top:-9999px;">s</div>');
88		setInterval($.checkFixHeight,1000);
89		$(window).resize($.checkFixHeight);
90		$.checkFixHeight();
91		$(window).load( function(){ $.checkFixHeight(true); } );
92	}
93})(jQuery);
94
95jQuery(document).ready(function(){
96	$(".fixHeight").fixHeight();
97});
98
99

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.