bootstrap_notify_gem 0.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 +7 -0
- data/.gitignore +9 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +29 -0
- data/README.md +42 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/bootstrap_notify_gem.gemspec +34 -0
- data/lib/bootstrap_notify_gem.rb +5 -0
- data/lib/bootstrap_notify_gem/version.rb +3 -0
- data/vendor/assets/javascripts/bootstrap_notify.js +416 -0
- metadata +84 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c1734fb0ce16485639b51c1ee21ee110337325ef
|
4
|
+
data.tar.gz: 2d3d76d5c7e4ac1d1678dc32657c258a9f43abe7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b4c8f7cc80d92cd895431353b9faf0a83ce8e1daf95cecbbe783324e44a6d236e433dfe021b9f005baeb03720f294b24b2ffb909947bcfe86db0232160937b9c
|
7
|
+
data.tar.gz: 74d67bc85db5c8b2a453a71d415e0c54556f408c06651b1737d132e93de3a7d9653bdb2a1e39fd6c661bec9e77ce90711c53e1f17f3e5bcc1c4225fd61f9b95b
|
data/.gitignore
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at jesse.krasnostein@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Jesse Krasnostein
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all 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,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
22
|
+
|
23
|
+
The MIT License (MIT) Copyright (c) 2015 Robert McIntosh
|
24
|
+
|
25
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
26
|
+
|
27
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
28
|
+
|
29
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# BootstrapNotify
|
2
|
+
|
3
|
+
BoostrapNotify is a wrapper for mouse0270's bootstrap-notify library which can be found here: https://github.com/mouse0270/bootstrap-notify
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'bootstrap_notify_gem'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install bootstrap_notify_gem
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Add the following line to your application.js file
|
24
|
+
```ruby
|
25
|
+
//= require bootstrap_notify
|
26
|
+
```
|
27
|
+
|
28
|
+
## Development
|
29
|
+
|
30
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
31
|
+
|
32
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
33
|
+
|
34
|
+
## Contributing
|
35
|
+
|
36
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/jkrasx/bootstrap_notify_gem. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
37
|
+
|
38
|
+
|
39
|
+
## License
|
40
|
+
|
41
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
42
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "bootstrap_notify_gem"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'bootstrap_notify_gem/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "bootstrap_notify_gem"
|
8
|
+
spec.version = BootstrapNotifyGem::VERSION
|
9
|
+
spec.authors = ["Jesse Krasnostein"]
|
10
|
+
|
11
|
+
spec.summary = %q{ A gem wrapper for Bootstrap Notify https://github.com/mouse0270/bootstrap-notify.}
|
12
|
+
spec.description = %q{ gem boostrap_notify is a wrapper for mouse0270's bootstrap-notify js package.}
|
13
|
+
spec.homepage = "https://github.com/jkras/bootstrap_notify"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
+
# if spec.respond_to?(:metadata)
|
19
|
+
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
20
|
+
# else
|
21
|
+
# raise "RubyGems 2.0 or newer is required to protect against " \
|
22
|
+
# "public gem pushes."
|
23
|
+
# end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
26
|
+
f.match(%r{^(test|spec|features)/})
|
27
|
+
end
|
28
|
+
spec.bindir = "exe"
|
29
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
30
|
+
spec.require_paths = ["lib"]
|
31
|
+
|
32
|
+
spec.add_development_dependency "bundler", "~> 1.14"
|
33
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
34
|
+
end
|
@@ -0,0 +1,416 @@
|
|
1
|
+
/*
|
2
|
+
* Project: Bootstrap Notify = v3.1.5
|
3
|
+
* Description: Turns standard Bootstrap alerts into "Growl-like" notifications.
|
4
|
+
* Author: Mouse0270 aka Robert McIntosh
|
5
|
+
* License: MIT License
|
6
|
+
* Website: https://github.com/mouse0270/bootstrap-growl
|
7
|
+
*/
|
8
|
+
|
9
|
+
/* global define:false, require: false, jQuery:false */
|
10
|
+
|
11
|
+
(function (factory) {
|
12
|
+
if (typeof define === 'function' && define.amd) {
|
13
|
+
// AMD. Register as an anonymous module.
|
14
|
+
define(['jquery'], factory);
|
15
|
+
} else if (typeof exports === 'object') {
|
16
|
+
// Node/CommonJS
|
17
|
+
factory(require('jquery'));
|
18
|
+
} else {
|
19
|
+
// Browser globals
|
20
|
+
factory(jQuery);
|
21
|
+
}
|
22
|
+
}(function ($) {
|
23
|
+
// Create the defaults once
|
24
|
+
var defaults = {
|
25
|
+
element: 'body',
|
26
|
+
position: null,
|
27
|
+
type: "info",
|
28
|
+
allow_dismiss: true,
|
29
|
+
allow_duplicates: true,
|
30
|
+
newest_on_top: false,
|
31
|
+
showProgressbar: false,
|
32
|
+
placement: {
|
33
|
+
from: "top",
|
34
|
+
align: "right"
|
35
|
+
},
|
36
|
+
offset: 20,
|
37
|
+
spacing: 10,
|
38
|
+
z_index: 1031,
|
39
|
+
delay: 5000,
|
40
|
+
timer: 1000,
|
41
|
+
url_target: '_blank',
|
42
|
+
mouse_over: null,
|
43
|
+
animate: {
|
44
|
+
enter: 'animated fadeInDown',
|
45
|
+
exit: 'animated fadeOutUp'
|
46
|
+
},
|
47
|
+
onShow: null,
|
48
|
+
onShown: null,
|
49
|
+
onClose: null,
|
50
|
+
onClosed: null,
|
51
|
+
onClick: null,
|
52
|
+
icon_type: 'class',
|
53
|
+
template: '<div data-notify="container" class="col-xs-11 col-sm-4 alert alert-{0}" role="alert"><button type="button" aria-hidden="true" class="close" data-notify="dismiss">×</button><span data-notify="icon"></span> <span data-notify="title">{1}</span> <span data-notify="message">{2}</span><div class="progress" data-notify="progressbar"><div class="progress-bar progress-bar-{0}" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%;"></div></div><a href="{3}" target="{4}" data-notify="url"></a></div>'
|
54
|
+
};
|
55
|
+
|
56
|
+
String.format = function () {
|
57
|
+
var args = arguments;
|
58
|
+
var str = arguments[0];
|
59
|
+
return str.replace(/(\{\{\d\}\}|\{\d\})/g, function (str) {
|
60
|
+
if (str.substring(0, 2) === "{{") return str;
|
61
|
+
var num = parseInt(str.match(/\d/)[0]);
|
62
|
+
return args[num + 1];
|
63
|
+
});
|
64
|
+
};
|
65
|
+
|
66
|
+
function isDuplicateNotification(notification) {
|
67
|
+
var isDupe = false;
|
68
|
+
|
69
|
+
$('[data-notify="container"]').each(function (i, el) {
|
70
|
+
var $el = $(el);
|
71
|
+
var title = $el.find('[data-notify="title"]').html().trim();
|
72
|
+
var message = $el.find('[data-notify="message"]').html().trim();
|
73
|
+
|
74
|
+
// The input string might be different than the actual parsed HTML string!
|
75
|
+
// (<br> vs <br /> for example)
|
76
|
+
// So we have to force-parse this as HTML here!
|
77
|
+
var isSameTitle = title === $("<div>" + notification.settings.content.title + "</div>").html().trim();
|
78
|
+
var isSameMsg = message === $("<div>" + notification.settings.content.message + "</div>").html().trim();
|
79
|
+
var isSameType = $el.hasClass('alert-' + notification.settings.type);
|
80
|
+
|
81
|
+
if (isSameTitle && isSameMsg && isSameType) {
|
82
|
+
//we found the dupe. Set the var and stop checking.
|
83
|
+
isDupe = true;
|
84
|
+
}
|
85
|
+
return !isDupe;
|
86
|
+
});
|
87
|
+
|
88
|
+
return isDupe;
|
89
|
+
}
|
90
|
+
|
91
|
+
function Notify(element, content, options) {
|
92
|
+
// Setup Content of Notify
|
93
|
+
var contentObj = {
|
94
|
+
content: {
|
95
|
+
message: typeof content === 'object' ? content.message : content,
|
96
|
+
title: content.title ? content.title : '',
|
97
|
+
icon: content.icon ? content.icon : '',
|
98
|
+
url: content.url ? content.url : '#',
|
99
|
+
target: content.target ? content.target : '-'
|
100
|
+
}
|
101
|
+
};
|
102
|
+
|
103
|
+
options = $.extend(true, {}, contentObj, options);
|
104
|
+
this.settings = $.extend(true, {}, defaults, options);
|
105
|
+
this._defaults = defaults;
|
106
|
+
if (this.settings.content.target === "-") {
|
107
|
+
this.settings.content.target = this.settings.url_target;
|
108
|
+
}
|
109
|
+
this.animations = {
|
110
|
+
start: 'webkitAnimationStart oanimationstart MSAnimationStart animationstart',
|
111
|
+
end: 'webkitAnimationEnd oanimationend MSAnimationEnd animationend'
|
112
|
+
};
|
113
|
+
|
114
|
+
if (typeof this.settings.offset === 'number') {
|
115
|
+
this.settings.offset = {
|
116
|
+
x: this.settings.offset,
|
117
|
+
y: this.settings.offset
|
118
|
+
};
|
119
|
+
}
|
120
|
+
|
121
|
+
//if duplicate messages are not allowed, then only continue if this new message is not a duplicate of one that it already showing
|
122
|
+
if (this.settings.allow_duplicates || (!this.settings.allow_duplicates && !isDuplicateNotification(this))) {
|
123
|
+
this.init();
|
124
|
+
}
|
125
|
+
}
|
126
|
+
|
127
|
+
$.extend(Notify.prototype, {
|
128
|
+
init: function () {
|
129
|
+
var self = this;
|
130
|
+
|
131
|
+
this.buildNotify();
|
132
|
+
if (this.settings.content.icon) {
|
133
|
+
this.setIcon();
|
134
|
+
}
|
135
|
+
if (this.settings.content.url != "#") {
|
136
|
+
this.styleURL();
|
137
|
+
}
|
138
|
+
this.styleDismiss();
|
139
|
+
this.placement();
|
140
|
+
this.bind();
|
141
|
+
|
142
|
+
this.notify = {
|
143
|
+
$ele: this.$ele,
|
144
|
+
update: function (command, update) {
|
145
|
+
var commands = {};
|
146
|
+
if (typeof command === "string") {
|
147
|
+
commands[command] = update;
|
148
|
+
} else {
|
149
|
+
commands = command;
|
150
|
+
}
|
151
|
+
for (var cmd in commands) {
|
152
|
+
switch (cmd) {
|
153
|
+
case "type":
|
154
|
+
this.$ele.removeClass('alert-' + self.settings.type);
|
155
|
+
this.$ele.find('[data-notify="progressbar"] > .progress-bar').removeClass('progress-bar-' + self.settings.type);
|
156
|
+
self.settings.type = commands[cmd];
|
157
|
+
this.$ele.addClass('alert-' + commands[cmd]).find('[data-notify="progressbar"] > .progress-bar').addClass('progress-bar-' + commands[cmd]);
|
158
|
+
break;
|
159
|
+
case "icon":
|
160
|
+
var $icon = this.$ele.find('[data-notify="icon"]');
|
161
|
+
if (self.settings.icon_type.toLowerCase() === 'class') {
|
162
|
+
$icon.removeClass(self.settings.content.icon).addClass(commands[cmd]);
|
163
|
+
} else {
|
164
|
+
if (!$icon.is('img')) {
|
165
|
+
$icon.find('img');
|
166
|
+
}
|
167
|
+
$icon.attr('src', commands[cmd]);
|
168
|
+
}
|
169
|
+
self.settings.content.icon = commands[command];
|
170
|
+
break;
|
171
|
+
case "progress":
|
172
|
+
var newDelay = self.settings.delay - (self.settings.delay * (commands[cmd] / 100));
|
173
|
+
this.$ele.data('notify-delay', newDelay);
|
174
|
+
this.$ele.find('[data-notify="progressbar"] > div').attr('aria-valuenow', commands[cmd]).css('width', commands[cmd] + '%');
|
175
|
+
break;
|
176
|
+
case "url":
|
177
|
+
this.$ele.find('[data-notify="url"]').attr('href', commands[cmd]);
|
178
|
+
break;
|
179
|
+
case "target":
|
180
|
+
this.$ele.find('[data-notify="url"]').attr('target', commands[cmd]);
|
181
|
+
break;
|
182
|
+
default:
|
183
|
+
this.$ele.find('[data-notify="' + cmd + '"]').html(commands[cmd]);
|
184
|
+
}
|
185
|
+
}
|
186
|
+
var posX = this.$ele.outerHeight() + parseInt(self.settings.spacing) + parseInt(self.settings.offset.y);
|
187
|
+
self.reposition(posX);
|
188
|
+
},
|
189
|
+
close: function () {
|
190
|
+
self.close();
|
191
|
+
}
|
192
|
+
};
|
193
|
+
|
194
|
+
},
|
195
|
+
buildNotify: function () {
|
196
|
+
var content = this.settings.content;
|
197
|
+
this.$ele = $(String.format(this.settings.template, this.settings.type, content.title, content.message, content.url, content.target));
|
198
|
+
this.$ele.attr('data-notify-position', this.settings.placement.from + '-' + this.settings.placement.align);
|
199
|
+
if (!this.settings.allow_dismiss) {
|
200
|
+
this.$ele.find('[data-notify="dismiss"]').css('display', 'none');
|
201
|
+
}
|
202
|
+
if ((this.settings.delay <= 0 && !this.settings.showProgressbar) || !this.settings.showProgressbar) {
|
203
|
+
this.$ele.find('[data-notify="progressbar"]').remove();
|
204
|
+
}
|
205
|
+
},
|
206
|
+
setIcon: function () {
|
207
|
+
if (this.settings.icon_type.toLowerCase() === 'class') {
|
208
|
+
this.$ele.find('[data-notify="icon"]').addClass(this.settings.content.icon);
|
209
|
+
} else {
|
210
|
+
if (this.$ele.find('[data-notify="icon"]').is('img')) {
|
211
|
+
this.$ele.find('[data-notify="icon"]').attr('src', this.settings.content.icon);
|
212
|
+
} else {
|
213
|
+
this.$ele.find('[data-notify="icon"]').append('<img src="' + this.settings.content.icon + '" alt="Notify Icon" />');
|
214
|
+
}
|
215
|
+
}
|
216
|
+
},
|
217
|
+
styleDismiss: function () {
|
218
|
+
this.$ele.find('[data-notify="dismiss"]').css({
|
219
|
+
position: 'absolute',
|
220
|
+
right: '10px',
|
221
|
+
top: '5px',
|
222
|
+
zIndex: this.settings.z_index + 2
|
223
|
+
});
|
224
|
+
},
|
225
|
+
styleURL: function () {
|
226
|
+
this.$ele.find('[data-notify="url"]').css({
|
227
|
+
backgroundImage: 'url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)',
|
228
|
+
height: '100%',
|
229
|
+
left: 0,
|
230
|
+
position: 'absolute',
|
231
|
+
top: 0,
|
232
|
+
width: '100%',
|
233
|
+
zIndex: this.settings.z_index + 1
|
234
|
+
});
|
235
|
+
},
|
236
|
+
placement: function () {
|
237
|
+
var self = this,
|
238
|
+
offsetAmt = this.settings.offset.y,
|
239
|
+
css = {
|
240
|
+
display: 'inline-block',
|
241
|
+
margin: '0px auto',
|
242
|
+
position: this.settings.position ? this.settings.position : (this.settings.element === 'body' ? 'fixed' : 'absolute'),
|
243
|
+
transition: 'all .5s ease-in-out',
|
244
|
+
zIndex: this.settings.z_index
|
245
|
+
},
|
246
|
+
hasAnimation = false,
|
247
|
+
settings = this.settings;
|
248
|
+
|
249
|
+
$('[data-notify-position="' + this.settings.placement.from + '-' + this.settings.placement.align + '"]:not([data-closing="true"])').each(function () {
|
250
|
+
offsetAmt = Math.max(offsetAmt, parseInt($(this).css(settings.placement.from)) + parseInt($(this).outerHeight()) + parseInt(settings.spacing));
|
251
|
+
});
|
252
|
+
if (this.settings.newest_on_top === true) {
|
253
|
+
offsetAmt = this.settings.offset.y;
|
254
|
+
}
|
255
|
+
css[this.settings.placement.from] = offsetAmt + 'px';
|
256
|
+
|
257
|
+
switch (this.settings.placement.align) {
|
258
|
+
case "left":
|
259
|
+
case "right":
|
260
|
+
css[this.settings.placement.align] = this.settings.offset.x + 'px';
|
261
|
+
break;
|
262
|
+
case "center":
|
263
|
+
css.left = 0;
|
264
|
+
css.right = 0;
|
265
|
+
break;
|
266
|
+
}
|
267
|
+
this.$ele.css(css).addClass(this.settings.animate.enter);
|
268
|
+
$.each(Array('webkit-', 'moz-', 'o-', 'ms-', ''), function (index, prefix) {
|
269
|
+
self.$ele[0].style[prefix + 'AnimationIterationCount'] = 1;
|
270
|
+
});
|
271
|
+
|
272
|
+
$(this.settings.element).append(this.$ele);
|
273
|
+
|
274
|
+
if (this.settings.newest_on_top === true) {
|
275
|
+
offsetAmt = (parseInt(offsetAmt) + parseInt(this.settings.spacing)) + this.$ele.outerHeight();
|
276
|
+
this.reposition(offsetAmt);
|
277
|
+
}
|
278
|
+
|
279
|
+
if ($.isFunction(self.settings.onShow)) {
|
280
|
+
self.settings.onShow.call(this.$ele);
|
281
|
+
}
|
282
|
+
|
283
|
+
this.$ele.one(this.animations.start, function () {
|
284
|
+
hasAnimation = true;
|
285
|
+
}).one(this.animations.end, function () {
|
286
|
+
self.$ele.removeClass(self.settings.animate.enter);
|
287
|
+
if ($.isFunction(self.settings.onShown)) {
|
288
|
+
self.settings.onShown.call(this);
|
289
|
+
}
|
290
|
+
});
|
291
|
+
|
292
|
+
setTimeout(function () {
|
293
|
+
if (!hasAnimation) {
|
294
|
+
if ($.isFunction(self.settings.onShown)) {
|
295
|
+
self.settings.onShown.call(this);
|
296
|
+
}
|
297
|
+
}
|
298
|
+
}, 600);
|
299
|
+
},
|
300
|
+
bind: function () {
|
301
|
+
var self = this;
|
302
|
+
|
303
|
+
this.$ele.find('[data-notify="dismiss"]').on('click', function () {
|
304
|
+
self.close();
|
305
|
+
});
|
306
|
+
|
307
|
+
if ($.isFunction(self.settings.onClick)) {
|
308
|
+
this.$ele.on('click', function (event) {
|
309
|
+
if (event.target != self.$ele.find('[data-notify="dismiss"]')[0]) {
|
310
|
+
self.settings.onClick.call(this, event);
|
311
|
+
}
|
312
|
+
});
|
313
|
+
}
|
314
|
+
|
315
|
+
this.$ele.mouseover(function () {
|
316
|
+
$(this).data('data-hover', "true");
|
317
|
+
}).mouseout(function () {
|
318
|
+
$(this).data('data-hover', "false");
|
319
|
+
});
|
320
|
+
this.$ele.data('data-hover', "false");
|
321
|
+
|
322
|
+
if (this.settings.delay > 0) {
|
323
|
+
self.$ele.data('notify-delay', self.settings.delay);
|
324
|
+
var timer = setInterval(function () {
|
325
|
+
var delay = parseInt(self.$ele.data('notify-delay')) - self.settings.timer;
|
326
|
+
if ((self.$ele.data('data-hover') === 'false' && self.settings.mouse_over === "pause") || self.settings.mouse_over != "pause") {
|
327
|
+
var percent = ((self.settings.delay - delay) / self.settings.delay) * 100;
|
328
|
+
self.$ele.data('notify-delay', delay);
|
329
|
+
self.$ele.find('[data-notify="progressbar"] > div').attr('aria-valuenow', percent).css('width', percent + '%');
|
330
|
+
}
|
331
|
+
if (delay <= -(self.settings.timer)) {
|
332
|
+
clearInterval(timer);
|
333
|
+
self.close();
|
334
|
+
}
|
335
|
+
}, self.settings.timer);
|
336
|
+
}
|
337
|
+
},
|
338
|
+
close: function () {
|
339
|
+
var self = this,
|
340
|
+
posX = parseInt(this.$ele.css(this.settings.placement.from)),
|
341
|
+
hasAnimation = false;
|
342
|
+
|
343
|
+
this.$ele.attr('data-closing', 'true').addClass(this.settings.animate.exit);
|
344
|
+
self.reposition(posX);
|
345
|
+
|
346
|
+
if ($.isFunction(self.settings.onClose)) {
|
347
|
+
self.settings.onClose.call(this.$ele);
|
348
|
+
}
|
349
|
+
|
350
|
+
this.$ele.one(this.animations.start, function () {
|
351
|
+
hasAnimation = true;
|
352
|
+
}).one(this.animations.end, function () {
|
353
|
+
$(this).remove();
|
354
|
+
if ($.isFunction(self.settings.onClosed)) {
|
355
|
+
self.settings.onClosed.call(this);
|
356
|
+
}
|
357
|
+
});
|
358
|
+
|
359
|
+
setTimeout(function () {
|
360
|
+
if (!hasAnimation) {
|
361
|
+
self.$ele.remove();
|
362
|
+
if (self.settings.onClosed) {
|
363
|
+
self.settings.onClosed(self.$ele);
|
364
|
+
}
|
365
|
+
}
|
366
|
+
}, 600);
|
367
|
+
},
|
368
|
+
reposition: function (posX) {
|
369
|
+
var self = this,
|
370
|
+
notifies = '[data-notify-position="' + this.settings.placement.from + '-' + this.settings.placement.align + '"]:not([data-closing="true"])',
|
371
|
+
$elements = this.$ele.nextAll(notifies);
|
372
|
+
if (this.settings.newest_on_top === true) {
|
373
|
+
$elements = this.$ele.prevAll(notifies);
|
374
|
+
}
|
375
|
+
$elements.each(function () {
|
376
|
+
$(this).css(self.settings.placement.from, posX);
|
377
|
+
posX = (parseInt(posX) + parseInt(self.settings.spacing)) + $(this).outerHeight();
|
378
|
+
});
|
379
|
+
}
|
380
|
+
});
|
381
|
+
|
382
|
+
$.notify = function (content, options) {
|
383
|
+
var plugin = new Notify(this, content, options);
|
384
|
+
return plugin.notify;
|
385
|
+
};
|
386
|
+
$.notifyDefaults = function (options) {
|
387
|
+
defaults = $.extend(true, {}, defaults, options);
|
388
|
+
return defaults;
|
389
|
+
};
|
390
|
+
|
391
|
+
$.notifyClose = function (selector) {
|
392
|
+
|
393
|
+
if (typeof selector === "undefined" || selector === "all") {
|
394
|
+
$('[data-notify]').find('[data-notify="dismiss"]').trigger('click');
|
395
|
+
}else if(selector === 'success' || selector === 'info' || selector === 'warning' || selector === 'danger'){
|
396
|
+
$('.alert-' + selector + '[data-notify]').find('[data-notify="dismiss"]').trigger('click');
|
397
|
+
} else if(selector){
|
398
|
+
$(selector + '[data-notify]').find('[data-notify="dismiss"]').trigger('click');
|
399
|
+
}
|
400
|
+
else {
|
401
|
+
$('[data-notify-position="' + selector + '"]').find('[data-notify="dismiss"]').trigger('click');
|
402
|
+
}
|
403
|
+
};
|
404
|
+
|
405
|
+
$.notifyCloseExcept = function (selector) {
|
406
|
+
|
407
|
+
if(selector === 'success' || selector === 'info' || selector === 'warning' || selector === 'danger'){
|
408
|
+
$('[data-notify]').not('.alert-' + selector).find('[data-notify="dismiss"]').trigger('click');
|
409
|
+
} else{
|
410
|
+
$('[data-notify]').not(selector).find('[data-notify="dismiss"]').trigger('click');
|
411
|
+
}
|
412
|
+
};
|
413
|
+
|
414
|
+
|
415
|
+
}));
|
416
|
+
|
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bootstrap_notify_gem
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jesse Krasnostein
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-05-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.14'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.14'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: " gem boostrap_notify is a wrapper for mouse0270's bootstrap-notify js
|
42
|
+
package."
|
43
|
+
email:
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- CODE_OF_CONDUCT.md
|
50
|
+
- Gemfile
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- bin/console
|
55
|
+
- bin/setup
|
56
|
+
- bootstrap_notify_gem.gemspec
|
57
|
+
- lib/bootstrap_notify_gem.rb
|
58
|
+
- lib/bootstrap_notify_gem/version.rb
|
59
|
+
- vendor/assets/javascripts/bootstrap_notify.js
|
60
|
+
homepage: https://github.com/jkras/bootstrap_notify
|
61
|
+
licenses:
|
62
|
+
- MIT
|
63
|
+
metadata: {}
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
requirements: []
|
79
|
+
rubyforge_project:
|
80
|
+
rubygems_version: 2.6.11
|
81
|
+
signing_key:
|
82
|
+
specification_version: 4
|
83
|
+
summary: A gem wrapper for Bootstrap Notify https://github.com/mouse0270/bootstrap-notify.
|
84
|
+
test_files: []
|