RSS
 

Archive for avril, 2007

Visited link … by CSS

22 avr

I read this article this weekend and I was really fooled by the simplicity and the efficiency of the proposed script. The author explains how he can find visited sites by using only the CSS property visited of a hypertext link.
How does it work?
In fact in the page the author « hidde » a list link of the sites he wants to test.

<a href="http://urlToTest/">MySite.com</a> ....

He also has defines a particular css property for the visited links
a:visited { .. height:100px; ... }

Then your browser makes the rest by marking the links you have already visited. It remains to go through these links and to test their offsetHeight property.

var items = document.getElementsByTagName('a'); for (var i=0,i<items.length; i++) { if (items[i].offsetHeight == 100) { //Site already visited .....

Simple and effective ….

 
 

Détection des sites visités…par CSS

22 avr

Je suis tombé sur cet article ce week-end et j’ai vraiment été bluffé par la simplicité et l’efficacité du script proposé. L’auteur explique comment il peut retrouver les sites visités par l’utilisateur en utilisant uniquement la propriété CSS visited d’un lien hypertexte.
Comment ça marche ?
En fait dans la page l’auteur à « caché » la liste des sites qu’il désire tester sous forme de liens hypertextes.

<a href="http://urlToTest/">MySite.com</a> ....

Il a aussi définit une propriété css particulière pour les liens visités
a:visited { .. height:100px; ... }

Ensuite votre navigateur fait le reste en marquant les liens que vous avez déjà visités
Il reste plus qu’à parcourir ces liens et de tester leur propriété offsetHeight.
var items = document.getElementsByTagName('a'); for (var i=0,i<items.length; i++) { if (items[i].offsetHeight == 100) { //Site already visited .....

Simple et efficace….

 
 

Release V0.9 de Rialto

19 avr

Une nouvelle version de Rialto (v0.9) est disponible dans la section download du site

Quoi de neuf:

* Correction des bugs
* les onglets ont maintenant un nouveau paramètre ‘orientation’ qui permet de déterminer le sens d’affichage des titres d’onglets avec comme valeurs `t’ pour top, `l’ pour left, `r’ pour right et `b’ pour bottom.
*intégration de la console de débugage firebug lite. Si vous disposez du plugin dans Firefox les messages lui seront envoyés. Sinon (IE ou FF sans firebug) une émulation de la console apparait dans un frame flottant. J’ai déjà évoqué cette intégration ici
* le composant grid devient skinable

La prochaine version de Rialto sera la V1 et elle est prévu pour le mois de septembre.

 
 

Release V0.9 of Rialto

19 avr

A new version of Rialto is available in the download section of the site corresponding to the 0.9 release:

What’s new:

* bug corection
* the tabFolder has a new parameter call orientation that allow to set the orientation of the tabitem with `t’ for top, `l’ for left, `r’ for right and `b’ for bottom position.
* integration of firebug lite for debug. If you have the firebug plugin in FF then all the messages will be display in. Else (IE or FF without firebug) an emulation of the console appear in a floating frame in your page. I already talk about it here
* the grid become skinable

Notice that the next version will be the V1. We plan to release it in september.

 
 

Application RCP fullscreen

06 avr

Desktop ou Web, quel choix faire ? Je me pose la question en ce moment. Une des fonctionnalités spécifique qui fait la différence c’est le « fullscreen ». Sous IE comme sous Firefox une barre de scroll reste à droite, dommage. En SWT il est possible d’avoir un fullscreen complet et même de mettre la fenêtre en « toujours visible », ci-dessous le code pour le faire, il suffit simplement de specifier le style du Shell NO_TRIM pour supprimer la bordure et l’entete par defaut et ON_TOP pour mettre la fenêtre toujours visible (ça c’est pas faisable en Web à ma connaissance) :
<pre> public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor { public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) { super(configurer); } public ActionBarAdvisor createActionBarAdvisor(IActionBarConfigurer configurer) { return new ApplicationActionBarAdvisor(configurer); } public void preWindowOpen() { IWorkbenchWindowConfigurer configurer = getWindowConfigurer(); configurer.setShellStyle(SWT.NO_TRIM | SWT.ON_TOP); configurer.setShowCoolBar(false); configurer.setShowStatusLine(false); configurer.setTitle("Test FullScreen RCP"); } @Override public void createWindowContents(Shell shell) { super.createWindowContents(shell); shell.setMaximized(true); } } </pre>

 
No Comments

Posted in Eclipse

 

Fullscreen RCP application

06 avr

Desktop or Web, which choice ? I asking the question. One of the features that makes the difference is the fullscreen mode. Under IE or Firefox a scroll bar stay on the left. In SWT it’s possible to have a real fullscreen mode and also force the window on top. Underneath you see the code to do that, all you have to do is simply set the style of the Shell to NO_TRIM to remove the border and the default header and ON_TOP to force the window on top of the others (actually i don’t know how i can do that in Web) :
<pre> public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor { public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) { super(configurer); } public ActionBarAdvisor createActionBarAdvisor(IActionBarConfigurer configurer) { return new ApplicationActionBarAdvisor(configurer); } public void preWindowOpen() { IWorkbenchWindowConfigurer configurer = getWindowConfigurer(); configurer.setShellStyle(SWT.NO_TRIM | SWT.ON_TOP); configurer.setShowCoolBar(false); configurer.setShowStatusLine(false); configurer.setTitle("Test FullScreen RCP"); } @Override public void createWindowContents(Shell shell) { super.createWindowContents(shell); shell.setMaximized(true); } } </pre>

 
1 Comment

Posted in Eclipse

 

XML/Javascript UI development

06 avr

In following my previous news on GUI conception, the Jonathan Allen’s news ask the question a new time, talking about Javascript approach and presenting the new Firefox 3.0 approach with Gran Paradiso.

 

XML/Javascript UI developement

06 avr

Pour faire suite à mon précédent article sur la conception de GUI, l’article de Jonathan Allen pose une nouvelle fois la question en abordant le sujet de Javascript et en présentant la nouvelle approche de Firefox 3.0 avec Gran Paradiso.

 

Modele de boite et quirks mode….

05 avr

L’une des difficultés dans le design de composants javascript provient des différences d’interprétation du modèle de boite de la part des navigateurs. Pour faire simple, le W3C spécifie que la largeur ou la hauteur d’un élément doit correspondre à son contenu effectif. C’est à dire que les dimensions de padding, border et margins doivent être ajouter aux dimensions spécifiées. Malheureusement, Microsoft dans ces premières versions de navigateurs (jusqu’à internet explore 5) utilise un autre rendu, c’est à dire que la taille d’un élément corresponds à sa taille globale (incluant les bordures, marges….).

Vous me direz « bon c’est pas grave, ils ont corrigé le tir depuis la version 6″. Oui mais non en raison du mode Quirks (par opposition au mode standard) qui permet au navigateur d’assurer une rétro-compatibilité en conservant l’ancien mode de calcul. Et comment est on en mode quirks (entre autre) ?

En utilisant une page HTML sans DOCTYPE autant dire dans la majorité des cas

Pour visualiser le phénomène il suffit de tester le code suivant dans une page HTML

<html>
<head>
	<title></title>
</head>
<script>
function init(){
var div=document.getElementById('div1');
div.style.width="200px";
div.style.height="100px";
div.style.border="5px solid red";
div.style.backgroundColor="blue";

var iw=document.getElementById('width');
var ih=document.getElementById('height');
var iow=document.getElementById('offwidth');
var ioh=document.getElementById('offheigth');

div.onmouseover=function(){
iw.value=this.style.width;
ih.value=this.style.height;
iow.value=this.offsetWidth;
ioh.value=this.offsetHeight;
}

div.onmouseout=function(){
iw.value="";
ih.value="";
iow.value="";
ioh.value="";
}

}
</script>
<body onload="init();">
<div id='div1'></div>
Width :<input type='text' id='width'/>
Height :<input type='text' id='height'/>
OffsetWidth :<input type='text' id='offwidth'/>
OffsetHeight :<input type='text' id='offheigth'/>
</body>
</html>

Vous observerez selon les navigateurs la différence entre la taille fixée (width et height) et la taille réellement occupée (offsetWidth et offsetHeight) en passant la souris sur la div.

Alors quelles sont les solutions:

  • introduire dans vos pages la fameuse doctype.
  • <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/DTD/strict.dtd">
  • Utiliser des techniques de détection de navigateurs pour au besoin redimensionner les éléments

La plupart des frameworks ajax utilise la 2eme solution dans la mesure ou ils ne maîtrisent pas les pages dans lesquelles ils sont exécutés.

Attention il ne faut pas oublier de tester le mode de rendu pour affecter ou non les nouvelles tailles. Il suffit pour cela de tester la propriété document.compatMode

  • si la propriété vaut « CSS1Compat il s’agit du mode standart et on n’a pas besoin de modifier les tailles
  • si la propriété vaut « BackCompat » il s’agit du mode Quirks et il faut modifier les tailles

Ci-dessous un squelette de fonction permettant de modifier le width d’un objet

function(oHtml){
	if (window.event && document.compatMode== "BackCompat") {
	//Récuperer les border,margins et padding
	var delta=......;
	//MODEL IE On augmente les tailles
	oHtml.style.width =  parseInt(oHtml.style.width) + delta +"px";
	}
}

Ce probleme peut sembler anodin mais la construction de composant complexes nécessitent l’assemblage d’un grand nombre d’élément HTML et les positionnement sont très rigoureux. Des décalages de 1 ou 2px ont bien évidemment des conséquences sur la cohérence du composant.

Et voilà tout ce travail pour un bug qui date ….

 
 

Box model and Quirks mode

05 avr

One difficultie in the design of javascript components results from differences of interpretation from the browsers. To make simple, the W3C specifies that the width or the height of an element has to reflect its actual contents. That is that the dimensions of padding, border and margins have to be to add to the specified dimensions. Regrettably, Microsoft in the first versions of his browser (up to internet explorer 5) use another model, that is than the size of an element correspond to its global size (including borders, set the margins).

You will say « Ok but they fixed it since version 6 « .
Yes but not because of the Quirks mode (by opposition to the standard mode) which allows the browse to insure a retro compatibility by preserving the former mode of renderer.

And when can you say that you are in Quirks mode (among others)?

By using an HTML page without DOCTYPE in other words in the majority of the cases

To observe the phenomenon just test the following code in a HTML page.

<html>
<head>
	<title></title>
</head>
<script>
function init(){
var div=document.getElementById('div1');
div.style.width="200px";
div.style.height="100px";
div.style.border="5px solid red";
div.style.backgroundColor="blue";

var iw=document.getElementById('width');
var ih=document.getElementById('height');
var iow=document.getElementById('offwidth');
var ioh=document.getElementById('offheigth');

div.onmouseover=function(){
iw.value=this.style.width;
ih.value=this.style.height;
iow.value=this.offsetWidth;
ioh.value=this.offsetHeight;
}

div.onmouseout=function(){
iw.value="";
ih.value="";
iow.value="";
ioh.value="";
}

}
</script>
<body onload="init();">
<div id='div1'></div>
Width :<input type='text' id='width'/>
Height :<input type='text' id='height'/>
OffsetWidth :<input type='text' id='offwidth'/>
OffsetHeight :<input type='text' id='offheigth'/>
</body>
</html>

You will observe according to browsers the difference beetween the fixed size (width and height) and the real occupied size (offsetWidth and offsetHeight) by passing the mouse on the div.

Then what are the solutions

  • Insert in your page the following doctype.
  • <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/DTD/strict.dtd">
  • Use browser detection and at the need re-size elements

Most of the ajax frameworks use the 2nd solution because they can’t be sure of the pages in which they are executed.

You should not forget to test the mode of renderer to affect or not the new sizes. Just test the property document.compatMode

  • if the value is « CSS1Compat then you are in standart mod and you don’t need to change the size
  • if the value is « BackCompat » you are in quirks mode and you have to set the size

Here is a squeleton of function that change the width of an object

function(oHtml){
	if (window.event && document.compatMode== "BackCompat") {
	//Get border,margins and padding size
	var delta=......;
	//IE and Quirks mode so we increase the size
	oHtml.style.width =  parseInt(oHtml.style.width) + delta +"px";
	}
}

This probleme can seem harmless but the construction of complex components require the assembly of a large number of HTML element and size are very rigorous. A gap of 1 or 2px have naturally consequences on the coherence of the component.

And so, all this work for this old bug…..