easy_modal_window 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -4
- data/app/views/easy_modal_window/base_dialog.js.erb +6 -2
- data/lib/easy_modal_window.rb +12 -8
- data/lib/easy_modal_window/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 349676271caa27036813e23be466cddfd58a7bb5
|
4
|
+
data.tar.gz: 6e585413cbaf808d83859b03dc993cb45afa5a44
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e6f96a38b9f8f87db298dccf583103f1c521cc671dedbcd4911b7b12280298263a15e0f4bd3ee58df07a8ec24905e86077c56f3cc8108fa69f2e3f1fbda86e4
|
7
|
+
data.tar.gz: 13d7e37e2f48d67f21bd78cfa862d51e842130428785250ac38643043ee2ef006f59dbe57ae3163120dc10e3f83bf8785e86d7687dbae78cad1a14b133fd5256
|
data/README.md
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
# EasyModalWindow
|
2
2
|
|
3
|
-
This is wrapper for jQuery-UI Dialog.
|
3
|
+
This is wrapper for jQuery-UI Dialog. Additionally it contain several templates for render errors from ActiveRecord and
|
4
|
+
[ErrorMessagesContainer](https://github.com/Loriowar/error_messages_container).
|
5
|
+
|
6
|
+
## Dependency
|
7
|
+
|
8
|
+
Gem require [jQuery-UI](https://jqueryui.com/) version 1.8 or greater.
|
4
9
|
|
5
10
|
## Installation
|
6
11
|
|
@@ -26,6 +31,7 @@ Helper `render_base_dialog`. It take parameters like a `dialog`, but in more eas
|
|
26
31
|
|
27
32
|
render_base_dialog(
|
28
33
|
render_template: 'example_template',
|
34
|
+
locals: {id: 42},
|
29
35
|
resizable: false,
|
30
36
|
height: 'auto',
|
31
37
|
width: 'auto',
|
@@ -36,15 +42,17 @@ Helper `render_base_dialog`. It take parameters like a `dialog`, but in more eas
|
|
36
42
|
buttons: {
|
37
43
|
load_button: {
|
38
44
|
name: l(:load_button),
|
39
|
-
action: "$('#modal-window-ajax-form').submit();"
|
45
|
+
action: "$('#modal-window-ajax-form').submit();",
|
46
|
+
class: 'my-first-css-class'
|
40
47
|
},
|
41
48
|
close_button: {
|
42
49
|
name: l(:close_button),
|
43
|
-
action: "$(this).dialog('close');"
|
50
|
+
action: "$(this).dialog('close');",
|
51
|
+
class: 'my-second-css-class'
|
44
52
|
}
|
45
53
|
}
|
46
54
|
|
47
|
-
Here we can skip any parameters except `render_template`.
|
55
|
+
Here we can skip any parameters except `render_template` or `render_partial`.
|
48
56
|
|
49
57
|
**NOTE:** by default modal window puts in `#ajax-modal` element; you can specify other selector in `window_selector` option.
|
50
58
|
|
@@ -26,8 +26,12 @@ $modalWindow.dialog({
|
|
26
26
|
buttons: {
|
27
27
|
<% modal_options.buttons.each do |button_options| %>
|
28
28
|
<% if button_options[:condition] %>
|
29
|
-
"<%= button_options[:
|
30
|
-
|
29
|
+
"<%= button_options[:internal_name] %>": {
|
30
|
+
text: "<%= button_options[:name] %>",
|
31
|
+
class: "<%= button_options[:class] %>",
|
32
|
+
click: function() {
|
33
|
+
<%= button_options[:action].html_safe %>
|
34
|
+
}
|
31
35
|
},
|
32
36
|
<% end %>
|
33
37
|
<% end %>
|
data/lib/easy_modal_window.rb
CHANGED
@@ -23,7 +23,8 @@ module EasyModalWindow
|
|
23
23
|
@modal_options[:width] = 'auto'
|
24
24
|
# hash with button descriptions: {first_button: {name: 'Name',
|
25
25
|
# condition: -> {...},
|
26
|
-
# action: 'location.reload();'
|
26
|
+
# action: 'location.reload();',
|
27
|
+
# class: 'my-css-class'},
|
27
28
|
# second_button: ...}
|
28
29
|
@modal_options[:buttons] = {}
|
29
30
|
# dialog callbacks
|
@@ -65,13 +66,16 @@ module EasyModalWindow
|
|
65
66
|
end
|
66
67
|
|
67
68
|
def buttons
|
68
|
-
@modal_options[:buttons].inject([]) do |h, v|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
69
|
+
@modal_options[:buttons].inject([]) do |h, (k, v)|
|
70
|
+
h.push(
|
71
|
+
{
|
72
|
+
internal_name: k,
|
73
|
+
name: v[:name] || 'unknown',
|
74
|
+
condition: value_of(v[:condition]).nil? || value_of(v[:condition]),
|
75
|
+
action: v[:action] || '',
|
76
|
+
class: v[:class] || ''
|
77
|
+
}
|
78
|
+
)
|
75
79
|
end
|
76
80
|
end
|
77
81
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easy_modal_window
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Zabrovskiy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|