Create list with different style in MediaWiki - mediawiki

In MediaWiki, I would like to create a list with a different style, let's say a bullet list with plus icon instead of square icon.
What should I do:
Change the css style, but I don't want to change the css style of all bullet lists just specific ones
Create a Template, but it doesn't seem to fit the problem
Create a parser extension, I read the includes/parser/BlockLevelPass.php but I don't really understood how MediaWiki parses the bullet list.
Example:
⊕ Element1
⊕ Element2
Instead of:
▪ Element1
▪ Element2

As #Tgr said, the best way is to define a CSS class for your list, and then create a template that wraps your list in a div with that class.
For demonstration purposes, I'll show you how to use a circle marker, as plus signs aren't one of the default options for list-style-type, and therefore take more effort to set up.
First, add the following to MediaWiki:Common.css:
.circle-list li {
list-style-type: circle;
}
Then create Template:Circle list with the following code:
<div class="circle-list">
{{{1}}}
</div>
To use the template on a wiki page:
{{Circle list|1=
* Foo
* Bar
* Baz
}}
(The 1= is not required on wiki pages, but it will prevent the output from breaking if your list contains a = sign.)
For how to tweak the CSS to display plus signs instead of circles, this answer should get you started.

Related

How to use XML data as variables in CSS?

I want to develop a display of data that cannot, for technical reasons, be put into a database, so XML seems to be my only solution so far. I need to display elements on an x/y axis graph, each one to be clickable and open a div containing further information. Imagine a list of fruits, to be displayed based on an x axis of crunchiness (0-100) and a y axis of greenness (0-100), then when clicked you can see nutritional information, photo, etc. (something a little like this)
The XML would be something like this:
<fruit_list>
<fruit>
<name>Orange</name>
<xaxis>7</xaxis>
<yaxis>5</yaxis>
<description>round and orange and not crunchy</description>
</fruit>
<fruit>
<name>Granny Smith apple</name>
<xaxis>85</xaxis>
<yaxis>90</yaxis>
<description>round and green and crunchy</description>
</fruit>
</fruit_list>
I was hoping that there would be a way to use the value of the x and y data in the XML to define the position of the elements in the CSS. I have to admit I haven't had much experience with XML, I have only ever used it to display data in simple tables. Anyone have an idea?
This is just an idea of mine, but you could use different CSS classes for a custom range on the x&y axis.
For example, you could define that Range 90-100 (x) and 90-100 (y) has the class
.x90-100_y90-100{
/*Your CSS comes here...*/
}
Range 90-100 (x) and 80-89 (y) has the class
.x90-100_y80-89{
/*Your CSS comes here...*/
}
...
And so one.
Then you could asign the classes to the HTML elements (JS,PHP,etc) in the function where you create your HTML elements from the XML file.
Maybe this can help you :)

Create a list that lets appear an element

I'm new in web design and in web development, and I found myself in trouble while I was designing a website. Actually I'm working on Wordpress, but I have to customize a page "by hand", because it's the only way for accomplishing this task. My aim is to create a list in which each list item will make appear an element somewhere in the page. Specifically I should have a collapsible list where each "subitem" click lets a new list appear on the right, where this new list is different from the others.
Now, my question is, how can I do this? How can I "link" a subitem with a hidden list that will result visible clicking on the specific subitem? Does anybody indicate me the right way to pursue at least ( such as using CSS, Javascript, HTML, ... ) ?
P.S. Sorry for my bad English.
I hope someone could help me
In javascript, look into using things like this:
var new_div = document.createElement("div");
var node = document.createTextNode("This div is new.");
new_div.appendChild(node);
var element = document.getElementById("div1");
element.appendChild(new_div);
to make an element appear, the createElement is used (creates html tag) you can then style the element using setAttribute() or removeAttribute(),
and to link the new content to the list items, the getElementById is used (each item in the list needs its own id to identify it, if each item does different things).

Displaying HTML lists with more than 10 items in columns

