博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
mootools_MooTools dwCheckboxes插件
阅读量:2520 次
发布时间:2019-05-11

本文共 2644 字,大约阅读时间需要 8 分钟。

mootools

Update / Fix: The checkboxes will no longer toggle when the "mouseup" event doesn't occur on a checkbox.

更新/修复:当复选框上没有发生“ mouseup”事件时,复选框将不再切换。

Every morning I wake up to a bunch of emails in my Gmail inbox that I delete without reading. I end up clicking so many damn checkboxes that my finger damn near falls off. With that in mind, I've created the dwCheckboxes plugin, a MooTools-based class that allows users to click down on a checkbox and drag their mouse over other checkboxes to check or uncheck numerous checkboxes within one click.

每天早上,我都会在Gmail收件箱中醒来一堆电子邮件,这些邮件是我删除而没有阅读的邮件。 我最终单击了该死的复选框,以至于该死的手指掉了下来。 考虑到这一点,我创建了dwCheckboxes插件,这是一个基于MooTools的类,它允许用户单击复选框并在其他复选框上拖动鼠标以在一次单击中选中或取消选中多个复选框。

MooTools JavaScript (The MooTools JavaScript)

var dwCheckboxes = new Class({		//implements	Implements: [Options],		//options	options: {		elements: 'input[type=checkbox]',	//checkboxes to use		mode: 'toggle'								//toggle|check|uncheck	},		//initialization	initialize: function(options) {		//set options		this.setOptions(options);		//prevent drag start in IE		document.ondragstart = function () { return false; }		//ensure that the elements are a Element		this.options.elements = $$(this.options.elements);		//manage the checkbox actions		this.manage();	},		//a method that does whatever should be done	manage: function() {		var active = 0;		this.options.elements.each(function(el) {			el.addEvents({				'mousedown': function(e) {					e.stop();					active = 1;					el.checked = !el.checked;				},				'mouseenter': function(e) {					if(active === 1) {						el.checked = ('toggle' == this.options.mode ? !el.checked : 'check' == this.options.mode);					}				}.bind(this),				'click': function(e) {					el.checked = !el.checked;					active = 0; 				}			});		}.bind(this));		var label = $$('label[for=' + el.get('id') + ']');		if(label.length) {			label[0].addEvent('click',function() {				el.checked = !el.checked;			});		}		window.addEvent('mouseup',function() { active = 0; });	}});

There are two options for this mall plugin:

该商城插件有两种选择:

  • elements: the collection of input boxes to apply the plugins for (defaults to all checkboxes).

    elements :要为其应用插件的输入框的集合(默认为所有复选框)。

  • mode: one of three options: toggle, check, or uncheck (defaults to "toggle")

    模式 :三个选项之一:切换,选中或取消选中(默认为“切换”)

MooTools的用法 (The MooTools Usage)

//when the DOM is ready to gowindow.addEvent('domready',function() {	var togglers = new dwCheckboxes({ elements: $$('.toggle'), mode: 'toggle' });	var checked = new dwCheckboxes({ elements: $$('.checked'), mode: 'check' });	var unchecked = new dwCheckboxes({ elements: $$('.unchecked'), mode: 'uncheck' });});

翻译自:

mootools

转载地址:http://fcpwd.baihongyu.com/

你可能感兴趣的文章
Zookeeper+websocket实现对分布式服务器的实时监控(附源码下载)
查看>>
Asp.net MVC中的ViewData与ViewBag(转)
查看>>
Nunit -断言使用()
查看>>
guava入门
查看>>
Oracle to_char 转换数值
查看>>
selinux-网络服务安全
查看>>
10个维修中最常见的蓝屏代码,值得收藏!
查看>>
indexOf、instanceOf、typeOf、valueOf详解
查看>>
好程序员web前端教程:对象
查看>>
十道海量数据处理面试题与十个方法大总结
查看>>
sql表操作的基础语法
查看>>
【hdoj_1049】Climbing Worm
查看>>
android 开发之 - 百度地图 key 的申请
查看>>
SQL切换真假状态标识字段
查看>>
MySQL的数据类型
查看>>
获取控件在运行时于屏幕中的位置
查看>>
删除多个重复记录
查看>>
Meteor Shower POJ - 3669
查看>>
urllib
查看>>
.Net内存程序集的DUMP(ProFile篇)
查看>>