Use data-setup attribute to provide options

#10 · closed · 2 comments

View on GitHub ↗

q2apro

It would be great to give the percentage of the URL bar and the colour as a parameter in the HTML div of the progressbar. And then call the LineProgressbar using the class attribute: ``` $(document).ready(function() { $('.progressbar').LineProgressbar({ // percentage: 91, // not needed // fillBackgroundColor: '#3498db', // not needed height: '15px', ShowProgressCount: false, }); }); ``` A `data` attribute could be used, e.g. `<div class="progressbar" data-setup="{'p':91, 'bg':'#FF0'}"></div>`. Example of how videojs is doing it: https://docs.videojs.com/docs/guides/options.html#setting-options #enhancement

Comments

q2apro

Workaround: HTML: ``` <div class="progbar" data-p="90" data-bg="#3498db"></div> <div class="progbar" data-p="50" data-bg="#0098ff"></div> ``` JS: ``` $('.progbar').each( function(index, val) { $(this).LineProgressbar({ percentage: $(this).data('p'), fillBackgroundColor: $(this).data('bg'), height: '15px', ShowProgressCount: false, width: '50%', }); }); ``` Note: I used the class name `progressbar` first which messed up with the plugin's class (same name). I strongly advice to take another class name, e.g. `lineprogbar` or alike.

kingRayhan

@q2apro this option is coming in version 2