Adding a dialog XUL in addition to an overlay in Firefox extension - dialog

I am trying to add a dialog box using XUL to a Firefox extension that already has an overlay xul defined. I tried adding the dialog code in the same overlay.xul file, but run into a "dialog.getButton is not a function" error in the Error Console. The structure of the file looks like this:
<overlay id="xxx" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
... code...
<dialog id="yyy"
buttons=","
onload="onLoad();">
....
</dialog>
</overlay>
If I separate out the dialog xul code into a different file, then everything seems to work. The difference is that in the separate dialog.xul file, the dialog code looks like this:
<dialog id=yyy"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
buttons=","
onload="onLoad();">
...
</dialog>
Is it possible or correct to add the dialog code in the same overlay XUL file or should I actually separate them? Is it ok to have multiple XUL files for the same extension?

Is it possible or correct to add the dialog code in the same overlay XUL file
No.
should I actually separate them?
Yes.
Is it ok to have multiple XUL files for the same extension?
Yes.
You can have as many XUL files in your extension as you want. Each XUL document should be in a separate file - already because the root tag of the document matters. An overlay should have <overlay> as its root tag, a dialog needs to use the root tag <dialog> and a regular window <window>.

Related

How to work with a classpath resource in FXML to stay compatible with SceneBuilder?

When i'm using an image in my FXML code like this...
<Image url="#/de/myprj/assets/icons/arrow.png" />
...everything goes fine until the moment when i want to edit the FXML file in SceneBuilder. How can i use such resources within FXML with SceneBuilder?
It is far safer to set the image using CSS, either in scene builder or preferably in a stylesheet specific to your app.
Checkout: http://docs.oracle.com/javafx/2/api/javafx/scene/doc-files/cssref.html#imageview
edit:
Create a css file, load it into the scene's css files when you start your application.
scene.getStylesheets().add(new File("mycss.css").toURI().toString());
In your CSS file add the following:
.the-image {
-fx-image: url("theimage.png");
}
Make sure there is a file called theimage.png in the same directory as your css file. In scenebuilder, click on the ImageView. In the box that is labeled "Style Class" add the string the-image.
Voila.

Override downloading a file type with Chrome Extensions

I'm trying to build a chrome extension that overrides a download of a file and displays it in the browser. For example if you click on a link to a '.csv' file I'd like it to render in the browser instead of downloading it.
Chrome already does it for PDF's types and the Xml Tree extension also does exactly that for xml files.
So it should be possible, just not sure how to go about catching that event?
An implementation along the lines indicated by in the previous answers and specifically designed for CSV files can be found in this extension of mine on github:
https://github.com/rgrp/chrome-csv-viewer
Furthermore, with the new(ish) chrome webrequest API a direct approach is also now possible along the following lines:
Listen to onBeforeRequest (this has to be in a background script - see background.js)
Check if this is a CSV file (mimetype or file extension)
If so cancel the request and then display the data using xhr
A working version of this can be found in a branch of that extension: https://github.com/rgrp/chrome-csv-viewer/tree/4-webrequest-intercept
You could always look at the XML Tree code :).
If you only need to work with links, and not opening files from the address bar or File > Open, you could build a content script that adds a click event listener to every link.
In the event listener function:
Add e.preventDefault() in the first line to prevent the browser 'following' the link.
Using the link href value, get the data with XMLHttpRequest.
In the XMLHttpRequest callback, open a new tab and render content accordingly.
Obviously, in many ways, this is not a great solution:
you want 'normal' links to be handled as usual by the browser
how can you tell if a text file contains comma-separated values (for example) except by looking at the file extension which, of course, may not be reliable?
Are you specifically thinking of .csv files -- and/or other specific types of content?

How to include custom CSS or Javascript on a Content Item in Orchard

Sometimes I want to add some custom CSS or Javascript to a page but the HTML editor doesn't handle this gracefully, even when using text dialog.
I could use an alternate view but then I have to upload the view file to my host every edit.
Any ideas?
Ok, I found a module (Vandelay.Classy) that does exactly this.
http://orchardproject.net/gallery/List/Modules/Orchard.Module.Vandelay.Classy

Is it possible to create custom XUL elements from XPCOM or NPAPI?

I was wondering if it is possible to create a new XUL component via any available api, such as XPCOM or NPAPI, so we can use it our XUL files.
Let's say I wanted to clone the XULs vbox's components code and add a few modifications to it, so we could use our custom XUL component just like this:
<window>
<myvbox mycustomarg1="customValue"> Some content... </myvbox>
</window>
I know what XBL is and what is used for and it doesn't fit our need.
Any suggestion of how to achieve that?
Edit:
We need to create a browser component in Firefox as child of another browser object. The problem is some websites detect this child browser as iframe and we want to avoid this.
Thanks.
If the point is preventing a webpage loaded into a frame from messing with your XUL document then you should use <browser type="content"> - this establishes a security boundary between chrome and content which (among other things) prevents the content document from accessing its parent frame. It is important however that your XUL document itself is loaded as chrome and not content (by either being on top level or inside <browser type="chrome">). See https://developer.mozilla.org/en/XUL/Attribute/browser.type for documentation.

How to modify Sharepoint filetype icons depending on parts of the filename?

We have a SharePoint Document library, where we store html files with links to external files. Samples:
mypicture.jpg.html
mywordfile.docx.html
mypdffile.pdf.html
and so on. Now by default all Files show up with the HTML Icon, referenced in the DOCICON.XML file. Thats of course correct as the .html extension shows, it is a HTML file. But we want the files to have different icons, based on their original file type.
Is there a way to automatically change the Icon
during rendering or
when we save the file to the library (via SharePoint API)?
Any other approachs?
Why not use a little jquery to change the icon during rendering? Each doc in your library should be contained in
<td class="ms-vb-icon"><a tabindex=...><img ... src="/_layouts/images/ichtm.gif"></a></td>
I think you can slurp that into an array, assign a new var that's just the href stripped of path/filename. and .html, and use that to replace htm in the src tag.
Could you not just edit the DOCICON.xml to add the ".jpg.html" and ".docx.html" extensions in?
For a full listing of icon files see all "ic*.gif" files in the TEMPLATE\IMAGES directory under the 12 hive. Unfortunately, this will not solve your problem, but this is where you can change it based on the extension, if you so choose.
Note that a blog I wrote a while back has a different focus, but does discuss where the icons come from: http://wiki.threewill.com/display/is/2007/10/14/External+Link+for+Editing+a+SharePoint+Document.

Resources