ajaxspin 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +69 -0
- data/lib/ajaxspin.rb +6 -0
- data/lib/assets/javascripts/ajaxspin.js.coffee +27 -0
- metadata +87 -0
data/README.md
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
# Ajaxspin
|
2
|
+
|
3
|
+
A simple asset gem that provide an out-of-the box ajax status spin indicator
|
4
|
+
compatible with turbolinks and jquery/jquery_ujs events without any modification.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add these lines to your application's Gemfile assets group:
|
9
|
+
|
10
|
+
gem 'coffee-rails'
|
11
|
+
gem 'spinjs-rails'
|
12
|
+
gem 'ajaxspin'
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install ajaxspin
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
Add to your `application.js` or `application.js.coffee`:
|
25
|
+
|
26
|
+
#= require jquery.spin
|
27
|
+
#= require ajaxspin
|
28
|
+
|
29
|
+
Then, in somewhere, bind it to your `ready` and/or `page:change` events:
|
30
|
+
|
31
|
+
$(document).ready ->
|
32
|
+
$('.navbar').ajaxSpin()
|
33
|
+
|
34
|
+
The following events are already binded:
|
35
|
+
- showEvents: ajax:before, page:fetch and ajaxStart
|
36
|
+
- hideEvents: ajax:complete, page:change and ajaxComplete
|
37
|
+
|
38
|
+
You can easily modify this behavior (and the spin.js behavior) passing your
|
39
|
+
events as options:
|
40
|
+
|
41
|
+
$('.navbar').ajaxSpin
|
42
|
+
showEvents: 'ajax:before page:fetch ajaxStart myCustomShowEvent'
|
43
|
+
hideEvents: 'ajax:complete page:change ajaxComplete myCustomHideEvent'
|
44
|
+
spinjsOpts:
|
45
|
+
lines: 7
|
46
|
+
length: 6
|
47
|
+
width: 3
|
48
|
+
radius: 5
|
49
|
+
corners: 1
|
50
|
+
rotate: 0
|
51
|
+
color: '#000'
|
52
|
+
speed: 1.1
|
53
|
+
trail: 100
|
54
|
+
shadow: false
|
55
|
+
hwaccel: false
|
56
|
+
className: 'spinner'
|
57
|
+
zIndex: 2e9
|
58
|
+
top: 'auto'
|
59
|
+
left: 'auto'
|
60
|
+
|
61
|
+
That's all.
|
62
|
+
|
63
|
+
## Contributing
|
64
|
+
|
65
|
+
1. Fork it
|
66
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
67
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
68
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
69
|
+
5. Create new Pull Request
|
data/lib/ajaxspin.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
$ = jQuery
|
2
|
+
|
3
|
+
$.fn.ajaxSpin = (opts) ->
|
4
|
+
opts = $.extend {}, $.fn.ajaxSpin.options, opts
|
5
|
+
count = 0
|
6
|
+
|
7
|
+
loadState = (element, event) ->
|
8
|
+
count++
|
9
|
+
element.spin opts.spinjsOpts
|
10
|
+
|
11
|
+
doneState = (element, event) ->
|
12
|
+
count--
|
13
|
+
element.spin false if count == 0
|
14
|
+
|
15
|
+
@each ->
|
16
|
+
console.log($(this))
|
17
|
+
$e = $(this)
|
18
|
+
$(document).on opts.showEvents, (event) ->
|
19
|
+
loadState $e, event
|
20
|
+
$(document).on opts.hideEvents, (event) ->
|
21
|
+
doneState $e, event
|
22
|
+
|
23
|
+
$.fn.ajaxSpin.options =
|
24
|
+
spinjsOpts: undefined
|
25
|
+
showEvents: 'ajax:before page:fetch ajaxStart'
|
26
|
+
hideEvents: 'ajax:complete page:change ajaxComplete'
|
27
|
+
|
metadata
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ajaxspin
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Carlos Alexandro Becker
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-11-10 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: coffee-rails
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: spinjs-rails
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
description: A simple ajax status spin indicator build on top of spin.js
|
47
|
+
email:
|
48
|
+
- caarlos0@gmail.com
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- lib/assets/javascripts/ajaxspin.js.coffee
|
54
|
+
- lib/ajaxspin.rb
|
55
|
+
- README.md
|
56
|
+
homepage: http://github.com/caarlos0/ajaxspin
|
57
|
+
licenses: []
|
58
|
+
post_install_message:
|
59
|
+
rdoc_options: []
|
60
|
+
require_paths:
|
61
|
+
- lib
|
62
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ! '>='
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
segments:
|
69
|
+
- 0
|
70
|
+
hash: -3780490060108031913
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
segments:
|
78
|
+
- 0
|
79
|
+
hash: -3780490060108031913
|
80
|
+
requirements: []
|
81
|
+
rubyforge_project:
|
82
|
+
rubygems_version: 1.8.24
|
83
|
+
signing_key:
|
84
|
+
specification_version: 3
|
85
|
+
summary: A simple asset gem that provide an out-of-the box ajax status spin indicator
|
86
|
+
compatible with turbolinks and jquery/jquery_ujs events without any modification.
|
87
|
+
test_files: []
|