public
Description: Quicky Growl-like implementation for Prototype
Clone URL: git://github.com/tdreyno/prototypegrowl.git
Click here to lend your support to: prototypegrowl and make a donation at www.pledgie.com !
fixes and animation
tdreyno (author)
Fri Apr 04 19:33:08 -0700 2008
commit  8b4d5dbf414d582147770c671fccfc2d2dab8b6c
tree    729f5f1e88955793f6e8ca565b27cc9df79ab174
parent  93d1095fc558c7afeef45fe832dc77c88ac4d301
...
1
2
 
 
3
4
5
6
7
8
9
10
11
12
 
 
 
 
 
13
14
15
...
23
24
25
26
 
27
28
29
...
42
43
44
45
46
 
 
 
 
 
 
 
 
 
47
48
49
50
 
 
 
 
 
 
51
52
53
54
55
56
57
58
59
60
 
 
 
 
61
62
63
64
65
66
67
 
68
69
70
71
 
 
72
73
74
75
76
 
77
78
79
...
81
82
83
84
 
 
 
85
86
87
88
89
 
 
90
91
92
...
115
116
117
118
119
120
121
122
 
 
123
...
 
 
1
2
3
4
5
6
 
7
 
 
 
 
8
9
10
11
12
13
14
15
...
23
24
25
 
26
27
28
29
...
42
43
44
 
 
45
46
47
48
49
50
51
52
53
54
55
56
 
57
58
59
60
61
62
63
 
64
65
66
67
68
 
 
 
69
70
71
72
73
74
75
76
77
78
 
79
80
81
 
 
82
83
84
85
86
87
88
89
90
91
92
...
94
95
96
 
97
98
99
100
101
102
 
 
103
104
105
106
107
...
130
131
132
 
133
134
 
135
136
137
138
0
@@ -1,15 +1,15 @@
0
-/* Window.Growl, version 2.0: http://icebeat.bitacoras.com
0
- * Daniel Mota aka IceBeat <daniel.mota@gmail.com>
0
+/* Growl for Prototype
0
+ * Thomas Reynolds <tdreyno@gmail.com>
0
 --------------------------------------------------------------------------*/
0
 var Growl = {};
0
 
