Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var Aviso = new Class({
- Implements: [Events,Options],
- options: {
- tempo: 1200,
- alpha : 1,
- onComplete : Class.empty
- },
- initialize: function(texto,options){
- this.setOptions(options);
- this.texto = texto;
- if($('aviso')){
- this.el = new Element('div',{'class': 'bloco'});
- this.el.set('html','<p>'+texto+'</p>').inject($('aviso'));
- }else{
- new Element('div',{'id': 'aviso'}).inject(document.body,'top');
- this.el = new Element('div',{'class': 'bloco'}).set('html','<p>'+texto+'</p>').inject($('aviso'),'top');
- }
- window.addEvent('scroll', this.move);
- this.move();
- this.el.setOpacity(this.options.alpha);
- this.show();
- },
- show: function(){
- var myEffect = new Fx.Morph(this.el, {duration: 350, transition: Fx.Transitions.Sine.easeOut});
- myEffect.start({
- 'top': [5]
- });
- this.hide.delay(this.options.tempo+350, this);
- },
- hide: function(){
- if(this.el.getStyle('top').toInt()>-90){
- var myEffect = new Fx.Morph(this.el, {duration: 350, transition: Fx.Transitions.Sine.easeOut});
- myEffect.start({
- 'top': [-90],
- 'opacity' : [this.options.alpha, 0]
- });
- myEffect.addEvent('onComplete',function(el){
- el.destroy();
- });
- }
- this.fireEvent('onComplete',[],250);
- },
- move : function(){
- var a = $('aviso');
- var n = a.getChildren().length;
- if(n==0) window.removeEvents('scroll');
- a.setStyles({
- top: ""+window.getScrollTop()+"px"
- });
- }
- });
Add Comment
Please, Sign In to add comment