Esempio n. 1
0
/**
 * Implements hook_js_alter().
 */
function omega_js_alter(&$js)
{
    // If the AJAX.js isn't included... we don't need the ajaxPageState settings!
    if (!isset($js['misc/ajax.js']) && isset($js['settings']['data'])) {
        foreach ($js['settings']['data'] as $delta => $setting) {
            if (array_key_exists('ajaxPageState', $setting)) {
                if (count($setting) == 1) {
                    unset($js['settings']['data'][$delta]);
                } else {
                    unset($js['settings']['data'][$delta]['ajaxPageState']);
                }
            }
        }
    }
    if (!omega_extension_enabled('assets')) {
        return;
    }
    if ($regex = omega_theme_get_setting('omega_js_exclude_regex')) {
        omega_exclude_assets($js, $regex);
    }
    // Move the specified JavaScript files to the footer.
    if (($footer = omega_theme_get_setting('omega_js_footer')) && is_array($footer)) {
        $regex = omega_generate_path_regex($footer);
        $mapping = omega_generate_asset_mapping($js);
        foreach (preg_grep($regex, $mapping) as $key => $match) {
            $js[$key]['scope'] = 'footer';
        }
    }
}
/**
 * Implements hook_js_alter().
 */
function omega_js_alter(&$js)
{
    if (!omega_extension_enabled('assets')) {
        return;
    }
    if ($regex = omega_theme_get_setting('omega_js_exclude_regex')) {
        omega_exclude_assets($js, $regex);
    }
    // Move the specified JavaScript files to the footer.
    if (($footer = omega_theme_get_setting('omega_js_footer')) && is_array($footer)) {
        $regex = omega_generate_path_regex($footer);
        $mapping = omega_generate_asset_mapping($js);
        foreach (preg_grep($regex, $mapping) as $key => $match) {
            $js[$key]['scope'] = 'footer';
        }
    }
}