Skip to content

Commit

Permalink
tweaked family trees, disabled javascript clicker on non-search pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Friedly committed Mar 5, 2010
1 parent d0ba6d1 commit c5c923d
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 25 deletions.
14 changes: 14 additions & 0 deletions app/views/families/show.html.erb
@@ -1,5 +1,19 @@
<h1>Family tree of <%= link_to @parent.name, @parent %></h1>

<% if(@parent.mother && @parent.father) %>
<div class="parents">
<%= link_to @parent.father.name, @parent.father %>
<%= link_to @parent.mother.name, @parent.mother %>
</div>
<div class="clear"></div>
<div class="linedown">&nbsp;</div>
<% else if(@parent.mother || @parent.father) %>
<%= link_to @parent.father.name, @parent.father unless !@parent.father %>
<%= link_to @parent.mother.name, @parent.mother unless ! @parent.mother%>
<div class="linedown">&nbsp;</div>
<% end end %>
<%= render( :partial => "family",
:locals => {
:parent => @parent,
Expand Down
5 changes: 5 additions & 0 deletions app/views/people/show.html.erb
Expand Up @@ -33,6 +33,11 @@
<% end %>
</p>

<p>
<b>Family Tree:</b>
<%= link_to "Family tree of " + @person.name, {:controller => "families", :action => "show", :id => @person.id } %>
</p>

<p>
<b>Description:</b>
<%=h @person.description %>
Expand Down
55 changes: 30 additions & 25 deletions public/javascripts/admin.js
@@ -1,34 +1,39 @@
$(document).ready(function(){

// create my word-actions div
$('<div id="word-actions" class="hoverbox"><a href="/people/new" id="create-person">Create Person</a></div>')
.appendTo('body');
var WordActions = $('#word-actions');
var CPLink = $('#create-person');
var WAWidth = WordActions.width()
// only bother with this if we're on a page with verses
if($("p.verse:first").length) {

// placeholder for the current selected word
var Word;
// create my word-actions div
$('<div id="word-actions" class="hoverbox"><a href="/people/new" id="create-person">Create Person</a></div>')
.appendTo('body');
var WordActions = $('#word-actions');
var CPLink = $('#create-person');
var WAWidth = WordActions.width()

// event when a word is clicked
$("p.verse span").live('click',function(){
if(Word){
Word.removeClass('active-word');
}
Word = $(this);
Word.addClass('active-word');

// show the actions box
var offset = Word.offset();
offset.top = offset.top - 2;
offset.left = offset.left - (WAWidth - Word.width())/2;
WordActions.offset(offset);
// placeholder for the current selected word
var Word;

// update the links
CPLink.attr('href', '/people/new?name=' + Word.text().replace(/[^a-z ]/i,''));
});
// event when a word is clicked
$("p.verse span").live('click',function(){
if(Word){
Word.removeClass('active-word');
}
Word = $(this);
Word.addClass('active-word');

// show the actions box
var offset = Word.offset();
offset.top = offset.top - 2;
offset.left = offset.left - (WAWidth - Word.width())/2;
WordActions.offset(offset);

// update the links
CPLink.attr('href', '/people/new?name=' + Word.text().replace(/[^a-z ]/i,''));
});

}

// autocomplete for the parents
// autocomplete for the parents (only runs on pages with #father_name or #mother_name fields)
$('#father_name, #mother_name').autocomplete(
"/people/parent", // .json or .xml also work
{
Expand Down
21 changes: 21 additions & 0 deletions public/stylesheets/biblepeople.css
Expand Up @@ -20,6 +20,27 @@

/* family tree styles */

.parents {
margin-left:0.5em;
border: 1px solid grey;
border-top:0;
float:left;
}

.parents a {
position:relative;
top: -0.5em;
background-color:white;
}

.parents a:first-child {
left: -1em;
}

.parents a:last-child {
right: -1em;
}

.family {
float: left;
}
Expand Down

0 comments on commit c5c923d

Please sign in to comment.