Quantcast
Channel: Rating & Star Rating – Html Use
Viewing all 10 articles
Browse latest View live

jQuery Bar Rating Plugin

$
0
0

Download   Demo

jQuery Bar Rating Plugin works by transforming a standard select box into a rating widget. It’s only 4kb minified and easy to style with CSS.

1. INCLUDE CSS AND JS FILES

<link href="css/examples.css" rel="stylesheet" type="text/css"/>
<script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script src="../jquery.barrating.js"></script>

2. HTML

<div class="input select rating-a">
	<label for="example-a">Basic example:</label>
	<select id="example-a" name="rating">
		<option value="1">1</option>
		<option value="2">2</option>
		<option value="3">3</option>
		<option value="4">4</option>
		<option value="5">5</option>
		<option value="6">6</option>
		<option value="7" selected="selected">7</option>
		<option value="8">8</option>
		<option value="9">9</option>
		<option value="10">10</option>
	</select>
</div>

3. JAVASCRIPT

$(function () {
	$('#example-a').barrating();
});

4. OPTIONS

initialRating:null

Pass an option value to specify initial rating. If null, the plugin will try to set the initial rating by finding an option with a `selected` attribute.

showValues:false

If set to true, rating values will be displayed on the bars.

showSelectedRating:true

If set to true, user selected rating will be displayed next to the widget.

reverse:false

If set to true, the ratings will be reversed.

readonly:false

If set to true, the ratings will be read-only.

5. METHODS

$(‘select’).barrating(‘show’);

Shows the rating widget.

$(‘select’).barrating(‘clear’);

Clears the rating.

$(‘select’).barrating(‘destroy’);

Destroys the rating widget.

6. CALLBACKS

onSelect:function(value, text)

Fired when a rating is selected.

onClear:function(value, text)

Fired when a rating is cleared.

onDestroy:function(value, text)

Fired when a rating is destroyed.

The post jQuery Bar Rating Plugin appeared first on Html Use.


Bootstrap Rating

$
0
0

Download   Demo

Bootstrap Rating is a jQuery plugin that creates a rating control that uses Bootstrap glyphicons for rating symbols.

1. INCLUDE CSS AND JS FILES

<link href="dist/css/bootstrap.css" rel="stylesheet">
<script type="text/javascript" src="dist/js/jquery-1.10.2.js"></script>
<script type="text/javascript" src="bootstrap-rating.js"></script>

2. HTML

<input type="hidden" class="rating"/>

3. JAVASCRIPT

$('input').rating();

4. ADVANCED

Behind the rating control

Bootstrap Rating uses an input to keep the rating value. But the relationship between the behind the scenes input control and the rating control goes a little further. This input is the associated control. They are tied together.

You can disable the rating control simply disabling its associated input control:

<input type="hidden" class="rating" disabled="disabled"/>

Make it read only:

<input type="hidden" class="rating" readonly="readonly"/>

Set its initial value:

<input type="hidden" class="rating" value="2"/>

Or attach events:

$('input').on('change', function () {
  alert('Rating: ' + $(this).val());
});

Changing the rating symbols

The default rating symbols can be replaced with another ones. Just add the desired glyphicon for the filled and empty states:

<input type="hidden" class="rating" data-filled="glyphicon glyphicon-heart" data-empty="glyphicon glyphicon-heart-empty"/>

Again, you can explicitly initialize the plugin passing the glyphicons as parameters:

$('input').rating({
  filled: 'glyphicon glyphicon-heart',
  empty: 'glyphicon glyphicon-heart-empty'
});

If you want to change the default glyphicons for all the rating controls, you only need to override the plugin default values:

$.fn.rating.defaults.filled = 'glyphicon glyphicon-heart';
$.fn.rating.defaults.empty = 'glyphicon glyphicon-heart-empty';

This needs only be called once, but remember to make these assignments before the rating controls are created.

Though this control idea is to use glyphicons provided by Bootstrap, any custom symbol can be used. Even not font based ones:

.symbol {
  display: inline-block;
  border-radius: 50%;
  border: 5px double white;
  width: 30px;
  height: 30px;
}

