Development

Changeset 2730

You must first sign up to be able to contribute.

Changeset 2730

Show
Ignore:
Timestamp:
11/17/06 12:58:36 (2 years ago)
Author:
superhaggis
Message:

Refactored attribute handling in yui_animation().
Added opacity and fontSize handling.
Edited docblock example to reflect additional attributes.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfYUIPlugin/lib/helper/YUIAnimationHelper.php

    r2729 r2730  
    6161 *   'duration'        => The duration of the animation (in seconds;  
    6262 *                        defaults to 1) 
     63 *   'opacity_from'    => The opacity that the element should start at. 
     64 *   'opacity_to'      => The opacity that the element should finish at. 
     65 *   'fontsize_from'   => The size that the element's font should  
     66 *                        start at. 
     67 *   'fontsize_to'     => The size that the element's font should 
     68 *                        finish at. 
     69 *   'fontsize_unit'   => The unit of measurement that the font should  
     70 *                        change by. (defaults to %) 
    6371 * 
    6472 *   Choose either of these width-specific options: 
     
    6775 * 
    6876 *   Choose either of these height-specific options: 
    69  *   'to_height'        => The height that the element should finish at. 
    70  *   'by_height'        => The height that the element should change by. 
     77 *   'to_height'       => The height that the element should finish at. 
     78 *   'by_height'       => The height that the element should change by. 
    7179 *    
    7280 * Example usage:   
    7381 * 
    7482 *   100x50px black box that expands to 400x200px after 2 seconds using 
    75  *   the 'elasticOut' animation effect. 
     83 *   the 'elasticOut' animation effect.  Opacity also changes from 100%  
     84 *   to 25% and font size changes from 100% to 250%. 
    7685 * 
    7786 *   <?php use_helper('YUIAnimation') ?> 
    7887 *   ... 
    79  *   <div id="foo" style="background-color: #000000; height: 50px; width: 100px"></div> 
     88 *   <div id="foo" style="color: #FFFFFF; background-color: #000000;  
     89 *        height: 50px; width: 100px">hello, world!</div> 
    8090 *   <?php echo link_to('click me!', '#', array( 
    8191 *     'onclick' => yui_animation('elasticOut', 'foo', array( 
     
    8494 *       'to_height' => '200', 
    8595 *       'to_width' => '400', 
     96 *       'opacity_from' => '1', 
     97 *       'opacity_to' => '0.25', 
     98 *       'fontsize_from' => '100', 
     99 *       'fontsize_to' => '250', 
     100 *       'fontsize_unit' => '%', 
    86101 *       'duration' => '2', 
    87102 *     )), 
     
    109124  { 
    110125    $width  = ""; 
    111     $width .= "width: {"; 
     126    $width .= "width: { "; 
     127 
     128    $width_attributes = array(); 
    112129 
    113130    if (isset($options['from_width'])) 
     131    { 
     132      $from_width = "from: " . $options['from_width']; 
     133      $width_attributes[] = $from_width; 
     134    } 
     135     
     136    if (isset($options['to_width'])) 
     137    { 
     138      $to_width = "to: " . $options['to_width']; 
     139      $width_attributes[] = $to_width; 
     140    } 
     141    elseif (isset($options['by_width'])) 
     142    { 
     143      $by_width = "by: " . $options['by_width']; 
     144      $width_attributes[] = $by_width; 
     145    } 
     146     
     147    if (isset($options['unit_width'])) 
     148    { 
     149      $unit_width = "unit: '" . $options['unit_width']; 
     150      $width_attributes[] = $unit_width; 
     151    } 
     152 
     153    $width .= join(', ', $width_attributes); 
     154 
     155    $width .= " }"; 
     156 
     157    $dimensions[] = $width; 
     158  } 
     159 
     160  if (isset($options['from_height']) || isset($options['to_height']) || isset($options['by_height'])) 
     161  { 
     162    $height  = ""; 
     163    $height .= "height: { "; 
     164 
     165    $height_attributes = array(); 
     166 
     167    if (isset($options['from_height'])) 
     168    { 
     169      $from_height = "from: " . $options['from_height']; 
     170      $height_attributes[] = $from_height; 
     171    } 
     172     
     173    if (isset($options['to_height'])) 
     174    { 
     175      $to_height = "to: " . $options['to_height']; 
     176      $height_attributes[] = $to_height; 
     177    } 
     178    elseif (isset($options['by_height'])) 
     179    { 
     180      $by_height = "by: " . $options['by_height']; 
     181      $height_attributes[] = $by_height; 
     182    } 
     183     
     184    if (isset($options['unit_height'])) 
     185    { 
     186      $unit_height = "unit: '" . $options['unit_height']; 
     187      $height_attributes[] = $unit_height; 
     188    } 
     189 
     190    $height .= join(', ', $height_attributes); 
     191 
     192    $height .= " }"; 
     193 
     194    $dimensions[] = $height; 
     195  } 
     196 
     197  if (isset($options['opacity_from']) || isset($options['opacity_to'])) 
     198  { 
     199    $opacity  = ""; 
     200    $opacity .= "opacity: { "; 
     201 
     202    $opacity_attributes = array(); 
     203 
     204    if (isset($options['opacity_from'])) 
     205    {  
     206      $opacity_from = "from: " . $options['opacity_from'];     
     207      $opacity_attributes[] = $opacity_from; 
     208    } 
     209     
     210    if (isset($options['opacity_to'])) 
     211    { 
     212      $opacity_to = "to: " . $options['opacity_to']; 
     213      $opacity_attributes[] = $opacity_to; 
     214    } 
     215 
     216    $opacity .= join(', ', $opacity_attributes); 
     217 
     218    $opacity .= " }"; 
     219 
     220    $dimensions[] = $opacity; 
     221  } 
     222 
     223  if (isset($options['fontsize_from']) || isset($options['fontsize_to'])) 
     224  { 
     225    $fontsize  = ""; 
     226    $fontsize .= "fontSize: { "; 
     227 
     228    $fontsize_attributes = array(); 
     229 
     230    if (isset($options['fontsize_from'])) 
    114231    {      
    115       $width .= " from: " . $options['from_width']; 
    116     } 
    117      
    118     if (isset($options['to_width'])) 
    119     { 
    120       $width .= ", to: " . $options['to_width']; 
    121     } 
    122     elseif (isset($options['by_width'])) 
    123     { 
    124       $width .= ", by: " . $options['by_width']; 
    125     } 
    126      
    127     if (isset($options['unit_width'])) 
    128     { 
    129       $width .= ", unit: '" . $options['unit_width'] . "' "; 
    130     } 
    131  
    132     $width .= " }"; 
    133  
    134     $dimensions[] = $width; 
    135   } 
    136  
    137   if (isset($options['from_height']) || isset($options['to_height']) || isset($options['by_height'])) 
    138   { 
    139     $height  = ""; 
    140     $height .= "height: {"; 
    141  
    142     if (isset($options['from_height'])) 
    143     {      
    144       $height .= " from: " . $options['from_height']; 
    145     } 
    146      
    147     if (isset($options['to_height'])) 
    148     { 
    149       $height .= ", to: " . $options['to_height']; 
    150     } 
    151     elseif (isset($options['by_height'])) 
    152     { 
    153       $height .= ", by: " . $options['by_height']; 
    154     } 
    155      
    156     if (isset($options['unit_height'])) 
    157     { 
    158       $height .= ", unit: '" . $options['unit_height'] . "' "; 
    159     } 
    160  
    161     $height .= " }"; 
    162  
    163     $dimensions[] = $height; 
     232      $fontsize_from = "from: " . $options['fontsize_from']; 
     233      $fontsize_attributes[] = $fontsize_from; 
     234    } 
     235     
     236    if (isset($options['fontsize_to'])) 
     237    { 
     238      $fontsize_to = "to: " . $options['fontsize_to']; 
     239      $fontsize_attributes[] = $fontsize_to; 
     240    } 
     241 
     242    if (isset($options['fontsize_unit'])) 
     243    { 
     244      $fontsize_unit = "unit: " . $options['fontsize_unit']; 
     245      $fontsize_attributes[] = $fontsize_unit; 
     246    } 
     247    else 
     248    { 
     249      $fontsize_unit = "unit: '%'"; 
     250      $fontsize_attributes[] = $fontsize_unit; 
     251    } 
     252 
     253    $fontsize .= join(', ', $fontsize_attributes); 
     254 
     255    $fontsize .= " }"; 
     256 
     257    $dimensions[] = $fontsize; 
    164258  } 
    165259