From c336def2d576dda27530d4c990fb683dbb56e67e Mon Sep 17 00:00:00 2001 From: marcelglaeser Date: Thu, 23 Mar 2017 17:55:58 +0100 Subject: [PATCH 1/9] Update README.md --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index debaa1b..c6edd69 100644 --- a/README.md +++ b/README.md @@ -98,6 +98,17 @@ or for a custom rating scale: ]); // ... ``` +to enable resetable: +```php +add('rating', RatingType::class, [ + //... + 'resetable' => true, + //... + ]); + // ... +``` ###Display in a twig template using the rating filter ``` From c513c77e429bcaabeed988a3881f10a6a653972b Mon Sep 17 00:00:00 2001 From: marcelglaeser Date: Thu, 23 Mar 2017 17:57:41 +0100 Subject: [PATCH 2/9] Update rating.js function resettable --- Resources/public/js/rating.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Resources/public/js/rating.js b/Resources/public/js/rating.js index 825ce67..44a5053 100644 --- a/Resources/public/js/rating.js +++ b/Resources/public/js/rating.js @@ -1,5 +1,5 @@ -$(function(){ - var labelWasClicked = function labelWasClicked(){ +$(function () { + var labelWasClicked = function labelWasClicked() { var input = $(this).siblings().filter('input'); if (input.attr('disabled')) { return; @@ -7,20 +7,20 @@ $(function(){ input.val($(this).attr('data-value')); } - var turnToStar = function turnToStar(){ + var turnToStar = function turnToStar() { if ($(this).find('input').attr('disabled')) { return; } - var labels = $(this).find('div'); + var labels = $(this).find('div').filter(':not(#rating_star_reset)'); labels.removeClass(); labels.addClass('star'); } - var turnStarBack = function turnStarBack(){ + var turnStarBack = function turnStarBack() { var rating = parseInt($(this).find('input').val()); if (rating > 0) { - var selectedStar = $(this).children().filter('#rating_star_'+rating) - var prevLabels = $(selectedStar).nextAll(); + var selectedStar = $(this).children().filter('#rating_star_' + rating); + var prevLabels = $(selectedStar).nextAll().filter(':not(#rating_star_reset)'); prevLabels.removeClass(); prevLabels.addClass('star-full'); selectedStar.removeClass(); @@ -28,8 +28,8 @@ $(function(){ } } - $('.star, .rating-well').click(labelWasClicked); + $('.star, .star-reset, .rating-well').click(labelWasClicked); $('.rating-well').each(turnStarBack); - $('.rating-well').hover(turnToStar,turnStarBack); + $('.rating-well').hover(turnToStar, turnStarBack); -}); \ No newline at end of file +}); From b59da3acce55b1ccc7001e7c6ccd29e3fa99f020 Mon Sep 17 00:00:00 2001 From: marcelglaeser Date: Thu, 23 Mar 2017 17:58:24 +0100 Subject: [PATCH 3/9] Update rating.css add .rating div.star-reset --- Resources/public/css/rating.css | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/Resources/public/css/rating.css b/Resources/public/css/rating.css index c841efb..3118b2a 100644 --- a/Resources/public/css/rating.css +++ b/Resources/public/css/rating.css @@ -65,6 +65,30 @@ color:#999; } +.rating div.star-reset { + font-family:FontAwesome; + font-weight:normal; + font-style:normal; + font-size: 25px; + display:inline-block; + position: relative; +} + +.rating div.star-reset:hover { + cursor:pointer; +} + +.rating div.star-reset:before { + content:"\f05e"; + padding-right:5px; + color:#999; +} + +.rating div.star-reset:hover:before,.rating div.star-reset:hover~div.star-reset:before { + content:"\f05e"; + color:#990000; +} + .rating div.fa-norm { font-size: 1em; } @@ -89,4 +113,4 @@ .rating div.fa-5x { font-size: 5em; -} \ No newline at end of file +} From 329430f9f9abc10a8dd665f637ea4f9263ce8572 Mon Sep 17 00:00:00 2001 From: marcelglaeser Date: Thu, 23 Mar 2017 17:58:59 +0100 Subject: [PATCH 4/9] Update rating.html.twig add the rating_star_reset div --- Resources/views/rating.html.twig | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Resources/views/rating.html.twig b/Resources/views/rating.html.twig index 7045516..fec9e81 100644 --- a/Resources/views/rating.html.twig +++ b/Resources/views/rating.html.twig @@ -9,6 +9,9 @@ {% for star in 1..stars %}
{% endfor %} + {% if resettable %} +
+ {% endif %} {% endspaceless %} @@ -27,4 +30,4 @@ {%- endif -%} {%- endfor -%} {% endspaceless %} -{% endblock rating_widget_container_attributes %} \ No newline at end of file +{% endblock rating_widget_container_attributes %} From e73ae204971a0e1a7af9365478041cfe98c79e22 Mon Sep 17 00:00:00 2001 From: marcelglaeser Date: Thu, 23 Mar 2017 17:59:29 +0100 Subject: [PATCH 5/9] Update RatingType.php add 'resettable' --- Form/RatingType.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Form/RatingType.php b/Form/RatingType.php index 9ecc036..344999d 100644 --- a/Form/RatingType.php +++ b/Form/RatingType.php @@ -14,7 +14,8 @@ class RatingType extends AbstractType public function buildView(FormView $view, FormInterface $form, array $options) { $view->vars = array_replace($view->vars, [ - 'stars' => $options['stars'] + 'stars' => $options['stars'], + 'resettable' => $options['resettable'] ]); } @@ -26,6 +27,7 @@ public function configureOptions(OptionsResolver $resolver) ], 'scale' => 1, 'stars' => 5, + 'resettable' => false, ]); } @@ -38,4 +40,4 @@ public function getName() { return 'rating'; } -} \ No newline at end of file +} From 7533de520eab18b26d19977aae1a7ef6eee46f2e Mon Sep 17 00:00:00 2001 From: marcelglaeser Date: Thu, 23 Mar 2017 17:59:51 +0100 Subject: [PATCH 6/9] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c6edd69..e103ff5 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,7 @@ or for a custom rating scale: ]); // ... ``` -to enable resetable: +to enable resettable: ```php Date: Thu, 23 Mar 2017 18:02:48 +0100 Subject: [PATCH 7/9] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e103ff5..4a4c701 100644 --- a/README.md +++ b/README.md @@ -104,7 +104,7 @@ to enable resettable: // ... $builder->add('rating', RatingType::class, [ //... - 'resetable' => true, + 'resettable' => true, //... ]); // ... From 71719a52a185146497860c23236fbbd6eae56238 Mon Sep 17 00:00:00 2001 From: marcelglaeser Date: Fri, 24 Mar 2017 10:22:29 +0100 Subject: [PATCH 8/9] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 4a4c701..4c5168d 100644 --- a/README.md +++ b/README.md @@ -99,6 +99,10 @@ or for a custom rating scale: // ... ``` to enable resettable: +Reset resets the value to 0. + +![resettable](https://cloud.githubusercontent.com/assets/6400771/24266249/73591b78-1006-11e7-87b5-04937893ad2f.png) + ```php Date: Sat, 5 Jan 2019 19:53:34 +0100 Subject: [PATCH 9/9] Update rating.css Change to Font Awesome 5 Pro. It needs a Font Awesome Licence!! --- Resources/public/css/rating.css | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/Resources/public/css/rating.css b/Resources/public/css/rating.css index 3118b2a..2443176 100644 --- a/Resources/public/css/rating.css +++ b/Resources/public/css/rating.css @@ -12,9 +12,8 @@ } .rating div.star { - font-family:FontAwesome; - font-weight:normal; - font-style:normal; + font-family:"Font Awesome 5 Pro"; + font-weight:400; font-size: 25px; display:inline-block; position: relative; @@ -25,7 +24,7 @@ } .rating div.star:before { - content:"\f006"; + content:"\f005"; padding-right:5px; color:#999; } @@ -33,12 +32,12 @@ .rating div.star:hover:before,.rating div.star:hover~div.star:before { content:"\f005"; color:#e3cf7a; + font-weight:900; } .rating div.star-full { - font-family:FontAwesome; - font-weight:normal; - font-style:normal; + font-family:"Font Awesome 5 Pro"; + font-weight:900; font-size: 25px; display:inline-block; position: relative; @@ -51,7 +50,7 @@ } .rating div.star-empty { - font-family:FontAwesome; + font-family:"Font Awesome 5 Pro"; font-weight:normal; font-style:normal; font-size: 25px; @@ -60,13 +59,13 @@ } .rating div.star-empty:before { - content:"\f006"; + content:"\f005"; padding-right:5px; color:#999; } .rating div.star-reset { - font-family:FontAwesome; + font-family:"Font Awesome 5 Pro"; font-weight:normal; font-style:normal; font-size: 25px;