From 9e7c6b0f026717e68701cda0e12e031c43bff047 Mon Sep 17 00:00:00 2001 From: Connor Turland Date: Sun, 28 Oct 2012 14:37:46 -0400 Subject: [PATCH] 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 --- .../Jit/ForceDirected/metamapFD.js | 2 +- app/assets/javascripts/application.js | 80 ++++++++++++++++--- app/assets/stylesheets/application.css | 30 ++++++- app/controllers/main_controller.rb | 17 +++- app/controllers/sessions_controller.rb | 8 +- app/views/items/_item.html.erb | 2 +- app/views/items/show.html.erb | 2 +- app/views/layouts/application.html.erb | 42 +++++++--- app/views/main/metamap.html.erb | 25 ++++++ app/views/main/samplemap.html.erb | 34 ++++++++ app/views/maps/_map.html.erb | 2 +- app/views/maps/_newsynapse.html.erb | 40 +++++----- app/views/maps/destroy.js.erb | 1 + app/views/maps/show.html.erb | 2 +- app/views/synapses/_new.html.erb | 38 ++++----- app/views/synapses/new.html.erb | 36 ++++----- config/routes.rb | 3 +- 17 files changed, 274 insertions(+), 90 deletions(-) create mode 100644 app/views/main/metamap.html.erb create mode 100644 app/views/main/samplemap.html.erb create mode 100644 app/views/maps/destroy.js.erb diff --git a/app/assets/javascripts/Jit/ForceDirected/metamapFD.js b/app/assets/javascripts/Jit/ForceDirected/metamapFD.js index d3b4bcb0..f944a5e2 100644 --- a/app/assets/javascripts/Jit/ForceDirected/metamapFD.js +++ b/app/assets/javascripts/Jit/ForceDirected/metamapFD.js @@ -222,7 +222,7 @@ function initFD(){ node.eachAdjacency(function(adj) { adj.setDataset('end', { lineWidth: 3, - color: '#36acfb' + color: '#FFF' }); }); } else { diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 48d26acf..8a410406 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -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; }); } } diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index cda002d1..f27cb8f4 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -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; diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb index 682b8e5e..a333b8f3 100644 --- a/app/controllers/main_controller.rb +++ b/app/controllers/main_controller.rb @@ -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 diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 67baa140..a431a13f 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -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 diff --git a/app/views/items/_item.html.erb b/app/views/items/_item.html.erb index 22035d19..169f4213 100644 --- a/app/views/items/_item.html.erb +++ b/app/views/items/_item.html.erb @@ -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 %>

<%= item.item_category.name %>

<%= image_tag item.item_category.icon, :class => 'icon', :size => '50x50' %> <%= link_to item.name, user_item_path(@user, item), :class => 'title' %> diff --git a/app/views/items/show.html.erb b/app/views/items/show.html.erb index eb13810b..e4e6eba1 100644 --- a/app/views/items/show.html.erb +++ b/app/views/items/show.html.erb @@ -4,7 +4,7 @@ <%= image_tag @item.item_category.icon, :class => 'icon', :size => '50x50' %>
-

<%= @item.name %> <% if authenticated? %><%= link_to "[edit]", edit_user_item_path(@user, @item) %><% end %>

+

<%= @item.name %> <% if @item.permission == "commons" || @item.user == @user %><%= link_to "[edit]", edit_user_item_path(@user, @item) %><% end %>

<%= @item.desc %>

diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index e28d7ece..3b71e812 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -49,29 +49,45 @@ <%= content_tag :div, class: authenticated? ? "main authenticated" : "main unauthenticated" do %>
-

<%= link_to "metamaps", root_path %>

 beta +

<%= link_to "metamaps", root_url %>

 beta <% unless authenticated? %>
  • <%= link_to "Login", new_session_path, id: "Login" %>
  • |
  • <%= link_to "Maps", allmaps_path %>
  • +
  • |
  • +
  • <%= link_to "All", metamap_path %>
<% end %> <% if authenticated? %> -
    -
  • <%= link_to "Logout", session_path, method: 'delete', id: "Login" %>
  • -
  • <%= link_to "Account", edit_user_url(user) %>
  • -
  • <%= link_to "My Maps", user_maps_url(user) %>
  • -
  • <%= link_to "My Synapses", user_synapses_url(user) %>
  • -
  • <%= link_to "My Topics", user_items_url(user) %>
  • + <% end %>
