fixes #166, #196 and #197 - adding full width option and applying in

full width template, thx @johnnypeck!
This commit is contained in:
Ben Word
2012-01-08 11:58:57 -07:00
parent 320ce427e8
commit 9da422e008
3 changed files with 49 additions and 18 deletions

View File

@@ -1,28 +1,33 @@
jQuery.noConflict(); jQuery.noConflict();
jQuery(document).ready(function(){
jQuery(document).ready(function(){
var $main = jQuery('#main_class'); var $main = jQuery('#main_class');
var $sidebar = jQuery('#sidebar_class'); var $sidebar = jQuery('#sidebar_class');
var $fullwidth = jQuery('#fullwidth_class');
var framework = jQuery('.roots_css_frameworks select option:selected').val(); var framework = jQuery('.roots_css_frameworks select option:selected').val();
var user_main_class = $main.val(); var user_main_class = $main.val();
var user_sidebar_class = $sidebar.val(); var user_sidebar_class = $sidebar.val();
var user_fullwidth_class = $fullwidth.val();
jQuery('.roots_css_frameworks select').change(function (e) { jQuery('.roots_css_frameworks select').change(function (e) {
var main_class = roots_css_frameworks[this.value].classes.main; var main_class = roots_css_frameworks[this.value].classes.main;
var sidebar_class = roots_css_frameworks[this.value].classes.sidebar; var sidebar_class = roots_css_frameworks[this.value].classes.sidebar;
var fullwidth_class = roots_css_frameworks[this.value].classes.fullwidth;
// if the selected framework was the one originally set, load the original classes instead of the defaults // if the selected framework was the one originally set, load the original classes instead of the defaults
if (this.value === framework) { if (this.value === framework) {
$main.val(user_main_class); $main.val(user_main_class);
$sidebar.val(user_sidebar_class); $sidebar.val(user_sidebar_class);
$fullwidth.val(user_fullwidth_class);
} else { } else {
$main.val(main_class); $main.val(main_class);
$sidebar.val(sidebar_class); $sidebar.val(sidebar_class);
$fullwidth.val(fullwidth_class);
} }
$main.siblings('small').children().text(main_class); $main.siblings('small').children().text(main_class);
$sidebar.siblings('small').children().text(sidebar_class); $sidebar.siblings('small').children().text(sidebar_class);
$fullwidth.siblings('small').children().text(fullwidth_class);
}); });
}); });

View File

