From 8a8f360fca3fe4f4ed8f7b4646c313fb91ce0e8e Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Tue, 14 May 2013 22:49:31 -0700 Subject: [PATCH] updated signalr.js messenger.js --- Gruntfile.js | 76 +++++++++-------- UI/JsLibraries/jquery.signalR.js | 68 +++++++++++---- UI/JsLibraries/messenger.js | 140 +++++++++++++++---------------- 3 files changed, 161 insertions(+), 123 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 724c7f9b9..5c1cfd0a0 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -5,48 +5,50 @@ module.exports = function (grunt) { pkg: grunt.file.readJSON('package.json'), curl: { - 'UI/JsLibraries/backbone.js' : 'http://documentcloud.github.io/backbone/backbone.js', - 'UI/JsLibraries/backbone.marionette.js' : 'http://marionettejs.com/downloads/backbone.marionette.js', - 'UI/JsLibraries/backbone.modelbinder.js' : 'http://raw.github.com/theironcook/Backbone.ModelBinder/master/Backbone.ModelBinder.js', - 'UI/JsLibraries/backbone.mutators.js' : 'http://raw.github.com/asciidisco/Backbone.Mutators/master/backbone.mutators.js', - 'UI/JsLibraries/backbone.shortcuts.js' : 'http://raw.github.com/bry4n/backbone-shortcuts/master/backbone.shortcuts.js', - //'UI/JsLibraries/bootstrap.js': - //'UI/JsLibraries/bootstrap.slider.js': - 'UI/JsLibraries/handlebars.runtime.js' : 'http://raw.github.com/wycats/handlebars.js/master/dist/handlebars.runtime.js', - 'UI/JsLibraries/jquery.cookie.js' : 'http://raw.github.com/carhartl/jquery-cookie/master/jquery.cookie.js', - 'UI/JsLibraries/jquery.js' : 'http://code.jquery.com/jquery.js', - 'UI/JsLibraries/jquery.backstretch.js' : 'http://raw.github.com/srobbin/jquery-backstretch/master/jquery.backstretch.js', + 'UI/JsLibraries/backbone.js' : 'http://documentcloud.github.io/backbone/backbone.js', + 'UI/JsLibraries/backbone.marionette.js' : 'http://marionettejs.com/downloads/backbone.marionette.js', + 'UI/JsLibraries/backbone.modelbinder.js' : 'http://raw.github.com/theironcook/Backbone.ModelBinder/master/Backbone.ModelBinder.js', + 'UI/JsLibraries/backbone.mutators.js' : 'http://raw.github.com/asciidisco/Backbone.Mutators/master/backbone.mutators.js', + 'UI/JsLibraries/backbone.shortcuts.js' : 'http://raw.github.com/bry4n/backbone-shortcuts/master/backbone.shortcuts.js', + 'UI/JsLibraries/backbone.pageable.js' : 'http://raw.github.com/wyuenho/backbone-pageable/master/lib/backbone-pageable.js', + 'UI/JsLibraries/backbone.backgrid.js' : 'http://raw.github.com/wyuenho/backgrid/master/lib/backgrid.js', + 'UI/JsLibraries/backbone.backgrid.paginator.js' : 'http://raw.github.com/wyuenho/backgrid/master/lib/extensions/paginator/backgrid-paginator.js', + 'UI/JsLibraries/backbone.backgrid.filter.js' : 'http://raw.github.com/wyuenho/backgrid/master/lib/extensions/filter/backgrid-filter.js', - 'UI/JsLibraries/jquery.signalR.js' : 'https://raw.github.com/SignalR/SignalR/master/samples/Microsoft.AspNet.SignalR.Hosting.AspNet.Samples/Scripts/jquery.signalR.js', + 'UI/JsLibraries/handlebars.runtime.js' : 'http://raw.github.com/wycats/handlebars.js/master/dist/handlebars.runtime.js', - 'UI/JsLibraries/require.js' : 'http://raw.github.com/jrburke/requirejs/master/require.js', - 'UI/JsLibraries/sugar.js' : 'http://raw.github.com/andrewplummer/Sugar/master/release/sugar-full.development.js', - 'UI/JsLibraries/underscore.js' : 'http://underscorejs.org/underscore.js', - 'UI/JsLibraries/backbone.pageable.js' : 'http://raw.github.com/wyuenho/backbone-pageable/master/lib/backbone-pageable.js', - 'UI/JsLibraries/backbone.backgrid.js' : 'http://raw.github.com/wyuenho/backgrid/master/lib/backgrid.js', - 'UI/JsLibraries/backbone.backgrid.paginator.js' : 'http://raw.github.com/wyuenho/backgrid/master/lib/extensions/paginator/backgrid-paginator.js', - 'UI/JsLibraries/backbone.backgrid.filter.js' : 'http://raw.github.com/wyuenho/backgrid/master/lib/extensions/filter/backgrid-filter.js', - 'UI/JsLibraries/messenger.js' : 'http://raw.github.com/HubSpot/messenger/master/build/js/messenger.js', - 'UI/JsLibraries/lunr.js' : 'http://raw.github.com/olivernn/lunr.js/master/lunr.js', - 'UI/Content/messenger.css' : 'http://raw.github.com/HubSpot/messenger/master/build/css/messenger.css', - 'UI/Content/bootstrap.toggle-switch.css' : 'http://raw.github.com/ghinda/css-toggle-switch/gh-pages/toggle-switch.css', - 'UI/Content/messenger.future.css' : 'http://raw.github.com/HubSpot/messenger/master/build/css/messenger-theme-future.css', + 'UI/JsLibraries/jquery.js' : 'http://code.jquery.com/jquery.js', + 'UI/JsLibraries/jquery.backstretch.js' : 'http://raw.github.com/srobbin/jquery-backstretch/master/jquery.backstretch.js', + 'UI/JsLibraries/jquery.cookie.js' : 'http://raw.github.com/carhartl/jquery-cookie/master/jquery.cookie.js', + 'UI/JsLibraries/jquery.signalR.js' : 'https://raw.github.com/SignalR/SignalR/master/samples/Microsoft.AspNet.SignalR.Hosting.AspNet.Samples/Scripts/jquery.signalR.js', + + + 'UI/JsLibraries/require.js' : 'http://raw.github.com/jrburke/requirejs/master/require.js', + 'UI/JsLibraries/sugar.js' : 'http://raw.github.com/andrewplummer/Sugar/master/release/sugar-full.development.js', + 'UI/JsLibraries/underscore.js' : 'http://underscorejs.org/underscore.js', + 'UI/JsLibraries/lunr.js' : 'http://raw.github.com/olivernn/lunr.js/master/lunr.js', + + 'UI/JsLibraries/messenger.js' : 'http://raw.github.com/HubSpot/messenger/master/build/js/messenger.js', + 'UI/Content/Messenger/messenger.css' : 'http://raw.github.com/HubSpot/messenger/master/build/css/messenger.css', + 'UI/Content/Messenger/messenger.future.css' : 'http://raw.github.com/HubSpot/messenger/master/build/css/messenger-theme-future.css', + + 'UI/Content/bootstrap.toggle-switch.css' : 'http://raw.github.com/ghinda/css-toggle-switch/gh-pages/toggle-switch.css', 'UI/Content/FontAwesome/fontawesome.otf' : 'http://github.com/FortAwesome/Font-Awesome/blob/master/build/assets/font-awesome/font/FontAwesome.otf?raw=true', - 'UI/Content/FontAwesome/fontawesome-webfont.eot' : 'https://github.com/FortAwesome/Font-Awesome/blob/master/build/assets/font-awesome/font/fontawesome-webfont.eot?raw=true', - 'UI/Content/FontAwesome/fontawesome-webfont.svg' : 'https://github.com/FortAwesome/Font-Awesome/blob/master/build/assets/font-awesome/font/fontawesome-webfont.svg?raw=true', - 'UI/Content/FontAwesome/fontawesome-webfont.ttf' : 'https://github.com/FortAwesome/Font-Awesome/blob/master/build/assets/font-awesome/font/fontawesome-webfont.ttf?raw=true', - 'UI/Content/FontAwesome/fontawesome-webfont.woff': 'https://github.com/FortAwesome/Font-Awesome/blob/master/build/assets/font-awesome/font/fontawesome-webfont.woff?raw=true', + 'UI/Content/FontAwesome/fontawesome-webfont.eot' : 'http://github.com/FortAwesome/Font-Awesome/blob/master/build/assets/font-awesome/font/fontawesome-webfont.eot?raw=true', + 'UI/Content/FontAwesome/fontawesome-webfont.svg' : 'http://github.com/FortAwesome/Font-Awesome/blob/master/build/assets/font-awesome/font/fontawesome-webfont.svg?raw=true', + 'UI/Content/FontAwesome/fontawesome-webfont.ttf' : 'http://github.com/FortAwesome/Font-Awesome/blob/master/build/assets/font-awesome/font/fontawesome-webfont.ttf?raw=true', + 'UI/Content/FontAwesome/fontawesome-webfont.woff': 'http://github.com/FortAwesome/Font-Awesome/blob/master/build/assets/font-awesome/font/fontawesome-webfont.woff?raw=true', - 'UI/Content/FontAwesome/bootstrap.less' : 'https://raw.github.com/FortAwesome/Font-Awesome/master/build/assets/font-awesome/less/bootstrap.less', - 'UI/Content/FontAwesome/core.less' : 'https://raw.github.com/FortAwesome/Font-Awesome/master/build/assets/font-awesome/less/core.less', - 'UI/Content/FontAwesome/extras.less' : 'https://raw.github.com/FortAwesome/Font-Awesome/master/build/assets/font-awesome/less/extras.less', - 'UI/Content/FontAwesome/font-awesome-ie7.less' : 'https://raw.github.com/FortAwesome/Font-Awesome/master/build/assets/font-awesome/less/font-awesome-ie7.less', - 'UI/Content/FontAwesome/font-awesome.less' : 'https://raw.github.com/FortAwesome/Font-Awesome/master/build/assets/font-awesome/less/font-awesome.less', - 'UI/Content/FontAwesome/icons.less' : 'https://raw.github.com/FortAwesome/Font-Awesome/master/build/assets/font-awesome/less/icons.less', - 'UI/Content/FontAwesome/mixins.less' : 'https://raw.github.com/FortAwesome/Font-Awesome/master/build/assets/font-awesome/less/mixins.less', - 'UI/Content/FontAwesome/path.less' : 'https://raw.github.com/FortAwesome/Font-Awesome/master/build/assets/font-awesome/less/path.less', - 'UI/Content/FontAwesome/variables.less' : 'https://raw.github.com/FortAwesome/Font-Awesome/master/build/assets/font-awesome/less/variables.less' + 'UI/Content/FontAwesome/bootstrap.less' : 'http://raw.github.com/FortAwesome/Font-Awesome/master/build/assets/font-awesome/less/bootstrap.less', + 'UI/Content/FontAwesome/core.less' : 'http://raw.github.com/FortAwesome/Font-Awesome/master/build/assets/font-awesome/less/core.less', + 'UI/Content/FontAwesome/extras.less' : 'http://raw.github.com/FortAwesome/Font-Awesome/master/build/assets/font-awesome/less/extras.less', + 'UI/Content/FontAwesome/font-awesome-ie7.less' : 'http://raw.github.com/FortAwesome/Font-Awesome/master/build/assets/font-awesome/less/font-awesome-ie7.less', + 'UI/Content/FontAwesome/font-awesome.less' : 'http://raw.github.com/FortAwesome/Font-Awesome/master/build/assets/font-awesome/less/font-awesome.less', + 'UI/Content/FontAwesome/icons.less' : 'http://raw.github.com/FortAwesome/Font-Awesome/master/build/assets/font-awesome/less/icons.less', + 'UI/Content/FontAwesome/mixins.less' : 'http://raw.github.com/FortAwesome/Font-Awesome/master/build/assets/font-awesome/less/mixins.less', + 'UI/Content/FontAwesome/path.less' : 'http://raw.github.com/FortAwesome/Font-Awesome/master/build/assets/font-awesome/less/path.less', + 'UI/Content/FontAwesome/variables.less' : 'http://raw.github.com/FortAwesome/Font-Awesome/master/build/assets/font-awesome/less/variables.less' }, clean: { diff --git a/UI/JsLibraries/jquery.signalR.js b/UI/JsLibraries/jquery.signalR.js index 646c97482..23e8a7aa4 100644 --- a/UI/JsLibraries/jquery.signalR.js +++ b/UI/JsLibraries/jquery.signalR.js @@ -1,7 +1,7 @@ /* jquery.signalR.core.js */ /*global window:false */ /*! - * ASP.NET SignalR JavaScript Library v1.1.0-beta1 + * ASP.NET SignalR JavaScript Library v1.1.0 * http://signalr.net/ * * Copyright Microsoft Open Technologies, Inc. All rights reserved. @@ -805,7 +805,7 @@ throw new Error("Connections query string property must be either a string or object."); }, - getUrl: function (connection, transport, reconnecting, appendReconnectUrl) { + getUrl: function (connection, transport, reconnecting, poll) { /// Gets the url for making a GET based connect request var baseUrl = transport === "webSockets" ? "" : connection.baseUrl, url = baseUrl + connection.appRelativeUrl, @@ -822,11 +822,11 @@ if (!reconnecting) { url += "/connect"; } else { - if (appendReconnectUrl) { - url += "/reconnect"; - } else { - // A silent reconnect should only ever occur with the longPolling transport + if (poll) { + // longPolling transport specific url += "/poll"; + } else { + url += "/reconnect"; } if (connection.messageId) { @@ -1621,7 +1621,23 @@ initialConnectedFired = true; onSuccess(); connection.log("Longpolling connected"); - }; + }, + reconnectErrors = 0, + reconnectTimeoutId = null, + fireReconnected = function (instance) { + window.clearTimeout(reconnectTimeoutId); + reconnectTimeoutId = null; + + if (changeState(connection, + signalR.connectionState.reconnecting, + signalR.connectionState.connected) === true) { + // Successfully reconnected! + connection.log("Raising the reconnect event"); + $(instance).triggerHandler(events.onReconnect); + } + }, + // 1 hour + maxFireReconnectedTimeout = 3600000; if (connection.pollXhr) { connection.log("Polling xhr requests already exists, aborting."); @@ -1638,7 +1654,8 @@ var messageId = instance.messageId, connect = (messageId === null), reconnecting = !connect, - url = transportLogic.getUrl(instance, that.name, reconnecting, raiseReconnect); + polling = !raiseReconnect, + url = transportLogic.getUrl(instance, that.name, reconnecting, polling); // If we've disconnected during the time we've tried to re-instantiate the poll then stop. if (isDisconnecting(instance) === true) { @@ -1657,6 +1674,15 @@ var delay = 0, data; + // Reset our reconnect errors so if we transition into a reconnecting state again we trigger + // reconnected quickly + reconnectErrors = 0; + + // If there's currently a timeout to trigger reconnect, fire it now before processing messages + if (reconnectTimeoutId !== null) { + fireReconnected(); + } + fireConnect(); if (minData) { @@ -1689,11 +1715,21 @@ }, error: function (data, textStatus) { + // Stop trying to trigger reconnect, connection is in an error state + // If we're not in the reconnect state this will noop + window.clearTimeout(reconnectTimeoutId); + reconnectTimeoutId = null; + if (textStatus === "abort") { connection.log("Aborted xhr requst."); return; } + // Increment our reconnect errors, we assume all errors to be reconnect errors + // In the case that it's our first error this will cause Reconnect to be fired + // after 1 second due to reconnectErrors being = 1. + reconnectErrors++; + if (connection.state !== signalR.connectionState.reconnecting) { connection.log("An error occurred using longPolling. Status = " + textStatus + ". " + data.responseText); $(instance).triggerHandler(events.onError, [data.responseText]); @@ -1711,15 +1747,15 @@ } }); + // This will only ever pass after an error has occured via the poll ajax procedure. if (reconnecting && raiseReconnect === true) { - if (changeState(connection, - signalR.connectionState.reconnecting, - signalR.connectionState.connected) === true) { - // Successfully reconnected! - connection.log("Raising the reconnect event"); - $(instance).triggerHandler(events.onReconnect); - } + // We wait to reconnect depending on how many times we've failed to reconnect. + // This is essentially a heuristic that will exponentially increase in wait time before + // triggering reconnected. This depends on the "error" handler of Poll to cancel this + // timeout if it triggers before the Reconnected event fires. + // The Math.min at the end is to ensure that the reconnect timeout does not overflow. + reconnectTimeoutId = window.setTimeout(function () { fireReconnected(instance); }, Math.min(1000 * (Math.pow(2, reconnectErrors) - 1), maxFireReconnectedTimeout)); } }(connection)); @@ -2083,5 +2119,5 @@ /*global window:false */ /// (function ($) { - $.signalR.version = "1.1.0-beta1"; + $.signalR.version = "1.1.0"; }(window.jQuery)); diff --git a/UI/JsLibraries/messenger.js b/UI/JsLibraries/messenger.js index 371ee5098..4acfe7b47 100644 --- a/UI/JsLibraries/messenger.js +++ b/UI/JsLibraries/messenger.js @@ -1,4 +1,4 @@ -/*! messenger 1.3.0 2013-03-21 */ +/*! messenger 1.3.1 2013-05-14 */ /* * This file begins the output concatenated into messenger.js * @@ -299,7 +299,7 @@ window.Messenger.Events = (function() { })(); (function() { - var $, ActionMessenger, BaseView, Events, RetryingMessage, _, _Message, _Messenger, _ref, _ref1, + var $, ActionMessenger, BaseView, Events, RetryingMessage, _, _Message, _Messenger, _ref, _ref1, _ref2, __hasProp = {}.hasOwnProperty, __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, __slice = [].slice, @@ -307,9 +307,9 @@ window.Messenger.Events = (function() { $ = jQuery; - _ = _ != null ? _ : window.Messenger._; + _ = (_ref = window._) != null ? _ref : window.Messenger._; - Events = (_ref = typeof Backbone !== "undefined" && Backbone !== null ? Backbone.Events : void 0) != null ? _ref : window.Messenger.Events; + Events = (_ref1 = typeof Backbone !== "undefined" && Backbone !== null ? Backbone.Events : void 0) != null ? _ref1 : window.Messenger.Events; BaseView = (function() { @@ -426,7 +426,7 @@ window.Messenger.Events = (function() { }; _Message.prototype.update = function(opts) { - var _ref1, + var _ref2, _this = this; if (_.isString(opts)) { opts = { @@ -436,7 +436,7 @@ window.Messenger.Events = (function() { $.extend(this.options, opts); this.lastUpdate = new Date(); this.rendered = false; - this.events = (_ref1 = this.options.events) != null ? _ref1 : {}; + this.events = (_ref2 = this.options.events) != null ? _ref2 : {}; this.render(); this.actionsToEvents(); this.delegateEvents(); @@ -487,12 +487,12 @@ window.Messenger.Events = (function() { }; _Message.prototype.actionsToEvents = function() { - var act, name, _ref1, _results, + var act, name, _ref2, _results, _this = this; - _ref1 = this.options.actions; + _ref2 = this.options.actions; _results = []; - for (name in _ref1) { - act = _ref1[name]; + for (name in _ref2) { + act = _ref2[name]; _results.push(this.events["click [data-action=\"" + name + "\"] a"] = (function(act) { return function(e) { e.preventDefault(); @@ -506,11 +506,11 @@ window.Messenger.Events = (function() { }; _Message.prototype.checkClickable = function() { - var evt, name, _ref1, _results; - _ref1 = this.events; + var evt, name, _ref2, _results; + _ref2 = this.events; _results = []; - for (name in _ref1) { - evt = _ref1[name]; + for (name in _ref2) { + evt = _ref2[name]; if (name === 'click') { _results.push(this.$message.addClass('messenger-clickable')); } else { @@ -521,20 +521,20 @@ window.Messenger.Events = (function() { }; _Message.prototype.undelegateEvents = function() { - var _ref1; + var _ref2; _Message.__super__.undelegateEvents.apply(this, arguments); - return (_ref1 = this.$message) != null ? _ref1.removeClass('messenger-clickable') : void 0; + return (_ref2 = this.$message) != null ? _ref2.removeClass('messenger-clickable') : void 0; }; _Message.prototype.parseActions = function() { - var act, actions, n_act, name, _ref1, _ref2; + var act, actions, n_act, name, _ref2, _ref3; actions = []; - _ref1 = this.options.actions; - for (name in _ref1) { - act = _ref1[name]; + _ref2 = this.options.actions; + for (name in _ref2) { + act = _ref2[name]; n_act = $.extend({}, act); n_act.name = name; - if ((_ref2 = n_act.label) == null) { + if ((_ref3 = n_act.label) == null) { n_act.label = name; } actions.push(n_act); @@ -543,7 +543,7 @@ window.Messenger.Events = (function() { }; _Message.prototype.template = function(opts) { - var $action, $actions, $cancel, $link, $message, $text, action, _i, _len, _ref1, + var $action, $actions, $cancel, $link, $message, $text, action, _i, _len, _ref2, _this = this; $message = $("
"); if (opts.showCloseButton) { @@ -559,9 +559,9 @@ window.Messenger.Events = (function() { if (opts.actions.length) { $actions = $('
'); } - _ref1 = opts.actions; - for (_i = 0, _len = _ref1.length; _i < _len; _i++) { - action = _ref1[_i]; + _ref2 = opts.actions; + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + action = _ref2[_i]; $action = $(''); $action.attr('data-action', "" + action.name); $link = $(''); @@ -619,24 +619,24 @@ window.Messenger.Events = (function() { }; RetryingMessage.prototype.clearTimers = function() { - var name, timer, _ref1, _ref2; - _ref1 = this._timers; - for (name in _ref1) { - timer = _ref1[name]; + var name, timer, _ref2, _ref3; + _ref2 = this._timers; + for (name in _ref2) { + timer = _ref2[name]; clearTimeout(timer); } this._timers = {}; - return (_ref2 = this.$message) != null ? _ref2.removeClass('messenger-retry-soon messenger-retry-later') : void 0; + return (_ref3 = this.$message) != null ? _ref3.removeClass('messenger-retry-soon messenger-retry-later') : void 0; }; RetryingMessage.prototype.render = function() { - var action, name, _ref1, _results; + var action, name, _ref2, _results; RetryingMessage.__super__.render.apply(this, arguments); this.clearTimers(); - _ref1 = this.options.actions; + _ref2 = this.options.actions; _results = []; - for (name in _ref1) { - action = _ref1[name]; + for (name in _ref2) { + action = _ref2[name]; if (action.auto) { _results.push(this.startCountdown(name, action)); } else { @@ -676,13 +676,13 @@ window.Messenger.Events = (function() { }; RetryingMessage.prototype.startCountdown = function(name, action) { - var $phrase, remaining, tick, _ref1, + var $phrase, remaining, tick, _ref2, _this = this; if (this._timers[name] != null) { return; } $phrase = this.$message.find("[data-action='" + name + "'] .messenger-phrase"); - remaining = (_ref1 = action.delay) != null ? _ref1 : 3; + remaining = (_ref2 = action.delay) != null ? _ref2 : 3; if (remaining <= 10) { this.$message.removeClass('messenger-retry-later'); this.$message.addClass('messenger-retry-soon'); @@ -765,13 +765,13 @@ window.Messenger.Events = (function() { }; _Messenger.prototype._enforceIdConstraint = function(msg) { - var entry, _i, _len, _msg, _ref1; + var entry, _i, _len, _msg, _ref2; if (msg.options.id == null) { return; } - _ref1 = this.history; - for (_i = 0, _len = _ref1.length; _i < _len; _i++) { - entry = _ref1[_i]; + _ref2 = this.history; + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + entry = _ref2[_i]; _msg = entry.msg; if ((_msg.options.id != null) && _msg.options.id === msg.options.id && msg !== _msg) { if (msg.options.singleton) { @@ -785,13 +785,13 @@ window.Messenger.Events = (function() { }; _Messenger.prototype.newMessage = function(opts) { - var msg, _ref1, _ref2, _ref3, + var msg, _ref2, _ref3, _ref4, _this = this; if (opts == null) { opts = {}; } opts.messenger = this; - _Message = (_ref1 = (_ref2 = Messenger.themes[(_ref3 = opts.theme) != null ? _ref3 : this.options.theme]) != null ? _ref2.Message : void 0) != null ? _ref1 : RetryingMessage; + _Message = (_ref2 = (_ref3 = Messenger.themes[(_ref4 = opts.theme) != null ? _ref4 : this.options.theme]) != null ? _ref3.Message : void 0) != null ? _ref2 : RetryingMessage; msg = new _Message(opts); msg.on('show', function() { if (opts.scrollTo && _this.$el.css('position') !== 'fixed') { @@ -803,13 +803,13 @@ window.Messenger.Events = (function() { }; _Messenger.prototype.updateMessageSlotClasses = function() { - var anyShown, last, rec, willBeFirst, _i, _len, _ref1; + var anyShown, last, rec, willBeFirst, _i, _len, _ref2; willBeFirst = true; last = null; anyShown = false; - _ref1 = this.history; - for (_i = 0, _len = _ref1.length; _i < _len; _i++) { - rec = _ref1[_i]; + _ref2 = this.history; + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + rec = _ref2[_i]; rec.$slot.removeClass('first last shown'); if (rec.msg.shown && rec.msg.rendered) { rec.$slot.addClass('shown'); @@ -828,11 +828,11 @@ window.Messenger.Events = (function() { }; _Messenger.prototype.hideAll = function() { - var rec, _i, _len, _ref1, _results; - _ref1 = this.history; + var rec, _i, _len, _ref2, _results; + _ref2 = this.history; _results = []; - for (_i = 0, _len = _ref1.length; _i < _len; _i++) { - rec = _ref1[_i]; + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + rec = _ref2[_i]; _results.push(rec.msg.hide()); } return _results; @@ -927,7 +927,7 @@ window.Messenger.Events = (function() { }; ActionMessenger.prototype._parseEvents = function(events) { - var desc, firstSpace, func, label, out, type, _ref1; + var desc, firstSpace, func, label, out, type, _ref2; if (events == null) { events = {}; } @@ -937,7 +937,7 @@ window.Messenger.Events = (function() { firstSpace = label.indexOf(' '); type = label.substring(0, firstSpace); desc = label.substring(firstSpace + 1); - if ((_ref1 = out[type]) == null) { + if ((_ref2 = out[type]) == null) { out[type] = {}; } out[type][desc] = func; @@ -965,7 +965,7 @@ window.Messenger.Events = (function() { }; ActionMessenger.prototype.run = function() { - var args, attr, events, m_opts, msg, opts, promiseAttrs, _i, _len, _ref1, _ref2, + var args, attr, events, m_opts, msg, opts, promiseAttrs, _i, _len, _ref2, _ref3, _this = this; m_opts = arguments[0], opts = arguments[1], args = 3 <= arguments.length ? __slice.call(arguments, 2) : []; if (opts == null) { @@ -973,7 +973,7 @@ window.Messenger.Events = (function() { } m_opts = $.extend(true, {}, this.messageDefaults, this.doDefaults, m_opts != null ? m_opts : {}); events = this._parseEvents(m_opts.events); - msg = (_ref1 = m_opts.messageInstance) != null ? _ref1 : this.newMessage(m_opts); + msg = (_ref2 = m_opts.messageInstance) != null ? _ref2 : this.newMessage(m_opts); if (m_opts.id != null) { msg.options.id = m_opts.id; } @@ -984,20 +984,20 @@ window.Messenger.Events = (function() { })); } _.each(['error', 'success'], function(type) { - var old, _ref2, _ref3; - if ((_ref2 = opts[type]) != null ? _ref2._originalHandler : void 0) { + var old, _ref3, _ref4; + if ((_ref3 = opts[type]) != null ? _ref3._originalHandler : void 0) { opts[type] = opts[type]._originalHandler; } - old = (_ref3 = opts[type]) != null ? _ref3 : function() {}; + old = (_ref4 = opts[type]) != null ? _ref4 : function() {}; opts[type] = function() { - var data, msgOpts, msgText, r, reason, resp, xhr, _ref10, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9; + var data, msgOpts, msgText, r, reason, resp, xhr, _ref10, _ref11, _ref5, _ref6, _ref7, _ref8, _ref9; resp = 1 <= arguments.length ? __slice.call(arguments, 0) : []; - _ref4 = _this._normalizeResponse.apply(_this, resp), reason = _ref4[0], data = _ref4[1], xhr = _ref4[2]; + _ref5 = _this._normalizeResponse.apply(_this, resp), reason = _ref5[0], data = _ref5[1], xhr = _ref5[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 ((_ref6 = m_opts.errorCount) == null) { m_opts.errorCount = 0; } m_opts.errorCount += 1; @@ -1007,20 +1007,20 @@ window.Messenger.Events = (function() { 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) && (_ref7 = xhr != null ? xhr.status : void 0, __indexOf.call(m_opts.ignoredErrorCodes, _ref7) >= 0))) { msg.hide(); return; } msgOpts = $.extend({}, m_opts, { message: msgText, type: type, - events: (_ref7 = events[type]) != null ? _ref7 : {}, + events: (_ref8 = events[type]) != null ? _ref8 : {}, hideOnNavigate: type === 'success' }); - if (typeof ((_ref8 = msgOpts.retry) != null ? _ref8.allow : void 0) === 'number') { + if (typeof ((_ref9 = msgOpts.retry) != null ? _ref9.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 && ((_ref10 = msgOpts.retry) != null ? _ref10.allow : void 0)) { if (msgOpts.retry.delay == null) { if (msgOpts.errorCount < 4) { msgOpts.retry.delay = 10; @@ -1029,7 +1029,7 @@ window.Messenger.Events = (function() { } } if (msgOpts.hideAfter) { - if ((_ref10 = msgOpts._hideAfter) == null) { + if ((_ref11 = msgOpts._hideAfter) == null) { msgOpts._hideAfter = msgOpts.hideAfter; } msgOpts.hideAfter = msgOpts._hideAfter + msgOpts.retry.delay; @@ -1076,7 +1076,7 @@ window.Messenger.Events = (function() { if (msg[attr] != null) { delete msg[attr]; } - msg[attr] = (_ref2 = msg._actionInstance) != null ? _ref2[attr] : void 0; + msg[attr] = (_ref3 = msg._actionInstance) != null ? _ref3[attr] : void 0; } return msg; }; @@ -1095,7 +1095,7 @@ window.Messenger.Events = (function() { })(_Messenger); $.fn.messenger = function() { - var $el, args, func, instance, opts, _ref1, _ref2, _ref3; + var $el, args, func, instance, opts, _ref2, _ref3, _ref4; func = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : []; if (func == null) { func = {}; @@ -1104,7 +1104,7 @@ window.Messenger.Events = (function() { if (!(func != null) || !_.isString(func)) { opts = func; if (!($el.data('messenger') != null)) { - _Messenger = (_ref1 = (_ref2 = Messenger.themes[opts.theme]) != null ? _ref2.Messenger : void 0) != null ? _ref1 : ActionMessenger; + _Messenger = (_ref2 = (_ref3 = Messenger.themes[opts.theme]) != null ? _ref3.Messenger : void 0) != null ? _ref2 : ActionMessenger; $el.data('messenger', instance = new _Messenger($.extend({ el: $el }, opts))); @@ -1112,7 +1112,7 @@ window.Messenger.Events = (function() { } return $el.data('messenger'); } else { - return (_ref3 = $el.data('messenger'))[func].apply(_ref3, args); + return (_ref4 = $el.data('messenger'))[func].apply(_ref4, args); } }; @@ -1163,7 +1163,7 @@ window.Messenger.Events = (function() { $.extend(Messenger, { Message: RetryingMessage, Messenger: ActionMessenger, - themes: (_ref1 = Messenger.themes) != null ? _ref1 : {} + themes: (_ref2 = Messenger.themes) != null ? _ref2 : {} }); $.globalMessenger = window.Messenger = Messenger;