public
Description: scripty2: for a more delicious web
Homepage: http://script.aculo.us/2
Clone URL: git://github.com/madrobby/scripty2.git
Click here to lend your support to: scripty2 and make a donation at www.pledgie.com !
cosmetic refactoring of base.js
madrobby (author)
Wed May 07 16:08:38 -0700 2008
commit  13e917456e16beff8c01d86b41b7897d095b8456
tree    60efc63bc45f5b46735275882cc51810d2073d14
parent  5b9dbb17f04bd3e09273e9869a550e261d12b5dd
...
5
6
7
8
9
10
11
12
13
14
15
16
 
 
17
18
19
20
21
 
 
 
 
22
23
24
25
 
 
26
27
28
...
5
6
7
 
 
 
 
8
 
 
 
 
9
10
11
 
 
 
 
12
13
14
15
16
17
 
 
18
19
20
21
22
0
@@ -5,24 +5,18 @@ var Effect = {
0
     this.queues = [];
0
     this.globalQueue = new Effect.Queue();
0
     this.queues.push(this.globalQueue);
0
-    this.activeEffectCount = 0;
0
-
0
-    this.setHeartbeat(heartbeat || new Effect.Heartbeat());
0
-    document.observe('effect:heartbeat', this.renderQueues.bind(this));
0
 
0
-    document.observe('effect:queued', function(){
0
-      Effect.activeEffectCount++;
0
-      if (Effect.activeEffectCount == 1) Effect.heartbeat.start();
0
-    });
0
+    this.heartbeat = heartbeat || new Effect.Heartbeat();
0
+    this.activeEffectCount = 0;
0
 
0
-    document.observe('effect:dequeued', function(){
0
-      Effect.activeEffectCount--;
0
-      if (Effect.activeEffectCount == 0) Effect.heartbeat.stop();
0
-    });
0
+    document
0
+      .observe('effect:heartbeat', this.renderQueues.bind(this))
0
+      .observe('effect:queued',    this.beatOnDemand.bind(this, 1))
0
+      .observe('effect:dequeued',  this.beatOnDemand.bind(this, -1));
0
   },
0
 
0
-  setHeartbeat: function(heartbeat) {
0
-    this.heartbeat = heartbeat;
0
+  beatOnDemand: function(dir) {
0
+    this.heartbeat[(this.activeEffectCount += dir) > 0 ? 'start' : 'stop']();
0
   },
0
 
0
   renderQueues: function() {

Comments