Commit 7391983adb35bbbeb3118ef4d156a981078cd0dd
1 parent
682ee5be
Exists in
master
and in
21 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
| ... | ... | @@ -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