too tired cause I stayed up to stupid late to say something intelligeblle here see.
This commit is contained in:
parent
a9462d0f0e
commit
940c6f02a5
11 changed files with 136 additions and 56 deletions
|
@ -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 {
|
||||
|
|
|
@ -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) {
|
|||
<div class="CardOnGraph" \
|
||||
id="topic_$_id_$"> \
|
||||
<a href="#" class="close-link">close</a> \
|
||||
<p class="type best_in_place" \
|
||||
id="best_in_place_metacode" \
|
||||
<p class="type best_in_place best_in_place_metacode" \
|
||||
data-url="/topics/$_id_$" \
|
||||
data-object="topic" \
|
||||
data-collection=$_metacode_choices_$ \
|
||||
|
@ -543,24 +542,23 @@ function onCreateLabelHandler(domElement, node) {
|
|||
src="$_imgsrc_$" /> \
|
||||
<div class="scroll"> \
|
||||
<span class="title"> \
|
||||
<span class="best_in_place" \
|
||||
id="best_in_place_name" \
|
||||
<span class="best_in_place best_in_place_name" \
|
||||
data-url="/topics/$_id_$" \
|
||||
data-object="topic" \
|
||||
data-attribute="name" \
|
||||
data-type="input">$_name_$</span> \
|
||||
<a href="/topics/$_id_$" target="_blank"> \
|
||||
<a href="/topics/$_id_$" class="topic-go-arrow" target="_blank"> \
|
||||
<img class="topic-go-arrow" \
|
||||
title="Go to the topic page" \
|
||||
src="/assets/go-arrow.png" /> \
|
||||
</a> \
|
||||
<div class="clearfloat"></div> \
|
||||
</span> \
|
||||
<div class="contributor"> \
|
||||
Added by: <a href="/users/$_userid_$">$_username_$</a> \
|
||||
</div> \
|
||||
<div class="desc"> \
|
||||
<span class="best_in_place" \
|
||||
id="best_in_place_desc" \
|
||||
<span class="best_in_place best_in_place_desc" \
|
||||
data-url="/topics/$_id_$" \
|
||||
data-object="topic" \
|
||||
data-nil="$_desc_nil_$" \
|
||||
|
@ -568,8 +566,7 @@ function onCreateLabelHandler(domElement, node) {
|
|||
data-type="textarea">$_desc_$</span> \
|
||||
</div> \
|
||||
</div> \
|
||||
<span class="best_in_place" \
|
||||
id="best_in_place_link" \
|
||||
<span class="best_in_place best_in_place_link" \
|
||||
data-url="/topics/$_id_$" \
|
||||
data-object="topic" \
|
||||
data-attribute="link" \
|
||||
|
@ -612,7 +609,7 @@ function onCreateLabelHandler(domElement, node) {
|
|||
|
||||
var desc_nil = "<span class='gray'>Click to add description.</span>";
|
||||
html = html.replace(/\$_desc_nil_\$/g, desc_nil);
|
||||
if (node.getData("desc") == "") {
|
||||
if (node.getData("desc") == "" && userid != null) {
|
||||
html = html.replace(/\$_desc_\$/g, desc_nil);
|
||||
} else {
|
||||
html = html.replace(/\$_desc_\$/g, node.getData("desc"));
|
||||
|
|
|
@ -3,4 +3,4 @@
|
|||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
||||
|
||||
jQuery ->
|
||||
$('.best_in_place').best_in_place()
|
||||
$('.authenticated .best_in_place').best_in_place()
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
<script type="text/javascript">
|
||||
//create a global array we can fill with id's of loaded nodes
|
||||
var loaded_nodes = new Array();
|
||||
</script>
|
||||
<div id="loaded_nodes" class="hidden"></div>
|
|
@ -60,6 +60,5 @@
|
|||
|
||||
<% end %>
|
||||
<%= render :partial => 'layouts/ga' if Rails.env.production? %>
|
||||
<%= render :partial => 'layouts/nodeinfo' %>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -91,7 +91,10 @@
|
|||
</ul>
|
||||
</div>
|
||||
<%= 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 %>
|
||||
</div>
|
|
@ -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
|
||||
});
|
||||
|
|
|
@ -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
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue