Sha256: c59f57b90f9cb8eb1d43bd64a70150020b3b5b81272a7523b27b5006c5d9511b
Contents?: true
Size: 1.26 KB
Versions: 10
Compression:
Stored size: 1.26 KB
Contents
class @SpinningForm constructor: (element) -> @element = $(element) @submitBtn = @element.find("[type='submit']") @setBindings() setBindings: () => @element.on('ajax:beforeSend', (event, xhr, settings) => @disableBtn() @submitBtn.html("<i class='fa fa-spinner fa-spin'> </i> Saving...") ) @element.on('ajax:success', (event, xhr, status) => @submitBtn .addClass('btn-info') .html("<i class='fa fa-check'> </i> Saved") ) @element.on('ajax:error', (event, xhr, status) => @submitBtn .addClass('btn-danger') .html("<i class='fa fa-exclamation-triangle'> </i> Oups!") ) @element.on('ajax:complete', (event, xhr, status) => setTimeout( () => @clearBtnClasses() @enableBtn() @submitBtn.html("<i class='fa fa-check'> </i> Save") , 2000 ) ) disableBtn: () => @submitBtn.prop('disabled', true) enableBtn: () => @submitBtn.prop('disabled', false) clearBtnClasses: () => @submitBtn .removeClass('btn-info') .removeClass('btn-danger') $.fn.spinningForm = () -> @each -> new SpinningForm($(this)) jQuery -> $("form[data-remote='true']").each () -> $(this).spinningForm()
Version data entries
10 entries across 10 versions & 1 rubygems