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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
addClass: function (value) {
    if (jQuery.isFunction(value)) {
        return this.each(function (i) {
            var self = jQuery(this);
            self.addClass(value.call(this, i, self.attr("class")));
        });
    }

    if (value && typeof value === "string") {
        var classNames = (value || "").split(rspace);

        for (var i = 0, l = this.length; i < l; i++) {
            var elem = this[i];

            if (elem.nodeType === 1) {
                if (!elem.className) {
                    elem.className = value;

                } else {
                    var className = " " + elem.className + " ",
                        setClass = elem.className;
                    for (var c = 0, cl = classNames.length; c < cl; c++) {
                        if (className.indexOf(" " + classNames[c] + " ") < 0) {
                            setClass += " " + classNames[c];
                        }
                    }
                    elem.className = jQuery.trim(setClass);
                }
            }
        }
    }

    return this;
}

/* ---- */

css: function (elem, name, force, extra) {
    if (name === "width" || name === "height") {
        var val, props = cssShow,
            which = name === "width" ? cssWidth : cssHeight;

        function getWH() {
            val = name === "width" ? elem.offsetWidth : elem.offsetHeight;

            if (extra === "border") {
                return;
            }

            jQuery.each(which, function () {
                if (!extra) {
                    val -= parseFloat(jQuery.curCSS(elem, "padding" + this, true)) || 0;
                }

                if (extra === "margin") {
                    val += parseFloat(jQuery.curCSS(elem, "margin" + this, true)) || 0;
                } else {
                    val -= parseFloat(jQuery.curCSS(elem, "border" + this + "Width", true)) || 0;
                }
            });
        }

        if (elem.offsetWidth !== 0) {
            getWH();
        } else {
            jQuery.swap(elem, props, getWH);
        }

        return Math.max(0, Math.round(val));
    }

    return jQuery.curCSS(elem, name, force);
}