Code snippets for symfony 1.x

Navigation

Snippets tagged "slider"

slider wrapper

function slider_element($handle_id,$track_id, $control_var='',$options = array())
{
    use_helper('Javascript');
    $response = sfContext::getInstance()->getResponse();
    $response->addJavascript(sfConfig::get('sf_prototype_web_dir').'/js/prototype');
    $response->addJavascript(sfConfig::get('sf_prototype_web_dir').'/js/builder');
    $response->addJavascript(sfConfig::get('sf_prototype_web_dir').'/js/effects');
    $response->addJavascript(sfConfig::get('sf_prototype_web_dir').'/js/slider');
 
 
    foreach (array('tag', 'overlap', 'constraint', 'handle') as $option)
    {
      if (isset($options[$option]))
      {
        $options[$option] = "'{$options[$option]}'";
      }
    } 
 
    if (isset($options['hoverclass']))
    {
      $options['hoverclass'] = "'{$options['hoverclass']}'";
    }
    if (isset($options['range']))
    {
        if (is_array($options['range']))
            $options['range'] = '$R('."{$options['range'][0]},{$options['range'][1]})";
        else
            $options['range'] = '$R('."{$options['range']})";       
    }
 
 
    if (isset($options['values']))
    {
      $options['values'] = _array_or_string_for_javascript($options['values']);
    }
 
    if ($control_var == '')
        return javascript_tag("new Control.Slider('$handle_id','$track_id', "._options_for_javascript($options).")");
    else 
        return javascript_tag("var $control_var = new Control.Slider('$handle_id','$track_id', "._options_for_javascript($options).")");
}

Since there is no Symfony wraper for Control.slider, I produced something like this, based on other symfony helpers :)

by JarosÅ‚aw J on 2007-08-03, tagged slider 
(4 comments)