diff --git a/app/assets/javascripts/Jit/filters.js b/app/assets/javascripts/Jit/filters.js index 271361ad..f1b09eec 100644 --- a/app/assets/javascripts/Jit/filters.js +++ b/app/assets/javascripts/Jit/filters.js @@ -93,10 +93,12 @@ var findMappers = ['name', 'topic (by name)', 'map (by name)', 'synapse (by topi function hideAll(duration) { if (duration == null) duration = 500; Mconsole.graph.eachNode( function (n) { - n.setData('alpha', 0.4, 'end'); - n.eachAdjacency(function(adj) { - adj.setData('alpha', 0.4, 'end'); - }); + if (!(n.getData('inCommons') || n.getData('onCanvas'))) { + n.setData('alpha', 0.4, 'end'); + n.eachAdjacency(function(adj) { + adj.setData('alpha', 0.4, 'end'); + }); + } }); Mconsole.fx.animate({ modes: ['node-property:alpha', @@ -109,7 +111,7 @@ function showAll(duration) { Mconsole.graph.eachNode( function (n) { n.setData('alpha', 1, 'end'); n.eachAdjacency(function(adj) { - adj.setData('alpha', 1, 'end'); + adj.setData('alpha', 1, 'end'); }); }); Mconsole.fx.animate({ @@ -163,10 +165,20 @@ function onCanvasSearch(name,mapID,mapperID) { function clearCanvas() { - Mconsole.graph.eachNode( function(n) { Mconsole.graph.removeNode(n.id); $('#'+n.id).remove(); }); + Mconsole.graph.eachNode( function(n) { Mconsole.graph.removeNode(n.id); Mconsole.labels.disposeLabel(n.id); }); Mconsole.plot(); } +function clearFoundData() { + Mconsole.graph.eachNode( function(n) { + if (n.getData('inCommons') === true) { + Mconsole.graph.removeNode(n.id); + Mconsole.labels.disposeLabel(n.id); + } + }); + Mconsole.plot(); +} + //// @@ -256,18 +268,20 @@ $(document).ready(function() { // only have the autocomplete enabled if they are searching in the commons if (firstVal == "checked" && secondVal == "checked"){ - $('#topic_by_name_input').autocomplete( "option", "disabled", false ); + //$('#topic_by_name_input').autocomplete( "option", "disabled", false ); + $('#topic_by_name_input').autocomplete( "option", "disabled", true ); } else if (firstVal == "checked"){ - showAll(); + setTimeout(function(){showAll();},0); $('#topic_by_name_input').autocomplete( "option", "disabled", true ); } else if (secondVal == "checked"){ - hideAll(); - $('#topic_by_name_input').autocomplete( "option", "disabled", false ); + //setTimeout(function(){hideAll();},0); + //$('#topic_by_name_input').autocomplete( "option", "disabled", false ); + $('#topic_by_name_input').autocomplete( "option", "disabled", true ); } else { - alert('Either select searching In the Commons, or On the Canvas to search'); + alert('You either need to have searching On Your Canvas or In the Commons enabled'); } }, stop: function (event, $elem) { @@ -278,20 +292,26 @@ $(document).ready(function() { var topicName = $('#topic_by_name_input').val(); // run a search on the canvas or in the commons or both if (firstVal == "checked" && secondVal == "checked"){ - onCanvasSearch(topicName,null,null); - // and run a search in the commons + setTimeout(function(){onCanvasSearch(topicName,null,null);},0); + $('#topicsByName').val(topicName); + $('#topicsByUser').val(""); + $('#topicsByMap').val(""); + $('#get_topics_form').submit(); } else if (firstVal == "checked"){ - onCanvasSearch(topicName,null,null); + setTimeout(function(){onCanvasSearch(topicName,null,null);},0); } else if (secondVal == "checked"){ - //run a search in the commons + $('#topicsByName').val(topicName); + $('#topicsByUser').val(""); + $('#topicsByMap').val(""); + $('#get_topics_form').submit(); } else { //do nothing } - if (topicName == "") showAll(); + if (topicName == "") { clearFoundData(); } }, delay: 2000 }); @@ -416,18 +436,20 @@ $(document).ready(function() { // only have the autocomplete enabled if they are searching in the commons if (firstNewVal == "checked" && secondNewVal == "checked"){ - onCanvasSearch(null,data.item.id,null); + setTimeout(function(){onCanvasSearch(null,data.item.id,null);},0); $('#topicsByMap').val(data.item.id); $('#topicsByUser').val(""); + $('#topicsByName').val(""); $('#get_topics_form').submit(); } else if (firstNewVal == "checked"){ - onCanvasSearch(null,data.item.id,null); + setTimeout(function(){onCanvasSearch(null,data.item.id,null);},0); } else if (secondNewVal == "checked"){ //hideAll(); $('#topicsByMap').val(data.item.id); $('#topicsByUser').val(""); + $('#topicsByName').val(""); $('#get_topics_form').submit(); } else { @@ -460,19 +482,21 @@ $(document).ready(function() { // only have the autocomplete enabled if they are searching in the commons - if (firstNewVal == "checked" && secondNewVal == "checked"){ - onCanvasSearch(null,null,data.item.id.toString()); + if (firstNewVal == "checked" && secondNewVal == "checked"){ + setTimeout(function(){onCanvasSearch(null,null,data.item.id.toString());},0); $('#topicsByUser').val(data.item.id); $('#topicsByMap').val(""); + $('#topicsByName').val(""); $('#get_topics_form').submit(); } else if (firstNewVal == "checked"){ - onCanvasSearch(null,null,data.item.id.toString()); + setTimeout(function(){onCanvasSearch(null,null,data.item.id.toString());},0); } else if (secondNewVal == "checked"){ //hideAll(); $('#topicsByUser').val(data.item.id); $('#topicsByMap').val(""); + $('#topicsByName').val(""); $('#get_topics_form').submit(); } else { diff --git a/app/assets/javascripts/Jit/graphsettings.js b/app/assets/javascripts/Jit/graphsettings.js index a332b058..30b2eea0 100644 --- a/app/assets/javascripts/Jit/graphsettings.js +++ b/app/assets/javascripts/Jit/graphsettings.js @@ -367,7 +367,7 @@ var nodeSettings = { } //check for edge label in data - var desc = adj.getData("desc") + ' (' + adj.getData("id") + ')'; + var desc = adj.getData("desc"); var showDesc = adj.getData("showDesc"); if( desc != "" && showDesc ) { //now adjust the label placement @@ -399,7 +399,7 @@ function selectEdgeOnClickHandler(adj) { function selectNodeOnClickHandler(node) { - $('.showcard').css('display','none'); + $('.showcard').css('display','none'); $('.name').css('display','block'); $('.name.topic_' + node.id).css('display','none'); $('.showcard.topic_' + node.id).fadeIn('fast'); @@ -529,8 +529,7 @@ function onCreateLabelHandler(domElement, node) {
\ close \ -

\

\ \ - $_name_$ \ - \ + \ \ \ +
\
\
\ Added by: $_username_$ \
\
\ - $_desc_$ \
\
\ - - $('.best_in_place').best_in_place() \ No newline at end of file + $('.authenticated .best_in_place').best_in_place() \ No newline at end of file diff --git a/app/assets/stylesheets/topics.css.scss b/app/assets/stylesheets/topics.css.scss index f1fd4ea9..ecf313fb 100644 --- a/app/assets/stylesheets/topics.css.scss +++ b/app/assets/stylesheets/topics.css.scss @@ -38,6 +38,15 @@ line-height: 24px;} .topic .link { position:absolute; width:170px; top:295px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } +.best_in_place_name { + max-width:130px; + float:left; +} + +.best_in_place_name input{ + max-width:130px; +} + .topic-go-arrow { width: 1em; height: 1em; diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb index 7b8e7e3a..286d6280 100644 --- a/app/controllers/main_controller.rb +++ b/app/controllers/main_controller.rb @@ -12,15 +12,28 @@ class MainController < ApplicationController def search @current = current_user @topics = Array.new() + @synapses = Array.new() + if params[:topics_by_name] != "" + like_keyword = "%"+params[:topics_by_name]+"%" + @topics = Topic.where("name LIKE ?", like_keyword) + end if params[:topics_by_user_id] != "" @user = User.find(params[:topics_by_user_id]) - @topics = Topic.visibleToUser(@current, @user) - elsif params[:topics_by_map_id] != "" - @map = Map.find(params[:topics_by_map_id]) - @topics = @map.topics.delete_if{|topic| not topic.authorize_to_view(@current)} + @topics = @topics | Topic.visibleToUser(@current, @user) end + if params[:topics_by_map_id] != "" + @map = Map.find(params[:topics_by_map_id]) + @topics = @topics | @map.topics.delete_if{|topic| not topic.authorize_to_view(@current)} + end + + @topics.each do |t| + t.synapses.each do |s| + @synapses = @synapses.push(s) if not @synapses.include? s + end + end + respond_to do |format| - format.js { respond_with(@topics) } + format.js { respond_with(@topics,@synapses) } end end diff --git a/app/views/layouts/_nodeinfo.html.erb b/app/views/layouts/_nodeinfo.html.erb deleted file mode 100644 index fb41da0d..00000000 --- a/app/views/layouts/_nodeinfo.html.erb +++ /dev/null @@ -1,5 +0,0 @@ - - diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index f1703bd5..6ba778a6 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -60,6 +60,5 @@ <% end %> <%= render :partial => 'layouts/ga' if Rails.env.production? %> - <%= render :partial => 'layouts/nodeinfo' %> diff --git a/app/views/main/console.html.erb b/app/views/main/console.html.erb index 9287ff81..ad2bfac0 100644 --- a/app/views/main/console.html.erb +++ b/app/views/main/console.html.erb @@ -91,7 +91,10 @@
<%= form_tag("/search", :method => "get", :id => 'get_topics_form', :class => 'get_topics_form', :remote => true) do %> + <%= text_field_tag(:topics_by_name, "", :id => "topicsByName", :class => "getTopicsInput") %> <%= text_field_tag(:topics_by_user_id, "", :id => "topicsByUser", :class => "getTopicsInput") %> <%= text_field_tag(:topics_by_map_id, "", :id => "topicsByMap", :class => "getTopicsInput") %> + <%= text_field_tag(:synapses_by_user_id, "", :id => "synapsesByUser", :class => "getTopicsInput") %> + <%= text_field_tag(:synapses_by_map_id, "", :id => "synapsesByMap", :class => "getTopicsInput") %> <% end %> \ No newline at end of file diff --git a/app/views/main/search.js.erb b/app/views/main/search.js.erb index 04c5b436..b515d2ec 100644 --- a/app/views/main/search.js.erb +++ b/app/views/main/search.js.erb @@ -15,22 +15,25 @@ var even = true; temp.setData('dim', 1, 'start'); temp.setData('dim', 25, 'end'); temp.setData('inCommons',true); + temp.setData('onCanvas',false); temp.setPos(new $jit.Complex(myX, myY), 'current'); temp.setPos(new $jit.Complex(myX, myY), 'start'); temp.setPos(new $jit.Complex(myX, myY), 'end'); - Mconsole.fx.plotNode(temp, Mconsole.canvas); + Mconsole.fx.plotNode(temp, Mconsole.canvas); + Mconsole.labels.plotLabel(Mconsole.canvas, temp, Mconsole.config); myX += 100; even = !even; } else { var temp = Mconsole.graph.getNode('<%= topic.id %>'); - if (temp == null) { + if (temp == null || temp.getData('inCommons')) { var newnode = <%= topic.self_as_json.html_safe %>; Mconsole.graph.addNode(newnode); var temp = Mconsole.graph.getNode('<%= topic.id %>'); temp.setData('dim', 1, 'start'); temp.setData('dim', 25, 'end'); temp.setData('inCommons',true); + temp.setData('onCanvas',false); if (myX > (w-100)) { myX = -w + 400; myY += 200; @@ -47,13 +50,41 @@ var even = true; temp.setPos(new $jit.Complex(myX, myY+100), 'end'); } Mconsole.fx.plotNode(temp, Mconsole.canvas); + Mconsole.labels.plotLabel(Mconsole.canvas, temp, Mconsole.config); myX += 100; even = !even; } } <% end %> + +<% @synapses.each do |synapse| %> + var temp1 = null, temp2 = null; + temp1 = Mconsole.graph.getNode(<%= synapse.topic1.id %>); + temp2 = Mconsole.graph.getNode(<%= synapse.topic2.id %>); + if (!(temp1 == undefined || temp2 == undefined)) { + Mconsole.graph.addAdjacence(temp1, temp2, {}); + temp = Mconsole.graph.getAdjacence(temp1.id, temp2.id); + temp.setDataset('start', { + lineWidth: 0.4 + }); + temp.setDataset('end', { + lineWidth: 2 + }); + var d = new Array(<%= synapse.node1_id.to_s() %>, <%= synapse.node2_id.to_s() %>); + temp.setDataset('current', { + desc: '<%= synapse.desc %>', + showDesc: false, + category: '<%= synapse.category %>', + id: '<%= synapse.id %>', + userid: '<%= synapse.user.id %>', + username: '<%= synapse.user.name %>' + }); + temp.data.$direction = d; + Mconsole.fx.plotLine(temp, Mconsole.canvas); + } +<% end %> Mconsole.fx.animate({ - modes: ['node-property:dim'], + modes: ['node-property:dim','edge-property:lineWidth'], duration: 500 }); diff --git a/app/views/synapses/create.js.erb b/app/views/synapses/create.js.erb index 1823b646..325ee2e9 100644 --- a/app/views/synapses/create.js.erb +++ b/app/views/synapses/create.js.erb @@ -12,12 +12,10 @@ if ( Mconsole != null) { temp = Mconsole.graph.getAdjacence(temp1.id, temp2.id); console.log(temp); temp.setDataset('start', { - lineWidth: 0.4, - color: '#d1d1d1' + lineWidth: 0.4 }); temp.setDataset('end', { - lineWidth: 3, - color: '#36acfb' + lineWidth: 2 }); var d = new Array(<%= @synapse.node1_id.to_s() %>, <%= @synapse.node2_id.to_s() %>); temp.setDataset('current', { @@ -31,7 +29,7 @@ if ( Mconsole != null) { temp.data.$direction = d; Mconsole.fx.plotLine(temp, Mconsole.canvas); Mconsole.fx.animate({ - modes: ['edge-property:lineWidth:color'], + modes: ['edge-property:lineWidth'], duration: 400 }); } diff --git a/app/views/topics/create.js.erb b/app/views/topics/create.js.erb index debc125c..e9ca494d 100644 --- a/app/views/topics/create.js.erb +++ b/app/views/topics/create.js.erb @@ -24,6 +24,8 @@ if (!$.isEmptyObject(Mconsole.graph.nodes)) { var temp = Mconsole.graph.getNode('<%= @topic.id %>'); temp.setData('dim', 1, 'start'); temp.setData('dim', 40, 'end'); + temp.setData('onCanvas', false); + temp.setData('inCommons', false); if (gType == "centered") { var tempPos = new $jit.Complex(x, y); @@ -58,12 +60,16 @@ if (!$.isEmptyObject(Mconsole.graph.nodes)) { tempInit = false; } }); - } else { + } else if ( '<%= @synapse %>' == "false" ) { Mconsole.fx.plotNode(temp, Mconsole.canvas); Mconsole.fx.animate({ modes: ['node-property:dim'], - duration: 500 + duration: 500, + onComplete: function() { + selectNodeOnClickHandler(temp); + } }); + } } else { @@ -72,12 +78,17 @@ if (!$.isEmptyObject(Mconsole.graph.nodes)) { var temp = Mconsole.graph.getNode('<%= @topic.id %>'); temp.setData('dim', 1, 'start'); temp.setData('dim', 25, 'end'); + temp.setData('onCanvas', false); + temp.setData('inCommons', false); temp.setPos(new $jit.Complex(x, y), 'current'); temp.setPos(new $jit.Complex(x, y), 'start'); temp.setPos(new $jit.Complex(x, y), 'end'); Mconsole.fx.plotNode(temp, Mconsole.canvas); Mconsole.fx.animate({ modes: ['node-property:dim'], - duration: 500 + duration: 500, + onComplete: function() { + selectNodeOnClickHandler(temp); + } }); }