This fixes Cataloging -> Create New Marc Record in xulrunner 1.9, but illustrates...
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 17 Nov 2008 00:10:13 +0000 (00:10 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 17 Nov 2008 00:10:13 +0000 (00:10 +0000)
var test = 'See!';
var w = window.open('some_interface.html');
w.xulG = {
    'foreign_data' : 'hey, some_interface.html can make use of me, because xulG is now defined in its context',
    'foreign_function' : function() {
        alert("hey, some_interface.html can call me, but I'm a closure and stay scoped to my original context. Treat me as a callback.  " + test)
    }
);

If the window is not modal, then this works.  It also works with iframes.

var iframe = document.createElement('iframe');
iframe.setAttribute('src','some_interface.html');
iframe.contentWindow.xulG = { 'foo' : 'bar' };

But what stopped working with xulrunner 1.9 is an example similar to the one above, where the iframe already exists.

var iframe = document.getElementById('some_iframe');
iframe.setAttribute('src','some_interface.html'); // This now loads asynchronously and does not wait for the current javascript thread to complete
iframe.contentWindow.xulG = { 'foo' : 'bar' }; // And so this gets shoved in possibly after the onload event for some_interface.html, or maybe not at all.  I'm not sure yet

One other mechanism for shoving xulG into a foreign context appears to still work, and that's the progress listener that shoves into browser elements, to preserve xulG during different page loads.

git-svn-id: svn://svn.open-ils.org/ILS/trunk@11231 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/server/cat/marc_new.xul

index 780edc1..c8eb42a 100644 (file)
                                                                        }
                                                                }
                                                        };
-                                                       $('marc_editor').setAttribute('src',url);
+                            var marc_editor = document.createElement('iframe');
+                            $('marc_editor_box').appendChild(marc_editor);
+                                                       marc_editor.setAttribute('flex','1');
+                                                       marc_editor.setAttribute('src',url);
                                                        netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-                                                       get_contentWindow($('marc_editor')).xulG = params;
+                                                       get_contentWindow(marc_editor).xulG = params;
 
                                                        /* hide template widgets */
                                                        $('actions').hidden = true;
        <messagecatalog id="circStrings" src="/xul/server/locale/<!--#echo var='locale'-->/circ.properties" />
        <messagecatalog id="commonStrings" src="/xul/server/locale/<!--#echo var='locale'-->/common.properties" />
 
-       <vbox flex="1">
+       <vbox id="marc_editor_box" flex="1">
                <hbox id="actions">
                        <hbox id="menu_placeholder" />
                        <button id="load" label="&staff.cat.marc_new.load.label;" accesskey="&staff.cat.marc_new.load.accesskey;"/>
                </hbox>
-               <iframe id="marc_editor" flex="1"/>
        </vbox>
 
 </window>