Alien-Web-HalBrowser

 view release on metacpan or  search on metacpan

share/js/hal/views/location_bar.js  view on Meta::CPAN

HAL.Views.LocationBar = Backbone.View.extend({
  initialize: function(opts) {
    this.vent = opts.vent;
    _.bindAll(this, 'render');
    _.bindAll(this, 'onButtonClick');
    this.vent.bind('location-change', this.render);
    this.vent.bind('location-change', _.bind(this.showSpinner, this));
    this.vent.bind('response', _.bind(this.hideSpinner, this));
  },

  events: {
    'submit form': 'onButtonClick'
  },

  className: 'address',

  render: function(e) {
    e = e || { url: '' };
    this.$el.html(this.template(e));
  },

  onButtonClick: function(e) {
    e.preventDefault();
    this.vent.trigger('location-go', this.getLocation());
  },

  getLocation: function() {
    return this.$el.find('input').val();
  },

  showSpinner: function() {
    this.$el.find('.ajax-loader').addClass('visible');
  },

  hideSpinner: function() {
    this.$el.find('.ajax-loader').removeClass('visible');
  },

  template: _.template($('#location-bar-template').html())
});



( run in 1.223 second using v1.01-cache-2.11-cpan-e1769b4cff6 )