From be0c29252e13fb36dfbba1932c4efa788ba17802 Mon Sep 17 00:00:00 2001 From: Zev Benjamin Date: Wed, 10 Jul 2013 13:33:00 -0400 Subject: [PATCH] Make make_loading_indicator take its optional text via an options argument (imported from commit 935f9049c00183f52bad80d54520f81efceb3e49) --- zephyr/static/js/settings.js | 2 +- zephyr/static/js/setup.js | 2 +- zephyr/static/js/util.js | 7 ++++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/zephyr/static/js/settings.js b/zephyr/static/js/settings.js index 694fa5adf2..bc2c88fbd8 100644 --- a/zephyr/static/js/settings.js +++ b/zephyr/static/js/settings.js @@ -131,7 +131,7 @@ $(function () { jQuery.each($('#bot_avatar_file_input')[0].files, function (i, file) { formData.append('file-'+i, file); }); - util.make_loading_indicator($('#create_bot_spinner'), 'Adding bot'); + util.make_loading_indicator($('#create_bot_spinner'), {text: 'Adding bot'}); $('#create_bot_button').hide(); $.ajax({ url: '/json/create_bot', diff --git a/zephyr/static/js/setup.js b/zephyr/static/js/setup.js index f770497468..37bb877939 100644 --- a/zephyr/static/js/setup.js +++ b/zephyr/static/js/setup.js @@ -5,7 +5,7 @@ $(function () { // Display loading indicator. This disappears after the first // get_updates completes. if (page_params.have_initial_messages) { - util.make_loading_indicator($('#page_loading_indicator'), 'Loading...'); + util.make_loading_indicator($('#page_loading_indicator'), {text: 'Loading...'}); } else if (!page_params.needs_tutorial) { util.show_first_run_message(); } diff --git a/zephyr/static/js/util.js b/zephyr/static/js/util.js index 0f432d36ef..42e5225fcd 100644 --- a/zephyr/static/js/util.js +++ b/zephyr/static/js/util.js @@ -32,15 +32,16 @@ exports.set_favicon = function (url) { } }; -exports.make_loading_indicator = function (container, text) { +exports.make_loading_indicator = function (container, opts) { + opts = $.extend({}, opts); container.empty(); var spinner_elem = $('
'); container.append(spinner_elem); var text_width = 0; - if (text !== '' && text !== undefined) { + if (opts.text !== undefined && opts.text !== '') { var text_elem = $(''); - text_elem.text(text); + text_elem.text(opts.text); container.append(text_elem); // See note, below text_width = 20 + text_elem.width();