Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 

107 Zeilen
2.4 KiB

  1. define([
  2. 'js/system/events',
  3. 'js/system/client',
  4. 'html!ui/templates/reputation/template',
  5. 'css!ui/templates/reputation/styles'
  6. ], function (
  7. events,
  8. client,
  9. template,
  10. styles
  11. ) {
  12. return {
  13. tpl: template,
  14. centered: true,
  15. modal: true,
  16. list: null,
  17. postRender: function () {
  18. this.onEvent('onGetReputations', this.onGetReputations.bind(this));
  19. this.onEvent('onShowReputation', this.toggle.bind(this, true));
  20. },
  21. build: function () {
  22. var list = this.list;
  23. this.find('.info .heading-bottom').html('');
  24. this.find('.info .description').html('');
  25. this.find('.bar-outer').hide();
  26. if (list.length == 0)
  27. this.find('.heading-bottom').html("you haven't discovered any factions yet");
  28. else
  29. this.find('.heading-bottom').html('select a faction to see more info');
  30. var elList = this.find('.list').empty();
  31. list.forEach(function (l) {
  32. if (l.noGainRep)
  33. return;
  34. var html = '<div class="faction">' + l.name.toLowerCase() + '</div>';
  35. var el = $(html)
  36. .appendTo(elList);
  37. el
  38. .on('click', this.onSelectFaction.bind(this, el, l));
  39. }, this);
  40. },
  41. onSelectFaction: function (el, faction) {
  42. this.find('.selected').removeClass('selected');
  43. $(el).addClass('selected');
  44. this.find('.info .heading-bottom').html(faction.name.toLowerCase());
  45. this.find('.info .description').html(faction.description.toLowerCase());
  46. var rep = faction.rep;
  47. var tier = faction.tier;
  48. var tiers = faction.tiers;
  49. var prevTier = tiers[tier];
  50. var nextTier = (tier == tiers.length - 1) ? tiers[tiers.length - 1] : tiers[tier + 1];
  51. var percentage = (rep - prevTier.rep) / (nextTier.rep - prevTier.rep) * 100;
  52. this.find('.bar-outer').show();
  53. this.find('.front').css({
  54. width: percentage + '%'
  55. });
  56. var w = ~~(this.find('.front').width() / 5) * 5;
  57. this.find('.front').css({
  58. width: w + 'px'
  59. });
  60. percentage = ~~(percentage * 10) / 10;
  61. this.find('.tier').html(tiers[tier].name.toLowerCase() + ' (' + percentage + '%)');
  62. },
  63. onGetReputations: function (list) {
  64. this.list = list;
  65. this.list.sort(function (a, b) {
  66. if (a.name[0] < b.name[0])
  67. return -1;
  68. else
  69. return 1;
  70. });
  71. if (this.el.is(':visible'))
  72. this.build();
  73. },
  74. toggle: function () {
  75. var shown = !this.el.is(':visible');
  76. if (shown) {
  77. this.build();
  78. this.show();
  79. } else
  80. this.hide();
  81. }
  82. };
  83. });