Commit 7391983adb35bbbeb3118ef4d156a981078cd0dd
1 parent
682ee5be
Exists in
master
and in
29 other branches
Add loading overlay js/css
Showing
5 changed files
with
46 additions
and
0 deletions
Show diff stats
3.4 KB
public/javascripts/application.js
| @@ -21,6 +21,7 @@ | @@ -21,6 +21,7 @@ | ||
| 21 | * noosfero libraries | 21 | * noosfero libraries |
| 22 | *= require_self | 22 | *= require_self |
| 23 | *= require modal.js | 23 | *= require modal.js |
| 24 | +*= require loading-overlay.js | ||
| 24 | * views speficics | 25 | * views speficics |
| 25 | *= require add-and-join.js | 26 | *= require add-and-join.js |
| 26 | *= require report-abuse.js | 27 | *= require report-abuse.js |
| @@ -0,0 +1,36 @@ | @@ -0,0 +1,36 @@ | ||
| 1 | +if (typeof loading_overlay === 'undefined') { | ||
| 2 | + | ||
| 3 | +// block user actions while making a post. Also indicate the network transaction | ||
| 4 | +loading_overlay = { | ||
| 5 | + | ||
| 6 | + show: function (selector) { | ||
| 7 | + var element = jQuery(selector); | ||
| 8 | + if (element.length > 0) { | ||
| 9 | + var overlay = jQuery('<div>', { | ||
| 10 | + class: 'loading-overlay', | ||
| 11 | + css: { | ||
| 12 | + width: element.outerWidth(), | ||
| 13 | + height: element.outerHeight(), | ||
| 14 | + left: element.position().left, | ||
| 15 | + top: element.position().top, | ||
| 16 | + marginLeft: parseFloat(element.css('margin-left')), | ||
| 17 | + marginTop: parseFloat(element.css('margin-top')), | ||
| 18 | + marginRight: parseFloat(element.css('margin-right')), | ||
| 19 | + marginBottom: parseFloat(element.css('margin-bottom')), | ||
| 20 | + }, | ||
| 21 | + }).appendTo(element).get(0); | ||
| 22 | + | ||
| 23 | + overlay.dest = element; | ||
| 24 | + element.loading_overlay = overlay; | ||
| 25 | + } | ||
| 26 | + }, | ||
| 27 | + | ||
| 28 | + hide: function (selector) { | ||
| 29 | + var element = jQuery(selector); | ||
| 30 | + var overlay = element.find('.loading-overlay'); | ||
| 31 | + overlay.remove(); | ||
| 32 | + }, | ||
| 33 | + | ||
| 34 | +}; | ||
| 35 | + | ||
| 36 | +} |
public/stylesheets/application.css
| @@ -11,6 +11,7 @@ | @@ -11,6 +11,7 @@ | ||
| 11 | * noosfero libraries | 11 | * noosfero libraries |
| 12 | *= require_self | 12 | *= require_self |
| 13 | *= require iepngfix/iepngfix | 13 | *= require iepngfix/iepngfix |
| 14 | + *= require loading-overlay | ||
| 14 | * views specifics | 15 | * views specifics |
| 15 | *= require chat | 16 | *= require chat |
| 16 | *= require search | 17 | *= require search |