[open-ils-commits] r11231 - trunk/Open-ILS/xul/staff_client/server/cat

svn at svn.open-ils.org svn at svn.open-ils.org
Sun Nov 16 19:10:13 EST 2008


Author: phasefx
Date: 2008-11-16 19:10:13 -0500 (Sun, 16 Nov 2008)
New Revision: 11231

Modified:
   trunk/Open-ILS/xul/staff_client/server/cat/marc_new.xul
Log:
This fixes Cataloging -> Create New Marc Record in xulrunner 1.9, but illustrates a problem that can probably be found elsewhere in the code.  First, a little context.  One of the main mechanisms for inter-window communication within the staff client is the "shoving" of data and functions from one context into a foreign context.  So, for example, you may have code that looks like this:

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.



Modified: trunk/Open-ILS/xul/staff_client/server/cat/marc_new.xul
===================================================================
--- trunk/Open-ILS/xul/staff_client/server/cat/marc_new.xul	2008-11-16 19:50:53 UTC (rev 11230)
+++ trunk/Open-ILS/xul/staff_client/server/cat/marc_new.xul	2008-11-17 00:10:13 UTC (rev 11231)
@@ -124,9 +124,12 @@
 									}
 								}
 							};
-							$('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;
@@ -155,12 +158,11 @@
 	<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>



More information about the open-ils-commits mailing list