(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('<span class="ui-refresh-icon"></span><span class="ui-refresh-label">\u70b9\u51fb\u52a0\u8f7d\u000d\u000a</span>'); 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);