mootools_使用MooTools咆哮发出的低吼式通知

mootools

MooTools Roar - Growl

When I think of premier MooTools plugin developers, Harald "digitarald" Kirschner is usually one of the first people that come to mind. Harald has built some of MooTools' most popular plugins, including AutoCompleter, FancyUpload, and History Manager. My favorite plugin created Harald is Roar -- a Growl clone built with MooTools.

当我想到主要的MooTools插件开发人员时, Harald“ digitarald” Kirschner通常是第一个想到的人。 Harald构建了MooTools最受欢迎的一些插件,包括AutoCompleter,FancyUpload和History Manager。 我最喜欢创建的插件Harald是Roar-用MooTools构建的Growl克隆。

CSS (The CSS)

Roar comes packaged with a default CSS file that you may customize to your heart's content. I like Harald's default formatting -- it looks very much like Growl.

Roar随附了一个默认CSS文件,您可以根据自己的心脏内容对其进行自定义。 我喜欢Harald的默认格式-看起来非常像Growl。

MooTools的用法 (The MooTools Usage)


window.addEvent('domready',function() {
	var roar = new Roar({
		position: 'upperRight'
	});
	$('submit-button').addEvent('click',function(){ 
		roar.alert('MooTools FTW!!','But you already know that.'); 
	});
});


The above is as basic as it gets. Harald did a great job picking the best default settings -- I usually only update the position to be in the top-right corner of the browser. The alert method adds an item to the queue. Be sure to check out the Roar class' source to see the wealth of options the plugin provides.

上面是最基本的。 Harald在选择最佳默认设置方面做得很出色-我通常只将位置更新为浏览器的右上角。 警报方法将项目添加到队列。 请务必查看Roar类的源代码,以查看插件提供的丰富选项。

So when's a good time to use Roar? I usually use Roar when doing AJAX requests. Take the following as an example:

那么什么时候该使用Roar呢? 我通常在执行AJAX请求时使用Roar。 以以下为例:


var roar = new Roar({
	position: 'upperRight'
});
var myRequest = new Request({
	url: 'some-url.php',
	method: 'post',
	data: {
		mootools: 'ftw'
	},
	onRequest: function() {
		roar.alert('Submitting your data','Please wait one moment.');
	},
	onSuccess: function() {
		roar.alert('Success!','Your data was successfully saved.');
	},
	onFailure: function() {
		roar.alert('Ooops!','Your data could not be saved.  Please try again.');
	}
});


I add alerts during the Request's request, success, and failure events. That way the user always knows what's happening.

我在请求的请求,成功和失败事件期间添加警报。 这样,用户始终知道发生了什么。

Those of you that work on Macs know how great Growl is. Growl is an unobtrusive, welcomed method of receiving notifications. Take the power of Growl to your website with Roar!

那些在Mac上工作的人都知道Growl有多么出色。 怒吼是一种不打扰,受欢迎的接收通知的方法。 通过咆哮将低吼的力量带到您的网站!

翻译自: https://davidwalsh.name/mootools-growl

mootools

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值