Permalink
Browse files

Added ability to modify background color and z-index

git-svn-id: https://svn.thoughtbot.com/plugins/mile_marker/trunk@158 7bbfaf0e-4d1d-0410-9690-a8bb5f8ef2aa
  • Loading branch information...
1 parent a5b8506 commit dd1e2a66cf08a2f776bb892d7392007e16a3886d jyurek committed Aug 3, 2007
Showing with 20 additions and 1 deletion.
  1. +8 −1 lib/mile_marker.rb
  2. +12 −0 test/mile_marker_test.rb
View
@@ -22,6 +22,13 @@ class MileMarker
# to 'development' only.
@@environments = ['development']
cattr_accessor :environments
+
+ def self.options
+ @options ||= {
+ :z_index => 1000,
+ :background_color => "#000"
+ }
+ end
# Return true if the Mile Marker functionality is enabled for the current environment
def self.enabled?
@@ -45,7 +52,7 @@ def self.initialize_mile_marker()
}
function init_miles() {
$$('*[mile]').each(function(block, index) {
- html = '<div id="mile_'+index+'" style="display: none; z-index: 1000; position: absolute; background-color: #000; opacity: 0.4; filter: alpha(opacity=40); color: #eee; font-family: Lucida Sans, Helvetica; font-size: 16px; font-weight: bold; white-space: nowrap; overflow: hidden;"><p style="padding: 3px 5px; background-color: #000; opacity: 1.0; filter: alpha(opacity=100); display: inline; color: #f3f3f3;">'+block.getAttribute('mile')+'</p></div>'
+ html = '<div id="mile_'+index+'" style="display: none; z-index: #{options[:z_index]}; position: absolute; background-color: #{options[:background_color]}; opacity: 0.4; filter: alpha(opacity=40); color: #eee; font-family: Lucida Sans, Helvetica; font-size: 16px; font-weight: bold; white-space: nowrap; overflow: hidden;"><p style="padding: 3px 5px; background-color: #000; opacity: 1.0; filter: alpha(opacity=100); display: inline; color: #f3f3f3;">'+block.getAttribute('mile')+'</p></div>'
new Insertion.Before($(block), html);
Position.clone($(block), $('mile_'+index));
if($('mile_'+index).getHeight() <= 25) { $('mile_'+index).setStyle({fontSize: '10px'}); }
@@ -67,4 +67,16 @@ def test_javascript_should_be_added_to_head_if_enabled
add_initialize_mile_marker
assert_match /script/, response.body
end
+
+ def test_z_index_and_other_options_in_css_set_as_specified_in_options
+ Thoughtbot::MileMarker.environments = ['development']
+ Thoughtbot::MileMarker.options[:z_index] = "1234"
+ Thoughtbot::MileMarker.options[:background_color] = "purple"
+ ENV['RAILS_ENV']="development"
+ response.body = "<head></head>"
+ add_initialize_mile_marker
+ assert_match /script/, response.body
+ assert_match /z-index: 1234/, response.body
+ assert_match /background-color: purple/, response.body
+ end
end

0 comments on commit dd1e2a6

Please sign in to comment.