.symbol-empty {
  background-color: #ccc;
}

.symbol-filled {
  background-color: black;
}

<input type="hidden" class="rating" data-filled="symbol symbol-filled" data-empty="symbol symbol-empty"/>

It means that the rating control is not tightly tied to Bootstrap and you can use it without Bootstrap.

Setting rate range

The default range is [0..5), or in plain text, starting at 0 and stopping before 5.

It can be overriden by means of two data attributes, data-start for the start rate value and data-stop for the stop/end one. If you want to define a range [1..10):

<input type="hidden" class="rating" data-start="1" data-stop="10"/>

Also you can explicitly initialize the plugin passing the start and stop values as parameters:

$('input').rating({
  start: 1,
  stop: 10
});

If what you need is to change the default start and stop values for all the rating controls, just override the plugin defaults:

$.fn.rating.defaults.start = 1;
$.fn.rating.defaults.stop = 10;

Stepping different

The rating range spans all the integers from start to stop, incremented or decremented by a step. The default step is 1.

Use data-step attribute to change the stepping:

<input type="hidden" class="rating" data-stop="10" data-step="2"/>

Or the explicit initialization:

$('input').rating({
  stop: 10,
  step: 2
});

Also, as usual, you can change the default step globally:

$.fn.rating.defaults.step = 2

My Python background wouldn’t forgive me not supporting negative stepping:

<input type="hidden" class="rating" data-stop="-10" data-step="-2"/>

The post Bootstrap Rating appeared first on Html Use.

Raterater – jQuery 5 star rating plugin

$
0
0

Download   Demo

Raterater is a jQuery 5 star rating plugin based on Font Awesome icons that allows arbitrary star fractions, variable star sizes, and CSS colors.

Requirements

  • jquery >=1.4.1
  • font-awesome >= 4.2.0

1. INCLUDE CSS AND JS FILES

<link href="http://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet"/>
<link href="raterater.css" rel="stylesheet"/>

<script src="https://code.jquery.com/jquery-1.4.1.min.js"></script>
<script src="raterater.jquery.js"></script>

2. HTML

<div class="ratebox" data-id="1" data-rating="2.2"></div>
<div class="ratebox" data-id="2" data-rating="3.6"></div>

3. JAVASCRIPT

$( '.ratebox' ).raterater( { submitFunction: 'rateAlert', allowChange: true } );
function rateAlert(id, rating)
{
    alert( 'Rating for ' + id + ' is ' + rating + ' stars!' );
}

The post Raterater – jQuery 5 star rating plugin appeared first on Html Use.

Youtubars – Display Youtube user feed

$
0
0

Download   Demo

This jquery plugin Youtubars  is Display Youtube user feed with jQuery and Handlebars Template.

1. INCLUDE JS FILES

<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/handlebars.js/2.0.0-alpha.4/handlebars.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.8.2/moment.min.js"></script>
<script type="text/javascript" src="src/youtube.min.js"></script>

2. HTML

<div id="container" class="clearfix"><img class="loading" src="img/ajax-loader.gif" alt="Loading"></div>

