vendor/assets/javascripts/messenger.js in messengerjs-rails-1.3.6.2 vs vendor/assets/javascripts/messenger.js in messengerjs-rails-1.4.0
- old
+ new
@@ -1,6 +1,6 @@
-/*! messenger 1.3.6 */
+/*! messenger 1.4.0 */
/*
* 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.
@@ -329,23 +329,23 @@
return this.el = this.$el[0];
};
BaseView.prototype.delegateEvents = function(events) {
var delegateEventSplitter, eventName, key, match, method, selector, _results;
- if (!(events || (events = _.result(this, 'events')))) {
+ if (!(events || (events = _.result(this, "events")))) {
return;
}
- delegateEventSplitter = /^(\S+)\s*(.*)$/;
this.undelegateEvents();
+ delegateEventSplitter = /^(\S+)\s*(.*)$/;
_results = [];
for (key in events) {
method = events[key];
if (!_.isFunction(method)) {
method = this[events[key]];
}
if (!method) {
- throw new Error("Method " + events[key] + " does not exist");
+ throw new Error("Method \"" + events[key] + "\" does not exist");
}
match = key.match(delegateEventSplitter);
eventName = match[1];
selector = match[2];
method = _.bind(method, this);
@@ -990,11 +990,11 @@
}
return [type, data, xhr];
};
ActionMessenger.prototype.run = function() {
- var args, attr, events, getMessageText, handler, handlers, m_opts, msg, old, opts, promiseAttrs, type, _i, _len, _ref2, _ref3,
+ var args, events, getMessageText, handler, handlers, m_opts, msg, old, opts, type, _ref2,
_this = this;
m_opts = arguments[0], opts = arguments[1], args = 3 <= arguments.length ? __slice.call(arguments, 2) : [];
if (opts == null) {
opts = {};
}
@@ -1117,18 +1117,10 @@
}
msg._actionInstance = m_opts.action.apply(m_opts, [opts].concat(__slice.call(args)));
if (m_opts.returnsPromise) {
msg._actionInstance.then(handlers.success, handlers.error);
}
- promiseAttrs = ['done', 'progress', 'fail', 'state', 'then'];
- for (_i = 0, _len = promiseAttrs.length; _i < _len; _i++) {
- attr = promiseAttrs[_i];
- if (msg[attr] != null) {
- delete msg[attr];
- }
- msg[attr] = (_ref3 = msg._actionInstance) != null ? _ref3[attr] : void 0;
- }
return msg;
};
ActionMessenger.prototype["do"] = ActionMessenger.prototype.run;
@@ -1143,9 +1135,48 @@
m_opts = _.extend({}, m_opts, {
action: action,
returnsPromise: true
});
return this.run(m_opts);
+ };
+
+ ActionMessenger.prototype.error = function(m_opts) {
+ if (m_opts == null) {
+ m_opts = {};
+ }
+ if (typeof m_opts === 'string') {
+ m_opts = {
+ message: m_opts
+ };
+ }
+ m_opts.type = 'error';
+ return this.post(m_opts);
+ };
+
+ ActionMessenger.prototype.info = function(m_opts) {
+ if (m_opts == null) {
+ m_opts = {};
+ }
+ if (typeof m_opts === 'string') {
+ m_opts = {
+ message: m_opts
+ };
+ }
+ m_opts.type = 'info';
+ return this.post(m_opts);
+ };
+
+ ActionMessenger.prototype.success = function(m_opts) {
+ if (m_opts == null) {
+ m_opts = {};
+ }
+ if (typeof m_opts === 'string') {
+ m_opts = {
+ message: m_opts
+ };
+ }
+ m_opts.type = 'success';
+ return this.post(m_opts);
};
return ActionMessenger;
})(_Messenger);