Guest User

Untitled

a guest
May 25th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. var Aviso = new Class({
  2. Implements: [Events,Options],
  3.  
  4. options: {
  5. tempo: 1200,
  6. alpha : 1,
  7. onComplete : Class.empty
  8. },
  9.  
  10. initialize: function(texto,options){
  11. this.setOptions(options);
  12. this.texto = texto;
  13.  
  14. if($('aviso')){
  15. this.el = new Element('div',{'class': 'bloco'});
  16. this.el.set('html','<p>'+texto+'</p>').inject($('aviso'));
  17. }else{
  18. new Element('div',{'id': 'aviso'}).inject(document.body,'top');
  19. this.el = new Element('div',{'class': 'bloco'}).set('html','<p>'+texto+'</p>').inject($('aviso'),'top');
  20. }
  21.  
  22. window.addEvent('scroll', this.move);
  23. this.move();
  24. this.el.setOpacity(this.options.alpha);
  25. this.show();
  26. },
  27.  
  28. show: function(){
  29. var myEffect = new Fx.Morph(this.el, {duration: 350, transition: Fx.Transitions.Sine.easeOut});
  30. myEffect.start({
  31. 'top': [5]
  32. });
  33. this.hide.delay(this.options.tempo+350, this);
  34. },
  35.  
  36. hide: function(){
  37. if(this.el.getStyle('top').toInt()>-90){
  38. var myEffect = new Fx.Morph(this.el, {duration: 350, transition: Fx.Transitions.Sine.easeOut});
  39. myEffect.start({
  40. 'top': [-90],
  41. 'opacity' : [this.options.alpha, 0]
  42. });
  43. myEffect.addEvent('onComplete',function(el){
  44. el.destroy();
  45. });
  46. }
  47. this.fireEvent('onComplete',[],250);
  48. },
  49.  
  50. move : function(){
  51. var a = $('aviso');
  52. var n = a.getChildren().length;
  53. if(n==0) window.removeEvents('scroll');
  54. a.setStyles({
  55. top: ""+window.getScrollTop()+"px"
  56. });
  57. }
  58. });
Add Comment
Please, Sign In to add comment