Skip to content

Commit

Permalink
Update #12481 Fix list item metadata duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Lewis committed Jun 21, 2017
1 parent 5487f39 commit 05cd469
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 23 deletions.
23 changes: 0 additions & 23 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -815,29 +815,6 @@ $(document).ready(function(){
}
});

$('.hub_feed_more_control,.republished_feed_more_control').live({
click: function(e){
e.preventDefault();
if($(this).hasClass('more_details_included')){
$(this).closest('li').find('.metadata').remove();
$(this).removeClass('more_details_included');
$(this).find('.fa').removeClass('fa-caret-down');
$(this).find('.fa').addClass('fa-caret-right');
return;
}
var elem = this;
$.ajax({
url: $(this).attr('href'),
success: function(html){
$(elem).addClass('more_details_included');
$(elem).closest('li').find('.media-body').append(html);
$(elem).find('.fa').removeClass('fa-caret-right');
$(elem).find('.fa').addClass('fa-caret-down');
}
});
}
});

if($('.ui-widget-content').length > 0){
$('#hub_search_form,#hub_tag_search_form').live({
submit: function(e){
Expand Down
32 changes: 32 additions & 0 deletions app/assets/javascripts/hubs/bookmark_collections.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/* globals $ */
$('.hub_feed_more_control, .republished_feed_more_control')
.live({ click: toggleListItemMetadata })

function toggleListItemMetadata (e) {
e.preventDefault()

var element = $(this)

if (element.hasClass('more_details_included')) {
hideListItemMetadata(element)
} else {
showListItemMetadata(element)
}
}

function hideListItemMetadata (element) {
element.removeClass('more_details_included')
element.closest('li').find('.metadata').empty()
element.find('.fa').removeClass('fa-caret-down').addClass('fa-caret-right')
}

function showListItemMetadata (element) {
$.ajax({
url: element.attr('href'),
success: function (html) {
element.addClass('more_details_included')
element.closest('li').find('.metadata').replaceWith(html)
element.find('.fa').removeClass('fa-caret-right').addClass('fa-caret-down')
}
})
}
1 change: 1 addition & 0 deletions app/views/hub_feeds/_list_item.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
- else
= link_to hub_hub_feed_path(@hub, hub_feed) do
%h2= raw(strip_tags(hub_feed.to_s))
.metadata
- if defined?(show_hubs) && show_hubs == true
%span.smaller
in #{link_to(hub_feed.hub, hub_path(hub_feed.hub))}
1 change: 1 addition & 0 deletions app/views/republished_feeds/_list_item.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@
\#{link_to('RSS', remix_items_path(republished_feed.url_key, format: :rss))} 
\#{link_to('ATOM', remix_items_path(republished_feed.url_key, format: :atom))} 
\#{link_to('JSON', remix_items_path(republished_feed.url_key, format: :json, callback: 'callback'))}
.metadata

0 comments on commit 05cd469

Please sign in to comment.