mootools
![MooTools Roar - Growl](https://i-blog.csdnimg.cn/blog_migrate/782ab8830a809aa448a136879c7f185b.png)
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有多么出色。 怒吼是一种不打扰,受欢迎的接收通知的方法。 通过咆哮将低吼的力量带到您的网站!
mootools