Skip to content

Commit

Permalink
Changed date selector to change on mouse over and not leave page when…
Browse files Browse the repository at this point in the history
… no new date is selected
  • Loading branch information
Franklin Webber committed Aug 1, 2013
1 parent 0bce294 commit 2819271
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions app/views/schedule/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
</li>
<li>
<a href="#" class="schedule-current"><%= nav_date_format(@schedule.publish_date) %></a>
<input type="date" class="schedule-datepicker" style="display: none;" value="<%= @schedule.publish_date %>" />
<input type="date" class="schedule-datepicker" style="display: none;" value="<%= @schedule.publish_date %>" data-original="<%= @schedule.publish_date %>" />
</li>

<li>
Expand Down Expand Up @@ -33,16 +33,22 @@
$(".content-edit").toggle();
});

$(".schedule-current").on("click",function(event) {
$(".schedule-current").on("mouseover",function(event) {
event.preventDefault();
$(this).toggle();
$(".schedule-datepicker").toggle();
});

$(".schedule-datepicker").on("focusout",function(event) {
event.preventDefault();

var newDate = $(this).val().replace(/-/g,'');
window.location.href= "/" + newDate;
var originalDate = $(this).data("original").replace(/-/g,'');

if (newDate !== originalDate) {
window.location.href= "/" + newDate;
}

});

});
Expand Down

0 comments on commit 2819271

Please sign in to comment.