Example #1
0
function nbcu_page_alter($page)
{
    $typeKit = "<script src='https://use.typekit.net/duz4krn.js'></script>\n   <script>try{Typekit.load({ async: true });}catch(e){}</script>";
    $ie_js_files = "\n\t<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->\n    <!--[if lt IE 9]>\n      <script src='https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js'></script>\n      <script src='https://oss.maxcdn.com/respond/1.4.2/respond.min.js'></script>\n    <![endif]-->\n\t";
    include_once __DIR__ . '/mobile-detect/mdetect.php';
    $md = new uagent_info();
    $ua = $md->Get_Uagent();
    $isEdge = "false";
    if (strpos($ua, 'edge') !== false) {
        $isEdge = "true";
    }
    // dpm($ua);
    $mobileTest = $md->DetectMobileLong();
    $mobileDetect = "<script type='text/javascript'>\n    var useSkrollr = " . $mobileTest . ";\n    var isEdge = " . $isEdge . ";\n  </script>";
    $ie_scripts = array('#type' => 'markup', '#markup' => $ie_js_files, '#weight' => 10000);
    $typekit_scripts = array('#type' => 'markup', '#markup' => $typeKit, '#weight' => 0);
    $mobile_detect = array('#type' => 'markup', '#markup' => $mobileDetect, '#weight' => 0);
    drupal_add_html_head($ie_scripts, 'ie-helpers');
    drupal_add_html_head($typekit_scripts, 'typekit');
    drupal_add_html_head($mobile_detect, 'mobile-detect');
}