fixed bugs for adding new topic on any page

This commit is contained in:
Connor Turland 2012-10-21 14:32:17 -04:00
parent ded6ffe7e5
commit 23f7db2e1c
9 changed files with 37 additions and 20 deletions

View file

@ -21,12 +21,13 @@
$('.nodemargin').css('padding-top',$('.focus').css('height'));
$('#newtopic').click(function(event){
obj = $('#new_item');
obj = document.getElementById('new_item');
if (obj != null) {
$('#new_item').fadeIn('fast');
return false;
event.preventDefault();
}
});
});

View file

@ -19,7 +19,7 @@ html, body, div, h1, h2, h3, h4, h5, h6, ul, ol, dl, li, dt, dd, p, blockquote,
pre, form, fieldset, table, th, td, legend { margin: 0; padding: 0; }
img {border:0; padding:0; margin:0; display:block; text-indent:-9999px;}
html, body, .main, .wrapper, .home { height: 100%; }
html, body, .main, .wrapper, #container { height: 100%; }
html { }
body { background:#031924 url(background2.jpg) repeat 0 0; font-family:Arial, Helvetica, sans-serif; background-attachment:fixed; color:#FFF; }
@ -30,9 +30,10 @@ h2 {display:block; text-align:center; background: #333; font-size:24px;}
a {color:#2d6a5d; text-decoration:none;}
.clearfloat {clear:both;}
.new_session, .new_synapse, .edit_item, .edit_synapse { display: block; width: 350px; margin: 0 auto; background: #D1D1D1; padding: 20px; border-radius: 15px; color: #000; }
.new_session, .new_user, .new_item, .new_synapse, .edit_item, .edit_synapse { display: block; width: 350px; margin: 0 auto; background: #D1D1D1; padding: 20px; border-radius: 15px; color: #000; border:2px solid #000; }
.new_item { display: none; position:absolute; left:50%; top:50%; margin:-175px 0 0 -195px; width: 350px; background: #D1D1D1; padding: 20px; border-radius: 15px; color: #000; border:2px solid #000; }
.anypage .new_item { display: none; position:absolute; left:50%; top:50%; margin:-175px 0 0 -195px; border:2px solid #000; }
#closenewtopic { position:absolute; top: 3px; right:3px; }
label, select, input, textarea { display:block; }
@ -46,13 +47,14 @@ input[type="submit"] { margin-top:5px; }
.contentarea ul {margin:0 0 0 1em; }
.contentarea ol {margin:0 0 0 1.3em; }
.main { overflow:hidden; }
.main { overflow-x:hidden; }
.headertop { display:block; position:fixed; top:0; left:0; z-index:10; height:38px; width:100%; min-width:622px; background: url(topbg2.png) repeat-x top left; }
#mainTitle { float: left; }
#mainTitle a { color:#FFF; }
.headertop ul { display:block; float: right; }
.headertop ul li {display:block; float:right; margin:10px 5px 0 5px; }
.headertop ul li a { color:#FFF; }
.wrapper {display:block; height:100%; margin:50px 0; }

View file

@ -34,8 +34,6 @@ belongs_to :item_category
#build a json object of everything connected to a specified node
def map_as_json
Jbuilder.encode do |json|
@single = Array.new
@single.push(self)
@items = network(self,nil)
json.array!(@items) do |item|

View file

@ -1,4 +1,6 @@
<div class="anypage">
<%= form_for Item.new, url: items_path, remote: true do |form| %>
<button id="closenewtopic" onclick="$('#new_item').fadeOut('fast'); $('#new_item')[0].reset(); return false;">close</button>
<h3>Add Item</h3>
<label for="category">Category</label>
<%= select_tag "category", options_from_collection_for_select(ItemCategory.all, "id", "name") %>
@ -9,4 +11,5 @@
<label for="item_link">Link</label>
<%= form.text_field :link, class: "link" %>
<%= form.submit "Add Item", class: "addItem", id: "addItem" %>
<% end %>
<% end %>
</div>

View file

@ -1,11 +1,22 @@
$('#new_item').fadeOut('fast');
$('#new_item')[0].reset()
var newnode = <%= @item.self_as_json.html_safe %>;
fd.graph.addNode(newnode);
var temp = fd.graph.getNode('<%= @item.id %>');
temp.setData('dim', 1, 'start');
temp.setData('dim', 40, 'end');
fd.fx.animate({
// if there's a map, add the node to that, if its in card view add card
obj = document.getElementById('container');
if (obj != null) {
var newnode = <%= @item.self_as_json.html_safe %>;
fd.graph.addNode(newnode);
var temp = fd.graph.getNode('<%= @item.id %>');
temp.setData('dim', 1, 'start');
temp.setData('dim', 40, 'end');
fd.fx.animate({
modes: ['node-property:dim'],
duration: 400
});
});
}
else {
$('#cards').prepend('<%= escape_javascript(render(@item)) %>');
}

View file

@ -1,6 +1,6 @@
<h1>All Topics</h1>
<div class="items" id="items">
<div class="items" id="cards">
<% @items.each do |item| %>
<%= render item %>
<% end %>

View file

@ -1,3 +1,4 @@
<div class="nothidden">
<%= form_for @item || Item.new, url: items_path do |form| %>
<h3>Add Item</h3>
<label for="category">Category</label>
@ -9,4 +10,5 @@
<label for="item_link">Link</label>
<%= form.text_field :link, class: "link" %>
<%= form.submit "Add Item", class: "add" %>
<% end %>
<% end %>
</div>

View file

@ -1,5 +1,5 @@
<% unless @item.nil? %>
<div class="home" id="home">
<div class="home" id="container">
<div id="center-container">
<div id="infovis"></div>
</div>

View file

@ -1,4 +1,4 @@
<div class="everything" id="everything">
<div class="everything" id="cards">
<% @all.each do |object| %>
<%= render object %>
<% end %>