(function (a, b) { a.ui.define("refresh", { _data: { ready: null, statechange: null }, _setup: function () { var d = this, e = d._data, c = d.root(); e.$upelem = c.find(".ui-refresh-up"); e.$downelem = c.find(".ui-refresh-down"); c.addclass("ui-refresh"); return d }, _init: function () { var c = this, d = c._data; a.each(["up", "down"], function (g, f) { var e = d["$" + f + "elem"], h = e.get(0); if (e.length) { c._status(f, true); if (!h.childnodes.length || (e.find(".ui-refresh-icon").length && e.find(".ui-refresh-label").length)) { !h.childnodes.length && c._createbtn(f); d.refreshinfo || (d.refreshinfo = {}); d.refreshinfo[f] = { $icon: e.find(".ui-refresh-icon"), $label: e.find(".ui-refresh-label"), text: e.find(".ui-refresh-label").html()} } e.on("click", function () { if (!c._status(f) || d._actdir) { return } c._setstyle(f, "loading"); c._loadingaction(f, "click") }) } }); return c }, _createbtn: function (c) { this._data["$" + c + "elem"].html('\u52a0\u8f7d\u66f4\u591a '); return this }, _setstyle: function (d, f) { var e = this, c = a.event("statechange"); e.trigger(c, [e._data["$" + d + "elem"], f, d]); if (c.defaultprevented) { return e } return e._changestyle(d, f) }, _changestyle: function (c, f) { var e = this._data, d = e.refreshinfo[c]; switch (f) { case "loaded": d["$label"].html(d.text); d["$icon"].removeclass(); e._actdir = ""; break; case "loading": d["$label"].html("\u52a0\u8f7d\u4e2d..."); d["$icon"].addclass("ui-loading"); e._actdir = c; break; case "disable": d["$label"].html("\u6ca1\u6709\u66f4\u591a\u5185\u5bb9\u4e86"); break } return this }, _loadingaction: function (c, d) { var f = this, g = f._data, e = g.ready; a.isfunction(e) && e.call(f, c, d); f._status(c, false); return f }, afterdataloading: function (c) { var d = this, c = c || d._data._actdir; d._setstyle(c, "loaded"); d._status(c, true); return d }, _status: function (d, c) { var e = this._data; return c === b ? e["_" + d + "open"] : e["_" + d + "open"] = !!c }, _setable: function (d, c, e) { var f = this, g = f._data, h = c ? [c] : ["up", "down"]; a.each(h, function (l, k) { var j = g["$" + k + "elem"]; if (!j.length) { return } d ? j.show() : (e ? j.hide() : f._setstyle(k, "disable")); f._status(k, d) }); return f }, disable: function (c, d) { return this._setable(false, c, d) }, enable: function (c) { return this._setable(true, c) } }) })(zepto);