#4613 UI: proper tag coloring
Merged a month ago by pingou. Opened a month ago by jlanda.
jlanda/pagure fix-tag-coloring  into  master

@@ -0,0 +1,5 @@ 

+ $(document).ready(function() {

+   $("[data-bg-color").each(function(ind, obj) {

+     $(obj).css('background-color', $(obj).attr('data-bg-color'));

+   });

+ }); 

\ No newline at end of file

file modified
+2 -7

@@ -656,6 +656,8 @@ 

    url_for('static', filename='vendor/jquery.caret/jquery.caret.min.js') }}?version={{ g.version}}"></script>

  <script type="text/javascript" nonce="{{ g.nonce }}" src="{{

    url_for('static', filename='vendor/jquery.atwho/jquery.atwho.min.js') }}?version={{ g.version}}"></script>

+ <script type="text/javascript" nonce="{{ g.nonce }}" src="{{

+   url_for('static', filename='tags.js') }}?version={{ g.version}}"></script>

  

  <script type="text/javascript" nonce="{{ g.nonce }}">

  

@@ -802,12 +804,6 @@ 

  });

  };

  

- function color_tags() {

-   $(".badge-tag").each(function(ind, obj) {

-     $(obj).css('background-color', $(obj).attr('data-bg-color'));

-   });

- }

- 

  $(document).ready(function() {

    var cur_hash = null;

  

@@ -855,7 +851,6 @@ 

    cancel_edit_btn();

    setup_edit_btns();

    setup_reply_btns();

-   color_tags();

  

  });

  </script>

file modified
+2 -6

@@ -538,13 +538,10 @@ 

  

  <script type="text/javascript" nonce="{{ g.nonce }}" src="{{

    url_for('static', filename='vendor/selectize/selectize.min.js') }}?version={{ g.version}}"></script>

+ <script type="text/javascript" nonce="{{ g.nonce }}" src="{{

+   url_for('static', filename='tags.js') }}?version={{ g.version}}"></script>

  

  <script type="text/javascript" nonce="{{ g.nonce }}">

- function color_tags() {

-   $(".small-badge-tag").each(function(ind, obj) {

-     $(obj).css('background-color', $(obj).attr('data-bg-color'));

-   });

- }

  

  function update_progress_bar() {

    $(".progress-bar").each(function(ind, obj) {

@@ -553,7 +550,6 @@ 

  }

  

  $(document).ready(function() {

-     color_tags();

      update_progress_bar();

  

      $("#search_pattern-selectize-reset").on('click', function(e){

@@ -76,7 +76,8 @@ 

  

  {% block jscripts %}

  {{ super() }}

- 

+ <script type="text/javascript" nonce="{{ g.nonce }}" src="{{

+   url_for('static', filename='tags.js') }}?version={{ g.version}}"></script>

  <script type="text/javascript" nonce="{{ g.nonce }}">

  

  function update_progress_bar() {

@@ -764,6 +764,8 @@ 

    url_for('static', filename='vendor/jquery.atwho/jquery.atwho.min.js') }}?version={{ g.version}}"></script>

  <script type="text/javascript" nonce="{{ g.nonce }}" src="{{

    url_for('static', filename='request_ev.js') }}?version={{ g.version}}"></script>

+ <script type="text/javascript" nonce="{{ g.nonce }}" src="{{

+   url_for('static', filename='tags.js') }}?version={{ g.version}}"></script>

  

  <script type="text/javascript" nonce="{{ g.nonce }}">

  function cancel_edit_btn() {

@@ -1319,12 +1321,6 @@ 

  <script type="text/javascript" nonce="{{ g.nonce }}">

  var cur_hash = null;

  

- function color_tags() {

-   $(".badge-tag").each(function(ind, obj) {

-     $(obj).css('background-color', $(obj).attr('data-bg-color'));

-   });

- }

- 

  function highlight_comment() {

    var _hash = window.location.hash;

    if (_hash != cur_hash) {

@@ -1389,7 +1385,6 @@ 

  }

  

  $(document).ready(function () {

-   color_tags();

  

    {% if g.authenticated and pull_request %}

    function set_up_subcribed() {

@@ -279,6 +279,8 @@ 

  

  {% block jscripts %}

  {{ super() }}

+ <script type="text/javascript" nonce="{{ g.nonce }}" src="{{

+   url_for('static', filename='tags.js') }}?version={{ g.version}}"></script>

  

  <script type="text/javascript" nonce="{{ g.nonce }}">

  

@@ -299,6 +299,8 @@ 

  

  <script type="text/javascript" nonce="{{ g.nonce }}" src="{{

    url_for('static', filename='vendor/selectize/selectize.min.js') }}?version={{ g.version}}"></script>

+ <script type="text/javascript" nonce="{{ g.nonce }}" src="{{

+   url_for('static', filename='tags.js') }}?version={{ g.version}}"></script>

  

  <script type="text/javascript" nonce="{{ g.nonce }}">

  $(document).ready(function() {

@@ -1117,6 +1117,8 @@ 

  

  <script type="text/javascript" nonce="{{ g.nonce }}" src="{{

    url_for('static', filename='vendor/selectize/selectize.min.js') }}?version={{ g.version}}"></script>

