Skip to content

Commit

Permalink
code tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
rdrew committed Jul 6, 2020
1 parent 87645f3 commit ecf21d8
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 73 deletions.
17 changes: 17 additions & 0 deletions template.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,23 @@ function islandarchives_menu_tree__menu_block__2(&$variables) {

function islandarchives_form_alter(&$form, &$form_state, $form_id) {
// target a single form
if($form_id == "search_block_form"){
$form['search_block_form']['#title'] = t('Search the archives...'); // Change the text on the label element
$form['search_block_form']['#title_display'] = 'invisible'; // Toggle label visibilty
$form['search_block_form']['#size'] = 40; // define size of the textfield
//$form['search_block_form']['#default_value'] = t('Search the archives...'); // Set a default value for the textfield
$form['actions']['submit']['#value'] = t('GO!'); // Change the text on the submit button
$form['actions']['submit'] = array('#type' => 'image_button', '#src' => base_path() . path_to_theme() . '/images/Magnifying_glass_icon.svg');

// Add extra attributes to the text box
$form['search_block_form']['#attributes']['onblur'] = "if (this.value == '') {this.value = 'Search the archives...';}";
$form['search_block_form']['#attributes']['onfocus'] = "if (this.value == 'Search the archives...') {this.value = '';}";
// Prevent user from searching the default text
$form['#attributes']['onsubmit'] = "if(this.search_block_form.value=='Search the archives...'){ alert('Please enter a search'); return false; }";

// Alternative (HTML5) placeholder attribute instead of using the javascript
$form['search_block_form']['#attributes']['placeholder'] = t('Search the archives...');
}
if($form_id == "islandora_solr_simple_search_form"){
$form['simple']['islandora_simple_search_query']['#default_value'] = t('Search the archives...'); // Set a default value for the textfield
$form['simple']['islandora_simple_search_query']['#attributes']['onblur'] = "if (this.value == '') {this.value = 'Search the archives...';}";
Expand Down
37 changes: 37 additions & 0 deletions templates/search-block-form.tpl.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

/**
* @file
* Displays the search form block.
*
* Available variables:
* - $search_form: The complete search form ready for print.
* - $search: Associative array of search elements. Can be used to print each
* form element separately.
*
* Default elements within $search:
* - $search['search_block_form']: Text input area wrapped in a div.
* - $search['actions']: Rendered form buttons.
* - $search['hidden']: Hidden form elements. Used to validate forms when
* submitted.
*
* Modules can add to the search form, so it is recommended to check for their
* existence before printing. The default keys will always exist. To check for
* a module-provided field, use code like this:
* @code
* <?php if (isset($search['extra_field'])): ?>
* <div class="extra-field">
* <?php print $search['extra_field']; ?>
* </div>
* <?php endif; ?>
* @endcode
*
* @see template_preprocess_search_block_form()
*/
?>
<div class="container-inline">
<?php if (empty($variables['form']['#block']->subject)): ?>
<h2 class="element-invisible"><?php print t('Search form'); ?></h2>
<?php endif; ?>
<?php print $search_form; ?>
</div>
78 changes: 51 additions & 27 deletions templates/system/page.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,44 +13,46 @@


?>

<style>
</style>
<div<?php print $attributes; ?>>


<div id="offcanvas-full-screen" class="mobile-nav-panel offcanvas-full-screen" data-off-canvas data-transition="overlap">
<div class="offcanvas-full-screen-inner">
<button class="offcanvas-full-screen-close" aria-label="Close menu" type="button" data-close>
<button class=" offcanvas-full-screen-close" aria-label="Close menu" type="button" data-close>
<span aria-hidden="true">&times;</span>
</button>
<div class="form-item form-type-textfield form-item-search-block-form">
<label class="element-invisible" for="edit-search-block-form--2">Search </label>
<input title="Enter the terms you wish to search for." onblur="if (this.value == '') {this.value = 'Search';}" onfocus="if (this.value == 'Search') {this.value = '';}" placeholder="Search" type="text" id="edit-search-block-form--2" name="search_block_form" value="Search the archives..." size="40" maxlength="128" class="form-text">
</div>
<?php print render($page['navigation']); ?>
</div>
</div>






<div class="nav-wrapper">
<nav class="topnav" role="navigation">
<div class="site-branding">
<a href="https://upei.ca" title="<?php print t('Home'); ?>" rel="home" class="site-branding__logo">
<?php echo file_get_contents( $image_path . "upei.svg"); ?>
</a>
<?php if ($site_name): ?>
<a href="http://islandarchives.ca" class="site-branding__name" title="<?php print t('Home'); ?>" rel="home">IslandArchives </a>
<?php endif; ?>
<?php if ($site_slogan): ?>
<h2 class="site-branding__slogan"><?php print $site_slogan; ?></h2>
<?php endif; ?>
<div data-sticky-container>
<div class="nav-wrapper" data-sticky data-options="marginTop:0;" style="width:100%">
<nav class="topnav" role="navigation" >
<div class="site-branding">
<a href="https://upei.ca" title="<?php print t('Home'); ?>" rel="home" class="site-branding__logo">
<?php echo file_get_contents( $image_path . "upei.svg"); ?>
</a>
<?php if ($site_name): ?>
<a href="http://islandarchives.ca" class="site-branding__name" title="<?php print t('Home'); ?>" rel="home">IslandArchives </a>
<?php endif; ?>
<?php if ($site_slogan): ?>
<h2 class="site-branding__slogan"><?php print $site_slogan; ?></h2>
<?php endif; ?>
</div>
<div class="topnav-right">
<button onclick="searchDropdown()" class="search-dropdown-toggle button" type="button" data-toggle="search-dropdown"> <?php echo file_get_contents( $image_path . "Magnifying_glass_icon.svg"); ?> </button>
<?php print render($page['navigation']); ?>
</div>
<?php print render($page['navigation']); ?>
<button class="menu-icon light" type="button" data-toggle="offcanvas-full-screen"></button>
</nav>
</div>

<button class="menu-icon light" type="button" data-toggle="offcanvas-full-screen"></button>
</nav>
<div class="search-dropdown" id="search-dropdown" ><div class="dropdown-content">
<?php print render($page['search_dropdown']); ?>
</div></div>
</div>
</div>
<!--bottom stuff removed-->

<header class="l-header l-constrained" role="banner">
Expand Down Expand Up @@ -147,3 +149,25 @@
</footer>

</div>
<script>
/* When the user clicks on the button,
toggle between hiding and showing the dropdown content */
function searchDropdown() {
document.getElementById("search-dropdown").classList.toggle("show");
}

// Close the dropdown menu if the user clicks outside of it
window.onclick = function(event) {
if (!event.target.matches('.search-dropdown-toggle')) {
var dropdowns = document.getElementsByClassName("dropdown-content");
var i;
for (i = 0; i < dropdowns.length; i++) {
var openDropdown = dropdowns[i];
if (openDropdown.classList.contains('show')) {
openDropdown.classList.remove('show');
}
}
}
}

</script>
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@


?>

<style>
</style>
<div<?php print $attributes; ?>>


<div id="offcanvas-full-screen" class="mobile-nav-panel offcanvas-full-screen" data-off-canvas data-transition="overlap">
<div class="offcanvas-full-screen-inner">
<button class="offcanvas-full-screen-close" aria-label="Close menu" type="button" data-close>
Expand All @@ -24,31 +28,29 @@
</div>
</div>

<div data-sticky-container>
<div class="nav-wrapper" data-sticky data-options="marginTop:0;" style="width:100%">
<nav class="topnav" role="navigation" >
<div class="site-branding">
<a href="https://upei.ca" title="<?php print t('Home'); ?>" rel="home" class="site-branding__logo">
<?php echo file_get_contents( $image_path . "upei.svg"); ?>
</a>
<?php if ($site_name): ?>
<a href="http://islandarchives.ca" class="site-branding__name" title="<?php print t('Home'); ?>" rel="home">IslandArchives </a>
<?php endif; ?>
<?php if ($site_slogan): ?>
<h2 class="site-branding__slogan"><?php print $site_slogan; ?></h2>
<?php endif; ?>
</div>
<div class="topnav-right">
<button onclick="searchDropdown()" class="search-dropdown-toggle button" type="button" data-toggle="search-dropdown"> <?php echo file_get_contents( $image_path . "Magnifying_glass_icon.svg"); ?> </button>
<?php print render($page['navigation']); ?>





<div class="nav-wrapper">
<nav class="topnav" role="navigation">
<div class="site-branding">
<a href="https://upei.ca" title="<?php print t('Home'); ?>" rel="home" class="site-branding__logo">
<?php echo file_get_contents( $image_path . "upei.svg"); ?>
</a>
<?php if ($site_name): ?>
<a href="http://islandarchives.ca" class="site-branding__name" title="<?php print t('Home'); ?>" rel="home">IslandArchives </a>
<?php endif; ?>
<?php if ($site_slogan): ?>
<h2 class="site-branding__slogan"><?php print $site_slogan; ?></h2>
<?php endif; ?>
</div>
<button class="menu-icon light" type="button" data-toggle="offcanvas-full-screen"></button>
</nav>
<div class="search-dropdown" id="search-dropdown" ><div class="dropdown-content">
<?php print render($page['search_dropdown']); ?>
</div></div>
</div>
</div>
<?php print render($page['navigation']); ?>
<button class="menu-icon light" type="button" data-toggle="offcanvas-full-screen"></button>
</nav>
</div>

<!--bottom stuff removed-->

<header class="l-header l-constrained" role="banner">
Expand Down Expand Up @@ -145,25 +147,3 @@
</footer>

</div>
<script>
/* When the user clicks on the button,
toggle between hiding and showing the dropdown content */
function searchDropdown() {
document.getElementById("search-dropdown").classList.toggle("show");
}

// Close the dropdown menu if the user clicks outside of it
window.onclick = function(event) {
if (!event.target.matches('.search-dropdown-toggle')) {
var dropdowns = document.getElementsByClassName("dropdown-content");
var i;
for (i = 0; i < dropdowns.length; i++) {
var openDropdown = dropdowns[i];
if (openDropdown.classList.contains('show')) {
openDropdown.classList.remove('show');
}
}
}
}

</script>

0 comments on commit ecf21d8

Please sign in to comment.