Guest User

Untitled

a guest
Jul 21st, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. /**
  2. * jQuery-plugin loadingIndicator
  3. *
  4. * used to show a loading indicator in the center of the given object
  5. *
  6. * usage: jQuery('#dialog').loadingindicator('show', { 'caption' : 'Bitte warten'});
  7. * jQuery('#dialog').loadingindicator('hide');
  8. **/
  9. (function($) {
  10. $.fn.loadingIndicator = function(command, settings) {
  11.  
  12. settings = jQuery.extend({
  13. caption: ''
  14. }, settings);
  15.  
  16. return this.each(function() {
  17. if (command == 'show') {
  18. $(this).css('position', 'relative');
  19. $(this).prepend(
  20. '<div id="dialogLoadingIndicator" style="text-align:center"><img src="' +
  21. '/img/loading.gif"/>' +
  22. (settings.caption ? '<p>' + settings.caption + '</p>' : '') +
  23. '</div>'
  24. );
  25.  
  26. /*var left = parseInt(($(this).width() - $('#dialogLoadingIndicator').width()) / 2);
  27. left += parseInt($(this).css('paddingLeft'));
  28. var top = parseInt(($(this).height() - $('#dialogLoadingIndicator').height()) / 2);
  29.  
  30. $('#dialogLoadingIndicator').css('position', 'absolute');
  31. $('#dialogLoadingIndicator').css('left', left + 'px');
  32. $('#dialogLoadingIndicator').css('top', top + 'px');
  33. */
  34.  
  35. } else {
  36. $('#dialogLoadingIndicator').remove();
  37. }
  38. });
  39. }
  40. })(jQuery);
Add Comment
Please, Sign In to add comment