xinyb
2024-04-23 2ef61846432762b570d5f2004a4551225da01324
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
 
Title:        jQMeter: a jQuery Progress Meter Plugin
Author:        Gerardo Larios
Version:    0.1.2
Website:    http://www.gerardolarios.com/plugins-and-tools/jqmeter
License:     Dual licensed under the MIT and GPL licenses.
 
*/
 
!function (e) {
    e.fn.extend({
        jQMeter: function (t) {
            t && "object" == typeof t && (t = e.extend({}, e.jQMeter.defaults, t)), this.each(function () {
                new e.jQMeter(this, t)
            })
        }
    }), e.jQMeter = function (t, r) {
        e(t).children(".outer-therm").children(".inner-therm").children().text('');//清空
        if (goal = parseInt(r.goal.replace(/\D/g, "")), raised = r.raised, width = r.width, height = r.height, bgColor = r.bgColor, barColor = r.barColor, orientation = r.orientation, animationSpeed = r.animationSpeed, counterSpeed = r.counterSpeed, displayTotal = r.displayTotal, total = raised / goal * 100, total >= 100 && (total = 100), "vertical" == orientation ? (e(t).html('<div class="therm outer-therm vertical"><div class="therm inner-therm vertical"><span style="display:none;">' + raised + "</span></div></div>"), e(t).children(".outer-therm").attr("style", "width:" + width + ";height:" + height + ";background-color:" + bgColor), e(t).children(".outer-therm").children(".inner-therm").attr("style", "background-color:" + barColor + ";height:0;width:" + width), e(t).children(".outer-therm").children(".inner-therm").animate({height: total + "%"}, animationSpeed)) : (e(t).html('<div class="therm outer-therm"><div class="therm inner-therm"><span style="display:none;">' + raised + "</span></div></div>"), e(t).children(".outer-therm").attr("style", "width:" + width + ";height:" + height + ";background-color:" + bgColor), e(t).children(".outer-therm").children(".inner-therm").attr("style", "background-color:" + barColor + ";height:" + height + ";width:0"), e(t).children(".outer-therm").children(".inner-therm").animate({width: total + "%"}, animationSpeed)), displayTotal) {
            var i = parseInt(height), n = i / 2 - 13 + "px 10px";
            "horizontal" != orientation && (n = "10px 0"), e(t).children(".outer-therm").children(".inner-therm").children().show(), e(t).children(".outer-therm").children(".inner-therm").children().css("padding", n), e({Counter: 0}).animate({Counter: e(t).children(".outer-therm").children(".inner-therm").children().text()}, {
                duration: counterSpeed,
                easing: "swing",
                step: function () {
                    let count = this.Counter;
                    if (r.raised.indexOf(".") != -1) {
                        count = Math.round(count * 100) / 100;
                    } else {
                        count = Math.ceil(count);
                    }
                    e(t).children(".outer-therm").children(".inner-therm").children().text(count + "%");
                }
            })
        }
        e(t).append("<style>.therm{height:30px;border-radius:5px;}.outer-therm{margin:20px 0;}.inner-therm span {color: #fff;display: inline-block;float: right;font-family: Trebuchet MS;font-size: 20px;font-weight: bold;}.vertical.inner-therm span{width:100%;text-align:center;}.vertical.outer-therm{position:relative;}.vertical.inner-therm{position:absolute;bottom:0;}</style>")
    }, e.jQMeter.defaults = {
        width: "100%",
        height: "50px",
        bgColor: "#444",
        barColor: "#bfd255",
        orientation: "horizontal",
        animationSpeed: 2e3,
        counterSpeed: 2e3,
        displayTotal: !0
    }
}(jQuery);