Créer un compte ou loggez-vous pour pouvoir ajouter, commenter et noter les snippets.

Navigation

Tags relatifs

my Symfony Plugins

Plugins demos


My bookmarks

Vous pouvez commenter/noter en utilisant le compte anonymous (mot de passe: anonymous)
You can comment/rate using the anonymous account (password: anonymous).

Snippets taggés : "class" Snippets taggés : "class"

[Prototype] Boucler sur une liste d'éléments d'une classe donnée - 171 view(s)

[Edit 20090223: Ajout exemple avec invoke]

Exemple: Lien "Développer / Réduire au titre sur la page" d'accueil.

$$('.snippet').invoke('toggle');

ou itération manuelle:

function toggle_snippets()
{
    var f = $$('.post-content');
    for(var i=0; i < f.length; i++) {
        f[i].toggle();
    }
}
par COil le 2008-09-29, taggé : class  list  prototype 
(1 commentaire)

[symfony 1.1] Classe de formulaire typique - 687 view(s)

<?php
 
/**
 * Form to add a classified ad.
 * 
 * @author loic.vernet
 * @since  7 august 08
 *
 * @package    form
 */
 
class qbNewThreadForm extends qbThreadForm 
{
  // Default mask to create fields names
  public static $main_fields_name = 'qb_thread';
 
  // Default labels
  protected $labels = array(
 
    // Thread
    'title'         => 'Sujet',
    'category_id'   => 'Forum',
 
    // Contact form
    'qb_post'       => 'Post',
  );
 
  // Default fields to keep
  protected $fields_to_keep = array(
 
    // Thread
    'id',
    'category_id',
 
    // Post
    'qb_post',
  );
 
  // Liste of field that can't be modified by direct input values
  protected static $protected_fields = array(
  );
 
  /**
   * Configuration of form.
   */
  public function configure()
  {
    // Build widgets
    $this->setWidgetOptions();
 
    // Set wdigets
    $this->processWidgets();
 
    // Set validators    
    $this->processValidators();
 
    // Embed other forms
    $this->embedForms();
  }
 
  /**
   * Set generic options for widgets.
   * 
   * @author loic.vernet
   * @since
   */
  protected function setWidgetOptions()
  {
    // name format
    $this->widgetSchema->setNameFormat(self::$main_fields_name. '[%s]');
 
    // Set labels    
    $this->setLabels($this->labels);
 
    // Allow extra fields for all forms
    $this->allowExtraFields();
  }
 
  /**
   * set all widgets.
   * 
   * @author loic.vernet
   * @since
   */
  public function processWidgets()
  {
    $this->removeAllFieldsExcept($this->fields_to_keep);
 
    $this->widgetSchema['category_id'] = new sfWidgetFormPropelSelect(
      array(
        'model'     => 'qbCategory', 
        'add_empty' => false,
        //'criteria'  => ipAdBasePeer::getCategoriesCriteria()
    ));
 
    $this->widgetSchema['title'] = new sfWidgetFormInput();
  }  
 
  /**
   * Set all validators.
   * 
   * @author loic.vernet
   * @since 
   */
  public function processValidators()
  {
    $this->validatorSchema['category_id'] = new sfValidatorString(
        array('required' => true),
        array('required' => 'Veuillez choisir un forum')
    );
 
    $this->validatorSchema['title'] = new sfValidatorString(
        array('required' => true),
        array('required' => 'Veuillez choisir un titre pour le sujet')
    );
  }
 
  /**
   * Embed other forms to the current form.
   * 
   * @author loic.vernet 
   * @since 
   */
  protected function embedForms()
  {
  }
}
par COil le 2008-09-29, taggé : class  field  form  labels  symfony  validator  widget 
(1 commentaire)

[Prototype] Création d'une classe - 128 view(s)

var Fruit = Class.create();
Fruit.prototype = {
  initialize: function(fruit){
    this.fruit = fruit;
  },
  toString: function(){
    return 'I am a fruit and my name is "' + this.fruit + '".'; 
  }
}
var apple = new Fruit('apple');
 
$('fruits').update(apple);
$('fruits').innerHTML;
// -> 'I am a fruit and my name is "apple".'
par COil le 2008-09-29, taggé : class  javascript  prototype 
(1 commentaire)

[PHP] Reduire le coût de performances de require_once - 99 view(s)

class_exists('sfCache') or require_once($sf_symfony_lib_dir.'/cache/sfCache.class.php');
 
par COil le 2008-09-29, taggé : class  optimisation  php 
Debug toolbar