+ <script type="text/javascript" nonce="{{ g.nonce }}" src="{{

+   url_for('static', filename='tags.js') }}?version={{ g.version}}"></script>

  

  <script type="text/javascript" nonce="{{ g.nonce }}">

  function updateform() {

@@ -1130,15 +1132,8 @@ 

    });

  };

  

- function color_tags() {

-   $(".badge").each(function(ind, obj) {

-     $(obj).css('background-color', $(obj).attr('data-bg-color'));

-   });

- }

- 

  $(document).ready(function() {

      updateform();

-     color_tags();

  

      $('#generate_new_hook_token').click(function() {

          return confirm('Are you sure to generate a new token for '

@@ -138,6 +138,8 @@ 

  

  {% block jscripts %}

      {{ super() }}

+ <script type="text/javascript" nonce="{{ g.nonce }}" src="{{

+   url_for('static', filename='tags.js') }}?version={{ g.version}}"></script>

  <script type="text/javascript" nonce="{{ g.nonce }}">

  $(document).ready(function() {

    var $acls_selectize = $('#acls-selectize').selectize({

@@ -4,7 +4,6 @@ 

  

  {% from "_render_issues.html" import render_issue_row %}

  

- 

  {% block userprofile_content %}

  <div class="pt-4">

    <div class="container pb-5">

@@ -58,6 +57,8 @@ 

  

  {% block jscripts %}

  {{ super() }}

+ <script type="text/javascript" nonce="{{ g.nonce }}" src="{{

+   url_for('static', filename='tags.js') }}?version={{ g.version}}"></script>

  <script type="text/javascript" nonce="{{ g.nonce }}">

    count_issues(status='.issue-status-open');

    $(function(){

@@ -66,6 +66,8 @@ 

  

  {% block jscripts %}

  {{ super() }}

+ <script type="text/javascript" nonce="{{ g.nonce }}" src="{{

+   url_for('static', filename='tags.js') }}?version={{ g.version}}"></script>

  <script type="text/javascript" nonce="{{ g.nonce }}">

    count_issues(status='.pr-status-open');

    $(function(){

Implements tag coloring jinga2 macro using it here and there
Fixes #4604

Rather than using jinja, shouldn't we just define the function in a .js file and call it where we want?

rebased onto bc513ac

a month ago

rebased onto cc5555f

a month ago

js moves to .js file :D

I like this approach more.

I'm a bit surprised to see the .js include in some template where that code wasn't removed from.

rebased onto e89d842

a month ago

I like this approach more.
I'm a bit surprised to see the .js include in some template where that code wasn't removed from.

Those views were hitting #4604 . I git grepped all the code looking for data-bg-color and following jinga2 inheritance|macro hierarchy now, I think that I caught all the tags on pagure, but could be someone more hiding somewhere that did not match my grep finding process =)

rebased onto 1177b47

a month ago

Ok, thanks :)

Since this isn't covered in the tests, I'm going to get it in right now :)

Pull-Request has been merged by pingou

a month ago