Last active
April 4, 2016 09:45
-
-
Save theStreets93/15e9def32406bbb81c020bd9e20c6c30 to your computer and use it in GitHub Desktop.
Magento 1 - Review Stars - Prototype
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.observe('dom:loaded', function(){ | |
$$('#product-review-table td input').each(function(el){ | |
el.observe('click', function(ev){ | |
var attr = el.readAttribute('value'); | |
var tr = el.up('tr'); | |
tr.className = ""; | |
tr.addClassName('star_' + attr); | |
}); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#product-review-table { | |
thead { | |
display: none; | |
max-height: 0px; | |
overflow: hidden; | |
} | |
tr { | |
td { | |
position: relative; | |
padding: 0px; | |
cursor: pointer; | |
&:hover { | |
background-color: rgba(0, 0, 0, 0.04); | |
} | |
&::before { | |
width: 13px; | |
height: 13px; | |
display: block; | |
background: url(../../images/bkg_rating.gif); | |
background-repeat: no-repeat; | |
background-position: center top; | |
content: ""; | |
position: absolute; | |
top: 11.5px; | |
left: 11.5px; | |
} | |
input[type="radio"]{ | |
opacity: 0; | |
margin: 0px; | |
width: 36px; | |
height: 36px; | |
cursor: pointer; | |
} | |
} | |
&.star_1 { | |
td:nth-of-type(1)::before { | |
background-position: center bottom; | |
} | |
} | |
&.star_2 { | |
td:nth-of-type(-n+2)::before { | |
background-position: center bottom; | |
} | |
} | |
&.star_3 { | |
td:nth-of-type(-n+3)::before { | |
background-position: center bottom; | |
} | |
} | |
&.star_4 { | |
td:nth-of-type(-n+4)::before { | |
background-position: center bottom; | |
} | |
} | |
&.star_5 { | |
td:nth-of-type(-n+5)::before { | |
background-position: center bottom; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment