Skip to content

Commit

Permalink
Flux Layout - refactor and add $minify
Browse files Browse the repository at this point in the history
Cleanup core layout building functions and introduce/deploy $minify - just defines new lines (or empty) to minify output.
  • Loading branch information
Jonnyauk committed Sep 20, 2014
1 parent a8d39b3 commit a60713f
Showing 1 changed file with 26 additions and 24 deletions.
50 changes: 26 additions & 24 deletions wf-content/css/wf-css-flux-layout.php
Expand Up @@ -38,7 +38,7 @@

<?php

/* DO IT! */
/* DO IT! Just for testing and development */
$wf_grid = new wflux_layout;
$wf_grid->grid_container();
$wf_grid->grid_float_blocks();
Expand All @@ -48,9 +48,8 @@
$wf_grid->grid_relative_loops(array(1,2,3,4,5,6,7,8,9,10,11,12));
$wf_grid->grid_media_queries();


/**
* Grid building functionality for wf-css-dynamic-columns file
* Percent based CSS layout generator
* @since 2.0
*/
class wflux_layout {
Expand All @@ -60,6 +59,7 @@ class wflux_layout {
protected $rwd_column_width; // Width of columns (%)
protected $rwd_class_prepend; // Prepend all CSS selectors (or not!)
protected $rwd_class_proportional; // Prepend all CSS selectors (or not!)
protected $rwd_minify; // CSS selector - column width blocks
protected $rwd_class_block; // CSS selector - column width blocks
protected $rwd_class_space_left; // CSS selector - padding left
protected $rwd_class_space_right; // CSS selector - padding right
Expand All @@ -74,14 +74,16 @@ function __construct() {
$this->rwd_width = ( is_numeric( $_GET['w'] ) && $_GET['w'] <= 101 ) ? $_GET['w'] : 80;
$this->rwd_columns = ( is_numeric( $_GET['c'] ) && $_GET['c'] <= 101 ) ? $_GET['c'] : 20;
$this->rwd_column_width = 100 / $this->rwd_columns;

$this->rwd_class_prepend = '';
$this->rwd_class_proportional = 'size-';
$this->rwd_class_proportional = 'span-';
$this->rwd_minify = "\n";

$this->rwd_class_block = $this->rwd_class_prepend . 'span';
$this->rwd_class_space_left = $this->rwd_class_prepend . 'pad-left';
$this->rwd_class_space_right = $this->rwd_class_prepend . 'pad-right';
$this->rwd_class_move_left = $this->rwd_class_prepend . 'move-left';
$this->rwd_class_move_right = $this->rwd_class_prepend . 'move-right';
$this->rwd_minify_2 = $this->rwd_minify . $this->rwd_minify;

}

Expand All @@ -90,8 +92,8 @@ function __construct() {
*/
function grid_container(){

echo '.container { width: ' . $this->rwd_width . '%; margin: 0 auto; }';
echo "\n" . "\n";
echo '.container { '
. 'width: ' . $this->rwd_width . '%; margin: 0 auto; }' . $this->rwd_minify_2;

}

Expand All @@ -100,12 +102,11 @@ function grid_container(){
*/
function grid_float_blocks(){

for ($limit=1; $limit <= $this->rwd_columns; $limit++) {
for ( $limit=1; $limit <= $this->rwd_columns; $limit++ ) {
echo 'div.' . $this->rwd_class_block . '-' . $limit;
echo ($limit == $this->rwd_columns) ? '' : ', ';
}
echo " { float: left; margin: 0; }";
echo "\n" . "\n";
echo " { float: left; margin: 0; }" . $this->rwd_minify_2;

}

Expand All @@ -114,11 +115,11 @@ function grid_float_blocks(){
*/
function grid_blocks(){

for ($limit=1; $limit <= $this->rwd_columns; $limit++) {
echo '.' . $this->rwd_class_block . '-' . $limit;
echo ' { width: ' . $this->rwd_column_width * $limit . '%; ' . "} " . "\n";
for ( $limit=1; $limit <= $this->rwd_columns; $limit++ ) {
echo '.' . $this->rwd_class_block . '-' . $limit . ' { width: '
. $this->rwd_column_width * $limit . '%; ' . "} " . $this->rwd_minify;
}
echo "\n";
echo $this->rwd_minify;

}

Expand All @@ -134,8 +135,8 @@ function grid_mover( $type, $definition, $direction ){
$css_2 = ( $direction == 'l' ) ? ' 0 0; ' : '; ';

for ( $limit=1; $limit <= $this->rwd_columns; $limit++ ) {
echo '.' . $definition . '-' . $limit . ' ' . $css_1;
echo $this->rwd_column_width * $limit . '%' . $css_2 . '} ' . "\n";
echo '.' . $definition . '-' . $limit . ' ' . $css_1
. $this->rwd_column_width * $limit . '%' . $css_2 . '} ' . $this->rwd_minify;
}

}
Expand All @@ -144,15 +145,15 @@ function grid_space_loops(){

$this->grid_mover( 'space', $this->rwd_class_space_left, 'l' );
$this->grid_mover( 'space', $this->rwd_class_space_right, 'r' );
echo "\n";
echo $this->rwd_minify;

}

function grid_push_loops(){

$this->grid_mover( 'push', $this->rwd_class_move_left, 'l' );
$this->grid_mover( 'push', $this->rwd_class_move_right, 'r' );
echo "\n";
echo $this->rwd_minify;

}

Expand Down Expand Up @@ -194,25 +195,26 @@ function grid_relative_loops($sizes) {

if ( $def[0] > 0 ) {

echo '/**** ' . $def[0] . ' - ' . $def[1] . ' ****/' . "\n";
echo '/**** ' . $def[0] . ' - ' . $def[1] . ' ****/' . $this->rwd_minify;

if ( $size == 1 ){
echo 'rwd-size-1 .' . $this->rwd_class_prepend . $def[1]
.' { width: 100%; ' . "} " . "\n";

echo 'rwd-size-1 .' . $this->rwd_class_prepend
. $def[1] .' { width: 100%; ' . "} " . $this->rwd_minify;

} else {

for ( $limit=1; $limit < $size; $limit++ ) {

echo '.' . $this->rwd_class_prepend . $this->rwd_class_proportional . $limit . '-' . $def[0]
. ', .' . $this->rwd_class_prepend . $this->rwd_class_proportional . $limit . '-' . $def[1]
. ' { width: ' . $limit * ( 100 / $size ) . '%; ' .
'float:left;' . "} " . "\n";
. ' { width: ' . $limit * ( 100 / $size ) . '%; ' . 'float:left;' . "} " . $this->rwd_minify;

}

}

echo "\n";
echo $this->rwd_minify;

}

Expand Down

0 comments on commit a60713f

Please sign in to comment.