Skip to content
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

Displayonly disables the caption and therefore the value could only be guessed. #177

Closed
14 of 17 tasks
Bhoft opened this issue Dec 20, 2017 · 2 comments
Closed
14 of 17 tasks
Labels

Comments

@Bhoft
Copy link
Contributor

Bhoft commented Dec 20, 2017

Prerequisites

  • I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
  • The issue still exists against the latest master branch of bootstrap-star-rating.
  • This is not an usage question. I confirm having read the plugin documentation and demos.
  • This is not a general programming / coding question. (Those should be directed to the webtips Q & A forum).
  • I have attempted to find the simplest possible steps to reproduce the issue.
  • I have included a failing test as a pull request (Optional).

Steps to reproduce the issue

  1. create a display only StarRating like

     echo kartik\rating\StarRating::widget([
                'name' => 'rating_44',
                'value' => 3.4,
                'pluginOptions' => [
                    'displayOnly' => true,
                    'showCaption' => true,
                    'size' => 'xs',
                    'max' => 10,
                    'stars' => 10,
                    'step' => 0.1,
                    'defaultCaption' => '{rating} points',
                    'starCaptions' => new JsExpression("function(val){return val == 1 ? '1 Point' : val + ' Points';}")
                ]
      ]);
    
  2. with displayOnly = true no caption is rendered. because it is disabled in the js code. there is no way to enable it manually.

      if (self.displayOnly) {
             self.inactive = true;
             self.showClear = false;
             self.showCaption = false;
      }
    
  3. the only solution to have an output of the current value is to echo it manually.
    which is of course possible but it would be useful that the caption could be enabled or at least give the div of the widget a title =" with the value" so the value is shown at least on hover.

  4. i tried to set inactive = true, showClear = false manually but then the inactive state is overwritten by
    self.inactive = (self.disabled || self.readonly); in the _checkDisabled function.
    I didn't wanted to prevent to set readOnly' => true, or 'disabled' => true, through the normal options as this would then would change the cursor: not-allowed;.

A solution could also be that the caption isn't disabled by default when displayOnly is true but then could be set manually that it is hidden.
So remove this line https://github.com/kartik-v/bootstrap-star-rating/blob/master/js/star-rating.js#L256

btw merry christmas :)

Environment

Browsers

  • [X ] Google Chrome
  • Mozilla Firefox
  • Internet Explorer
  • Safari

Operating System

  • Windows
  • Mac OS X
  • Linux
  • Mobile

Libraries

  • jQuery version:
  • bootstrap-star-rating version:

Isolating the problem

  • This bug happens on the plugin demos page
  • The bug happens consistently across all tested browsers
  • This bug happens when using bootstrap-star-rating without other plugins
  • I can reproduce this bug in a jsbin
@kartik-v kartik-v added the bug label Dec 20, 2017
@Bhoft
Copy link
Contributor Author

Bhoft commented Jan 10, 2018

Hi Kartik,
first happy new year.

Will this bug be fixed soon?
Should i create a pull request and remove just the causing line of code?
Or do you think of adding additional features in the newer versions like alt / title attributes for the div to display the current value in display mode?

br

@kartik-v
Copy link
Owner

Thanks @Bhoft and wish you the same. Unfortunately not got a time to look at it... it would be great if you could help with a PR that is extensible. I will anyway look at it a bit when I get time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants