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 55aa31f1..7f926de3 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; } @@ -155,4 +162,4 @@ margin: -0.75em 0 0; #mainTitle { float: left; } #mainTitle a { color:#FFF; font-family: "vinyl",sans-serif; font-style: italic; text-transform:uppercase; font-weight: 400; } -#beta { float:left; margin-left: 7px; } \ No newline at end of file +#beta { float:left; margin-left: 7px; } 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 @@
<%= form_for Item.new, url: user_items_url(user), remote: true do |form| %> - -

Add Topic

- - <%= select_tag "category", options_from_collection_for_select(ItemCategory.order("name ASC").all, "id", "name") %> - <%= form.text_field :name %> - - <%= form.text_area :desc, class: "description", :rows => 5 %> - - <%= form.text_field :link, class: "link" %> - - <%= 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 %> -
\ No newline at end of file + diff --git a/app/views/items/create.js.erb b/app/views/items/create.js.erb index c0e95bdd..6979ded2 100644 --- a/app/views/items/create.js.erb +++ b/app/views/items/create.js.erb @@ -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(); -} \ No newline at end of file +} diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 08abb8c2..7d9b50c0 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -2,6 +2,12 @@ Metamaps + <% if authenticated? %> + + <% end %> <%= stylesheet_link_tag "application", :media => "all" %> <%= javascript_include_tag "application" %>