Sha256: ad91e599fb4f4403b53afbbc693c693dc9b6a3ce23bf46212f31b1a08b6d0fad

Contents?: true

Size: 1.86 KB

Versions: 31

Compression:

Stored size: 1.86 KB

Contents

// Get the translation center engine root path
translation_center_root = "<%= Rails.application.routes.url_helpers.translation_center_path %>"

translation_center_translation_key_path = function(id) { return translation_center_root + '/translation_keys/' + id }

$(document).ready(function() {
  if($('body').children('#tc-inspector-links').length == 0 && $('#tc_no_inspector').length == 0 )
    $('body').append('<div id="tc-inspector-links"></div>');

  // for each key add a link that goes to the key page
  $('.tc-inspector-key').each(function(){
    var top = $(this).offset().top - 20;
    var left = $(this).offset().left - 10;
    var id = $(this).data('id');
    // missing translation will be in red while translated will be in green
    var badgeClass = getBadge($(this).data('type'));
    $('#tc-inspector-links').append($('<a>').attr('title', 'Click to visit key').attr('target', 'key_inspect').attr('href', translation_center_translation_key_path(id)).attr('data-id', id).attr('style', 'left:' + left + 'px;top:' + top + 'px' ).attr('class', 'icon-edit tc-badge ' + badgeClass  + ' tc-inspector-link'));

  });

  // highlight the key when user hovers over it
  $(".tc-inspector-link").mouseover(function() {
    var id = $(this).data('id');
    var key = $('.tc-inspector-key[data-id=' + id + ']');
    var color = getColor(key.data('type'));
    key.css('color', color);
  }).mouseout(function(){
    var id = $(this).data('id');
    $('.tc-inspector-key[data-id=' + id + ']').css('color', '');
  });

  function getBadge(status) {
    if(status == 'untranslated')
      return 'tc-badge-important'
    else if(status == 'pending')
      return 'tc-badge-warning'
    else
      return 'tc-badge-success'
  }

  function getColor(status) {
    if(status == 'untranslated')
      return 'red'
    else if(status == 'pending')
      return 'orange'
    else
      return 'green'
  }


});

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
translation_center-1.6.1 app/assets/javascripts/translation_center/inspector.js.erb
translation_center-1.6.0 app/assets/javascripts/translation_center/inspector.js.erb
translation_center-1.5.9 app/assets/javascripts/translation_center/inspector.js.erb
translation_center-1.5.8 app/assets/javascripts/translation_center/inspector.js.erb
translation_center-1.5.7 app/assets/javascripts/translation_center/inspector.js.erb
translation_center-1.5.6 app/assets/javascripts/translation_center/inspector.js.erb
translation_center-1.5.5 app/assets/javascripts/translation_center/inspector.js.erb
translation_center-1.5.4 app/assets/javascripts/translation_center/inspector.js.erb
translation_center-1.5.3 app/assets/javascripts/translation_center/inspector.js.erb
translation_center-1.5.2 app/assets/javascripts/translation_center/inspector.js.erb
translation_center-1.5.1 app/assets/javascripts/translation_center/inspector.js.erb
translation_center-1.5.0 app/assets/javascripts/translation_center/inspector.js.erb
translation_center-1.4.1 app/assets/javascripts/translation_center/inspector.js.erb
translation_center-1.4.0 app/assets/javascripts/translation_center/inspector.js.erb
translation_center-1.3.1 app/assets/javascripts/translation_center/inspector.js.erb
translation_center-1.3.0 app/assets/javascripts/translation_center/inspector.js.erb
translation_center-1.2.1 app/assets/javascripts/translation_center/inspector.js.erb
translation_center-1.2.0 app/assets/javascripts/translation_center/inspector.js.erb
translation_center-1.1.0 app/assets/javascripts/translation_center/inspector.js.erb
translation_center-1.0.4 app/assets/javascripts/translation_center/inspector.js.erb