alertifyjs-rails 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
data/README.md
CHANGED
@@ -26,6 +26,11 @@ The alertify files will be added to the asset pipeline and available for you to
|
|
26
26
|
//= require alertify
|
27
27
|
```
|
28
28
|
|
29
|
+
Optional js(coffe script) replace browser confirm dialog
|
30
|
+
```javascript
|
31
|
+
//= require alertify/alertify/confirm-modal
|
32
|
+
```
|
33
|
+
|
29
34
|
In order to get the CSS, add the following line to `app/assets/stylesheets/application.css.scss`
|
30
35
|
|
31
36
|
```css
|
@@ -1,23 +1,28 @@
|
|
1
|
-
module AlertifyjsHelper
|
2
|
-
ALERT_TYPES = [:error, :info, :success, :warning] unless const_defined?(:ALERT_TYPES)
|
3
|
-
|
1
|
+
module AlertifyjsHelper
|
4
2
|
def alertify_flash
|
3
|
+
valid_alertify = ["error", "message", "success", "warning"]
|
5
4
|
jsReturn = javascript_tag()
|
5
|
+
js_alertify = ""
|
6
|
+
queue = 0
|
6
7
|
flash.each do |type, message|
|
7
|
-
# Skip empty messages, e.g. for devise messages set to nothing in a locale file.
|
8
8
|
next if message.blank?
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
9
|
+
type = type.to_s
|
10
|
+
case type
|
11
|
+
when "alert"
|
12
|
+
type = "error"
|
13
|
+
when "notice"
|
14
|
+
type = "success"
|
15
|
+
when "info"
|
16
|
+
type = "message"
|
17
|
+
end
|
18
|
+
next unless valid_alertify.include?(type)
|
15
19
|
Array(message).each do |msg|
|
16
|
-
js_alertify << "alertify.#{type}('#{j(msg)}')
|
20
|
+
js_alertify << "setTimeout(function(){alertify.#{type}('#{j(msg)}');}, #{queue});"
|
17
21
|
end
|
18
|
-
|
19
|
-
end
|
22
|
+
queue += 100
|
23
|
+
end
|
20
24
|
flash.clear
|
25
|
+
jsReturn = javascript_tag(js_alertify)
|
21
26
|
jsReturn.html_safe()
|
22
27
|
end
|
23
|
-
end
|
28
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
$.rails.allowAction = (link) ->
|
2
|
+
return true unless link.attr('data-confirm')
|
3
|
+
$.rails.showConfirmDialog(link) # look bellow for implementations
|
4
|
+
false # always stops the action since code runs asynchronously
|
5
|
+
|
6
|
+
$.rails.confirmed = (link) ->
|
7
|
+
link.removeAttr('data-confirm')
|
8
|
+
if link.data('method')=='delete'
|
9
|
+
link.trigger('click.rails')
|
10
|
+
else
|
11
|
+
if link.get(0).click
|
12
|
+
link.get(0).click()
|
13
|
+
|
14
|
+
$.rails.showConfirmDialog = (link) ->
|
15
|
+
message = link.data 'confirm'
|
16
|
+
#grab the dialog instance and set multiple settings at once.
|
17
|
+
alertify.dialog("confirm").setting(
|
18
|
+
theme:
|
19
|
+
ok: "btn btn-primary"
|
20
|
+
cancel: "btn btn-danger"
|
21
|
+
title: 'Your confirmation is needed'
|
22
|
+
transition:'pulse'
|
23
|
+
labels:
|
24
|
+
ok: "Confirm!"
|
25
|
+
cancel: "Cancel"
|
26
|
+
message: message
|
27
|
+
onok: ->
|
28
|
+
$.rails.confirmed link
|
29
|
+
#alertify.success "Nice!"
|
30
|
+
oncancel: ->
|
31
|
+
#alertify.error "Action Canceled!"
|
32
|
+
defaultFocus: 'cancel'
|
33
|
+
).show().autoCancel(5)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alertifyjs-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-09-
|
12
|
+
date: 2014-09-24 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Use Alertify.js (alertifyjs.com) with Rails 3 and 4
|
15
15
|
email:
|
@@ -30,6 +30,7 @@ files:
|
|
30
30
|
- lib/alertifyjs/rails/railtie.rb
|
31
31
|
- lib/alertifyjs/rails/version.rb
|
32
32
|
- vendor/assets/javascripts/alertify.js
|
33
|
+
- vendor/assets/javascripts/alertify/confirm-modal.js.coffee
|
33
34
|
- vendor/assets/stylesheets/alertify.css
|
34
35
|
- vendor/assets/stylesheets/alertify.rtl.css
|
35
36
|
- vendor/assets/stylesheets/alertify/bootstrap.css
|