(function($, undefined){

var slice = Array.prototype.slice;
var functionToString = Function.prototype.toString;

var Has = Backbone.Has = extend({

  constructor: function(model, name, options) {
    var has = model._has || (model._has = {});
    if (has[name]) return has[name];
    has[name] = this;
    this.model = model;
    this.options = _.extend(options || {}, {name: name});
    this.collection = (model._all || (model._all = new Collection()))
      .bind('has:initialize', this.initialize, this)
      .bind('has:change', this.change, this);
  },

  // initialize a model
  initialize: function(model) {},

  // handle change event for a model
  change: function(model) {},

  // find models based on name/options
  findModel: function() { },

  // find collections based on name/options
  findCollection: function() { },

  buildCollection: function(model) {
    var options = _.defaults(this.options, {
      scoped: true,
      where: function(){ return true; }
    });
    var collection = new options.collection([], {
      comparator: options.comparator
    });
    collection[options.inverseOf] = model;
    if (options.scoped) collection.scope = model;
    return collection;
  },

  associate: function(model, other) {
    this._notify('associate', model, other);
  },

  dissociate: function(model, other) {
    this._notify('dissociate', model, other);
  },

  _notify: function(event, model, other) {
    var options = this.options;
    if (!other._changing && other._initialized) return notify();
    other._queue[options.source] = notify;
    function notify() {
      model.trigger(event + ':' + options.inverseOf, model, other);
    }
  }

}, {

  _queue: [],

  initialize: function() {
    var callback;
    while (callback = Has._queue.shift()) callback();
  }

});

// initialize associations on page load
$(Has.initialize);

var HasProp = Backbone.HasProp = Has.extend({

  constructor: function() {
    var o = HasProp.__super__.constructor.apply(this, arguments);
    if (o) return o;
    var options = this.options;
    _.defaults(options, {attr: options.name, setter: _.identity});
    this.collection.bind('change:' + options.attr, this._change, this);
  },

  initialize: function(model) {
    this._change(model, model.get(this.options.attr));
  },

  _change: function(model, val) {
    var options = this.options;
    model[options.name] = val == null ? undefined : options.setter(val);
  }

});

var HasOne = Backbone.HasOne = Has.extend({

  constructor: function() {
    var o = HasOne.__super__.constructor.apply(this, arguments);
    if (o) return o;
    var options = this.options;
    _.defaults(options, {
      source: options.name,
      idAttr: options.name + '_id',
      inverseOf: funcName(this.model).toLowerCase(),
      model: this.findModel()
    });
    this._owners = {};
    this.collection
      .bind('associate:' + options.name, this._replace, this)
      .bind('dissociate:' + options.name, this._remove, this);
  },

  initialize: function(model) {
    var options = this.options;
    this._replace(model, model.get(options.name) || model.get(options.idAttr));
  },

  change: function(model) {
    var id, options = this.options, name = options.name, idAttr = options.idAttr;
    if (model.hasChanged(name)) {
      this._replace(model, model.get(name));
    } else if (model.hasChanged(idAttr)) {
      (id = model.get(idAttr)) ? this._replace(model, {id: id}) : this._remove(model);
    }
  },

  _destroy: function(model) {
    var owner = this._owners[model.cid];
    owner && owner.unset(this.options.source);
  },

  _remove: function(model) {
    this._replace(model, null);
  },

  _replace: function(model, now) {
    var valid, prev, options = this.options, name = options.name, idAttr = options.idAttr;
    var owners = this._owners;

    if (_.isNumber(now)) now = {id: now};
    if (model[name] && model[name].attributes === now) return;

    valid = _.isObject(now) && !_.isArray(now);
    if (valid && !(now instanceof Backbone.Model)) {
      now = new options.model(now);
    }

    if ((prev = model[name]) === now) return;

    // tear down previous association
    if (!valid) model.unset(name, idAttr);
    if (prev) {
      delete model[name];
      delete owners[prev.cid];
      this.dissociate(prev.unbind('destroy', this._destroy), model);
    }

    if (!valid) return;

    // set up new association
    model[name] = now;
    model.set(name, now.attributes);
    model.set(idAttr, now.id);
    owners[now.cid] = model;
    now.bind('destroy', this._destroy, this);
    this.associate(now, model);
  }

});

var HasMany = Backbone.HasMany = Has.extend({

  constructor: function() {
    var o = HasMany.__super__.constructor.apply(this, arguments);
    if (o) return o;
    var options = _.defaults(this.options, {
      inverseOf: funcName(this.model).toLowerCase(),
      source: this.options.name,
      collection: this.findCollection()
    });
    this.collection
      .bind('add', this._initialize, this)
      .bind('associate:' + options.source.singularize(), this._associate, this)
      .bind('dissociate:' + options.source.singularize(), this._dissociate, this);
  },

  initialize: function(model) {
    model[this.options.name].reset(this.parse(model));
  },

  change: function(model) {
    var options = this.options;
    if (model.hasChanged(options.source)) model[options.name].reset(this.parse(model));
  },

  parse: function(model) {
    var options = this.options, collection = model[options.name];
    var models = collection.parse(model.get(options.source));
    // Avoid modifying during iteration.
    return _.filter(_.map(_.toArray(models), function(attrs) {
      return new collection.model(attrs);
    }), options.where);
  },

  _initialize: function(model) {
    var collection = model[this.options.name] = this.buildCollection(model)
      .bind('add', this._add, this)
      .bind('remove', this._remove, this)
      .bind('reset', this._reset, this);
    collection._owner = model;
  },

  _add: function(model, collection) {
    var owner = collection._owner, a = owner.get(this.options.source);
    _.isArray(a) && a.splice(collection.indexOf(model), 0, model.attributes);
    this.associate(model, owner);
  },

  _remove: function(model, collection) {
    var owner = collection._owner, a = owner.get(this.options.source);
    _.isArray(a) && a.splice(_.indexOf(a, model.attributes), 1);
    this.dissociate(model, owner);
  },

  _reset: function(collection) {
    var self = this, owner = collection._owner;
    owner.set(this.options.source, _.pluck(collection.models || [], 'attributes'));
    collection.each(function(model){ self.associate(model, owner); });
  },

  _associate: function(model, other) {
    var options = this.options;
    if (options.where(model)) model[options.name].add(other);
  },

  _dissociate: function(model, other) {
    model[this.options.name].remove(other);
  }

});

var HasManyThrough = Backbone.HasManyThrough = Has.extend({

  constructor: function() {
    var o = HasManyThrough.__super__.constructor.apply(this, arguments);
    if (o) return o;
    this._associate = andThis(this._associate, this);
    this._dissociate = andThis(this._dissociate, this);
    var options = this.options;
    options.collection || (options.collection = this.findCollection());
    _.defaults(options, {
      source: funcName(options.collection.prototype.model).underscore(),
      inverseOf: funcName(options.through.collection.prototype.model).underscore()
    });
    this.collection.bind('add', this._initialize, this);
  },

  initialize: function(model) {
    this._reset(model[this.options.through.name]);
  },

  findThrough: function(model, other) {
    var options = this.options, inverseOf = options.through.inverseOf;
    return model[options.through.name].detect(function(m) {
      return m[inverseOf] === model && m[options.source] === other;
    });
  },

  _initialize: function(model) {
    var options = this.options;
    var collection = model[options.name] = this.buildCollection(model)
      .bind('add', this.__add, this)
      .bind('remove', this.__remove, this);
    collection._owner = model;
    collection['super'] = model[options.through.name]
      .bind('add', this._add, this)
      .bind('remove', this._remove, this)
      .bind('reset', this._reset, this)
      .bind('associate:' + options.source, this._associate)
      .bind('dissociate:' + options.source, this._dissociate);
  },

  _add: function(model, collection) {
    var owner = collection._owner, options = this.options;
    if (!(model = model[options.source]) || !options.where(model)) return;
    owner[options.name].add(model);
  },

  _remove: function(model, collection) {
    var owner = collection._owner, options = this.options, source = options.source;
    if (!(model = model[source])) return;
    if (collection.any(function(m){ return m[source] === model; })) return;
    owner[options.name].remove(model);
  },

  _reset: function(through) {
    var owner = through._owner, options = this.options;
    owner[options.name].reset(_.filter(_.compact(_.uniq(
      _.pluck(through.models, options.source))), options.where));
  },

  _associate: function(through, model, other) {
    var owner = through._owner, options = this.options;
    if (options.where(other)) owner[options.name].add(other);
  },

  _dissociate: function(through, model, other) {
    var owner = through._owner, options = this.options;
    if (through.any(function(m){ return m[options.source] === other; })) return;
    owner[options.name].remove(other);
  },

  __add: function(model, collection) {
    var owner = collection._owner;
    if (!!this.findThrough(owner, model)) return;
    var attrs = {}, options = this.options, through = owner[options.through.name];
    attrs[options.source] = model;
    attrs[options.through.inverseOf] = owner;
    if (model.isNew() || owner.isNew()) {
      through.add(attrs);
      return;
    }
    through.create(attrs, {
      error: function() { collection.remove(model); }
    });
  },

  __remove: function(model, collection) {
    var t = this.findThrough(collection._owner, model);
    t && t.destroy({
      error: function(){ collection.add(model); }
    });
  }

});

var Sub = Has.Sub = function(collection, options) {
  collection
    .bind('add', this._add, this)
    .bind('remove', this._remove, this)
    .bind('reset', this._reset, this);
  options = this.options = _.defaults(options || {}, {
    collection: collection.constructor
  });
  this.collection = new options.collection([], {
    'super': collection,
    comparator: options.comparator
  });
};

Sub.extend = Has.extend;

_.extend(Sub.prototype, {

  _add: function() {},
  _remove: function() {},
  _reset: function() {}

});


var Uniq = Has.Uniq = Sub.extend({

  constructor: function(collection) {
    Uniq.__super__.constructor.apply(this, arguments);
    this.collection.comparator = collection.comparator;
    collection.bind('change:' + this.options.attr, this._change, this);
    this._models = {};
    this._counts = {};
    this._reset(collection);
  },

  _add: function(model, collection) {
    var val = model.get(this.options.attr);
    if (!this._counts[val]) this._counts[val] = 0;
    if (!this._counts[val]++) this.collection.add(this._models[val] = model);
  },

  _remove: function(model, collection) {
    this._removeVal(model.get(this.options.attr));
  },

  _reset: function(collection) {
    var val, attr = this.options.attr;
    this._counts = {};
    collection.each(this._add, this);
    _.each(this.collection.toArray(), function(model){
      if (this._counts[val = model.get(attr)]) return;
      this.collection.remove(this._models[val]);
      delete this._models[val];
    }, this);
  },

  _change: function(model) {
    this._removeVal(model.previous(this.options.attr));
    this._add(model);
  },

  _removeVal: function(val) {
    if (--this._counts[val]) return;
    this.collection.remove(this._models[val]);
    delete this._models[val];
  }

});


var Limit = Has.Limit = Sub.extend({

  constructor: function(collection) {
    Limit.__super__.constructor.apply(this, arguments);
    this.collection.comparator = collection.comparator;
    this._reset(collection);
  },

  _add: function(model, collection) {
    if (collection.indexOf(model) >= this.options.limit) return;
    this.collection.add(model);
    if (this.collection.length > this.options.limit) {
      this.collection.remove(this.collection.last());
    }
  },

  _remove: function(model, collection) {
    var limit = this.options.limit;
    this.collection.remove(model);
    if (this.collection.length >= limit) return;
    if (collection.length < limit) return;
    this.collection.add(collection.at(limit - 1));
  },

  _reset: function(collection) {
    this.collection.reset(collection.first(this.options.limit), {soft: true});
  }

});


var Subset = Has.Subset = Sub.extend({

  constructor: function(collection) {
    Subset.__super__.constructor.apply(this, arguments);
    var options = this.options;
    _.defaults(options, {filter: function(){ return true; }});
    this.collection.reset(collection.filter(options.filter))
      .bind('filter', this._filter, this);
  },

  _add: function(model) {
    if (this.options.filter(model)) this.collection.add(model);
  },

  _remove: function(model) {
    this.collection.remove(model);
  },

  _reset: function(collection) {
    this.collection.reset(collection.filter(this.options.filter), {soft: true});
  },

  _filter: function(options) {
    options || (options = {});
    if (_.isFunction(options)) options = {filter: options};
    this.options.filter = options.filter;
    this._reset(this.collection['super']);
  }

});


var Subgroups = Has.Subgroups = Sub.extend({

  constructor: function(collection, options) {
    Subgroups.__super__.constructor.apply(this, arguments);
    this.collection.comparator = function(model){ return model.get('key'); };
    this.byKey = this.collection.byKey = {};
    this._reset(collection);
  },

  _add: function(model) {
    var key, group, byKey = this.byKey, options = this.options;
    if (group = byKey[key = options.groupBy(model)]) {
      group.collection.add(model);
      byKey[key].set({length: group.collection.length});
      return;
    }
    this.collection.add(byKey[key] = new Model({key: key, length: 1}, {
      collection: new options.collection([model], {
        'super': this.collection,
        comparator: options.comparator
      })
    }));
  },

  _remove: function(model) {
    var group, byKey = this.byKey, options = this.options;
    (group = this.collection.detect(function(_model){
      return _model.collection.include(model);
    }))
    .collection.remove(model);
    group.set({length: group.collection.length});
    if (!group.collection.length) {
      delete byKey[group.get('key')];
      group.destroy();
    }
  },

  _reset: function(collection) {
    collection.each(this._add, this);
    var models = _.flatten(this.collection.map(function(model){
      return model.collection.models;
    }));
    _.each(_.difference(models, collection.models), this._remove, this);
  }

});


var Collection = Has.Collection = Backbone.Collection.extend({

  constructor: function(models, options) {
    Collection.__super__.constructor.apply(this, arguments);
    this.cid = _.uniqueId('c');
    options || (options = {});
    if (options['super']) this['super'] = options['super'];
  },

  fetch: function() {
    var s = this['super'];
    if (s) return s.fetch.apply(s, arguments);
    return Collection.__super__.fetch.apply(this, arguments);
  },

  reset: function(models, options) {
    options || (options = {});
    if (!options.soft) return Collection.__super__.reset.apply(this, arguments);
    var self = this;
    models = _.map(models, function(model){ return self._add(model, options); });
    return this.remove(_.difference(this.models, models), options);
  },

  subset: function(options) {
    if (_.isFunction(options)) options = {filter: options};
    return new Subset(this, options).collection;
  },

  subgroups: function(options) {
    if (_.isFunction(options)) options = {groupBy: options};
    return new Subgroups(this, options).collection;
  },

  limit: function(options) {
    if (_.isNumber(options)) options = {limit: options};
    return new Limit(this, options).collection;
  },

  uniq: function(options) {
    if (_.isString(options)) options = {attr: options};
    return new Uniq(this, options).collection;
  },

  move: function(model, x) {
    var i;
    if (_.isNumber(model)) model = this.get(model);
    if (!~(i = this.indexOf(model))) return;
    return this.at(x + i);
  },

  next: function(model) { return this.move(model, 1); },

  prev: function(model) { return this.move(model, -1); },

  _add: function(model, options) {
    model = this._prepareModel(model);
    if (this.getByCid(model)) return model;
    return Collection.__super__._add.apply(this, arguments);
  }

});


var Model = Has.Model = Backbone.Model.extend({

  constructor: function(attrs, options) {
    this._queue = {};

    var id, cid, model, ctor = this.constructor;
    var all = ctor._all || (ctor._all = new Collection());

    // return subclass if appropriate
    var sub = this.findConstructor && this.findConstructor(attrs, options);
    if (sub && !(this instanceof sub)) return new sub(attrs, options);

    // return existing model if found
    if (attrs && (cid = attrs._cid)) return all.getByCid(cid);
    if (attrs && (id = attrs.id) && (model = all.get(id))) {
      model.set(attrs, options);
      return model;
    }

    Model.__super__.constructor.apply(this, arguments);
  },

  initialize: function() {
    var has, self = this;
    this.set({_cid: this.cid});
    var ctor = this.constructor;
    do {
      (ctor._all || (ctor._all = new Collection())).add(self);
    } while(ctor.__super__ && (ctor = ctor.__super__.constructor));
    this.trigger('has:initialize', this);
    this._initialized = true;
    this._dequeue();
    Model.__super__.initialize.apply(this, arguments);
  },

  change: function() {
    var has, self = this;
    this.trigger('has:change', this);
    if (this._initialized) this._dequeue();
    Model.__super__.change.apply(this, arguments);
  },

  _dequeue: function() {
    var queue = this._queue;
    this._queue = {};
    for (var key in queue) queue[key]();
  }

}, {

  has: function(callback) {
    Has._queue.push(_.bind(callback, this));
    return this;
  },

  hasProp: function(name, options) {
    if (_.isFunction(options)) options = {setter: options};
    new HasProp(this, name, options);
    return this;
  },

  hasOne: function(name, options) {
    new HasOne(this, name, options);
    return this;
  },

  hasMany: function(name, options) {
    var through = options && options.through;
    if (_.isString(through)) options.through = through = {name: through};
    if (through) {
      options.through = new HasMany(this, through.name, through).options;
      new HasManyThrough(this, name, options);
      return this;
    }
    new HasMany(this, name, options);
    return this;
  }

});

function funcName(f) {
  if (!_.isFunction(f)) return '';
  if (f.name) return f.name;
  var m = functionToString.call(f).match(/function (.{1,})\(/);
  return f.name = m && m.length > 1 ? m[1] : '';
}

function andThis(f, context) {
  return function() {
    return f.apply(context || this, [this].concat(_.toArray(arguments)));
  };
}

function extend(proto, _class) {
  proto.constructor || (proto.constructor = function(){});
  var ctor = proto.constructor;
  ctor.extend = Backbone.Model.extend;
  _.extend(ctor, _class);
  _.extend(ctor.prototype, proto);
  return ctor;
}

})(jQuery);

(function($, undefined) {

  var List = Backbone.List = Backbone.View.extend({

    tagName: 'ol',

    className: function(){ return 'list'; },

    // override for custom list items
    itemType: Backbone.View,

    // override for custom options per item
    itemOptions: {},

    // clicking items triggers select events
    selectable: false,

    // can select multiple items at once
    multi: false,

    events: function() {
      return {'click *': '_select'};
    },

    initialize: function() {
      _.bindAll(this, '_itemEvent');
      this.views = [];
      this._views = {};
      this.$el || (this.$el = $(this.el));
      if (this.options.addClass) this.$el.addClass(this.options.addClass);

      _.defaults(this.options, {
        autoFetch: this.options.size !== 0
      });

      List.__super__.initialize.apply(this, arguments);

      _.each('itemType itemOptions selectable multi'.split(/\s+/),
        function(k) {
          if (this.options[k]) this[k] = this.options[k];
        }, this);

      this.collection.autoFetch = this.options.autoFetch;
      this.collection
        .bind('add', this._add, this)
        .bind('remove', this._remove, this)
        .bind('reset', this._reset, this)
        .bind('change:id', this._changeId, this);
    },

    select: function (view, options) {
      options || (options = {});
      if (!(view = this.findView(view))) return;
      this.highlight(view);
      if (this.multi) {
        this._toggle(view, options.selected, options);
      } else if (this.selected !== view) {
        this._toggle(this.selected, false, options);
        this._toggle(this.selected = view, true, options);
      }
    },

    unselect: function(view, options) {
      options || (options = {});
      if (!(view = this.findView(view))) return;
      if (this.selected === view) delete this.selected;
      this._toggle(view, false, options);
    },

    unselectAll: function() {
      _.each(this.views, this.unselect, this);
    },

    highlight: function(view) {
      if (!(view = this.findView(view))) return;
      this._highlight(this.highlighted, false);
      this._highlight(this.highlighted = view, true);
    },

    move: function(x) {
      this.highlight(this.highlighted ?
        this.collection.move(this.highlighted.model, x) :
        this.collection.first());
    },

    moveNext: function() {
      this.move(1);
    },

    movePrev: function() {
      this.move(-1);
    },

    // find view by model (c)id or view cid
    findView: function(id) {
      return this._views && this._views[id && id.cid || id];
    },

    render: function() {
      // TODO: Stop un-delegating events in the first place.
      this.delegateEvents();
      _.each(_.pluck(this.views, 'model'), this._remove, this);
      this.collection.each(this._add, this);
      return this;
    },

    _changeId: function(model, id) {
      var view = this._views[model.cid];
      if (id && view) this._views[id] = view;
      if (!id) delete this._views[model.previous('id')];
    },

    _add: function(model) {
      if (this.findView(model)) return;
      var options = this.itemOptions || {};
      if (_.isFunction(this.itemOptions)) options = this.itemOptions(model);
      var isList = /^[uo]l$/i.test(this.tagName);
      var tagName = options.tagName || this.itemType.prototype.tagName;
      if (isList && tagName == 'div') tagName = 'li';

      var view = new this.itemType(_.extend({
        model: model,
        tagName: tagName,
        parent: this,
        templateOptions: this.templateOptions
      }, options))
      .bind('all', this._itemEvent, this);

      this._views[model.cid] = this._views[view.cid] = view;
      if (model.id) this._views[model.id] = view;
      this.views.splice(this.collection.indexOf(model), 0, view);

      var el = view.render().el;
      if (isList && tagName != 'li') el = $('<li></li>').append(el);

      var prev = this.findView(this.collection.prev(model));
      prev ? $(this._el(prev)).after(el) : this.$el.prepend(el);

      this.trigger('add', view);
    },

    _remove: function(model) {
      var view;
      if (!(view = this.findView(model))) return;
      view.unbind('all', this._itemEvent);
      $(this._el(view)).remove();
      delete this._views[model.cid];
      delete this._views[view.cid];
      if (model.id) delete this._views[model.id];
      if (this.selected === view) delete this.selected;
      this.views.splice(_.indexOf(this.views, view), 1);
      this.trigger('remove', view);
    },

    _reset: function() {
      this.collection.each(this._add, this);
      var models = _.pluck(this.views, 'model');
      _.each(_.difference(models, this.collection.models), this._remove, this);
      this.views = this.collection.map(this.findView, this);
      var el = $(this.el);
      _.each(this.views, function(view) { el.append(view.el); });
    },

    // find dom element associated with a model/view
    _el: function(view) {
      if (!(view = this.findView(view))) return;
      if (view.el.parentNode === this.el) return view.el;
      return view.el.parentNode;
    },

    _itemEvent: function() {
      this.trigger.apply(this, arguments);
    },

    _select: function(e) {
      if (!this.selectable) return;
      if (e.currentTarget.parentNode !== this.el) return;
      this.select(_.find(this.views, function(view) {
        return this._el(view) === e.currentTarget;
      }, this));
    },

    _highlight: function(view, toggle) {
      if (toggle == null) toggle = true;
      if (!(view = this.findView(view))) return;
      $(this._el(view)).toggleClass('highlight', toggle);
    },

    _toggle: function(view, selected, options) {
      options || (options = {});
      if (!(view = this.findView(view))) return;
      if (selected == null) selected = !view.__selected;
      view.__selected = !!selected;
      if (options.silent) return;
      var args = [view.model, view, selected];
      view.trigger.apply(view, [selected ? 'select' : 'unselect'].concat(args));
      view.trigger.apply(view, ['toggle'].concat(args));
    }

  });

})(jQuery);

(function($){

  var rChop = /(\s*\S+|\s)$/;

  $.truncate = function(html, options){
    return $('<div></div>').append(html).truncate(options).html();
  };

  $.fn.truncate = function(options){
    options = $.extend({}, $.truncate.defaults, options || {});

    return this.each(function(){
      var self = $(this);

      if (options.noBreaks) {
        $('br', this).replaceWith(' ');
      }

      var text = self.text(), excess = text.length - options.length;

      if (options.words && excess > 0) {
        excess = text.length - text.substring(0, options.length).replace(rChop, '').length - 1;
      }

      if (excess < 0 || !excess && !options.truncated) return self;

      $.each(self.contents().get().reverse(), function(i, el){
        var $el = $(el),
          text = $el.text(),
          length = text.length;

        if (length <= excess) {
          options.truncated = true;
          excess -= length;
          $el.remove();
          return;
        }

        if (el.nodeType === 3) {
          text = text.substring(0, length - excess - 1);
          $el.replaceWith(text + options.ellipsis);
          return false;
        }

        $el.truncate($.extend(options, { length: length - excess }));
        return false;
      });
    });
  };

  $.truncate.defaults = {
    words: false,
    noBreaks: false,
    length: Infinity,
    ellipsis: '\u2060\u2026'
  };

})(jQuery);

(function(undefined) {

_.extend(Backbone.Has.prototype, {

  findModel: function() {
    var name = this.options.name;
    if (_.isString(name)) return P.models[name.replace(/.*::/, '').camelize()];
  },

  findCollection: function() {
    var options = this.options;
    var name = options.name;
    var className = options.className;
    return P.models[className || (name && name.camelize().pluralize())];
  }

});

})();

(function(){

var slice = Array.prototype.slice;

_.extend(Backbone.Model.prototype, {

  // Until #565 is fixed, patch clear so that it removes id and does not
  // replace attributes.
  // https://github.com/documentcloud/backbone/pull/565
  //
  // Until #570 (or similar) is merged, allow a key value pair as an
  // alternative to an object.
  // https://github.com/documentcloud/backbone/pull/570
  //
  // Until #736 is fixed, do not set _changing to false unless
  // !alreadyChanging.
  // https://github.com/documentcloud/backbone/pull/736
  //
  // Until #739 is fixed, implement unset/clear in terms of set
  // https://github.com/documentcloud/backbone/pull/739
  //
  // Pull request forthcoming:
  // Set attribute to new value regardless of equality test.

  set : function(attrs, options) {
    if (attrs != null && !_.isObject(attrs)) {
      var args = slice.call(arguments), attrs = {};
      while ((options = args.shift()) != null && !_.isObject(options)) attrs[options] = args.shift();
    }

    // Extract attributes and options.
    options || (options = {});
    if (!attrs) return this;
    if (attrs.attributes) attrs = attrs.attributes;
    if (options.unset) for (var attr in attrs) attrs[attr] = void 0;
    var now = this.attributes, escaped = this._escapedAttributes;

    // Run validation.
    if (!options.silent && this.validate && !this._performValidation(attrs, options)) return false;

    // Check for changes of `id`.
    if (this.idAttribute in attrs) this.id = attrs[this.idAttribute];

    // We're about to start triggering change events.
    var alreadyChanging = this._changing;
    this._changing = true;

    // Update attributes.
    for (var attr in attrs) {
      var val = attrs[attr], prev = now[attr], unset = attr in now;
      options.unset ? delete now[attr] : now[attr] = val;
      if (!_.isEqual(prev, val) || options.unset && unset) {
        delete escaped[attr];
        this._changed = true;
        if (!options.silent) this.trigger('change:' + attr, this, val, options);
      }
    }

    // Fire the `"change"` event, if the model has been changed.
    if (!alreadyChanging) {
      if (!options.silent && this._changed) this.change(options);
      this._changing = false;
    }
    return this;
  },

  // Remove an attribute from the model, firing `"change"` unless you choose
  // to silence it. `unset` is a noop if the attribute doesn't exist.
  unset : function(attrs, options) {
    if (_.isString(attrs)) {
      var key, args = _.toArray(arguments), attrs = {};
      while (_.isString(key = args.shift())) attrs[key] = void 0;
      options = key;
    }
    (options || (options = {})).unset = true;
    return this.set(attrs, options);
  },

  // Clear all attributes on the model, firing `"change"` unless you choose
  // to silence it.
  clear : function(options) {
    var keys = _.without(_.keys(this.attributes), 'id');
    return this.unset.apply(this, keys.concat([options]));
  },

  changedAttributes : function(now) {
    if (!this._changed) return false;
    now || (now = this.attributes);
    var changed = false, old = this._previousAttributes;
    for (var attr in now) {
      if (_.isEqual(old[attr], now[attr])) continue;
      (changed || (changed = {}))[attr] = now[attr];
    }
    for (var attr in old) {
      if (!(attr in now)) (changed || (changed = {}))[attr] = void 0;
    }
    return changed;
  }

});

// Until #683 is fixed, patch events so that nested calls to trigger will not
// drop calls.
// https://github.com/documentcloud/backbone/pull/683
Backbone.Events = {

  // Bind an event, specified by a string name, `ev`, to a `callback` function.
  // Passing `"all"` will bind the callback to all events fired.
  bind : function(ev, callback, context) {
    var calls = this._callbacks || (this._callbacks = {});
    var list  = calls[ev] || (calls[ev] = {});
    var tail = list.tail || (list.tail = list.next = {});
    tail.callback = callback;
    tail.context = context;
    list.tail = tail.next = {};
    return this;
  },

  // Remove one or many callbacks. If `callback` is null, removes all
  // callbacks for the event. If `ev` is null, removes all bound callbacks
  // for all events.
  unbind : function(ev, callback) {
    var calls, node, prev;
    if (!ev) {
      this._callbacks = {};
    } else if (calls = this._callbacks) {
      if (!callback) {
        calls[ev] = {};
      } else if (node = calls[ev]) {
        while ((prev = node) && (node = node.next)) {
          if (node.callback !== callback) continue;
          prev.next = node.next;
          node.context = node.callback = null;
          break;
        }
      }
    }
    return this;
  },

  // Trigger an event, firing all bound callbacks. Callbacks are passed the
  // same arguments as `trigger` is, apart from the event name.
  // Listening for `"all"` passes the true event name as the first argument.
  trigger : function(eventName) {
    var node, calls, callback, args, ev, events = ['all', eventName];
    if (!(calls = this._callbacks)) return this;
    while (ev = events.pop()) {
      if (!(node = calls[ev])) continue;
      args = ev == 'all' ? arguments : slice.call(arguments, 1);
      while (node = node.next) if (callback = node.callback) callback.apply(node.context || this, args);
    }
    return this;
  }

};

_.extend(Backbone.View.prototype, {

  // view.$() should return $el
  $: function(selector) {
    if (selector == null) return this.$el || (this.$el = $(this.el));
    return $(selector, this.el);
  }

});

_.each([
  Backbone.Model.prototype,
  Backbone.Collection.prototype,
  Backbone.Router.prototype,
  Backbone.View.prototype
], function(proto){ _.extend(proto, Backbone.Events); });

var sync = Backbone.sync;

Backbone.sync = function(method, model, options) {
  return sync.apply(this, arguments).done(function() {
    model.fetched_at = new Date();
  });
};

})();

(function($){

var toString = Object.prototype.toString;
var itemValue = $.fn.itemValue;
var t = $('<div itemscope itemtype="type" itemid="id" itemprop="prop" itemref="ref">')[0];

$.fn.extend({

  itemValue: function(value){
    if (!arguments.length) return itemValue.call(this);

    return this.each(function(){
      var format, truncate, length;
      var el = $(this), val = value;
      if ($.isArray(val) && el.data('join')) val = val.join(', ');
      switch (this.tagName.toUpperCase()) {
        case 'META':
          el.attr({content: val});
          break;
        case 'AUDIO':
        case 'EMBED':
        case 'IFRAME':
        case 'IMG':
        case 'SOURCE':
        case 'TRACK':
        case 'VIDEO':
          if (val && $.type(val) == 'string') el.attr({src: val});
          break;
        case 'A':
        case 'AREA':
        case 'LINK':
          el.attr({href: val});
          break;
        case 'OBJECT':
          el.attr({data: val});
          break;
        case 'TIME':
          val = new Date(val);
          el.attr({title: val.toString()});
          format = el.data('format');
          if (moment && format == 'timeago') {
            val = moment(val).fromNow();
          } else if (format) {
            val = moment(val).format(format);
          }
          el.html(val);
          break;
        default:
          el.html((el.data('truncate') || {}).length ?
            $.truncate(val, el.data('truncate')) : val);
          break;
      }
      if (el.data('empty') == 'hidden') el.toggle(!!val);
    });
  },

  // Some implementations (e.g. jsdom) of getAttribute return the empty string
  // for non-existent attributes. Use `hasAttribute` instead.
  // https://developer.mozilla.org/en/DOM/element.getAttribute#Notes
  //
  // IE7 doesn't support `hasAttribute`, fall back to `!= undefined`.
  itemScope: t.itemScope ? function() {
    return this[0].itemScope;
  } : t.hasAttribute ? function() {
    return this[0].hasAttribute('itemscope');
  } : function() {
    return this.attr('itemscope') != null;
  }

});

})(jQuery);

if (!window.I18n) { I18n = {}; }

I18n.defaultLocale = "en";

I18n.translations = {"en":{"date":{"formats":{"default":"%Y-%m-%d","short":"%b %d","long":"%B %d, %Y"},"day_names":["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],"abbr_day_names":["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],"month_names":[null,"January","February","March","April","May","June","July","August","September","October","November","December"],"abbr_month_names":[null,"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],"order":["year","month","day"]},"time":{"formats":{"default":"%a, %d %b %Y %H:%M:%S %z","short":"%b %d, %l:%M %p %Z","long":"%a %b %d, %Y, %l:%M %p %Z","time_only":"%l:%M %p %Z"},"am":"AM","pm":"PM"},"support":{"array":{"words_connector":", ","two_words_connector":" and ","last_word_connector":", and "}},"errors":{"format":"%{attribute} %{message}","messages":{"inclusion":"is not included in the list","exclusion":"is reserved","invalid":"is invalid","confirmation":"doesn't match confirmation","accepted":"must be accepted","empty":"can't be empty","blank":"can't be blank","too_long":"is too long (maximum is %{count} characters)","too_short":"is too short (minimum is %{count} characters)","wrong_length":"is the wrong length (should be %{count} characters)","not_a_number":"is not a number","not_an_integer":"must be an integer","greater_than":"must be greater than %{count}","greater_than_or_equal_to":"must be greater than or equal to %{count}","equal_to":"must be equal to %{count}","less_than":"must be less than %{count}","less_than_or_equal_to":"must be less than or equal to %{count}","odd":"must be odd","even":"must be even","expired":"has expired, please request a new one","not_found":"not found","already_confirmed":"was already confirmed","not_locked":"was not locked","not_saved":{"one":"1 error prohibited this %{resource} from being saved:","other":"%{count} errors prohibited this %{resource} from being saved:"}}},"activerecord":{"errors":{"messages":{"taken":"has already been taken","record_invalid":"Validation failed: %{errors}"}}},"number":{"format":{"separator":".","delimiter":",","precision":3,"significant":false,"strip_insignificant_zeros":false},"currency":{"format":{"format":"%u%n","unit":"$","separator":".","delimiter":",","precision":2,"significant":false,"strip_insignificant_zeros":false}},"percentage":{"format":{"delimiter":""}},"precision":{"format":{"delimiter":""}},"human":{"format":{"delimiter":"","precision":3,"significant":true,"strip_insignificant_zeros":true},"storage_units":{"format":"%n %u","units":{"byte":{"one":"Byte","other":"Bytes"},"kb":"KB","mb":"MB","gb":"GB","tb":"TB"}},"decimal_units":{"format":"%n %u","units":{"unit":"","thousand":"Thousand","million":"Million","billion":"Billion","trillion":"Trillion","quadrillion":"Quadrillion"}}}},"datetime":{"distance_in_words":{"half_a_minute":"half a minute","less_than_x_seconds":{"one":"less than 1 second","other":"less than %{count} seconds"},"x_seconds":{"one":"1 second","other":"%{count} seconds"},"less_than_x_minutes":{"one":"less than a minute","other":"less than %{count} minutes"},"x_minutes":{"one":"1 minute","other":"%{count} minutes"},"about_x_hours":{"one":"about 1 hour","other":"about %{count} hours"},"x_days":{"one":"1 day","other":"%{count} days"},"about_x_months":{"one":"about 1 month","other":"about %{count} months"},"x_months":{"one":"1 month","other":"%{count} months"},"about_x_years":{"one":"about 1 year","other":"about %{count} years"},"over_x_years":{"one":"over 1 year","other":"over %{count} years"},"almost_x_years":{"one":"almost 1 year","other":"almost %{count} years"}},"prompts":{"year":"Year","month":"Month","day":"Day","hour":"Hour","minute":"Minute","second":"Seconds"}},"helpers":{"select":{"prompt":"Please select"},"submit":{"create":"Create %{model}","update":"Update %{model}","submit":"Save %{model}"}},"devise":{"failure":{"already_authenticated":"You are already signed in.","unauthenticated":"You need to sign in or sign up before continuing.","unconfirmed":"You have to confirm your account before continuing.","locked":"Your account is locked.","invalid":"<span>Oops!</span> Your email or password were invalid.","invalid_token":"Invalid authentication token.","timeout":"Your session expired, please sign in again to continue.","inactive":"Your account was not activated yet."},"sessions":{"signed_in":"Signed in successfully.","signed_out":"Signed out successfully."},"passwords":{"send_instructions":"You will receive an email with instructions about how to reset your password in a few minutes.","updated":"Your password was changed successfully. You are now signed in.","updated_not_active":"Your password was changed successfully.","send_paranoid_instructions":"If your e-mail exists on our database, you will receive a password recovery link on your e-mail"},"confirmations":{"send_instructions":"You will receive an email with instructions about how to confirm your account in a few minutes.","send_paranoid_instructions":"If your e-mail exists on our database, you will receive an email with instructions about how to confirm your account in a few minutes.","confirmed":"Your account was successfully confirmed. You are now signed in."},"registrations":{"signed_up":"You have signed up successfully. If enabled, a confirmation was sent to your e-mail.","inactive_signed_up":"You have signed up successfully. However, we could not sign you in because your account is %{reason}.","updated":"You updated your account successfully.","destroyed":"Bye! Your account was successfully cancelled. We hope to see you again soon.","reasons":{"inactive":"inactive","unconfirmed":"unconfirmed","locked":"locked"}},"unlocks":{"send_instructions":"You will receive an email with instructions about how to unlock your account in a few minutes.","unlocked":"Your account was successfully unlocked. You are now signed in.","send_paranoid_instructions":"If your account exists, you will receive an email with instructions about how to unlock it in a few minutes."},"omniauth_callbacks":{"success":"Successfully authorized from %{kind} account.","failure":"Could not authorize you from %{kind} because \"%{reason}\"."},"mailer":{"confirmation_instructions":{"subject":"Confirmation instructions"},"reset_password_instructions":{"subject":"Reset password instructions"},"unlock_instructions":{"subject":"Unlock Instructions"}}},"community_settings":{"form":{"open":"Open, anyone can join","closed":"Closed, attendees must be invited","public":"Public, anyone can view","private":"Private, only registered attendees can view"}},"admin":{"communities":{"new":{"get_started":"Get started by creating your top-level community. Later you'll customize this community and its events."}}},"users":{"index":{"sort":{"most_recent":"Most recently updated","first_name":"First name","last_name":"Last name"}},"show":{"links_title":"Web Links","posts_title":"Recent Posts","tweets_title":"Recent Tweets"}},"models":{"label_sets":{"names":{"track":"Track","keywords":"Keywords","categories":"Categories"}},"users":{"errors":{"email":{"not_found":"could not be found."}}},"groups":{"levels":{"names":{"gold":"Gold","silver":"Silver","bronze":"Bronze"}}},"datafeed":{"errors":{"disabled_datafeed_update":"This data feed cannot be updated because it is disabled."},"client":{"base":{"invalid_password":"The password was not accepted.","missing_event":"No event ID was provided.","invalid_event":"The event ID `%{event_id}' was not accepted."},"amiando":{"invalid_credentials":"The API key was not accepted.","invalid_event":"No API key was provided.","server_error":"Amiando responded with an error: `%{error_id}'.","generic_error":"Amiando client error: `%{error}'."},"certain":{"missing_credentials":"No API key, username and/or password were provided.","invalid_api_key":"The API key is invalid.","invalid_credentials":"The username and/or password were not accepted.","blank_result":"Certain API returned a response with a blank result.","generic_error":"Certain client error: `%{error}'."},"cvent":{"invalid_credentials":"The account name, username and/or password were not accepted.","missing_event":"The event ID provided is blank or invalid.","server_error":"An error has occured on the Cvent servers.","generic_error":"Cvent client error: `%{error}'."},"eventbrite":{"missing_credentials":"No email address and/or password were provided.","invalid_user_name":"The email address was not accepted.","generic_error":"Eventbrite client error: `%{error}'."},"reg_online":{"missing_credentials":"No username and/or password were provided.","invalid_credentials":"The username and/or password were not accepted.","generic_error":"RegOnline client error: `%{error}'."},"web":{"generic_error":"Web client error: `%{error}'."}}},"templates":{"mail":{"allowed":{"system_notices":"System notices","private_notices":"Private messages","public_notices":"Public messages","daily_update":"Daily update"}}},"messages":{"mails":{"errors":{"enabled_for_email":"must be enabled for email.","not_allowed":"does not allow this type of message."}}},"question":{"questions":{"tags":"Tags","category":"Category"}},"ribbon":{"names":{"speaker":"Speaker","sponsor":"Sponsor","exhibitor":"Exhibitor"}}},"formtastic":{"titles":{"basics":"Basics","access":"Access"},"hints":{"community":{"domain":"Blank unless using a CNAME from another domain."},"email":{"email":"Email address of the initial community administrator."},"user":{"password":"Password for the initial community administrator.","edit":{"password":"","password_confirmation":"Please confirm your password."}},"url":{"url":"Separate multiple sites by commas or spaces."}}},"flash":{"success":{"saved":"<span>Success!</span> The %{thing} was successfully saved.","updated":"<span>Success!</span> The %{thing} was successfully updated."},"errors":{"validation":"<span>Error!</span> Validation errors prevented the community from being saved."}},"loading":"loading"},"fr":{"date":{"formats":{"default":"%d/%m/%Y","short":"%e %b","long":"%e %B %Y"},"day_names":["dimanche","lundi","mardi","mercredi","jeudi","vendredi","samedi"],"abbr_day_names":["dim","lun","mar","mer","jeu","ven","sam"],"month_names":[null,"janvier","f\u00e9vrier","mars","avril","mai","juin","juillet","ao\u00fbt","septembre","octobre","novembre","d\u00e9cembre"],"abbr_month_names":[null,"jan.","f\u00e9v.","mar.","avr.","mai","juin","juil.","ao\u00fbt","sept.","oct.","nov.","d\u00e9c."],"order":["day","month","year"]},"time":{"formats":{"default":"%d %B %Y %H:%M:%S","short":"%d %b %H:%M","long":"%A %d %B %Y %H:%M"},"am":"am","pm":"pm"},"datetime":{"distance_in_words":{"half_a_minute":"une demi-minute","less_than_x_seconds":{"zero":"moins d'une seconde","one":"moins d'une\u00a0seconde","other":"moins de %{count}\u00a0secondes"},"x_seconds":{"one":"1\u00a0seconde","other":"%{count}\u00a0secondes"},"less_than_x_minutes":{"zero":"moins d'une\u00a0minute","one":"moins d'une\u00a0minute","other":"moins de %{count}\u00a0minutes"},"x_minutes":{"one":"1\u00a0minute","other":"%{count}\u00a0minutes"},"about_x_hours":{"one":"environ une heure","other":"environ %{count}\u00a0heures"},"x_days":{"one":"1\u00a0jour","other":"%{count}\u00a0jours"},"about_x_months":{"one":"environ un mois","other":"environ %{count}\u00a0mois"},"x_months":{"one":"1\u00a0mois","other":"%{count}\u00a0mois"},"about_x_years":{"one":"environ un an","other":"environ %{count}\u00a0ans"},"over_x_years":{"one":"plus d'un an","other":"plus de %{count}\u00a0ans"},"almost_x_years":{"one":"presqu'un an","other":"presque %{count} ans"}},"prompts":{"year":"Ann\u00e9e","month":"Mois","day":"Jour","hour":"Heure","minute":"Minute","second":"Seconde"}},"number":{"format":{"separator":",","delimiter":" ","precision":3,"significant":false,"strip_insignificant_zeros":false},"currency":{"format":{"format":"%n %u","unit":"\u20ac","separator":",","delimiter":" ","precision":2,"significant":false,"strip_insignificant_zeros":false}},"percentage":{"format":{"delimiter":""}},"precision":{"format":{"delimiter":""}},"human":{"format":{"delimiter":"","precision":2,"significant":true,"strip_insignificant_zeros":true},"storage_units":{"format":"%n %u","units":{"byte":{"one":"octet","other":"octets"},"kb":"ko","mb":"Mo","gb":"Go","tb":"To"}},"decimal_units":{"format":"%n %u","units":{"unit":"","thousand":"millier","million":"million","billion":"milliard","trillion":"billion","quadrillion":"million de milliards"}}}},"support":{"array":{"words_connector":", ","two_words_connector":" et ","last_word_connector":" et "},"select":{"prompt":"Veuillez s\u00e9lectionner"}},"helpers":{"select":{"prompt":"Veuillez s\u00e9lectionner"},"submit":{"create":"Cr\u00e9er un(e) %{model}","update":"Modifier ce(tte) %{model}","submit":"Enregistrer ce(tte) %{model}"}},"errors":{"format":"Le %{attribute} %{message}","messages":{"inclusion":"n'est pas inclus(e) dans la liste","exclusion":"n'est pas disponible","invalid":"n'est pas valide","confirmation":"ne concorde pas avec la confirmation","accepted":"doit \u00eatre accept\u00e9(e)","empty":"doit \u00eatre rempli(e)","blank":"doit \u00eatre rempli(e)","too_long":{"one":"est trop long (pas plus d'un caract\u00e8re)","other":"est trop long (pas plus de %{count} caract\u00e8res)"},"too_short":{"one":"est trop court (au moins un caract\u00e8re)","other":"est trop court (au moins %{count} caract\u00e8res)"},"wrong_length":{"one":"ne fait pas la bonne longueur (doit comporter un seul caract\u00e8re)","other":"ne fait pas la bonne longueur (doit comporter %{count} caract\u00e8res)"},"not_a_number":"n'est pas un nombre","not_an_integer":"doit \u00eatre un nombre entier","greater_than":"doit \u00eatre sup\u00e9rieur \u00e0 %{count}","greater_than_or_equal_to":"doit \u00eatre sup\u00e9rieur ou \u00e9gal \u00e0 %{count}","equal_to":"doit \u00eatre \u00e9gal \u00e0 %{count}","less_than":"doit \u00eatre inf\u00e9rieur \u00e0 %{count}","less_than_or_equal_to":"doit \u00eatre inf\u00e9rieur ou \u00e9gal \u00e0 %{count}","odd":"doit \u00eatre impair","even":"doit \u00eatre pair","taken":"n'est pas disponible","record_invalid":"La validation a \u00e9chou\u00e9 : %{errors}"},"template":{"header":{"one":"Impossible d'enregistrer ce(tte) %{model} : 1 erreur","other":"Impossible d'enregistrer ce(tte) %{model} : %{count} erreurs"},"body":"Veuillez v\u00e9rifier les champs suivants\u00a0: "}},"activerecord":{"errors":{"messages":{"inclusion":"n'est pas inclus(e) dans la liste","exclusion":"n'est pas disponible","invalid":"n'est pas valide","confirmation":"ne concorde pas avec la confirmation","accepted":"doit \u00eatre accept\u00e9(e)","empty":"doit \u00eatre rempli(e)","blank":"doit \u00eatre rempli(e)","too_long":{"one":"est trop long (pas plus d'un caract\u00e8re)","other":"est trop long (pas plus de %{count} caract\u00e8res)"},"too_short":{"one":"est trop court (au moins un caract\u00e8re)","other":"est trop court (au moins %{count} caract\u00e8res)"},"wrong_length":{"one":"ne fait pas la bonne longueur (doit comporter un seul caract\u00e8re)","other":"ne fait pas la bonne longueur (doit comporter %{count} caract\u00e8res)"},"not_a_number":"n'est pas un nombre","not_an_integer":"doit \u00eatre un nombre entier","greater_than":"doit \u00eatre sup\u00e9rieur \u00e0 %{count}","greater_than_or_equal_to":"doit \u00eatre sup\u00e9rieur ou \u00e9gal \u00e0 %{count}","equal_to":"doit \u00eatre \u00e9gal \u00e0 %{count}","less_than":"doit \u00eatre inf\u00e9rieur \u00e0 %{count}","less_than_or_equal_to":"doit \u00eatre inf\u00e9rieur ou \u00e9gal \u00e0 %{count}","odd":"doit \u00eatre impair","even":"doit \u00eatre pair","taken":"n'est pas disponible","record_invalid":"La validation a \u00e9chou\u00e9 : %{errors}"},"template":{"header":{"one":"Impossible d'enregistrer ce(tte) %{model} : 1 erreur","other":"Impossible d'enregistrer ce(tte) %{model} : %{count} erreurs"},"body":"Veuillez v\u00e9rifier les champs suivants\u00a0: "},"full_messages":{"format":"%{attribute} %{message}"}}},"loading":"chargement"},"pt":{"date":{"abbr_day_names":["Dom","Seg","Ter","Qua","Qui","Sex","S\u00e1b"],"abbr_month_names":[null,"Jan","Fev","Mar","Abr","Mai","Jun","Jul","Ago","Set","Out","Nov","Dez"],"day_names":["Domingo","Segunda","Ter\u00e7a","Quarta","Quinta","Sexta","S\u00e1bado"],"formats":{"default":"%d/%m/%Y","long":"%d de %B de %Y","short":"%d de %B"},"month_names":[null,"Janeiro","Fevereiro","Mar\u00e7o","Abril","Maio","Junho","Julho","Agosto","Setembro","Outubro","Novembro","Dezembro"],"order":["day","month","year"]},"datetime":{"distance_in_words":{"about_x_hours":{"one":"aproximadamente 1 hora","other":"aproximadamente %{count} horas"},"about_x_months":{"one":"aproximadamente 1 m\u00eas","other":"aproximadamente %{count} meses"},"about_x_years":{"one":"aproximadamente 1 ano","other":"aproximadamente %{count} anos"},"almost_x_years":{"one":"quase 1 ano","other":"quase %{count} years"},"half_a_minute":"meio minuto","less_than_x_minutes":{"one":"menos de um minuto","other":"menos de %{count} minutos"},"less_than_x_seconds":{"one":"menos de 1 segundo","other":"menos de %{count} segundos"},"over_x_years":{"one":"mais de 1 ano","other":"mais de %{count} anos"},"x_days":{"one":"1 dia","other":"%{count} dias"},"x_minutes":{"one":"1 minuto","other":"%{count} minutos"},"x_months":{"one":"1 m\u00eas","other":"%{count} meses"},"x_seconds":{"one":"1 segundo","other":"%{count} segundos"}},"prompts":{"day":"Dia","hour":"Hora","minute":"Minuto","month":"M\u00eas","second":"Segundo","year":"Ano"}},"errors":{"format":"%{attribute} %{message}","messages":{"accepted":"tem de ser aceite","blank":"n\u00e3o pode estar em branco","confirmation":"n\u00e3o coincide com a confirma\u00e7\u00e3o","empty":"n\u00e3o pode estar vazio","equal_to":"tem de ser igual a %{count}","even":"tem de ser par","exclusion":"\u00e9 reservado","greater_than":"tem de ser maior que %{count}","greater_than_or_equal_to":"tem de ser maior ou igual a %{count}","inclusion":"n\u00e3o est\u00e1 inclu\u00eddo na lista","invalid":"\u00e9 inv\u00e1lido","less_than":"tem de ser menor que %{count}","less_than_or_equal_to":"tem de ser menor ou igual a %{count}","not_a_number":"n\u00e3o \u00e9 um n\u00famero","not_an_integer":"tem de ser um inteiro","odd":"tem de ser \u00edmpar","record_invalid":"A valida\u00e7\u00e3o falhou: %{errors}","taken":"n\u00e3o est\u00e1 dispon\u00edvel","too_long":"\u00e9 demasiado grande (o m\u00e1ximo \u00e9 de %{count} caracteres)","too_short":"\u00e9 demasiado pequeno (o m\u00ednimo \u00e9 de %{count} caracteres)","wrong_length":"comprimento errado (deve ter %{count} caracteres)"},"template":{"body":"Por favor, verifique os seguintes campos:","header":{"one":"N\u00e3o foi poss\u00edvel guardar %{model}: 1 erro","other":"N\u00e3o foi poss\u00edvel guardar %{model}: %{count} erros"}}},"helpers":{"select":{"prompt":"Por favor seleccione"},"submit":{"create":"Criar %{model}","submit":"Salvar %{model}","update":"Actualizar %{model}"}},"number":{"currency":{"format":{"delimiter":".","format":"%u%n","precision":2,"separator":",","significant":false,"strip_insignificant_zeros":false,"unit":"\u20ac"}},"format":{"delimiter":".","precision":3,"separator":",","significant":false,"strip_insignificant_zeros":false},"human":{"decimal_units":{"format":"%n %u","units":{"billion":{"one":"mil milh\u00f5es","other":"mil milh\u00f5es"},"million":{"one":"milh\u00e3o","other":"milh\u00f5es"},"quadrillion":{"one":"mil bili\u00f5es","other":"mil bili\u00f5es"},"thousand":"mil","trillion":{"one":"bili\u00e3o","other":"bili\u00f5es"},"unit":""}},"format":{"delimiter":"","precision":1,"significant":true,"strip_insignificant_zeros":true},"storage_units":{"format":"%n %u","units":{"byte":{"one":"Byte","other":"Bytes"},"gb":"GB","kb":"KB","mb":"MB","tb":"TB"}}},"percentage":{"format":{"delimiter":""}},"precision":{"format":{"delimiter":""}}},"support":{"array":{"last_word_connector":", e","two_words_connector":" e ","words_connector":", "}},"time":{"am":"am","formats":{"default":"%A, %d de %B de %Y, %H:%Mh","long":"%A, %d de %B de %Y, %H:%Mh","short":"%d/%m, %H:%M hs"},"pm":"pm"}},"ko":{"date":{"abbr_day_names":["\uc77c","\uc6d4","\ud654","\uc218","\ubaa9","\uae08","\ud1a0"],"abbr_month_names":[null,"1\uc6d4","2\uc6d4","3\uc6d4","4\uc6d4","5\uc6d4","6\uc6d4","7\uc6d4","8\uc6d4","9\uc6d4","10\uc6d4","11\uc6d4","12\uc6d4"],"day_names":["\uc77c\uc694\uc77c","\uc6d4\uc694\uc77c","\ud654\uc694\uc77c","\uc218\uc694\uc77c","\ubaa9\uc694\uc77c","\uae08\uc694\uc77c","\ud1a0\uc694\uc77c"],"formats":{"default":"%Y/%m/%d","long":"%Y\ub144 %m\uc6d4 %d\uc77c (%a)","short":"%m/%d"},"month_names":[null,"1\uc6d4","2\uc6d4","3\uc6d4","4\uc6d4","5\uc6d4","6\uc6d4","7\uc6d4","8\uc6d4","9\uc6d4","10\uc6d4","11\uc6d4","12\uc6d4"],"order":["year","month","day"]},"datetime":{"distance_in_words":{"about_x_hours":{"one":"\uc57d \ud55c \uc2dc\uac04","other":"\uc57d %{count}\uc2dc\uac04"},"about_x_months":{"one":"\uc57d \ud55c \ub2ec","other":"\uc57d %{count}\ub2ec"},"about_x_years":{"one":"\uc57d \uc77c \ub144","other":"\uc57d %{count}\ub144"},"almost_x_years":{"one":"\uc77c \ub144 \uc774\ud558","other":"%{count}\ub144 \uc774\ud558"},"half_a_minute":"30\ucd08","less_than_x_minutes":{"one":"\uc77c \ubd84 \uc774\ud558","other":"%{count}\ubd84 \uc774\ud558"},"less_than_x_seconds":{"one":"\uc77c \ucd08 \uc774\ud558","other":"%{count}\ucd08 \uc774\ud558"},"over_x_years":{"one":"\uc77c \ub144 \uc774\uc0c1","other":"%{count}\ub144 \uc774\uc0c1"},"x_days":{"one":"\ud558\ub8e8","other":"%{count}\uc77c"},"x_minutes":{"one":"\uc77c \ubd84","other":"%{count}\ubd84"},"x_months":{"one":"\ud55c \ub2ec","other":"%{count}\ub2ec"},"x_seconds":{"one":"\uc77c \ucd08","other":"%{count}\ucd08"}},"prompts":{"day":"\uc77c","hour":"\uc2dc","minute":"\ubd84","month":"\uc6d4","second":"\ucd08","year":"\ub144"}},"errors":{"format":"%{attribute} %{message}","messages":{"accepted":"\uc744(\ub97c) \ubc18\ub4dc\uc2dc \ud655\uc778\ud574\uc57c \ud569\ub2c8\ub2e4","blank":"\uc5d0 \ub0b4\uc6a9\uc744 \uc785\ub825\ud574 \uc8fc\uc138\uc694","confirmation":"\uc740(\ub294) \uc11c\ub85c \uc77c\uce58\ud574\uc57c \ud569\ub2c8\ub2e4","empty":"\uc5d0 \ub0b4\uc6a9\uc744 \uc785\ub825\ud574 \uc8fc\uc138\uc694","equal_to":"\uc740(\ub294) %{count}\uacfc \uac19\uc544\uc57c \ud569\ub2c8\ub2e4","even":"\uc5d0 \uc9dd\uc218\ub97c \uc785\ub825\ud574 \uc8fc\uc138\uc694","exclusion":"\uc740(\ub294) \uc774\ubbf8 \uc608\uc57d\ub418\uc5b4 \uc788\ub294 \uac12\uc785\ub2c8\ub2e4","greater_than":"\uc740(\ub294) %{count}\ubcf4\ub2e4 \ucee4\uc57c \ud569\ub2c8\ub2e4","greater_than_or_equal_to":"\uc740(\ub294) %{count}\ubcf4\ub2e4 \ud06c\uac70\uc57c \uac19\uc544\uc57c \ud569\ub2c8\ub2e4","inclusion":"\uc740(\ub294) \ubaa9\ub85d\uc5d0 \ud3ec\ud568\ub418\uc5b4 \uc788\ub294 \uac12\uc774 \uc544\ub2d9\ub2c8\ub2e4","invalid":"\uc740(\ub294) \uc62c\ubc14\ub974\uc9c0 \uc54a\uc740 \uac12\uc785\ub2c8\ub2e4","less_than":"\uc740(\ub294) %{count}\ubcf4\ub2e4 \uc791\uc544\uc57c \ud569\ub2c8\ub2e4","less_than_or_equal_to":"\uc740(\ub294) %{count}\uacfc \uc791\uac70\ub098 \uac19\uc544\uc57c \ud569\ub2c8\ub2e4","not_a_number":"\uc5d0 \uc22b\uc790\ub97c \uc785\ub825\ud574 \uc8fc\uc138\uc694","not_an_integer":"\uc5d0 \uc815\uc218\ub97c \uc785\ub825\ud574 \uc8fc\uc138\uc694","odd":"\uc5d0 \ud640\uc218\ub97c \uc785\ub825\ud574 \uc8fc\uc138\uc694","record_invalid":"\ub370\uc774\ud130 \uac80\uc99d\uc5d0 \uc2e4\ud328\ud558\uc600\uc2b5\ub2c8\ub2e4. %{errors}","taken":"\uc740(\ub294) \uc774\ubbf8 \uc874\uc7ac\ud569\ub2c8\ub2e4.","too_long":"\uc740(\ub294) %{count}\uc790\ub97c \ub118\uc744 \uc218 \uc5c6\uc2b5\ub2c8\ub2e4","too_short":"\uc740(\ub294) \uc801\uc5b4\ub3c4 %{count}\uc790\ub97c \ub118\uc5b4\uc57c \ud569\ub2c8\ub2e4","wrong_length":"\uc740(\ub294) %{count}\uc790\uc5ec\uc57c \ud569\ub2c8\ub2e4"},"template":{"body":"\ub2e4\uc74c \ud56d\ubaa9\uc5d0 \ubb38\uc81c\uac00 \ubc1c\uacac\ub418\uc5c8\uc2b5\ub2c8\ub2e4:","header":{"one":"\ud55c \uac1c\uc758 \uc624\ub958\uac00 \ubc1c\uc0dd\ud574 %{model}\ub97c \uc800\uc7a5 \ud560 \uc218 \uc5c6\uc2b5\ub2c8\ub2e4","other":"%{count}\uac1c\uc758 \uc624\ub958\uac00 \ubc1c\uc0dd\ud574 %{model}\ub97c \uc800\uc7a5 \ud560 \uc218 \uc5c6\uc2b5\ub2c8\ub2e4"}}},"helpers":{"select":{"prompt":"\uc120\ud0dd\ud574\uc8fc\uc138\uc694"},"submit":{"create":"\ub4f1\ub85d","submit":"\uc81c\ucd9c","update":"\uac31\uc2e0"}},"number":{"currency":{"format":{"delimiter":",","format":"%n%u","precision":0,"separator":".","significant":false,"strip_insignificant_zeros":false,"unit":"\uc6d0"}},"format":{"delimiter":",","precision":3,"separator":".","significant":false,"strip_insignificant_zeros":false},"human":{"decimal_units":{"format":"%n%u","units":{"billion":"\uc2ed\uc5b5","million":"\ubc31\ub9cc","quadrillion":"\uacbd","thousand":"\ucc9c","trillion":"\uc870","unit":""}},"format":{"delimiter":"","precision":3,"significant":true,"strip_insignificant_zeros":true},"storage_units":{"format":"%n%u","units":{"byte":"\ubc14\uc774\ud2b8","gb":"\uae30\uac00\ubc14\uc774\ud2b8","kb":"\ud0ac\ub85c\ubc14\uc774\ud2b8","mb":"\uba54\uac00\ubc14\uc774\ud2b8","tb":"\ud14c\ub77c\ubc14\uc774\ud2b8"}}},"percentage":{"format":{"delimiter":""}},"precision":{"format":{"delimiter":""}}},"support":{"array":{"last_word_connector":", ","two_words_connector":"\uc640(\uacfc) ","words_connector":", "}},"time":{"am":"\uc624\uc804","formats":{"default":"%Y/%m/%d %H:%M:%S","long":"%Y\ub144 %B\uc6d4 %d\uc77c, %H\uc2dc %M\ubd84 %S\ucd08 %Z","short":"%y/%m/%d %H:%M"},"pm":"\uc624\ud6c4"},"loading":"\ub85c\ub4dc"}};

(function(){

  var interpolatePattern = /%\{([^}]+)\}/g;

  //Replace %{foo} with obj.foo
  function interpolate(str, obj){
    return str.replace(interpolatePattern, function(){
      return typeof obj[arguments[1]] == 'undefined' ? arguments[0] : obj[arguments[1]];
    });
  };

  //Split "foo.bar" to ["foo", "bar"] if key is a string
  function keyToArray(key){
    if (!key) return [];
    if (typeof key != "string") return key;
    return key.split('.');
  };

  function locale(){
    return I18n.locale || I18n.defaultLocale;
  };

  function getLocaleFromCookie(){
    var cookies = document.cookie.split(/\s*;\s*/),
        i, pair, locale;
    for (i = 0; i < cookies.length; i++) {
      pair = cookies[i].split('=');
      if (pair[0] === 'locale') { locale = pair[1]; break; }
    }
    return locale;
  };


  I18n.init = function(){
    this.locale = getLocaleFromCookie();
  };

  //Works mostly the same as the Ruby equivalent, except there are
  //no symbols in JavaScript, so keys are always strings. The only time
  //this makes a difference is when differentiating between keys and values
  //in the defaultValue option. Strings starting with ":" will be considered
  //to be keys and used for lookup, while other strings are returned as-is.
  I18n.translate = function(key, opts){
    if (typeof key != "string") { //Bulk lookup
      var a = [], i;
      for (i=0; i<key.length; i++) {
        a.push(this.translate(key[i], opts));
      }
      return a;
    } else {
      opts = opts || {};
      opts.defaultValue = opts.defaultValue || null;
      key = keyToArray(opts.scope).concat(keyToArray(key));
      var value = this.lookup(key, opts.defaultValue);
      if (typeof value != "string" && value) value = this.pluralize(value, opts.count);
      if (typeof value == "string") value = interpolate(value, opts);
      return value;
    }
  };

  I18n.t = I18n.translate;

  //Looks up a translation using an array of strings where the last
  //is the key and any string before that define the scope. The current
  //locale is always prepended and does not need to be provided. The second
  //parameter is an array of strings used as defaults if the key can not be
  //found. If a key starts with ":" it is used as a key for lookup.
  //This method does not perform pluralization or interpolation.
  I18n.lookup = function(keys, defaults){
    var i = 0, value = this.translations[locale()];
    defaults = typeof defaults == "string" ? [defaults] : (defaults || []);
    while (keys[i]) {
      value = value && value[keys[i]];
      i++;
    }
    if (value){
      return value;
    } else {
      if (defaults.length == 0) {
        return null;
      } else if (defaults[0].substr(0,1) == ':') {
        return this.lookup(keys.slice(0,keys.length-1).concat(keyToArray(defaults[0].substr(1))), defaults.slice(1));
      } else {
        return defaults[0];
      }
    }
  };

  I18n.pluralize = function(value, count){
    if (typeof count != 'number') return value;
    return count == 1 ? value.one : value.other;
  };

})();

I18n.init();

(function() {
  var Application,
    __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __slice = Array.prototype.slice;

  window.P || (window.P = new (Application = (function() {

    function Application() {
      this.decodeEntities = __bind(this.decodeEntities, this);
      this.support = __bind(this.support, this);
      this.title = __bind(this.title, this);
      var _ref, _ref2;
      this.logger = $.log;
      if ((_ref = this.logger) != null) _ref.init('INFO', true);
      if ((_ref2 = this.logger) != null) _ref2.debug("Logger setup.");
      this.settings = {
        env: 'development',
        ops: {
          support_email: 'support@pathable.com'
        },
        mixpanel: {
          api_key: '9153465e104075d088719eba11426082',
          token: 'a35646dc369fa5a6a8cce42e0c3a7ea6'
        }
      };
      this.development = true;
    }

    Application.prototype.bootstrap = function(data) {
      var _base, _name, _ref, _ref2,
        _this = this;
      this.revision = data.revision;
      this.session = new this.models.Session(data.session);
      this.session.bind('change', function() {
        return _this.user = _this.session.user;
      });
      this.community = typeof (_base = this.models)[_name = (_ref = data.community) != null ? _ref.class_name : void 0] === "function" ? new _base[_name](data.community) : void 0;
      this.association = ((_ref2 = this.community) != null ? _ref2.association : void 0) || this.community;
      this.user = this.session.user;
      this.current_admin = new this.models.User(data.current_admin);
      this.in_mobile_view = data.in_mobile_view;
      this.flash = data.flash;
      return this.announcements = new this.models.Announcements(data.announcements);
    };

    Application.prototype.namespace = function(target, name, block) {
      var item, top, _i, _len, _ref, _ref2;
      if (arguments.length < 3) {
        _ref = [(typeof exports !== 'undefined' ? exports : window)].concat(__slice.call(arguments)), target = _ref[0], name = _ref[1], block = _ref[2];
      }
      top = target;
      _ref2 = name.split('.');
      for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
        item = _ref2[_i];
        target = target[item] || (target[item] = {});
      }
      return block(target, top);
    };

    Application.prototype.pathname = function(object, root, path) {
      var name, nested_path, property;
      if (root == null) root = this;
      if (path == null) path = [];
      if (!object) return;
      if (typeof object === 'function') object = new object;
      for (name in root) {
        property = root[name];
        if (property === object.constructor) return name;
        if (typeof property === 'object') {
          nested_path = this.pathname(object, property, path);
          if (nested_path) return path.concat(name, nested_path).join('.');
        }
      }
    };

    Application.prototype.url = function(url, model, options) {
      var connector, path;
      if (options == null) {
        options = {
          extra: ''
        };
      }
      path = window.location.pathname.split('/')[1];
      if (/admin|host/.test(path) && url.indexOf("/" + path + "/") !== 0 && !options.excludeSection) {
        url = ("/" + path) + url;
      }
      if (model instanceof Backbone.Model && model.id) {
        connector = /\/$/.test(url) ? '' : '/';
        url += connector + model.id;
      }
      return url + (options['extra'] || '');
    };

    Application.prototype.start = function(data) {
      var _this = this;
      this.bootstrap(data);
      $('.support').live('click', this.support);
      this.localizer = new P.views.locales.Localizer({
        model: P.community.locales
      });
      this.localizer.render();
      this.router = (function() {
        if (this.in_mobile_view) {
          this.logger.info('Rendering mobile format.');
          return new P.routers.MobileRouter();
        } else {
          switch (window.location.pathname.split('/')[1]) {
            case 'host':
              return new P.routers.HostRouter();
            case 'admin':
              return new P.routers.AdminRouter();
            default:
              return new P.routers.AttendeeRouter();
          }
        }
      }).call(this);
      this.layout = this.router.layout;
      this.tracker = new P.models.tracking.Tracker();
      this.tracker.start();
      if (this.in_mobile_view) {
        $(document).bind('pagebeforechange', function(e, data) {
          Backbone.history.checkUrl();
          if (_this.router.visible != null) {
            data.toPage = $(_this.router.visible.el);
          }
        });
      }
      if (!this.in_mobile_view) return Backbone.history.start();
    };

    Application.prototype.title = function(title) {
      return document.title = (this.decodeEntities(this.community.get('name')) || '') + (title ? " :: " + title : '');
    };

    Application.prototype.support = function() {
      var _ref, _ref2, _ref3, _ref4;
      return typeof UserVoice !== "undefined" && UserVoice !== null ? UserVoice.showPopupWidget({
        custom_fields: {
          permalink: ((_ref = this.community) != null ? _ref.get('custom_slug') : void 0) || '',
          'user-profile': ((_ref2 = this.user) != null ? _ref2.id : void 0) || '',
          'full-name': ((_ref3 = this.user) != null ? _ref3.get('full_name') : void 0) || '',
          email: ((_ref4 = this.user) != null ? _ref4.get('primary_email') : void 0) || '',
          browser: navigator.userAgent,
          page: document.location.href
        }
      }) : void 0;
    };

    Application.prototype.decodeEntities = function(encoded) {
      return $("<div></div>").html(encoded).text();
    };

    return Application;

  })()));

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.errors', function(x) {
    x.ApplicationError = (function() {

      function ApplicationError(attrs) {
        if (attrs == null) attrs = {};
        this["class"] = attrs["class"] || 'error';
        this.messages = attrs.messages;
      }

      return ApplicationError;

    })();
    x.GeneralError = (function(_super) {

      __extends(GeneralError, _super);

      function GeneralError(attrs) {
        GeneralError.__super__.constructor.apply(this, arguments);
      }

      return GeneralError;

    })(x.ApplicationError);
    return x.ValidationError = (function(_super) {

      __extends(ValidationError, _super);

      function ValidationError(attrs) {
        ValidationError.__super__.constructor.apply(this, arguments);
        this.attribute = attrs.attribute;
        this.model = attrs.model;
        this.namespace = attrs.namespace;
        this.handler = attrs.handler;
      }

      return ValidationError;

    })(x.ApplicationError);
  });

}).call(this);

(function() {

  P.Events = _.extend(Backbone.Events, {
    one: function(event, f) {
      var _this = this;
      return this.bind(event, function() {
        _this.unbind(event, f);
        return f.apply(_this, arguments);
      });
    }
  });

}).call(this);

(function() {
  var rName;

  rName = /function (.{1,})\(/;

  P.funcName = function(func) {
    var m;
    if (!_.isFunction(func)) return '';
    if (func.name) return func.name;
    m = func.toString().match(rName);
    return func.name = (m != null) && m.length > 1 ? m[1] : '';
  };

}).call(this);

(function() {

  if (!String.prototype.namespacify) {
    String.prototype.namespacify = function() {
      var array, className, path, re, string;
      string = this;
      array = string.split('::');
      className = array[array.length - 1];
      re = new RegExp("::" + className + "$");
      path = string.replace(re, '');
      path = path.replace('::', '.').toLowerCase();
      return "" + path + "." + className;
    };
  }

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    x.Model = (function(_super) {

      __extends(Model, _super);

      function Model(attrs, options) {
        this._urlBase = __bind(this._urlBase, this);
        this.is = __bind(this.is, this);
        this.fetched = __bind(this.fetched, this);
        var o;
        if ((o = Model.__super__.constructor.apply(this, arguments)) != null) {
          return o;
        }
        this.urlOptions || (this.urlOptions = {
          singleton: false
        });
        this.className = P.funcName(this.constructor);
        this.instanceName = (this.className || '').toLowerCase();
      }

      Model.prototype.url = function(options) {
        if (options == null) options = {};
        return P.url("/" + (this._urlBase()), this, options);
      };

      Model.prototype.fragment = function() {
        return "#" + (this._urlBase()) + "/" + this.id;
      };

      Model.prototype.findConstructor = function(attrs, options) {
        var class_name;
        if (!_.isString(class_name = attrs != null ? attrs.class_name : void 0)) {
          return;
        }
        return P.models[class_name.replace(/.*::/, '').camelize()];
      };

      Model.prototype.toJSON = function() {
        var _this = this;
        return _.reduce(this.attributes, function(memo, v, k) {
          if (_this[k] instanceof Backbone.Model) return memo;
          if (_this[k] instanceof Backbone.Collection) return memo;
          memo[k] = v;
          return memo;
        }, {});
      };

      Model.prototype.parse = function(data) {
        if (_.isArray(data) && data.length) return data[0];
        return data;
      };

      Model.prototype.fetched = function() {
        return !!this.fetched_at;
      };

      Model.prototype.is = function(model) {
        var id;
        return this.id && (id = model != null ? model.id : void 0) && +this.id === +id;
      };

      Model.prototype._urlBase = function() {
        if (!(this.urlBase || this.className)) return '';
        return (this.urlBase || this.className).underscore().pluralize();
      };

      return Model;

    })(Backbone.Has.Model);
    return _.extend(x.Model.prototype, P.Events);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    x.Collection = (function(_super) {

      __extends(Collection, _super);

      Collection.prototype.model = P.models.Model;

      function Collection(models, options) {
        var _this = this;
        if (options == null) options = {};
        this.fetched = __bind(this.fetched, this);
        this.build = __bind(this.build, this);
        Collection.__super__.constructor.apply(this, arguments);
        _.each(['searchOptions'], function(s) {
          if (options[s] != null) return _this[s] = options[s];
        });
      }

      Collection.prototype.name = function() {
        return P.funcName(this.constructor).underscore();
      };

      Collection.prototype.build = function(attributes) {
        var model;
        if (attributes == null) attributes = {};
        model = new this.model(attributes);
        model.collection = this;
        return model;
      };

      Collection.prototype.addFromRow = function(row) {
        return this.add(this.model.fromRow(row));
      };

      Collection.prototype.enableAutoFetch = function(options) {
        var autoFetcher,
          _this = this;
        if (this.autoFetchEnabled === true) return false;
        this.autoFetchEnabled = true;
        if ((options != null ? options.regularly : void 0) == null) {
          options = {
            regularly: 10 * 60 * 1000,
            onceIn: false
          };
        }
        autoFetcher = function() {
          P.logger.trace("Auto fetching collection " + (_this.name()));
          _this.trigger('fetching');
          return _this.fetch();
        };
        if (options.onceIn) window.setTimeout(autoFetcher, options.onceIn);
        return window.setInterval(autoFetcher, options.regularly);
      };

      Collection.prototype.clear = function() {
        return this.reset([]);
      };

      Collection.prototype.clone = function() {
        return new this.constructor(this.map(function(m) {
          return m.clone();
        }));
      };

      Collection.prototype.fetch = function() {
        this.enableAutoFetch(this.autoFetch);
        return Collection.__super__.fetch.apply(this, arguments);
      };

      Collection.prototype.search = function(searchOptions, options) {
        if (searchOptions == null) searchOptions = {};
        if (options == null) options = {};
        _.extend(this.searchOptions, searchOptions);
        this.fetch(options);
        return this.trigger('search');
      };

      Collection.prototype.url = function(path) {
        var name, url, _ref,
          _this = this;
        if (path == null) path = '';
        name = P.funcName(this.constructor);
        url = P.url("" + (((_ref = this.scope) != null ? _ref.url() : void 0) || '') + "/" + (name.underscore()) + path, this);
        if (this.searchOptions == null) return url;
        _.defaults(this.searchOptions, {
          page: 1,
          query: '',
          per_page: 10,
          order: 'updated_at',
          sort_mode: 'desc',
          "with": {},
          classes: this.modelClasses || [P.funcName(this.model)]
        });
        return url + '?' + jQuery.param(_.map('query page per_page sort_mode order'.split(/\s+/), function(k) {
          return {
            name: k,
            value: _this.searchOptions[k]
          };
        }).concat(_.map(this.searchOptions["with"] || {}, function(v, k) {
          return {
            name: "with[" + k + "]",
            value: v
          };
        })).concat(_.map(this.searchOptions.conditions || {}, function(v, k) {
          return {
            name: "conditions[" + k + "]",
            value: v
          };
        })).concat(_.map(this.searchOptions.classes || [], function(c) {
          return {
            name: 'classes[]',
            value: c
          };
        })));
      };

      Collection.prototype.parse = function(response) {
        if ((response != null ? response.results : void 0) != null) {
          this.fetched_at = response.fetched_at, this.total_entries = response.total_entries, this.total_pages = response.total_pages, this.per_page = response.per_page, this.sort_mode = response.sort_mode;
          this.current_page = response.current_page - 1;
          return response.results;
        }
        if ((response != null ? response.models : void 0) != null) {
          this.fetched_at = response.fetched_at;
          return response.models;
        }
        return response;
      };

      Collection.prototype.fetched = function() {
        return !!this.fetched_at;
      };

      Collection.prototype.save = function(attrs, options) {
        var data, params,
          _this = this;
        if (options == null) options = {};
        data = _.extend({
          ids: this.pluck('id')
        }, attrs);
        params = _.extend({
          type: 'PUT',
          dataType: 'json',
          contentType: 'application/json',
          data: JSON.stringify(data),
          url: this.url('/update_many'),
          error: function(resp) {
            return _this.trigger('error', _this, resp, options);
          }
        }, options);
        return $.ajax(params);
      };

      return Collection;

    })(Backbone.Has.Collection);
    return _.extend(x.Collection.prototype, P.Events);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    return x.CommunitySettings = (function(_super) {

      __extends(CommunitySettings, _super);

      function CommunitySettings() {
        var o;
        if ((o = CommunitySettings.__super__.constructor.apply(this, arguments)) != null) {
          return o;
        }
      }

      CommunitySettings.prototype.defaults = {
        open: true,
        public: true,
        email_from_address: 'system@pathable.com',
        show_user_tweets: true,
        max_msg_recipients: null
      };

      return CommunitySettings;

    })(P.models.Model);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };

  P.namespace('P.views.discussions.discussions', function(x) {
    return x.RecipientsFeature = (function() {

      function RecipientsFeature() {
        this._adjustMaxRecipients = __bind(this._adjustMaxRecipients, this);
        this.enforceMaxRecipients = __bind(this.enforceMaxRecipients, this);
      }

      RecipientsFeature.prototype.maxRecipients = function() {
        return P.community.settings.get('max_msg_recipients');
      };

      RecipientsFeature.prototype.enforceMaxRecipients = function(collection) {
        collection.bind('add', this._adjustMaxRecipients);
        return collection.bind('remove', this._adjustMaxRecipients);
      };

      RecipientsFeature.prototype._adjustMaxRecipients = function() {
        if (this.isPrivate()) {
          return this.autoSuggest.options.maxChoices = this.maxRecipients;
        } else {
          return this.autoSuggest.options.maxChoices = null;
        }
      };

      return RecipientsFeature;

    })();
  });

}).call(this);

(function() {

  P.namespace('P.views.links', function(x) {
    return x.FormFeature = (function() {

      function FormFeature() {}

      FormFeature.prototype.getLinkList = function() {
        return {
          link_list: this.$('.link_list textarea').val()
        };
      };

      FormFeature.prototype.setLinkList = function() {
        var urls;
        urls = this.model.links.pluck('url');
        return this.$('.link_list textarea').val(urls.join(', '));
      };

      return FormFeature;

    })();
  });

}).call(this);

(function() {

  P.namespace('P.views.shared.forms', function(x) {
    return x.ErrorsFeature = (function() {

      function ErrorsFeature() {}

      ErrorsFeature.prototype.bindErrors = function(options) {
        var _this = this;
        if (options == null) options = {};
        this.flash || (this.flash = P.layout.flash);
        if (this.collection != null) {
          P.logger.trace('Collection error handling setup.');
          this.bindErrorHandlers(this.collection, options);
        }
        if (this.model != null) {
          P.logger.trace('Model error handling setup.');
          this.bindErrorHandlers(this.model, options);
          return this.model.bind('error', function(model) {
            return _this.trigger('error');
          });
        }
      };

      ErrorsFeature.prototype.bindErrorHandlers = function(thing, options) {
        var _this = this;
        if (thing == null) return false;
        return thing.bind('error', function(model, resp) {
          var attribute, error, messages, _fn;
          if (resp instanceof P.errors.ValidationError) {
            return _this.addFormError(resp);
          }
          try {
            error = $.parseJSON(resp.responseText);
          } catch (e) {
            _this.flashError({
              error: P.localizer.t('forms.errors.json_parse_error', {
                support_email: P.settings.ops.support_email
              })
            }, P.localizer.t('client_error', {
              scope: ['forms', 'errors']
            }));
            error = {};
          }
          if (resp.status === 500) {
            if (error.error == null) {
              error = {
                error: P.localizer.t('forms.errors.general_error', {
                  support_email: P.settings.ops.support_email
                })
              };
            }
            _this.flashError(error, P.localizer.t('server_500', {
              scope: ['forms', 'errors']
            }));
          }
          if (resp.status === 401) {
            error.messages || (error.messages = _.flatten([error.error || '']));
            _this.flashError(error, P.localizer.t('server_401', {
              scope: ['forms', 'errors']
            }));
          }
          if (resp.status === 422) {
            _fn = function(attribute, messages) {
              return _this.addFormError(new P.errors.ValidationError({
                messages: messages,
                model: model,
                attribute: attribute,
                namespace: options.namespace,
                handler: options.handler
              }));
            };
            for (attribute in error) {
              messages = error[attribute];
              _fn(attribute, messages);
            }
          }
          if (resp.status === 404) {
            return _this.flashError(error, P.localizer.t('server_404', {
              scope: ['forms', 'errors']
            }));
          }
        });
      };

      ErrorsFeature.prototype.flashError = function(error, prepend) {
        var _ref;
        return this.flash.show({
          attribute: error != null ? error.attribute : void 0,
          message: error != null ? (_ref = error.messages) != null ? _ref.join(', ') : void 0 : void 0,
          "class": 'error'
        }, prepend);
      };

      ErrorsFeature.prototype.clearFormErrors = function(e) {
        this.removeFormError((e != null ? $(e.currentTarget).parents('.input') : $(this.el).find('.input')));
        if (this.flash != null) return this.flash.hide();
      };

      ErrorsFeature.prototype.removeFormError = function(input) {
        return input.removeClass('error').find('.inline-errors').fadeOut(function() {
          return $(this).remove();
        });
      };

      ErrorsFeature.prototype.addFormError = function(error) {
        var container, errors, messages, model_class,
          _this = this;
        model_class = error.namespace || error.model.className.underscore();
        container = this.$(".input." + error.attribute);
        container.addClass('error');
        errors = container.find('p.inline-errors');
        P.logger.warning("Validation error: " + (error.messages.join(', ')));
        if (!errors.length) {
          errors = container.append("<p class=\"inline-errors\"></p>").find('p.inline-errors');
        }
        messages = [];
        _.each(_.uniq(error.messages), function(message, index) {
          return messages.push(message);
        });
        errors.html(messages.join(' ')).fadeIn();
        if (error.handler != null) return error.handler(error, messages);
      };

      return ErrorsFeature;

    })();
  });

}).call(this);

(function() {

  P.namespace('P.views.shared.forms', function(x) {
    return x.FocusFeature = (function() {

      function FocusFeature() {}

      FocusFeature.prototype.register = function(view) {
        return view.bind('rendered', this.focus);
      };

      FocusFeature.prototype.focus = function(delay) {
        var _this = this;
        if (delay == null) delay = false;
        return setTimeout(function() {
          return _this.$('input:visible:first').focus();
        }, 0);
      };

      return FocusFeature;

    })();
  });

}).call(this);

(function() {

  P.namespace('P.views.shared.forms', function(x) {
    return x.FormValueGetFeature = (function() {

      function FormValueGetFeature() {}

      FormValueGetFeature.prototype.protectedValues = ['id'];

      FormValueGetFeature.prototype.getValues = function(namespace) {
        var formPredicate, values,
          _this = this;
        formPredicate = namespace || this.model.className.underscore();
        values = {};
        _.each(this.model.attributes, function(originalValue, name) {
          var domID, el, value;
          if (!_.any(_this.protectedValues, function(a) {
            return a === name;
          })) {
            domID = "#" + formPredicate + "_" + name;
            el = $(_this.el).find(domID);
            if (!(el.is(':checkbox') && !el.prop('checked'))) value = el.val();
            P.logger.trace("Setting " + _this.model.className + "[" + name + "] to value of domID " + domID + " (" + value + ")");
            if (value != null) return values[name] = value;
          }
        });
        return values;
      };

      return FormValueGetFeature;

    })();
  });

}).call(this);

(function() {

  P.namespace('P.views.shared.forms', function(x) {
    return x.FormValueSetFeature = (function() {

      function FormValueSetFeature() {}

      FormValueSetFeature.prototype.setValues = function(namespace) {
        var formPredicate;
        formPredicate = namespace || this.model.className.underscore();
        P.logger.trace("Assigning model attributes to form values.");
        return this.parseAndSetValues(formPredicate, this.model.attributes);
      };

      FormValueSetFeature.prototype.parseAndSetValues = function(namespace, values) {
        var field, value, _results,
          _this = this;
        _results = [];
        for (field in values) {
          value = values[field];
          _results.push((function(field, value) {
            var el, subValues, _i, _len, _results2;
            if (value instanceof P.models.Collection && value.length > 0) {
              _results2 = [];
              for (_i = 0, _len = value.length; _i < _len; _i++) {
                subValues = value[_i];
                _results2.push((function(subValues) {
                  return _this.parseAndSetValues("" + namespace + "_" + field + "_attributes_" + _i, subValues);
                })(subValues));
              }
              return _results2;
            } else {
              P.logger.trace("Setting #" + namespace + "_" + field + " to " + value);
              el = _this.$("#" + namespace + "_" + field);
              if (el.is('[type="file"]')) return;
              if (el.is(':checkbox') && _.isBoolean(value)) {
                return el.prop('checked', value);
              } else {
                return el.val(value != null ? String(value) : value);
              }
            }
          })(field, value));
        }
        return _results;
      };

      return FormValueSetFeature;

    })();
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  -P.namespace('P.models', function(x) {
    x.Group = (function(_super) {

      __extends(Group, _super);

      Group.prototype.defaults = {
        name: ''
      };

      function Group() {
        this.adminUsers = __bind(this.adminUsers, this);
        this.adminMemberships = __bind(this.adminMemberships, this);
        var o;
        if ((o = Group.__super__.constructor.apply(this, arguments)) != null) {
          return o;
        }
      }

      Group.prototype.adminMemberships = function() {
        var _this = this;
        return _.filter(this.memberships.models, function(membership) {
          return _.include(membership.get('roles'), 'admin');
        });
      };

      Group.prototype.adminUsers = function() {
        var _this = this;
        return _.map(this.adminMemberships(), function(membership) {
          return membership.user;
        });
      };

      return Group;

    })(P.models.Model);
    return x.Group.has(function() {
      this.hasMany('memberships');
      this.hasMany('noRibbonUsers', {
        collection: P.models.Users,
        through: {
          name: 'noRibbonMemberships',
          source: 'memberships',
          collection: P.models.Memberships,
          where: function(model) {
            return !model.ribbon;
          }
        }
      });
      this.hasMany('users', {
        scoped: false,
        through: {
          name: 'memberships'
        }
      });
      this.hasMany('membershipsRibbons', {
        through: {
          name: 'memberships'
        },
        collection: P.models.Ribbons
      });
      this.hasMany('speakers', {
        collection: P.models.Users,
        through: {
          name: 'speakerships',
          source: 'speakerships',
          collection: P.models.Memberships
        }
      });
      this.hasMany('affiliations');
      this.hasMany('documents');
      this.hasMany('discussions', {
        scoped: false
      });
      this.hasMany('links');
      this.hasMany('posts', {
        collection: P.models.feeds.Posts
      });
      return this.hasMany('tweets', {
        collection: P.models.feeds.Tweets
      });
    });
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    x.Community = (function(_super) {

      __extends(Community, _super);

      function Community() {
        this.level_label_set = __bind(this.level_label_set, this);
        var o;
        if ((o = Community.__super__.constructor.apply(this, arguments)) != null) {
          return o;
        }
      }

      Community.prototype.initialize = function() {
        var _this = this;
        Community.__super__.initialize.apply(this, arguments);
        this.groups.searchOptions = {
          order: 'groups.memberships_count'
        };
        this.groups.comparator = void 0;
        _.each('page layout'.split(/\s+/), function(role) {
          return _this.mail_templates[role.pluralize()] = _this.mail_templates.subset({
            collection: P.models.Templates,
            filter: function(model) {
              return model.get('role') === role;
            }
          });
        });
        this.user_label_sets = this.label_sets.subset({
          collection: P.models.LabelSets,
          filter: function(model) {
            return model.get('class_name') === 'Users::LabelSet';
          }
        });
        this.sponsors = this.organizations.subset({
          collection: P.models.Organizations,
          filter: function(model) {
            return model.get('sponsor');
          }
        });
        return this.locales = new P.models.Locales;
      };

      Community.prototype.defaults = {
        name: null,
        custom_slug: null,
        domain: null,
        time_zone: null,
        time_zone_offset: 0,
        settings: null
      };

      Community.prototype.level_label_set = function() {
        var label_set;
        label_set = this.label_sets.detect(function(l) {
          return l.get('name') === 'level';
        });
        label_set.labels.fetch();
        return label_set;
      };

      Community.prototype.isL10nEnabled = function() {
        return this.get('l10n_enabled') === true;
      };

      return Community;

    })(P.models.Group);
    return x.Community.has(function() {
      this.hasProp('created_at', function(val) {
        return new Date(val);
      });
      this.hasOne('settings', {
        model: P.models.CommunitySettings,
        inverseOf: 'group'
      });
      this.hasOne('calendar', {
        inverseOf: 'group'
      });
      this.hasMany('stats', {
        collection: P.models.CommunityStats,
        inverseOf: 'group'
      });
      this.hasMany('groups', {
        scoped: false,
        inverseOf: 'group'
      });
      this.hasMany('discussions', {
        scoped: false,
        inverseOf: 'group'
      });
      this.hasMany('tweets', {
        collection: P.models.feeds.Tweets,
        inverseOf: 'group'
      });
      this.hasMany('posts', {
        collection: P.models.feeds.Posts,
        inverseOf: 'group'
      });
      this.hasMany('questions', {
        scoped: false,
        inverseOf: 'group'
      });
      this.hasMany('ribbons', {
        scoped: false,
        invsereOf: 'group'
      });
      this.hasMany('mail_templates', {
        scoped: false,
        inverseOf: 'group',
        collection: P.models.Templates
      });
      this.hasMany('locations', {
        scoped: false,
        inverseOf: 'group',
        inverseOf: 'group'
      });
      this.hasMany('label_sets', {
        scoped: false,
        inverseOf: 'group'
      });
      this.hasMany('categories', {
        scoped: false,
        inverseOf: 'group',
        collection: P.models.Categories
      });
      this.hasMany('levels', {
        scoped: false,
        inverseOf: 'group',
        collection: P.models.Labels
      });
      this.hasMany('organizations', {
        scoped: false,
        inverseOf: 'group'
      });
      this.hasMany('events', {
        scoped: false,
        inverseOf: 'group'
      });
      this.hasMany('ribbons', {
        scoped: false,
        inverseOf: 'group'
      });
      this.hasMany('links', {
        scoped: false,
        inverseOf: 'group'
      });
      this.hasMany('posts', {
        scoped: false,
        inverseOf: 'group',
        collection: P.models.feeds.Posts
      });
      return this.hasMany('tweets', {
        scoped: false,
        inverseOf: 'group',
        collection: P.models.feeds.Tweets
      });
    });
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    return x.Association = (function(_super) {

      __extends(Association, _super);

      function Association() {
        var o;
        if ((o = Association.__super__.constructor.apply(this, arguments)) != null) {
          return o;
        }
      }

      Association.prototype.defaults = {
        name: null,
        custom_slug: null,
        domain: null,
        time_zone: null
      };

      return Association;

    })(P.models.Community);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    x.Event = (function(_super) {

      __extends(Event, _super);

      function Event() {
        var o;
        if ((o = Event.__super__.constructor.apply(this, arguments)) != null) {
          return o;
        }
      }

      Event.prototype.defaults = {
        name: null,
        domain: null,
        custom_slug: null,
        time_zone: null,
        starts_at: '2000-01-01',
        starts_at: '2000-01-01'
      };

      Event.prototype.isMultiDay = function() {
        var ends, starts;
        starts = this.get('starts_at');
        ends = this.get('ends_at');
        return starts && ends && starts < ends;
      };

      Event.prototype.rootUrl = function() {
        var scheme, url;
        url = this.get('domain');
        scheme = "" + window.location.protocol + "//";
        if (!!(url != null ? url.indexOf(scheme) : void 0)) {
          url = "" + scheme + url;
        }
        return url;
      };

      return Event;

    })(P.models.Community);
    return x.Event.has(function() {
      this.hasProp('starts_at', function(val) {
        return new Date(val);
      });
      this.hasProp('ends_at', function(val) {
        return new Date(val);
      });
      return this.hasOne('association', {
        inverseOf: 'group'
      });
    });
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    return x.Template = (function(_super) {

      __extends(Template, _super);

      function Template() {
        this._type = __bind(this._type, this);
        var o;
        if ((o = Template.__super__.constructor.apply(this, arguments)) != null) {
          return o;
        }
      }

      Template.prototype.initialize = function() {
        Template.__super__.initialize.apply(this, arguments);
        this.bind('change:class_name', this._type);
        return this._type();
      };

      Template.prototype._type = function() {
        var _ref;
        return this.set({
          _type: (_ref = this.get('class_name')) != null ? _ref.replace(/.*::/, '').toLowerCase() : void 0
        });
      };

      Template.prototype.defaults = {
        role: 'page',
        name: null,
        subject: null,
        body: null,
        preview: null,
        layout_id: null,
        valid_roles: []
      };

      return Template;

    })(P.models.Model);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    return x.EmailTemplate = (function(_super) {

      __extends(EmailTemplate, _super);

      function EmailTemplate() {
        var o;
        if ((o = EmailTemplate.__super__.constructor.apply(this, arguments)) != null) {
          return o;
        }
      }

      return EmailTemplate;

    })(x.Template);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    x.Membership = (function(_super) {

      __extends(Membership, _super);

      function Membership(attrs, options) {
        var o;
        if ((attrs != null ? attrs.group : void 0) instanceof x.Meeting && !(this instanceof x.Attendance)) {
          return new x.Attendance(attrs, options);
        }
        if ((o = Membership.__super__.constructor.apply(this, arguments)) != null) {
          return o;
        }
      }

      Membership.prototype.defaults = function() {
        return {
          user_display_name: '',
          send_email: false,
          ribbon_id: null,
          question_id: null,
          roles: []
        };
      };

      Membership.prototype.isFor = function(groupOrUser) {
        return (groupOrUser instanceof P.models.User && this.user.is(groupOrUser)) || (groupOrUser instanceof P.models.Group && this.group.is(groupOrUser));
      };

      Membership.prototype.url = function() {
        return P.url("/" + (this.group.instanceName.pluralize()) + "/" + (this.get('group_id')) + (Membership.__super__.url.call(this, {
          excludeSection: true
        })));
      };

      return Membership;

    })(P.models.Model);
    return x.Membership.has(function() {
      this.hasOne('ribbon');
      this.hasOne('user');
      this.hasOne('group');
      return this.hasOne('answer');
    });
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    x.User = (function(_super) {

      __extends(User, _super);

      function User() {
        this.subscription = __bind(this.subscription, this);
        var o;
        if ((o = User.__super__.constructor.apply(this, arguments)) != null) {
          return o;
        }
      }

      User.prototype.initialize = function() {
        var _this = this;
        User.__super__.initialize.apply(this, arguments);
        this.tags = this.groups.subset({
          collection: P.models.Tags,
          filter: function(model) {
            return model.get('class_name') === 'Groups::Tag';
          }
        });
        this.meetings = this.groups.subset({
          collection: P.models.Meetings,
          filter: function(model) {
            var _ref;
            return model instanceof P.models.Meeting && (!model.get('private') || ((_ref = model.memberships["for"](_this)) != null ? _ref.isAttending() : void 0));
          }
        });
        this.meetings.public = this.meetings.subset({
          collection: P.models.Meetings,
          filter: function(model) {
            return !model.get('private');
          }
        });
        this.meetings.speaking = this.meetings.public.subset({
          collection: P.models.Meetings,
          filter: function(model) {
            return _this.memberships.any(function(m) {
              var _ref;
              return m.group === model && ((_ref = m.ribbon) != null ? _ref.isSpeaker() : void 0);
            });
          }
        });
        this.discussions.private = this.discussions.subset({
          collection: P.models.Discussions,
          filter: function(model) {
            return model.get('private');
          }
        });
        this.messages.private = this.messages.subset({
          collection: P.models.Messages,
          filter: function(model) {
            var _ref;
            return (_ref = model.discussion) != null ? _ref.get('private') : void 0;
          }
        });
        this.messages.public = this.messages.subset({
          collection: P.models.Messages,
          filter: function(model) {
            var _ref;
            return !((_ref = model.discussion) != null ? _ref.get('private') : void 0);
          }
        });
        return this.uniqueRibbons = this.ribbons.uniq('name');
      };

      User.prototype.defaults = {
        anonymous: true,
        first_name: null,
        last_name: null,
        organization_name: null,
        credentials: null,
        dirty: false,
        title: null,
        primary_email: null,
        password: null,
        password_confirmation: null,
        bio: null,
        ribbon_ids: [],
        roles: [],
        visible: false,
        has_accepted_legal: false,
        strict_validation: true,
        enabled_for_email: true,
        photo_url_cropped: '/assets/images/application/user/cropped.gif',
        photo_url_full: '/assets/images/application/user/full.gif',
        external_id: null
      };

      User.prototype.allowedMails = {
        'allowed_mails_custom': 'custom',
        'allowed_mails_private_notices': 'private_notices',
        'allowed_mails_public_notices': 'public_notices',
        'allowed_mails_daily_update': 'daily_update'
      };

      User.prototype.subscription = function() {
        return new P.models.users.Subscription({
          user_id: this.id,
          email: this.get('primary_email')
        });
      };

      User.prototype.formattedName = function(style) {
        var email, last_initial;
        if (this.get('full_name') == null) {
          email = this.get('primary_email');
          if (email == null) return _.escape('<unknown>');
          return email.substring(0, email.lastIndexOf('@'));
        }
        switch (style) {
          case 'full':
            return this.get('full_name');
          case 'short':
            return this.get('first_name');
          case 'medium':
            last_initial = (this.get('last_name') != null ? "" + (this.get('last_name')[0]) + "." : '');
            return "" + (this.get('first_name')) + " " + last_initial;
          default:
            return this.get('full_name');
        }
      };

      User.prototype.hasRole = function(role, group) {
        var _ref;
        if (group == null) group = P.community;
        return _.include((_ref = this.memberships["for"](group)) != null ? _ref.get('roles') : void 0, role);
      };

      return User;

    })(P.models.Model);
    return x.User.has(function() {
      this.hasMany('answers');
      this.hasMany('memberships');
      this.hasMany('labels');
      this.hasMany('categories', {
        collection: P.models.Groups,
        through: {
          source: 'category_memberships',
          name: 'category_memberships',
          collection: P.models.Memberships,
          where: function(model) {
            return model.answer.question.get('question').toLowerCase() === 'category';
          }
        }
      });
      this.hasMany('groups', {
        collection: P.models.Groups,
        through: 'memberships'
      });
      this.hasMany('attendances', {
        collection: P.models.Attendances
      });
      this.hasMany('discussions');
      this.hasMany('messages', {
        comparator: function(model) {
          return -model.get('created_at');
        }
      });
      this.hasMany('links');
      this.hasMany('posts', {
        collection: P.models.feeds.Posts
      });
      this.hasMany('tweets', {
        collection: P.models.feeds.Tweets
      });
      this.hasMany('ribbons');
      this.hasMany('consumer_tokens');
      this.hasMany('contacts', {
        collection: P.models.Users,
        through: {
          name: 'user_contacts',
          collection: P.models.UserContacts
        },
        source: 'contact'
      });
      this.hasMany('connections', {
        collection: P.models.Users,
        through: {
          name: 'user_connections',
          collection: P.models.UserContacts
        },
        source: 'contact'
      });
      return this.hasMany('user_contactees', {
        collection: P.models.UserContacts
      });
    });
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    return x.Category = (function(_super) {

      __extends(Category, _super);

      function Category() {
        var o;
        if ((o = Category.__super__.constructor.apply(this, arguments)) != null) {
          return o;
        }
      }

      return Category;

    })(P.models.Group);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    x.Affiliation = (function(_super) {

      __extends(Affiliation, _super);

      function Affiliation() {
        var o;
        if ((o = Affiliation.__super__.constructor.apply(this, arguments))) {
          return o;
        }
      }

      Affiliation.prototype.defaults = {
        parent_id: null,
        child_id: null,
        booth: null,
        level_name: null
      };

      Affiliation.prototype.url = function() {
        return P.url("/groups/" + (this.get('child_id')) + (Affiliation.__super__.url.call(this, {
          excludeSection: true
        })));
      };

      return Affiliation;

    })(P.models.Model);
    return x.Affiliation.has(function() {
      this.hasOne('parent', {
        model: P.models.Group
      });
      this.hasOne('child', {
        model: P.models.Group
      });
      return this.hasOne('level', {
        model: P.models.Label
      });
    });
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    return x.Affiliations = (function(_super) {

      __extends(Affiliations, _super);

      function Affiliations() {
        Affiliations.__super__.constructor.apply(this, arguments);
      }

      Affiliations.prototype.model = P.models.Affiliation;

      return Affiliations;

    })(P.models.Collection);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    return x.AllGroup = (function(_super) {

      __extends(AllGroup, _super);

      function AllGroup() {
        this.fragment = __bind(this.fragment, this);
        AllGroup.__super__.constructor.apply(this, arguments);
      }

      AllGroup.prototype.defaults = {
        name: 'All',
        friendly_name: 'All'
      };

      AllGroup.prototype.url = function() {
        throw new Error('AllGroup is abstract and should never be persisted.');
      };

      AllGroup.prototype.fragment = function() {
        return '#users';
      };

      return AllGroup;

    })(P.models.Model);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    return x.Announcement = (function(_super) {

      __extends(Announcement, _super);

      function Announcement() {
        var o;
        if ((o = Announcement.__super__.constructor.apply(this, arguments)) != null) {
          return o;
        }
      }

      return Announcement;

    })(P.models.Model);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    return x.Announcements = (function(_super) {

      __extends(Announcements, _super);

      Announcements.prototype.model = P.models.Announcement;

      function Announcements() {
        Announcements.__super__.constructor.apply(this, arguments);
        if (P.settings.env !== 'development') {
          this.enableAutoFetch({
            regularly: 15000
          });
        }
      }

      Announcements.prototype.url = function() {
        return '/announcements';
      };

      Announcements.prototype.unhide = function() {
        return this._hidden = false;
      };

      Announcements.prototype.hide = function() {
        this._hidden = true;
        return $.ajax("" + (this.url()) + "/hide", {
          type: 'PUT'
        });
      };

      Announcements.prototype.isHidden = function() {
        return !!this._hidden;
      };

      return Announcements;

    })(P.models.Collection);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    x.Answer = (function(_super) {

      __extends(Answer, _super);

      function Answer() {
        var o;
        if ((o = Answer.__super__.constructor.apply(this, arguments)) != null) {
          return o;
        }
      }

      return Answer;

    })(P.models.Model);
    return x.Answer.has(function() {
      this.hasOne('question', {
        scoped: false
      });
      this.hasMany('tags', {
        scoped: false
      });
      return this.hasMany('memberships', {
        scoped: false
      });
    });
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    return x.Answers = (function(_super) {

      __extends(Answers, _super);

      function Answers() {
        this.toQuestion = __bind(this.toQuestion, this);
        Answers.__super__.constructor.apply(this, arguments);
      }

      Answers.prototype.model = P.models.Answer;

      Answers.prototype.toQuestion = function(question) {
        return this.detect(function(a) {
          return a.get('question_id') === question.id;
        });
      };

      return Answers;

    })(P.models.Collection);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    return x.Attachment = (function(_super) {

      __extends(Attachment, _super);

      function Attachment() {
        var o;
        if ((o = Attachment.__super__.constructor.apply(this, arguments)) != null) {
          return o;
        }
      }

      return Attachment;

    })(P.models.Model);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    return x.Attachments = (function(_super) {

      __extends(Attachments, _super);

      function Attachments() {
        Attachments.__super__.constructor.apply(this, arguments);
      }

      Attachments.prototype.model = P.models.Attachment;

      return Attachments;

    })(P.models.Collection);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    return x.Attendance = (function(_super) {

      __extends(Attendance, _super);

      Attendance.prototype.urlBase = 'Membership';

      function Attendance() {
        this.isAttending = __bind(this.isAttending, this);
        var o;
        if ((o = Attendance.__super__.constructor.apply(this, arguments)) != null) {
          return o;
        }
      }

      Attendance.prototype.defaults = function() {
        return _.extend(Attendance.__super__.defaults.apply(this, arguments), {
          status: null,
          status_message: null
        });
      };

      Attendance.prototype.isAttending = function() {
        return _.include(['tentative', 'accepted', 'unresponded'], this.get('status'));
      };

      return Attendance;

    })(P.models.Membership);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    return x.Attendances = (function(_super) {

      __extends(Attendances, _super);

      function Attendances() {
        Attendances.__super__.constructor.apply(this, arguments);
      }

      Attendances.prototype.model = x.Attendance;

      return Attendances;

    })(x.Collection);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    x.Calendar = (function(_super) {

      __extends(Calendar, _super);

      function Calendar() {
        var o;
        if ((o = Calendar.__super__.constructor.apply(this, arguments)) != null) {
          return o;
        }
      }

      Calendar.prototype.initialize = function() {
        Calendar.__super__.initialize.apply(this, arguments);
        return this.meetings.searchOptions = _.extend(this.meetings.searchOptions || {}, {
          per_page: 999,
          classes: []
        });
      };

      return Calendar;

    })(P.models.Model);
    return x.Calendar.has(function() {
      this.hasMany('label_sets');
      this.hasOne('community');
      this.hasMany('meetings', {
        scoped: false
      });
      this.hasMany('labels', {
        through: 'meetings',
        inverseOf: 'group'
      });
      return this.hasOne('settings', {
        model: P.models.CalendarSettings
      });
    });
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    return x.CalendarSettings = (function(_super) {

      __extends(CalendarSettings, _super);

      function CalendarSettings() {
        var o;
        if ((o = CalendarSettings.__super__.constructor.apply(this, arguments)) != null) {
          return o;
        }
      }

      CalendarSettings.prototype.defaults = {
        meeting_length_max: null,
        meeting_length_min: null,
        restrict_locations_to_reserved: false
      };

      return CalendarSettings;

    })(P.models.Model);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    return x.Categories = (function(_super) {

      __extends(Categories, _super);

      function Categories() {
        Categories.__super__.constructor.apply(this, arguments);
      }

      Categories.prototype.model = x.Category;

      return Categories;

    })(P.models.Collection);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    return x.Communities = (function(_super) {

      __extends(Communities, _super);

      function Communities() {
        Communities.__super__.constructor.apply(this, arguments);
      }

      Communities.prototype.model = P.models.Community;

      return Communities;

    })(P.models.Collection);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    return x.CommunityStat = (function(_super) {

      __extends(CommunityStat, _super);

      function CommunityStat() {
        var o;
        if ((o = CommunityStat.__super__.constructor.apply(this, arguments)) != null) {
          return o;
        }
      }

      CommunityStat.prototype.label = function() {
        var _ref;
        return this.get('label') || ((_ref = this.get('name')) != null ? _ref.titleize() : void 0) || '';
      };

      return CommunityStat;

    })(P.models.Model);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    return x.CommunityStats = (function(_super) {

      __extends(CommunityStats, _super);

      function CommunityStats() {
        this.statFor = __bind(this.statFor, this);
        CommunityStats.__super__.constructor.apply(this, arguments);
      }

      CommunityStats.prototype.model = P.models.CommunityStat;

      CommunityStats.prototype.url = '/host/stats';

      CommunityStats.prototype.statFor = function(name) {
        return this.detect(function(stat) {
          return stat.get('name') === name;
        });
      };

      return CommunityStats;

    })(P.models.Collection);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    return x.ConsumerToken = (function(_super) {

      __extends(ConsumerToken, _super);

      function ConsumerToken() {
        var o;
        if ((o = ConsumerToken.__super__.constructor.apply(this, arguments)) != null) {
          return o;
        }
      }

      return ConsumerToken;

    })(P.models.Model);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    return x.ConsumerTokens = (function(_super) {

      __extends(ConsumerTokens, _super);

      function ConsumerTokens() {
        ConsumerTokens.__super__.constructor.apply(this, arguments);
      }

      ConsumerTokens.prototype.model = P.models.ConsumerToken;

      return ConsumerTokens;

    })(P.models.Collection);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    x.Datafeed = (function(_super) {

      __extends(Datafeed, _super);

      Datafeed.prototype.defaults = {
        description: '',
        service: ''
      };

      function Datafeed() {
        this._modelType = __bind(this._modelType, this);
        var o;
        if ((o = Datafeed.__super__.constructor.apply(this, arguments)) != null) {
          return o;
        }
      }

      Datafeed.prototype.initialize = function() {
        Datafeed.__super__.initialize.apply(this, arguments);
        this.bind('change:model_class', this._modelType);
        return this._modelType();
      };

      Datafeed.prototype.toggleStatus = function() {
        var _this = this;
        return $.ajax("" + (this.url()) + "/" + (this.get('enabled') ? 'disable' : 'enable'), {
          type: 'PUT',
          success: function() {
            return _this.fetch();
          }
        });
      };

      Datafeed.prototype.forceSync = function() {
        var _this = this;
        return $.ajax("" + (this.url()) + "/sync", {
          type: 'PUT',
          success: function() {
            return _this.fetch();
          }
        });
      };

      Datafeed.prototype.toJSON = function() {
        var _this = this;
        return _.reduce('description service enabled external_event_id feed_url\
        last_processed_at last_result mail_template_id model_class user_name\
        xslt import_mappings_attributes type auth_token password\
        '.split(/\s+/), (function(memo, prop) {
          memo[prop] = _this.get(prop);
          return memo;
        }), {});
      };

      Datafeed.prototype._modelType = function() {
        var _ref;
        return this.set({
          model_type: (_ref = this.get('model_class')) != null ? _ref.replace(/.*::/, '').toLowerCase().pluralize() : void 0
        });
      };

      return Datafeed;

    })(P.models.Model);
    return x.Datafeed.has(function() {
      this.hasMany('import_mappings');
      return this.hasProp('last_processed_at', function(val) {
        return new Date(val);
      });
    });
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    return x.Datafeeds = (function(_super) {

      __extends(Datafeeds, _super);

      function Datafeeds() {
        Datafeeds.__super__.constructor.apply(this, arguments);
      }

      Datafeeds.prototype.model = P.models.Datafeed;

      return Datafeeds;

    })(P.models.Collection);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    x.Discussion = (function(_super) {

      __extends(Discussion, _super);

      function Discussion() {
        this._messages = __bind(this._messages, this);
        this._to = __bind(this._to, this);
        var o;
        if ((o = Discussion.__super__.constructor.apply(this, arguments)) != null) {
          return o;
        }
      }

      Discussion.prototype.initialize = function() {
        var _this = this;
        Discussion.__super__.initialize.apply(this, arguments);
        this._messages();
        this._to();
        return _.each(['add', 'remove', 'reset'], function(event) {
          _this.messages.bind(event, _this._messages);
          return _this.messages.bind(event, _this._to);
        });
      };

      Discussion.prototype.hash = function() {
        return '#' + (this.get('private') ? 'inbox' : 'discussions');
      };

      Discussion.prototype.fragment = function() {
        return "" + (this.hash()) + "/" + this.id;
      };

      Discussion.prototype._to = function() {
        return this.to = this.get('private') ? this.participants : this.authors;
      };

      Discussion.prototype._messages = function() {
        var msg;
        msg = this.messages.last();
        return this.set({
          latest_created_at: msg != null ? msg.get('created_at') : void 0,
          latest_body: msg != null ? msg.get('body') : void 0,
          latest_user_id: msg != null ? msg.get('user_id') : void 0
        });
      };

      return Discussion;

    })(P.models.Model);
    return x.Discussion.has(function() {
      this.hasProp('created_at', function(val) {
        return new Date(val);
      });
      this.hasMany('authors', {
        collection: P.models.Users,
        scoped: false
      });
      this.hasMany('participants', {
        collection: P.models.Users,
        scoped: false
      });
      this.hasMany('groups_discussions', {
        scoped: false
      });
      this.hasMany('groups', {
        collection: P.models.Groups,
        through: 'groups_discussions',
        scoped: false
      });
      return this.hasMany('messages');
    });
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    return x.Discussions = (function(_super) {

      __extends(Discussions, _super);

      function Discussions() {
        Discussions.__super__.constructor.apply(this, arguments);
      }

      Discussions.prototype.model = P.models.Discussion;

      Discussions.prototype.comparator = function(model) {
        var _ref, _ref2;
        return -new Date((_ref = model.messages) != null ? (_ref2 = _ref.last()) != null ? _ref2.get('created_at') : void 0 : void 0).getTime();
      };

      return Discussions;

    })(P.models.Collection);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    x.Document = (function(_super) {

      __extends(Document, _super);

      function Document() {
        var o;
        if ((o = Document.__super__.constructor.apply(this, arguments)) != null) {
          return o;
        }
      }

      Document.prototype.defaults = {
        name: '',
        search_text: ''
      };

      return Document;

    })(P.models.Model);
    return x.Document.has(function() {
      return this.hasOne('author', {
        model: P.models.User
      });
    });
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    return x.Documents = (function(_super) {

      __extends(Documents, _super);

      function Documents() {
        Documents.__super__.constructor.apply(this, arguments);
      }

      Documents.prototype.model = P.models.Document;

      return Documents;

    })(x.Collection);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    return x.Events = (function(_super) {

      __extends(Events, _super);

      function Events() {
        Events.__super__.constructor.apply(this, arguments);
      }

      Events.prototype.model = P.models.Event;

      return Events;

    })(P.models.Collection);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.models.feeds', function(x) {
    return x.Post = (function(_super) {

      __extends(Post, _super);

      function Post() {
        var o;
        if ((o = Post.__super__.constructor.apply(this, arguments)) != null) {
          return o;
        }
      }

      return Post;

    })(P.models.Model);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.models.feeds', function(x) {
    return x.Posts = (function(_super) {

      __extends(Posts, _super);

      function Posts() {
        Posts.__super__.constructor.apply(this, arguments);
      }

      Posts.prototype.model = x.Post;

      return Posts;

    })(P.models.Collection);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.models.feeds', function(x) {
    x.Tweet = (function(_super) {

      __extends(Tweet, _super);

      function Tweet() {
        this.externalURL = __bind(this.externalURL, this);
        var o;
        if ((o = Tweet.__super__.constructor.apply(this, arguments)) != null) {
          return o;
        }
      }

      Tweet.prototype.externalURL = function() {
        return "http://twitter.com/" + (this.get('author_username'));
      };

      return Tweet;

    })(P.models.Model);
    _.each(['profile_url', 'display_name', 'avatar_url'], function(attr) {
      return x.Tweet.prototype["author_" + attr] = function() {
        var _ref;
        return (_ref = this.get('author')) != null ? _ref[attr] : void 0;
      };
    });
    return x.Tweet.has(function() {
      return this.hasMany('owners', {
        collection: P.models.Collection
      });
    });
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.models.feeds', function(x) {
    return x.Tweets = (function(_super) {

      __extends(Tweets, _super);

      function Tweets() {
        Tweets.__super__.constructor.apply(this, arguments);
      }

      Tweets.prototype.model = x.Tweet;

      return Tweets;

    })(P.models.Collection);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    return x.Groups = (function(_super) {

      __extends(Groups, _super);

      function Groups() {
        this.initialize = __bind(this.initialize, this);
        Groups.__super__.constructor.apply(this, arguments);
      }

      Groups.prototype.model = P.models.Group;

      Groups.prototype.initialize = function() {
        var _ref;
        return (_ref = this.searchOptions) != null ? _ref : this.searchOptions = {
          order: 'groups.memberships_count'
        };
      };

      return Groups;

    })(P.models.Collection);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    x.GroupsDiscussion = (function(_super) {

      __extends(GroupsDiscussion, _super);

      function GroupsDiscussion() {
        var o;
        if ((o = GroupsDiscussion.__super__.constructor.apply(this, arguments)) != null) {
          return o;
        }
      }

      return GroupsDiscussion;

    })(P.models.Model);
    return x.GroupsDiscussion.has(function() {
      this.hasOne('group');
      return this.hasOne('discussion');
    });
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    return x.GroupsDiscussions = (function(_super) {

      __extends(GroupsDiscussions, _super);

      function GroupsDiscussions() {
        GroupsDiscussions.__super__.constructor.apply(this, arguments);
      }

      GroupsDiscussions.prototype.model = P.models.GroupsDiscussion;

      return GroupsDiscussions;

    })(P.models.Collection);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    x.Import = (function(_super) {

      __extends(Import, _super);

      Import.prototype.defaults = {
        source: 'File',
        mode: ''
      };

      function Import() {
        this._modelType = __bind(this._modelType, this);
        var o;
        if ((o = Import.__super__.constructor.apply(this, arguments)) != null) {
          return o;
        }
      }

      Import.prototype.initialize = function() {
        Import.__super__.initialize.apply(this, arguments);
        this.bind('change:model_class', this._modelType);
        return this._modelType();
      };

      Import.prototype.toJSON = function() {
        var _this = this;
        return _.reduce('source mode created_at finished_at mail_template_id result\
        updated_at model_class import_mappings_attributes attachment_ids\
        '.split(/\s+/), (function(memo, attr) {
          memo[attr] = _this.get(attr);
          return memo;
        }), {});
      };

      Import.prototype._modelType = function() {
        var _ref;
        return this.set({
          model_type: (_ref = this.get('model_class')) != null ? _ref.replace(/.*::/, '').toLowerCase().pluralize() : void 0
        });
      };

      return Import;

    })(P.models.Model);
    return x.Import.has(function() {
      this.hasMany('attachments');
      this.hasMany('import_mappings');
      return this.hasProp('finished_at', function(val) {
        return new Date(val);
      });
    });
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    return x.ImportMapping = (function(_super) {

      __extends(ImportMapping, _super);

      function ImportMapping() {
        var o;
        if ((o = ImportMapping.__super__.constructor.apply(this, arguments)) != null) {
          return o;
        }
      }

      ImportMapping.prototype.defaults = {
        from_column: '',
        to_column: ''
      };

      ImportMapping.prototype.fromColumnLabel = function() {
        var _ref;
        return (_ref = this.get('from_column')) != null ? _ref.replace(/\//, ' ').humanize().titleize() : void 0;
      };

      return ImportMapping;

    })(P.models.Model);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    return x.ImportMappings = (function(_super) {

      __extends(ImportMappings, _super);

      function ImportMappings() {
        ImportMappings.__super__.constructor.apply(this, arguments);
      }

      ImportMappings.prototype.model = P.models.ImportMapping;

      return ImportMappings;

    })(P.models.Collection);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    return x.Imports = (function(_super) {

      __extends(Imports, _super);

      function Imports() {
        Imports.__super__.constructor.apply(this, arguments);
      }

      Imports.prototype.model = P.models.Import;

      return Imports;

    })(P.models.Collection);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    x.Label = (function(_super) {

      __extends(Label, _super);

      function Label() {
        var o;
        if ((o = Label.__super__.constructor.apply(this, arguments)) != null) {
          return o;
        }
      }

      Label.prototype.defaults = {
        name: '',
        color: null
      };

      Label.prototype.url = function() {
        return P.url("/label_sets/" + (this.get('label_set_id')) + (Label.__super__.url.call(this, {
          excludeSection: true
        })));
      };

      return Label;

    })(P.models.Model);
    return x.Label.has(function() {
      return this.hasOne('label_set');
    });
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    x.LabelSet = (function(_super) {

      __extends(LabelSet, _super);

      function LabelSet() {
        var o;
        if ((o = LabelSet.__super__.constructor.apply(this, arguments)) != null) {
          return o;
        }
      }

      LabelSet.prototype.defaults = {
        name: ''
      };

      LabelSet.prototype.class_id = function() {
        return this.get('name').underscore();
      };

      return LabelSet;

    })(P.models.Model);
    return x.LabelSet.has(function() {
      return this.hasMany('labels');
    });
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    return x.LabelSets = (function(_super) {

      __extends(LabelSets, _super);

      function LabelSets() {
        LabelSets.__super__.constructor.apply(this, arguments);
      }

      LabelSets.prototype.model = P.models.LabelSet;

      return LabelSets;

    })(P.models.Collection);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    return x.Labels = (function(_super) {

      __extends(Labels, _super);

      function Labels() {
        Labels.__super__.constructor.apply(this, arguments);
      }

      Labels.prototype.model = P.models.Label;

      return Labels;

    })(P.models.Collection);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    return x.Link = (function(_super) {

      __extends(Link, _super);

      function Link() {
        var o;
        if ((o = Link.__super__.constructor.apply(this, arguments)) != null) {
          return o;
        }
      }

      return Link;

    })(P.models.Model);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    return x.Links = (function(_super) {

      __extends(Links, _super);

      function Links() {
        this.withoutURL = __bind(this.withoutURL, this);
        this.withURL = __bind(this.withURL, this);
        Links.__super__.constructor.apply(this, arguments);
      }

      Links.prototype.model = P.models.Link;

      Links.prototype.withURL = function(matches) {
        var links;
        matches = _.flatten([matches]);
        links = this.select(function(link) {
          return (link.get('url') || '').search(matches) > -1;
        });
        return new x.Links(links);
      };

      Links.prototype.withoutURL = function(matches) {
        var links;
        matches = _.flatten([matches]);
        links = this.select(function(link) {
          return (link.get('url') || '').search(matches) === -1;
        });
        return new x.Links(links);
      };

      return Links;

    })(P.models.Collection);
  });

}).call(this);

(function() {

  P.namespace('P.models', function(x) {
    return x.Locales = (function() {

      function Locales() {
        this.locale = I18n.locale;
        moment.lang(this.locale);
        this.translations || (this.translations = {});
      }

      Locales.prototype.defaultLocale = I18n.defaultLocale;

      Locales.prototype.translations = I18n.translations;

      Locales.prototype.addTranslations = function(locale, translations) {
        var _base;
        (_base = this.translations)[locale] || (_base[locale] = {});
        return _.extend(this.translations[locale], translations);
      };

      Locales.prototype.translate = function(key, options) {
        var k, value, _i, _len, _results;
        if (options == null) options = {};
        if (_.isString(key)) {
          options["default"] || (options["default"] = key.humanize(false));
          key = this._keyToArray(options.scope).concat(this._keyToArray(key));
          value = this._lookup(key, options["default"]);
          if (options.pluralize || !_.isString(value) && value) {
            value = this._pluralize(value, options.count);
          }
          if (_.isString(value)) value = this._interpolate(value, options);
          return value;
        } else {
          _results = [];
          for (_i = 0, _len = key.length; _i < _len; _i++) {
            k = key[_i];
            _results.push(this.translate(k, options));
          }
          return _results;
        }
      };

      Locales.prototype.t = Locales.prototype.translate;

      Locales.prototype._locale = function() {
        return this.locale || this.defaultLocale;
      };

      Locales.prototype._lookup = function(keys, defaults) {
        var k, value, _i, _len;
        value = this.translations[this._locale()];
        defaults = _.isString(defaults) ? [defaults] : defaults || [];
        for (_i = 0, _len = keys.length; _i < _len; _i++) {
          k = keys[_i];
          value = value && value[k];
        }
        if (value != null) {
          return value;
        } else {
          return defaults.length && defaults[0];
        }
      };

      Locales.prototype._interpolatePattern = /%\{([^}]+)\}/g;

      Locales.prototype._interpolate = function(str, vars) {
        return str.replace(this._interpolatePattern, function() {
          if (_.isUndefined(vars[arguments[1]])) {
            return arguments[0];
          } else {
            return vars[arguments[1]];
          }
        });
      };

      Locales.prototype._pluralize = function(value, count) {
        if (count === 1) {
          return value.one || value;
        } else {
          return value.other || value.pluralize();
        }
      };

      Locales.prototype._keyToArray = function(key) {
        if (!key) return [];
        if (!_.isString(key)) return key;
        return key.split('.');
      };

      return Locales;

    })();
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    return x.Location = (function(_super) {

      __extends(Location, _super);

      function Location() {
        this.initialize = __bind(this.initialize, this);
        var o;
        if ((o = Location.__super__.constructor.apply(this, arguments)) != null) {
          return o;
        }
      }

      Location.prototype.initialize = function() {
        var _this = this;
        Location.__super__.initialize.apply(this, arguments);
        this.set('name_with_capacity', this.name_with_capacity());
        return this.bind('change', function(model) {
          return _this.set('name_with_capacity', _this.name_with_capacity());
        });
      };

      Location.prototype.defaults = {
        name: '',
        capacity: null,
        reservable: false,
        managed: false
      };

      Location.prototype.name_with_capacity = function() {
        if (this.get('capacity') != null) {
          return this.get('name') + ' (' + this.get('capacity') + ')';
        } else {
          return this.get('name');
        }
      };

      return Location;

    })(P.models.Model);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    return x.Locations = (function(_super) {

      __extends(Locations, _super);

      function Locations() {
        Locations.__super__.constructor.apply(this, arguments);
      }

      Locations.prototype.model = x.Location;

      return Locations;

    })(x.Collection);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    x.Meeting = (function(_super) {

      __extends(Meeting, _super);

      Meeting.prototype.defaults = {
        name: '',
        private: 0,
        location_name: null,
        location_id: null,
        time_zone_offset: 0
      };

      function Meeting() {
        this._offset = __bind(this._offset, this);
        var o;
        if ((o = Meeting.__super__.constructor.apply(this, arguments)) != null) {
          return o;
        }
      }

      Meeting.prototype.initialize = function() {
        var _this = this;
        Meeting.__super__.initialize.apply(this, arguments);
        return _.each(['starts_at', 'ends_at'], function(prop) {
          _this.set(prop + '_local', _this._offset(_this.get(prop)));
          _this.bind('change:' + prop, function(model, val) {
            return _this.set(prop + '_local', _this._offset(val));
          });
          return _this.bind('change:' + prop + '_local', function(model, val) {
            return _this.set(prop, _this._offset(val, {
              remove: true
            }));
          });
        });
      };

      Meeting.prototype.hasLabel = function(id) {
        return this.labels.any(function(l) {
          return l.id === id;
        });
      };

      Meeting.prototype._offset = function(timestamp, options) {
        var offset;
        if (timestamp == null) return null;
        _.defaults(options || (options = {}), {
          remove: false
        });
        if (timestamp instanceof Date) timestamp = timestamp.getTime();
        offset = (moment(timestamp).zone() * 60 + this.get('time_zone_offset')) * 1000;
        return new Date(timestamp + (options.remove ? -offset : offset));
      };

      return Meeting;

    })(P.models.Group);
    return x.Meeting.has(function() {
      this.hasOne('calendar', {
        inverseOf: 'group'
      });
      this.hasOne('location', {
        inverseOf: 'group'
      });
      this.hasMany('labels', {
        inverseOf: 'group'
      });
      return this.hasOne('community', {
        inverseOf: 'group'
      });
    });
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    return x.Meetings = (function(_super) {

      __extends(Meetings, _super);

      function Meetings() {
        this._with = __bind(this._with, this);
        this.publicOnly = __bind(this.publicOnly, this);
        this.privateOnly = __bind(this.privateOnly, this);
        this.public = __bind(this.public, this);
        this.private = __bind(this.private, this);
        Meetings.__super__.constructor.apply(this, arguments);
      }

      Meetings.prototype.model = x.Meeting;

      Meetings.prototype.private = function() {
        return this._with({
          private: 1
        });
      };

      Meetings.prototype.public = function() {
        return this._with({
          private: 0
        });
      };

      Meetings.prototype.from = function(meetings) {
        var _this = this;
        return new x.Meetings(meetings.filter(function(model) {
          return _this.get(model.id) != null;
        }));
      };

      Meetings.prototype.byTime = function() {
        return this._byTime || (this._byTime = this.subgroups({
          groupBy: function(model) {
            return new Date(model.get('starts_at_local'));
          },
          comparator: function(model) {
            return model.get('starts_at_local');
          }
        }));
      };

      Meetings.prototype.byDay = function() {
        return this._byDay || (this._byDay = this.subgroups({
          groupBy: function(model) {
            var val;
            if (val = moment(model.get('starts_at_local'))) {
              return moment([val.year(), val.month(), val.date()])["native"]();
            }
          },
          comparator: function(model) {
            return model.get('starts_at_local');
          }
        }));
      };

      Meetings.prototype.privateOnly = function() {
        return this.searchOptions["with"].private === 1;
      };

      Meetings.prototype.publicOnly = function() {
        return this.searchOptions["with"].private === 0;
      };

      Meetings.prototype._with = function(withParams) {
        if (withParams == null) withParams = {};
        return new x.Meetings([], {
          searchOptions: {
            "with": withParams,
            classes: ['Groups::Meetings::Meeting']
          }
        });
      };

      return Meetings;

    })(x.Collection);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    return x.Memberships = (function(_super) {

      __extends(Memberships, _super);

      function Memberships() {
        this.withoutRibbons = __bind(this.withoutRibbons, this);
        this.build = __bind(this.build, this);
        Memberships.__super__.constructor.apply(this, arguments);
      }

      Memberships.prototype.model = x.Membership;

      Memberships.prototype.build = function(attrs) {
        var meeting, membership;
        if (attrs == null) attrs = {};
        _.extend(attrs, {
          group_id: this.group.id,
          group: this.group
        });
        meeting = this.scope instanceof P.models.Meeting;
        membership = meeting ? new P.models.Attendance(attrs) : new P.models.Membership(attrs);
        membership.collection = this;
        return membership;
      };

      Memberships.prototype["for"] = function(groupOrUser) {
        return this.detect(function(m) {
          return m.isFor(groupOrUser);
        });
      };

      Memberships.prototype.speakers = function() {
        return new x.Memberships(this.filter(function(membership) {
          var _ref;
          return (_ref = membership.ribbon) != null ? _ref.isSpeaker() : void 0;
        }));
      };

      Memberships.prototype.withoutRibbons = function() {
        return this.reject(function(membership) {
          return membership.ribbon;
        });
      };

      return Memberships;

    })(x.Collection);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    x.Message = (function(_super) {

      __extends(Message, _super);

      Message.prototype.defaults = {
        body: null
      };

      function Message() {
        var o;
        if ((o = Message.__super__.constructor.apply(this, arguments)) != null) {
          return o;
        }
      }

      Message.prototype.fragment = function() {
        return this.discussion.fragment();
      };

      Message.prototype.url = function() {
        return P.url("/discussions/" + (this.get('discussion_id')) + (Message.__super__.url.call(this, {
          excludeSection: true
        })));
      };

      return Message;

    })(P.models.Model);
    return x.Message.has(function() {
      this.hasOne('user');
      this.hasOne('discussion', {
        model: P.models.Discussion
      });
      return this.hasProp('created_at', function(val) {
        return new Date(val);
      });
    });
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    return x.Messages = (function(_super) {

      __extends(Messages, _super);

      function Messages() {
        Messages.__super__.constructor.apply(this, arguments);
      }

      Messages.prototype.model = P.models.Message;

      Messages.prototype.comparator = function(model) {
        return new Date(model.get('created_at'));
      };

      return Messages;

    })(P.models.Collection);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.models.messages', function(x) {
    return x.Mail = (function(_super) {

      __extends(Mail, _super);

      Mail.prototype.defaults = {
        template_id: null
      };

      function Mail() {
        var o;
        if ((o = Mail.__super__.constructor.apply(this, arguments)) != null) {
          return o;
        }
      }

      return Mail;

    })(P.models.Model);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    x.Organization = (function(_super) {

      __extends(Organization, _super);

      function Organization() {
        var o;
        if ((o = Organization.__super__.constructor.apply(this, arguments)) != null) {
          return o;
        }
      }

      Organization.prototype.initialize = function() {
        var _this = this;
        Organization.__super__.initialize.apply(this, arguments);
        return this.labels.tags = this.labels.subset({
          collection: P.models.Labels,
          filter: function(model) {
            var _ref, _ref2;
            return ((_ref = model.label_set) != null ? (_ref2 = _ref.get('name')) != null ? _ref2.toLowerCase() : void 0 : void 0) === 'tags';
          }
        });
      };

      Organization.prototype.validate = function(attrs) {
        if (attrs.name != null) {
          if (attrs.name === 'FAILED:isUnique') {
            return new P.errors.ValidationError({
              messages: ['is already taken'],
              attribute: 'name'
            });
          }
        }
      };

      Organization.prototype.defaults = {
        name: null,
        level: null
      };

      return Organization;

    })(P.models.Group);
    return x.Organization.has(function() {
      this.hasMany('labels', {
        inverseOf: 'group'
      });
      return this.hasOne('level', {
        model: P.models.Label,
        inverseOf: 'group'
      });
    });
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    return x.Organizations = (function(_super) {

      __extends(Organizations, _super);

      function Organizations() {
        Organizations.__super__.constructor.apply(this, arguments);
      }

      Organizations.prototype.model = P.models.Organization;

      return Organizations;

    })(P.models.Collection);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    return x.PasswordReset = (function(_super) {

      __extends(PasswordReset, _super);

      function PasswordReset() {
        PasswordReset.__super__.constructor.apply(this, arguments);
      }

      PasswordReset.prototype.defaults = {
        email: ''
      };

      PasswordReset.prototype.url = '/session/reset_password';

      return PasswordReset;

    })(P.models.Model);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    x.Question = (function(_super) {

      __extends(Question, _super);

      Question.prototype.defaults = {
        question: 'Tags',
        input_type: 'auto_suggest',
        active: true,
        tag_list: null
      };

      function Question() {
        var o;
        if ((o = Question.__super__.constructor.apply(this, arguments)) != null) {
          return o;
        }
      }

      return Question;

    })(P.models.Model);
    return x.Question.has(function() {
      return this.hasMany('tags', {
        scoped: false
      });
    });
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    return x.Questions = (function(_super) {

      __extends(Questions, _super);

      function Questions() {
        Questions.__super__.constructor.apply(this, arguments);
      }

      Questions.prototype.model = P.models.Question;

      Questions.prototype.url = function(extra) {
        return P.url('/questions', this, {
          extra: extra
        });
      };

      return Questions;

    })(P.models.Collection);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    x.Ribbon = (function(_super) {

      __extends(Ribbon, _super);

      function Ribbon() {
        this.isSpeaker = __bind(this.isSpeaker, this);
        var o;
        if ((o = Ribbon.__super__.constructor.apply(this, arguments)) != null) {
          return o;
        }
      }

      Ribbon.prototype.isSpeaker = function() {
        return /^speaker$/i.test(this.get('name'));
      };

      return Ribbon;

    })(P.models.Model);
    return x.Ribbon.has(function() {
      return this.hasMany('memberships');
    });
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    return x.Ribbons = (function(_super) {

      __extends(Ribbons, _super);

      function Ribbons() {
        this.speaker = __bind(this.speaker, this);
        Ribbons.__super__.constructor.apply(this, arguments);
      }

      Ribbons.prototype.model = P.models.Ribbon;

      Ribbons.prototype.speaker = function() {
        return this.detect(function(r) {
          return r.get('name').toLowerCase() === 'speaker';
        });
      };

      return Ribbons;

    })(P.models.Collection);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    x.Session = (function(_super) {

      __extends(Session, _super);

      Session.prototype.defaults = {
        logged_in: false,
        email: '',
        password: ''
      };

      Session.prototype.url = '/session';

      function Session() {
        var o;
        if ((o = Session.__super__.constructor.apply(this, arguments)) != null) {
          return o;
        }
      }

      Session.prototype.initialize = function() {
        var _this = this;
        Session.__super__.initialize.apply(this, arguments);
        this.user || (this.user = new x.User({
          anonymous: true
        }));
        return this.bind('change', function() {
          if (_this.hasChanged('logged_in')) return _this.notify();
        });
      };

      Session.prototype.notify = function() {
        var loggedIn,
          _this = this;
        loggedIn = this.get('logged_in');
        return _.each([loggedIn && 'login' || 'logout', 'loginout'], function(event) {
          return _this.trigger(event, _this, loggedIn);
        });
      };

      Session.prototype.signOut = function(cb) {
        return this.save({
          id: 0,
          logged_in: false,
          email: false,
          password: false
        }, {
          success: cb
        });
      };

      Session.prototype.destroy = function() {
        this.id = 1;
        return Session.__super__.destroy.apply(this, arguments);
      };

      Session.prototype.toJSON = function() {
        return _.reduce(this.attributes, function(memo, v, k) {
          if (!_.isObject(v)) memo[k] = v;
          return memo;
        }, {});
      };

      return Session;

    })(P.models.Model);
    return x.Session.has(function() {
      return this.hasOne('user');
    });
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };

  P.namespace('P.models.status', function(x) {
    return x.Checker = (function() {

      function Checker() {
        this._update = __bind(this._update, this);
        this._check = __bind(this._check, this);        this.status = new x.Status;
        this.status.bind('change', this._update);
        this.updater = new x.Updater;
      }

      Checker.prototype.start = function() {
        var interval;
        if (!this.status.isCheckable()) return;
        interval = 15000;
        return this._checker = window.setInterval(this._check, interval);
      };

      Checker.prototype.stop = function() {
        if (this._checker) return window.clearInterval(this._checker);
      };

      Checker.prototype._check = function() {
        return this.status.fetch();
      };

      Checker.prototype._update = function() {
        if (this.status.areAssetsStale()) {
          this.stop();
          return this.updater.reload();
        } else if (this.status.isAppStale()) {
          return this.updater.notify();
        }
      };

      return Checker;

    })();
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.models.status', function(x) {
    return x.Status = (function(_super) {

      __extends(Status, _super);

      function Status() {
        var o;
        if ((o = Status.__super__.constructor.apply(this, arguments)) != null) {
          return o;
        }
        this.revision = P.revision;
        this.assets = _.reduce({
          script: 'src',
          link: 'href'
        }, this._buildAssetList, []);
      }

      Status.prototype.url = function() {
        var params;
        params = _.reduce({
          revision: this.revision,
          assets: this.assets
        }, function(p, v, k) {
          if (!_.isEmpty(v)) p[k] = v;
          return p;
        }, {});
        return "/s?" + ($.param(params));
      };

      Status.prototype.isAppStale = function() {
        return this.get('app') === false;
      };

      Status.prototype.areAssetsStale = function() {
        return this.get('assets') === false;
      };

      Status.prototype.isCheckable = function() {
        return false;
        return !_.isEmpty(this.revision);
      };

      Status.prototype._buildAssetList = function(assets, pathAttr, assetType) {
        var assetPathMatcher, pathname;
        assetPathMatcher = /pathable\.com/;
        pathname = function(url) {
          var a, p;
          a = document.createElement('a');
          a.href = url;
          p = a.pathname;
          if (p[0] === '/') {
            return p;
          } else {
            return "/" + p;
          }
        };
        return assets.concat(_($(assetType)).chain().filter(function(s) {
          return assetPathMatcher.test($(s).attr(pathAttr));
        }).map(function(s) {
          return pathname($(s).attr(pathAttr));
        }).value());
      };

      return Status;

    })(P.models.Model);
  });

}).call(this);

(function() {

  P.namespace('P.models.status', function(x) {
    return x.Updater = (function() {

      function Updater() {}

      Updater.prototype.notify = function() {
        return P.layout.flash.show({
          message: P.localizer.t('update_imminent'),
          "class": 'info'
        });
      };

      Updater.prototype.reload = function() {
        window.alert(P.localizer.t('reload_required'));
        return window.location.reload(true);
      };

      return Updater;

    })();
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    return x.Tag = (function(_super) {

      __extends(Tag, _super);

      Tag.prototype.urlBase = 'groups';

      function Tag() {
        var o;
        if ((o = Tag.__super__.constructor.apply(this, arguments)) != null) {
          return o;
        }
      }

      return Tag;

    })(P.models.Group);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    return x.Tags = (function(_super) {

      __extends(Tags, _super);

      function Tags() {
        this.initialize = __bind(this.initialize, this);
        Tags.__super__.constructor.apply(this, arguments);
      }

      Tags.prototype.model = P.models.Tag;

      Tags.prototype.initialize = function() {
        var _ref;
        return (_ref = this.searchOptions) != null ? _ref : this.searchOptions = {
          order: 'groups.memberships_count'
        };
      };

      return Tags;

    })(P.models.Collection);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    return x.Templates = (function(_super) {

      __extends(Templates, _super);

      function Templates() {
        Templates.__super__.constructor.apply(this, arguments);
      }

      Templates.prototype.model = P.models.Template;

      Templates.prototype.byRole = function(role) {
        return new x.Templates(this.select(function(t) {
          return t.get('role') === role;
        }));
      };

      return Templates;

    })(P.models.Collection);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    return x.Theme = (function(_super) {

      __extends(Theme, _super);

      function Theme() {
        var o;
        if ((o = Theme.__super__.constructor.apply(this, arguments)) != null) {
          return o;
        }
      }

      return Theme;

    })(P.models.Model);
  });

}).call(this);

(function() {

  P.namespace('P.models.tracking', function(x) {
    return x.Chart = (function() {

      function Chart() {
        this.platform = new window.Mixpanel.Platform(P.settings.mixpanel.api_key, P.community.settings.get('mp_bucket_secret'), P.community.id);
      }

      Chart.prototype.line = function(el) {
        if (el == null) return false;
        return this.platform.create_line_chart(el, ['attendee search'], {
          drilldown: true
        });
      };

      return Chart;

    })();
  });

}).call(this);

(function() {

  P.namespace('P.models.tracking', function(x) {
    return x.Tracker = (function() {

      function Tracker() {
        var _ref;
        window.mpq = [];
        this.init(P.settings.mixpanel.token);
        if (P.development) {
          this.setConfig({
            test: true
          });
        }
        if (((_ref = P.logger) != null ? _ref.levelWeight : void 0) <= 1) {
          this.setConfig({
            debug: true
          });
        }
      }

      Tracker.prototype.start = function() {
        var mp, s;
        mp = document.createElement('script');
        mp.type = 'text/javascript';
        mp.async = true;
        mp.src = 'http://api.mixpanel.com/site_media/js/api/mixpanel.js';
        s = document.getElementsByTagName('script')[0];
        return s.parentNode.insertBefore(mp, s);
      };

      Tracker.prototype.init = function(token) {
        return window.mpq.push(['init', token]);
      };

      Tracker.prototype.setConfig = function(config) {
        return window.mpq.push(['set_config', config]);
      };

      Tracker.prototype.track = function(event, properties) {
        if (properties == null) properties = {};
        _.extend(properties, {
          bucket: P.community.id
        });
        return window.mpq.push(['track', event, properties]);
      };

      return Tracker;

    })();
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    x.UserContact = (function(_super) {

      __extends(UserContact, _super);

      function UserContact() {
        var o;
        if ((o = UserContact.__super__.constructor.apply(this, arguments)) != null) {
          return o;
        }
      }

      UserContact.prototype.defaults = {
        user_id: null,
        contact_id: null,
        notes: null
      };

      UserContact.prototype.isMarked = function() {
        return this.get('class_name') === 'UserContacts::MarkedUserContact';
      };

      UserContact.prototype.fragment = function() {
        return "#contacts/" + this.id;
      };

      UserContact.prototype.url = function() {
        return P.url("/users/" + (this.get('user_id')) + (UserContact.__super__.url.call(this, {
          excludeSection: true
        })));
      };

      return UserContact;

    })(P.models.Model);
    return x.UserContact.has(function() {
      this.hasOne('user');
      return this.hasOne('contact', {
        model: P.models.User
      });
    });
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    return x.UserContacts = (function(_super) {

      __extends(UserContacts, _super);

      function UserContacts() {
        UserContacts.__super__.constructor.apply(this, arguments);
      }

      UserContacts.prototype.model = P.models.UserContact;

      UserContacts.prototype.comparator = function(userContact) {
        var _ref;
        return (_ref = userContact.contact) != null ? _ref.formattedName('full') : void 0;
      };

      return UserContacts;

    })(P.models.Collection);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.models', function(x) {
    return x.Users = (function(_super) {

      __extends(Users, _super);

      function Users() {
        Users.__super__.constructor.apply(this, arguments);
      }

      Users.prototype.model = P.models.User;

      return Users;

    })(P.models.Collection);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.models.users', function(x) {
    return x.Subscription = (function(_super) {

      __extends(Subscription, _super);

      Subscription.prototype.defaults = {
        id: 1,
        user_id: null,
        email: null,
        enabled: true
      };

      function Subscription() {
        var o;
        if ((o = Subscription.__super__.constructor.apply(this, arguments)) != null) {
          return o;
        }
      }

      return Subscription;

    })(P.models.Model);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };

  P.namespace('P.views.shared', function(x) {
    var Template;
    x.Template = Template = (function() {

      function Template() {
        this.print = __bind(this.print, this);        this.__p = [];
      }

      Template.prototype.print = function() {
        return this.__p.push.apply(this.__p, arguments);
      };

      Template.prototype.toString = function() {
        return this.__p.join('');
      };

      return Template;

    })();
    _.extend(x.Template, {
      settings: {
        evaluate: /<%([\s\S]+?)%>/g,
        interpolate: /<%=([\s\S]+?)%>/g
      }
    });
    return x.template = function(str, data, tmpl) {
      var format, func, settings, t;
      settings = x.Template.settings;
      str = 'var __p=this.__p,print=this.print;' + 'with(obj||{}){__p.push(\'' + str.replace(/[\\]/g, '\\\\').replace(/'/g, "\\'").replace(settings.interpolate, function(match, code) {
        return "'," + code.replace(/\\'/g, "'") + ",'";
      }).replace(settings.evaluate || null, function(match, code) {
        return "');" + code.replace(/\\'/g, "'").replace(/[\r\n\t]/g, ' ') + "__p.push('";
      }).replace(/\r/g, '\\r').replace(/\n/g, '\\n').replace(/\t/g, '\\t') + "');}";
      format = function(e) {
        e.message += ("\n\ntemplate:\n" + str + "\n") + (e.stack ? "\nstack:\n" + e.stack : '');
        return e;
      };
      try {
        t = new Function('obj', str);
      } catch (e) {
        throw format(e);
      }
      func = function(data, tmpl) {
        var _tmpl;
        try {
          _tmpl = tmpl || new Template();
          t.call(_tmpl, data);
          if (tmpl) {
            return '';
          } else {
            return _tmpl.toString();
          }
        } catch (e) {
          throw format(e);
        }
      };
      if (data) {
        return func(data, tmpl);
      } else {
        return func;
      }
    };
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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 = Array.prototype.slice;

  P.namespace('P.views.shared', function(x) {
    return Backbone.List.prototype.itemType = x.View = (function(_super) {

      __extends(View, _super);

      View.prototype.events = function() {
        return {};
      };

      View.prototype.className = function() {
        return '';
      };

      View.prototype.login = function(session) {};

      View.prototype.logout = function(session) {};

      View.prototype.loginout = function(session, loggedIn) {};

      function View() {
        this.render = __bind(this.render, this);
        this.renderTemplate = __bind(this.renderTemplate, this);
        this.itemValues = __bind(this.itemValues, this);        if (!(this.applyFeatures != null)) {
          throw new Error("Oops, looks like a constructor\nfunction was called without new?");
        }
        this.applyFeatures();
        View.__super__.constructor.apply(this, arguments);
        this.$el = $(this.el);
      }

      View.prototype.initialize = function() {
        var _ref, _ref2,
          _this = this;
        View.__super__.initialize.apply(this, arguments);
        if (this.options.templateName) {
          this.templateName = this.options.templateName;
        }
        this.templateOptions = this.options.templateOptions || {
          exclude: []
        };
        this.parent = this.options.parent;
        if ((this.constructor.prototype.config != null) && (this.options.config != null)) {
          $.extend(true, (this.config || (this.config = {})), this.options.config);
        }
        if (this.model != null) $(this.el).attr('itemscope', 'itemscope');
        if ((_ref = this.model) != null) _ref.bind('change', this.itemValues);
        return (_ref2 = P.session) != null ? _ref2.bind('all', function() {
          var args, event;
          event = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
          if (event === 'login' || event === 'logout' || event === 'loginout') {
            return _this[event].apply(_this, args);
          }
        }) : void 0;
      };

      View.prototype.itemValues = function() {
        var _this = this;
        if (!(this.el && this.model)) return;
        return $(this.el).properties().each(function(i, el) {
          if (el === _this.el || (el = $(el)).itemScope()) return;
          return el.itemValue(_this.model.get(el.itemProp()[0]));
        });
      };

      View.prototype.applyFeatures = function() {
        var _this = this;
        if (this.features == null) return false;
        return _.each(this.features, function(feature) {
          _.extend(_this, feature.prototype);
          if (feature.prototype.register != null) {
            return feature.prototype.register(_this);
          }
        });
      };

      View.prototype.goto = function(target) {
        if (target instanceof P.models.Model) {
          return window.location.href = target.fragment();
        } else {
          return window.location.href = target;
        }
      };

      View.prototype.focus = function(selector) {
        return this.$(selector).focus();
      };

      View.prototype.append = function(selector, view) {
        var _ref;
        if (view == null) {
          _ref = [this.el, selector], selector = _ref[0], view = _ref[1];
        }
        if (view == null) return false;
        return this.$(selector).append(this._view(view));
      };

      View.prototype.prepend = function(selector, view) {
        var _ref;
        if (view == null) {
          _ref = [this.el, selector], selector = _ref[0], view = _ref[1];
        }
        if (view == null) return false;
        return this.$(selector).prepend(this._view(view));
      };

      View.prototype.replaceWith = function(selector, view) {
        if (view == null) return false;
        return this.$(selector).replaceWith(this._view(view));
      };

      View.prototype.replaceAll = function(selector, view) {
        if (!(view instanceof Backbone.View)) return false;
        view.el = this.$(selector)[0];
        view.render();
        return view.delegateEvents();
      };

      View.prototype.html = function(selector, view) {
        if (view == null) return false;
        return this.$(selector).html(this._view(view));
      };

      View.prototype.template = function(path, options) {
        if (options == null) options = {};
        try {
          if (path.match(/^\.|\#/)) {
            return _.template($(path).html(), options);
          } else {
            return JST[path](options);
          }
        } catch (e) {
          P.logger.error("Error building template: '" + path + "'.  Does it exists?\n" + e.message);
          return '';
        }
      };

      View.prototype.renderTemplate = function() {
        var options;
        if (this.templateName != null) {
          P.logger.debug("Building template " + this.templateName);
          options = _.extend(this.templateOptions || {}, {
            view: this,
            model: this.model,
            collection: this.collection,
            locales: P.community.locales,
            options: this.templateOptions
          });
          return $(this.el).html(innerShiv(this.template(this.templateName, options), false));
        }
      };

      View.prototype.use = function(thing) {
        if (thing instanceof P.models.Collection) {
          this.collection = thing;
          return this.render();
        } else if (thing instanceof P.models.Model) {
          this.model = thing;
          return this.render();
        } else {
          throw new Error("Can only 'use' a P.models.Model or P.models.Collection. Tried with " + thing);
        }
      };

      View.prototype.render = function() {
        var loggedIn, _ref,
          _this = this;
        this.renderTemplate();
        this._renderButtons();
        this.renderAutolists();
        this.delegateEvents();
        this.trigger('rendered');
        this.itemValues();
        this.$el.addClass(this.options.addClass);
        loggedIn = (_ref = P.session) != null ? _ref.get('logged_in') : void 0;
        _.each([loggedIn && 'login' || 'logout', 'loginout'], function(event) {
          return _this[event](P.session, loggedIn);
        });
        return this;
      };

      View.prototype.destroy = function() {
        return $(this.el).remove();
      };

      View.prototype.renderAutolists = function() {
        var listType,
          _this = this;
        listType = (this.autolistType != null) && this.autolistType() || P.views.shared.lists.TitledList;
        return this.$('[data-autolist]').each(function(i, el) {
          var autolist, options, searchOptions;
          try {
            options = JSON.parse($(el).attr('data-autolist'));
          } catch (_error) {}
          searchOptions = (options != null ? options.searchOptions : void 0) || {};
          options = _.extend({
            itemType: P.views.posts.Post,
            collection: new P.models.feeds.Posts([], {
              'searchOptions': searchOptions
            }).limit(3),
            addClass: 'ui-listview',
            autoFetch: {
              regularly: 1000 * 60
            }
          }, options || {});
          autolist = new listType(options);
          if (autolist.collection.fetched_at == null) autolist.collection.fetch();
          return _this.replaceWith(el, autolist);
        });
      };

      View.prototype._renderButtons = function() {
        var _this = this;
        if (this.buttons != null) this.replaceWith('.controls', this.buttons);
        return this.$('.control_bar').find('button,[data-button]').each(function(i, el) {
          var options;
          try {
            options = JSON.parse((el = $(el)).attr('data-button'));
          } catch (_error) {}
          return (new P.views.shared.Button(_.extend(options || {}, {
            el: el
          }))).render();
        });
      };

      View.prototype._view = function(view) {
        if (view instanceof Backbone.View) {
          return view.render().el;
        } else {
          return view;
        }
      };

      return View;

    })(Backbone.View);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.shared.mobile', function(x) {
    return x.View = (function(_super) {

      __extends(View, _super);

      function View() {
        View.__super__.constructor.apply(this, arguments);
      }

      View.prototype.autolistType = function() {
        return x.lists.List;
      };

      return View;

    })(P.views.shared.View);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.shared', function(x) {
    return x.Component = (function(_super) {

      __extends(Component, _super);

      function Component() {
        this.initialize = __bind(this.initialize, this);
        Component.__super__.constructor.apply(this, arguments);
      }

      Component.prototype.initialize = function() {
        var _ref;
        Component.__super__.initialize.apply(this, arguments);
        return this.flash = this.options.flash || ((_ref = this.parent) != null ? _ref.flash : void 0);
      };

      Component.prototype.setup = function() {};

      return Component;

    })(x.View);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.shared.forms', function(x) {
    return x.Form = (function(_super) {

      __extends(Form, _super);

      function Form() {
        this.render = __bind(this.render, this);
        this.enableButtons = __bind(this.enableButtons, this);
        this.disableButtons = __bind(this.disableButtons, this);
        this.edit = __bind(this.edit, this);
        this.saved = __bind(this.saved, this);
        Form.__super__.constructor.apply(this, arguments);
      }

      Form.prototype.events = function() {
        return _.extend(Form.__super__.events.apply(this, arguments), {
          submit: 'save'
        });
      };

      Form.prototype.initialize = function() {
        var _this = this;
        Form.__super__.initialize.apply(this, arguments);
        P.views.shared.Template.prototype.form_template_root = 'shared/forms';
        this.buttons = new P.views.shared.ControlBar({
          controls: ['save']
        });
        this.bind('saving', this.disableButtons);
        this.bind('saved', this.enableButtons);
        this.bind('error', this.enableButtons);
        if (this.parts != null) {
          return _.each(this.parts, function(part, name) {
            return _this[name] = new part({
              parent: _this,
              model: _this.model
            });
          });
        }
      };

      Form.prototype.formValues = function() {
        var values,
          _this = this;
        if (this.parts == null) throw '"formValues" method must be implemented';
        values = {};
        _.each(this.parts, function(part, name) {
          return _.extend(values, _this[name].formValues());
        });
        return values;
      };

      Form.prototype.saved = function() {};

      Form.prototype.edit = function(model, options) {
        var _this = this;
        if (options == null) options = {};
        if (model == null) throw 'ArgumentException: model cannot be null';
        this.model = model;
        this.render();
        this.$('.tristate:checkbox').tristate({
          initialState: 'intermediate',
          imgPath: '/assets/images/tristate/',
          autoIntermediate: true
        });
        this.trigger('edit');
        if (this.parts == null) return;
        return _.each(this.parts, function(part, name) {
          _this[name].model = _this.model;
          return _this[name].trigger('edit');
        });
      };

      Form.prototype.save = function(e) {
        var _this = this;
        if (e != null) e.preventDefault();
        this.trigger('saving');
        return this.model.save(this.formValues(), {
          success: function(model) {
            return _this.trigger('saved', model);
          }
        });
      };

      Form.prototype.disableButtons = function() {
        return this.buttons.disable();
      };

      Form.prototype.enableButtons = function() {
        return this.buttons.enable();
      };

      Form.prototype.clear = function() {
        return this.$('input[type!="checkbox"]:visible').val('');
      };

      Form.prototype.render = function() {
        var _this = this;
        if (this.model == null) return this;
        Form.__super__.render.apply(this, arguments);
        if (this.parts != null) {
          _.each(this.parts, function(part, name) {
            _this[name].model = _this.model;
            return _this.replaceWith("." + name, _this[name]);
          });
        }
        this.$('button').unbind("." + this.cid).bind("click." + this.cid, function() {
          $(this).closest('form').submit();
          return false;
        });
        this.trigger('rendered');
        return this;
      };

      return Form;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.shared.tables', function(x) {
    return x.Row = (function(_super) {

      __extends(Row, _super);

      function Row() {
        Row.__super__.constructor.apply(this, arguments);
      }

      Row.prototype.tagName = 'tr';

      Row.prototype.render = function() {
        Row.__super__.render.apply(this, arguments);
        $(this.el).addClass(this.className);
        return this;
      };

      return Row;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.shared.tables', function(x) {
    return x.Table = (function(_super) {

      __extends(Table, _super);

      function Table() {
        this._cleanModel = __bind(this._cleanModel, this);
        this.render = __bind(this.render, this);
        this.renderList = __bind(this.renderList, this);
        this.renderTruncatedLong = __bind(this.renderTruncatedLong, this);
        this.renderTruncatedShort = __bind(this.renderTruncatedShort, this);
        this.renderTruncated = __bind(this.renderTruncated, this);
        this.renderBoolean = __bind(this.renderBoolean, this);
        this.renderTime = __bind(this.renderTime, this);
        this.renderDate = __bind(this.renderDate, this);
        this.destroy = __bind(this.destroy, this);
        this.add = __bind(this.add, this);
        this.refresh = __bind(this.refresh, this);
        this.renderTable = __bind(this.renderTable, this);
        Table.__super__.constructor.apply(this, arguments);
      }

      Table.prototype.templateName = 'shared/tables/_table';

      Table.prototype.initialize = function() {
        Table.__super__.initialize.apply(this, arguments);
        if (this.options.serverSide == null) this.options.serverSide = false;
        this.setupColumns();
        return this.setupFilters();
      };

      Table.prototype.setupColumns = function() {
        var afterColumns, beforeColumns, columnDefs, columns, configuredColumns, indexOfUpdatedAt, _base, _i, _len, _ref;
        beforeColumns = {
          id: {
            width: '0px',
            visible: false
          },
          controls: {
            title: '',
            width: '12px',
            "class": 'selector'
          }
        };
        afterColumns = {
          updated_at: {
            title: 'Updated',
            width: '200px',
            sortable: true,
            type: 'date',
            use_rendered: false,
            render: this.renderDate
          },
          created_at: {
            title: 'Created',
            width: '200px',
            visible: false,
            sortable: true,
            type: 'date',
            use_rendered: false,
            render: this.renderDate
          }
        };
        columnDefs = {};
        configuredColumns = typeof this.columns === 'function' ? this.columns() : this.columns;
        _ref = [beforeColumns, configuredColumns, afterColumns];
        for (_i = 0, _len = _ref.length; _i < _len; _i++) {
          columns = _ref[_i];
          _.extend(columnDefs, columns);
        }
        this.columns = this.mapColumnDefinitions(columnDefs);
        this.templateOptions.columns = this.columns;
        this.initialFilters = this.mapInitialFilterState(this.columns, this.collection);
        indexOfUpdatedAt = _.indexOf(_.pluck(this.columns, 'mDataProp'), 'updated_at');
        return (_base = this.options).defaultSort || (_base.defaultSort = [[indexOfUpdatedAt, 'desc']]);
      };

      Table.prototype.mapColumnDefinitions = function(columns) {
        var col, cols, feature, features, name, prefix, properties, property, value, _i, _len, _ref, _ref2, _ref3, _ref4, _ref5, _ref6;
        prefix = function(value) {
          switch (typeof value) {
            case 'boolean':
              return 'b';
            case 'function':
              return 'fn';
            case 'number':
              return 'i';
            case 'string':
              return 's';
            default:
              return 's';
          }
        };
        cols = [];
        for (name in columns) {
          properties = columns[name];
          col = {
            sName: name,
            sTitle: properties.title || name.humanize(),
            mDataProp: properties.source || name
          };
          col.bSortable = properties.sortable || ((_ref = properties.features) != null ? _ref.sortable : void 0) || false;
          col.bSearchable = properties.searchable || ((_ref2 = properties.features) != null ? _ref2.searchable : void 0) || false;
          col.bFilterable = properties.filterable || ((_ref3 = properties.features) != null ? _ref3.filterable : void 0) || false;
          col.bUseRendered = properties.use_rendered || ((_ref4 = properties.features) != null ? _ref4.use_rendered : void 0) || true;
          col.bVisible = properties.visible || ((_ref5 = properties.features) != null ? _ref5.visible : void 0) || true;
          if ((features = properties.features) && (features != null)) {
            _ref6 = _.flatten([features]);
            for (_i = 0, _len = _ref6.length; _i < _len; _i++) {
              feature = _ref6[_i];
              col['b' + feature.camelize()] = true;
            }
          }
          for (property in properties) {
            value = properties[property];
            col[prefix(value) + property.camelize()] = value;
          }
          cols.push(col);
        }
        return cols;
      };

      Table.prototype.mapInitialFilterState = function(columns, collection) {
        var filters, search;
        if (!((collection != null) && (collection.searchOptions != null))) {
          return false;
        }
        search = collection.searchOptions["with"];
        filters = [];
        _.each(columns, function(col) {
          var name, value;
          name = col.sName;
          value = search != null ? search[name] : void 0;
          return filters.push((search != null ? search[name] : void 0) != null ? {
            sSearch: value
          } : null);
        });
        return filters;
      };

      Table.prototype.attributeNames = function() {
        return _.pluck(this.columns, 'sName');
      };

      Table.prototype.indexOf = function(name) {
        return this.attributeNames().indexOf(name);
      };

      Table.prototype.renderTable = function() {
        var ajaxSource,
          _this = this;
        if (this.options.serverSide && (this.collection != null)) {
          ajaxSource = this.collection.url();
        }
        this.dataTable = $(this.el).find('table').dataTable({
          oLanguage: {
            "sSearch": "Search all columns:",
            oPaginate: {
              sFirst: P.localizer.t('first', {
                scope: ['tables', 'pagination']
              }),
              sLast: P.localizer.t('last', {
                scope: ['tables', 'pagination']
              }),
              sNext: P.localizer.t('next', {
                scope: ['tables', 'pagination']
              }),
              sPrevious: P.localizer.t('previous', {
                scope: ['tables', 'pagination']
              })
            },
            sEmptyTable: P.localizer.t('empty', {
              scope: 'tables'
            }),
            sInfo: P.localizer.t('base', {
              scope: ['tables', 'info']
            }),
            sInfoEmpty: P.localizer.t('empty', {
              scope: ['tables', 'info']
            }),
            sInfoFiltered: P.localizer.t('filtered', {
              scope: ['tables', 'info']
            }),
            sInfoPostFix: P.localizer.t('post_fix', {
              scope: ['tables', 'info']
            }),
            sLengthMenu: P.localizer.t('length_menu', {
              scope: 'tables'
            }),
            sLoadingRecords: P.localizer.t('loading', {
              scope: 'tables'
            }),
            sProcessing: P.localizer.t('processing', {
              scope: 'tables'
            }),
            sSearch: P.localizer.t('search', {
              scope: 'tables'
            }),
            sUrl: P.localizer.t('url', {
              scope: 'tables'
            }),
            sZeroRecords: P.localizer.t('zero_records', {
              scope: 'tables'
            })
          },
          bProcessing: true,
          bAutoWidth: false,
          bServerSide: this.options.serverSide,
          sAjaxSource: ajaxSource,
          sAjaxDataProp: 'results',
          sDom: '<"H"lfr><".notice">t<"F"ip>',
          bJQueryUI: true,
          bSortClasses: true,
          aoColumns: this.columns,
          aoSearchCols: this.initialFilters || [],
          aaSorting: this.options.defaultSort,
          sPaginationType: "full_numbers",
          fnServerData: this.options.serverSideCB,
          fnDrawCallback: this.options.drawCallback,
          fnInitComplete: function() {
            return $('div.dataTables_processing').html("<img src=\"/assets/images/embed/loading_large.gif\">\n<p>" + (P.localizer.t('processing', {
              scope: 'tables'
            })) + "</p>");
          },
          fnRowCallback: this.options.renderRowCB
        });
        this.dataTable.fnSetFilteringDelay(1000);
        return this.parent.bind('route', function() {
          _this.dataTable.fnFilterClear();
          return _.each(_this.filters, function(filter) {
            return filter.reset();
          });
        });
      };

      Table.prototype.setupFilters = function() {
        var filterables,
          _this = this;
        this.filters = [];
        filterables = _.select(this.columns, function(column) {
          return column.bFilterable === true;
        });
        return _.each(filterables, function(column) {
          return _this.filters.push(new x.Filter({
            parent: _this,
            column: column
          }));
        });
      };

      Table.prototype.renderFilters = function() {
        var _this = this;
        return _.each(this.filters, function(filter) {
          return filter.render();
        });
      };

      Table.prototype.rowConstructor = x.Row;

      Table.prototype.refresh = function() {
        return this.dataTable.fnDraw(false);
      };

      Table.prototype.add = function(model) {
        return this.dataTable.fnAddData(this._cleanModel(model), true);
      };

      Table.prototype.visible = function(names, visible, redraw) {
        var _this = this;
        if (visible == null) visible = true;
        if (redraw == null) redraw = false;
        names = _.flatten([names]);
        return _.each(names, function(name) {
          return _this.dataTable.fnSetColumnVis(_this.indexOf(name), visible, redraw);
        });
      };

      Table.prototype.destroy = function() {
        var ids, selected,
          _this = this;
        selected = this.selected();
        if (selected.length < 1) {
          return this.flash.show({
            message: P.localizer.t('no_rows_selected', {
              scope: ['tables', 'errors']
            }),
            "class": 'warn'
          }, 'Oops!');
        }
        if (confirm('Are you sure?')) {
          ids = selected.pluck('id');
          return $.ajax({
            url: this.collection.url('/destroy_all'),
            type: 'DELETE',
            data: {
              'id[]': ids
            },
            success: function() {
              _this.collection.remove(selected);
              return _this.dataTable.fnDraw();
            }
          });
        }
      };

      Table.prototype.renderDate = function(data, format) {
        var d, date;
        if (format == null) format = 'M/D/YYYY h:mm a';
        date = this.getColumnValue(data);
        if (!date) return '--';
        d = new moment(date);
        return d.format(d.hours() === 0 && d.minutes() === 0 ? 'M/D/YYYY' : format);
      };

      Table.prototype.renderTime = function(data) {
        return this.renderDate(data, 'h:mm a');
      };

      Table.prototype.renderBoolean = function(data) {
        if (this.getColumnValue(data)) {
          return 'Yes';
        } else {
          return 'No';
        }
      };

      Table.prototype.renderTruncated = function(data, options) {
        if (options == null) {
          options = {
            length: 25
          };
        }
        return $.truncate(this.getColumnValue(data), options);
      };

      Table.prototype.renderTruncatedShort = function(data) {
        return this.renderTruncated(data, {
          length: 8
        });
      };

      Table.prototype.renderTruncatedLong = function(data) {
        return this.renderTruncated(data, {
          length: 25
        });
      };

      Table.prototype.renderList = function(data) {
        var els;
        els = this.getColumnValue(data);
        if (!_.isArray(els)) els = [];
        return els.join(', ');
      };

      Table.prototype.getColumnValue = function(data) {
        var col;
        if ((col = data.iDataColumn) == null) return data;
        return data.aData[data.oSettings.aoColumns[col].mDataProp || col];
      };

      Table.prototype.render = function() {
        Table.__super__.render.apply(this, arguments);
        this.renderTable();
        this.renderFilters();
        return this;
      };

      Table.prototype._cleanModel = function(model) {
        var c, _i, _len, _name, _ref;
        model = _.reduce(model.attributes, function(memo, v, k) {
          var ignore;
          ignore = !(v instanceof Date) && _.isObject(v);
          if (_.isArray(v)) ignore = _.isEmpty(v) || _.isObject(v[0]);
          if (!ignore) memo[k] = model[k] || v;
          return memo;
        }, {});
        _ref = this.columns;
        for (_i = 0, _len = _ref.length; _i < _len; _i++) {
          c = _ref[_i];
          model[_name = c.mDataProp] || (model[_name] = '');
        }
        return model;
      };

      return Table;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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 = Array.prototype.slice;

  P.namespace('P.views.shared.lists', function(x) {
    x.Wrapper = (function(_super) {

      __extends(Wrapper, _super);

      function Wrapper() {
        this.render = __bind(this.render, this);
        this.initialize = __bind(this.initialize, this);
        Wrapper.__super__.constructor.apply(this, arguments);
      }

      Wrapper.prototype.className = function() {
        return "" + Wrapper.__super__.className.apply(this, arguments) + " list";
      };

      Wrapper.prototype.initialize = function() {
        var options, _base,
          _this = this;
        Wrapper.__super__.initialize.apply(this, arguments);
        options = (_base = this.options).list || (_base.list = {});
        _.each('itemType itemOptions multi selectable size templateOptions\
        autoFetch collection'.split(/\s+/), function(option) {
          return options[option] || (options[option] = _this.options[option]);
        });
        this.list = new Backbone.List(_.defaults(options, {
          itemType: this.itemType,
          itemOptions: this.itemOptions,
          multi: this.multi,
          selectable: this.selectable
        }));
        return this.list.bind('all', function() {
          var args;
          args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
          return _this.trigger.apply(_this, args);
        });
      };

      Wrapper.prototype.render = function() {
        Wrapper.__super__.render.apply(this, arguments);
        this.append(this.list);
        return this;
      };

      return Wrapper;

    })(P.views.shared.Component);
    return _.each('findView select unselect unselectAll'.split(/\s+/), function(f) {
      return x.Wrapper.prototype[f] = function() {
        return this.list[f].apply(this, arguments);
      };
    });
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.shared.lists', function(x) {
    return x.Controls = (function(_super) {

      __extends(Controls, _super);

      function Controls() {
        Controls.__super__.constructor.apply(this, arguments);
      }

      Controls.prototype.templateName = 'shared/lists/_controls';

      Controls.prototype.tagName = 'span';

      Controls.prototype.className = function() {
        return "" + Controls.__super__.className.apply(this, arguments) + " control_bar";
      };

      Controls.prototype.initialize = function() {
        var _base, _base2, _base3;
        Controls.__super__.initialize.apply(this, arguments);
        (_base = this.options).controls || (_base.controls = {});
        (_base2 = this.options.controls).link || (_base2.link = '#');
        (_base3 = this.options.controls).title || (_base3.title = P.localizer.t('view_all'));
        return this.templateOptions = this.options.controls;
      };

      return Controls;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.shared.lists', function(x) {
    return x.Count = (function(_super) {

      __extends(Count, _super);

      function Count() {
        Count.__super__.constructor.apply(this, arguments);
      }

      Count.prototype.templateName = 'shared/lists/_count';

      Count.prototype.className = function() {
        return "" + Count.__super__.className.apply(this, arguments) + " count";
      };

      Count.prototype.tagName = 'span';

      Count.prototype.initialize = function() {
        var _this = this;
        Count.__super__.initialize.call(this);
        if (typeof this.options.count === 'number') {
          this.templateOptions.count = this.options.count;
          return this.render;
        } else {
          this.templateOptions.count = this.collection.total_entries || this.collection.length;
          return _.each(['add', 'remove', 'reset'], function(event) {
            return _this.collection.bind(event, _this.render);
          });
        }
      };

      return Count;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.shared.lists', function(x) {
    return x.Search = (function(_super) {

      __extends(Search, _super);

      function Search() {
        this.renderInfo = __bind(this.renderInfo, this);
        this.clear = __bind(this.clear, this);
        this.search = __bind(this.search, this);
        this.initialize = __bind(this.initialize, this);
        Search.__super__.constructor.apply(this, arguments);
      }

      Search.prototype.tagName = 'form';

      Search.prototype.className = function() {
        return "" + Search.__super__.className.apply(this, arguments) + " search";
      };

      Search.prototype.templateName = 'shared/lists/_search';

      Search.prototype.events = function() {
        return _.extend(Search.__super__.events.apply(this, arguments), {
          'submit': 'search',
          'change select.order': 'search'
        });
      };

      Search.prototype.initialize = function() {
        var _base, _base2;
        Search.__super__.initialize.apply(this, arguments);
        this.track = this.options.track || this.track;
        _.extend((_base = this.collection).searchOptions || (_base.searchOptions = {}), this.options.search);
        this.collection.bind('reset', this.renderInfo);
        this.collection.bind('reset', this.track);
        if ((_base2 = this.templateOptions).sort == null) {
          _base2.sort = {
            options: _.map(this.options.sort, function(value, key) {
              return [value.label || key.capitalize(), value.order];
            })
          };
        }
        this.button = new P.views.shared.Button({
          label: P.localizer.t('search')
        });
        return this.paginator = new P.views.shared.Paginator({
          collection: this.collection,
          parent: this
        });
      };

      Search.prototype.track = function() {};

      Search.prototype.search = function(e) {
        var params;
        if (e == null) e = {};
        params = {};
        if (e instanceof jQuery.Event) {
          e.preventDefault();
          params = this._searchParams();
        } else {
          params = e;
          if (params.query != null) {
            $(this.el).find("#search_query").val("\"" + params.query + "\"");
          }
        }
        this.loading(true);
        this.paginator.clear();
        return this.collection.search(params);
      };

      Search.prototype.clear = function() {
        this.loading(true);
        this.$('input.query').val('');
        this.$('select.order option:first-child').attr('selected', 'selected');
        return this.paginator.clear();
      };

      Search.prototype.reset = function() {
        this.clear();
        return this.collection.search(this._searchParams());
      };

      Search.prototype.loading = function(show) {
        $(this.el).find('.info .counts').toggle(!show);
        return $(this.el).find('.info .loading').toggle(show);
      };

      Search.prototype.renderInfo = function() {
        var counts, order;
        order = $(this.el).find('.order .control');
        counts = $(this.el).find('.info .counts');
        counts.find('.total_entries').text(this.collection.total_entries);
        counts.find('.count').text(this.collection.length);
        order.show();
        return this.loading(false);
      };

      Search.prototype.render = function() {
        Search.__super__.render.apply(this, arguments);
        this.replaceWith('button.search', this.button);
        this.replaceWith('.paging', this.paginator.el);
        return this;
      };

      Search.prototype._searchParams = function() {
        var order, _ref;
        return {
          query: this.$('input.query').val() || '',
          order: order = this.$('select.order').val() || this.options.order || 'updated_at',
          sort_mode: ((_ref = _.detect(this.options.sort, function(value, key) {
            return value.order === order;
          })) != null ? _ref.sort_mode : void 0) || 'desc',
          page: 1
        };
      };

      return Search;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.shared.lists', function(x) {
    return x.TabbedList = (function(_super) {

      __extends(TabbedList, _super);

      function TabbedList() {
        this._toggleSelected = __bind(this._toggleSelected, this);
        this._remove = __bind(this._remove, this);
        this._add = __bind(this._add, this);
        this.render = __bind(this.render, this);
        this.initialize = __bind(this.initialize, this);
        TabbedList.__super__.constructor.apply(this, arguments);
      }

      TabbedList.prototype.initialize = function() {
        TabbedList.__super__.initialize.apply(this, arguments);
        this.tabs = new x.Tabs({
          collection: this.collection,
          label: this.options.label
        }).bind('toggle', this._toggleSelected).bind('add', this._add).bind('remove', this._remove);
        return $(this.tabs.el).delegate('a', 'click', function(e) {
          return e.preventDefault();
        });
      };

      TabbedList.prototype.render = function() {
        TabbedList.__super__.render.apply(this, arguments);
        this.prepend(this.tabs);
        return this;
      };

      TabbedList.prototype._add = function(view) {
        if (this.tabs.selected != null) return $(this.list._el(view.model)).hide();
        return this.tabs.select(view);
      };

      TabbedList.prototype._remove = function() {
        if (this.tabs.selected == null) {
          return this.tabs.select(this.collection.first());
        }
      };

      TabbedList.prototype._toggleSelected = function(model, view, selected) {
        $(this.list._el(model)).toggle(selected);
        return $(view.el).toggleClass('selected', selected);
      };

      return TabbedList;

    })(x.Wrapper);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.shared.lists', function(x) {
    return x.Tabs = (function(_super) {

      __extends(Tabs, _super);

      function Tabs() {
        Tabs.__super__.constructor.apply(this, arguments);
      }

      Tabs.prototype.className = 'tabs';

      Tabs.prototype.selectable = true;

      Tabs.prototype.itemOptions = function() {
        return {
          className: 'primary',
          label: this.options.label,
          templateName: 'shared/lists/_tab'
        };
      };

      return Tabs;

    })(Backbone.List);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.shared.lists', function(x) {
    return x.Title = (function(_super) {

      __extends(Title, _super);

      function Title() {
        this._count = __bind(this._count, this);
        this.render = __bind(this.render, this);
        Title.__super__.constructor.apply(this, arguments);
      }

      Title.prototype.templateName = 'shared/lists/_title';

      Title.prototype.tagName = 'h4';

      Title.prototype.className = function() {
        return "" + Title.__super__.className.apply(this, arguments) + " title uppercase header";
      };

      Title.prototype.MIN_COUNT = 5;

      Title.prototype.initialize = function() {
        var _this = this;
        Title.__super__.initialize.apply(this, arguments);
        this.collection.bind('reset', function() {
          return _this.$('.loading').hide();
        });
        this.collection.bind('reset', this._count);
        return this.collection.bind('fetching', function() {
          return _this.$('.loading').show();
        });
      };

      Title.prototype.render = function() {
        Title.__super__.render.apply(this, arguments);
        this._count();
        if (this.options.controls) {
          this.replaceWith('.controls', new x.Controls({
            controls: this.options.controls
          }));
        }
        return this;
      };

      Title.prototype._count = function() {
        if (this.options.showCount && this.collection.length >= this.MIN_COUNT) {
          return this.replaceWith('.count', new x.Count({
            collection: this.collection,
            count: this.options.showCount
          }));
        }
      };

      return Title;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.shared.lists', function(x) {
    return x.TitledList = (function(_super) {

      __extends(TitledList, _super);

      function TitledList() {
        this.render = __bind(this.render, this);
        this._toggle = __bind(this._toggle, this);
        this.initialize = __bind(this.initialize, this);
        TitledList.__super__.constructor.apply(this, arguments);
      }

      TitledList.prototype.initialize = function() {
        var title,
          _this = this;
        TitledList.__super__.initialize.apply(this, arguments);
        _.defaults(this.options, {
          hideEmpty: true
        });
        if (_.isString(title = this.options.title)) {
          this.options.title = {
            title: title
          };
        }
        if (this.options.title != null) {
          this.title = new x.Title(_.extend(this.options.title, {
            showCount: this.options.showCount,
            controls: this.options.controls,
            collection: this.options.collection
          }));
        }
        return _.each(['add', 'remove', 'reset'], function(event) {
          return _this.collection.bind(event, _this._toggle);
        });
      };

      TitledList.prototype._toggle = function() {
        if (this.options.hideEmpty) {
          return this.$el.toggle(!this.collection.isEmpty());
        }
      };

      TitledList.prototype.render = function() {
        TitledList.__super__.render.apply(this, arguments);
        this._toggle();
        if (this.title != null) this.prepend(this.title);
        return this;
      };

      return TitledList;

    })(x.Wrapper);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.shared', function(x, top) {
    return x.Page = (function(_super) {

      __extends(Page, _super);

      function Page() {
        this.visible = __bind(this.visible, this);
        this._title = __bind(this._title, this);
        this.initialize = __bind(this.initialize, this);
        Page.__super__.constructor.apply(this, arguments);
      }

      Page.prototype.initialize = function() {
        var _ref;
        Page.__super__.initialize.apply(this, arguments);
        this.bind('route', this._title);
        if ((_ref = this.model) != null) _ref.bind('change', this._title);
        this.flash = P.layout.flash;
        return this.navigation = typeof this.navigationType === "function" ? new this.navigationType({
          model: this.model,
          parent: this
        }) : void 0;
      };

      Page.prototype._title = function() {
        return P.title(_.isFunction(this.title) ? this.title() : this.title);
      };

      Page.prototype.className = function() {
        return "" + Page.__super__.className.apply(this, arguments) + " page";
      };

      Page.prototype.clear = function() {};

      Page.prototype.render = function() {
        Page.__super__.render.apply(this, arguments);
        this.attach();
        if (this.navigation != null) {
          this.replaceWith('.navigation', this.navigation);
        }
        return this;
      };

      Page.prototype.attach = function() {
        return $('#content').append(this.el);
      };

      Page.prototype.visible = function() {
        return P.router.visible === this;
      };

      return Page;

    })(x.View);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.shared', function(x) {
    return x.HostPage = (function(_super) {

      __extends(HostPage, _super);

      function HostPage() {
        HostPage.__super__.constructor.apply(this, arguments);
      }

      HostPage.prototype.className = function() {
        return '';
      };

      HostPage.prototype.attach = function() {
        return $('#content > .page > .main').append(this.el);
      };

      return HostPage;

    })(x.Page);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.shared', function(x) {
    return x.Button = (function(_super) {

      __extends(Button, _super);

      function Button() {
        this.render = __bind(this.render, this);
        this.enable = __bind(this.enable, this);
        this.disable = __bind(this.disable, this);
        this.initialize = __bind(this.initialize, this);
        Button.__super__.constructor.apply(this, arguments);
      }

      Button.prototype.tagName = 'button';

      Button.prototype.initialize = function() {
        var _base, _base2, _base3;
        Button.__super__.initialize.apply(this, arguments);
        (_base = this.options).disabledLabel || (_base.disabledLabel = 'Saving');
        (_base2 = this.options).buttonClass || (_base2.buttonClass = 'default');
        return (_base3 = this.options).icons || (_base3.icons = {});
      };

      Button.prototype.disable = function() {
        $(this.el).button({
          icons: {
            primary: 'ui-icon-disk'
          },
          disabled: true
        });
        return $(this.el).find('.ui-button-text').text("" + this.options.disabledLabel + "...");
      };

      Button.prototype.enable = function() {
        $(this.el).button({
          icons: this.options.icons,
          disabled: false
        });
        return $(this.el).find('.ui-button-text').text(this.text);
      };

      Button.prototype.render = function() {
        Button.__super__.render.apply(this, arguments);
        $(this.el).button(this.options);
        $(this.el).addClass(this.options.buttonClass);
        return this;
      };

      return Button;

    })(x.Component);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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 = Array.prototype.slice;

  P.namespace('P.views.shared', function(x) {
    return x.Calendar = (function(_super) {

      __extends(Calendar, _super);

      function Calendar() {
        this._updateModel = __bind(this._updateModel, this);
        this._viewDisplay = __bind(this._viewDisplay, this);
        this._findEvent = __bind(this._findEvent, this);
        this._findSource = __bind(this._findSource, this);
        this._call = __bind(this._call, this);
        this._convert = __bind(this._convert, this);
        this._reset = __bind(this._reset, this);
        this._remove = __bind(this._remove, this);
        this._add = __bind(this._add, this);
        this._change = __bind(this._change, this);
        this.remove = __bind(this.remove, this);
        this.add = __bind(this.add, this);
        this.refresh = __bind(this.refresh, this);
        this.destroy = __bind(this.destroy, this);
        this.setDate = __bind(this.setDate, this);
        this.render = __bind(this.render, this);
        var _this = this;
        Calendar.__super__.constructor.apply(this, arguments);
        this._sources = {};
        _.each('gotoDate removeEventSource removeEvents updateEvent\
        addEventSource unselect renderEvent rerenderEvents'.split(/\s+/), function(s) {
          return _this[s] = function() {
            var args;
            args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
            return _this._call.apply(_this, [s].concat(__slice.call(args)));
          };
        });
      }

      Calendar.prototype.render = function() {
        var options,
          _this = this;
        Calendar.__super__.render.apply(this, arguments);
        options = {};
        _.each('height selectable select allDaySlot defaultView slotMinutes'.split(/\s+/), function(s) {
          if (_this.options[s] != null) return options[s] = _this.options[s];
        });
        _.defaults(options, {
          height: 800,
          allDaySlot: false,
          defaultView: 'agendaDay',
          viewDisplay: this._viewDisplay,
          eventDrop: this._updateModel,
          eventResize: this._updateModel
        });
        $(this.el).fullCalendar(options);
        _.each(this._sources, this.addEventSource);
        this.setDate(this.options.defaultDate);
        return this;
      };

      Calendar.prototype.setDate = function(date) {
        if (date != null) return $(this.el).fullCalendar('gotoDate', date);
      };

      Calendar.prototype.destroy = function() {
        var cid, source, _len, _ref;
        _ref = this._sources;
        for (source = 0, _len = _ref.length; source < _len; source++) {
          cid = _ref[source];
          this.removeCollection(source.__collection);
        }
        return this._call('destroy');
      };

      Calendar.prototype.refresh = function() {
        return this._call('render');
      };

      Calendar.prototype.add = function(collection, options) {
        var source,
          _this = this;
        if (options == null) options = {};
        if (this._findSource(collection)) return;
        _.defaults(options, {
          color: 'blue',
          title: void 0,
          editable: false
        });
        source = this._sources[collection.cid] = {
          __options: options,
          __collection: collection,
          __change: function(model) {
            return _this._change(model, collection);
          },
          events: collection.map(function(model) {
            return _this._convert(model, options);
          })
        };
        collection.bind('add', this._add);
        collection.bind('remove', this._remove);
        collection.bind('reset', this._reset);
        collection.bind('change', source.__change);
        return this.addEventSource(source);
      };

      Calendar.prototype.remove = function(collection) {
        var source,
          _this = this;
        if (!(source = this._findSource(collection))) return;
        collection.unbind('add', this._add);
        collection.unbind('remove', this._remove);
        collection.unbind('reset', this._reset);
        collection.unbind('change', source.__change);
        this.removeEventSource(source);
        this.removeEvents(function(event) {
          return _.include(source.events, event);
        });
        return delete this._sources[collection.cid];
      };

      Calendar.prototype._change = function(model, collection) {
        var event, events, __options, _ref,
          _this = this;
        if (!(_ref = this._findSource(collection), events = _ref.events, __options = _ref.__options, _ref)) {
          return;
        }
        if (!_.any('name starts_at_local ends_at_local id'.split(/\s+/), function(p) {
          return model.hasChanged(p);
        })) {
          return;
        }
        event = this._findEvent(model, events);
        return this.updateEvent(_.extend(event, this._convert(model, __options)));
      };

      Calendar.prototype._add = function(model, collection) {
        var event, events, __options, _ref;
        if (!(_ref = this._findSource(collection), events = _ref.events, __options = _ref.__options, _ref)) {
          return;
        }
        event = this._convert(model, __options);
        events.splice(collection.indexOf(model), 0, event);
        return this.renderEvent(event);
      };

      Calendar.prototype._remove = function(model, collection) {
        var event, events, _ref,
          _this = this;
        if (!(_ref = this._findSource(collection), events = _ref.events, _ref)) {
          return;
        }
        event = this._findEvent(model, events);
        events.splice(_.indexOf(events, event), 1);
        return this.removeEvents(function(e) {
          return e === event;
        });
      };

      Calendar.prototype._reset = function(collection) {
        var source,
          _this = this;
        if (!(source = this._findSource(collection))) return;
        this.removeEvents(function(event) {
          return _.include(source.events, event);
        });
        source.events = collection.map(function(model) {
          return _this._convert(model, source.__options);
        });
        return _.each(source.events, this.renderEvent);
      };

      Calendar.prototype._convert = function(model, options) {
        return {
          __model: model,
          id: model.cid,
          color: options.color,
          editable: options.editable,
          title: options.title || model.get('name'),
          start: new Date(model.get('starts_at_local')),
          end: new Date(model.get('ends_at_local')),
          allDay: false
        };
      };

      Calendar.prototype._call = function() {
        var args, method, _ref;
        method = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
        return (_ref = $(this.el)).fullCalendar.apply(_ref, [method].concat(__slice.call(args)));
      };

      Calendar.prototype._findSource = function(cid) {
        return this._sources[(cid != null ? cid.cid : void 0) || cid];
      };

      Calendar.prototype._findEvent = function(model, events) {
        var _this = this;
        return _.detect((events != null ? events.events : void 0) || events, function(event) {
          return event.__model === model;
        });
      };

      Calendar.prototype._viewDisplay = function(view) {
        var start, step,
          _this = this;
        if (view.name === 'agendaDay' && _.isArray(this.options.open)) {
          start = new Date(view.start);
          step = view.opt('slotMinutes');
          return this.$('.fc-agenda-slots .fc-agenda-axis').each(function(i, el) {
            var allowed, end;
            moment(end = new Date(start)).add('m', step);
            allowed = _.any(_this.options.open, function(d) {
              return d.start < end && start < d.end;
            });
            $(el).css({
              backgroundColor: allowed ? '' : 'lightgray'
            });
            return start = end;
          });
        }
      };

      Calendar.prototype._updateModel = function(event) {
        var model;
        return (model = event.__model).set({
          starts_at_local: event.start,
          ends_at_local: event.end
        });
      };

      return Calendar;

    })(x.Component);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.shared', function(x) {
    return x.ColorPicker = (function(_super) {

      __extends(ColorPicker, _super);

      function ColorPicker() {
        this._notify = __bind(this._notify, this);
        this.setColor = __bind(this.setColor, this);
        ColorPicker.__super__.constructor.apply(this, arguments);
      }

      ColorPicker.prototype.templateName = 'shared/_color_picker';

      ColorPicker.prototype.events = {
        'change': '_notify'
      };

      ColorPicker.prototype.color = {
        hex: '#0022ff'
      };

      ColorPicker.prototype.config = {
        flat: true
      };

      ColorPicker.prototype.setColor = function(color) {
        this.color = color;
        return this.$('.picker').ColorPickerSetColor(this.color.hex + '');
      };

      ColorPicker.prototype.render = function() {
        var _this = this;
        ColorPicker.__super__.render.apply(this, arguments);
        this.$('.picker').ColorPicker(_.extend(this.config, {
          onChange: function(hsb, hex, rgb) {
            _this.color = {
              hex: "#" + hex
            };
            return _this._notify();
          }
        }));
        return this;
      };

      ColorPicker.prototype._notify = function() {
        return this.trigger('change', this);
      };

      return ColorPicker;

    })(x.Component);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.shared', function(x) {
    return x.ControlBar = (function(_super) {

      __extends(ControlBar, _super);

      function ControlBar() {
        this.find = __bind(this.find, this);
        this.hideButton = __bind(this.hideButton, this);
        this.showButton = __bind(this.showButton, this);
        ControlBar.__super__.constructor.apply(this, arguments);
      }

      ControlBar.prototype.initialize = function() {
        var _base,
          _this = this;
        ControlBar.__super__.initialize.apply(this, arguments);
        (_base = this.options).buttonOptions || (_base.buttonOptions = []);
        _.each(this.options.controls, function(control) {
          return _this.options.buttonOptions.push(_this.setupControl(control));
        });
        return this.buttons = new P.views.shared.ButtonSet(this.options.buttonOptions);
      };

      ControlBar.prototype.className = function() {
        return "" + ControlBar.__super__.className.apply(this, arguments) + " control_bar";
      };

      ControlBar.prototype.setupControl = function(control) {
        switch (control) {
          case 'add':
            return {
              label: P.localizer.t('add'),
              icons: {
                primary: 'ui-icon-plus'
              },
              className: 'new'
            };
          case 'remove':
            return {
              label: P.localizer.t('remove'),
              icons: {
                primary: 'ui-icon-trash'
              },
              className: 'destroy'
            };
          case 'edit':
            return {
              label: P.localizer.t('edit'),
              icons: {
                primary: 'ui-icon-pencil'
              },
              className: 'edit'
            };
          case 'reply':
            return {
              label: P.localizer.t('reply'),
              icons: {
                primary: 'ui-icon-arrowrefresh-1-w'
              },
              className: 'primary reply'
            };
          case 'save':
            return {
              label: P.localizer.t('save'),
              icons: {
                primary: 'ui-icon-disk'
              },
              className: 'primary save'
            };
          case 'message':
            return {
              label: P.localizer.t('message'),
              icons: {
                primary: 'ui-icon-mail-closed'
              },
              className: 'message'
            };
          case 'send':
            return {
              label: P.localizer.t('send'),
              disabledLabel: 'Sending',
              icons: {
                primary: 'ui-icon-mail-closed'
              },
              className: 'primary send'
            };
          case 'newDiscussion':
            return {
              label: P.localizer.t('start_conversation'),
              icons: {
                primary: 'ui-icon-mail-closed'
              },
              className: 'new-discussion'
            };
          case 'signIn':
            return {
              label: P.localizer.t('sign_in'),
              icons: {
                primary: 'ui-icon-locked'
              },
              className: 'primary signIn'
            };
          case 'editSettings':
            return {
              label: P.localizer.t('edit_settings'),
              icons: {
                primary: 'ui-icon-wrench'
              },
              className: 'edit-settings'
            };
        }
      };

      ControlBar.prototype.renderButtons = function() {
        var _this = this;
        return _.each(this.buttons.buttons, function(button) {
          return _this.append(button);
        });
      };

      ControlBar.prototype.showButton = function(labels) {
        var _this = this;
        labels = _.flatten([labels]);
        return _.each(labels, function(label) {
          var _ref;
          return (_ref = _this.find(label)) != null ? _ref.$el.show() : void 0;
        });
      };

      ControlBar.prototype.hideButton = function(labels) {
        var _this = this;
        labels = _.flatten([labels]);
        return _.each(labels, function(label) {
          var _ref;
          return (_ref = _this.find(label)) != null ? _ref.$el.hide() : void 0;
        });
      };

      ControlBar.prototype.find = function(label) {
        return this.buttons.find(label);
      };

      ControlBar.prototype.swap = function(showLabel, hideLabel) {
        this.showButton(showLabel);
        return this.hideButton(hideLabel);
      };

      ControlBar.prototype.disable = function() {
        return this.buttons.get(0).disable();
      };

      ControlBar.prototype.enable = function() {
        return this.buttons.get(0).enable();
      };

      ControlBar.prototype.render = function() {
        ControlBar.__super__.render.apply(this, arguments);
        this.renderButtons();
        return this;
      };

      return ControlBar;

    })(x.Component);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.shared', function(x) {
    return x.DatePicker = (function(_super) {

      __extends(DatePicker, _super);

      function DatePicker() {
        this._adjustWith = __bind(this._adjustWith, this);
        this._notify = __bind(this._notify, this);
        DatePicker.__super__.constructor.apply(this, arguments);
      }

      DatePicker.prototype.events = {
        'change': '_notify'
      };

      DatePicker.prototype.tagName = 'input';

      DatePicker.prototype.config = {
        gotoCurrent: true
      };

      DatePicker.prototype.initialize = function() {
        DatePicker.__super__.initialize.apply(this, arguments);
        return _.bindAll(this, 'render');
      };

      DatePicker.prototype.getDate = function() {
        return $(this.el).datepicker('getDate');
      };

      DatePicker.prototype.setDate = function(date) {
        if (date != null) return $(this.el).datepicker('setDate', date);
      };

      DatePicker.prototype.refresh = function() {
        return $(this.el).datepicker('refresh');
      };

      DatePicker.prototype.render = function() {
        DatePicker.__super__.render.apply(this, arguments);
        $(this.el).datepicker(this.config);
        return this;
      };

      DatePicker.prototype._notify = function() {
        this.trigger('change', this);
        return this._adjustWith();
      };

      DatePicker.prototype._adjustWith = function() {
        if (!this.options["with"]) return;
        return this.options["with"].setDate(moment(new Date(this.getDate())).add('d', 2)["native"]());
      };

      return DatePicker;

    })(x.Component);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.shared', function(x) {
    x.Dialog = (function(_super) {

      __extends(Dialog, _super);

      function Dialog() {
        this.render = __bind(this.render, this);
        this.clear = __bind(this.clear, this);
        this.close = __bind(this.close, this);
        this.center = __bind(this.center, this);
        this.open = __bind(this.open, this);
        Dialog.__super__.constructor.apply(this, arguments);
      }

      Dialog.prototype.initialize = function() {
        var _base;
        Dialog.__super__.initialize.apply(this, arguments);
        if ((_base = this.options).width == null) _base.width = 550;
        if (this.formType != null) {
          this.form || (this.form = new this.formType({
            parent: this
          }));
        }
        this.flash = new x.Flash();
        return this.spinner = new x.Spinner();
      };

      Dialog.prototype.open = function() {
        return $(this.el).dialog('open');
      };

      Dialog.prototype.center = function() {
        return $(this.el).dialog('widget').position({
          my: 'center',
          at: 'center',
          of: window
        });
      };

      Dialog.prototype.close = function() {
        return $(this.el).dialog('close');
      };

      Dialog.prototype.clear = function() {};

      Dialog.prototype.render = function() {
        var _this = this;
        Dialog.__super__.render.apply(this, arguments);
        this.dialog = $(this.el).dialog({
          autoOpen: false,
          width: this.options.width,
          height: this.options.height,
          modal: true,
          zIndex: 20000,
          resizable: false,
          position: 'center',
          create: function(e, ui) {
            _this.prepend(_this.flash);
            _this.prepend(_this.spinner);
            return _this.center();
          }
        });
        return this;
      };

      return Dialog;

    })(x.Component);
    return x.Dialog.currentlyOpen = function() {
      return _.max($('.ui-dialog:visible'), function(d) {
        return +$(d).css('zIndex');
      });
    };
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.shared', function(x) {
    return x.Flash = (function(_super) {

      __extends(Flash, _super);

      Flash.prototype.className = function() {
        return "" + Flash.__super__.className.apply(this, arguments) + " flash";
      };

      Flash.prototype.events = function() {
        return _.extend(Flash.__super__.events.apply(this, arguments), {
          'click .flash-message': 'hide'
        });
      };

      function Flash() {
        this.render = __bind(this.render, this);
        this.parseError = __bind(this.parseError, this);
        this.clear = __bind(this.clear, this);
        this.hide = __bind(this.hide, this);
        this.show = __bind(this.show, this);        Flash.__super__.constructor.apply(this, arguments);
        this.classStyles = ['error', 'info', 'warn', 'success'];
      }

      Flash.prototype.DELAY = 10000;

      Flash.prototype.show = function(opt, prepend) {
        if (prepend == null) prepend = '';
        if (!(opt != null)) return false;
        this.clear();
        opt = this.parseError(opt);
        $(this.el).html("<span class=\"flash-message\"><strong>" + prepend + "</strong> " + (opt.message || '') + "</span>").removeClass(this.classStyles).addClass((opt != null ? opt["class"] : void 0) || 'success').css({
          opacity: 0
        }).show().animate({
          opacity: 100
        });
        if (this._timer) clearTimeout(this._timer);
        if (opt != null ? opt.hide : void 0) {
          return this._timer = this.hide(this.DELAY);
        }
      };

      Flash.prototype.hide = function(delay) {
        var _this = this;
        if (delay == null) delay = this.DELAY;
        return setTimeout(function() {
          return $(_this.el).animate({
            opacity: 0,
            complete: function() {
              return _this.clear();
            }
          }, function() {
            return $(_this.el).hide();
          });
        }, delay);
      };

      Flash.prototype.clear = function() {
        $(this.el).html('');
        return $(this.el).removeClass().addClass('flash');
      };

      Flash.prototype.parseError = function(opt) {
        if (opt.error) {
          return {
            message: opt.error.message || opt.error,
            "class": 'error'
          };
        } else {
          return opt;
        }
      };

      Flash.prototype.render = function() {
        Flash.__super__.render.apply(this, arguments);
        $(this.el).css({
          opacity: 0
        });
        return this;
      };

      return Flash;

    })(x.Component);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.shared', function(x) {
    return x.HtmlEditor = (function(_super) {

      __extends(HtmlEditor, _super);

      function HtmlEditor() {
        this.render = __bind(this.render, this);
        this.setContent = __bind(this.setContent, this);
        this.initialize = __bind(this.initialize, this);
        HtmlEditor.__super__.constructor.apply(this, arguments);
      }

      HtmlEditor.prototype.tagName = 'textarea';

      HtmlEditor.prototype.customTokenSet = {
        name: 'Colors',
        className: 'colors',
        dropMenu: [
          {
            name: 'First name',
            replaceWith: '{{=user.first_name}}'
          }, {
            name: 'Last name',
            replaceWith: '{{=user.last_name}}'
          }, {
            name: 'Full name',
            replaceWith: '{{=user.full_name}}'
          }, {
            name: 'Authentication URL',
            replaceWith: '{{=user.authentication_url}}'
          }, {
            name: 'Email',
            replaceWith: '{{=user.primary_email}}'
          }, {
            name: 'Title',
            replaceWith: '{{=user.title}}'
          }, {
            name: 'Credentials',
            replaceWith: '{{=user.credentials}}'
          }, {
            name: 'Organization name',
            replaceWith: '{{=user.organization_name}}'
          }, {
            name: 'Bio',
            replaceWith: '{{=user.bio}}'
          }, {
            name: 'Last updated at',
            replaceWith: '{{=user.updated_at}}'
          }, {
            name: 'Community Name',
            replaceWith: '{{=community.name}}'
          }, {
            name: 'Community Domain',
            replaceWith: '{{=community.domain}}'
          }, {
            name: 'Community Time Zone',
            replaceWith: '{{=community.time_zone}}'
          }, {
            name: 'Event Name',
            replaceWith: '{{=event.name}}'
          }, {
            name: 'Event start date',
            replaceWith: '{{=event.starts_at}}'
          }, {
            name: 'Event end date',
            replaceWith: '{{=event.ends_at}}'
          }, {
            name: 'Event blurb',
            replaceWith: '{{=event.blurb}}'
          }
        ]
      };

      HtmlEditor.prototype.config = {};

      HtmlEditor.prototype.initialize = function() {
        var _ref;
        HtmlEditor.__super__.initialize.apply(this, arguments);
        if (this.config == null) {
          this.config = {};
          $.extend(true, this.config, (_ref = $.markItUp) != null ? _ref.htmlSettings : void 0);
        }
        if (!_.include(this.config.markupSet, this.customTokenSet)) {
          return this.config.markupSet.push(this.customTokenSet);
        }
      };

      HtmlEditor.prototype.setContent = function(content) {
        return $(this.el).val(content);
      };

      HtmlEditor.prototype.render = function() {
        var _this = this;
        HtmlEditor.__super__.render.apply(this, arguments);
        setTimeout(function() {
          if ($(_this.el).data('markedup')) return;
          return $(_this.el).data('markedup', true).markItUp(_this.config);
        });
        return this;
      };

      return HtmlEditor;

    })(x.Component);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.shared', function(x) {
    return x.Navigation = (function(_super) {

      __extends(Navigation, _super);

      function Navigation() {
        Navigation.__super__.constructor.apply(this, arguments);
      }

      Navigation.prototype.className = function() {
        return "" + Navigation.__super__.className.apply(this, arguments) + " navigation secondary";
      };

      Navigation.prototype.templateName = 'shared/_navigation';

      return Navigation;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.shared', function(x) {
    return x.Paginator = (function(_super) {

      __extends(Paginator, _super);

      function Paginator() {
        this.clear = __bind(this.clear, this);
        this.flipPage = __bind(this.flipPage, this);
        var _base, _base2;
        Paginator.__super__.constructor.apply(this, arguments);
        this.collection.bind('reset', this.render);
        (_base = this.options).num_display_entries || (_base.num_display_entries = 3);
        (_base2 = this.options).num_edge_entries || (_base2.num_edge_entries = 1);
      }

      Paginator.prototype.className = function() {
        return "" + Paginator.__super__.className.apply(this, arguments) + " paginator";
      };

      Paginator.prototype.flipPage = function(page) {
        if (!this.firstFlip) {
          this.firstFlip = true;
          return false;
        }
        this.parent.loading(true);
        this.collection.search({
          page: page + 1
        });
        return false;
      };

      Paginator.prototype.clear = function() {
        this.paginated = false;
        return this.firstFlip = false;
      };

      Paginator.prototype.render = function() {
        Paginator.__super__.render.apply(this, arguments);
        if (this.paginated) return false;
        this.paginated = true;
        $(this.el).pagination(this.collection.total_entries + 0, {
          callback: this.flipPage,
          items_per_page: this.collection.per_page,
          num_display_entries: this.options.num_display_entries,
          num_edge_entries: this.options.num_edge_entries,
          prev_text: '&lt;',
          next_text: '&gt;'
        });
        return this;
      };

      return Paginator;

    })(x.Component);
  });

}).call(this);


/*
  RichText is for displaying sanitized HTML with some basic rich text
  components such as a bio or blurb.
*/

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.shared', function(x) {
    return x.RichText = (function(_super) {

      __extends(RichText, _super);

      function RichText() {
        this.render = __bind(this.render, this);        RichText.__super__.constructor.apply(this, arguments);
        this.model.bind("change:" + this.options.attribute, this.render);
      }

      RichText.prototype.className = function() {
        return "" + RichText.__super__.className.apply(this, arguments) + " rich-text";
      };

      RichText.prototype.render = function() {
        RichText.__super__.render.apply(this, arguments);
        $(this.el).html(this.model.get(this.options.attribute));
        return this;
      };

      return RichText;

    })(x.Component);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.shared', function(x) {
    return x.SelectBox = (function(_super) {

      __extends(SelectBox, _super);

      function SelectBox() {
        var _base;
        SelectBox.__super__.constructor.apply(this, arguments);
        if ((_base = this.templateOptions).blankOption == null) {
          _base.blankOption = '';
        }
      }

      SelectBox.prototype.templateName = 'shared/_select_options';

      SelectBox.prototype.tagName = 'select';

      SelectBox.prototype.val = function() {
        return $(this.el).val();
      };

      SelectBox.prototype.render = function() {
        SelectBox.__super__.render.apply(this, arguments);
        return this;
      };

      return SelectBox;

    })(x.Component);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.shared', function(x) {
    return x.Spinner = (function(_super) {

      __extends(Spinner, _super);

      function Spinner() {
        this.render = __bind(this.render, this);
        Spinner.__super__.constructor.apply(this, arguments);
      }

      Spinner.prototype.templateName = 'layouts/_spinner';

      Spinner.prototype.id = "spinner";

      Spinner.prototype.render = function() {
        Spinner.__super__.render.apply(this, arguments);
        $(this.el).html("<img src='/assets/images/application/loading_facebook.gif' />");
        $(this.el).ajaxStart(function() {
          return $(this).show();
        }).ajaxStop(function() {
          return $(this).hide();
        });
        return this;
      };

      return Spinner;

    })(x.View);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.shared', function(x) {
    return x.TextEditor = (function(_super) {

      __extends(TextEditor, _super);

      function TextEditor() {
        this._render = __bind(this._render, this);
        this.render = __bind(this.render, this);
        this.initialize = __bind(this.initialize, this);
        TextEditor.__super__.constructor.apply(this, arguments);
      }

      TextEditor.prototype.defaultConfig = {
        rmUnusedControls: true,
        css: '/stylesheets/compiled/jwysiwyg_iframe.css',
        rmUnwantedBr: true,
        initialContent: '',
        iFrameClass: 'iframe-default',
        controls: {
          bold: {
            visible: true
          },
          italic: {
            visible: true
          },
          underline: {
            visible: true
          },
          strikeThrough: {
            visible: true
          },
          separator: true,
          insertOrderedList: {
            visible: true
          },
          insertUnorderedList: {
            visible: true
          },
          separator: true,
          insertTable: {
            visible: true
          },
          createLink: {
            visible: true
          },
          html: {
            visible: false
          },
          undo: {
            visible: false
          },
          redo: {
            visible: false
          }
        }
      };

      TextEditor.prototype.tagName = 'textarea';

      TextEditor.prototype.id = 'text_editor';

      TextEditor.prototype.initialize = function() {
        TextEditor.__super__.initialize.apply(this, arguments);
        this.config || (this.config = {});
        return $.extend(true, this.config, this.defaultConfig);
      };

      TextEditor.prototype.destroy = function() {
        return $(this.el).wysiwyg('destroy');
      };

      TextEditor.prototype.clear = function() {
        return $(this.el).wysiwyg('clear');
      };

      TextEditor.prototype.getContent = function() {
        return $(this.el).wysiwyg('getContent');
      };

      TextEditor.prototype.setContent = function(html) {
        return $(this.el).wysiwyg('setContent', html);
      };

      TextEditor.prototype.addTokenPicker = function() {
        var pickerHTML, tokenPicker;
        pickerHTML = this.template('text_editor/_token_picker');
        tokenPicker = {
          groupIndex: 2,
          icon: '/stylesheets/vendor/jwysiwyg/quote02.gif',
          visible: true,
          exec: function() {
            var _this = this;
            if ($.wysiwyg.controls && $.wysiwyg.controls.tokenPicker) {
              return $.wysiwyg.controls.tokenPicker(this, pickerHTML);
            } else if ($.wysiwyg.autoload) {
              return $.wysiwyg.autoload.control("wysiwyg.tokenpicker.js", function() {
                return _this.controls.insertToken.exec.apply(_this);
              });
            } else {
              throw '$.wysiwyg.controls.tokenPicker not defined.\nYou need to include wysiwyg.tokenpicker.js file';
            }
          },
          tags: ["tokens"],
          tooltip: "Insert token"
        };
        return $(this.el).wysiwyg('addControl', 'tokenPicker', tokenPicker);
      };

      TextEditor.prototype.addHtmlControl = function() {
        return this.config.controls.html.visible = true;
      };

      TextEditor.prototype.render = function() {
        TextEditor.__super__.render.apply(this, arguments);
        setTimeout(this._render);
        return this;
      };

      TextEditor.prototype._render = function() {
        if (!$.wysiwyg) return;
        $(this.el).wysiwyg(this.config);
        if (this.config.controls.tokenPicker != null) return this.addTokenPicker();
      };

      return TextEditor;

    })(x.Component);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.shared', function(x) {
    return x.TimePicker = (function(_super) {

      __extends(TimePicker, _super);

      function TimePicker() {
        this._adjustWith = __bind(this._adjustWith, this);
        this._notify = __bind(this._notify, this);
        this.render = __bind(this.render, this);
        this.setTime = __bind(this.setTime, this);
        this.getTime = __bind(this.getTime, this);
        TimePicker.__super__.constructor.apply(this, arguments);
      }

      TimePicker.prototype.initialize = function() {
        return TimePicker.__super__.initialize.apply(this, arguments);
      };

      TimePicker.prototype.events = {
        'change': '_notify'
      };

      TimePicker.prototype.config = {
        show24Hours: false,
        step: 15
      };

      TimePicker.prototype.tagName = 'input';

      TimePicker.prototype.getTime = function() {
        return $.timePicker(this.el).getTime();
      };

      TimePicker.prototype.setTime = function(date) {
        if (date != null) return $.timePicker(this.el).setTime(date);
      };

      TimePicker.prototype.render = function() {
        TimePicker.__super__.render.apply(this, arguments);
        $(this.el).timePicker(this.config);
        return this;
      };

      TimePicker.prototype._notify = function() {
        this.trigger('change', this);
        return this._adjustWith();
      };

      TimePicker.prototype._adjustWith = function() {
        if (!this.options["with"]) return;
        return this.options["with"].setTime(moment(this.getTime()).add('h', 1)["native"]());
      };

      return TimePicker;

    })(x.Component);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.shared', function(x) {
    return x.ToolTip = (function(_super) {

      __extends(ToolTip, _super);

      function ToolTip() {
        ToolTip.__super__.constructor.apply(this, arguments);
      }

      ToolTip.prototype.config = {
        content: {
          text: '',
          title: {
            text: ''
          }
        },
        style: {
          classes: 'ui-tooltip-pathable ui-tooltip-rounded ui-tooltip-shadow'
        },
        show: {
          when: 'mouseover',
          delay: 5
        },
        hide: {
          when: 'mouseout',
          fixed: true
        },
        position: {
          my: 'bottom center',
          at: 'top center',
          effect: true,
          adjust: {
            y: 10
          }
        }
      };

      ToolTip.prototype.reposition = function() {
        return $(this.el).qtip('reposition');
      };

      ToolTip.prototype.disable = function(state) {
        return this.$(this.options.target).qtip(state ? 'disable' : 'enable');
      };

      ToolTip.prototype.render = function() {
        var _this = this;
        ToolTip.__super__.render.apply(this, arguments);
        if (this.options.content != null) {
          this.config.content.text = this.$(this.options.content).clone();
        }
        if (this.options.title != null) {
          this.config.content.title.text = this.$(this.options.title);
        }
        this.config.events = {
          render: function(event, qtip) {
            return _this.trigger('render', event, qtip);
          }
        };
        this.options.target.qtip(this.config);
        return this;
      };

      return ToolTip;

    })(x.Component);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.shared', function(x) {
    return x.Uploadify = (function(_super) {

      __extends(Uploadify, _super);

      function Uploadify(options) {
        Uploadify.__super__.constructor.apply(this, arguments);
        _.bindAll(this, 'render');
        if (options != null) {
          this.fileExt = options.fileExt;
          this.fileDesc = options.fileDesc;
        }
      }

      Uploadify.prototype.tagName = 'input';

      Uploadify.prototype.clear = function() {
        return this.attachment = null;
      };

      Uploadify.prototype.processUpload = function() {
        var csrf_param, csrf_token, params,
          _this = this;
        if (this.attachment != null) return true;
        params = {};
        csrf_token = $('meta[name=csrf-token]').attr('content');
        csrf_param = $('meta[name=csrf-param]').attr('content');
        params[csrf_param] = encodeURIComponent(csrf_token);
        params[P.session.get('session_key')] = P.session.get('session');
        $(this.el).attr('id', "" + ($(this.el).attr('id')) + "_" + (this._randomId()));
        return $(this.el).uploadify({
          uploader: '/flashes/uploadify.swf',
          script: '/attachments',
          checkExisting: false,
          cancelImg: 'assets/images/uploadify/cancel.png',
          fileDataName: 'attachment[attachment]',
          fileExt: this.fileExt || '*.jpg;*.gif;*.png',
          fileDesc: this.fileDesc || 'Image Files (.JPG, .GIF, .PNG)',
          sizeLimit: 3145728,
          auto: true,
          debug: P.development,
          scriptData: params,
          onError: function(e) {
            return P.logger.error('Uploadify error:');
          },
          onComplete: function(event, queueID, fileObj, response, data) {
            data = JSON.parse(response);
            _this.attachment = new P.models.Attachment(data);
            P.logger.debug("Successfully uploaded file and created attachment " + _this.attachment.id);
            return true;
          }
        });
      };

      Uploadify.prototype.render = function() {
        var _this = this;
        Uploadify.__super__.render.apply(this, arguments);
        setTimeout(function() {
          if ($(_this.el).data('uploadified')) return;
          $(_this.el).data('uploadified', true);
          _this.clear();
          return _this.processUpload();
        }, 0);
        return this;
      };

      Uploadify.prototype._randomId = function() {
        return Math.floor(new Date().getTime() * Math.random());
      };

      return Uploadify;

    })(x.Component);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; },
    __indexOf = Array.prototype.indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };

  P.namespace('P.views.shared.auto_suggest', function(x) {
    return x.AutoSuggest = (function(_super) {

      __extends(AutoSuggest, _super);

      AutoSuggest.prototype.events = function() {
        return _.extend(AutoSuggest.__super__.events.apply(this, arguments), {
          click: 'focusInput'
        });
      };

      AutoSuggest.prototype.className = 'suggest';

      function AutoSuggest() {
        this._isAll = __bind(this._isAll, this);
        this._remove = __bind(this._remove, this);
        this._select = __bind(this._select, this);
        this._source = __bind(this._source, this);
        this._clearAllGroup = __bind(this._clearAllGroup, this);
        this._restrictSearchClass = __bind(this._restrictSearchClass, this);
        this._keydown = __bind(this._keydown, this);
        this.focusInput = __bind(this.focusInput, this);
        var Search, _base,
          _this = this;
        AutoSuggest.__super__.constructor.apply(this, arguments);
        _.defaults(this.options, {
          fixed: 0,
          choicesClassName: 'as-selections'
        });
        this.search = new (Search = (function(_super2) {

          __extends(Search, _super2);

          function Search() {
            Search.__super__.constructor.apply(this, arguments);
          }

          return Search;

        })(P.models.Collection))([], {
          searchOptions: this.options.searchOptions || {}
        });
        (_base = this.options).disableFreeForm || (_base.disableFreeForm = false);
        if (this.options.valueTransformer != null) {
          this.valueTransformer = this.options.valueTransformer;
        }
        this.collection || (this.collection = new P.models.Collection());
        this.items = new Backbone.List({
          tagName: 'ul',
          className: this.options.choicesClassName,
          collection: this.collection,
          itemType: x.Choice,
          itemOptions: function() {
            return {
              read_only: !_this.enabled
            };
          }
        });
        this.items.bind('remove', this._remove);
        this.collection.bind('add', this._restrictSearchClass);
        this.collection.bind('remove', this._restrictSearchClass);
        this.collection.bind('add', this._clearAllGroup);
        this.input = $('<input>');
        this.inputLi = $('<li class="as-input"></li>').append(this.input);
        $(this.items.el).append(this.inputLi);
        _.each('add remove'.split(/\s+/), function(event) {
          return _this.items.bind(event, function() {
            return _this.inputLi.before(_this.inputLi.find('~li'));
          });
        });
        this.enabled || (this.enabled = true);
        if (this.enabled) {
          this.enable();
        } else {
          this.disable();
        }
      }

      AutoSuggest.prototype.enable = function() {
        this.enabled = true;
        this.input.prop('disabled', false);
        return this.input.prop('hidden', false);
      };

      AutoSuggest.prototype.disable = function() {
        this.enabled = false;
        this.input.prop('disabled', true);
        return this.input.prop('hidden', true);
      };

      AutoSuggest.prototype.focusInput = function() {
        return this.focus(this.input);
      };

      AutoSuggest.prototype.clear = function() {
        return this.collection.reset([]);
      };

      AutoSuggest.prototype.valueTransformer = function(value) {
        return value;
      };

      AutoSuggest.prototype.buildModel = function(value) {
        var isEmail;
        isEmail = value.match(/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i);
        if (isEmail) {
          return new P.models.User({
            primary_email: value
          });
        } else if (this.collection.model === P.models.Label) {
          return new P.models.Label({
            name: value,
            friendly_name: value
          });
        } else if (this._isAll(value)) {
          return new P.models.AllGroup();
        } else {
          return new P.models.Tag({
            friendly_name: value
          });
        }
      };

      AutoSuggest.prototype.render = function() {
        var _this = this;
        AutoSuggest.__super__.render.apply(this, arguments);
        this.append(this.items);
        $(this.input).autocomplete({
          html: true,
          select: this._select,
          source: this._source,
          focus: function(e, ui) {
            $(e.target).val('');
            return false;
          },
          close: function(e, ui) {
            $(e.target).val('');
            return true;
          },
          change: function(e, ui) {
            $(e.target).val('');
            return true;
          },
          create: function(e, ui) {
            _this.trigger('created');
            return _this.input.keydown(_this._keydown);
          }
        });
        return this;
      };

      AutoSuggest.prototype._keydown = function(e) {
        var BACKSPACE, COMMA, ENTER, SPACE, TAB, val, _ref;
        _ref = jQuery.ui.keyCode, TAB = _ref.TAB, COMMA = _ref.COMMA, ENTER = _ref.ENTER, SPACE = _ref.SPACE, BACKSPACE = _ref.BACKSPACE;
        val = this.input.val();
        if ((this.options.maxChoices != null) && this.collection.length >= this.options.maxChoices && e.keyCode !== BACKSPACE && e.keyCode !== TAB) {
          e.preventDefault();
        }
        switch (e.keyCode) {
          case TAB:
          case COMMA:
          case ENTER:
            if (!val || this.options.disableFreeForm && !this._isAll(val)) return;
            if ((this.options.maxChoices != null) && this.collection.length >= this.options.maxChoices) {
              return;
            }
            e.preventDefault();
            this.collection.add(this.buildModel(val));
            return this.input.val('');
          case BACKSPACE:
            if (!val || this.collection.length > this.options.fixed) return;
            e.preventDefault();
            return this.collection.remove(this.collection.last());
        }
      };

      AutoSuggest.prototype._restrictSearchClass = function(model) {
        var className, _ref, _ref2;
        if ((_ref = this.search.searchOptions) != null ? (_ref2 = _ref.classes) != null ? _ref2.length : void 0 : void 0) {
          return;
        }
        if (this.collection.isEmpty() || model instanceof P.models.AllGroup) {
          return this.search.searchOptions.classes = ['User', 'Groups::Tag'];
        } else {
          className = this.collection.first().className;
          if (className === 'Attendance') className = 'User';
          return this.search.searchOptions.classes = [className];
        }
      };

      AutoSuggest.prototype._clearAllGroup = function() {
        if (!(this.collection.length > 1)) return;
        return this.collection.remove(this.collection.detect(function(m) {
          return m instanceof P.models.AllGroup;
        }));
      };

      AutoSuggest.prototype._source = function(request, response) {
        var _this = this;
        _.extend(this.search.searchOptions, {
          query: request.term,
          "with": {
            community_id: P.association.id
          }
        });
        return this.search.fetch({
          success: function(results) {
            var models;
            models = results.filter(function(model) {
              var classes;
              classes = _this.search.searchOptions.classes;
              return _.any([model.className, model.get('class_name')], function(c) {
                return __indexOf.call(classes, c) >= 0;
              });
            });
            return response(_.map(models, function(model) {
              return {
                label: new x.Label({
                  model: model
                }).render().el,
                value: model
              };
            }));
          }
        });
      };

      AutoSuggest.prototype._select = function(e, ui) {
        var model, _ref;
        e.preventDefault();
        model = (_ref = ui.item) != null ? _ref.value : void 0;
        if (!(model != null) || (model instanceof P.models.AllGroup && !this.collection.isEmpty())) {
          return true;
        }
        if ((this.options.maxChoices != null) && this.collection.length >= this.options.maxChoices) {
          return true;
        }
        this.input.val('');
        return this.collection.add(this.valueTransformer(model));
      };

      AutoSuggest.prototype._remove = function(model) {
        return this.collection.remove(model);
      };

      AutoSuggest.prototype._isAll = function(val) {
        return /^all$/i.test(val);
      };

      return AutoSuggest;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.shared.auto_suggest', function(x) {
    return x.Choice = (function(_super) {

      __extends(Choice, _super);

      Choice.prototype.tagName = 'li';

      Choice.prototype.templateName = 'shared/auto_suggest/_token';

      Choice.prototype.events = function() {
        return _.extend(Choice.__super__.events.apply(this, arguments), {
          'click': 'remove'
        });
      };

      function Choice() {
        this.clear = __bind(this.clear, this);        Choice.__super__.constructor.apply(this, arguments);
        _.defaults(this.options, {
          fixed: false
        });
        this.label = new x.Label({
          model: this.model
        });
      }

      Choice.prototype.remove = function() {
        if (this.options.fixed) return;
        return this.trigger('remove', this.model);
      };

      Choice.prototype.clear = function() {
        return $(this.el).remove();
      };

      Choice.prototype.render = function() {
        Choice.__super__.render.apply(this, arguments);
        $(this.el).find('.as-token').append(this.label.render().el);
        if (!this.read_only) {
          $(this.el).find('.as-token').button({
            icons: {
              secondary: 'ui-icon-close'
            }
          });
        }
        return this;
      };

      return Choice;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.shared.auto_suggest', function(x) {
    return x.Label = (function(_super) {

      __extends(Label, _super);

      function Label() {
        Label.__super__.constructor.apply(this, arguments);
      }

      Label.prototype.className = 'label';

      Label.prototype.templateName = 'shared/auto_suggest/_label';

      return Label;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };

  P.namespace('P.views.shared', function(x) {
    return x.ButtonSet = (function() {

      function ButtonSet(options) {
        var _this = this;
        this.options = options;
        this.find = __bind(this.find, this);
        this.buttons = [];
        _.each(this.options, function(options) {
          if (options != null) return _this.buttons.push(new x.Button(options));
        });
        if (!(this.primary != null)) this.buttons[0].options.primary = true;
      }

      ButtonSet.prototype.find = function(label) {
        return _.detect(this.buttons, function(button) {
          return button.options.label === label;
        });
      };

      ButtonSet.prototype.get = function(index) {
        return this.buttons[index];
      };

      ButtonSet.prototype.set = function(index, button) {
        return this.buttons[index] = button;
      };

      ButtonSet.prototype.primary = function() {
        return (_.select(this.buttons, function(button) {
          return button.options.primary;
        }))[0];
      };

      return ButtonSet;

    })();
  });

}).call(this);

(function() {
  var Template,
    __slice = Array.prototype.slice;

  Template = P.views.shared.Template;

  P.namespace('P.views.shared.forms', function(x) {
    var FormBuilder, addClass, attrs, humanize;
    addClass = function() {
      var args, s;
      s = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
      return _.uniq(_.compact((s || '').split(/\s+/)).concat(args)).join(' ');
    };
    attrs = function(attrs) {
      var k, v;
      return ((function() {
        var _results;
        _results = [];
        for (k in attrs) {
          v = attrs[k];
          if (!(v != null) || v === false) continue;
          if (v === true) {
            _results.push(" " + k + "='" + k + "'");
          } else {
            _results.push(" " + k + "='" + (v.toString().replace("'", '&quot;')) + "'");
          }
        }
        return _results;
      })()).join('');
    };
    humanize = function(s) {
      return $.trim(s.replace(/^[a-z]|_[a-z]/ig, function(m) {
        return m.toUpperCase().replace(/_/g, ' ');
      }));
    };
    _.extend(Template.prototype, {
      form_template_root: 'shared/forms',
      in_list: 0,
      semantic_for: function(type, model, options, callback) {
        var form, _ref;
        if (!callback) _ref = [{}, options], options = _ref[0], callback = _ref[1];
        callback || (callback = function() {});
        form = new FormBuilder(model, this);
        options["class"] = addClass(options["class"], 'formtastic', form.className());
        if (type === 'form') {
          JST["" + Template.prototype.form_template_root + "/form"]({
            callback: callback,
            attrs: attrs,
            options: options,
            form: form
          }, this);
        } else if (type === 'fields') {
          callback(form);
        }
        return this;
      },
      semantic_form_for: function(model, options, callback) {
        return this.semantic_for.apply(this, ['form'].concat(__slice.call(arguments)));
      },
      semantic_fields_for: function(model, options, callback) {
        return this.semantic_for.apply(this, ['fields'].concat(__slice.call(arguments)));
      }
    });
    return x.FormBuilder = FormBuilder = (function() {

      function FormBuilder(model, context, opt) {
        var _ref;
        this.model = model;
        this.context = context;
        this.opt = opt != null ? opt : {};
        _ref = this.opt, this.namespace = _ref.namespace, this.field = _ref.field, this.index = _ref.index, this.parent = _ref.parent;
      }

      FormBuilder.prototype.className = function() {
        var _ref;
        if (_.isString(this.model)) return this.model;
        return P.funcName((_ref = this.model) != null ? _ref.constructor : void 0).replace(/([A-Z])/g, '_$1').replace(/^_/, '').toLowerCase();
      };

      /*
          Writes a fieldset with className 'buttons'.
      
              <fieldset class="buttons">
                <ol>
                  <!-- buttons... -->
                </ol>
              </fieldset>
      */

      FormBuilder.prototype.buttons = function(options, callback) {
        var wrap, _ref;
        if (!callback) _ref = [{}, options], options = _ref[0], callback = _ref[1];
        callback || (callback = function() {});
        wrap = !!this.context.in_list;
        this.context.in_list++;
        options["class"] = addClass(options["class"], 'buttons');
        JST["" + Template.prototype.form_template_root + "/buttons"]({
          attrs: attrs,
          options: options,
          callback: callback,
          wrap: wrap
        }, this.context);
        this.context.in_list--;
      };

      /*
          Writes a fieldset with className 'inputs'.
      
            <fieldset class="inputs">
              <ol>
                <!-- fields... -->
              </ol>
            </fieldset>
      
          If `options.for` is provided, it is equivalent to a nested call to
          `semantic_fields_for` with `options.for`.
      
            <% builder.inputs({'for': 'attr'}, function(f){ %>
              <!-- content... -->
            <% }); %>
      
          is equivalent to:
      
            <% builder.inputs({'for': 'attr'}, function(f){ %>
              <% f.semantic_fields_for('attr', function(f){ %>
                <!-- content... -->
              <% }); %>
            <% }); %>
      */

      FormBuilder.prototype.inputs = function(options, callback) {
        var field, wrap, _ref;
        if (!callback) _ref = [{}, options], options = _ref[0], callback = _ref[1];
        callback || (callback = function() {});
        if (options["for"]) {
          field = options["for"];
          delete options["for"];
          this.semantic_fields_for(field, function(f) {
            return f.inputs(options, callback);
          });
          return;
        }
        wrap = !!this.context.in_list;
        this.context.in_list++;
        options["class"] = addClass(options["class"], 'inputs');
        JST["" + Template.prototype.form_template_root + "/inputs"]({
          attrs: attrs,
          options: options,
          callback: callback,
          wrap: wrap,
          form: this
        }, this.context);
        this.context.in_list--;
      };

      /*
          Creates a new FormBuilder based on `field`.
      
          If `field` is a string, then the corresponding attribute is used as the
          model(s).  If `field` is an object then a new namespace is used.  If
          `field` (or the object in the `field` attribute) is a Backbone
          Collection then its models will be used.
      
          `callback` is executed once for each model in `field`.
      */

      FormBuilder.prototype.semantic_fields_for = function(field, callback) {
        var index, model, models, namespace, opt, _len, _ref;
        if (callback == null) callback = function() {};
        if (field == null) return;
        models = _.isString(field) ? (_ref = this.model) != null ? _ref[field] : void 0 : field;
        if (models instanceof Backbone.Collection) models = models.models;
        if (!_.isArray(models)) models = [models];
        if (models == null) return;
        namespace = this.className();
        if (this.parent) namespace = "" + this.namespace + "_" + this.field;
        opt = null;
        if (_.isString(field)) {
          opt = {
            parent: this,
            namespace: namespace,
            field: field,
            index: index
          };
        }
        for (index = 0, _len = models.length; index < _len; index++) {
          model = models[index];
          callback(new FormBuilder(model, this.context, opt));
        }
      };

      /*
          Writes an input of the following form (input may be a different type,
          e.g. a textarea):
      
            <li id="{id}_input">
              <label for="{id}">{label}</label>
              <input class="{as}" id="{id}" name="{name}">
            </li>
      
          where
      
            {id} = <classname>_<field>
            {name} = <classname>[<field>]
      
          If nested (using semantic_fields_for or inputs)
      
            {id} = <namespace>_<field>_attributes_<index>_<field>
            {name} = <namespace>[<field>_attributes][<index>][<field>]
      
          The list item is only included if the FormBuilder (or one of its
          ancestors) is currently writing an ol (by using inputs).
      
          Attributes on input_html and wrapper_html are added the the input and
          the list item respectively.  New classes are appended to the existing
          class.
      
          If the field name includes the string 'email' or 'password' the input
          type (options.as) will be set appropriately.
      */

      FormBuilder.prototype.input = function(field, opt) {
        var id, name;
        if (opt == null) opt = {};
        if (!opt.as && /password/.test(field)) opt.as = 'password';
        if (!opt.as && /email/.test(field)) opt.as = 'email';
        name = this.parent ? "" + this.namespace + "[" + this.field + "_attributes][" + this.index + "]" : this.className();
        name += "[" + field + "]";
        if (opt.as === 'check_boxes') name += '[]';
        id = this.parent ? "" + this.namespace + "_" + this.field + "_attributes_" + this.index : this.className();
        id += "_" + field;
        opt = _.extend({
          humanize: humanize,
          locales: P.localizer.locales,
          attrs: attrs,
          id: id,
          className: this.className(),
          as: 'string',
          label: humanize(P.localizer.t(field)),
          name: name,
          field: field,
          wrapper_html: {},
          input_html: {},
          collection: []
        }, opt);
        opt.wrapper_html = _.extend({
          "class": "" + field + " input ",
          id: "" + id + "_input"
        }, opt.wrapper_html);
        opt.input_html = _.extend({
          id: id,
          name: opt.name
        }, opt.input_html);
        opt.wrapper_html["class"] = addClass(opt.wrapper_html["class"], opt.as, opt.required ? 'required' : 'optional');
        JST["" + Template.prototype.form_template_root + "/item"]({
          options: opt,
          wrap: !!this.context.in_list,
          form: this
        }, this.context);
      };

      return FormBuilder;

    })();
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.shared.forms', function(x) {
    return x.MultieditForm = (function(_super) {

      __extends(MultieditForm, _super);

      function MultieditForm() {
        MultieditForm.__super__.constructor.apply(this, arguments);
      }

      MultieditForm.prototype.addTextInputsValues = function(values, attrs) {
        var _this = this;
        return _.each(attrs, function(attr) {
          var selector, value;
          selector = "input#" + _this.namespace + "_" + attr;
          value = _this.$(selector).get(0).value;
          if (value !== "") return values[attr] = value;
        });
      };

      MultieditForm.prototype.addTristatesValues = function(values, attrs) {
        var _this = this;
        return _.each(attrs, function(attr) {
          var selector, state;
          selector = "." + attr + " input";
          state = _this.$(selector).getState();
          if (state !== 'intermediate') return values[attr] = state === 'checked';
        });
      };

      MultieditForm.prototype.addGroupTristatesValues = function(values, attrs) {
        var _this = this;
        return _.each(attrs, function(attr) {
          var dirtyBoxes, selector;
          selector = "." + attr + " :checkbox";
          dirtyBoxes = _.reject(_this.$(selector), function(cb) {
            return $(cb).getState() === 'intermediate';
          });
          if (dirtyBoxes.length <= 0) return;
          values["add_" + attr] = _.reject(dirtyBoxes, function(box) {
            return $(box).getState() !== 'checked';
          }).map(function(box) {
            return box.value;
          });
          return values["remove_" + attr] = _.reject(dirtyBoxes, function(box) {
            return $(box).getState() !== 'unchecked';
          }).map(function(box) {
            return box.value;
          });
        });
      };

      return MultieditForm;

    })(x.Form);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.shared.forms', function(x) {
    return x.Part = (function(_super) {

      __extends(Part, _super);

      function Part() {
        Part.__super__.constructor.apply(this, arguments);
        _.bindAll(this, 'bubble', 'save');
        this.bind('error', this.bubble);
      }

      Part.prototype.bubble = function() {
        return this.parent.trigger('error');
      };

      Part.prototype.formValues = function() {
        throw 'RuntimeError: "formValues" method must be implemented!';
      };

      Part.prototype.save = function() {
        return this.parent.save();
      };

      Part.prototype.render = function() {
        if (this.model == null) return false;
        Part.__super__.render.apply(this, arguments);
        this.replaceWith('.controls', this.buttons);
        return this;
      };

      return Part;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.shared.mobile', function(x) {
    return x.DateTimePicker = (function(_super) {

      __extends(DateTimePicker, _super);

      DateTimePicker.prototype.tagName = 'input';

      DateTimePicker.prototype.config = {
        preset: 'datetime',
        theme: 'ios',
        stepMinute: 5
      };

      DateTimePicker.prototype.events = {
        'change': '_notify'
      };

      function DateTimePicker() {
        this._adjustWith = __bind(this._adjustWith, this);
        this._notify = __bind(this._notify, this);
        this.getDateTime = __bind(this.getDateTime, this);
        this.setDateTime = __bind(this.setDateTime, this);
        this.initialize = __bind(this.initialize, this);        DateTimePicker.__super__.constructor.apply(this, arguments);
      }

      DateTimePicker.prototype.initialize = function() {
        return DateTimePicker.__super__.initialize.apply(this, arguments);
      };

      DateTimePicker.prototype.setDateTime = function(dateTime) {
        var values;
        dateTime = moment(dateTime);
        values = this.config.preset === 'datetime' ? [dateTime.month(), dateTime.date(), dateTime.year(), dateTime.hours(), dateTime.minutes(), 'pm'] : [dateTime.hours(), dateTime.minutes()];
        return $(this.el).scroller('setValue', values);
      };

      DateTimePicker.prototype.getDateTime = function() {
        return $(this.el).scroller('getDate');
      };

      DateTimePicker.prototype.render = function() {
        DateTimePicker.__super__.render.apply(this, arguments);
        $(this.el).scroller(this.config);
        return this;
      };

      DateTimePicker.prototype._notify = function() {
        this.trigger('change', this);
        return this._adjustWith();
      };

      DateTimePicker.prototype._adjustWith = function() {
        if (!this.options["with"]) return;
        return this.options["with"].setDateTime(moment(this.getDateTime()).add('minutes', 30)["native"]());
      };

      return DateTimePicker;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.shared.mobile.form', function(x) {
    return x.Form = (function(_super) {

      __extends(Form, _super);

      function Form() {
        this.render = __bind(this.render, this);
        this.initialize = __bind(this.initialize, this);
        Form.__super__.constructor.apply(this, arguments);
      }

      Form.prototype.initialize = function() {
        Form.__super__.initialize.apply(this, arguments);
        return P.views.shared.Template.prototype.form_template_root = 'shared/mobile/forms';
      };

      Form.prototype.render = function() {
        Form.__super__.render.apply(this, arguments);
        return this;
      };

      return Form;

    })(P.views.shared.forms.Form);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.shared.mobile.lists', function(x) {
    return x.List = (function(_super) {

      __extends(List, _super);

      function List() {
        this._refresh = __bind(this._refresh, this);
        this.render = __bind(this.render, this);
        List.__super__.constructor.apply(this, arguments);
      }

      List.prototype.tagName = 'ul';

      List.prototype.initialize = function() {
        var _this = this;
        List.__super__.initialize.apply(this, arguments);
        if (this.options.title) {
          this.title = new x.Title({
            templateOptions: {
              title: this.options.title
            }
          });
        }
        $(this.el).attr({
          'data-role': 'listview',
          'data-inset': 'true'
        });
        return _.each(['add', 'reset'], function(event) {
          return _this.collection.bind(event, _this._refresh);
        });
      };

      List.prototype.render = function() {
        List.__super__.render.apply(this, arguments);
        this._refresh();
        return this;
      };

      List.prototype._refresh = function() {
        if ((this.title != null) && !this.collection.isEmpty()) {
          this.$el.prepend(this.title);
        }
        if ($.data(this.el, 'listview')) return $(this.el).listview('refresh');
      };

      return List;

    })(Backbone.List);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.shared.mobile.lists', function(x) {
    return x.More = (function(_super) {

      __extends(More, _super);

      function More() {
        this.render = __bind(this.render, this);
        this.showMore = __bind(this.showMore, this);
        More.__super__.constructor.apply(this, arguments);
      }

      More.prototype.events = function() {
        return _.extend(More.__super__.events.apply(this, arguments), {
          'click .show_more': 'showMore'
        });
      };

      More.prototype.templateName = 'shared/mobile/lists/_more';

      More.prototype.className = 'more';

      More.prototype.initialize = function() {
        var _this = this;
        More.__super__.initialize.apply(this, arguments);
        return this.collection.bind('reset', function() {
          _this.$('.loading').hide();
          return _this.$('.more').toggle(_this.collection.total_entries > _this.collection.length);
        });
      };

      More.prototype.showMore = function() {
        var _base, _base2,
          _this = this;
        (_base = ((_base2 = this.collection).searchOptions || (_base2.searchOptions = {}))).page || (_base.page = 0);
        this.collection.searchOptions.page += 1;
        this.$('.loading').show();
        this.$('.more').hide();
        this.collection.fetch({
          add: true,
          silent: true,
          success: function() {
            return _this.collection.trigger('reset');
          }
        });
        return this;
      };

      More.prototype.render = function() {
        More.__super__.render.apply(this, arguments);
        return this;
      };

      return More;

    })(P.views.shared.mobile.View);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.shared.mobile.lists', function(x) {
    return x.Search = (function(_super) {

      __extends(Search, _super);

      function Search() {
        this.render = __bind(this.render, this);
        this.search = __bind(this.search, this);
        this.showMore = __bind(this.showMore, this);
        Search.__super__.constructor.apply(this, arguments);
      }

      Search.prototype.events = function() {
        return _.extend(Search.__super__.events.apply(this, arguments), {
          'click .show_more': 'showMore',
          'submit form.search': 'search'
        });
      };

      Search.prototype.templateName = 'shared/mobile/lists/_search';

      Search.prototype.initialize = function() {
        var _this = this;
        Search.__super__.initialize.apply(this, arguments);
        this.list = this.options.list;
        this.collection = this.list.collection;
        this.collection.bind('reset', function() {
          _this.$('.loading').hide();
          _this.$('.results').show();
          _this.$('.more').toggle(_this.collection.total_entries > _this.collection.length);
          return _this.list.$el.show();
        });
        return this.search();
      };

      Search.prototype.showMore = function() {
        var _base, _base2,
          _this = this;
        (_base = ((_base2 = this.collection).searchOptions || (_base2.searchOptions = {}))).page || (_base.page = 0);
        this.collection.searchOptions.page += 1;
        this.$('.loading').show();
        this.$('.more').hide();
        this.collection.fetch({
          add: true,
          silent: true,
          success: function() {
            return _this.collection.trigger('reset');
          }
        });
        return this;
      };

      Search.prototype.search = function(e) {
        if (e != null) e.preventDefault();
        this.list.$el.hide();
        this.$('.loading').show();
        this.$('.more,.results').hide();
        this.collection.search({
          query: this.$("input.query").val() || '',
          page: 1,
          per_page: 50
        });
        return this;
      };

      Search.prototype.render = function() {
        Search.__super__.render.apply(this, arguments);
        this.replaceWith('ul.list', this.list);
        return this;
      };

      return Search;

    })(P.views.shared.mobile.View);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.shared.mobile.lists', function(x) {
    return x.Title = (function(_super) {

      __extends(Title, _super);

      function Title() {
        this.render = __bind(this.render, this);
        this.initialize = __bind(this.initialize, this);
        Title.__super__.constructor.apply(this, arguments);
      }

      Title.prototype.templateName = 'shared/mobile/lists/_title';

      Title.prototype.className = function() {
        return "" + Title.__super__.className.apply(this, arguments) + " ";
      };

      Title.prototype.tagName = 'li';

      Title.prototype.initialize = function() {
        return Title.__super__.initialize.apply(this, arguments);
      };

      Title.prototype.render = function() {
        Title.__super__.render.apply(this, arguments);
        $(this.el).attr('data-role', 'list-divider');
        return this;
      };

      return Title;

    })(P.views.shared.mobile.View);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.shared.mobile', function(x) {
    return x.Page = (function(_super) {

      __extends(Page, _super);

      Page.prototype.attributes = {
        'data-role': 'page',
        'data-theme': 'x'
      };

      Page.prototype._title = function(title) {
        if (title == null) title = this.options.title || this.title;
        if (_.isFunction(title)) {
          return title();
        } else {
          return title || '';
        }
      };

      function Page() {
        this._title = __bind(this._title, this);        Page.__super__.constructor.apply(this, arguments);
        $(this.el).bind('pagebeforecreate', this.render);
      }

      return Page;

    })(P.views.shared.mobile.View);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.shared', function(x) {
    return x.Table = (function(_super) {

      __extends(Table, _super);

      function Table() {
        this.destroy = __bind(this.destroy, this);        Table.__super__.constructor.apply(this, arguments);
        this.table = new this.tableConstructor({
          parent: this
        });
      }

      Table.prototype.tableConstructor = x.tables.Table;

      Table.prototype.destroy = function() {
        return this.table.destroy();
      };

      return Table;

    })(x.HostPage);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.shared.tables', function(x) {
    return x.ControllableRow = (function(_super) {

      __extends(ControllableRow, _super);

      function ControllableRow() {
        this._select = __bind(this._select, this);
        this.render = __bind(this.render, this);
        this.toggle = __bind(this.toggle, this);
        this.unselect = __bind(this.unselect, this);
        this.select = __bind(this.select, this);
        this.destroy = __bind(this.destroy, this);
        this.edit = __bind(this.edit, this);
        this.initialize = __bind(this.initialize, this);
        ControllableRow.__super__.constructor.apply(this, arguments);
      }

      ControllableRow.prototype.initialize = function() {
        ControllableRow.__super__.initialize.apply(this, arguments);
        this.selected = false;
        this.bind('select', this.select);
        this.bind('unselect', this.unselect);
        return this.bind('toggle', this.toggle);
      };

      ControllableRow.prototype.events = function() {
        return _.extend(ControllableRow.__super__.events.apply(this, arguments), {
          "click .controls input": 'toggle',
          "click": 'edit'
        });
      };

      ControllableRow.prototype.edit = function(e) {
        if ($(e.target).is('.controls input')) return true;
        P.logger.trace('Editing row for model: ', this.model);
        return this.parent.parent.edit.open(this.model);
      };

      ControllableRow.prototype.destroy = function(e) {
        e.preventDefault();
        return this.model.destroy();
      };

      ControllableRow.prototype.select = function() {
        return this._select(true);
      };

      ControllableRow.prototype.unselect = function() {
        return this._select(false);
      };

      ControllableRow.prototype.toggle = function(e) {
        e.stopPropagation();
        return this._select(!this.selected);
      };

      ControllableRow.prototype.render = function() {
        ControllableRow.__super__.render.apply(this, arguments);
        this.$('td:first').html(this.controlHTML());
        return this;
      };

      ControllableRow.prototype.controlHTML = function() {
        return '<div class="controls">\n  <input class="domID" type="checkbox">\n</div>';
      };

      ControllableRow.prototype._select = function(selected) {
        this.selected = selected;
        $(this.el).toggleClass('highlighted', selected);
        this.$('.controls input').prop('checked', selected);
        return this.trigger((this.selected ? 'selected' : 'unselected'));
      };

      return ControllableRow;

    })(x.Row);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.shared.tables', function(x) {
    return x.Filter = (function(_super) {

      __extends(Filter, _super);

      function Filter() {
        Filter.__super__.constructor.apply(this, arguments);
      }

      Filter.prototype.defaultFilterValue = 'Search...';

      Filter.prototype.getIndex = function(name) {
        return this.parent.dataTable.fnGetColumnIndex(name);
      };

      Filter.prototype.filter = function(name, value) {
        return this.parent.dataTable.fnFilter(value, this.getIndex(name));
      };

      Filter.prototype.ohBehave = function() {
        var that,
          _this = this;
        $(this.el).typeWatch({
          wait: 750,
          highlight: true,
          captureLength: 2,
          callback: function(val) {
            var name;
            if (val === _this.defaultFilterValue) return false;
            name = $(_this)[0].el.name;
            return _this.filter(name, val);
          }
        });
        that = this;
        $(this.el).focus(function() {
          if (this.value !== that.defaultFilterValue) return;
          $(this).addClass('active');
          return $(this).val('');
        });
        return $(this.el).blur(function(i) {
          var name;
          if ($(this).val() !== "") return;
          $(this).removeClass('active');
          $(this).val(that.defaultFilterValue);
          name = $(this).attr('name');
          return that.filter(name, '');
        });
      };

      Filter.prototype.selectBehave = function() {
        var that;
        that = this;
        return $(this.el).change(function() {
          var name;
          name = $(this).attr('name');
          return that.filter(name, this.value);
        });
      };

      Filter.prototype.reset = function() {
        return $(this.el).val('');
      };

      Filter.prototype.render = function() {
        Filter.__super__.render.apply(this, arguments);
        if (this.options.column.sFilterType === 'select') {
          this.el = $(this.parent.el).find("tfoot th select[name='" + this.options.column.sName + "']").get(0);
          this.selectBehave();
        } else {
          this.el = $(this.parent.el).find("tfoot th input[name='" + this.options.column.sName + "']").get(0);
          this.ohBehave();
        }
        return this;
      };

      return Filter;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.shared.tables', function(x) {
    return x.InlineTable = (function(_super) {

      __extends(InlineTable, _super);

      function InlineTable() {
        InlineTable.__super__.constructor.apply(this, arguments);
        _.bindAll(this, 'renderRows');
      }

      InlineTable.prototype.bindRenderRows = function() {
        return this.collection.bind('reset', this.renderRows);
      };

      InlineTable.prototype.renderRows = function() {
        var _this = this;
        return this.collection.each(function(model) {
          var row;
          row = new _this.rowConstructor({
            model: model,
            parent: _this
          });
          return _this.dataTable.fnAddTr(row.render().el);
        });
      };

      return InlineTable;

    })(x.Table);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.shared.tables', function(x) {
    return x.NavRow = (function(_super) {

      __extends(NavRow, _super);

      function NavRow() {
        this.edit = __bind(this.edit, this);
        NavRow.__super__.constructor.apply(this, arguments);
      }

      NavRow.prototype.edit = function(e) {
        if ($(e.target).is('.controls input')) return true;
        return P.router.redirectTo(this.model.fragment());
      };

      return NavRow;

    })(P.views.shared.tables.ControllableRow);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.shared.tables', function(x) {
    return x.ServerSideTable = (function(_super) {

      __extends(ServerSideTable, _super);

      ServerSideTable.prototype.format = 'json';

      ServerSideTable.prototype.rowConstructor = x.ControllableRow;

      ServerSideTable.prototype.events = function() {
        return _.extend(ServerSideTable.__super__.events.apply(this, arguments), {
          'click input.select-page': '_toggleSelectPage',
          'click a.select-all': '_toggleSelectAll',
          'click a.select-none': '_selectNone'
        });
      };

      function ServerSideTable() {
        this._toggleSelectPage = __bind(this._toggleSelectPage, this);
        this._toggleSelectAll = __bind(this._toggleSelectAll, this);
        this._selectNone = __bind(this._selectNone, this);
        this._allSelectedNotice = __bind(this._allSelectedNotice, this);
        this.render = __bind(this.render, this);
        this.renderRow = __bind(this.renderRow, this);
        this.serverSideCB = __bind(this.serverSideCB, this);
        var _base;
        ServerSideTable.__super__.constructor.apply(this, arguments);
        this.rows = [];
        this.options.serverSide = true;
        this.options.renderRowCB = this.renderRow;
        (_base = this.options).serverSideCB || (_base.serverSideCB = this.serverSideCB);
      }

      ServerSideTable.prototype.serverSideCB = function(sSource, aoData, fnCallback) {
        var _this = this;
        if (this.collection == null) return;
        this._lastRequestSet = aoData;
        this.rows.length = 0;
        return this.collection.fetch({
          data: $.param(aoData.concat({
            name: 'asWildcardAttributes',
            value: this.wildcardColumns || []
          })),
          success: function() {
            var total_entries;
            _this._allSelectedNotice(false);
            total_entries = _this.collection.total_entries || 0;
            return fnCallback({
              iTotalDisplayRecords: total_entries,
              iTotalRecords: total_entries,
              results: _this.collection.map(_this._cleanModel)
            });
          }
        });
      };

      ServerSideTable.prototype.renderRow = function(nRow, aData, iDisplayIndex) {
        var model, row;
        model = this.collection.get(aData.id);
        row = new this.rowConstructor({
          model: model,
          el: nRow,
          parent: this
        });
        row.bind('unselected', this._allSelectedNotice, false);
        this.rows.push(row);
        return row.render().el;
      };

      ServerSideTable.prototype.selected = function() {
        var rows;
        rows = this.rows.filter(function(row) {
          return row.selected;
        });
        if (rows.length === 0) {
          this.flash.show({
            message: P.localizer.t('no_rows_selected', {
              scope: ['tables', 'errors']
            }),
            "class": 'warn'
          }, 'Oops!');
          throw new Error('No rows selected error.');
        }
        if (this.allSelected) {
          return this.collection;
        } else {
          return new this.collection.constructor(rows.map(function(row) {
            return row.model;
          }));
        }
      };

      ServerSideTable.prototype.render = function() {
        ServerSideTable.__super__.render.apply(this, arguments);
        this._allSelectedNotice(false);
        this.$('thead th.selector .DataTables_sort_wrapper').html('<span class="controls"><input class="select-page" type="checkbox"></span>');
        return this;
      };

      ServerSideTable.prototype._allSelectedNotice = function(message) {
        if (message) {
          return this.$('.notice').addClass('active').html(message);
        } else {
          this.allSelected = false;
          this.$('.controls input.select-page').prop('checked', false);
          return this.$('.notice').removeClass('active').html('');
        }
      };

      ServerSideTable.prototype._selectNone = function(e) {
        e.preventDefault();
        return this._toggleSelectPage(false);
      };

      ServerSideTable.prototype._toggleSelectAll = function(e) {
        var _this = this;
        e.preventDefault();
        return this.collection.fetch({
          data: $.param(this._lastRequestSet.concat([
            {
              name: 'bIDsOnly',
              value: true
            }, {
              name: 'iDisplayLength',
              value: 9999
            }, {
              name: 'iDisplayStart',
              value: 0
            }
          ])),
          success: function(collection, results) {
            _this.allSelected = true;
            return _this._allSelectedNotice("All " + _this.collection.length + " rows matching this search are selected. <a class=\"select-none\" href=\"#\">Clear selection</a>");
          }
        });
      };

      ServerSideTable.prototype._toggleSelectPage = function(force) {
        var allSelected,
          _this = this;
        allSelected = (force != null) && !(force instanceof jQuery.Event) ? force : this.$('.controls input.select-page').prop('checked');
        if (allSelected) {
          this._allSelectedNotice("All " + this.rows.length + " rows on this page are selected. <a class=\"select-all\" href=\"#\">Select all " + this.collection.total_entries + " rows matching this search.</a>");
        } else {
          this._allSelectedNotice(false);
        }
        return _.each(this.rows, function(row) {
          return row.trigger(allSelected ? 'select' : 'unselect');
        });
      };

      return ServerSideTable;

    })(x.Table);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.shared.tabs', function(x) {
    return x.Tab = (function(_super) {

      __extends(Tab, _super);

      Tab.prototype.templateName = 'shared/tabs/_tab';

      Tab.prototype.tagName = 'li';

      Tab.prototype.className = function() {
        return "" + Tab.__super__.className.apply(this, arguments) + " primary";
      };

      Tab.prototype.events = function() {
        return _.extend(Tab.__super__.events.apply(this, arguments), {
          'click': 'activate'
        });
      };

      function Tab() {
        Tab.__super__.constructor.apply(this, arguments);
        this.label = this.options.label;
        this.templateOptions.label = this.label;
      }

      Tab.prototype.activate = function(e) {
        e.preventDefault();
        if (!$(this.el).is('.disabled')) return this.trigger('activate', this);
      };

      Tab.prototype.disable = function() {
        return $(this.el).addClass('disabled');
      };

      Tab.prototype.enable = function() {
        return $(this.el).removeClass('disabled');
      };

      return Tab;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.shared.tabs', function(x) {
    return x.Tabs = (function(_super) {

      __extends(Tabs, _super);

      function Tabs() {
        this.select = __bind(this.select, this);
        this.showTabs = __bind(this.showTabs, this);
        this.hideTabs = __bind(this.hideTabs, this);
        this.disable = __bind(this.disable, this);
        Tabs.__super__.constructor.apply(this, arguments);
      }

      Tabs.prototype.templateName = 'shared/tabs/_tabs';

      Tabs.prototype.className = function() {
        return "" + Tabs.__super__.className.apply(this, arguments) + " tabs";
      };

      Tabs.prototype.length = 0;

      Tabs.prototype.initialize = function() {
        Tabs.__super__.initialize.apply(this, arguments);
        this._tabs = {};
        this._tabsIndex = [];
        this._selectors = {};
        return this.add(this.options.tabs || []);
      };

      Tabs.prototype.add = function(tabs) {
        var _this = this;
        if (!_.isArray(tabs)) tabs = [tabs];
        return _.each(_.flatten(tabs), function(tabOptions) {
          var label, tab;
          label = tabOptions.label;
          _this._selectors[label] = tabOptions.selector;
          tab = _this._tabs[label] = new x.Tab({
            label: label
          });
          _this._tabsIndex.push(tab);
          _this.length += 1;
          return tab.bind('activate', function(tab) {
            return _this.activate(tab);
          });
        });
      };

      Tabs.prototype.activate = function(tab) {
        if (!tab) return;
        $(this.el).find('li').removeClass('selected');
        $(tab.el).addClass('selected');
        this.active = tab;
        this._hideContent();
        this._showContent(tab);
        return this.trigger('activate', tab);
      };

      Tabs.prototype.activateNextOrClose = function() {
        var index, _ref, _this;
        _this = this;
        for (index = 0, _ref = this.tabs.length - 1; 0 <= _ref ? index <= _ref : index >= _ref; 0 <= _ref ? index++ : index--) {
          if (_this.tabs[index].label === _this.active.label) {
            return _this.activate(_this._tabs[_this.tabs[index + 1].label]);
          }
        }
        return this.parent.close();
      };

      Tabs.prototype.disable = function(labels) {
        var _this = this;
        labels = _.flatten([labels]);
        return _.each(labels, function(label) {
          var _ref;
          return (_ref = _this.get(label)) != null ? _ref.disable() : void 0;
        });
      };

      Tabs.prototype.enable = function(labels) {
        var _this = this;
        labels = _.flatten([labels]);
        return _.each(labels, function(label) {
          var _ref;
          return (_ref = _this.get(label)) != null ? _ref.enable() : void 0;
        });
      };

      Tabs.prototype.hideTabs = function(labels) {
        var _this = this;
        labels = _.flatten([labels]);
        return _.each(labels, function(label) {
          var _ref;
          return (_ref = _this.get(label)) != null ? _ref.$el.hide() : void 0;
        });
      };

      Tabs.prototype.showTabs = function(labels) {
        var _this = this;
        labels = _.flatten([labels]);
        return _.each(labels, function(label) {
          var _ref;
          return (_ref = _this.get(label)) != null ? _ref.$el.show() : void 0;
        });
      };

      Tabs.prototype.get = function(label) {
        return this._tabs[label];
      };

      Tabs.prototype.goHome = function() {
        return this.activate(this.first());
      };

      Tabs.prototype.select = function(label) {
        return this.activate(this.get(label));
      };

      Tabs.prototype.first = function() {
        return this._tabsIndex[0];
      };

      Tabs.prototype.root = function() {
        return this.$(this.parent.el);
      };

      Tabs.prototype.render = function() {
        var _this = this;
        Tabs.__super__.render.apply(this, arguments);
        this.$('ol').empty();
        _.each(this._tabs, function(tab, key) {
          return _this.$('ol').append(tab.render().el);
        });
        this.goHome();
        return this;
      };

      Tabs.prototype._hideContent = function() {
        var _this = this;
        return _.each(this._selectors, function(selector, label) {
          return _this.root().find(selector).hide();
        });
      };

      Tabs.prototype._showContent = function(tab) {
        return this.root().find(this._selectors[tab.options.label]).show();
      };

      return Tabs;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.users', function(x) {
    return x.FormBasics = (function(_super) {

      __extends(FormBasics, _super);

      FormBasics.prototype.className = function() {
        return "" + FormBasics.__super__.className.apply(this, arguments) + " basics";
      };

      FormBasics.prototype.templateName = 'users/_form_basics';

      FormBasics.prototype.features = [P.views.shared.forms.ErrorsFeature, P.views.shared.forms.FormValueGetFeature, P.views.shared.forms.FormValueSetFeature, P.views.shared.forms.FocusFeature];

      FormBasics.prototype.events = function() {
        return _.extend(FormBasics.__super__.events.apply(this, arguments), {
          'focus input': 'clearFormErrors',
          'click #user_change_password_control a': 'askForPassword'
        });
      };

      function FormBasics() {
        this._optimize = __bind(this._optimize, this);
        this.setAnswers = __bind(this.setAnswers, this);
        this.askForPassword = __bind(this.askForPassword, this);
        this.assignPasswords = __bind(this.assignPasswords, this);
        this.saved = __bind(this.saved, this);        FormBasics.__super__.constructor.apply(this, arguments);
        this.uploadify = new P.views.shared.Uploadify();
        this.answers = new P.views.answers.FormSet();
        this.buttons = new P.views.shared.ControlBar({
          controls: ['save']
        });
        this.bind('saved', this.saved);
        this.bind('edit', this.setup);
        this.model.bind('change:allowed_mails', this._optimize, this);
      }

      FormBasics.prototype.setup = function() {
        var _this = this;
        this.bindErrors({
          handler: function(error, messages) {
            switch (error.attribute) {
              case 'emails.email':
                return _this.flash.show({
                  message: P.localizer.t('email', {
                    scope: ['forms', 'errors'],
                    messages: error.messages.join(', ')
                  }),
                  "class": 'error'
                });
              case 'has_accepted_legal':
                return _this.flash.show({
                  message: P.localizer.t('acceptance', {
                    scope: ['forms', 'errors']
                  }),
                  "class": 'error'
                });
            }
          }
        });
        this.focus(true);
        this.setAnswers();
        this.setValues();
        this.setRibbonIds();
        this.assignPasswords();
        this.assignRoles();
        this._optimize();
        return this.model.bind('change:needs_to_set_password', this.assignPasswords);
      };

      FormBasics.prototype.saved = function() {
        this.uploadify.clear();
        return this.setAnswers();
      };

      FormBasics.prototype.formValues = function() {
        var values, _ref;
        values = {
          roles: _.map(this.$('.roles input:checked'), function(el) {
            return el.value;
          }),
          temp_attachment_id: (_ref = this.uploadify.attachment) != null ? _ref.id : void 0,
          answers_attributes: this.answers.formValues(),
          has_accepted_legal: this.$('.has_accepted_legal input').prop('checked'),
          visible: this.$('.visible input').prop('checked'),
          wants_default_allowed_mails: !this.model.get('dirty') ? this.$('.wants_default_allowed_mails input').prop('checked') : void 0
        };
        _.defaults(values, this.getValues());
        return values;
      };

      FormBasics.prototype.setRibbonIds = function() {
        return $('select#user_ribbon_ids').val(this.model.ribbons.map(function(r) {
          return r.id;
        }));
      };

      FormBasics.prototype.assignRoles = function() {
        var _this = this;
        return _.each(this.model.get('roles'), function(role) {
          return _this.$("#user_roles_" + role).attr('checked', 'checked');
        });
      };

      FormBasics.prototype.assignRoles = function() {
        var _this = this;
        return _.each(this.model.get('roles'), function(role) {
          return _this.$("#user_roles_" + role).attr('checked', 'checked');
        });
      };

      FormBasics.prototype.assignPasswords = function() {
        var control, passwords;
        passwords = this.$('.password');
        control = this.$('#user_change_password_control');
        if (!this.model.get('needs_to_set_password')) {
          P.logger.trace("Hiding password fields.");
          passwords.hide();
          return control.show();
        } else {
          P.logger.trace("Showing password fields.");
          passwords.show();
          return control.hide();
        }
      };

      FormBasics.prototype.askForPassword = function(e) {
        e.preventDefault();
        return this.model.set({
          needs_to_set_password: true
        });
      };

      FormBasics.prototype.setAnswers = function() {
        return this.answers.use(this.model.answers);
      };

      FormBasics.prototype.render = function() {
        FormBasics.__super__.render.apply(this, arguments);
        this.replaceAll('.photo input', this.uploadify);
        this.html('.answers', this.answers);
        return this;
      };

      FormBasics.prototype._optimize = function() {
        this.$('.roles').hide();
        this.$('.ribbon_ids').hide();
        this.$('.send_mail').hide();
        this.$('.has_accepted_legal').toggle(!this.model.get('dirty'));
        this.$('.wants_default_allowed_mails').toggle(!this.model.get('dirty'));
        this.$('.visible input').prop('checked', this.model.get('visible') || !this.model.get('dirty'));
        return this.$('.wants_default_allowed_mails input').prop('checked', true);
      };

      return FormBasics;

    })(P.views.shared.forms.Part);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.users', function(x) {
    return x.FormDetails = (function(_super) {

      __extends(FormDetails, _super);

      FormDetails.prototype.className = function() {
        return "" + FormDetails.__super__.className.apply(this, arguments) + " details";
      };

      FormDetails.prototype.templateName = 'users/_form_details';

      FormDetails.prototype.events = function() {
        return _.extend(FormDetails.__super__.events.apply(this, arguments), {
          'focus input': 'clearFormErrors'
        });
      };

      function FormDetails() {
        this.setAnswers = __bind(this.setAnswers, this);        FormDetails.__super__.constructor.apply(this, arguments);
        this.textEditor = new P.views.shared.TextEditor();
        this.buttons = new P.views.shared.ControlBar({
          controls: ['save']
        });
        this.websites = new P.views.links.FormPart();
        this.twitters = new P.views.links.FormPart({
          templateOptions: {
            label: 'Twitter',
            field_id: 'twitters_list',
            hint: P.localizer.t('twitters_list_hint')
          },
          urlPrefix: 'http://twitter.com/'
        });
        this.bind('edit', this.setup);
      }

      FormDetails.prototype.features = [P.views.shared.forms.ErrorsFeature, P.views.shared.forms.FormValueGetFeature, P.views.shared.forms.FocusFeature];

      FormDetails.prototype.setup = function() {
        this.bindErrors();
        this.assignBio();
        this.websites.use(this.model.links.withoutURL('http://twitter.com/'));
        this.twitters.use(this.model.links.withURL('http://twitter.com/'));
        return this.model.bind('change:answer_attributes', this.setAnswers);
      };

      FormDetails.prototype.formValues = function() {
        var links, values;
        links = (this.websites.getLinks().concat(this.twitters.getLinks())).join(',');
        values = {
          bio: this.textEditor.getContent(),
          link_list: links
        };
        return _.extend(values, this.getValues());
      };

      FormDetails.prototype.assignBio = function() {
        var _this = this;
        return setTimeout((function() {
          return _this.textEditor.setContent(_this.model.get('bio') || '');
        }), 500);
      };

      FormDetails.prototype.setAnswers = function() {
        return this.answers.use(this.model.answers);
      };

      FormDetails.prototype.render = function() {
        FormDetails.__super__.render.apply(this, arguments);
        this.replaceAll('.bio textarea', this.textEditor);
        this.replaceWith('.answers', this.answers);
        this.replaceWith('.websites', this.websites);
        this.replaceWith('.twitters', this.twitters);
        return this;
      };

      return FormDetails;

    })(P.views.shared.forms.Part);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.users', function(x) {
    return x.FormSettings = (function(_super) {

      __extends(FormSettings, _super);

      FormSettings.prototype.className = function() {
        return "" + FormSettings.__super__.className.apply(this, arguments) + " settings";
      };

      FormSettings.prototype.templateName = 'users/_form_settings';

      FormSettings.prototype.events = function() {
        return _.extend(FormSettings.__super__.events.apply(this, arguments), {
          'focus input': 'clearFormErrors',
          'change .enabled_for_email': '_setup'
        });
      };

      function FormSettings() {
        this._setup = __bind(this._setup, this);
        this.render = __bind(this.render, this);
        this.formValues = __bind(this.formValues, this);        FormSettings.__super__.constructor.apply(this, arguments);
        this.buttons = new P.views.shared.ControlBar({
          controls: ['save']
        });
        this.bind('edit', this.setup);
      }

      FormSettings.prototype.features = [P.views.shared.forms.ErrorsFeature, P.views.shared.forms.FormValueGetFeature, P.views.shared.forms.FormValueSetFeature, P.views.shared.forms.FocusFeature];

      FormSettings.prototype.setup = function() {
        var _this = this;
        this.bindErrors();
        this.setValues();
        this._setup();
        return _.each(P.community.get('user_valid_allowed_mails'), function(type) {
          return _this.$(".allowed_mails input[value=" + type + "]").prop('checked', _.include(_this.model.get('allowed_mails'), type));
        });
      };

      FormSettings.prototype.formValues = function() {
        return {
          enabled_for_email: this.$('.enabled_for_email input').prop('checked'),
          allowed_mails: this.model.get('dirty') ? _.map(this.$('.allowed_mails input:checked'), function(el) {
            return el.value;
          }) : void 0
        };
      };

      FormSettings.prototype.render = function() {
        FormSettings.__super__.render.apply(this, arguments);
        this._setup();
        return this;
      };

      FormSettings.prototype._setup = function() {
        return this.$('.allowed_mails').toggle(this.$('.enabled_for_email input').prop('checked'));
      };

      return FormSettings;

    })(P.views.shared.forms.Part);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.users', function(x) {
    return x.Form = (function(_super) {

      __extends(Form, _super);

      Form.prototype.className = function() {
        return "" + Form.__super__.className.apply(this, arguments) + " formtastic";
      };

      Form.prototype.templateName = 'users/_form';

      Form.prototype.events = function() {
        return _.extend(Form.__super__.events.apply(this, arguments), {
          'click button.save': 'save'
        });
      };

      function Form() {
        Form.__super__.constructor.apply(this, arguments);
        this.bind('saved', this.saved);
        this.bind('edit', this.setup);
        this.bind('error', this._error);
      }

      Form.prototype.parts = {
        basics: P.views.users.FormBasics,
        details: P.views.users.FormDetails,
        settings: P.views.users.FormSettings
      };

      Form.prototype.protect = function(yah) {
        if (yah == null) yah = true;
        if (yah) {
          this.$('.roles').hide();
          this.$('.ribbon_ids').hide();
          return this.$('.send_mail').hide();
        } else {
          this.$('.roles').show();
          this.$('.ribbon_ids').show();
          return this.$('.send_mail').show();
        }
      };

      Form.prototype.saved = function() {
        var tab, tabs;
        tabs = this.parent.tabs;
        tab = tabs.active;
        this.basics.trigger('saved');
        if (tab.label === P.localizer.t('user_basics')) {
          return tabs.activate(tabs.get('Details'));
        } else {
          if (this.parent instanceof P.views.shared.Dialog) {
            this.parent.parent.table.add(this.model);
            return this.parent.close();
          } else {
            P.router.layout.flash.show({
              message: P.localizer.t('my_profile_updated')
            });
            this._refreshUser();
            return P.router.redirectTo('#');
          }
        }
      };

      Form.prototype.render = function() {
        Form.__super__.render.apply(this, arguments);
        this.protect(true);
        return this;
      };

      Form.prototype._refreshUser = function() {
        P.user.fetch();
        return P.user.links.fetch();
      };

      Form.prototype._error = function() {
        var tabs;
        tabs = this.parent.tabs;
        return tabs.activate(tabs.get('Basics'));
      };

      return Form;

    })(P.views.shared.forms.Form);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.users', function(x) {
    return x.Card = (function(_super) {

      __extends(Card, _super);

      Card.prototype.className = function() {
        return "" + Card.__super__.className.apply(this, arguments) + " user card";
      };

      Card.prototype.templateName = 'users/_card';

      Card.prototype.events = {
        'click': '_click'
      };

      function Card() {
        this._changeOrg = __bind(this._changeOrg, this);
        this._click = __bind(this._click, this);
        this.loginout = __bind(this.loginout, this);
        this.toolTipContent = __bind(this.toolTipContent, this);
        this.setupControls = __bind(this.setupControls, this);
        var _this = this;
        Card.__super__.constructor.apply(this, arguments);
        _.defaults(this.options, {
          showControls: true,
          photo_size: 'cropped',
          slideOut: true,
          clickableCard: true
        });
        this.tip = new P.views.shared.ToolTip({
          el: this.el,
          target: $(this.el),
          content: this.toolTipContent()
        });
        this.ribbons = new Backbone.List({
          itemType: P.views.ribbons.Ribbon,
          className: 'ribbons clear',
          collection: this.model.ribbons.uniq('name'),
          tagName: 'span'
        });
        this.categories = new Backbone.List({
          itemType: P.views.labels.Label,
          addClass: 'labels',
          collection: this.model.categories
        });
        this.model.bind('change', this._changeOrg);
        _.each('add remove change'.split(/\s+/), function(e) {
          return _this.model.groups.bind(e, _this._changeOrg);
        });
        this.tip.bind('render', this.setupControls);
      }

      Card.prototype.setupControls = function(event, qtip) {
        this._setupNewDiscussion(qtip);
        return this._setupAddRemoveContact(qtip);
      };

      Card.prototype.toolTipContent = function() {
        return JST['users/_bubble']({
          model: this.model,
          locales: P.community.locales,
          hideName: true
        });
      };

      Card.prototype.render = function() {
        var _ref;
        Card.__super__.render.apply(this, arguments);
        this.replaceWith('.ribbons', this.ribbons);
        this.html('.categories', this.categories);
        this._changeOrg();
        if (this.options.showControls && this.model.id !== ((_ref = P.user) != null ? _ref.id : void 0) && this.options.clickableCard) {
          this.tip.render();
          this.tip.disable(!P.session.get('logged_in'));
        }
        if (this.options.slideOut === false) this.$(this.el).addClass('no_shadow');
        if (this.model.categories.length) {
          this.$(this.el).css({
            border: "1px solid " + (this.model.categories.first().get('color'))
          });
        } else {
          this.$(this.el).css({
            border: "1px solid white"
          });
        }
        return this;
      };

      Card.prototype.loginout = function(session, loggedIn) {
        Card.__super__.loginout.apply(this, arguments);
        return this.tip.disable(!loggedIn || !this.options.clickableCard);
      };

      Card.prototype._click = function(e) {
        if (!this.options.clickableCard) return;
        e.preventDefault();
        return this.goto(this.model.fragment());
      };

      Card.prototype._changeOrg = function() {
        var org,
          _this = this;
        org = this.model.groups.detect(function(model) {
          return model instanceof P.models.Organization && model.get('name') === _this.model.get('organization_name');
        });
        if (org != null) {
          this.$('.organization a').attr({
            href: org.fragment()
          }).html(this.model.get('organization_name'));
        }
        return this.$('.organization a').toggleClass('unclickable', !(org != null));
      };

      Card.prototype._setupNewDiscussion = function(qtip) {
        var _this = this;
        return $(qtip.elements.content).find('.new-discussion').click(function(e) {
          e.preventDefault();
          qtip.hide();
          return P.router.layout.discussion.open(_this.model);
        });
      };

      Card.prototype._setupAddRemoveContact = function(qtip) {
        var isContact, userContactId, _ref,
          _this = this;
        _.each('add remove'.split(/\s+/), function(event) {
          return _this.model.user_contactees.bind(event, _this.render);
        });
        this.model.user_contactees.bind;
        userContactId = (_ref = this.model.user_contactees.find(function(model) {
          return model.isMarked();
        })) != null ? _ref.get('id') : void 0;
        isContact = userContactId !== void 0;
        $(qtip.elements.content).find('.new-contact').toggle(!isContact).click(function(e) {
          var userContact;
          e.preventDefault();
          userContact = new P.models.UserContact({
            contact_id: _this.model.id
          });
          P.user.user_contacts.add(userContact);
          return userContact.save({}, {
            success: function(uc) {
              return _this.model.user_contactees.add(uc);
            }
          });
        });
        return $(qtip.elements.content).find('.destroy-contact').toggle(isContact).click(function(e) {
          var model;
          e.preventDefault();
          model = P.user.user_contacts.get(userContactId);
          model || (model = P.user.user_contacts.add({
            id: userContactId
          }).get(userContactId));
          return model.destroy({
            success: function() {
              return _this.model.user_contactees.remove(model);
            }
          });
        });
      };

      return Card;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.users', function(x) {
    return x.Completeness = (function(_super) {

      __extends(Completeness, _super);

      function Completeness() {
        Completeness.__super__.constructor.apply(this, arguments);
      }

      Completeness.prototype.render = function() {
        Completeness.__super__.render.apply(this, arguments);
        $(this.el).html(JST['users/_completeness']({
          bio: this.model.get('bio'),
          options: this.templateOptions
        }));
        $(this.el).fadeIn();
        return this;
      };

      return Completeness;

    })(P.views.shared.View);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.users', function(x) {
    return x.Navigation = (function(_super) {

      __extends(Navigation, _super);

      function Navigation() {
        this.loginout = __bind(this.loginout, this);
        this._addRemoveContact = __bind(this._addRemoveContact, this);
        this._meet = __bind(this._meet, this);
        this._edit = __bind(this._edit, this);
        this._message = __bind(this._message, this);
        this.render = __bind(this.render, this);
        Navigation.__super__.constructor.apply(this, arguments);
      }

      Navigation.prototype.templateName = 'users/_navigation';

      Navigation.prototype.events = function() {
        return _.extend(Navigation.__super__.events.apply(this, arguments), {
          'click .edit': '_edit',
          'click .message': '_message',
          'click .meet': '_meet',
          'click .add-contact': '_addRemoveContact',
          'click .destroy-contact': '_addRemoveContact'
        });
      };

      Navigation.prototype.render = function() {
        var isContact, userContactId, _ref;
        Navigation.__super__.render.apply(this, arguments);
        this.model.user_contactees.bind;
        userContactId = (_ref = this.model.user_contactees.find(function(model) {
          return model.isMarked();
        })) != null ? _ref.get('id') : void 0;
        isContact = userContactId !== void 0;
        if (isContact) this.$('.add-contact').hide();
        if (!isContact) this.$('.destroy-contact').hide();
        return this;
      };

      Navigation.prototype._message = function() {
        return P.router.layout.discussion.open(this.model);
      };

      Navigation.prototype._edit = function() {
        return this.goto('#user/edit');
      };

      Navigation.prototype._meet = function() {
        return this.goto('#meetings/new&user=' + this.model.id);
      };

      Navigation.prototype._addRemoveContact = function() {
        var isContact, model, userContact, userContactId, _ref,
          _this = this;
        userContactId = (_ref = this.model.user_contactees.find(function(model) {
          return model.isMarked();
        })) != null ? _ref.get('id') : void 0;
        isContact = userContactId !== void 0;
        if (!isContact) {
          this.$('.add-contact').hide();
          this.$('.destroy-contact').show();
          userContact = new P.models.UserContact({
            contact_id: this.model.id
          });
          P.user.user_contacts.add(userContact);
          return userContact.save({}, {
            success: function(uc) {
              return _this.model.user_contactees.add(uc);
            }
          });
        } else {
          this.$('.destroy-contact').hide();
          this.$('.add-contact').show();
          model = P.user.user_contacts.get(userContactId);
          model || (model = P.user.user_contacts.add({
            id: userContactId
          }).get(userContactId));
          return model.destroy({
            success: function() {
              return _this.model.user_contactees.remove(model);
            }
          });
        }
      };

      Navigation.prototype.loginout = function(session, loggedIn) {
        Navigation.__super__.loginout.apply(this, arguments);
        $(this.el).toggle(loggedIn);
        return this.$('.meet').toggle(this.model !== P.user);
      };

      return Navigation;

    })(P.views.shared.Navigation);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.users', function(x) {
    return x.PreviewForm = (function(_super) {

      __extends(PreviewForm, _super);

      function PreviewForm() {
        PreviewForm.__super__.constructor.apply(this, arguments);
      }

      PreviewForm.prototype.events = function() {
        return _.extend(PreviewForm.__super__.events.apply(this, arguments), {
          'submit': 'save',
          'blur input': 'updatePreview'
        });
      };

      PreviewForm.prototype.updatePreview = function(e) {
        var attrs, className, value, _ref;
        className = (_ref = $(e.target).attr('id')) != null ? _ref.replace('user_', '') : void 0;
        value = $(e.target).val();
        if (!className) return false;
        P.logger.trace("Updating preview attribute '" + className + "' with value '" + value + "'");
        attrs = {};
        attrs[className] = value;
        return this.model.set(attrs);
      };

      return PreviewForm;

    })(P.views.users.Form);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.users', function(x) {
    return x.Schedule = (function(_super) {

      __extends(Schedule, _super);

      function Schedule() {
        this.render = __bind(this.render, this);
        this.initialize = __bind(this.initialize, this);
        Schedule.__super__.constructor.apply(this, arguments);
      }

      Schedule.prototype.className = function() {
        return "" + Schedule.__super__.className.apply(this, arguments) + " user schedule";
      };

      Schedule.prototype.templateName = 'users/_schedule';

      Schedule.prototype.initialize = function() {
        Schedule.__super__.initialize.apply(this, arguments);
        return this.speaking_at = new P.views.shared.lists.TitledList({
          itemType: P.views.meetings.Meeting,
          collection: this.collection,
          title: P.localizer.t('speaking_at'),
          addClass: 'links'
        });
      };

      Schedule.prototype.render = function() {
        Schedule.__super__.render.apply(this, arguments);
        this.replaceWith('.speaking_at', this.speaking_at);
        return this;
      };

      return Schedule;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.users', function(x) {
    return x.SmallCard = (function(_super) {

      __extends(SmallCard, _super);

      function SmallCard() {
        this.loginout = __bind(this.loginout, this);
        SmallCard.__super__.constructor.apply(this, arguments);
      }

      SmallCard.prototype.className = function() {
        return "user small-card";
      };

      SmallCard.prototype.templateName = 'users/_small_card';

      SmallCard.prototype.initialize = function() {
        SmallCard.__super__.initialize.apply(this, arguments);
        return _.defaults(this.options, {
          user_name: false
        });
      };

      SmallCard.prototype.toolTipContent = function() {
        return JST['users/_bubble']({
          hideName: this.options.user_name,
          model: this.model,
          locales: P.community.locales
        });
      };

      SmallCard.prototype.loginout = function(session, loggedIn) {
        SmallCard.__super__.loginout.apply(this, arguments);
        return this.$('.controls').toggle(loggedIn);
      };

      SmallCard.prototype.render = function() {
        var border_shadow;
        SmallCard.__super__.render.apply(this, arguments);
        this.$('.user_name').toggle(this.options.user_name);
        this.$(this.el).css({
          border: 'none'
        });
        if (this.model.categories.length) {
          border_shadow = "" + (this.model.categories.first().get('color')) + " 0 0 5px";
          this.$('a').css({
            '-moz-box-shadow': border_shadow,
            '-webkit-box-shadow': border_shadow,
            '-o-box-shadow': border_shadow,
            'box-shadow': border_shadow
          });
        }
        return this;
      };

      return SmallCard;

    })(x.Card);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.users', function(x) {
    return x.User = (function(_super) {

      __extends(User, _super);

      function User() {
        var _base;
        User.__super__.constructor.apply(this, arguments);
        if ((_base = this.templateOptions).nameFormat == null) {
          _base.nameFormat = 'medium';
        }
      }

      User.prototype.className = function() {
        return "" + User.__super__.className.apply(this, arguments) + " users-user";
      };

      User.prototype.templateName = 'users/_user';

      return User;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var _this = this,
    __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.users', function(x) {
    return x.Edit = (function(_super) {

      __extends(Edit, _super);

      function Edit() {
        _this._optimize = __bind(_this._optimize, this);
        _this.logout = __bind(_this.logout, this);
        _this.render = __bind(_this.render, this);
        _this.title = __bind(_this.title, this);
        _this.initialize = __bind(_this.initialize, this);
        Edit.__super__.constructor.apply(this, arguments);
      }

      Edit.prototype.templateName = 'users/edit';

      Edit.prototype.className = function() {
        return "" + Edit.__super__.className.apply(this, arguments) + " user-edit";
      };

      Edit.prototype.initialize = function() {
        Edit.__super__.initialize.apply(this, arguments);
        this.model = P.user;
        this.form = new P.views.users.PreviewForm({
          model: this.model,
          parent: this
        });
        this.tabs = new P.views.shared.tabs.Tabs({
          parent: this,
          tabs: [
            {
              label: P.localizer.t('user_basics'),
              selector: '.basics'
            }, {
              label: P.localizer.t('user_details'),
              selector: '.details'
            }, {
              label: P.localizer.t('user_email_settings'),
              selector: '.settings'
            }
          ]
        });
        return this.bind('route', this._optimize);
      };

      Edit.prototype.title = function() {
        var _ref;
        return (_ref = this.model) != null ? _ref.get('full_name') : void 0;
      };

      Edit.prototype.render = function() {
        var _this = this;
        Edit.__super__.render.apply(this, arguments);
        this.replaceWith('.form', this.form);
        this.card = new P.views.users.Card({
          model: P.user
        });
        this.replaceWith('.sidebar > .user', this.card);
        this.form.edit(P.user);
        this.replaceWith('.tabs', this.tabs);
        setTimeout(function() {
          return _this._optimize();
        });
        return this;
      };

      Edit.prototype.logout = function() {
        Edit.__super__.logout.apply(this, arguments);
        if (P.router.visible === this) return P.router.redirectTo('#');
      };

      Edit.prototype._optimize = function() {
        var f, _ref;
        f = ((_ref = this.model) != null ? _ref.get('dirty') : void 0) && 'showTabs' || 'hideTabs';
        return this.tabs[f]('Email Settings');
      };

      return Edit;

    })(P.views.shared.Page);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.users', function(x) {
    return x.Index = (function(_super) {

      __extends(Index, _super);

      Index.prototype.title = function() {
        return P.localizer.t('user', {
          pluralize: true
        });
      };

      Index.prototype.templateName = 'users/index';

      Index.prototype.className = function() {
        return "" + Index.__super__.className.apply(this, arguments) + " users index";
      };

      function Index() {
        this._resetSearch = __bind(this._resetSearch, this);
        var _this = this;
        Index.__super__.constructor.apply(this, arguments);
        this.collection = new P.models.Users();
        this.users = new P.views.shared.lists.TitledList({
          addClass: 'two-col users users-medium',
          itemType: P.views.users.Card,
          itemOptions: {
            showControls: true
          },
          collection: this.collection
        });
        this.search = new P.views.shared.lists.Search({
          collection: this.collection,
          sort: {
            most_recent: {
              label: P.localizer.t('most_recent_sort'),
              order: 'updated_at'
            },
            first_name: {
              label: P.localizer.t('first_name_sort'),
              order: 'first_name',
              sort_mode: 'asc'
            },
            last_name: {
              label: P.localizer.t('last_name_sort'),
              order: 'last_name',
              sort_mode: 'asc'
            }
          },
          search: {
            classes: ['User']
          },
          track: function() {
            return P.tracker.track('attendee search', _this.collection.searchOptions);
          }
        });
        this.groups = new P.views.groups.ListSet({
          search: this.search,
          collection: P.community.questions
        });
        this.bind('route', this._resetSearch);
      }

      Index.prototype.render = function() {
        Index.__super__.render.apply(this, arguments);
        this.replaceWith('.users-search', this.search);
        this.replaceWith('.users-list', this.users);
        this.replaceWith('.groups-listSet', this.groups);
        this.groups.reset();
        return this;
      };

      Index.prototype._resetSearch = function() {
        return this.search.reset();
      };

      return Index;

    })(P.views.shared.Page);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.users', function(x) {
    return x.Show = (function(_super) {

      __extends(Show, _super);

      function Show() {
        this.render = __bind(this.render, this);
        this.title = __bind(this.title, this);
        this.initialize = __bind(this.initialize, this);
        Show.__super__.constructor.apply(this, arguments);
      }

      Show.prototype.templateName = 'users/show';

      Show.prototype.className = function() {
        return "" + Show.__super__.className.apply(this, arguments) + " users show";
      };

      Show.prototype.navigationType = x.Navigation;

      Show.prototype.initialize = function() {
        Show.__super__.initialize.apply(this, arguments);
        this.user = new P.views.users.Card({
          model: this.model,
          photo_size: 'full',
          slideOut: false,
          clickableCard: false
        });
        this.messages = new P.views.shared.lists.TitledList({
          selectable: true,
          collection: this.model.messages.public.limit(5),
          addClass: 'overline no_photo messages',
          itemType: P.views.discussions.messages.Message,
          title: P.localizer.t('message', {
            pluralize: true
          }).titleize()
        });
        this.messages.bind('select', function(message) {
          return P.router.redirectTo(message.discussion.fragment());
        });
        this.links = new P.views.links.List({
          collection: this.model.links,
          templateOptions: {
            title: P.localizer.t('websites')
          },
          autoFetch: true
        });
        this.posts = new P.views.posts.List({
          collection: this.model.posts.limit(5),
          title: P.localizer.t('recent_posts'),
          templateOptions: {
            exclude: []
          },
          autoFetch: true
        });
        this.tweets = new P.views.shared.lists.TitledList({
          itemType: P.views.tweets.Tweet,
          collection: this.model.tweets.limit(5),
          title: P.localizer.t('recent_tweets'),
          templateOptions: {
            exclude: ['display_name', 'photo']
          },
          addClass: 'entries tweets overline with_hover',
          autoFetch: {
            regularly: 10 * 60 * 1000,
            onceIn: 5 * 1000
          }
        });
        this.answers = new P.views.answers.List({
          collection: this.model.answers
        });
        return this.schedule = new P.views.users.Schedule({
          user: this.model,
          collection: this.model.meetings.speaking,
          templateOptions: {
            title: P.localizer.t('meeting').titleize()
          },
          autoFetch: true
        });
      };

      Show.prototype.title = function() {
        var _ref;
        return (_ref = this.model) != null ? _ref.get('full_name') : void 0;
      };

      Show.prototype.render = function() {
        Show.__super__.render.apply(this, arguments);
        if (!this.model.get('visible') && (this.model.id = P.user.id)) {
          P.layout.flash.show({
            message: P.localizer.t('my_profile_hidden', {
              enable_route: '#user/edit'
            }),
            "class": 'warn',
            hide: false
          });
        }
        this.replaceWith('.card', this.user);
        this.replaceWith('.answers', this.answers);
        this.replaceWith('.messages', this.messages);
        this.replaceWith('.links', this.links);
        this.replaceWith('.posts', this.posts);
        this.replaceWith('.tweets', this.tweets);
        this.replaceWith('.schedule', this.schedule);
        return this;
      };

      return Show;

    })(P.views.shared.Page);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.attendances', function(x) {
    return x.Form = (function(_super) {

      __extends(Form, _super);

      function Form() {
        this.render = __bind(this.render, this);
        this.saved = __bind(this.saved, this);
        this.formValues = __bind(this.formValues, this);
        this.initialize = __bind(this.initialize, this);
        Form.__super__.constructor.apply(this, arguments);
      }

      Form.prototype.initialize = function() {
        Form.__super__.initialize.apply(this, arguments);
        this.bind('saved', this.saved);
        return this.bind('edit', this.setup);
      };

      Form.prototype.className = function() {
        return "" + Form.__super__.className.apply(this, arguments) + " formtastic";
      };

      Form.prototype.templateName = 'attendances/_form';

      Form.prototype.features = [P.views.shared.forms.ErrorsFeature, P.views.shared.forms.FormValueGetFeature, P.views.shared.forms.FormValueSetFeature, P.views.shared.forms.FocusFeature];

      Form.prototype.formValues = function() {
        var values;
        values = this.getValues();
        values['status'] = _.map(this.$('input:radio:checked'), function(el) {
          return el.value;
        }).join('');
        return values;
      };

      Form.prototype.saved = function(model) {
        this.parent.close();
        return this.parent.parent.setup();
      };

      Form.prototype.render = function() {
        Form.__super__.render.apply(this, arguments);
        return this;
      };

      return Form;

    })(P.views.shared.forms.Form);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.attendances', function(x) {
    return x.Attendance = (function(_super) {

      __extends(Attendance, _super);

      function Attendance() {
        this.render = __bind(this.render, this);
        this.initialize = __bind(this.initialize, this);
        Attendance.__super__.constructor.apply(this, arguments);
      }

      Attendance.prototype.templateName = 'attendances/_attendance';

      Attendance.prototype.className = function() {
        return "" + Attendance.__super__.className.apply(this, arguments) + " attendance";
      };

      Attendance.prototype.initialize = function() {
        Attendance.__super__.initialize.apply(this, arguments);
        this.card = new P.views.users.Card({
          model: this.model.user
        });
        return this.status = new x.Status({
          model: this.model
        });
      };

      Attendance.prototype.render = function() {
        Attendance.__super__.render.apply(this, arguments);
        this.replaceWith('.user', this.card);
        this.replaceWith('.status', this.status);
        return this;
      };

      return Attendance;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.attendances', function(x) {
    return x.Edit = (function(_super) {

      __extends(Edit, _super);

      function Edit() {
        this.initialize = __bind(this.initialize, this);
        Edit.__super__.constructor.apply(this, arguments);
      }

      Edit.prototype.className = function() {
        return "" + Edit.__super__.className.apply(this, arguments) + " attendance edit";
      };

      Edit.prototype.formType = x.Form;

      Edit.prototype.initialize = function() {
        Edit.__super__.initialize.apply(this, arguments);
        return this.form.bind('saved', this.close);
      };

      Edit.prototype.open = function(model) {
        Edit.__super__.open.apply(this, arguments);
        return this.form.edit(model);
      };

      Edit.prototype.render = function() {
        Edit.__super__.render.apply(this, arguments);
        this.append(this.form);
        return this;
      };

      return Edit;

    })(P.views.shared.Dialog);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.attendances', function(x) {
    return x.Status = (function(_super) {

      __extends(Status, _super);

      function Status() {
        this._colorize = __bind(this._colorize, this);
        this.render = __bind(this.render, this);
        this.initialize = __bind(this.initialize, this);
        Status.__super__.constructor.apply(this, arguments);
      }

      Status.prototype.templateName = 'attendances/_status';

      Status.prototype.className = function() {
        return "" + Status.__super__.className.apply(this, arguments) + " status";
      };

      Status.prototype.initialize = function() {
        Status.__super__.initialize.apply(this, arguments);
        return this.model.bind('change', this._colorize);
      };

      Status.prototype.render = function() {
        Status.__super__.render.apply(this, arguments);
        this._colorize();
        return this;
      };

      Status.prototype._colorize = function() {
        if (!this.model.get('status')) this.$('.status').text('unresponded');
        this.$('.status').removeClass('accepted tentative declined');
        return this.$('.status').addClass(this.$('.status').text());
      };

      return Status;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.memberships', function(x) {
    return x.Edit = (function(_super) {

      __extends(Edit, _super);

      function Edit() {
        Edit.__super__.constructor.apply(this, arguments);
      }

      Edit.prototype.initialize = function() {
        Edit.__super__.initialize.apply(this, arguments);
        return this.form = new x.Form({
          parent: this,
          collection: this.collection
        });
      };

      Edit.prototype.className = function() {
        return "" + Edit.__super__.className.apply(this, arguments) + " memberships-edit";
      };

      Edit.prototype.open = function(model) {
        if (model == null) model = new P.models.Membership();
        Edit.__super__.open.apply(this, arguments);
        this.form.edit(model);
        return this.center();
      };

      Edit.prototype.render = function() {
        Edit.__super__.render.apply(this, arguments);
        this.append(this.form);
        return this;
      };

      return Edit;

    })(P.views.shared.Dialog);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.memberships', function(x) {
    return x.Row = (function(_super) {

      __extends(Row, _super);

      function Row() {
        Row.__super__.constructor.apply(this, arguments);
        this.user = new P.views.users.User({
          model: this.model.user
        });
        if (this.model.ribbon != null) {
          this.ribbon = new P.views.ribbons.Ribbon({
            model: this.model.ribbon
          });
        }
      }

      Row.prototype.render = function() {
        Row.__super__.render.apply(this, arguments);
        this.html('.user', this.user);
        this.html('.ribbon', this.ribbon);
        return this;
      };

      return Row;

    })(P.views.shared.tables.ControllableRow);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.memberships', function(x) {
    return x.Table = (function(_super) {

      __extends(Table, _super);

      function Table() {
        Table.__super__.constructor.apply(this, arguments);
      }

      Table.prototype.columns = {
        user: {
          title: 'Name',
          width: '130px',
          "class": 'user',
          features: []
        },
        roles: {
          title: 'Roles',
          width: '70px'
        },
        ribbon: {
          width: '70px',
          "class": 'ribbon',
          features: []
        }
      };

      Table.prototype.wildcardColumns = ['full_name'];

      Table.prototype.className = function() {
        return "" + Table.__super__.className.apply(this, arguments) + " table";
      };

      Table.prototype.rowConstructor = x.Row;

      return Table;

    })(P.views.shared.tables.ServerSideTable);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.memberships', function(x) {
    return x.Form = (function(_super) {

      __extends(Form, _super);

      function Form() {
        this.render = __bind(this.render, this);
        this.saved = __bind(this.saved, this);
        this.getRoles = __bind(this.getRoles, this);
        this.formValues = __bind(this.formValues, this);
        this.clear = __bind(this.clear, this);
        this.setup = __bind(this.setup, this);
        this.initialize = __bind(this.initialize, this);
        Form.__super__.constructor.apply(this, arguments);
      }

      Form.prototype.initialize = function() {
        Form.__super__.initialize.apply(this, arguments);
        this.autoSuggest = new P.views.shared.auto_suggest.AutoSuggest({
          disableFreeForm: false,
          searchOptions: {
            classes: ['User']
          }
        });
        this.buttons = new P.views.shared.ControlBar({
          controls: ['save']
        });
        this.templateOptions.questions = P.community.questions;
        this.bind('saved', this.saved);
        return this.bind('edit', this.setup);
      };

      Form.prototype.className = function() {
        return "" + Form.__super__.className.apply(this, arguments) + " memberships-form formtastic";
      };

      Form.prototype.tagName = 'div';

      Form.prototype.templateName = 'memberships/_form';

      Form.prototype.features = [P.views.shared.forms.ErrorsFeature, P.views.shared.forms.FormValueGetFeature, P.views.shared.forms.FormValueSetFeature, P.views.shared.forms.FocusFeature];

      Form.prototype.setup = function() {
        P.logger.debug('Setting up form, using model:', this.model);
        this.bindErrors();
        this.setValues();
        this.setRoles();
        this.autoSuggest.clear();
        if (this.model.isNew()) {
          return this.autoSuggest.enable();
        } else {
          this.autoSuggest.disable();
          return this.autoSuggest.collection.add(this.model.user);
        }
      };

      Form.prototype.clear = function() {
        return this.autoSuggest.clear();
      };

      Form.prototype.formValues = function() {
        var users_attributes, users_ids, values;
        values = this.getValues();
        values['roles'] = this.getRoles();
        if (this.model.isNew()) {
          users_attributes = [];
          users_ids = [];
          this.autoSuggest.collection.each(function(model) {
            if (model.id != null) {
              return users_attributes.push({
                id: model.id,
                primary_email: model.get('primary_email')
              });
            } else {
              return users_attributes.push({
                full_name: model.get('friendly_name'),
                primary_email: model.get('primary_email')
              });
            }
          });
        }
        values['users_attributes'] = users_attributes;
        return values;
      };

      Form.prototype.getRoles = function() {
        return _.map(this.$('.roles input:checked'), function(el) {
          return el.value;
        });
      };

      Form.prototype.setRoles = function() {
        var _this = this;
        this.$('.roles input').prop('checked', false);
        return _.each(this.model.get('roles'), function(role) {
          return _this.$(".roles input[value=" + role + "]").prop('checked', true);
        });
      };

      Form.prototype.saved = function(model) {
        this.parent.close();
        return this.parent.parent.table.add(model);
      };

      Form.prototype.render = function() {
        Form.__super__.render.apply(this, arguments);
        this.replaceWith('.memberships-users', this.autoSuggest);
        return this;
      };

      return Form;

    })(P.views.shared.forms.Form);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.memberships', function(x) {
    return x.Index = (function(_super) {

      __extends(Index, _super);

      function Index() {
        this["new"] = __bind(this["new"], this);
        this.initialize = __bind(this.initialize, this);
        Index.__super__.constructor.apply(this, arguments);
      }

      Index.prototype.initialize = function() {
        Index.__super__.initialize.apply(this, arguments);
        this.table = new x.Table({
          parent: this
        });
        return this.edit = new x.Edit({
          parent: this
        });
      };

      Index.prototype.className = function() {
        return "" + Index.__super__.className.apply(this, arguments) + " memberships-index";
      };

      Index.prototype.templateName = 'memberships/_index';

      Index.prototype.events = function() {
        return _.extend(Index.__super__.events.apply(this, arguments), {
          'click button.add': 'new',
          'click button.destroy': 'destroy'
        });
      };

      Index.prototype.use = function(collection) {
        this.collection = collection;
        this.table.collection = this.collection;
        return this.table.render();
      };

      Index.prototype["new"] = function() {
        var membership;
        membership = this.collection.build({
          group_id: this.collection.group.id,
          group: this.collection.group
        });
        return this.edit.open(membership);
      };

      Index.prototype.destroy = function() {
        return this.table.destroy();
      };

      Index.prototype.render = function() {
        Index.__super__.render.apply(this, arguments);
        this.replaceWith('.table', this.table);
        this.edit.render();
        return this;
      };

      return Index;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.memberships', function(x) {
    return x.List = (function(_super) {

      __extends(List, _super);

      function List() {
        List.__super__.constructor.apply(this, arguments);
      }

      List.prototype.itemType = P.views.users.Card;

      List.prototype.itemOptions = function(model) {
        return {
          model: model.user,
          showControls: true
        };
      };

      return List;

    })(P.views.shared.lists.TitledList);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.groups', function(x) {
    return x.Form = (function(_super) {

      __extends(Form, _super);

      function Form() {
        Form.__super__.constructor.apply(this, arguments);
        this.uploadify = new P.views.shared.Uploadify();
        this.textEditor = new P.views.shared.TextEditor();
        _.defaults(this.options, {
          showPhotoControl: false
        });
        this.bind('saved', this.saved);
        this.bind('edit', this.setup);
      }

      Form.prototype.namespace = 'tag';

      Form.prototype.className = function() {
        return "" + Form.__super__.className.apply(this, arguments) + " groups-form";
      };

      Form.prototype.templateName = 'groups/_form';

      Form.prototype.features = [P.views.shared.forms.ErrorsFeature, P.views.shared.forms.FormValueGetFeature, P.views.shared.forms.FormValueSetFeature, P.views.shared.forms.FocusFeature, P.views.links.FormFeature];

      Form.prototype.formValues = function() {
        var values, _ref;
        values = this.getValues(this.namespace);
        values['blurb'] = this.textEditor.getContent();
        values['temp_attachment_id'] = (_ref = this.uploadify.attachment) != null ? _ref.id : void 0;
        return values;
      };

      Form.prototype.assignBlurb = function() {
        return this.textEditor.setContent(this.model.get('blurb') || '');
      };

      Form.prototype.setup = function() {
        this.clearFormErrors();
        this.bindErrors({
          namespace: this.namespace
        });
        this.setValues(this.namespace);
        return this.assignBlurb();
      };

      Form.prototype.saved = function() {
        return this.clearFormErrors();
      };

      Form.prototype.render = function() {
        Form.__super__.render.apply(this, arguments);
        this.replaceAll('.blurb textarea', this.textEditor);
        if (this.uploadify != null) this.replaceAll('.logo input', this.uploadify);
        return this;
      };

      return Form;

    })(P.views.shared.forms.Form);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.groups', function(x) {
    return x.Card = (function(_super) {

      __extends(Card, _super);

      function Card() {
        this._toggle = __bind(this._toggle, this);
        this._counts = __bind(this._counts, this);
        this.render = __bind(this.render, this);
        Card.__super__.constructor.apply(this, arguments);
      }

      Card.prototype.templateName = 'groups/_card';

      Card.prototype.className = function() {
        return "" + Card.__super__.className.apply(this, arguments) + " group no_shadow card";
      };

      Card.prototype.initialize = function() {
        Card.__super__.initialize.apply(this, arguments);
        this.members = new P.views.shared.lists.TitledList({
          itemType: P.views.users.SmallCard,
          addClass: 'users users-small',
          collection: this.model.users.limit(this.options.membersLimit || 4)
        });
        return this.model.bind('change', this._counts);
      };

      Card.prototype.render = function() {
        Card.__super__.render.apply(this, arguments);
        this._counts();
        this.replaceWith('.members', this.members);
        return this;
      };

      Card.prototype._counts = function() {
        this.$('.discussions_count').toggle(!!this.model.get('discussions_count'));
        return this.$('.documents_count').toggle(!!this.model.get('documents_count'));
      };

      Card.prototype._toggle = function(e) {
        if ($(e.target).closest('a', this.el).length) return;
        return $(this.members.el).slideToggle();
      };

      return Card;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.groups', function(x) {
    return x.Edit = (function(_super) {

      __extends(Edit, _super);

      function Edit() {
        this.use = __bind(this.use, this);
        this.initialize = __bind(this.initialize, this);
        Edit.__super__.constructor.apply(this, arguments);
      }

      Edit.prototype.templateName = 'groups/_edit';

      Edit.prototype.className = function() {
        return "" + Edit.__super__.className.apply(this, arguments) + " groups edit";
      };

      Edit.prototype.formType = P.views.groups.Form;

      Edit.prototype.initialize = function() {
        Edit.__super__.initialize.apply(this, arguments);
        this.memberships = new P.views.memberships.Index({
          parent: this
        });
        this.affiliations = new P.views.affiliations.Index({
          parent: this
        });
        this.documents = new P.views.documents.Index({
          parent: this
        });
        this.tabs = new P.views.shared.tabs.Tabs({
          parent: this,
          tabs: [
            {
              label: P.localizer.t('basics'),
              selector: '.groups-form'
            }, {
              label: P.localizer.t('members'),
              selector: '.memberships-index'
            }, {
              label: P.localizer.t('group_documents'),
              selector: '.documents-index'
            }, {
              label: P.localizer.t('affiliation', {
                pluralize: true
              }),
              selector: '.affiliations-index'
            }
          ]
        });
        return this.form.bind('saved', this.close);
      };

      Edit.prototype.open = function(model) {
        Edit.__super__.open.apply(this, arguments);
        model || (model = new P.models.Group);
        this.form.edit(model);
        this.use(model);
        this.tabs.goHome();
        return this.center();
      };

      Edit.prototype.use = function(model) {
        var existingGroupTabs;
        this.model = model;
        existingGroupTabs = [
          P.localizer.t('members'), P.localizer.t('group_documents'), P.localizer.t('affiliation', {
            pluralize: true
          })
        ];
        if (model.isNew()) {
          return this.tabs.disable(existingGroupTabs);
        } else {
          this.tabs.enable(existingGroupTabs);
          this.memberships.use(model.memberships);
          this.documents["for"](model);
          this.affiliations.use(model.affiliations);
          model.memberships.fetch();
          return model.affiliations.fetch();
        }
      };

      Edit.prototype.render = function() {
        Edit.__super__.render.apply(this, arguments);
        this.replaceWith('.form', this.form);
        this.replaceWith('.memberships', this.memberships);
        this.replaceWith('.documents', this.documents);
        this.replaceWith('.affiliations', this.affiliations);
        this.replaceWith('.tabs', this.tabs);
        return this;
      };

      return Edit;

    })(P.views.shared.Dialog);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.groups', function(x) {
    return x.Group = (function(_super) {

      __extends(Group, _super);

      function Group() {
        var _base;
        Group.__super__.constructor.apply(this, arguments);
        if ((_base = this.templateOptions).nameFormat == null) {
          _base.nameFormat = 'medium';
        }
      }

      Group.prototype.className = function() {
        return "" + Group.__super__.className.apply(this, arguments) + " group";
      };

      Group.prototype.templateName = 'groups/_group';

      return Group;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.groups', function(x) {
    return x.List = (function(_super) {

      __extends(List, _super);

      List.prototype.className = function() {
        return "" + List.__super__.className.apply(this, arguments) + " labelized";
      };

      List.prototype.itemType = x.Card;

      List.prototype.itemOptions = function() {
        return {
          membersLimit: this.options.groupOptions.membersLimit,
          search: this.options.search
        };
      };

      function List() {
        this.itemOptions = __bind(this.itemOptions, this);
        var _base;
        List.__super__.constructor.apply(this, arguments);
        if ((_base = this.options).groupOptions == null) _base.groupOptions = {};
        if (this.options.question != null) {
          this.collection.scope = this.options.question;
          this.templateOptions.title = this.options.question.get('question');
        }
      }

      List.prototype.clear = function() {
        return this.$('.group').removeClass('selected');
      };

      return List;

    })(P.views.shared.lists.TitledList);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.groups', function(x) {
    return x.ListSet = (function(_super) {

      __extends(ListSet, _super);

      ListSet.prototype.className = function() {
        return "" + ListSet.__super__.className.apply(this, arguments) + " groups-list-set";
      };

      function ListSet() {
        var _this = this;
        ListSet.__super__.constructor.apply(this, arguments);
        this.groups = this.collection.map(function(model) {
          return new P.views.groups.TagList({
            question: model,
            search: _this.options.search,
            collection: new P.models.Groups()
          });
        });
      }

      ListSet.prototype.reset = function() {
        return _.each(this.groups, function(view) {
          return view.collection.fetch();
        });
      };

      ListSet.prototype.render = function() {
        var _this = this;
        ListSet.__super__.render.apply(this, arguments);
        _.each(this.groups, function(view) {
          return _this.append(view);
        });
        return this;
      };

      return ListSet;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.groups', function(x) {
    return x.Navigation = (function(_super) {

      __extends(Navigation, _super);

      function Navigation() {
        this._edit = __bind(this._edit, this);
        this._message = __bind(this._message, this);
        this._remove = __bind(this._remove, this);
        this._add = __bind(this._add, this);
        this.loginout = __bind(this.loginout, this);
        this.render = __bind(this.render, this);
        this.setup = __bind(this.setup, this);
        Navigation.__super__.constructor.apply(this, arguments);
      }

      Navigation.prototype.events = function() {
        return _.extend(Navigation.__super__.events.apply(this, arguments), {
          'click .add': '_add',
          'click .remove': '_remove',
          'click .message': '_message',
          'click .edit': '_edit'
        });
      };

      Navigation.prototype.templateName = 'groups/_navigation';

      Navigation.prototype.initialize = function() {
        var _this = this;
        Navigation.__super__.initialize.apply(this, arguments);
        this.join = new P.views.memberships.my.Edit({
          parent: this,
          collection: this.model.memberships
        });
        this.edit = new x.Edit({
          model: this.model
        });
        return _.each(['add', 'remove', 'reset'], function(event) {
          return P.user.memberships.bind(event, _this.setup);
        });
      };

      Navigation.prototype.setup = function(a, b) {
        var member, unschedulable;
        unschedulable = this.model.get('unschedulable');
        member = P.user.groups.get(this.model) != null;
        this.$('button.remove').toggle(!unschedulable && member);
        return this.$('button.add').toggle(!(unschedulable || member));
      };

      Navigation.prototype.render = function() {
        Navigation.__super__.render.apply(this, arguments);
        this.join.render();
        this.edit.render();
        return this;
      };

      Navigation.prototype.loginout = function(session, loggedIn) {
        Navigation.__super__.loginout.apply(this, arguments);
        this.setup();
        this.$('.control_bar').toggle(loggedIn);
        return this.$('button.edit').toggle(loggedIn && session.user.hasRole('admin'));
      };

      Navigation.prototype._add = function() {
        return (new P.models.Attendance({
          user_id: P.user.id,
          group_id: this.model.id
        })).save();
      };

      Navigation.prototype._remove = function() {
        var _ref,
          _this = this;
        return (_ref = P.user.memberships.find(function(m) {
          return m.get('group_id') === _this.model.id;
        })) != null ? _ref.destroy() : void 0;
      };

      Navigation.prototype._message = function() {
        return P.router.layout.discussion.open(this.model);
      };

      Navigation.prototype._edit = function() {
        return this.edit.open(this.model);
      };

      return Navigation;

    })(P.views.shared.Navigation);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.groups', function(x) {
    return x.SmallList = (function(_super) {

      __extends(SmallList, _super);

      function SmallList() {
        SmallList.__super__.constructor.apply(this, arguments);
      }

      SmallList.prototype.itemType = x.Tag;

      SmallList.prototype.itemOptions = function() {
        return {
          search: this.options.search
        };
      };

      return SmallList;

    })(x.List);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.groups', function(x) {
    return x.Tag = (function(_super) {

      __extends(Tag, _super);

      function Tag() {
        Tag.__super__.constructor.apply(this, arguments);
      }

      Tag.prototype.templateName = 'groups/_tag';

      Tag.prototype.className = function() {
        return "" + Tag.__super__.className.apply(this, arguments) + " tag";
      };

      return Tag;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.groups', function(x) {
    return x.TagGroup = (function(_super) {

      __extends(TagGroup, _super);

      function TagGroup() {
        this._toggleCount = __bind(this._toggleCount, this);
        this.render = __bind(this.render, this);
        this.initialize = __bind(this.initialize, this);
        TagGroup.__super__.constructor.apply(this, arguments);
      }

      TagGroup.prototype.tagName = 'a';

      TagGroup.prototype.className = 'tag';

      TagGroup.prototype.templateName = 'groups/_tag_group';

      TagGroup.prototype.initialize = function() {
        var href;
        TagGroup.__super__.initialize.apply(this, arguments);
        href = this.model instanceof P.models.Meeting ? this.model.get('url') : this.model.fragment();
        $(this.el).attr({
          href: href,
          title: this.model.get('name')
        });
        return this.model.bind('change:memberships_count', this._toggleCount);
      };

      TagGroup.prototype.render = function() {
        TagGroup.__super__.render.apply(this, arguments);
        this._toggleCount();
        return this;
      };

      TagGroup.prototype._toggleCount = function() {
        return this.$('.count').toggle(this.model.get('memberships_count') > 0);
      };

      return TagGroup;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.groups', function(x) {
    return x.TagList = (function(_super) {

      __extends(TagList, _super);

      function TagList() {
        this.itemOptions = __bind(this.itemOptions, this);
        TagList.__super__.constructor.apply(this, arguments);
      }

      TagList.prototype.className = function() {
        return "" + TagList.__super__.className.apply(this, arguments) + " labelized tag_list";
      };

      TagList.prototype.itemType = x.TagGroup;

      TagList.prototype.itemOptions = function() {
        return {
          search: this.options.search,
          truncate: this.options.truncate
        };
      };

      TagList.prototype.initialize = function() {
        var question;
        if (question = this.options.question) {
          this.collection.scope = question;
          this.options.title = question.get('question');
        }
        return TagList.__super__.initialize.apply(this, arguments);
      };

      TagList.prototype.clear = function() {
        return $(this.el).find('.group').removeClass('selected');
      };

      return TagList;

    })(P.views.shared.lists.TitledList);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.groups', function(x) {
    return x.Index = (function(_super) {

      __extends(Index, _super);

      function Index() {
        this._resetSearch = __bind(this._resetSearch, this);
        this.loginout = __bind(this.loginout, this);
        this.logout = __bind(this.logout, this);
        this.login = __bind(this.login, this);
        Index.__super__.constructor.apply(this, arguments);
      }

      Index.prototype.title = function() {
        return P.localizer.t('group', {
          pluralize: true
        });
      };

      Index.prototype.templateName = 'groups/index';

      Index.prototype.className = function() {
        return "" + Index.__super__.className.apply(this, arguments) + " groups index";
      };

      Index.prototype.initialize = function() {
        var _ref,
          _this = this;
        Index.__super__.initialize.apply(this, arguments);
        this.groups = new P.views.groups.List({
          collection: this.collection,
          addClass: 'two-col detailed_group_set',
          groupOptions: {
            membersLimit: 6
          }
        });
        this.search = new P.views.shared.lists.Search({
          collection: this.collection,
          sort: {
            popularity: {
              label: P.localizer.t('popularity_sort'),
              order: 'groups.memberships_count',
              sort_mode: 'desc'
            },
            name: {
              label: P.localizer.t('name_sort'),
              order: 'groups.name',
              sort_mode: 'asc'
            }
          },
          search: {
            classes: ['Group'],
            per_page: 10
          },
          track: function() {
            return P.tracker.track('attendee search', _this.collection.searchOptions);
          }
        });
        this.bind('route', this._resetSearch);
        return (_ref = P.user.tags) != null ? _ref.bind('change', function(event) {
          var _ref2;
          return (_ref2 = _this.myGroups) != null ? _ref2.render() : void 0;
        }) : void 0;
      };

      Index.prototype.render = function() {
        Index.__super__.render.apply(this, arguments);
        this.replaceWith('.groups-search', this.search);
        this.replaceWith('.groups', this.groups);
        P.logger.debug("P.views.groups.Index @groups", this.groups);
        return this;
      };

      Index.prototype.login = function(session) {
        Index.__super__.login.apply(this, arguments);
        session.user.tags.fetch();
        this.myGroups = new P.views.groups.List({
          collection: session.user.tags,
          addClass: "detailed_group_set",
          title: P.localizer.t('my_groups'),
          groupOptions: {
            membersLimit: 4
          }
        });
        return this.html('.my-groups', this.myGroups);
      };

      Index.prototype.logout = function(session) {
        var _ref;
        Index.__super__.logout.apply(this, arguments);
        if ((_ref = this.myGroups) != null) _ref.destroy();
        return delete this.myGroups;
      };

      Index.prototype.loginout = function(session, loggedIn) {
        var _ref;
        Index.__super__.loginout.apply(this, arguments);
        return (_ref = this.myGroups) != null ? _ref.$el.toggle(loggedIn) : void 0;
      };

      Index.prototype._resetSearch = function() {
        return this.search.reset();
      };

      return Index;

    })(P.views.shared.Page);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.groups', function(x) {
    return x.Show = (function(_super) {

      __extends(Show, _super);

      function Show() {
        this.title = __bind(this.title, this);
        Show.__super__.constructor.apply(this, arguments);
      }

      Show.prototype.templateName = 'groups/show';

      Show.prototype.className = function() {
        return "" + Show.__super__.className.apply(this, arguments) + " groups show";
      };

      Show.prototype.cardType = x.Card;

      Show.prototype.navigationType = x.Navigation;

      Show.prototype.initialize = function() {
        Show.__super__.initialize.apply(this, arguments);
        this.card = new this.cardType({
          model: this.model,
          expandable: false,
          templateOptions: {
            hideProps: ['blurb']
          }
        });
        this.blurb = new P.views.shared.RichText({
          model: this.model,
          addClass: 'blurb',
          attribute: 'blurb'
        });
        this.users = new P.views.shared.lists.TitledList({
          itemType: P.views.users.Card,
          itemOptions: function(model) {
            return {
              showControls: true
            };
          },
          addClass: this.model instanceof P.models.Meeting ? 'two-col small' : 'three-col',
          collection: this.model instanceof P.models.Meeting ? this.model.noRibbonUsers : this.model.users,
          showCount: this.model instanceof P.models.Meeting ? true : this.model.get('memberships_count'),
          title: this.model instanceof P.models.Meeting ? P.localizer.t('user', {
            pluralize: true
          }) : P.localizer.t('latest_members')
        });
        this.discussions = new P.views.shared.lists.TitledList({
          selectable: true,
          itemType: P.views.discussions.discussions.Discussion,
          collection: this.model.discussions,
          controls: {
            link: '#discussions'
          },
          addClass: 'overline with_hover',
          title: P.localizer.t('discussion', {
            pluralize: true
          })
        });
        this.links = new P.views.links.List({
          collection: this.model.links,
          templateOptions: {
            title: P.localizer.t('websites')
          }
        });
        this.documents = new P.views.documents.List({
          collection: this.model.documents,
          title: P.localizer.t('document', {
            pluralize: true
          })
        });
        return this.discussions.bind('select', function(discussion) {
          return P.router.redirectTo(discussion.fragment());
        });
      };

      Show.prototype.title = function() {
        var _ref;
        return (_ref = this.model) != null ? _ref.get('name') : void 0;
      };

      Show.prototype.render = function() {
        Show.__super__.render.apply(this, arguments);
        this.replaceWith('>.main>.group>.card', this.card);
        this.replaceWith('.blurb', this.blurb);
        if (this.users != null) this.replaceWith('.users', this.users);
        this.replaceWith('.discussions', this.discussions);
        this.replaceWith('.links', this.links);
        this.replaceWith('.documents', this.documents);
        return this;
      };

      return Show;

    })(P.views.shared.Page);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.organizations', function(x) {
    return x.Blurb = (function(_super) {

      __extends(Blurb, _super);

      function Blurb() {
        Blurb.__super__.constructor.apply(this, arguments);
      }

      Blurb.prototype.templateName = 'organizations/_blurb';

      Blurb.prototype.initialize = function() {
        Blurb.__super__.initialize.apply(this, arguments);
        return this.model.bind('change', this.render);
      };

      return Blurb;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.organizations', function(x) {
    return x.Booth = (function(_super) {

      __extends(Booth, _super);

      function Booth() {
        Booth.__super__.constructor.apply(this, arguments);
      }

      Booth.prototype.templateName = 'organizations/_booth';

      Booth.prototype.initialize = function() {
        Booth.__super__.initialize.apply(this, arguments);
        return this.model.bind('change', this.render);
      };

      return Booth;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.organizations', function(x) {
    return x.Card = (function(_super) {

      __extends(Card, _super);

      Card.prototype.className = function() {
        return "organization card";
      };

      Card.prototype.templateName = 'organizations/_card';

      function Card() {
        this.setupCardClick = __bind(this.setupCardClick, this);
        var _base, _base2, _base3;
        Card.__super__.constructor.apply(this, arguments);
        (_base = this.templateOptions).logo_size || (_base.logo_size = 'full');
        if ((_base2 = this.templateOptions).slideOut == null) {
          _base2.slideOut = true;
        }
        if ((_base3 = this.options).showControls == null) {
          _base3.showControls = true;
        }
        this.model.bind('change', this.render);
        this.bind('render', this.setupCardClick());
        this.name = new x.Name({
          model: this.model
        });
        this.booth = new x.Booth({
          model: this.model,
          templateOptions: this.templateOptions
        });
        this.blurb = new x.Blurb({
          model: this.model,
          templateOptions: this.templateOptions
        });
        this.logo = new x.Logo({
          model: this.model,
          templateOptions: this.templateOptions
        });
      }

      Card.prototype.render = function() {
        Card.__super__.render.apply(this, arguments);
        this.replaceWith('.name', this.name);
        this.replaceWith('.booth', this.booth);
        this.replaceWith('.blurb', this.blurb);
        this.replaceWith('.logo', this.logo);
        if (this.model.get('level') != null) {
          this.html('.level', this.model.level.get('name'));
          this.$(this.el).css('border', "1px solid " + (this.model.level.get('color')));
          this.$('.level').css('background-color', this.model.level.get('color'));
          this.$('.level').addClass("level_" + this.model.level.id);
        }
        if (this.templateOptions.slideOut === false) {
          this.$(this.el).addClass('no_shadow');
        }
        return this;
      };

      Card.prototype.setupCardClick = function() {
        var _this = this;
        return $(this.el).click(function(e) {
          e.preventDefault();
          return _this.goto(_this.model.fragment());
        });
      };

      return Card;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.organizations', function(x) {
    return x.Edit = (function(_super) {

      __extends(Edit, _super);

      function Edit() {
        this.initialize = __bind(this.initialize, this);
        Edit.__super__.constructor.apply(this, arguments);
      }

      Edit.prototype.formType = P.views.organizations.Form;

      Edit.prototype.initialize = function() {
        this.formType = P.views.organizations.Form;
        return Edit.__super__.initialize.apply(this, arguments);
      };

      Edit.prototype.open = function(model) {
        if (model == null) model = new P.models.Organization();
        return Edit.__super__.open.call(this, model);
      };

      return Edit;

    })(P.views.groups.Edit);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.organizations', function(x) {
    return x.Form = (function(_super) {

      __extends(Form, _super);

      Form.prototype.namespace = 'organization';

      Form.prototype.templateName = 'organizations/_form';

      Form.prototype._twitterPrefix = 'http://twitter.com/';

      Form.prototype.initialize = function() {
        Form.__super__.initialize.apply(this, arguments);
        this.websites = new P.views.links.FormPart();
        this.twitters = new P.views.links.FormPart({
          templateOptions: {
            label: 'Twitter',
            field_id: 'twitters_list',
            hint: 'Enter Twitter usernames; e.g. "pathable, flippyhead"'
          },
          urlPrefix: this._twitterPrefix
        });
        this.tags = new P.views.shared.auto_suggest.AutoSuggest({
          collection: new P.models.Labels,
          searchOptions: {
            classes: ['Organizations::Label'],
            order: 'name'
          }
        });
        return this.bind('edit', this.setup);
      };

      function Form() {
        this.render = __bind(this.render, this);
        this.setup = __bind(this.setup, this);
        this.initialize = __bind(this.initialize, this);        Form.__super__.constructor.apply(this, arguments);
        this.textEditor.addHtmlControl();
      }

      Form.prototype.formValues = function() {
        var links, tags, values;
        values = Form.__super__.formValues.apply(this, arguments);
        links = (this.websites.getLinks().concat(this.twitters.getLinks())).join(',');
        tags = _.compact(this.tags.collection.map(function(t) {
          return t.get('name');
        })).join(',');
        return _.extend({
          link_list: links,
          tags: tags
        }, values);
      };

      Form.prototype.setup = function() {
        var _this = this;
        Form.__super__.setup.apply(this, arguments);
        return this.model.fetch({
          success: function() {
            _this.websites.use(_this.model.links.withoutURL(_this._twitterPrefix));
            _this.twitters.use(_this.model.links.withURL(_this._twitterPrefix));
            return _this.tags.collection.reset(_this.model.labels.tags.models);
          }
        });
      };

      Form.prototype.render = function() {
        Form.__super__.render.apply(this, arguments);
        this.replaceWith('.websites', this.websites);
        this.replaceWith('.twitters', this.twitters);
        this.replaceWith('.organization-tags', this.tags);
        return this;
      };

      return Form;

    })(P.views.groups.Form);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.organizations', function(x) {
    return x.List = (function(_super) {

      __extends(List, _super);

      List.prototype.className = function() {
        return "" + List.__super__.className.apply(this, arguments) + " organizations organizations-medium";
      };

      function List() {
        List.__super__.constructor.apply(this, arguments);
        if (this.options == null) this.options = {};
        if (this.templateOptions == null) this.templateOptions = {};
      }

      List.prototype.itemType = x.Card;

      List.prototype.itemOptions = function() {
        return {
          showControls: true
        };
      };

      return List;

    })(Backbone.List);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.organizations', function(x) {
    return x.Logo = (function(_super) {

      __extends(Logo, _super);

      function Logo() {
        Logo.__super__.constructor.apply(this, arguments);
      }

      Logo.prototype.templateName = 'organizations/_logo';

      Logo.prototype.initialize = function() {
        Logo.__super__.initialize.apply(this, arguments);
        return this.model.bind('change', this.render);
      };

      return Logo;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.organizations', function(x) {
    return x.Name = (function(_super) {

      __extends(Name, _super);

      function Name() {
        Name.__super__.constructor.apply(this, arguments);
      }

      Name.prototype.templateName = 'organizations/_name';

      Name.prototype.initialize = function() {
        Name.__super__.initialize.apply(this, arguments);
        return this.model.bind('change', this.render);
      };

      return Name;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.organizations', function(x) {
    return x.Navigation = (function(_super) {

      __extends(Navigation, _super);

      function Navigation() {
        this._edit = __bind(this._edit, this);
        this._message = __bind(this._message, this);
        this.loginout = __bind(this.loginout, this);
        this.render = __bind(this.render, this);
        Navigation.__super__.constructor.apply(this, arguments);
      }

      Navigation.prototype.events = function() {
        return _.extend(Navigation.__super__.events.apply(this, arguments), {
          'click .edit': '_edit'
        });
      };

      Navigation.prototype.templateName = 'organizations/_navigation';

      Navigation.prototype.initialize = function() {
        Navigation.__super__.initialize.apply(this, arguments);
        return this.edit = new x.Edit({
          model: this.model,
          width: 750
        });
      };

      Navigation.prototype.render = function() {
        Navigation.__super__.render.apply(this, arguments);
        this.edit.render();
        return this;
      };

      Navigation.prototype.loginout = function(session, loggedIn) {
        Navigation.__super__.loginout.apply(this, arguments);
        this.setup();
        this.$('.control_bar').toggle(loggedIn);
        return this.$('button.edit').toggle(loggedIn && (session.user.hasRole('admin', this.model) || session.user.hasRole('admin', P.community)));
      };

      Navigation.prototype._message = function() {
        return P.router.layout.discussion.open(this.model);
      };

      Navigation.prototype._edit = function() {
        return this.edit.open(this.model);
      };

      return Navigation;

    })(P.views.shared.Navigation);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.organizations', function(x) {
    return x.Organization = (function(_super) {

      __extends(Organization, _super);

      function Organization() {
        var _base, _base2;
        Organization.__super__.constructor.apply(this, arguments);
        if ((_base = this.templateOptions).nameFormat == null) {
          _base.nameFormat = 'photo';
        }
        if ((_base2 = this.templateOptions).logo_size == null) {
          _base2.logo_size = 'full';
        }
      }

      Organization.prototype.render = function() {
        Organization.__super__.render.apply(this, arguments);
        if (this.model.get('level') != null) {
          this.html('.level', this.model.level.get('name'));
          this.$(this.el).css('border', "1px solid " + (this.model.level.get('color')));
          this.$('.level').css('background-color', this.model.level.get('color'));
          this.$('.level').addClass("level_" + this.model.level.id);
        }
        return this;
      };

      Organization.prototype.className = function() {
        return "" + Organization.__super__.className.apply(this, arguments) + " organization";
      };

      Organization.prototype.templateName = 'organizations/_organization';

      return Organization;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.organizations', function(x) {
    return x.SmallCard = (function(_super) {

      __extends(SmallCard, _super);

      function SmallCard() {
        SmallCard.__super__.constructor.apply(this, arguments);
      }

      SmallCard.prototype.className = function() {
        return "organization small-card";
      };

      SmallCard.prototype.templateName = 'organizations/_small_card';

      SmallCard.prototype.render = function() {
        SmallCard.__super__.render.apply(this, arguments);
        return this;
      };

      return SmallCard;

    })(x.Card);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.organizations', function(x) {
    return x.Tag = (function(_super) {

      __extends(Tag, _super);

      function Tag() {
        Tag.__super__.constructor.apply(this, arguments);
      }

      Tag.prototype.className = 'title tag';

      Tag.prototype.templateName = 'organizations/_tag';

      return Tag;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.organizations', function(x) {
    return x.Index = (function(_super) {

      __extends(Index, _super);

      Index.prototype.title = 'Attendees';

      Index.prototype.templateName = 'organizations/index';

      Index.prototype.className = function() {
        return "page organizations index";
      };

      function Index() {
        this._resetSearch = __bind(this._resetSearch, this);
        var _this = this;
        Index.__super__.constructor.apply(this, arguments);
        this.collection.searchOptions = _.extend(this.collection.searchOptions || {}, {
          per_page: 60,
          order: 'groups.name',
          classes: []
        });
        this.organizations = new P.views.organizations.List({
          addClass: 'three-col',
          collection: this.collection,
          templateOptions: {
            photo_size: 'full',
            include: ['blurb']
          }
        });
        this.search = new P.views.shared.lists.Search({
          collection: this.collection,
          options: {
            order: 'Name'
          },
          search: {
            classes: ['Organization']
          },
          track: function() {
            return P.tracker.track('organization search', _this.collection.searchOptions);
          }
        });
        this.bind('route', this._resetSearch);
        this.groups = new P.views.groups.ListSet({
          search: this.search,
          collection: P.community.questions
        });
      }

      Index.prototype.render = function() {
        Index.__super__.render.apply(this, arguments);
        P.logger.debug("Organizations", this.collection);
        this.replaceWith('.organizations-search', this.search);
        this.replaceWith('.organizations-list', this.organizations);
        this.replaceWith('.groups-listSet', this.groups);
        this.groups.reset();
        return this;
      };

      Index.prototype._resetSearch = function() {
        return this.search.reset();
      };

      return Index;

    })(P.views.shared.Page);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.organizations', function(x) {
    return x.Show = (function(_super) {

      __extends(Show, _super);

      function Show() {
        Show.__super__.constructor.apply(this, arguments);
      }

      Show.prototype.templateName = 'organizations/show';

      Show.prototype.className = function() {
        return "page organizations show";
      };

      Show.prototype.initialize = function() {
        Show.__super__.initialize.apply(this, arguments);
        this.navigation = new x.Navigation({
          model: this.model
        });
        this.name = new x.Name({
          model: this.model
        });
        this.logo = new x.Logo({
          model: this.model,
          templateOptions: {
            logo_size: 'full'
          }
        });
        this.blurb = new x.Blurb({
          model: this.model
        });
        this.tags = new P.views.shared.lists.TitledList({
          title: P.localizer.t('tags'),
          collection: this.model.labels.tags,
          itemType: x.Tag,
          addClass: 'labelized tag_list'
        });
        this.links = new P.views.links.List({
          collection: this.model.links,
          templateOptions: {
            title: P.localizer.t('websites')
          },
          autoFetch: true
        });
        this.documents = new P.views.documents.List({
          collection: this.model.documents,
          title: P.localizer.t('document', {
            pluralize: true
          })
        });
        this.members = new P.views.shared.lists.TitledList({
          itemType: P.views.users.Card,
          itemOptions: function(model) {
            return {
              showControls: true
            };
          },
          addClass: 'two-col small',
          collection: this.model.users,
          title: P.localizer.t('staff')
        });
        if (this.model.level) return this.level = this.model.level.attributes.name;
      };

      Show.prototype.title = function() {
        var _ref;
        return (_ref = this.model) != null ? _ref.get('name') : void 0;
      };

      Show.prototype.render = function() {
        Show.__super__.render.apply(this, arguments);
        this.replaceWith('.name', this.name);
        this.replaceWith('#level', this.level);
        this.replaceWith('.logo', this.logo);
        this.replaceWith('.links', this.links);
        this.replaceWith('.documents', this.documents);
        this.replaceWith('.members', this.members);
        this.replaceWith('.blurb', this.blurb);
        this.replaceWith('.tags', this.tags);
        this.model.fetch();
        return this;
      };

      return Show;

    })(P.views.shared.Page);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.sessions', function(x) {
    return x.Edit = (function(_super) {

      __extends(Edit, _super);

      function Edit() {
        this.render = __bind(this.render, this);
        Edit.__super__.constructor.apply(this, arguments);
      }

      Edit.prototype.initialize = function() {
        var _base;
        Edit.__super__.initialize.apply(this, arguments);
        (_base = this.options).height || (_base.height = 350);
        this.signinForm = new x.Form({
          model: this.model,
          parent: this
        });
        this.resetPasswordForm = new x.ResetPasswordForm({
          parent: this
        });
        return this.tabs = new P.views.shared.tabs.Tabs({
          parent: this,
          tabs: [
            {
              label: P.localizer.t('sign_in'),
              selector: this.signinForm.el
            }, {
              label: P.localizer.t('forgot_password'),
              selector: this.resetPasswordForm.el
            }
          ]
        });
      };

      Edit.prototype.open = function() {
        Edit.__super__.open.apply(this, arguments);
        this.tabs.goHome();
        this.center();
        return this.signinForm.setup();
      };

      Edit.prototype.render = function() {
        Edit.__super__.render.apply(this, arguments);
        this.append(this.signinForm);
        this.append(this.resetPasswordForm);
        this.prepend(this.tabs);
        return this;
      };

      return Edit;

    })(P.views.shared.Dialog);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.sessions', function(x) {
    return x.Form = (function(_super) {

      __extends(Form, _super);

      function Form() {
        this.render = __bind(this.render, this);
        this.trackSignin = __bind(this.trackSignin, this);
        this.saved = __bind(this.saved, this);
        this.formValues = __bind(this.formValues, this);
        this.setup = __bind(this.setup, this);
        this.initialize = __bind(this.initialize, this);
        Form.__super__.constructor.apply(this, arguments);
      }

      Form.prototype.templateName = 'sessions/_form';

      Form.prototype.features = [P.views.shared.forms.ErrorsFeature, P.views.shared.forms.FormValueGetFeature, P.views.shared.forms.FocusFeature];

      Form.prototype.initialize = function() {
        var _base;
        Form.__super__.initialize.apply(this, arguments);
        this.model = new P.models.Session();
        (_base = this.model).user || (_base.user = new P.models.User());
        this.bind('saved', this.saved);
        this.bind('saved', this.trackSignin);
        return this.buttons = new P.views.shared.ControlBar({
          buttonOptions: [
            {
              label: P.localizer.t('sign_in'),
              disabledLabel: P.localizer.t('signing_in'),
              buttonClass: 'submit'
            }
          ]
        });
      };

      Form.prototype.setup = function() {
        this.focus(true);
        return this.bindErrors();
      };

      Form.prototype.formValues = function() {
        var values;
        this.model.set({
          id: null,
          email: '',
          password: ''
        });
        values = {
          remember_me: this.$('#user_remember_me').is(':checked')
        };
        return _.defaults(values, this.getValues('user'));
      };

      Form.prototype.saved = function() {
        Form.__super__.saved.apply(this, arguments);
        P.session.set(this.model);
        this.parent.close();
        P.router.layout.flash.show({
          "class": 'success',
          message: P.localizer.t('welcome_back_user', {
            user: P.user.get('first_name') || P.localizer.t('friend')
          })
        });
        if (!P.community.settings.get('public')) return document.location.reload();
      };

      Form.prototype.trackSignin = function() {
        return P.tracker.track('signins');
      };

      Form.prototype.render = function() {
        Form.__super__.render.apply(this, arguments);
        return this;
      };

      return Form;

    })(P.views.shared.forms.Form);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.sessions', function(x) {
    return x.ResetPasswordForm = (function(_super) {

      __extends(ResetPasswordForm, _super);

      function ResetPasswordForm() {
        this.render = __bind(this.render, this);
        this.saved = __bind(this.saved, this);
        this.setup = __bind(this.setup, this);
        this.formValues = __bind(this.formValues, this);
        ResetPasswordForm.__super__.constructor.apply(this, arguments);
      }

      ResetPasswordForm.prototype.templateName = 'sessions/_reset_password_form';

      ResetPasswordForm.prototype.features = [P.views.shared.forms.ErrorsFeature, P.views.shared.forms.FormValueGetFeature, P.views.shared.forms.FocusFeature];

      ResetPasswordForm.prototype.initialize = function() {
        ResetPasswordForm.__super__.initialize.apply(this, arguments);
        this.buttons = new P.views.shared.ControlBar({
          buttonOptions: [
            {
              label: P.localizer.t('send'),
              disabledLabel: 'Sending',
              icons: {
                primary: 'ui-icon-mail-closed'
              }
            }
          ]
        });
        this.flash = this.parent.flash;
        this.model = new P.models.PasswordReset();
        this.bind('saved', this.saved);
        return this.bind('edit', this.setup);
      };

      ResetPasswordForm.prototype.formValues = function() {
        this.model = new P.models.PasswordReset();
        return this.getValues();
      };

      ResetPasswordForm.prototype.setup = function() {
        this.focus(true);
        return this.bindErrors();
      };

      ResetPasswordForm.prototype.saved = function() {
        this.parent.close();
        return P.router.layout.flash.show({
          message: P.localizer.t('reset_password_created')
        }, P.localizer.t('done'));
      };

      ResetPasswordForm.prototype.render = function() {
        ResetPasswordForm.__super__.render.apply(this, arguments);
        this.bindErrors();
        this.focus(true);
        return this;
      };

      return ResetPasswordForm;

    })(P.views.shared.forms.Form);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.answers', function(x) {
    return x.Form = (function(_super) {

      __extends(Form, _super);

      function Form() {
        this.render = __bind(this.render, this);
        this.formValues = __bind(this.formValues, this);
        this.setup = __bind(this.setup, this);
        Form.__super__.constructor.apply(this, arguments);
      }

      Form.prototype.templateName = 'answers/_form';

      Form.prototype.className = 'answer_form';

      Form.prototype.hideTagList = true;

      Form.prototype.initialize = function() {
        Form.__super__.initialize.apply(this, arguments);
        this.templateOptions.hideTagList = this.hideTagList;
        this.question = this.options.question;
        this.model || (this.model = new P.models.Answer());
        this.model.question = this.question;
        if (this.question.input_type = 'select') {
          this.options.selectGroups = this.question.tags;
          return this.options.includeBlank = true;
        }
      };

      Form.prototype.use = function(model) {
        this.model = model;
        if (this.question.input_type = 'select') {
          return this.$('.answer select option:selected').text(this.model.get('answer'));
        } else {
          return this.$('.answer input').val(this.model.get('answer'));
        }
      };

      Form.prototype.clear = function() {
        return this.$('input').val('');
      };

      Form.prototype.setup = function() {};

      Form.prototype.formValues = function() {
        var values;
        values = {};
        if (this.model != null) {
          values['id'] = this.model.id;
          values['question_id'] = this.model.get('question_id');
        }
        if (this.question.input_type = 'select') {
          values['answer'] = this.$('.answer select option:selected').text();
        } else {
          values['answer'] = this.$('.answer input').val();
        }
        return values;
      };

      Form.prototype.render = function() {
        Form.__super__.render.apply(this, arguments);
        return this;
      };

      return Form;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.answers', function(x) {
    return x.Answer = (function(_super) {

      __extends(Answer, _super);

      Answer.prototype.templateName = 'answers/_answer';

      Answer.prototype.className = function() {
        return "" + Answer.__super__.className.apply(this, arguments) + " answer";
      };

      function Answer() {
        Answer.__super__.constructor.apply(this, arguments);
        this.groups = new P.views.groups.TagList({
          collection: this.model.tags,
          question: this.model.question
        });
      }

      Answer.prototype.render = function() {
        Answer.__super__.render.apply(this, arguments);
        this.replaceWith('.groups', this.groups);
        return this;
      };

      return Answer;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.answers', function(x) {
    return x.AutoSuggestForm = (function(_super) {

      __extends(AutoSuggestForm, _super);

      function AutoSuggestForm() {
        AutoSuggestForm.__super__.constructor.apply(this, arguments);
      }

      AutoSuggestForm.prototype.templateName = 'answers/_form';

      AutoSuggestForm.prototype.className = 'answer_form';

      AutoSuggestForm.prototype.hideTagList = false;

      AutoSuggestForm.prototype.initialize = function() {
        var _this = this;
        AutoSuggestForm.__super__.initialize.apply(this, arguments);
        this.autoSuggest = new P.views.shared.auto_suggest.AutoSuggest({
          searchOptions: {
            classes: ['Groups::Tag']
          }
        });
        this.staticSuggest = new P.views.static_suggestions.List({
          collection: this.question.tags,
          hint: this.question.get('hint') || 'Type your own above, or select from suggested tags:'
        });
        this.staticSuggest.bind('toggle', function(model, view, selected) {
          try {
            return _this.autoSuggest.collection[selected && 'add' || 'remove'](model);
          } catch (error) {
            return P.logger.warning('Error initializing AutoSuggest:', error);
          }
        });
        this.autoSuggest.collection.bind('remove', function(model) {
          return _this.staticSuggest.unselect(model);
        });
        return this.autoSuggest.collection.bind('add', function(model) {
          if (!_this.autoSuggest.collection.include(model)) {
            return _this.staticSuggest.select(model, {
              silent: true
            });
          }
        });
      };

      AutoSuggestForm.prototype.use = function(model) {
        this.model = model;
        this.clear();
        return this.setupAutoSuggest();
      };

      AutoSuggestForm.prototype.clear = function() {
        P.logger.trace("Clearing AutoSuggest for form:", this);
        return this.autoSuggest.clear();
      };

      AutoSuggestForm.prototype.setupAutoSuggest = function() {
        var _this = this;
        this.autoSuggest.clear();
        return this.model.tags.each(function(group) {
          _this.autoSuggest.collection.add(group);
          return _this.staticSuggest.select(group, {
            selected: true
          });
        });
      };

      AutoSuggestForm.prototype.formValues = function() {
        var answers, values;
        answers = [];
        values = AutoSuggestForm.__super__.formValues.apply(this, arguments);
        this.autoSuggest.collection.each(function(item) {
          if (item instanceof P.models.Group) {
            return answers.push(item.get('friendly_name'));
          }
        });
        values['answer'] = answers.join(', ');
        return values;
      };

      AutoSuggestForm.prototype.render = function() {
        AutoSuggestForm.__super__.render.apply(this, arguments);
        this.replaceWith('.answer input', this.autoSuggest);
        this.replaceWith('.tag_list input', this.staticSuggest);
        this.staticSuggest.$el.hide();
        return this;
      };

      return AutoSuggestForm;

    })(P.views.answers.Form);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.answers', function(x) {
    return x.FormSet = (function(_super) {

      __extends(FormSet, _super);

      function FormSet() {
        this._showSuggestions = __bind(this._showSuggestions, this);
        this.initialize = __bind(this.initialize, this);
        FormSet.__super__.constructor.apply(this, arguments);
      }

      FormSet.prototype.initialize = function() {
        var _this = this;
        FormSet.__super__.initialize.apply(this, arguments);
        this.answerForms = {};
        return P.community.questions.each(function(question) {
          var formType;
          formType = P.views.answers[question.get('input_type') === 'auto_suggest' ? 'AutoSuggestForm' : 'Form'];
          return _this.answerForms[question.id] = new formType({
            question: question
          });
        });
      };

      FormSet.prototype.tagName = 'fieldset';

      FormSet.prototype.className = function() {
        return "" + FormSet.__super__.className.apply(this, arguments) + " inputs";
      };

      FormSet.prototype.events = function() {
        return _.extend(FormSet.__super__.events.apply(this, arguments), {
          'focus .answer_form': '_showSuggestions'
        });
      };

      FormSet.prototype._showSuggestions = function(e) {
        $('.tag_list', e.currentTarget).slideDown('slow');
        return this.$('.answer_form').each(function(i, form) {
          if (form !== e.currentTarget) return $('.tag_list', form).slideUp();
        });
      };

      FormSet.prototype.use = function(collection) {
        var _this = this;
        this.clear();
        this.collection = collection;
        return P.community.questions.each(function(question) {
          var answer, form;
          form = _this.answerForms[question.id];
          if (form == null) return;
          if (!(answer = _this.collection.toQuestion(question))) {
            answer = new P.models.Answer({
              question: question
            });
            _this.collection.add(answer);
          }
          return form.use(answer);
        });
      };

      FormSet.prototype.formValues = function() {
        return _.map(this.answerForms, function(form) {
          return form.formValues();
        });
      };

      FormSet.prototype.clear = function() {
        return _.each(this.answerForms, function(form) {
          return form.clear();
        });
      };

      FormSet.prototype.render = function() {
        var _this = this;
        FormSet.__super__.render.apply(this, arguments);
        _.each(this.answerForms, function(form) {
          return _this.append(form);
        });
        return this;
      };

      return FormSet;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.answers', function(x) {
    return x.List = (function(_super) {

      __extends(List, _super);

      function List() {
        List.__super__.constructor.apply(this, arguments);
      }

      List.prototype.itemType = P.views.answers.Answer;

      List.prototype.className = function() {
        return "" + List.__super__.className.apply(this, arguments) + " answers groups-list-set";
      };

      return List;

    })(P.views.shared.lists.TitledList);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.users', function(x) {
    return x.FormBasics = (function(_super) {

      __extends(FormBasics, _super);

      function FormBasics() {
        FormBasics.__super__.constructor.apply(this, arguments);
      }

      FormBasics.prototype.formValues = function() {
        var values, _ref;
        values = {
          roles: _.map(this.$('.roles input:checked'), function(el) {
            return el.value;
          }),
          temp_attachment_id: (_ref = this.uploadify.attachment) != null ? _ref.id : void 0,
          answers_attributes: this.answers.formValues(),
          visible: this.$('.visible input').prop('checked')
        };
        _.defaults(values, this.getValues());
        return values;
      };

      FormBasics.prototype._optimize = function() {
        if (this.model.isNew()) this.$('.visible input').prop('checked', false);
        this.$('.wants_default_allowed_mails').hide();
        return this.$('.has_accepted_legal').hide();
      };

      return FormBasics;

    })(P.views.users.FormBasics);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.users', function(x) {
    return x.FormSettings = (function(_super) {

      __extends(FormSettings, _super);

      function FormSettings() {
        this.formValues = __bind(this.formValues, this);
        FormSettings.__super__.constructor.apply(this, arguments);
      }

      FormSettings.prototype.formValues = function() {
        return {
          enabled_for_email: this.$('.enabled_for_email input').prop('checked'),
          allowed_mails: !this.model.isNew() ? _.map(this.$('.allowed_mails input:checked'), function(el) {
            return el.value;
          }) : void 0
        };
      };

      return FormSettings;

    })(P.views.users.FormSettings);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.users', function(x) {
    return x.Form = (function(_super) {

      __extends(Form, _super);

      function Form() {
        Form.__super__.constructor.apply(this, arguments);
        this.mail = new P.views.messages.mail.Form({
          model: this.model
        });
        this.details.textEditor.addHtmlControl();
      }

      Form.prototype.parts = {
        basics: P.views.host.users.FormBasics,
        details: P.views.users.FormDetails,
        settings: P.views.host.users.FormSettings
      };

      Form.prototype.events = function() {
        return _.extend(Form.__super__.events.apply(this, arguments), {
          'click input.send_mail': 'toggleMail'
        });
      };

      Form.prototype.formValues = function() {
        var values;
        values = Form.__super__.formValues.apply(this, arguments);
        _.defaults(values, {
          strict_validation: false,
          mails_attributes: this.mail.formValues()
        });
        return values;
      };

      Form.prototype.toggleMail = function(e) {
        var input;
        input = this.$('input.send_mail');
        if (input.is(':checked')) {
          return this.mail.$el.show();
        } else {
          return this.mail.$el.hide();
        }
      };

      Form.prototype.render = function() {
        Form.__super__.render.apply(this, arguments);
        this.protect(false);
        this.replaceWith('.mail', this.mail);
        this.replaceWith('.extra', this.extra);
        this.toggleMail();
        return this;
      };

      return Form;

    })(P.views.users.Form);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.users', function(x) {
    return x.Edit = (function(_super) {

      __extends(Edit, _super);

      function Edit() {
        Edit.__super__.constructor.apply(this, arguments);
      }

      Edit.prototype.initialize = function() {
        Edit.__super__.initialize.apply(this, arguments);
        this.form = new x.Form({
          model: this.model,
          parent: this
        });
        this.extra = new x.Extra({
          model: this.model
        });
        return this.tabs = new P.views.shared.tabs.Tabs({
          parent: this,
          tabs: [
            {
              label: 'Basics',
              selector: '.basics'
            }, {
              label: 'Details',
              selector: '.details'
            }, {
              label: 'Extra',
              selector: '.extra'
            }
          ]
        });
      };

      Edit.prototype.templateName = 'host/users/_edit';

      Edit.prototype.className = function() {
        return "" + Edit.__super__.className.apply(this, arguments) + " users-edit";
      };

      Edit.prototype.open = function(model) {
        if (model == null) model = new P.models.User();
        Edit.__super__.open.apply(this, arguments);
        this.form.edit(model);
        this.extra.edit(model);
        this.tabs.goHome();
        return this.center();
      };

      Edit.prototype.clear = function() {
        Edit.__super__.clear.apply(this, arguments);
        return this.textEditor.clear();
      };

      Edit.prototype.render = function() {
        Edit.__super__.render.apply(this, arguments);
        this.replaceWith('.form', this.form);
        this.replaceWith('.tabs', this.tabs);
        this.replaceWith('.extra', this.extra);
        return this;
      };

      return Edit;

    })(P.views.shared.Dialog);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.users', function(x) {
    return x.Extra = (function(_super) {

      __extends(Extra, _super);

      Extra.prototype.templateName = 'host/users/_extra';

      Extra.prototype.className = function() {
        return "" + Extra.__super__.className.apply(this, arguments) + " extra";
      };

      Extra.prototype.features = [P.views.shared.forms.FormValueSetFeature];

      Extra.prototype.events = function() {
        return _.extend(Extra.__super__.events.apply(this, arguments), {
          'click input': 'select'
        });
      };

      function Extra() {
        Extra.__super__.constructor.apply(this, arguments);
        this.bind('edit', this.setup);
      }

      Extra.prototype.select = function(e) {
        e.preventDefault();
        return e.currentTarget.select();
      };

      Extra.prototype.setup = function() {
        return this.setValues();
      };

      return Extra;

    })(P.views.shared.forms.Form);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.users', function(x) {
    return x.MultieditForm = (function(_super) {

      __extends(MultieditForm, _super);

      MultieditForm.prototype.className = function() {
        return "" + MultieditForm.__super__.className.apply(this, arguments) + " user_multi_edit";
      };

      MultieditForm.prototype.templateName = 'host/users/multi_edit_form';

      MultieditForm.prototype.features = [P.views.shared.forms.ErrorsFeature, P.views.shared.forms.FormValueGetFeature, P.views.shared.forms.FormValueSetFeature, P.views.shared.forms.FocusFeature];

      MultieditForm.prototype.namespace = "users";

      function MultieditForm() {
        this.toggleAllowedMails = __bind(this.toggleAllowedMails, this);
        this.formValues = __bind(this.formValues, this);        MultieditForm.__super__.constructor.apply(this, arguments);
        this.buttons = new P.views.shared.ControlBar({
          controls: ['save']
        });
        this.bind('saved', this.saved);
        this.bind('edit', this.setup);
      }

      MultieditForm.prototype.setup = function() {
        var _this = this;
        this.focus(true);
        this.bindErrors({
          namespace: this.namespace
        });
        this.model.bind('change:needs_to_set_password', this.assignPasswords);
        this.$('.enabled_for_email input').bind("stateChanged", function() {
          return _this.toggleAllowedMails();
        });
        this.toggleAllowedMails();
        return this.$('#users_ribbon_ids').prepend("<option value=''>(none)</option>");
      };

      MultieditForm.prototype.events = function() {
        return _.extend(MultieditForm.__super__.events.apply(this, arguments), {
          'focus input': 'clearFormErrors'
        });
      };

      MultieditForm.prototype.formValues = function() {
        var values;
        values = {
          'strict_validation': false
        };
        this.addTextInputsValues(values, ['password', 'password_confirmation', 'credentials', 'organization_name', 'title']);
        this.addTristatesValues(values, ['visible', 'has_accepted_legal', 'enabled_for_email']);
        this.addGroupTristatesValues(values, ['roles', 'allowed_mails']);
        this.getRibbonIds(values);
        return values;
      };

      MultieditForm.prototype.render = function() {
        MultieditForm.__super__.render.apply(this, arguments);
        return this;
      };

      MultieditForm.prototype.toggleAllowedMails = function() {
        return this.$('.allowed_mails').toggle(this.$('.enabled_for_email input').getState() === 'checked');
      };

      MultieditForm.prototype.getRibbonIds = function(values) {
        var value;
        value = this.$('#users_ribbon_ids').val();
        if (value != null) return values['ribbon_ids'] = value;
      };

      return MultieditForm;

    })(P.views.shared.forms.MultieditForm);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.users', function(x) {
    return x.Table = (function(_super) {

      __extends(Table, _super);

      function Table() {
        this.collection = new P.models.Users();
        Table.__super__.constructor.apply(this, arguments);
      }

      Table.prototype.columns = function() {
        return {
          first_name: {
            title: 'First',
            width: '100px',
            features: ['sortable', 'filterable'],
            filter_type: 'string',
            render: this.renderTruncatedShort
          },
          last_name: {
            title: 'Last',
            width: '100px',
            features: ['sortable', 'filterable'],
            filter_type: 'string',
            render: this.renderTruncatedShort
          },
          'emails.email': {
            source: 'primary_email',
            title: 'Email',
            width: '100px',
            features: ['sortable', 'filterable'],
            filter_type: 'string',
            render: this.renderTruncatedLong
          },
          organization_name: {
            title: 'Organization',
            width: '200px',
            features: ['sortable', 'filterable'],
            filter_type: 'string',
            render: this.renderTruncatedLong
          },
          roles: {
            title: 'Roles',
            width: '130px',
            features: ['filterable'],
            filter_type: 'select',
            filter_options: [['admin', 'admin']],
            render: this.renderList,
            visible: false
          },
          'ribbons.name': {
            source: 'ribbon_names',
            title: 'Ribbons',
            width: '130px',
            features: ['filterable'],
            filter_type: 'select',
            filter_options: [['Speaker', 'Speaker'], ['Sponsor', 'Sponsor'], ['Exhibitor', 'Exhibitor']],
            render: this.renderList
          },
          'users.dirty': {
            source: 'dirty',
            title: 'Resp.',
            width: '130px',
            features: ['sortable', 'filterable'],
            filter_type: 'select',
            filter_options: [[1, 'Yes'], [0, 'No']],
            render: this.renderBoolean
          }
        };
      };

      Table.prototype.wildcardColumns = ['first_name', 'last_name', 'emails.email', 'organization_name'];

      Table.prototype.className = function() {
        return "" + Table.__super__.className.apply(this, arguments) + " users-table";
      };

      Table.prototype.rowConstructor = P.views.shared.tables.NavRow;

      return Table;

    })(P.views.shared.tables.ServerSideTable);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.users', function(x) {
    return x.Tabs = (function(_super) {

      __extends(Tabs, _super);

      function Tabs() {
        Tabs.__super__.constructor.apply(this, arguments);
      }

      Tabs.prototype.tabs = [
        {
          label: 'Basics',
          selector: '.basics'
        }, {
          label: 'Details',
          selector: '.details'
        }, {
          label: 'Extra',
          selector: '.extra'
        }
      ];

      Tabs.prototype.render = function() {
        return Tabs.__super__.render.apply(this, arguments);
      };

      return Tabs;

    })(P.views.shared.tabs.Tabs);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.users', function(x) {
    return x.EditPage = (function(_super) {

      __extends(EditPage, _super);

      function EditPage() {
        EditPage.__super__.constructor.apply(this, arguments);
      }

      EditPage.prototype.templateName = 'host/users/edit';

      EditPage.prototype.className = function() {
        return "" + EditPage.__super__.className.apply(this, arguments) + " users edit";
      };

      EditPage.prototype.initialize = function() {
        var _this = this;
        EditPage.__super__.initialize.apply(this, arguments);
        this.form = new x.Form({
          model: this.model,
          parent: this
        });
        this.extra = new x.Extra({
          model: this.model
        });
        this.tabs = new P.views.shared.tabs.Tabs({
          parent: this,
          tabs: [
            {
              label: 'Basics',
              selector: '.basics'
            }, {
              label: 'Details',
              selector: '.details'
            }, {
              label: 'Email Settings',
              selector: '.settings'
            }, {
              label: 'Extra',
              selector: '.extra'
            }
          ]
        });
        return this.form.bind('saved', function() {
          return P.router.redirectTo('#users');
        });
      };

      EditPage.prototype.render = function() {
        EditPage.__super__.render.apply(this, arguments);
        this.replaceWith('.form', this.form);
        this.replaceWith('.tabs', this.tabs);
        this.replaceWith('.extra', this.extra);
        this.form.edit(this.model);
        this.extra.edit(this.model);
        this.tabs.goHome();
        return this;
      };

      return EditPage;

    })(P.views.shared.HostPage);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.users', function(x) {
    return x.Index = (function(_super) {

      __extends(Index, _super);

      Index.prototype.templateName = 'host/users/index';

      Index.prototype.events = function() {
        return _.extend(Index.__super__.events.apply(this, arguments), {
          'click button.destroy': '_destroy',
          'click button.message': '_message',
          'click button.edit': '_edit'
        });
      };

      function Index() {
        this.render = __bind(this.render, this);        Index.__super__.constructor.apply(this, arguments);
        this.table = new P.views.host.users.Table({
          parent: this
        });
        this.edit = new x.Edit({
          model: new P.models.User(),
          parent: this
        });
        this.mail = new P.views.host.messages.mail.Edit({
          parent: this
        });
      }

      Index.prototype.render = function() {
        Index.__super__.render.apply(this, arguments);
        this.replaceWith('.table', this.table);
        this.mail.render();
        this.edit.render();
        return this;
      };

      Index.prototype._destroy = function() {
        return this.table.destroy();
      };

      Index.prototype._message = function() {
        this.mail.use(this.table.selected());
        return this.mail.open();
      };

      Index.prototype._edit = function() {
        var selected;
        selected = this.table.selected();
        if (selected.length < 1) {
          return this.flash.show({
            message: 'Please select one or more rows first.',
            "class": 'warn'
          }, 'Oops!');
        } else if (selected.length === 1) {
          return P.router.redirectTo(selected.models[0].fragment());
        } else {
          P.views.host.users.Multiedit.current_collection = selected;
          return P.router.redirectTo("#users/multiedit");
        }
      };

      return Index;

    })(P.views.shared.Table);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.users', function(x) {
    return x.Multiedit = (function(_super) {

      __extends(Multiedit, _super);

      function Multiedit() {
        Multiedit.__super__.constructor.apply(this, arguments);
      }

      Multiedit.prototype.templateName = 'host/users/multi_edit';

      Multiedit.prototype.className = function() {
        return "" + Multiedit.__super__.className.apply(this, arguments) + " users multi_edit";
      };

      Multiedit.prototype.initialize = function() {
        var _this = this;
        Multiedit.__super__.initialize.apply(this, arguments);
        this.form = new x.MultieditForm({
          collection: this.collection,
          parent: this
        });
        return this.form.bind('saved', function() {
          P.router.layout.flash.show({
            message: "Changes to " + _this.collection.length + " users queued.  It may take a few minutes for changes to appear."
          });
          return P.router.redirectTo('#users');
        });
      };

      Multiedit.prototype.render = function() {
        Multiedit.__super__.render.apply(this, arguments);
        this.replaceWith('.form', this.form);
        this.form.edit(this.collection);
        return this;
      };

      return Multiedit;

    })(P.views.shared.HostPage);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.layouts', function(x) {
    return x.Navigation = (function(_super) {

      __extends(Navigation, _super);

      function Navigation() {
        Navigation.__super__.constructor.apply(this, arguments);
      }

      Navigation.prototype.templateName = 'layouts/host/_navigation';

      Navigation.prototype.initialize = function() {
        Navigation.__super__.initialize.apply(this, arguments);
        return this.contextSwitcher = new P.views.layouts.ContextSwitcher({
          tagName: 'li',
          className: 'secondary contextSwitch',
          path: '/host',
          templateOptions: {
            community: P.association,
            events: P.association.events
          }
        });
      };

      Navigation.prototype.activate = function(id) {};

      Navigation.prototype.render = function() {
        Navigation.__super__.render.apply(this, arguments);
        this.replaceWith('.contextSwitch', this.contextSwitcher);
        return this;
      };

      return Navigation;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.layouts', function(x) {
    return x.Application = (function(_super) {

      __extends(Application, _super);

      function Application() {
        this.render = __bind(this.render, this);
        this.initialize = __bind(this.initialize, this);
        Application.__super__.constructor.apply(this, arguments);
      }

      Application.prototype.initialize = function() {
        var _this = this;
        Application.__super__.initialize.apply(this, arguments);
        this.navigation = new P.views.host.layouts.Navigation();
        this.flash = new P.views.layouts.Flash({
          el: '#flash'
        });
        this.footer = new P.views.layouts.Footer();
        this.router = this.options.router;
        this.router.bind('loading', function() {
          var _ref;
          if ((_ref = _this.router.visible) != null) _ref.$el.hide();
          return $('#loading').show();
        });
        this.router.bind('load', function() {
          return $('#loading').hide();
        });
        return this.router.bind('route', function() {
          return $('#loading').hide();
        });
      };

      Application.prototype.render = function() {
        Application.__super__.render.apply(this, arguments);
        this.html('.footer', this.footer);
        this.flash.render();
        $('.sidebar').html(this.navigation.render().el);
        return this;
      };

      return Application;

    })(P.views.shared.View);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.groups', function(x) {
    return x.Edit = (function(_super) {

      __extends(Edit, _super);

      function Edit() {
        Edit.__super__.constructor.apply(this, arguments);
      }

      Edit.prototype.templateName = 'host/groups/_edit';

      Edit.prototype.className = function() {
        return "" + Edit.__super__.className.apply(this, arguments) + " groups-edit";
      };

      return Edit;

    })(P.views.groups.Edit);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.groups', function(x) {
    return x.Table = (function(_super) {

      __extends(Table, _super);

      function Table() {
        Table.__super__.constructor.apply(this, arguments);
      }

      Table.prototype.columns = {
        name: {
          width: '130px',
          features: ['sortable', 'searchable', 'filterable'],
          filter_type: 'string'
        },
        memberships_count: {
          title: 'Members',
          width: '70px',
          sortable: true,
          type: 'numeric'
        },
        affiliation_names: {
          title: 'Affiliations',
          width: '200px',
          "class": 'ellipsis'
        }
      };

      Table.prototype.wildcardColumns = ['name'];

      Table.prototype.className = function() {
        return "" + Table.__super__.className.apply(this, arguments) + " groups-table";
      };

      Table.prototype.rowConstructor = P.views.shared.tables.NavRow;

      return Table;

    })(P.views.shared.tables.ServerSideTable);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.groups', function(x) {
    return x.EditPage = (function(_super) {

      __extends(EditPage, _super);

      function EditPage() {
        this.initialize = __bind(this.initialize, this);
        EditPage.__super__.constructor.apply(this, arguments);
      }

      EditPage.prototype.templateName = 'groups/edit';

      EditPage.prototype.className = function() {
        return "" + EditPage.__super__.className.apply(this, arguments) + " groups edit";
      };

      EditPage.prototype.returnUrl = '#groups';

      EditPage.prototype.formType = function() {
        return P.views.groups.Form;
      };

      EditPage.prototype.initialize = function() {
        var _this = this;
        EditPage.__super__.initialize.apply(this, arguments);
        _.defaults(this.options, {
          returnUrl: this.returnUrl
        });
        this.form = new (this.formType())({
          parent: this
        }).bind('saved', function() {
          return P.router.redirectTo(_this.options.returnUrl);
        });
        this.form.textEditor.addHtmlControl();
        this.memberships = new P.views.memberships.Index({
          parent: this
        });
        this.affiliations = new P.views.affiliations.Index({
          parent: this
        });
        this.documents = new P.views.documents.Index({
          parent: this
        });
        return this.tabs = new P.views.shared.tabs.Tabs({
          parent: this,
          tabs: [
            {
              label: 'Basics',
              selector: '.groups-form'
            }, {
              label: 'Members',
              selector: '.memberships-index'
            }, {
              label: 'Documents',
              selector: '.documents-index'
            }, {
              label: 'Affiliations',
              selector: '.affiliations-index'
            }
          ]
        });
      };

      EditPage.prototype.render = function() {
        EditPage.__super__.render.apply(this, arguments);
        this.replaceWith('.form', this.form);
        this.replaceWith('.memberships', this.memberships);
        this.replaceWith('.documents', this.documents);
        this.replaceWith('.affiliations', this.affiliations);
        this.replaceWith('.tabs', this.tabs);
        this.form.edit(this.model);
        if (this.model.isNew()) {
          this.tabs.disable(['Members', 'Documents', 'Affiliations']);
        } else {
          this.tabs.enable(['Members', 'Documents', 'Affiliations']);
          this.memberships.use(this.model.memberships);
          this.documents["for"](this.model);
          this.affiliations.use(this.model.affiliations);
          this.model.memberships.fetch();
          this.model.affiliations.fetch();
        }
        this.tabs.goHome();
        return this;
      };

      return EditPage;

    })(P.views.shared.HostPage);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.groups', function(x) {
    return x.Index = (function(_super) {

      __extends(Index, _super);

      Index.prototype.title = 'Groups';

      Index.prototype.tableConstructor = x.Table;

      Index.prototype.templateName = 'host/groups/index';

      Index.prototype.events = function() {
        return _.extend(Index.__super__.events.apply(this, arguments), {
          'click button.destroy': 'destroy'
        });
      };

      function Index() {
        Index.__super__.constructor.apply(this, arguments);
        this.collection = new P.models.Groups();
        this.table = new x.Table({
          parent: this,
          collection: this.collection
        });
      }

      Index.prototype.destroy = function() {
        return this.table.destroy();
      };

      Index.prototype.render = function() {
        Index.__super__.render.apply(this, arguments);
        this.replaceWith('.table', this.table);
        return this;
      };

      return Index;

    })(P.views.shared.HostPage);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.communitySettings', function(x) {
    return x.Form = (function(_super) {

      __extends(Form, _super);

      function Form() {
        this.saved = __bind(this.saved, this);
        this.setup = __bind(this.setup, this);        Form.__super__.constructor.apply(this, arguments);
        this.bind('saved', this.saved);
        this.bind('edit', this.setup);
      }

      Form.prototype.className = function() {
        return "" + Form.__super__.className.apply(this, arguments) + " community_settings-form";
      };

      Form.prototype.templateName = 'community_settings/_form';

      Form.prototype.features = [P.views.shared.forms.ErrorsFeature, P.views.shared.forms.FormValueGetFeature, P.views.shared.forms.FormValueSetFeature];

      Form.prototype.formValues = function() {
        var attrs;
        attrs = this.getValues();
        attrs['show_user_tweets'] = this.$('.show_user_tweets input').prop('checked');
        return attrs;
      };

      Form.prototype.setup = function() {
        this.bindErrors();
        return this.setValues();
      };

      Form.prototype.saved = function(model) {
        return Form.__super__.saved.apply(this, arguments);
      };

      Form.prototype.render = function() {
        Form.__super__.render.apply(this, arguments);
        return this;
      };

      return Form;

    })(P.views.shared.forms.Form);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.communities', function(x) {
    return x.Chart = (function(_super) {

      __extends(Chart, _super);

      Chart.prototype.templateName = 'host/communities/_chart';

      Chart.prototype.events = function() {
        return _.extend(Chart.__super__.events.apply(this, arguments), {
          'change select': 'refreshChart'
        });
      };

      function Chart() {
        this.refreshChart = __bind(this.refreshChart, this);        Chart.__super__.constructor.apply(this, arguments);
        this.chart = new P.models.tracking.Chart;
      }

      Chart.prototype.trackedEvents = {
        'pageviews': {
          label: 'Page views',
          drilldown: ['view']
        },
        'signins': {
          label: 'Sign-ins'
        },
        'attendee search': {
          label: 'Attendee searches',
          drilldown: true
        }
      };

      Chart.prototype.buildChartSelector = function() {
        var event, options, _ref, _results;
        this.eventSelect = $(this.el).find('select');
        _ref = this.trackedEvents;
        _results = [];
        for (event in _ref) {
          options = _ref[event];
          _results.push(this.eventSelect.append($("<option/>").attr("value", event).html(options.label)));
        }
        return _results;
      };

      Chart.prototype.selectedEvent = function() {
        return this.eventSelect.find('option:selected').val();
      };

      Chart.prototype.refreshChart = function() {
        var event;
        this.chartContainer || (this.chartContainer = $(this.el).find('div'));
        event = this.selectedEvent();
        return this.chart.platform.create_line_chart(this.chartContainer, [event], {
          unit: 'week',
          mapping: {
            event: this.trackedEvents[event].label
          },
          drilldown: this.trackedEvents[event].drilldown || []
        });
      };

      Chart.prototype.render = function() {
        Chart.__super__.render.apply(this, arguments);
        this.buildChartSelector();
        this.refreshChart();
        return this;
      };

      return Chart;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.communities', function(x) {
    return x.Edit = (function(_super) {

      __extends(Edit, _super);

      function Edit() {
        this.initialize = __bind(this.initialize, this);
        Edit.__super__.constructor.apply(this, arguments);
      }

      Edit.prototype.className = function() {
        return "" + Edit.__super__.className.apply(this, arguments) + " community edit";
      };

      Edit.prototype.initialize = function() {
        var _this = this;
        Edit.__super__.initialize.apply(this, arguments);
        this.form = P.community.className === 'Event' ? new P.views.host.events.Form({
          parent: this,
          model: this.model
        }) : new x.Form({
          parent: this,
          model: this.model
        });
        return this.form.bind('saved', function() {
          return _this.close();
        });
      };

      Edit.prototype.open = function() {
        Edit.__super__.open.apply(this, arguments);
        this.form.edit(P.community);
        return this.center();
      };

      Edit.prototype.render = function() {
        Edit.__super__.render.apply(this, arguments);
        this.append(this.form);
        return this;
      };

      return Edit;

    })(P.views.shared.Dialog);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.communities', function(x) {
    return x.Form = (function(_super) {

      __extends(Form, _super);

      function Form() {
        this.initialize = __bind(this.initialize, this);
        Form.__super__.constructor.apply(this, arguments);
      }

      Form.prototype.templateName = 'communities/_form';

      Form.prototype.namespace = 'community';

      Form.prototype.features = [P.views.shared.forms.ErrorsFeature, P.views.shared.forms.FormValueGetFeature, P.views.shared.forms.FormValueSetFeature, P.views.shared.forms.FocusFeature];

      Form.prototype.initialize = function() {
        Form.__super__.initialize.apply(this, arguments);
        this.settings = new P.views.host.communitySettings.Form;
        return this.twitters = new P.views.links.FormPart({
          templateOptions: {
            label: 'Twitter',
            field_id: 'twitters_list',
            hint: 'Enter Twitter hashtags for event; e.g. "pathable, awesome"'
          },
          urlPrefix: 'http://search.twitter.com/search?q='
        });
      };

      Form.prototype.formValues = function() {
        var attrs;
        attrs = Form.__super__.formValues.apply(this, arguments);
        attrs['link_list'] = this.twitters.getLinks().join(',');
        return attrs;
      };

      Form.prototype.setup = function() {
        Form.__super__.setup.apply(this, arguments);
        this.bindErrors();
        this.focus(true);
        this.twitters.use(this.model.links.withURL('http://search.twitter.com/'));
        return this.settings.edit(this.model.settings);
      };

      Form.prototype.saved = function() {
        this.settings.save();
        Form.__super__.saved.apply(this, arguments);
        return P.layout.flash.show({
          message: 'Community saved!'
        });
      };

      Form.prototype.render = function() {
        Form.__super__.render.apply(this, arguments);
        this.replaceWith('.settings', this.settings);
        this.replaceWith('.twitters', this.twitters);
        return this;
      };

      return Form;

    })(P.views.groups.Form);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.communities', function(x) {
    return x.Show = (function(_super) {

      __extends(Show, _super);

      function Show() {
        this._editSettings = __bind(this._editSettings, this);
        this.render = __bind(this.render, this);
        Show.__super__.constructor.apply(this, arguments);
      }

      Show.prototype.templateName = 'host/communities/show';

      Show.prototype.id = 'communities-show';

      Show.prototype.events = function() {
        return _.extend(Show.__super__.events.apply(this, arguments), {
          'click .edit-settings': '_editSettings'
        });
      };

      Show.prototype.initialize = function() {
        Show.__super__.initialize.apply(this, arguments);
        this.buttons = new P.views.shared.ControlBar({
          controls: ['editSettings']
        });
        this.chart = new x.Chart;
        return P.association.stats.bind('refresh', this.render);
      };

      Show.prototype.render = function() {
        Show.__super__.render.apply(this, arguments);
        this.replaceWith('.chart', this.chart);
        return this;
      };

      Show.prototype._editSettings = function() {
        this.edit = new P.views.host.communities.Edit();
        this.edit.render();
        return this.edit.open();
      };

      return Show;

    })(P.views.shared.HostPage);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.events', function(x) {
    return x.Edit = (function(_super) {

      __extends(Edit, _super);

      function Edit() {
        Edit.__super__.constructor.apply(this, arguments);
        this.form = new x.Form({
          parent: this
        });
      }

      Edit.prototype.open = function(model) {
        if (model == null) model = new P.models.Event();
        return Edit.__super__.open.call(this, model);
      };

      return Edit;

    })(P.views.host.groups.Edit);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.events', function(x) {
    return x.Form = (function(_super) {

      __extends(Form, _super);

      function Form() {
        this.initialize = __bind(this.initialize, this);
        Form.__super__.constructor.apply(this, arguments);
      }

      Form.prototype.templateName = 'events/_form';

      Form.prototype.namespace = 'event';

      Form.prototype.initialize = function() {
        Form.__super__.initialize.apply(this, arguments);
        this.endsAt = new P.views.shared.DatePicker();
        return this.startsAt = new P.views.shared.DatePicker({
          "with": this.endsAt
        });
      };

      Form.prototype.formValues = function() {
        var attrs;
        attrs = Form.__super__.formValues.apply(this, arguments);
        attrs['starts_at'] = this.startsAt.getDate();
        attrs['ends_at'] = this.endsAt.getDate();
        return attrs;
      };

      Form.prototype.setup = function() {
        Form.__super__.setup.apply(this, arguments);
        this.startsAt.setDate(this.model.starts_at);
        return this.endsAt.setDate(this.model.ends_at);
      };

      Form.prototype.saved = function() {
        Form.__super__.saved.apply(this, arguments);
        return P.layout.flash.show({
          message: 'Event saved!'
        });
      };

      Form.prototype.render = function() {
        Form.__super__.render.apply(this, arguments);
        this.replaceAll('.starts_at input', this.startsAt);
        this.replaceAll('.ends_at input', this.endsAt);
        return this;
      };

      return Form;

    })(P.views.host.communities.Form);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.events', function(x) {
    return x.Table = (function(_super) {

      __extends(Table, _super);

      function Table() {
        this.columns = __bind(this.columns, this);        this.collection = new P.models.Events();
        Table.__super__.constructor.apply(this, arguments);
      }

      Table.prototype.columns = function() {
        return {
          name: {
            width: '130px',
            features: ['sortable', 'searchable', 'filterable'],
            filter_type: 'string'
          },
          memberships_count: {
            title: 'Members',
            width: '70px'
          },
          starts_at: {
            title: 'Starts',
            width: '200px',
            sortable: true,
            type: 'date',
            use_rendered: false,
            render: this.renderDate
          },
          ends_at: {
            title: 'Ends',
            width: '200px',
            sortable: true,
            type: 'date',
            use_rendered: false,
            render: this.renderDate
          }
        };
      };

      Table.prototype.wildcardColumns = ['name'];

      Table.prototype.className = function() {
        return "" + Table.__super__.className.apply(this, arguments) + " events-table";
      };

      Table.prototype.rowConstructor = P.views.host.groups.Row;

      return Table;

    })(P.views.shared.tables.ServerSideTable);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.events', function(x) {
    return x.Index = (function(_super) {

      __extends(Index, _super);

      Index.prototype.title = 'Events';

      Index.prototype.id = 'events-index';

      Index.prototype.className = '';

      Index.prototype.templateName = 'host/events/index';

      Index.prototype.events = function() {
        return _.extend(Index.__super__.events.apply(this, arguments), {
          'click button.new': 'new',
          'click button.destroy': 'destroy'
        });
      };

      function Index() {
        this.render = __bind(this.render, this);        Index.__super__.constructor.apply(this, arguments);
        this.buttons = new P.views.shared.ControlBar({
          controls: ['add', 'remove']
        });
        this.table = new x.Table({
          parent: this
        });
        this.edit = new x.Edit({
          parent: this
        });
      }

      Index.prototype["new"] = function() {
        return this.edit.open();
      };

      Index.prototype.destroy = function() {
        return this.table.destroy();
      };

      Index.prototype.render = function() {
        Index.__super__.render.apply(this, arguments);
        this.replaceWith('.controls', this.buttons);
        this.replaceWith('.events-table', this.table);
        this.edit.render();
        return this;
      };

      return Index;

    })(P.views.shared.Table);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.themes', function(x) {
    return x.Edit = (function(_super) {

      __extends(Edit, _super);

      Edit.prototype.title = 'Themes';

      function Edit() {
        Edit.__super__.constructor.apply(this, arguments);
        this.form = new P.views.host.themes.Form({
          parent: this
        });
      }

      Edit.prototype.id = 'themes-edit';

      Edit.prototype.render = function() {
        Edit.__super__.render.apply(this, arguments);
        $(this.el).html(this.form.render().el);
        return this;
      };

      return Edit;

    })(P.views.shared.Page);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.themes', function(x) {
    return x.Form = (function(_super) {

      __extends(Form, _super);

      function Form() {
        Form.__super__.constructor.apply(this, arguments);
        this.model = new P.models.Theme(P.community.get('theme'));
        this.bind('saved', this.saved);
      }

      Form.prototype.className = function() {
        return "" + Form.__super__.className.apply(this, arguments) + " theme-form";
      };

      Form.prototype.templateName = 'host/themes/form';

      Form.prototype.features = [P.views.shared.forms.ErrorsFeature, P.views.shared.forms.FormValueGetFeature, P.views.shared.forms.FormValueSetFeature, P.views.shared.forms.FocusFeature];

      Form.prototype.formValues = function() {
        return this.getValues();
      };

      Form.prototype.saved = function(model) {
        Form.__super__.saved.apply(this, arguments);
        return P.layout.flash.show({
          message: 'Theme updated!'
        });
      };

      return Form;

    })(P.views.shared.forms.Form);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.meetings', function(x) {
    return x.Meeting = (function(_super) {

      __extends(Meeting, _super);

      function Meeting() {
        Meeting.__super__.constructor.apply(this, arguments);
      }

      Meeting.prototype.className = function() {
        return "" + Meeting.__super__.className.apply(this, arguments) + " meeting";
      };

      Meeting.prototype.templateName = 'meetings/_meeting';

      return Meeting;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.entries', function(x) {
    return x.Entry = (function(_super) {

      __extends(Entry, _super);

      function Entry() {
        Entry.__super__.constructor.apply(this, arguments);
      }

      Entry.prototype.templateName = 'entries/_entry';

      return Entry;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.posts', function(x) {
    return x.Post = (function(_super) {

      __extends(Post, _super);

      function Post() {
        Post.__super__.constructor.apply(this, arguments);
      }

      Post.prototype.className = function() {
        return "" + Post.__super__.className.apply(this, arguments) + " overline with_hover";
      };

      return Post;

    })(P.views.entries.Entry);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.tweets', function(x) {
    return x.Tweet = (function(_super) {

      __extends(Tweet, _super);

      function Tweet() {
        Tweet.__super__.constructor.apply(this, arguments);
      }

      Tweet.prototype.templateName = 'tweets/_tweet';

      return Tweet;

    })(P.views.entries.Entry);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.mobile.tweets', function(x) {
    return x.TweetItem = (function(_super) {

      __extends(TweetItem, _super);

      function TweetItem() {
        this.render = __bind(this.render, this);
        this.initialize = __bind(this.initialize, this);
        TweetItem.__super__.constructor.apply(this, arguments);
      }

      TweetItem.prototype.tagName = 'li';

      TweetItem.prototype.templateName = 'mobile/tweets/_tweet_item';

      TweetItem.prototype.initialize = function() {
        return TweetItem.__super__.initialize.apply(this, arguments);
      };

      TweetItem.prototype.render = function() {
        TweetItem.__super__.render.apply(this, arguments);
        return this;
      };

      return TweetItem;

    })(P.views.shared.mobile.View);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.mobile.ribbons', function(x) {
    return x.Ribbon = (function(_super) {

      __extends(Ribbon, _super);

      function Ribbon() {
        Ribbon.__super__.constructor.apply(this, arguments);
      }

      Ribbon.prototype.templateName = 'mobile/ribbons/_ribbon';

      Ribbon.prototype.className = 'ribbon';

      Ribbon.prototype.tagName = 'span';

      Ribbon.prototype.render = function() {
        Ribbon.__super__.render.apply(this, arguments);
        this.$(this.el).addClass(this.model.get('name').toLowerCase());
        this.$(this.el).attr({
          title: this.model.get('name').toLowerCase()
        });
        return this;
      };

      return Ribbon;

    })(P.views.shared.mobile.View);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.mobile.posts', function(x) {
    return x.PostItem = (function(_super) {

      __extends(PostItem, _super);

      function PostItem() {
        PostItem.__super__.constructor.apply(this, arguments);
      }

      PostItem.prototype.tagName = 'li';

      PostItem.prototype.templateName = 'mobile/posts/_post_item';

      return PostItem;

    })(P.views.shared.mobile.View);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.mobile.links', function(x) {
    return x.LinkItem = (function(_super) {

      __extends(LinkItem, _super);

      function LinkItem() {
        LinkItem.__super__.constructor.apply(this, arguments);
      }

      LinkItem.prototype.templateName = 'mobile/links/_link_item';

      return LinkItem;

    })(P.views.shared.mobile.View);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.mobile.meetings', function(x) {
    return x.Meeting = (function(_super) {

      __extends(Meeting, _super);

      function Meeting() {
        this.render = __bind(this.render, this);
        Meeting.__super__.constructor.apply(this, arguments);
      }

      Meeting.prototype.tagName = 'li';

      Meeting.prototype.templateName = 'mobile/meetings/_meeting';

      Meeting.prototype.initialize = function() {
        Meeting.__super__.initialize.apply(this, arguments);
        return this.labels = new P.views.shared.View({
          templateName: 'mobile/meetings/_labels',
          collection: this.model.labels
        });
      };

      Meeting.prototype.render = function() {
        Meeting.__super__.render.apply(this, arguments);
        this.html('.labels', this.labels);
        return this;
      };

      return Meeting;

    })(P.views.shared.mobile.View);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.mobile.users', function(x) {
    return x.User = (function(_super) {

      __extends(User, _super);

      User.prototype.templateName = 'mobile/users/_user';

      function User() {
        this.render = __bind(this.render, this);        User.__super__.constructor.apply(this, arguments);
        this.ribbons = new P.views.shared.mobile.lists.List({
          itemType: P.views.mobile.ribbons.Ribbon,
          collection: this.model.ribbons,
          tagName: 'div',
          className: 'ribbons',
          title: false
        });
        this.categories = new P.views.shared.mobile.lists.List({
          itemType: P.views.labels.Label,
          className: 'labels',
          collection: this.model.categories
        });
      }

      User.prototype.render = function() {
        User.__super__.render.apply(this, arguments);
        this.replaceWith('.ribbons', this.ribbons);
        $(this.categories.el).removeAttr('data-role');
        $(this.categories.el).removeAttr('data-inset');
        this.replaceWith('.categories', this.categories);
        return this;
      };

      return User;

    })(P.views.shared.mobile.View);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.affiliations', function(x) {
    return x.Edit = (function(_super) {

      __extends(Edit, _super);

      function Edit() {
        Edit.__super__.constructor.apply(this, arguments);
        this.form = new x.Form({
          parent: this
        });
      }

      Edit.prototype.className = function() {
        return "" + Edit.__super__.className.apply(this, arguments) + " memberships-edit";
      };

      Edit.prototype.open = function(model) {
        if (model == null) model = new P.models.Membership();
        Edit.__super__.open.apply(this, arguments);
        this.form.edit(model);
        return this.center();
      };

      Edit.prototype.render = function() {
        Edit.__super__.render.apply(this, arguments);
        this.append(this.form);
        return this;
      };

      return Edit;

    })(P.views.shared.Dialog);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.affiliations', function(x) {
    return x.Form = (function(_super) {

      __extends(Form, _super);

      function Form() {
        Form.__super__.constructor.apply(this, arguments);
        _.bindAll(this);
        this.autoSuggest = new P.views.shared.auto_suggest.AutoSuggest({
          disableFreeForm: true,
          searchOptions: {
            classes: ['Group']
          }
        });
        this.buttons = new P.views.shared.ControlBar({
          controls: ['save']
        });
        this.bind('saved', this.saved);
        this.bind('edit', this.setup);
      }

      Form.prototype.className = 'affiliations-form formtastic';

      Form.prototype.tagName = 'div';

      Form.prototype.templateName = 'affiliations/_form';

      Form.prototype.features = [P.views.shared.forms.ErrorsFeature, P.views.shared.forms.FormValueGetFeature, P.views.shared.forms.FormValueSetFeature, P.views.shared.forms.FocusFeature];

      Form.prototype.setup = function() {
        P.logger.debug('Setting up form, using model:', this.model);
        this.bindErrors();
        this.setValues();
        this.setRoles();
        if (this.model.level) {
          this.$('.level option[value=' + this.model.level.id + ']').attr('selected', 'selected');
        }
        this.autoSuggest.clear();
        if (this.model.isNew()) {
          return this.autoSuggest.enable();
        } else {
          this.autoSuggest.collection.add(this.model.parent);
          return this.autoSuggest.disable();
        }
      };

      Form.prototype.formValues = function() {
        var parent_attributes, values;
        values = this.getValues();
        values['roles'] = this.getRoles();
        values['level_name'] = this.$('.level option:selected').text();
        if (this.model.isNew()) {
          parent_attributes = this.autoSuggest.collection.map(function(m) {
            return {
              id: m.id
            };
          });
        }
        values['parent_attributes'] = parent_attributes;
        return values;
      };

      Form.prototype.getRoles = function() {
        return _.map(this.$('input.roles:checked'), function(el) {
          return el.value;
        });
      };

      Form.prototype.setRoles = function() {
        var _this = this;
        this.$('input.roles').prop('checked', false);
        return _.each(this.model.get('roles'), function(role) {
          return _this.$("input.roles[value=" + role + "]").prop('checked', true);
        });
      };

      Form.prototype.saved = function(model) {
        this.parent.close();
        return this.parent.parent.table.add(model);
      };

      Form.prototype.render = function() {
        Form.__super__.render.apply(this, arguments);
        this.replaceWith('.affiliations-groups', this.autoSuggest);
        return this;
      };

      return Form;

    })(P.views.shared.forms.Form);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.affiliations', function(x) {
    return x.Index = (function(_super) {

      __extends(Index, _super);

      function Index() {
        Index.__super__.constructor.apply(this, arguments);
        this.table = new x.Table({
          parent: this
        });
        this.edit = new x.Edit({
          parent: this
        });
      }

      Index.prototype.className = 'affiliations-index';

      Index.prototype.templateName = 'affiliations/_index';

      Index.prototype.events = function() {
        return _.extend(Index.__super__.events.apply(this, arguments), {
          'click button.add': 'new',
          'click button.destroy': 'destroy'
        });
      };

      Index.prototype.use = function(collection) {
        this.collection = collection;
        this.table.collection = collection;
        this.table.render();
        return this.showExtra();
      };

      Index.prototype.showExtra = function() {
        var visible;
        visible = this.collection.group instanceof P.models.Organization;
        return this.table.visible(['roles', 'booth', 'level'], visible);
      };

      Index.prototype["new"] = function() {
        var affiliation;
        affiliation = new P.models.Affiliation({
          child_id: this.collection.group.id
        });
        return this.edit.open(affiliation);
      };

      Index.prototype.destroy = function() {
        return this.table.destroy();
      };

      Index.prototype.render = function() {
        Index.__super__.render.apply(this, arguments);
        this.replaceWith('.table', this.table);
        this.edit.render();
        return this;
      };

      return Index;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.affiliations', function(x) {
    return x.Row = (function(_super) {

      __extends(Row, _super);

      function Row() {
        var _ref, _ref2;
        Row.__super__.constructor.apply(this, arguments);
        this.group = new P.views.groups.Group({
          model: this.model.parent
        });
        this.level = (_ref = this.model.level) != null ? _ref.get('name') : void 0;
        this.roles = (_ref2 = this.model.get('roles')) != null ? _ref2.join(', ') : void 0;
      }

      Row.prototype.render = function() {
        Row.__super__.render.apply(this, arguments);
        this.html('.parent', this.group);
        if (this.level != null) this.html('.level', this.level);
        this.html('.roles', this.roles);
        return this;
      };

      return Row;

    })(P.views.shared.tables.ControllableRow);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.affiliations', function(x) {
    return x.Table = (function(_super) {

      __extends(Table, _super);

      function Table() {
        Table.__super__.constructor.apply(this, arguments);
      }

      Table.prototype.columns = {
        parent: {
          title: 'Group/Event',
          width: '130px',
          "class": 'parent',
          features: []
        },
        roles: {
          title: 'Roles',
          "class": 'roles',
          width: '70px'
        },
        level: {
          "class": 'level',
          width: '70px'
        },
        booth: {
          width: '40px'
        }
      };

      Table.prototype.wildcardColumns = [];

      Table.prototype.className = 'table';

      Table.prototype.rowConstructor = x.Row;

      return Table;

    })(P.views.shared.tables.ServerSideTable);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.communities', function(x) {
    return x.Private = (function(_super) {

      __extends(Private, _super);

      function Private() {
        this.showSignIn = __bind(this.showSignIn, this);
        this.login = __bind(this.login, this);
        this.render = __bind(this.render, this);
        Private.__super__.constructor.apply(this, arguments);
      }

      Private.prototype.templateName = 'communities/_private';

      Private.prototype.className = 'authentication_error';

      Private.prototype.initialize = function() {
        return Private.__super__.initialize.apply(this, arguments);
      };

      Private.prototype.render = function() {
        Private.__super__.render.apply(this, arguments);
        this.replaceWith(".event", P.community.get('friendly_name'));
        return this;
      };

      Private.prototype.login = function() {
        return P.router.redirectTo('#');
      };

      Private.prototype.showSignIn = function(e) {
        return e.preventDefault();
      };

      return Private;

    })(P.views.shared.Page);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.communities', function(x) {
    return x.Show = (function(_super) {

      __extends(Show, _super);

      function Show() {
        this.render = __bind(this.render, this);
        this.loginout = __bind(this.loginout, this);
        this.logout = __bind(this.logout, this);
        this.login = __bind(this.login, this);
        this.initialize = __bind(this.initialize, this);
        Show.__super__.constructor.apply(this, arguments);
      }

      Show.prototype.className = function() {
        return "" + Show.__super__.className.apply(this, arguments) + " communities show";
      };

      Show.prototype.templateName = 'communities/show';

      Show.prototype.initialize = function() {
        Show.__super__.initialize.apply(this, arguments);
        this.discussions = new P.views.shared.lists.TitledList({
          selectable: true,
          itemType: P.views.discussions.discussions.Discussion,
          collection: this.model.discussions.limit(5),
          addClass: 'overline with_hover',
          controls: {
            link: '#discussions'
          },
          title: P.localizer.t('discussion', {
            pluralize: true
          })
        });
        this.discussions.bind('select', function(discussion) {
          return P.router.redirectTo(discussion.fragment());
        });
        this.extra = new P.views.discussions.discussions.Extra({
          collection: this.model.discussions
        });
        this.posts = new P.views.posts.List({
          collection: this.model.posts.limit(5),
          title: P.localizer.t('recent_posts'),
          templateOptions: {
            exclude: []
          },
          controls: {
            link: '#posts'
          }
        });
        this.tweets = new P.views.shared.lists.TitledList({
          itemType: P.views.tweets.Tweet,
          addClass: 'overline with_hover',
          collection: this.model.tweets.limit(5),
          title: P.localizer.t('recent_tweets'),
          templateOptions: {
            exclude: []
          },
          controls: {
            link: '#tweets'
          }
        });
        this.recent = new P.views.shared.lists.TitledList({
          itemType: P.views.users.SmallCard,
          addClass: 'users users-small',
          collection: new P.models.Users().limit(8),
          title: P.localizer.t('recent_users')
        });
        if (this.model.sponsors != null) {
          this.sponsors = new P.views.shared.lists.TitledList({
            itemType: P.views.organizations.Organization,
            collection: this.model.sponsors,
            addClass: 'sponsor_list'
          });
        }
        if (this.model instanceof P.models.Association) {
          this.communityEvents = new Backbone.List({
            itemType: P.views.events.Event,
            collection: this.model.events,
            title: P.localizer.t('community_events')
          });
        }
        if (this.model instanceof P.models.Event) {
          this.speakers = new P.views.shared.lists.TitledList({
            itemType: P.views.users.SmallCard,
            addClass: 'users users-small',
            collection: new P.models.Users([], {
              searchOptions: {
                conditions: {
                  ribbons: 'speaker'
                }
              }
            }).limit(8),
            title: P.localizer.t('speakers')
          });
        }
        return this.oauthConsumers = new P.views.oauth_consumers.Edit({
          model: P.user
        });
      };

      Show.prototype.login = function(session) {
        Show.__super__.login.apply(this, arguments);
        session.user.tags.fetch();
        this.groups = new P.views.groups.List({
          collection: session.user.tags,
          title: P.localizer.t('my_groups'),
          groupOptions: {
            membersLimit: 7
          }
        });
        this.html('.groups', this.groups);
        this.connections = new P.views.connections.WhoDoYouKnow({
          title: P.localizer.t('recent_connections'),
          collection: session.user.connections.limit(8),
          itemType: P.views.users.SmallCard,
          hideEmpty: false,
          addClass: 'users users-small'
        });
        return this.html('.connections', this.connections);
      };

      Show.prototype.logout = function(session) {
        var _ref, _ref2;
        Show.__super__.logout.apply(this, arguments);
        if ((_ref = this.groups) != null) _ref.destroy();
        delete this.groups;
        if ((_ref2 = this.connections) != null) _ref2.destroy();
        return delete this.connections;
      };

      Show.prototype.loginout = function(session, loggedIn) {
        var _ref, _ref2;
        Show.__super__.loginout.apply(this, arguments);
        if ((_ref = this.groups) != null) _ref.$el.toggle(loggedIn);
        if ((_ref2 = this.connections) != null) _ref2.$el.toggle(loggedIn);
        return this.oauthConsumers.$el.toggle(loggedIn);
      };

      Show.prototype.render = function() {
        Show.__super__.render.apply(this, arguments);
        this.replaceWith('.discussions', this.discussions);
        this.replaceWith('.discussions-extra', this.extra);
        this.replaceWith('.tweets', this.tweets);
        this.replaceWith('.posts', this.posts);
        this.replaceWith('.recent', this.recent);
        if (this.communityEvents != null) {
          this.replaceWith('.events', this.communityEvents);
        }
        if (this.speakers != null) this.replaceWith('.speakers', this.speakers);
        if (this.sponsors != null) this.replaceWith('.sponsors', this.sponsors);
        this.model.discussions.fetch();
        this.model.tweets.fetch();
        this.model.posts.fetch();
        if (this.groups != null) this.groups.collection.fetch();
        if (this.speakers != null) this.speakers.collection.fetch();
        this.recent.collection.fetch();
        return this;
      };

      return Show;

    })(P.views.shared.Page);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.connections', function(x) {
    return x.Card = (function(_super) {

      __extends(Card, _super);

      function Card() {
        Card.__super__.constructor.apply(this, arguments);
      }

      Card.prototype.render = function() {
        Card.__super__.render.apply(this, arguments);
        this._renderSocialNetworkOverlays();
        return this;
      };

      Card.prototype._renderSocialNetworkOverlays = function() {
        var container,
          _this = this;
        container = this.make('ul', {
          'class': 'social-network-overlays'
        });
        this.model.user_contactees.each(function(userContactee) {
          var service;
          service = userContactee.get('service');
          return $(container).append(_this.make('li', {
            title: service,
            'class': service
          }, service));
        });
        return $(this.el).append(container);
      };

      return Card;

    })(P.views.users.Card);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.connections', function(x) {
    return x.Search = (function(_super) {

      __extends(Search, _super);

      function Search() {
        this.search = __bind(this.search, this);
        this._renderInfo = __bind(this._renderInfo, this);
        this._filter = __bind(this._filter, this);
        Search.__super__.constructor.apply(this, arguments);
      }

      Search.prototype.tagName = 'form';

      Search.prototype.className = function() {
        return "" + Search.__super__.className.apply(this, arguments) + " search";
      };

      Search.prototype.templateName = 'connections/_search';

      Search.prototype.events = function() {
        return _.extend(Search.__super__.events.apply(this, arguments), {
          'change .filter select': '_filter'
        });
      };

      Search.prototype.initialize = function() {
        var _base;
        Search.__super__.initialize.apply(this, arguments);
        (_base = this.collection).searchOptions || (_base.searchOptions = {});
        this.collection.bind('reset', this._renderInfo);
        return this.paginator = new P.views.shared.Paginator({
          collection: P.user.connections,
          parent: this
        });
      };

      Search.prototype.render = function() {
        Search.__super__.render.apply(this, arguments);
        this.replaceWith('.paginator', this.paginator.el);
        return this;
      };

      Search.prototype.reset = function() {
        this._clear();
        return this.collection.search(this._searchParams());
      };

      Search.prototype._filter = function(e) {
        var params;
        params = {};
        if (e instanceof jQuery.Event) {
          e.preventDefault();
          params = this._searchParams();
        } else {
          params = e;
        }
        this._loading(true);
        this.paginator.clear();
        return this.collection.search(params);
      };

      Search.prototype._renderInfo = function() {
        var counts, filter;
        filter = $(this.el).find('select.filter');
        counts = $(this.el).find('.info .counts');
        counts.find('.total_entries').text(P.user.connections.length);
        filter.show();
        return this._loading(false);
      };

      Search.prototype._searchParams = function() {
        var params, service;
        params = {
          "with": {
            type: 'UserContacts::SocialNetworkUserContact'
          },
          page: 1,
          per_page: 1000
        };
        service = this.$('select').val();
        if (!_.isEmpty(service)) params["with"].service = service;
        return params;
      };

      Search.prototype._clear = function() {
        this._loading(true);
        this.$('select.filter option:first-child').attr('selected', 'selected');
        return this.paginator.clear();
      };

      Search.prototype._loading = function(show) {
        $(this.el).find('.info .counts').toggle(!show);
        return $(this.el).find('.info .loading').toggle(show);
      };

      Search.prototype.search = function(e) {
        var params;
        if (e == null) e = {};
        params = {};
        if (e instanceof jQuery.Event) {
          e.preventDefault();
          params = this._searchParams();
        } else {
          params = e;
          if (params.query != null) {
            $(this.el).find("#search_query").val("\"" + params.query + "\"");
          }
        }
        this._loading(true);
        this.paginator.clear();
        return this.collection.search(params);
      };

      return Search;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.connections', function(x) {
    return x.WhoDoYouKnow = (function(_super) {

      __extends(WhoDoYouKnow, _super);

      WhoDoYouKnow.prototype.events = function() {
        return _.extend(WhoDoYouKnow.__super__.events.apply(this, arguments), {
          'click button.connections': '_findConnections'
        });
      };

      function WhoDoYouKnow() {
        this._findConnections = __bind(this._findConnections, this);        WhoDoYouKnow.__super__.constructor.apply(this, arguments);
        this.controls = new P.views.shared.ControlBar({
          addClass: 'who-do-you-know',
          buttonOptions: [
            {
              className: 'connections',
              label: P.localizer.t('find_contacts'),
              icons: {
                primary: 'ui-icon-star'
              }
            }
          ]
        });
      }

      WhoDoYouKnow.prototype.render = function() {
        WhoDoYouKnow.__super__.render.apply(this, arguments);
        this.append(this.controls);
        return this;
      };

      WhoDoYouKnow.prototype._findConnections = function(e) {
        e.preventDefault();
        return P.router.redirectTo('#connections');
      };

      return WhoDoYouKnow;

    })(P.views.shared.lists.TitledList);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.connections', function(x) {
    return x.Index = (function(_super) {

      __extends(Index, _super);

      Index.prototype.title = function() {
        return P.localizer.t('connections');
      };

      Index.prototype.templateName = 'connections/index';

      Index.prototype.className = function() {
        return "" + Index.__super__.className.apply(this, arguments) + " connections index";
      };

      Index.prototype.events = function() {
        return _.extend(Index.__super__.events.apply(this, arguments), {
          'click .connect': '_connect'
        });
      };

      Index.prototype.snButtons = {
        facebook: {
          name: 'Facebook',
          label: 'Find Facebook Friends',
          icons: {
            primary: 'facebook'
          }
        },
        linkedin: {
          name: 'LinkedIn',
          label: 'Find LinkedIn Contacts',
          icons: {
            primary: 'linkedin'
          }
        },
        twitter: {
          name: 'Twitter',
          label: 'Find Twitter Friends',
          icons: {
            primary: 'twitter'
          }
        }
      };

      Index.prototype.logout = function(session, loggedIn) {
        Index.__super__.logout.apply(this, arguments);
        return P.router.redirectTo('#');
      };

      function Index() {
        this._renderButtons = __bind(this._renderButtons, this);
        this._connect = __bind(this._connect, this);
        this._resetSearch = __bind(this._resetSearch, this);
        this.logout = __bind(this.logout, this);
        var options, service,
          _this = this;
        Index.__super__.constructor.apply(this, arguments);
        this.controls = new P.views.shared.ControlBar({
          buttonOptions: _.map(_.values(this.snButtons), function(button) {
            return _.extend(button, {
              className: 'connect'
            });
          })
        });
        this.consumerTokens = P.user.consumer_tokens;
        _.each('add remove reset'.split(/\s+/), function(event) {
          return _this.consumerTokens.bind(event, _this._renderButtons);
        });
        this.connections = new P.views.shared.lists.TitledList({
          collection: P.user.connections,
          itemType: x.Card,
          addClass: 'three-col users users-medium'
        });
        this.search = new x.Search({
          collection: P.user.user_connections,
          templateOptions: {
            filter: {
              options: [[P.localizer.t('show_all'), '']].concat((function() {
                var _ref, _results;
                _ref = this.snButtons;
                _results = [];
                for (service in _ref) {
                  options = _ref[service];
                  _results.push([options.name, service]);
                }
                return _results;
              }).call(this))
            }
          }
        });
        this.bind('route', this._resetSearch);
      }

      Index.prototype.render = function() {
        Index.__super__.render.apply(this, arguments);
        this.replaceWith('.controls', this.controls);
        this.replaceWith('.connections-search', this.search);
        this.replaceWith('.connections', this.connections);
        if (!_.isEmpty(P.flash.notice)) {
          P.layout.flash.show({
            message: P.flash.notice,
            "class": 'info'
          });
        }
        if (!_.isEmpty(P.flash.error)) {
          P.layout.flash.show({
            message: P.flash.error,
            "class": 'error'
          });
        }
        return this;
      };

      Index.prototype._resetSearch = function() {
        return this.search.reset();
      };

      Index.prototype._connect = function(e) {
        var button, options, service;
        button = this.controls.buttons.get($(e.currentTarget).index('.connect'));
        service = ((function() {
          var _ref, _results;
          _ref = this.snButtons;
          _results = [];
          for (service in _ref) {
            options = _ref[service];
            if (options.label === button.options.label) _results.push(service);
          }
          return _results;
        }).call(this))[0];
        return this.goto("/oauth_consumers/" + service);
      };

      Index.prototype._renderButtons = function() {
        var _this = this;
        this.controls.showButton(_.pluck(_.values(this.snButtons), 'label'));
        return this.controls.hideButton(_.map(this.consumerTokens.pluck('service_name'), function(service) {
          var _ref;
          return (_ref = _this.snButtons[service]) != null ? _ref.label : void 0;
        }));
      };

      return Index;

    })(P.views.shared.Page);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.contacts', function(x) {
    return x.Card = (function(_super) {

      __extends(Card, _super);

      function Card() {
        this._click = __bind(this._click, this);
        Card.__super__.constructor.apply(this, arguments);
      }

      Card.prototype._click = function(e) {
        var _ref;
        e.preventDefault();
        return this.parent.select((_ref = this.model.user_contactees.find(function(model) {
          return model.isMarked();
        })) != null ? _ref.get('id') : void 0);
      };

      return Card;

    })(P.views.users.Card);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.contacts', function(x) {
    return x.Contact = (function(_super) {

      __extends(Contact, _super);

      function Contact() {
        this.render = __bind(this.render, this);
        Contact.__super__.constructor.apply(this, arguments);
      }

      Contact.prototype.templateName = 'contacts/_contact';

      Contact.prototype.className = 'contact';

      Contact.prototype.initialize = function() {
        Contact.__super__.initialize.apply(this, arguments);
        return this.model.bind('change', this.render);
      };

      Contact.prototype.render = function() {
        Contact.__super__.render.apply(this, arguments);
        this.html('.notes', this.model.get('notes'));
        return this;
      };

      return Contact;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.contacts', function(x) {
    return x.Controls = (function(_super) {

      __extends(Controls, _super);

      function Controls() {
        this._destroy = __bind(this._destroy, this);
        this._edit = __bind(this._edit, this);
        this._userShow = __bind(this._userShow, this);
        Controls.__super__.constructor.apply(this, arguments);
      }

      Controls.prototype.className = function() {
        return "" + Controls.__super__.className.apply(this, arguments) + " controls";
      };

      Controls.prototype.events = function() {
        return _.extend(Controls.__super__.events.apply(this, arguments), {
          'click .user-show': '_userShow',
          'click .edit': '_edit',
          'click .destroy': '_destroy'
        });
      };

      Controls.prototype.initialize = function() {
        Controls.__super__.initialize.apply(this, arguments);
        return this.buttons = new P.views.shared.ControlBar({
          buttonOptions: [
            {
              label: P.localizer.t('view_contact'),
              buttonClass: 'user-show',
              icons: {
                primary: 'ui-icon-person'
              }
            }, {
              label: P.localizer.t('edit_contact'),
              buttonClass: 'edit',
              icons: {
                primary: 'ui-icon-note'
              }
            }, {
              label: P.localizer.t('remove_from_contacts'),
              buttonClass: 'destroy',
              icons: {
                primary: 'ui-icon-trash'
              }
            }
          ]
        });
      };

      Controls.prototype.render = function() {
        Controls.__super__.render.apply(this, arguments);
        this.append(this.buttons);
        return this;
      };

      Controls.prototype._userShow = function() {
        return P.router.redirectTo(this.model.contact.fragment());
      };

      Controls.prototype._edit = function(e) {
        return this.parent.editContact.open();
      };

      Controls.prototype._destroy = function() {
        return this.parent.destroyContact.open();
      };

      return Controls;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.contacts', function(x) {
    return x.Destroy = (function(_super) {

      __extends(Destroy, _super);

      function Destroy() {
        this.cancel = __bind(this.cancel, this);
        this.destroy = __bind(this.destroy, this);
        Destroy.__super__.constructor.apply(this, arguments);
      }

      Destroy.prototype.templateName = 'contacts/_destroy';

      Destroy.prototype.className = function() {
        return "" + Destroy.__super__.className.apply(this, arguments) + " contacts destroy";
      };

      Destroy.prototype.events = {
        'click .destroy': 'destroy',
        'click .cancel': 'cancel'
      };

      Destroy.prototype.initialize = function() {
        Destroy.__super__.initialize.apply(this, arguments);
        this.card = new x.Card({
          model: this.model.contact,
          showControls: false
        });
        return this.controls = new P.views.shared.ControlBar({
          buttonOptions: [
            {
              label: 'Yes',
              buttonClass: 'destroy',
              icons: {
                primary: 'ui-icon-check'
              }
            }, {
              label: 'Cancel',
              buttonClass: 'cancel',
              icons: {
                primary: 'ui-icon-cancel'
              }
            }
          ]
        });
      };

      Destroy.prototype.open = function(model) {
        Destroy.__super__.open.apply(this, arguments);
        return this.center();
      };

      Destroy.prototype.destroy = function(e) {
        e.preventDefault();
        return this._destroy();
      };

      Destroy.prototype.cancel = function(e) {
        e.preventDefault();
        return this.close();
      };

      Destroy.prototype.render = function() {
        Destroy.__super__.render.apply(this, arguments);
        this.prepend(this.card);
        this.replaceWith('.controls', this.controls);
        return this;
      };

      Destroy.prototype._destroy = function() {
        var _this = this;
        return this.model.destroy({
          success: function(model) {
            P.user.user_contacts.remove(model);
            _this.close();
            return P.layout.flash.show({
              message: P.localizer.t('contact_destroyed')
            });
          }
        });
      };

      return Destroy;

    })(P.views.shared.Dialog);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.contacts', function(x) {
    return x.Detail = (function(_super) {

      __extends(Detail, _super);

      function Detail() {
        Detail.__super__.constructor.apply(this, arguments);
      }

      Detail.prototype.templateName = 'contacts/_detail';

      Detail.prototype.className = function() {
        return "" + Detail.__super__.className.apply(this, arguments) + " contact-detail";
      };

      Detail.prototype.initialize = function() {
        Detail.__super__.initialize.apply(this, arguments);
        this.card = new P.views.users.Card({
          model: this.model.contact,
          showControls: false
        });
        this.controls = new x.Controls({
          model: this.model,
          parent: this
        });
        this.contact = new x.Contact({
          model: this.model
        });
        this.editContact = new x.Edit({
          model: this.model,
          parent: this
        });
        return this.destroyContact = new x.Destroy({
          model: this.model,
          parent: this
        });
      };

      Detail.prototype.render = function() {
        Detail.__super__.render.apply(this, arguments);
        this.replaceWith('.card', this.card);
        this.replaceWith('.controls', this.controls);
        this.replaceWith('.contact', this.contact);
        this.editContact.render();
        this.destroyContact.render();
        return this;
      };

      return Detail;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.contacts', function(x) {
    return x.Edit = (function(_super) {

      __extends(Edit, _super);

      function Edit() {
        Edit.__super__.constructor.apply(this, arguments);
      }

      Edit.prototype.className = function() {
        return "" + Edit.__super__.className.apply(this, arguments) + " contacts edit";
      };

      Edit.prototype.initialize = function() {
        Edit.__super__.initialize.apply(this, arguments);
        this.card = new x.Card({
          model: this.model.contact,
          showControls: false
        });
        return this.form = new x.Form({
          model: this.model,
          parent: this
        });
      };

      Edit.prototype.open = function(model) {
        Edit.__super__.open.apply(this, arguments);
        this.form.edit(model || (model = new P.models.UserContact));
        return this.center();
      };

      Edit.prototype.render = function() {
        Edit.__super__.render.apply(this, arguments);
        this.append(this.card);
        this.append(this.form);
        return this;
      };

      return Edit;

    })(P.views.shared.Dialog);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.contacts', function(x) {
    return x.Form = (function(_super) {

      __extends(Form, _super);

      Form.prototype.className = function() {
        return "" + Form.__super__.className.apply(this, arguments) + " contacts-form";
      };

      Form.prototype.templateName = 'contacts/_form';

      Form.prototype.features = [P.views.shared.forms.ErrorsFeature, P.views.shared.forms.FocusFeature];

      function Form() {
        this.saved = __bind(this.saved, this);
        this.save = __bind(this.save, this);        Form.__super__.constructor.apply(this, arguments);
        this.textEditor = new P.views.shared.TextEditor();
        this.buttons = new P.views.shared.ControlBar({
          controls: ['save']
        });
        this.bind('saved', this.saved);
      }

      Form.prototype.edit = function() {
        var _this = this;
        this.bindErrors();
        return setTimeout(function() {
          return _this.textEditor.setContent(_this.model.get('notes'));
        });
      };

      Form.prototype.save = function(e) {
        var _this = this;
        if (e != null) e.preventDefault();
        return this.model.set(this.formValues()).save({}, {
          success: function(model) {
            return _this.trigger('saved', model);
          }
        });
      };

      Form.prototype.formValues = function() {
        return {
          notes: this.textEditor.getContent()
        };
      };

      Form.prototype.saved = function(model) {
        this.parent.close();
        return P.layout.flash.show({
          message: P.localizer.t('contact_updated')
        });
      };

      Form.prototype.destroy = function() {
        return this.textEditor.destroy();
      };

      Form.prototype.render = function() {
        Form.__super__.render.apply(this, arguments);
        this.replaceWith('textarea.body', this.textEditor);
        return this;
      };

      return Form;

    })(P.views.shared.forms.Form);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.contacts', function(x) {
    return x.Index = (function(_super) {

      __extends(Index, _super);

      Index.prototype.title = function() {
        return P.localizer.t('contact', {
          pluralize: true
        });
      };

      Index.prototype.templateName = 'contacts/index';

      Index.prototype.className = function() {
        return "" + Index.__super__.className.apply(this, arguments) + " contacts index";
      };

      Index.prototype.events = function() {
        return _.extend(Index.__super__.events.apply(this, arguments), {
          'click button.connections': '_findConnections'
        });
      };

      function Index() {
        this._findConnections = __bind(this._findConnections, this);
        this.logout = __bind(this.logout, this);
        this.renderInfo = __bind(this.renderInfo, this);
        this.select = __bind(this.select, this);
        var _this = this;
        Index.__super__.constructor.apply(this, arguments);
        this.collection = P.user.user_contacts;
        this.collection.searchOptions = {
          "with": {
            type: 'UserContacts::MarkedUserContact'
          },
          per_page: 10
        };
        this.collection.bind('remove', function() {
          var _ref;
          return (_ref = _this.detail) != null ? _ref.remove() : void 0;
        });
        this.contacts = new P.views.shared.lists.TitledList({
          title: this.title,
          collection: P.user.contacts,
          itemType: x.Card,
          itemOptions: {
            parent: this,
            showControls: true
          },
          addClass: 'users users-medium'
        });
        this.paginator = new P.views.shared.Paginator({
          collection: this.collection,
          parent: this
        });
        this.collection.bind('reset', this.renderInfo);
        this.controls = new P.views.shared.ControlBar({
          addClass: 'who-do-you-know',
          buttonOptions: [
            {
              className: 'connections',
              label: P.localizer.t('find_contacts'),
              icons: {
                primary: 'ui-icon-star'
              }
            }
          ]
        });
      }

      Index.prototype.select = function(id) {
        var model, _ref;
        if (!(model = this.collection.get(id))) return;
        if ((_ref = this.detail) != null) _ref.destroy();
        return this.html('.detail', (this.detail = new x.Detail({
          model: model
        })));
      };

      Index.prototype.loading = function(show) {
        $(this.el).find('.info .counts').toggle(!show);
        return $(this.el).find('.info .loading').toggle(show);
      };

      Index.prototype.renderInfo = function() {
        var counts;
        counts = $(this.el).find('.info .counts');
        counts.find('.total_entries').text(this.collection.total_entries);
        counts.find('.count').text(this.collection.length);
        return this.loading(false);
      };

      Index.prototype.logout = function(session, loggedIn) {
        Index.__super__.logout.apply(this, arguments);
        return P.router.redirectTo('#');
      };

      Index.prototype.render = function() {
        Index.__super__.render.apply(this, arguments);
        this.replaceWith('.controls', this.controls);
        this.replaceWith('.contacts-list', this.contacts);
        this.replaceWith('.paging', this.paginator.el);
        this.collection.search({
          page: 1
        });
        return this;
      };

      Index.prototype._findConnections = function(e) {
        e.preventDefault();
        return P.router.redirectTo('#connections');
      };

      return Index;

    })(P.views.shared.Page);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.discussions.discussions', function(x) {
    return x.Detail = (function(_super) {

      __extends(Detail, _super);

      function Detail() {
        this.loginout = __bind(this.loginout, this);
        this.destroy = __bind(this.destroy, this);
        this.render = __bind(this.render, this);
        this.initialize = __bind(this.initialize, this);
        Detail.__super__.constructor.apply(this, arguments);
      }

      Detail.prototype.templateName = 'discussions/discussions/_detail';

      Detail.prototype.className = function() {
        return "" + Detail.__super__.className.apply(this, arguments) + " discussion_detail";
      };

      Detail.prototype.initialize = function() {
        Detail.__super__.initialize.apply(this, arguments);
        this.to = new x.To({
          model: this.model,
          all: true
        });
        this.messages = new Backbone.List({
          collection: this.model.messages,
          addClass: 'overline with_hover',
          parent: this,
          itemType: P.views.discussions.messages.ListItem
        });
        return this.form = new P.views.discussions.messages.Form({
          model: this.model
        });
      };

      Detail.prototype.render = function() {
        Detail.__super__.render.apply(this, arguments);
        this.replaceWith('.to', this.to);
        this.replaceWith('.messages', this.messages);
        this.replaceWith('.form', this.form);
        return this;
      };

      Detail.prototype.destroy = function() {
        return this.form.destroy();
      };

      Detail.prototype.loginout = function(session, loggedIn) {
        Detail.__super__.loginout.apply(this, arguments);
        return this.form.$el.toggle(loggedIn);
      };

      return Detail;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.discussions.discussions', function(x) {
    return x.Discussion = (function(_super) {

      __extends(Discussion, _super);

      function Discussion() {
        this._messages = __bind(this._messages, this);
        this._remove = __bind(this._remove, this);
        this.render = __bind(this.render, this);
        Discussion.__super__.constructor.apply(this, arguments);
      }

      Discussion.prototype.templateName = 'discussions/discussions/_discussion';

      Discussion.prototype.className = function() {
        return "" + Discussion.__super__.className.apply(this, arguments) + " discussions item";
      };

      Discussion.prototype.events = function() {
        return _.extend(Discussion.__super__.events.apply(this, arguments), {
          'click': '_click'
        });
      };

      Discussion.prototype.initialize = function() {
        var _this = this;
        Discussion.__super__.initialize.apply(this, arguments);
        _.each('add remove reset'.split(/\s+/), function(event) {
          return _this.model.messages.bind(event, _this._messages);
        });
        return this.model.messages.bind('remove', this._remove);
      };

      Discussion.prototype.render = function() {
        Discussion.__super__.render.apply(this, arguments);
        this._messages();
        return this;
      };

      Discussion.prototype._click = function(e) {
        if ($(e.target).closest('a,button', this.el).length) return;
        return P.router.redirectTo(this.model.fragment());
      };

      Discussion.prototype._remove = function() {
        if (this.model.messages.length) return;
        return this.model.trigger('destroy');
      };

      Discussion.prototype._messages = function() {
        var _ref;
        if (!((_ref = this.model.messages) != null ? _ref.length : void 0)) return;
        this.replaceWith('.to', new x.To({
          model: this.model,
          truncate: 20
        }));
        return this.replaceWith('.user', new P.views.users.SmallCard({
          parent: this,
          model: new P.models.User({
            id: this.model.get('latest_user_id')
          })
        }));
      };

      return Discussion;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.discussions.discussions', function(x) {
    return x.Edit = (function(_super) {

      __extends(Edit, _super);

      function Edit() {
        Edit.__super__.constructor.apply(this, arguments);
      }

      Edit.prototype.templateName = 'discussions/discussions/_edit';

      Edit.prototype.initialize = function() {
        var _ref,
          _this = this;
        Edit.__super__.initialize.apply(this, arguments);
        this.form = new P.views.discussions.discussions.Form({
          parent: this
        });
        this.myGroups = new P.models.Question({
          question: 'My Groups'
        });
        this.myGroups.groups = P.user.tags;
        this.collection = new P.models.Questions((_ref = P.community.questions) != null ? _ref.models : void 0);
        this.collection.add(this.myGroups);
        this.groups = new Backbone.List({
          selectable: true,
          collection: this.collection,
          itemType: P.views.static_suggestions.List,
          itemOptions: function(question) {
            return {
              collection: question.tags,
              title: question.get('question')
            };
          }
        });
        this.groups.bind('toggle', function(model, view, selected) {
          if (model instanceof P.models.Group) {
            return _this.form.autoSuggest.collection[selected && 'add' || 'remove'](model);
          }
        });
        this.form.autoSuggest.collection.bind('remove', function(model) {
          return _.each(_this.groups.views, function(list) {
            return list.unselect(model);
          });
        });
        return this.options.width = 800;
      };

      Edit.prototype.className = function() {
        return "" + Edit.__super__.className.apply(this, arguments) + " discussions-edit";
      };

      Edit.prototype.open = function(targetModel, editModel) {
        var addTarget;
        if (targetModel == null) targetModel = false;
        if (editModel == null) editModel = new P.models.Discussion;
        Edit.__super__.open.apply(this, arguments);
        this.form.edit(editModel || (new P.models.Discussion()));
        if (targetModel === true) {
          addTarget = new P.models.AllGroup();
        } else if (targetModel != null) {
          addTarget = targetModel;
        }
        _.each(this.groups.views, function(list) {
          return list.unselectAll();
        });
        if (addTarget !== false) this.form.autoSuggest.collection.add(addTarget);
        this.$('input.subject').focus();
        this.form.targetModel = targetModel;
        return this.center();
      };

      Edit.prototype.render = function() {
        Edit.__super__.render.apply(this, arguments);
        this.replaceWith('.form', this.form);
        this.replaceWith('.groups', this.groups);
        $(this.groups.el).addClass('ui-accordion ui-widget ui-helper-reset').find('> li ol').hide().end().find('> li.highlight ol').show().end().find('> li h4').prepend('<span class="arrow"></span>');
        return this;
      };

      return Edit;

    })(P.views.shared.Dialog);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.discussions.discussions', function(x) {
    return x.Extra = (function(_super) {

      __extends(Extra, _super);

      function Extra() {
        this._message = __bind(this._message, this);
        this.loginout = __bind(this.loginout, this);
        this.render = __bind(this.render, this);
        this.initialize = __bind(this.initialize, this);
        Extra.__super__.constructor.apply(this, arguments);
      }

      Extra.prototype.className = function() {
        return "" + Extra.__super__.className.apply(this, arguments) + " discussions-extra";
      };

      Extra.prototype.templateName = 'discussions/discussions/_extra';

      Extra.prototype.events = function() {
        return _.extend(Extra.__super__.events.apply(this, arguments), {
          'click .message': '_message'
        });
      };

      Extra.prototype.initialize = function() {
        var _ref;
        Extra.__super__.initialize.apply(this, arguments);
        this.buttons = new P.views.shared.ControlBar({
          buttonOptions: [
            {
              label: P.localizer.t('start_conversation'),
              className: 'message'
            }
          ]
        });
        this.templateOptions.count = (_ref = P.community.stats.statFor('total_public_messages')) != null ? _ref.get('value') : void 0;
        return this.collection.bind('reset', this.render);
      };

      Extra.prototype.render = function() {
        var empty;
        Extra.__super__.render.apply(this, arguments);
        empty = this.collection.isEmpty();
        this.$('.empty').toggle(empty);
        this.$('.count').toggle(!empty);
        return this;
      };

      Extra.prototype.loginout = function(session, loggedIn) {
        Extra.__super__.loginout.apply(this, arguments);
        this.buttons.$el.toggle(loggedIn);
        return this.$('.be_first').toggle(loggedIn);
      };

      Extra.prototype._message = function() {
        return P.router.layout.discussion.open(true);
      };

      return Extra;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.discussions.discussions', function(x) {
    return x.Form = (function(_super) {

      __extends(Form, _super);

      function Form() {
        this.isPrivate = __bind(this.isPrivate, this);
        this.setup = __bind(this.setup, this);
        Form.__super__.constructor.apply(this, arguments);
      }

      Form.prototype.tagName = 'form';

      Form.prototype.className = function() {
        return "" + Form.__super__.className.apply(this, arguments) + " formtastic discussion";
      };

      Form.prototype.templateName = 'discussions/discussions/_form';

      Form.prototype.features = [P.views.shared.forms.ErrorsFeature, P.views.shared.forms.FormValueSetFeature, P.views.shared.forms.FocusFeature, x.RecipientsFeature];

      Form.prototype.initialize = function() {
        Form.__super__.initialize.apply(this, arguments);
        _.bindAll(this);
        this.autoSuggest = new P.views.shared.auto_suggest.AutoSuggest({
          model: this.model,
          disableFreeForm: true,
          searchOptions: {
            classes: ['Groups::Tag', 'User']
          },
          maxChoices: this.maxRecipients()
        });
        this.enforceMaxRecipients(this.autoSuggest.collection);
        this.textEditor = new P.views.shared.TextEditor();
        this.buttons = new P.views.shared.ControlBar({
          controls: ['send']
        });
        this.bind('edit', this.setup);
        return this.bind('saved', this.saved);
      };

      Form.prototype.formValues = function() {
        var groups_discussions_attributes, participations_attributes,
          _this = this;
        groups_discussions_attributes = [];
        participations_attributes = [];
        this._groups = [];
        _.each(this.autoSuggest.collection.each(function(item) {
          if (item instanceof P.models.User) {
            return participations_attributes.push({
              user_id: item.id
            });
          } else if (item instanceof P.models.Group) {
            groups_discussions_attributes.push({
              group_id: item.id
            });
            return _this._groups.push(item);
          }
        }));
        if (this.isPrivate()) {
          participations_attributes.push({
            user_id: P.user.id
          });
        }
        return {
          subject: $(this.el).find("#discussion_subject").val(),
          participations_attributes: participations_attributes,
          groups_discussions_attributes: groups_discussions_attributes,
          messages_attributes: [
            {
              body: this.textEditor.getContent(),
              user_id: P.user.id
            }
          ],
          private: this.isPrivate()
        };
      };

      Form.prototype.setup = function() {
        this.bindErrors();
        this.textEditor.clear();
        this.autoSuggest.clear();
        return this.$('.subject input').val();
      };

      Form.prototype.saved = function() {
        var _this = this;
        P.layout.flash.show({
          message: P.localizer.t('discussion_created'),
          "class": 'info'
        });
        this.parent.close();
        if (this.isPrivate()) {
          return P.user.discussions.add(this.model);
        } else {
          P.community.discussions.add(this.model);
          return _.each(this._groups, function(group) {
            return group.discussions.add(_this.model);
          });
        }
      };

      Form.prototype.render = function() {
        Form.__super__.render.apply(this, arguments);
        this.focus(true);
        this.replaceAll('.discussion_body', this.textEditor);
        this.replaceWith('.discussion_to', this.autoSuggest);
        return this;
      };

      Form.prototype.isPrivate = function() {
        return this.autoSuggest.collection.all(function(m) {
          return m instanceof P.models.User;
        });
      };

      return Form;

    })(P.views.shared.forms.Form);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.discussions.discussions', function(x) {
    return x.Row = (function(_super) {

      __extends(Row, _super);

      function Row() {
        Row.__super__.constructor.apply(this, arguments);
        this.users = new x.Users({
          collection: this.model.to
        });
        this.subject = new x.Subject({
          model: this.model
        });
      }

      Row.prototype.className = function() {
        return "" + Row.__super__.className.apply(this, arguments) + " discussion";
      };

      Row.prototype.edit = function(e) {
        return this.goto(this.model);
      };

      Row.prototype.render = function() {
        Row.__super__.render.apply(this, arguments);
        this.html('.participants', this.users);
        this.html('.subject', this.subject);
        return this;
      };

      return Row;

    })(P.views.shared.tables.ControllableRow);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.discussions.discussions', function(x) {
    return x.Subject = (function(_super) {

      __extends(Subject, _super);

      function Subject() {
        Subject.__super__.constructor.apply(this, arguments);
      }

      Subject.prototype.className = function() {
        return "" + Subject.__super__.className.apply(this, arguments) + " subject";
      };

      Subject.prototype.templateName = 'discussions/discussions/_subject';

      Subject.prototype.render = function() {
        Subject.__super__.render.apply(this, arguments);
        this.groups = new P.views.groups.List({
          collection: this.model.groups
        });
        this.replaceWith('.groups', this.groups);
        return this;
      };

      return Subject;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.discussions.discussions', function(x) {
    return x.Table = (function(_super) {

      __extends(Table, _super);

      function Table() {
        Table.__super__.constructor.apply(this, arguments);
        if (this.collection == null) this.collection = new P.models.Discussions();
        if (this.options.private) this.collection.scope = P.user;
      }

      Table.prototype.columns = {
        controls: {
          visible: false
        },
        participants: {
          filter_type: 'string',
          "class": 'participants',
          features: [],
          width: '150px'
        },
        subject: {
          filter_type: 'string',
          "class": 'subject',
          features: ['sortable', 'filterable']
        }
      };

      Table.prototype.className = function() {
        return "" + Table.__super__.className.apply(this, arguments) + " discussions-table table";
      };

      Table.prototype.rowConstructor = x.Row;

      Table.prototype.wildcardColumns = ['subject'];

      return Table;

    })(P.views.shared.tables.ServerSideTable);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.discussions.discussions', function(x) {
    return x.Title = (function(_super) {

      __extends(Title, _super);

      function Title() {
        Title.__super__.constructor.apply(this, arguments);
        this.to = new x.To({
          model: this.model
        });
        this.model.bind('change', this.render);
      }

      Title.prototype.className = function() {
        return "" + Title.__super__.className.apply(this, arguments) + " discussion title";
      };

      Title.prototype.templateName = 'discussions/discussions/_title';

      Title.prototype.render = function() {
        Title.__super__.render.apply(this, arguments);
        P.logger.debug("Rendering to:", this.to);
        this.replaceWith('.to', this.to);
        return this;
      };

      return Title;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.discussions.discussions', function(x) {
    return x.To = (function(_super) {

      __extends(To, _super);

      function To() {
        To.__super__.constructor.apply(this, arguments);
      }

      To.prototype.tagName = 'span';

      To.prototype.className = function() {
        return "" + To.__super__.className.apply(this, arguments) + " to";
      };

      To.prototype.render = function() {
        To.__super__.render.apply(this, arguments);
        this.to = this.model.get('private') && this.model.groups.isEmpty() ? new x.Users({
          collection: this.model.participants
        }) : new P.views.groups.TagList({
          tagName: 'span',
          list: {
            tagName: 'span'
          },
          collection: this.model.groups,
          truncate: this.options.truncate
        });
        this.$el.empty();
        if (!this.model.get('private') && this.options.all && this.model.groups.isEmpty()) {
          this.append(new P.views.groups.TagGroup({
            model: new P.models.AllGroup()
          }));
        }
        this.append(this.to);
        return this;
      };

      return To;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.discussions.discussions', function(x) {
    return x.Users = (function(_super) {

      __extends(Users, _super);

      function Users() {
        var _this = this;
        Users.__super__.constructor.apply(this, arguments);
        _.each('change add remove reset'.split(/\s+/), function(event) {
          return _this.collection.bind(event, _this.render);
        });
      }

      Users.prototype.className = function() {
        return "" + Users.__super__.className.apply(this, arguments) + " authors";
      };

      Users.prototype.buildUsers = function() {
        var models;
        models = this.collection.filter(function(model) {
          return model !== P.user;
        });
        return this.users = _.map(models, function(model) {
          return new P.views.users.User({
            model: model
          });
        });
      };

      Users.prototype.render = function() {
        var endHTML, html, startHTML, user,
          _this = this;
        Users.__super__.render.apply(this, arguments);
        $(this.el).empty();
        this.buildUsers();
        if (this.users.length === 1) {
          user = this.users[0];
          user.templateOptions.nameFormat = 'full';
          this.append(user);
        } else if (this.users.length <= 6) {
          html = _.map(this.users, function(user) {
            user.templateOptions.nameFormat = 'full';
            return $(user.render().el).html();
          });
          $(this.el).append(html.join(''));
        } else if (this.users.length >= 7) {
          startHTML = $(this.users[0].render().el).html();
          endHTML = _.map(this.users.slice(-3), function(user) {
            return $(user.render().el).html();
          });
          $(this.el).append(startHTML + ' ... ' + endHTML.join(', '));
        }
        return this;
      };

      return Users;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.discussions.discussions', function(x) {
    return x.Index = (function(_super) {

      __extends(Index, _super);

      function Index() {
        this._newDiscussion = __bind(this._newDiscussion, this);
        this.loginout = __bind(this.loginout, this);
        this._select = __bind(this._select, this);
        this.select = __bind(this.select, this);
        Index.__super__.constructor.apply(this, arguments);
      }

      Index.prototype.title = function() {
        return P.localizer.t('discussion', {
          pluralize: true
        });
      };

      Index.prototype.className = function() {
        return "" + Index.__super__.className.apply(this, arguments) + " discussions index";
      };

      Index.prototype.templateName = 'discussions/discussions/index';

      Index.prototype.events = function() {
        return _.extend(Index.__super__.events.apply(this, arguments), {
          'click .new-discussion': '_newDiscussion'
        });
      };

      Index.prototype.initialize = function() {
        var _this = this;
        Index.__super__.initialize.apply(this, arguments);
        this.collection.searchOptions = _.extend(this.collection.searchOptions || {}, {
          per_page: 999,
          classes: []
        });
        this.buttons = new P.views.shared.ControlBar({
          controls: ['newDiscussion']
        });
        this.discussions = new Backbone.List({
          selectable: true,
          addClass: 'index_list overline with_hover',
          itemType: x.Discussion,
          collection: this.collection
        });
        this.collection.bind('remove', function() {
          var _ref;
          return (_ref = _this.detail) != null ? _ref.remove() : void 0;
        });
        return this.collection.bind('reset', this._select);
      };

      Index.prototype.render = function() {
        Index.__super__.render.apply(this, arguments);
        this.replaceWith('.discussions', this.discussions);
        return this;
      };

      Index.prototype.select = function(id) {
        if (this.selected === id) return;
        return this._select(this.selected = id || this.selected);
      };

      Index.prototype._select = function(id) {
        var model, _ref;
        if (!(model = this.collection.get(this.selected))) return;
        this.discussions.select(this.selected, {
          silent: true
        });
        if ((_ref = this.detail) != null) _ref.destroy();
        return this.html('.detail', (this.detail = new x.Detail({
          model: model
        })));
      };

      Index.prototype.loginout = function(session, loggedIn) {
        Index.__super__.loginout.apply(this, arguments);
        return this.buttons.$el.toggle(loggedIn);
      };

      Index.prototype._newDiscussion = function() {
        var showAllTag;
        showAllTag = !(this.collection.scope instanceof P.models.User);
        return P.router.layout.discussion.open(showAllTag);
      };

      return Index;

    })(P.views.shared.Page);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.discussions.messages', function(x) {
    return x.Controls = (function(_super) {

      __extends(Controls, _super);

      function Controls() {
        this._isAllowedToDestroy = __bind(this._isAllowedToDestroy, this);
        this.loginout = __bind(this.loginout, this);
        this._replyAll = __bind(this._replyAll, this);
        this._reply = __bind(this._reply, this);
        this._destroy = __bind(this._destroy, this);
        this.render = __bind(this.render, this);
        Controls.__super__.constructor.apply(this, arguments);
      }

      Controls.prototype.className = function() {
        return "" + Controls.__super__.className.apply(this, arguments) + " controls";
      };

      Controls.prototype.events = function() {
        return _.extend(Controls.__super__.events.apply(this, arguments), {
          'click .destroy': '_destroy',
          'click .reply_all': '_replyAll',
          'click .reply': '_reply'
        });
      };

      Controls.prototype.initialize = function() {
        Controls.__super__.initialize.apply(this, arguments);
        return this.buttons = new P.views.shared.ControlBar({
          buttonOptions: [
            this.model.user.id !== P.user.id ? {
              label: P.localizer.t('reply'),
              buttonClass: 'reply',
              icons: {
                primary: 'ui-icon-arrowreturn-1-e'
              }
            } : void 0, {
              label: P.localizer.t('reply_all'),
              buttonClass: 'reply_all',
              icons: {
                primary: 'ui-icon-arrowreturnthick-1-e'
              }
            }, {
              label: P.localizer.t('delete'),
              buttonClass: 'destroy',
              icons: {
                primary: 'ui-icon-trash'
              }
            }
          ]
        });
      };

      Controls.prototype.render = function() {
        Controls.__super__.render.apply(this, arguments);
        this.append(this.buttons);
        return this;
      };

      Controls.prototype._destroy = function() {
        var _this = this;
        return this.model.destroy({
          success: function() {
            return P.layout.flash.show({
              message: P.localizer.t('message_destroyed')
            });
          }
        });
      };

      Controls.prototype._reply = function() {
        return P.router.layout.discussion.open(this.model.user);
      };

      Controls.prototype._replyAll = function(e) {
        var detail;
        detail = this.parent.parent.parent;
        e.preventDefault();
        $.scrollTo('.messages-form .wysiwyg iframe');
        this.buttons.buttons.get(0).focus();
        return $('.messages-form .wysiwyg iframe', detail.el).focus();
      };

      Controls.prototype.loginout = function(session, loggedIn) {
        Controls.__super__.loginout.apply(this, arguments);
        this.buttons.$el.toggle(loggedIn);
        return this.buttons[this._isAllowedToDestroy(session.user) ? 'showButton' : 'hideButton']('Delete');
      };

      Controls.prototype._isAllowedToDestroy = function(user) {
        return (user != null ? user.id : void 0) === this.model.user.id || (user != null ? user.hasRole('admin', P.community) : void 0);
      };

      return Controls;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.discussions.messages', function(x) {
    return x.Form = (function(_super) {

      __extends(Form, _super);

      Form.prototype.className = function() {
        return "" + Form.__super__.className.apply(this, arguments) + " messages-form";
      };

      Form.prototype.templateName = 'discussions/messages/_form';

      function Form() {
        var _this = this;
        Form.__super__.constructor.apply(this, arguments);
        this.textEditor = new P.views.shared.TextEditor();
        this.buttons = new P.views.shared.ControlBar({
          controls: ['send']
        });
        this.bind('saved', function() {
          return _this.textEditor.clear();
        });
      }

      Form.prototype.features = [P.views.shared.forms.ErrorsFeature, P.views.shared.forms.FocusFeature];

      Form.prototype.formValues = function() {
        return {
          body: this.textEditor.getContent()
        };
      };

      Form.prototype.setup = function() {
        return this.bindErrors();
      };

      Form.prototype.save = function(e) {
        var values,
          _this = this;
        if (e != null) e.preventDefault();
        this.trigger('saving');
        values = _.extend(this.formValues(), {
          user_id: P.user.id,
          created_at: new Date(),
          discussion_id: this.model.id
        });
        return this.model.messages.create(values, {
          success: function(model) {
            return _this.trigger('saved', model);
          }
        });
      };

      Form.prototype.destroy = function() {
        return this.textEditor.destroy();
      };

      Form.prototype.render = function() {
        Form.__super__.render.apply(this, arguments);
        this.setup();
        this.replaceAll('textarea.body', this.textEditor);
        return this;
      };

      return Form;

    })(P.views.shared.forms.Form);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.discussions.messages', function(x) {
    return x.ListItem = (function(_super) {

      __extends(ListItem, _super);

      function ListItem() {
        this.render = __bind(this.render, this);
        ListItem.__super__.constructor.apply(this, arguments);
      }

      ListItem.prototype.templateName = 'discussions/messages/_list_item';

      ListItem.prototype.className = function() {
        return "" + ListItem.__super__.className.apply(this, arguments) + " list_item";
      };

      ListItem.prototype.initialize = function() {
        ListItem.__super__.initialize.apply(this, arguments);
        this.controls = new x.Controls({
          model: this.model,
          parent: this
        });
        return this.user_card = new P.views.users.SmallCard({
          model: this.model.user,
          user_name: true
        });
      };

      ListItem.prototype.render = function() {
        ListItem.__super__.render.apply(this, arguments);
        this.replaceWith('.controls', this.controls);
        this.replaceWith('.user-card', this.user_card);
        return this;
      };

      return ListItem;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.discussions.messages', function(x) {
    return x.Message = (function(_super) {

      __extends(Message, _super);

      function Message() {
        Message.__super__.constructor.apply(this, arguments);
      }

      Message.prototype.templateName = 'discussions/messages/_message';

      Message.prototype.className = function() {
        return "" + Message.__super__.className.apply(this, arguments) + " entry";
      };

      return Message;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.documents', function(x) {
    return x.Document = (function(_super) {

      __extends(Document, _super);

      function Document() {
        Document.__super__.constructor.apply(this, arguments);
      }

      Document.prototype.tagName = 'span';

      Document.prototype.templateName = 'documents/_document';

      Document.prototype.className = function() {
        return "" + Document.__super__.className.apply(this, arguments) + " document";
      };

      return Document;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.documents', function(x) {
    return x.Edit = (function(_super) {

      __extends(Edit, _super);

      function Edit() {
        Edit.__super__.constructor.apply(this, arguments);
        this.form = new x.Form({
          parent: this
        });
      }

      Edit.prototype.className = function() {
        return "" + Edit.__super__.className.apply(this, arguments) + " documents-edit";
      };

      Edit.prototype.open = function(model) {
        if (model == null) model = new P.models.Document();
        Edit.__super__.open.apply(this, arguments);
        this.form.attachable = this.attachable;
        this.form.edit(model);
        return this.center();
      };

      Edit.prototype.render = function() {
        Edit.__super__.render.apply(this, arguments);
        this.append(this.form);
        return this;
      };

      return Edit;

    })(P.views.shared.Dialog);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.documents', function(x) {
    return x.Form = (function(_super) {

      __extends(Form, _super);

      function Form() {
        this.render = __bind(this.render, this);
        this.saved = __bind(this.saved, this);
        this.formValues = __bind(this.formValues, this);
        this.clear = __bind(this.clear, this);
        this.setup = __bind(this.setup, this);        Form.__super__.constructor.apply(this, arguments);
        this.autoSuggest = new P.views.shared.auto_suggest.AutoSuggest({
          disableFreeForm: true,
          searchOptions: {
            classes: ['User']
          }
        });
        this.buttons = new P.views.shared.ControlBar({
          controls: ['save']
        });
        this.uploadify = new P.views.shared.Uploadify({
          id: 'document_attachment',
          fileExt: '*',
          fileDesc: 'all files'
        });
        this.bind('saved', this.saved);
        this.bind('edit', this.setup);
      }

      Form.prototype.className = function() {
        return "" + Form.__super__.className.apply(this, arguments) + " documents-form formtastic";
      };

      Form.prototype.tagName = 'div';

      Form.prototype.templateName = 'documents/_form';

      Form.prototype.features = [P.views.shared.forms.ErrorsFeature, P.views.shared.forms.FormValueGetFeature, P.views.shared.forms.FormValueSetFeature, P.views.shared.forms.FocusFeature];

      Form.prototype.setup = function() {
        P.logger.debug('Setting up form, using model:', this.model);
        this.bindErrors();
        this.setValues();
        this.autoSuggest.clear();
        if ((this.model.author != null) && !this.model.author.isNew()) {
          return this.autoSuggest.collection.add(this.model.author);
        }
      };

      Form.prototype.clear = function() {
        return this.autoSuggest.clear();
      };

      Form.prototype.formValues = function() {
        var author, values, _ref;
        values = this.getValues();
        author = this.autoSuggest.collection.first();
        values['author_id'] = author != null ? author.id : void 0;
        values['temp_attachment_id'] = (_ref = this.uploadify.attachment) != null ? _ref.id : void 0;
        values['attachable_type'] = this.attachable.get('class_name');
        values['attachable_id'] = this.attachable.id;
        return values;
      };

      Form.prototype.saved = function(model) {
        this.parent.close();
        return this.parent.parent.table.add(model);
      };

      Form.prototype.render = function() {
        Form.__super__.render.apply(this, arguments);
        this.replaceWith('.documents-author', this.autoSuggest);
        this.replaceAll('.attachment input', this.uploadify);
        return this;
      };

      return Form;

    })(P.views.shared.forms.Form);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.documents', function(x) {
    return x.Index = (function(_super) {

      __extends(Index, _super);

      Index.prototype.className = function() {
        return "" + Index.__super__.className.apply(this, arguments) + " documents-index";
      };

      Index.prototype.templateName = 'documents/_index';

      Index.prototype.events = function() {
        return _.extend(Index.__super__.events.apply(this, arguments), {
          'click button.add': 'new',
          'click button.destroy': 'destroy'
        });
      };

      function Index() {
        Index.__super__.constructor.apply(this, arguments);
        this.table = new x.Table({
          parent: this
        });
        this.edit = new x.Edit({
          parent: this
        });
      }

      Index.prototype["for"] = function(model) {
        this.edit.attachable = model;
        return this.use(model.documents);
      };

      Index.prototype.use = function(collection) {
        this.collection = collection;
        this.table.collection = collection;
        return this.table.render();
      };

      Index.prototype["new"] = function() {
        return this.edit.open(new P.models.Document());
      };

      Index.prototype.destroy = function() {
        return this.table.destroy();
      };

      Index.prototype.render = function() {
        Index.__super__.render.apply(this, arguments);
        this.replaceWith('.table', this.table);
        this.edit.render();
        return this;
      };

      return Index;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.documents', function(x) {
    return x.List = (function(_super) {

      __extends(List, _super);

      function List() {
        List.__super__.constructor.apply(this, arguments);
      }

      List.prototype.className = function() {
        return "" + List.__super__.className.apply(this, arguments) + " documents list overline with_hover";
      };

      List.prototype.itemType = x.Document;

      return List;

    })(P.views.shared.lists.TitledList);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.documents', function(x) {
    return x.Manager = (function(_super) {

      __extends(Manager, _super);

      function Manager() {
        Manager.__super__.constructor.apply(this, arguments);
      }

      Manager.prototype.add = function() {
        var document;
        document = new P.models.Document({
          group_id: this.model.id
        });
        return this.edit.open(document);
      };

      Manager.prototype.remove = function() {};

      return Manager;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.documents', function(x) {
    return x.Row = (function(_super) {

      __extends(Row, _super);

      function Row() {
        Row.__super__.constructor.apply(this, arguments);
        if (this.model.author != null) {
          this.user = new P.views.users.User({
            model: this.model.author
          });
        }
      }

      Row.prototype.render = function() {
        Row.__super__.render.apply(this, arguments);
        if (this.user != null) this.html('.user', this.user);
        return this;
      };

      return Row;

    })(P.views.shared.tables.ControllableRow);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.documents', function(x) {
    return x.Table = (function(_super) {

      __extends(Table, _super);

      function Table() {
        Table.__super__.constructor.apply(this, arguments);
      }

      Table.prototype.columns = {
        name: {
          width: '130px'
        },
        created_at: {
          width: '70px'
        }
      };

      Table.prototype.className = function() {
        return "" + Table.__super__.className.apply(this, arguments) + " table";
      };

      Table.prototype.rowConstructor = x.Row;

      return Table;

    })(P.views.shared.tables.ServerSideTable);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.events', function(x) {
    return x.Event = (function(_super) {

      __extends(Event, _super);

      function Event() {
        Event.__super__.constructor.apply(this, arguments);
      }

      Event.prototype.templateName = 'events/_event';

      Event.prototype.className = function() {
        return "" + Event.__super__.className.apply(this, arguments) + " entry";
      };

      return Event;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.events', function(x) {
    return x.Private = (function(_super) {

      __extends(Private, _super);

      function Private() {
        Private.__super__.constructor.apply(this, arguments);
      }

      Private.prototype.render = function() {
        Private.__super__.render.apply(this, arguments);
        $(this.el).html(JST['events/_private']({}));
        return this;
      };

      return Private;

    })(P.views.shared.Page);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.events', function(x) {
    return x.Show = (function(_super) {

      __extends(Show, _super);

      function Show() {
        this.render = __bind(this.render, this);
        this.initialize = __bind(this.initialize, this);
        Show.__super__.constructor.apply(this, arguments);
      }

      Show.prototype.className = function() {
        return "" + Show.__super__.className.apply(this, arguments) + " events show";
      };

      Show.prototype.templateName = 'events/show';

      Show.prototype.initialize = function() {
        Show.__super__.initialize.apply(this, arguments);
        this.speakers = new P.views.shared.lists.TitledList({
          itemType: P.views.users.SmallCard,
          addClass: 'users users-small',
          collection: new P.models.Users([], {
            searchOptions: {
              conditions: {
                ribbons: 'speaker'
              }
            }
          }).limit(8),
          templateOptions: {
            title: 'Speakers'
          }
        });
        return this.sponsors = new P.views.shared.lists.TitledList({
          addClass: "sponsor_list",
          itemType: P.views.organizations.Organization,
          collection: this.model.sponsors
        });
      };

      Show.prototype.render = function() {
        Show.__super__.render.apply(this, arguments);
        this.replaceWith('.speakers', this.speakers);
        this.replaceWith('.sponsors', this.sponsors);
        this.speakers.collection.fetch();
        return this;
      };

      return Show;

    })(P.views.communities.Show);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.calendarSettings', function(x) {
    return x.Edit = (function(_super) {

      __extends(Edit, _super);

      function Edit() {
        Edit.__super__.constructor.apply(this, arguments);
      }

      Edit.prototype.className = function() {
        return "" + Edit.__super__.className.apply(this, arguments) + " calendar_settings edit";
      };

      Edit.prototype.initialize = function() {
        Edit.__super__.initialize.apply(this, arguments);
        return this.form = new x.Form({
          parent: this
        });
      };

      Edit.prototype.open = function() {
        var _this = this;
        Edit.__super__.open.apply(this, arguments);
        return P.community.calendar.settings.fetch({
          success: function() {
            _this.form.edit(P.community.calendar.settings);
            return _this.center();
          }
        });
      };

      Edit.prototype.render = function() {
        Edit.__super__.render.apply(this, arguments);
        this.append(this.form);
        return this;
      };

      return Edit;

    })(P.views.shared.Dialog);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.calendarSettings', function(x) {
    return x.Form = (function(_super) {

      __extends(Form, _super);

      function Form() {
        this.saved = __bind(this.saved, this);
        this.setup = __bind(this.setup, this);        Form.__super__.constructor.apply(this, arguments);
        this.bind('saved', this.saved);
        this.bind('edit', this.setup);
      }

      Form.prototype.className = function() {
        return "" + Form.__super__.className.apply(this, arguments) + " calendar_settings-form";
      };

      Form.prototype.templateName = 'calendar_settings/_form';

      Form.prototype.features = [P.views.shared.forms.ErrorsFeature, P.views.shared.forms.FormValueGetFeature, P.views.shared.forms.FormValueSetFeature, P.views.shared.forms.FocusFeature];

      Form.prototype.formValues = function() {
        var values;
        values = this.getValues();
        values['restrict_locations_to_reserved'] = this.$('.restrict_locations_to_reserved input').prop('checked');
        return values;
      };

      Form.prototype.setup = function() {
        this.clearFormErrors();
        this.bindErrors();
        return this.setValues();
      };

      Form.prototype.saved = function(model) {
        this.clearFormErrors();
        this.model = model;
        return this.parent.close();
      };

      Form.prototype.render = function() {
        Form.__super__.render.apply(this, arguments);
        return this;
      };

      return Form;

    })(P.views.shared.forms.Form);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.calendarSettings', function(x) {
    return x.Show = (function(_super) {

      __extends(Show, _super);

      function Show() {
        Show.__super__.constructor.apply(this, arguments);
        this.model = P.community.calendar.settings;
        this.edit = new x.Edit({
          model: this.model
        });
      }

      Show.prototype.render = function() {
        Show.__super__.render.apply(this, arguments);
        $(this.el).find('.community_settings-edit').replaceWith(this.edit.render().el);
        this.edit.render();
        return this;
      };

      return Show;

    })(P.views.shared.HostPage);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.categories', function(x) {
    return x.Form = (function(_super) {

      __extends(Form, _super);

      function Form() {
        this.render = __bind(this.render, this);
        this.setup = __bind(this.setup, this);
        Form.__super__.constructor.apply(this, arguments);
      }

      Form.prototype.initialize = function() {
        Form.__super__.initialize.apply(this, arguments);
        this.color = new P.views.shared.ColorPicker({
          parent: this
        });
        this.bind('saved', this.saved);
        return this.bind('edit', this.setup);
      };

      Form.prototype.templateName = 'host/labels/_form';

      Form.prototype.features = [P.views.shared.forms.ErrorsFeature, P.views.shared.forms.FormValueSetFeature, P.views.shared.forms.FormValueGetFeature, P.views.shared.forms.FocusFeature];

      Form.prototype.formValues = function() {
        return _.extend(this.getValues('category'), {
          color: this.color.color.hex
        });
      };

      Form.prototype.setup = function() {
        this.setValues();
        this.bindErrors();
        this.focus(true);
        return this.color.setColor({
          hex: this.model.get('color')
        });
      };

      Form.prototype.saved = function(model) {
        P.community.questions.fetch();
        return P.layout.flash.show({
          message: 'Category saved!'
        });
      };

      Form.prototype.render = function() {
        Form.__super__.render.apply(this, arguments);
        this.replaceWith('.color input', this.color);
        return this;
      };

      return Form;

    })(P.views.shared.forms.Form);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.categories', function(x) {
    return x.Row = (function(_super) {

      __extends(Row, _super);

      function Row() {
        Row.__super__.constructor.apply(this, arguments);
      }

      Row.prototype.render = function() {
        Row.__super__.render.apply(this, arguments);
        this.$('.color').css('background-color', this.model.get('color'));
        return this;
      };

      return Row;

    })(P.views.shared.tables.NavRow);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.categories', function(x) {
    return x.Table = (function(_super) {

      __extends(Table, _super);

      function Table() {
        Table.__super__.constructor.apply(this, arguments);
      }

      Table.prototype.columns = {
        name: {
          title: 'name',
          width: '200px',
          features: ['sortable', 'filterable'],
          filter_type: 'string'
        },
        color: {
          title: 'Color',
          width: '130px',
          features: ['sortable', 'filterable'],
          filter_type: 'string',
          "class": 'color uppercase'
        }
      };

      Table.prototype.wildcardColumns = ['name'];

      Table.prototype.rowConstructor = x.Row;

      return Table;

    })(P.views.shared.tables.ServerSideTable);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.categories', function(x) {
    return x.Edit = (function(_super) {

      __extends(Edit, _super);

      Edit.prototype.templateName = 'host/categories/edit';

      function Edit() {
        var _this = this;
        Edit.__super__.constructor.apply(this, arguments);
        this.form = new x.Form({
          parent: this
        }).bind('saved', function() {
          return P.router.redirectTo('#categories');
        });
      }

      Edit.prototype.render = function() {
        Edit.__super__.render.apply(this, arguments);
        this.append(this.form);
        this.form.edit(this.model);
        return this;
      };

      return Edit;

    })(P.views.shared.HostPage);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.categories', function(x) {
    return x.Index = (function(_super) {

      __extends(Index, _super);

      Index.prototype.templateName = 'host/categories/index';

      Index.prototype.events = function() {
        return _.extend(Index.__super__.events.apply(this, arguments), {
          'click button.destroy': '_destroy'
        });
      };

      function Index() {
        this.render = __bind(this.render, this);        Index.__super__.constructor.apply(this, arguments);
        this.table = new x.Table({
          parent: this,
          collection: this.collection
        });
      }

      Index.prototype.render = function() {
        Index.__super__.render.apply(this, arguments);
        this.replaceWith('.table', this.table);
        return this;
      };

      Index.prototype._destroy = function() {
        return this.table.destroy();
      };

      return Index;

    })(P.views.shared.Table);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.datafeeds', function(x) {
    return x.Credentials = (function(_super) {

      __extends(Credentials, _super);

      function Credentials() {
        Credentials.__super__.constructor.apply(this, arguments);
        this.parent = this.options.parent;
      }

      Credentials.prototype.credentialsAttributes = ['user_name', 'password', 'auth_token', 'external_event_id', 'feed_url', 'xslt'];

      Credentials.prototype.setContent = function() {
        var attr, input, model, _i, _len, _ref, _results;
        if ((model = this.parent.model) != null) {
          this.$('legend').html(this.parent.model.get('service_name') + ' Credentials');
          _ref = this.credentialsAttributes;
          _results = [];
          for (_i = 0, _len = _ref.length; _i < _len; _i++) {
            attr = _ref[_i];
            input = this.$("[name='datafeed\\[" + attr + "\\]']");
            input.val(model.get(attr));
            if (input.is(':text')) {
              _results.push(input.css({
                display: 'block'
              }));
            } else {
              _results.push(void 0);
            }
          }
          return _results;
        }
      };

      Credentials.prototype.render = function() {
        var model, service, _ref;
        $(this.el).hide().find('#credentials-container').empty();
        if ((this.parent != null) && (service = (_ref = this.parent.model) != null ? _ref.get('service') : void 0) && service !== '') {
          model = new P.models.Datafeed();
          $(this.el).find('#credentials-container').html(JST["host/datafeeds/_" + service]({
            model: model
          }));
          this.setContent();
          $(this.el).show();
        }
        return this;
      };

      return Credentials;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.datafeeds', function(x) {
    return x.Form = (function(_super) {

      __extends(Form, _super);

      Form.prototype.events = function() {
        return _.extend(Form.__super__.events.apply(this, arguments), {
          'change select[name="datafeed\\[service\\]"]': 'setService'
        });
      };

      function Form() {
        this.renderMappings = __bind(this.renderMappings, this);
        this.renderCredentials = __bind(this.renderCredentials, this);
        this.setService = __bind(this.setService, this);
        this.saved = __bind(this.saved, this);
        this.setup = __bind(this.setup, this);        Form.__super__.constructor.apply(this, arguments);
        this.modelType = this.options.modelType;
        this.modelClass = this.options.modelClass;
        this.attachModel();
        this.bind('edit', this.setup);
        this.bind('saved', this.saved);
      }

      Form.prototype.features = [P.views.shared.forms.ErrorsFeature, P.views.shared.forms.FormValueGetFeature, P.views.shared.forms.FormValueSetFeature, P.views.shared.forms.FocusFeature];

      Form.prototype.attachModel = function(new_model) {
        new_model || (new_model = new P.models.Datafeed({
          model_class: this.modelClass
        }));
        this.model = new_model;
        this.model.bind('change:service', this.renderCredentials);
        return this.model.bind('change:service', this.renderMappings);
      };

      Form.prototype.edit = function(model) {
        this.attachModel(model);
        return this.trigger('edit');
      };

      Form.prototype.setup = function() {
        this.bindErrors();
        this.setValues();
        this.renderCredentials();
        this.renderMappings();
        return this.focus(true);
      };

      Form.prototype.saved = function() {
        this.model.unbind('change:service', this.renderCredentials);
        this.model.unbind('change:service', this.renderMappings);
        return P.layout.flash.show({
          message: 'Data feed saved!'
        });
      };

      Form.prototype.formValues = function() {
        var attr, formPredicate, value, values, _i, _len, _ref, _ref2;
        values = this.getValues();
        values.mail_template_id = this.$('select[name="datafeed\\[mail_template_id\\]"]').val();
        formPredicate = this.model.className.underscore();
        _ref2 = (_ref = this.credentials) != null ? _ref.credentialsAttributes : void 0;
        for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
          attr = _ref2[_i];
          value = $(this.el).find("#" + formPredicate + "_" + attr).val();
          if (value === void 0) {
            values[attr] = '';
          } else if (value === '') {
            delete values[attr];
          } else {
            values[attr] = value;
          }
        }
        _.extend(values, {
          import_mappings_attributes: this.mappings.formValues()
        });
        values.type = this.modelType;
        values.model_class = this.modelClass;
        return values;
      };

      Form.prototype.setService = function(e) {
        var select, val;
        select = $(e.currentTarget);
        val = select.val();
        return this.model.set({
          service_name: select.find("option[value='" + val + "']").text(),
          service: val
        });
      };

      Form.prototype.renderCredentials = function() {
        this.credentials || (this.credentials = new x.Credentials({
          el: this.$('#datafeed-credentials'),
          parent: this
        }));
        return this.credentials.render();
      };

      Form.prototype.renderMappings = function() {
        var existing_mappings, import_mappings, mappings,
          _this = this;
        this.mappings || (this.mappings = new P.views.host.imports.Mappings({
          el: this.$('#datafeed-import_mappings'),
          parent: this
        }));
        existing_mappings = this.model.import_mappings.pluck('from_column');
        mappings = _.reject(P.field_mappings[_.last(this.model.get('model_class').split('::')).underscore()][this.model.get('service')], function(mapping) {
          return existing_mappings.indexOf(mapping.from_column) >= 0;
        });
        import_mappings = new P.models.ImportMappings(mappings);
        import_mappings.add(this.model.import_mappings.models, {
          at: 0,
          silent: true
        });
        return this.mappings.render({
          mappings: import_mappings,
          targets: P.target_fields[_.last(this.modelClass.split('::')).underscore()]
        });
      };

      return Form;

    })(P.views.shared.forms.Form);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.datafeeds', function(x) {
    return x.Row = (function(_super) {

      __extends(Row, _super);

      function Row() {
        Row.__super__.constructor.apply(this, arguments);
        this.rowButtons = new x.RowButtons({
          el: this.$('td:eq(1)'),
          parent: this
        });
      }

      Row.prototype.render = function() {
        Row.__super__.render.apply(this, arguments);
        this.rowButtons.render();
        return this;
      };

      return Row;

    })(P.views.shared.tables.NavRow);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.datafeeds', function(x) {
    return x.RowButtons = (function(_super) {

      __extends(RowButtons, _super);

      function RowButtons() {
        this.renderButtons = __bind(this.renderButtons, this);
        this.forceSync = __bind(this.forceSync, this);
        this.toggleStatus = __bind(this.toggleStatus, this);
        RowButtons.__super__.constructor.apply(this, arguments);
      }

      RowButtons.prototype.events = function() {
        return _.extend(RowButtons.__super__.events.apply(this, arguments), {
          'click .datafeed-status': 'toggleStatus',
          'click #datafeed-refresh': 'forceSync'
        });
      };

      RowButtons.prototype.initialize = function() {
        RowButtons.__super__.initialize.apply(this, arguments);
        this.syncButton = new P.views.shared.Button({
          label: 'Update',
          icons: {
            primary: 'ui-icon-refresh'
          },
          id: 'datafeed-refresh'
        });
        this.statusButtons = new P.views.shared.ButtonSet([
          {
            label: 'Enable',
            icons: {
              primary: 'ui-icon-play'
            },
            className: 'datafeed-status'
          }, {
            label: 'Disable',
            icons: {
              primary: 'ui-icon-pause'
            },
            className: 'datafeed-status'
          }
        ]);
        this.model = this.parent.model;
        return this.model.bind('change:enabled', this.renderButtons);
      };

      RowButtons.prototype.toggleStatus = function(e) {
        e.stopPropagation();
        return this.model.toggleStatus();
      };

      RowButtons.prototype.forceSync = function(e) {
        e.stopPropagation();
        return this.model.forceSync();
      };

      RowButtons.prototype.renderButtons = function() {
        this.$el.empty();
        this.renderStatusButtons();
        return this.append(this.syncButton);
      };

      RowButtons.prototype.renderStatusButtons = function() {
        var enabled;
        enabled = this.model.get('enabled') || false;
        return this.append(this.statusButtons.get(Number(enabled)));
      };

      RowButtons.prototype.render = function() {
        RowButtons.__super__.render.apply(this, arguments);
        this.renderButtons();
        return this;
      };

      return RowButtons;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.datafeeds', function(x) {
    return x.Table = (function(_super) {

      __extends(Table, _super);

      function Table() {
        this.columns = __bind(this.columns, this);        Table.__super__.constructor.apply(this, arguments);
        this.collection = new P.models.Datafeeds([], {
          searchOptions: {
            "with": {
              model_class: this.parent.modelClass
            }
          }
        });
      }

      Table.prototype.className = function() {
        return "" + Table.__super__.className.apply(this, arguments) + " datafeeds-table";
      };

      Table.prototype.columns = function() {
        return {
          enabled: {
            title: '',
            width: '100px'
          },
          description: {
            width: '200px',
            features: ['sortable', 'searchable', 'filterable'],
            filter_type: 'string'
          },
          service_name: {
            title: 'Service',
            width: '100px',
            features: ['sortable', 'searchable', 'filterable'],
            filter_type: 'string'
          },
          last_processed_at: {
            title: 'Last Processed',
            width: '150px',
            sortable: true,
            use_rendered: false,
            render: this.renderDate
          },
          last_result: {
            title: 'Result',
            width: '200px'
          }
        };
      };

      Table.prototype.rowConstructor = x.Row;

      return Table;

    })(P.views.shared.tables.ServerSideTable);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.datafeeds', function(x) {
    return x.Edit = (function(_super) {

      __extends(Edit, _super);

      Edit.prototype.className = function() {
        return "" + Edit.__super__.className.apply(this, arguments) + " datafeeds-edit";
      };

      function Edit() {
        this._redirect = __bind(this._redirect, this);        Edit.__super__.constructor.apply(this, arguments);
        if (this.model.isNew()) {
          this.model.set({
            model_class: this.modelClass
          });
        }
        this.form = new (this.formType())({
          modelType: this.modelType,
          modelClass: this.modelClass,
          parent: this
        });
        this.form.bind('saved', this._redirect);
      }

      Edit.prototype.destroy = function() {
        Edit.__super__.destroy.apply(this, arguments);
        return this.form.unbind('saved', this._redirect);
      };

      Edit.prototype.render = function() {
        Edit.__super__.render.apply(this, arguments);
        this.append(this.form);
        this.form.edit(this.model);
        return this;
      };

      Edit.prototype._redirect = function() {
        return P.router.redirectTo("#" + (this.model.get('model_type')) + "/datafeeds");
      };

      return Edit;

    })(P.views.shared.HostPage);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.datafeeds', function(x) {
    return x.Index = (function(_super) {

      __extends(Index, _super);

      function Index() {
        Index.__super__.constructor.apply(this, arguments);
      }

      Index.prototype.modelType = '';

      Index.prototype.modelClass = '';

      Index.prototype.tableConstructor = x.Table;

      Index.prototype.templateName = 'host/datafeeds/index';

      Index.prototype.id = 'datafeeds-index';

      Index.prototype.events = function() {
        return _.extend(Index.__super__.events.apply(this, arguments), {
          'click button.destroy': 'destroy'
        });
      };

      Index.prototype.destroy = function() {
        return this.table.destroy();
      };

      Index.prototype.render = function() {
        Index.__super__.render.apply(this, arguments);
        this.replaceWith('.datafeeds-table', this.table);
        return this;
      };

      return Index;

    })(P.views.shared.Table);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.datafeeds.meetings', function(x) {
    return x.Form = (function(_super) {

      __extends(Form, _super);

      function Form() {
        Form.__super__.constructor.apply(this, arguments);
      }

      Form.prototype.templateName = '#templates-meeting_datafeeds-form';

      return Form;

    })(P.views.host.datafeeds.Form);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.datafeeds.meetings', function(x) {
    return x.Edit = (function(_super) {

      __extends(Edit, _super);

      function Edit() {
        Edit.__super__.constructor.apply(this, arguments);
      }

      Edit.prototype.modelType = 'MeetingDatafeed';

      Edit.prototype.modelClass = 'Groups::Meetings::Meeting';

      Edit.prototype.formType = function() {
        return x.Form;
      };

      return Edit;

    })(P.views.host.datafeeds.Edit);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.datafeeds.meetings', function(x) {
    return x.Index = (function(_super) {

      __extends(Index, _super);

      function Index() {
        Index.__super__.constructor.apply(this, arguments);
      }

      Index.prototype.modelType = 'MeetingDatafeed';

      Index.prototype.modelClass = 'Groups::Meetings::Meeting';

      return Index;

    })(P.views.host.datafeeds.Index);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.datafeeds.users', function(x) {
    return x.Form = (function(_super) {

      __extends(Form, _super);

      function Form() {
        Form.__super__.constructor.apply(this, arguments);
      }

      Form.prototype.templateName = '#templates-user_datafeeds-form';

      Form.prototype.attachModel = function() {
        Form.__super__.attachModel.apply(this, arguments);
        if (_.isEmpty(this.model.get('xslt'))) {
          return this.model.set({
            xslt: P.xslt.users
          }, {
            silent: true
          });
        }
      };

      return Form;

    })(P.views.host.datafeeds.Form);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.datafeeds.users', function(x) {
    return x.Edit = (function(_super) {

      __extends(Edit, _super);

      function Edit() {
        Edit.__super__.constructor.apply(this, arguments);
      }

      Edit.prototype.modelType = 'UserDatafeed';

      Edit.prototype.modelClass = 'User';

      Edit.prototype.formType = function() {
        return x.Form;
      };

      return Edit;

    })(P.views.host.datafeeds.Edit);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.datafeeds.users', function(x) {
    return x.Index = (function(_super) {

      __extends(Index, _super);

      function Index() {
        Index.__super__.constructor.apply(this, arguments);
      }

      Index.prototype.modelType = 'UserDatafeed';

      Index.prototype.modelClass = 'User';

      return Index;

    })(P.views.host.datafeeds.Index);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.imports', function(x) {
    return x.Attachments = (function(_super) {

      __extends(Attachments, _super);

      function Attachments() {
        Attachments.__super__.constructor.apply(this, arguments);
        this.uploadify();
      }

      Attachments.prototype.uploadify = function() {
        var params,
          _this = this;
        $(this.el).attr('id', "" + ($(this.el).attr('id')) + "_" + (this._getRandomId()));
        params = {
          model_class: this.parent.model_class,
          auth_token: P.user.get('authentication_token')
        };
        return $(this.el).uploadify({
          uploader: '/flashes/uploadify.swf',
          cancelImg: 'assets/images/uploadify/cancel.png',
          script: '/host/imports/new.json',
          scriptData: params,
          method: 'get',
          fileDataName: 'import[attachments_attributes][0][attachment]',
          fileDesc: 'CSV or XML files',
          fileExt: '*.csv;*.xml',
          auto: true,
          debug: P.development,
          onError: function(e) {
            return P.logger.error('Uploadify error:');
          },
          onComplete: function(event, queueID, fileObj, response, data) {
            var attrs;
            attrs = JSON.parse(response);
            if (attrs.target_fields != null) {
              _this.parent.model.set({
                target_fields: attrs.target_fields
              });
            }
            if (attrs.attachments != null) {
              _this.parent.model.attachments.reset(attrs.attachments);
            }
            if (attrs.import_mappings != null) {
              _this.parent.model.import_mappings.reset(attrs.import_mappings);
            }
            return true;
          }
        });
      };

      Attachments.prototype._getRandomId = function() {
        return Math.floor(new Date().getTime() * Math.random());
      };

      return Attachments;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.imports', function(x) {
    return x.Form = (function(_super) {

      __extends(Form, _super);

      Form.prototype.templateName = '#templates-imports-form';

      Form.prototype.className = function() {
        return "" + Form.__super__.className.apply(this, arguments) + " imports-form";
      };

      Form.prototype.features = [P.views.shared.forms.ErrorsFeature, P.views.shared.forms.FormValueGetFeature, P.views.shared.forms.FormValueSetFeature, P.views.shared.forms.FocusFeature];

      function Form() {
        this.render = __bind(this.render, this);
        this.renderMappings = __bind(this.renderMappings, this);
        this.saved = __bind(this.saved, this);
        this.setup = __bind(this.setup, this);        Form.__super__.constructor.apply(this, arguments);
        this.model_class = this.model.get('model_class');
        this.attachModel();
        this.bind('saved', this.saved);
        this.bind('edit', this.setup);
      }

      Form.prototype.attachModel = function(new_model) {
        new_model || (new_model = new P.models.Import({
          model_class: this.model_class
        }));
        this.model = new_model;
        return this.model.import_mappings.bind('reset', this.renderMappings);
      };

      Form.prototype.formValues = function() {
        return {
          model_class: this.model_class,
          mode: this.$('select[name="import\\[mode\\]"]').val(),
          mail_template_id: this.$('select[name="import\\[mail_template_id\\]"]').val(),
          import_mappings_attributes: this.mappings.formValues(),
          attachment_ids: this.model.attachments.pluck('id')
        };
      };

      Form.prototype.setup = function() {
        this.bindErrors();
        this.$("input[name='import\\[mode\\]'][value='" + (this.model.get('mode')) + "']").attr('checked', 'checked');
        this.renderMappings();
        return this.attachments || (this.attachments = new x.Attachments({
          el: this.$('input:file'),
          parent: this
        }));
      };

      Form.prototype.edit = function(model) {
        this.attachModel(model);
        return this.trigger('edit');
      };

      Form.prototype.saved = function() {
        return P.layout.flash.show({
          message: 'Import saved!'
        });
      };

      Form.prototype.renderMappings = function() {
        return this.mappings.render();
      };

      Form.prototype.render = function() {
        Form.__super__.render.apply(this, arguments);
        this.mappings = new x.Mappings({
          el: this.$('fieldset#import_mappings'),
          parent: this
        });
        return this;
      };

      return Form;

    })(P.views.shared.forms.Form);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.imports', function(x) {
    return x.Mapping = (function(_super) {

      __extends(Mapping, _super);

      function Mapping() {
        Mapping.__super__.constructor.apply(this, arguments);
      }

      Mapping.prototype.templateName = 'host/import_mappings/_form';

      Mapping.prototype.tagName = 'p';

      Mapping.prototype.className = function() {
        return "" + Mapping.__super__.className.apply(this, arguments) + " select";
      };

      Mapping.prototype.formValues = function() {
        return {
          id: this.model.get('id'),
          from_column: this.model.get('from_column'),
          to_column: this.$('select').val()
        };
      };

      return Mapping;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.imports', function(x) {
    return x.Mappings = (function(_super) {

      __extends(Mappings, _super);

      function Mappings() {
        this.renderMappings = __bind(this.renderMappings, this);        Mappings.__super__.constructor.apply(this, arguments);
        this.container = $(this.el).find('#import_mappings-container');
        this.mapper = this.parent.model.className.underscore();
      }

      Mappings.prototype.formValues = function() {
        return _.invoke(this.mappings, 'formValues');
      };

      Mappings.prototype.renderMappings = function(options) {
        var collection, targets,
          _this = this;
        $(this.el).hide();
        collection = (options != null ? options.mappings : void 0) || this.parent.model.import_mappings;
        targets = (options != null ? options.targets : void 0) || this.parent.model.get('target_fields') || [];
        this.mappings = [];
        if (collection.length > 0) {
          this.container.empty();
          collection.each(function(mapping, index) {
            var view;
            view = new x.Mapping({
              model: mapping,
              templateOptions: {
                mapper: _this.mapper,
                targets: targets,
                index: index
              }
            });
            _this.container.append(view.render().el);
            return _this.mappings.push(view);
          });
          return $(this.el).show();
        }
      };

      Mappings.prototype.render = function(options) {
        Mappings.__super__.render.apply(this, arguments);
        this.renderMappings(options);
        return this;
      };

      return Mappings;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.imports', function(x) {
    return x.Table = (function(_super) {

      __extends(Table, _super);

      Table.prototype.columns = function() {
        return {
          source: {
            width: '130px',
            filterable: true,
            filter_type: 'string'
          },
          finished_at: {
            width: '130px',
            sortable: true,
            type: 'date',
            use_rendered: false,
            render: this.renderDate
          },
          result: {
            width: '200px',
            searchable: true
          }
        };
      };

      Table.prototype.rowConstructor = P.views.shared.tables.NavRow;

      Table.prototype.className = function() {
        return "" + Table.__super__.className.apply(this, arguments) + " imports-table";
      };

      function Table() {
        this.refreshTable = __bind(this.refreshTable, this);
        this.columns = __bind(this.columns, this);        Table.__super__.constructor.apply(this, arguments);
        this.collection = new P.models.Imports([], {
          searchOptions: {
            "with": {
              model_class: this.parent.model_class
            }
          }
        });
        this.collection.enableAutoFetch();
      }

      Table.prototype.refreshTable = function() {
        return this.dataTable.fnDraw();
      };

      return Table;

    })(P.views.shared.tables.ServerSideTable);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.imports', function(x) {
    return x.Edit = (function(_super) {

      __extends(Edit, _super);

      Edit.prototype.className = function() {
        return "" + Edit.__super__.className.apply(this, arguments) + " imports-edit";
      };

      function Edit() {
        Edit.__super__.constructor.apply(this, arguments);
        this.form = new x.Form({
          model: this.model
        }).bind('saved', this._redirect);
      }

      Edit.prototype.destroy = function() {
        Edit.__super__.destroy.apply(this, arguments);
        return this.form.unbind('saved', this._redirect);
      };

      Edit.prototype.render = function() {
        Edit.__super__.render.apply(this, arguments);
        this.append(this.form);
        this.form.edit(this.model);
        return this;
      };

      Edit.prototype._redirect = function() {
        return P.router.redirectTo("#" + (this.model.get('model_type')) + "/imports");
      };

      return Edit;

    })(P.views.shared.HostPage);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.imports', function(x) {
    return x.Index = (function(_super) {

      __extends(Index, _super);

      function Index() {
        Index.__super__.constructor.apply(this, arguments);
      }

      Index.prototype.model_class = '';

      Index.prototype.tableConstructor = x.Table;

      Index.prototype.templateName = 'host/imports/index';

      Index.prototype.id = 'imports-index';

      Index.prototype.events = function() {
        return _.extend(Index.__super__.events.apply(this, arguments), {
          'click button.destroy': 'destroy'
        });
      };

      Index.prototype.destroy = function() {
        return this.table.destroy();
      };

      Index.prototype.render = function() {
        Index.__super__.render.apply(this, arguments);
        this.replaceWith('.imports-table', this.table);
        return this;
      };

      return Index;

    })(P.views.shared.Table);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.imports.meetings', function(x) {
    return x.Index = (function(_super) {

      __extends(Index, _super);

      function Index() {
        Index.__super__.constructor.apply(this, arguments);
      }

      Index.prototype.model_class = 'Groups::Meetings::Meeting';

      return Index;

    })(P.views.host.imports.Index);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.imports', function(x) {
    return x.Organizations = (function(_super) {

      __extends(Organizations, _super);

      function Organizations() {
        Organizations.__super__.constructor.apply(this, arguments);
      }

      Organizations.prototype.model_class = 'Organization';

      return Organizations;

    })(x.Index);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.imports.organizations', function(x) {
    return x.Index = (function(_super) {

      __extends(Index, _super);

      function Index() {
        Index.__super__.constructor.apply(this, arguments);
      }

      Index.prototype.model_class = 'Organization';

      return Index;

    })(P.views.host.imports.Index);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.imports.users', function(x) {
    return x.Index = (function(_super) {

      __extends(Index, _super);

      function Index() {
        Index.__super__.constructor.apply(this, arguments);
      }

      Index.prototype.model_class = 'User';

      return Index;

    })(P.views.host.imports.Index);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.labels', function(x) {
    return x.Form = (function(_super) {

      __extends(Form, _super);

      function Form() {
        this.render = __bind(this.render, this);
        this.setup = __bind(this.setup, this);
        Form.__super__.constructor.apply(this, arguments);
      }

      Form.prototype.initialize = function() {
        Form.__super__.initialize.apply(this, arguments);
        this.color = new P.views.shared.ColorPicker({
          parent: this
        });
        this.bind('saved', this.saved);
        return this.bind('edit', this.setup);
      };

      Form.prototype.className = function() {
        return "" + Form.__super__.className.apply(this, arguments);
      };

      Form.prototype.templateName = 'host/labels/_form';

      Form.prototype.features = [P.views.shared.forms.ErrorsFeature, P.views.shared.forms.FormValueSetFeature, P.views.shared.forms.FormValueGetFeature, P.views.shared.forms.FocusFeature];

      Form.prototype.formValues = function() {
        var values;
        values = this.getValues();
        values.color = this.color.color.hex;
        return values;
      };

      Form.prototype.setup = function() {
        this.setValues();
        this.bindErrors();
        this.focus(true);
        return this.color.setColor({
          hex: this.model.get('color')
        });
      };

      Form.prototype.saved = function(model) {
        return P.layout.flash.show({
          message: 'Label saved!'
        });
      };

      Form.prototype.render = function() {
        Form.__super__.render.apply(this, arguments);
        this.replaceWith('.color input', this.color);
        return this;
      };

      return Form;

    })(P.views.shared.forms.Form);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.labels', function(x) {
    return x.Row = (function(_super) {

      __extends(Row, _super);

      function Row() {
        Row.__super__.constructor.apply(this, arguments);
      }

      Row.prototype.render = function() {
        Row.__super__.render.apply(this, arguments);
        this.$('.color').css('background-color', this.model.get('color'));
        return this;
      };

      return Row;

    })(P.views.shared.tables.NavRow);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.labels', function(x) {
    return x.Table = (function(_super) {

      __extends(Table, _super);

      function Table() {
        Table.__super__.constructor.apply(this, arguments);
      }

      Table.prototype.columns = {
        name: {
          title: 'name',
          width: '200px',
          features: ['sortable', 'filterable'],
          filter_type: 'string'
        },
        color: {
          title: 'Color',
          width: '130px',
          features: ['sortable', 'filterable'],
          filter_type: 'string',
          "class": 'color uppercase'
        }
      };

      Table.prototype.wildcardColumns = ['name'];

      Table.prototype.className = function() {
        return "" + Table.__super__.className.apply(this, arguments);
      };

      Table.prototype.rowConstructor = x.Row;

      return Table;

    })(P.views.shared.tables.ServerSideTable);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.labels', function(x) {
    return x.Edit = (function(_super) {

      __extends(Edit, _super);

      function Edit() {
        Edit.__super__.constructor.apply(this, arguments);
      }

      Edit.prototype.templateName = 'host/labels/edit';

      Edit.prototype.initialize = function() {
        Edit.__super__.initialize.apply(this, arguments);
        return this.form = new x.Form().bind('saved', function() {
          return P.router.redirectTo('#labels/' + this.model.label_set.get('name'));
        });
      };

      Edit.prototype.render = function() {
        Edit.__super__.render.apply(this, arguments);
        this.append(this.form);
        this.form.edit(this.model);
        return this;
      };

      return Edit;

    })(P.views.shared.HostPage);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.labels', function(x) {
    return x.Index = (function(_super) {

      __extends(Index, _super);

      Index.prototype.templateName = 'host/labels/index';

      Index.prototype.events = function() {
        return _.extend(Index.__super__.events.apply(this, arguments), {
          'click button.destroy': '_destroy'
        });
      };

      function Index() {
        this.render = __bind(this.render, this);        Index.__super__.constructor.apply(this, arguments);
        this.table = new x.Table({
          parent: this,
          collection: this.collection
        });
      }

      Index.prototype.render = function() {
        Index.__super__.render.apply(this, arguments);
        this.replaceWith('.table', this.table);
        return this;
      };

      Index.prototype._destroy = function() {
        return this.table.destroy();
      };

      return Index;

    })(P.views.shared.Table);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.locations', function(x) {
    return x.Form = (function(_super) {

      __extends(Form, _super);

      function Form() {
        this.setup = __bind(this.setup, this);
        Form.__super__.constructor.apply(this, arguments);
      }

      Form.prototype.initialize = function() {
        Form.__super__.initialize.apply(this, arguments);
        this.bind('saved', this.saved);
        return this.bind('edit', this.setup);
      };

      Form.prototype.className = function() {
        return "" + Form.__super__.className.apply(this, arguments) + " questions-form";
      };

      Form.prototype.templateName = 'host/locations/_form';

      Form.prototype.features = [P.views.shared.forms.ErrorsFeature, P.views.shared.forms.FormValueSetFeature, P.views.shared.forms.FormValueGetFeature, P.views.shared.forms.FocusFeature];

      Form.prototype.formValues = function() {
        var values;
        values = this.getValues();
        values['managed'] = true;
        values['reservable'] = this.$('.reservable input').prop('checked');
        return values;
      };

      Form.prototype.setup = function() {
        this.setValues();
        this.bindErrors();
        this.focus(true);
        if (this.model.isNew()) {
          return this.$('.reservable input').prop('checked', true);
        }
      };

      Form.prototype.saved = function(model) {
        return P.layout.flash.show({
          message: 'Location saved!'
        });
      };

      return Form;

    })(P.views.shared.forms.Form);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.locations', function(x) {
    return x.Table = (function(_super) {

      __extends(Table, _super);

      function Table() {
        this.collection = P.community.locations;
        Table.__super__.constructor.apply(this, arguments);
      }

      Table.prototype.columns = {
        name: {
          width: '130px',
          sortable: true,
          type: 'string'
        },
        reservable: {
          width: '40px',
          sortable: true,
          type: 'string'
        },
        capacity: {
          width: '40px',
          sortable: true,
          type: 'integer'
        }
      };

      Table.prototype.wildcardColumns = ['name'];

      Table.prototype.className = function() {
        return "" + Table.__super__.className.apply(this, arguments) + " locations-table";
      };

      Table.prototype.rowConstructor = P.views.shared.tables.NavRow;

      return Table;

    })(P.views.shared.tables.ServerSideTable);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.locations', function(x) {
    return x.Edit = (function(_super) {

      __extends(Edit, _super);

      function Edit() {
        Edit.__super__.constructor.apply(this, arguments);
      }

      Edit.prototype.templateName = 'host/locations/edit';

      Edit.prototype.initialize = function() {
        var _this = this;
        Edit.__super__.initialize.apply(this, arguments);
        return this.form = new x.Form({
          model: this.model
        }).bind('saved', function() {
          return P.router.redirectTo('#locations');
        });
      };

      Edit.prototype.render = function() {
        Edit.__super__.render.apply(this, arguments);
        this.append(this.form);
        this.form.edit(this.model);
        return this;
      };

      return Edit;

    })(P.views.shared.HostPage);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.locations', function(x) {
    return x.Index = (function(_super) {

      __extends(Index, _super);

      function Index() {
        this.render = __bind(this.render, this);
        Index.__super__.constructor.apply(this, arguments);
      }

      Index.prototype.tableConstructor = x.Table;

      Index.prototype.templateName = 'host/locations/index';

      Index.prototype.render = function() {
        Index.__super__.render.apply(this, arguments);
        this.replaceWith('.table', this.table);
        return this;
      };

      return Index;

    })(P.views.shared.Table);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.meetings', function(x) {
    return x.Table = (function(_super) {

      __extends(Table, _super);

      function Table() {
        this.columns = __bind(this.columns, this);
        Table.__super__.constructor.apply(this, arguments);
      }

      Table.prototype.columns = function() {
        return {
          name: {
            width: '200px',
            features: ['sortable', 'searchable', 'filterable'],
            filter_type: 'string'
          },
          memberships_count: {
            title: 'Count',
            width: '80px',
            features: ['sortable']
          },
          starts_at: {
            title: 'Starts',
            source: 'starts_at_local',
            width: '185px',
            sortable: true,
            type: 'date',
            use_rendered: false,
            render: this.renderDate
          },
          ends_at: {
            title: 'Ends',
            source: 'ends_at_local',
            width: '100px',
            sortable: true,
            type: 'date',
            use_rendered: false,
            render: this.renderTime
          }
        };
      };

      Table.prototype.wildcardColumns = ['name'];

      Table.prototype.className = function() {
        return "" + Table.__super__.className.apply(this, arguments) + " table";
      };

      Table.prototype.rowConstructor = P.views.shared.tables.NavRow;

      return Table;

    })(P.views.shared.tables.ServerSideTable);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.meetings', function(x) {
    return x.EditPage = (function(_super) {

      __extends(EditPage, _super);

      function EditPage() {
        EditPage.__super__.constructor.apply(this, arguments);
      }

      EditPage.prototype.templateName = 'meetings/_edit';

      EditPage.prototype.returnUrl = '#meetings/public';

      EditPage.prototype.formType = function() {
        if (this.model.get('private')) {
          return P.views.meetings.private.Form;
        } else {
          return P.views.meetings.public.Form;
        }
      };

      return EditPage;

    })(P.views.host.groups.EditPage);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.meetings', function(x) {
    return x.Index = (function(_super) {

      __extends(Index, _super);

      Index.prototype.title = 'Schedule';

      Index.prototype.tableConstructor = x.Table;

      Index.prototype.templateName = 'host/meetings/index';

      Index.prototype.events = function() {
        return _.extend(Index.__super__.events.apply(this, arguments), {
          'click button.destroy': '_destroy',
          'click .edit-settings': '_editSettings'
        });
      };

      function Index() {
        this._editSettings = __bind(this._editSettings, this);        Index.__super__.constructor.apply(this, arguments);
        this.collection = P.community.calendar.meetings[this.options.private ? 'private' : 'public']();
        this.table = new x.Table({
          parent: this,
          collection: this.collection
        });
        this.settingsEdit = new P.views.host.calendarSettings.Edit;
      }

      Index.prototype.render = function() {
        Index.__super__.render.apply(this, arguments);
        this.replaceWith('.table', this.table);
        this.settingsEdit.render();
        return this;
      };

      Index.prototype._destroy = function() {
        return this.table.destroy();
      };

      Index.prototype._editSettings = function() {
        return this.settingsEdit.open();
      };

      return Index;

    })(P.views.shared.HostPage);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.messages.mail', function(x) {
    return x.Edit = (function(_super) {

      __extends(Edit, _super);

      function Edit() {
        Edit.__super__.constructor.apply(this, arguments);
      }

      Edit.prototype.initialize = function() {
        Edit.__super__.initialize.apply(this, arguments);
        return this.form = new x.Form({
          parent: this,
          select: this.options.select
        });
      };

      Edit.prototype.open = function() {
        return Edit.__super__.open.apply(this, arguments);
      };

      Edit.prototype.use = function(collection) {
        this.collection = collection;
        this.form.use(collection);
        return this.form.edit(new P.models.messages.Mail());
      };

      Edit.prototype.render = function() {
        Edit.__super__.render.apply(this, arguments);
        this.append(this.form);
        return this;
      };

      return Edit;

    })(P.views.shared.Dialog);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.messages.mail', function(x) {
    return x.Form = (function(_super) {

      __extends(Form, _super);

      function Form() {
        this.render = __bind(this.render, this);
        this.setup = __bind(this.setup, this);
        this.selectOption = __bind(this.selectOption, this);
        this.use = __bind(this.use, this);
        this.formValues = __bind(this.formValues, this);
        this.initialize = __bind(this.initialize, this);
        Form.__super__.constructor.apply(this, arguments);
      }

      Form.prototype.templateName = 'host/messages/mail/_form';

      Form.prototype.features = [P.views.shared.forms.ErrorsFeature, P.views.shared.forms.FormValueGetFeature, P.views.shared.forms.FormValueSetFeature, P.views.shared.forms.FocusFeature];

      Form.prototype.initialize = function() {
        Form.__super__.initialize.apply(this, arguments);
        this.templateOptions.pages = P.community.mail_templates.pages;
        this.buttons = new P.views.shared.ControlBar({
          controls: ['save']
        });
        this.bind('edit', this.setup);
        return this.bind('saved', this.saved);
      };

      Form.prototype.formValues = function() {
        var values;
        values = this.getValues();
        _.extend(values, {
          user_ids: this.collection.map(function(user) {
            return user.id;
          })
        });
        return values;
      };

      Form.prototype.saved = function() {
        return this.parent.close();
      };

      Form.prototype.use = function(collection) {
        return this.collection = collection;
      };

      Form.prototype.selectOption = function(name) {
        this.$('#mail_template_id option:selected').removeAttr('selected');
        return this.$("#mail_template_id option:contains(\"" + name + "\")").prop('selected', true);
      };

      Form.prototype.setup = function() {
        this.bindErrors();
        this.$('.selected-count').html(this.collection.length);
        if (this.options.select != null) {
          return this.selectOption(this.options.select);
        }
      };

      Form.prototype.render = function() {
        Form.__super__.render.apply(this, arguments);
        return this;
      };

      return Form;

    })(P.views.shared.forms.Form);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.organizations', function(x) {
    return x.Table = (function(_super) {

      __extends(Table, _super);

      function Table() {
        this.columns = __bind(this.columns, this);        this.collection = new P.models.Organizations();
        Table.__super__.constructor.apply(this, arguments);
      }

      Table.prototype.columns = function() {
        return {
          name: {
            title: 'Name',
            width: '130px',
            features: ['sortable', 'filterable'],
            filter_type: 'string'
          },
          updated_at: {
            title: 'Last Updated',
            width: '130px',
            features: ['sortable', 'filterable'],
            filter_type: 'string'
          }
        };
      };

      Table.prototype.wildcardColumns = ['name'];

      Table.prototype.className = function() {
        return "" + Table.__super__.className.apply(this, arguments) + " organizations-table";
      };

      Table.prototype.rowConstructor = P.views.shared.tables.NavRow;

      return Table;

    })(P.views.shared.tables.ServerSideTable);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.organizations', function(x) {
    return x.Edit = (function(_super) {

      __extends(Edit, _super);

      function Edit() {
        Edit.__super__.constructor.apply(this, arguments);
      }

      Edit.prototype.templateName = 'organizations/edit';

      Edit.prototype.returnUrl = '#organizations';

      Edit.prototype.formType = function() {
        return P.views.organizations.Form;
      };

      return Edit;

    })(P.views.host.groups.EditPage);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.organizations', function(x) {
    return x.Index = (function(_super) {

      __extends(Index, _super);

      Index.prototype.className = '';

      Index.prototype.templateName = 'host/organizations/index';

      Index.prototype.events = function() {
        return _.extend(Index.__super__.events.apply(this, arguments), {
          'click button.destroy': '_destroy',
          'click button.message': '_message'
        });
      };

      function Index() {
        this.render = __bind(this.render, this);        Index.__super__.constructor.apply(this, arguments);
        this.table = new x.Table({
          parent: this
        });
        this.mail = new P.views.host.messages.mail.Edit({
          parent: this,
          select: 'organizations/invite_admins'
        });
      }

      Index.prototype.render = function() {
        Index.__super__.render.apply(this, arguments);
        this.replaceWith('.table', this.table);
        this.mail.render();
        return this;
      };

      Index.prototype._destroy = function() {
        return this.table.destroy();
      };

      Index.prototype._message = function() {
        var membershipCollections,
          _this = this;
        membershipCollections = _.map(this.table.selected().models, function(org) {
          return org.memberships;
        });
        return P.router.load(membershipCollections).done(function() {
          var users;
          users = _.flatten(_.map(_this.table.selected().models, function(org) {
            return org.adminUsers();
          }));
          if (users.length === 0) {
            _this.flash.show({
              message: 'The selected organizations have no admins.',
              "class": 'warn'
            }, 'Oops!');
            throw new Error('No users selected error.');
          }
          _this.mail.use(new P.models.Users(users));
          return _this.mail.open();
        });
      };

      return Index;

    })(P.views.shared.HostPage);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.questions', function(x) {
    return x.Form = (function(_super) {

      __extends(Form, _super);

      function Form() {
        this.setup = __bind(this.setup, this);
        Form.__super__.constructor.apply(this, arguments);
      }

      Form.prototype.initialize = function() {
        Form.__super__.initialize.apply(this, arguments);
        this.bind('saved', this.saved);
        return this.bind('edit', this.setup);
      };

      Form.prototype.className = function() {
        return "" + Form.__super__.className.apply(this, arguments) + " questions-form";
      };

      Form.prototype.templateName = 'questions/_form';

      Form.prototype.features = [P.views.shared.forms.ErrorsFeature, P.views.shared.forms.FormValueSetFeature, P.views.shared.forms.FormValueGetFeature];

      Form.prototype.formValues = function() {
        return _.extend(this.getValues(), {
          active: this.$('[name="question[active]"]').is(':checked')
        });
      };

      Form.prototype.setup = function() {
        return this.setValues();
      };

      Form.prototype.saved = function(model) {
        return P.layout.flash.show({
          message: 'Question saved!'
        });
      };

      return Form;

    })(P.views.shared.forms.Form);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.questions', function(x) {
    return x.Table = (function(_super) {

      __extends(Table, _super);

      function Table() {
        this.collection = new P.models.Questions();
        Table.__super__.constructor.apply(this, arguments);
      }

      Table.prototype.columns = {
        question: {
          width: '130px',
          sortable: true,
          type: 'string'
        },
        active: {
          width: '130px',
          sortable: true,
          type: 'string'
        }
      };

      Table.prototype.wildcardColumns = ['name'];

      Table.prototype.className = function() {
        return "" + Table.__super__.className.apply(this, arguments) + " questions-table";
      };

      Table.prototype.rowConstructor = P.views.shared.tables.NavRow;

      return Table;

    })(P.views.shared.tables.ServerSideTable);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.questions', function(x) {
    return x.Edit = (function(_super) {

      __extends(Edit, _super);

      function Edit() {
        this._redirect = __bind(this._redirect, this);        Edit.__super__.constructor.apply(this, arguments);
        this.form = new P.views.host.questions.Form({
          parent: this
        }).bind('saved', this._redirect);
      }

      Edit.prototype.destroy = function() {
        Edit.__super__.destroy.apply(this, arguments);
        return this.form.unbind('saved', this._redirect);
      };

      Edit.prototype.render = function() {
        Edit.__super__.render.apply(this, arguments);
        this.append(this.form);
        this.form.edit(this.model);
        return this;
      };

      Edit.prototype._redirect = function() {
        return P.router.redirectTo('#questions');
      };

      return Edit;

    })(P.views.shared.HostPage);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.questions', function(x) {
    return x.Index = (function(_super) {

      __extends(Index, _super);

      function Index() {
        this.render = __bind(this.render, this);
        Index.__super__.constructor.apply(this, arguments);
      }

      Index.prototype.id = 'questions-index';

      Index.prototype.tableConstructor = x.Table;

      Index.prototype.templateName = 'host/questions/index';

      Index.prototype.render = function() {
        Index.__super__.render.apply(this, arguments);
        this.replaceWith('.table', this.table);
        return this;
      };

      return Index;

    })(P.views.shared.Table);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.reports', function(x) {
    return x.Overview = (function(_super) {

      __extends(Overview, _super);

      Overview.prototype.title = 'Reports';

      function Overview() {
        Overview.__super__.constructor.apply(this, arguments);
        this.chart = new P.models.tracking.Chart();
      }

      Overview.prototype.render = function() {
        Overview.__super__.render.apply(this, arguments);
        this.chart.line(this.el);
        return this;
      };

      return Overview;

    })(P.views.shared.HostPage);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.templates', function(x) {
    return x.Table = (function(_super) {

      __extends(Table, _super);

      function Table() {
        Table.__super__.constructor.apply(this, arguments);
      }

      Table.prototype.columns = {
        name: {
          width: '130px',
          features: ['sortable', 'searchable', 'filterable'],
          filter_type: 'string'
        },
        subject: {
          features: ['sortable', 'searchable', 'filterable'],
          filter_type: 'string'
        },
        role: {
          features: [],
          filter_type: 'string'
        }
      };

      Table.prototype.wildcardColumns = ['name', 'subject'];

      Table.prototype.className = function() {
        return "" + Table.__super__.className.apply(this, arguments) + " templates";
      };

      Table.prototype.rowConstructor = P.views.shared.tables.NavRow;

      return Table;

    })(P.views.shared.tables.ServerSideTable);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.templates', function(x) {
    return x.Edit = (function(_super) {

      __extends(Edit, _super);

      function Edit() {
        this._redirect = __bind(this._redirect, this);
        Edit.__super__.constructor.apply(this, arguments);
      }

      Edit.prototype.formType = function() {
        return P.views.templates.Form;
      };

      Edit.prototype.initialize = function() {
        Edit.__super__.initialize.apply(this, arguments);
        return this.form = new (this.formType())({
          markItUpSet: this.markItUpSet
        }).bind('saved', this._redirect);
      };

      Edit.prototype.destroy = function() {
        Edit.__super__.destroy.apply(this, arguments);
        return this.form.unbind('saved', this._redirect);
      };

      Edit.prototype.render = function() {
        Edit.__super__.render.apply(this, arguments);
        this.append(this.form);
        this.form.edit(this.model);
        return this;
      };

      Edit.prototype._redirect = function() {
        return P.router.redirectTo(this.returnUrl);
      };

      return Edit;

    })(P.views.shared.HostPage);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.templates', function(x) {
    return x.Index = (function(_super) {

      __extends(Index, _super);

      function Index() {
        Index.__super__.constructor.apply(this, arguments);
      }

      Index.prototype.title = 'Templates';

      Index.prototype["with"] = {};

      Index.prototype.initialize = function() {
        Index.__super__.initialize.apply(this, arguments);
        this.collection = new P.models.Templates([], {
          searchOptions: {
            "with": this["with"]
          }
        });
        this.collection.modelClasses = ["Templates::Template"];
        return this.table = new x.Table({
          parent: this,
          collection: this.collection
        });
      };

      Index.prototype.render = function() {
        Index.__super__.render.apply(this, arguments);
        this.replaceWith('.table', this.table);
        return this;
      };

      return Index;

    })(P.views.shared.HostPage);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.templates.jst', function(x) {
    return x.Edit = (function(_super) {
      var _ref;

      __extends(Edit, _super);

      function Edit() {
        Edit.__super__.constructor.apply(this, arguments);
      }

      Edit.prototype.formType = function() {
        return P.views.templates.jst.Form;
      };

      Edit.prototype.markItUpSet = ((_ref = $.markItUp) != null ? _ref.htmlSettings : void 0) || {};

      Edit.prototype.templateName = 'host/templates/jst/edit';

      Edit.prototype.returnUrl = '#templates/jst';

      return Edit;

    })(P.views.host.templates.Edit);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.templates.jst', function(x) {
    return x.Index = (function(_super) {
      var _ref;

      __extends(Index, _super);

      function Index() {
        Index.__super__.constructor.apply(this, arguments);
      }

      Index.prototype["with"] = {
        type: 'Templates::Jst'
      };

      Index.prototype.markItUpSet = ((_ref = $.markItUp) != null ? _ref.htmlSettings : void 0) || {};

      Index.prototype.templateName = 'host/templates/jst/index';

      Index.prototype.events = function() {
        return _.extend(Index.__super__.events.apply(this, arguments), {
          'click button.destroy': 'destroy'
        });
      };

      Index.prototype.destroy = function() {
        return this.table.destroy();
      };

      return Index;

    })(P.views.host.templates.Index);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.templates.mail', function(x) {
    return x.Edit = (function(_super) {
      var _ref;

      __extends(Edit, _super);

      function Edit() {
        Edit.__super__.constructor.apply(this, arguments);
      }

      Edit.prototype.formType = function() {
        return P.views.templates.mail.Form;
      };

      Edit.prototype.markItUpSet = ((_ref = $.markItUp) != null ? _ref.htmlSettings : void 0) || {};

      Edit.prototype.templateName = 'host/templates/mail/edit';

      Edit.prototype.returnUrl = '#templates/mail';

      Edit.prototype.initialize = function() {
        var _this = this;
        Edit.__super__.initialize.apply(this, arguments);
        this.preview = new P.views.templates.Preview();
        this.tabs = new P.views.shared.tabs.Tabs({
          parent: this,
          tabs: [
            {
              label: 'Edit',
              selector: this.form.el
            }, {
              label: 'Preview',
              selector: this.preview.el
            }
          ]
        });
        return this.tabs.bind('activate', function(tab) {
          if (tab.label !== 'Preview') return;
          return _this.preview.preview(_this.model);
        });
      };

      Edit.prototype.render = function() {
        Edit.__super__.render.apply(this, arguments);
        this.replaceWith('.tabs', this.tabs);
        this.append(this.preview);
        return this;
      };

      return Edit;

    })(P.views.host.templates.Edit);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.templates.mail', function(x) {
    return x.Index = (function(_super) {
      var _ref;

      __extends(Index, _super);

      function Index() {
        Index.__super__.constructor.apply(this, arguments);
      }

      Index.prototype["with"] = {
        type: 'Templates::Mail'
      };

      Index.prototype.markItUpSet = ((_ref = $.markItUp) != null ? _ref.htmlSettings : void 0) || {};

      Index.prototype.templateName = 'host/templates/mail/index';

      Index.prototype.events = function() {
        return _.extend(Index.__super__.events.apply(this, arguments), {
          'click button.destroy': 'destroy'
        });
      };

      Index.prototype.destroy = function() {
        return this.table.destroy();
      };

      return Index;

    })(P.views.host.templates.Index);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.templates.scss', function(x) {
    return x.Edit = (function(_super) {
      var _ref;

      __extends(Edit, _super);

      function Edit() {
        Edit.__super__.constructor.apply(this, arguments);
      }

      Edit.prototype.markItUpSet = ((_ref = $.markItUp) != null ? _ref.cssSettings : void 0) || {};

      Edit.prototype.templateName = 'host/templates/scss/edit';

      Edit.prototype.returnUrl = '#templates/scss';

      return Edit;

    })(P.views.host.templates.Edit);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.host.templates.scss', function(x) {
    return x.Index = (function(_super) {
      var _ref;

      __extends(Index, _super);

      function Index() {
        Index.__super__.constructor.apply(this, arguments);
      }

      Index.prototype["with"] = {
        type: 'Templates::Scss'
      };

      Index.prototype.markItUpSet = ((_ref = $.markItUp) != null ? _ref.cssSettings : void 0) || {};

      Index.prototype.templateName = 'host/templates/scss/index';

      return Index;

    })(P.views.host.templates.Index);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.labels', function(x) {
    return x.Form = (function(_super) {

      __extends(Form, _super);

      function Form() {
        this.render = __bind(this.render, this);
        this.use = __bind(this.use, this);
        this.getID = __bind(this.getID, this);
        this.initialize = __bind(this.initialize, this);
        Form.__super__.constructor.apply(this, arguments);
      }

      Form.prototype.templateName = 'labels/_form';

      Form.prototype.className = 'label';

      Form.prototype.initialize = function() {
        Form.__super__.initialize.apply(this, arguments);
        return this.model || (this.model = new P.models.Label());
      };

      Form.prototype.getID = function() {
        return this.$('.label select').val();
      };

      Form.prototype.use = function(label) {
        var _ref;
        this.model = label;
        return this.$('.label select').val((_ref = this.model) != null ? _ref.id : void 0);
      };

      Form.prototype.render = function() {
        Form.__super__.render.apply(this, arguments);
        return this;
      };

      return Form;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.labels', function(x) {
    return x.Label = (function(_super) {

      __extends(Label, _super);

      function Label() {
        this.render = __bind(this.render, this);
        Label.__super__.constructor.apply(this, arguments);
      }

      Label.prototype.templateName = 'labels/_label';

      Label.prototype.className = function() {
        return "" + Label.__super__.className.apply(this, arguments) + " label";
      };

      Label.prototype.render = function() {
        Label.__super__.render.apply(this, arguments);
        return this;
      };

      return Label;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.layouts', function(x) {
    return x.Announcements = (function(_super) {

      __extends(Announcements, _super);

      Announcements.prototype.events = function() {
        return _.extend(Announcements.__super__.events.apply(this, arguments), {
          'click .flash-message': 'hide'
        });
      };

      function Announcements() {
        this.hide = __bind(this.hide, this);
        this.refresh = __bind(this.refresh, this);        Announcements.__super__.constructor.apply(this, arguments);
        this.collection = P.announcements;
        this.collection.bind('reset', this.refresh);
        this._reset();
      }

      Announcements.prototype.refresh = function(e) {
        if (!this._isFresh()) {
          this._reset();
          return this.announce();
        }
      };

      Announcements.prototype.announce = function() {
        if (this.collection.isHidden() || _.isEmpty(this.latest)) {
          this.clear();
          return;
        }
        return this.show({
          message: this.latest.get('message'),
          "class": 'warn'
        });
      };

      Announcements.prototype.render = function() {
        Announcements.__super__.render.apply(this, arguments);
        return this;
      };

      Announcements.prototype.hide = function() {
        Announcements.__super__.hide.apply(this, arguments);
        return this.collection.hide();
      };

      Announcements.prototype._reset = function() {
        this.collection.unhide();
        return this.latest = this.collection.last();
      };

      Announcements.prototype._isFresh = function() {
        var _ref;
        return this.latest && this.latest.get('id') === ((_ref = this.collection.last()) != null ? _ref.get('id') : void 0);
      };

      return Announcements;

    })(P.views.shared.Flash);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.layouts', function(x) {
    return x.Banner = (function(_super) {

      __extends(Banner, _super);

      function Banner() {
        Banner.__super__.constructor.apply(this, arguments);
      }

      Banner.prototype.templateName = 'layouts/_banner';

      Banner.prototype.initialize = function() {
        return Banner.__super__.initialize.apply(this, arguments);
      };

      Banner.prototype.render = function() {
        Banner.__super__.render.apply(this, arguments);
        return this;
      };

      return Banner;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.layouts', function(x) {
    return x.ContextSwitcher = (function(_super) {

      __extends(ContextSwitcher, _super);

      function ContextSwitcher() {
        this._switchContext = __bind(this._switchContext, this);
        ContextSwitcher.__super__.constructor.apply(this, arguments);
      }

      ContextSwitcher.prototype.templateName = 'layouts/_context_switcher';

      ContextSwitcher.prototype.events = function() {
        return _.extend(ContextSwitcher.__super__.events.apply(this, arguments), {
          'change select': '_switchContext'
        });
      };

      ContextSwitcher.prototype.render = function() {
        ContextSwitcher.__super__.render.apply(this, arguments);
        $(this.el).find("option[value='" + (P.community.get('domain')) + "']").attr('selected', true);
        return this;
      };

      ContextSwitcher.prototype._switchContext = function(e) {
        var domain;
        e.preventDefault();
        domain = $(this.el).find('option:selected').val();
        if (!!domain.indexOf(window.location.protocol)) {
          domain = "" + window.location.protocol + "//" + domain;
        }
        domain = "" + domain + this.options.path;
        return P.router.redirectTo(domain);
      };

      return ContextSwitcher;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.layouts', function(x) {
    return x.Flash = (function(_super) {

      __extends(Flash, _super);

      function Flash() {
        Flash.__super__.constructor.apply(this, arguments);
      }

      Flash.prototype.render = function() {
        return Flash.__super__.render.apply(this, arguments);
      };

      return Flash;

    })(P.views.shared.Flash);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.layouts', function(x) {
    return x.Footer = (function(_super) {

      __extends(Footer, _super);

      function Footer() {
        Footer.__super__.constructor.apply(this, arguments);
      }

      Footer.prototype.templateName = 'layouts/_footer';

      Footer.prototype.tagName = 'ul';

      Footer.prototype.render = function() {
        Footer.__super__.render.apply(this, arguments);
        return this;
      };

      return Footer;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.layouts', function(x) {
    return x.Navigation = (function(_super) {

      __extends(Navigation, _super);

      function Navigation() {
        this.close_dropdown = __bind(this.close_dropdown, this);
        this._dropdown = __bind(this._dropdown, this);
        this.showSignIn = __bind(this.showSignIn, this);
        this.signOut = __bind(this.signOut, this);
        this.loginout = __bind(this.loginout, this);
        Navigation.__super__.constructor.apply(this, arguments);
      }

      Navigation.prototype.templateName = 'layouts/_navigation';

      Navigation.prototype.tagName = 'ol';

      Navigation.prototype.events = function() {
        return _.extend(Navigation.__super__.events.apply(this, arguments), {
          'click .signIn': 'showSignIn',
          'click .signOut': 'signOut',
          'click a.dropdown_toggle': '_dropdown'
        });
      };

      Navigation.prototype.initialize = function() {
        Navigation.__super__.initialize.apply(this, arguments);
        this.edit = new P.views.sessions.Edit();
        return _.bindAll(this, 'close_dropdown');
      };

      Navigation.prototype.activate = function(id) {
        if (!id.match(/^\#/)) id = "\#" + id;
        $(this.el).find('li').removeClass('selected');
        return $(this.el).find("a[href=\"" + id + "\"]").parents('li').addClass('selected');
      };

      Navigation.prototype.render = function() {
        Navigation.__super__.render.apply(this, arguments);
        this.edit.render();
        if (P.community.isL10nEnabled()) this._renderLocaleSelector();
        return this;
      };

      Navigation.prototype.loginout = function(session, loggedIn) {
        Navigation.__super__.loginout.apply(this, arguments);
        this.$('.private-control').toggle(loggedIn || P.community.settings.get('public'));
        this.$('.authorized-control').toggle(loggedIn);
        this.$('.unauthorized-control').toggle(!loggedIn);
        this.$('.admin-control').toggle(loggedIn && session.user.hasRole('admin', P.community));
        if (loggedIn) {
          this.html(this.$('.friendly_name'), P.localizer.t('welcome_user', {
            name: session.user.get('first_name') || P.localizer.t('user')
          }));
          return this.html(this.$('.dropdown_toggle span.photo'), "<img src='" + (session.user.get('photo_url_cropped')) + "'>");
        }
      };

      Navigation.prototype.signOut = function(e) {
        e.preventDefault();
        P.session.signOut(function() {
          if (!P.community.settings.get('public')) {
            return P.router.redirectTo('#community/private');
          }
        });
        return this.render();
      };

      Navigation.prototype.showSignIn = function(e) {
        if (e != null) e.preventDefault();
        this.edit.open();
        return this.edit.center();
      };

      Navigation.prototype._dropdown = function(e) {
        e.preventDefault();
        $(e.currentTarget).parent("li").toggleClass('open');
        $(document).one('click', this.close_dropdown);
        return false;
      };

      Navigation.prototype.close_dropdown = function() {
        return $('li.dropdown').removeClass('open');
      };

      Navigation.prototype._renderLocaleSelector = function() {
        return new P.views.locales.Selector({
          el: this.$('.locales')
        }).render();
      };

      return Navigation;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.layouts', function(x) {
    return x.Application = (function(_super) {

      __extends(Application, _super);

      function Application() {
        var _this = this;
        Application.__super__.constructor.apply(this, arguments);
        this.discussion = new P.views.discussions.discussions.Edit();
        this.navigation = new P.views.layouts.Navigation();
        this.banner = new P.views.layouts.Banner();
        this.flash = new x.Flash();
        this.announcements = new x.Announcements();
        this.spinner = new P.views.shared.Spinner();
        this.footer = new P.views.layouts.Footer();
        this.router = this.options.router;
        this.router.bind('loading', function() {
          var _ref;
          if ((_ref = _this.router.visible) != null) _ref.$el.hide();
          return $('#loading').show();
        });
        this.router.bind('load', function() {
          return $('#loading').hide();
        });
        this.router.bind('route', function() {
          return $('#loading').hide();
        });
      }

      Application.prototype.render = function() {
        Application.__super__.render.apply(this, arguments);
        this.discussion.render();
        this.html('#navigation', this.navigation);
        this.html('.footer', this.footer);
        this.html('#flash', this.flash);
        this.html('#announcements', this.announcements);
        this.html('#banner', this.banner);
        this.append('#navigation', this.spinner);
        this.announcements.announce();
        return this;
      };

      return Application;

    })(P.views.shared.View);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.links', function(x) {
    return x.FormPart = (function(_super) {

      __extends(FormPart, _super);

      function FormPart() {
        this.use = __bind(this.use, this);
        this.setLinks = __bind(this.setLinks, this);
        FormPart.__super__.constructor.apply(this, arguments);
      }

      FormPart.prototype.templateName = 'links/_form_part';

      FormPart.prototype.initialize = function() {
        var _base, _base2, _base3;
        FormPart.__super__.initialize.apply(this, arguments);
        this.collection || (this.collection = new P.models.Links());
        (_base = this.templateOptions).field_id || (_base.field_id = null);
        (_base2 = this.templateOptions).hint || (_base2.hint = null);
        return (_base3 = this.templateOptions).label || (_base3.label = null);
      };

      FormPart.prototype.setLinks = function() {
        var links,
          _this = this;
        if (this.collection == null) return;
        links = this.collection.map(function(l) {
          return (l.get('url') || '').replace(_this.options.urlPrefix, '');
        });
        return this.$('input').val(links.join(', '));
      };

      FormPart.prototype.getLinks = function() {
        var links,
          _this = this;
        links = _.compact(_.map(this.$('input').val().split(/[\s,\,]/), function(s) {
          return $.trim(s);
        }));
        if (this.options.urlPrefix != null) {
          links = _.map(links, function(link) {
            if (link.search(_this.options.urlPrefix) > -1) {
              return link;
            } else {
              return "" + _this.options.urlPrefix + link;
            }
          });
        }
        return links;
      };

      FormPart.prototype.use = function(collection) {
        this.collection = collection;
        return this.setLinks();
      };

      FormPart.prototype.render = function() {
        FormPart.__super__.render.apply(this, arguments);
        this.setLinks();
        return this;
      };

      return FormPart;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.links', function(x) {
    return x.Link = (function(_super) {

      __extends(Link, _super);

      function Link() {
        this.render = __bind(this.render, this);
        Link.__super__.constructor.apply(this, arguments);
      }

      Link.prototype.render = function() {
        Link.__super__.render.apply(this, arguments);
        $(this.el).html(JST['links/_link']({
          link: this.model,
          options: this.templateOptions
        }));
        return this;
      };

      return Link;

    })(P.views.shared.View);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.links', function(x) {
    return x.List = (function(_super) {

      __extends(List, _super);

      function List() {
        List.__super__.constructor.apply(this, arguments);
      }

      List.prototype.className = function() {
        return "" + List.__super__.className.apply(this, arguments) + " links with_hover";
      };

      List.prototype.itemType = x.Link;

      return List;

    })(P.views.shared.lists.TitledList);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.locales', function(x) {
    return x.Selector = (function(_super) {

      __extends(Selector, _super);

      function Selector() {
        this._switchLocale = __bind(this._switchLocale, this);
        this._toggleDropdown = __bind(this._toggleDropdown, this);
        Selector.__super__.constructor.apply(this, arguments);
      }

      Selector.prototype.events = function() {
        return _.extend(Selector.__super__.events.apply(this, arguments), {
          'click a.locale': '_switchLocale',
          'click a.dropdown_toggle': '_toggleDropdown'
        });
      };

      Selector.prototype.render = function() {
        Selector.__super__.render.apply(this, arguments);
        this._setLocale();
        this._renderAvailableLocales();
        return this;
      };

      Selector.prototype._setLocale = function() {
        return this.$('.dropdown_toggle').text("[" + P.community.locales.locale + "]");
      };

      Selector.prototype._renderAvailableLocales = function() {
        var _this = this;
        return _.each(_.keys(P.community.locales.translations), function(code) {
          return _this.$('.dropdown_menu').append(_this.make('li', {}, _this.make('a', {
            'class': 'locale',
            'title': code
          }, _this._localeNameMaps[code])));
        });
      };

      Selector.prototype._toggleDropdown = function(e) {
        if (e != null) e.preventDefault();
        return this.$('.dropdown_menu').toggle();
      };

      Selector.prototype._switchLocale = function(e) {
        var href, selected;
        e.preventDefault();
        selected = $(e.currentTarget).attr('title');
        if (P.community.locales.locale !== selected) {
          href = '/';
          if (selected !== P.community.settings.get('default_locale')) {
            href += selected;
          }
          href += window.location.hash;
          return window.location.href = href;
        } else {
          return this._toggleDropdown();
        }
      };

      Selector.prototype._localeNameMaps = {
        'en': 'English',
        'fr': 'French',
        'ko': 'Korean',
        'pt': 'Portuguese'
      };

      return Selector;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.locales', function(x) {
    x.Localizer = (function(_super) {

      __extends(Localizer, _super);

      function Localizer() {
        Localizer.__super__.constructor.apply(this, arguments);
      }

      Localizer.prototype.initialize = function() {
        return this.locales = this.model;
      };

      Localizer.prototype.render = function() {
        this.templateName = "translations/_" + this.locales.locale;
        Localizer.__super__.render.apply(this, arguments);
        return this;
      };

      return Localizer;

    })(P.views.shared.Component);
    return _.each('translate t'.split(/\s+/), function(method) {
      return x.Localizer.prototype[method] = function() {
        var _ref;
        return (_ref = this.locales)[method].apply(_ref, arguments);
      };
    });
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.locations', function(x) {
    return x.Form = (function(_super) {

      __extends(Form, _super);

      function Form() {
        this.render = __bind(this.render, this);
        this.selectID = __bind(this.selectID, this);
        this.use = __bind(this.use, this);
        this.getName = __bind(this.getName, this);
        this.getID = __bind(this.getID, this);
        this.initialize = __bind(this.initialize, this);
        Form.__super__.constructor.apply(this, arguments);
      }

      Form.prototype.templateName = 'locations/_form';

      Form.prototype.className = 'location';

      Form.prototype.initialize = function() {
        Form.__super__.initialize.apply(this, arguments);
        this.model || (this.model = new P.models.Location());
        this.templateOptions.restrict = this.options.restrictToReservable;
        this.collection.bind('reset', this.render);
        return this.collection.bind('add', this.render);
      };

      Form.prototype.getID = function() {
        return this.$('.location select').val();
      };

      Form.prototype.getName = function() {
        return this.$('.name input').val();
      };

      Form.prototype.use = function(location) {
        var _ref, _ref2;
        this.model = location;
        this.$('.location select').val((_ref = this.model) != null ? _ref.id : void 0);
        return this.$('.name input').val((_ref2 = this.model) != null ? _ref2.get('name') : void 0);
      };

      Form.prototype.selectID = function(id) {
        return this.$('.location select').val(id);
      };

      Form.prototype.render = function() {
        Form.__super__.render.apply(this, arguments);
        this.use(this.model);
        return this;
      };

      return Form;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.meetings', function(x) {
    return x.Card = (function(_super) {

      __extends(Card, _super);

      function Card() {
        this._modelUpdated = __bind(this._modelUpdated, this);
        this._updateMembership = __bind(this._updateMembership, this);
        this._remove = __bind(this._remove, this);
        this._add = __bind(this._add, this);
        this._toggle = __bind(this._toggle, this);
        this.render = __bind(this.render, this);
        Card.__super__.constructor.apply(this, arguments);
      }

      Card.prototype.className = function() {
        return "" + Card.__super__.className.apply(this, arguments) + " meeting card";
      };

      Card.prototype.templateName = 'meetings/_card';

      Card.prototype.initialize = function() {
        var _this = this;
        Card.__super__.initialize.apply(this, arguments);
        _.defaults(this.options, {
          expandable: true,
          speakers: true
        });
        this.labels = new Backbone.List({
          itemType: x.Label,
          addClass: 'labels',
          collection: this.model.labels
        });
        _.each(['add', 'remove', 'reset'], function(event) {
          return _this.model.memberships.bind(event, _this._updateMembership);
        });
        return this.model.bind('change', this._modelUpdated);
      };

      Card.prototype.events = function() {
        return _.extend(Card.__super__.events.apply(this, arguments), {
          'click button.add': '_add',
          'click button.remove': '_remove',
          'click': this.options.expandable ? '_toggle' : void 0
        });
      };

      Card.prototype.render = function() {
        Card.__super__.render.apply(this, arguments);
        this.replaceWith('.labels', this.labels);
        if (this.options.speakers) {
          this.html('.speaker_names', this.model.speakers.pluck('full_name').join(', '));
          this.replaceWith('.speakers', new Backbone.List({
            addClass: 'users users-small',
            itemType: P.views.users.SmallCard,
            itemOptions: function(model) {
              return {
                model: model.user
              };
            },
            collection: this.model.speakers
          }));
        }
        if (this.options.expandable) {
          this.$('> .extra').hide();
        } else {
          this.$('.control_bar').hide();
          this.$(this.el).addClass('no_shadow');
        }
        if (this.model.get('private')) {
          $(this.el).addClass('private');
          this.$('.control_bar').hide();
        }
        if (this.model.labels.length) {
          this.$('> .stripe').css({
            "background-color": this.model.labels.first().get('color')
          });
        }
        if (this.model.get('unschedulable')) this.$('.control_bar').hide();
        this._modelUpdated();
        return this;
      };

      Card.prototype.loginout = function(session, loggedIn) {
        Card.__super__.loginout.apply(this, arguments);
        this.$('.control_bar').toggle(loggedIn);
        return this._updateMembership();
      };

      Card.prototype._toggle = function(e) {
        if ($(e.target).closest('a,button', this.el).length) return;
        this.$('> .extra').slideToggle();
        return $(this.el).toggleClass('open');
      };

      Card.prototype._add = function(e) {
        (new P.models.Attendance({
          user_id: P.user.id,
          group_id: this.model.id
        })).save();
        return this.model.trigger('attended', this.model);
      };

      Card.prototype._remove = function(e) {
        var _ref,
          _this = this;
        if (this.model.users.get(P.user) != null) {
          if ((_ref = P.user.memberships.find(function(m) {
            return m.get('group_id') === _this.model.id;
          })) != null) {
            _ref.destroy();
          }
          return this.model.trigger('unattended', this.model);
        }
      };

      Card.prototype._updateMembership = function() {
        var member;
        member = this.model.users.get(P.user);
        $(this.el).toggleClass('attending', !!member);
        if (this.model.get('mandatory')) return;
        this.$('button.remove').toggleClass('hidden', !member);
        return this.$('button.add').toggleClass('hidden', !!member);
      };

      Card.prototype._modelUpdated = function() {
        var mandatory;
        mandatory = this.model.get('mandatory');
        if (mandatory) {
          this.$('button.remove').toggleClass('hidden', true);
          this.$('button.add').toggleClass('hidden', true);
          return this.$('.mandatory').toggleClass('hidden', false);
        } else {
          this.$('.mandatory').toggleClass('hidden', true);
          return this._updateMembership();
        }
      };

      return Card;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.meetings', function(x) {
    return x.Edit = (function(_super) {

      __extends(Edit, _super);

      function Edit() {
        Edit.__super__.constructor.apply(this, arguments);
        this.form = new x.Form({
          parent: this
        });
      }

      Edit.prototype.open = function(model) {
        if (model == null) {
          model = this.collection.build({
            private: this.collection.privateOnly()
          });
        }
        return Edit.__super__.open.call(this, model);
      };

      return Edit;

    })(P.views.groups.Edit);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.meetings', function(x) {
    return x.Form = (function(_super) {

      __extends(Form, _super);

      function Form() {
        var _this = this;
        Form.__super__.constructor.apply(this, arguments);
        this.textEditor.addHtmlControl();
        this.date = new P.views.shared.DatePicker();
        this.endTime = new P.views.shared.TimePicker();
        this.startTime = new P.views.shared.TimePicker({
          "with": this.endTime
        });
        this.autoSuggest = new P.views.shared.auto_suggest.AutoSuggest({
          disableFreeForm: true,
          searchOptions: {
            classes: ['User']
          },
          valueTransformer: function(value) {
            if (!(value instanceof P.models.User)) return;
            return new P.models.Attendance({
              user: value,
              group: _this.model
            });
          }
        });
        this.attendees = this.autoSuggest.collection;
        this.removedAttendees = new P.models.Collection;
        this.attendees.bind('remove', function(attendee) {
          return _this.removedAttendees.add(attendee);
        });
        this.defaults = {
          date: new Date(P.community.starts_at),
          startsAt: new Date(0, 0, 0, 5, 0, 0),
          endsAt: new Date(0, 0, 0, 6, 0, 0)
        };
      }

      Form.prototype.templateName = 'meetings/_form';

      Form.prototype.namespace = 'meeting';

      Form.prototype.formValues = function() {
        var attrs, organizer, ribbon;
        this.model.set({
          starts_at: this.mergeDateAndTime(this.date.getDate(), this.startTime.getTime()),
          ends_at: this.mergeDateAndTime(this.date.getDate(), this.endTime.getTime())
        });
        attrs = _.extend(Form.__super__.formValues.apply(this, arguments), {
          starts_at: this.model.get('starts_at'),
          ends_at: this.model.get('ends_at'),
          time_zone_offset: moment(this.model.get('starts_at_local')).zone() * 60,
          label_ids: _.map(this.$('select.label_id'), function(select) {
            return $(select).val();
          })
        });
        if (!this.model.get('private')) {
          ribbon = P.community.ribbons.speaker();
          attrs.unschedulable = this.$('[name=meeting\\[unschedulable\\]]').is(':checked');
          attrs.mandatory = this.$('[name=meeting\\[mandatory\\]]').is(':checked');
        }
        attrs.attendances_attributes = this.attendees.map(function(model) {
          return {
            id: model.id,
            user_id: model.user.id,
            ribbon_id: ribbon != null ? ribbon.id : void 0
          };
        }).concat(this.removedAttendees.map(function(model) {
          return {
            id: model.id,
            _destroy: 1
          };
        }));
        if (organizer = _.first(attrs.attendances_attributes)) {
          organizer.roles = 'organizer';
          organizer.status = 'accepted';
        }
        return attrs;
      };

      Form.prototype.setup = function() {
        var _this = this;
        Form.__super__.setup.apply(this, arguments);
        this.attendees.reset(this.model.memberships.models);
        this.model.memberships.bind('reset', function() {
          var memberships;
          memberships = _this.model.memberships;
          _this.attendees.reset([]);
          return _this.attendees.add((_this.model.get('private') ? memberships : memberships.speakers()).toArray());
        });
        this.date.setDate(new Date(this.model.get('starts_at_local')) || this.defaults.date);
        this.startTime.setTime(new Date(this.model.get('starts_at_local')) || this.defaults.startsAt);
        this.endTime.setTime(new Date(this.model.get('ends_at_local')) || this.defaults.endsAt);
        if (this.model.labels) {
          return this.model.labels.each(function(label) {
            return _this.$("select." + (label.label_set.class_id())).val(label.id);
          });
        }
      };

      Form.prototype.saved = function() {
        Form.__super__.saved.apply(this, arguments);
        return P.layout.flash.show({
          message: P.localizer.t('meeting_updated')
        });
      };

      Form.prototype.render = function() {
        Form.__super__.render.apply(this, arguments);
        this.replaceWith('.speakers input', this.autoSuggest);
        this.replaceAll('.date input', this.date);
        this.replaceAll('.start-time input', this.startTime);
        this.replaceAll('.end-time input', this.endTime);
        return this;
      };

      Form.prototype.mergeDateAndTime = function(date, time) {
        if (!((date != null) && (time != null))) return;
        time = moment(new Date(time));
        return moment(new Date(date)).minutes(time.minutes()).hours(time.hours())["native"]();
      };

      return Form;

    })(P.views.groups.Form);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.meetings', function(x) {
    return x.Label = (function(_super) {

      __extends(Label, _super);

      function Label() {
        this.render = __bind(this.render, this);
        Label.__super__.constructor.apply(this, arguments);
      }

      Label.prototype.tagName = 'a';

      Label.prototype.templateName = 'meetings/_label';

      Label.prototype.render = function() {
        Label.__super__.render.apply(this, arguments);
        $(this.el).attr({
          "class": this.model.get('class_name'),
          href: '#meetings' + (this.model.id ? "/label/" + this.model.id : '')
        });
        return this;
      };

      return Label;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.meetings', function(x) {
    return x.List = (function(_super) {

      __extends(List, _super);

      function List() {
        List.__super__.constructor.apply(this, arguments);
      }

      List.prototype.className = function() {
        return "" + List.__super__.className.apply(this, arguments) + " links";
      };

      List.prototype.itemType = x.Meeting;

      return List;

    })(P.views.shared.lists.TitledList);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.meetings', function(x) {
    return x.Navigation = (function(_super) {

      __extends(Navigation, _super);

      function Navigation() {
        this._modelUpdated = __bind(this._modelUpdated, this);
        this.render = __bind(this.render, this);
        Navigation.__super__.constructor.apply(this, arguments);
      }

      Navigation.prototype.templateName = 'meetings/_navigation';

      Navigation.prototype.initialize = function() {
        var scope;
        Navigation.__super__.initialize.apply(this, arguments);
        scope = this.model.get('private') ? P.views.meetings.private : P.views.meetings.public;
        this.edit = new scope.Edit({
          model: this.model
        });
        return this.model.bind('change', this._modelUpdated);
      };

      Navigation.prototype.render = function() {
        Navigation.__super__.render.apply(this, arguments);
        this._modelUpdated();
        return this;
      };

      Navigation.prototype._modelUpdated = function() {
        var mandatory;
        mandatory = this.model.get('mandatory');
        this.$('button.remove').toggleClass('hidden', mandatory);
        return this.$('button.add').toggleClass('hidden', mandatory);
      };

      return Navigation;

    })(P.views.groups.Navigation);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.meetings', function(x) {
    return x.Ribbon = (function(_super) {

      __extends(Ribbon, _super);

      function Ribbon() {
        this.render = __bind(this.render, this);
        this.initialize = __bind(this.initialize, this);
        Ribbon.__super__.constructor.apply(this, arguments);
      }

      Ribbon.prototype.initialize = function() {
        var _ref,
          _this = this;
        Ribbon.__super__.initialize.apply(this, arguments);
        this.users = new P.models.Users(this.options.group.memberships.filter(function(model) {
          return model.ribbon === _this.model;
        }).map(function(model) {
          return model.user;
        }));
        return this.list = new P.views.shared.lists.TitledList({
          addClass: 'two-col small users users-medium',
          itemType: P.views.users.Card,
          itemOptions: {
            showControls: true
          },
          title: (_ref = this.model.get('name')) != null ? _ref.pluralize() : void 0,
          collection: this.users,
          showCount: false
        });
      };

      Ribbon.prototype.render = function() {
        Ribbon.__super__.render.apply(this, arguments);
        this.append(this.list);
        return this;
      };

      return Ribbon;

    })(P.views.shared.View);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.meetings', function(x) {
    return x.EditPage = (function(_super) {

      __extends(EditPage, _super);

      function EditPage() {
        this._changeEndTime = __bind(this._changeEndTime, this);
        this._changeStartTime = __bind(this._changeStartTime, this);
        this._changeDate = __bind(this._changeDate, this);
        this._changeName = __bind(this._changeName, this);
        this._addUser = __bind(this._addUser, this);
        this.render = __bind(this.render, this);
        this.destroy = __bind(this.destroy, this);
        this.initialize = __bind(this.initialize, this);
        this.title = __bind(this.title, this);
        EditPage.__super__.constructor.apply(this, arguments);
      }

      EditPage.prototype.title = function() {
        var _ref;
        return ((_ref = this.model) != null ? _ref.get('name') : void 0) || 'New Meeting';
      };

      EditPage.prototype.templateName = 'meetings/edit';

      EditPage.prototype.className = function() {
        return "" + EditPage.__super__.className.apply(this, arguments) + " meetings edit";
      };

      EditPage.prototype.events = function() {
        return _.extend(EditPage.__super__.events.apply(this, arguments), {
          'change .meeting_name': '_changeName',
          'change .meeting_date': '_changeDate',
          'change .meeting_start_time': '_changeStartTime',
          'change .meeting_end_time': '_changeEndTime'
        });
      };

      EditPage.prototype.initialize = function() {
        var _this = this;
        EditPage.__super__.initialize.apply(this, arguments);
        this.collection = new P.models.Collection([this.model]);
        this.form = new P.views.meetings.private.Form();
        this.form.bind('saved', function() {
          return P.router.redirectTo('#meetings');
        });
        this.form.edit(this.model);
        _.extend(this.form.options, {
          hint: 'You are the organizer of this meeting.'
        });
        this.form.autoSuggest.options.fixed = 1;
        this.calendar = new P.views.shared.Calendar({
          selectable: true,
          slotMinutes: 15,
          select: function(start, end) {
            _this.model.set({
              starts_at_local: start.getTime(),
              ends_at_local: end.getTime()
            });
            return _this.calendar.unselect();
          }
        });
        this.model.bind('change:starts_at_local', function(model, val) {
          var _ref, _ref2, _ref3;
          if ((_ref = _this.meeting_date) != null) {
            _ref.val(moment(val).format('MM/DD/YYYY'));
          }
          if ((_ref2 = _this.meeting_start_time) != null) {
            _ref2.val(moment(val).format('hh:mm A'));
          }
          return (_ref3 = _this.calendar) != null ? _ref3.gotoDate(new Date(val)) : void 0;
        });
        this.model.bind('change:ends_at_local', function(model, val) {
          var _ref;
          return (_ref = _this.meeting_end_time) != null ? _ref.val(moment(val).format('hh:mm A')) : void 0;
        });
        this.model.bind('change:name', function(model, val) {
          var _ref;
          return (_ref = _this.meeting_name) != null ? _ref.val(val) : void 0;
        });
        this.model.bind('change', function() {
          if (!_.any('name starts_at_local ends_at_local'.split(/\s+/), function(s) {
            return _this.model.hasChanged(s);
          })) {
            return;
          }
          return _this.form._fetchLocations();
        });
        this.model.users.each(this._addUser);
        this.form.attendees.bind('add', function(attendance) {
          return _this.model.memberships.add(attendance);
        });
        this.form.attendees.bind('remove', function(attendance) {
          return _this.model.memberships.remove(_this.model.memberships["for"](attendance.user));
        });
        this.model.users.bind('add', function(model) {
          _this._addUser(model);
          return model.fetch();
        });
        return this.model.users.bind('remove', function(model) {
          return _this.calendar.remove(user.meetings);
        });
      };

      EditPage.prototype.destroy = function() {
        var _ref;
        return (_ref = this.calendar) != null ? _ref.destroy() : void 0;
      };

      EditPage.prototype.render = function() {
        EditPage.__super__.render.apply(this, arguments);
        this.replaceWith('.sidebar .form', this.form);
        this.replaceWith('.main .calendar', this.calendar);
        this.calendar.refresh();
        this.meeting_date = this.$('.meeting_date');
        this.meeting_start_time = this.$('.meeting_start_time');
        this.meeting_end_time = this.$('.meeting_end_time');
        this.meeting_name = this.$('.meeting_name');
        this.model.set({
          name: 'Private Meeting',
          starts_at_local: moment(new Date(P.community.starts_at)).hours(12).minutes(0).seconds(0)["native"](),
          ends_at_local: moment(new Date(P.community.starts_at)).hours(13).minutes(0).seconds(0)["native"]()
        });
        this.calendar.add(this.collection, {
          color: 'green',
          editable: true
        });
        return this;
      };

      EditPage.prototype._addUser = function(user) {
        return this.calendar.add(user.meetings, user === P.user ? {
          color: 'blue'
        } : {
          color: 'red',
          title: 'BUSY'
        });
      };

      EditPage.prototype._changeName = function(e) {
        return this.model.set('name', $(e.target).val());
      };

      EditPage.prototype._changeDate = function(e) {
        var day,
          _this = this;
        day = moment(new Date($(e.target).val()));
        return _.each(['starts_at_local', 'ends_at_local'], function(attr) {
          return _this.model.set(attr, moment(_this.model.get(attr)).year(day.year()).month(day.month()).date(day.date())["native"]().getTime());
        });
      };

      EditPage.prototype._changeStartTime = function(e) {
        var time;
        time = moment($(e.target).val(), 'hh:mm A');
        return this.model.set('starts_at_local', moment(this.model.get('starts_at_local')).hours(time.hours()).minutes(time.minutes())["native"]().getTime());
      };

      EditPage.prototype._changeEndTime = function(e) {
        var time;
        time = moment($(e.target).val(), 'hh:mm A');
        return this.model.set('ends_at_local', moment(this.model.get('ends_at_local')).hours(time.hours()).minutes(time.minutes())["native"]().getTime());
      };

      return EditPage;

    })(P.views.shared.Page);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.meetings', function(x) {
    return x.Index = (function(_super) {

      __extends(Index, _super);

      function Index() {
        this.loginout = __bind(this.loginout, this);
        this.render = __bind(this.render, this);
        this.filter = __bind(this.filter, this);
        this.initialize = __bind(this.initialize, this);
        Index.__super__.constructor.apply(this, arguments);
      }

      Index.prototype.title = 'Schedule';

      Index.prototype.templateName = 'meetings/index';

      Index.prototype.className = function() {
        return "" + Index.__super__.className.apply(this, arguments) + " meetings index";
      };

      Index.prototype.initialize = function() {
        var _this = this;
        Index.__super__.initialize.apply(this, arguments);
        this.collection = this.collection.subset();
        this.tabs = new P.views.shared.lists.TabbedList({
          addClass: 'meetings',
          collection: this.collection.byDay(),
          label: function(model) {
            return moment(model.get('key')).format('ddd, MMM Do');
          },
          itemType: P.views.shared.lists.TitledList,
          itemOptions: function(model) {
            return {
              hideEmpty: false,
              addClass: 'day',
              title: {
                tagName: 'h2',
                title: moment(model.get('key')).format('ddd, MMM Do')
              },
              collection: model.collection.byTime(),
              itemType: P.views.shared.lists.TitledList,
              itemOptions: function(model) {
                return {
                  addClass: 'time',
                  title: {
                    tagName: 'time',
                    title: moment(model.get('key')).format('h:mm a')
                  },
                  collection: model.collection,
                  itemType: x.Card
                };
              }
            };
          }
        });
        this.labelSets = new Backbone.List({
          itemType: P.views.shared.lists.TitledList,
          addClass: 'label-set',
          itemOptions: function(model) {
            return {
              collection: model.labels,
              title: model.get('name'),
              selectable: true,
              multi: false,
              addClass: 'labels',
              itemType: x.Label
            };
          },
          collection: P.community.calendar.label_sets
        });
        return this.labelSets.bind('toggle', function(model, view, selected) {
          return $(view.el).toggleClass('highlight', selected);
        });
      };

      Index.prototype.filter = function(label) {
        var _this = this;
        this.$('.sidebar a.all').toggleClass('highlight', !label);
        _.each(this.labelSets.views, function(list) {
          if (list.findView(label) != null) return list.select(label);
          return list.unselect(list.list.selected);
        });
        return this.collection.trigger('filter', function(model) {
          if (label == null) return true;
          return model.hasLabel(+label);
        });
      };

      Index.prototype.render = function() {
        Index.__super__.render.apply(this, arguments);
        this.replaceWith('.meetings', this.tabs);
        this.replaceWith('.sidebar .labelSets', this.labelSets);
        if (!(P.community.calendar.label_sets.length > 0)) {
          this.$('.sidebar a.all').hide();
        }
        this.prepend(".meetings", "<h1 class='centered print'>" + (P.community.get('name')) + " Schedule</h1>");
        return this;
      };

      Index.prototype.loginout = function(session, loggedIn) {
        Index.__super__.loginout.apply(this, arguments);
        this.$('.schedule_buttonset').toggle(!!loggedIn);
        return this.$('.print_my_schedule').toggle(!!loggedIn);
      };

      return Index;

    })(P.views.shared.Page);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.meetings', function(x) {
    return x.My = (function(_super) {

      __extends(My, _super);

      function My() {
        this._toggleEmpty = __bind(this._toggleEmpty, this);
        My.__super__.constructor.apply(this, arguments);
      }

      My.prototype.templateName = 'meetings/my';

      My.prototype.initialize = function() {
        var _this = this;
        My.__super__.initialize.apply(this, arguments);
        return _.each(['add', 'remove', 'reset'], function(event) {
          return _this.collection.bind(event, _this._toggleEmpty);
        });
      };

      My.prototype.render = function() {
        My.__super__.render.apply(this, arguments);
        this._toggleEmpty();
        return this;
      };

      My.prototype._toggleEmpty = function() {
        this.$('.main > .empty').toggle(this.collection.isEmpty());
        this.$('a.print_schedule').toggle(!this.collection.isEmpty());
        return this.$('a.export').toggle(!this.collection.isEmpty());
      };

      return My;

    })(x.Index);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.meetings.private', function(x) {
    return x.Edit = (function(_super) {

      __extends(Edit, _super);

      function Edit() {
        this.render = __bind(this.render, this);        Edit.__super__.constructor.apply(this, arguments);
        this.form = new x.Form({
          parent: this
        });
      }

      Edit.prototype.render = function() {
        Edit.__super__.render.apply(this, arguments);
        return this;
      };

      return Edit;

    })(P.views.meetings.Edit);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.meetings.private', function(x) {
    return x.Form = (function(_super) {

      __extends(Form, _super);

      function Form() {
        this._fetchLocations = __bind(this._fetchLocations, this);        Form.__super__.constructor.apply(this, arguments);
        this.startTime.bind('change', this._fetchLocations);
        this.endTime.bind('change', this._fetchLocations);
        this.date.bind('change', this._fetchLocations);
        this.autoSuggest.collection.bind('add', this._fetchLocations);
        this.autoSuggest.collection.bind('remove', this._fetchLocations);
        this.location = new P.views.locations.Form({
          restrictToReservable: P.community.calendar.settings.get('restrict_locations_to_reserved'),
          collection: new P.models.Locations(P.community.locations.models, {
            searchOptions: {
              conditions: {
                'starts_at': null,
                'ends_at': null,
                'capacity': null
              }
            }
          })
        });
      }

      Form.prototype.templateName = 'meetings/_form';

      Form.prototype.namespace = 'meeting';

      Form.prototype._fetchLocations = function() {
        var ends_at, locationID, starts_at,
          _this = this;
        if (!P.community.calendar.settings.get('restrict_locations_to_reserved')) {
          return;
        }
        this.model.set({
          starts_at: this.mergeDateAndTime(this.date.getDate(), this.startTime.getTime()),
          ends_at: this.mergeDateAndTime(this.date.getDate(), this.endTime.getTime())
        });
        starts_at = this.model.get('starts_at');
        ends_at = this.model.get('ends_at');
        if (starts_at && ends_at) {
          locationID = this.location.getID() || this.model.get('location_id');
          this.location.collection.searchOptions.conditions.starts_at = starts_at;
          this.location.collection.searchOptions.conditions.ends_at = ends_at;
          this.location.collection.searchOptions.conditions.time_zone_offset = moment(this.model.get('starts_at_local')).zone() * 60;
          this.location.collection.searchOptions.conditions.capacity = this.autoSuggest.collection.length;
          this.location.collection.searchOptions.conditions.meeting_id = this.model.id;
          return this.location.collection.fetch({
            success: function() {
              if (locationID != null) {
                if (_this.$(".location select option[value=" + locationID + "]").length > 0) {
                  return _this.location.selectID(locationID);
                } else {
                  _this.clearFormErrors();
                  return _this.addFormError({
                    model: _this.model,
                    attribute: 'location',
                    messages: ["Previously selected location is not available for this time or number of people. Please select another."]
                  });
                }
              }
            }
          });
        }
      };

      Form.prototype.formValues = function() {
        var attrs;
        attrs = Form.__super__.formValues.apply(this, arguments);
        if (this.location.getID()) {
          attrs.location_id = this.location.getID();
          attrs.location_name = null;
        } else {
          attrs.location_id = null;
          attrs.location_name = this.location.getName();
        }
        return attrs;
      };

      Form.prototype.setup = function() {
        Form.__super__.setup.apply(this, arguments);
        if (this.model.get('location_name') != null) {
          this.model.location.set({
            name: this.model.get('location_name')
          });
        }
        this.location.use(this.model.location);
        return this._fetchLocations();
      };

      Form.prototype.render = function() {
        Form.__super__.render.apply(this, arguments);
        this.replaceWith('.location', this.location);
        return this;
      };

      return Form;

    })(P.views.meetings.Form);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.meetings.private', function(x) {
    return x.Navigation = (function(_super) {

      __extends(Navigation, _super);

      function Navigation() {
        this._showChangeControl = __bind(this._showChangeControl, this);
        this._showAcceptControl = __bind(this._showAcceptControl, this);
        this.setup = __bind(this.setup, this);
        this._statusWords = __bind(this._statusWords, this);
        this._status = __bind(this._status, this);
        this.render = __bind(this.render, this);
        this.change = __bind(this.change, this);
        this.respond = __bind(this.respond, this);
        this.loginout = __bind(this.loginout, this);
        Navigation.__super__.constructor.apply(this, arguments);
      }

      Navigation.prototype.templateName = 'meetings/private/_navigation';

      Navigation.prototype.events = function() {
        return _.extend(Navigation.__super__.events.apply(this, arguments), {
          'click .respond': 'respond',
          'click .status-status a': 'change'
        });
      };

      Navigation.prototype.initialize = function() {
        Navigation.__super__.initialize.apply(this, arguments);
        this.attendanceEdit = new P.views.attendances.Edit({
          parent: this
        });
        return this.model.bind('change', this.setup);
      };

      Navigation.prototype.loginout = function(session, loggedIn) {
        var _ref;
        Navigation.__super__.loginout.apply(this, arguments);
        this.$('button.edit').toggle(loggedIn && (_.include((_ref = this.model.memberships["for"](session.user)) != null ? _ref.get('roles') : void 0, 'organizer') || session.user.hasRole('admin')));
        if (loggedIn) {
          this.$el.show();
          return this.setup();
        } else {
          return this.$el.hide();
        }
      };

      Navigation.prototype.respond = function() {
        return this.attendanceEdit.open(this.model.memberships["for"](P.user));
      };

      Navigation.prototype.change = function(e) {
        e.preventDefault();
        this._showAcceptControl();
        return this.respond();
      };

      Navigation.prototype.render = function() {
        Navigation.__super__.render.apply(this, arguments);
        this.attendanceEdit.render();
        return this;
      };

      Navigation.prototype._status = function() {
        var _ref;
        return (_ref = this.model.memberships["for"](P.user)) != null ? _ref.get('status') : void 0;
      };

      Navigation.prototype._statusWords = function(status) {
        switch (status) {
          case 'accepted':
            return "You've accepted.";
          case 'tentative':
            return "You're tentative.";
          case 'declined':
            return "You've declined.";
          case 'unresponded':
            return "You've not responded.";
        }
      };

      Navigation.prototype.setup = function() {
        var status;
        status = this._status();
        if ((status != null) && status !== 'unresponded') {
          return this._showChangeControl(status);
        } else {
          return this._showAcceptControl();
        }
      };

      Navigation.prototype._showAcceptControl = function() {
        this.$('.status-status').hide();
        return this.$('button.respond').show();
      };

      Navigation.prototype._showChangeControl = function(status) {
        this.$('.current-status').text(this._statusWords(status));
        this.$('.status-status').show();
        return this.$('button.respond').hide();
      };

      return Navigation;

    })(P.views.meetings.Navigation);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.meetings.public', function(x) {
    return x.Edit = (function(_super) {

      __extends(Edit, _super);

      function Edit() {
        Edit.__super__.constructor.apply(this, arguments);
        this.form = new x.Form({
          parent: this
        });
      }

      return Edit;

    })(P.views.meetings.Edit);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.meetings.public', function(x) {
    return x.Form = (function(_super) {

      __extends(Form, _super);

      function Form() {
        Form.__super__.constructor.apply(this, arguments);
        this.location = new P.views.locations.Form({
          restrictToReservable: false,
          collection: new P.models.Locations(P.community.locations.models, {
            searchOptions: {
              conditions: {
                'starts_at': null,
                'ends_at': null,
                'capacity': null
              }
            }
          })
        });
      }

      Form.prototype.templateName = 'meetings/_form';

      Form.prototype.namespace = 'meeting';

      Form.prototype.formValues = function() {
        var attrs;
        attrs = Form.__super__.formValues.apply(this, arguments);
        attrs.location_id = null;
        attrs.location_name = this.location.getName();
        return attrs;
      };

      Form.prototype.setup = function() {
        Form.__super__.setup.apply(this, arguments);
        if (this.model.get('location_name') != null) {
          this.model.location.set({
            name: this.model.get('location_name')
          });
        }
        return this.location.use(this.model.location);
      };

      Form.prototype.render = function() {
        Form.__super__.render.apply(this, arguments);
        this.replaceWith('.location', this.location);
        return this;
      };

      return Form;

    })(P.views.meetings.Form);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.meetings', function(x) {
    return x.Show = (function(_super) {

      __extends(Show, _super);

      function Show() {
        this.render = __bind(this.render, this);
        this.logout = __bind(this.logout, this);
        this.initialize = __bind(this.initialize, this);
        Show.__super__.constructor.apply(this, arguments);
      }

      Show.prototype.className = function() {
        return "" + Show.__super__.className.apply(this, arguments) + " meetings";
      };

      Show.prototype.cardType = x.Card;

      Show.prototype.templateName = 'meetings/show';

      Show.prototype.initialize = function() {
        Show.__super__.initialize.apply(this, arguments);
        this.navigation = new (this.model.get('private') ? P.views.meetings.private.Navigation : x.Navigation)({
          model: this.model
        });
        _.defaults(this.card.options, {
          speakers: false
        });
        if (this.model.get('private')) {
          this.users = void 0;
          return this.attendees = new P.views.shared.lists.TitledList({
            itemType: P.views.attendances.Attendance,
            collection: this.model.memberships,
            title: 'Attendees',
            showCount: false
          });
        } else {
          return this.attendees = new Backbone.List({
            itemType: x.Ribbon,
            itemOptions: {
              group: this.model
            },
            collection: this.model.membershipsRibbons
          });
        }
      };

      Show.prototype.logout = function(session) {
        if (this.model.get('private')) {
          this.model.clear({
            silent: true
          });
          return P.router.redirectTo('#');
        }
      };

      Show.prototype.render = function() {
        Show.__super__.render.apply(this, arguments);
        this.replaceWith('>.sidebar>.attendees', this.attendees);
        return this;
      };

      return Show;

    })(P.views.groups.Show);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.memberships.my', function(x) {
    return x.Edit = (function(_super) {

      __extends(Edit, _super);

      function Edit() {
        Edit.__super__.constructor.apply(this, arguments);
      }

      Edit.prototype.initialize = function() {
        Edit.__super__.initialize.apply(this, arguments);
        return this.form = new x.Form({
          parent: this,
          collection: this.collection
        });
      };

      return Edit;

    })(P.views.memberships.Edit);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.memberships.my', function(x) {
    return x.Form = (function(_super) {

      __extends(Form, _super);

      function Form() {
        this.render = __bind(this.render, this);
        this.formValues = __bind(this.formValues, this);
        this.saved = __bind(this.saved, this);
        this.setup = __bind(this.setup, this);
        this.initialize = __bind(this.initialize, this);
        Form.__super__.constructor.apply(this, arguments);
      }

      Form.prototype.templateName = 'memberships/my/_form';

      Form.prototype.features = [P.views.shared.forms.ErrorsFeature, P.views.shared.forms.FormValueGetFeature, P.views.shared.forms.FormValueSetFeature];

      Form.prototype.className = function() {
        return "" + Form.__super__.className.apply(this, arguments) + " memberships-form formtastic";
      };

      Form.prototype.initialize = function() {
        Form.__super__.initialize.apply(this, arguments);
        this.bind('saved', this.saved);
        return this.bind('edit', this.setup);
      };

      Form.prototype.setup = function() {
        P.logger.debug('Setting up form, using model:', this.model);
        this.bindErrors();
        return this.setValues();
      };

      Form.prototype.saved = function(model) {
        model.user = P.user;
        model.set({
          user_id: P.user.id
        });
        this.collection.add(model);
        this.parent.close();
        return this.parent.parent.setup();
      };

      Form.prototype.formValues = function() {
        var v;
        v = this.getValues();
        return v;
      };

      Form.prototype.render = function() {
        Form.__super__.render.apply(this, arguments);
        return this;
      };

      return Form;

    })(P.views.shared.forms.Form);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.messages.mail', function(x) {
    return x.Form = (function(_super) {

      __extends(Form, _super);

      Form.prototype.templateName = 'messages/mail/_form';

      Form.prototype.className = function() {
        return "" + Form.__super__.className.apply(this, arguments) + " mail-picker";
      };

      function Form() {
        Form.__super__.constructor.apply(this, arguments);
        this._templates = new P.views.shared.SelectBox({
          collection: P.community.mail_templates,
          templateOptions: {
            blankOption: 'Select to send message...'
          }
        });
        this._events = new P.views.shared.SelectBox({
          collection: P.association.events,
          templateOptions: {
            blankOption: ''
          }
        });
      }

      Form.prototype.formValues = function() {
        return {
          template_id: this._templates.val(),
          event_id: this._events.val()
        };
      };

      Form.prototype.render = function() {
        Form.__super__.render.apply(this, arguments);
        this.html('.templates', this._templates);
        this.html('.events', this._events);
        return this;
      };

      return Form;

    })(P.views.shared.forms.Part);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.mobile.communities', function(x) {
    return x.Show = (function(_super) {

      __extends(Show, _super);

      Show.prototype.tagName = 'section';

      Show.prototype.templateName = 'mobile/communities/show';

      function Show() {
        this.loginout = __bind(this.loginout, this);
        this._toggle = __bind(this._toggle, this);
        this.render = __bind(this.render, this);
        var _this = this;
        Show.__super__.constructor.apply(this, arguments);
        _.each(['add', 'remove', 'reset'], function(ev) {
          return P.community.organizations.bind(ev, _this._toggle);
        });
      }

      Show.prototype.render = function() {
        Show.__super__.render.apply(this, arguments);
        this._toggle();
        return this;
      };

      Show.prototype._toggle = function() {
        return this.$('.exhibitors').toggle(!!P.community.organizations.length);
      };

      Show.prototype.loginout = function(session, loggedIn) {
        Show.__super__.loginout.apply(this, arguments);
        this.$('.login').toggle(!loggedIn);
        return this.$('.logout,.my-schedule,.contacts,.inbox').toggle(!!loggedIn);
      };

      return Show;

    })(P.views.shared.mobile.Page);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.mobile.contacts', function(x) {
    return x.Contact = (function(_super) {

      __extends(Contact, _super);

      function Contact() {
        this.showContact = __bind(this.showContact, this);
        Contact.__super__.constructor.apply(this, arguments);
      }

      Contact.prototype.templateName = 'mobile/contacts/_contact';

      Contact.prototype.events = {
        'click': 'showContact'
      };

      Contact.prototype.showContact = function(e) {
        var _ref;
        e.preventDefault();
        return this.parent.select((_ref = this.model.user_contactees.find(function(model) {
          return model.isMarked();
        })) != null ? _ref.get('id') : void 0);
      };

      return Contact;

    })(P.views.shared.mobile.View);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.mobile.contacts', function(x) {
    return x.Form = (function(_super) {

      __extends(Form, _super);

      Form.prototype.templateName = 'mobile/contacts/_form';

      Form.prototype.features = [P.views.shared.forms.FormValueGetFeature, P.views.shared.forms.FormValueSetFeature, P.views.shared.forms.FocusFeature];

      Form.prototype.events = function() {
        return _.extend(Form.__super__.events.apply(this, arguments), {
          'click .cancel': 'cancel'
        });
      };

      function Form() {
        this.saved = __bind(this.saved, this);
        this.cancel = __bind(this.cancel, this);        Form.__super__.constructor.apply(this, arguments);
        this.bind('saved', this.saved);
      }

      Form.prototype.save = function(e) {
        var _this = this;
        if (e != null) e.preventDefault();
        return this.model.save(this.getValues(), {
          success: function(model) {
            return _this.trigger('saved', model);
          }
        });
      };

      Form.prototype.cancel = function(e) {
        if (e != null) e.preventDefault();
        return this.close();
      };

      Form.prototype.saved = function() {
        Form.__super__.saved.apply(this, arguments);
        this.close();
        return P.layout.flash.show({
          message: '<b>Contact notes updated</b>',
          "class": 'success'
        });
      };

      Form.prototype.open = function() {
        this.setValues();
        return this.$el.show();
      };

      Form.prototype.close = function() {
        return this.$el.hide();
      };

      Form.prototype.render = function() {
        Form.__super__.render.apply(this, arguments);
        this.close();
        return this;
      };

      return Form;

    })(P.views.shared.mobile.form.Form);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.mobile.contacts', function(x) {
    return x.Index = (function(_super) {

      __extends(Index, _super);

      Index.prototype.tagName = 'section';

      Index.prototype.templateName = 'mobile/contacts/index';

      Index.prototype.events = function() {
        return _.extend(Index.__super__.events.apply(this, arguments), {
          'click .show_more': 'showMore'
        });
      };

      function Index() {
        this.showMore = __bind(this.showMore, this);
        this.select = __bind(this.select, this);
        var _this = this;
        Index.__super__.constructor.apply(this, arguments);
        this.collection = P.user.user_contacts;
        this.collection.searchOptions = {
          "with": {
            type: 'UserContacts::MarkedUserContact'
          },
          page: 1,
          per_page: 20
        };
        this.collection.comparator = function(userContact) {
          var _ref;
          return (_ref = userContact.contact) != null ? _ref.formattedName('full') : void 0;
        };
        this.collection.bind('reset', function() {
          _this.$('.loading').hide();
          return _this.$('.more').toggle(_this.collection.total_entries > _this.collection.length);
        });
        this.contacts = new P.views.shared.mobile.lists.List({
          collection: P.user.contacts,
          itemType: x.Contact,
          itemOptions: {
            parent: this
          }
        });
      }

      Index.prototype.select = function(id) {
        var model;
        if (model = this.collection.get(id)) {
          return P.router.redirectTo(model.fragment());
        } else {
          return P.layout.flash.show({
            message: 'Contact not found',
            "class": 'error'
          });
        }
      };

      Index.prototype.showMore = function(e) {
        var _base, _base2,
          _this = this;
        (_base = ((_base2 = this.collection).searchOptions || (_base2.searchOptions = {}))).page || (_base.page = 0);
        this.collection.searchOptions.page += 1;
        this.$('.loading').show();
        this.$('.more').hide();
        this.collection.fetch({
          add: true,
          silent: true,
          success: function() {
            return _this.collection.trigger('reset');
          }
        });
        return this;
      };

      Index.prototype.render = function() {
        Index.__super__.render.apply(this, arguments);
        this.$('.more').hide();
        this.html('.contacts', this.contacts);
        this.collection.fetch();
        return this;
      };

      Index.prototype.title = function() {
        return 'Contacts';
      };

      return Index;

    })(P.views.shared.mobile.Page);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.mobile.contacts', function(x) {
    return x.Show = (function(_super) {

      __extends(Show, _super);

      Show.prototype.tagName = 'section';

      Show.prototype.templateName = 'mobile/contacts/show';

      Show.prototype.events = {
        'click .edit': '_edit',
        'click .destroy': '_destroy'
      };

      function Show() {
        this._destroy = __bind(this._destroy, this);
        this._edit = __bind(this._edit, this);
        this._renderContact = __bind(this._renderContact, this);        Show.__super__.constructor.apply(this, arguments);
        this.contact = new x.Contact({
          model: new P.models.User
        });
        this.model.bind('change', this._renderContact);
        this.form = new x.Form({
          model: this.model
        });
      }

      Show.prototype.render = function() {
        Show.__super__.render.apply(this, arguments);
        this._renderContact();
        this.replaceWith('.form', this.form);
        return this;
      };

      Show.prototype.title = function() {
        return 'Contact';
      };

      Show.prototype._renderContact = function() {
        this.contact.use(this.model.contact || new P.models.User);
        return this.html('.contact', this.contact);
      };

      Show.prototype._edit = function(e) {
        e.preventDefault();
        return this.form.open();
      };

      Show.prototype._destroy = function(e) {
        e.preventDefault();
        if (confirm('Are you sure?')) {
          this.model.destroy();
          return P.router.redirectTo('#contacts');
        }
      };

      return Show;

    })(P.views.shared.mobile.Page);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.mobile.discussions.discussions', function(x) {
    return x.Discussion = (function(_super) {

      __extends(Discussion, _super);

      function Discussion() {
        this.render = __bind(this.render, this);
        Discussion.__super__.constructor.apply(this, arguments);
      }

      Discussion.prototype.templateName = 'mobile/discussions/discussions/_discussion';

      Discussion.prototype.initialize = function() {
        return Discussion.__super__.initialize.apply(this, arguments);
      };

      Discussion.prototype.render = function() {
        Discussion.__super__.render.apply(this, arguments);
        return this;
      };

      return Discussion;

    })(P.views.shared.mobile.View);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.mobile.discussions.discussions', function(x) {
    return x.Form = (function(_super) {

      __extends(Form, _super);

      function Form() {
        this.isPrivate = __bind(this.isPrivate, this);
        this.render = __bind(this.render, this);
        Form.__super__.constructor.apply(this, arguments);
      }

      Form.prototype.className = function() {
        return "" + Form.__super__.className.apply(this, arguments) + " messages-form";
      };

      Form.prototype.templateName = 'mobile/discussions/discussions/_form';

      Form.prototype.features = [P.views.shared.forms.ErrorsFeature, P.views.shared.forms.FormValueSetFeature, P.views.shared.forms.FocusFeature, P.views.discussions.discussions.RecipientsFeature];

      Form.prototype.events = function() {
        return _.extend(Form.__super__.events.apply(this, arguments), {
          'focus input': 'clearFormErrors'
        });
      };

      Form.prototype.initialize = function() {
        var _this = this;
        Form.__super__.initialize.apply(this, arguments);
        _.bindAll(this);
        this.autoSuggest = new P.views.shared.auto_suggest.AutoSuggest({
          model: this.model,
          disableFreeForm: true,
          searchOptions: {
            classes: ['Groups::Tag', 'User']
          },
          maxChoices: this.maxRecipients()
        });
        this.autoSuggest.bind('created', function() {
          return _this.autoSuggest.$('input').data('autocomplete').menu.element.page();
        });
        this.buttons = new P.views.shared.ControlBar({
          controls: ['send']
        });
        this.enforceMaxRecipients(this.autoSuggest.collection);
        return this.bind('saved', this.saved);
      };

      Form.prototype.formValues = function() {
        var groups_discussions_attributes, participations_attributes,
          _this = this;
        groups_discussions_attributes = [];
        participations_attributes = [];
        this._groups = [];
        _.each(this.autoSuggest.collection.each(function(item) {
          if (item instanceof P.models.User) {
            return participations_attributes.push({
              user_id: item.id
            });
          } else if (item instanceof P.models.Group) {
            groups_discussions_attributes.push({
              group_id: item.id
            });
            return _this._groups.push(item);
          }
        }));
        if (this.isPrivate()) {
          participations_attributes.push({
            user_id: P.user.id
          });
        }
        return {
          subject: this.$(".subject input").val(),
          participations_attributes: participations_attributes,
          groups_discussions_attributes: groups_discussions_attributes,
          messages_attributes: [
            {
              body: this.$('.body textarea').val(),
              user_id: P.user.id
            }
          ],
          private: this.isPrivate()
        };
      };

      Form.prototype.saved = function() {
        var _this = this;
        P.layout.flash.show({
          message: P.localizer.t('discussion_created'),
          "class": 'info'
        });
        P.router.redirectTo('#discussions');
        if (this.isPrivate()) {
          return P.user.discussions.add(this.model);
        } else {
          P.community.discussions.add(this.model);
          return _.each(this._groups, function(group) {
            return group.discussions.add(_this.model);
          });
        }
      };

      Form.prototype.render = function() {
        var _this = this;
        Form.__super__.render.apply(this, arguments);
        this.bindErrors({
          handler: function(error, messages) {
            switch (error.attribute) {
              case 'messages.body':
                return _this.flash.show({
                  message: P.localizer.t('body', {
                    scope: ['forms', 'errors'],
                    messages: error.messages.join(', ')
                  }),
                  "class": 'error'
                });
              case 'subject':
                return _this.flash.show({
                  message: P.localizer.t('subject', {
                    scope: ['forms', 'errors'],
                    messages: error.messages.join(', ')
                  }),
                  "class": 'error'
                });
            }
          }
        });
        this.autoSuggest.clear();
        this.$('.subject input').val();
        this.focus(true);
        if (!this.model.participants.isEmpty()) {
          this.model.participants.each(function(p) {
            return _this.autoSuggest.collection.add(p);
          });
        } else {
          this.autoSuggest.collection.add(this.model.groups.isEmpty() ? new P.models.AllGroup() : this.model.groups);
        }
        this.replaceWith('.discussion_to', this.autoSuggest);
        return this;
      };

      Form.prototype.isPrivate = function() {
        return this.autoSuggest.collection.all(function(m) {
          return m instanceof P.models.User;
        });
      };

      return Form;

    })(P.views.shared.mobile.form.Form);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.mobile.discussions.discussions', function(x) {
    return x.Edit = (function(_super) {

      __extends(Edit, _super);

      function Edit() {
        this.logout = __bind(this.logout, this);
        this.render = __bind(this.render, this);
        Edit.__super__.constructor.apply(this, arguments);
      }

      Edit.prototype.templateName = 'mobile/discussions/discussions/edit';

      Edit.prototype.initialize = function() {
        Edit.__super__.initialize.apply(this, arguments);
        this.form = new x.Form({
          model: this.model
        });
        return this.model.bind('change', this.update);
      };

      Edit.prototype.render = function() {
        Edit.__super__.render.apply(this, arguments);
        this.replaceWith('.form', this.form);
        return this;
      };

      Edit.prototype.logout = function() {
        Edit.__super__.logout.apply(this, arguments);
        if (P.router.visible === this) return P.router.redirectTo('#');
      };

      Edit.prototype.title = function() {
        return 'New Message';
      };

      return Edit;

    })(P.views.shared.mobile.Page);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.mobile.discussions.discussions', function(x) {
    return x.Index = (function(_super) {

      __extends(Index, _super);

      function Index() {
        this.loginout = __bind(this.loginout, this);
        this.initialize = __bind(this.initialize, this);
        Index.__super__.constructor.apply(this, arguments);
      }

      Index.prototype.templateName = 'mobile/discussions/discussions/index';

      Index.prototype.initialize = function() {
        Index.__super__.initialize.apply(this, arguments);
        this.discussions = new P.views.shared.mobile.lists.List({
          itemType: x.Discussion,
          collection: this.collection,
          itemOptions: function() {
            return {
              addClass: 'discussion'
            };
          }
        });
        return this.collection.fetch();
      };

      Index.prototype.render = function() {
        Index.__super__.render.apply(this, arguments);
        this.html('.discussions', this.discussions);
        return this;
      };

      Index.prototype.loginout = function(session, loggedIn) {
        Index.__super__.loginout.apply(this, arguments);
        return this.$('.button_holder').toggle(loggedIn);
      };

      Index.prototype.title = function() {
        return P.localizer.t('discussion', {
          pluralize: true
        }).capitalize();
      };

      return Index;

    })(P.views.shared.mobile.Page);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.mobile.discussions.discussions', function(x) {
    return x.Show = (function(_super) {

      __extends(Show, _super);

      function Show() {
        this.loginout = __bind(this.loginout, this);
        this.render = __bind(this.render, this);
        Show.__super__.constructor.apply(this, arguments);
      }

      Show.prototype.templateName = 'mobile/discussions/discussions/show';

      Show.prototype.initialize = function() {
        var _this = this;
        Show.__super__.initialize.apply(this, arguments);
        this.messages = new P.views.shared.mobile.lists.List({
          collection: this.model.messages,
          itemOptions: function(model) {
            return {
              templateName: 'mobile/discussions/messages/_message'
            };
          }
        });
        this.form = new P.views.mobile.discussions.messages.Form({
          model: this.model
        });
        this.to = new P.views.discussions.discussions.To({
          model: this.model,
          all: true
        });
        return this.model.bind('change', this.update);
      };

      Show.prototype.render = function() {
        Show.__super__.render.apply(this, arguments);
        this.html('.messages', this.messages);
        this.replaceWith('.form', this.form);
        this.replaceWith('.to', this.to);
        return this;
      };

      Show.prototype.loginout = function(session, loggedIn) {
        Show.__super__.loginout.apply(this, arguments);
        return this.form.$el.toggle(loggedIn);
      };

      Show.prototype.title = function() {
        return 'Inbox';
      };

      return Show;

    })(P.views.shared.mobile.Page);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.mobile.discussions.messages', function(x) {
    return x.Form = (function(_super) {

      __extends(Form, _super);

      function Form() {
        this.render = __bind(this.render, this);
        this.saved = __bind(this.saved, this);
        this.formValues = __bind(this.formValues, this);
        this.initialize = __bind(this.initialize, this);
        Form.__super__.constructor.apply(this, arguments);
      }

      Form.prototype.templateName = 'mobile/discussions/messages/_form';

      Form.prototype.features = [P.views.shared.forms.ErrorsFeature, P.views.shared.forms.FormValueGetFeature, P.views.shared.forms.FocusFeature];

      Form.prototype.initialize = function() {
        Form.__super__.initialize.apply(this, arguments);
        return this.bind('saved', this.saved);
      };

      Form.prototype.formValues = function() {
        return this.getValues();
      };

      Form.prototype.saved = function() {
        Form.__super__.saved.apply(this, arguments);
        P.layout.flash.show({
          "class": 'success',
          message: '<b>Your message has been sent!</b>'
        });
        this.$('textarea.body').val('');
        return P.user.discussions.fetch();
      };

      Form.prototype.save = function(e) {
        var _this = this;
        if (e != null) e.preventDefault();
        this.model.messages.create({
          body: this.$('textarea.body').val(),
          discussion_id: this.model.id,
          created_at: new Date(),
          user_id: P.user.id
        }, {
          success: function(model) {
            return _this.trigger('saved', model);
          }
        });
        return this.trigger('saving');
      };

      Form.prototype.render = function() {
        Form.__super__.render.apply(this, arguments);
        this.bindErrors();
        this.focus(true);
        return this;
      };

      return Form;

    })(P.views.shared.mobile.form.Form);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.mobile.discussions.messages', function(x) {
    return x.Message = (function(_super) {

      __extends(Message, _super);

      function Message() {
        this.render = __bind(this.render, this);
        Message.__super__.constructor.apply(this, arguments);
      }

      Message.prototype.templateName = 'mobile/discussions/messages/_message';

      Message.prototype.initialize = function() {
        return Message.__super__.initialize.apply(this, arguments);
      };

      Message.prototype.render = function() {
        Message.__super__.render.apply(this, arguments);
        return this;
      };

      return Message;

    })(P.views.shared.mobile.View);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.documents', function(x) {
    return x.Document = (function(_super) {

      __extends(Document, _super);

      function Document() {
        this.render = __bind(this.render, this);
        Document.__super__.constructor.apply(this, arguments);
      }

      Document.prototype.tagName = 'li';

      Document.prototype.templateName = 'mobile/documents/_document';

      Document.prototype.initialize = function() {
        return Document.__super__.initialize.apply(this, arguments);
      };

      Document.prototype.render = function() {
        Document.__super__.render.apply(this, arguments);
        return this;
      };

      return Document;

    })(P.views.shared.mobile.View);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.mobile.groups', function(x) {
    return x.Index = (function(_super) {

      __extends(Index, _super);

      Index.prototype.templateName = 'mobile/groups/index';

      Index.prototype.tagName = 'section';

      function Index() {
        this.render = __bind(this.render, this);        Index.__super__.constructor.apply(this, arguments);
        this.collection = new P.models.Groups([], {
          searchOptions: {
            per_page: 25
          }
        });
        this.groups = new P.views.shared.mobile.lists.List({
          collection: this.collection,
          itemOptions: {
            templateName: 'mobile/groups/_group'
          }
        });
        this.search = new P.views.shared.mobile.lists.Search({
          list: this.groups
        });
      }

      Index.prototype.render = function() {
        Index.__super__.render.apply(this, arguments);
        this.prepend('.search', this.search);
        return this;
      };

      return Index;

    })(P.views.shared.mobile.Page);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.mobile.groups', function(x) {
    return x.Show = (function(_super) {

      __extends(Show, _super);

      Show.prototype.tagName = 'section';

      Show.prototype.templateName = 'mobile/users/index';

      function Show() {
        this.title = __bind(this.title, this);
        this.render = __bind(this.render, this);        Show.__super__.constructor.apply(this, arguments);
        this.collection = new P.models.Users([], {
          searchOptions: {
            per_page: 25
          }
        });
        this.collection.scope = this.model;
        this.users = new P.views.mobile.users.List({
          collection: this.collection
        });
        this.search = new P.views.shared.mobile.lists.Search({
          list: this.users
        });
      }

      Show.prototype.render = function() {
        Show.__super__.render.apply(this, arguments);
        this.html('.search', this.search);
        return this;
      };

      Show.prototype.title = function() {
        return this.model.get('name');
      };

      return Show;

    })(P.views.shared.mobile.Page);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.mobile.layouts', function(x) {
    return x.Flash = (function(_super) {

      __extends(Flash, _super);

      function Flash() {
        this.render = __bind(this.render, this);
        this.parseError = __bind(this.parseError, this);
        this.clear = __bind(this.clear, this);
        this.hide = __bind(this.hide, this);
        this.show = __bind(this.show, this);
        Flash.__super__.constructor.apply(this, arguments);
      }

      Flash.prototype.events = function() {
        return Flash.__super__.events.apply(this, arguments);
      };

      Flash.prototype.show = function(flash, prepend) {
        var _this = this;
        if (prepend == null) prepend = '';
        if (!(flash != null)) return false;
        return $("<div class='ui-loader ui-overlay-shadow ui-body-e ui-corner-all'>\n  <h1>" + flash.message + "</h1>\n</div>").css({
          display: 'block',
          opacity: 0.96,
          top: $(window).scrollTop() + 100
        }).appendTo($.mobile.pageContainer).delay(1500).fadeOut(400, function() {
          return _this.remove();
        });
      };

      Flash.prototype.hide = function() {};

      Flash.prototype.clear = function() {};

      Flash.prototype.parseError = function() {};

      Flash.prototype.render = function() {};

      return Flash;

    })(P.views.shared.Flash);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.mobile.layouts', function(x) {
    return x.Application = (function(_super) {

      __extends(Application, _super);

      function Application() {
        Application.__super__.constructor.apply(this, arguments);
        this.flash = new x.Flash();
      }

      return Application;

    })(P.views.shared.mobile.View);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.mobile.links', function(x) {
    return x.List = (function(_super) {

      __extends(List, _super);

      function List() {
        this.render = __bind(this.render, this);
        List.__super__.constructor.apply(this, arguments);
      }

      List.prototype.itemType = P.views.mobile.links.LinkItem;

      List.prototype.render = function() {
        List.__super__.render.apply(this, arguments);
        $(this.el).prepend($('<li data-role="list-divider">Websites</li>'));
        return this;
      };

      return List;

    })(P.views.shared.mobile.lists.List);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.mobile.meetings', function(x) {
    return x.Attendees = (function(_super) {

      __extends(Attendees, _super);

      Attendees.prototype.tagName = 'section';

      Attendees.prototype.templateName = 'mobile/users/index';

      function Attendees() {
        this.render = __bind(this.render, this);        Attendees.__super__.constructor.apply(this, arguments);
        this.attendees = this.model.noRibbonUsers;
        this.users = new P.views.shared.mobile.lists.List({
          itemType: P.views.mobile.users.User,
          collection: this.model.noRibbonUsers
        });
      }

      Attendees.prototype.render = function() {
        Attendees.__super__.render.apply(this, arguments);
        if (this.attendees.length > 0) {
          this.html('.search', this.users);
        } else {
          this.html('.search', "<p class='center'>There are no attendees for this session.</p>");
        }
        this.model.fetch();
        return this;
      };

      Attendees.prototype.title = function() {
        return 'Attendees';
      };

      return Attendees;

    })(P.views.shared.mobile.Page);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.mobile.meetings', function(x) {
    return x.Discussion = (function(_super) {

      __extends(Discussion, _super);

      function Discussion() {
        this.render = __bind(this.render, this);
        Discussion.__super__.constructor.apply(this, arguments);
      }

      Discussion.prototype.templateName = 'mobile/discussions/discussions/_discussion';

      Discussion.prototype.initialize = function() {
        return Discussion.__super__.initialize.apply(this, arguments);
      };

      Discussion.prototype.render = function() {
        Discussion.__super__.render.apply(this, arguments);
        this.$('.discussion_url').attr('href', "#meetings/" + this.options.parent.id + "/discussions/" + this.options.model.id);
        return this;
      };

      return Discussion;

    })(P.views.shared.mobile.View);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.mobile.meetings', function(x) {
    return x.Discussions = (function(_super) {

      __extends(Discussions, _super);

      function Discussions() {
        this.initialize = __bind(this.initialize, this);
        Discussions.__super__.constructor.apply(this, arguments);
      }

      Discussions.prototype.templateName = 'mobile/discussions/discussions/index';

      Discussions.prototype.initialize = function() {
        Discussions.__super__.initialize.apply(this, arguments);
        return this.discussions = new P.views.shared.mobile.lists.List({
          itemType: P.views.mobile.meetings.Discussion,
          collection: this.model.discussions,
          itemOptions: {
            addClass: 'discussion',
            parent: this.model
          }
        });
      };

      Discussions.prototype.render = function() {
        Discussions.__super__.render.apply(this, arguments);
        if (this.model.discussions.length > 0) {
          this.html('.discussions', this.discussions);
        } else {
          this.html('.discussions', "<p class='center'>There are no conversations for this session.</p>");
        }
        this.model.fetch();
        return this;
      };

      Discussions.prototype.title = function() {
        return 'Discussions';
      };

      return Discussions;

    })(P.views.shared.mobile.Page);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.mobile.meetings', function(x) {
    return x.DiscussionsShow = (function(_super) {

      __extends(DiscussionsShow, _super);

      function DiscussionsShow() {
        this.render = __bind(this.render, this);
        DiscussionsShow.__super__.constructor.apply(this, arguments);
      }

      DiscussionsShow.prototype.initialize = function() {
        return DiscussionsShow.__super__.initialize.apply(this, arguments);
      };

      DiscussionsShow.prototype.render = function() {
        DiscussionsShow.__super__.render.apply(this, arguments);
        return this;
      };

      DiscussionsShow.prototype.title = function() {
        return 'Meeting Discussion';
      };

      return DiscussionsShow;

    })(P.views.mobile.discussions.discussions.Show);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.mobile.meetings', function(x) {
    return x.Documents = (function(_super) {

      __extends(Documents, _super);

      function Documents() {
        this.initialize = __bind(this.initialize, this);
        Documents.__super__.constructor.apply(this, arguments);
      }

      Documents.prototype.templateName = 'mobile/documents/index';

      Documents.prototype.initialize = function() {
        Documents.__super__.initialize.apply(this, arguments);
        return this.documents = new P.views.shared.mobile.lists.List({
          itemType: P.views.documents.Document,
          collection: this.model.documents
        });
      };

      Documents.prototype.render = function() {
        Documents.__super__.render.apply(this, arguments);
        if (this.model.documents.length > 0) {
          this.html('.documents', this.documents);
        } else {
          this.html('.documents', "<p class='center'>There are no hand-outs for this session.</p>");
        }
        this.model.fetch();
        return this;
      };

      Documents.prototype.title = function() {
        return 'Documents';
      };

      return Documents;

    })(P.views.shared.mobile.Page);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.mobile.meetings', function(x) {
    return x.List = (function(_super) {

      __extends(List, _super);

      function List() {
        List.__super__.constructor.apply(this, arguments);
      }

      List.prototype.itemType = x.Meeting;

      return List;

    })(P.views.shared.mobile.lists.List);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.mobile.meetings', function(x) {
    return x.Navigation = (function(_super) {

      __extends(Navigation, _super);

      function Navigation() {
        this._setup = __bind(this._setup, this);
        this._remove = __bind(this._remove, this);
        this._add = __bind(this._add, this);
        this.render = __bind(this.render, this);
        this.initialize = __bind(this.initialize, this);
        Navigation.__super__.constructor.apply(this, arguments);
      }

      Navigation.prototype.templateName = 'mobile/meetings/_navigation';

      Navigation.prototype.initialize = function() {
        var _this = this;
        Navigation.__super__.initialize.apply(this, arguments);
        return _.each(['add', 'remove', 'reset'], function(event) {
          return _this.model.users.bind(event, _this._setup);
        });
      };

      Navigation.prototype.events = {
        'click .add a': '_add',
        'click .remove a': '_remove'
      };

      Navigation.prototype.render = function() {
        Navigation.__super__.render.apply(this, arguments);
        this.$('.remove').hide();
        this.$('.add').hide();
        return this;
      };

      Navigation.prototype._add = function(e) {
        e.preventDefault();
        return this.model.users.add(P.user);
      };

      Navigation.prototype._remove = function(e) {
        e.preventDefault();
        return this.model.users.remove(P.user);
      };

      Navigation.prototype._setup = function() {
        var member, unschedulable;
        unschedulable = this.model.get('unschedulable');
        member = this.model.users.get(P.user) != null;
        this.$('.remove').toggle(!unschedulable && member);
        return this.$('.add').toggle(!(unschedulable || member));
      };

      return Navigation;

    })(P.views.shared.mobile.View);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.mobile.meetings', function(x) {
    return x.Day = (function(_super) {

      __extends(Day, _super);

      function Day() {
        this._update = __bind(this._update, this);
        this.render = __bind(this.render, this);
        Day.__super__.constructor.apply(this, arguments);
      }

      Day.prototype.templateName = 'mobile/meetings/day';

      Day.prototype.initialize = function() {
        var _this = this;
        Day.__super__.initialize.apply(this, arguments);
        _.each(['add', 'remove', 'reset'], function(ev) {
          return _this.collection.bind(ev, _this._update);
        });
        return this.date = moment(this.options.date, 'YYYY-M-D')["native"]();
      };

      Day.prototype.render = function() {
        var _this = this;
        Day.__super__.render.apply(this, arguments);
        this.append(':jqmData(role="content")', new P.views.shared.mobile.lists.List({
          itemType: x.Meeting,
          collection: this.collection.subset({
            filter: function(model) {
              return moment(model.get('starts_at_local')).format('YYYY-M-D') === _this.options.date;
            },
            comparator: function(model) {
              return model.get('starts_at_local');
            }
          })
        }));
        this._update();
        return this;
      };

      Day.prototype._update = function() {
        var dates, next, nextDay, prev, url,
          _this = this;
        nextDay = moment(new Date(this.date)).add('d', 1)["native"]();
        dates = _.pluck(this.collection.models, 'starts_at_local');
        next = new Date(_.min(_.filter(dates, function(date) {
          return date >= nextDay;
        })));
        prev = new Date(_.max(_.filter(dates, function(date) {
          return date < _this.date;
        })));
        url = '#meetings/' + (this.options.route ? this.options.route + '/' : '');
        this.$('.next').toggle(!_.isNaN(next.getTime())).find('a').attr({
          href: url + moment(next).format('YYYY-M-D')
        }).find('.ui-btn-text').text(moment(next).format('ddd MMM Do'));
        return this.$('.prev').toggle(!_.isNaN(prev.getTime())).find('a').attr({
          href: url + moment(prev).format('YYYY-M-D')
        }).find('.ui-btn-text').text(moment(prev).format('ddd MMM Do'));
      };

      return Day;

    })(P.views.shared.mobile.Page);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.mobile.meetings', function(x) {
    return x.Index = (function(_super) {

      __extends(Index, _super);

      function Index() {
        this.loginout = __bind(this.loginout, this);
        this.render = __bind(this.render, this);
        this.initialize = __bind(this.initialize, this);
        Index.__super__.constructor.apply(this, arguments);
      }

      Index.prototype.templateName = 'mobile/meetings/index';

      Index.prototype.initialize = function() {
        var _this = this;
        Index.__super__.initialize.apply(this, arguments);
        this.meetings = new P.views.shared.mobile.lists.List({
          collection: this.collection.byDay(),
          itemOptions: function(model) {
            return {
              templateName: 'mobile/meetings/_date',
              route: _this.options.route
            };
          }
        });
        return this.meetings.collection.fetch();
      };

      Index.prototype.render = function() {
        Index.__super__.render.apply(this, arguments);
        this.append(':jqmData(role="content")', this.meetings);
        if (this.options.route === "my") {
          this.$(this.el).find('.my-schedule').hide();
        }
        return this;
      };

      Index.prototype.loginout = function(session, loggedIn) {
        Index.__super__.loginout.apply(this, arguments);
        return this.$('.my-schedule').toggle(!!loggedIn);
      };

      return Index;

    })(P.views.shared.mobile.Page);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.mobile.meetings.private', function(x) {
    return x.Form = (function(_super) {

      __extends(Form, _super);

      function Form() {
        this._fetchLocations = __bind(this._fetchLocations, this);
        this._initTime = __bind(this._initTime, this);
        this.render = __bind(this.render, this);
        this.saved = __bind(this.saved, this);
        this.formValues = __bind(this.formValues, this);
        this.initialize = __bind(this.initialize, this);
        Form.__super__.constructor.apply(this, arguments);
      }

      Form.prototype.templateName = 'mobile/meetings/private/_form';

      Form.prototype.features = [P.views.shared.forms.ErrorsFeature, P.views.shared.forms.FormValueGetFeature, P.views.shared.forms.FocusFeature];

      Form.prototype.events = function() {
        return _.extend(Form.__super__.events.apply(this, arguments), {
          'focus input': 'clearFormErrors'
        });
      };

      Form.prototype.initialize = function() {
        Form.__super__.initialize.apply(this, arguments);
        this.bind('saved', this.saved);
        this.endTime = new P.views.shared.mobile.DateTimePicker({
          config: {
            preset: 'time',
            theme: 'ios'
          }
        });
        this.startDateTime = new P.views.shared.mobile.DateTimePicker({
          config: {
            preset: 'datetime',
            theme: 'ios'
          },
          "with": this.endTime
        });
        this.startDateTime.bind('rendered', this._initTime);
        this.startDateTime.bind('change', this._fetchLocations);
        this.endTime.bind('change', this._fetchLocations);
        this.location = new P.views.locations.Form({
          collection: new P.models.Locations(P.community.locations.models, {
            searchOptions: {
              conditions: {
                'starts_at': null,
                'ends_at': null
              }
            }
          })
        });
        return this.model.users.add(P.user, {
          silent: true
        });
      };

      Form.prototype.formValues = function() {
        var organizer, values,
          _this = this;
        values = this.getValues();
        values['starts_at'] = this.startDateTime.getDateTime();
        values['ends_at'] = P.views.meetings.Form.prototype.mergeDateAndTime(this.startDateTime.getDateTime(), this.endTime.getDateTime());
        values['attendances_attributes'] = this.model.users.map(function(user) {
          return {
            user_id: user.id
          };
        });
        values['location_id'] = this.location.getID();
        organizer = _.detect(values['attendances_attributes'], function(a) {
          return a.user_id === P.user.id;
        });
        organizer.roles = 'organizer';
        organizer.status = 'accepted';
        return values;
      };

      Form.prototype.saved = function() {
        Form.__super__.saved.apply(this, arguments);
        P.layout.flash.show({
          "class": 'success',
          message: '<b>Your meeting request has been sent!</b>'
        });
        this.model.set({
          id: null
        });
        return P.router.redirectTo((this.model.users.detect(function(u) {
          return u.id !== P.user.id;
        })).fragment());
      };

      Form.prototype.render = function() {
        Form.__super__.render.apply(this, arguments);
        this.bindErrors();
        this.focus(true);
        this.replaceAll('.location', this.location);
        this.replaceAll('input.starts_at', this.startDateTime);
        this.replaceAll('input.ends_at', this.endTime);
        return this;
      };

      Form.prototype._initTime = function() {
        var _this = this;
        return setTimeout(function() {
          return _this.startDateTime.setDateTime(P.community.starts_at);
        });
      };

      Form.prototype._fetchLocations = function() {
        var ends_at, starts_at,
          _this = this;
        starts_at = this.startDateTime.getDateTime();
        ends_at = P.views.meetings.Form.prototype.mergeDateAndTime(this.startDateTime.getDateTime(), this.endTime.getDateTime());
        if (starts_at && ends_at) {
          this.location.collection.searchOptions.conditions.starts_at = starts_at;
          this.location.collection.searchOptions.conditions.ends_at = ends_at;
          return this.location.collection.fetch({
            success: function() {
              return $(_this.el).trigger('create');
            }
          });
        }
      };

      return Form;

    })(P.views.shared.mobile.form.Form);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.mobile.meetings.private', function(x) {
    return x.Navigation = (function(_super) {

      __extends(Navigation, _super);

      function Navigation() {
        this._highlight = __bind(this._highlight, this);
        this.respond = __bind(this.respond, this);
        this.render = __bind(this.render, this);
        this.initialize = __bind(this.initialize, this);
        Navigation.__super__.constructor.apply(this, arguments);
      }

      Navigation.prototype.templateName = 'mobile/meetings/private/_navigation';

      Navigation.prototype.initialize = function() {
        var _ref,
          _this = this;
        Navigation.__super__.initialize.apply(this, arguments);
        return (_ref = this.model.memberships["for"](P.user)) != null ? _ref.bind('change:status', function() {
          var status;
          status = (function() {
            var _ref2;
            switch ((_ref2 = this.model.memberships["for"](P.user)) != null ? _ref2.get('status') : void 0) {
              case 'accepted':
                return "Meeting accepted";
              case 'declined':
                return "Meeting declined";
              default:
                return "Meeting marked tentative";
            }
          }).call(_this);
          P.layout.flash.show({
            "class": 'success',
            message: status
          });
          return _this._highlight();
        }) : void 0;
      };

      Navigation.prototype.events = function() {
        return _.extend(Navigation.__super__.events.apply(this, arguments), {
          'click a': 'respond'
        });
      };

      Navigation.prototype.render = function() {
        Navigation.__super__.render.apply(this, arguments);
        this._highlight();
        return this;
      };

      Navigation.prototype.respond = function(e) {
        var _ref;
        e.preventDefault();
        return (_ref = this.model.memberships["for"](P.user)) != null ? _ref.save({
          status: $(e.currentTarget).attr('data-value')
        }) : void 0;
      };

      Navigation.prototype._highlight = function() {
        var _this = this;
        return _.each(this.$('a'), function(a) {
          var _ref;
          $(a).attr({
            'data-theme': 'a'
          });
          if (((_ref = _this.model.memberships["for"](P.user)) != null ? _ref.get('status') : void 0) === $(a).attr('data-value')) {
            return $(a).attr({
              'data-theme': 'e'
            }).removeClass('ui-btn-down-a ui-btn-up-a').addClass('ui-btn-down-e ui-btn-up-e');
          } else {
            return $(a).attr({
              'data-theme': 'a'
            }).removeClass('ui-btn-down-e ui-btn-up-e').addClass('ui-btn-down-a ui-btn-up-a');
          }
        });
      };

      return Navigation;

    })(P.views.shared.mobile.View);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.mobile.meetings.private', function(x) {
    return x.Edit = (function(_super) {

      __extends(Edit, _super);

      function Edit() {
        this.render = __bind(this.render, this);
        this.initialize = __bind(this.initialize, this);
        Edit.__super__.constructor.apply(this, arguments);
      }

      Edit.prototype.tagName = 'section';

      Edit.prototype.templateName = 'mobile/meetings/private/edit';

      Edit.prototype.initialize = function() {
        Edit.__super__.initialize.apply(this, arguments);
        return this.form = new x.Form({
          model: this.model
        });
      };

      Edit.prototype.render = function() {
        Edit.__super__.render.apply(this, arguments);
        this.replaceWith('.form', this.form);
        return this;
      };

      return Edit;

    })(P.views.shared.mobile.Page);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.mobile.meetings', function(x) {
    return x.Show = (function(_super) {

      __extends(Show, _super);

      function Show() {
        this.render = __bind(this.render, this);
        Show.__super__.constructor.apply(this, arguments);
      }

      Show.prototype.tagName = 'section';

      Show.prototype.templateName = 'mobile/meetings/show';

      Show.prototype.initialize = function() {
        var _this = this;
        Show.__super__.initialize.apply(this, arguments);
        this.navigation = new (this.model.get('private') ? P.views.mobile.meetings.private.Navigation : x.Navigation)({
          model: this.model
        });
        this.labels = new P.views.shared.View({
          templateName: 'mobile/meetings/_labels',
          collection: this.model.labels
        });
        this.speakers = new P.views.mobile.users.List({
          collection: this.model.memberships.speakers(),
          title: "Speakers",
          itemOptions: function(model) {
            return {
              model: model.user
            };
          }
        });
        this.model.bind('change:labels', function() {
          return _this.html('.labels', _this.labels);
        });
        this.model.bind('change', function() {
          _this.html('.documents_count', _this.model.documents.length);
          return _this.html('.discussions_count', _this.model.discussions.length);
        });
        this.model.noRibbonUsers.bind('add', function() {
          return _this.html('.attendees_count', _this.model.noRibbonUsers.length);
        });
        return this.model.fetch();
      };

      Show.prototype.render = function() {
        Show.__super__.render.apply(this, arguments);
        this.html('.labels', this.labels);
        if (this.speakers.collection.length > 0) {
          this.html('.speakers', this.speakers);
        }
        this.html('.attendees_count', this.model.noRibbonUsers.length);
        this.html('.navigation', this.navigation);
        return this;
      };

      return Show;

    })(P.views.shared.mobile.Page);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.mobile.organizations', function(x) {
    return x.Index = (function(_super) {

      __extends(Index, _super);

      Index.prototype.templateName = 'mobile/organizations/index';

      function Index() {
        this.render = __bind(this.render, this);        Index.__super__.constructor.apply(this, arguments);
        this.collection.searchOptions = {
          per_page: 20
        };
        this.organizations = new P.views.shared.mobile.lists.List({
          collection: this.collection,
          itemOptions: {
            templateName: 'mobile/organizations/_organization'
          }
        });
        this.more = new P.views.shared.mobile.lists.More({
          collection: this.collection
        });
        this.collection.fetch();
      }

      Index.prototype.render = function() {
        Index.__super__.render.apply(this, arguments);
        this.prepend(':jqmData(role="content")', this.organizations);
        $(this.el).find('[data-role="header"] > h1').html("Exhibitors");
        this.replaceWith('.more', this.more);
        return this;
      };

      return Index;

    })(P.views.shared.mobile.Page);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.mobile.organizations', function(x) {
    return x.Show = (function(_super) {

      __extends(Show, _super);

      function Show() {
        this._changeModel = __bind(this._changeModel, this);
        this.render = __bind(this.render, this);
        Show.__super__.constructor.apply(this, arguments);
      }

      Show.prototype.tagName = 'section';

      Show.prototype.templateName = 'mobile/organizations/show';

      Show.prototype.initialize = function() {
        Show.__super__.initialize.apply(this, arguments);
        this.links = new P.views.shared.mobile.lists.List({
          itemType: P.views.mobile.links.LinkItem,
          title: 'Links',
          collection: this.model.links
        });
        this.members = new P.views.mobile.users.List({
          collection: this.model.users,
          title: "Staff"
        });
        this.tags = new P.views.shared.mobile.lists.List({
          itemType: P.views.organizations.Tag,
          title: 'Tags',
          collection: this.model.labels.tags
        });
        return this.model.bind('change', this._changeModel);
      };

      Show.prototype.render = function() {
        Show.__super__.render.apply(this, arguments);
        P.logger.debug(this.model);
        this.model.fetch();
        this.html('.members', this.members);
        this.html('.links', this.links);
        this.html('.tags', this.tags);
        this._changeModel();
        return this;
      };

      Show.prototype._changeModel = function() {
        return this.$('.organization_booth').toggle((this.model.get('booth') != null) && this.model.get('booth') !== "");
      };

      return Show;

    })(P.views.shared.mobile.Page);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.mobile.sessions', function(x) {
    return x.Form = (function(_super) {

      __extends(Form, _super);

      Form.prototype.templateName = 'mobile/sessions/_form';

      Form.prototype.features = [P.views.shared.forms.ErrorsFeature, P.views.shared.forms.FormValueGetFeature, P.views.shared.forms.FocusFeature];

      function Form() {
        this.render = __bind(this.render, this);
        this.trackSignin = __bind(this.trackSignin, this);
        this.saved = __bind(this.saved, this);
        this.formValues = __bind(this.formValues, this);
        var _this = this;
        Form.__super__.constructor.apply(this, arguments);
        this.model || (this.model = new P.models.Session());
        this.bind('saving', function() {
          return _this.model.set({
            id: null
          });
        });
        this.bind('saved', this.saved);
        this.bind('saved', this.trackSignin);
      }

      Form.prototype.formValues = function() {
        return _.defaults({
          remember_me: true
        }, this.getValues('user'));
      };

      Form.prototype.saved = function() {
        P.layout.flash.show({
          "class": 'success',
          message: "<b>\n  Welcome back, " + (P.user.get('first_name') || 'friend') + "!\n</b>"
        });
        return P.router.redirectTo('#');
      };

      Form.prototype.trackSignin = function() {
        return P.tracker.track('signins');
      };

      Form.prototype.render = function() {
        Form.__super__.render.apply(this, arguments);
        this.bindErrors();
        this.focus(true);
        return this;
      };

      return Form;

    })(P.views.shared.forms.Form);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.mobile.sessions', function(x) {
    return x.ResetPasswordForm = (function(_super) {

      __extends(ResetPasswordForm, _super);

      ResetPasswordForm.prototype.templateName = 'mobile/sessions/_reset_password_form';

      ResetPasswordForm.prototype.features = [P.views.shared.forms.ErrorsFeature, P.views.shared.forms.FormValueGetFeature, P.views.shared.forms.FocusFeature];

      function ResetPasswordForm() {
        this.render = __bind(this.render, this);
        this.saved = __bind(this.saved, this);
        this.formValues = __bind(this.formValues, this);
        var _this = this;
        ResetPasswordForm.__super__.constructor.apply(this, arguments);
        this.model || (this.model = new P.models.PasswordReset());
        this.bind('saving', function() {
          return _this.model.set({
            id: null
          });
        });
        this.bind('saved', this.saved);
      }

      ResetPasswordForm.prototype.formValues = function() {
        return this.getValues();
      };

      ResetPasswordForm.prototype.saved = function() {
        P.layout.flash.show({
          "class": 'success',
          message: "<b>Done.</b> You'll soon receive an email with instructions on resetting your password."
        });
        return P.router.redirectTo('#');
      };

      ResetPasswordForm.prototype.render = function() {
        ResetPasswordForm.__super__.render.apply(this, arguments);
        this.bindErrors();
        this.focus(true);
        return this;
      };

      return ResetPasswordForm;

    })(P.views.shared.forms.Form);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.mobile.sessions', function(x) {
    return x.New = (function(_super) {

      __extends(New, _super);

      New.prototype.templateName = 'mobile/sessions/new';

      function New() {
        New.__super__.constructor.apply(this, arguments);
        this.model = P.session;
        this.form = new x.Form({
          model: this.model
        });
      }

      New.prototype.render = function() {
        New.__super__.render.apply(this, arguments);
        this.append('[data-role=content]', this.form);
        return this;
      };

      return New;

    })(P.views.shared.mobile.Page);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.mobile.sessions', function(x) {
    return x.ResetPassword = (function(_super) {

      __extends(ResetPassword, _super);

      ResetPassword.prototype.templateName = 'mobile/sessions/reset_password';

      function ResetPassword() {
        ResetPassword.__super__.constructor.apply(this, arguments);
        this.model = new P.models.PasswordReset();
        this.form = new x.ResetPasswordForm({
          model: this.model
        });
      }

      ResetPassword.prototype.render = function() {
        ResetPassword.__super__.render.apply(this, arguments);
        this.append('[data-role=content]', this.form);
        return this;
      };

      return ResetPassword;

    })(P.views.shared.mobile.Page);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.mobile.users', function(x) {
    return x.List = (function(_super) {

      __extends(List, _super);

      function List() {
        List.__super__.constructor.apply(this, arguments);
      }

      List.prototype.itemType = x.User;

      return List;

    })(P.views.shared.mobile.lists.List);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.mobile.users', function(x) {
    return x.SmallCard = (function(_super) {

      __extends(SmallCard, _super);

      SmallCard.prototype.templateName = 'mobile/users/_user';

      function SmallCard() {
        this.render = __bind(this.render, this);        SmallCard.__super__.constructor.apply(this, arguments);
        this.ribbons = new P.views.mobile.ribbons.List({
          collection: this.model.ribbons
        });
      }

      SmallCard.prototype.render = function() {
        SmallCard.__super__.render.apply(this, arguments);
        this.replaceWith('.ribbons', this.ribbons);
        return this;
      };

      return SmallCard;

    })(P.views.shared.mobile.View);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.mobile.users', function(x) {
    return x.Index = (function(_super) {

      __extends(Index, _super);

      Index.prototype.tagName = 'section';

      Index.prototype.templateName = 'mobile/users/index';

      function Index() {
        this.render = __bind(this.render, this);        Index.__super__.constructor.apply(this, arguments);
        this.collection = new P.models.Users([], {
          searchOptions: {
            per_page: 25
          }
        });
        this.users = new x.List({
          collection: this.collection
        });
        this.search = new P.views.shared.mobile.lists.Search({
          list: this.users
        });
      }

      Index.prototype.render = function() {
        Index.__super__.render.apply(this, arguments);
        this.html('.search', this.search);
        return this;
      };

      Index.prototype.title = function() {
        return 'Attendees';
      };

      return Index;

    })(P.views.shared.mobile.Page);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.mobile.users', function(x) {
    return x.Show = (function(_super) {

      __extends(Show, _super);

      Show.prototype.tagName = 'section';

      Show.prototype.templateName = 'mobile/users/show';

      Show.prototype.events = {
        'click a.create-contact': 'createContact',
        'click a.destroy-contact': 'destroyContact',
        'click a.photo_link': 'gotoPhoto'
      };

      function Show() {
        this._setupAddRemoveContact = __bind(this._setupAddRemoveContact, this);
        this.gotoPhoto = __bind(this.gotoPhoto, this);
        this.destroyContact = __bind(this.destroyContact, this);
        this.createContact = __bind(this.createContact, this);
        this.loginout = __bind(this.loginout, this);
        var _this = this;
        Show.__super__.constructor.apply(this, arguments);
        this.links = new P.views.shared.mobile.lists.List({
          itemType: P.views.mobile.links.LinkItem,
          title: 'Websites',
          collection: this.model.links
        });
        this.posts = new P.views.shared.mobile.lists.List({
          itemType: P.views.mobile.posts.PostItem,
          title: 'Posts',
          collection: this.model.posts.limit(5)
        });
        this.tweets = new P.views.shared.mobile.lists.List({
          itemType: P.views.mobile.tweets.TweetItem,
          title: 'Tweets',
          collection: this.model.tweets.limit(5)
        });
        this.categories = new P.views.shared.mobile.lists.List({
          itemType: P.views.labels.Label,
          addClass: 'labels',
          tagName: 'div',
          className: 'labels',
          collection: this.model.categories
        });
        this.ribbons = new P.views.shared.mobile.lists.List({
          itemType: P.views.mobile.ribbons.Ribbon,
          collection: this.model.ribbons,
          tagName: 'div',
          className: 'ribbons',
          title: false
        });
        _.each('add remove'.split(/\s+/), function(event) {
          return _this.model.user_contactees.bind(event, _this._setupAddRemoveContact);
        });
      }

      Show.prototype.render = function() {
        Show.__super__.render.apply(this, arguments);
        this.replaceWith('.links', this.links);
        this.replaceWith('.posts', this.posts);
        this.replaceWith('.categories', this.categories);
        this.replaceWith('.ribbons', this.ribbons);
        this.replaceWith('.tweets', this.tweets);
        this.model.fetch();
        this.model.posts.fetch();
        this.model.tweets.fetch();
        this._setupAddRemoveContact();
        return this;
      };

      Show.prototype.loginout = function(session, loggedIn) {
        Show.__super__.loginout.apply(this, arguments);
        return this.$('.button_holder').toggle(loggedIn);
      };

      Show.prototype.createContact = function(e) {
        var userContact,
          _this = this;
        e.preventDefault();
        userContact = new P.models.UserContact({
          contact_id: this.model.id
        });
        P.user.user_contacts.add(userContact);
        return userContact.save({}, {
          success: function(uc) {
            _this.model.user_contactees.add(uc);
            return P.layout.flash.show({
              message: 'Contact added',
              "class": 'info'
            });
          }
        });
      };

      Show.prototype.destroyContact = function(e) {
        var model, userContactId, _ref,
          _this = this;
        e.preventDefault();
        userContactId = (_ref = this.model.user_contactees.find(function(model) {
          return model.isMarked();
        })) != null ? _ref.get('id') : void 0;
        model = P.user.user_contacts.get(userContactId);
        model || (model = P.user.user_contacts.add({
          id: userContactId
        }).get(userContactId));
        return model.destroy({
          success: function() {
            _this.model.user_contactees.remove(model);
            return P.layout.flash.show({
              message: 'Contact removed',
              "class": 'info'
            });
          }
        });
      };

      Show.prototype.gotoPhoto = function(e) {
        e.preventDefault();
        return this.goto("#users/" + this.model.id + "/photo");
      };

      Show.prototype._setupAddRemoveContact = function() {
        var userContactId, _ref;
        userContactId = (_ref = this.model.user_contactees.find(function(model) {
          return model.isMarked();
        })) != null ? _ref.get('id') : void 0;
        this.$('.create-contact').toggle(!(userContactId != null));
        return this.$('.destroy-contact').toggle(userContactId != null);
      };

      return Show;

    })(P.views.shared.mobile.Page);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.mobile.users', function(x) {
    return x.ShowPhoto = (function(_super) {

      __extends(ShowPhoto, _super);

      function ShowPhoto() {
        ShowPhoto.__super__.constructor.apply(this, arguments);
      }

      ShowPhoto.prototype.tagName = 'section';

      ShowPhoto.prototype.templateName = 'mobile/users/show_photo';

      ShowPhoto.prototype.render = function() {
        ShowPhoto.__super__.render.apply(this, arguments);
        this.model.fetch();
        return this;
      };

      return ShowPhoto;

    })(P.views.shared.mobile.Page);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.oauth_consumers', function(x) {
    return x.Edit = (function(_super) {

      __extends(Edit, _super);

      function Edit() {
        Edit.__super__.constructor.apply(this, arguments);
      }

      Edit.prototype.templateName = 'oauth_consumers/_edit';

      Edit.prototype.className = function() {
        return "" + Edit.__super__.className.apply(this, arguments) + " oauth list";
      };

      return Edit;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.pages', function(x) {
    return x.Show = (function(_super) {

      __extends(Show, _super);

      function Show() {
        this.render = __bind(this.render, this);
        this.initialize = __bind(this.initialize, this);
        Show.__super__.constructor.apply(this, arguments);
      }

      Show.prototype.className = function() {
        return "" + Show.__super__.className.apply(this, arguments) + " pages show";
      };

      Show.prototype.initialize = function() {
        Show.__super__.initialize.apply(this, arguments);
        return this.templateName = "pages/custom/" + (this.options.templateName || 'example');
      };

      Show.prototype.render = function() {
        Show.__super__.render.apply(this, arguments);
        return this;
      };

      return Show;

    })(P.views.shared.Page);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.posts', function(x) {
    return x.List = (function(_super) {

      __extends(List, _super);

      function List() {
        List.__super__.constructor.apply(this, arguments);
      }

      List.prototype.className = function() {
        return "" + List.__super__.className.apply(this, arguments) + " overline with_hover";
      };

      List.prototype.itemType = x.Post;

      return List;

    })(P.views.shared.lists.TitledList);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.posts', function(x) {
    return x.Index = (function(_super) {

      __extends(Index, _super);

      function Index() {
        Index.__super__.constructor.apply(this, arguments);
      }

      Index.prototype.title = 'Posts';

      Index.prototype.templateName = 'posts/index';

      Index.prototype.className = function() {
        return "" + Index.__super__.className.apply(this, arguments) + " posts index";
      };

      Index.prototype.initialize = function() {
        Index.__super__.initialize.apply(this, arguments);
        return this.posts = new P.views.posts.List({
          collection: P.community.posts.limit(50),
          templateOptions: {
            title: 'Recent Posts',
            exclude: []
          }
        });
      };

      Index.prototype.render = function() {
        Index.__super__.render.apply(this, arguments);
        P.community.posts.fetch();
        this.replaceWith('.posts', this.posts);
        return this;
      };

      return Index;

    })(P.views.shared.Page);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.ribbons', function(x) {
    return x.Ribbon = (function(_super) {

      __extends(Ribbon, _super);

      function Ribbon() {
        this.render = __bind(this.render, this);
        Ribbon.__super__.constructor.apply(this, arguments);
      }

      Ribbon.prototype.tagName = 'span';

      Ribbon.prototype.initialize = function() {
        Ribbon.__super__.initialize.apply(this, arguments);
        return this.model.bind('change', this.render);
      };

      Ribbon.prototype.destroy = function() {
        Ribbon.__super__.destroy.apply(this, arguments);
        return this.model.unbind('change', this.render);
      };

      Ribbon.prototype.render = function() {
        var name;
        Ribbon.__super__.render.apply(this, arguments);
        name = this.model.get('name');
        $(this.el).addClass('ribbon').addClass(name.toLowerCase()).attr({
          title: name
        }).html(name);
        return this;
      };

      return Ribbon;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.roles', function(x) {
    return x.Form = (function(_super) {

      __extends(Form, _super);

      Form.prototype.className = function() {
        return "" + Form.__super__.className.apply(this, arguments) + " users-form formtastic";
      };

      Form.prototype.tagName = 'form';

      Form.prototype.templateName = 'users/_form';

      Form.prototype.events = function() {
        return _.extend(Form.__super__.events.apply(this, arguments), {
          'submit': 'save'
        });
      };

      function Form() {
        Form.__super__.constructor.apply(this, arguments);
        this.bind('saved', this.saved);
        this.bind('edit', this.setup);
      }

      Form.prototype.parts = {
        basics: P.views.users.FormBasics,
        details: P.views.users.FormDetails
      };

      Form.prototype.saved = function() {
        switch (this.tabs.get('selected')) {
          case 0:
            return this.tabs.set('selected', 1);
          case 1:
            if (this.parent instanceof P.views.shared.Dialog) {
              return this.parent.close();
            } else {
              P.user.fetch();
              return P.router.redirectTo('#user');
            }
        }
      };

      Form.prototype.render = function() {
        Form.__super__.render.apply(this, arguments);
        this.replaceWith('.tabs', this.tabs);
        return this;
      };

      return Form;

    })(P.views.shared.forms.Form);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.static_suggestions', function(x) {
    return x.List = (function(_super) {

      __extends(List, _super);

      function List() {
        this._select = __bind(this._select, this);
        this._click = __bind(this._click, this);
        this._prevent = __bind(this._prevent, this);
        this.render = __bind(this.render, this);
        this.initialize = __bind(this.initialize, this);
        List.__super__.constructor.apply(this, arguments);
      }

      List.prototype.className = function() {
        return "" + List.__super__.className.apply(this, arguments) + " groups-list-set tag_list";
      };

      List.prototype.events = function() {
        return _.extend(List.__super__.events.apply(this, arguments), {
          'click a': '_prevent',
          'click h4': '_click'
        });
      };

      List.prototype.multi = true;

      List.prototype.selectable = true;

      List.prototype.itemType = P.views.groups.TagGroup;

      List.prototype.initialize = function() {
        List.__super__.initialize.apply(this, arguments);
        this.bind('select', function(model, view) {
          if (this.parent == null) return $(view.el).fadeTo('fast', 0.5);
        });
        this.bind('unselect', function(model, view) {
          if (this.parent == null) return $(view.el).fadeTo('fast', 1.0);
        });
        return this.bind('toggle', function(model, view, selected) {
          return view.$('a').toggleClass('selected', selected);
        });
      };

      List.prototype.render = function() {
        List.__super__.render.apply(this, arguments);
        if (this.parent != null) this._select($('h4:first', this.parent.el));
        if (!this.$('p.inline-hints').length) {
          this.$(this.el).prepend("<p class='inline-hints'>" + (this.options.hint || '') + "</p>");
        }
        return this;
      };

      List.prototype._prevent = function(e) {
        return e.preventDefault();
      };

      List.prototype._click = function(e) {
        return this._select(e.currentTarget);
      };

      List.prototype._select = function(el) {
        if (this.parent == null) return;
        $(this.parent.el).find('h4 + ol').slideUp();
        return $(el).find('+ol').slideDown();
      };

      return List;

    })(P.views.shared.lists.TitledList);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.templates', function(x) {
    return x.Form = (function(_super) {

      __extends(Form, _super);

      function Form() {
        this.render = __bind(this.render, this);
        this.saved = __bind(this.saved, this);
        this.setup = __bind(this.setup, this);
        this.formValues = __bind(this.formValues, this);
        this.initialize = __bind(this.initialize, this);
        Form.__super__.constructor.apply(this, arguments);
      }

      Form.prototype.className = function() {
        return "" + Form.__super__.className.apply(this, arguments) + " templates-form";
      };

      Form.prototype.templateName = 'templates/_form';

      Form.prototype.features = [P.views.shared.forms.ErrorsFeature, P.views.shared.forms.FormValueGetFeature, P.views.shared.forms.FormValueSetFeature, P.views.shared.forms.FocusFeature, P.views.links.FormFeature];

      Form.prototype.initialize = function() {
        Form.__super__.initialize.apply(this, arguments);
        this.templateOptions.layouts = null;
        this.editor = new P.views.shared.HtmlEditor({
          config: this.options.markItUpSet
        });
        this.bind('saved', this.saved);
        return this.bind('edit', this.setup);
      };

      Form.prototype.formValues = function() {
        var values;
        values = this.getValues();
        values['send_preview'] = this.$('input.send_preview').val();
        values['body'] = this.$('.body textarea').val();
        return values;
      };

      Form.prototype.setup = function() {
        this.bindErrors();
        this.setValues();
        this.editor.setContent(this.model.get('body') || '');
        return this.$('.layout_id').show();
      };

      Form.prototype.saved = function(model) {
        return P.layout.flash.show({
          message: P.localizer.t('template_updated')
        });
      };

      Form.prototype.render = function() {
        Form.__super__.render.apply(this, arguments);
        this.replaceWith('.body > textarea', this.editor);
        return this;
      };

      return Form;

    })(P.views.shared.forms.Form);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.templates', function(x) {
    return x.Preview = (function(_super) {

      __extends(Preview, _super);

      function Preview() {
        this.preview = __bind(this.preview, this);
        this.render = __bind(this.render, this);
        this.initialize = __bind(this.initialize, this);
        Preview.__super__.constructor.apply(this, arguments);
      }

      Preview.prototype.className = function() {
        return "" + Preview.__super__.className.apply(this, arguments) + " templates-preview";
      };

      Preview.prototype.templateName = 'templates/_preview';

      Preview.prototype.initialize = function() {
        Preview.__super__.initialize.apply(this, arguments);
        return this.templateOptions.inIframe = true;
      };

      Preview.prototype.render = function() {
        Preview.__super__.render.apply(this, arguments);
        this.$('iframe').hide();
        return this;
      };

      Preview.prototype.preview = function(model) {
        var _this = this;
        if (model == null) return false;
        if (this.templateOptions.inIframe) this.$('iframe').hide();
        model.preview = true;
        return model.fetch({
          success: function(results) {
            if (_this.templateOptions.inIframe) {
              _this.$('iframe').prop('src', "" + (model.url()) + ".html");
              return _this.$('iframe').show();
            } else {
              return _this.replaceWith('.templates-preview', '<div class="templates-preview">' + model.get('preview') + '</div>');
            }
          }
        }, model.preview = false);
      };

      return Preview;

    })(P.views.shared.Component);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.templates.jst', function(x) {
    return x.Form = (function(_super) {

      __extends(Form, _super);

      function Form() {
        this.setup = __bind(this.setup, this);
        Form.__super__.constructor.apply(this, arguments);
      }

      Form.prototype.setup = function() {
        Form.__super__.setup.apply(this, arguments);
        return this.$('.layout_id').hide();
      };

      Form.prototype.formValues = function() {
        return _.extend(Form.__super__.formValues.apply(this, arguments), {
          type: 'Templates::Jst'
        });
      };

      return Form;

    })(P.views.templates.Form);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.templates.mail', function(x) {
    return x.Form = (function(_super) {

      __extends(Form, _super);

      function Form() {
        this.saved = __bind(this.saved, this);
        this.setup = __bind(this.setup, this);
        Form.__super__.constructor.apply(this, arguments);
      }

      Form.prototype.templateName = 'templates/mail/_form';

      Form.prototype.initialize = function() {
        Form.__super__.initialize.apply(this, arguments);
        return this.templateOptions.layouts = P.community.mail_templates.layouts;
      };

      Form.prototype.formValues = function() {
        return _.extend(Form.__super__.formValues.apply(this, arguments), {
          type: 'Templates::Mail'
        });
      };

      Form.prototype.setup = function() {
        Form.__super__.setup.apply(this, arguments);
        if (this.model.get('role') !== 'page') return this.$('.layout_id').hide();
      };

      Form.prototype.saved = function(model) {
        Form.__super__.saved.apply(this, arguments);
        return P.community.associate('mail_template', model);
      };

      return Form;

    })(P.views.templates.Form);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.tweets', function(x) {
    return x.Index = (function(_super) {

      __extends(Index, _super);

      function Index() {
        Index.__super__.constructor.apply(this, arguments);
      }

      Index.prototype.title = 'Twitter';

      Index.prototype.templateName = 'tweets/index';

      Index.prototype.className = function() {
        return "" + Index.__super__.className.apply(this, arguments) + " tweets index";
      };

      Index.prototype.initialize = function() {
        Index.__super__.initialize.apply(this, arguments);
        return this.tweets = new P.views.shared.lists.TitledList({
          itemType: P.views.tweets.Tweet,
          addClass: 'overline with_hover',
          collection: P.community.tweets.limit(50),
          templateOptions: {
            title: 'Recent Tweets',
            exclude: []
          }
        });
      };

      Index.prototype.render = function() {
        Index.__super__.render.apply(this, arguments);
        P.community.tweets.fetch();
        this.replaceWith('.tweets', this.tweets);
        return this;
      };

      return Index;

    })(P.views.shared.Page);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.users.settings', function(x) {
    return x.Form = (function(_super) {

      __extends(Form, _super);

      function Form() {
        Form.__super__.constructor.apply(this, arguments);
      }

      Form.prototype.className = function() {
        return "" + Form.__super__.className.apply(this, arguments) + " formtastic";
      };

      Form.prototype.templateName = 'users/subscriptions/_form';

      Form.prototype.features = [P.views.shared.forms.ErrorsFeature, P.views.shared.forms.FormValueGetFeature, P.views.shared.forms.FormValueSetFeature, P.views.shared.forms.FocusFeature];

      Form.prototype.initialize = function() {
        Form.__super__.initialize.apply(this, arguments);
        this.buttons = new P.views.shared.ControlBar({
          controls: ['save']
        });
        this.bind('saved', this.saved);
        return this.bind('edit', this.setup);
      };

      Form.prototype.setup = function() {
        this.bindErrors();
        this.$('input#subscription_enabled_1').prop('checked', true);
        return this.$('.email input').val(P.user.get('primary_email'));
      };

      Form.prototype.formValues = function() {
        var values;
        values = this.getValues();
        return _.extend(values, {
          enabled: this.$('input#subscription_enabled_1').prop('checked')
        });
      };

      Form.prototype.saved = function(model) {
        if (this.model.get('enabled')) {
          return P.layout.flash.show({
            message: P.localizer.t('email_alerts_enabled'),
            "class": 'info'
          });
        } else {
          return P.layout.flash.show({
            message: P.localizer.t('email_alerts_disabled'),
            "class": 'info'
          });
        }
      };

      return Form;

    })(P.views.shared.forms.Form);
  });

}).call(this);

(function() {



}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.views.users.subscriptions', function(x) {
    return x.Form = (function(_super) {

      __extends(Form, _super);

      function Form() {
        Form.__super__.constructor.apply(this, arguments);
      }

      Form.prototype.className = function() {
        return "" + Form.__super__.className.apply(this, arguments) + " formtastic";
      };

      Form.prototype.templateName = 'users/subscriptions/_form';

      Form.prototype.features = [P.views.shared.forms.ErrorsFeature, P.views.shared.forms.FormValueGetFeature, P.views.shared.forms.FormValueSetFeature, P.views.shared.forms.FocusFeature];

      Form.prototype.initialize = function() {
        Form.__super__.initialize.apply(this, arguments);
        this.buttons = new P.views.shared.ControlBar({
          controls: ['save']
        });
        this.bind('saved', this.saved);
        return this.bind('edit', this.setup);
      };

      Form.prototype.setup = function() {
        var _this = this;
        Form.__super__.setup.apply(this, arguments);
        this.bindErrors({
          handler: function(error, messages) {
            switch (error.attribute) {
              case 'primary_email':
                return _this.flash.show({
                  message: P.localizer.t('subscription_email', {
                    support_email: P.settings.ops.support_email,
                    scope: ['forms', 'errors']
                  }),
                  "class": 'error'
                });
            }
          }
        });
        this.bindErrors();
        this.setValues();
        return this.$('input#subscription_enabled_1').prop('checked', true);
      };

      Form.prototype.formValues = function() {
        var values;
        values = this.getValues();
        return _.extend(values, {
          enabled: this.$('input#subscription_enabled_1').prop('checked')
        });
      };

      Form.prototype.saved = function(model) {
        if (this.model.get('enabled')) {
          return P.layout.flash.show({
            message: P.localizer.t('community_email_alerts_enabled'),
            "class": 'info'
          });
        } else {
          return P.layout.flash.show({
            message: P.localizer.t('community_email_alerts_disabled'),
            "class": 'info'
          });
        }
      };

      return Form;

    })(P.views.shared.forms.Form);
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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; };

  P.namespace('P.views.users.subscriptions', function(x) {
    return x.Edit = (function(_super) {

      __extends(Edit, _super);

      function Edit() {
        this._block = __bind(this._block, this);
        this.login = __bind(this.login, this);
        Edit.__super__.constructor.apply(this, arguments);
      }

      Edit.prototype.title = 'Subscription';

      Edit.prototype.templateName = 'users/subscriptions/edit';

      Edit.prototype.className = function() {
        return "" + Edit.__super__.className.apply(this, arguments) + " subscriptions show";
      };

      Edit.prototype.initialize = function() {
        Edit.__super__.initialize.apply(this, arguments);
        this.form = new x.Form({
          parent: this,
          model: this.model.subscription()
        });
        return this.bind('route', this._block);
      };

      Edit.prototype.render = function() {
        Edit.__super__.render.apply(this, arguments);
        this.replaceWith('.form', this.form);
        this.form.edit(this.model.subscription());
        return this;
      };

      Edit.prototype.login = function() {
        Edit.__super__.login.apply(this, arguments);
        return this._block();
      };

      Edit.prototype._block = function() {
        if (P.session.get('logged_in')) return P.router.redirectTo('#user/edit');
      };

      return Edit;

    })(P.views.shared.Page);
  });

}).call(this);

(function() {

  P.namespace('P.helpers', function(x) {
    return x.Authentication = {
      requireLogin: function() {
        if (P.session.get('logged_in')) return true;
        P.logger.debug('Action requires login, redirecting to home.');
        P.layout.flash.show({
          message: P.localizer.t('require_signin'),
          hide: true,
          "class": 'warn'
        });
        window.location.hash = '#';
        return false;
      },
      authenticateUser: function() {
        if (P.community.settings.get('public')) {
          P.logger.debug('Public event, access allowed.');
          return true;
        } else if (P.session.get('logged_in')) {
          P.logger.debug('Private event and user logged in, access allowed.');
          return true;
        } else {
          P.logger.debug('Private event and user not logged in, access denied.');
          this.redirectTo('#community/private');
          return false;
        }
      },
      authenticateHost: function() {
        if (P.user.hasRole('admin', P.community)) {
          P.logger.debug('Host logged in.');
          return true;
        } else {
          P.logger.debug('Access denied to host tools.');
          this.redirectTo('/');
          return false;
        }
      },
      authenticateAdmin: function() {
        if (P.session.get('admin_logged_in')) {
          P.logger.debug('Admin logged in.');
          return true;
        } else {
          P.logger.debug('Access denied for Admin.');
          this.redirectTo('#session/new');
          return false;
        }
      }
    };
  });

}).call(this);

(function() {

  P.namespace('P.helpers', function(x) {
    return x.Cookies = {
      setCookie: function(name, value, days) {
        var date, expires;
        if (days) {
          date = new Date();
          date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
          expires = "; expires=" + date.toGMTString();
        } else {
          expires = "";
        }
        return document.cookie = name + "=" + value + expires + "; path=/";
      },
      getCookie: function(name) {
        var ca, nameEQ, value, _i, _len;
        nameEQ = name + "=";
        ca = document.cookie.split(';');
        for (_i = 0, _len = ca.length; _i < _len; _i++) {
          value = ca[_i];
          while (value.charAt(0) === ' ') {
            value = value.substring(1, value.length);
          }
          if (value.indexOf(nameEQ) === 0) {
            return value.substring(nameEQ.length, value.length);
          }
        }
        return null;
      },
      deleteCookie: function(name) {
        return this.setCookie(name, "", -1);
      }
    };
  });

}).call(this);

(function() {

  P.namespace('P.helpers', function(x) {
    return x.Tracking = {
      track: function(event, properties) {
        var _ref, _ref2;
        if (properties == null) properties = {};
        _.defaults(properties, {
          user_id: (_ref = P.user) != null ? _ref.get('id') : void 0,
          event_id: (_ref2 = P.event) != null ? _ref2.get('id') : void 0
        });
        P.tracker.track(event, properties);
        return true;
      }
    };
  });

}).call(this);

(function() {
  var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
    __hasProp = Object.prototype.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 = Array.prototype.slice;

  P.namespace('P.routers', function(x) {
    x.ApplicationRouter = (function(_super) {

      __extends(ApplicationRouter, _super);

      function ApplicationRouter() {
        this.load = __bind(this.load, this);
        this.navigate = __bind(this.navigate, this);
        this.filter = __bind(this.filter, this);
        this.params = __bind(this.params, this);
        this.changeView = __bind(this.changeView, this);
        this.routeOnce = __bind(this.routeOnce, this);
        this.routeTo = __bind(this.routeTo, this);
        this.redirectTo = __bind(this.redirectTo, this);
        this.beforeFilter = __bind(this.beforeFilter, this);
        var _this = this;
        this.route('*splat', 'notfound', function(splat) {
          P.layout.flash.show({
            message: P.localizer.t('route_not_found', {
              route: splat
            }),
            hide: true,
            "class": 'warn'
          });
          return _this.redirectTo('#');
        });
        ApplicationRouter.__super__.constructor.apply(this, arguments);
      }

      ApplicationRouter.prototype.initialize = function() {
        ApplicationRouter.__super__.initialize.apply(this, arguments);
        _.bindAll(this, 'authenticateAdmin', 'authenticateUser', 'authenticateHost', 'track');
        this.views = {};
        this.filters = [];
        if (_.isFunction(this.layout)) {
          return this.layout = new this.layout({
            el: 'body',
            router: this
          }).render();
        }
      };

      ApplicationRouter.prototype.beforeFilter = function(filter, options) {
        var except, only;
        if (options == null) options = {};
        except = this._compact(_.flatten([options.except]));
        only = this._compact(_.flatten([options.only]));
        return this.filters.push({
          only: only,
          except: except,
          filter: filter
        });
      };

      ApplicationRouter.prototype.redirectTo = function(url, skipFilters) {
        this.skipFilters = skipFilters != null ? skipFilters : true;
        return window.location[/$\#/.test(url) && 'hash' || 'href'] = url;
      };

      ApplicationRouter.prototype.route = function(route, name, callback) {
        var filteredCallback,
          _this = this;
        filteredCallback = function() {
          if (!(_this.skipFilters || _this.filter({
            name: Backbone.history.fragment
          }))) {
            return false;
          }
          _this.skipFilters = false;
          return callback.apply(_this, arguments);
        };
        return ApplicationRouter.__super__.route.call(this, route, name, filteredCallback);
      };

      ApplicationRouter.prototype.routeTo = function(view, options) {
        var name, _base;
        if (options == null) options = {};
        this.navigate(name = Backbone.history.fragment);
        if (_.isFunction(view)) {
          view = (_base = this.views)[name] || (_base[name] = new view(options).render());
        }
        this.changeView(this.visible, (this.visible = view));
        this.trigger('route', this.visible);
        return this.visible.trigger('route');
      };

      ApplicationRouter.prototype.routeOnce = function(view, options) {
        if (options == null) options = {};
        if (view = this.routeTo.apply(this, arguments)) {
          view.render();
          return this.one('route', function() {
            return view.destroy();
          });
        }
      };

      ApplicationRouter.prototype.changeView = function(from, to) {
        if (from != null) from.$el.hide();
        to.$el.show();
        return P.title();
      };

      ApplicationRouter.prototype.params = function() {
        var params;
        params = $.url().fparam();
        _.each(_.keys(params), function(key) {
          return params[key] = decodeURIComponent(params[key]);
        });
        return params;
      };

      ApplicationRouter.prototype.filter = function(options) {
        var successful,
          _this = this;
        if (options == null) options = {};
        successful = true;
        _.each(this.filters, function(filter) {
          if (_this._include(filter, options.name) && !filter.filter(_this)) {
            return successful = false;
          }
        });
        return successful;
      };

      ApplicationRouter.prototype.navigate = function(name) {};

      ApplicationRouter.prototype.load = function() {
        var items, _ref,
          _this = this;
        items = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
        items = _.compact(_.flatten(items));
        this.trigger('loading');
        if ((_ref = this._loading) != null) _ref.reject();
        this._loading = $.Deferred().done(function() {
          return _this.trigger('load');
        });
        if (_.all(_.invoke(items, 'fetched'), _.identity)) this._loading.resolve();
        $.when.apply($, _.invoke(items, 'fetch')).done(function() {
          return _this._loading.resolve();
        });
        return this._loading.promise();
      };

      ApplicationRouter.prototype._include = function(filter, name) {
        if (!(filter.only.length || filter.except.length)) return true;
        return (filter.only.length && _.include(filter.only, name)) || (filter.except.length && !_.include(filter.except, name));
      };

      ApplicationRouter.prototype._compact = function(array) {
        return _.without(array, null, void 0);
      };

      return ApplicationRouter;

    })(Backbone.Router);
    return _.extend(x.ApplicationRouter.prototype, P.helpers.Authentication, P.helpers.Tracking, P.Events);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.routers', function(x) {
    return x.AttendeeRouter = (function(_super) {

      __extends(AttendeeRouter, _super);

      function AttendeeRouter() {
        AttendeeRouter.__super__.constructor.apply(this, arguments);
        this.beforeFilter(this.requireLogin, {
          only: ['inbox', 'contacts', 'connections', 'user/edit']
        });
        this.beforeFilter(this.authenticateUser, {
          except: ['community/private', 'signin']
        });
        this.bind('route', this.trackPageview);
        this.statusChecker = new P.models.status.Checker();
        this.statusChecker.start();
      }

      AttendeeRouter.prototype.layout = P.views.layouts.Application;

      AttendeeRouter.prototype.routes = {
        'community': 'communityShow',
        'community/private': 'communityPrivate',
        'discussions': 'discussions',
        'discussions/:id': 'discussions',
        'inbox': 'inbox',
        'inbox/:id': 'inbox',
        'page/:id': 'page',
        'groups': 'groups',
        'groups/edit/:id': 'groupEdit',
        'groups/:id': 'groupShow',
        'organizations': 'organizations',
        'organizations/edit/:id': 'organizationEdit',
        'organizations/:id': 'organizationShow',
        'posts': 'posts',
        'tweets': 'tweets',
        'users': 'usersIndex',
        'user': 'user',
        'users/:id': 'users',
        'user/edit': 'userEdit',
        'user/edit/:tab': 'userEdit',
        'user/subscription&:params': 'subscription',
        'signin': 'signin',
        'meetings': 'meetings',
        'meetings/new:p': 'meetingsNew',
        'meetings/my': 'meetingsMy',
        'meetings/label/:label': 'meetings',
        'meetings/my/label/:label': 'meetingsMy',
        'meetings/:id': 'meetingShow',
        'contacts': 'contactsIndex',
        'connections': 'connectionsIndex',
        '': 'communityShow'
      };

      AttendeeRouter.prototype.navigate = function(name) {
        var _ref, _ref2;
        this.layout.navigation.activate(name);
        if ((_ref = P.layout.flash) != null) _ref.hide();
        if ((_ref2 = P.layout.spinner) != null) _ref2.$el.hide();
        return P.layout.navigation.close_dropdown();
      };

      AttendeeRouter.prototype.meetings = function(label) {
        var _this = this;
        return this.load(P.community.calendar.meetings).done(function() {
          var _base;
          _this.routeTo((_base = _this.views).meetings || (_base.meetings = new P.views.meetings.Index({
            collection: P.community.calendar.meetings,
            label_id: label
          }).render()));
          return _this.visible.filter(label);
        });
      };

      AttendeeRouter.prototype.meetingsMy = function(label) {
        var _this = this;
        return this.load(P.user.meetings).done(function() {
          var _base;
          _this.routeTo((_base = _this.views).meetingsMy || (_base.meetingsMy = new P.views.meetings.My({
            collection: P.user.meetings,
            label_id: label
          }).render()));
          return _this.visible.filter(label);
        });
      };

      AttendeeRouter.prototype.meetingShow = function(id) {
        var model,
          _this = this;
        return this.load(model = new P.models.Meeting({
          id: id
        })).done(function() {
          return _this.routeOnce(new P.views.meetings.Show({
            model: model
          }));
        });
      };

      AttendeeRouter.prototype.meetingsNew = function() {
        var model, user,
          _this = this;
        model = new P.models.Meeting({
          private: true,
          calendar_id: P.community.calendar.id
        });
        user = new P.models.User({
          id: +this.params().user
        });
        model.users.add([P.user, user]);
        return this.load(P.user, user).done(function() {
          return _this.routeOnce(new P.views.meetings.EditPage({
            model: model
          }));
        });
      };

      AttendeeRouter.prototype.communityShow = function() {
        return this.routeTo(P.views.communities.Show, {
          model: P.community
        });
      };

      AttendeeRouter.prototype.communityPrivate = function(x) {
        return this.routeTo(P.views.communities.Private);
      };

      AttendeeRouter.prototype.discussions = function(id) {
        return this._discussions(id, P.community.discussions, 'discussions');
      };

      AttendeeRouter.prototype.inbox = function(id) {
        return this._discussions(id, P.user.discussions.private, 'inbox');
      };

      AttendeeRouter.prototype.page = function(templateName) {
        return this.routeTo(P.views.pages.Show, {
          templateName: templateName
        });
      };

      AttendeeRouter.prototype.groups = function() {
        var _this = this;
        return this.load(P.community.groups).done(function() {
          var _base;
          return _this.routeTo((_base = _this.views).groups || (_base.groups = new P.views.groups.Index({
            collection: P.community.groups
          }).render()));
        });
      };

      AttendeeRouter.prototype.groupShow = function(id) {
        var model,
          _this = this;
        return this.load(model = new P.models.Group({
          id: id
        })).done(function() {
          return _this.routeOnce(new P.views.groups.Show({
            model: model
          }));
        });
      };

      AttendeeRouter.prototype.groupEdit = function(id) {
        return this.routeTo(P.views.groups.Edit, {
          model: new P.models.Group({
            id: id
          })
        });
      };

      AttendeeRouter.prototype.organizations = function() {
        return this.routeTo(P.views.organizations.Index, {
          collection: P.community.organizations
        });
      };

      AttendeeRouter.prototype.organizationShow = function(id) {
        return this.routeOnce(new P.views.organizations.Show({
          model: new P.models.Organization({
            id: id
          })
        }));
      };

      AttendeeRouter.prototype.organizationEdit = function(id) {
        return this.routeTo(P.views.organizations.Edit, {
          model: new P.models.Organization({
            id: id
          })
        });
      };

      AttendeeRouter.prototype.posts = function() {
        return this.routeTo(P.views.posts.Index);
      };

      AttendeeRouter.prototype.tweets = function() {
        return this.routeTo(P.views.tweets.Index);
      };

      AttendeeRouter.prototype.subscription = function(params) {
        params = this.params(params);
        return this.routeTo(P.views.users.subscriptions.Edit, {
          model: new P.models.User({
            id: params['i'],
            primary_email: params['e']
          })
        });
      };

      AttendeeRouter.prototype.usersIndex = function() {
        return this.routeTo(P.views.users.Index);
      };

      AttendeeRouter.prototype.userEdit = function(tab) {
        var view;
        tab || (tab = 0);
        return view = this.routeTo(P.views.users.Edit, {
          tab: tab
        });
      };

      AttendeeRouter.prototype.user = function() {
        return this.users(P.session.user.id);
      };

      AttendeeRouter.prototype.users = function(id) {
        var model, promise,
          _this = this;
        model = new P.models.User({
          id: id || P.user.id
        });
        promise = this.load(model);
        return promise.done(function() {
          if (model.get('visible') || model.id === P.user.id) {
            return _this.routeOnce(new P.views.users.Show({
              model: model
            }));
          } else {
            P.layout.flash.show({
              message: P.localizer.t('user_not_found'),
              "class": 'error'
            });
            return _this.redirectTo('#');
          }
        });
      };

      AttendeeRouter.prototype.signin = function() {
        P.layout.navigation.showSignIn();
        return Backbone.history.navigate("#");
      };

      AttendeeRouter.prototype.contactsIndex = function() {
        return this.routeTo(P.views.contacts.Index);
      };

      AttendeeRouter.prototype.connectionsIndex = function() {
        return this.routeTo(P.views.connections.Index);
      };

      AttendeeRouter.prototype.trackPageview = function(view) {
        return this.track('pageviews', {
          view: P.pathname(view, P.views)
        });
      };

      AttendeeRouter.prototype._discussions = function(id, collection, route) {
        var _this = this;
        return this.load(collection).done(function() {
          var selected, view, _base;
          _this.routeTo(view = (_base = _this.views)[route] || (_base[route] = new P.views.discussions.discussions.Index({
            collection: collection
          }).render()));
          selected = id || view.selected || '';
          Backbone.history.navigate("#" + route + "/" + selected, false);
          return view.select(+id);
        });
      };

      return AttendeeRouter;

    })(x.ApplicationRouter);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.routers', function(x) {
    return x.HostRouter = (function(_super) {

      __extends(HostRouter, _super);

      HostRouter.prototype.layout = P.views.host.layouts.Application;

      function HostRouter() {
        HostRouter.__super__.constructor.apply(this, arguments);
        _.bindAll(this, 'authenticateHost');
        this.beforeFilter(this.authenticateHost);
      }

      HostRouter.prototype.initialize = function() {
        HostRouter.__super__.initialize.apply(this, arguments);
        this.route(/^meetings\/(private|public)\/?$/, 'meetings', this.meetings);
        this.route(/^meetings\/(private|public)\/new\/?$/, 'meetingsNew', this.meetingsNew);
        this.route(/^meetings\/(\d+)\/?$/, 'meetingsEdit', this.meetingsEdit);
        this.route(/^labels\/([^/]+)\/?$/, 'labels', this.labels);
        this.route(/^labels\/([^/]+)\/new$/, 'labelsNew', this.labelsNew);
        this.route(/^labels\/(\d+)\/?$/, 'labelsEdit', this.labelsEdit);
        this.route(/^templates\/(jst|scss|mail)\/?$/, 'templates', this.templates);
        this.route(/^templates\/(jst|scss|mail)\/new\/?$/, 'templatesNew', this.templatesNew);
        this.route(/^templates\/(\d+)\/?$/, 'templatesEdit', this.templatesEdit);
        this.route(/^(meetings|users|organizations)\/imports\/?$/, 'importsIndex', this.importsIndex);
        this.route(/^(meetings|users|organizations)\/imports\/new\/?$/, 'importsIndex', this.importsNew);
        this.route(/^imports\/(\d+)\/?$/, 'importsEdit', this.importsEdit);
        this.route(/^(meetings|users)\/datafeeds\/?$/, 'datafeedsIndex', this.datafeedsIndex);
        this.route(/^(meetings|users)\/datafeeds\/new\/?$/, 'datafeedsIndex', this.datafeedsNew);
        return this.route(/^datafeeds\/(\d+)\/?$/, 'datafeedsEdit', this.datafeedsEdit);
      };

      HostRouter.prototype.routes = {
        'events': 'eventsIndex',
        'groups': 'groupsIndex',
        'groups/new': 'groupsNew',
        'groups/:id': 'groupsEdit',
        'questions': 'questionsIndex',
        'questions/new': 'questionsNew',
        'questions/:id': 'questionsEdit',
        'locations': 'locationsIndex',
        'locations/new': 'locationsNew',
        'locations/:id': 'locationsEdit',
        'meeting_labels/:set': 'meeting_labels',
        'categories': 'categories',
        'categories/new': 'categoriesNew',
        'categories/:id': 'categoriesEdit',
        'reports': 'reportsOverview',
        'users': 'usersIndex',
        'users/new': 'usersNew',
        'users/multiedit': 'usersMulti',
        'users/:id': 'usersEdit',
        'organizations': 'organizationsIndex',
        'organizations/new': 'organizationsNew',
        'organizations/:id': 'organizationsEdit',
        '': 'communitiesShow',
        'theme': 'themeEdit',
        'session/destroy': 'sessionDestroy',
        'settings': 'communitySettingsShow'
      };

      HostRouter.prototype.navigate = function(name) {
        this.layout.navigation.activate(name);
        return P.layout.flash.hide();
      };

      HostRouter.prototype.communitiesShow = function() {
        return this.routeTo(P.views.host.communities.Show);
      };

      HostRouter.prototype.communitySettingsShow = function() {
        return this.routeTo(P.views.host.communitySettings.Show);
      };

      HostRouter.prototype.groupsIndex = function() {
        return this.routeTo(P.views.host.groups.Index);
      };

      HostRouter.prototype.groupsNew = function() {
        return this.routeOnce(new P.views.host.groups.EditPage({
          model: new P.models.Tag()
        }));
      };

      HostRouter.prototype.groupsEdit = function(id) {
        var model,
          _this = this;
        return this.load(model = new P.models.Tag({
          id: id
        })).done(function() {
          return _this.routeOnce(new P.views.host.groups.EditPage({
            model: model
          }));
        });
      };

      HostRouter.prototype.eventsIndex = function() {
        return this.routeTo(P.views.host.events.Index);
      };

      HostRouter.prototype.usersIndex = function() {
        return this.routeTo(P.views.host.users.Index);
      };

      HostRouter.prototype.usersNew = function() {
        return this.routeOnce(new P.views.host.users.EditPage({
          model: new P.models.User()
        }));
      };

      HostRouter.prototype.usersMulti = function() {
        if (P.views.host.users.Multiedit.current_collection != null) {
          return this.routeOnce(new P.views.host.users.Multiedit({
            collection: P.views.host.users.Multiedit.current_collection
          }));
        } else {
          return this.redirectTo("#users");
        }
      };

      HostRouter.prototype.usersEdit = function(id) {
        var model,
          _this = this;
        return this.load(model = new P.models.User({
          id: id
        })).done(function() {
          return _this.routeOnce(new P.views.host.users.EditPage({
            model: model
          }));
        });
      };

      HostRouter.prototype.organizationsIndex = function() {
        return this.routeTo(P.views.host.organizations.Index);
      };

      HostRouter.prototype.organizationsNew = function() {
        return this.routeOnce(new P.views.host.organizations.Edit({
          model: new P.models.Organization()
        }));
      };

      HostRouter.prototype.organizationsEdit = function(id) {
        var model,
          _this = this;
        return this.load(model = new P.models.Organization({
          id: id
        })).done(function() {
          return _this.routeOnce(new P.views.host.organizations.Edit({
            model: model
          }));
        });
      };

      HostRouter.prototype.questionsIndex = function() {
        return this.routeTo(P.views.host.questions.Index);
      };

      HostRouter.prototype.questionsNew = function() {
        return this.routeOnce(new P.views.host.questions.Edit({
          model: new P.models.Question()
        }));
      };

      HostRouter.prototype.questionsEdit = function(id) {
        var model,
          _this = this;
        return this.load(model = new P.models.Question({
          id: id
        })).done(function() {
          return _this.routeOnce(new P.views.host.questions.Edit({
            model: model
          }));
        });
      };

      HostRouter.prototype.meeting_labels = function(set) {
        var labelSet;
        labelSet = P.community.calendar.label_sets.detect(function(l) {
          return l.get('name') === set;
        });
        return this.routeTo(P.views.host.labels.Index, {
          model: labelSet,
          collection: labelSet.labels
        });
      };

      HostRouter.prototype.categories = function() {
        return this.routeTo(P.views.host.categories.Index, {
          collection: P.community.categories
        });
      };

      HostRouter.prototype.categoriesNew = function() {
        return this.routeOnce(new P.views.host.categories.Edit({
          model: new P.models.Category()
        }));
      };

      HostRouter.prototype.categoriesEdit = function(id) {
        var model,
          _this = this;
        return this.load(model = new P.models.Category({
          id: id
        })).done(function() {
          return _this.routeOnce(new P.views.host.categories.Edit({
            model: model
          }));
        });
      };

      HostRouter.prototype.locationsIndex = function() {
        return this.routeTo(P.views.host.locations.Index);
      };

      HostRouter.prototype.locationsNew = function() {
        return this.routeOnce(new P.views.host.locations.Edit({
          model: new P.models.Location()
        }));
      };

      HostRouter.prototype.locationsEdit = function(id) {
        var model,
          _this = this;
        return this.load(model = new P.models.Location({
          id: id
        })).done(function() {
          return _this.routeOnce(new P.views.host.locations.Edit({
            model: model
          }));
        });
      };

      HostRouter.prototype.reportsOverview = function() {
        return this.routeTo(P.views.host.reports.Overview);
      };

      HostRouter.prototype.importsIndex = function(type) {
        return this.routeTo(P.views.host.imports[type].Index, {
          type: type
        });
      };

      HostRouter.prototype.importsNew = function(type) {
        return this.routeOnce(new P.views.host.imports.Edit({
          model: new P.models.Import({
            model_class: P.views.host.imports[type].Index.prototype.model_class
          })
        }));
      };

      HostRouter.prototype.importsEdit = function(id) {
        var model,
          _this = this;
        return this.load(model = new P.models.Import({
          id: id
        })).done(function() {
          return _this.routeOnce(new P.views.host.imports.Edit({
            model: model
          }));
        });
      };

      HostRouter.prototype.datafeedsIndex = function(type) {
        return this.routeTo(P.views.host.datafeeds[type].Index, {
          type: type
        });
      };

      HostRouter.prototype.datafeedsNew = function(type) {
        return this.routeOnce(new P.views.host.datafeeds[type].Edit({
          model: new P.models.Datafeed()
        }));
      };

      HostRouter.prototype.datafeedsEdit = function(id) {
        var model,
          _this = this;
        return this.load(model = new P.models.Datafeed({
          id: id
        })).done(function() {
          return _this.routeOnce(new P.views.host.datafeeds[model.get('model_type')].Edit({
            model: model
          }));
        });
      };

      HostRouter.prototype.themeEdit = function() {
        return this.routeTo(P.views.host.themes.Edit);
      };

      HostRouter.prototype.meetings = function(type) {
        var _base, _name;
        return this.routeTo((_base = this.views)[_name = 'meetings_' + type] || (_base[_name] = new P.views.host.meetings.Index({
          private: type === 'private'
        }).render()));
      };

      HostRouter.prototype.meetingsNew = function(type) {
        return this.routeOnce(new P.views.host.meetings.EditPage({
          returnUrl: '#meetings/' + type,
          model: new P.models.Meeting({
            private: type === 'private'
          })
        }));
      };

      HostRouter.prototype.meetingsEdit = function(id) {
        var model,
          _this = this;
        return this.load(model = new P.models.Meeting({
          id: id
        })).done(function() {
          return _this.routeOnce(new P.views.host.meetings.EditPage({
            model: model,
            returnUrl: '#meetings/' + (model.get('private') && 'private' || 'public')
          }));
        });
      };

      HostRouter.prototype.labels = function(name) {
        var set;
        set = P.community.calendar.label_sets.detect(function(s) {
          return s.get('name') === name;
        });
        if (set == null) {
          set = P.community.label_sets.detect(function(s) {
            return s.get('name') === name;
          });
        }
        return this.routeTo(P.views.host.labels.Index, {
          model: set,
          collection: set.labels
        });
      };

      HostRouter.prototype.labelsNew = function(set) {
        set = P.community.label_sets.detect(function(s) {
          return s.get('name') === set;
        });
        return this.routeOnce(new P.views.host.labels.Edit({
          model: new P.models.Label({
            label_set: set
          })
        }));
      };

      HostRouter.prototype.labelsEdit = function(id) {
        var model,
          _this = this;
        return this.load(model = new P.models.Label({
          id: id
        })).done(function() {
          return _this.routeOnce(new P.views.host.labels.Edit({
            model: model
          }));
        });
      };

      HostRouter.prototype.templates = function(type) {
        return this.routeTo(P.views.host.templates[type].Index);
      };

      HostRouter.prototype.templatesNew = function(type) {
        return this.routeOnce(new P.views.host.templates[type].Edit({
          model: new P.models.Template({
            type: type
          })
        }));
      };

      HostRouter.prototype.templatesEdit = function(id) {
        var model,
          _this = this;
        return this.load(model = new P.models.Template({
          id: id
        })).done(function() {
          return _this.routeOnce(new P.views.host.templates[model.get('_type')].Edit({
            model: model
          }));
        });
      };

      HostRouter.prototype.sessionDestroy = function() {
        var _this = this;
        return P.session.destroy({
          success: function() {
            return _this.redirectTo('/');
          }
        });
      };

      return HostRouter;

    })(x.ApplicationRouter);
  });

}).call(this);

(function() {
  var __hasProp = Object.prototype.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; };

  P.namespace('P.routers', function(x) {
    return x.MobileRouter = (function(_super) {

      __extends(MobileRouter, _super);

      MobileRouter.prototype.layout = P.views.mobile.layouts.Application;

      function MobileRouter() {
        MobileRouter.__super__.constructor.apply(this, arguments);
        this.beforeFilter(this.authenticateUser, {
          except: ['community/private', 'signin']
        });
        this.beforeFilter(this.requireLogin, {
          only: ['contactsIndex', 'contactsShow']
        });
        this.bind('route', this.trackPageview);
        if (navigator.userAgent.match(/iPhone/i)) {
          $(window).bind('orientationchange', function(event) {
            if (window.orientation === 90 || window.orientation === -90 || window.orientation === 270) {
              return $('meta[name="viewport"]').attr('content', 'height=device-width,width=device-height,initial-scale=1.0,maximum-scale=1.0');
            } else {
              return $('meta[name="viewport"]').attr('content', 'height=device-height,width=device-width,initial-scale=1.0,maximum-scale=1.0');
            }
          }).trigger('orientationchange');
        }
      }

      MobileRouter.prototype.routes = {
        'community/private': 'communityPrivate',
        'users': 'usersIndex',
        'user': 'user',
        'users/:id': 'usersShow',
        'users/:id/photo': 'userPhoto',
        '': 'communityShow',
        'meetings/private&:params': 'meetingsPrivate',
        'meetings': 'meetings',
        'meetings/my': 'meetingsMy',
        'meetings/my/:date': 'meetingsMy',
        'meetings/:y-:m-:d': 'meetings',
        'meetings/:id': 'meetingsShow',
        'exhibitors': 'exhibitorsIndex',
        'organizations/:id': 'organizationsShow',
        'speakers': 'speakersIndex',
        'mySchedule': 'mySchedule',
        'groups': 'groupsIndex',
        'groups/:id': 'groupsShow',
        'signin': 'signin',
        'signout': 'signout',
        'reset_password': 'resetPassword',
        'discussions/new&:params': 'discussionsNew',
        'discussions/new': 'discussionsNew',
        'discussions': 'discussionsIndex',
        'discussions/:id': 'discussionsShow',
        'inbox': 'inbox',
        'inbox/:id': 'inboxShow',
        'contacts': 'contactsIndex',
        'contacts/:id': 'contactsShow',
        'meetings/:id/documents': 'meetingsDocuments',
        'meetings/:id/discussions': 'meetingsDiscussions',
        'meetings/:id/attendees': 'meetingsAttendees',
        'meetings/:meeting_id/discussions/:id': 'meetingsDiscussionsShow'
      };

      MobileRouter.prototype.communityShow = function() {
        return this.routeTo(P.views.mobile.communities.Show);
      };

      MobileRouter.prototype.communityPrivate = function(x) {
        return this.routeTo(P.views.communities.Private);
      };

      MobileRouter.prototype.usersIndex = function() {
        return this.routeTo(P.views.mobile.users.Index);
      };

      MobileRouter.prototype.exhibitorsIndex = function() {
        return this.routeTo(P.views.mobile.organizations.Index, {
          collection: P.community.organizations
        });
      };

      MobileRouter.prototype.organizationsShow = function(id) {
        return this.routeTo(P.views.mobile.organizations.Show, {
          model: new P.models.Organization({
            id: id
          })
        });
      };

      MobileRouter.prototype.speakersIndex = function() {
        return this.routeTo(P.views.mobile.users.Index);
      };

      MobileRouter.prototype.user = function() {
        return this.routeTo(P.views.mobile.users.Show, {
          model: P.user
        });
      };

      MobileRouter.prototype.usersShow = function(id) {
        return this.routeTo(P.views.mobile.users.Show, {
          model: new P.models.User({
            id: id
          })
        });
      };

      MobileRouter.prototype.userPhoto = function(id) {
        return this.routeTo(P.views.mobile.users.ShowPhoto, {
          model: new P.models.User({
            id: id
          })
        });
      };

      MobileRouter.prototype.meetings = function(y, m, d) {
        return this._meetings('', P.community.calendar.meetings, y && ("" + y + "-" + m + "-" + d));
      };

      MobileRouter.prototype.meetingsMy = function(date) {
        return this._meetings('my', P.user.meetings, date);
      };

      MobileRouter.prototype._meetings = function(route, collection, date) {
        this.routeTo(P.views.mobile.meetings[date && 'Day' || 'Index'], {
          date: date,
          route: route,
          collection: collection
        });
        return P.community.calendar.meetings.fetch();
      };

      MobileRouter.prototype.meetingsShow = function(id) {
        return this.routeTo(P.views.mobile.meetings.Show, {
          model: new P.models.Meeting({
            id: id
          })
        });
      };

      MobileRouter.prototype.meetingsPrivate = function(params) {
        var meeting;
        params = this.params(params);
        meeting = new P.models.Meeting({
          private: true
        });
        meeting.users.add({
          id: params.user_id
        }, {
          silent: true
        });
        return this.routeTo(P.views.mobile.meetings.private.Edit, {
          model: meeting
        });
      };

      MobileRouter.prototype.trackPageview = function(view) {
        return this.track('pageviews', {
          view: P.pathname(view, P.views)
        });
      };

      MobileRouter.prototype.mySchedule = function() {
        return this.routeTo(P.views.mobile.meetings.MySchedule);
      };

      MobileRouter.prototype.groupsIndex = function() {
        return this.routeTo(P.views.mobile.groups.Index);
      };

      MobileRouter.prototype.groupsShow = function(id) {
        return this.routeTo(P.views.mobile.groups.Show, {
          model: new P.models.Group({
            id: id
          })
        });
      };

      MobileRouter.prototype.discussionsIndex = function() {
        return this.routeTo(P.views.mobile.discussions.discussions.Index, {
          collection: P.community.discussions
        });
      };

      MobileRouter.prototype.discussionsNew = function() {
        var discussion, groups, params, users;
        params = this.params();
        if (params.user_id != null) {
          users = new P.models.Users([
            new P.models.User({
              id: params.user_id
            })
          ]);
        } else if (params.group_id) {
          groups = new P.models.Groups([
            {
              id: params.group_id
            }
          ]);
        } else {
          groups = [new P.models.AllGroup()];
        }
        discussion = new P.models.Discussion({
          private: users != null,
          participants: users,
          groups: groups
        });
        P.user.discussions.add(discussion);
        return this.routeTo(new P.views.mobile.discussions.discussions.Edit({
          model: discussion
        }));
      };

      MobileRouter.prototype.discussionsShow = function(id) {
        var model;
        model = new P.models.Discussion({
          id: id
        });
        model.fetch();
        return this.routeTo(new P.views.mobile.discussions.discussions.Show({
          model: model
        }));
      };

      MobileRouter.prototype.inbox = function() {
        return this.routeTo(P.views.mobile.discussions.discussions.Index, {
          collection: P.user.discussions,
          title: P.localizer.t('inbox', {
            pluralize: false
          }).capitalize()
        });
      };

      MobileRouter.prototype.inboxShow = function(id) {
        return this.routeTo(P.views.mobile.discussions.discussions.Show, {
          model: P.user.discussions.get(id)
        });
      };

      MobileRouter.prototype.contactsIndex = function() {
        return this.routeTo(P.views.mobile.contacts.Index);
      };

      MobileRouter.prototype.contactsShow = function(id) {
        var model;
        if (!(model = P.user.user_contacts.get(id))) {
          model = new P.models.UserContact({
            id: id
          });
          model.collection = P.user.user_contacts;
          model.fetch();
        }
        return this.routeTo(P.views.mobile.contacts.Show, {
          model: model
        });
      };

      MobileRouter.prototype.meetingsDocuments = function(id) {
        return this.routeTo(P.views.mobile.meetings.Documents, {
          model: new P.models.Meeting({
            id: id
          })
        });
      };

      MobileRouter.prototype.meetingsDiscussions = function(id) {
        return this.routeTo(P.views.mobile.meetings.Discussions, {
          model: new P.models.Meeting({
            id: id
          })
        });
      };

      MobileRouter.prototype.meetingsAttendees = function(id) {
        return this.routeTo(P.views.mobile.meetings.Attendees, {
          model: new P.models.Meeting({
            id: id
          })
        });
      };

      MobileRouter.prototype.meetingsDiscussionsShow = function(meeting_id, id) {
        var meeting;
        P.logger.info("meetingsDiscussionsShow");
        meeting = new P.models.Meeting({
          id: meeting_id
        });
        return this.routeTo(P.views.mobile.meetings.DiscussionsShow, {
          meeting: meeting,
          model: meeting.discussions.get(id)
        });
      };

      MobileRouter.prototype.changeView = function(from, to) {
        return $.mobile.pageContainer.append(to.el);
      };

      MobileRouter.prototype.signin = function() {
        return this.routeTo(P.views.mobile.sessions.New);
      };

      MobileRouter.prototype.signout = function() {
        return P.session.signOut(function() {
          return P.router.redirectTo(P.community.settings.get('public') ? '#' : '#community/private');
        });
      };

      MobileRouter.prototype.resetPassword = function() {
        return this.routeTo(P.views.mobile.sessions.ResetPassword);
      };

      return MobileRouter;

    })(x.ApplicationRouter);
  });

}).call(this);

