Skip to content

Instantly share code, notes, and snippets.

@arbales
Created October 15, 2009 05:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arbales/210723 to your computer and use it in GitHub Desktop.
Save arbales/210723 to your computer and use it in GitHub Desktop.
/*
* 417east Messaging
*
* Copyright (c) 2009 Austin Robert Bales
* Licensed under the LGPL license.
*
*/
message_index=0;
var Message = Class.create({
initialize:function(messageText,className, clickToDismiss){
var _class="message "+ className;
var _span=new Element("span").update(messageText);
message_index++;
var _div=new Element("div",{style:"display:none;",id:"message-"+message_index}).update(_span);
_div.addClassName(_class); // Because IE doesn't set the class name from a constructor.
$('container').insert({before:_div});
new Effect.Parallel([
new Effect.Appear(_div, {sync: true}),
new Effect.Move(_div, { sync: true, x: 300, y: 35, mode: 'relative' })
]);
new Effect.Parallel([
new Effect.Fade(_div, {sync: true}),
new Effect.Move(_div, { sync: true, x: 300, y: 150, mode: 'relative' })
], {delay: 3,duration:2});
_div.observe("click",function(){
this.fade({
afterFinish:function(){
_div.stopObserving();
_div.remove()
}
})
});
if(clickToDismiss){
setTimeout(function(){
_div.stopObserving();
_div.fade({afterFinish:function(){
_div.remove()
}
})
},20000)
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment