From 8b7017df2207af2260a7119ab6c610633fba4676 Mon Sep 17 00:00:00 2001 From: Devin Howard Date: Sat, 5 Jan 2013 11:39:44 -0500 Subject: [PATCH 1/4] added class to the focus div telling us what topic page we're on --- app/views/topics/show.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/topics/show.html.erb b/app/views/topics/show.html.erb index c80ea25b..c6b4e023 100644 --- a/app/views/topics/show.html.erb +++ b/app/views/topics/show.html.erb @@ -1,4 +1,4 @@ -
+

<%= @topic.metacode.name %>

<%= image_tag @topic.metacode.icon, :class => 'icon', :size => '50x50' %> From d316df3192b508d18e7f8d3a6693921711ccdfa9 Mon Sep 17 00:00:00 2001 From: Devin Howard Date: Sat, 5 Jan 2013 11:51:36 -0500 Subject: [PATCH 2/4] added span around title text on topic view top cards --- app/views/topics/show.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/topics/show.html.erb b/app/views/topics/show.html.erb index c6b4e023..f8087f43 100644 --- a/app/views/topics/show.html.erb +++ b/app/views/topics/show.html.erb @@ -4,7 +4,7 @@ <%= image_tag @topic.metacode.icon, :class => 'icon', :size => '50x50' %>
-

<%= @topic.name %> <% if (@topic.permission == "commons" && authenticated?) || @topic.user == user %><%= link_to "[edit]", edit_topic_path(@topic) %><% end %>

+

<%= @topic.name %> <% if (@topic.permission == "commons" && authenticated?) || @topic.user == user %><%= link_to "[edit]", edit_topic_path(@topic) %><% end %>

<%= @topic.desc %>

