TheCoder4eu / BootsFaces-OSP

BootsFaces - Open Source Project
Apache License 2.0
246 stars 102 forks source link

b:slider2 with decimal number (step) values #976

Closed jepsar closed 6 years ago

jepsar commented 6 years ago

I would like to be able to slide in steps of 0.25. Is this a feature you are willing to support? Or should I create a composite component for this?

jepsar commented 6 years ago

FYI, I just did a quick hack where I've overloaded the slider2 Core and Renderer classes. I've changed the types of the min, max and step attribute to float and that already "worked". Only thing that is not yet handled (of course) is locale based number formatting.

Slider2 with decimal step and value
stephanrauh commented 6 years ago

Pull requests are welcome. As far as I remember, I tried to allow for decimal numbers myself, but for some reason I didn't managed to do so. It seems you've got more luck. Go ahead!

jepsar commented 6 years ago

@stephanrauh While I'm at it, I'll fix a small bug in determining the default value.

        if (v == null) {
            v = max / 2;
            slider.setValue(v);
        }

should be:

        if (v == null) {
            v = min + (max - min) / 2;
            slider.setValue(v);
        }

Do you want me to create a new issue for this?

jepsar commented 6 years ago

@stephanrauh working on this issue right now. I see that there is a precision attribute which was ment to be used for floating values, but is not used at this moment. Can we deprecate / remove that in favour of a new formatter attribute?

See formatter at https://github.com/seiyria/bootstrap-slider#options

stephanrauh commented 6 years ago

@jepsar Sure. There's no point in keeping an attribute we don't use anyways. Just one thing: the attribute formatter is a JavaScript callback function, at least in the seiyria lib. That's great for advanced users, but it may confuse all those developers loving BootsFaces because the don't have to learn JS and CSS. So I'd like to see an easy-entry option, something everybody understands at first glance. Once we've got that, I'd also love to see an advanced option such as a JS callback.

Did you already install the Eclipse plugin to generate the source codes from the BootsFaces.jsfdsl file? If not, add your attributes to the BootsFaces.jsfdsl file, and I'll generate the source codes for you.