Sha256: a4cbc6b4265a57aeb05dbc80707a697fc7189439c21dc085157fe925420e685e

Contents?: true

Size: 959 Bytes

Versions: 4

Compression:

Stored size: 959 Bytes

Contents

//= require letter_opener_web/jquery-1.8.3.min
//= require letter_opener_web/jquery_ujs
//= require letter_opener_web/favcount

function update_favicon(favicon) {
  favicon.set($('.letter-opener tbody tr').length);
}

jQuery(function($) {
  var favicon = new Favcount($('link[rel="icon"]').attr('href'));
  update_favicon(favicon);

  $('.letter-opener').on('click', 'tr', function() {
    var $this = $(this);
    $('iframe').attr('src', $this.find('a').attr('href'));
    $this.parent().find('.active').removeClass('active');
    $this.addClass('active');
  });

  $('.refresh').click(function(e) {
    e.preventDefault();

    var table = $('.letter-opener');
    table.find('tbody').empty().append('<tr><td colspan="2">Loading...</td></tr>');
    table.load(table.data('letters-path') + ' .letter-opener', function() {
      $('iframe').attr('src', $('.letter-opener tbody a:first-child()').attr('href'));
      update_favicon(favicon);
    });
  });
});

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
letter_opener_web-1.3.1 app/assets/javascripts/letter_opener_web/application.js
letter_opener_web-1.3.0 app/assets/javascripts/letter_opener_web/application.js
letter_opener_web-1.2.3 app/assets/javascripts/letter_opener_web/application.js
letter_opener_web-1.2.2 app/assets/javascripts/letter_opener_web/application.js