Only draw a color picker when it is shown

(imported from commit 3ad2f3dbc753a1e04429ac365aa1c9d244742cbc)
This commit is contained in:
Zev Benjamin 2013-01-10 14:22:25 -05:00
parent 3442ac05b8
commit 717513cc07
1 changed files with 3 additions and 11 deletions

View File

@ -81,15 +81,6 @@ function get_button_for_stream(stream_name) {
return $('#subscription_' + stream_info[stream_name.toLowerCase()].id).find('.unsubscribe_button'); return $('#subscription_' + stream_info[stream_name.toLowerCase()].id).find('.unsubscribe_button');
} }
function draw_colorpicker(stream_name) {
var colorpicker = $('#subscription_' + stream_info[stream_name.toLowerCase()].id).find('.colorpicker');
colorpicker.spectrum(colorpicker_options);
}
function draw_all_colorpickers() {
$('.colorpicker').spectrum(colorpicker_options);
}
function add_to_stream_list(stream_name) { function add_to_stream_list(stream_name) {
var stream_sub_row; var stream_sub_row;
var sub; var sub;
@ -120,7 +111,6 @@ function add_to_stream_list(stream_name) {
stream_info[lstream_name] = sub; stream_info[lstream_name] = sub;
$('#subscriptions_table').prepend(templates.subscription({subscriptions: [sub]})); $('#subscriptions_table').prepend(templates.subscription({subscriptions: [sub]}));
draw_colorpicker(stream_name);
} }
} }
@ -184,7 +174,6 @@ exports.fetch = function () {
subscriptions.push(sub); subscriptions.push(sub);
}); });
$('#subscriptions_table').append(templates.subscription({subscriptions: subscriptions})); $('#subscriptions_table').append(templates.subscription({subscriptions: subscriptions}));
draw_all_colorpickers();
} }
$('#streams').focus().select(); $('#streams').focus().select();
}, },
@ -342,6 +331,9 @@ $(function () {
var stream = sub_row.find('.subscription_name').text(); var stream = sub_row.find('.subscription_name').text();
var error_elem = sub_row.find('.subscriber_list_container .alert-error'); var error_elem = sub_row.find('.subscriber_list_container .alert-error');
var list = sub_row.find('.subscriber_list_container ul'); var list = sub_row.find('.subscriber_list_container ul');
var colorpicker = sub_row.find('.colorpicker');
colorpicker.spectrum(colorpicker_options);
error_elem.addClass('hide'); error_elem.addClass('hide');
list.empty(); list.empty();