ladda.jquery.js 894 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*!
  2. * Ladda for jQuery
  3. * http://lab.hakim.se/ladda
  4. * MIT licensed
  5. *
  6. * Copyright (C) 2015 Hakim El Hattab, http://hakim.se
  7. */
  8. (function( Ladda, $ ) {
  9. if ($ === undefined)
  10. return console.error( 'jQuery required for Ladda.jQuery' );
  11. var arr = [];
  12. $ = $.extend( $, {
  13. ladda: function( arg ) {
  14. if( arg === 'stopAll' )
  15. Ladda.stopAll();
  16. }
  17. });
  18. $.fn = $.extend( $.fn, {
  19. ladda: function( arg ) {
  20. var args = arr.slice.call( arguments, 1 );
  21. if( arg === 'bind' ) {
  22. args.unshift( $( this ).selector );
  23. Ladda.bind.apply( Ladda, args );
  24. }
  25. else {
  26. $( this ).each( function() {
  27. var $this = $( this ), ladda;
  28. if( arg === undefined )
  29. $this.data( 'ladda', Ladda.create( this ) );
  30. else {
  31. ladda = $this.data( 'ladda' );
  32. ladda[arg].apply( ladda, args );
  33. }
  34. });
  35. }
  36. return this;
  37. }
  38. });
  39. }( this.Ladda, this.jQuery ));