jquery_ajax_status 1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a3a31d3ba5cffb2bc8e625be0cb818753e2d341c
4
+ data.tar.gz: cdd3c803a6d2d07c719db26a3a459635cf732182
5
+ SHA512:
6
+ metadata.gz: b10b33a3ae414759584d8338b512f7524154884a395a1d17859156f8deb2075c1548e88ed5d9bf3249483079f6dcdb9140cd8b6c5086a8807dcafd9023a42f58
7
+ data.tar.gz: a97f63df33ab6b5b833741606699dd39e013f348ef52484d3107a71995dd98407f7b0a71bd76094154f1a2279cdf7419c89e2182e5e5cfa7f6bc0c62b6e9eb92
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright © 2014-2015 LICO Innovations
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ The software is provided "as is", without warranty of any kind, express or
16
+ implied, including but not limited to the warranties of merchantability, fitness
17
+ for a particular purpose and noninfringement. In no event shall the authors or
18
+ copyright holders be liable for any claim, damages or other liability, whether
19
+ in an action of contract, tort or otherwise, arising from, out of or in
20
+ connection with the software or the use or other dealings in the software.
data/README.markdown ADDED
@@ -0,0 +1,121 @@
1
+ [![Gem Version](https://badge.fury.io/rb/jquery_ajax_status.svg)](http://badge.fury.io/rb/jquery_ajax_status)
2
+
3
+ A simple loading indicator to show you're doing AJAX requests.
4
+
5
+ [Here's a demo](https://cdn.rawgit.com/bluerail/jquery_ajax_status/master/demo.html)
6
+
7
+
8
+ Usage
9
+ =====
10
+ Include the [JavaScript code](https://github.com/bluerail/jquery_ajax_status/tree/master/lib/assets/javascripts)
11
+ and the [stylesheet](https://github.com/bluerail/jquery_ajax_status/tree/master/lib/assets/stylesheets).
12
+ For Ruby on Rails, you can use the gem (see below).
13
+
14
+ We automatically hook into jQuery callbacks.
15
+
16
+ Ruby on Rails installation
17
+ --------------------------
18
+ This is packaged as a Ruby gem ready to use in a Rails app.
19
+
20
+ Add to your `Gemfile`
21
+
22
+ gem 'jquery_ajax_status'
23
+
24
+ Add to your `application.js`:
25
+
26
+ // =require jquery_ajax_status
27
+
28
+ And to your `application.css`:
29
+
30
+ /* =require jquery_ajax_status */
31
+
32
+
33
+ Configuration
34
+ =============
35
+ It should work out of the box, configuration is optional. Here are the defaults:
36
+
37
+ window.ajax_status = {
38
+ // Show after /n/ milliseconds; this prevents having the loader pop-up
39
+ // constantly for requests that are near-instantaneous
40
+ delay: 500,
41
+
42
+ // Animate the background
43
+ animate: true,
44
+
45
+ // CSS class to add; %%CLASS%% in html is replaced by this
46
+ class: 'ajax-status-default',
47
+
48
+ // Text to use; %%TEXT%% in html is replaced by this
49
+ text: 'Loading…',
50
+
51
+ // HTML to append
52
+ html: "<div id="ajax-status" class="%%CLASS%%">" +
53
+ "<span class="ajax-status-animate"></span>" +
54
+ "<span class="ajax-status-text">%%TEXT%%</span>" +
55
+ </div>"
56
+ }
57
+
58
+ You can change a setting with:
59
+
60
+ window.ajax_status.delay = 2000
61
+
62
+ *Do not* override the entire `window.ajax_status` object, as this also includes
63
+ the code to make it run.
64
+
65
+
66
+ Tips
67
+ ====
68
+
69
+ I want one of those spinning thingies
70
+ -------------------------------------
71
+ You can override `window.ajax_status.text` to use a different text. This can
72
+ also be HTML:
73
+
74
+ window.ajax_status.animate = false
75
+ window.ajax_status.text = '<i class="fa fa-spinner fa-spin"></i>'
76
+
77
+
78
+ I want to translate the `Loading…` text
79
+ ---------------------------------------
80
+ Again, override `window.ajax_status.text`, for example for gettext:
81
+
82
+ window.ajax_status.text = _('Loading')
83
+
84
+
85
+ I want to start it manually
86
+ ---------------------------
87
+ Use `window.ajax_status.start` and `window.ajax_status.stop`.
88
+
89
+ For example:
90
+
91
+ # Unbind the default events
92
+ $(document).off 'ajaxStart page:fetch', window.ajax_status.start
93
+ $(document).off 'ajaxComplete page:change', window.ajax_status.stop
94
+
95
+ # And the turbolink events
96
+ $(document).off 'page:fetch', window.ajax_status.start
97
+ $(document).off 'page:change', window.ajax_status.stop
98
+
99
+ # Trigger for this ajax call
100
+ jQuery.ajax
101
+ url: '/foo'
102
+ beforeSend: window.ajax_status.start
103
+ complete: window.ajax_status.stop
104
+ success: (data) ->
105
+ # ...
106
+ error: ->
107
+ # ...
108
+
109
+
110
+ I don't like the {colors,font size,position,etc}
111
+ ------------------------------------------------
112
+ You have 2 options:
113
+
114
+ - Change `window.ajax_status.class` to something else; you still get some CSS
115
+ from the `#ajax-status` id, but this is what most people want.
116
+ - Don't include my CSS and write your own.
117
+
118
+
119
+ I want more configuration!
120
+ --------------------------
121
+ Submit a patch ;-)
@@ -0,0 +1,59 @@
1
+ // Generated by CoffeeScript 1.9.1
2
+ (function() {
3
+ var timer;
4
+
5
+ timer = null;
6
+
7
+ window.ajax_status = {
8
+ delay: 500,
9
+ animate: true,
10
+ "class": 'ajax-status-default',
11
+ text: 'Loading…',
12
+ html: "<div id=\"ajax-status\" class=\"%%CLASS%%\">\n <span class=\"ajax-status-animate\"></span>\n <span class=\"ajax-status-text\">%%TEXT%%</span>\n</div>",
13
+ start: function() {
14
+ $(document.body).css('cursor', 'wait');
15
+ clearTimeout(timer);
16
+ return setTimeout(window.ajax_status.show, ajax_status.delay);
17
+ },
18
+ stop: function() {
19
+ $(document.body).css('cursor', '');
20
+ clearTimeout(timer);
21
+ return window.ajax_status.hide();
22
+ },
23
+ hide: function() {
24
+ return $('#ajax-status').slideUp(150, function() {
25
+ return $('#ajax-status').remove();
26
+ });
27
+ },
28
+ show: function() {
29
+ $(document.body).append(ajax_status.html.replace('%%TEXT%%', window.ajax_status.text).replace('%%CLASS%%', window.ajax_status["class"]));
30
+ return $('#ajax-status').slideDown(150, function() {
31
+ var fun;
32
+ if (!ajax_status.animate) {
33
+ return;
34
+ }
35
+ fun = function() {
36
+ if ($('#ajax-status .ajax-status-animate').length === 0 || !ajax_status.animate) {
37
+ return;
38
+ }
39
+ return $('#ajax-status .ajax-status-animate').css('left', "-" + ($('#ajax-status .ajax-status-animate').outerWidth()) + "px").animate({
40
+ left: ($('#ajax-status').outerWidth()) + "px"
41
+ }, {
42
+ duration: 2000,
43
+ complete: fun
44
+ });
45
+ };
46
+ return fun();
47
+ });
48
+ }
49
+ };
50
+
51
+ $(document).on('ajaxStart', window.ajax_status.start);
52
+
53
+ $(document).on('ajaxComplete', window.ajax_status.stop);
54
+
55
+ $(document).on('page:fetch', window.ajax_status.start);
56
+
57
+ $(document).on('page:change', window.ajax_status.stop);
58
+
59
+ }).call(this);
@@ -0,0 +1,72 @@
1
+ timer = null
2
+
3
+ window.ajax_status =
4
+ # Show after /n/ milliseconds; this prevents having the loader pop-up
5
+ # constantly for requests that are near-instantaneous
6
+ delay: 500
7
+
8
+ # Animate the background
9
+ animate: true
10
+
11
+ # CSS class to add; %%CLASS%% in html is replaced by this
12
+ class: 'ajax-status-default'
13
+
14
+ # Text to use; %%TEXT%% in html is replaced by this
15
+ text: 'Loading…'
16
+
17
+ # HTML to append
18
+ html: """<div id="ajax-status" class="%%CLASS%%">
19
+ <span class="ajax-status-animate"></span>
20
+ <span class="ajax-status-text">%%TEXT%%</span>
21
+ </div>"""
22
+
23
+
24
+ # Functions
25
+
26
+ # Start showing it after the delay
27
+ start: ->
28
+ $(document.body).css 'cursor', 'wait'
29
+ clearTimeout timer
30
+ setTimeout window.ajax_status.show, ajax_status.delay
31
+
32
+
33
+ # Stop showing the status
34
+ stop: ->
35
+ $(document.body).css 'cursor', ''
36
+ clearTimeout timer
37
+ window.ajax_status.hide()
38
+
39
+
40
+ # Hide the widget
41
+ hide: -> $('#ajax-status').slideUp 150, -> $('#ajax-status').remove()
42
+
43
+
44
+ # Show the widget
45
+ show: ->
46
+ $(document.body).append(ajax_status.html
47
+ .replace('%%TEXT%%', window.ajax_status.text)
48
+ .replace('%%CLASS%%', window.ajax_status.class))
49
+
50
+ $('#ajax-status').slideDown 150, ->
51
+ return unless ajax_status.animate
52
+
53
+ fun = ->
54
+ return if $('#ajax-status .ajax-status-animate').length is 0 or not ajax_status.animate
55
+ $('#ajax-status .ajax-status-animate')
56
+ .css 'left', "-#{$('#ajax-status .ajax-status-animate').outerWidth()}px"
57
+ .animate {
58
+ left: "#{$('#ajax-status').outerWidth()}px"
59
+ }, {
60
+ duration: 2000
61
+ complete: fun
62
+ }
63
+ fun()
64
+
65
+
66
+ # Hook into jQuery events
67
+ $(document).on 'ajaxStart', window.ajax_status.start
68
+ $(document).on 'ajaxComplete', window.ajax_status.stop
69
+
70
+ # ... and into turbolinks
71
+ $(document).on 'page:fetch', window.ajax_status.start
72
+ $(document).on 'page:change', window.ajax_status.stop
@@ -0,0 +1,38 @@
1
+ #ajax-status {
2
+ z-index: 99999;
3
+ overflow: hidden;
4
+ display: none;
5
+ position: fixed;
6
+ top: 0;
7
+ left: 50%;
8
+ text-align: center; }
9
+ #ajax-status .ajax-status-animate {
10
+ position: absolute;
11
+ top: 0;
12
+ bottom: 0;
13
+ left: -1em;
14
+ width: 1em; }
15
+
16
+ .ajax-status-default {
17
+ width: 10em;
18
+ margin-left: -5em;
19
+ height: 2.5em;
20
+ line-height: 2.5em;
21
+ border-bottom-right-radius: 3px;
22
+ border-bottom-left-radius: 3px;
23
+ background-color: #2a9b3f;
24
+ color: #fff;
25
+ box-shadow: 0 0 3px rgba(0, 0, 0, 0.4); }
26
+ .ajax-status-default .ajax-status-animate {
27
+ background-image: -webkit-linear-gradient(left, #2a9b3f, #144b1e 50%, #2a9b3f);
28
+ background-image: linear-gradient(to right, #2a9b3f, #144b1e 50%, #2a9b3f);
29
+ background-repeat: no-repeat;
30
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FF2A9B3F', endColorstr='#FF2A9B3F', GradientType=1); }
31
+ .ajax-status-default .ajax-status-text {
32
+ position: absolute;
33
+ left: 0;
34
+ width: 10em;
35
+ text-shadow: -1px 1px #333;
36
+ font-weight: bold; }
37
+
38
+ /*# sourceMappingURL=jquery_ajax_status.css.map */
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "mappings": "AAIA,YAAY;EAGV,OAAO,EAAE,KAAK;EACd,QAAQ,EAAE,MAAM;EAChB,OAAO,EAAE,IAAI;EAEb,QAAQ,EAAE,KAAK;EACf,GAAG,EAAE,CAAC;EACN,IAAI,EAAE,GAAG;EACT,UAAU,EAAE,MAAM;EAElB,iCAAoB;IAClB,QAAQ,EAAE,QAAQ;IAClB,GAAG,EAAE,CAAC;IACN,MAAM,EAAE,CAAC;IACT,IAAI,EAAE,IAA0B;IAChC,KAAK,EAAE,GAAuB;;AAGlC,oBAAoB;EAClB,KAAK,EAzBa,IAAI;EA0BtB,WAAW,EAAE,IAAyB;EACtC,MAAM,EA1Ba,KAAK;EA2BxB,WAAW,EA3BQ,KAAK;EA4BxB,0BAA0B,EAAE,GAAG;EAC/B,yBAAyB,EAAE,GAAG;EAC9B,gBAAgB,EAAE,OAAO;EACzB,KAAK,EAAE,IAAI;EACX,UAAU,EAAE,0BAA0B;EAEtC,yCAAoB;IAElB,gBAAgB,EAAE,4DAA4D;IAC9E,gBAAgB,EAAE,wDAAwD;IAC1E,iBAAiB,EAAE,SAAS;IAC5B,MAAM,EAAE,8GAA8G;EAExH,sCAAiB;IAEf,QAAQ,EAAE,QAAQ;IAClB,IAAI,EAAE,CAAC;IACP,KAAK,EA9CW,IAAI;IAgDpB,WAAW,EAAE,aAAa;IAC1B,WAAW,EAAE,IAAI",
4
+ "sources": ["jquery_ajax_status.sass"],
5
+ "names": [],
6
+ "file": "jquery_ajax_status.css"
7
+ }
@@ -0,0 +1,50 @@
1
+ $ajax_status_width: 10em
2
+ $ajax_status_height: 2.5em
3
+
4
+
5
+ #ajax-status
6
+ // If you're using bootstrap
7
+ //z-index: $zindex-navbar-fixed + 1;
8
+ z-index: 99999
9
+ overflow: hidden
10
+ display: none
11
+
12
+ position: fixed
13
+ top: 0
14
+ left: 50%
15
+ text-align: center
16
+
17
+ .ajax-status-animate
18
+ position: absolute
19
+ top: 0
20
+ bottom: 0
21
+ left: -($ajax_status_width / 10)
22
+ width: $ajax_status_width / 10
23
+
24
+
25
+ .ajax-status-default
26
+ width: $ajax_status_width
27
+ margin-left: -($ajax_status_width / 2)
28
+ height: $ajax_status_height
29
+ line-height: $ajax_status_height
30
+ border-bottom-right-radius: 3px
31
+ border-bottom-left-radius: 3px
32
+ background-color: #2a9b3f
33
+ color: #fff
34
+ box-shadow: 0 0 3px rgba(0, 0, 0, 0.4)
35
+
36
+ .ajax-status-animate
37
+ //@include gradient-horizontal-three-colors(#2a9b3f, darken(#2a9b3f, 20%), 50%, #2a9b3f);
38
+ background-image: -webkit-linear-gradient(left, #2a9b3f, #144b1e 50%, #2a9b3f)
39
+ background-image: linear-gradient(to right, #2a9b3f, #144b1e 50%, #2a9b3f)
40
+ background-repeat: no-repeat
41
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FF2A9B3F', endColorstr='#FF2A9B3F', GradientType=1)
42
+
43
+ .ajax-status-text
44
+ // Make sure it's above the animator; z-index doesn't work
45
+ position: absolute
46
+ left: 0
47
+ width: $ajax_status_width
48
+
49
+ text-shadow: -1px 1px #333
50
+ font-weight: bold
@@ -0,0 +1,7 @@
1
+ module JqueryAjaxStatus
2
+ end
3
+
4
+ if defined? ::Rails
5
+ class JqueryAjaxStatus::Engine < ::Rails::Engine
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jquery_ajax_status
3
+ version: !ruby/object:Gem::Version
4
+ version: '1.1'
5
+ platform: ruby
6
+ authors:
7
+ - Martin Tournoij
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-08-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: coffee-rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: jquery-rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: sass
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description:
56
+ email:
57
+ - martin@arp242.net
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - MIT-LICENSE
63
+ - README.markdown
64
+ - lib/assets/javascripts/jquery_ajax_status.js
65
+ - lib/assets/javascripts/jquery_ajax_status.js.coffee
66
+ - lib/assets/stylesheets/jquery_ajax_status.css
67
+ - lib/assets/stylesheets/jquery_ajax_status.css.map
68
+ - lib/assets/stylesheets/jquery_ajax_status.sass
69
+ - lib/jquery_ajax_status.rb
70
+ homepage: https://github.com/bluerail/jquery_ajax_status
71
+ licenses:
72
+ - MIT
73
+ metadata: {}
74
+ post_install_message:
75
+ rdoc_options: []
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ requirements: []
89
+ rubyforge_project:
90
+ rubygems_version: 2.4.5.1
91
+ signing_key:
92
+ specification_version: 4
93
+ summary: A simple loading indicator to show you're doing ajax requests
94
+ test_files: []