Skip to content

Commit

Permalink
Merge pull request #30 from prrashi/rc-v2.3.0
Browse files Browse the repository at this point in the history
Rc v2.3.0
  • Loading branch information
prrashi authored Apr 10, 2017
2 parents fc4e204 + 52dbeef commit 3b9072a
Show file tree
Hide file tree
Showing 11 changed files with 82 additions and 44 deletions.
3 changes: 2 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ module.exports = function(grunt) {
}
, jshint: {
options: {
jshintrc: true
jshintrc: true,
reporterOutput: ""
}
, files: ["<%= config.srcDir %><%= config.name %>.js"]
}
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rateYo",
"version": "2.2.0",
"version": "2.3.0",
"homepage": "https://github.com/prrashi/rateYo",
"authors": [
"prrashi <[email protected]>"
Expand Down
6 changes: 6 additions & 0 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
<div class="rateyo"></div>
<div class="rateyo"></div>
<div class="rateyo"></div>
<div class="rateyo"
data-rateyo-rating="50%"
data-rateyo-rtl="true"
data-rateyo-spacing="10px"
data-rateyo-rated-fill="#FF0000"
data-rateyo-num-stars="10"></div>
<script type="text/javascript" src="../bower_components/jquery/dist/jquery.min.js"></script>
<script type="text/javascript" src="../src/jquery.rateyo.js"></script>

Expand Down
2 changes: 1 addition & 1 deletion min/jquery.rateyo.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion min/jquery.rateyo.min.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions min/jquery.rateyo.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion min/jquery.rateyo.min.js.map

Large diffs are not rendered by default.

44 changes: 22 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
{
"name": "rateYo"
, "version": "2.2.0"
, "description": "A simple and flexible star rating plugin"
, "main": "js/jquery.rateyo.js"
, "repository": {
"type": "git"
, "url": "git://github.com/prrashi/rateYo.git"
}
, "author": "prashanth pamidi (https://github.com/prrashi)"
, "bugs": {
"url": "https://github.com/prrashi/rateYo/issues"
}
, "devDependencies": {
"grunt": "~0.4.5"
, "grunt-contrib-clean": "~0.6.0"
, "grunt-contrib-watch": "~0.6.1"
, "grunt-contrib-uglify": "~0.6.0"
, "grunt-contrib-less": "~0.12.0"
, "grunt-contrib-jshint": "~0.10.0"
, "matchdep": "~0.3.0"
}
, "homepage": "http://rateyo.fundoocode.ninja/"
"name": "rateYo",
"version": "2.3.0",
"description": "A simple and flexible star rating plugin",
"main": "js/jquery.rateyo.js",
"repository": {
"type": "git",
"url": "git://github.com/prrashi/rateYo.git"
},
"author": "prashanth pamidi (https://github.com/prrashi)",
"bugs": {
"url": "https://github.com/prrashi/rateYo/issues"
},
"devDependencies": {
"grunt": "~0.4.5",
"grunt-contrib-clean": "~0.6.0",
"grunt-contrib-jshint": "~0.10.0",
"grunt-contrib-less": "~0.12.0",
"grunt-contrib-uglify": "~0.6.0",
"grunt-contrib-watch": "~0.6.1",
"matchdep": "~0.3.0"
},
"homepage": "http://rateyo.fundoocode.ninja/"
}
1 change: 1 addition & 0 deletions src/jquery.rateyo.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
-webkit-box-sizing: content-box;
-moz-box-sizing: content-box;
box-sizing: content-box;
direction: ltr;
}
.jq-ry-container[readonly="readonly"] {
cursor: default;
Expand Down
59 changes: 44 additions & 15 deletions src/jquery.rateyo.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*****
* rateYo - v2.2.0
* rateYo - v2.3.0
* http://prrashi.github.io/rateyo/
* Copyright (c) 2014 Prashanth Pamidi; Licensed MIT
*****/
Expand Down Expand Up @@ -118,9 +118,9 @@
}

var hexValues = hexRegex.exec(hex),
r = parseInt(hexValues[1], 16),
g = parseInt(hexValues[2], 16),
b = parseInt(hexValues[3], 16);
r = parseInt(hexValues[1], 16),
g = parseInt(hexValues[2], 16),
b = parseInt(hexValues[3], 16);

return {r:r, g:g, b:b};
};
Expand All @@ -137,7 +137,7 @@

if (newVal.length === 1) {

newVal = "0" + newVal;
newVal = "0" + newVal;
}

return newVal;
Expand Down Expand Up @@ -168,11 +168,11 @@
return "#" + r + g + b;
}

function RateYo ($node, options) {
function RateYo ($node, options) {

/*
* The Contructor, whose instances are used by plugin itself
*/
/*
* The Contructor, whose instances are used by plugin itself
*/

// Storing the HTML element as a property, for future access
this.node = $node.get(0);
Expand Down Expand Up @@ -263,6 +263,14 @@

percent = options.rtl ? 100 - percent : percent;

if (percent < 0) {

percent = 0;
} else if (percent > 100) {

percent = 100;
}

$ratedGroup.css("width", percent + "%");
}

Expand Down Expand Up @@ -563,7 +571,7 @@

if (spacing > 0) {

/*
/*
* If there is spacing between stars, take the percentage of width covered
* and subtract the percentage of width covered by stars and spacing, to find
* how many stars are covered, the number of stars covered is the rating
Expand Down Expand Up @@ -604,7 +612,7 @@
calculatedRating = maxValue - calculatedRating;
}

return calculatedRating;
return parseFloat(calculatedRating);
}

function setReadOnly (newValue) {
Expand Down Expand Up @@ -827,10 +835,10 @@

method = setSpacing;
break;
case "rtl":
case "rtl":

method = setRtl;
break;
break;
case "onInit":

method = setOnInit;
Expand Down Expand Up @@ -1087,10 +1095,31 @@

var existingInstance = getInstance(this, rateYoInstances);

if (!existingInstance) {
if (existingInstance) {

return new RateYo($(this), $.extend({}, options));
return existingInstance;
}

var $node = $(this),
dataAttrs = {};

$.each($node.data(), function (key, value) {

if (key.indexOf("rateyo") !== 0) {

return;
}

var optionName = key.replace(/^rateyo/, "");

optionName = optionName[0].toLowerCase() + optionName.slice(1);

dataAttrs[optionName] = value;

delete options[optionName];
});

return new RateYo($(this), $.extend({}, dataAttrs, options));
});
}

Expand Down
1 change: 1 addition & 0 deletions src/jquery.rateyo.less
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
-webkit-box-sizing: content-box;
-moz-box-sizing: content-box;
box-sizing: content-box;
direction: ltr;

&[readonly="readonly"] {

Expand Down

0 comments on commit 3b9072a

Please sign in to comment.