I got this error when I wanted to add another menu to my drop-down menu.
I am not sure why this error came up.
I added dropdown.avatar. because that what other menus also had. But it didn't work. What could I be missing here?
circle CI said it's a 33:41 error Parsing error: Unexpected token
31 | <Link route="/stats">
32 | <a>
> 33 | <Icon type="profile" /> {{t("dropdown.avatar.viewMoreStats")}}
| ^
34 | </a>
35 | </Link>
36 | </li>
So I am working on an old XUL overlay add-on and encountered this problem, and simplified it to a minimal add-on. Was wondering if someone could explain to me if I am doing something wrong, if I misunderstood something, or how to get this to work as expected. Complete code below. Testing in both FF 29.0b1 and 49.0a1, same results.
In the main XUL file, I define a stringbundleset and a stringbundle, both with (very likely) unique IDs. In the JavaScript file, I want to simply get the bundle (not the set) by element ID, and use the getString (or getFormattedString) method. In the main JavaScript file, I have an event listener call a load function which can call other functions, including an init function, where I put the string grabbing code. All the string variables are defined globally with var (outside the init function). The problem is, I get getString is not a function. Further, console.log() DOES NOT EVEN WORK ANYWHERE IN THE FUNCTION, so I can't even check the value of variable that's supposed to hold the returned strings bundle.
In my add-on, I use the exact same pattern in Options and About XUL files, and it works, as the MDN documentation says it should. So I excluded this from the example code.
If attempting to build and test, note that in the example JavaScript code, I have the broken block that tries to use the XUL stringbundle and fails, and the working pure javascript-only technique which uses createBundle() is commented out. This is easily modified with the //* code /**/ comment pattern, just delete the 1st / and add a / on the other block and rebuild the xpi.
Here's an example screenshot of what the working code should create. The add-on relies on the old status bar. I used "The Addon Bar (Restored)" add-on. Note "TSBS" on the status bar. Right click "TSBS", a menu pops up with Options at the top. These labels are pulled in from the .dtd file. The Menu is a sub menu that has labels set by the tsbs.js script, pulling values from the .properties file. The example shows them pulled from the JS-only method. I am trying to get it to work from the XUL/DOM method.
I realize that XUL add-ons will die soon anyways. I realize that I shouldn't be relying solely upon the status bar. I realize I should just use the JS-only method as it seems more reliable. But I am asking this because I noticed it and wanted to learn from it. Any idea how to correct or improve the code pattern, or is this a known problem or common pitfall?
Directory tree:
test_string_bundle_set-1.0.0-fx
+-- chrome
| +-- content
| | +-- tsbs.js
| | +-- tsbs.xul
| +-- locale
| | +-- en-US
| | +-- contents.rdf
| | +-- tsbs.dtd
| | +-- tsbs.properties
+-- chrome.manifest
+-- install.rdf
chrome.manifest:
overlay chrome://browser/content/browser.xul chrome://{00735700-7357-7357-7357-073570073570}/content/tsbs.xul
content {00735700-7357-7357-7357-073570073570} chrome/content/
locale {00735700-7357-7357-7357-073570073570} en-US chrome/locale/en-US/
install.rdf:
<?xml version="1.0" encoding="UTF-8"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>{00735700-7357-7357-7357-073570073570}</em:id>
<em:version>1.0.0</em:version>
<em:type>2</em:type>
<em:name>Test String Bundle Sets</em:name>
<em:description>Test String Bundle Sets</em:description>
<em:creator>Quite A. Character</em:creator>
<!--Firefox-->
<em:targetApplication>
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>29.0</em:minVersion>
<em:maxVersion>49.*</em:maxVersion>
</Description>
</em:targetApplication>
</Description>
</RDF>
chrome/content/tsbs.js:
var tsbs_strings;
var tsbs_string_4;
var tsbs_string_5;
var tsbs_string_6;
function tsbs_load( ) {
tsbs_init( );
return true;
}
function tsbs_close( ) {
return true;
}
window.addEventListener( 'load', tsbs_load, false );
window.addEventListener( 'close', tsbs_close, false );
function tsbs_init( ) {
//* XUL/DOM method
tsbs_strings = document.getElementById( 'tsbs-strings' );
console.log( 'TSBS->tsbs_init()->tsbs_strings: ' + typeof tsbs_strings );
tsbs_string_4 = tsbs_strings.getString( 'tsbs.properties.string.4' );
tsbs_string_5 = tsbs_strings.getString( 'tsbs.properties.string.5' );
tsbs_string_6 = tsbs_strings.getString( 'tsbs.properties.string.6' );
/**/
/* JS-only method
tsbs_strings = Services.strings.createBundle( 'chrome://{00735700-7357-7357-7357-073570073570}/locale/tsbs.properties' );
console.log( 'TSBS->tsbs_init()->tsbs_strings: ' + typeof tsbs_strings );
tsbs_string_4 = tsbs_strings.GetStringFromName( 'tsbs.properties.string.4' );
tsbs_string_5 = tsbs_strings.GetStringFromName( 'tsbs.properties.string.5' );
tsbs_string_6 = tsbs_strings.GetStringFromName( 'tsbs.properties.string.6' );
/**/
document.getElementById( 'tsbs-item-4' ).label = tsbs_string_4;
document.getElementById( 'tsbs-item-5' ).label = tsbs_string_5;
document.getElementById( 'tsbs-item-6' ).label = tsbs_string_6;
}
chrome/content/tsbs.xul:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<!DOCTYPE overlay SYSTEM "chrome://{00735700-7357-7357-7357-073570073570}/locale/tsbs.dtd">
<overlay id="tsbs-overlay" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="chrome://{00735700-7357-7357-7357-073570073570}/content/tsbs.js"/>
<stringbundleset id="tsbs-stringset">
<stringbundle id="tsbs-strings" src="chrome://{00735700-7357-7357-7357-073570073570}/locale/tsbs.properties"/>
</stringbundleset>
<statusbar id="status-bar">
<statusbarpanel
id="tsbs-display"
label="&tsbs.dtd.statusbarpanel.display;"
pack="end"
context="tsbs-contextmenu"
/>
</statusbar>
<window id="main-window">
<vbox id="tsbs-notifier">
<popupset id="mainPopupSet">
<menupopup id="tsbs-contextmenu" position="before_end">
<menuitem id="tsbs-options" label="&tsbs.dtd.options;"/>
<menuitem label="&tsbs.dtd.string.1;"/>
<menuitem label="&tsbs.dtd.string.2;"/>
<menuitem label="&tsbs.dtd.string.3;"/>
<menu id="tsbs-menu" label="&tsbs.dtd.menu;">
<menupopup id="tsbs-submenu">
<menuitem id="tsbs-item-4"/>
<menuitem id="tsbs-item-5"/>
<menuitem id="tsbs-item-6"/>
</menupopup>
</menu>
</menupopup>
</popupset>
</vbox>
</window>
</overlay>
chrome/locale/en-US/contents.rdf:
<?xml version="1.0" encoding="UTF-8"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:chrome="http://www.mozilla.org/rdf/chrome#">
<Seq about="urn:mozilla:locale:root">
<li resource="urn:mozilla:locale:en-US"/>
</Seq>
<Description about="urn:mozilla:locale:en-US">
<chrome:packages>
<Seq about="urn:mozilla:locale:en-US:packages">
<li resource="urn:mozilla:locale:en-US:{00735700-7357-7357-7357-073570073570}"/>
</Seq>
</chrome:packages>
</Description>
</RDF>
chrome/locale/en-US/tsbs.dtd:
<!ENTITY tsbs.dtd.statusbarpanel.display "TSBS" >
<!ENTITY tsbs.dtd.options "Options" >
<!ENTITY tsbs.dtd.menu "Menu" >
<!ENTITY tsbs.dtd.string.1 "One" >
<!ENTITY tsbs.dtd.string.2 "Two" >
<!ENTITY tsbs.dtd.string.3 "Three" >
chrome/locale/en-US/tsbs.properties:
extensions.{00735700-7357-7357-7357-073570073570}.description=Test String Bundle Sets
tsbs.properties.string.4=four
tsbs.properties.string.5=five
tsbs.properties.string.6=six
I believe this is your problem:
<stringbundleset id="tsbs-stringset">
In XUL overlays if a direct child of <overlay> has an ID, it's supposed to match an element in the base document. If it does, its contents is inserted under the matching element. If it doesn't this part of an overlay is ignored.
The existing stringbundleset in browser.xul can be matched using:
<stringbundleset id="stringbundleset">
Also I don't believe there's a 'close' event (use 'unload'), and you don't need the contents.rdf since Firefox 2 or so. Regarding console.log() not working - you checked the Browser Console, not the Web Console, right?
Is there any way how can navigation from file "file1.xhtml" to another file "file2.xhtml" which is located in parent folder be implemented that "faces-config.xml" navigation is not used at all.
ProjectName
+---+
WebContent
+---+
| subfolder
| +---+
| file1.xhtml
+---+
file2.xhtml
Navigation from file2.xhtml to file1.xtml:
<h:link value="Go to file1" outcome="subfolder/file2" />
Navigation from file1.xhtml to file2.xtml:
<h:link value="Go to file2" outcome="?" />
The following should work
<h:link value="Go to file1" outcome="/file1" />
I am trying to add a menu separator before and after my menuitem in firefox's contextmenu .
This is my expected output...
| |
| |
|Select All |
|---------------------|
|Show Meaning |
|---------------------|
| |
My code...
<popup id="contentAreaContextMenu">
<menuseparator />
<menuitem id="diction-show-meaning" label="Show meaning" oncommand="" insertafter="context-selectall"/>
<menuseparator />
</popup>
However the menu separators are appearing at the END of the context menu!
How does one enclose a menuitem for contentAreaContextMenu?
I don't prefer to do it dynamically through java script. But let me know if that's the only way possible...
Try
<popup id="contentAreaContextMenu">
<menuitem id="diction-show-meaning" label="Show meaning" oncommand="" insertafter="context-sep-selectall"/>
<menuseparator />
</popup>
I'm trying to create a mobile application with JQuery Mobile that is responsive design.
In other words, I want, in smartphone, that "page1.html" and "page2.html" are loaded in separed pages like that :
_________ __________
|Page1 | |Page2 |
|.html | on click |.html |
| | <--------- | |
| | |go to |
|go to | on click |page1 btn|
|page2 btn| ----------> | |
|_________| |_________|
And, in tablets, I want that page1.html and page2.html are loaded in the same page like that :
-----------------------------
|Page1.html | Page2.html |
| |
| |
| |
| |
| |
|----------------------------
How to do that with JQueryMobile ? I have try to $.mobile.loadpage(url) and $.mobile.changepage(url) but the problem is that the page is replaced and I need to have two pages in a single view for tablets.
Thanks per advance for your help.
Its simple enough, like #Omar said, first of all use a single page template like this with 'data-role=page' denoting each page.
<body>
<div data-role="page" data-theme="d" id="pageOne">
<---header---->
<--- content --->
<---footer---->
</div>
<div data-role="page" data-theme="d" id="pageTwo">
<---header---->
<--- content --->
<---footer---->
</div>
Now, Jquery mobile will automatically show 'pageOne' on first load and hide 'pageTwo' and on navigating to 'pagetwo' will hide 'pageOne'.
After this you can write a css media query similar to this:
#media all and (min-width: 450px) {
#pageOne{
display:block;
float: left;
width:50%;
postion:relative;
}
#pagetwo{
display:inline-block;
float:right;
width:50%;
padding-left: 2em;
postion:relative;
}
}
So if any with width greater than the mentioned width(450px) will have both the pages displayed side by side. Hope this helps. Here is a simple working sample I made.
http://jsfiddle.net/uwZpM/