diff --git a/app/assets/images/go-arrow.png b/app/assets/images/go-arrow.png new file mode 100644 index 00000000..74181fe8 Binary files /dev/null and b/app/assets/images/go-arrow.png differ diff --git a/app/assets/javascripts/Jit/graphsettings.js b/app/assets/javascripts/Jit/graphsettings.js index 2330484d..49b34535 100644 --- a/app/assets/javascripts/Jit/graphsettings.js +++ b/app/assets/javascripts/Jit/graphsettings.js @@ -527,8 +527,8 @@ function clickDragOnTopic(node, eventInfo, e) { function onCreateLabelHandler(domElement, node) { var html = ' \
\ + close \

$_metacode_$

\ - \ - $_metacode_$ \ - \
\ - $_name_$ \ + \ + \ + $_name_$ \ + \ + \ + \ + \
\ Added by: $_username_$ \
\
\ -

$_desc_$

\ + $_desc_$ \
\
\ - $_link_$ \ + $_link_$ \ + \ + \ + \
'; //create metacode_choices array from imgArray - var metacode_choices = "'["; + var metacodes = new Array(); for (var key in imgArray) { 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 ] metacode_choices = metacode_choices.slice(0, -1); metacode_choices += "]'"; @@ -577,7 +609,11 @@ function onCreateLabelHandler(domElement, node) { 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")); + if (node.getData("desc") == "") { + html = html.replace(/\$_desc_\$/g, 'Click to add description.'); + } else { + html = html.replace(/\$_desc_\$/g, node.getData("desc")); + } html = html.replace(/\$_link_\$/g, node.getData("link")); html = html.replace(/\$_metacode_choices_\$/g, metacode_choices); @@ -588,7 +624,7 @@ function onCreateLabelHandler(domElement, node) { domElement.appendChild(showCard); // add some events to the label - showCard.onclick = function(){ + $(showCard).find('a.close-link').click(function(){ delete node.selected; node.setData('dim', 25, 'current'); node.eachAdjacency(function (adj) { @@ -602,11 +638,11 @@ function onCreateLabelHandler(domElement, node) { modes: ['edge-property:lineWidth:color'], duration: 500 }); -// $('.showcard.topic_' + node.id).fadeOut('fast', function(){ -// $('.name').css('display','block'); -// Mconsole.plot(); -// }); - } + $('.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'), @@ -621,4 +657,14 @@ function onCreateLabelHandler(domElement, node) { nameContainer.onclick = function(){ 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 diff --git a/app/assets/stylesheets/topics.css.scss b/app/assets/stylesheets/topics.css.scss index 7fbc6738..b672a538 100644 --- a/app/assets/stylesheets/topics.css.scss +++ b/app/assets/stylesheets/topics.css.scss @@ -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 .delete {position: absolute; +.close-link, +.topic .delete { +position: absolute; top: -14px; left: 0px; background: none; @@ -34,4 +36,10 @@ line-height: 24px;} .topic .desc { font-size:15px; font-family:Arial, Helvetica, sans-serif; } .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; } \ No newline at end of file +.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; +} diff --git a/app/controllers/topics_controller.rb b/app/controllers/topics_controller.rb index cec65cda..fb49ae15 100644 --- a/app/controllers/topics_controller.rb +++ b/app/controllers/topics_controller.rb @@ -46,16 +46,6 @@ class TopicsController < ApplicationController 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 def create diff --git a/app/views/topics/showcard.html.erb b/app/views/topics/showcard.html.erb deleted file mode 100644 index ccceea1d..00000000 --- a/app/views/topics/showcard.html.erb +++ /dev/null @@ -1,29 +0,0 @@ -
-
-

- <%= @topic.metacode.name %> -

- <%= @topic.metacode.name %> -
- - <%= @topic.name %> - -
- Added by: - - <%= @user.name %> - -
-
-

- <%= @topic.desc %> -

-
-
- - <%= @topic.link %> - -
-
diff --git a/config/routes.rb b/config/routes.rb index fe7301d5..d5bd31ba 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -10,8 +10,6 @@ ISSAD::Application.routes.draw do match 'maps/:id/savelayout', to: 'maps#savelayout', via: :put, as: :savelayout - match 'showcard/:id', to: 'items#showcard', via: :get, as: :showcard - resource :session resources :topics do