mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	Layout for colorizing streams.
(imported from commit 50d359ed44f46a0c666778bf510dafbb3e6e6f97)
This commit is contained in:
		
				
					committed by
					
						
						Jessica McKellar
					
				
			
			
				
	
			
			
			
						parent
						
							745ca0d451
						
					
				
				
					commit
					f71affdc11
				
			@@ -1,7 +1,8 @@
 | 
			
		||||
{{! Client-side Mustache template for rendering subscriptions.}}
 | 
			
		||||
<tr>
 | 
			
		||||
  <td>
 | 
			
		||||
    {{subscription}}
 | 
			
		||||
    <input class="colorpicker" type="text" value="{{color}}" />
 | 
			
		||||
    <span class="subscription_name">{{subscription}}</span>
 | 
			
		||||
  </td>
 | 
			
		||||
  <td class="span2">
 | 
			
		||||
    <button class="btn btn-block" type="button" name="subscription"
 | 
			
		||||
 
 | 
			
		||||
@@ -16,6 +16,26 @@ function case_insensitive_subscription_index(stream_name) {
 | 
			
		||||
    return -1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// TODO: The way that we find the row is kind of fragile
 | 
			
		||||
// and liable to break with streams with " in their name,
 | 
			
		||||
// just like our unsubscribe button code.
 | 
			
		||||
function draw_colorpicker(stream_name) {
 | 
			
		||||
    var colorpicker = $('#subscriptions_table').find('button[value="' + stream_name + '"]').parent().prev().find('input');
 | 
			
		||||
    colorpicker.spectrum({
 | 
			
		||||
        clickoutFiresChange: true,
 | 
			
		||||
        showPalette: true,
 | 
			
		||||
        palette: [
 | 
			
		||||
            ['a47462', 'c2726a', 'e4523d', 'e7664d', 'ee7e4a', 'f4ae55'],
 | 
			
		||||
            ['76ce90', '53a063', '94c849', 'bfd56f', 'fae589', 'f5ce6e'],
 | 
			
		||||
            ['a6dcbf', 'addfe5', 'a6c7e5', '4f8de4', '95a5fd', 'b0a5fd'],
 | 
			
		||||
            ['c2c2c2', 'c8bebf', 'c6a8ad', 'e79ab5', 'bd86e5', '9987e1']
 | 
			
		||||
        ],
 | 
			
		||||
        change: function (color) {
 | 
			
		||||
            console.log("Changing color for", stream_name, "to", color);
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function add_to_stream_list(stream_name) {
 | 
			
		||||
    var stream_sub_row;
 | 
			
		||||
 | 
			
		||||
@@ -31,7 +51,8 @@ function add_to_stream_list(stream_name) {
 | 
			
		||||
                .removeAttr("onclick")
 | 
			
		||||
                .click(function (event) {exports.unsubscribe(stream_name);});
 | 
			
		||||
        } else {
 | 
			
		||||
            $('#subscriptions_table').prepend(templates.subscription({subscription: stream_name}));
 | 
			
		||||
            $('#subscriptions_table').prepend(templates.subscription({subscription: stream_name, color: "c2c2c2"}));
 | 
			
		||||
            draw_colorpicker(stream_name);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -54,7 +75,8 @@ exports.fetch = function () {
 | 
			
		||||
            $('#subscriptions_table tr').remove();
 | 
			
		||||
            if (data) {
 | 
			
		||||
                $.each(data.subscriptions, function (index, name) {
 | 
			
		||||
                    $('#subscriptions_table').append(templates.subscription({subscription: name}));
 | 
			
		||||
                    $('#subscriptions_table').append(templates.subscription({subscription: name, color: "c2c2c2"}));
 | 
			
		||||
                    draw_colorpicker(name);
 | 
			
		||||
                });
 | 
			
		||||
            }
 | 
			
		||||
            $('#streams').focus().select();
 | 
			
		||||
 
 | 
			
		||||
@@ -557,3 +557,8 @@ table.floating_recipient {
 | 
			
		||||
#fmt_help_table {
 | 
			
		||||
    table-layout: fixed;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.subscription_name {
 | 
			
		||||
    vertical-align: middle;
 | 
			
		||||
    padding-left: 0.5em;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user