Development

Changeset 8967

You must first sign up to be able to contribute.

Changeset 8967

Show
Ignore:
Timestamp:
05/15/08 01:42:11 (2 months ago)
Author:
Jonathan.Todd
Message:

sfYUIPlugin: branches/jtodd - Added function to include skin stylesheets, updated README

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfYUIPlugin/branches/jtodd/README

    r8961 r8967  
    2828- addStylesheet replaced by addComponentStylesheet 
    2929- addStylesheet added which adds stylesheet which aren't tied to a component 
     30- addComponentStylesheetSkin allows you to add a skin CSS file for a particular component 
    3031- suffix (like '-min') can be passed in as it seems to varry as to which components have a -min version 
    3132- Added YUICssHelper to include stylesheets not tied with components 
  • plugins/sfYUIPlugin/branches/jtodd/lib/helper/YUIDatatableHelper.php

    r8965 r8967  
    9898 
    9999 
     100// EXAMPLE USE:  
     101// use_helper('YUIDatatable'); 
     102// $persons = Doctrine::getTable('Person')->findAll(); 
     103// $fields = array('id' => array('label' => 'ID', 'yui_def' => 'width: 25, sortable:true, resizeable:true'), 
     104//                 'email' => array('label' => 'Email', 'yui_def' => 'width: 200, sortable:true, resizeable:true'), 
     105//                 'address_type_enum_id' => array('label' => 'Type', 'yui_def' => 'width: 25, sortable:true, resizeable:true'), 
     106//                 'priority_enum_id' => array('label' => 'Priority', 'yui_def' => 'width: 25, sortable:true, resizeable:true'), 
     107//                 'actions' => array('label' => 'Actions', 'yui_def' => 'width: 30, sortable:true, resizeable:true') 
     108// ); 
     109// $actions = array('Edit' => url_for('EmailInformation/edit')); 
     110//  
     111// $js_fields = yui_datatable_fields_to_js($fields); 
     112// $js_columnDefs = yui_datatable_fields_to_columndefs($fields); 
     113// $js_data = yui_datatable_doctrine_object_to_data_js($persons,$fields,$actions); 
     114//  
     115// yui_datatable_start('yui_email_list','', $js_data, $js_fields, $js_columnDefs); 
     116 
    100117/** 
    101118 * Mark the start of the Tabview block. 
     
    103120 * of designated Tabview HTML. 
    104121 * 
    105  * Example usage: 
    106  * 
    107  *   <?php yui_datatable_start('demo') ?> 
    108122 *  
    109123 * @param string $element 
     
    126140   
    127141 
     142  sfYUI::addComponentSkinStylesheet('datatable','datatable', 'sam', '', 'last'); 
    128143   
    129   sfContext::getInstance()->getResponse()->addStylesheet('http://yui.yahooapis.com/2.5.1/build/datatable/assets/skins/sam/datatable.css','last');  
    130   //sfYUI::addComponentStylesheet('tabview', 'tabview', '-min'); 
    131    
    132    
    133    
    134  
    135144  $str = <<<EOD 
    136145  <div id="$element"></div> 
  • plugins/sfYUIPlugin/branches/jtodd/lib/helper/YUITabviewHelper.php

    r8966 r8967  
    5252  sfYUI::addComponentStylesheet('tabview', 'tabview', '-min'); 
    5353   
    54   sfContext::getInstance()->getResponse()->addStylesheet('http://yui.yahooapis.com/2.5.1/build/tabview/assets/skins/sam/tabview.css','last');  
     54  sfYUI::addComponentSkinStylesheet('tabview', 'tabview', 'sam', '', 'last'); 
    5555   
    5656 
  • plugins/sfYUIPlugin/branches/jtodd/lib/sfYUI.class.php

    r8959 r8967  
    143143   
    144144  /** 
     145   * Adds a skin stylesheet for a component to the list of included stylesheets. Pulls from either 
     146   * local or Yahoo's CDN. 
     147   * 
     148   * @param string $component The Yahoo! UI components name. 
     149   * @param string $stylesheet The Yahoo! UI components stylesheet name to include. 
     150   * @param string $suffix Suffix to be appended to file name (ie '-min') 
     151   * @param string $postion 'first' | 'last' controls when the stylesheet is loaded in the page 
     152   * @param array  $options Options that addStylesheet accept 
     153   *  
     154   */ 
     155  public static function addComponentSkinStylesheet($component, $stylesheet, $skin = 'sam', $suffix = null, $position = '', $options = array()) 
     156  { 
     157    $include = sprintf('skin_%s_%s', $component, $stylesheet); 
     158     
     159    // If there is no suffix, get it from the settings.yml   
     160    if($suffix == null) 
     161      $suffix = sfConfig::get('sf_yui_js_suffix'); 
     162       
     163    // check if the stylesheet is already included 
     164    if (!in_array($include, self::$included_stylesheets)) 
     165    { 
     166      // Pull from CDN 
     167      if(sfConfig::get('sf_yui_use_cdn')) 
     168      { 
     169        sfContext::getInstance()->getResponse()->addStylesheet( 
     170          sprintf('%s/%s%s/%s/assets/skins/%s/%s.css', 
     171          sfConfig::get('sf_yui_cdn_url'), 
     172          sfConfig::get('sf_yui_version'), 
     173          sfConfig::get('sf_yui_cdn_folder'), 
     174          $component, 
     175          $skin, 
     176          $stylesheet   
     177        ),$position,$options); 
     178      }            
     179      // Pull from local 
     180      else 
     181      { 
     182        sfContext::getInstance()->getResponse()->addStylesheet( 
     183          sprintf('%s/%s/assets/skins/%s/%s.css', 
     184          sfConfig::get('sf_yui_js_dir'), 
     185          $component, 
     186          $skin, 
     187          $stylesheet 
     188        ),$position,$options); 
     189      } 
     190       
     191      // add stylesheet to the included list 
     192      array_push(self::$included_stylesheets, $include); 
     193    }     
     194  } 
     195   
     196  /** 
    145197   * Adds a stylesheet to the list of included stylesheets. Pulls from either 
    146198   * local or Yahoo's CDN. Stylesheets differ from component stylesheets in that