Permalink
Browse files

feature(js): elgg/spinner now supports optional text to be displayed

fixes #8979
  • Loading branch information...
jdalsem committed Apr 15, 2016
1 parent d6f5f17 commit da5c5b06cb665ddec7ab10802dd5c499f61474a6
@@ -4,7 +4,7 @@ define(function (require) {
elgg = require('elgg');
$('.theme-sandbox-content-spinner a').on('click', function () {
spinner[ $(this).data('method') ]();
spinner[ $(this).data('method') ]($(this).data('spinnerText'));
return false;
});
@@ -1,4 +1,5 @@
<p class="theme-sandbox-content-spinner">
<a data-method="start" class="mls" href="#">spinner.start();</a>
<a data-method="start" data-spinner-text="Feeding the hamster" class="mls" href="#">spinner.start('Feeding the hamster');</a>
<a data-method="stop" class="mls" href="#">spinner.stop();</a>
</p>
@@ -4,21 +4,34 @@ define(function (require) {
var active = false;
var SHOW_DELAY = 20;
$('body').append('<div class="elgg-spinner"><div class="elgg-ajax-loader"></div></div>');
$('body').append('<div class="elgg-spinner"><div class="elgg-ajax-loader"></div><div class="elgg-spinner-text elgg-subtext"></div></div>');
return {
start: function () {
start: function (text) {
active = true;
this.clearText();
setTimeout(function () {
if (active) {
$('body').addClass('elgg-spinner-active');
}
}, SHOW_DELAY);
this.setText(text);
},
stop: function () {
active = false;
$('body').removeClass('elgg-spinner-active');
}
},
setText: function (text) {
$('.elgg-spinner .elgg-spinner-text').text(text);
},
clearText: function () {
$('.elgg-spinner .elgg-spinner-text').html('');
},
};
});

0 comments on commit da5c5b0

Please sign in to comment.