flash_notifier 1.0.2 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: c9dac58ebe2fc82a573cd36d6fa27a80a3f6ea11
4
- data.tar.gz: 4c3b4dd1ec0dcd7317f126743d174b95c9d88ae9
2
+ SHA256:
3
+ metadata.gz: 396ef0affcaddb843573904223bc64c6f2ad16848524d7bddf402d2faa25359e
4
+ data.tar.gz: 66382515b6f271bb0d64f5c3dff8534e0fd48c628b9b04e58a3b87f315e22eb7
5
5
  SHA512:
6
- metadata.gz: ae377a6ac2cb3d3d7e89744efaba0f77f4e202af281ba4978407b5247995f019dac59936b5dc069f4873422a9566d0f4bbe3b2e52f5c6e691338f6eaaa86a9ee
7
- data.tar.gz: 807afd3e23e1229eb73a6939461f14c485a5fc31a0ea0b360b5ccfcb34d9ce75588633c993f2d50e51a7e0ef5861f4e3cbf8a4fec1e26505e67773d3215d4dd3
6
+ metadata.gz: 16f66f9eb7b9b71ebd4ddce16f2af183e15a72b3f41af20f22f5faaa7158ba01fded2cfed7e3ff348243a517cb9b640f4a3303d80cad89950a4526e52a11158d
7
+ data.tar.gz: 8984a1f1e63e51a6ad02c6ab42e8d902d032407109e9dec99c71630f8e9e9c9dd0320fca8d8ea7d27d7716c451603dbf36f4aea934af4e0b399fb289bdc93dd2
data/README.md CHANGED
@@ -26,6 +26,12 @@ Add this helper method in your layout and make sure you have bootstrap installed
26
26
 
27
27
  <%= build_bootstrap_flash %>
28
28
 
29
+ You can make the flash dismissible by passing following optional options to the above helper method
30
+
31
+ <%= build_bootstrap_flash dismiss: true, timeout: 5000 %>
32
+
33
+ ##### default timeout duration is 5000, ignore this option if you want to use default timeout duration
34
+
29
35
  ### For other two libraries follow following steps
30
36
 
31
37
  #### Step 1: Choose a Library Noty JS or Toastr JS
@@ -86,4 +92,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
86
92
 
87
93
  ## Code of Conduct
88
94
 
89
- Everyone interacting in the FlashNotifier project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/flash_notifier/blob/master/CODE_OF_CONDUCT.md).
95
+ Everyone interacting in the FlashNotifier project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/fakhir-shad/flash_notifier/blob/master/CODE_OF_CONDUCT.md).
@@ -1,7 +1,7 @@
1
1
  module FlashHelper
2
2
  def build_flash *args
3
- options = args.last.is_a?(::Hash) ? args.pop.with_indifferent_access : {}
4
- html = content_tag(:div, '', data: { flash_notifier_options: options })
3
+ options = extract_args args
4
+ html = append_options_to_dom options
5
5
  flash.each do |type, message|
6
6
  flash_type = (%w(notice success).include?(type)) ? 'success' : (( %w(alert error).include?(type)) ? 'error' : (%w(warning info).include?(type) ? type : 'info' ))
7
7
  html += content_tag(:div, '' , data: { flash_notifier: 'inside gem', flash_type: flash_type, flash_msg: message })
@@ -9,7 +9,11 @@ module FlashHelper
9
9
  html.html_safe
10
10
  end
11
11
 
12
- def build_bootstrap_flash
12
+ def build_bootstrap_flash *args
13
+ options = extract_args args
14
+ append_options_to_dom options
15
+ dismissible = options.has_key?(:dismiss) && options[:dismiss]
16
+ timeout = options.has_key?(:timeout) ? options[:timeout] : 5000
13
17
  alert_klasses = {
14
18
  success: 'alert-success',
15
19
  error: 'alert-danger',
@@ -18,12 +22,28 @@ module FlashHelper
18
22
  }
19
23
  html = ''
20
24
  flash.each do |type, message|
21
- html += content_tag :div, class: "alert #{alert_klasses[type.to_sym] || type.to_s} alert-dismissible fade show", role: 'alert' do
25
+ html += content_tag :div, class: "alert #{alert_klasses[type.to_sym] || type.to_s} alert-dismissible fade in show #{options[:wrapper_class]}", role: 'alert', data: {flash_notifier: 'bootstrap'} do
22
26
  inner_html = link_to 'x', '#', class: 'close', data: {dismiss: 'alert'}, aria_label: 'close', title: 'close'
23
27
  inner_html += content_tag :div, message, class: 'text'
24
28
  inner_html.html_safe
25
29
  end
26
30
  end
31
+ dismiss_alert_script = javascript_tag <<-JS
32
+ setTimeout(function(){
33
+ $.each($("[data-flash-notifier='bootstrap']"), function(index, alert){
34
+ $(alert).alert('close');
35
+ })
36
+ }, #{timeout});
37
+ JS
38
+ html += dismiss_alert_script if dismissible
27
39
  html.html_safe
28
40
  end
41
+
42
+ private
43
+ def extract_args args
44
+ args.last.is_a?(::Hash) ? args.pop.with_indifferent_access : {}
45
+ end
46
+ def append_options_to_dom options
47
+ content_tag(:div, '', data: { flash_notifier_options: options })
48
+ end
29
49
  end
@@ -1,3 +1,3 @@
1
1
  module FlashNotifier
2
- VERSION = "1.0.2"
2
+ VERSION = "1.1.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flash_notifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fakhir Shad
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2018-08-06 00:00:00.000000000 Z
12
+ date: 2018-08-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -88,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
88
  version: '0'
89
89
  requirements: []
90
90
  rubyforge_project:
91
- rubygems_version: 2.6.13
91
+ rubygems_version: 2.7.3
92
92
  signing_key:
93
93
  specification_version: 4
94
94
  summary: Integrate Flash Messages with ease using Noty JS, Toastr JS or Bootstrap