getting frame.contentWindow with remote xul, for the purpose of callbacks
[Evergreen.git] / Open-ILS / xul / staff_client / chrome / content / evergreen / main / controller.js
1 dump('entering main/controller.js\n');
2
3 if (typeof main == 'undefined') main = {};
4 main.controller = function () {
5
6         JSAN.use('util.error'); this.error = new util.error();
7
8         return this;
9 };
10
11 main.controller.prototype = {
12
13         'init' : function (params) {
14
15                 if (typeof params.control_map == 'undefined') throw('main.controller.init: No control_map');
16
17                 this.control_map = params.control_map;
18                 this.render_list = [];
19                 this.view = {};
20                 
21                 for (var i in this.control_map) {
22                         var cmd = document.getElementById(i);
23                         if (cmd) {
24                                 for (var j in this.control_map[i][0]) {
25                                         if (this.control_map[i][1]) {
26                                                 var ev_type = this.control_map[i][0][j];
27                                                 switch(ev_type) {
28                                                         case 'render':
29                                                                 this.render_list.push( [i, this.control_map[i][1](cmd)] ); 
30                                                         break;
31                                                         default: cmd.addEventListener(ev_type,this.control_map[i][1],false);
32                                                 }
33                                         }
34                                 }
35                         }
36                         this.view[i] = cmd;
37                 }
38         },
39
40         'render' : function(id) {
41                 for (var i in this.render_list) {
42                         try {
43                                 if (id) {
44                                         if (id == this.render_list[i][0]) this.render_list[i][1]();
45                                 } else {
46                                         this.render_list[i][1]();
47                                 }
48                         } catch(E) {
49                                 var error = 'Problem in circ.checkout.render with\n' 
50                                         + this.render_list[i] + '\n\n' + js2JSON(E);
51                                 this.error.sdump('D_ERROR',error);
52                         }
53                 }
54         }
55 }
56 dump('exiting main/controller.js\n');