michael_hintbuble 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.specification CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: michael_hintbuble
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 1
10
- version: 1.0.1
9
+ - 2
10
+ version: 1.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Coroutine
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2010-10-13 00:00:00 -05:00
20
+ date: 2010-10-18 00:00:00 -05:00
21
21
  default_executable:
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
data/README.rdoc CHANGED
@@ -35,8 +35,7 @@ What's that, you want a few more details? You got it, bro.
35
35
  that, it will take the same options as <tt>ActionController::Base#render</tt>. It'll also take a few
36
36
  more, namely:
37
37
 
38
- * <tt>:class</tt> - the css style to assign to the outermost div container (defaults to "michael_hintbuble_bubble")
39
- * <tt>:style</tt> - additional css style assignments for the outermost div container (defaults to "")
38
+ * <tt>:class</tt> - an additional css style to assign to the outermost div container (facilitates multiple stylings)
40
39
  * <tt>:position</tt> - css-style value that specifies the hint bubble's relative position, e.g., top, bottom, right, or left (defaults to right)
41
40
  * <tt>:event_names</tt> - an array of strings specifying the events that should trigger the display of the hint bubble (accepts focus and/or mouseover)
42
41
  * <tt>:before_show</tt> - a Javascript function that will be invoked before the hint bubble is shown
@@ -68,18 +67,16 @@ Michael Hintbuble
68
67
  == Multiple Hint Bubble Styles
69
68
 
70
69
  If you need to style more than one kind of hint bubble (e.g., one style for tooltips, one style for errors), just
71
- use the <tt>:class</tt> option to set a new css class name on the outermost div. That'll give you a logical anchor
70
+ use the <tt>:class</tt> option to append a css class name on the outermost div. That'll give you a logical anchor
72
71
  around which you can restyle all the interior classes.
73
72
 
74
- Please note that the blocking iframe is automatically given a class name equal to the outermost div's class name plus
73
+ Please note that the blocking iframe is automatically given an additional class name equal to the outermost div's class name plus
75
74
  the string "_frame".
76
75
 
77
76
  By default, the top-level class assignments are "michael_hintbuble_bubble" and "michael_hintbuble_bubble_frame".
78
77
 
79
78
  If you set the <tt>:class</tt> option to <tt>:error_bubble</tt>, the top-level class assignments will be
80
- "error_bubble" and "error_bubble_frame".
81
-
82
- The <tt>:style</tt> option can be used to provide one-off styling, as needed.
79
+ "michael_hintbuble_bubble error_bubble" and "michael_hintbuble_bubble_frame error_bubble_frame".
83
80
 
84
81
 
85
82
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.1
1
+ 1.0.2
@@ -1,13 +1,14 @@
1
1
  class MichaelHintbubleGenerator < Rails::Generator::Base
2
2
 
3
- # This method copies stylesheet and javascript files to the
3
+ # This method copies images, javascript, and stylesheet files to the
4
4
  # corresponding public directories.
5
5
  #
6
6
  def manifest
7
7
  record do |m|
8
- m.file "michael_hintbuble_pointer.png", "public/images/michael_hintbuble_pointer.png"
9
- m.file "michael_hintbuble.css", "public/stylesheets/michael_hintbuble.css"
10
- m.file "michael_hintbuble.js", "public/javascripts/michael_hintbuble.js"
8
+ m.file "help_bubble_pointer.png", "public/images/help_bubble_pointer.png"
9
+ m.file "error_bubble_pointer.png", "public/images/error_bubble_pointer.png"
10
+ m.file "michael_hintbuble.css", "public/stylesheets/michael_hintbuble.css"
11
+ m.file "michael_hintbuble.js", "public/javascripts/michael_hintbuble.js"
11
12
  end
12
13
  end
13
14
  end
@@ -1,15 +1,10 @@
1
- /**
2
- * These styles are provided as examples. Feel free to change them however you like.
3
- * Go ahead, see if we fucking care.
4
- */
5
-
1
+ /* common styles */
6
2
  .michael_hintbuble_bubble_frame {
7
3
  position: absolute;
8
4
  border: none;
9
5
  z-index: 1;
10
6
  filter: alpha(opacity=0); /* really only needed if ie6 suport is enabled */
11
7
  }
12
-
13
8
  .michael_hintbuble_bubble {
14
9
  position: absolute;
15
10
  top: 0;
@@ -31,18 +26,51 @@
31
26
  -moz-border-radius: 2px;
32
27
  -webkit-border-radius: 2px;
33
28
  }
34
- .michael_hintbuble_bubble .bottom,
29
+ .michael_hintbuble_bubble .bottom,
35
30
  .michael_hintbuble_bubble .left,
36
31
  .michael_hintbuble_bubble .right,
37
32
  .michael_hintbuble_bubble .top {
38
- background: url('../images/michael_hintbuble_pointer.png') no-repeat bottom;
39
- }
40
- .michael_hintbuble_bubble .bottom {
41
33
  background-position: top;
34
+ background-repeat: no-repeat;
42
35
  }
43
36
  .michael_hintbuble_bubble .left {
44
37
  background-position: right;
45
38
  }
46
39
  .michael_hintbuble_bubble .right {
47
40
  background-position: left;
41
+ }
42
+ .michael_hintbuble_bubble .top {
43
+ background-position: bottom;
44
+ }
45
+
46
+
47
+ /* error override styles */
48
+ .error_bubble {
49
+ width: 250px;
50
+ }
51
+ .error_bubble .container .content {
52
+ background: #d00;
53
+ color: #fff;
54
+ }
55
+ .error_bubble .bottom,
56
+ .error_bubble .left,
57
+ .error_bubble .right,
58
+ .error_bubble .top {
59
+ background-image: url('../images/error_bubble_pointer.png');
60
+ }
61
+
62
+
63
+ /* help override styles */
64
+ .help_bubble {
65
+ width: 300px;
66
+ }
67
+ .help_bubble .container .content {
68
+ background: #333;
69
+ color: #fff;
70
+ }
71
+ .help_bubble .bottom,
72
+ .help_bubble .left,
73
+ .help_bubble .right,
74
+ .help_bubble .top {
75
+ background-image: url('../images/help_bubble_pointer.png');
48
76
  }
