From c5c923d66ff1f2d070176564b48778d981194308 Mon Sep 17 00:00:00 2001 From: Nathan Friedly Date: Fri, 5 Mar 2010 07:55:35 -0800 Subject: [PATCH] tweaked family trees, disabled javascript clicker on non-search pages --- app/views/families/show.html.erb | 14 ++++++++ app/views/people/show.html.erb | 5 +++ public/javascripts/admin.js | 55 ++++++++++++++++-------------- public/stylesheets/biblepeople.css | 21 ++++++++++++ 4 files changed, 70 insertions(+), 25 deletions(-) diff --git a/app/views/families/show.html.erb b/app/views/families/show.html.erb index 5cab953..10a56c9 100644 --- a/app/views/families/show.html.erb +++ b/app/views/families/show.html.erb @@ -1,5 +1,19 @@

Family tree of <%= link_to @parent.name, @parent %>

+<% if(@parent.mother && @parent.father) %> +
+ <%= link_to @parent.father.name, @parent.father %> + <%= link_to @parent.mother.name, @parent.mother %> +
+
+
 
+<% 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%> +
 
+<% end end %> + + <%= render( :partial => "family", :locals => { :parent => @parent, diff --git a/app/views/people/show.html.erb b/app/views/people/show.html.erb index bc8fed4..de0c72d 100644 --- a/app/views/people/show.html.erb +++ b/app/views/people/show.html.erb @@ -33,6 +33,11 @@ <% end %>

+

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

+

Description: <%=h @person.description %> diff --git a/public/javascripts/admin.js b/public/javascripts/admin.js index 765c113..00b18d1 100644 --- a/public/javascripts/admin.js +++ b/public/javascripts/admin.js @@ -1,34 +1,39 @@ $(document).ready(function(){ - // create my word-actions div - $('

Create Person
') - .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 + $('
Create Person
') + .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 { diff --git a/public/stylesheets/biblepeople.css b/public/stylesheets/biblepeople.css index 1070620..7583cb6 100644 --- a/public/stylesheets/biblepeople.css +++ b/public/stylesheets/biblepeople.css @@ -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; }