/**
 * Adds the header settings to the settings form.
 *
 * @param array $form
 *   The form element array to add the settings fields to.
 */
function _nitobe_add_header_settings(&$form)
{
    $form["nitobe_header_settings"] = array("#type" => "fieldset", "#title" => "Page header settings");
    // -- Should the alternating color title effect be applied?
    $default = theme_get_setting("nitobe_title_effect", "nitobe");
    $desc = t("Should the title be adjusted to apply an alternate color to every other word and remove inter-word spacing?");
    $form["nitobe_header_settings"]["nitobe_title_effect"] = array("#type" => "checkbox", "#title" => t("Apply title effect"), "#default_value" => $default, "#description" => $desc);
    // -- Get the header image list.
    $images = _nitobe_get_header_list(TRUE);
    $options = array("<random>" => "<Random Header Image>");
    foreach ($images as $filename => $data) {
        $options[$filename] = $data->pretty_name;
    }
    // -- The setting for the header image.
    $current = theme_get_setting("nitobe_header_image", "nitobe");
    $default = in_array($current, array_keys($options)) ? $current : "<random>";
    $form["nitobe_header_settings"]["nitobe_header_image"] = array("#type" => "select", "#title" => t("Header image"), "#options" => $options, "#default_value" => $default);
    // -- Show the header image if the mastead region has content?
    $default = theme_get_setting("nitobe_masthead_always_show", "nitobe");
    $desc = t("By default, if there is block content in the Masthead region, the header image will not be displayed. Check this box to cause the header image to be displayed as the region's background image.");
    $form["nitobe_header_settings"]["nitobe_masthead_always_show"] = array("#type" => "checkbox", "#title" => t("Always show masthead image"), "#default_value" => $default, "#description" => $desc);
}
Exemple #2
0
/**
 * Generates the JavaScript for rotating the header image.
 *
 * @return string
 *   The JavaScript for rotating the header.
 */
function _nitobe_random_header_js()
{
    global $base_url;
    $files = _nitobe_get_header_list();
    $names = array();
    foreach ($files as $file => $data) {
        $names[] = $base_url . '/' . $file;
    }
    $names_js = drupal_json_encode($names);
    $js = <<<EOJS
jQuery(document).ready(function() {
  var names = {$names_js};
  jQuery(".region-masthead").css("background-image", "url(" + names[Math.floor(Math.random() * names.length)] + ")");
});
EOJS;
    return $js;
}