kenny_dialoggins 1.0.5 → 1.0.6
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.
- data/.specification +3 -8
- data/README.rdoc +1 -0
- data/VERSION +1 -1
- data/kenny_dialoggins.gemspec +1 -1
- data/lib/generators/kenny_dialoggins/templates/kenny_dialoggins.js +7 -6
- data/lib/kenny_dialoggins/helpers.rb +10 -4
- data/test/kenny_dialoggins/helpers_test.rb +14 -15
- metadata +9 -4
data/.specification
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kenny_dialoggins
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 31
|
5
4
|
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 1
|
8
7
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
8
|
+
- 5
|
9
|
+
version: 1.0.5
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Coroutine
|
@@ -17,7 +16,7 @@ autorequire:
|
|
17
16
|
bindir: bin
|
18
17
|
cert_chain: []
|
19
18
|
|
20
|
-
date: 2010-
|
19
|
+
date: 2010-11-11 00:00:00 -06:00
|
21
20
|
default_executable:
|
22
21
|
dependencies:
|
23
22
|
- !ruby/object:Gem::Dependency
|
@@ -28,7 +27,6 @@ dependencies:
|
|
28
27
|
requirements:
|
29
28
|
- - ">="
|
30
29
|
- !ruby/object:Gem::Version
|
31
|
-
hash: 11
|
32
30
|
segments:
|
33
31
|
- 2
|
34
32
|
- 3
|
@@ -44,7 +42,6 @@ dependencies:
|
|
44
42
|
requirements:
|
45
43
|
- - ">="
|
46
44
|
- !ruby/object:Gem::Version
|
47
|
-
hash: 11
|
48
45
|
segments:
|
49
46
|
- 2
|
50
47
|
- 3
|
@@ -94,7 +91,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
94
91
|
requirements:
|
95
92
|
- - ">="
|
96
93
|
- !ruby/object:Gem::Version
|
97
|
-
hash: 3
|
98
94
|
segments:
|
99
95
|
- 0
|
100
96
|
version: "0"
|
@@ -103,7 +99,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
99
|
requirements:
|
104
100
|
- - ">="
|
105
101
|
- !ruby/object:Gem::Version
|
106
|
-
hash: 3
|
107
102
|
segments:
|
108
103
|
- 0
|
109
104
|
version: "0"
|
data/README.rdoc
CHANGED
@@ -32,6 +32,7 @@ What's that, you want more details? You got it, buddy.
|
|
32
32
|
<tt>render_dialog</tt> always needs a unique id for its first argument. After that, it will
|
33
33
|
take the same options as <tt>ActionController::Base#render</tt>. It'll also take a few more, namely:
|
34
34
|
|
35
|
+
* <tt>:id</tt> - an element id for the generated dialog. If not provided, the value provided as the first argument to render_dialog will be used.
|
35
36
|
* <tt>:class</tt> - a css class name that will be appended to the outermost div to facilitate multiple styles
|
36
37
|
* <tt>:before_show</tt> - a Javascript function that will be invoked before the dialog is shown
|
37
38
|
* <tt>:after_show</tt> - a Javascript function that will be invoked after the dialog has become visible
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.6
|
data/kenny_dialoggins.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{kenny_dialoggins}
|
8
|
-
s.version = "1.0.
|
8
|
+
s.version = "1.0.6"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Coroutine", "Tim Lowrimore", "John Dugan"]
|
@@ -33,11 +33,12 @@ KennyDialoggins.Dialog = function(content, options) {
|
|
33
33
|
this._hideListener = this._generateHideListener();
|
34
34
|
this._isShowing = false;
|
35
35
|
|
36
|
-
this.
|
37
|
-
this.
|
38
|
-
this.
|
39
|
-
this.
|
40
|
-
this.
|
36
|
+
this._id = options["id"];
|
37
|
+
this._class = options["class"] || "";
|
38
|
+
this._beforeShow = options["beforeShow"] || Prototype.emptyFunction;
|
39
|
+
this._afterShow = options["afterShow"] || Prototype.emptyFunction;
|
40
|
+
this._beforeHide = options["beforeHide"] || Prototype.emptyFunction;
|
41
|
+
this._afterHide = options["afterHide"] || Prototype.emptyFunction;
|
41
42
|
|
42
43
|
this._makeDialog();
|
43
44
|
this.setContent(content);
|
@@ -186,7 +187,7 @@ Object.extend(KennyDialoggins.Dialog.prototype, {
|
|
186
187
|
*/
|
187
188
|
_makeDialog: function() {
|
188
189
|
if (!this._element) {
|
189
|
-
this._element = new Element("DIV");
|
190
|
+
this._element = new Element("DIV", { id: this._id });
|
190
191
|
this._element.addClassName("kenny_dialoggins_dialog");
|
191
192
|
if (this._class) {
|
192
193
|
this._element.addClassName(this._class);
|
@@ -6,6 +6,7 @@ module Coroutine
|
|
6
6
|
# to this method is the dialog's <tt>id</tt>. The id is required and should be unique.
|
7
7
|
# Further options may be provided; those that are specific to the dialog are:
|
8
8
|
#
|
9
|
+
# * <tt>:id</tt> - an element id for the generated dialog. If not provided, the value provided as the first argument to render_dialog will be used.
|
9
10
|
# * <tt>:class</tt> - a css class name that will be appended to the outermost div to facilitate multiple styles
|
10
11
|
# * <tt>:before_show</tt> - a Javascript function that will be invoked before the dialog is shown
|
11
12
|
# * <tt>:after_show</tt> - a Javascript function that will be invoked after the dialog has become visible
|
@@ -22,7 +23,7 @@ module Coroutine
|
|
22
23
|
# #
|
23
24
|
# # <script type="text/javascript">
|
24
25
|
# # //<![CDATA[
|
25
|
-
# # KennyDialoggins.Dialog.instances['foo_dialog'] = new KennyDialoggins.Dialog('Hello, Foo!', {});
|
26
|
+
# # KennyDialoggins.Dialog.instances['foo_dialog'] = new KennyDialoggins.Dialog('Hello, Foo!', {'id':'foo_dialog'});
|
26
27
|
# # //]]>
|
27
28
|
# # </script>
|
28
29
|
# <%= render_dialog :foo_dialog, :partial => "foo" %>
|
@@ -35,7 +36,7 @@ module Coroutine
|
|
35
36
|
# # Generates:
|
36
37
|
# # <script type="text/javascript">
|
37
38
|
# # //<![CDATA[
|
38
|
-
# # KennyDialoggins.Dialog.instances['foo_dialog'] = new KennyDialoggins.Dialog('Hello, Foo!', {beforeShow:function() { alert('bar!') }});
|
39
|
+
# # KennyDialoggins.Dialog.instances['foo_dialog'] = new KennyDialoggins.Dialog('Hello, Foo!', {'id':'foo_dialog', 'beforeShow':function() { alert('bar!') }});
|
39
40
|
# # //]]>
|
40
41
|
# # </script>
|
41
42
|
# <%= render_dialog :foo_dialog, :partial => "foo", :before_show => "function() { alert('bar!') }" %>
|
@@ -46,7 +47,12 @@ module Coroutine
|
|
46
47
|
def render_dialog(id, options = {}, &block)
|
47
48
|
options[:inline] = capture(&block) if block_given?
|
48
49
|
render_options = extract_dialog_render_options(options)
|
49
|
-
javascript_options =
|
50
|
+
javascript_options = extract_dialog_javascript_options(options)
|
51
|
+
|
52
|
+
# In the event an id is not provided in the options, we'll use the
|
53
|
+
# dialog id.
|
54
|
+
javascript_options[:id] ||= id
|
55
|
+
javascript_options = dialog_options_to_js(javascript_options)
|
50
56
|
|
51
57
|
content = escape_javascript(render(render_options))
|
52
58
|
|
@@ -82,7 +88,7 @@ module Coroutine
|
|
82
88
|
# javascript library.
|
83
89
|
#
|
84
90
|
def dialog_javascript_option_keys
|
85
|
-
[:class, :before_show, :after_show, :before_hide, :after_hide]
|
91
|
+
[:class, :id, :before_show, :after_show, :before_hide, :after_hide]
|
86
92
|
end
|
87
93
|
|
88
94
|
|
@@ -46,7 +46,7 @@ class KennyDialogginsHelpersTest < ActionView::TestCase
|
|
46
46
|
text = "Who wants to play volleyball on a court with a four-foot net?"
|
47
47
|
expected = "<script type=\"text/javascript\">\n" \
|
48
48
|
"//<![CDATA[\n" \
|
49
|
-
"KennyDialoggins.Dialog.instances['danger_zone'] = new KennyDialoggins.Dialog('" + text + "', {});\n" \
|
49
|
+
"Event.observe(window, 'load', function() { KennyDialoggins.Dialog.instances['danger_zone'] = new KennyDialoggins.Dialog('" + text + "', {'id':'danger_zone'}) });\n" \
|
50
50
|
"//]]>\n" \
|
51
51
|
"</script>"
|
52
52
|
actual = @view.render_dialog(:danger_zone, :text => text)
|
@@ -54,6 +54,19 @@ class KennyDialogginsHelpersTest < ActionView::TestCase
|
|
54
54
|
assert_equal expected, actual
|
55
55
|
end
|
56
56
|
|
57
|
+
def test_render_dialog_with_id
|
58
|
+
text = "I secretly likes me some Bone Thugs. Woot! --Kenny"
|
59
|
+
id = "bone_thugs_dialog"
|
60
|
+
expected = "<script type=\"text/javascript\">\n" \
|
61
|
+
"//<![CDATA[\n" \
|
62
|
+
"Event.observe(window, 'load', function() { KennyDialoggins.Dialog.instances['thuggin'] = new KennyDialoggins.Dialog('" + text + "', {'id':'" + id + "'}) });\n" \
|
63
|
+
"//]]>\n" \
|
64
|
+
"</script>"
|
65
|
+
|
66
|
+
actual = @view.render_dialog(:thuggin, :text => text, :id => id)
|
67
|
+
|
68
|
+
assert_equal expected, actual
|
69
|
+
end
|
57
70
|
|
58
71
|
# verify show dialog returns proper javascript command.
|
59
72
|
def test_show_dialog
|
@@ -72,18 +85,4 @@ class KennyDialogginsHelpersTest < ActionView::TestCase
|
|
72
85
|
assert_equal expected, actual
|
73
86
|
end
|
74
87
|
|
75
|
-
|
76
|
-
# verify private function converts ruby hash to javascript hash properly.
|
77
|
-
def test_dialog_options_to_js
|
78
|
-
options = {
|
79
|
-
:before_show => "function{ alert('hello, world!'); }",
|
80
|
-
:after_show => "function{ alert('goodbye, world!'); }"
|
81
|
-
}
|
82
|
-
|
83
|
-
expected = "{beforeShow:#{options[:before_show]},afterShow:#{options[:after_show]}}"
|
84
|
-
actual = @view.dialog_options_to_js_proxy(options)
|
85
|
-
|
86
|
-
assert_equal expected, actual
|
87
|
-
end
|
88
|
-
|
89
88
|
end
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kenny_dialoggins
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 27
|
5
|
+
prerelease:
|
5
6
|
segments:
|
6
7
|
- 1
|
7
8
|
- 0
|
8
|
-
-
|
9
|
-
version: 1.0.
|
9
|
+
- 6
|
10
|
+
version: 1.0.6
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Coroutine
|
@@ -27,6 +28,7 @@ dependencies:
|
|
27
28
|
requirements:
|
28
29
|
- - ">="
|
29
30
|
- !ruby/object:Gem::Version
|
31
|
+
hash: 11
|
30
32
|
segments:
|
31
33
|
- 2
|
32
34
|
- 3
|
@@ -42,6 +44,7 @@ dependencies:
|
|
42
44
|
requirements:
|
43
45
|
- - ">="
|
44
46
|
- !ruby/object:Gem::Version
|
47
|
+
hash: 11
|
45
48
|
segments:
|
46
49
|
- 2
|
47
50
|
- 3
|
@@ -91,6 +94,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
91
94
|
requirements:
|
92
95
|
- - ">="
|
93
96
|
- !ruby/object:Gem::Version
|
97
|
+
hash: 3
|
94
98
|
segments:
|
95
99
|
- 0
|
96
100
|
version: "0"
|
@@ -99,13 +103,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
99
103
|
requirements:
|
100
104
|
- - ">="
|
101
105
|
- !ruby/object:Gem::Version
|
106
|
+
hash: 3
|
102
107
|
segments:
|
103
108
|
- 0
|
104
109
|
version: "0"
|
105
110
|
requirements: []
|
106
111
|
|
107
112
|
rubyforge_project:
|
108
|
-
rubygems_version: 1.
|
113
|
+
rubygems_version: 1.4.2
|
109
114
|
signing_key:
|
110
115
|
specification_version: 3
|
111
116
|
summary: Dead simple, beautiful dialogs for Rails.
|