Skip to content

Commit

Permalink
Replacing the gif AJAX spinner with spin.js
Browse files Browse the repository at this point in the history
Fixes Bug 992822

Change-Id: Ibd1b81ca54dd47ffb01f3ced9ca92ad1ed727483
  • Loading branch information
John Postlethwait committed May 1, 2012
1 parent aef2e5a commit 8396026
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 13 deletions.
22 changes: 19 additions & 3 deletions horizon/static/horizon/js/horizon.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,16 @@ var Horizon = function() {
}
};

horizon.spinner_options = {
lines: 10,
length: 5,
width: 2,
radius: 3,
color: '#000',
speed: 0.8,
trail: 50
};

/* Namespace for core functionality related to DataTables. */
horizon.datatables = {
update: function () {
Expand Down Expand Up @@ -140,11 +150,17 @@ var Horizon = function() {
},
success: function (data, textStatus, jqXHR) {
var $new_row = $(data);

if($new_row.hasClass('status_unknown')) {
// only add spinning animation if row needs update
var spinner = '<i class="icon-updating ajax-updating"></i>';
$new_row.find("td.status_unknown").prepend(spinner);
var spinner_elm = $new_row.find("td.status_unknown:last");

spinner_elm.css('padding-left', '32px');
spinner_elm.spin(horizon.spinner_options);

$(spinner_elm.data().spinner.el).css('top', '9px');
$(spinner_elm.data().spinner.el).css('left', '-15px');
}

// Only replace row if the html content has changed
if($new_row.html() != $row.html()) {
if($row.find(':checkbox').is(':checked')) {
Expand Down
17 changes: 17 additions & 0 deletions horizon/static/horizon/js/spin.jquery.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// jQuery add-on for allowing spin.js to act on jQuery elements directly.

$.fn.spin = function(opts) {
this.each(function() {
var $this = $(this),
data = $this.data();

if (data.spinner) {
data.spinner.stop();
delete data.spinner;
}
if (opts !== false) {
data.spinner = new Spinner($.extend({color: $this.css('color')}, opts)).spin(this);
}
});
return this;
};
2 changes: 2 additions & 0 deletions horizon/static/horizon/js/spin.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 1 addition & 10 deletions openstack_dashboard/static/dashboard/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -514,17 +514,8 @@ table form {
white-space: nowrap;
}

.icon-updating.ajax-updating {
background: transparent url(../img/spinner.gif) no-repeat center center;
padding: 1px;
}

td .icon-updating.ajax-updating {
margin-right: 5px;
}

.overview {
font-size: 24px;
font-size: 24px;
}

#monitoring {
Expand Down
Binary file removed openstack_dashboard/static/dashboard/img/spinner.gif
Binary file not shown.
2 changes: 2 additions & 0 deletions openstack_dashboard/templates/_scripts.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{% comment %} jQuery and Plugins {% endcomment %}
<script src='{{ STATIC_URL }}horizon/js/jquery/jquery.min.js' type='text/javascript' charset="utf-8"></script>
<script src="{{ STATIC_URL }}horizon/js/spin.js" type="text/javascript" charset="utf-8"></script>
<script src="{{ STATIC_URL }}horizon/js/spin.jquery.js" type="text/javascript" charset="utf-8"></script>
<script src='{{ STATIC_URL }}horizon/js/json2.js' type='text/javascript' charset="utf-8"></script>
<script src='{{ STATIC_URL }}horizon/js/jquery/jquery.cookie.js' type='text/javascript' charset="utf-8"></script>
<script src='{{ STATIC_URL }}horizon/js/jquery/jquery.quicksearch.js' type='text/javascript' charset="utf-8"></script>
Expand Down

0 comments on commit 8396026

Please sign in to comment.