[open-ils-commits] r16220 - in trunk/Open-ILS/xul/staff_client: chrome/content/main chrome/skin server/skin (phasefx)
svn at svn.open-ils.org
svn at svn.open-ils.org
Mon Apr 12 17:41:00 EDT 2010
Author: phasefx
Date: 2010-04-12 17:40:54 -0400 (Mon, 12 Apr 2010)
New Revision: 16220
Modified:
trunk/Open-ILS/xul/staff_client/chrome/content/main/bindings.xml
trunk/Open-ILS/xul/staff_client/chrome/skin/global.css
trunk/Open-ILS/xul/staff_client/server/skin/global.css
Log:
XBL for a <help> widget. It will try to load help content from various static and dynamic URL's, stopping
at the first one that it finds. If for example, I were to add this to /xul/server/patron/display.xul:
<help id="bar" src="foo.html" />
We would get a "Help" button that if clicked would then it would test these locations:
foo.html (if @foo not set, then custom_help.html)
/xul/server/patron/display.xul.help.html
/xul/server/patron/help.html
/xul/server/help.html
/xul/help.html
/help.html
and since @id is defined, it would also tack on ?id=bar (for log tracking and/or dynamic use by the content).
It will open the location in a non-modal pop-up window. Navigation buttons not included.
MAYBE TODO:
Add an @anchor for dynamically appending a hash component to each URL tested.
Implement a browser with Back/Forward/Search/Index functionality.
Modified: trunk/Open-ILS/xul/staff_client/chrome/content/main/bindings.xml
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/main/bindings.xml 2010-04-12 19:15:10 UTC (rev 16219)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/main/bindings.xml 2010-04-12 21:40:54 UTC (rev 16220)
@@ -5,6 +5,113 @@
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:xbl="http://www.mozilla.org/xbl">
+ <binding id="help">
+ <resources/>
+
+ <content>
+ <!-- FIXME: I18N -->
+ <xul:button label="Help" accesskey="H" xbl:inherits="label,accesskey" />
+ </content>
+
+ <implementation>
+
+ <constructor>
+ <![CDATA[
+ try {
+ // This widget will try to load help content from various static and dynamic URL's, stopping at the
+ // first one that it finds. Given an example location.href of '/xul/server/patron/display.xul' and
+ // a @src of 'foo.html', it will check these URL's in this order:
+ //
+ // foo.html (if @foo not set, then custom_help.html)
+ // /xul/server/patron/display.xul.help.html
+ // /xul/server/patron/help.html
+ // /xul/server/help.html
+ // /xul/help.html
+ // /help.html
+
+ this.addEventListener( 'command', function(ev) { this._open_window(); }, false);
+ } catch(E) {
+ alert('Error constructing help widget in bindings.xml: ' + E);
+ throw(E);
+ }
+ ]]>
+ </constructor>
+
+ <property name="src">
+ <getter>
+ <![CDATA[
+ try {
+ return this.getAttribute('src');
+ } catch(E) {
+ alert('Error getting @src in help widget in bindings.xml: ' + E);
+ throw(E);
+ }
+ ]]>
+ </getter>
+ <setter>
+ <![CDATA[
+ try {
+ this.setAttribute('src',val);
+ return val;
+ } catch(E) {
+ alert('Error setting @src in help widget in bindings.xml: ' + E);
+ throw(E);
+ }
+ ]]>
+ </setter>
+ </property>
+
+ <method name="_open_window">
+ <body>
+ <![CDATA[
+ try {
+ var x = new XMLHttpRequest();
+ x.open("HEAD",this.src || 'custom_help.html',false);
+ x.send(null);
+ if (x.status == 200) {
+ window.open((this.src || 'custom_help.html')+'?id='+this.id,this.getAttribute('label'),'resizable,scrollbars');
+ } else {
+ var pathname = location.pathname;
+ x.open("HEAD",pathname + '.help.html',false);
+ x.send(null);
+ if (x.status == 200) {
+ window.open(pathname+'.help.html?id='+this.id,this.getAttribute('label'),'resizable,scrollbars');
+ } else {
+ var pathparts = pathname.split('/');
+ var url;
+ for (var i = pathparts.length - 2; i>0 && x.status != 200; i--) {
+ url = '';
+ for ( j = 1; j <= i; j++ ) { url += '/' + pathparts[j]; };
+ url = url + '/help.html';
+ x.open("HEAD",url,false);
+ x.send(null);
+ }
+ if (x.status == 200) {
+ window.open(url+'?id='+this.id,this.getAttribute('label'),'resizable,scrollbars');
+ } else {
+ x.open("HEAD","/help.html",false);
+ x.send(null);
+ if (x.status == 200) {
+ window.open('/help.html?id='+this.id,this.getAttribute('label'),'resizable,scrollbars');
+ } else {
+ /* FIXME - I18N */
+ alert('No Help Found');
+ }
+ }
+ }
+ }
+ } catch(E) {
+ alert('Error opening window in help widget in bindings.xml: ' + E);
+ throw(E);
+ }
+ ]]>
+ </body>
+ </method>
+
+ </implementation>
+ </binding>
+
+
<binding id="messagecatalog">
<resources/>
Modified: trunk/Open-ILS/xul/staff_client/chrome/skin/global.css
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/skin/global.css 2010-04-12 19:15:10 UTC (rev 16219)
+++ trunk/Open-ILS/xul/staff_client/chrome/skin/global.css 2010-04-12 21:40:54 UTC (rev 16220)
@@ -17,6 +17,7 @@
.shrinkable_groupbox { font-weight: bold; -moz-binding: url('chrome://open_ils_staff_client/content/main/bindings.xml#caption'); }
messagecatalog { -moz-binding: url('chrome://open_ils_staff_client/content/main/bindings.xml#messagecatalog'); }
+help { -moz-binding: url('chrome://open_ils_staff_client/content/main/bindings.xml#help'); }
.my_overflow { overflow: auto; }
Modified: trunk/Open-ILS/xul/staff_client/server/skin/global.css
===================================================================
--- trunk/Open-ILS/xul/staff_client/server/skin/global.css 2010-04-12 19:15:10 UTC (rev 16219)
+++ trunk/Open-ILS/xul/staff_client/server/skin/global.css 2010-04-12 21:40:54 UTC (rev 16220)
@@ -3,6 +3,7 @@
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
@namespace html url("http://www.w3.org/TR/REC-html40");
+help { -moz-binding: url('/xul/server/main/bindings.xml#help'); }
messagecatalog { -moz-binding: url('/xul/server/main/bindings.xml#messagecatalog'); }
.shrinkable_groupbox { font-weight: bold; -moz-binding: url('/xul/server/main/bindings.xml#caption'); }
More information about the open-ils-commits
mailing list