raty icon indicating copy to clipboard operation
raty copied to clipboard

Support for data-raty-* options

Open deleugpn opened this issue 8 years ago • 1 comments

Is it possible or is there any plan for supporting in-html attribute?

Instead of

jQuery('.ticket-raty').raty({
    starOff: 'img/raty/star-off.png'
});

we would be able to do

<div class="ticket-raty" data-raty-star-on="img/raty/star-on.png"></div>

And thus focusing more on pure HTML + library as oppose to HTML + JS + Library.

deleugpn avatar Dec 09 '16 18:12 deleugpn

Here the pull request https://github.com/wbotelhos/raty/pull/168

If you want you can costumize youron code like this:

// #jQuery.plugin - raty for a star rating view
    if ($().raty) {
        $('.getraty').each(function () {
            // startype = i
            var startype = $(this).data('startype');
            if (typeof startype == 'undefined' || startype.length == 0)
                startype = 'i';

            // readonly = true
            var readonly = $(this).data('readonly');
            if (typeof readonly == 'undefined' || readonly.length == 0)
                readonly = true;

            // score = 5
            var score = $(this).data('readonly');
            if (typeof score == 'undefined' || score.length == 0)
                score = 5;

            $(this).raty({starType: startype, readOnly: readonly, score: score});
        });
    } // END - #jQuery.raty

arturmamedov avatar Dec 19 '16 17:12 arturmamedov