@@ -63,7 +63,8 @@ $roots_css_frameworks = array(
'classes' => array( 'classes' => array(
'container' => 'span-24', 'container' => 'span-24',
'main' => 'span-14 append-1', 'main' => 'span-14 append-1',
'sidebar' => 'span-8 prepend-1 last' 'sidebar' => 'span-8 prepend-1 last',
'fullwidth' => 'span-24'
) )
), ),
'960gs_12' => array( '960gs_12' => array(
@@ -72,7 +73,8 @@ $roots_css_frameworks = array(
'classes' => array( 'classes' => array(
'container' => 'container_12', 'container' => 'container_12',
'main' => 'grid_7 suffix_1', 'main' => 'grid_7 suffix_1',
'sidebar' => 'grid_4' 'sidebar' => 'grid_4',
'fullwidth' => 'grid_12'
) )
), ),
'960gs_16' => array( '960gs_16' => array(
@@ -81,7 +83,8 @@ $roots_css_frameworks = array(
'classes' => array( 'classes' => array(
'container' => 'container_16', 'container' => 'container_16',
'main' => 'grid_9 suffix_1', 'main' => 'grid_9 suffix_1',
'sidebar' => 'grid_6' 'sidebar' => 'grid_6',
'fullwidth' => 'grid_16'
) )
), ),
'960gs_24' => array( '960gs_24' => array(
@@ -90,16 +93,18 @@ $roots_css_frameworks = array(
'classes' => array( 'classes' => array(
'container' => 'container_24', 'container' => 'container_24',
'main' => 'grid_15 suffix_1', 'main' => 'grid_15 suffix_1',
'sidebar' => 'grid_8' 'sidebar' => 'grid_8',
'fullwidth' => 'grid_24'
) )
), ),
'1140' => array( '1140' => array(
'name' => '1140', 'name' => '1140',
'label' => __('1140', 'roots'), 'label' => __('1140', 'roots'),
'classes' => array( 'classes' => array(
'container' => '', 'container' => 'row',
'main' => 'eightcol', 'main' => 'eightcol',
'sidebar' => 'fourcol last' 'sidebar' => 'fourcol last',
'fullwidth' => 'twelvecol'
) )
), ),
'adapt' => array( 'adapt' => array(
@@ -108,7 +113,8 @@ $roots_css_frameworks = array(
'classes' => array( 'classes' => array(
'container' => 'container_12 clearfix', 'container' => 'container_12 clearfix',
'main' => 'grid_7 suffix_1', 'main' => 'grid_7 suffix_1',
'sidebar' => 'grid_4' 'sidebar' => 'grid_4',
'fullwidth' => 'grid_12'
) )
), ),
'less' => array( 'less' => array(
@@ -117,7 +123,8 @@ $roots_css_frameworks = array(
'classes' => array( 'classes' => array(
'container' => 'container', 'container' => 'container',
'main' => '', 'main' => '',
'sidebar' => '' 'sidebar' => '',
'fullwidth' => ''
) )
), ),
'foundation' => array( 'foundation' => array(
@@ -126,7 +133,8 @@ $roots_css_frameworks = array(
'classes' => array( 'classes' => array(
'container' => 'row', 'container' => 'row',
'main' => 'eight columns', 'main' => 'eight columns',
'sidebar' => 'four columns' 'sidebar' => 'four columns',
'fullwidth' => 'twelve columns'
) )
), ),
'bootstrap' => array( 'bootstrap' => array(
@@ -135,7 +143,8 @@ $roots_css_frameworks = array(
'classes' => array( 'classes' => array(
'container' => 'row', 'container' => 'row',
'main' => 'span11', 'main' => 'span11',
'sidebar' => 'span5' 'sidebar' => 'span5',
'fullwidth' => 'span16'
) )
), ),
'bootstrap_less' => array( 'bootstrap_less' => array(
@@ -144,7 +153,8 @@ $roots_css_frameworks = array(
'classes' => array( 'classes' => array(
'container' => 'row', 'container' => 'row',
'main' => 'span11', 'main' => 'span11',
'sidebar' => 'span5' 'sidebar' => 'span5',
'fullwidth' => 'span16'
) )
), ),
'none' => array( 'none' => array(
@@ -153,7 +163,8 @@ $roots_css_frameworks = array(
'classes' => array( 'classes' => array(
'container' => '', 'container' => '',
'main' => '', 'main' => '',
'sidebar' => '' 'sidebar' => '',
'fullwidth' => ''
) )
) )
); );
@@ -179,6 +190,7 @@ function roots_get_default_theme_options($default_framework = '') {
'container_class' => $default_framework_settings['classes']['container'], 'container_class' => $default_framework_settings['classes']['container'],
'main_class' => $default_framework_settings['classes']['main'], 'main_class' => $default_framework_settings['classes']['main'],
'sidebar_class' => $default_framework_settings['classes']['sidebar'], 'sidebar_class' => $default_framework_settings['classes']['sidebar'],
'fullwidth_class' => $default_framework_settings['classes']['fullwidth'],
'google_analytics_id' => '', 'google_analytics_id' => '',
'root_relative_urls' => true, 'root_relative_urls' => true,
'clean_menu' => true, 'clean_menu' => true,
@@ -243,6 +255,16 @@ function roots_theme_options_render_page() {
</td> </td>
</tr> </tr>
<tr valign="top"><th scope="row"><?php _e('Full Width CSS Classes', 'roots'); ?></th>
<td>
<fieldset><legend class="screen-reader-text"><span><?php _e('#fullwidth CSS Classes', 'roots'); ?></span></legend>
<input type="text" name="roots_theme_options[fullwidth_class]" id="fullwidth_class" value="<?php echo esc_attr($roots_options['fullwidth_class']); ?>" class="regular-text" />
<br />
<small class="description"><?php _e('Default:', 'roots'); ?> <span><?php echo $roots_default_options['fullwidth_class']; ?></span></small>
</fieldset>
</td>
</tr>
<?php if($roots_options['css_framework'] == 'bootstrap') { ?> <?php if($roots_options['css_framework'] == 'bootstrap') { ?>
<tr valign="top"><th scope="row"><?php _e('Bootstrap Javascript Packages', 'roots'); ?></th> <tr valign="top"><th scope="row"><?php _e('Bootstrap Javascript Packages', 'roots'); ?></th>
<td> <td>
@@ -328,6 +350,10 @@ function roots_theme_options_validate($input) {
$output['sidebar_class'] = wp_filter_nohtml_kses($input['sidebar_class']); $output['sidebar_class'] = wp_filter_nohtml_kses($input['sidebar_class']);
} }
if (isset($input['fullwidth_class'])) {
$output['fullwidth_class'] = wp_filter_nohtml_kses($input['fullwidth_class']);
}
if (isset($input['google_analytics_id'])) { if (isset($input['google_analytics_id'])) {
if (preg_match('/^ua-\d{4,9}-\d{1,4}$/i', $input['google_analytics_id'])) { if (preg_match('/^ua-\d{4,9}-\d{1,4}$/i', $input['google_analytics_id'])) {
$output['google_analytics_id'] = $input['google_analytics_id']; $output['google_analytics_id'] = $input['google_analytics_id'];

View File

@@ -6,7 +6,7 @@ get_header(); ?>
<?php roots_content_before(); ?> <?php roots_content_before(); ?>
<div id="content" class="<?php echo $roots_options['container_class']; ?>"> <div id="content" class="<?php echo $roots_options['container_class']; ?>">
<?php roots_main_before(); ?> <?php roots_main_before(); ?>
<div id="main" class="<?php echo $roots_options['container_class']; ?>" role="main"> <div id="main" class="<?php echo $roots_options['fullwidth_class']; ?>" role="main">
<div class="container"> <div class="container">
<?php roots_loop_before(); ?> <?php roots_loop_before(); ?>
<?php get_template_part('loop', 'page'); ?> <?php get_template_part('loop', 'page'); ?>