Merge branch 'master' of github.com:Connoropolous/metamaps_gen002
This commit is contained in:
commit
9cb11c08d4
6 changed files with 80 additions and 67 deletions
BIN
app/assets/images/go-arrow.png
Normal file
BIN
app/assets/images/go-arrow.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 22 KiB |
|
@ -527,8 +527,8 @@ function clickDragOnTopic(node, eventInfo, e) {
|
||||||
function onCreateLabelHandler(domElement, node) {
|
function onCreateLabelHandler(domElement, node) {
|
||||||
var html = ' \
|
var html = ' \
|
||||||
<div class="CardOnGraph" \
|
<div class="CardOnGraph" \
|
||||||
title="Click to Hide" \
|
|
||||||
id="topic_$_id_$"> \
|
id="topic_$_id_$"> \
|
||||||
|
<a href="#" class="close-link">close</a> \
|
||||||
<p class="type best_in_place" \
|
<p class="type best_in_place" \
|
||||||
id="best_in_place_metacode" \
|
id="best_in_place_metacode" \
|
||||||
data-url="/topics/$_id_$" \
|
data-url="/topics/$_id_$" \
|
||||||
|
@ -536,37 +536,69 @@ function onCreateLabelHandler(domElement, node) {
|
||||||
data-collection=$_metacode_choices_$ \
|
data-collection=$_metacode_choices_$ \
|
||||||
data-attribute="metacode" \
|
data-attribute="metacode" \
|
||||||
data-type="select">$_metacode_$</p> \
|
data-type="select">$_metacode_$</p> \
|
||||||
<a href="/topics/$_id_$"> \
|
<img alt="$_metacode_$" \
|
||||||
<img alt="$_metacode_$" \
|
class="icon" \
|
||||||
class="icon" \
|
height="50" \
|
||||||
height="50" \
|
width="50" \
|
||||||
width="50" \
|
|
||||||
src="$_imgsrc_$" /> \
|
src="$_imgsrc_$" /> \
|
||||||
</a> \
|
|
||||||
<div class="scroll"> \
|
<div class="scroll"> \
|
||||||
<span class="title best_in_place" \
|
<span class="title"> \
|
||||||
id="best_in_place_name" \
|
<span class="best_in_place" \
|
||||||
data-url="/topics/$_id_$" \
|
id="best_in_place_name" \
|
||||||
data-object="topic" \
|
data-url="/topics/$_id_$" \
|
||||||
data-attribute="name" \
|
data-object="topic" \
|
||||||
data-type="input">$_name_$</span> \
|
data-attribute="name" \
|
||||||
|
data-type="input"> \
|
||||||
|
$_name_$</span> \
|
||||||
|
<a href="/topics/$_id_$" target="_blank"> \
|
||||||
|
<img class="topic-go-arrow" \
|
||||||
|
title="Go to the topic page" \
|
||||||
|
src="/assets/go-arrow.png" /> \
|
||||||
|
</a> \
|
||||||
|
</span> \
|
||||||
<div class="contributor"> \
|
<div class="contributor"> \
|
||||||
Added by: <a href="/users/$_userid_$">$_username_$</a> \
|
Added by: <a href="/users/$_userid_$">$_username_$</a> \
|
||||||
</div> \
|
</div> \
|
||||||
<div class="desc"> \
|
<div class="desc"> \
|
||||||
<p>$_desc_$</p> \
|
<span class="best_in_place" \
|
||||||
|
id="best_in_place_desc" \
|
||||||
|
data-url="/topics/$_id_$" \
|
||||||
|
data-object="topic" \
|
||||||
|
data-attribute="desc" \
|
||||||
|
data-type="textarea">$_desc_$</span> \
|
||||||
</div> \
|
</div> \
|
||||||
</div> \
|
</div> \
|
||||||
<a href="$_link_$" class="link" target="_blank">$_link_$</a> \
|
<span class="best_in_place" \
|
||||||
|
id="best_in_place_link" \
|
||||||
|
data-url="/topics/$_id_$" \
|
||||||
|
data-object="topic" \
|
||||||
|
data-attribute="link" \
|
||||||
|
data-type="input">$_link_$</span> \
|
||||||
|
<a href="$_link_$" class="link" target="_blank"> \
|
||||||
|
<img class="topic-go-arrow link" \
|
||||||
|
title="Visit $_link_$" \
|
||||||
|
src="/assets/go-arrow.png" /> \
|
||||||
|
</a> \
|
||||||
</div>';
|
</div>';
|
||||||
|
|
||||||
//create metacode_choices array from imgArray
|
//create metacode_choices array from imgArray
|
||||||
var metacode_choices = "'[";
|
var metacodes = new Array();
|
||||||
for (var key in imgArray) {
|
for (var key in imgArray) {
|
||||||
if (imgArray.hasOwnProperty(key)) {
|
if (imgArray.hasOwnProperty(key)) {
|
||||||
metacode_choices += '["' + key + '","' + key + '"],';
|
if (key != node.getData("metacode")) {
|
||||||
|
metacodes.push(key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Arrange it how we want it
|
||||||
|
metacodes.sort();
|
||||||
|
metacodes.unshift(node.getData("metacode"));
|
||||||
|
|
||||||
|
var metacode_choices = "'[";
|
||||||
|
for (var i in metacodes) {
|
||||||
|
metacode_choices += '["' + metacodes[i] + '","' + metacodes[i] + '"],';
|
||||||
|
}
|
||||||
//remove trailing comma and add ]
|
//remove trailing comma and add ]
|
||||||
metacode_choices = metacode_choices.slice(0, -1);
|
metacode_choices = metacode_choices.slice(0, -1);
|
||||||
metacode_choices += "]'";
|
metacode_choices += "]'";
|
||||||
|
@ -577,7 +609,11 @@ function onCreateLabelHandler(domElement, node) {
|
||||||
html = html.replace(/\$_name_\$/g, node.name);
|
html = html.replace(/\$_name_\$/g, node.name);
|
||||||
html = html.replace(/\$_userid_\$/g, node.getData("userid"));
|
html = html.replace(/\$_userid_\$/g, node.getData("userid"));
|
||||||
html = html.replace(/\$_username_\$/g, node.getData("username"));
|
html = html.replace(/\$_username_\$/g, node.getData("username"));
|
||||||
html = html.replace(/\$_desc_\$/g, node.getData("desc"));
|
if (node.getData("desc") == "") {
|
||||||
|
html = html.replace(/\$_desc_\$/g, '<span style="color: #cccccc">Click to add description.</span>');
|
||||||
|
} else {
|
||||||
|
html = html.replace(/\$_desc_\$/g, node.getData("desc"));
|
||||||
|
}
|
||||||
html = html.replace(/\$_link_\$/g, node.getData("link"));
|
html = html.replace(/\$_link_\$/g, node.getData("link"));
|
||||||
html = html.replace(/\$_metacode_choices_\$/g, metacode_choices);
|
html = html.replace(/\$_metacode_choices_\$/g, metacode_choices);
|
||||||
|
|
||||||
|
@ -588,7 +624,7 @@ function onCreateLabelHandler(domElement, node) {
|
||||||
domElement.appendChild(showCard);
|
domElement.appendChild(showCard);
|
||||||
|
|
||||||
// add some events to the label
|
// add some events to the label
|
||||||
showCard.onclick = function(){
|
$(showCard).find('a.close-link').click(function(){
|
||||||
delete node.selected;
|
delete node.selected;
|
||||||
node.setData('dim', 25, 'current');
|
node.setData('dim', 25, 'current');
|
||||||
node.eachAdjacency(function (adj) {
|
node.eachAdjacency(function (adj) {
|
||||||
|
@ -602,11 +638,11 @@ function onCreateLabelHandler(domElement, node) {
|
||||||
modes: ['edge-property:lineWidth:color'],
|
modes: ['edge-property:lineWidth:color'],
|
||||||
duration: 500
|
duration: 500
|
||||||
});
|
});
|
||||||
// $('.showcard.topic_' + node.id).fadeOut('fast', function(){
|
$('.showcard.topic_' + node.id).fadeOut('fast', function(){
|
||||||
// $('.name').css('display','block');
|
$('.name').css('display','block');
|
||||||
// Mconsole.plot();
|
Mconsole.plot();
|
||||||
// });
|
});
|
||||||
}
|
});
|
||||||
|
|
||||||
// Create a 'name' button and add it to the main node label
|
// Create a 'name' button and add it to the main node label
|
||||||
var nameContainer = document.createElement('span'),
|
var nameContainer = document.createElement('span'),
|
||||||
|
@ -621,4 +657,14 @@ function onCreateLabelHandler(domElement, node) {
|
||||||
nameContainer.onclick = function(){
|
nameContainer.onclick = function(){
|
||||||
selectNodeOnClickHandler(node)
|
selectNodeOnClickHandler(node)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//bind callbacks
|
||||||
|
$(showCard).find('.type.best_in_place').bind("ajax:success", function() {
|
||||||
|
var metacode = $(this).html();
|
||||||
|
$(showCard).find('img.icon').attr('alt', metacode);
|
||||||
|
$(showCard).find('img.icon').attr('src', imgArray[metacode].src);
|
||||||
|
|
||||||
|
node.setData("metacode", metacode);
|
||||||
|
Mconsole.plot();
|
||||||
|
});
|
||||||
}//onCreateLabelHandler
|
}//onCreateLabelHandler
|
||||||
|
|
|
@ -4,7 +4,9 @@
|
||||||
|
|
||||||
.topic { display:block; float:left; position:relative; width:175px; height:300px; padding:10px 5px 10px 35px; background: url('bg.png'); border-radius:15px; margin:30px 0 30px 50px; color:#000; }
|
.topic { display:block; float:left; position:relative; width:175px; height:300px; padding:10px 5px 10px 35px; background: url('bg.png'); border-radius:15px; margin:30px 0 30px 50px; color:#000; }
|
||||||
|
|
||||||
.topic .delete {position: absolute;
|
.close-link,
|
||||||
|
.topic .delete {
|
||||||
|
position: absolute;
|
||||||
top: -14px;
|
top: -14px;
|
||||||
left: 0px;
|
left: 0px;
|
||||||
background: none;
|
background: none;
|
||||||
|
@ -34,4 +36,10 @@ line-height: 24px;}
|
||||||
.topic .desc { font-size:15px; font-family:Arial, Helvetica, sans-serif; }
|
.topic .desc { font-size:15px; font-family:Arial, Helvetica, sans-serif; }
|
||||||
.topic .desc h3 { font-style:normal; margin-top:5px; }
|
.topic .desc h3 { font-style:normal; margin-top:5px; }
|
||||||
|
|
||||||
.topic .link { position:absolute; width:170px; top:295px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
.topic .link { position:absolute; width:170px; top:295px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||||
|
|
||||||
|
.topic-go-arrow {
|
||||||
|
width: 1em;
|
||||||
|
height: 1em;
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
|
|
@ -46,16 +46,6 @@ class TopicsController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# GET showcard/:id
|
|
||||||
def showcard
|
|
||||||
@user = current_user
|
|
||||||
@topic = Topic.find(params[:id]).authorize_to_show(@user)
|
|
||||||
|
|
||||||
respond_to do |format|
|
|
||||||
format.html { respond_with(@topic, @user) }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# POST topics
|
# POST topics
|
||||||
def create
|
def create
|
||||||
|
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
<div class="showcard topic_<%= @topic.id %>">
|
|
||||||
<div class="CardOnGraph" title="Click to Hide" id="topic_' + node.id + '">
|
|
||||||
<p class="type">
|
|
||||||
<%= @topic.metacode.name %>
|
|
||||||
</p>
|
|
||||||
<img alt="<%= @topic.metacode.name %>"
|
|
||||||
src="/assets/<%= @topic.metacode.name %>.png"
|
|
||||||
class="icon" height="50" width="50" />
|
|
||||||
<div class="scroll">
|
|
||||||
<a href="/topics/<%=@topic.id%>" class="title">
|
|
||||||
<%= @topic.name %>
|
|
||||||
</a>
|
|
||||||
<div class="contributor">
|
|
||||||
Added by:
|
|
||||||
<a href="/users/<%= @user.id %>">
|
|
||||||
<%= @user.name %>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
<div class="desc">
|
|
||||||
<p>
|
|
||||||
<%= @topic.desc %>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div><!-- div.scroll -->
|
|
||||||
<a href="<%= @topic.link %>" class="link" target="_blank">
|
|
||||||
<%= @topic.link %>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
|
@ -10,8 +10,6 @@ ISSAD::Application.routes.draw do
|
||||||
|
|
||||||
match 'maps/:id/savelayout', to: 'maps#savelayout', via: :put, as: :savelayout
|
match 'maps/:id/savelayout', to: 'maps#savelayout', via: :put, as: :savelayout
|
||||||
|
|
||||||
match 'showcard/:id', to: 'items#showcard', via: :get, as: :showcard
|
|
||||||
|
|
||||||
resource :session
|
resource :session
|
||||||
|
|
||||||
resources :topics do
|
resources :topics do
|
||||||
|
|
Loading…
Reference in a new issue