Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Facet - theme functions and styling #133

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions css/drupal.css
Original file line number Diff line number Diff line change
Expand Up @@ -219,3 +219,79 @@ color: #551A8B;
font-style: italic;
font-size: 14px;
}

/* Support for faceted search */
.current-search-item-active-items a {
display:inline-block;
background-color: #0c5963;
border: 1px solid black;
font-size: 15px;
line-height: 24px;
vertical-align: middle;
color: white;
padding: 1px 0 2px 0;
}

/* NB this is the active class rather than state! */
.current-search-item-active-items a.active {
color: white;
}

.current-search-item-active-items a:hover {
background-color: black;
}

.campl-theme-1 .current-search-item-active-items a {
background-color: #004e8f;
}

.campl-theme-2 .current-search-item-active-items a {
background-color: #0c5963;
}

.campl-theme-3 .current-search-item-active-items a {
background-color: #6a2068;
}

.campl-theme-4 .current-search-item-active-items a {
background-color: #355918;
}

.campl-theme-5 .current-search-item-active-items a {
background-color: #ab3901;
}

.campl-theme-6 .current-search-item-active-items a {
background-color: #a51137;
}

.campl-theme-7 .current-search-item-active-items a {
background-color: #5F5F5F;
}

.campl-theme-8 .current-search-item-active-items a {
background-color: #404f24;
}

.campl-theme-9 .current-search-item-active-items a {
background-color: #5f5f5f;
}

.facetapi-deactivate {
color: white;
padding-left: 0.3em;
}

ul.facetapi-facetapi-checkbox-links li {
list-style-type: none;
list-style-image: none;
margin-left: 0;
}

.current-search-item .facetapi-link-text {
padding-right: 0.5em;
}

ul.facetapi-facetapi-checkbox-links input.facetapi-checkbox {
margin-right: 0.5em !important;
}
71 changes: 71 additions & 0 deletions template.php
Original file line number Diff line number Diff line change
Expand Up @@ -1372,3 +1372,74 @@ function cambridge_theme_aggregator_block_item($variables) {

return $output;
}

/**
* Theme functions for Current search block.
*/

/**
* Returns HTML for an active facet item.
*
* @param $variables
* An associative array containing the keys 'text', 'path', and 'options'. See
* the l() function for information about these variables.
*
* @ingroup themeable
*/
function cambridge_theme_current_search_link_active($variables) {
// Sanitizes the link text if necessary.
$sanitize = empty($variables['options']['html']);
$link_text = ($sanitize) ? check_plain($variables['text']) : $variables['text'];
$link_text = '<span class="facetapi-link-text">' . $link_text . '</span>';

// Theme function variables fro accessible markup.
// @see http://drupal.org/node/1316580
$accessible_vars = array(
'text' => $variables['text'],
'active' => TRUE,
);

// Builds link, passes through t() which gives us the ability to change the
// position of the widget on a per-language basis.
$replacements = array(
'!current_search_deactivate_widget' => theme('current_search_deactivate_widget', $variables),
'!current_search_accessible_markup' => theme('current_search_accessible_markup', $accessible_vars),
);
$variables['text'] = t('!current_search_deactivate_widget !current_search_accessible_markup', $replacements);
$variables['options']['html'] = TRUE;
$variables['options']['attributes']['class'][] = 'active';
return l($variables['text'] . $link_text, $variables['path'], $variables['options']);
}

function cambridge_theme_current_search_deactivate_widget($variables) {
return '<span class="facetapi-deactivate">[X]</span>';
}

function cambridge_theme_current_search_keys($variables) {

$url = arg();
$cp = check_plain(current_path());

$link_text = check_plain($variables['keys']);

// Theme function variables fro accessible markup.
// @see http://drupal.org/node/1316580
$accessible_vars = array(
'text' => $link_text,
'active' => TRUE,
);

// Builds link, passes through t() which gives us the ability to change the
// position of the widget on a per-language basis.
$replacements = array(
'!current_search_deactivate_widget' => theme('current_search_deactivate_widget', $variables),
'!current_search_accessible_markup' => theme('current_search_accessible_markup', $accessible_vars),
);

$variables['text'] = t('!current_search_deactivate_widget !current_search_accessible_markup', $replacements);
$variables['path'] = $cp;
$variables['options']['html'] = TRUE;
$variables['options']['attributes']['title'] = 'search text';
$link_text = '<span class="facetapi-link-text">' . $link_text . '</span>';
return theme_link($variables) . $link_text;
}