Sha256: e22d8e533e3342045dc3b9325e82747d87e43da0a7932373339953b12e0eb9b3

Contents?: true

Size: 1.96 KB

Versions: 15

Compression:

Stored size: 1.96 KB

Contents

_.templateSettings = {
    interpolate: /<@=(.+?)@>/g,
    escape: /<@-(.+?)@>/g,
    evaluate: /<@(.+?)@>/g
};

var flapjack = {

  module: function() {
    // Internal module cache.
    var modules = {};

    // Create a new module reference scaffold or load an
    // existing module.
    return function(name) {
      // If this module has already been created, return it.
      if (modules[name]) {
        return modules[name];
      }

      // Create a module and save it under this name
      return modules[name] = { Views: {} };
    };
  }()
};

$(document).ready(function() {

  flapjack.ActionsView = Backbone.View.extend({
    initialize: function() {
      this.template = _.template($('#contact-actions-template').html());
    },
    tagName: 'div',
    className: 'actions',
    events: {
      "click button#addContact" : "addContact",
    },
    render: function() {
      this.$el.html(this.template({}));
      return this;
    },
    addContact: function() {
      // skip if modal showing
      if ( $('#contactModal').hasClass('in') ) { return; }

      var contactDetailsView = new (Contact.Views.ContactDetails)({model: new (Contact.Model)()});
      contactDetailsView.render();

      $('div.modal-dialog').append(contactDetailsView.$el);
      $('#contactModal').modal('show');
    }
  });

  flapjack['api_url'] = $('div#data-api-url').data('api-url');

  var Contact = flapjack.module("contact");

  var actionsView = new flapjack.ActionsView();

  flapjack.contactList = new Contact.List();

  flapjack.contactList.fetch({
    success: function(collection, response, options) {
      var contactListView = new (Contact.Views.List)({collection: collection});
      contactListView.render();
      $('tbody#contactList').replaceWith(contactListView.$el);

      $('#contactModal').on('hidden.bs.modal', function (e) {
        e.stopImmediatePropagation();
        $('div.modal-dialog').empty();
      });

      $('#container').append(actionsView.render().el);
    }
  });

});

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
flapjack-0.9.6 lib/flapjack/gateways/web/public/js/flapjack.js
flapjack-0.9.5 lib/flapjack/gateways/web/public/js/flapjack.js
flapjack-0.9.4 lib/flapjack/gateways/web/public/js/flapjack.js
flapjack-1.1.0 lib/flapjack/gateways/web/public/js/flapjack.js
flapjack-1.0.0 lib/flapjack/gateways/web/public/js/flapjack.js
flapjack-1.0.0rc6 lib/flapjack/gateways/web/public/js/flapjack.js
flapjack-1.0.0rc5 lib/flapjack/gateways/web/public/js/flapjack.js
flapjack-0.9.3 lib/flapjack/gateways/web/public/js/flapjack.js
flapjack-1.0.0rc3 lib/flapjack/gateways/web/public/js/flapjack.js
flapjack-1.0.0rc2 lib/flapjack/gateways/web/public/js/flapjack.js
flapjack-0.9.2 lib/flapjack/gateways/web/public/js/flapjack.js
flapjack-0.9.1 lib/flapjack/gateways/web/public/js/flapjack.js
flapjack-1.0.0rc1 lib/flapjack/gateways/web/public/js/flapjack.js
flapjack-0.9.0 lib/flapjack/gateways/web/public/js/flapjack.js
flapjack-0.8.12 lib/flapjack/gateways/web/public/js/flapjack.js