]> git.evergreen-ils.org Git - Evergreen.git/blob - Evergreen/staff_client/chrome/content/evergreen/main/clam_shell.js
Various stuff to find a speed bottleneck. It was the register_window function. need...
[Evergreen.git] / Evergreen / staff_client / chrome / content / evergreen / main / clam_shell.js
1 sdump('D_TRACE','Loading clam_shell.js\n');
2
3 function clam_shell_init(p) {
4         sdump('D_CLAM',"TESTING: clam_shell.js: " + mw.G['main_test_variable'] + '\n');
5         if (p) {
6                 if (p.horizontal) {
7                         get_widget(p.w.document,p.clamshell).orient = 'horizontal';
8                 } else if (p.vertical) {
9                         get_widget(p.w.document,p.clamshell).orient = 'vertical';
10                 }
11         }
12         var nl = get_widget(p.w.document,p.clamshell).getElementsByTagName('deck');
13         var first_deck = nl[0];
14         var second_deck = nl[1];
15
16         p.w.first_deck = first_deck;
17         p.w.second_deck = second_deck;
18         p.w.get_card_in_first_deck = function (idx) {
19                 if (idx)
20                         return first_deck.childNodes[ idx ];
21                 else
22                         return first_deck.selectedPanel;
23         }
24         p.w.get_card_in_second_deck = function (idx) {
25                 if (idx)
26                         return second_deck.childNodes[ idx ];
27                 else
28                         return second_deck.selectedPanel;
29         }
30         p.w.set_first_deck = function (idx) { return set_deck(p.w.document,first_deck,idx); };
31         p.w.set_second_deck = function (idx) { return set_deck(p.w.document,second_deck,idx); };
32         p.w.replace_card_in_first_deck = function (idx,chrome,params) {
33                 return replace_card_in_deck(p.w.document,first_deck,idx,chrome,params);
34         };
35         p.w.replace_card_in_second_deck = function (idx,chrome,params) {
36                 return replace_card_in_deck(p.w.document,second_deck,idx,chrome,params);
37         };
38         p.w.new_card_in_first_deck = function (chrome,params) {
39                 return new_card_in_deck(p.w.document,first_deck,chrome,params);
40         };
41         p.w.new_card_in_second_deck = function (chrome,params) {
42                 return new_card_in_deck(p.w.document,second_deck,chrome,params);
43         };
44
45         if (p.onload) {
46                 try {
47                         sdump('D_TRACE','trying psuedo-onload: ' + p.onload + '\n');
48                         p.onload(p.w);
49                 } catch(E) {
50                         sdump('D_ERROR', js2JSON(E) + '\n' );
51                 }
52         }
53
54         return;
55 }
56
57 function new_card_in_deck(doc,deck,chrome,params) {
58         sdump('D_CLAM',arg_dump(arguments));
59         deck = get_widget(doc,deck);
60         var new_card = document.createElement('iframe');
61         deck.appendChild(new_card);
62         new_card.setAttribute('flex','1');
63         new_card.setAttribute('src',chrome);
64         new_card.setAttribute('id','card_'+(deck.childNodes.length-1));
65         return new_card.contentWindow;
66 }
67
68 function replace_card_in_deck(doc,deck,idx,chrome,params) {
69         sdump('D_CLAM',arg_dump(arguments));
70         deck = get_widget(doc,deck);
71         var old_card = deck.childNodes[ idx ];
72         var new_card = document.createElement('iframe');
73         new_card.setAttribute('flex','1');
74         new_card.setAttribute('src',chrome);
75         deck.appendChild(new_card);
76         deck.replaceChild(new_card,old_card);
77         new_card.setAttribute('id','card_'+idx);
78         new_card.contentWindow.mw = mw;
79         if (params)
80                 new_card.contentWindow.params = params;
81         return new_card.contentWindow;
82 }