Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JQuery Highlight and row calculation #51

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions generators/event_calendar/templates/jq_javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@
* Handles when events span rows, or don't have a background color
*/
jQuery(document).ready(function($) {
var highlight_color = "#2EAC6A";
var highlight_color = "#6ABEFF";
var bg_color = null;

// highlight events that have a background color
$(".ec-event-bg").live("mouseover", function() {
event_id = $(this).attr("data-event-id");
event_class_name = $(this).attr("data-event-class");
$("#ec-"+event_class_name+"-"+event_id).css("background-color", highlight_color);
bg_color = $(".ec-"+event_class_name+"-"+event_id).css("background-color");
$(".ec-"+event_class_name+"-"+event_id).css("background-color", highlight_color);
});
$(".ec-event-bg").live("mouseout", function() {
event_id = $(this).attr("data-event-id");
event_class_name = $(this).attr("data-event-class");
event_color = $(this).attr("data-color");
$("#ec-"+event_class_name+"-"+event_id).css("background-color", event_color);
$(".ec-"+event_class_name+"-"+event_id).css("background-color", bg_color);
});

// highlight events that don't have a background color
Expand Down
4 changes: 4 additions & 0 deletions generators/event_calendar/templates/stylesheet.css
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ a.ec-day-link {
white-space: nowrap;
}

.ec-event-bg {
background-color: #9aa4ad;
}

.ec-event :hover {
/* doesn't look as good as js highlighting */
/* background-color: #2eac6a; */
Expand Down
6 changes: 3 additions & 3 deletions lib/event_calendar/calendar_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def calendar(options = {}, &block)

cal << %(<td class="ec-event-cell" colspan="#{(dates[1]-dates[0]).to_i + 1}" )
cal << %(style="padding-top: #{options[:event_margin]}px;">)
cal << %(<div id="ec-#{class_name}-#{event.id}" class="ec-event )
cal << %(<div id="ec-#{class_name}-#{event.id}" class="ec-event ec-#{class_name}-#{event.id} )
if class_name != "event"
cal << %(ec-#{class_name} )
end
Expand All @@ -222,7 +222,7 @@ def calendar(options = {}, &block)
cal << %(style="color: #{event.color}; )
else
cal << %(ec-event-bg" )
cal << %(style="background-color: #{event.color}; )
#cal << %(style="background-color: #{event.color}; )
end

cal << %(padding-top: #{options[:event_padding_top]}px; )
Expand Down Expand Up @@ -341,7 +341,7 @@ def cal_row_heights(options)
# if we reached the end of the week, calculate this row's height
if index % 7 == 0
total_event_height = options[:event_height] + options[:event_margin]
calc_row_height = (num_event_rows * total_event_height) + options[:day_nums_height] + options[:event_margin]
calc_row_height = ((num_event_rows+2) * total_event_height) + options[:day_nums_height] + options[:event_margin]
row_height = [min_height, calc_row_height].max
row_heights << row_height
num_event_rows = 0
Expand Down