Merge branch 'devel'

This commit is contained in:
Devin Howard 2012-12-15 19:48:25 -05:00
commit e0858f5b39
6 changed files with 52 additions and 36 deletions

View file

@ -129,6 +129,7 @@ function graphSettings(type) {
// add some events to the label
nameContainer.onmouseover = function(){
if (node.id == 0) return;
$('.showcard').css('display','none');
$('.name').css('display','block');
$('.name.item_' + node.id).css('display','none');
@ -328,7 +329,7 @@ function graphSettings(type) {
// defining custom node type
var nodeSettings = {
var nodeSettings = {
'customNode': {
'render': function (node, canvas) {
var pos = node.pos.getc(true),
@ -427,20 +428,25 @@ function selectNodeOnClickHandler(node) {
//for the canvasDoubleClickHandler function
var canvasDoubleClickHandlerObject = new Object();
canvasDoubleClickHandlerObject.stored_timestamp = 0;
canvasDoubleClickHandlerObject.storedTime = 0;
function canvasDoubleClickHandler(e) {
var TOLERANCE = 1000; //1 second
console.log(e);
var TOLERANCE = 300; //0.3 seconds
//grab the location and timestamp of the click
var stored_timestamp = canvasDoubleClickHandlerObject.stored_timestamp;
var now = Date.now(); //not compatible with IE8 FYI
//grab the location and timestamp of the click
var storedTime = canvasDoubleClickHandlerObject.storedTime;
var now = Date.now(); //not compatible with IE8 FYI
if (now - stored_timestamp < TOLERANCE) {
//pop up node creation :)
$('#new_item').fadeIn('fast');
//NOTE: we have e.x, e.y so use them!!
} else {
canvasDoubleClickHandlerObject.stored_timestamp = now;
}
if (now - storedTime < TOLERANCE) {
//pop up node creation :)
document.getElementById('new_item').style.left = e.x + "px";
document.getElementById('new_item').style.top = e.y + "px";
$('#item_x').val(e.x);
$('#item_y').val(e.y);
$('#new_item').fadeIn('fast');
$('#item_name').focus();
} else {
canvasDoubleClickHandlerObject.storedTime = now;
}
}//canvasDoubleClickHandler

View file

@ -33,14 +33,21 @@ h2 {display:block; text-align:center; font-family: "vinyl",sans-serif; backgroun
a {color:#2d6a5d; text-decoration:none;}
.clearfloat {clear:both;}
.new_session, .new_user, .new_item, .new_synapse, .new_map, .edit_user, .edit_item, .edit_synapse, .edit_map, .invite { display: block; width: 350px; position:absolute; left:50%; top:0; margin:200px 0 0 -195px; background: url('bg.png'); padding: 20px; border-radius: 15px; color: #000; border:2px solid #000; }
.new_session, .new_user, .new_synapse, .new_map, .edit_user, .edit_item, .edit_synapse, .edit_map, .invite { display: block; width: 350px; position:absolute; left:50%; top:0; margin:200px 0 0 -195px; background: url('bg.png'); padding: 20px; border-radius: 15px; color: #000; border:2px solid #000; }
.invite p { margin:10px 0; }
.invite strong { text-align:center; display:block; color:#67AF9F; }
.anypage .new_item, .anypage .new_synapse { display: none; position:absolute; left:50%; top:0; margin:200px 0 0 -195px; border:2px solid #000; }
.anypage .new_synapse { display: none; position:absolute; left:50%; top:0; margin:200px 0 0 -195px; border:2px solid #000; }
#closenewtopic, #closenewsynapse { position:absolute; top: 3px; right:3px; }
.anypage .new_item {
display: none;
position: absolute;
background: url('bg.png');
border: 2px solid #000;
}
label, select, input, textarea { display:block; }

View file

@ -63,14 +63,20 @@ class ItemsController < ApplicationController
else
@item = Item.new()
@item.name = params[:item][:name]
@item.desc = params[:item][:desc]
@item.link = params[:item][:link]
@item.permission = params[:item][:permission]
@item.item_category = ItemCategory.find(params[:category])
@item.desc = ""
@item.link = ""
@item.permission = 'commons'
@item.item_category = ItemCategory.all.first
#@item.item_category = ItemCategory.find(params[:category])
@item.user = @user
@item.save
end
@position = Hash.new()
@position.x = params[:item][:x]
@position.y = params[:item][:y]
@position.save
@mapping = Mapping.new()
if params[:item][:map]
@ -85,7 +91,7 @@ class ItemsController < ApplicationController
respond_to do |format|
format.html { respond_with(@user, location: user_item_url(@user, @item)) }
format.js { respond_with(@item, @mapping) }
format.js { respond_with(@item, @mapping, @position) }
end
end

View file

@ -1,17 +1,7 @@
<div class="anypage">
<%= form_for Item.new, url: user_items_url(user), remote: true do |form| %>
<button id="closenewtopic" onclick="$('#new_item').fadeOut('fast'); $('#new_item')[0].reset(); return false;">close</button>
<h3>Add Topic</h3>
<label for="category">Category</label>
<%= select_tag "category", options_from_collection_for_select(ItemCategory.order("name ASC").all, "id", "name") %>
<label for="item_name">Title</label>
<%= form.text_field :name %>
<label for="item_desc">Description</label>
<%= form.text_area :desc, class: "description", :rows => 5 %>
<label for="item_link">Link</label>
<%= form.text_field :link, class: "link" %>
<label for="item_permission">Permission</label>
<%= form.select(:permission, options_for_select(['commons', 'public', 'private'])) %>
<%= form.submit "Add Topic", class: "addTopic", id: "addTopic" %>
<%= form.hidden_field :x, :value => 0 %>
<%= form.hidden_field :y, :value => 0 %>
<% end %>
</div>
</div>

View file

@ -3,7 +3,8 @@ $('#new_item')[0].reset();
if(viewMode == "graph") {
var newnode = <%= @item.self_as_json.html_safe %>;
var x = <%= position.x %>;
var y = <%= position.y %>;
if (Mconsole != null) {
Mconsole.graph.addNode(newnode);
@ -44,4 +45,4 @@ else {
alert('wrong!');
$('#cards').prepend('<%= escape_javascript(render(@item)) %>');
$(".scroll").mCustomScrollbar();
}
}

View file

@ -2,6 +2,12 @@
<html>
<head>
<title>Metamaps</title>
<% if authenticated? %>
<script type="text/javascript">
var userid = "<%= user.id %>";
var username = "<%= user.name %>";
</script>
<% end %>
<%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_include_tag "application" %>
<script type="text/javascript" src="//use.typekit.net/tki2nyo.js"></script>