From 8f13413ab7fa04f0e39d33ffa669e3694266f68d Mon Sep 17 00:00:00 2001 From: Devin Howard Date: Sat, 5 Jan 2013 11:57:25 -0500 Subject: [PATCH 3/4] callbacks now working - incluing to update card at top of topic view pages --- app/assets/javascripts/Jit/graphsettings.js | 38 ++++++++++++++++----- app/assets/stylesheets/topics.css.scss | 4 +++ 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/app/assets/javascripts/Jit/graphsettings.js b/app/assets/javascripts/Jit/graphsettings.js index 330a6b20..341b5e92 100644 --- a/app/assets/javascripts/Jit/graphsettings.js +++ b/app/assets/javascripts/Jit/graphsettings.js @@ -575,6 +575,7 @@ function onCreateLabelHandler(domElement, node) { $_link_$ \ @@ -610,18 +611,18 @@ 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(/\$_metacode_choices_\$/g, metacode_choices); + html = html.replace(/\$_link_\$/g, node.getData("link")); var desc_nil = "Click to add description."; html = html.replace(/\$_desc_nil_\$/g, desc_nil); if (node.getData("desc") == "" && userid != null) { + //logged in but desc isn't there so it's invisible html = html.replace(/\$_desc_\$/g, desc_nil); } 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); - var showCard = document.createElement('div'); showCard.className = 'showcard topic_' + node.id; showCard.innerHTML = html; @@ -649,7 +650,7 @@ function onCreateLabelHandler(domElement, node) { }); }); - //$(showCard).find('.scroll').mCustomScrollbar(); + $(showCard).find('.scroll').mCustomScrollbar(); // Create a 'name' button and add it to the main node label var nameContainer = document.createElement('span'), @@ -707,14 +708,23 @@ function onCreateLabelHandler(domElement, node) { nameContainer.onmouseout = function(){ $('.name.topic_' + node.id + ' .nodeOptions').css('display','none'); } - - //bind callbacks - $(showCard).find('.type.best_in_place').bind("ajax:success", function() { + //jQuery selector for the card thing at the top of a topic view + //only works if we're editing the topic whose page we are on + //e.g. on /topics/1 you only need to update .focus.topic_1 + var topcard = '.focus.topic_' + node.id; + + //bind best_in_place ajax callbacks + $(showCard).find('.best_in_place_metacode') + .bind("ajax:success", function() { var metacode = $(this).html(); + //changing img alt, img src for top card (topic view page) + //and on-canvas card. Also changing image of node $(showCard).find('img.icon').attr('alt', metacode); $(showCard).find('img.icon').attr('src', imgArray[metacode].src); - + $(topcard + ' img').attr('alt', metacode); + $(topcard + ' img').attr('src', imgArray[metacode].src); + $(topcard + ' .focusleft p').html(metacode); node.setData("metacode", metacode); Mconsole.plot(); }); @@ -722,6 +732,18 @@ function onCreateLabelHandler(domElement, node) { $(showCard).find('.best_in_place_name').bind("ajax:success", function() { var name = $(this).html(); $(nameContainer).find('.label').html(name); + $(topcard + ' .focusmiddle .title-text').html(name); + }); + + $(showCard).find('.best_in_place_desc').bind("ajax:success", function() { + var desc = $(this).html(); + $(topcard + ' .focusmiddle p').html(desc); + }); + + $(showCard).find('.best_in_place_link').bind("ajax:success", function() { + var link = $(this).html(); + $(topcard + ' .focusright a').html(link); + $(topcard + ' .focusright a').attr('href', link); }); }//onCreateLabelHandler diff --git a/app/assets/stylesheets/topics.css.scss b/app/assets/stylesheets/topics.css.scss index 6ed2b6b6..25f43311 100644 --- a/app/assets/stylesheets/topics.css.scss +++ b/app/assets/stylesheets/topics.css.scss @@ -95,3 +95,7 @@ line-height: 24px;} .gray { color: #999999; } + +.edit-link { + float: right; +} From d90954e3a7b35632137abc2f6e4fd6e3bf41540f Mon Sep 17 00:00:00 2001 From: Devin Howard Date: Sat, 5 Jan 2013 12:45:02 -0500 Subject: [PATCH 4/4] got links working via best_in_place --- app/assets/javascripts/Jit/graphsettings.js | 35 ++++++++++++++------- app/assets/stylesheets/topics.css.scss | 4 --- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/app/assets/javascripts/Jit/graphsettings.js b/app/assets/javascripts/Jit/graphsettings.js index 341b5e92..779b1391 100644 --- a/app/assets/javascripts/Jit/graphsettings.js +++ b/app/assets/javascripts/Jit/graphsettings.js @@ -571,18 +571,27 @@ function onCreateLabelHandler(domElement, node) { data-type="textarea">$_desc_$ \
\
\ - \ - $_link_$ \ - \ - (Edit) \ + $_go_link_$ \ + $_a_tag_$$_link_$$_close_a_tag_$ \
'; + //link is rendered differently if user is logged out or in + var go_link, a_tag, close_a_tag; + if (userid == null) { + golink = ''; + var a_tag = ''; + var close_a_tag = ''; + } else { + go_link = '[go]'; + a_tag = ''; + close_a_tag = ''; + } + //create metacode_choices array from imgArray var metacodes = new Array(); for (var key in imgArray) { @@ -605,6 +614,8 @@ function onCreateLabelHandler(domElement, node) { metacode_choices = metacode_choices.slice(0, -1); metacode_choices += "]'"; + var desc_nil = "Click to add description."; + 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); @@ -613,8 +624,10 @@ function onCreateLabelHandler(domElement, node) { html = html.replace(/\$_username_\$/g, node.getData("username")); html = html.replace(/\$_metacode_choices_\$/g, metacode_choices); html = html.replace(/\$_link_\$/g, node.getData("link")); + html = html.replace(/\$_go_link_\$/g, go_link); + html = html.replace(/\$_a_tag_\$/g, a_tag); + html = html.replace(/\$_close_a_tag_\$/g, close_a_tag); - var desc_nil = "Click to add description."; html = html.replace(/\$_desc_nil_\$/g, desc_nil); if (node.getData("desc") == "" && userid != null) { //logged in but desc isn't there so it's invisible diff --git a/app/assets/stylesheets/topics.css.scss b/app/assets/stylesheets/topics.css.scss index 25f43311..6ed2b6b6 100644 --- a/app/assets/stylesheets/topics.css.scss +++ b/app/assets/stylesheets/topics.css.scss @@ -95,7 +95,3 @@ line-height: 24px;} .gray { color: #999999; } - -.edit-link { - float: right; -}