Projet

Général

Profil

Révision 4853591f

Ajouté par Assos Assos il y a environ 10 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/fivestar/js/fivestar.js
1
/**
2
 * @file
3
 *
4
 * Fivestar JavaScript behaviors integration.
5
 */
6

  
1 7
/**
2 8
 * Create a degradeable star rating interface out of a simple form structure.
3 9
 *
......
8 14

  
9 15
Drupal.behaviors.fivestar = {
10 16
  attach: function (context) {
11
    $('div.fivestar-form-item').once('fivestar', function() {
17
    $(context).find('div.fivestar-form-item').once('fivestar', function() {
12 18
      var $this = $(this);
13 19
      var $container = $('<div class="fivestar-widget clearfix"></div>');
14 20
      var $select = $('select', $this);
......
36 42
        }
37 43
      });
38 44

  
39
      $container.find('.star:lt(' + index + ')').addClass('on');
45
      if (index != -1) {
46
        $container.find('.star').slice(0, index).addClass('on');
47
      }
40 48
      $container.addClass('fivestar-widget-' + ($options.length));
41 49
      $container.find('a')
42 50
        .bind('click', $this, Drupal.behaviors.fivestar.rate)
......
53 61
    var $widget = event.data;
54 62
    var value = this.hash.replace('#', '');
55 63
    $('select', $widget).val(value).change();
56
    var $this_star = $this.closest('.star');
64
    var $this_star = (value == 0) ? $this.parent().parent().find('.star') : $this.closest('.star');
57 65
    $this_star.prevAll('.star').andSelf().addClass('on');
58 66
    $this_star.nextAll('.star').removeClass('on');
67
    if(value==0){
68
      $this_star.removeClass('on');
69
    }
70

  
59 71
    event.preventDefault();
60 72
  },
61 73
  hover: function(event) {

Formats disponibles : Unified diff