text changes to registration mail content
[namibia] / public / ape-source / Pipe / Pipe.js
1 APE.Pipe  = new Class({
2
3         Implements: APE.Events,
4
5         initialize: function(ape, options){
6                 this.pipe = options.pipe;
7                 this.properties = options.pipe.properties;
8
9                 this.ape = ape;
10                 
11                 this.initRequestMethod();
12
13                 this.ape.addPipe(this.pipe.pubid, this);
14         },
15
16         initRequestMethod: function() {
17                 this.request = {};
18                 this.request = {
19                         send: function() {
20                                 var args = this.parsePipeCmd.apply(this, arguments);
21                                 this.ape.request.send.apply(this.ape.request, args);
22                         }.bind(this),
23                         cycledStack: {
24                                 add: function() {
25                                         var args = this.parsePipeCmd.apply(this, arguments);
26                                         this.ape.request.cycledStack.add.apply(this.ape.request.cycledStack, args);
27                                 }.bind(this),
28                                 send: this.ape.request.send,
29                                 setTime: this.ape.request.cycledStack.setTime.bind(this.ape.request.cycledStack)
30                         },
31                         stack :  {
32                                 add: function() {
33                                         var args = this.parsePipeCmd.apply(this, arguments);
34                                         this.ape.request.stack.add.apply(this.ape.request.stack, args);
35                                 }.bind(this),
36                                 send: this.ape.request.stack.send.bind(this.ape.request.stack)
37                         }
38                 }
39         },
40
41         parsePipeCmd: function() {
42                         //convert arguments to a real array to avoid a bug with firefox see bug #292215  https://bugzilla.mozilla.org/show_bug.cgi?id=292215
43                         var args = Array.prototype.slice.call(arguments);
44                         if ($type(arguments[0]) == 'array') {
45                                 for (var i = 0; i < args[0].length; i++) {
46                                         if (!args[0][i].params) args[0][i].params = {};
47                                         if (this.pipe) args[0][i].pipe = this.pipe.pubid;
48                                 }
49                         } else {
50                                 if (!args[1]) args[1] = {};
51                                 if (this.pipe) args[1].pipe = this.pipe.pubid;
52                         }
53                         return args;
54         },
55
56         send: function(data){
57                 this.request.send('SEND', {'msg': data});
58         },
59
60         getPubid: function(){
61                 return this.pipe.pubid;
62         },
63
64         fireGlobalEvent: function(type, fn, internal) {
65                 this.fireEvent(type, fn, internal);
66                 this.ape.fireEvent(type, fn, internal);
67         },
68
69         fireInTheHall: this.fireGlobalEvent
70
71 });