diff --git a/app/views/main/metamap.html.erb b/app/views/main/metamap.html.erb new file mode 100644 index 00000000..0f9e900c --- /dev/null +++ b/app/views/main/metamap.html.erb @@ -0,0 +1,25 @@ +<% unless @item.nil? %> +
+
+
+
+
+
+
+
+ +<% end %> +<% if @item.nil? %> +


Shucks, there is nothing in metamaps.

+<% end %> + +<% if authenticated? %> + <%= render :partial => 'items/new' %> + <%= render :partial => 'synapses/new' %> +<% end %> + diff --git a/app/views/main/samplemap.html.erb b/app/views/main/samplemap.html.erb new file mode 100644 index 00000000..d808b248 --- /dev/null +++ b/app/views/main/samplemap.html.erb @@ -0,0 +1,34 @@ +

+
+

# of Topics: <%= @map.items.count %>

+

# of Synapses: <%= @map.synapses.count %>

+
+
+

<%= @map.name %>

+
+

<%= @map.desc %>

+
+
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+ + \ No newline at end of file diff --git a/app/views/maps/_map.html.erb b/app/views/maps/_map.html.erb index 425115a0..8058a39c 100644 --- a/app/views/maps/_map.html.erb +++ b/app/views/maps/_map.html.erb @@ -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' %>

<%= map.desc %>

# of Topics: <%= map.items.count %>

# of Synapses: <%= map.synapses.count %>

diff --git a/app/views/maps/_newsynapse.html.erb b/app/views/maps/_newsynapse.html.erb index 11760702..9bce585d 100644 --- a/app/views/maps/_newsynapse.html.erb +++ b/app/views/maps/_newsynapse.html.erb @@ -1,21 +1,21 @@ -
- <%= form_for Synapse.new, url: user_synapses_url(user), remote: true do |form| %> - -

Add Synapse Between Topics

- <%= hidden_field_tag(:category, "Item") %> - <% if Item.all.count > 0 %> - - <%= select_tag :node1_id, options_from_collection_for_select(Item.order("name ASC").all, "id", "name") %> - <% end %> - - <%= form.text_field :desc, class: "description" %> - <% if Item.all.count > 0 %> - - <%= select_tag :node2_id, options_from_collection_for_select(Item.order("name ASC").all, "id", "name") %> - <% end %> - - <%= form.select(:permission, options_for_select(['commons', 'public', 'private'])) %> - <%= form.hidden_field :map, :value => @map.id %> - <%= form.submit "Add Synapse", class: "add" %> - <% end %> +
+ <%= form_for Synapse.new, url: user_synapses_url(user), remote: true do |form| %> + +

Add Synapse Between Topics

+ <%= hidden_field_tag(:category, "Item") %> + <% if Item.visibleToUser(user, nil).count > 0 %> + + <%= select_tag :node1_id, options_from_collection_for_select(Item.order("name ASC").visibleToUser(user, nil), "id", "name") %> + <% end %> + + <%= form.text_field :desc, class: "description" %> + <% if Item.visibleToUser(user, nil).count > 0 %> + + <%= select_tag :node2_id, options_from_collection_for_select(Item.order("name ASC").visibleToUser(user, nil), "id", "name") %> + <% end %> + + <%= form.select(:permission, options_for_select(['commons', 'public', 'private'])) %> + <%= form.hidden_field :map, :value => @map.id %> + <%= form.submit "Add Synapse", class: "add" %> + <% end %>
\ No newline at end of file diff --git a/app/views/maps/destroy.js.erb b/app/views/maps/destroy.js.erb new file mode 100644 index 00000000..fa847ae6 --- /dev/null +++ b/app/views/maps/destroy.js.erb @@ -0,0 +1 @@ +$('#<%= dom_id(@item) %>').fadeOut('slow'); \ No newline at end of file diff --git a/app/views/maps/show.html.erb b/app/views/maps/show.html.erb index 848fb6d3..36a78b48 100644 --- a/app/views/maps/show.html.erb +++ b/app/views/maps/show.html.erb @@ -4,7 +4,7 @@

