New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement: new feature iconRangeSame #135

Open
viniciusjl opened this Issue Jul 11, 2014 · 0 comments

Comments

Projects
None yet
1 participant
@viniciusjl

I've just added a new feature iconRangeSame that should be used in conjunction with iconRange.

The iconRangeSame is a boolean feature (default is false), when it is set to true, all icons before the current one (icons at left of current icon) are shown as the current one.

This has the same effect as http://www.htmldrive.net/items/show/170/Colourful-rating-system-with-CSS3-And-jQuery (See also the issue #71 ).

Here is the diff:

diff -c jquery.raty.js.ORIG jquery.raty.js
*** jquery.raty.js.ORIG 2014-07-10 19:08:46.000000000 -0300
--- jquery.raty.js  2014-07-10 21:03:03.631117818 -0300
***************
*** 343,348 ****
--- 343,353 ----

      _fill: function(score) {
        var hash = 0;
+       if (this.opt.iconRangeSame && this.opt.iconRange) {
+         while (hash < this.opt.iconRange.length && this.opt.iconRange[hash].range < score) {
+           hash++;
+         }
+       }

        for (var i = 1; i <= this.stars.length; i++) {
          var
***************
*** 505,511 ****
      },

      _setIcon: function(star, icon) {
!       star[this.opt.starType === 'img' ? 'src' : 'className'] = this.opt.path + icon;
      },

      _setTarget: function(target, score) {
--- 510,517 ----
      },

      _setIcon: function(star, icon) {
!       if (star)
!         star[this.opt.starType === 'img' ? 'src' : 'className'] = this.opt.path + icon;
      },

      _setTarget: function(target, score) {
***************
*** 526,532 ****
            integer = parseInt(Math.ceil(score), 10),
            star    = this.stars[integer - 1];

!         star.title = methods._getHint.call(this, score, evt);
        }
      },

--- 532,539 ----
            integer = parseInt(Math.ceil(score), 10),
            star    = this.stars[integer - 1];

!         if (star)
!           star.title = methods._getHint.call(this, score, evt);
        }
      },

***************
*** 732,737 ****
--- 739,745 ----
      halfShow     : true,
      hints        : ['bad', 'poor', 'regular', 'good', 'gorgeous'],
      iconRange    : undefined,
+     iconRangeSame: false,
      mouseout     : undefined,
      mouseover    : undefined,
      noRatedMsg   : 'Not rated yet!',

Diff finished.  Thu Jul 10 21:18:46 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment