Sha256: c2c42c8b3b1d6fc840357374cf16f646e05600c91844afbd670fe6b8aa650f4d

Contents?: true

Size: 989 Bytes

Versions: 2

Compression:

Stored size: 989 Bytes

Contents

Zest.Telephony.Views.StatusView = Backbone.View.extend({
  className: 'agent-status-wrapper',

  events: {
    'click button' : 'toggleAvailable'
  },

  template: JST["templates/telephony/status_view"],

  initialize: function (options) {
    this.agent = new Zest.Telephony.Models.Agent({csr_id: options.csrId});
    this.agent.bind("change", this.render, this);

    $(document).bind("telephony:csrDidChangeStatus", $.proxy(this.renderStatus, this));
    $(document).bind("telephony:csrNotAvailable", $.proxy(this.setNotAvailable, this));
    $(document).bind("telephony:toggleCsrStatus", $.proxy(this.toggleAvailable, this));
  },

  toggleAvailable: function(event) {
    event.preventDefault();
    this.agent.toggleAvailable();
  },

  setNotAvailable: function() {
    this.agent.updateStatus();
  },

  renderStatus: function(event, data) {
    this.agent.set(data);
  },

  render: function() {
    $(this.el).html(this.template({ agent: this.agent }));
    return this;
  }
});

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
telephony-1.0.4 app/assets/javascripts/telephony/views/status_view.js
telephony-1.0.3 app/assets/javascripts/telephony/views/status_view.js