PageSourceSearch

https://shirosai.shop/common/js/jqueryAutoHeight.js

js shirosai.shop collected 2026-10-01 06:44:01 UTC 2,721 bytes, 89 lines download raw bytes

1/*
2 * jquery-auto-height.js
3 *
4 * Copyright (c) 2010 Tomohiro Okuwaki (http://www.tinybeans.net/blog/)
5 * Licensed under MIT Lisence:
6 * http://www.opensource.org/licenses/mit-license.php
7 * http://sourceforge.jp/projects/opensource/wiki/licenses%2FMIT_license
8 *
9 * Since:   2010-04-19
10 * Update:  2010-07-02
11 * version: 0.03
12 * Comment: 
13 *
14 * jQuery 1.2 later
15 * 
16 */
17
18 (function($){
19    $.fn.autoHeight = function(options){
20        var op = $.extend({
21        
22            column  : 0,
23            clear   : 0,
24            height  : 'minHeight',
25            reset   : '',
26            descend : function descend (a,b){ return b-a; }
27        
28        },options || {}); // optionsに値があれば上書きする
29
30        var self = $(this);
31        var n = 0,
32            hMax,
33            hList = new Array(),
34            hListLine = new Array();
35            hListLine[n] = 0;
36
37        // 要素の高さを取得
38        self.each(function(i){
39            if (op.reset == 'reset') {
40                $(this).removeAttr('style');
41            }
42            var h = $(this).height();
43            hList[i] = h;
44            if (op.column > 1) {
45                // op.columnごとの最大値を格納していく
46                if (h > hListLine[n]) {
47                    hListLine[n] = h;
48                }
49                if ( (i > 0) && (((i+1) % op.column) == 0) ) {
50                    n++;
51                    hListLine[n] = 0;
52                };
53            }
54        });
55
56        // 取得した高さの数値を降順に並べ替え
57        hList = hList.sort(op.descend);
58        hMax = hList[0];
59        
60        // 高さの最大値を要素に適用
61        var browser = $.browser.version;
62        if (op.column > 1) {
63            for (var j=0; j<hListLine.length; j++) {
64                for (var k=0; k<op.column; k++) {
65                    if (browser == '6.0') {
66                        self.eq(j*op.column+k).height(hListLine[j]);
67                        if (k == 0 && op.clear != 0) self.eq(j*op.column+k).css('clear','both');
68                    } else {
69                        self.eq(j*op.column+k).css(op.height,hListLine[j]);
70                        if (k == 0 && op.clear != 0) self.eq(j*op.column+k).css('clear','both');
71                    }
72                }
73            }
74        } else {
75            if (browser == '6.0') {
76                self.height(hMax);
77            } else {
78                self.css(op.height,hMax);
79            }
80        }
81    };
82})(jQuery);
83
84jQuery(function($){
85    $("#news-list li").autoHeight({column:3, clear:1});
86    $(".content-main #news-list li").autoHeight({column:2, clear:1});
87    $(".content-main #news-list2 li").autoHeight({column:2, clear:1});
88});
89

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.