Archive for May, 2009

BeautyTips and exact positioning

Sunday, May 31st, 2009

 IdeaDay 31.5 While developing ideaday.de – my company's website – I came up with the idea to use speech bubbles for user interaction, along with a picture of three business men set against a sunset background.

There's a wonderful plugin called BeatyTips to create these bubbles. It's using so-called canvas drawing to create these beatiful speech bubbles, originally meant as tool tips.

So far, so good. I set up my picture as a background image, and inserted the bubble JS code.

That's where the trouble with exact positioning started. You see, I wanted the image to be centered, and the bubble's spikes to protrude from the most likely mouth position of each of the men.

Here's the code I finally came up with – it may be of use to some people running into the same problems.

1) index.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

It's important that the DOCTYPE is transitional – with strict DOCTYPE, IE 7 wouldn't show the bubbles

<HTML lang="de">
<HEAD>
(…)
<!– BEAUTYTIPS –>
<script src="js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/jquery.hoverIntent.minified.js" type="text/javascript" charset="utf-8"></script>
<script src="js/bgiframe_2.1.1/jquery.bgiframe.min.js" type="text/javascript" charset="utf-8"></script>
<!–[if IE]><script src="js/excanvas_r3/excanvas.js" type="text/javascript" charset="utf-8"></script><![endif]–>
<script src="js/jquery.bt.min.js" type="text/javascript" charset="utf-8"></script>
<!– /STUFF –>

There's a lot going on here. Jquery, the base JS library BeautyTips is based upon, is included. If the browser is IE – this is an IE specific control structure, the other browsers treat this as a comment – ExplorerCanvas developed by Google  is included:

Firefox, Safari and Opera 9 support the canvas tag to allow 2D command-based
drawing operations. ExplorerCanvas brings the same functionality to Internet
Explorer; web developers only need to include a single script tag in their
existing canvas webpages to enable this support.

<link href="css/ideaday.css" rel="stylesheet" type="text/css" />
</HEAD>
<BODY>
<DIV style="position:relative; height:100%; width:100%; overflow:hidden;">

The table (see below) is actually higher than the viewport's height – this DIV, in combination with additional CSS (see below), prevents the browsers from displaying scroll bars, the content is clipped to viewport height – which makes for a nice user experience ("What's the scrollbar for, hon?").

<center>
<TABLE border="0" width="1181px" height="100%" style="background-image: url('/assets/ideaday-team.jpg'); background-repeat:no-repeat; border-style:none;">
<TR height="260px"><TD colspan=7>&nbsp;</TD></TR>
<TR height="1px">
<TD width="300px">&nbsp;</TD>
<TD width="1px"><DIV type="text" id="left" style="" class="target"></DIV></TD>
<TD width="253px">&nbsp;</TD>
<TD width="1px"><DIV type="text" id="center" style="" class="target"></TD>
<TD width="253px">&nbsp;</TD>
<TD width="1px"><DIV type="text" id="right" style="" class="target"></TD>
<TD>&nbsp;</TD>
<TR height="700px"><TD colspan=7>&nbsp;</TD></TR>
</TABLE>
</center>
</DIV>

The table is set to the width of the background image. The height, and an "*" for the last TR's height is respected by Firefox and Opera – but not by IE. Using 700px for the last TR ensures the table shows the full background image (which is 826px high), whereas the DIV above clips it to viewport height.

The bubbles' spikes will begin at the 1px wide and high DIVs included in the TDs above. To position them exactly, I've built this whole table and tailored the position of the containing TDs to fit. Positioning the DIVs absolutely won't work, as you have no idea where the image actually is (it is centered, remember?), and BeautyTips had trouble with relative positioning. This table method does work like a charm, though!

<script type="text/javascript">
window.onload = function(){
$('#left').bt({
trigger: 'none',
clickAnywhereToClose: false,
ajaxPath: '/php/interact.php',
width: 600,
fill: 'rgba(255, 255, 255, .9)',
strokeWidth: 0, /*no stroke*/
spikeLength: 40,
spikeGirth: 10,
padding: 20,
cornerRadius: 30,
cssStyles: {
fontFamily: 'tahoma,verdana,arial,sans-serif',
fontSize: '13px'
}
});
$('#left').btOn();

(…)

</BODY>
</HTML>

This is the actual script to display the speech bubble, loading the contents via AJAX. I toggle it on manually ($('#left').btOn();), there's no on mouse-over event in my case.

2) ideaday.css

html,body{
margin:0;
padding:0;
height:100%;
border:none;
overflow:auto;
background-color:#000;

}

html>body { overflow: visible; }

(…)

  • To avoid a black border on top of the image, we have to set margin and padding of html and body to zero.
  • The height has to be 100% as IE sets the viewport height to what is needed by the content – the table's 100% would NOT correspond to the full viewport height which is available. On second thought, maybe one could do without this, as the table's last row is stretching beyond the picture's height, thus forcing the viewport to be high enough.
  • the overflow:auto and html>body part are needed to prevent the Internet Explorer showing scrollbars.

Voilà.

Bipolare Störungen und mehr

Wednesday, May 13th, 2009

Drei Links: "My Life as a Bipolar Mom" -"When Mom or Dad are Bipolar, Kids are at Risk, too." – "How to Care for and Cope with a Bipolar Spouse"

  • trotz Medikation hat Christina immer noch Stimmungsschwankungen, und zusätzlich dazu  die Nebenwirkungen der Medikamente ("Ich brauche zwei Frappucinos um Morgens in Schwung zu kommen")
  • Kinder von einem Elternteil mit Bipolarer Störung haben ein 14 x Risiko zu erkranken, bei zwei Eltern mit bipolarer Störung ein 45 x Risiko. Ca. 5,7 Millionen Menschen über 18 haben diese Erkrankung in den USA.
  • "Getting angry because a person has bipolar disorder won’t help anything."

Margaret Thatcher and what I may learn

Monday, May 4th, 2009

Margaret Thatcher from WikipediaMargaret Thatcher from WikipediaThese are excerpts from an interesting Time article:

"In the words of a Saint — Francis of Assisi. "Where there is discord," she [Margaret Thatcher] quoted, "may we bring harmony. Where there is error, may we bring truth. Where there is doubt, may we bring faith. And where there is despair, may we bring hope."

"[...] she evaluated policy options against a very short set of criteria.

  • Did a proposal reduce taxation or increase it?
  • Did it expand economic freedom or restrict it?
  • Did it strengthen Britain's role in the world or diminish it?
  • Did it reward initiative or encourage dependency?

Keeping things simple enabled her to maintain focus on what she really wanted to achieve. "

The idea here is, to set up a set of such criteria for me to make business decisions. Not everything is about turnover, of course – there's other aspects, too (for instance, is this endeavour inspiring to me?).  I shall call them my golden rules.

"Financially [...] she was remarkably circumspect in the way she went about privatizing state-owned businesses, first appointing soul mates to head up the nationalized industries, then establishing stiff financial and business targets.

Only when she was sure the ground had been properly tilled did she sell a business off. "

This relates to my experience flinging projects at people, without giving them time to accomodate themselves first. You've got to check the performance and experience level of them first! One may be good at web-design, one may be bad at it, creating more work for you, who's holding himself responsible to the customers. Better check it out first :-)

Transférer le modèle des Témoins de Jéhovah

Saturday, May 2nd, 2009

Les Témoins des Jéhovah sont très imbu du son religion.