ohsnap-rails 0.1.0 → 0.2.0
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 +4 -4
- data/.DS_Store +0 -0
- data/README.md +2 -0
- data/lib/ohsnap/rails/version.rb +1 -1
- data/vendor/assets/javasccripts/ohsnap.js +47 -19
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a6106a98633b12a09570fadefd08f27002f00e64
|
|
4
|
+
data.tar.gz: cf6daf70d733e3699bf2fd0be836cc9c561c18ad
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 153dc53f32d8aa533b94a885da1541a7afa7048d004397da559422258a5054f57388ac30b54fa4125242ad03f7c528fbda526b7ab069e65d1146353dc592845a
|
|
7
|
+
data.tar.gz: 7102bd382e2f069ecd7b754a4f4e45afb8ebb6abfc111ce649fb822b2ae9470867878170342430ddceee7ef580ce9cd2ced663ca5958a2c3b9bc24e3b92601d6
|
data/.DS_Store
CHANGED
|
Binary file
|
data/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Ohsnap
|
|
2
2
|
|
|
3
|
+
[](https://badge.fury.io/rb/ohsnap-rails)
|
|
4
|
+
|
|
3
5
|
A ruby gem for ohsnap.js [library by justin domingue](https://github.com/justindomingue)
|
|
4
6
|
|
|
5
7
|
A simple notification jQuery/Zepto library designed to be used in mobile apps
|
data/lib/ohsnap/rails/version.rb
CHANGED
|
@@ -4,27 +4,45 @@
|
|
|
4
4
|
*
|
|
5
5
|
* author: Justin Domingue
|
|
6
6
|
* date: september 18, 2015
|
|
7
|
-
* version: 0.
|
|
7
|
+
* version: 1.0.0
|
|
8
8
|
* copyright - nice copyright over here
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
/* Shows a toast on the page
|
|
12
12
|
* Params:
|
|
13
13
|
* text: text to show
|
|
14
|
-
*
|
|
14
|
+
* options: object that can override the following options
|
|
15
|
+
* color: alert will have class 'alert-color'. Default null
|
|
16
|
+
* icon: class of the icon to show before the alert. Default null
|
|
17
|
+
* duration: duration of the notification in ms. Default 5000ms
|
|
18
|
+
* container-id: id of the alert container. Default 'ohsnap'
|
|
19
|
+
* fade-duration: duration of the fade in/out of the alerts. Default 'fast'
|
|
15
20
|
*/
|
|
16
|
-
function ohSnap(text,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
function ohSnap(text, options) {
|
|
22
|
+
var defaultOptions = {
|
|
23
|
+
'color' : null, // color is CSS class `alert-color`
|
|
24
|
+
'icon' : null, // class of the icon to show before the alert text
|
|
25
|
+
'duration' : '5000', // duration of the notification in ms
|
|
26
|
+
'container-id': 'ohsnap', // id of the alert container
|
|
27
|
+
'fade-duration': 'fast', // duration of the fade in/out of the alerts. fast, slow or integer in ms
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
options = (typeof options == 'object') ? $.extend(defaultOptions, options) : defaultOptions;
|
|
31
|
+
|
|
32
|
+
var $container = $('#'+options['container-id']),
|
|
33
|
+
icon_markup = "",
|
|
34
|
+
color_markup = "";
|
|
35
|
+
|
|
36
|
+
if (options.icon) {
|
|
37
|
+
icon_markup = "<span class='" + options.icon + "'></span> ";
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (options.color) {
|
|
41
|
+
color_markup = 'alert-' + options.color;
|
|
24
42
|
}
|
|
25
43
|
|
|
26
44
|
// Generate the HTML
|
|
27
|
-
html = $('<div class="alert
|
|
45
|
+
var html = $('<div class="alert ' + color_markup + '">' + icon_markup + text + '</div>').fadeIn(options['fade-duration']);
|
|
28
46
|
|
|
29
47
|
// Append the label to the container
|
|
30
48
|
$container.append(html);
|
|
@@ -34,23 +52,33 @@ function ohSnap(text, color, icon) {
|
|
|
34
52
|
ohSnapX($(this));
|
|
35
53
|
});
|
|
36
54
|
|
|
37
|
-
// After '
|
|
55
|
+
// After 'duration' seconds, the animation fades out
|
|
38
56
|
setTimeout(function() {
|
|
39
57
|
ohSnapX(html);
|
|
40
|
-
},
|
|
58
|
+
}, options.duration);
|
|
41
59
|
}
|
|
42
60
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
61
|
+
/* Removes a toast from the page
|
|
62
|
+
* params:
|
|
63
|
+
* Called without arguments, the function removes all alerts
|
|
64
|
+
* element: a jQuery object to remove
|
|
65
|
+
* options:
|
|
66
|
+
* duration: duration of the alert fade out - 'fast', 'slow' or time in ms. Default 'fast'
|
|
67
|
+
*/
|
|
68
|
+
function ohSnapX(element, options) {
|
|
69
|
+
defaultOptions = {
|
|
70
|
+
'duration': 'fast'
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
options = (typeof options == 'object') ? $.extend(defaultOptions, options) : defaultOptions;
|
|
46
74
|
|
|
47
75
|
if (typeof element !== "undefined") {
|
|
48
|
-
element.fadeOut(
|
|
76
|
+
element.fadeOut(options.duration, function() {
|
|
49
77
|
$(this).remove();
|
|
50
78
|
});
|
|
51
79
|
} else {
|
|
52
|
-
$('.alert').fadeOut(
|
|
80
|
+
$('.alert').fadeOut(options.duration, function() {
|
|
53
81
|
$(this).remove();
|
|
54
82
|
});
|
|
55
83
|
}
|
|
56
|
-
}
|
|
84
|
+
}
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ohsnap-rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Rahul Lakhaney
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2016-02-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -85,3 +85,4 @@ signing_key:
|
|
|
85
85
|
specification_version: 4
|
|
86
86
|
summary: Ruby gem for ohsnap.
|
|
87
87
|
test_files: []
|
|
88
|
+
has_rdoc:
|