diff --git a/app/assets/javascripts/Jit/graphsettings.js b/app/assets/javascripts/Jit/graphsettings.js
index 37ceedb5..8b53015d 100644
--- a/app/assets/javascripts/Jit/graphsettings.js
+++ b/app/assets/javascripts/Jit/graphsettings.js
@@ -111,55 +111,7 @@ function graphSettings(type) {
// Add text to the labels. This method is only triggered
// on label creation and only for DOM labels (not native canvas ones).
onCreateLabel: function (domElement, node) {
- var html =
- '
' + node.getData("metacode") + '
' +
- '

' +
- '
' +
- '
' + node.getData('desc') + '.' + '
' +
- '' + node.getData('link') + '';
- var showCard = document.createElement('div');
- showCard.className = 'showcard topic_' + node.id;
- showCard.innerHTML = html;
- showCard.style.display = "none";
- domElement.appendChild(showCard);
-
- // add some events to the label
- showCard.onclick = function(){
- delete node.selected;
- node.setData('dim', 25, 'current');
- node.eachAdjacency(function (adj) {
- adj.setDataset('end', {
- lineWidth: 2,
- color: '#222222'
- });
- adj.setData('showDesc', false, 'current');
- });
- Mconsole.fx.animate({
- modes: ['edge-property:lineWidth:color'],
- duration: 500
- });
-// $('.showcard.topic_' + node.id).fadeOut('fast', function(){
-// $('.name').css('display','block');
-// Mconsole.plot();
-// });
- }
-
- // Create a 'name' button and add it
- // to the main node label
- var nameContainer = document.createElement('span'),
- style = nameContainer.style;
- nameContainer.className = 'name topic_' + node.id;
- nameContainer.innerHTML = '' + node.name + '
';
- domElement.appendChild(nameContainer);
- style.fontSize = "0.9em";
- style.color = "#222222";
-
- // add some events to the label
- nameContainer.onclick = function(){
- selectNodeOnClickHandler(node)
- }
+ onCreateLabelHandler(domElement, node);
},
// Change node styles when DOM labels are placed
// or moved.
@@ -294,62 +246,7 @@ function graphSettings(type) {
// Add text to the labels. This method is only triggered
// on label creation and only for DOM labels (not native canvas ones).
onCreateLabel: function (domElement, node) {
- var html =
- '' + node.getData("metacode") + '
' +
- '

' +
- '
' +
- '
' + node.getData('desc') + '.' + '
' +
- '' + node.getData('link') + '';
- var showCard = document.createElement('div');
- showCard.className = 'showcard topic_' + node.id;
- showCard.innerHTML = html;
- showCard.style.display = "none";
- domElement.appendChild(showCard);
-
- // add some events to the label
- showCard.onclick = function(){
- if (!Mconsole.busy) {
- delete node.selected;
- node.setData('dim', 25, 'current');
- node.eachAdjacency(function (adj) {
- adj.setDataset('end', {
- lineWidth: 2,
- color: '#222222'
- });
- adj.setData('showDesc', false, 'current');
- });
- Mconsole.fx.animate({
- modes: ['edge-property:lineWidth:color'],
- duration: 500
- });
-// $('.showcard.topic_' + node.id).fadeOut('fast', function(){
-// $('.name').css('display','block');
-// Mconsole.plot();
-// });
- }
- }
-
- // Create a 'name' button and add it
- // to the main node label
- var nameContainer = document.createElement('span'),
- style = nameContainer.style;
- nameContainer.className = 'name topic_' + node.id;
- nameContainer.innerHTML = '' + node.name + '
';
- domElement.appendChild(nameContainer);
- style.fontSize = "0.9em";
- style.color = "#222222";
-
- // add some events to the label
- nameContainer.onclick = function(){
- if (!Mconsole.busy) {
- selectNodeOnClickHandler(node);
- Mconsole.onClick(node.id, {
- hideLabels: false
- });
- }
- }
+ onCreateLabelHandler(domElement, node);
},
// Change node styles when DOM labels are placed
// or moved.
@@ -626,3 +523,104 @@ function clickDragOnTopic(node, eventInfo, e) {
}
}
}
+
+function onCreateLabelHandler(domElement, node) {
+ var html = ' \
+ ';
+
+ //create metacode_choices array from imgArray
+ var metacode_choices = "'[";
+ for (var key in imgArray) {
+ if (imgArray.hasOwnProperty(key)) {
+ var caps = key;
+ var nocaps = caps.toLowerCase();
+ metacode_choices += '["' + nocaps + '","' + caps + '"],';
+ }
+ }
+ //remove trailing comma and add ]
+ metacode_choices = metacode_choices.slice(0, -1);
+ metacode_choices += "]'";
+
+ html = html.replace(/\$_id_\$/g, node.id);
+ html = html.replace(/\$_metacode_\$/g, node.getData("metacode"));
+ html = html.replace(/\$_imgsrc_\$/g, imgArray[node.getData("metacode")].src);
+ html = html.replace(/\$_name_\$/g, node.name);
+ html = html.replace(/\$_userid_\$/g, node.getData("userid"));
+ html = html.replace(/\$_username_\$/g, node.getData("username"));
+ html = html.replace(/\$_desc_\$/g, node.getData("desc"));
+ html = html.replace(/\$_link_\$/g, node.getData("link"));
+ html = html.replace(/\$_metacode_choices_\$/g, metacode_choices);
+
+ var showCard = document.createElement('div');
+ showCard.className = 'showcard topic_' + node.id;
+ showCard.innerHTML = html;
+ showCard.style.display = "none";
+ domElement.appendChild(showCard);
+
+ // add some events to the label
+ showCard.onclick = function(){
+ delete node.selected;
+ node.setData('dim', 25, 'current');
+ node.eachAdjacency(function (adj) {
+ adj.setDataset('end', {
+ lineWidth: 2,
+ color: '#222222'
+ });
+ adj.setData('showDesc', false, 'current');
+ });
+ Mconsole.fx.animate({
+ modes: ['edge-property:lineWidth:color'],
+ duration: 500
+ });
+// $('.showcard.topic_' + node.id).fadeOut('fast', function(){
+// $('.name').css('display','block');
+// Mconsole.plot();
+// });
+ }
+
+ // Create a 'name' button and add it to the main node label
+ var nameContainer = document.createElement('span'),
+ style = nameContainer.style;
+ nameContainer.className = 'name topic_' + node.id;
+ nameContainer.innerHTML = '' + node.name + '
';
+ domElement.appendChild(nameContainer);
+ style.fontSize = "0.9em";
+ style.color = "#222222";
+
+ // add some events to the label
+ nameContainer.onclick = function(){
+ selectNodeOnClickHandler(node)
+ }
+}//onCreateLabelHandler