]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/xul/staff_client/chrome/content/evergreen/util/deck.js
patron.display sets it up so that circ.checkout can talk to patron.summary
[Evergreen.git] / Open-ILS / xul / staff_client / chrome / content / evergreen / util / deck.js
1 dump('entering util/deck.js\n');
2
3 if (typeof util == 'undefined') util = {};
4 util.deck = function (id) {
5
6         this.node = document.getElementById(id);
7
8         JSAN.use('util.error'); this.error = new util.error();
9
10         if (!this.node) {
11                 var error = 'util.deck: Could not find element ' + id;
12                 this.error.sdump('D_ERROR',error);
13                 throw(error);
14         }
15         if (this.node.nodeName != 'deck') {
16                 var error = 'util.deck: ' + id + 'is not a deck';
17                 this.error.sdump('D_ERROR',error);
18                 throw(error);
19         }
20
21         return this;
22 };
23
24 util.deck.prototype = {
25
26         'find_index' : function (url) {
27                 var idx = -1;
28                 var nodes = this.node.childNodes;
29                 for (var i = 0; i < nodes.length; i++) {
30                         if (nodes[i].getAttribute('src') == url) idx = i;
31                 }
32                 return idx;
33         },
34
35         'set_iframe' : function (url,params,content_params) {
36                 var idx = this.find_index(url);
37                 if (idx>-1) {
38                         this.node.selectedIndex = idx;
39                         return this.node.childNodes[idx];
40                 } else {
41                         return this.new_iframe(url,params,content_params);
42                 }
43                 
44                 
45         },
46
47         'reset_iframe' : function (url,params,content_params) {
48                 this.remove_iframe(url);
49                 return this.new_iframe(url,params,content_params);
50         },
51
52         'new_iframe' : function (url,params,content_params) {
53                 var idx = this.find_index(url);
54                 if (idx>-1) throw('An iframe already exists in deck with url = ' + url);
55
56                 var iframe = document.createElement('iframe');
57                 iframe.setAttribute('src',url);
58                 iframe.setAttribute('flex','1');
59                 this.node.appendChild( iframe );
60                 this.node.selectedIndex = this.node.childNodes.length - 1;
61                 if (content_params) {
62                         try {
63                                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
64                                 this.error.sdump('D_DECK', 'frame.contentWindow = ' + iframe.contentWindow + '\n');
65                                 iframe.contentWindow.IAMXUL = true;
66                                 iframe.contentWindow.xulG = content_params;
67                         } catch(E) {
68                                 dump('E: ' + E + '\n');
69                         }
70                 }
71                 return iframe;
72         },
73
74         'remove_iframe' : function (url) {
75                 var idx = this.find_index(url);
76                 if (idx>-1) {
77                         this.node.removeChild( this.node.childNodes[ idx ] );
78                 }
79         }
80 }       
81
82 dump('exiting util/deck.js\n');