diff --git a/app/assets/javascripts/Jit/graphsettings.js b/app/assets/javascripts/Jit/graphsettings.js index 0248841a..25f24fcf 100644 --- a/app/assets/javascripts/Jit/graphsettings.js +++ b/app/assets/javascripts/Jit/graphsettings.js @@ -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 diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 9d05327d..b9e8ffc3 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -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; } diff --git a/app/controllers/items_controller.rb b/app/controllers/items_controller.rb index e79c39f3..fed86c2e 100644 --- a/app/controllers/items_controller.rb +++ b/app/controllers/items_controller.rb @@ -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 diff --git a/app/views/items/_new.html.erb b/app/views/items/_new.html.erb index f3ab866d..fd0d38eb 100644 --- a/app/views/items/_new.html.erb +++ b/app/views/items/_new.html.erb @@ -1,17 +1,7 @@