/** * Implements template_preprocess_html(). */ function radix_preprocess_html(&$variables) { global $base_url; // // Add Bootstrap JS from CDN if bootstrap library is not installed. if (!module_exists('bootstrap_library')) { $base = parse_url($base_url); $url = $base['scheme'] . '://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js'; $jquery_ui_library = drupal_get_library('system', 'ui'); $jquery_ui_js = reset($jquery_ui_library['js']); drupal_add_js($url, array('type' => 'external', 'group' => JS_LIBRARY, 'weight' => $jquery_ui_js['weight'] - 1)); } // // // Add support for the Modenizr module. // // Load modernizr.js only if modernizr module is not present. // if (!module_exists('modernizr')) { // drupal_add_js(drupal_get_path('theme', 'radix') . '/assets/js/modernizr.js'); // } // Add meta for Bootstrap Responsive. // <meta name="viewport" content="width=device-width, initial-scale=1.0"> $element = array('#tag' => 'meta', '#attributes' => array('name' => 'viewport', 'content' => 'width=device-width, initial-scale=1.0')); drupal_add_html_head($element, 'bootstrap_responsive'); // Add some custom classes for panels pages. if (module_exists('page_manager') && count(page_manager_get_current_page())) { $variables['is_panel'] = TRUE; // Get the current panel display and add some classes to body. if ($display = panels_get_current_page_display()) { $variables['classes_array'][] = 'panel-layout-' . $display->layout; // Add a custom class for each region that has content. $regions = array_keys($display->panels); foreach ($regions as $region) { $variables['classes_array'][] = 'panel-region-' . $region; } } } }
function mytinytodo_page_add_library($module, $name) { global $base_path; if ($library = drupal_get_library($module, $name)) { if ($library['js']) { foreach ($library['js'] as $file => $info) { mytinytodo_page_add_js($file); } } if ($library['css']) { foreach ($library['css'] as $file => $info) { mytinytodo_page_add_css($file); } } } }
/** * Implements hook_js_alter(). */ function color_glass_js_alter(&$js) { // Exclude specified JavaScript files from theme. $excludes = _bootstrap_get_theme_info(NULL, 'exclude][js'); $theme_path = drupal_get_path('theme', 'color_glass'); // Add or replace JavaScript files when matching paths are detected. // Replacement files must begin with '_', like '_node.js'. $files = _bootstrap_file_scan_directory($theme_path . '/js', '/\\.js$/'); foreach ($files as $file) { $path = str_replace($theme_path . '/js/', '', $file->uri); // Detect if this is a replacement file. $replace = FALSE; if (preg_match('/^[_]/', $file->filename)) { $replace = TRUE; $path = dirname($path) . '/' . preg_replace('/^[_]/', '', $file->filename); } $matches = array(); if (preg_match('/^modules\\/([^\\/]*)/', $path, $matches)) { if (!module_exists($matches[1])) { continue; } else { $path = str_replace('modules/' . $matches[1], drupal_get_path('module', $matches[1]), $path); } } // Path should always exist to either add or replace JavaScript file. if (!empty($js[$path])) { // Replace file. if ($replace) { $js[$file->uri] = $js[$path]; $js[$file->uri]['data'] = $file->uri; unset($js[$path]); } else { $js[$file->uri] = drupal_js_defaults($file->uri); $js[$file->uri]['group'] = JS_THEME; } } } // Ensure jQuery Once is always loaded. // @see https://drupal.org/node/2149561 if (empty($js['misc/jquery.once.js'])) { $jquery_once = drupal_get_library('system', 'jquery.once'); $js['misc/jquery.once.js'] = $jquery_once['js']['misc/jquery.once.js']; $js['misc/jquery.once.js'] += drupal_js_defaults('misc/jquery.once.js'); } // Always add bootstrap.js last. $bootstrap = $theme_path . '/js/bootstrap.js'; $js[$bootstrap] = drupal_js_defaults($bootstrap); $js[$bootstrap]['group'] = JS_THEME; $js[$bootstrap]['scope'] = 'footer'; if (!empty($excludes)) { $js = array_diff_key($js, drupal_map_assoc($excludes)); } // Add Bootstrap settings. $js['settings']['data'][]['bootstrap'] = array('anchorsFix' => _bootstrap_setting('anchors_fix'), 'anchorsSmoothScrolling' => _bootstrap_setting('anchors_smooth_scrolling'), 'formHasError' => (int) _bootstrap_setting('forms_has_error_value_toggle'), 'popoverEnabled' => _bootstrap_setting('popover_enabled'), 'popoverOptions' => array('animation' => (int) _bootstrap_setting('popover_animation'), 'html' => (int) _bootstrap_setting('popover_html'), 'placement' => _bootstrap_setting('popover_placement'), 'selector' => _bootstrap_setting('popover_selector'), 'trigger' => implode(' ', array_filter(array_values((array) _bootstrap_setting('popover_trigger')))), 'triggerAutoclose' => (int) _bootstrap_setting('popover_trigger_autoclose'), 'title' => _bootstrap_setting('popover_title'), 'content' => _bootstrap_setting('popover_content'), 'delay' => (int) _bootstrap_setting('popover_delay'), 'container' => _bootstrap_setting('popover_container')), 'tooltipEnabled' => _bootstrap_setting('tooltip_enabled'), 'tooltipOptions' => array('animation' => (int) _bootstrap_setting('tooltip_animation'), 'html' => (int) _bootstrap_setting('tooltip_html'), 'placement' => _bootstrap_setting('tooltip_placement'), 'selector' => _bootstrap_setting('tooltip_selector'), 'trigger' => implode(' ', array_filter(array_values((array) _bootstrap_setting('tooltip_trigger')))), 'delay' => (int) _bootstrap_setting('tooltip_delay'), 'container' => _bootstrap_setting('tooltip_container'))); if ($bscdn_js = _bootstrap_setting('bscdn_js')) { $cdn_weight = -99.98999999999999; $js[$bscdn_js] = drupal_js_defaults($bscdn_js); $js[$bscdn_js]['type'] = 'external'; $js[$bscdn_js]['every_page'] = TRUE; $js[$bscdn_js]['weight'] = $cdn_weight; } }