mirror of
https://github.com/zulip/zulip.git
synced 2025-11-11 09:27:43 +00:00
Add support for absolutely positioned loading indicators
(imported from commit 749b1e866610c686c27cd0a5a492a04dc4d00bf6)
This commit is contained in:
@@ -32,9 +32,23 @@ exports.set_favicon = function (url) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.make_loading_indicator = function (container, opts) {
|
exports.make_loading_indicator = function (outer_container, opts) {
|
||||||
opts = $.extend({}, opts);
|
opts = $.extend({}, opts);
|
||||||
|
var container = outer_container;
|
||||||
container.empty();
|
container.empty();
|
||||||
|
|
||||||
|
if (opts.abs_positioned !== undefined && opts.abs_positioned) {
|
||||||
|
// Create some additional containers to facilitate absolutely
|
||||||
|
// positioned spinners.
|
||||||
|
var container_id = container.attr('id');
|
||||||
|
var inner_container = $('<div id="' + container_id + '_box_container"></div>');
|
||||||
|
container.append(inner_container);
|
||||||
|
container = inner_container;
|
||||||
|
inner_container = $('<div id="' + container_id + '_box"></div>');
|
||||||
|
container.append(inner_container);
|
||||||
|
container = inner_container;
|
||||||
|
}
|
||||||
|
|
||||||
var spinner_elem = $('<div class="loading_indicator_spinner"></div>');
|
var spinner_elem = $('<div class="loading_indicator_spinner"></div>');
|
||||||
container.append(spinner_elem);
|
container.append(spinner_elem);
|
||||||
var text_width = 0;
|
var text_width = 0;
|
||||||
@@ -56,9 +70,9 @@ exports.make_loading_indicator = function (container, opts) {
|
|||||||
// too small. The container's div will be slightly too small,
|
// too small. The container's div will be slightly too small,
|
||||||
// but that's probably OK for our purposes.
|
// but that's probably OK for our purposes.
|
||||||
container.css({width: 38 + text_width,
|
container.css({width: 38 + text_width,
|
||||||
height: 38,
|
height: 38});
|
||||||
display: 'block',
|
outer_container.css({display: 'block',
|
||||||
'white-space': 'nowrap'});
|
'white-space': 'nowrap'});
|
||||||
|
|
||||||
var spinner = new Spinner({
|
var spinner = new Spinner({
|
||||||
lines: 8,
|
lines: 8,
|
||||||
@@ -69,8 +83,8 @@ exports.make_loading_indicator = function (container, opts) {
|
|||||||
shadow: false,
|
shadow: false,
|
||||||
zIndex: 1000
|
zIndex: 1000
|
||||||
}).spin(spinner_elem[0]);
|
}).spin(spinner_elem[0]);
|
||||||
container.data("spinner_obj", spinner);
|
outer_container.data("spinner_obj", spinner);
|
||||||
container.data("destroying", false);
|
outer_container.data("destroying", false);
|
||||||
|
|
||||||
// Make the spinner appear in the center of its enclosing
|
// Make the spinner appear in the center of its enclosing
|
||||||
// element. spinner.el is a 0x0 div. The parts of the spinner
|
// element. spinner.el is a 0x0 div. The parts of the spinner
|
||||||
|
|||||||
Reference in New Issue
Block a user