<script id="youtube-template" type="text/x-handlebars-template">
    {{#each this}}
	<div class="video clearfix">
		<div class="thumb"><a target="_blank" title="{{title}}" href="{{link}}"><img title="{{title}}" alt="{{title}}" src="{{image}}"></a><span>{{duration}}</span></div>
		<div class="video-content">
			<h2><a target="_blank" title="{{title}}" href="{{link}}">{{title}}</a></h2>
			<p class="date"><strong>Published: </strong>{{published}}</p>
			<p class="views"><strong>Views: </strong>{{viewCount}}</p>
			{{#if description}}
			<p class="description">{{description}}</p>
			{{/if}}
		</div>
	</div>
    {{/each}}
</script>

3. JAVASCRIPT

Youtubars.init({
	template: $('#youtube-template').html(),
	container: $('#container'),
	username: 'googlechrome',
	count: 30
});

The post Youtubars – Display Youtube user feed appeared first on Html Use.

Retina Share Buttons

RSS Feed Tweaks WordPress Plugin

$
0
0

Download   Demo

RSS Feed Tweeks – WordPress Plugin

This WordPress plugin enables a lot of options to manage your WordPress website RSS Feed behaviour.

Here’s a list of all features that comes with this plugin:

  1. Delay feeds by specified minutes. Best for correcting any errors or typos in the posts.
  2. You can upload a custom logo for RSS Feed
  3. Include post thumbnail in RSS Feeds
  4. Disable all RSS feeds with a custom message that can be managed from plugin settings.
  5. Exclude certain categories from RSS Feeds
  6. Include custom post types within RSS Feeds
  7. Specify custom content above and below posts in RSS feeds.
  8. Translation ready via .PO file.

Disabled RSS on WordPress website

\\

Modified RSS Feed display

\\

The post RSS Feed Tweaks WordPress Plugin appeared first on Html Use.

A simple and flexible star rating plugin

$
0
0

Download   Demo

RateYo is a tiny and flexible jQuery star rating plugin, it uses SVG to render rating, so no images required.

Browser Support: Supported by all modern browsers from IE9

1. INCLUDE CSS AND JS FILES

<link rel="stylesheet" href="jquery.rateyo.css"/>
<script src="jquery.js"></script>
<script src="jquery.rateyo.js"></script>

2. HTML

<div id="rateYo"></div>

3. JAVASCRIPT

$(function () {
  $("#rateYo").rateYo({
    rating: 3.6
  });
});

4. OPTIONS

starWidth: string, default: 18px

The width of each star, the width of a star is always equal to its height

$(function () {
  $("#rateYo").rateYo({
    starWidth: "40px"
  });
});

 

normalFill: string, default: #808080

The background color for the un-rated part of a star

$(function () {
  $("#rateYo").rateYo({
    normalFill: "#A0A0A0"
  });
});

 

ratedFill: string, default: #F39C12

The background color for the rated part of a star

$(function () {
  $("#rateYo").rateYo({
    ratedFill: "#E74C3C"
  });
});

numStars: number, default: 5

Number of stars to use, to display the rating

$(function () {
  $("#rateYo").rateYo({
    numStars: 10
  });
});

minValue: number, default: 0

The Minimum value, you want the rating to start with.

$(function () {
  $("#rateYo").rateYo({
    minValue: 1
  });
});

 

maxValue: number, default: 5

The Maximum value, you want the rating to end with.

$(function () {
  $("#rateYo").rateYo({
    maxValue: 1,
    numStars: 1,
    starWidth: "40px"
  });
});

Precision: number, default: 1

The precision of rating.

$(function () {
  $("#rateYo").rateYo({
    precision: 2,
  });
});

rating: number/string, default: 0

The rating can be given in either percentage or number,
it should be given in a string, if it is a percentage.

$(function () {
  $("#rateYo").rateYo({
    rating: "50%",
    precision: 0
  });
});

readOnly: boolean, default: false

Set readOnly: true, if you want the rating to be non-editable

$(function () {
  $("#rateYo").rateYo({
    rating: 3.2,
    readOnly: true
  });
});

onSet: function, default: null

This function is called whenever the rating is set,
It is called after initialization, as the rating would be set for the first time.

Params:
This function will be called with two parameters,
1) rating: the number representing rating,
2) rateYoInstance: an instance of the plugin containing some public functions

Context:
The context( this ) of the function will be set to the HTML element on which the plugin is initialized.

$(function () {
  $("#rateYo").rateYo({
    onSet: function (rating, rateYoInstance) {
      alert("Rating is set to: " + rating);
    }
  });
});

onChange: function, default: null

This function is called whenever the rating is changed (not set),

The Params and Context for the function would be exactly same as that of onSet callback.

$(function () {
  $("#rateYo").rateYo({
    onChange: function (rating, rateYoInstance) {
      $(this).next().text(rating);
    }
  });
});

5. METHODS

All methods follow a common signature.

A method of the plugin can be called by passing the name of the method as the first parameter

If no arguments are passed after the method name, it is considered as a getter, else it is considered as a setter

option:

In the following demo, the color of the rating is set based on the value of the rating

Enjoy!, the multicolor rating demo 🙂

$(function () {
  var $rateYo = $("#rateYo").rateYo({
      ratedFill: getColor()
  }.rateYo("option", "onChange", function () {
    /* get all options of the plugin */
    var options = $rateYo.rateYo("option");

    /* get color according to rating */
    $rateYo.rateYo("option", "ratedFill", getColor(options));
  }).rateYo("option", "onSet", function () {

    /* get all options of the plugin */
    var options = $rateYo.rateYo("option");

    /* set rating and color */
    $rateYo.rateYo("option", "ratedFill", getColor(options));
  });
});

rating: Get Rating

<!-- HTML -->
<div id="rateYo"></div>
<div>
  <button id="getRating" >Get Rating</button>
  <button id="setRating" >Set Random Rating</button>
</div>
/* Javascript */

$(function () {

  var $rateYo = $("#rateYo").rateYo();

  $("#getRating").click(function () {

    /* get rating */
    var rating = $rateYo.rateYo("method", "rating");

    window.alert("Its " + rating + " Yo!");
  });

  $("#setRating").click(function () {

    /* set rating */
    var rating = getRandomRating();
    $rateYo.rateYo("method", "rating", rating);
  });
});

 

destroy: Destroy

<!-- HTML -->
<div id="rateYo"></div>
<div>
  <button id="destroy">Destroy</button>
  <button id="initialize">Initialize</button>
</div>
/* Javascript */

$(function () {

  var $rateYo = $("#rateYo").rateYo();

  $("#destroy").click(function () {

    $rateYo.rateYo("method", "destroy");
  });

  $("#initialize").click(function () {

    $rateYo.rateYo();
  });
});

6. EVENTS

rateyo.set

This event shall be fired when ever the rating is set.

This new rating shall be passed in the second parameter to the event handler

$(function () {

  $("#rateYo").rateYo()
              .on("rateyo.set", function (e, data) {

                  alert("The rating is set to " + data.rating + "!");
              });
});

rateyo.change

This event will be fired when ever the rating is change.

This new rating shall be passed in the second parameter to the event handler

/* javascript */

$(function () {

  $("#rateYo").rateYo()
              .on("rateyo.change", function (e, data) {

                var rating = data.rating;
                $(this).next().text(rating);
              });
});

The post A simple and flexible star rating plugin appeared first on Html Use.

tweetParser.js

$
0
0

Download Demo

tweetParser.js Parse elements containing a tweets and turn URLS, @users & #hashtags into working urls.

1. INCLUDE JS FILES

<script src="js/jquery.min.js"></script>
<script src="js/jquery.tweetParser.min.js"></script>

2. HTML

<p class="tweets">This is my awesome text only tweet ! #web #twitter @twitter http://www.twitter.com/ !!</p>

3. JAVASCRIPT

//basic usage
$("p.tweets").tweetParser();

//With parameters
$("p.tweets").tweetParser({
	urlClass : "tweet_link", //this is default
	userClass : "tweet_user", //this is default
	hashtagClass : "hashtag", //this is default
	target : "_blank" //this is default
});

4. OPTIONS

Parameters Type default description
urlClass String tweet_link css Class used for url in the tweet
userClass String tweet_user css Class used for @user profil url in the tweet
hashtagClass String hashtag css Class used for hashtags url in the tweet
target HTML attribute for anchor tags _blank target used for all generated

The post tweetParser.js appeared first on Html Use.


jRate – Rating jQuery plugin

jsSocials – Social Network Sharing Plugin

$
0
0

Download   Demo

 

jsSocials is a simple social network sharing jQuery plugin. It’s flexible and easily extensible. Configure visual appearance. Choose one of several themes provided. Add any yet unsupported social network if needed.

  • Tuning :  jsSocials allows to easily customize appearance. Define how your share controls should look considering screen width.
  • Themes :  jsSocials supports several themes. Chose the most appropriate for you design.
  • Custom Shares :  jsSocials gives the ability to register any custom share with ease.

The post jsSocials – Social Network Sharing Plugin appeared first on Html Use.

Viewing all 10 articles
Browse latest View live