0
 Growl.Base = Class.create({
0
-
0
   options: {
0
- image: 'http://www.icebeat.bitacoras.com/public/mootools/growl/growl.jpg',
0
- title: 'Window.Growl by Daniel Mota',
0
- text: 'http://icebeat.bitacoras.com',
0
- duration: 2
0
+ image: 'growl.jpg',
0
+ title: 'Default popup title',
0
+ text: 'Lorem ipsum, whatever',
0
+ autohide: 2,
0
+ animated: 0.75
0
   },
0
   
0
   initialize: function(background) {
0
@@ -23,7 +23,7 @@ Growl.Base = Class.create({
0
   create: function() {
0
     var block_elem = new Element('div').hide().setStyle(Object.extend({
0
       position: 'absolute',
0
- 'z-index': '999',
0
+ zIndex: '999',
0
       color: '#fff',
0
       font: '12px/14px "Lucida Grande", Arial, Helvetica, Verdana, sans-serif',
0
       background: 'url(' + this.background + ') no-repeat'
0
@@ -42,38 +42,51 @@ Growl.Base = Class.create({
0
   },
0
   
0
   show: function(block_elem, options) {
0
- block_elem.show();
0
- this.hide.bind(this).delay(options.duration);
0
+ if (this.options.animated)
0
+ new Effect.Appear(block_elem, { duration: this.options.animated });
0
+ else
0
+ block_elem.show();
0
+
0
+ if (this.options.autohide)
0
+ this.hide.bind(this).delay(options.autohide);
0
+ else
0
+ block_elem.observe('click', this.hide.bindAsEventListener(this));
0
   },
0
   
0
   hide: function(elem) {
0
- elem.hide();
0
+ if (this.options.animated)
0
+ new Effect.Fade(elem, { duration: this.options.animated });
0
+ else {
0
+ elem.hide();
0
+ elem.remove();
0
+ }
0
   }
0
-
0
 });
0
 
0
 Growl.Smoke = Class.create(Growl.Base, {
0
   initialize: function($super) {
0
     this.queue = [];
0
- $super(arguments[1] || 'http://www.icebeat.bitacoras.com/public/mootools/growl/smoke.png', {
0
- div: { width: '298px', height: '73px' },
0
- img: { float: 'left', margin: '12px;' },
0
+ this.from_top = 0;
0
+ $super(arguments[1] || 'smoke.png', {
0
+ div: { width: '298px', height: '73px', right: '10px' },
0
+ img: { float: 'left', margin: '12px' },
0
       h3: { margin: 0, padding: '10px 0', 'font-size': '13px' },
0
       p: { margin: '0 10px', 'font-size': '12px' }
0
     });
0
   },
0
   
0
   show: function($super) {
0
- var options = Object.extend(this.options, arguments[0] || {});
0
+ var options = Object.extend(this.options, arguments[1] || {});
0
     block_elem = this.create();
0
     
0
- var delta = document.viewport.getScrollOffsets()[1]+10+((this.queue.length)*83);
0
- block_elem.setStyle({ 'top':delta+'px', 'right':'10px', 'display':'block'});
0
+ var delta = document.viewport.getScrollOffsets()[1] + 10 + this.from_top;
0
+ block_elem.setStyle({ top: delta+'px' });
0
     
0
     block_elem.down('img').setAttribute('src', options.image);
0
     block_elem.down('h3').update(options.title);
0
     block_elem.down('p').update(options.text);
0
     
0
+ this.from_top += 83;
0
     this.queue.push(block_elem);
0
     $super(block_elem, options);
0
   },
0
@@ -81,12 +94,14 @@ Growl.Smoke = Class.create(Growl.Base, {
0
   hide: function($super) {
0
     var elem = this.queue.shift();
0
     $super(elem);
0
- elem.remove();
0
+
0
+ if (this.queue.length == 0)
0
+ this.from_top = 0;
0
   }
0
 });
0
 
0
-/*Gr0wl.Bezel = Class.create(Gr0wl.Base, {
0
-
0
+/*
0
+Gr0wl.Bezel = Class.create(Gr0wl.Base, {
0
   create: function() {
0
     this.i=0;
0
     this.parent({
0
@@ -115,7 +130,7 @@ Growl.Smoke = Class.create(Growl.Base, {
0
     this.i--;
0
     this.callChain();
0
   }
0
-
0
 });
0
 
0
-Gr0wl.Bezel.implement(new Chain);*/
0
\ No newline at end of file
0
+Gr0wl.Bezel.implement(new Chain);
0
+*/
0
\ No newline at end of file
...
4
5
6
 
7
8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
10
11
 
12
13
14
...
26
27
28
29
 
 
 
 
 
30
31
32
33
34
35
36
37
38
39
 
 
 
 
 
 
 
40
41
42
43
...
4
5
6
7
8
 
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
 
39
40
41
42
...
54
55
56
 
57
58
59
60
61
62
63
64
 
 
 
 
 
 
 
65
66
67
68
69
70
71
72
73
74
75
0
@@ -4,11 +4,39 @@
0
 <title>Window.Growl 2.0</title>
0
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
0
 <script type="text/javascript" charset="utf-8" src="prototype-1.6.0.2.js"></script>
0
+<script type="text/javascript" charset="utf-8" src="effects.js"></script>
0
 <script type="text/javascript" charset="utf-8" src="growl.js"></script>
0
-<link rel="stylesheet" href="http://icebeat.bitacoras.com/mootools/growl/css.css" type="text/css" />
0
+<style type="text/css" media="screen">
0
+ * {
0
+ margin: 0;
0
+ padding: 0; }
0
+
0
+ body {
0
+ margin:50px;
0
+ font: 13px/14px "Lucida Grande", Arial, Helvetica, Verdana, sans-serif; }
0
+
0
+ a {
0
+ color:#666; }
0
+
0
+ a:hover {
0
+ text-decoration:none; }
0
+
0
+ ul, li {
0
+ margin:10px; }
0
+
0
+ pre {
0
+ width:450px;
0
+ background-color:#0C1021;
0
+ padding:20px;
0
+ margin:25px 0px; }
0
+
0
+ code {
0
+ color:#7D93B8;
0
+ font: 12px/13px Monaco, Courier, monospace; }
0
+</style>
0
 </head>
0
 <body>
0
- <h3><img src="http://icebeat.bitacoras.com/mootools/growl/logo.jpg" alt="Window.Growl 2.0" title="Window.Growl 2.0"></h3>
0
+ <h3><img src="logo.jpg" alt="Window.Growl 2.0" title="Window.Growl 2.0"></h3>
0
   <ul>
0
     <li><a href="#" id="smoke" title="Show msg Smoke">Show Growl Smoke.</a></li>
0
     <li><a href="#" id="bezel" title="Show msg Bezel">Show Growl Bezel.</a></li>
0
@@ -26,17 +54,21 @@
0
   <script type="text/javascript" charset="utf-8">
0
     var growl = new Growl.Smoke;
0
     $('smoke').observe('click', function(event) {
0
- growl.show();
0
+ growl.show({
0
+ image: 'http://www.gravatar.com/avatar.php?gravatar_id=a4c4bd782c415f9ec93fe11e5694bf06&rating=PG&size=48',
0
+ title: 'Hey look, it&rsquo;s me!',
0
+ autohide: 0
0
+ });
0
       event.stop();
0
     });
0
     
0
- $('bezel').observe('click', function(event) {
0
- var growl = new Growl.Bezel;
0
- growl.show({
0
- title: 'Window.Growl<br />By Daniel Mota'
0
- });
0
- event.stop();
0
- });
0
+ // $('bezel').observe('click', function(event) {
0
+ // var growl = new Growl.Bezel;
0
+ // growl.show({
0
+ // title: 'Window.Growl<br />By Daniel Mota'
0
+ // });
0
+ // event.stop();
0
+ // });
0
   </script>
0
 </body>
0
 </html>
0
\ No newline at end of file

Comments

    No one has commented yet.