Adding Twitter bootstrap support

This commit is contained in:
Corey Wagehoft
2011-11-07 22:35:52 -06:00
parent 4255324a7b
commit b0bcc89dd9
2 changed files with 161 additions and 3 deletions

View File

@@ -5,11 +5,16 @@ add_action('roots_head', 'roots_fout_b_gone');
add_action('roots_head', 'roots_1140_head');
add_action('roots_head', 'roots_adapt_head');
add_action('roots_head', 'roots_foundation_head');
add_action('roots_head', 'roots_bootstrap_head');
add_action('roots_stylesheets', 'roots_get_stylesheets');
add_action('roots_header_before', 'roots_1140_header_before');
add_action('roots_header_after', 'roots_1140_header_after');
add_action('roots_footer_before', 'roots_1140_footer_before');
add_action('roots_footer_after', 'roots_1140_footer_after');
add_action('roots_header_before', 'roots_bootstrap_header_before');
add_action('roots_header_after', 'roots_bootstrap_header_after');
add_action('roots_footer_before', 'roots_bootstrap_footer_before');
add_action('roots_footer_after', 'roots_bootstrap_footer_after');
add_action('roots_post_inside_before', 'roots_page_breadcrumb');
function roots_google_analytics() {
@@ -90,6 +95,49 @@ function roots_foundation_head() {
}
}
function roots_bootstrap_head() {
global $roots_options;
$roots_css_framework = $roots_options['css_framework'];
$roots_bootstrap_js = $roots_options['bootstrap_javascript'];
$roots_bootstrap_less_js = $roots_options['bootstrap_less_javascript'];
$template_uri = get_template_directory_uri();
if ($roots_css_framework === 'bootstrap') {
echo "\t<!--[if lt IE 9]>\n";
echo "\t\t<script src=\"http://html5shim.googlecode.com/svn/trunk/html5.js\"></script>\n";
echo "\t<![endif]-->\n";
}
if ($roots_css_framework === 'bootstrap_less') {
echo "\t<!--[if lt IE 9]>\n";
echo "\t\t<script src=\"http://html5shim.googlecode.com/svn/trunk/html5.js\"></script>\n";
echo "\t<![endif]-->\n";
echo "\t<script src=\"$template_uri/js/bootstrap/less-1.1.3.min.js\"></script>\n";
}
if ($roots_bootstrap_js === true) {
$roots_options['bootstrap_less_javascript'] = false;
echo "\t<script src=\"$template_uri/js/bootstrap/bootstrap-alerts.js\"></script>\n";
echo "\t<script src=\"$template_uri/js/bootstrap/bootstrap-buttons.js\"></script>\n";
echo "\t<script src=\"$template_uri/js/bootstrap/bootstrap-dropdown.js\"></script>\n";
echo "\t<script src=\"$template_uri/js/bootstrap/bootstrap-modal.js\"></script>\n";
echo "\t<script src=\"$template_uri/js/bootstrap/bootstrap-popover.js\"></script>\n";
echo "\t<script src=\"$template_uri/js/bootstrap/bootstrap-scrollspy.js\"></script>\n";
echo "\t<script src=\"$template_uri/js/bootstrap/bootstrap-tabs.js\"></script>\n";
echo "\t<script src=\"$template_uri/js/bootstrap/bootstrap-twipsy.js\"></script>\n";
}
if ($roots_bootstrap_less_js === true) {
$roots_options['bootstrap_javascript'] = false;
echo "\t<script src=\"$template_uri/js/bootstrap/bootstrap-alerts.js\"></script>\n";
echo "\t<script src=\"$template_uri/js/bootstrap/bootstrap-buttons.js\"></script>\n";
echo "\t<script src=\"$template_uri/js/bootstrap/bootstrap-dropdown.js\"></script>\n";
echo "\t<script src=\"$template_uri/js/bootstrap/bootstrap-modal.js\"></script>\n";
echo "\t<script src=\"$template_uri/js/bootstrap/bootstrap-popover.js\"></script>\n";
echo "\t<script src=\"$template_uri/js/bootstrap/bootstrap-scrollspy.js\"></script>\n";
echo "\t<script src=\"$template_uri/js/bootstrap/bootstrap-tabs.js\"></script>\n";
echo "\t<script src=\"$template_uri/js/bootstrap/bootstrap-twipsy.js\"></script>\n";
}
}
function roots_get_stylesheets() {
global $roots_options;
$roots_css_framework = $roots_options['css_framework'];
@@ -134,6 +182,12 @@ function roots_get_stylesheets() {
case 'less' :
$styles .= stylesheet_link_tag('/less/less.css');
break;
case 'bootstrap' :
$styles .= stylesheet_link_tag('/bootstrap/bootstrap.css');
break;
case 'bootstrap_less' :
$styles .= stylesheet_link_tag_boostrap_less('/bootstrap/lib/bootstrap.less');
break;
}
if (class_exists('RGForms')) {
@@ -167,6 +221,11 @@ function stylesheet_link_tag($file, $tabs = 0, $newline = true) {
return $indent . '<link rel="stylesheet" href="' . get_template_directory_uri() . '/css' . $file . '">' . ($newline ? "\n" : "");
}
function stylesheet_link_tag_boostrap_less($file, $tabs = 0, $newline = true) {
$indent = str_repeat("\t", $tabs);
return $indent . '<link rel="stylesheet/less" media="all" href="' . get_template_directory_uri() . '/css' . $file . '">' . ($newline ? "\n" : "");
}
function roots_1140_header_before() {
global $roots_options;
$roots_css_framework = $roots_options['css_framework'];
@@ -200,6 +259,39 @@ function roots_1140_footer_after() {
echo "</div></div><!-- /.row /.container -->\n";
}
}
function roots_bootstrap_header_before() {
global $roots_options;
$roots_css_framework = $roots_options['css_framework'];
if ($roots_css_framework === 'bootstrap' || $roots_css_framework === 'bootstrap_less') {
echo '<div class="container">', "\n";
}
}
function roots_bootstrap_header_after() {
global $roots_options;
$roots_css_framework = $roots_options['css_framework'];
if ($roots_css_framework === 'bootstrap' || $roots_css_framework === 'bootstrap_less') {
echo "</div><!-- /.container -->\n";
echo '<div class="container">', "\n";
}
}
function roots_bootstrap_footer_before() {
global $roots_options;
$roots_css_framework = $roots_options['css_framework'];
if ($roots_css_framework === 'bootstrap' || $roots_css_framework === 'bootstrap_less') {
echo "</div><!-- /.container -->\n";
echo '<div class="container">', "\n";
}
}
function roots_bootstrap_footer_after() {
global $roots_options;
$roots_css_framework = $roots_options['css_framework'];
if ($roots_css_framework === 'bootstrap' || $roots_css_framework === 'bootstrap_less') {
echo "</div><!-- /.container -->\n";
}
}
function roots_page_breadcrumb() {
global $post;