Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
Merge pull request #2 from alice/master
Browse files Browse the repository at this point in the history
Push the full class calculation into the databinding layer
  • Loading branch information
dfreedm committed Apr 18, 2014
2 parents e0114fd + 94d697f commit daaec58
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
2 changes: 1 addition & 1 deletion demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<meta charset="utf-8">
<script src="../platform/platform.js"></script>
<link rel="import" href="polymer-ui-ratings.html">
<link rel="stylesheet" href="../polymer-ui-base/base.css">
<link rel="stylesheet" href="../polymer-ui-base-css/base.css">
</head>
<body unresolved>
<polymer-ui-ratings value="3"></polymer-ui-ratings>
Expand Down
12 changes: 3 additions & 9 deletions polymer-ui-ratings.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<template>
<link rel="stylesheet" href="polymer-ui-ratings.css">
<template repeat="{{star in stars}}">
<span id="star" index="{{star.index}}" class="{{star.starClass}}" on-tap="{{updateValue}}"></span>
<span id="star" class="{{ {full: star < value} | tokenList }}" on-tap="{{updateValue}}"></span>
</template>
</template>
<script>
Expand All @@ -60,18 +60,12 @@
countChanged: function() {
this.stars = [];
for (var i = 0; i < this.count; i++) {
this.stars.push({index: i});
this.stars.push(i);
}
this.valueChanged();
},
valueChanged: function() {
this.stars && this.stars.forEach(function(s, i) {
s.starClass = i < this.value ? 'full' : '';
}.bind(this));
},
updateValue: function(event, detail, sender) {
var s = sender.templateInstance.model.star;
this.value = s.index + (s.starClass ? 0 : 1);
this.value = s + Number(s >= this.value);
}
});
</script>
Expand Down

0 comments on commit daaec58

Please sign in to comment.