kenny_dialoggins 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/.specification +45 -9
- data/README.rdoc +1 -1
- data/VERSION +1 -1
- data/kenny_dialoggins.gemspec +6 -2
- data/lib/generators/kenny_dialoggins/kenny_dialoggins_generator.rb +18 -0
- data/lib/generators/kenny_dialoggins/templates/kenny_dialoggins.css +20 -0
- data/lib/generators/kenny_dialoggins/templates/kenny_dialoggins.js +268 -0
- metadata +7 -3
data/.gitignore
ADDED
data/.specification
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kenny_dialoggins
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 31
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
9
|
+
- 2
|
10
|
+
version: 0.1.2
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Coroutine
|
@@ -16,10 +17,41 @@ autorequire:
|
|
16
17
|
bindir: bin
|
17
18
|
cert_chain: []
|
18
19
|
|
19
|
-
date: 2010-
|
20
|
+
date: 2010-07-29 00:00:00 -05:00
|
20
21
|
default_executable:
|
21
|
-
dependencies:
|
22
|
-
|
22
|
+
dependencies:
|
23
|
+
- !ruby/object:Gem::Dependency
|
24
|
+
name: actionpack
|
25
|
+
prerelease: false
|
26
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
27
|
+
none: false
|
28
|
+
requirements:
|
29
|
+
- - ">="
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
hash: 11
|
32
|
+
segments:
|
33
|
+
- 2
|
34
|
+
- 3
|
35
|
+
- 4
|
36
|
+
version: 2.3.4
|
37
|
+
type: :runtime
|
38
|
+
version_requirements: *id001
|
39
|
+
- !ruby/object:Gem::Dependency
|
40
|
+
name: activesupport
|
41
|
+
prerelease: false
|
42
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
hash: 11
|
48
|
+
segments:
|
49
|
+
- 2
|
50
|
+
- 3
|
51
|
+
- 4
|
52
|
+
version: 2.3.4
|
53
|
+
type: :development
|
54
|
+
version_requirements: *id002
|
23
55
|
description: Kenny Dialoggins allows you to include scriptaculous dialogs in Rails applications using the same syntax employed for rendering partials.
|
24
56
|
email: gems@coroutine.com
|
25
57
|
executables: []
|
@@ -34,9 +66,9 @@ files:
|
|
34
66
|
- README.rdoc
|
35
67
|
- Rakefile
|
36
68
|
- VERSION
|
37
|
-
- generators/
|
38
|
-
- generators/
|
39
|
-
- generators/
|
69
|
+
- generators/kenny_dialoggins/kenny_dialoggins_generator.rb
|
70
|
+
- generators/kenny_dialoggins/templates/kenny_dialoggins.css
|
71
|
+
- generators/kenny_dialoggins/templates/kenny_dialoggins.js
|
40
72
|
- init.rb
|
41
73
|
- kenny_dialoggins.gemspec
|
42
74
|
- lib/kenny_dialoggins.rb
|
@@ -54,23 +86,27 @@ rdoc_options:
|
|
54
86
|
require_paths:
|
55
87
|
- lib
|
56
88
|
required_ruby_version: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
57
90
|
requirements:
|
58
91
|
- - ">="
|
59
92
|
- !ruby/object:Gem::Version
|
93
|
+
hash: 3
|
60
94
|
segments:
|
61
95
|
- 0
|
62
96
|
version: "0"
|
63
97
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
64
99
|
requirements:
|
65
100
|
- - ">="
|
66
101
|
- !ruby/object:Gem::Version
|
102
|
+
hash: 3
|
67
103
|
segments:
|
68
104
|
- 0
|
69
105
|
version: "0"
|
70
106
|
requirements: []
|
71
107
|
|
72
108
|
rubyforge_project:
|
73
|
-
rubygems_version: 1.3.
|
109
|
+
rubygems_version: 1.3.7
|
74
110
|
signing_key:
|
75
111
|
specification_version: 3
|
76
112
|
summary: Dead simple, beautiful dialogs for Rails.
|
data/README.rdoc
CHANGED
@@ -94,7 +94,7 @@ Either way, then generate the stylesheet and javascript files I need.
|
|
94
94
|
|
95
95
|
== IE6 Support
|
96
96
|
|
97
|
-
I'm not what you'd call a huge fan
|
97
|
+
I'm not what you'd call a huge fan of IE6, so I don't provide a blocking
|
98
98
|
iframe for my dialogs by default. But I can. You just need to ask nicely.
|
99
99
|
|
100
100
|
At the top of the generated javascript file, just change the obviously-named property
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
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 = "0.
|
8
|
+
s.version = "0.2.0"
|
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"]
|
@@ -16,7 +16,8 @@ Gem::Specification.new do |s|
|
|
16
16
|
"README.rdoc"
|
17
17
|
]
|
18
18
|
s.files = [
|
19
|
-
".
|
19
|
+
".gitignore",
|
20
|
+
".specification",
|
20
21
|
"MIT-LICENSE",
|
21
22
|
"README.rdoc",
|
22
23
|
"Rakefile",
|
@@ -26,6 +27,9 @@ Gem::Specification.new do |s|
|
|
26
27
|
"generators/kenny_dialoggins/templates/kenny_dialoggins.js",
|
27
28
|
"init.rb",
|
28
29
|
"kenny_dialoggins.gemspec",
|
30
|
+
"lib/generators/kenny_dialoggins/kenny_dialoggins_generator.rb",
|
31
|
+
"lib/generators/kenny_dialoggins/templates/kenny_dialoggins.css",
|
32
|
+
"lib/generators/kenny_dialoggins/templates/kenny_dialoggins.js",
|
29
33
|
"lib/kenny_dialoggins.rb",
|
30
34
|
"lib/kenny_dialoggins/helpers.rb",
|
31
35
|
"rails/init.rb",
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class KennyDialogginsGenerator < Rails::Generator::Base
|
2
|
+
|
3
|
+
# This method establishes the path to the templates directory.
|
4
|
+
#
|
5
|
+
def self.source_root
|
6
|
+
@source_root ||= File.expand_path('../templates', __FILE__)
|
7
|
+
end
|
8
|
+
|
9
|
+
|
10
|
+
# This method copies stylesheet and javascript files to the
|
11
|
+
# corresponding public directories.
|
12
|
+
#
|
13
|
+
def copy_assets
|
14
|
+
copy_file "kenny_dialoggins.js", "public/javascripts/kenny_dialoggins.js"
|
15
|
+
copy_file "kenny_dialoggins.css", "public/stylesheets/kenny_dialoggins.css"
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
/**
|
2
|
+
* These styles are provided as examples. Feel free to change them however you like.
|
3
|
+
*/
|
4
|
+
.kenny_dialoggins_dialog {
|
5
|
+
position: absolute;
|
6
|
+
padding: 1em;
|
7
|
+
border: 1px solid #BBB;
|
8
|
+
background: #FFF;
|
9
|
+
z-index: 2;
|
10
|
+
-moz-box-shadow: 4px 4px 16px rgba(0,0,0,0.5);
|
11
|
+
-webkit-box-shadow: 4px 4px 16px rgba(0,0,0,0.5);
|
12
|
+
filter: alpha(opacity=100); /* really only needed if ie6 suport is enabled */
|
13
|
+
}
|
14
|
+
|
15
|
+
.kenny_dialoggins_dialog_frame {
|
16
|
+
position: absolute;
|
17
|
+
border: none;
|
18
|
+
z-index: 1;
|
19
|
+
filter: alpha(opacity=0); /* really only needed if ie6 suport is enabled */
|
20
|
+
}
|
@@ -0,0 +1,268 @@
|
|
1
|
+
/**
|
2
|
+
* Kenny Dialoggins creates pretty dialogs using prototype and
|
3
|
+
* scriptaculous. These functions work with ActionView
|
4
|
+
* helpers to provide dialog components that can be programmed
|
5
|
+
* using the same syntax as rendering partials.
|
6
|
+
*
|
7
|
+
*
|
8
|
+
* Brought to you by the good folks at Coroutine. Hire us!
|
9
|
+
* http://coroutine.com
|
10
|
+
*/
|
11
|
+
var KennyDialoggins = {}
|
12
|
+
|
13
|
+
|
14
|
+
/**
|
15
|
+
* This property governs whether or not KD bothers creating and
|
16
|
+
* managing a blocking iframe to accommodate ie6.
|
17
|
+
*
|
18
|
+
* Defaults to false, but override if you must.
|
19
|
+
*/
|
20
|
+
KennyDialoggins.SUPPORT_IE6_BULLSHIT = false;
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
/**
|
25
|
+
* This function puts you on the highway to the danger
|
26
|
+
* zone by defining the KD dialog class.
|
27
|
+
*/
|
28
|
+
KennyDialoggins.Dialog = function(content, options) {
|
29
|
+
options = options || {};
|
30
|
+
|
31
|
+
this._element = null;
|
32
|
+
this._frame = null;
|
33
|
+
this._hideListener = this._generateHideListener();
|
34
|
+
this._is_showing = false;
|
35
|
+
|
36
|
+
this._beforeShow = options["beforeShow"] || Prototype.emptyFunction
|
37
|
+
this._afterShow = options["afterShow"] || Prototype.emptyFunction
|
38
|
+
this._beforeHide = options["beforeHide"] || Prototype.emptyFunction
|
39
|
+
this._afterHide = options["afterHide"] || Prototype.emptyFunction
|
40
|
+
|
41
|
+
this._makeDialog();
|
42
|
+
this.setContent(content);
|
43
|
+
document.body.appendChild(this._element);
|
44
|
+
|
45
|
+
if (KennyDialoggins.SUPPORT_IE6_BULLSHIT) {
|
46
|
+
this._makeFrame();
|
47
|
+
document.body.appendChild(this._frame);
|
48
|
+
}
|
49
|
+
}
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
// ----------------------------------------------------------------------------
|
54
|
+
// Class methods
|
55
|
+
// ----------------------------------------------------------------------------
|
56
|
+
|
57
|
+
/**
|
58
|
+
* This hash maps the dialog id to the dialog object itself. It allows the Rails
|
59
|
+
* code a way to specify the js object it wishes to invoke.
|
60
|
+
*/
|
61
|
+
KennyDialoggins.Dialog.instances = {};
|
62
|
+
|
63
|
+
|
64
|
+
/**
|
65
|
+
* This hash is a convenience that allows us to write slightly denser code when
|
66
|
+
* calculating the dialog's position.
|
67
|
+
*/
|
68
|
+
KennyDialoggins.Dialog._POSITION_FN_MAP = $H({
|
69
|
+
left: "getWidth",
|
70
|
+
top: "getHeight"
|
71
|
+
});
|
72
|
+
|
73
|
+
|
74
|
+
/**
|
75
|
+
* This method shows the dialog with the corresponding id.
|
76
|
+
*
|
77
|
+
* @param {String} id The id value of the dialog element (also the key
|
78
|
+
* in the instances hash.)
|
79
|
+
*
|
80
|
+
* @return {Object} an instance of KennyDialoggins.Dialog
|
81
|
+
*
|
82
|
+
*/
|
83
|
+
KennyDialoggins.Dialog.show = function(id) {
|
84
|
+
var dialog = this.instances[id];
|
85
|
+
if(dialog) {
|
86
|
+
dialog.show();
|
87
|
+
}
|
88
|
+
return dialog;
|
89
|
+
}
|
90
|
+
|
91
|
+
|
92
|
+
/**
|
93
|
+
* This method hides the dialog with the corresponding id.
|
94
|
+
*
|
95
|
+
* @param {String} id The id value of the dialog element (also the key
|
96
|
+
* in the instances hash.)
|
97
|
+
*
|
98
|
+
* @return {Object} an instance of KennyDialoggins.Dialog
|
99
|
+
*
|
100
|
+
*/
|
101
|
+
KennyDialoggins.Dialog.hide = function(id) {
|
102
|
+
var dialog = this.instances[id];
|
103
|
+
if(dialog) {
|
104
|
+
dialog.hide();
|
105
|
+
}
|
106
|
+
return dialog;
|
107
|
+
}
|
108
|
+
|
109
|
+
|
110
|
+
/**
|
111
|
+
* This method returns a boolean indiciating whether or not the
|
112
|
+
* dialog with the corresponding id is showing.
|
113
|
+
*
|
114
|
+
* @param {String} id The id value of the dialog element (also the key
|
115
|
+
* in the instances hash.)
|
116
|
+
*
|
117
|
+
* @return {Boolean} Whether or not the dialog with the corresponding
|
118
|
+
* id is showing.
|
119
|
+
*
|
120
|
+
*/
|
121
|
+
KennyDialoggins.Dialog.is_showing = function(id) {
|
122
|
+
var dialog = this.instances[id];
|
123
|
+
if (!dialog) {
|
124
|
+
throw "No dialog cound be found for the supplied id.";
|
125
|
+
}
|
126
|
+
return dialog.is_showing();
|
127
|
+
}
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
// ----------------------------------------------------------------------------
|
132
|
+
// Instance methods
|
133
|
+
// ----------------------------------------------------------------------------
|
134
|
+
|
135
|
+
Object.extend(KennyDialoggins.Dialog.prototype, {
|
136
|
+
|
137
|
+
/**
|
138
|
+
* This function constructs the dialog element and hides it by default.
|
139
|
+
*
|
140
|
+
* The class name is set outside the element constructor to accommodate
|
141
|
+
* a discrepancy in how prototype handles this particular attribute. The
|
142
|
+
* attribute is set as className in IE8--rather than class--which means the
|
143
|
+
* styles are not applied and the element's positioning gets royally
|
144
|
+
* screwed up.
|
145
|
+
*/
|
146
|
+
_makeDialog: function() {
|
147
|
+
if (!this._element) {
|
148
|
+
this._element = new Element("DIV");
|
149
|
+
this._element.className = "kenny_dialoggins_dialog";
|
150
|
+
this._element.hide();
|
151
|
+
}
|
152
|
+
},
|
153
|
+
|
154
|
+
|
155
|
+
/**
|
156
|
+
* This function constructs the iframe element and hides it by default.
|
157
|
+
*
|
158
|
+
* The class name is set outside the element constructor to accommodate
|
159
|
+
* a discrepancy in how prototype handles this particular attribute. The
|
160
|
+
* attribute is set as className in IE8--rather than class--which means the
|
161
|
+
* styles are not applied and the element's positioning gets royally
|
162
|
+
* screwed up.
|
163
|
+
*/
|
164
|
+
_makeFrame: function() {
|
165
|
+
if (!this._frame) {
|
166
|
+
this._frame = new Element("IFRAME");
|
167
|
+
this._frame.className = "kenny_dialoggins_dialog_frame";
|
168
|
+
this._frame.setAttribute("src", "about:blank");
|
169
|
+
this._frame.hide();
|
170
|
+
}
|
171
|
+
},
|
172
|
+
|
173
|
+
|
174
|
+
/**
|
175
|
+
* This function creates the function that handles click events when the dialog is
|
176
|
+
* shown. The handler ignores clicks targeted from within the dialog; any click
|
177
|
+
* targeted outside the dialog causes the dialog to hide itself and cancel the
|
178
|
+
* observer.
|
179
|
+
*/
|
180
|
+
_generateHideListener: function() {
|
181
|
+
return function(evt) {
|
182
|
+
var origin = evt.findElement(".kenny_dialoggins_dialog");
|
183
|
+
if (this._element !== origin) {
|
184
|
+
this.hide();
|
185
|
+
}
|
186
|
+
}.bind(this);
|
187
|
+
},
|
188
|
+
|
189
|
+
|
190
|
+
/**
|
191
|
+
* This function sets the content of the dialog element.
|
192
|
+
*
|
193
|
+
* @param {Object} content The html content for the dialog.
|
194
|
+
*/
|
195
|
+
setContent: function(content) {
|
196
|
+
this._element.update(content);
|
197
|
+
},
|
198
|
+
|
199
|
+
|
200
|
+
/**
|
201
|
+
* This function displays the dialog. It uses a scriptaculous effect to fade in,
|
202
|
+
* centers the dialog in the viewport (and adjusts the blocking iframe, if in use),
|
203
|
+
* and connects a click observer to hide the dialog whenever mouse focus leaves
|
204
|
+
* the dialog.
|
205
|
+
*/
|
206
|
+
show: function() {
|
207
|
+
KennyDialoggins.Dialog._POSITION_FN_MAP.each(function(pair) {
|
208
|
+
var method = pair.last();
|
209
|
+
this._element.style[pair.first()] =
|
210
|
+
(document.viewport[method]() / 2 + document.viewport.getScrollOffsets()[pair.first()] - this._element[method]() / 2) + "px";
|
211
|
+
}.bind(this));
|
212
|
+
|
213
|
+
if (this._frame) {
|
214
|
+
this._frame.style.top = this._element.style.top;
|
215
|
+
this._frame.style.left = this._element.style.left;
|
216
|
+
this._frame.style.width = this._element.getWidth() + "px";
|
217
|
+
this._frame.style.height = this._element.getHeight() + "px";
|
218
|
+
|
219
|
+
new Effect.Appear(this._frame, {
|
220
|
+
duration: 0.2
|
221
|
+
});
|
222
|
+
}
|
223
|
+
|
224
|
+
new Effect.Appear(this._element, {
|
225
|
+
duration: 0.2,
|
226
|
+
beforeStart: this._beforeShow,
|
227
|
+
afterFinish: function() {
|
228
|
+
this._is_showing = true;
|
229
|
+
this._afterShow();
|
230
|
+
document.observe("click", this._hideListener);
|
231
|
+
}.bind(this)
|
232
|
+
});
|
233
|
+
},
|
234
|
+
|
235
|
+
|
236
|
+
/**
|
237
|
+
* This function hides the dialog. It uses a scriptaculous effect to fade out
|
238
|
+
* and disconnects the click observer to prevent memory leaks.
|
239
|
+
*/
|
240
|
+
hide: function() {
|
241
|
+
new Effect.Fade(this._element, {
|
242
|
+
duration: 0.2,
|
243
|
+
beforeStart: this._beforeHide,
|
244
|
+
afterFinish: function() {
|
245
|
+
this._is_showing = false;
|
246
|
+
this._afterHide();
|
247
|
+
document.stopObserving("click", this._hideListener);
|
248
|
+
}.bind(this)
|
249
|
+
});
|
250
|
+
|
251
|
+
if (this._frame) {
|
252
|
+
new Effect.Fade(this._frame, {
|
253
|
+
duration: 0.2
|
254
|
+
});
|
255
|
+
}
|
256
|
+
},
|
257
|
+
|
258
|
+
|
259
|
+
/**
|
260
|
+
* This function indicates whether or not the dialog is currently
|
261
|
+
* being shown.
|
262
|
+
*
|
263
|
+
* @return {Boolean} Whether or not the dialog is being shown.
|
264
|
+
*/
|
265
|
+
is_showing: function() {
|
266
|
+
return this._is_showing;
|
267
|
+
}
|
268
|
+
});
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kenny_dialoggins
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
- 1
|
9
8
|
- 2
|
10
|
-
|
9
|
+
- 0
|
10
|
+
version: 0.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Coroutine
|
@@ -61,6 +61,7 @@ extensions: []
|
|
61
61
|
extra_rdoc_files:
|
62
62
|
- README.rdoc
|
63
63
|
files:
|
64
|
+
- .gitignore
|
64
65
|
- .specification
|
65
66
|
- MIT-LICENSE
|
66
67
|
- README.rdoc
|
@@ -71,6 +72,9 @@ files:
|
|
71
72
|
- generators/kenny_dialoggins/templates/kenny_dialoggins.js
|
72
73
|
- init.rb
|
73
74
|
- kenny_dialoggins.gemspec
|
75
|
+
- lib/generators/kenny_dialoggins/kenny_dialoggins_generator.rb
|
76
|
+
- lib/generators/kenny_dialoggins/templates/kenny_dialoggins.css
|
77
|
+
- lib/generators/kenny_dialoggins/templates/kenny_dialoggins.js
|
74
78
|
- lib/kenny_dialoggins.rb
|
75
79
|
- lib/kenny_dialoggins/helpers.rb
|
76
80
|
- rails/init.rb
|