diff --git a/sites/all/modules/custom/player_solr/js/player_solr.results.js b/sites/all/modules/custom/player_solr/js/player_solr.results.js
index 5ae9a5e..e174b32 100644
--- a/sites/all/modules/custom/player_solr/js/player_solr.results.js
+++ b/sites/all/modules/custom/player_solr/js/player_solr.results.js
@@ -5,7 +5,8 @@
(function( $, undefined ) {
Drupal.behaviors.player_solr_search_results = {
attach: function(context, settings) {
- $('.search-result-text', context)
+ $('.search-result-text:not(.player-solr-processed)', context)
+ .addClass('player-solr-processed')
// Only show two episodes per programme initially.
.find('.episode:gt(1)')
.hide()
@@ -13,30 +14,36 @@
.each(function() {
var count = parseInt($(this).find('.search-episode-count').text());
var shown = $(this).find('.episode:visible').length;
- $(this).append(
- $('
')
- );
+ $(this)
+ .append('')
+ .find('.show-more')
+ .append(
+ $('')
+ );
// If we hid anything, we need to add a button to show it again.
if ($(this).find(':hidden').length) {
var count = parseInt($(this).find('.search-episode-count').text());
// Use the title from the title link.
var title = $(this).find('.programme-title a').text().toUpperCase();
- $(this).append(
- $(' SEE MORE ' + title + ' EPISODES
').click(function () {
- // Switching this programme result to "Expanded" view.
- $(this).siblings('.search-episode-pager').find('.search-end').text($(this).siblings('.episode').length);
- if (count > 5) {
- // Add a second link to the programme page.
- var link = $(this).siblings('.programme-title').find('a').attr('href');
- // Copy the programme link over.
- $(this).after('');
- }
- $(this).siblings(':hidden').fadeIn('slow').end().remove();
- })
- );
+ $(this)
+ .find('.show-more')
+ .append(
+ $('SEE MORE ' + title + ' EPISODES
').click(function () {
+ // Switching this programme result to "Expanded" view.
+ $(this).siblings('.search-episode-pager').find('.search-end').text($(this).parent().siblings('.episode').length);
+ if (count > 5) {
+ // Add a second link to the programme page.
+ var link = $(this).parent().siblings('.programme-title').find('a').attr('href');
+ // Copy the programme link over.
+ $(this).after('');
+ }
+ $(this).parent().siblings(':hidden').fadeIn('slow').end().end().remove();
+ })
+ );
}
});
- $('.search-results-wrapper', context)
+ $('.search-results-wrapper:not(.player-solr-processed)', context)
+ .addClass('player-solr-processed')
// Only show four programmes initially.
.find('.search-wrapper:gt(3)')
.hide()
@@ -44,14 +51,17 @@
.each(function () {
var count = $(this).find('.search-wrapper').length;
var shown = $(this).find('.search-wrapper:visible').length;
- $(this).append(
- $('')
- );
- $(this).append(
- $('VIEW MORE PROGRAMMES
').click(function () {
+ $(this)
+ .append('')
+ .find('.show-more:last')
+ .append(
+ $('')
+ )
+ .append(
+ $('VIEW MORE PROGRAMMES
').click(function () {
// Show 4 more programmes.
- $(this).siblings('.search-wrapper:hidden:lt(4)').fadeIn('slow');
- var shown = $(this).siblings('.search-wrapper:visible').length;
+ $(this).parent().siblings('.search-wrapper:hidden:lt(4)').fadeIn('slow');
+ var shown = $(this).parent().siblings('.search-wrapper:visible').length;
// Update the pager.
$(this).siblings('.search-programme-pager').find('.search-end').text(shown);
if (shown == count) {
@@ -59,7 +69,7 @@
$(this).remove();
}
})
- );
+ );
});
}
};