• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

fntneves/jquery-labelauty: A lightweight and beautiful jQuery plugin for radio a ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

fntneves/jquery-labelauty

开源软件地址:

https://github.com/fntneves/jquery-labelauty

开源编程语言:

CSS 74.6%

开源软件介绍:

This repository is no longer mantained.

I recommend you to use reactive and modern JavaScript frameworks, such as VueJS and React.

Labelauty jQuery Plugin

A nice and lightweight jQuery plugin that gives beauty to checkboxes and radio buttons and allows custom labels for each status of (un)checked inputs.

Demo: http://fntneves.github.io/jquery-labelauty

Note: Labelauty does not support Internet Explorer 7 and 8.

Installation

Install with Bower :

bower install labelauty --save

Install with NPM :

npm install labelauty --save

Install with Yarn :

yarn add labelauty

Fast Usage

Write your checkbox or radio input in body section and call labelauty() to beautify it. Note: Call plugin when document is ready. See below:

<input type="checkbox"/>
$(document).ready(function(){
	$(":checkbox").labelauty();
});

Simple, isn't it?

Aria Uses

To add a Aria attributes, just add a aria-label. Labelauty will add tabindex, role and checked attributes.

<input aria-label="This branch is awesome" type="checkbox"/>

Use Cases

  • If you want to create user-friendly websites, this is the right choice!

  • Very useful in remember me checkboxes, in settings panel, etc.

How does it work ?

The above case will generate one checkbox with default labels "Checked" and "Unchecked", one for each input state.

You can change the default labels (see Options section) or give custom labels to each checkbox, like the following example:

<input type="checkbox" data-labelauty="Don't synchronize files|Synchronize my files"/>
$(document).ready(function(){
	$(":checkbox").labelauty();
});

The data-labelauty attribute of radio and checkbox inputs lets you write custom labels for unchecked|checked cases. Pipe character |, is the default separator between these two labels. You can change it (see Options section).

The data-labelauty attribute can be used in three different ways:


Unchecked|Checked

To choose a custom label for Unchecked and Checked states.

<input type="checkbox" data-labelauty="Don't synchronize files|Synchronize my files"/>

Message

Without separator, the Message text will be the permanent label. It means that label will not change between input state.

<input type="checkbox" data-labelauty="Synchronize my files"/>

Omitted

By omitting this attribute, the default labels will be shown.

<input type="checkbox"/>

Options

Set a new class value that will be applied to changed inputs.

$(":checkbox").labelauty({ class: "myclass" });

When label is set to false, only the input icon appears and changes.

$(":checkbox").labelauty({ label: false });

When icon is set to false, only the input text label appears and changes.

$(":checkbox").labelauty({ icon: false });

Change separator between custom labels, in data-labelauty attribute. Choose your separator with separator.

$(":checkbox").labelauty({ separator: "-" });

Do you want to generate random ID's for all inputs? Change force_random_id to true.

$(":checkbox").labelauty({
	force_random_id: true,
});

Do you want custom default labels? Set new text in checked_label and unchecked_label.

$(":checkbox").labelauty({
	checked_label: "You selected this",
	unchecked_label: "You don't want it"
});

Actually, custom labels have different number of characters or width. So, you can set minimum-width to custom CSS option.

$(":checkbox").labelauty({ minimum_width: "170px" });

If you dislike the previous option, then you can set labels with the same width. Just set same_width to true.

$(":checkbox").labelauty({ same_width: true });

Customization

You are free to customize all styles included in Labelauty jQuery Plugin.

Just edit jquery-labelauty.css to your liking and change images as you wish.

The included CSS file is tiny and simple. Don't be afraid to change it.

Acknowledgements

© 2013, Francisco Neves. Released under the MIT License.

Labelauty is authored and maintained by Francisco Neves.

Contributors can help to make this plugin better.

You can follow Trello of this repo.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap