mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-11-02 18:47:10 -05:00 
			
		
		
		
	Restructure colour.js to work withing a .ready()
This commit is contained in:
		
							parent
							
								
									4f4c515629
								
							
						
					
					
						commit
						ea05ab2b06
					
				@ -2,14 +2,16 @@
 | 
				
			|||||||
// drop-down on the `Add tag` page that will update to show the selected tag
 | 
					// drop-down on the `Add tag` page that will update to show the selected tag
 | 
				
			||||||
// color as the drop-down value is changed.
 | 
					// color as the drop-down value is changed.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if (django.jQuery("#id_colour").length) {
 | 
					django.jQuery(document).ready(function(){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (django.jQuery("#id_colour").length) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    let colour;
 | 
					    let colour;
 | 
				
			||||||
    let colour_num;
 | 
					    let colour_num;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    colour_num = django.jQuery("#id_colour").val() - 1;
 | 
					    colour_num = django.jQuery("#id_colour").val() - 1;
 | 
				
			||||||
    colour = django.jQuery('#id_colour')[0][colour_num].text;
 | 
					    colour = django.jQuery('#id_colour')[0][colour_num].text;
 | 
				
			||||||
    django.jQuery('#id_colour').after('<div class="colour_square"></div>')
 | 
					    django.jQuery('#id_colour').after('<div class="colour_square"></div>');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    django.jQuery('.colour_square').css({
 | 
					    django.jQuery('.colour_square').css({
 | 
				
			||||||
      'float': 'left',
 | 
					      'float': 'left',
 | 
				
			||||||
@ -25,20 +27,16 @@ if (django.jQuery("#id_colour").length) {
 | 
				
			|||||||
      colour = django.jQuery('#id_colour')[0][colour_num].text;
 | 
					      colour = django.jQuery('#id_colour')[0][colour_num].text;
 | 
				
			||||||
      django.jQuery('.colour_square').css({'background': colour});
 | 
					      django.jQuery('.colour_square').css({'background': colour});
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
// The following jQuery snippet will add a small square next to each selection
 | 
					  } else if (django.jQuery("select[id*='colour']").length) {
 | 
				
			||||||
// drop-down on the `Edit tags` page that will update to show the selected tag
 | 
					 | 
				
			||||||
// color as the drop-down value is changed.
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
if (django.jQuery('select[id*="-colour"]').length) {
 | 
					 | 
				
			||||||
    django.jQuery('select[id*="-colour"]').each(function (index, element) {
 | 
					    django.jQuery('select[id*="-colour"]').each(function (index, element) {
 | 
				
			||||||
      let id;
 | 
					      let id;
 | 
				
			||||||
        let loop_colour_num
 | 
					      let loop_colour_num;
 | 
				
			||||||
        let loop_colour
 | 
					      let loop_colour;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      id = "colour_square_" + index;
 | 
					      id = "colour_square_" + index;
 | 
				
			||||||
        django.jQuery(element).after('<div class="colour_square" id="' + id + '"></div>')
 | 
					      django.jQuery(element).after('<div class="colour_square" id="' + id + '"></div>');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      loop_colour_num = django.jQuery(element).val() - 1;
 | 
					      loop_colour_num = django.jQuery(element).val() - 1;
 | 
				
			||||||
      loop_colour = django.jQuery(element)[0][loop_colour_num].text;
 | 
					      loop_colour = django.jQuery(element)[0][loop_colour_num].text;
 | 
				
			||||||
@ -53,7 +51,7 @@ if (django.jQuery('select[id*="-colour"]').length) {
 | 
				
			|||||||
                        } </style>").appendTo("head");
 | 
					                        } </style>").appendTo("head");
 | 
				
			||||||
      django.jQuery('#' + id).css({'background': loop_colour});
 | 
					      django.jQuery('#' + id).css({'background': loop_colour});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        console.log(id, loop_colour_num, loop_colour)
 | 
					      console.log(id, loop_colour_num, loop_colour);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      django.jQuery(element).change(function () {
 | 
					      django.jQuery(element).change(function () {
 | 
				
			||||||
        loop_colour_num = django.jQuery(element).val() - 1;
 | 
					        loop_colour_num = django.jQuery(element).val() - 1;
 | 
				
			||||||
@ -62,4 +60,7 @@ if (django.jQuery('select[id*="-colour"]').length) {
 | 
				
			|||||||
        console.log('#' + id, loop_colour)
 | 
					        console.log('#' + id, loop_colour)
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
    })
 | 
					    })
 | 
				
			||||||
}
 | 
					
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user