updated header to have dropdown menus. fixed synapses that were showing up blue. ensured that when creating new synapses, you can only see the list for which you have permissions to see

This commit is contained in:
Connor Turland 2012-10-28 14:37:46 -04:00
parent d4c3898f5f
commit 9e7c6b0f02
17 changed files with 274 additions and 90 deletions

View file

@ -222,7 +222,7 @@ function initFD(){
node.eachAdjacency(function(adj) {
adj.setDataset('end', {
lineWidth: 3,
color: '#36acfb'
color: '#FFF'
});
});
} else {

View file

@ -43,21 +43,83 @@
}
});
var sliding = false;
$(".legend").hover(
// controls the sliding hover of the filters
var sliding1 = false;
$(".accountWrap").hover(
function () {
if (! sliding) {
sliding = true;
$("#iconLegend ul").slideDown('slow', function() {
sliding = false;
if (! sliding1) {
sliding1 = true;
$(".account").slideDown('slow', function() {
sliding1 = false;
});
}
},
function () {
if (! sliding) {
sliding = true;
if (! sliding1) {
sliding1 = true;
$(".account").slideUp('slow', function() {
sliding1 = false;
});
}
}
);
var sliding2 = false;
$(".createWrap").hover(
function () {
if (! sliding2) {
sliding2 = true;
$(".create").slideDown('slow', function() {
sliding2 = false;
});
}
},
function () {
if (! sliding2) {
sliding2 = true;
$(".create").slideUp('slow', function() {
sliding2 = false;
});
}
}
);
var sliding3 = false;
$(".exploreWrap").hover(
function () {
if (! sliding3) {
sliding3 = true;
$(".explore").slideDown('slow', function() {
sliding3 = false;
});
}
},
function () {
if (! sliding3) {
sliding3 = true;
$(".explore").slideUp('slow', function() {
sliding3 = false;
});
}
}
);
var sliding4 = false;
$(".legend").hover(
function () {
if (! sliding4) {
sliding4 = true;
$("#iconLegend ul").slideDown('slow', function() {
sliding4 = false;
});
}
},
function () {
if (! sliding4) {
sliding4 = true;
$("#iconLegend ul").slideUp('slow', function() {
sliding = false;
sliding4 = false;
});
}
}

View file

@ -61,7 +61,7 @@ input[type="submit"] { margin-top:5px; }
.nodemargin { padding-top:120px; }
.focus { position:fixed; top:0; left:0; width:90%; z-index:10; display: block; min-width:533px; margin: 50px 50px 25px 50px; background: url('bg.png'); border-radius: 20px; color:#000; border:1px solid #000; }
.focus { position:fixed; top:0; left:0; width:90%; z-index:2; display: block; min-width:533px; margin: 50px 50px 25px 50px; background: url('bg.png'); border-radius: 20px; color:#000; border:1px solid #000; }
.focus h1 { margin-top:0; }
.focusleft, .focusmiddle, .focusright { display:block; float:left; }
.focusleft { width:20%; min-width:70px; text-align:center; }
@ -79,6 +79,34 @@ input[type="submit"] { margin-top:5px; }
.divider { margin: 20px 50px 20px 50px; border-bottom:2px solid #FFF; }
.empty { margin-left:50px; }
#menus { margin-right:15px; }
.accountWrap, .createWrap, .exploreWrap { display:block; position:relative; cursor: pointer;}
#menus .account, #menus .create, #menus .explore { display:none; position:absolute; right:0; z-index:12; width:auto; color: #67AF9F;
white-space: nowrap;
text-align: center;
font-size: 16px;
overflow: hidden;
padding: 3px 8px;
margin: 0;
border: 2px solid #AAA;
background: white;
border-radius: 6px;
-webkit-border-radius: 6px;
-moz-border-radius: 6px;
box-shadow: 0 2px rgba(0, 0, 0, 0.05), 0 -2px rgba(0, 0, 0, 0.05) inset;
-webkit-box-shadow: 0 2px rgba(0, 0, 0, 0.05), 0 -2px rgba(0, 0, 0, 0.05) inset;
-moz-box-shadow: 0 2px rgba(0, 0, 0, 0.05), 0 -2px rgba(0, 0, 0, 0.05) inset;
background: -moz-linear-gradient( center top, rgba(255, 255, 255, 0) 50%, rgba(0, 0, 0, 0.03) 0% ) repeat scroll 0 0 white;
background: -webkit-gradient( linear, 0% 0%, 0% 100%, from(white), to(rgba(0, 0, 0, 0.03)), color-stop(0.5, rgba(255, 255, 255, 0)), color-stop(0.5, rgba(0, 0, 0, 0.03)) ) repeat scroll 0 0 white;
border: 1px solid rgba(0, 0, 0, 0.2);
}
#menus ul li { margin:0; clear:both; float:none; list-style-type:none; display:block; padding:3px; text-align:center; border-top:1px solid #999; }
#menus ul li.first { border:none; }
#menus ul li a:hover { color:#2d6a5d; }
#menus ul li a { color: #67AF9F; display:block; }
/* --- styling the filter ---*/
.legend { position:fixed; bottom:10px; right:15px; z-index:12; display:block; width:auto; color: #67AF9F;

View file

@ -3,7 +3,21 @@ class MainController < ApplicationController
respond_to :html, :js, :json
def home
#homepage pick a random map and show it
def samplemap
@current = current_user
@maps = Map.visibleToUser(@current, nil)
@map = @maps.sample
@mapjson = @map.self_as_json(@current).html_safe
respond_to do |format|
format.html { respond_with(@map, @user) }
format.json { respond_with(@mapjson) }
end
end
def metamap
@current = current_user
@item = Item.visibleToUser(@current, nil).first
@ -23,5 +37,6 @@ class MainController < ApplicationController
format.html { respond_with(@maps) }
end
end
end

View file

@ -21,9 +21,11 @@ class SessionsController < ApplicationController
@session = Session.create(params[:session])
@user = User.new
@connor = User.find(555629996)
@map = Map.find(5)
respond_with(@user, @session, location: root_url) do |format|
respond_with(@user, @session, location: user_map_url(@connor,@map)) do |format|
end
end
@ -33,7 +35,7 @@ class SessionsController < ApplicationController
@session.destroy
respond_to do |format|
format.html { respond_with(@session, location: root_url) }
format.html { respond_with(@session, location: maps_url) }
end
end

View file

@ -1,5 +1,5 @@
<%= div_for item, class: item.item_category.name do %>
<% if @user %><%= link_to 'Delete', user_item_path(@user,item), :class => 'delete', :confirm => 'Delete this topic and all synapses linking to it?', :method => :delete, :remote => true%><% end %>
<% if item.user == user %><%= link_to 'Delete', user_item_path(@user,item), :class => 'delete', :confirm => 'Delete this topic and all synapses linking to it?', :method => :delete, :remote => true%><% end %>
<p class="type"><%= item.item_category.name %></p>
<%= image_tag item.item_category.icon, :class => 'icon', :size => '50x50' %>
<%= link_to item.name, user_item_path(@user, item), :class => 'title' %>

View file

@ -4,7 +4,7 @@
<%= image_tag @item.item_category.icon, :class => 'icon', :size => '50x50' %>
</div>
<div class="focusmiddle">
<h1 class="title"><%= @item.name %> <% if authenticated? %><%= link_to "[edit]", edit_user_item_path(@user, @item) %><% end %></h1>
<h1 class="title"><%= @item.name %> <% if @item.permission == "commons" || @item.user == @user %><%= link_to "[edit]", edit_user_item_path(@user, @item) %><% end %></h1>
<div class="desc">
<p><%= @item.desc %></p>
</div>

View file

@ -49,29 +49,45 @@
<%= content_tag :div, class: authenticated? ? "main authenticated" : "main unauthenticated" do %>
<div class="headertop">
<h1 id="mainTitle"><%= link_to "metamaps", root_path %></h1>&nbsp;beta
<h1 id="mainTitle"><%= link_to "metamaps", root_url %></h1>&nbsp;beta
<% unless authenticated? %>
<ul>
<li><%= link_to "Login", new_session_path, id: "Login" %></li>
<li>|</li>
<li><%= link_to "Maps", allmaps_path %></li>
<li>|</li>
<li><%= link_to "All", metamap_path %></li>
</ul>
<% end %>
<% if authenticated? %>
<ul>
<li><%= link_to "Logout", session_path, method: 'delete', id: "Login" %></li>
<li><%= link_to "Account", edit_user_url(user) %></li>
<li><%= link_to "My Maps", user_maps_url(user) %></li>
<li><%= link_to "My Synapses", user_synapses_url(user) %></li>
<li><%= link_to "My Topics", user_items_url(user) %></li>
<ul id="menus">
<li class="accountWrap">
<p id="account">Account</p>
<ul class="account">
<li class="first"><%= link_to "My Topics", user_items_url(user) %></li>
<li><%= link_to "My Synapses", user_synapses_url(user) %></li>
<li><%= link_to "My Maps", user_maps_url(user) %></li>
<li><%= link_to "Settings", edit_user_url(user) %></li>
<li class="last"><%= link_to "Logout", session_path, method: 'delete', id: "Login" %></li>
</ul>
</li>
<li>|</li>
<li><%= link_to "Add Map", new_user_map_path(user), id: "newmap" %></li>
<li class="createWrap">
<p id="create">Create</p>
<ul class="create">
<li class="first"><%= link_to "Add Topic", new_user_item_path(user), id: "newtopic" %></li>
<li><%= link_to "Add Synapse", new_user_synapse_path(user), id: "newsynapse" %></li>
<li class="last"><%= link_to "Add Map", new_user_map_path(user), id: "newmap" %></li>
</ul>
</li>
<li>|</li>
<li><%= link_to "Add Synapse", new_user_synapse_path(user), id: "newsynapse" %></li>
<li>|</li>
<li><%= link_to "Add Topic", new_user_item_path(user), id: "newtopic" %></li>
<li>|</li>
<li><%= link_to "Maps", allmaps_path %></li>
<li class="exploreWrap">
<p id="explore">Explore</p>
<ul class="explore">
<li class="first"><%= link_to "Maps", allmaps_path %></li>
<li class="last"><%= link_to "Metamap", metamap_path %></li>
</ul>
</li>
</ul>
<% end %>
</div>

View file

@ -0,0 +1,25 @@
<% unless @item.nil? %>
<div class="home" id="container">
<div id="center-container">
<div id="infovis"></div>
</div>
<div id="showcard">
</div>
</div>
<div class="clearfloat"></div>
<script>
json = <%= @alljson %>;
$(document).ready(function() {
initFD();
});
</script>
<% end %>
<% if @item.nil? %>
<p><br>Shucks, there is nothing in metamaps.<p>
<% end %>
<% if authenticated? %>
<%= render :partial => 'items/new' %>
<%= render :partial => 'synapses/new' %>
<% end %>

View file

@ -0,0 +1,34 @@
<div class="focus">
<div class="focusleft">
<p># of Topics: <%= @map.items.count %></p>
<p># of Synapses: <%= @map.synapses.count %></p>
</div>
<div class="focusmiddle">
<h1 class="title"><%= @map.name %></h1>
<div class="desc">
<p><%= @map.desc %></p>
</div>
</div>
<div class="focusright">
<div class="link"><p>Permissions:<%= @map.permission %></p></div>
</div>
</div>
<div class="clearfloat nodemargin"></div>
<div class="maps" id="container">
<div id="center-container">
<div id="infovis"></div>
</div>
<div id="showcard">
</div>
</div>
<div class="clearfloat"></div>
<script>
json = <%= @mapjson %>;
if (json.length > 0) {
$(document).ready(function() {
initFD();
});
}
</script>

View file

@ -1,5 +1,5 @@
<%= div_for map do %>
<% if authenticated? %><%= link_to 'Delete', user_map_path(map.user,map), :class => 'delete', :confirm => 'Delete this map (nodes and synapses will remain)?', :method => :delete %><% end %>
<% if map.user == user %><%= link_to 'Delete', user_map_path(map.user,map), :class => 'delete', :confirm => 'Delete this map (nodes and synapses will remain)?', :method => :delete, :remote => true %><% end %>
<%= link_to map.name, user_map_path(map.user, map), :class => 'title' %>
<div class="desc"><p><%= map.desc %></p><p># of Topics: <%= map.items.count %></p><p># of Synapses: <%= map.synapses.count %></p></div>
<div class="link"><p>Permissions:<%= map.permission %></p></div>

View file

@ -1,21 +1,21 @@
<div class="anypage">
<%= form_for Synapse.new, url: user_synapses_url(user), remote: true do |form| %>
<button id="closenewsynapse" onclick="$('#new_synapse').fadeOut('fast'); $('#new_synapse')[0].reset(); return false;">close</button>
<h3>Add Synapse Between Topics</h3>
<%= hidden_field_tag(:category, "Item") %>
<% if Item.all.count > 0 %>
<label for="node1_id">Choose First Item</label>
<%= select_tag :node1_id, options_from_collection_for_select(Item.order("name ASC").all, "id", "name") %>
<% end %>
<label for="item_desc">Describe The Connection</label>
<%= form.text_field :desc, class: "description" %>
<% if Item.all.count > 0 %>
<label for="node2_id">Choose Second Item</label>
<%= select_tag :node2_id, options_from_collection_for_select(Item.order("name ASC").all, "id", "name") %>
<% end %>
<label for="synapse_permission">Permission</label>
<%= form.select(:permission, options_for_select(['commons', 'public', 'private'])) %>
<%= form.hidden_field :map, :value => @map.id %>
<%= form.submit "Add Synapse", class: "add" %>
<% end %>
<div class="anypage">
<%= form_for Synapse.new, url: user_synapses_url(user), remote: true do |form| %>
<button id="closenewsynapse" onclick="$('#new_synapse').fadeOut('fast'); $('#new_synapse')[0].reset(); return false;">close</button>
<h3>Add Synapse Between Topics</h3>
<%= hidden_field_tag(:category, "Item") %>
<% if Item.visibleToUser(user, nil).count > 0 %>
<label for="node1_id">Choose First Item</label>
<%= select_tag :node1_id, options_from_collection_for_select(Item.order("name ASC").visibleToUser(user, nil), "id", "name") %>
<% end %>
<label for="item_desc">Describe The Connection</label>
<%= form.text_field :desc, class: "description" %>
<% if Item.visibleToUser(user, nil).count > 0 %>
<label for="node2_id">Choose Second Item</label>
<%= select_tag :node2_id, options_from_collection_for_select(Item.order("name ASC").visibleToUser(user, nil), "id", "name") %>
<% end %>
<label for="synapse_permission">Permission</label>
<%= form.select(:permission, options_for_select(['commons', 'public', 'private'])) %>
<%= form.hidden_field :map, :value => @map.id %>
<%= form.submit "Add Synapse", class: "add" %>
<% end %>
</div>

View file

@ -0,0 +1 @@
$('#<%= dom_id(@item) %>').fadeOut('slow');

View file

@ -4,7 +4,7 @@
<p># of Synapses: <%= @map.synapses.count %></p>
</div>
<div class="focusmiddle">
<h1 class="title"><%= @map.name %> <% if authenticated? %><%= link_to "[edit]", edit_user_map_path(@user, @map) %><% end %></h1>
<h1 class="title"><%= @map.name %> <% if (@map.permission == "commons" && @user != nil) || @map.user == @user %><%= link_to "[edit]", edit_user_map_path(@user, @map) %><% end %></h1>
<div class="desc">
<p><%= @map.desc %></p>
</div>

View file

@ -1,20 +1,20 @@
<div class="anypage">
<%= form_for Synapse.new, url: user_synapses_url(user), remote: true do |form| %>
<button id="closenewsynapse" onclick="$('#new_synapse').fadeOut('fast'); $('#new_synapse')[0].reset(); return false;">close</button>
<h3>Add Synapse Between Topics</h3>
<%= hidden_field_tag(:category, "Item") %>
<% if Item.all.count > 0 %>
<label for="node1_id">Choose First Item</label>
<%= select_tag :node1_id, options_from_collection_for_select(Item.order("name ASC").all, "id", "name") %>
<% end %>
<label for="item_desc">Describe The Connection</label>
<%= form.text_field :desc, class: "description" %>
<% if Item.all.count > 0 %>
<label for="node2_id">Choose Second Item</label>
<%= select_tag :node2_id, options_from_collection_for_select(Item.order("name ASC").all, "id", "name") %>
<% end %>
<label for="synapse_permission">Permission</label>
<%= form.select(:permission, options_for_select(['commons', 'public', 'private'])) %>
<%= form.submit "Add Synapse", class: "add" %>
<% end %>
<div class="anypage">
<%= form_for Synapse.new, url: user_synapses_url(user), remote: true do |form| %>
<button id="closenewsynapse" onclick="$('#new_synapse').fadeOut('fast'); $('#new_synapse')[0].reset(); return false;">close</button>
<h3>Add Synapse Between Topics</h3>
<%= hidden_field_tag(:category, "Item") %>
<% if Item.visibleToUser(user, nil).count > 0 %>
<label for="node1_id">Choose First Item</label>
<%= select_tag :node1_id, options_from_collection_for_select(Item.order("name ASC").visibleToUser(user, nil), "id", "name") %>
<% end %>
<label for="item_desc">Describe The Connection</label>
<%= form.text_field :desc, class: "description" %>
<% if Item.visibleToUser(user, nil).count > 0 %>
<label for="node2_id">Choose Second Item</label>
<%= select_tag :node2_id, options_from_collection_for_select(Item.order("name ASC").visibleToUser(user, nil), "id", "name") %>
<% end %>
<label for="synapse_permission">Permission</label>
<%= form.select(:permission, options_for_select(['commons', 'public', 'private'])) %>
<%= form.submit "Add Synapse", class: "add" %>
<% end %>
</div>

View file

@ -1,19 +1,19 @@
<div class="newsynapses">
<%= form_for @synapse, url: user_synapses_url do |form| %>
<h3>Add Synapse Between Topics</h3>
<%= hidden_field_tag(:category, "Item") %>
<% if Item.all.count > 0 %>
<label for="node1_id">Choose First Item</label>
<%= select_tag :node1_id, options_from_collection_for_select(Item.order("name ASC").all, "id", "name") %>
<% end %>
<label for="item_desc">Describe The Connection</label>
<%= form.text_field :desc, class: "description" %>
<% if Item.all.count > 0 %>
<label for="node2_id">Choose Second Item</label>
<%= select_tag :node2_id, options_from_collection_for_select(Item.order("name ASC").all, "id", "name") %>
<% end %>
<label for="synapse_permission">Permission</label>
<%= form.select(:permission, options_for_select(['commons', 'public', 'private'])) %>
<%= form.submit "Add Synapse", class: "add" %>
<% end %>
<div class="newsynapses">
<%= form_for @synapse, url: user_synapses_url do |form| %>
<h3>Add Synapse Between Topics</h3>
<%= hidden_field_tag(:category, "Item") %>
<% if Item.visibleToUser(user, nil).count > 0 %>
<label for="node1_id">Choose First Item</label>
<%= select_tag :node1_id, options_from_collection_for_select(Item.order("name ASC").visibleToUser(user, nil), "id", "name") %>
<% end %>
<label for="item_desc">Describe The Connection</label>
<%= form.text_field :desc, class: "description" %>
<% if Item.visibleToUser(user, nil).count > 0 %>
<label for="node2_id">Choose Second Item</label>
<%= select_tag :node2_id, options_from_collection_for_select(Item.order("name ASC").visibleToUser(user, nil), "id", "name") %>
<% end %>
<label for="synapse_permission">Permission</label>
<%= form.select(:permission, options_for_select(['commons', 'public', 'private'])) %>
<%= form.submit "Add Synapse", class: "add" %>
<% end %>
</div>

View file

@ -1,7 +1,8 @@
ISSAD::Application.routes.draw do
root to: 'main#home', via: :get
root to: 'main#samplemap', via: :get
match 'metamap', to: 'main#metamap', via: :get, as: :metamap
match 'maps', to: 'main#allmaps', via: :get, as: :allmaps
resource :session