From 316a59dcd0f9dfc123dd970dd52112e63fc50786 Mon Sep 17 00:00:00 2001 From: phasefx Date: Tue, 13 Apr 2010 16:19:12 +0000 Subject: [PATCH] Reworking the widget to add more hooks for localized/custom content, and a @pathname attribute for overriding the location.pathname value used to derive URL's for content. Current behavior: 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 /xul/server/patron/display.xul.custom_help.html /xul/server/patron/display.xul.help.html /xul/server/patron/custom_help.html /xul/server/patron/help.html /xul/server/custom_help.html /xul/server/help.html /xul/custom_help.html /xul/help.html /custom_help.html /help.html If @pathname is specified, it will override the value from location.href The idea is that *custom_help.html files will never be stock. git-svn-id: svn://svn.open-ils.org/ILS/trunk@16228 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../staff_client/chrome/content/main/bindings.xml | 106 +++++++++++---------- 1 file changed, 54 insertions(+), 52 deletions(-) diff --git a/Open-ILS/xul/staff_client/chrome/content/main/bindings.xml b/Open-ILS/xul/staff_client/chrome/content/main/bindings.xml index 6e702be5ee..9216e581f2 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/bindings.xml +++ b/Open-ILS/xul/staff_client/chrome/content/main/bindings.xml @@ -22,12 +22,19 @@ // 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) + // foo.html + // /xul/server/patron/display.xul.custom_help.html // /xul/server/patron/display.xul.help.html + // /xul/server/patron/custom_help.html // /xul/server/patron/help.html + // /xul/server/custom_help.html // /xul/server/help.html + // /xul/custom_help.html // /xul/help.html + // /custom_help.html // /help.html + // + // If @pathname is specified, it will override the value from location.href this.addEventListener( 'command', function(ev) { this._open_window(); }, false); } catch(E) { @@ -37,65 +44,60 @@ ]]> - - - - - - - - - 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'); + if (test_url(pathname + '.help.html')) { + open_url(pathname + '.help.html'); } 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'); + var pathparts = pathname.split('/'); + var base_url; var url; var test_result; + for (var i = pathparts.length - 2; i>0 && !test_result; i--) { + base_url = ''; url = ''; + for ( j = 1; j <= i; j++ ) { base_url += '/' + pathparts[j]; }; + url = base_url + '/custom_help.html'; + test_result = test_url(url); + if (!test_result) { + url = base_url + '/help.html'; + test_result = test_url(url); + } + } + if (test_result) { + open_url(url); } else { - /* FIXME - I18N */ - alert('No Help Found'); + if (test_url("/custom_help.html")) { + open_url("/custom_help.html"); + } else { + if (test_url("/help.html")) { + open_url("/help.html"); + } else { + /* FIXME - I18N */ + alert('No Help Found'); + } + } } } } -- 2.11.0