I'm using XUL to write my firefox toolbar. I use that xul code to do simple label button:
<?xml version="1.0"?>
<overlay id="Sample"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"><script type="application/x-javascript" src="chrome://sample/content/sample.js" />
<toolbox id="toolbox">
<toolbar id="Sample" toolbarname="Sample" >
<label value="Lable Button "/>
</toolbar>
</toolbox>
</overlay>
My question is how to add logo image, image button and button menu...also how to add submenu. Please somebody submit a quick sample of code, so I will understand better.
What you have there isn't a button - it is a static label.
To add a logo use image tag (see example in the documentation).
To add an image button use toolbarbutton tag (see example in the documentation).
To add a submenu use toolbarbutton tag with type="menu" and put a menupopup tag inside (again, there is an example in the documentation).
Note: You can use src attribute to specify the image source for an image element and image attribute to specify the image source for a toolbarbutton element. However, it is preferable to set the images in CSS, you can use list-style-image property for that:
#myToolbarButton
{
list-style-image: url(chrome://myextension/skin/toolbar.png);
}
Related
I am using JavaFX Scene Builder 2.0 and I would like to add an image to a label using FXML.
In oracle docs, we can find how to achieve this using Java code, but I would like to achieve this using Scene Builder
There are two ways to achieve this
Using FXML
Using CSS
FXML
<Label text="My Image">
<graphic>
<ImageView fitWidth="150" preserveRatio="true" smooth="true">
<image>
<Image url="myImage.png"/>
</image>
</ImageView>
</graphic>
</Label>
Inside Scene Builder, drag an ImageView on top of a Label and it will automatically be set as a graphic for the label. Then select the ImageView and type the url of the image into the ImageView's image field in the Scene Builder properties pane.
CSS
Assign an id to the Label in your FXML. You will also find an id as the property of the Label in Scene Builder
<Label text= "My Image" id = "labelwithimage"/>
Now you can either assign the css values directly in fxml(makes things clumsy) or create a new css file and define your attributes in it
Direct Assignment
<Label text= "My Image" id = "labelwithimage" style="-fx-graphic:url('myImage.png'); -fx-graphic-text-gap : 10;"/>
For defining it in a css file, you need to create a css file, define the atrributes against the id assigned to the Label and include it in the FXML
mycss.css
#labelwithimage {
-fx-graphic: url("myImage.png");
-fx-graphic-text-gap : 10;
}
As you might have already guessed, -fx-graphic does everything that we wrote inside <graphic></graphic>, there are few other attributes like -fx-graphic-text-gap. You can find all the tags that can be used on Label in the css reference guide for label
Now the last thing in css is loading the css in the fxml. For this you need to include the following tag inside you fxml
<stylesheets>
<URL value="#mycss.css" />
</stylesheets>
Just make sure to have the proper imports in the FXML
It is also possible to do it directly in the Scene Builder, without touching the FXML or CSS manually.
Just drag and drop an ImageView node onto your label. You can then set the path to the image on the added ImageView node.
Alternatively, you may just drag an image file from your file explorer (or equivalent) to the label in Scene Builder. Scene Builder will add the intermediate ImageView node automatically. You may then adjust the path to your needs (document-relative, classpath-relative, etc.).
Actually the method is the same as in Java code and the direct modifications of the FXML: just set an ImageView as being the 'graphic' node of the label.
This also works the same for buttons.
When I click the AddThis Pinterest button, the box opens mid-screen, offereing a variety of images from my page. Cool. However, among those offered are grainy, enlarged portions of nav buttons, banner ads, and other images that are relevant. On the same, page the Favorites Bar PinIt button (from Pinterest itself) does it "correctly", meaning it only offeres meaningful images; no nav buttons included.
How can I exclude selected images from the AddThis Pinterest widget box?
Thanks in advance to anyone who can help.
The actual way to force an image is the "media" option, not the "url" option:
<a... pi:pinit:media='http://path/to/my/image.jpg'>...</a>
AddThis Pinterest has support for "at_include" and "at_exclude" classes for images.
Full post here: http://support.addthis.com/customer/portal/articles/1300322-pinterest-image-sharing#.UuAnmrvTm2x
Include Images
You can instruct the share preview to only grab specific images from
the page by using the “image_include” configuration option. First, set
image_include to your desired class name (id selectors are not
allowed, only class selectors), then add that same class name to each
of the images on the page that should be grabbed. For image_include,
don’t add the ‘.’ selector. Here’s an example:
<script type="text/javascript">
var addthis_config = {
image_include: "at_include"
}
Once image_include has been defined with a class, add that class to
the desired images on the page. In this example, the only images on
the page that will be grabbed, will be the images with the at_include
class (img1.jpg and img3.jpg).
<img src="http://www.example.com/img1.jpg" class="at_include" />
<img src="http://www.example.com/img2.jpg" />
<img src="http://www.example.com/img3.jpg" class="at_include" />
Exclude Images
You can instruct the share preview to ignore specific images from the
page by using the image_exclude configuration option. First, set
image_exclude to your desired class name (id selectors are not
allowed, only class selectors), then add that same class name to each
of the images on the page that should be ignored. For image_exclude,
don’t add the ‘.’ selector. Here’s an example:
<script type="text/javascript">
var addthis_config = {
image_exclude: "at_exclude"
}
Once image_exclude has been defined with a class, add that class to
the desired images on the page. In this example, the only image on the
page that will be grabbed, will be the image that doesn't have the
at_exclude class (img2.jpg).
<img src="http://www.example.com/img1.jpg" class="at_exclude" />
<img src="http://www.example.com/img2.jpg" />
<img src="http://www.example.com/img3.jpg" class="at_exclude" />
Image Container
You can also instruct the share preview to grab images from a specific
container, such as all the images contained within the class or id
that has a Pinterest share button. This can be really helpful if there
are multiple Pinterest share buttons on the page. Remember, the
Pinterest share button must be within the same container that the
images are located in. Also, notice that image_container needs to have
the ‘.’ or ‘#’ selector. Here's an example:
<script type="text/javascript">
var addthis_config = {
image_container: ".shared_content"
}
Once image_container has been defined with a class, add that class to
the desired on the page. In this example, the only images on the
page that will be grabbed, will be the images contained within the
shared_content .
<div class="shared_content">
Here's some example text. Images in this div will be grabbed.
<img src="http://www.example.com/img1.jpg" />
<img src="http://www.example.com/img2.jpg" />
<a class="addthis_button_pinterest_share"></a>
</div>
<div class="another_div">
Here's some more example text. Images in this div will not be grabbed.
<img src="http://www.example.com/img3.jpg" />
<img src="http://www.example.com/img4.jpg" />
</div>
If you want to specify a single image for Pinterest to use, you must specify the path to that image as the value of the pi:pinit:url property.
<a... pi:pinit:url='http://path/to/my/image.jpg'>...</a>
I'm using asp.net MVC3 and i want to show a table containing information about a course
In that i have a field called "Information" which show an image.
I want to show the a tooltip when the mouse is taken on that image
I'm showing image lik this:
<img id="ok" src="../../Images/info.jpg" alt="tooltip"/>
I dont want to use any added plugin
can anybody help me with this?
Use title as well as alt in the Html tag
<img id="ok" src="../../Images/info.jpg" title="This is your tooltip message"/>
alt attributes on img elements are used as alternate text in case the image does not exist. Some browsers display these as tool tips when hovering over the image, but its not standard.
You could use the title attribute to display a tool tip on hover of the image.
You should always provide an alt attribute when using images, this is best for accessibility (screen readers read the alt text), and will fail XHTML if you don't have the attribute.
I'm fairly new to JS and XUL so please bear with me if this is a noob query :-)
I am developing an extension for firefox which performs a custom action when a toolbar button (created by me) is clicked. I have been able to create the button using mozilla examples but what I have seen is that even when the extension is installed successfully (and I restart firefox to complete the changes) the button needs to be added manually to the toolbar. After this it can be used as required and even on subsequent launches of FF it stays in the toolbar.
I wanted to know if there is a way by which the button will be auto-loaded when the extension is successfully installed. My XUL script looks like so:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css"
href="chrome://custombutton/content/button.css"?>
<!DOCTYPE overlay >
<overlay id="custombutton-overlay"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript"
src="chrome://custombutton/content/button.js"/>
<!-- Firefox -->
<toolbarpalette id="BrowserToolbarPalette">
<toolbarbutton id="custom-button-1"/>
</toolbarpalette>
<!-- button details -->
<toolbarbutton id="custom-button-1"
label="Custom"
tooltiptext="My custom toolbar button"
oncommand="CustomButton[1]()"
class="toolbarbutton-1 chromeclass-toolbar-additional custombutton"
/>
</overlay>
You'll need to write some javascript code to accomplish that: Adding button by default. Take a look at Adding toolbar buttons to existing toolbars too.
Use the insertItem function: https://developer.mozilla.org/en/XUL/Method/insertItem You may 1. locate your container, such as the Navigation bar. 2. locate the target item to be inserted before or after. 3. insert your botton. 4. make it persist.
var nbar = document.getElementById("nav-bar");
var target = document.getElementById("urlbar-container");
var elem = nbar.firstChild;
while (elem) {
if (elem == target) {
break;
}
elem = elem.nextSibling;
}
nbar.insertItem("your-button-id", elem, null, false);
document.persist("nav-bar", "currentset");
So I have add to cart button, which is comprised of an anchor tag that has an image tag inside it. The anchor tag is using a bunch of javascript effects for mouseover etc that does image swap of this image in question etc.
Now, I have a function "AddCartButton" in my codebehind class that handles click event of this anchor tag. This obviously does not work when javascript is disabled. So I replaced the img tag inside the anchor tag with control, but Those swappings are not working for my though.
What are my options? I want the click to be handled by my C# function irrespective of whether javascript is enabled, and I want the mouseover effect when javascript is enabled.
P.S. It is a repost, but there was only 1 view or something for last post, so I changed the title a lil bit.
<div>
<a id = "addcartButton" href = "#" runat = "server" onMouseOut="MM_swapImgRestore()" onserverclick = "AddCartButton" onMouseOver="MM_swapImage('Image1111111111','','../_images/b_addCart_f2.gif',1)">
<img runat = "server" src='../_images/b_addCart.gif' AlternateText="Add to Cart" name="Image1111111111" width="106" height="29" border="0" />
</a>
</div>
So basically I want something that is working even when javascript is disabled. I still want all those mouseover effects etc when javascript is availabel though.
have you looked at ImageButton class?
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.imagebutton.aspx