adding grid debug capabilities, making search text configurable
authorhimerus
Fri, 4 Jun 2010 16:59:25 +0000 (16:59 +0000)
committerhimerus
Fri, 4 Jun 2010 16:59:25 +0000 (16:59 +0000)
css/960-rtl.css
css/debug.css [new file with mode: 0644]
i/debug/12_col.png [new file with mode: 0644]
i/debug/16_col.png [new file with mode: 0644]
i/debug/24_col.png [new file with mode: 0644]
js/debug.js [new file with mode: 0644]
js/omega.js
omega.info
preprocess/preprocess-html.inc
template.php
theme-settings.php

index ae20664..9dc10d0 100644 (file)
 
 .alpha {
   margin-left: 10px;
-  margin-right: 0;
+  margin-right: 0 !important;
 }
 
 .omega {
-  margin-left: 0;
+  margin-left: 0 !important;
   margin-right: 10px;
 }
 
diff --git a/css/debug.css b/css/debug.css
new file mode 100644 (file)
index 0000000..bd136a6
--- /dev/null
@@ -0,0 +1,56 @@
+/* $Id$ */
+#omega-debug {
+       position: fixed;
+       bottom: 0;
+       left: 0;
+       background: #000;
+       color: #FFF;
+       padding: 5px 10px;
+}
+#omega-debug hr {
+       height: 1px;
+       border-top: 1px dashed #FFF;
+       background: none;
+}
+#omega-debug a {
+       display: block;
+       text-decoration: none;
+       color: #FFF;
+}
+body.show-grid .container-16 {
+  background-image: url(../i/debug/16_col.png);
+}
+body.show-grid .container-12 {
+  background-image: url(../i/debug/12_col.png);
+}
+body.show-grid .container-24 {
+  background-image: url(../i/debug/24_col.png);
+}
+
+body.show-grid .grid-1:hover,
+body.show-grid .grid-2:hover,
+body.show-grid .grid-3:hover,
+body.show-grid .grid-4:hover,
+body.show-grid .grid-5:hover,
+body.show-grid .grid-6:hover,
+body.show-grid .grid-7:hover,
+body.show-grid .grid-8:hover,
+body.show-grid .grid-9:hover,
+body.show-grid .grid-10:hover,
+body.show-grid .grid-11:hover,
+body.show-grid .grid-12:hover,
+body.show-grid .grid-13:hover,
+body.show-grid .grid-14:hover,
+body.show-grid .grid-15:hover,
+body.show-grid .grid-16:hover,
+body.show-grid .grid-17:hover,
+body.show-grid .grid-18:hover,
+body.show-grid .grid-19:hover,
+body.show-grid .grid-20:hover,
+body.show-grid .grid-21:hover,
+body.show-grid .grid-22:hover,
+body.show-grid .grid-23:hover,
+body.show-grid .grid-24:hover {
+  background-color: rgba(0, 115, 186, .2);
+  outline: 1px dashed #0073ba;
+}
\ No newline at end of file
diff --git a/i/debug/12_col.png b/i/debug/12_col.png
new file mode 100644 (file)
index 0000000..ff0c6b9
Binary files /dev/null and b/i/debug/12_col.png differ
diff --git a/i/debug/16_col.png b/i/debug/16_col.png
new file mode 100644 (file)
index 0000000..1850f89
Binary files /dev/null and b/i/debug/16_col.png differ
diff --git a/i/debug/24_col.png b/i/debug/24_col.png
new file mode 100644 (file)
index 0000000..ea287ce
Binary files /dev/null and b/i/debug/24_col.png differ
diff --git a/js/debug.js b/js/debug.js
new file mode 100644 (file)
index 0000000..279033f
--- /dev/null
@@ -0,0 +1,71 @@
+//$Id$
+Drupal.grid_debug = function (context) {
+       // add an extra identifying class to body
+       omega('body').addClass('has-grid');
+       if(Drupal.settings.grid_overlay_state) {
+               // grid is on by default
+               omega('body').addClass('show-grid');
+               var debug_next_state = "Off";
+       }
+       else {
+               // grid is off by default
+               var debug_next_state = "On";
+       }
+       // add toggle button/section
+       omega('#page').after('<div id="omega-debug"><a href="#">Turn Debug <strong>'+debug_next_state+'</strong></a><div id="omega-debug-info"></div></div>');
+       // toggle info between clicks
+       omega('#omega-debug a').click(function(){
+               if(debug_next_state == "Off") {
+                       omega('#omega-debug a').html('Turn Debug <strong>On</strong>');
+                       omega('body').removeClass('show-grid');
+                       debug_next_state = "On";
+                       console.log('Overlay Turned Off...');
+                       return false;
+               }
+               else {
+                       omega('#omega-debug a').html('Turn Debug <strong>Off</strong>');
+                       omega('body').addClass('show-grid');
+                       debug_next_state = "Off";
+                       console.log('Overlay Turned On...');
+                       return false;
+               }       
+       });
+       
+       // show info on hovering region
+       omega('.has-grid .grid-1, .has-grid .grid-2, .has-grid .grid-3, .has-grid .grid-4, .has-grid .grid-5, .has-grid .grid-6, .has-grid .grid-7, .has-grid .grid-8, .has-grid .grid-9, .has-grid .grid-10, .has-grid .grid-11, .has-grid .grid-12, .has-grid .grid-13, .has-grid .grid-14, .has-grid .grid-15, .has-grid .grid-16, .has-grid .grid-17, .has-grid .grid-18, .has-grid .grid-19, .has-grid .grid-20, .has-grid .grid-21, .has-grid .grid-22, .has-grid .grid-23, .has-grid .grid-24')
+       .hover(function(){
+               if(omega(this).parents('body').hasClass('show-grid')) {
+                       var grid_classes = '';
+                       var i = 1;
+                       var grid_size = 'undefined';
+                       for(i = 1; i <= 24; i++) {
+                               var grid_size_test = 'grid-'+i; 
+                               if(omega(this).hasClass(grid_size_test)) {
+                                       var grid_size = grid_size_test;
+                               }
+                       }
+                       
+                       var container_parent = omega(this).parents('div[class*=container]');
+                       if(container_parent.hasClass('container-12')) {
+                               var container_size = 'container-12';
+                       }
+                       if(container_parent.hasClass('container-16')) {
+                               var container_size = 'container-16';
+                       }
+                       if(container_parent.hasClass('container-24')) {
+                               var container_size = 'container-24';
+                       }
+                       omega('#omega-debug-info').html('<hr /><div><strong>Container class: '+container_size+'</div><div><strong>Grid class: </strong>'+grid_size+'</div>');
+                       //omega('#omega-debug-info').html(container_info);
+               }
+       }, function(){
+               if(omega(this).parents('body').hasClass('show-grid')) {
+                       omega('#omega-debug-info').html('');
+               }
+       });
+       
+};
+
+omega(document).ready(function(){
+       var debug = new Drupal.grid_debug();
+});
\ No newline at end of file
index 1b4a596..73bf232 100644 (file)
@@ -18,5 +18,5 @@ function populateElement(selector, defvalue) {
 omega = jQuery.noConflict();
 omega(document).ready(function(){
        // give the search box some fancy stuff
-       populateElement('#search-box input.form-text, #search-block-form input.form-text', 'search...');
+       populateElement('#search-box input.form-text, #search-block-form input.form-text', Drupal.settings.default_search_text);
 });
\ No newline at end of file
index a40c2bb..0daaeb1 100644 (file)
@@ -13,7 +13,6 @@ stylesheets[all][] = css/defaults.css
 stylesheets[all][] = css/custom.css
 
 scripts[] = js/omega.js
-;scripts[] = js/
 
 regions[sidebar_first] = sidebar first
 regions[sidebar_second] = sidebar second
index f89e3ed..59ddcb4 100644 (file)
@@ -1,9 +1,39 @@
 <?php
-// NINESIXTY - Make sure framework styles are placed above all others.
-if(isset($vars['css'])) {
-  $vars['css_alt'] = omega_css_reorder($vars['css']);
-  $vars['styles'] = drupal_get_css($vars['css_alt']);
+// $Id$
+
+// grid debugging
+global $user;
+$debug_access = FALSE;
+$debug_roles = theme_get_setting('debug_grid_roles');
+if(!isset($user->roles[1])) {
+       // Check to see if $user has the appropriate role.
+       foreach($debug_roles AS $k => $v) {
+               if ($v && $user->roles[$k]) {
+                 // user has access to debug tools
+                 $debug_access = TRUE;
+               }
+       }
 }
+// if grid debug is ON, and user either has access by role, or is uid 1
+if(theme_get_setting('debug_grid_toggle') && ($debug_access || $user->uid == 1)) {
+       $debug_settings = array(
+    'grid_overlay_on' => theme_get_setting('debug_grid_toggle'),
+    'grid_overlay_state' => theme_get_setting('debug_grid_toggle_state'),
+       );
+       drupal_add_js($debug_settings, 'setting');
+       drupal_add_js(drupal_get_path('theme', 'omega') .'/js/debug.js', array('weight' => 1000, 'type' => 'file'));
+       drupal_add_css(drupal_get_path('theme', 'omega') .'/css/debug.css');
+}
+
+/**
+ * Allow the default text in the search box to be 100% configurable via backend theme settings
+ */
+$search_text_val = check_plain(theme_get_setting('omega_search_default_text')) ? check_plain(theme_get_setting('omega_search_default_text')) : 'search...';
+$search_text = array(
+  'default_search_text' => $search_text_val,
+);
+drupal_add_js($search_text, 'setting');
+
 // ACQUIA-MARINA
 // Set site title, slogan, mission, page title & separator (unless using Page Title module)
 if (!module_exists('page_title')) {
index 06dfbee..eadd480 100644 (file)
@@ -170,53 +170,7 @@ function ns() {
   }
   return $output;
 }
-/**
- * NINESIXTY - This rearranges how the style sheets are included so the framework styles
- * are included first.
- *
- * Sub-themes can override the framework styles when it contains css files with
- * the same name as a framework style. This can be removed once Drupal supports
- * weighted styles.
- */
-function omega_css_reorder($css) {
-  global $theme_info, $base_theme_info;
 
-  // Dig into the framework .info data.
-  $framework = !empty($base_theme_info) ? $base_theme_info[0]->info : $theme_info->info;
-
-  // Pull framework styles from the themes .info file and place them above all stylesheets.
-  if (isset($framework['stylesheets'])) {
-    foreach ($framework['stylesheets'] as $media => $styles_from_960) {
-      // Setup framework group.
-      if (isset($css[$media])) {
-        $css[$media] = array_merge(array('framework' => array()), $css[$media]);
-      }
-      else {
-        $css[$media]['framework'] = array();
-      }
-      foreach ($styles_from_960 as $style_from_960) {
-        // Force framework styles to come first.
-        if (strpos($style_from_960, 'framework') !== FALSE) {
-          $framework_shift = $style_from_960;
-          $remove_styles = array($style_from_960);
-          // Handle styles that may be overridden from sub-themes.
-          foreach ($css[$media]['theme'] as $style_from_var => $preprocess) {
-            if ($style_from_960 != $style_from_var && basename($style_from_960) == basename($style_from_var)) {
-              $framework_shift = $style_from_var;
-              $remove_styles[] = $style_from_var;
-              break;
-            }
-          }
-          $css[$media]['framework'][$framework_shift] = TRUE;
-          foreach ($remove_styles as $remove_style) {
-            unset($css[$media]['theme'][$remove_style]);
-          }
-        }
-      }
-    }
-  }
-  return $css;
-}
 
 /**
  * The region_builder function will create the variables needed to create
@@ -323,41 +277,6 @@ function rfilter($vars) {
 }
 
 /**
- * OMEGA - A function to return the alpha and or omega classes based on context
- * This function is not currently being used.
- * @param $vars
- * @param $elements
- * @param $current
- * @param $alpha
- * @param $omega
- * @return classes
- */
-function ao($vars, $elements, $current, $alpha = FALSE, $omega = FALSE){
-  $classes = array();
-  $regions = array();
-  // let's get rid of empty elements first
-  foreach($elements AS $k => $r) {
-    if($vars[$r]) {
-      $regions[$k] = $r;
-    }
-  }
-  // now we do another fast loop since we emptied out any blank zones to determine what
-  // regions are alpha & omega
-  foreach($regions AS $k => $r) {
-    $classes[$r] = '';
-    if(!$alpha){
-      $alpha = TRUE;
-      $classes[$r] .= ' alpha';
-    }
-    if(!$omega && ($k == count($regions) - 1 || count($regions) == 1 )) {
-      $omega = TRUE;
-      $classes[$r] .= ' omega';
-    }
-  }
-  return $classes[$current];
-}
-
-/**
  * Converts a string to a suitable html ID attribute.
  *
  * http://www.w3.org/TR/html4/struct/global.html#h-7.5.2 specifies what makes a
index 3870dc2..d187a7a 100644 (file)
@@ -49,6 +49,20 @@ function omega_form_system_theme_settings_alter(&$form, &$form_state) {
     );
 
     // Page titles
+      $form['omega_container']['omega_general']['search_settings'] = array(
+        '#type' => 'fieldset',
+        '#title' => t('Search Settings'),
+        '#description'   => t('You may configure search settings here.'),
+        '#collapsible' => TRUE,
+        '#collapsed' => TRUE,
+      );
+        $form['omega_container']['omega_general']['search_settings']['omega_search_default_text'] = array(
+          '#type' => 'textfield',
+          '#title' => t('Custom Default Search Text'),
+          '#size' => 60,
+          '#default_value' => theme_get_setting('omega_search_default_text'),
+          '#description'   => t('Enter default value to use in search boxes.'),
+        );
       $form['omega_container']['omega_general']['page_format_titles'] = array(
         '#type' => 'fieldset',
         '#title' => t('Page titles'),
@@ -606,6 +620,32 @@ function omega_form_system_theme_settings_alter(&$form, &$form_state) {
           '#options' => $grids,
           '#description' => t('Grid width of the last footer region. This number should be less than or equal to the container width defined above.'),
         );
+    // General Settings
+    $form['omega_container']['omega_admin'] = array(
+      '#type' => 'fieldset',
+      '#title' => t('Administrative Omega 960 Settings'),
+      '#description' => t('Configure options for administration and development.'),
+      '#collapsible' => TRUE,
+      '#collapsed' => TRUE,
+    );
+    $form['omega_container']['omega_admin']['debug_grid_toggle'] = array(
+      '#type'          => 'checkbox',
+      '#title'         => t('Enable grid overlay/toggle for selected roles.'),
+      '#default_value' => theme_get_setting('debug_grid_toggle'),
+    );
+    $form['omega_container']['omega_admin']['debug_grid_toggle_state'] = array(
+      '#type'          => 'checkbox',
+      '#title'         => t('Turn on grid overlay on page load. (otherwise requires clicking to enable)'),
+      '#default_value' => theme_get_setting('debug_grid_toggle_state'),
+    );
+    $role_options = array_map('check_plain', user_roles());
+    unset($role_options[1]);
+    $form['omega_container']['omega_admin']['debug_grid_roles'] = array(
+      '#type'          => 'checkboxes',
+      '#title'         => t('Roles that may use the grid overlay/debugging tool. (User 1 Automatically has access.)'),
+      '#default_value' => theme_get_setting('debug_grid_roles'),
+      '#options'       => $role_options,
+    );
   // Return theme settings form
   return $form;
 }
\ No newline at end of file