From 967d8ca786f57d1cad86dc1c7d1f2dc99b9ae7f7 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Wed, 21 Oct 2015 16:00:39 +0200 Subject: Show a spinner on hint/test buttons when clicked --- js/ladda/ladda.jquery.js | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 js/ladda/ladda.jquery.js (limited to 'js/ladda/ladda.jquery.js') diff --git a/js/ladda/ladda.jquery.js b/js/ladda/ladda.jquery.js new file mode 100644 index 0000000..42c3c80 --- /dev/null +++ b/js/ladda/ladda.jquery.js @@ -0,0 +1,46 @@ +/*! + * Ladda for jQuery + * http://lab.hakim.se/ladda + * MIT licensed + * + * Copyright (C) 2014 Hakim El Hattab, http://hakim.se + */ + +(function( Ladda, $ ) { + if ($ === undefined) + return console.error( 'jQuery required for Ladda.jQuery' ); + + var arr = []; + + $ = $.extend( $, { + ladda: function( arg ) { + if( arg === 'stopAll' ) + Ladda.stopAll(); + } + }); + + $.fn = $.extend( $.fn, { + ladda: function( arg ) { + var args = arr.slice.call( arguments, 1 ); + + if( arg === 'bind' ) { + args.unshift( $( this ).selector ); + Ladda.bind.apply( Ladda, args ); + } + else { + $( this ).each( function() { + var $this = $( this ), ladda; + + if( arg === undefined ) + $this.data( 'ladda', Ladda.create( this ) ); + else { + ladda = $this.data( 'ladda' ); + ladda[arg].apply( ladda, args ); + } + }); + } + + return this; + } + }); +}( this.Ladda, this.jQuery )); \ No newline at end of file -- cgit v1.2.1