vendor/assets/javascripts/messenger.js in messengerjs-rails-1.3.3 vs vendor/assets/javascripts/messenger.js in messengerjs-rails-1.3.5
- old
+ new
@@ -1,6 +1,6 @@
-/*! messenger 1.3.3 */
+/*! messenger 1.3.5 */
/*
* This file begins the output concatenated into messenger.js
*
* It establishes the Messenger object while preserving whatever it was before
* (for noConflict), and making it a callable function.
@@ -991,61 +991,60 @@
type: 'info'
}));
}
handlers = {};
_.each(['error', 'success'], function(type) {
+ var originalHandler;
+ originalHandler = opts[type];
return handlers[type] = function() {
- var data, defaultOpts, handlerResp, msgOpts, reason, resp, responseOpts, xhr, _base, _ref10, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9;
+ var data, defaultOpts, handlerResp, msgOpts, reason, resp, responseOpts, xhr, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9;
resp = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
- if ((_ref3 = opts[type]) != null ? _ref3._originalHandler : void 0) {
- opts[type] = opts[type]._originalHandler;
- }
- _ref4 = _this._normalizeResponse.apply(_this, resp), reason = _ref4[0], data = _ref4[1], xhr = _ref4[2];
+ _ref3 = _this._normalizeResponse.apply(_this, resp), reason = _ref3[0], data = _ref3[1], xhr = _ref3[2];
if (type === 'success' && !(msg.errorCount != null) && m_opts.showSuccessWithoutError === false) {
m_opts['successMessage'] = null;
}
if (type === 'error') {
- if ((_ref5 = m_opts.errorCount) == null) {
+ if ((_ref4 = m_opts.errorCount) == null) {
m_opts.errorCount = 0;
}
m_opts.errorCount += 1;
}
- handlerResp = m_opts.returnsPromise ? resp[0] : typeof (_base = opts[type])._originalHandler === "function" ? _base._originalHandler.apply(_base, resp) : void 0;
+ handlerResp = m_opts.returnsPromise ? resp[0] : typeof originalHandler === "function" ? originalHandler.apply(null, resp) : void 0;
responseOpts = _this._getHandlerResponse(handlerResp);
if (_.isString(responseOpts)) {
responseOpts = {
message: responseOpts
};
}
if (type === 'error' && ((xhr != null ? xhr.status : void 0) === 0 || reason === 'abort')) {
msg.hide();
return;
}
- if (type === 'error' && ((m_opts.ignoredErrorCodes != null) && (_ref6 = xhr != null ? xhr.status : void 0, __indexOf.call(m_opts.ignoredErrorCodes, _ref6) >= 0))) {
+ if (type === 'error' && ((m_opts.ignoredErrorCodes != null) && (_ref5 = xhr != null ? xhr.status : void 0, __indexOf.call(m_opts.ignoredErrorCodes, _ref5) >= 0))) {
msg.hide();
return;
}
defaultOpts = {
message: getMessageText(type, xhr),
type: type,
- events: (_ref7 = events[type]) != null ? _ref7 : {},
+ events: (_ref6 = events[type]) != null ? _ref6 : {},
hideOnNavigate: type === 'success'
};
msgOpts = $.extend({}, m_opts, defaultOpts, responseOpts);
- if (typeof ((_ref8 = msgOpts.retry) != null ? _ref8.allow : void 0) === 'number') {
+ if (typeof ((_ref7 = msgOpts.retry) != null ? _ref7.allow : void 0) === 'number') {
msgOpts.retry.allow--;
}
- if (type === 'error' && (xhr != null ? xhr.status : void 0) >= 500 && ((_ref9 = msgOpts.retry) != null ? _ref9.allow : void 0)) {
+ if (type === 'error' && (xhr != null ? xhr.status : void 0) >= 500 && ((_ref8 = msgOpts.retry) != null ? _ref8.allow : void 0)) {
if (msgOpts.retry.delay == null) {
if (msgOpts.errorCount < 4) {
msgOpts.retry.delay = 10;
} else {
msgOpts.retry.delay = 5 * 60;
}
}
if (msgOpts.hideAfter) {
- if ((_ref10 = msgOpts._hideAfter) == null) {
+ if ((_ref9 = msgOpts._hideAfter) == null) {
msgOpts._hideAfter = msgOpts.hideAfter;
}
msgOpts.hideAfter = msgOpts._hideAfter + msgOpts.retry.delay;
}
msgOpts._retryActions = true;
@@ -1085,10 +1084,9 @@
if (!m_opts.returnsPromise) {
for (type in handlers) {
handler = handlers[type];
old = opts[type];
opts[type] = handler;
- opts[type]._originalHandler = old;
}
}
msg._actionInstance = m_opts.action.apply(m_opts, [opts].concat(__slice.call(args)));
if (m_opts.returnsPromise) {
msg._actionInstance.then(handlers.success, handlers.error);