From 4ce09c58805358204b31ebe72bd5f7034d0beb8c Mon Sep 17 00:00:00 2001
From: Jeff Burnz <jeff@adaptivethemes.com>
Date: Wed, 2 Mar 2011 18:02:13 +0100
Subject: [PATCH] Issue #679478  min-max width

---
 adaptivetheme/inc/template.process.inc             |   10 +++-
 adaptivetheme/theme-settings.php                   |   72 ++++++++++++++++++++
 adaptivetheme_subtheme/adaptivetheme_subtheme.info |    3 +
 3 files changed, 84 insertions(+), 1 deletions(-)

diff --git a/adaptivetheme/inc/template.process.inc b/adaptivetheme/inc/template.process.inc
index 1b49b8c..70706e9 100644
--- a/adaptivetheme/inc/template.process.inc
+++ b/adaptivetheme/inc/template.process.inc
@@ -76,7 +76,15 @@ function adaptivetheme_preprocess_html(&$vars) {
         $styles[] = '.two-sidebars .region-sidebar-second{width:' . $sidebar_last_width . 'px; position: relative;' . $left . ':' . $push_right . 'px;}' . "\n";
       }
       $vars['at_layout'] = implode('', $styles);
-      $vars['layout'] = $vars['at_layout_width'] . $vars['at_layout'];
+      if (theme_get_setting('layout_minmax_toggle') == 1) {
+        $min_width = theme_get_setting('layout_min_width');
+        $max_width = theme_get_setting('layout_max_width');
+        $vars['min_max_width'] = 'div.container{min-width:'. $min_width . '; max-width:' . $max_width . ';}';
+        $vars['layout'] = $vars['at_layout_width'] . $vars['at_layout'] . $vars['min_max_width'];
+      }
+      else {
+        $vars['layout'] = $vars['at_layout_width'] . $vars['at_layout'];
+      }
     }
     else {
       $vars['layout'] = $vars['at_layout_width'];
diff --git a/adaptivetheme/theme-settings.php b/adaptivetheme/theme-settings.php
index 1266771..03ed579 100644
--- a/adaptivetheme/theme-settings.php
+++ b/adaptivetheme/theme-settings.php
@@ -48,6 +48,78 @@ function adaptivetheme_form_system_theme_settings_alter(&$form, $form_state) {
         ),
         //'#attributes' => array('class' => 'field-layout-width'),
       );
+      $form['layout']['page_layout']['layout_minmax_toggle'] = array(
+        '#prefix' => '<div class="page-width-toggle">',
+        '#suffix' => '</div>',
+        '#type' => 'checkbox',
+        '#title' => t('Set min/max widths: ') . '<span class="description">' . t('this enables a flexible width with a minimum and maximum page width.') . '</span>',
+        '#default_value' => theme_get_setting('layout_minmax_toggle'),
+        '#states' => array(
+          'visible' => array(
+              '#edit-layout-width' => array(
+                'value' => t('100%'),
+              ),
+          ),
+        ),
+      );
+      $form['layout']['page_layout']['layout_min_width'] = array(
+        '#type'  => 'select',
+        '#title' => t('Min width'),
+        '#description' => t('Set a min width.'),
+        '#default_value' => theme_get_setting('layout_min_width'),
+        '#options' => array(
+          '600px' => t('600px'),
+          '660px' => t('660px'),
+          '720px' => t('720px'),
+          '780px' => t('780px'),
+          '840px' => t('840px'),
+          '900px' => t('900px'),
+          '960px' => t('960px'),
+          '1020px' => t('1020px'),
+          '1080px' => t('1080px'),
+          '1140px' => t('1140px'),
+          '1200px' => t('1200px'),
+          '1260px' => t('1260px'),
+          '1320px' => t('1320px'),
+          '1380px' => t('1380px'),
+          '1440px' => t('1440px'),
+          '1500px' => t('1500px'),
+        ),
+        '#states' => array(
+          'visible' => array(
+            "input[name='layout_minmax_toggle']" => array("checked" => TRUE),
+          ),
+        ),
+      );
+      $form['layout']['page_layout']['layout_max_width'] = array(
+        '#type'  => 'select',
+        '#title' => t('Max width'),
+        '#description' => t('Set a max width.'),
+        '#default_value' => theme_get_setting('layout_max_width'),
+        '#options' => array(
+          '600px' => t('600px'),
+          '660px' => t('660px'),
+          '720px' => t('720px'),
+          '780px' => t('780px'),
+          '840px' => t('840px'),
+          '900px' => t('900px'),
+          '960px' => t('960px'),
+          '1020px' => t('1020px'),
+          '1080px' => t('1080px'),
+          '1140px' => t('1140px'),
+          '1200px' => t('1200px'),
+          '1260px' => t('1260px'),
+          '1320px' => t('1320px'),
+          '1380px' => t('1380px'),
+          '1440px' => t('1440px'),
+          '1500px' => t('1500px'),
+        ),
+        '#states' => array(
+          'visible' => array(
+            "input[name='layout_minmax_toggle']" => array("checked" => TRUE),
+          ),
+        ),
+      );
     } // endif width
     if (theme_get_setting('layout_enable_sidebars') == 'on') {
       $form['layout']['page_layout']['layout_sidebar_first_width'] = array(
diff --git a/adaptivetheme_subtheme/adaptivetheme_subtheme.info b/adaptivetheme_subtheme/adaptivetheme_subtheme.info
index e7493d4..1b52aad 100644
--- a/adaptivetheme_subtheme/adaptivetheme_subtheme.info
+++ b/adaptivetheme_subtheme/adaptivetheme_subtheme.info
@@ -128,6 +128,9 @@
   settings[menu_item_span_elements]        = 0
   settings[layout_method]                  = '0'
   settings[layout_width]                   = '960px'
+  settings[layout_min_width]               = '960px'
+  settings[layout_max_width]               = '1200px'
+  settings[layout_minmax_toggle]           = 0
   settings[layout_sidebar_first_width]     = '240'
   settings[layout_sidebar_last_width]      = '240'
   settings[layout_enable_settings]         = 'on'
-- 
1.7.4.msysgit.0