# of Synapses: <%= @map.synapses.count %>

-

<%= @map.name %> <% if authenticated? %><%= link_to "[edit]", edit_user_map_path(@user, @map) %><% end %>

+

<%= @map.name %> <% if (@map.permission == "commons" && @user != nil) || @map.user == @user %><%= link_to "[edit]", edit_user_map_path(@user, @map) %><% end %>

<%= @map.desc %>

diff --git a/app/views/synapses/_new.html.erb b/app/views/synapses/_new.html.erb index 712f82f4..ff76f351 100644 --- a/app/views/synapses/_new.html.erb +++ b/app/views/synapses/_new.html.erb @@ -1,20 +1,20 @@ -
- <%= form_for Synapse.new, url: user_synapses_url(user), remote: true do |form| %> - -

Add Synapse Between Topics

- <%= hidden_field_tag(:category, "Item") %> - <% if Item.all.count > 0 %> - - <%= select_tag :node1_id, options_from_collection_for_select(Item.order("name ASC").all, "id", "name") %> - <% end %> - - <%= form.text_field :desc, class: "description" %> - <% if Item.all.count > 0 %> - - <%= select_tag :node2_id, options_from_collection_for_select(Item.order("name ASC").all, "id", "name") %> - <% end %> - - <%= form.select(:permission, options_for_select(['commons', 'public', 'private'])) %> - <%= form.submit "Add Synapse", class: "add" %> - <% end %> +
+ <%= form_for Synapse.new, url: user_synapses_url(user), remote: true do |form| %> + +

Add Synapse Between Topics

+ <%= hidden_field_tag(:category, "Item") %> + <% if Item.visibleToUser(user, nil).count > 0 %> + + <%= select_tag :node1_id, options_from_collection_for_select(Item.order("name ASC").visibleToUser(user, nil), "id", "name") %> + <% end %> + + <%= form.text_field :desc, class: "description" %> + <% if Item.visibleToUser(user, nil).count > 0 %> + + <%= select_tag :node2_id, options_from_collection_for_select(Item.order("name ASC").visibleToUser(user, nil), "id", "name") %> + <% end %> + + <%= form.select(:permission, options_for_select(['commons', 'public', 'private'])) %> + <%= form.submit "Add Synapse", class: "add" %> + <% end %>
\ No newline at end of file diff --git a/app/views/synapses/new.html.erb b/app/views/synapses/new.html.erb index 1cb598e4..72db8593 100644 --- a/app/views/synapses/new.html.erb +++ b/app/views/synapses/new.html.erb @@ -1,19 +1,19 @@ -
- <%= form_for @synapse, url: user_synapses_url do |form| %> -

Add Synapse Between Topics

- <%= hidden_field_tag(:category, "Item") %> - <% if Item.all.count > 0 %> - - <%= select_tag :node1_id, options_from_collection_for_select(Item.order("name ASC").all, "id", "name") %> - <% end %> - - <%= form.text_field :desc, class: "description" %> - <% if Item.all.count > 0 %> - - <%= select_tag :node2_id, options_from_collection_for_select(Item.order("name ASC").all, "id", "name") %> - <% end %> - - <%= form.select(:permission, options_for_select(['commons', 'public', 'private'])) %> - <%= form.submit "Add Synapse", class: "add" %> - <% end %> +
+ <%= form_for @synapse, url: user_synapses_url do |form| %> +

Add Synapse Between Topics

+ <%= hidden_field_tag(:category, "Item") %> + <% if Item.visibleToUser(user, nil).count > 0 %> + + <%= select_tag :node1_id, options_from_collection_for_select(Item.order("name ASC").visibleToUser(user, nil), "id", "name") %> + <% end %> + + <%= form.text_field :desc, class: "description" %> + <% if Item.visibleToUser(user, nil).count > 0 %> + + <%= select_tag :node2_id, options_from_collection_for_select(Item.order("name ASC").visibleToUser(user, nil), "id", "name") %> + <% end %> + + <%= form.select(:permission, options_for_select(['commons', 'public', 'private'])) %> + <%= form.submit "Add Synapse", class: "add" %> + <% end %>
\ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index ee5f2e24..dcf1019b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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