updated graph styling and json generate code. updated add synapses page to not have all three forms in the same place.

This commit is contained in:
Connor Turland 2012-10-10 11:52:50 -04:00
parent 4d09fb6fc8
commit 606b59b644
7 changed files with 283 additions and 255 deletions

View file

@ -48,17 +48,20 @@ function init(){
// with dollar prefixed data-properties in the // with dollar prefixed data-properties in the
// JSON structure. // JSON structure.
Node: { Node: {
overridable: true overridable: true,
color: '#2D6A5D',
type: 'circle',
dim: 11
}, },
Edge: { Edge: {
overridable: true, overridable: true,
color: '#23A4FF', color: '#23A4FF',
lineWidth: 0.4 lineWidth: 0.5
}, },
//Native canvas text styling //Native canvas text styling
Label: { Label: {
type: labelType, //Native or HTML type: labelType, //Native or HTML
size: 10, size: 12,
style: 'bold' style: 'bold'
}, },
//Add Tips //Add Tips
@ -117,7 +120,7 @@ function init(){
onCreateLabel: function(domElement, node){ onCreateLabel: function(domElement, node){
domElement.innerHTML = node.name; domElement.innerHTML = node.name;
var style = domElement.style; var style = domElement.style;
style.fontSize = "0.8em"; style.fontSize = "0.9em";
style.color = "#ddd"; style.color = "#ddd";
}, },
// Change node styles when DOM labels are placed // Change node styles when DOM labels are placed

View file

@ -69,3 +69,9 @@ input[type="submit"] { margin-top:5px; }
.divider { margin: 20px 50px 20px 50px; border-bottom:2px solid #FFF; } .divider { margin: 20px 50px 20px 50px; border-bottom:2px solid #FFF; }
.empty { margin-left:50px; } .empty { margin-left:50px; }
.selecttype { display:block; margin:100px auto 0; width:500px; }
.selecttype button { display:inline-block; width:150px; height:50px; background: #2D6A5D; color: white; border-radius: 15px; cursor: pointer; }
.selecttype button:hover { border-width:4px; border-color:#CCC; }
.selecttype .middle { margin:0 20px; }
.newsynapses form {display:none; }

View file

@ -29,8 +29,6 @@ has_many :items, :through => :groupitems
def as_json def as_json
Jbuilder.encode do |json| Jbuilder.encode do |json|
@data1 = {'$color'=> '#909291'}
@data2 = {'$color'=> '#70A35E', '$type'=> 'triangle', '$dim'=> 11 }
@single = Array.new @single = Array.new
@single.push(self) @single.push(self)
@groups = @single + self.relatives @groups = @single + self.relatives
@ -39,10 +37,16 @@ has_many :items, :through => :groupitems
json.adjacencies group.synapses2.delete_if{|synapse| not @groups.include?(Group.find_by_id(synapse.node1_id))} do |json, synapse| json.adjacencies group.synapses2.delete_if{|synapse| not @groups.include?(Group.find_by_id(synapse.node1_id))} do |json, synapse|
json.nodeTo synapse.node1_id json.nodeTo synapse.node1_id
json.nodeFrom synapse.node2_id json.nodeFrom synapse.node2_id
json.data @data1
@synapsedata = Hash.new
@synapsedata['desc'] = synapse.desc
json.data @synapsedata
end end
json.data @data2 @groupdata = Hash.new
@groupdata['desc'] = group.desc
@groupdata['link'] = group.link
json.data @groupdata
json.id group.id json.id group.id
json.name group.name json.name group.name
end end

View file

@ -31,8 +31,6 @@ has_many :parent_items, :through => :itemitem_p, :source => :parent_item
def as_json def as_json
Jbuilder.encode do |json| Jbuilder.encode do |json|
@data1 = {'$color'=> '#909291'}
@data2 = {'$color'=> '#70A35E', '$type'=> 'triangle', '$dim'=> 11 }
@single = Array.new @single = Array.new
@single.push(self) @single.push(self)
@items = @single + self.relatives @items = @single + self.relatives
@ -41,10 +39,16 @@ has_many :parent_items, :through => :itemitem_p, :source => :parent_item
json.adjacencies item.synapses2.delete_if{|synapse| not @items.include?(Item.find_by_id(synapse.node1_id))} do |json, synapse| json.adjacencies item.synapses2.delete_if{|synapse| not @items.include?(Item.find_by_id(synapse.node1_id))} do |json, synapse|
json.nodeTo synapse.node1_id json.nodeTo synapse.node1_id
json.nodeFrom synapse.node2_id json.nodeFrom synapse.node2_id
json.data @data1
@synapsedata = Hash.new
@synapsedata['desc'] = synapse.desc
json.data @synapsedata
end end
json.data @data2 @itemdata = Hash.new
@itemdata['desc'] = item.desc
@itemdata['link'] = item.link
json.data @itemdata
json.id item.id json.id item.id
json.name item.name json.name item.name
end end

View file

@ -23,8 +23,6 @@ has_many :people2, :through => :synapses1, :source => :person2
def as_json def as_json
Jbuilder.encode do |json| Jbuilder.encode do |json|
@data1 = {'$color'=> '#909291'}
@data2 = {'$color'=> '#70A35E', '$type'=> 'triangle', '$dim'=> 11 }
@single = Array.new @single = Array.new
@single.push(self) @single.push(self)
@people = @single + self.relatives @people = @single + self.relatives
@ -33,10 +31,16 @@ has_many :people2, :through => :synapses1, :source => :person2
json.adjacencies person.synapses2.delete_if{|synapse| not @people.include?(Person.find_by_id(synapse.node1_id))} do |json, synapse| json.adjacencies person.synapses2.delete_if{|synapse| not @people.include?(Person.find_by_id(synapse.node1_id))} do |json, synapse|
json.nodeTo synapse.node1_id json.nodeTo synapse.node1_id
json.nodeFrom synapse.node2_id json.nodeFrom synapse.node2_id
json.data @data1
@synapsedata = Hash.new
@synapsedata['desc'] = synapse.desc
json.data @synapsedata
end end
json.data @data2 @persondata = Hash.new
@persondata['desc'] = person.desc
@persondata['link'] = person.link
json.data @persondata
json.id person.id json.id person.id
json.name person.name json.name person.name
end end

View file

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<title>Metamap</title> <title>Metamaps</title>
<%= stylesheet_link_tag "application", :media => "all" %> <%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_include_tag "application" %> <%= javascript_include_tag "application" %>
<%= csrf_meta_tags %> <%= csrf_meta_tags %>
@ -10,7 +10,7 @@
<%= content_tag :div, class: authenticated? ? "main authenticated" : "main unauthenticated" do %> <%= content_tag :div, class: authenticated? ? "main authenticated" : "main unauthenticated" do %>
<div class="headertop"> <div class="headertop">
<h1 id="mainTitle"><%= link_to "metamap", root_path %></h1>&nbsp;beta <h1 id="mainTitle"><%= link_to "metamaps", root_path %></h1>&nbsp;beta
<% unless authenticated? %> <% unless authenticated? %>
<ul> <ul>
<li><%= link_to "Login", new_session_path, id: "Login" %></li> <li><%= link_to "Login", new_session_path, id: "Login" %></li>

View file

@ -1,4 +1,10 @@
<%= form_for @synapse1, url: synapses_url do |form| %> <div class="selecttype">
<button onclick="$('.selecttype').fadeOut('fast', function(){$('.newsynapses form:eq(0)').fadeIn('fast')});">Group to Group</button>
<button class="middle" onclick="$('.selecttype').fadeOut('fast', function(){$('.newsynapses form:eq(1)').fadeIn('fast')});">Person to Person</button>
<button onclick="$('.selecttype').fadeOut('fast', function(){$('.newsynapses form:eq(2)').fadeIn('fast')});">Item to Item</button>
</div>
<div class="newsynapses">
<%= form_for @synapse1, url: synapses_url do |form| %>
<h3>Add Synapse Between Groups</h3> <h3>Add Synapse Between Groups</h3>
<%= hidden_field_tag(:category, "Group") %> <%= hidden_field_tag(:category, "Group") %>
<% if @allgroups.count > 0 %> <% if @allgroups.count > 0 %>
@ -12,8 +18,8 @@
<%= select_tag :node2_id, options_from_collection_for_select(@allgroups, "id", "name") %> <%= select_tag :node2_id, options_from_collection_for_select(@allgroups, "id", "name") %>
<% end %> <% end %>
<%= form.submit "Add Synapse", class: "add" %> <%= form.submit "Add Synapse", class: "add" %>
<% end %> <% end %>
<%= form_for @synapse2, url: synapses_url do |form| %> <%= form_for @synapse2, url: synapses_url do |form| %>
<h3>Add Synapse Between People</h3> <h3>Add Synapse Between People</h3>
<%= hidden_field_tag(:category, "Person") %> <%= hidden_field_tag(:category, "Person") %>
<% if @allpeople.count > 0 %> <% if @allpeople.count > 0 %>
@ -27,8 +33,8 @@
<%= select_tag :node2_id, options_from_collection_for_select(@allpeople, "id", "name") %> <%= select_tag :node2_id, options_from_collection_for_select(@allpeople, "id", "name") %>
<% end %> <% end %>
<%= form.submit "Add Synapse", class: "add" %> <%= form.submit "Add Synapse", class: "add" %>
<% end %> <% end %>
<%= form_for @synapse3, url: synapses_url do |form| %> <%= form_for @synapse3, url: synapses_url do |form| %>
<h3>Add Synapse Between Items</h3> <h3>Add Synapse Between Items</h3>
<%= hidden_field_tag(:category, "Item") %> <%= hidden_field_tag(:category, "Item") %>
<% if @allitems.count > 0 %> <% if @allitems.count > 0 %>
@ -42,4 +48,5 @@
<%= select_tag :node2_id, options_from_collection_for_select(@allitems, "id", "name") %> <%= select_tag :node2_id, options_from_collection_for_select(@allitems, "id", "name") %>
<% end %> <% end %>
<%= form.submit "Add Synapse", class: "add" %> <%= form.submit "Add Synapse", class: "add" %>
<% end %> <% end %>
</div>