@@ -35,8 +35,7 @@ MichaelHintbuble.Bubble = function(target_id, content, options) {
35
35
  this._positioner = null;
36
36
  this._isShowing = null;
37
37
 
38
- this._class = options["class"] || "michael_hintbuble_bubble";
39
- this._style = options["style"] || "";
38
+ this._class = options["class"] || "";
40
39
  this._eventNames = options["eventNames"] || ["mouseover"]
41
40
  this._position = options["position"] || "right";
42
41
  this._beforeShow = options["beforeShow"] || Prototype.emptyFunction
@@ -173,11 +172,11 @@ MichaelHintbuble.Bubble.prototype._attachObservers = function() {
173
172
  MichaelHintbuble.Bubble.prototype._makeBubble = function() {
174
173
  if (!this._element) {
175
174
  this._container = new Element("DIV");
176
- this._container.className = "container";
175
+ this._container.addClassName("container");
177
176
 
178
177
  this._element = new Element("DIV");
179
- this._element.className = this._class;
180
- this._element.writeAttribute("style", this._style);
178
+ this._element.addClassName("michael_hintbuble_bubble");
179
+ this._element.addClassName(this._class);
181
180
  this._element.update(this._container);
182
181
  this._element.hide();
183
182
  document.body.insert(this._element);
@@ -191,9 +190,11 @@ MichaelHintbuble.Bubble.prototype._makeBubble = function() {
191
190
  MichaelHintbuble.Bubble.prototype._makeFrame = function() {
192
191
  if (!this._frame) {
193
192
  this._frame = new Element("IFRAME");
194
- this._frame.className = this._class + "_frame";
193
+ this._frame.addClassName("michael_hintbuble_bubble_frame");
194
+ this._frame.addClassName(this._class + "_frame");
195
195
  this._frame.setAttribute("src", "about:blank");
196
196
  this._frame.hide();
197
+ document.body.insert(this._frame);
197
198
  }
198
199
  };
199
200
 
@@ -213,7 +214,8 @@ MichaelHintbuble.Bubble.prototype._makePositioner = function() {
213
214
  * class representing the relative position of the bubble to the target.
214
215
  */
215
216
  MichaelHintbuble.Bubble.prototype._updateContainerClass = function() {
216
- this._container.className = "container";
217
+ this._container.removeClassName();
218
+ this._container.addClassName("container");
217
219
  this._container.addClassName(this._positioner.styleClassForPosition());
218
220
  };
219
221
 
@@ -226,16 +228,15 @@ MichaelHintbuble.Bubble.prototype.finalize = function() {
226
228
  this._positioner.finalize();
227
229
  this._container.remove();
228
230
  this._element.remove();
229
-
231
+ if (this._frame) {
232
+ this._frame.remove();
233
+ }
234
+
230
235
  this._target = null;
231
236
  this._element = null;
232
237
  this._container = null;
233
238
  this._positioner = null;
234
-
235
- if (MichaelHintbuble.SUPPORT_IE6_BULLSHIT) {
236
- this._frame.remove();
237
- this._frame = null;
238
- }
239
+ this._frame = null;
239
240
  };
240
241
 
241
242
 
@@ -315,8 +316,8 @@ MichaelHintbuble.Bubble.prototype.show = function() {
315
316
 
316
317
  if (this._frame) {
317
318
  var layout = new Element.Layout(this._element);
318
- this._frame.style.top = layout.get("top") + "px";
319
- this._frame.style.left = layout.get("left") + "px";
319
+ this._frame.style.top = this._element.style.top;
320
+ this._frame.style.left = this._element.style.left;
320
321
  this._frame.style.width = layout.get("width") + "px";
321
322
  this._frame.style.height = layout.get("height") + "px";
322
323
 
@@ -10,13 +10,14 @@ class MichaelHintbubleGenerator < Rails::Generators::Base
10
10
  end
11
11
 
12
12
 
13
- # This method copies stylesheet and javascript files to the
13
+ # This method copies images, javascript, and stylesheet files to the
14
14
  # corresponding public directories.
15
15
  #
16
16
  def generate_assets
17
- copy_file "michael_hintbuble_pointer.png", "public/images/michael_hintbuble_pointer.png"
18
- copy_file "michael_hintbuble.css", "public/stylesheets/michael_hintbuble.css"
19
- copy_file "michael_hintbuble.js", "public/javascripts/michael_hintbuble.js"
17
+ copy_file "help_bubble_pointer.png", "public/images/help_bubble_pointer.png"
18
+ copy_file "error_bubble_pointer.png", "public/images/error_bubble_pointer.png"
19
+ copy_file "michael_hintbuble.css", "public/stylesheets/michael_hintbuble.css"
20
+ copy_file "michael_hintbuble.js", "public/javascripts/michael_hintbuble.js"
20
21
  end
21
22
 
22
23
  end
@@ -1,15 +1,10 @@
1
- /**
2
- * These styles are provided as examples. Feel free to change them however you like.
3
- * Go ahead, see if we fucking care.
4
- */
5
-
1
+ /* common styles */
6
2
  .michael_hintbuble_bubble_frame {
7
3
  position: absolute;
8
4
  border: none;
9
5
  z-index: 1;
10
6
  filter: alpha(opacity=0); /* really only needed if ie6 suport is enabled */
11
7
  }
12
-
13
8
  .michael_hintbuble_bubble {
14
9
  position: absolute;
15
10
  top: 0;
@@ -31,18 +26,51 @@
31
26
  -moz-border-radius: 2px;
32
27
  -webkit-border-radius: 2px;
33
28
  }
34
- .michael_hintbuble_bubble .bottom,
29
+ .michael_hintbuble_bubble .bottom,
35
30
  .michael_hintbuble_bubble .left,
36
31
  .michael_hintbuble_bubble .right,
37
32
  .michael_hintbuble_bubble .top {
38
- background: url('../images/michael_hintbuble_pointer.png') no-repeat bottom;
39
- }
40
- .michael_hintbuble_bubble .bottom {
41
33
  background-position: top;
34
+ background-repeat: no-repeat;
42
35
  }
43
36
  .michael_hintbuble_bubble .left {
44
37
  background-position: right;
45
38
  }
46
39
  .michael_hintbuble_bubble .right {
47
40
  background-position: left;
41
+ }
42
+ .michael_hintbuble_bubble .top {
43
+ background-position: bottom;
44
+ }
45
+
46
+
47
+ /* error override styles */
48
+ .error_bubble {
49
+ width: 250px;
50
+ }
51
+ .error_bubble .container .content {
52
+ background: #d00;
53
+ color: #fff;
54
+ }
55
+ .error_bubble .bottom,
56
+ .error_bubble .left,
57
+ .error_bubble .right,
58
+ .error_bubble .top {
59
+ background-image: url('../images/error_bubble_pointer.png');
60
+ }
61
+
62
+
63
+ /* help override styles */
64
+ .help_bubble {
65
+ width: 300px;
66
+ }
67
+ .help_bubble .container .content {
68
+ background: #333;
69
+ color: #fff;
70
+ }
71
+ .help_bubble .bottom,
72
+ .help_bubble .left,
73
+ .help_bubble .right,
74
+ .help_bubble .top {
75
+ background-image: url('../images/help_bubble_pointer.png');
48
76
  }
@@ -35,8 +35,7 @@ MichaelHintbuble.Bubble = function(target_id, content, options) {
35
35
  this._positioner = null;
36
36
  this._isShowing = null;
37
37
 
38
- this._class = options["class"] || "michael_hintbuble_bubble";
39
- this._style = options["style"] || "";
38
+ this._class = options["class"] || "";
40
39
  this._eventNames = options["eventNames"] || ["mouseover"]
41
40
  this._position = options["position"] || "right";
42
41
  this._beforeShow = options["beforeShow"] || Prototype.emptyFunction
@@ -173,11 +172,11 @@ MichaelHintbuble.Bubble.prototype._attachObservers = function() {
173
172
  MichaelHintbuble.Bubble.prototype._makeBubble = function() {
174
173
  if (!this._element) {
175
174
  this._container = new Element("DIV");
176
- this._container.className = "container";
175
+ this._container.addClassName("container");
177
176
 
178
177
  this._element = new Element("DIV");
179
- this._element.className = this._class;
180
- this._element.writeAttribute("style", this._style);
178
+ this._element.addClassName("michael_hintbuble_bubble");
179
+ this._element.addClassName(this._class);
181
180
  this._element.update(this._container);
182
181
  this._element.hide();
183
182
  document.body.insert(this._element);
@@ -191,9 +190,11 @@ MichaelHintbuble.Bubble.prototype._makeBubble = function() {
191
190
  MichaelHintbuble.Bubble.prototype._makeFrame = function() {
192
191
  if (!this._frame) {
193
192
  this._frame = new Element("IFRAME");
194
- this._frame.className = this._class + "_frame";
193
+ this._frame.addClassName("michael_hintbuble_bubble_frame");
194
+ this._frame.addClassName(this._class + "_frame");
195
195
  this._frame.setAttribute("src", "about:blank");
196
196
  this._frame.hide();
197
+ document.body.insert(this._frame);
197
198
  }
198
199
  };
199
200
 
@@ -213,7 +214,8 @@ MichaelHintbuble.Bubble.prototype._makePositioner = function() {
213
214
  * class representing the relative position of the bubble to the target.
214
215
  */
215
216
  MichaelHintbuble.Bubble.prototype._updateContainerClass = function() {
216
- this._container.className = "container";
217
+ this._container.removeClassName();
218
+ this._container.addClassName("container");
217
219
  this._container.addClassName(this._positioner.styleClassForPosition());
218
220
  };
219
221
 
@@ -226,16 +228,15 @@ MichaelHintbuble.Bubble.prototype.finalize = function() {
226
228
  this._positioner.finalize();
227
229
  this._container.remove();
228
230
  this._element.remove();
229
-
231
+ if (this._frame) {
232
+ this._frame.remove();
233
+ }
234
+
230
235
  this._target = null;
231
236
  this._element = null;
232
237
  this._container = null;
233
238
  this._positioner = null;
234
-
235
- if (MichaelHintbuble.SUPPORT_IE6_BULLSHIT) {
236
- this._frame.remove();
237
- this._frame = null;
238
- }
239
+ this._frame = null;
239
240
  };
240
241
 
241
242
 
@@ -315,8 +316,8 @@ MichaelHintbuble.Bubble.prototype.show = function() {
315
316
 
316
317
  if (this._frame) {
317
318
  var layout = new Element.Layout(this._element);
318
- this._frame.style.top = layout.get("top") + "px";
319
- this._frame.style.left = layout.get("left") + "px";
319
+ this._frame.style.top = this._element.style.top;
320
+ this._frame.style.left = this._element.style.left;
320
321
  this._frame.style.width = layout.get("width") + "px";
321
322
  this._frame.style.height = layout.get("height") + "px";
322
323
 
@@ -8,7 +8,6 @@ module Coroutine #:nodoc:
8
8
  # are specific to the hint bubble are:
9
9
  #
10
10
  # * <tt>:class</tt> - the css style to assign to the outermost div container (defaults to "michael_hintbuble_bubble")
11
- # * <tt>:style</tt> - additional css style assignments for outermost div container (defaults to "")
12
11
  # * <tt>:position</tt> - css-style value that specifies the hint bubble's relative position, e.g., top, bottom, right, or left (defaults to right)
13
12
  # * <tt>:event_names</tt> - an array of strings specifying the events that should trigger the display of the hint bubble
14
13
  # * <tt>:before_show</tt> - a Javascript function that will be invoked before the hint bubble is shown
@@ -71,10 +70,10 @@ module Coroutine #:nodoc:
71
70
  #
72
71
  def render_bubble(target_id, options = {}, &block)
73
72
  options[:inline] = capture(&block) if block_given?
74
- render_options = extract_bubble_render_options(options, &block)
73
+ render_options = extract_bubble_render_options(options)
75
74
  javascript_options = bubble_options_to_js(extract_bubble_javascript_options(options))
76
75
 
77
- content = escape_javascript(render(options))
76
+ content = escape_javascript(render(render_options))
78
77
 
79
78
  raise "You gotta specify a target id to register a hint bubble, baby." unless target_id
80
79
  raise "You gotta provide content to register a hint bubble, baby." unless content
@@ -106,7 +105,7 @@ module Coroutine #:nodoc:
106
105
  # javascript library.
107
106
  #
108
107
  def bubble_javascript_option_keys
109
- [:class, :style, :position, :event_names, :before_show, :after_show, :before_hide, :after_hide]
108
+ [:class, :position, :event_names, :before_show, :after_show, :before_hide, :after_hide]
110
109
  end
111
110
 
112
111
 
@@ -145,7 +144,6 @@ module Coroutine #:nodoc:
145
144
  def extract_bubble_javascript_options(options)
146
145
  js_options = options.reject { |k,v| !bubble_javascript_option_keys.include?(k) }
147
146
 
148
- js_options[:class] = "michael_hintbuble_bubble" if js_options[:class].blank?
149
147
  js_options[:position] = "right" if js_options[:position].blank?
150
148
  js_options[:event_names] = [] if js_options[:event_names].blank?
151
149
 
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{michael_hintbuble}
8
- s.version = "1.0.1"
8
+ s.version = "1.0.2"
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"]
12
- s.date = %q{2010-10-13}
12
+ s.date = %q{2010-10-18}
13
13
  s.description = %q{Michael HintBuble allows you to generate hint bubbles and tooltips in Rails applications using the same syntax used for rendering templates.}
14
14
  s.email = %q{gems@coroutine.com}
15
15
  s.extra_rdoc_files = [
@@ -23,14 +23,16 @@ Gem::Specification.new do |s|
23
23
  "Rakefile",
24
24
  "VERSION",
25
25
  "generators/michael_hintbuble/michael_hintbuble_generator.rb",
26
+ "generators/michael_hintbuble/templates/error_bubble_pointer.png",
27
+ "generators/michael_hintbuble/templates/help_bubble_pointer.png",
26
28
  "generators/michael_hintbuble/templates/michael_hintbuble.css",
27
29
  "generators/michael_hintbuble/templates/michael_hintbuble.js",
28
- "generators/michael_hintbuble/templates/michael_hintbuble_pointer.png",
29
30
  "init.rb",
30
31
  "lib/generators/michael_hintbuble/michael_hintbuble_generator.rb",
32
+ "lib/generators/michael_hintbuble/templates/error_bubble_pointer.png",
33
+ "lib/generators/michael_hintbuble/templates/help_bubble_pointer.png",
31
34
  "lib/generators/michael_hintbuble/templates/michael_hintbuble.css",
32
35
  "lib/generators/michael_hintbuble/templates/michael_hintbuble.js",
33
- "lib/generators/michael_hintbuble/templates/michael_hintbuble_pointer.png",
34
36
  "lib/michael_hintbuble.rb",
35
37
  "lib/michael_hintbuble/helpers.rb",
36
38
  "michael_hintbuble.gemspec",
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: michael_hintbuble
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 1
10
- version: 1.0.1
9
+ - 2
10
+ version: 1.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Coroutine
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2010-10-13 00:00:00 -05:00
20
+ date: 2010-10-18 00:00:00 -05:00
21
21
  default_executable:
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
@@ -68,14 +68,16 @@ files:
68
68
  - Rakefile
69
69
  - VERSION
70
70
  - generators/michael_hintbuble/michael_hintbuble_generator.rb
71
+ - generators/michael_hintbuble/templates/error_bubble_pointer.png
72
+ - generators/michael_hintbuble/templates/help_bubble_pointer.png
71
73
  - generators/michael_hintbuble/templates/michael_hintbuble.css
72
74
  - generators/michael_hintbuble/templates/michael_hintbuble.js
73
- - generators/michael_hintbuble/templates/michael_hintbuble_pointer.png
74
75
  - init.rb
75
76
  - lib/generators/michael_hintbuble/michael_hintbuble_generator.rb
77
+ - lib/generators/michael_hintbuble/templates/error_bubble_pointer.png
78
+ - lib/generators/michael_hintbuble/templates/help_bubble_pointer.png
76
79
  - lib/generators/michael_hintbuble/templates/michael_hintbuble.css
77
80
  - lib/generators/michael_hintbuble/templates/michael_hintbuble.js
78
- - lib/generators/michael_hintbuble/templates/michael_hintbuble_pointer.png
79
81
  - lib/michael_hintbuble.rb
80
82
  - lib/michael_hintbuble/helpers.rb
81
83
  - michael_hintbuble.gemspec