I have a generated HTML document that contains a number of unordered lists. Most are fairly short (eg, up to 5 entries) and some of those use full paragraphs as list entries. However, there are a couple lists that are longer than 20 entries, all of which are very short. I would like to display the long lists two columns but leave the short ones as single columns.
For example, I would like the list
Something short.
This is a long, overly verbose sentence that may wrap around on narrow screens, and certainly will wrap (perhaps more than once) if forced into two columns.
This is some more text
to display as a single column (as it does here), but for the list
Alice
Bob
Carol
David
Eve
Frank
Greta
Howard
Irma
Joseph
Katherine
Leo
...
to be displayed as two columns.
Unfortunately, I can't change the tool that generates the HTML and I would rather not add a post-processing step. However, I can change the CSS that the HTML loads. Is there any way to achieve this using pure CSS?
I don't really care if the columnized list reads left to right then top to bottom, or top to bottom then left to right.
I've tried using columns (and its browser-specific variants), but haven't found any method that doesn't also force the short lists into columns. :nth-child might help, but I haven't figured out how.
EDIT
Some of the generated HTML:
<ul>
<li>Composite:Aperture</li>
<li>Composite:DigitalZoom</li>
<li>Composite:DriveMode</li>
<li>Composite:FlashType</li>
<li>Composite:FOV</li>
<li>Composite:FocalLength35efl</li>
<li>Composite:HyperfocalDistance</li>
<li>Composite:ImageSize</li>
...
</ul>
It's just a basic, undecorated list.
How about using CSS3's for creating columns and JQuery for checking how long the text is.
JSFiddle
CSS
.two-col {
-webkit-column-count:2; /* Chrome, Safari, Opera */
-moz-column-count:2; /* Firefox */
column-count:2;
}
JQuery
$(document).ready(function(){
$( 'li' ).each(function() { // check each li on the page (or set a class only to the li's you want to check)
var textLength = $(this).text().length; // use text so HTML elements are not accounted for
if(textLength >= '200'){ // change 200 to the number of characters required before applying class
$(this).addClass('two-col'); // class name to be added
}
});
});

Setting some css properties according to variables

I want to add a variable to a css class. Is it possile? I mean I want to do something like the following:
#box[i]
{
padding: [i]px;
}
(for example: div which is name "box10" is supposed to get padding of 10px.)
I understand this may not be the right syntax, but I hope you can help me achieve the concept setting my class' properties up to a variable value.
It's currently not possible to use variables within CSS, however there are a number of other options available.
The simplest option would be to create a CSS style for each of your box IDs.
You could use JavaScript to add padding to the box, but it is not sensible to include presentation within logic. In jQuery, a loop to do this would look like (assuming your boxes are ):
$('div[id^=box]').each(function() {
$(this).css('padding',this.id.substr(3)+'px');
});
You could use a pre-processor tool, such as LESS to set variables in your CSS; but you would still need to specify each selector.
Setting padding based on different box ID values seems like an odd problem to have. It may be worth taking a look at whether your approach to building this page is correct. Don't forget every ID on the page should be unique. If you wish to use the same ID on multiple elements, you should use CSS classes.
If you are trying to create a box sized based on a number of results (such as poll results), then it would be easier to use the style attribute and set a width/padding on each element rather than create an ID for every possible outcome. For example:
<div style="width:10px"></div>
No, you can't do that with pure CSS, but you can use less for that.
CSS variables are introduced only in W3C draft at this point and didn't supported by browsers yet.
u could just use javascript, to detect the "name" and then get the substring so u have the number. then just make something like this:
var box = document.getElementByName("box10");
box.style.padding = box.name.substr(3) + "px";

fancy tooltips in Swing

I have a JTable that I would like to display a fancy tooltip (basically a JTextArea) for particular cells in a column. I am using a custom cell renderer, so it would be easy if I could figure out how to popup a window when I hover over the cell renderer's component.
Are there any examples of how to do this?
You can use HTML in tooltips, if you use the <html> and </html> tags around the content.
Use HTML to format the tooltip. Using colored (<font>) and multi-line (<br>) tooltips is now easy.
Creating and overwriting the default JToolTip is a bit harder. Every component has a JToolTip instance and you can retrieve this one with JComponent.createToolTip(). To create a custom tooltip, extend the cell renderer and override it's createToolTip to implement your custom functionality (return a custom extended version of JToolTip).
I'm not sure I totally am clear on what sort of customizations specifically you're hoping to do, so I'll be general here.
There is a class, UIManager, that controls the look and feel of components, including the swing ToolTip class. The simple way to make an easy change is to call a method in UIManager to set properties for the tooltips. Doing this you could do things like use BorderFactory to add a decorative border, or change the background color, etc.
Here are some examples of changing some of these properties:
UIManager.put("ToolTip.background", new ColorUIResource(255, 247, 200)); // The color is #fff7c8.
Border border = BorderFactory.createLineBorder(new Color(76,79,83)); // The color is #4c4f53.
UIManager.put("ToolTip.border", border);
ToolTipManager.sharedInstance().setDismissDelay(15000);// 15 seconds
If you want to change a whole bunch of things about their look and feel, it is better to extend your current look and feel with a class implementing custom tooltip look and feel. A full example of this can be found in this blog post by a former Sun developer.
You might also have a look at this Stack Overflow question on how to set the insets on a tooltip.