fixed bugs for adding new topic on any page
This commit is contained in:
parent
ded6ffe7e5
commit
23f7db2e1c
9 changed files with 37 additions and 20 deletions
|
@ -21,12 +21,13 @@
|
||||||
$('.nodemargin').css('padding-top',$('.focus').css('height'));
|
$('.nodemargin').css('padding-top',$('.focus').css('height'));
|
||||||
|
|
||||||
$('#newtopic').click(function(event){
|
$('#newtopic').click(function(event){
|
||||||
obj = $('#new_item');
|
obj = document.getElementById('new_item');
|
||||||
if (obj != null) {
|
if (obj != null) {
|
||||||
$('#new_item').fadeIn('fast');
|
$('#new_item').fadeIn('fast');
|
||||||
return false;
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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; }
|
pre, form, fieldset, table, th, td, legend { margin: 0; padding: 0; }
|
||||||
img {border:0; padding:0; margin:0; display:block; text-indent:-9999px;}
|
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 { }
|
html { }
|
||||||
body { background:#031924 url(background2.jpg) repeat 0 0; font-family:Arial, Helvetica, sans-serif; background-attachment:fixed; color:#FFF; }
|
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;}
|
a {color:#2d6a5d; text-decoration:none;}
|
||||||
.clearfloat {clear:both;}
|
.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; }
|
label, select, input, textarea { display:block; }
|
||||||
|
@ -46,13 +47,14 @@ input[type="submit"] { margin-top:5px; }
|
||||||
.contentarea ul {margin:0 0 0 1em; }
|
.contentarea ul {margin:0 0 0 1em; }
|
||||||
.contentarea ol {margin:0 0 0 1.3em; }
|
.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; }
|
.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 { float: left; }
|
||||||
#mainTitle a { color:#FFF; }
|
#mainTitle a { color:#FFF; }
|
||||||
.headertop ul { display:block; float: right; }
|
.headertop ul { display:block; float: right; }
|
||||||
.headertop ul li {display:block; float:right; margin:10px 5px 0 5px; }
|
.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; }
|
.wrapper {display:block; height:100%; margin:50px 0; }
|
||||||
|
|
||||||
|
|
|
@ -34,8 +34,6 @@ belongs_to :item_category
|
||||||
#build a json object of everything connected to a specified node
|
#build a json object of everything connected to a specified node
|
||||||
def map_as_json
|
def map_as_json
|
||||||
Jbuilder.encode do |json|
|
Jbuilder.encode do |json|
|
||||||
@single = Array.new
|
|
||||||
@single.push(self)
|
|
||||||
@items = network(self,nil)
|
@items = network(self,nil)
|
||||||
|
|
||||||
json.array!(@items) do |item|
|
json.array!(@items) do |item|
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
|
<div class="anypage">
|
||||||
<%= form_for Item.new, url: items_path, remote: true do |form| %>
|
<%= 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>
|
<h3>Add Item</h3>
|
||||||
<label for="category">Category</label>
|
<label for="category">Category</label>
|
||||||
<%= select_tag "category", options_from_collection_for_select(ItemCategory.all, "id", "name") %>
|
<%= select_tag "category", options_from_collection_for_select(ItemCategory.all, "id", "name") %>
|
||||||
|
@ -9,4 +11,5 @@
|
||||||
<label for="item_link">Link</label>
|
<label for="item_link">Link</label>
|
||||||
<%= form.text_field :link, class: "link" %>
|
<%= form.text_field :link, class: "link" %>
|
||||||
<%= form.submit "Add Item", class: "addItem", id: "addItem" %>
|
<%= form.submit "Add Item", class: "addItem", id: "addItem" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
</div>
|
|
@ -1,11 +1,22 @@
|
||||||
$('#new_item').fadeOut('fast');
|
$('#new_item').fadeOut('fast');
|
||||||
$('#new_item')[0].reset()
|
$('#new_item')[0].reset()
|
||||||
var newnode = <%= @item.self_as_json.html_safe %>;
|
|
||||||
fd.graph.addNode(newnode);
|
// if there's a map, add the node to that, if its in card view add card
|
||||||
var temp = fd.graph.getNode('<%= @item.id %>');
|
obj = document.getElementById('container');
|
||||||
temp.setData('dim', 1, 'start');
|
|
||||||
temp.setData('dim', 40, 'end');
|
|
||||||
fd.fx.animate({
|
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'],
|
modes: ['node-property:dim'],
|
||||||
duration: 400
|
duration: 400
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$('#cards').prepend('<%= escape_javascript(render(@item)) %>');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<h1>All Topics</h1>
|
<h1>All Topics</h1>
|
||||||
|
|
||||||
<div class="items" id="items">
|
<div class="items" id="cards">
|
||||||
<% @items.each do |item| %>
|
<% @items.each do |item| %>
|
||||||
<%= render item %>
|
<%= render item %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
<div class="nothidden">
|
||||||
<%= form_for @item || Item.new, url: items_path do |form| %>
|
<%= form_for @item || Item.new, url: items_path do |form| %>
|
||||||
<h3>Add Item</h3>
|
<h3>Add Item</h3>
|
||||||
<label for="category">Category</label>
|
<label for="category">Category</label>
|
||||||
|
@ -9,4 +10,5 @@
|
||||||
<label for="item_link">Link</label>
|
<label for="item_link">Link</label>
|
||||||
<%= form.text_field :link, class: "link" %>
|
<%= form.text_field :link, class: "link" %>
|
||||||
<%= form.submit "Add Item", class: "add" %>
|
<%= form.submit "Add Item", class: "add" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
</div>
|
|
@ -1,5 +1,5 @@
|
||||||
<% unless @item.nil? %>
|
<% unless @item.nil? %>
|
||||||
<div class="home" id="home">
|
<div class="home" id="container">
|
||||||
<div id="center-container">
|
<div id="center-container">
|
||||||
<div id="infovis"></div>
|
<div id="infovis"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<div class="everything" id="everything">
|
<div class="everything" id="cards">
|
||||||
<% @all.each do |object| %>
|
<% @all.each do |object| %>
|
||||||
<%= render object %>
|
<%= render object %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
Loading…
Reference in a new issue